block-editor.js 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 6411:
  4. /***/ (function(module, exports) {
  5. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  6. autosize 4.0.4
  7. license: MIT
  8. http://www.jacklmoore.com/autosize
  9. */
  10. (function (global, factory) {
  11. if (true) {
  12. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  13. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  14. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  15. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16. } else { var mod; }
  17. })(this, function (module, exports) {
  18. 'use strict';
  19. var map = typeof Map === "function" ? new Map() : function () {
  20. var keys = [];
  21. var values = [];
  22. return {
  23. has: function has(key) {
  24. return keys.indexOf(key) > -1;
  25. },
  26. get: function get(key) {
  27. return values[keys.indexOf(key)];
  28. },
  29. set: function set(key, value) {
  30. if (keys.indexOf(key) === -1) {
  31. keys.push(key);
  32. values.push(value);
  33. }
  34. },
  35. delete: function _delete(key) {
  36. var index = keys.indexOf(key);
  37. if (index > -1) {
  38. keys.splice(index, 1);
  39. values.splice(index, 1);
  40. }
  41. }
  42. };
  43. }();
  44. var createEvent = function createEvent(name) {
  45. return new Event(name, { bubbles: true });
  46. };
  47. try {
  48. new Event('test');
  49. } catch (e) {
  50. // IE does not support `new Event()`
  51. createEvent = function createEvent(name) {
  52. var evt = document.createEvent('Event');
  53. evt.initEvent(name, true, false);
  54. return evt;
  55. };
  56. }
  57. function assign(ta) {
  58. if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
  59. var heightOffset = null;
  60. var clientWidth = null;
  61. var cachedHeight = null;
  62. function init() {
  63. var style = window.getComputedStyle(ta, null);
  64. if (style.resize === 'vertical') {
  65. ta.style.resize = 'none';
  66. } else if (style.resize === 'both') {
  67. ta.style.resize = 'horizontal';
  68. }
  69. if (style.boxSizing === 'content-box') {
  70. heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
  71. } else {
  72. heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
  73. }
  74. // Fix when a textarea is not on document body and heightOffset is Not a Number
  75. if (isNaN(heightOffset)) {
  76. heightOffset = 0;
  77. }
  78. update();
  79. }
  80. function changeOverflow(value) {
  81. {
  82. // Chrome/Safari-specific fix:
  83. // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
  84. // made available by removing the scrollbar. The following forces the necessary text reflow.
  85. var width = ta.style.width;
  86. ta.style.width = '0px';
  87. // Force reflow:
  88. /* jshint ignore:start */
  89. ta.offsetWidth;
  90. /* jshint ignore:end */
  91. ta.style.width = width;
  92. }
  93. ta.style.overflowY = value;
  94. }
  95. function getParentOverflows(el) {
  96. var arr = [];
  97. while (el && el.parentNode && el.parentNode instanceof Element) {
  98. if (el.parentNode.scrollTop) {
  99. arr.push({
  100. node: el.parentNode,
  101. scrollTop: el.parentNode.scrollTop
  102. });
  103. }
  104. el = el.parentNode;
  105. }
  106. return arr;
  107. }
  108. function resize() {
  109. if (ta.scrollHeight === 0) {
  110. // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
  111. return;
  112. }
  113. var overflows = getParentOverflows(ta);
  114. var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
  115. ta.style.height = '';
  116. ta.style.height = ta.scrollHeight + heightOffset + 'px';
  117. // used to check if an update is actually necessary on window.resize
  118. clientWidth = ta.clientWidth;
  119. // prevents scroll-position jumping
  120. overflows.forEach(function (el) {
  121. el.node.scrollTop = el.scrollTop;
  122. });
  123. if (docTop) {
  124. document.documentElement.scrollTop = docTop;
  125. }
  126. }
  127. function update() {
  128. resize();
  129. var styleHeight = Math.round(parseFloat(ta.style.height));
  130. var computed = window.getComputedStyle(ta, null);
  131. // Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
  132. var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
  133. // The actual height not matching the style height (set via the resize method) indicates that
  134. // the max-height has been exceeded, in which case the overflow should be allowed.
  135. if (actualHeight < styleHeight) {
  136. if (computed.overflowY === 'hidden') {
  137. changeOverflow('scroll');
  138. resize();
  139. actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
  140. }
  141. } else {
  142. // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
  143. if (computed.overflowY !== 'hidden') {
  144. changeOverflow('hidden');
  145. resize();
  146. actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
  147. }
  148. }
  149. if (cachedHeight !== actualHeight) {
  150. cachedHeight = actualHeight;
  151. var evt = createEvent('autosize:resized');
  152. try {
  153. ta.dispatchEvent(evt);
  154. } catch (err) {
  155. // Firefox will throw an error on dispatchEvent for a detached element
  156. // https://bugzilla.mozilla.org/show_bug.cgi?id=889376
  157. }
  158. }
  159. }
  160. var pageResize = function pageResize() {
  161. if (ta.clientWidth !== clientWidth) {
  162. update();
  163. }
  164. };
  165. var destroy = function (style) {
  166. window.removeEventListener('resize', pageResize, false);
  167. ta.removeEventListener('input', update, false);
  168. ta.removeEventListener('keyup', update, false);
  169. ta.removeEventListener('autosize:destroy', destroy, false);
  170. ta.removeEventListener('autosize:update', update, false);
  171. Object.keys(style).forEach(function (key) {
  172. ta.style[key] = style[key];
  173. });
  174. map.delete(ta);
  175. }.bind(ta, {
  176. height: ta.style.height,
  177. resize: ta.style.resize,
  178. overflowY: ta.style.overflowY,
  179. overflowX: ta.style.overflowX,
  180. wordWrap: ta.style.wordWrap
  181. });
  182. ta.addEventListener('autosize:destroy', destroy, false);
  183. // IE9 does not fire onpropertychange or oninput for deletions,
  184. // so binding to onkeyup to catch most of those events.
  185. // There is no way that I know of to detect something like 'cut' in IE9.
  186. if ('onpropertychange' in ta && 'oninput' in ta) {
  187. ta.addEventListener('keyup', update, false);
  188. }
  189. window.addEventListener('resize', pageResize, false);
  190. ta.addEventListener('input', update, false);
  191. ta.addEventListener('autosize:update', update, false);
  192. ta.style.overflowX = 'hidden';
  193. ta.style.wordWrap = 'break-word';
  194. map.set(ta, {
  195. destroy: destroy,
  196. update: update
  197. });
  198. init();
  199. }
  200. function destroy(ta) {
  201. var methods = map.get(ta);
  202. if (methods) {
  203. methods.destroy();
  204. }
  205. }
  206. function update(ta) {
  207. var methods = map.get(ta);
  208. if (methods) {
  209. methods.update();
  210. }
  211. }
  212. var autosize = null;
  213. // Do nothing in Node.js environment and IE8 (or lower)
  214. if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
  215. autosize = function autosize(el) {
  216. return el;
  217. };
  218. autosize.destroy = function (el) {
  219. return el;
  220. };
  221. autosize.update = function (el) {
  222. return el;
  223. };
  224. } else {
  225. autosize = function autosize(el, options) {
  226. if (el) {
  227. Array.prototype.forEach.call(el.length ? el : [el], function (x) {
  228. return assign(x, options);
  229. });
  230. }
  231. return el;
  232. };
  233. autosize.destroy = function (el) {
  234. if (el) {
  235. Array.prototype.forEach.call(el.length ? el : [el], destroy);
  236. }
  237. return el;
  238. };
  239. autosize.update = function (el) {
  240. if (el) {
  241. Array.prototype.forEach.call(el.length ? el : [el], update);
  242. }
  243. return el;
  244. };
  245. }
  246. exports.default = autosize;
  247. module.exports = exports['default'];
  248. });
  249. /***/ }),
  250. /***/ 4403:
  251. /***/ (function(module, exports) {
  252. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  253. Copyright (c) 2018 Jed Watson.
  254. Licensed under the MIT License (MIT), see
  255. http://jedwatson.github.io/classnames
  256. */
  257. /* global define */
  258. (function () {
  259. 'use strict';
  260. var hasOwn = {}.hasOwnProperty;
  261. var nativeCodeString = '[native code]';
  262. function classNames() {
  263. var classes = [];
  264. for (var i = 0; i < arguments.length; i++) {
  265. var arg = arguments[i];
  266. if (!arg) continue;
  267. var argType = typeof arg;
  268. if (argType === 'string' || argType === 'number') {
  269. classes.push(arg);
  270. } else if (Array.isArray(arg)) {
  271. if (arg.length) {
  272. var inner = classNames.apply(null, arg);
  273. if (inner) {
  274. classes.push(inner);
  275. }
  276. }
  277. } else if (argType === 'object') {
  278. if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
  279. classes.push(arg.toString());
  280. continue;
  281. }
  282. for (var key in arg) {
  283. if (hasOwn.call(arg, key) && arg[key]) {
  284. classes.push(key);
  285. }
  286. }
  287. }
  288. }
  289. return classes.join(' ');
  290. }
  291. if ( true && module.exports) {
  292. classNames.default = classNames;
  293. module.exports = classNames;
  294. } else if (true) {
  295. // register as 'classnames', consistent with npm package name
  296. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  297. return classNames;
  298. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  299. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  300. } else {}
  301. }());
  302. /***/ }),
  303. /***/ 4827:
  304. /***/ (function(module) {
  305. // This code has been refactored for 140 bytes
  306. // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js
  307. var computedStyle = function (el, prop, getComputedStyle) {
  308. getComputedStyle = window.getComputedStyle;
  309. // In one fell swoop
  310. return (
  311. // If we have getComputedStyle
  312. getComputedStyle ?
  313. // Query it
  314. // TODO: From CSS-Query notes, we might need (node, null) for FF
  315. getComputedStyle(el) :
  316. // Otherwise, we are in IE and use currentStyle
  317. el.currentStyle
  318. )[
  319. // Switch to camelCase for CSSOM
  320. // DEV: Grabbed from jQuery
  321. // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
  322. // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
  323. prop.replace(/-(\w)/gi, function (word, letter) {
  324. return letter.toUpperCase();
  325. })
  326. ];
  327. };
  328. module.exports = computedStyle;
  329. /***/ }),
  330. /***/ 1198:
  331. /***/ (function(__unused_webpack_module, exports) {
  332. "use strict";
  333. /*istanbul ignore start*/
  334. Object.defineProperty(exports, "__esModule", ({
  335. value: true
  336. }));
  337. exports["default"] = Diff;
  338. /*istanbul ignore end*/
  339. function Diff() {}
  340. Diff.prototype = {
  341. /*istanbul ignore start*/
  342. /*istanbul ignore end*/
  343. diff: function diff(oldString, newString) {
  344. /*istanbul ignore start*/
  345. var
  346. /*istanbul ignore end*/
  347. options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  348. var callback = options.callback;
  349. if (typeof options === 'function') {
  350. callback = options;
  351. options = {};
  352. }
  353. this.options = options;
  354. var self = this;
  355. function done(value) {
  356. if (callback) {
  357. setTimeout(function () {
  358. callback(undefined, value);
  359. }, 0);
  360. return true;
  361. } else {
  362. return value;
  363. }
  364. } // Allow subclasses to massage the input prior to running
  365. oldString = this.castInput(oldString);
  366. newString = this.castInput(newString);
  367. oldString = this.removeEmpty(this.tokenize(oldString));
  368. newString = this.removeEmpty(this.tokenize(newString));
  369. var newLen = newString.length,
  370. oldLen = oldString.length;
  371. var editLength = 1;
  372. var maxEditLength = newLen + oldLen;
  373. var bestPath = [{
  374. newPos: -1,
  375. components: []
  376. }]; // Seed editLength = 0, i.e. the content starts with the same values
  377. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  378. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  379. // Identity per the equality and tokenizer
  380. return done([{
  381. value: this.join(newString),
  382. count: newString.length
  383. }]);
  384. } // Main worker method. checks all permutations of a given edit length for acceptance.
  385. function execEditLength() {
  386. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  387. var basePath =
  388. /*istanbul ignore start*/
  389. void 0
  390. /*istanbul ignore end*/
  391. ;
  392. var addPath = bestPath[diagonalPath - 1],
  393. removePath = bestPath[diagonalPath + 1],
  394. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  395. if (addPath) {
  396. // No one else is going to attempt to use this value, clear it
  397. bestPath[diagonalPath - 1] = undefined;
  398. }
  399. var canAdd = addPath && addPath.newPos + 1 < newLen,
  400. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  401. if (!canAdd && !canRemove) {
  402. // If this path is a terminal then prune
  403. bestPath[diagonalPath] = undefined;
  404. continue;
  405. } // Select the diagonal that we want to branch from. We select the prior
  406. // path whose position in the new string is the farthest from the origin
  407. // and does not pass the bounds of the diff graph
  408. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  409. basePath = clonePath(removePath);
  410. self.pushComponent(basePath.components, undefined, true);
  411. } else {
  412. basePath = addPath; // No need to clone, we've pulled it from the list
  413. basePath.newPos++;
  414. self.pushComponent(basePath.components, true, undefined);
  415. }
  416. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  417. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  418. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  419. } else {
  420. // Otherwise track this path as a potential candidate and continue.
  421. bestPath[diagonalPath] = basePath;
  422. }
  423. }
  424. editLength++;
  425. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  426. // sync and async mode which is never fun. Loops over execEditLength until a value
  427. // is produced.
  428. if (callback) {
  429. (function exec() {
  430. setTimeout(function () {
  431. // This should not happen, but we want to be safe.
  432. /* istanbul ignore next */
  433. if (editLength > maxEditLength) {
  434. return callback();
  435. }
  436. if (!execEditLength()) {
  437. exec();
  438. }
  439. }, 0);
  440. })();
  441. } else {
  442. while (editLength <= maxEditLength) {
  443. var ret = execEditLength();
  444. if (ret) {
  445. return ret;
  446. }
  447. }
  448. }
  449. },
  450. /*istanbul ignore start*/
  451. /*istanbul ignore end*/
  452. pushComponent: function pushComponent(components, added, removed) {
  453. var last = components[components.length - 1];
  454. if (last && last.added === added && last.removed === removed) {
  455. // We need to clone here as the component clone operation is just
  456. // as shallow array clone
  457. components[components.length - 1] = {
  458. count: last.count + 1,
  459. added: added,
  460. removed: removed
  461. };
  462. } else {
  463. components.push({
  464. count: 1,
  465. added: added,
  466. removed: removed
  467. });
  468. }
  469. },
  470. /*istanbul ignore start*/
  471. /*istanbul ignore end*/
  472. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  473. var newLen = newString.length,
  474. oldLen = oldString.length,
  475. newPos = basePath.newPos,
  476. oldPos = newPos - diagonalPath,
  477. commonCount = 0;
  478. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  479. newPos++;
  480. oldPos++;
  481. commonCount++;
  482. }
  483. if (commonCount) {
  484. basePath.components.push({
  485. count: commonCount
  486. });
  487. }
  488. basePath.newPos = newPos;
  489. return oldPos;
  490. },
  491. /*istanbul ignore start*/
  492. /*istanbul ignore end*/
  493. equals: function equals(left, right) {
  494. if (this.options.comparator) {
  495. return this.options.comparator(left, right);
  496. } else {
  497. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  498. }
  499. },
  500. /*istanbul ignore start*/
  501. /*istanbul ignore end*/
  502. removeEmpty: function removeEmpty(array) {
  503. var ret = [];
  504. for (var i = 0; i < array.length; i++) {
  505. if (array[i]) {
  506. ret.push(array[i]);
  507. }
  508. }
  509. return ret;
  510. },
  511. /*istanbul ignore start*/
  512. /*istanbul ignore end*/
  513. castInput: function castInput(value) {
  514. return value;
  515. },
  516. /*istanbul ignore start*/
  517. /*istanbul ignore end*/
  518. tokenize: function tokenize(value) {
  519. return value.split('');
  520. },
  521. /*istanbul ignore start*/
  522. /*istanbul ignore end*/
  523. join: function join(chars) {
  524. return chars.join('');
  525. }
  526. };
  527. function buildValues(diff, components, newString, oldString, useLongestToken) {
  528. var componentPos = 0,
  529. componentLen = components.length,
  530. newPos = 0,
  531. oldPos = 0;
  532. for (; componentPos < componentLen; componentPos++) {
  533. var component = components[componentPos];
  534. if (!component.removed) {
  535. if (!component.added && useLongestToken) {
  536. var value = newString.slice(newPos, newPos + component.count);
  537. value = value.map(function (value, i) {
  538. var oldValue = oldString[oldPos + i];
  539. return oldValue.length > value.length ? oldValue : value;
  540. });
  541. component.value = diff.join(value);
  542. } else {
  543. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  544. }
  545. newPos += component.count; // Common case
  546. if (!component.added) {
  547. oldPos += component.count;
  548. }
  549. } else {
  550. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  551. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  552. // The diffing algorithm is tied to add then remove output and this is the simplest
  553. // route to get the desired output with minimal overhead.
  554. if (componentPos && components[componentPos - 1].added) {
  555. var tmp = components[componentPos - 1];
  556. components[componentPos - 1] = components[componentPos];
  557. components[componentPos] = tmp;
  558. }
  559. }
  560. } // Special case handle for when one terminal is ignored (i.e. whitespace).
  561. // For this case we merge the terminal into the prior string and drop the change.
  562. // This is only available for string mode.
  563. var lastComponent = components[componentLen - 1];
  564. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  565. components[componentLen - 2].value += lastComponent.value;
  566. components.pop();
  567. }
  568. return components;
  569. }
  570. function clonePath(path) {
  571. return {
  572. newPos: path.newPos,
  573. components: path.components.slice(0)
  574. };
  575. }
  576. /***/ }),
  577. /***/ 1973:
  578. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  579. "use strict";
  580. var __webpack_unused_export__;
  581. /*istanbul ignore start*/
  582. __webpack_unused_export__ = ({
  583. value: true
  584. });
  585. exports.Kx = diffChars;
  586. __webpack_unused_export__ = void 0;
  587. /*istanbul ignore end*/
  588. var
  589. /*istanbul ignore start*/
  590. _base = _interopRequireDefault(__webpack_require__(1198))
  591. /*istanbul ignore end*/
  592. ;
  593. /*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  594. /*istanbul ignore end*/
  595. var characterDiff = new
  596. /*istanbul ignore start*/
  597. _base
  598. /*istanbul ignore end*/
  599. .
  600. /*istanbul ignore start*/
  601. default
  602. /*istanbul ignore end*/
  603. ();
  604. /*istanbul ignore start*/
  605. __webpack_unused_export__ = characterDiff;
  606. /*istanbul ignore end*/
  607. function diffChars(oldStr, newStr, options) {
  608. return characterDiff.diff(oldStr, newStr, options);
  609. }
  610. /***/ }),
  611. /***/ 1345:
  612. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  613. "use strict";
  614. var util = __webpack_require__(5022);
  615. function scrollIntoView(elem, container, config) {
  616. config = config || {};
  617. // document 归一化到 window
  618. if (container.nodeType === 9) {
  619. container = util.getWindow(container);
  620. }
  621. var allowHorizontalScroll = config.allowHorizontalScroll;
  622. var onlyScrollIfNeeded = config.onlyScrollIfNeeded;
  623. var alignWithTop = config.alignWithTop;
  624. var alignWithLeft = config.alignWithLeft;
  625. var offsetTop = config.offsetTop || 0;
  626. var offsetLeft = config.offsetLeft || 0;
  627. var offsetBottom = config.offsetBottom || 0;
  628. var offsetRight = config.offsetRight || 0;
  629. allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll;
  630. var isWin = util.isWindow(container);
  631. var elemOffset = util.offset(elem);
  632. var eh = util.outerHeight(elem);
  633. var ew = util.outerWidth(elem);
  634. var containerOffset = undefined;
  635. var ch = undefined;
  636. var cw = undefined;
  637. var containerScroll = undefined;
  638. var diffTop = undefined;
  639. var diffBottom = undefined;
  640. var win = undefined;
  641. var winScroll = undefined;
  642. var ww = undefined;
  643. var wh = undefined;
  644. if (isWin) {
  645. win = container;
  646. wh = util.height(win);
  647. ww = util.width(win);
  648. winScroll = {
  649. left: util.scrollLeft(win),
  650. top: util.scrollTop(win)
  651. };
  652. // elem 相对 container 可视视窗的距离
  653. diffTop = {
  654. left: elemOffset.left - winScroll.left - offsetLeft,
  655. top: elemOffset.top - winScroll.top - offsetTop
  656. };
  657. diffBottom = {
  658. left: elemOffset.left + ew - (winScroll.left + ww) + offsetRight,
  659. top: elemOffset.top + eh - (winScroll.top + wh) + offsetBottom
  660. };
  661. containerScroll = winScroll;
  662. } else {
  663. containerOffset = util.offset(container);
  664. ch = container.clientHeight;
  665. cw = container.clientWidth;
  666. containerScroll = {
  667. left: container.scrollLeft,
  668. top: container.scrollTop
  669. };
  670. // elem 相对 container 可视视窗的距离
  671. // 注意边框, offset 是边框到根节点
  672. diffTop = {
  673. left: elemOffset.left - (containerOffset.left + (parseFloat(util.css(container, 'borderLeftWidth')) || 0)) - offsetLeft,
  674. top: elemOffset.top - (containerOffset.top + (parseFloat(util.css(container, 'borderTopWidth')) || 0)) - offsetTop
  675. };
  676. diffBottom = {
  677. left: elemOffset.left + ew - (containerOffset.left + cw + (parseFloat(util.css(container, 'borderRightWidth')) || 0)) + offsetRight,
  678. top: elemOffset.top + eh - (containerOffset.top + ch + (parseFloat(util.css(container, 'borderBottomWidth')) || 0)) + offsetBottom
  679. };
  680. }
  681. if (diffTop.top < 0 || diffBottom.top > 0) {
  682. // 强制向上
  683. if (alignWithTop === true) {
  684. util.scrollTop(container, containerScroll.top + diffTop.top);
  685. } else if (alignWithTop === false) {
  686. util.scrollTop(container, containerScroll.top + diffBottom.top);
  687. } else {
  688. // 自动调整
  689. if (diffTop.top < 0) {
  690. util.scrollTop(container, containerScroll.top + diffTop.top);
  691. } else {
  692. util.scrollTop(container, containerScroll.top + diffBottom.top);
  693. }
  694. }
  695. } else {
  696. if (!onlyScrollIfNeeded) {
  697. alignWithTop = alignWithTop === undefined ? true : !!alignWithTop;
  698. if (alignWithTop) {
  699. util.scrollTop(container, containerScroll.top + diffTop.top);
  700. } else {
  701. util.scrollTop(container, containerScroll.top + diffBottom.top);
  702. }
  703. }
  704. }
  705. if (allowHorizontalScroll) {
  706. if (diffTop.left < 0 || diffBottom.left > 0) {
  707. // 强制向上
  708. if (alignWithLeft === true) {
  709. util.scrollLeft(container, containerScroll.left + diffTop.left);
  710. } else if (alignWithLeft === false) {
  711. util.scrollLeft(container, containerScroll.left + diffBottom.left);
  712. } else {
  713. // 自动调整
  714. if (diffTop.left < 0) {
  715. util.scrollLeft(container, containerScroll.left + diffTop.left);
  716. } else {
  717. util.scrollLeft(container, containerScroll.left + diffBottom.left);
  718. }
  719. }
  720. } else {
  721. if (!onlyScrollIfNeeded) {
  722. alignWithLeft = alignWithLeft === undefined ? true : !!alignWithLeft;
  723. if (alignWithLeft) {
  724. util.scrollLeft(container, containerScroll.left + diffTop.left);
  725. } else {
  726. util.scrollLeft(container, containerScroll.left + diffBottom.left);
  727. }
  728. }
  729. }
  730. }
  731. }
  732. module.exports = scrollIntoView;
  733. /***/ }),
  734. /***/ 5425:
  735. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  736. "use strict";
  737. module.exports = __webpack_require__(1345);
  738. /***/ }),
  739. /***/ 5022:
  740. /***/ (function(module) {
  741. "use strict";
  742. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  743. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  744. var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source;
  745. function getClientPosition(elem) {
  746. var box = undefined;
  747. var x = undefined;
  748. var y = undefined;
  749. var doc = elem.ownerDocument;
  750. var body = doc.body;
  751. var docElem = doc && doc.documentElement;
  752. // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式
  753. box = elem.getBoundingClientRect();
  754. // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop
  755. // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确
  756. // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin
  757. x = box.left;
  758. y = box.top;
  759. // In IE, most of the time, 2 extra pixels are added to the top and left
  760. // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and
  761. // IE6 standards mode, this border can be overridden by setting the
  762. // document element's border to zero -- thus, we cannot rely on the
  763. // offset always being 2 pixels.
  764. // In quirks mode, the offset can be determined by querying the body's
  765. // clientLeft/clientTop, but in standards mode, it is found by querying
  766. // the document element's clientLeft/clientTop. Since we already called
  767. // getClientBoundingRect we have already forced a reflow, so it is not
  768. // too expensive just to query them all.
  769. // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的
  770. // 窗口边框标准是设 documentElement ,quirks 时设置 body
  771. // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去
  772. // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置
  773. // 标准 ie 下 docElem.clientTop 就是 border-top
  774. // ie7 html 即窗口边框改变不了。永远为 2
  775. // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0
  776. x -= docElem.clientLeft || body.clientLeft || 0;
  777. y -= docElem.clientTop || body.clientTop || 0;
  778. return {
  779. left: x,
  780. top: y
  781. };
  782. }
  783. function getScroll(w, top) {
  784. var ret = w['page' + (top ? 'Y' : 'X') + 'Offset'];
  785. var method = 'scroll' + (top ? 'Top' : 'Left');
  786. if (typeof ret !== 'number') {
  787. var d = w.document;
  788. // ie6,7,8 standard mode
  789. ret = d.documentElement[method];
  790. if (typeof ret !== 'number') {
  791. // quirks mode
  792. ret = d.body[method];
  793. }
  794. }
  795. return ret;
  796. }
  797. function getScrollLeft(w) {
  798. return getScroll(w);
  799. }
  800. function getScrollTop(w) {
  801. return getScroll(w, true);
  802. }
  803. function getOffset(el) {
  804. var pos = getClientPosition(el);
  805. var doc = el.ownerDocument;
  806. var w = doc.defaultView || doc.parentWindow;
  807. pos.left += getScrollLeft(w);
  808. pos.top += getScrollTop(w);
  809. return pos;
  810. }
  811. function _getComputedStyle(elem, name, computedStyle_) {
  812. var val = '';
  813. var d = elem.ownerDocument;
  814. var computedStyle = computedStyle_ || d.defaultView.getComputedStyle(elem, null);
  815. // https://github.com/kissyteam/kissy/issues/61
  816. if (computedStyle) {
  817. val = computedStyle.getPropertyValue(name) || computedStyle[name];
  818. }
  819. return val;
  820. }
  821. var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i');
  822. var RE_POS = /^(top|right|bottom|left)$/;
  823. var CURRENT_STYLE = 'currentStyle';
  824. var RUNTIME_STYLE = 'runtimeStyle';
  825. var LEFT = 'left';
  826. var PX = 'px';
  827. function _getComputedStyleIE(elem, name) {
  828. // currentStyle maybe null
  829. // http://msdn.microsoft.com/en-us/library/ms535231.aspx
  830. var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name];
  831. // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值
  832. // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19
  833. // 在 ie 下不对,需要直接用 offset 方式
  834. // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了
  835. // From the awesome hack by Dean Edwards
  836. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  837. // If we're not dealing with a regular pixel number
  838. // but a number that has a weird ending, we need to convert it to pixels
  839. // exclude left right for relativity
  840. if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {
  841. // Remember the original values
  842. var style = elem.style;
  843. var left = style[LEFT];
  844. var rsLeft = elem[RUNTIME_STYLE][LEFT];
  845. // prevent flashing of content
  846. elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT];
  847. // Put in the new values to get a computed value out
  848. style[LEFT] = name === 'fontSize' ? '1em' : ret || 0;
  849. ret = style.pixelLeft + PX;
  850. // Revert the changed values
  851. style[LEFT] = left;
  852. elem[RUNTIME_STYLE][LEFT] = rsLeft;
  853. }
  854. return ret === '' ? 'auto' : ret;
  855. }
  856. var getComputedStyleX = undefined;
  857. if (typeof window !== 'undefined') {
  858. getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;
  859. }
  860. function each(arr, fn) {
  861. for (var i = 0; i < arr.length; i++) {
  862. fn(arr[i]);
  863. }
  864. }
  865. function isBorderBoxFn(elem) {
  866. return getComputedStyleX(elem, 'boxSizing') === 'border-box';
  867. }
  868. var BOX_MODELS = ['margin', 'border', 'padding'];
  869. var CONTENT_INDEX = -1;
  870. var PADDING_INDEX = 2;
  871. var BORDER_INDEX = 1;
  872. var MARGIN_INDEX = 0;
  873. function swap(elem, options, callback) {
  874. var old = {};
  875. var style = elem.style;
  876. var name = undefined;
  877. // Remember the old values, and insert the new ones
  878. for (name in options) {
  879. if (options.hasOwnProperty(name)) {
  880. old[name] = style[name];
  881. style[name] = options[name];
  882. }
  883. }
  884. callback.call(elem);
  885. // Revert the old values
  886. for (name in options) {
  887. if (options.hasOwnProperty(name)) {
  888. style[name] = old[name];
  889. }
  890. }
  891. }
  892. function getPBMWidth(elem, props, which) {
  893. var value = 0;
  894. var prop = undefined;
  895. var j = undefined;
  896. var i = undefined;
  897. for (j = 0; j < props.length; j++) {
  898. prop = props[j];
  899. if (prop) {
  900. for (i = 0; i < which.length; i++) {
  901. var cssProp = undefined;
  902. if (prop === 'border') {
  903. cssProp = prop + which[i] + 'Width';
  904. } else {
  905. cssProp = prop + which[i];
  906. }
  907. value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;
  908. }
  909. }
  910. }
  911. return value;
  912. }
  913. /**
  914. * A crude way of determining if an object is a window
  915. * @member util
  916. */
  917. function isWindow(obj) {
  918. // must use == for ie8
  919. /* eslint eqeqeq:0 */
  920. return obj != null && obj == obj.window;
  921. }
  922. var domUtils = {};
  923. each(['Width', 'Height'], function (name) {
  924. domUtils['doc' + name] = function (refWin) {
  925. var d = refWin.document;
  926. return Math.max(
  927. // firefox chrome documentElement.scrollHeight< body.scrollHeight
  928. // ie standard mode : documentElement.scrollHeight> body.scrollHeight
  929. d.documentElement['scroll' + name],
  930. // quirks : documentElement.scrollHeight 最大等于可视窗口多一点?
  931. d.body['scroll' + name], domUtils['viewport' + name](d));
  932. };
  933. domUtils['viewport' + name] = function (win) {
  934. // pc browser includes scrollbar in window.innerWidth
  935. var prop = 'client' + name;
  936. var doc = win.document;
  937. var body = doc.body;
  938. var documentElement = doc.documentElement;
  939. var documentElementProp = documentElement[prop];
  940. // 标准模式取 documentElement
  941. // backcompat 取 body
  942. return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp;
  943. };
  944. });
  945. /*
  946. 得到元素的大小信息
  947. @param elem
  948. @param name
  949. @param {String} [extra] 'padding' : (css width) + padding
  950. 'border' : (css width) + padding + border
  951. 'margin' : (css width) + padding + border + margin
  952. */
  953. function getWH(elem, name, extra) {
  954. if (isWindow(elem)) {
  955. return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);
  956. } else if (elem.nodeType === 9) {
  957. return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);
  958. }
  959. var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
  960. var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight;
  961. var computedStyle = getComputedStyleX(elem);
  962. var isBorderBox = isBorderBoxFn(elem, computedStyle);
  963. var cssBoxValue = 0;
  964. if (borderBoxValue == null || borderBoxValue <= 0) {
  965. borderBoxValue = undefined;
  966. // Fall back to computed then un computed css if necessary
  967. cssBoxValue = getComputedStyleX(elem, name);
  968. if (cssBoxValue == null || Number(cssBoxValue) < 0) {
  969. cssBoxValue = elem.style[name] || 0;
  970. }
  971. // Normalize '', auto, and prepare for extra
  972. cssBoxValue = parseFloat(cssBoxValue) || 0;
  973. }
  974. if (extra === undefined) {
  975. extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;
  976. }
  977. var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;
  978. var val = borderBoxValue || cssBoxValue;
  979. if (extra === CONTENT_INDEX) {
  980. if (borderBoxValueOrIsBorderBox) {
  981. return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle);
  982. }
  983. return cssBoxValue;
  984. }
  985. if (borderBoxValueOrIsBorderBox) {
  986. var padding = extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle);
  987. return val + (extra === BORDER_INDEX ? 0 : padding);
  988. }
  989. return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle);
  990. }
  991. var cssShow = {
  992. position: 'absolute',
  993. visibility: 'hidden',
  994. display: 'block'
  995. };
  996. // fix #119 : https://github.com/kissyteam/kissy/issues/119
  997. function getWHIgnoreDisplay(elem) {
  998. var val = undefined;
  999. var args = arguments;
  1000. // in case elem is window
  1001. // elem.offsetWidth === undefined
  1002. if (elem.offsetWidth !== 0) {
  1003. val = getWH.apply(undefined, args);
  1004. } else {
  1005. swap(elem, cssShow, function () {
  1006. val = getWH.apply(undefined, args);
  1007. });
  1008. }
  1009. return val;
  1010. }
  1011. function css(el, name, v) {
  1012. var value = v;
  1013. if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
  1014. for (var i in name) {
  1015. if (name.hasOwnProperty(i)) {
  1016. css(el, i, name[i]);
  1017. }
  1018. }
  1019. return undefined;
  1020. }
  1021. if (typeof value !== 'undefined') {
  1022. if (typeof value === 'number') {
  1023. value += 'px';
  1024. }
  1025. el.style[name] = value;
  1026. return undefined;
  1027. }
  1028. return getComputedStyleX(el, name);
  1029. }
  1030. each(['width', 'height'], function (name) {
  1031. var first = name.charAt(0).toUpperCase() + name.slice(1);
  1032. domUtils['outer' + first] = function (el, includeMargin) {
  1033. return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);
  1034. };
  1035. var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
  1036. domUtils[name] = function (elem, val) {
  1037. if (val !== undefined) {
  1038. if (elem) {
  1039. var computedStyle = getComputedStyleX(elem);
  1040. var isBorderBox = isBorderBoxFn(elem);
  1041. if (isBorderBox) {
  1042. val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle);
  1043. }
  1044. return css(elem, name, val);
  1045. }
  1046. return undefined;
  1047. }
  1048. return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);
  1049. };
  1050. });
  1051. // 设置 elem 相对 elem.ownerDocument 的坐标
  1052. function setOffset(elem, offset) {
  1053. // set position first, in-case top/left are set even on static elem
  1054. if (css(elem, 'position') === 'static') {
  1055. elem.style.position = 'relative';
  1056. }
  1057. var old = getOffset(elem);
  1058. var ret = {};
  1059. var current = undefined;
  1060. var key = undefined;
  1061. for (key in offset) {
  1062. if (offset.hasOwnProperty(key)) {
  1063. current = parseFloat(css(elem, key)) || 0;
  1064. ret[key] = current + offset[key] - old[key];
  1065. }
  1066. }
  1067. css(elem, ret);
  1068. }
  1069. module.exports = _extends({
  1070. getWindow: function getWindow(node) {
  1071. var doc = node.ownerDocument || node;
  1072. return doc.defaultView || doc.parentWindow;
  1073. },
  1074. offset: function offset(el, value) {
  1075. if (typeof value !== 'undefined') {
  1076. setOffset(el, value);
  1077. } else {
  1078. return getOffset(el);
  1079. }
  1080. },
  1081. isWindow: isWindow,
  1082. each: each,
  1083. css: css,
  1084. clone: function clone(obj) {
  1085. var ret = {};
  1086. for (var i in obj) {
  1087. if (obj.hasOwnProperty(i)) {
  1088. ret[i] = obj[i];
  1089. }
  1090. }
  1091. var overflow = obj.overflow;
  1092. if (overflow) {
  1093. for (var i in obj) {
  1094. if (obj.hasOwnProperty(i)) {
  1095. ret.overflow[i] = obj.overflow[i];
  1096. }
  1097. }
  1098. }
  1099. return ret;
  1100. },
  1101. scrollLeft: function scrollLeft(w, v) {
  1102. if (isWindow(w)) {
  1103. if (v === undefined) {
  1104. return getScrollLeft(w);
  1105. }
  1106. window.scrollTo(v, getScrollTop(w));
  1107. } else {
  1108. if (v === undefined) {
  1109. return w.scrollLeft;
  1110. }
  1111. w.scrollLeft = v;
  1112. }
  1113. },
  1114. scrollTop: function scrollTop(w, v) {
  1115. if (isWindow(w)) {
  1116. if (v === undefined) {
  1117. return getScrollTop(w);
  1118. }
  1119. window.scrollTo(getScrollLeft(w), v);
  1120. } else {
  1121. if (v === undefined) {
  1122. return w.scrollTop;
  1123. }
  1124. w.scrollTop = v;
  1125. }
  1126. },
  1127. viewportWidth: 0,
  1128. viewportHeight: 0
  1129. }, domUtils);
  1130. /***/ }),
  1131. /***/ 8575:
  1132. /***/ (function(module) {
  1133. if (typeof Object.create === 'function') {
  1134. // implementation from standard node.js 'util' module
  1135. module.exports = function inherits(ctor, superCtor) {
  1136. if (superCtor) {
  1137. ctor.super_ = superCtor
  1138. ctor.prototype = Object.create(superCtor.prototype, {
  1139. constructor: {
  1140. value: ctor,
  1141. enumerable: false,
  1142. writable: true,
  1143. configurable: true
  1144. }
  1145. })
  1146. }
  1147. };
  1148. } else {
  1149. // old school shim for old browsers
  1150. module.exports = function inherits(ctor, superCtor) {
  1151. if (superCtor) {
  1152. ctor.super_ = superCtor
  1153. var TempCtor = function () {}
  1154. TempCtor.prototype = superCtor.prototype
  1155. ctor.prototype = new TempCtor()
  1156. ctor.prototype.constructor = ctor
  1157. }
  1158. }
  1159. }
  1160. /***/ }),
  1161. /***/ 9894:
  1162. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1163. // Load in dependencies
  1164. var computedStyle = __webpack_require__(4827);
  1165. /**
  1166. * Calculate the `line-height` of a given node
  1167. * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.
  1168. * @returns {Number} `line-height` of the element in pixels
  1169. */
  1170. function lineHeight(node) {
  1171. // Grab the line-height via style
  1172. var lnHeightStr = computedStyle(node, 'line-height');
  1173. var lnHeight = parseFloat(lnHeightStr, 10);
  1174. // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')
  1175. if (lnHeightStr === lnHeight + '') {
  1176. // Save the old lineHeight style and update the em unit to the element
  1177. var _lnHeightStyle = node.style.lineHeight;
  1178. node.style.lineHeight = lnHeightStr + 'em';
  1179. // Calculate the em based height
  1180. lnHeightStr = computedStyle(node, 'line-height');
  1181. lnHeight = parseFloat(lnHeightStr, 10);
  1182. // Revert the lineHeight style
  1183. if (_lnHeightStyle) {
  1184. node.style.lineHeight = _lnHeightStyle;
  1185. } else {
  1186. delete node.style.lineHeight;
  1187. }
  1188. }
  1189. // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt)
  1190. // DEV: `em` units are converted to `pt` in IE6
  1191. // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length
  1192. if (lnHeightStr.indexOf('pt') !== -1) {
  1193. lnHeight *= 4;
  1194. lnHeight /= 3;
  1195. // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
  1196. } else if (lnHeightStr.indexOf('mm') !== -1) {
  1197. lnHeight *= 96;
  1198. lnHeight /= 25.4;
  1199. // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
  1200. } else if (lnHeightStr.indexOf('cm') !== -1) {
  1201. lnHeight *= 96;
  1202. lnHeight /= 2.54;
  1203. // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
  1204. } else if (lnHeightStr.indexOf('in') !== -1) {
  1205. lnHeight *= 96;
  1206. // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
  1207. } else if (lnHeightStr.indexOf('pc') !== -1) {
  1208. lnHeight *= 16;
  1209. }
  1210. // Continue our computation
  1211. lnHeight = Math.round(lnHeight);
  1212. // If the line-height is "normal", calculate by font-size
  1213. if (lnHeightStr === 'normal') {
  1214. // Create a temporary node
  1215. var nodeName = node.nodeName;
  1216. var _node = document.createElement(nodeName);
  1217. _node.innerHTML = '&nbsp;';
  1218. // If we have a text area, reset it to only 1 row
  1219. // https://github.com/twolfson/line-height/issues/4
  1220. if (nodeName.toUpperCase() === 'TEXTAREA') {
  1221. _node.setAttribute('rows', '1');
  1222. }
  1223. // Set the font-size of the element
  1224. var fontSizeStr = computedStyle(node, 'font-size');
  1225. _node.style.fontSize = fontSizeStr;
  1226. // Remove default padding/border which can affect offset height
  1227. // https://github.com/twolfson/line-height/issues/4
  1228. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
  1229. _node.style.padding = '0px';
  1230. _node.style.border = '0px';
  1231. // Append it to the body
  1232. var body = document.body;
  1233. body.appendChild(_node);
  1234. // Assume the line height of the element is the height
  1235. var height = _node.offsetHeight;
  1236. lnHeight = height;
  1237. // Remove our child from the DOM
  1238. body.removeChild(_node);
  1239. }
  1240. // Return the calculated height
  1241. return lnHeight;
  1242. }
  1243. // Export lineHeight
  1244. module.exports = lineHeight;
  1245. /***/ }),
  1246. /***/ 7970:
  1247. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1248. module.exports = __webpack_require__(195);
  1249. /***/ }),
  1250. /***/ 3110:
  1251. /***/ (function(module) {
  1252. "use strict";
  1253. /**
  1254. * Copyright (c) 2015, Facebook, Inc.
  1255. * All rights reserved.
  1256. *
  1257. * This source code is licensed under the BSD-style license found in the
  1258. * LICENSE file in the root directory of this source tree. An additional grant
  1259. * of patent rights can be found in the PATENTS file in the same directory.
  1260. *
  1261. * @providesModule ExecutionEnvironment
  1262. */
  1263. /*jslint evil: true */
  1264. var canUseDOM = !!(
  1265. typeof window !== 'undefined' &&
  1266. window.document &&
  1267. window.document.createElement
  1268. );
  1269. /**
  1270. * Simple, lightweight module assisting with the detection and context of
  1271. * Worker. Helps avoid circular dependencies and allows code to reason about
  1272. * whether or not they are in a Worker, even if they never include the main
  1273. * `ReactWorker` dependency.
  1274. */
  1275. var ExecutionEnvironment = {
  1276. canUseDOM: canUseDOM,
  1277. canUseWorkers: typeof Worker !== 'undefined',
  1278. canUseEventListeners:
  1279. canUseDOM && !!(window.addEventListener || window.attachEvent),
  1280. canUseViewport: canUseDOM && !!window.screen,
  1281. isInWorker: !canUseDOM // For now, this is true - might change in the future.
  1282. };
  1283. module.exports = ExecutionEnvironment;
  1284. /***/ }),
  1285. /***/ 3812:
  1286. /***/ (function(module) {
  1287. /**
  1288. * Copyright 2004-present Facebook. All Rights Reserved.
  1289. *
  1290. * @providesModule UserAgent_DEPRECATED
  1291. */
  1292. /**
  1293. * Provides entirely client-side User Agent and OS detection. You should prefer
  1294. * the non-deprecated UserAgent module when possible, which exposes our
  1295. * authoritative server-side PHP-based detection to the client.
  1296. *
  1297. * Usage is straightforward:
  1298. *
  1299. * if (UserAgent_DEPRECATED.ie()) {
  1300. * // IE
  1301. * }
  1302. *
  1303. * You can also do version checks:
  1304. *
  1305. * if (UserAgent_DEPRECATED.ie() >= 7) {
  1306. * // IE7 or better
  1307. * }
  1308. *
  1309. * The browser functions will return NaN if the browser does not match, so
  1310. * you can also do version compares the other way:
  1311. *
  1312. * if (UserAgent_DEPRECATED.ie() < 7) {
  1313. * // IE6 or worse
  1314. * }
  1315. *
  1316. * Note that the version is a float and may include a minor version number,
  1317. * so you should always use range operators to perform comparisons, not
  1318. * strict equality.
  1319. *
  1320. * **Note:** You should **strongly** prefer capability detection to browser
  1321. * version detection where it's reasonable:
  1322. *
  1323. * http://www.quirksmode.org/js/support.html
  1324. *
  1325. * Further, we have a large number of mature wrapper functions and classes
  1326. * which abstract away many browser irregularities. Check the documentation,
  1327. * grep for things, or ask on javascript@lists.facebook.com before writing yet
  1328. * another copy of "event || window.event".
  1329. *
  1330. */
  1331. var _populated = false;
  1332. // Browsers
  1333. var _ie, _firefox, _opera, _webkit, _chrome;
  1334. // Actual IE browser for compatibility mode
  1335. var _ie_real_version;
  1336. // Platforms
  1337. var _osx, _windows, _linux, _android;
  1338. // Architectures
  1339. var _win64;
  1340. // Devices
  1341. var _iphone, _ipad, _native;
  1342. var _mobile;
  1343. function _populate() {
  1344. if (_populated) {
  1345. return;
  1346. }
  1347. _populated = true;
  1348. // To work around buggy JS libraries that can't handle multi-digit
  1349. // version numbers, Opera 10's user agent string claims it's Opera
  1350. // 9, then later includes a Version/X.Y field:
  1351. //
  1352. // Opera/9.80 (foo) Presto/2.2.15 Version/10.10
  1353. var uas = navigator.userAgent;
  1354. var agent = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(uas);
  1355. var os = /(Mac OS X)|(Windows)|(Linux)/.exec(uas);
  1356. _iphone = /\b(iPhone|iP[ao]d)/.exec(uas);
  1357. _ipad = /\b(iP[ao]d)/.exec(uas);
  1358. _android = /Android/i.exec(uas);
  1359. _native = /FBAN\/\w+;/i.exec(uas);
  1360. _mobile = /Mobile/i.exec(uas);
  1361. // Note that the IE team blog would have you believe you should be checking
  1362. // for 'Win64; x64'. But MSDN then reveals that you can actually be coming
  1363. // from either x64 or ia64; so ultimately, you should just check for Win64
  1364. // as in indicator of whether you're in 64-bit IE. 32-bit IE on 64-bit
  1365. // Windows will send 'WOW64' instead.
  1366. _win64 = !!(/Win64/.exec(uas));
  1367. if (agent) {
  1368. _ie = agent[1] ? parseFloat(agent[1]) : (
  1369. agent[5] ? parseFloat(agent[5]) : NaN);
  1370. // IE compatibility mode
  1371. if (_ie && document && document.documentMode) {
  1372. _ie = document.documentMode;
  1373. }
  1374. // grab the "true" ie version from the trident token if available
  1375. var trident = /(?:Trident\/(\d+.\d+))/.exec(uas);
  1376. _ie_real_version = trident ? parseFloat(trident[1]) + 4 : _ie;
  1377. _firefox = agent[2] ? parseFloat(agent[2]) : NaN;
  1378. _opera = agent[3] ? parseFloat(agent[3]) : NaN;
  1379. _webkit = agent[4] ? parseFloat(agent[4]) : NaN;
  1380. if (_webkit) {
  1381. // We do not add the regexp to the above test, because it will always
  1382. // match 'safari' only since 'AppleWebKit' appears before 'Chrome' in
  1383. // the userAgent string.
  1384. agent = /(?:Chrome\/(\d+\.\d+))/.exec(uas);
  1385. _chrome = agent && agent[1] ? parseFloat(agent[1]) : NaN;
  1386. } else {
  1387. _chrome = NaN;
  1388. }
  1389. } else {
  1390. _ie = _firefox = _opera = _chrome = _webkit = NaN;
  1391. }
  1392. if (os) {
  1393. if (os[1]) {
  1394. // Detect OS X version. If no version number matches, set _osx to true.
  1395. // Version examples: 10, 10_6_1, 10.7
  1396. // Parses version number as a float, taking only first two sets of
  1397. // digits. If only one set of digits is found, returns just the major
  1398. // version number.
  1399. var ver = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(uas);
  1400. _osx = ver ? parseFloat(ver[1].replace('_', '.')) : true;
  1401. } else {
  1402. _osx = false;
  1403. }
  1404. _windows = !!os[2];
  1405. _linux = !!os[3];
  1406. } else {
  1407. _osx = _windows = _linux = false;
  1408. }
  1409. }
  1410. var UserAgent_DEPRECATED = {
  1411. /**
  1412. * Check if the UA is Internet Explorer.
  1413. *
  1414. *
  1415. * @return float|NaN Version number (if match) or NaN.
  1416. */
  1417. ie: function() {
  1418. return _populate() || _ie;
  1419. },
  1420. /**
  1421. * Check if we're in Internet Explorer compatibility mode.
  1422. *
  1423. * @return bool true if in compatibility mode, false if
  1424. * not compatibility mode or not ie
  1425. */
  1426. ieCompatibilityMode: function() {
  1427. return _populate() || (_ie_real_version > _ie);
  1428. },
  1429. /**
  1430. * Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we
  1431. * only need this because Skype can't handle 64-bit IE yet. We need to remove
  1432. * this when we don't need it -- tracked by #601957.
  1433. */
  1434. ie64: function() {
  1435. return UserAgent_DEPRECATED.ie() && _win64;
  1436. },
  1437. /**
  1438. * Check if the UA is Firefox.
  1439. *
  1440. *
  1441. * @return float|NaN Version number (if match) or NaN.
  1442. */
  1443. firefox: function() {
  1444. return _populate() || _firefox;
  1445. },
  1446. /**
  1447. * Check if the UA is Opera.
  1448. *
  1449. *
  1450. * @return float|NaN Version number (if match) or NaN.
  1451. */
  1452. opera: function() {
  1453. return _populate() || _opera;
  1454. },
  1455. /**
  1456. * Check if the UA is WebKit.
  1457. *
  1458. *
  1459. * @return float|NaN Version number (if match) or NaN.
  1460. */
  1461. webkit: function() {
  1462. return _populate() || _webkit;
  1463. },
  1464. /**
  1465. * For Push
  1466. * WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit
  1467. */
  1468. safari: function() {
  1469. return UserAgent_DEPRECATED.webkit();
  1470. },
  1471. /**
  1472. * Check if the UA is a Chrome browser.
  1473. *
  1474. *
  1475. * @return float|NaN Version number (if match) or NaN.
  1476. */
  1477. chrome : function() {
  1478. return _populate() || _chrome;
  1479. },
  1480. /**
  1481. * Check if the user is running Windows.
  1482. *
  1483. * @return bool `true' if the user's OS is Windows.
  1484. */
  1485. windows: function() {
  1486. return _populate() || _windows;
  1487. },
  1488. /**
  1489. * Check if the user is running Mac OS X.
  1490. *
  1491. * @return float|bool Returns a float if a version number is detected,
  1492. * otherwise true/false.
  1493. */
  1494. osx: function() {
  1495. return _populate() || _osx;
  1496. },
  1497. /**
  1498. * Check if the user is running Linux.
  1499. *
  1500. * @return bool `true' if the user's OS is some flavor of Linux.
  1501. */
  1502. linux: function() {
  1503. return _populate() || _linux;
  1504. },
  1505. /**
  1506. * Check if the user is running on an iPhone or iPod platform.
  1507. *
  1508. * @return bool `true' if the user is running some flavor of the
  1509. * iPhone OS.
  1510. */
  1511. iphone: function() {
  1512. return _populate() || _iphone;
  1513. },
  1514. mobile: function() {
  1515. return _populate() || (_iphone || _ipad || _android || _mobile);
  1516. },
  1517. nativeApp: function() {
  1518. // webviews inside of the native apps
  1519. return _populate() || _native;
  1520. },
  1521. android: function() {
  1522. return _populate() || _android;
  1523. },
  1524. ipad: function() {
  1525. return _populate() || _ipad;
  1526. }
  1527. };
  1528. module.exports = UserAgent_DEPRECATED;
  1529. /***/ }),
  1530. /***/ 7939:
  1531. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1532. "use strict";
  1533. /**
  1534. * Copyright 2013-2015, Facebook, Inc.
  1535. * All rights reserved.
  1536. *
  1537. * This source code is licensed under the BSD-style license found in the
  1538. * LICENSE file in the root directory of this source tree. An additional grant
  1539. * of patent rights can be found in the PATENTS file in the same directory.
  1540. *
  1541. * @providesModule isEventSupported
  1542. */
  1543. var ExecutionEnvironment = __webpack_require__(3110);
  1544. var useHasFeature;
  1545. if (ExecutionEnvironment.canUseDOM) {
  1546. useHasFeature =
  1547. document.implementation &&
  1548. document.implementation.hasFeature &&
  1549. // always returns true in newer browsers as per the standard.
  1550. // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
  1551. document.implementation.hasFeature('', '') !== true;
  1552. }
  1553. /**
  1554. * Checks if an event is supported in the current execution environment.
  1555. *
  1556. * NOTE: This will not work correctly for non-generic events such as `change`,
  1557. * `reset`, `load`, `error`, and `select`.
  1558. *
  1559. * Borrows from Modernizr.
  1560. *
  1561. * @param {string} eventNameSuffix Event name, e.g. "click".
  1562. * @param {?boolean} capture Check if the capture phase is supported.
  1563. * @return {boolean} True if the event is supported.
  1564. * @internal
  1565. * @license Modernizr 3.0.0pre (Custom Build) | MIT
  1566. */
  1567. function isEventSupported(eventNameSuffix, capture) {
  1568. if (!ExecutionEnvironment.canUseDOM ||
  1569. capture && !('addEventListener' in document)) {
  1570. return false;
  1571. }
  1572. var eventName = 'on' + eventNameSuffix;
  1573. var isSupported = eventName in document;
  1574. if (!isSupported) {
  1575. var element = document.createElement('div');
  1576. element.setAttribute(eventName, 'return;');
  1577. isSupported = typeof element[eventName] === 'function';
  1578. }
  1579. if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
  1580. // This is the only way to test support for the `wheel` event in IE9+.
  1581. isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
  1582. }
  1583. return isSupported;
  1584. }
  1585. module.exports = isEventSupported;
  1586. /***/ }),
  1587. /***/ 195:
  1588. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1589. "use strict";
  1590. /**
  1591. * Copyright (c) 2015, Facebook, Inc.
  1592. * All rights reserved.
  1593. *
  1594. * This source code is licensed under the BSD-style license found in the
  1595. * LICENSE file in the root directory of this source tree. An additional grant
  1596. * of patent rights can be found in the PATENTS file in the same directory.
  1597. *
  1598. * @providesModule normalizeWheel
  1599. * @typechecks
  1600. */
  1601. var UserAgent_DEPRECATED = __webpack_require__(3812);
  1602. var isEventSupported = __webpack_require__(7939);
  1603. // Reasonable defaults
  1604. var PIXEL_STEP = 10;
  1605. var LINE_HEIGHT = 40;
  1606. var PAGE_HEIGHT = 800;
  1607. /**
  1608. * Mouse wheel (and 2-finger trackpad) support on the web sucks. It is
  1609. * complicated, thus this doc is long and (hopefully) detailed enough to answer
  1610. * your questions.
  1611. *
  1612. * If you need to react to the mouse wheel in a predictable way, this code is
  1613. * like your bestest friend. * hugs *
  1614. *
  1615. * As of today, there are 4 DOM event types you can listen to:
  1616. *
  1617. * 'wheel' -- Chrome(31+), FF(17+), IE(9+)
  1618. * 'mousewheel' -- Chrome, IE(6+), Opera, Safari
  1619. * 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother!
  1620. * 'DOMMouseScroll' -- FF(0.9.7+) since 2003
  1621. *
  1622. * So what to do? The is the best:
  1623. *
  1624. * normalizeWheel.getEventType();
  1625. *
  1626. * In your event callback, use this code to get sane interpretation of the
  1627. * deltas. This code will return an object with properties:
  1628. *
  1629. * spinX -- normalized spin speed (use for zoom) - x plane
  1630. * spinY -- " - y plane
  1631. * pixelX -- normalized distance (to pixels) - x plane
  1632. * pixelY -- " - y plane
  1633. *
  1634. * Wheel values are provided by the browser assuming you are using the wheel to
  1635. * scroll a web page by a number of lines or pixels (or pages). Values can vary
  1636. * significantly on different platforms and browsers, forgetting that you can
  1637. * scroll at different speeds. Some devices (like trackpads) emit more events
  1638. * at smaller increments with fine granularity, and some emit massive jumps with
  1639. * linear speed or acceleration.
  1640. *
  1641. * This code does its best to normalize the deltas for you:
  1642. *
  1643. * - spin is trying to normalize how far the wheel was spun (or trackpad
  1644. * dragged). This is super useful for zoom support where you want to
  1645. * throw away the chunky scroll steps on the PC and make those equal to
  1646. * the slow and smooth tiny steps on the Mac. Key data: This code tries to
  1647. * resolve a single slow step on a wheel to 1.
  1648. *
  1649. * - pixel is normalizing the desired scroll delta in pixel units. You'll
  1650. * get the crazy differences between browsers, but at least it'll be in
  1651. * pixels!
  1652. *
  1653. * - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This
  1654. * should translate to positive value zooming IN, negative zooming OUT.
  1655. * This matches the newer 'wheel' event.
  1656. *
  1657. * Why are there spinX, spinY (or pixels)?
  1658. *
  1659. * - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn
  1660. * with a mouse. It results in side-scrolling in the browser by default.
  1661. *
  1662. * - spinY is what you expect -- it's the classic axis of a mouse wheel.
  1663. *
  1664. * - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and
  1665. * probably is by browsers in conjunction with fancy 3D controllers .. but
  1666. * you know.
  1667. *
  1668. * Implementation info:
  1669. *
  1670. * Examples of 'wheel' event if you scroll slowly (down) by one step with an
  1671. * average mouse:
  1672. *
  1673. * OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120)
  1674. * OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12)
  1675. * OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A)
  1676. * Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120)
  1677. * Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120)
  1678. *
  1679. * On the trackpad:
  1680. *
  1681. * OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6)
  1682. * OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A)
  1683. *
  1684. * On other/older browsers.. it's more complicated as there can be multiple and
  1685. * also missing delta values.
  1686. *
  1687. * The 'wheel' event is more standard:
  1688. *
  1689. * http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
  1690. *
  1691. * The basics is that it includes a unit, deltaMode (pixels, lines, pages), and
  1692. * deltaX, deltaY and deltaZ. Some browsers provide other values to maintain
  1693. * backward compatibility with older events. Those other values help us
  1694. * better normalize spin speed. Example of what the browsers provide:
  1695. *
  1696. * | event.wheelDelta | event.detail
  1697. * ------------------+------------------+--------------
  1698. * Safari v5/OS X | -120 | 0
  1699. * Safari v5/Win7 | -120 | 0
  1700. * Chrome v17/OS X | -120 | 0
  1701. * Chrome v17/Win7 | -120 | 0
  1702. * IE9/Win7 | -120 | undefined
  1703. * Firefox v4/OS X | undefined | 1
  1704. * Firefox v4/Win7 | undefined | 3
  1705. *
  1706. */
  1707. function normalizeWheel(/*object*/ event) /*object*/ {
  1708. var sX = 0, sY = 0, // spinX, spinY
  1709. pX = 0, pY = 0; // pixelX, pixelY
  1710. // Legacy
  1711. if ('detail' in event) { sY = event.detail; }
  1712. if ('wheelDelta' in event) { sY = -event.wheelDelta / 120; }
  1713. if ('wheelDeltaY' in event) { sY = -event.wheelDeltaY / 120; }
  1714. if ('wheelDeltaX' in event) { sX = -event.wheelDeltaX / 120; }
  1715. // side scrolling on FF with DOMMouseScroll
  1716. if ( 'axis' in event && event.axis === event.HORIZONTAL_AXIS ) {
  1717. sX = sY;
  1718. sY = 0;
  1719. }
  1720. pX = sX * PIXEL_STEP;
  1721. pY = sY * PIXEL_STEP;
  1722. if ('deltaY' in event) { pY = event.deltaY; }
  1723. if ('deltaX' in event) { pX = event.deltaX; }
  1724. if ((pX || pY) && event.deltaMode) {
  1725. if (event.deltaMode == 1) { // delta in LINE units
  1726. pX *= LINE_HEIGHT;
  1727. pY *= LINE_HEIGHT;
  1728. } else { // delta in PAGE units
  1729. pX *= PAGE_HEIGHT;
  1730. pY *= PAGE_HEIGHT;
  1731. }
  1732. }
  1733. // Fall-back if spin cannot be determined
  1734. if (pX && !sX) { sX = (pX < 1) ? -1 : 1; }
  1735. if (pY && !sY) { sY = (pY < 1) ? -1 : 1; }
  1736. return { spinX : sX,
  1737. spinY : sY,
  1738. pixelX : pX,
  1739. pixelY : pY };
  1740. }
  1741. /**
  1742. * The best combination if you prefer spinX + spinY normalization. It favors
  1743. * the older DOMMouseScroll for Firefox, as FF does not include wheelDelta with
  1744. * 'wheel' event, making spin speed determination impossible.
  1745. */
  1746. normalizeWheel.getEventType = function() /*string*/ {
  1747. return (UserAgent_DEPRECATED.firefox())
  1748. ? 'DOMMouseScroll'
  1749. : (isEventSupported('wheel'))
  1750. ? 'wheel'
  1751. : 'mousewheel';
  1752. };
  1753. module.exports = normalizeWheel;
  1754. /***/ }),
  1755. /***/ 5372:
  1756. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1757. "use strict";
  1758. /**
  1759. * Copyright (c) 2013-present, Facebook, Inc.
  1760. *
  1761. * This source code is licensed under the MIT license found in the
  1762. * LICENSE file in the root directory of this source tree.
  1763. */
  1764. var ReactPropTypesSecret = __webpack_require__(9567);
  1765. function emptyFunction() {}
  1766. function emptyFunctionWithReset() {}
  1767. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  1768. module.exports = function() {
  1769. function shim(props, propName, componentName, location, propFullName, secret) {
  1770. if (secret === ReactPropTypesSecret) {
  1771. // It is still safe when called from React.
  1772. return;
  1773. }
  1774. var err = new Error(
  1775. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  1776. 'Use PropTypes.checkPropTypes() to call them. ' +
  1777. 'Read more at http://fb.me/use-check-prop-types'
  1778. );
  1779. err.name = 'Invariant Violation';
  1780. throw err;
  1781. };
  1782. shim.isRequired = shim;
  1783. function getShim() {
  1784. return shim;
  1785. };
  1786. // Important!
  1787. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  1788. var ReactPropTypes = {
  1789. array: shim,
  1790. bigint: shim,
  1791. bool: shim,
  1792. func: shim,
  1793. number: shim,
  1794. object: shim,
  1795. string: shim,
  1796. symbol: shim,
  1797. any: shim,
  1798. arrayOf: getShim,
  1799. element: shim,
  1800. elementType: shim,
  1801. instanceOf: getShim,
  1802. node: shim,
  1803. objectOf: getShim,
  1804. oneOf: getShim,
  1805. oneOfType: getShim,
  1806. shape: getShim,
  1807. exact: getShim,
  1808. checkPropTypes: emptyFunctionWithReset,
  1809. resetWarningCache: emptyFunction
  1810. };
  1811. ReactPropTypes.PropTypes = ReactPropTypes;
  1812. return ReactPropTypes;
  1813. };
  1814. /***/ }),
  1815. /***/ 2652:
  1816. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1817. /**
  1818. * Copyright (c) 2013-present, Facebook, Inc.
  1819. *
  1820. * This source code is licensed under the MIT license found in the
  1821. * LICENSE file in the root directory of this source tree.
  1822. */
  1823. if (false) { var throwOnDirectAccess, ReactIs; } else {
  1824. // By explicitly using `prop-types` you are opting into new production behavior.
  1825. // http://fb.me/prop-types-in-prod
  1826. module.exports = __webpack_require__(5372)();
  1827. }
  1828. /***/ }),
  1829. /***/ 9567:
  1830. /***/ (function(module) {
  1831. "use strict";
  1832. /**
  1833. * Copyright (c) 2013-present, Facebook, Inc.
  1834. *
  1835. * This source code is licensed under the MIT license found in the
  1836. * LICENSE file in the root directory of this source tree.
  1837. */
  1838. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  1839. module.exports = ReactPropTypesSecret;
  1840. /***/ }),
  1841. /***/ 5438:
  1842. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1843. "use strict";
  1844. var __extends = (this && this.__extends) || (function () {
  1845. var extendStatics = Object.setPrototypeOf ||
  1846. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1847. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1848. return function (d, b) {
  1849. extendStatics(d, b);
  1850. function __() { this.constructor = d; }
  1851. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1852. };
  1853. })();
  1854. var __assign = (this && this.__assign) || Object.assign || function(t) {
  1855. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1856. s = arguments[i];
  1857. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  1858. t[p] = s[p];
  1859. }
  1860. return t;
  1861. };
  1862. var __rest = (this && this.__rest) || function (s, e) {
  1863. var t = {};
  1864. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  1865. t[p] = s[p];
  1866. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  1867. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  1868. t[p[i]] = s[p[i]];
  1869. return t;
  1870. };
  1871. exports.__esModule = true;
  1872. var React = __webpack_require__(9196);
  1873. var PropTypes = __webpack_require__(2652);
  1874. var autosize = __webpack_require__(6411);
  1875. var _getLineHeight = __webpack_require__(9894);
  1876. var getLineHeight = _getLineHeight;
  1877. var RESIZED = "autosize:resized";
  1878. /**
  1879. * A light replacement for built-in textarea component
  1880. * which automaticaly adjusts its height to match the content
  1881. */
  1882. var TextareaAutosizeClass = /** @class */ (function (_super) {
  1883. __extends(TextareaAutosizeClass, _super);
  1884. function TextareaAutosizeClass() {
  1885. var _this = _super !== null && _super.apply(this, arguments) || this;
  1886. _this.state = {
  1887. lineHeight: null
  1888. };
  1889. _this.textarea = null;
  1890. _this.onResize = function (e) {
  1891. if (_this.props.onResize) {
  1892. _this.props.onResize(e);
  1893. }
  1894. };
  1895. _this.updateLineHeight = function () {
  1896. if (_this.textarea) {
  1897. _this.setState({
  1898. lineHeight: getLineHeight(_this.textarea)
  1899. });
  1900. }
  1901. };
  1902. _this.onChange = function (e) {
  1903. var onChange = _this.props.onChange;
  1904. _this.currentValue = e.currentTarget.value;
  1905. onChange && onChange(e);
  1906. };
  1907. return _this;
  1908. }
  1909. TextareaAutosizeClass.prototype.componentDidMount = function () {
  1910. var _this = this;
  1911. var _a = this.props, maxRows = _a.maxRows, async = _a.async;
  1912. if (typeof maxRows === "number") {
  1913. this.updateLineHeight();
  1914. }
  1915. if (typeof maxRows === "number" || async) {
  1916. /*
  1917. the defer is needed to:
  1918. - force "autosize" to activate the scrollbar when this.props.maxRows is passed
  1919. - support StyledComponents (see #71)
  1920. */
  1921. setTimeout(function () { return _this.textarea && autosize(_this.textarea); });
  1922. }
  1923. else {
  1924. this.textarea && autosize(this.textarea);
  1925. }
  1926. if (this.textarea) {
  1927. this.textarea.addEventListener(RESIZED, this.onResize);
  1928. }
  1929. };
  1930. TextareaAutosizeClass.prototype.componentWillUnmount = function () {
  1931. if (this.textarea) {
  1932. this.textarea.removeEventListener(RESIZED, this.onResize);
  1933. autosize.destroy(this.textarea);
  1934. }
  1935. };
  1936. TextareaAutosizeClass.prototype.render = function () {
  1937. var _this = this;
  1938. var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight;
  1939. var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
  1940. return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) {
  1941. _this.textarea = element;
  1942. if (typeof _this.props.innerRef === 'function') {
  1943. _this.props.innerRef(element);
  1944. }
  1945. else if (_this.props.innerRef) {
  1946. _this.props.innerRef.current = element;
  1947. }
  1948. } }), children));
  1949. };
  1950. TextareaAutosizeClass.prototype.componentDidUpdate = function () {
  1951. this.textarea && autosize.update(this.textarea);
  1952. };
  1953. TextareaAutosizeClass.defaultProps = {
  1954. rows: 1,
  1955. async: false
  1956. };
  1957. TextareaAutosizeClass.propTypes = {
  1958. rows: PropTypes.number,
  1959. maxRows: PropTypes.number,
  1960. onResize: PropTypes.func,
  1961. innerRef: PropTypes.any,
  1962. async: PropTypes.bool
  1963. };
  1964. return TextareaAutosizeClass;
  1965. }(React.Component));
  1966. exports.TextareaAutosize = React.forwardRef(function (props, ref) {
  1967. return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref }));
  1968. });
  1969. /***/ }),
  1970. /***/ 773:
  1971. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1972. "use strict";
  1973. var __webpack_unused_export__;
  1974. __webpack_unused_export__ = true;
  1975. var TextareaAutosize_1 = __webpack_require__(5438);
  1976. exports.Z = TextareaAutosize_1.TextareaAutosize;
  1977. /***/ }),
  1978. /***/ 4793:
  1979. /***/ (function(module) {
  1980. var characterMap = {
  1981. "À": "A",
  1982. "Á": "A",
  1983. "Â": "A",
  1984. "Ã": "A",
  1985. "Ä": "A",
  1986. "Å": "A",
  1987. "Ấ": "A",
  1988. "Ắ": "A",
  1989. "Ẳ": "A",
  1990. "Ẵ": "A",
  1991. "Ặ": "A",
  1992. "Æ": "AE",
  1993. "Ầ": "A",
  1994. "Ằ": "A",
  1995. "Ȃ": "A",
  1996. "Ç": "C",
  1997. "Ḉ": "C",
  1998. "È": "E",
  1999. "É": "E",
  2000. "Ê": "E",
  2001. "Ë": "E",
  2002. "Ế": "E",
  2003. "Ḗ": "E",
  2004. "Ề": "E",
  2005. "Ḕ": "E",
  2006. "Ḝ": "E",
  2007. "Ȇ": "E",
  2008. "Ì": "I",
  2009. "Í": "I",
  2010. "Î": "I",
  2011. "Ï": "I",
  2012. "Ḯ": "I",
  2013. "Ȋ": "I",
  2014. "Ð": "D",
  2015. "Ñ": "N",
  2016. "Ò": "O",
  2017. "Ó": "O",
  2018. "Ô": "O",
  2019. "Õ": "O",
  2020. "Ö": "O",
  2021. "Ø": "O",
  2022. "Ố": "O",
  2023. "Ṍ": "O",
  2024. "Ṓ": "O",
  2025. "Ȏ": "O",
  2026. "Ù": "U",
  2027. "Ú": "U",
  2028. "Û": "U",
  2029. "Ü": "U",
  2030. "Ý": "Y",
  2031. "à": "a",
  2032. "á": "a",
  2033. "â": "a",
  2034. "ã": "a",
  2035. "ä": "a",
  2036. "å": "a",
  2037. "ấ": "a",
  2038. "ắ": "a",
  2039. "ẳ": "a",
  2040. "ẵ": "a",
  2041. "ặ": "a",
  2042. "æ": "ae",
  2043. "ầ": "a",
  2044. "ằ": "a",
  2045. "ȃ": "a",
  2046. "ç": "c",
  2047. "ḉ": "c",
  2048. "è": "e",
  2049. "é": "e",
  2050. "ê": "e",
  2051. "ë": "e",
  2052. "ế": "e",
  2053. "ḗ": "e",
  2054. "ề": "e",
  2055. "ḕ": "e",
  2056. "ḝ": "e",
  2057. "ȇ": "e",
  2058. "ì": "i",
  2059. "í": "i",
  2060. "î": "i",
  2061. "ï": "i",
  2062. "ḯ": "i",
  2063. "ȋ": "i",
  2064. "ð": "d",
  2065. "ñ": "n",
  2066. "ò": "o",
  2067. "ó": "o",
  2068. "ô": "o",
  2069. "õ": "o",
  2070. "ö": "o",
  2071. "ø": "o",
  2072. "ố": "o",
  2073. "ṍ": "o",
  2074. "ṓ": "o",
  2075. "ȏ": "o",
  2076. "ù": "u",
  2077. "ú": "u",
  2078. "û": "u",
  2079. "ü": "u",
  2080. "ý": "y",
  2081. "ÿ": "y",
  2082. "Ā": "A",
  2083. "ā": "a",
  2084. "Ă": "A",
  2085. "ă": "a",
  2086. "Ą": "A",
  2087. "ą": "a",
  2088. "Ć": "C",
  2089. "ć": "c",
  2090. "Ĉ": "C",
  2091. "ĉ": "c",
  2092. "Ċ": "C",
  2093. "ċ": "c",
  2094. "Č": "C",
  2095. "č": "c",
  2096. "C̆": "C",
  2097. "c̆": "c",
  2098. "Ď": "D",
  2099. "ď": "d",
  2100. "Đ": "D",
  2101. "đ": "d",
  2102. "Ē": "E",
  2103. "ē": "e",
  2104. "Ĕ": "E",
  2105. "ĕ": "e",
  2106. "Ė": "E",
  2107. "ė": "e",
  2108. "Ę": "E",
  2109. "ę": "e",
  2110. "Ě": "E",
  2111. "ě": "e",
  2112. "Ĝ": "G",
  2113. "Ǵ": "G",
  2114. "ĝ": "g",
  2115. "ǵ": "g",
  2116. "Ğ": "G",
  2117. "ğ": "g",
  2118. "Ġ": "G",
  2119. "ġ": "g",
  2120. "Ģ": "G",
  2121. "ģ": "g",
  2122. "Ĥ": "H",
  2123. "ĥ": "h",
  2124. "Ħ": "H",
  2125. "ħ": "h",
  2126. "Ḫ": "H",
  2127. "ḫ": "h",
  2128. "Ĩ": "I",
  2129. "ĩ": "i",
  2130. "Ī": "I",
  2131. "ī": "i",
  2132. "Ĭ": "I",
  2133. "ĭ": "i",
  2134. "Į": "I",
  2135. "į": "i",
  2136. "İ": "I",
  2137. "ı": "i",
  2138. "IJ": "IJ",
  2139. "ij": "ij",
  2140. "Ĵ": "J",
  2141. "ĵ": "j",
  2142. "Ķ": "K",
  2143. "ķ": "k",
  2144. "Ḱ": "K",
  2145. "ḱ": "k",
  2146. "K̆": "K",
  2147. "k̆": "k",
  2148. "Ĺ": "L",
  2149. "ĺ": "l",
  2150. "Ļ": "L",
  2151. "ļ": "l",
  2152. "Ľ": "L",
  2153. "ľ": "l",
  2154. "Ŀ": "L",
  2155. "ŀ": "l",
  2156. "Ł": "l",
  2157. "ł": "l",
  2158. "Ḿ": "M",
  2159. "ḿ": "m",
  2160. "M̆": "M",
  2161. "m̆": "m",
  2162. "Ń": "N",
  2163. "ń": "n",
  2164. "Ņ": "N",
  2165. "ņ": "n",
  2166. "Ň": "N",
  2167. "ň": "n",
  2168. "ʼn": "n",
  2169. "N̆": "N",
  2170. "n̆": "n",
  2171. "Ō": "O",
  2172. "ō": "o",
  2173. "Ŏ": "O",
  2174. "ŏ": "o",
  2175. "Ő": "O",
  2176. "ő": "o",
  2177. "Œ": "OE",
  2178. "œ": "oe",
  2179. "P̆": "P",
  2180. "p̆": "p",
  2181. "Ŕ": "R",
  2182. "ŕ": "r",
  2183. "Ŗ": "R",
  2184. "ŗ": "r",
  2185. "Ř": "R",
  2186. "ř": "r",
  2187. "R̆": "R",
  2188. "r̆": "r",
  2189. "Ȓ": "R",
  2190. "ȓ": "r",
  2191. "Ś": "S",
  2192. "ś": "s",
  2193. "Ŝ": "S",
  2194. "ŝ": "s",
  2195. "Ş": "S",
  2196. "Ș": "S",
  2197. "ș": "s",
  2198. "ş": "s",
  2199. "Š": "S",
  2200. "š": "s",
  2201. "Ţ": "T",
  2202. "ţ": "t",
  2203. "ț": "t",
  2204. "Ț": "T",
  2205. "Ť": "T",
  2206. "ť": "t",
  2207. "Ŧ": "T",
  2208. "ŧ": "t",
  2209. "T̆": "T",
  2210. "t̆": "t",
  2211. "Ũ": "U",
  2212. "ũ": "u",
  2213. "Ū": "U",
  2214. "ū": "u",
  2215. "Ŭ": "U",
  2216. "ŭ": "u",
  2217. "Ů": "U",
  2218. "ů": "u",
  2219. "Ű": "U",
  2220. "ű": "u",
  2221. "Ų": "U",
  2222. "ų": "u",
  2223. "Ȗ": "U",
  2224. "ȗ": "u",
  2225. "V̆": "V",
  2226. "v̆": "v",
  2227. "Ŵ": "W",
  2228. "ŵ": "w",
  2229. "Ẃ": "W",
  2230. "ẃ": "w",
  2231. "X̆": "X",
  2232. "x̆": "x",
  2233. "Ŷ": "Y",
  2234. "ŷ": "y",
  2235. "Ÿ": "Y",
  2236. "Y̆": "Y",
  2237. "y̆": "y",
  2238. "Ź": "Z",
  2239. "ź": "z",
  2240. "Ż": "Z",
  2241. "ż": "z",
  2242. "Ž": "Z",
  2243. "ž": "z",
  2244. "ſ": "s",
  2245. "ƒ": "f",
  2246. "Ơ": "O",
  2247. "ơ": "o",
  2248. "Ư": "U",
  2249. "ư": "u",
  2250. "Ǎ": "A",
  2251. "ǎ": "a",
  2252. "Ǐ": "I",
  2253. "ǐ": "i",
  2254. "Ǒ": "O",
  2255. "ǒ": "o",
  2256. "Ǔ": "U",
  2257. "ǔ": "u",
  2258. "Ǖ": "U",
  2259. "ǖ": "u",
  2260. "Ǘ": "U",
  2261. "ǘ": "u",
  2262. "Ǚ": "U",
  2263. "ǚ": "u",
  2264. "Ǜ": "U",
  2265. "ǜ": "u",
  2266. "Ứ": "U",
  2267. "ứ": "u",
  2268. "Ṹ": "U",
  2269. "ṹ": "u",
  2270. "Ǻ": "A",
  2271. "ǻ": "a",
  2272. "Ǽ": "AE",
  2273. "ǽ": "ae",
  2274. "Ǿ": "O",
  2275. "ǿ": "o",
  2276. "Þ": "TH",
  2277. "þ": "th",
  2278. "Ṕ": "P",
  2279. "ṕ": "p",
  2280. "Ṥ": "S",
  2281. "ṥ": "s",
  2282. "X́": "X",
  2283. "x́": "x",
  2284. "Ѓ": "Г",
  2285. "ѓ": "г",
  2286. "Ќ": "К",
  2287. "ќ": "к",
  2288. "A̋": "A",
  2289. "a̋": "a",
  2290. "E̋": "E",
  2291. "e̋": "e",
  2292. "I̋": "I",
  2293. "i̋": "i",
  2294. "Ǹ": "N",
  2295. "ǹ": "n",
  2296. "Ồ": "O",
  2297. "ồ": "o",
  2298. "Ṑ": "O",
  2299. "ṑ": "o",
  2300. "Ừ": "U",
  2301. "ừ": "u",
  2302. "Ẁ": "W",
  2303. "ẁ": "w",
  2304. "Ỳ": "Y",
  2305. "ỳ": "y",
  2306. "Ȁ": "A",
  2307. "ȁ": "a",
  2308. "Ȅ": "E",
  2309. "ȅ": "e",
  2310. "Ȉ": "I",
  2311. "ȉ": "i",
  2312. "Ȍ": "O",
  2313. "ȍ": "o",
  2314. "Ȑ": "R",
  2315. "ȑ": "r",
  2316. "Ȕ": "U",
  2317. "ȕ": "u",
  2318. "B̌": "B",
  2319. "b̌": "b",
  2320. "Č̣": "C",
  2321. "č̣": "c",
  2322. "Ê̌": "E",
  2323. "ê̌": "e",
  2324. "F̌": "F",
  2325. "f̌": "f",
  2326. "Ǧ": "G",
  2327. "ǧ": "g",
  2328. "Ȟ": "H",
  2329. "ȟ": "h",
  2330. "J̌": "J",
  2331. "ǰ": "j",
  2332. "Ǩ": "K",
  2333. "ǩ": "k",
  2334. "M̌": "M",
  2335. "m̌": "m",
  2336. "P̌": "P",
  2337. "p̌": "p",
  2338. "Q̌": "Q",
  2339. "q̌": "q",
  2340. "Ř̩": "R",
  2341. "ř̩": "r",
  2342. "Ṧ": "S",
  2343. "ṧ": "s",
  2344. "V̌": "V",
  2345. "v̌": "v",
  2346. "W̌": "W",
  2347. "w̌": "w",
  2348. "X̌": "X",
  2349. "x̌": "x",
  2350. "Y̌": "Y",
  2351. "y̌": "y",
  2352. "A̧": "A",
  2353. "a̧": "a",
  2354. "B̧": "B",
  2355. "b̧": "b",
  2356. "Ḑ": "D",
  2357. "ḑ": "d",
  2358. "Ȩ": "E",
  2359. "ȩ": "e",
  2360. "Ɛ̧": "E",
  2361. "ɛ̧": "e",
  2362. "Ḩ": "H",
  2363. "ḩ": "h",
  2364. "I̧": "I",
  2365. "i̧": "i",
  2366. "Ɨ̧": "I",
  2367. "ɨ̧": "i",
  2368. "M̧": "M",
  2369. "m̧": "m",
  2370. "O̧": "O",
  2371. "o̧": "o",
  2372. "Q̧": "Q",
  2373. "q̧": "q",
  2374. "U̧": "U",
  2375. "u̧": "u",
  2376. "X̧": "X",
  2377. "x̧": "x",
  2378. "Z̧": "Z",
  2379. "z̧": "z",
  2380. };
  2381. var chars = Object.keys(characterMap).join('|');
  2382. var allAccents = new RegExp(chars, 'g');
  2383. var firstAccent = new RegExp(chars, '');
  2384. function matcher(match) {
  2385. return characterMap[match];
  2386. }
  2387. var removeAccents = function(string) {
  2388. return string.replace(allAccents, matcher);
  2389. };
  2390. var hasAccents = function(string) {
  2391. return !!string.match(firstAccent);
  2392. };
  2393. module.exports = removeAccents;
  2394. module.exports.has = hasAccents;
  2395. module.exports.remove = removeAccents;
  2396. /***/ }),
  2397. /***/ 3124:
  2398. /***/ (function(module) {
  2399. "use strict";
  2400. // TODO: use call-bind, is-date, is-regex, is-string, is-boolean-object, is-number-object
  2401. function toS(obj) { return Object.prototype.toString.call(obj); }
  2402. function isDate(obj) { return toS(obj) === '[object Date]'; }
  2403. function isRegExp(obj) { return toS(obj) === '[object RegExp]'; }
  2404. function isError(obj) { return toS(obj) === '[object Error]'; }
  2405. function isBoolean(obj) { return toS(obj) === '[object Boolean]'; }
  2406. function isNumber(obj) { return toS(obj) === '[object Number]'; }
  2407. function isString(obj) { return toS(obj) === '[object String]'; }
  2408. // TODO: use isarray
  2409. var isArray = Array.isArray || function isArray(xs) {
  2410. return Object.prototype.toString.call(xs) === '[object Array]';
  2411. };
  2412. // TODO: use for-each?
  2413. function forEach(xs, fn) {
  2414. if (xs.forEach) { return xs.forEach(fn); }
  2415. for (var i = 0; i < xs.length; i++) {
  2416. fn(xs[i], i, xs);
  2417. }
  2418. return void undefined;
  2419. }
  2420. // TODO: use object-keys
  2421. var objectKeys = Object.keys || function keys(obj) {
  2422. var res = [];
  2423. for (var key in obj) { res.push(key); } // eslint-disable-line no-restricted-syntax
  2424. return res;
  2425. };
  2426. // TODO: use object.hasown
  2427. var hasOwnProperty = Object.prototype.hasOwnProperty || function (obj, key) {
  2428. return key in obj;
  2429. };
  2430. function copy(src) {
  2431. if (typeof src === 'object' && src !== null) {
  2432. var dst;
  2433. if (isArray(src)) {
  2434. dst = [];
  2435. } else if (isDate(src)) {
  2436. dst = new Date(src.getTime ? src.getTime() : src);
  2437. } else if (isRegExp(src)) {
  2438. dst = new RegExp(src);
  2439. } else if (isError(src)) {
  2440. dst = { message: src.message };
  2441. } else if (isBoolean(src) || isNumber(src) || isString(src)) {
  2442. dst = Object(src);
  2443. } else if (Object.create && Object.getPrototypeOf) {
  2444. dst = Object.create(Object.getPrototypeOf(src));
  2445. } else if (src.constructor === Object) {
  2446. dst = {};
  2447. } else {
  2448. var proto = (src.constructor && src.constructor.prototype)
  2449. || src.__proto__
  2450. || {};
  2451. var T = function T() {}; // eslint-disable-line func-style, func-name-matching
  2452. T.prototype = proto;
  2453. dst = new T();
  2454. }
  2455. forEach(objectKeys(src), function (key) {
  2456. dst[key] = src[key];
  2457. });
  2458. return dst;
  2459. }
  2460. return src;
  2461. }
  2462. function walk(root, cb, immutable) {
  2463. var path = [];
  2464. var parents = [];
  2465. var alive = true;
  2466. return (function walker(node_) {
  2467. var node = immutable ? copy(node_) : node_;
  2468. var modifiers = {};
  2469. var keepGoing = true;
  2470. var state = {
  2471. node: node,
  2472. node_: node_,
  2473. path: [].concat(path),
  2474. parent: parents[parents.length - 1],
  2475. parents: parents,
  2476. key: path[path.length - 1],
  2477. isRoot: path.length === 0,
  2478. level: path.length,
  2479. circular: null,
  2480. update: function (x, stopHere) {
  2481. if (!state.isRoot) {
  2482. state.parent.node[state.key] = x;
  2483. }
  2484. state.node = x;
  2485. if (stopHere) { keepGoing = false; }
  2486. },
  2487. delete: function (stopHere) {
  2488. delete state.parent.node[state.key];
  2489. if (stopHere) { keepGoing = false; }
  2490. },
  2491. remove: function (stopHere) {
  2492. if (isArray(state.parent.node)) {
  2493. state.parent.node.splice(state.key, 1);
  2494. } else {
  2495. delete state.parent.node[state.key];
  2496. }
  2497. if (stopHere) { keepGoing = false; }
  2498. },
  2499. keys: null,
  2500. before: function (f) { modifiers.before = f; },
  2501. after: function (f) { modifiers.after = f; },
  2502. pre: function (f) { modifiers.pre = f; },
  2503. post: function (f) { modifiers.post = f; },
  2504. stop: function () { alive = false; },
  2505. block: function () { keepGoing = false; },
  2506. };
  2507. if (!alive) { return state; }
  2508. function updateState() {
  2509. if (typeof state.node === 'object' && state.node !== null) {
  2510. if (!state.keys || state.node_ !== state.node) {
  2511. state.keys = objectKeys(state.node);
  2512. }
  2513. state.isLeaf = state.keys.length === 0;
  2514. for (var i = 0; i < parents.length; i++) {
  2515. if (parents[i].node_ === node_) {
  2516. state.circular = parents[i];
  2517. break; // eslint-disable-line no-restricted-syntax
  2518. }
  2519. }
  2520. } else {
  2521. state.isLeaf = true;
  2522. state.keys = null;
  2523. }
  2524. state.notLeaf = !state.isLeaf;
  2525. state.notRoot = !state.isRoot;
  2526. }
  2527. updateState();
  2528. // use return values to update if defined
  2529. var ret = cb.call(state, state.node);
  2530. if (ret !== undefined && state.update) { state.update(ret); }
  2531. if (modifiers.before) { modifiers.before.call(state, state.node); }
  2532. if (!keepGoing) { return state; }
  2533. if (
  2534. typeof state.node === 'object'
  2535. && state.node !== null
  2536. && !state.circular
  2537. ) {
  2538. parents.push(state);
  2539. updateState();
  2540. forEach(state.keys, function (key, i) {
  2541. path.push(key);
  2542. if (modifiers.pre) { modifiers.pre.call(state, state.node[key], key); }
  2543. var child = walker(state.node[key]);
  2544. if (immutable && hasOwnProperty.call(state.node, key)) {
  2545. state.node[key] = child.node;
  2546. }
  2547. child.isLast = i === state.keys.length - 1;
  2548. child.isFirst = i === 0;
  2549. if (modifiers.post) { modifiers.post.call(state, child); }
  2550. path.pop();
  2551. });
  2552. parents.pop();
  2553. }
  2554. if (modifiers.after) { modifiers.after.call(state, state.node); }
  2555. return state;
  2556. }(root)).node;
  2557. }
  2558. function Traverse(obj) {
  2559. this.value = obj;
  2560. }
  2561. Traverse.prototype.get = function (ps) {
  2562. var node = this.value;
  2563. for (var i = 0; i < ps.length; i++) {
  2564. var key = ps[i];
  2565. if (!node || !hasOwnProperty.call(node, key)) {
  2566. return void undefined;
  2567. }
  2568. node = node[key];
  2569. }
  2570. return node;
  2571. };
  2572. Traverse.prototype.has = function (ps) {
  2573. var node = this.value;
  2574. for (var i = 0; i < ps.length; i++) {
  2575. var key = ps[i];
  2576. if (!node || !hasOwnProperty.call(node, key)) {
  2577. return false;
  2578. }
  2579. node = node[key];
  2580. }
  2581. return true;
  2582. };
  2583. Traverse.prototype.set = function (ps, value) {
  2584. var node = this.value;
  2585. for (var i = 0; i < ps.length - 1; i++) {
  2586. var key = ps[i];
  2587. if (!hasOwnProperty.call(node, key)) { node[key] = {}; }
  2588. node = node[key];
  2589. }
  2590. node[ps[i]] = value;
  2591. return value;
  2592. };
  2593. Traverse.prototype.map = function (cb) {
  2594. return walk(this.value, cb, true);
  2595. };
  2596. Traverse.prototype.forEach = function (cb) {
  2597. this.value = walk(this.value, cb, false);
  2598. return this.value;
  2599. };
  2600. Traverse.prototype.reduce = function (cb, init) {
  2601. var skip = arguments.length === 1;
  2602. var acc = skip ? this.value : init;
  2603. this.forEach(function (x) {
  2604. if (!this.isRoot || !skip) {
  2605. acc = cb.call(this, acc, x);
  2606. }
  2607. });
  2608. return acc;
  2609. };
  2610. Traverse.prototype.paths = function () {
  2611. var acc = [];
  2612. this.forEach(function () {
  2613. acc.push(this.path);
  2614. });
  2615. return acc;
  2616. };
  2617. Traverse.prototype.nodes = function () {
  2618. var acc = [];
  2619. this.forEach(function () {
  2620. acc.push(this.node);
  2621. });
  2622. return acc;
  2623. };
  2624. Traverse.prototype.clone = function () {
  2625. var parents = [];
  2626. var nodes = [];
  2627. return (function clone(src) {
  2628. for (var i = 0; i < parents.length; i++) {
  2629. if (parents[i] === src) {
  2630. return nodes[i];
  2631. }
  2632. }
  2633. if (typeof src === 'object' && src !== null) {
  2634. var dst = copy(src);
  2635. parents.push(src);
  2636. nodes.push(dst);
  2637. forEach(objectKeys(src), function (key) {
  2638. dst[key] = clone(src[key]);
  2639. });
  2640. parents.pop();
  2641. nodes.pop();
  2642. return dst;
  2643. }
  2644. return src;
  2645. }(this.value));
  2646. };
  2647. function traverse(obj) {
  2648. return new Traverse(obj);
  2649. }
  2650. // TODO: replace with object.assign?
  2651. forEach(objectKeys(Traverse.prototype), function (key) {
  2652. traverse[key] = function (obj) {
  2653. var args = [].slice.call(arguments, 1);
  2654. var t = new Traverse(obj);
  2655. return t[key].apply(t, args);
  2656. };
  2657. });
  2658. module.exports = traverse;
  2659. /***/ }),
  2660. /***/ 9196:
  2661. /***/ (function(module) {
  2662. "use strict";
  2663. module.exports = window["React"];
  2664. /***/ })
  2665. /******/ });
  2666. /************************************************************************/
  2667. /******/ // The module cache
  2668. /******/ var __webpack_module_cache__ = {};
  2669. /******/
  2670. /******/ // The require function
  2671. /******/ function __webpack_require__(moduleId) {
  2672. /******/ // Check if module is in cache
  2673. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  2674. /******/ if (cachedModule !== undefined) {
  2675. /******/ return cachedModule.exports;
  2676. /******/ }
  2677. /******/ // Create a new module (and put it into the cache)
  2678. /******/ var module = __webpack_module_cache__[moduleId] = {
  2679. /******/ // no module.id needed
  2680. /******/ // no module.loaded needed
  2681. /******/ exports: {}
  2682. /******/ };
  2683. /******/
  2684. /******/ // Execute the module function
  2685. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  2686. /******/
  2687. /******/ // Return the exports of the module
  2688. /******/ return module.exports;
  2689. /******/ }
  2690. /******/
  2691. /************************************************************************/
  2692. /******/ /* webpack/runtime/compat get default export */
  2693. /******/ !function() {
  2694. /******/ // getDefaultExport function for compatibility with non-harmony modules
  2695. /******/ __webpack_require__.n = function(module) {
  2696. /******/ var getter = module && module.__esModule ?
  2697. /******/ function() { return module['default']; } :
  2698. /******/ function() { return module; };
  2699. /******/ __webpack_require__.d(getter, { a: getter });
  2700. /******/ return getter;
  2701. /******/ };
  2702. /******/ }();
  2703. /******/
  2704. /******/ /* webpack/runtime/define property getters */
  2705. /******/ !function() {
  2706. /******/ // define getter functions for harmony exports
  2707. /******/ __webpack_require__.d = function(exports, definition) {
  2708. /******/ for(var key in definition) {
  2709. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  2710. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  2711. /******/ }
  2712. /******/ }
  2713. /******/ };
  2714. /******/ }();
  2715. /******/
  2716. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  2717. /******/ !function() {
  2718. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  2719. /******/ }();
  2720. /******/
  2721. /******/ /* webpack/runtime/make namespace object */
  2722. /******/ !function() {
  2723. /******/ // define __esModule on exports
  2724. /******/ __webpack_require__.r = function(exports) {
  2725. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  2726. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  2727. /******/ }
  2728. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  2729. /******/ };
  2730. /******/ }();
  2731. /******/
  2732. /************************************************************************/
  2733. var __webpack_exports__ = {};
  2734. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  2735. !function() {
  2736. "use strict";
  2737. // ESM COMPAT FLAG
  2738. __webpack_require__.r(__webpack_exports__);
  2739. // EXPORTS
  2740. __webpack_require__.d(__webpack_exports__, {
  2741. "AlignmentControl": function() { return /* reexport */ AlignmentControl; },
  2742. "AlignmentToolbar": function() { return /* reexport */ AlignmentToolbar; },
  2743. "Autocomplete": function() { return /* reexport */ autocomplete; },
  2744. "BlockAlignmentControl": function() { return /* reexport */ BlockAlignmentControl; },
  2745. "BlockAlignmentToolbar": function() { return /* reexport */ BlockAlignmentToolbar; },
  2746. "BlockBreadcrumb": function() { return /* reexport */ block_breadcrumb; },
  2747. "BlockColorsStyleSelector": function() { return /* reexport */ color_style_selector; },
  2748. "BlockContextProvider": function() { return /* reexport */ BlockContextProvider; },
  2749. "BlockControls": function() { return /* reexport */ block_controls; },
  2750. "BlockEdit": function() { return /* reexport */ BlockEdit; },
  2751. "BlockEditorKeyboardShortcuts": function() { return /* reexport */ keyboard_shortcuts; },
  2752. "BlockEditorProvider": function() { return /* reexport */ provider; },
  2753. "BlockFormatControls": function() { return /* reexport */ BlockFormatControls; },
  2754. "BlockIcon": function() { return /* reexport */ block_icon; },
  2755. "BlockInspector": function() { return /* reexport */ block_inspector; },
  2756. "BlockList": function() { return /* reexport */ BlockList; },
  2757. "BlockMover": function() { return /* reexport */ block_mover; },
  2758. "BlockNavigationDropdown": function() { return /* reexport */ dropdown; },
  2759. "BlockPreview": function() { return /* reexport */ block_preview; },
  2760. "BlockSelectionClearer": function() { return /* reexport */ BlockSelectionClearer; },
  2761. "BlockSettingsMenu": function() { return /* reexport */ block_settings_menu; },
  2762. "BlockSettingsMenuControls": function() { return /* reexport */ block_settings_menu_controls; },
  2763. "BlockStyles": function() { return /* reexport */ block_styles; },
  2764. "BlockTitle": function() { return /* reexport */ BlockTitle; },
  2765. "BlockToolbar": function() { return /* reexport */ block_toolbar; },
  2766. "BlockTools": function() { return /* reexport */ BlockTools; },
  2767. "BlockVerticalAlignmentControl": function() { return /* reexport */ BlockVerticalAlignmentControl; },
  2768. "BlockVerticalAlignmentToolbar": function() { return /* reexport */ BlockVerticalAlignmentToolbar; },
  2769. "ButtonBlockAppender": function() { return /* reexport */ button_block_appender; },
  2770. "ButtonBlockerAppender": function() { return /* reexport */ ButtonBlockerAppender; },
  2771. "ColorPalette": function() { return /* reexport */ color_palette; },
  2772. "ColorPaletteControl": function() { return /* reexport */ ColorPaletteControl; },
  2773. "ContrastChecker": function() { return /* reexport */ contrast_checker; },
  2774. "CopyHandler": function() { return /* reexport */ copy_handler; },
  2775. "DefaultBlockAppender": function() { return /* reexport */ default_block_appender; },
  2776. "FontSizePicker": function() { return /* reexport */ font_size_picker; },
  2777. "InnerBlocks": function() { return /* reexport */ inner_blocks; },
  2778. "Inserter": function() { return /* reexport */ inserter; },
  2779. "InspectorAdvancedControls": function() { return /* reexport */ InspectorAdvancedControls; },
  2780. "InspectorControls": function() { return /* reexport */ inspector_controls; },
  2781. "JustifyContentControl": function() { return /* reexport */ JustifyContentControl; },
  2782. "JustifyToolbar": function() { return /* reexport */ JustifyToolbar; },
  2783. "LineHeightControl": function() { return /* reexport */ line_height_control; },
  2784. "MediaPlaceholder": function() { return /* reexport */ media_placeholder; },
  2785. "MediaReplaceFlow": function() { return /* reexport */ media_replace_flow; },
  2786. "MediaUpload": function() { return /* reexport */ media_upload; },
  2787. "MediaUploadCheck": function() { return /* reexport */ media_upload_check; },
  2788. "MultiSelectScrollIntoView": function() { return /* reexport */ MultiSelectScrollIntoView; },
  2789. "NavigableToolbar": function() { return /* reexport */ navigable_toolbar; },
  2790. "ObserveTyping": function() { return /* reexport */ observe_typing; },
  2791. "PanelColorSettings": function() { return /* reexport */ panel_color_settings; },
  2792. "PlainText": function() { return /* reexport */ plain_text; },
  2793. "RichText": function() { return /* reexport */ rich_text; },
  2794. "RichTextShortcut": function() { return /* reexport */ RichTextShortcut; },
  2795. "RichTextToolbarButton": function() { return /* reexport */ RichTextToolbarButton; },
  2796. "SETTINGS_DEFAULTS": function() { return /* reexport */ SETTINGS_DEFAULTS; },
  2797. "SkipToSelectedBlock": function() { return /* reexport */ skip_to_selected_block; },
  2798. "ToolSelector": function() { return /* reexport */ tool_selector; },
  2799. "Typewriter": function() { return /* reexport */ typewriter; },
  2800. "URLInput": function() { return /* reexport */ url_input; },
  2801. "URLInputButton": function() { return /* reexport */ url_input_button; },
  2802. "URLPopover": function() { return /* reexport */ url_popover; },
  2803. "Warning": function() { return /* reexport */ warning; },
  2804. "WritingFlow": function() { return /* reexport */ writing_flow; },
  2805. "__experimentalBlockAlignmentMatrixControl": function() { return /* reexport */ block_alignment_matrix_control; },
  2806. "__experimentalBlockFullHeightAligmentControl": function() { return /* reexport */ block_full_height_alignment_control; },
  2807. "__experimentalBlockPatternSetup": function() { return /* reexport */ block_pattern_setup; },
  2808. "__experimentalBlockPatternsList": function() { return /* reexport */ block_patterns_list; },
  2809. "__experimentalBlockVariationPicker": function() { return /* reexport */ block_variation_picker; },
  2810. "__experimentalBlockVariationTransforms": function() { return /* reexport */ block_variation_transforms; },
  2811. "__experimentalBorderRadiusControl": function() { return /* reexport */ BorderRadiusControl; },
  2812. "__experimentalColorGradientControl": function() { return /* reexport */ control; },
  2813. "__experimentalColorGradientSettingsDropdown": function() { return /* reexport */ ColorGradientSettingsDropdown; },
  2814. "__experimentalDateFormatPicker": function() { return /* reexport */ DateFormatPicker; },
  2815. "__experimentalDuotoneControl": function() { return /* reexport */ duotone_control; },
  2816. "__experimentalFontAppearanceControl": function() { return /* reexport */ FontAppearanceControl; },
  2817. "__experimentalFontFamilyControl": function() { return /* reexport */ FontFamilyControl; },
  2818. "__experimentalGetBorderClassesAndStyles": function() { return /* reexport */ getBorderClassesAndStyles; },
  2819. "__experimentalGetColorClassesAndStyles": function() { return /* reexport */ getColorClassesAndStyles; },
  2820. "__experimentalGetElementClassName": function() { return /* reexport */ __experimentalGetElementClassName; },
  2821. "__experimentalGetGapCSSValue": function() { return /* reexport */ getGapCSSValue; },
  2822. "__experimentalGetGradientClass": function() { return /* reexport */ __experimentalGetGradientClass; },
  2823. "__experimentalGetGradientObjectByGradientValue": function() { return /* reexport */ __experimentalGetGradientObjectByGradientValue; },
  2824. "__experimentalGetMatchingVariation": function() { return /* reexport */ __experimentalGetMatchingVariation; },
  2825. "__experimentalGetSpacingClassesAndStyles": function() { return /* reexport */ getSpacingClassesAndStyles; },
  2826. "__experimentalImageEditingProvider": function() { return /* reexport */ ImageEditingProvider; },
  2827. "__experimentalImageEditor": function() { return /* reexport */ ImageEditor; },
  2828. "__experimentalImageSizeControl": function() { return /* reexport */ ImageSizeControl; },
  2829. "__experimentalImageURLInputUI": function() { return /* reexport */ ImageURLInputUI; },
  2830. "__experimentalInspectorPopoverHeader": function() { return /* reexport */ InspectorPopoverHeader; },
  2831. "__experimentalLayoutStyle": function() { return /* reexport */ LayoutStyle; },
  2832. "__experimentalLetterSpacingControl": function() { return /* reexport */ LetterSpacingControl; },
  2833. "__experimentalLibrary": function() { return /* reexport */ library; },
  2834. "__experimentalLinkControl": function() { return /* reexport */ link_control; },
  2835. "__experimentalLinkControlSearchInput": function() { return /* reexport */ search_input; },
  2836. "__experimentalLinkControlSearchItem": function() { return /* reexport */ search_item; },
  2837. "__experimentalLinkControlSearchResults": function() { return /* reexport */ LinkControlSearchResults; },
  2838. "__experimentalListView": function() { return /* reexport */ components_list_view; },
  2839. "__experimentalPanelColorGradientSettings": function() { return /* reexport */ panel_color_gradient_settings; },
  2840. "__experimentalPreviewOptions": function() { return /* reexport */ PreviewOptions; },
  2841. "__experimentalPublishDateTimePicker": function() { return /* reexport */ publish_date_time_picker; },
  2842. "__experimentalRecursionProvider": function() { return /* reexport */ RecursionProvider; },
  2843. "__experimentalResponsiveBlockControl": function() { return /* reexport */ responsive_block_control; },
  2844. "__experimentalSpacingSizesControl": function() { return /* reexport */ SpacingSizesControl; },
  2845. "__experimentalTextDecorationControl": function() { return /* reexport */ TextDecorationControl; },
  2846. "__experimentalTextTransformControl": function() { return /* reexport */ TextTransformControl; },
  2847. "__experimentalUnitControl": function() { return /* reexport */ UnitControl; },
  2848. "__experimentalUseBlockOverlayActive": function() { return /* reexport */ useBlockOverlayActive; },
  2849. "__experimentalUseBlockPreview": function() { return /* reexport */ useBlockPreview; },
  2850. "__experimentalUseBorderProps": function() { return /* reexport */ useBorderProps; },
  2851. "__experimentalUseColorProps": function() { return /* reexport */ useColorProps; },
  2852. "__experimentalUseCustomSides": function() { return /* reexport */ useCustomSides; },
  2853. "__experimentalUseGradient": function() { return /* reexport */ __experimentalUseGradient; },
  2854. "__experimentalUseHasRecursion": function() { return /* reexport */ useHasRecursion; },
  2855. "__experimentalUseMultipleOriginColorsAndGradients": function() { return /* reexport */ useMultipleOriginColorsAndGradients; },
  2856. "__experimentalUseResizeCanvas": function() { return /* reexport */ useResizeCanvas; },
  2857. "__experimentaluseLayoutClasses": function() { return /* reexport */ useLayoutClasses; },
  2858. "__experimentaluseLayoutStyles": function() { return /* reexport */ useLayoutStyles; },
  2859. "__unstableBlockNameContext": function() { return /* reexport */ block_name_context; },
  2860. "__unstableBlockSettingsMenuFirstItem": function() { return /* reexport */ block_settings_menu_first_item; },
  2861. "__unstableBlockToolbarLastItem": function() { return /* reexport */ block_toolbar_last_item; },
  2862. "__unstableDuotoneFilter": function() { return /* reexport */ DuotoneFilter; },
  2863. "__unstableDuotoneStylesheet": function() { return /* reexport */ DuotoneStylesheet; },
  2864. "__unstableDuotoneUnsetStylesheet": function() { return /* reexport */ DuotoneUnsetStylesheet; },
  2865. "__unstableEditorStyles": function() { return /* reexport */ EditorStyles; },
  2866. "__unstableGetValuesFromColors": function() { return /* reexport */ getValuesFromColors; },
  2867. "__unstableIframe": function() { return /* reexport */ iframe; },
  2868. "__unstableInserterMenuExtension": function() { return /* reexport */ inserter_menu_extension; },
  2869. "__unstablePresetDuotoneFilter": function() { return /* reexport */ PresetDuotoneFilter; },
  2870. "__unstableRichTextInputEvent": function() { return /* reexport */ __unstableRichTextInputEvent; },
  2871. "__unstableUseBlockSelectionClearer": function() { return /* reexport */ useBlockSelectionClearer; },
  2872. "__unstableUseClipboardHandler": function() { return /* reexport */ useClipboardHandler; },
  2873. "__unstableUseMouseMoveTypingReset": function() { return /* reexport */ useMouseMoveTypingReset; },
  2874. "__unstableUseTypewriter": function() { return /* reexport */ useTypewriter; },
  2875. "__unstableUseTypingObserver": function() { return /* reexport */ useTypingObserver; },
  2876. "createCustomColorsHOC": function() { return /* reexport */ createCustomColorsHOC; },
  2877. "getColorClassName": function() { return /* reexport */ getColorClassName; },
  2878. "getColorObjectByAttributeValues": function() { return /* reexport */ getColorObjectByAttributeValues; },
  2879. "getColorObjectByColorValue": function() { return /* reexport */ getColorObjectByColorValue; },
  2880. "getComputedFluidTypographyValue": function() { return /* reexport */ getComputedFluidTypographyValue; },
  2881. "getFontSize": function() { return /* reexport */ getFontSize; },
  2882. "getFontSizeClass": function() { return /* reexport */ getFontSizeClass; },
  2883. "getFontSizeObjectByValue": function() { return /* reexport */ getFontSizeObjectByValue; },
  2884. "getGradientSlugByValue": function() { return /* reexport */ getGradientSlugByValue; },
  2885. "getGradientValueBySlug": function() { return /* reexport */ getGradientValueBySlug; },
  2886. "getPxFromCssUnit": function() { return /* reexport */ parse_css_unit_to_px; },
  2887. "getTypographyClassesAndStyles": function() { return /* reexport */ getTypographyClassesAndStyles; },
  2888. "store": function() { return /* reexport */ store; },
  2889. "storeConfig": function() { return /* reexport */ storeConfig; },
  2890. "transformStyles": function() { return /* reexport */ transform_styles; },
  2891. "useBlockDisplayInformation": function() { return /* reexport */ useBlockDisplayInformation; },
  2892. "useBlockEditContext": function() { return /* reexport */ useBlockEditContext; },
  2893. "useBlockProps": function() { return /* reexport */ useBlockProps; },
  2894. "useCachedTruthy": function() { return /* reexport */ useCachedTruthy; },
  2895. "useInnerBlocksProps": function() { return /* reexport */ useInnerBlocksProps; },
  2896. "useSetting": function() { return /* reexport */ useSetting; },
  2897. "withColorContext": function() { return /* reexport */ with_color_context; },
  2898. "withColors": function() { return /* reexport */ withColors; },
  2899. "withFontSizes": function() { return /* reexport */ with_font_sizes; }
  2900. });
  2901. // NAMESPACE OBJECT: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js
  2902. var selectors_namespaceObject = {};
  2903. __webpack_require__.r(selectors_namespaceObject);
  2904. __webpack_require__.d(selectors_namespaceObject, {
  2905. "__experimentalGetActiveBlockIdByBlockNames": function() { return __experimentalGetActiveBlockIdByBlockNames; },
  2906. "__experimentalGetAllowedBlocks": function() { return __experimentalGetAllowedBlocks; },
  2907. "__experimentalGetAllowedPatterns": function() { return __experimentalGetAllowedPatterns; },
  2908. "__experimentalGetBlockListSettingsForBlocks": function() { return __experimentalGetBlockListSettingsForBlocks; },
  2909. "__experimentalGetDirectInsertBlock": function() { return __experimentalGetDirectInsertBlock; },
  2910. "__experimentalGetGlobalBlocksByName": function() { return __experimentalGetGlobalBlocksByName; },
  2911. "__experimentalGetLastBlockAttributeChanges": function() { return __experimentalGetLastBlockAttributeChanges; },
  2912. "__experimentalGetParsedPattern": function() { return __experimentalGetParsedPattern; },
  2913. "__experimentalGetPatternTransformItems": function() { return __experimentalGetPatternTransformItems; },
  2914. "__experimentalGetPatternsByBlockTypes": function() { return __experimentalGetPatternsByBlockTypes; },
  2915. "__experimentalGetReusableBlockTitle": function() { return __experimentalGetReusableBlockTitle; },
  2916. "__unstableGetBlockWithoutInnerBlocks": function() { return __unstableGetBlockWithoutInnerBlocks; },
  2917. "__unstableGetClientIdWithClientIdsTree": function() { return __unstableGetClientIdWithClientIdsTree; },
  2918. "__unstableGetClientIdsTree": function() { return __unstableGetClientIdsTree; },
  2919. "__unstableGetContentLockingParent": function() { return __unstableGetContentLockingParent; },
  2920. "__unstableGetEditorMode": function() { return __unstableGetEditorMode; },
  2921. "__unstableGetSelectedBlocksWithPartialSelection": function() { return __unstableGetSelectedBlocksWithPartialSelection; },
  2922. "__unstableGetTemporarilyEditingAsBlocks": function() { return __unstableGetTemporarilyEditingAsBlocks; },
  2923. "__unstableGetVisibleBlocks": function() { return __unstableGetVisibleBlocks; },
  2924. "__unstableHasActiveBlockOverlayActive": function() { return __unstableHasActiveBlockOverlayActive; },
  2925. "__unstableIsFullySelected": function() { return __unstableIsFullySelected; },
  2926. "__unstableIsLastBlockChangeIgnored": function() { return __unstableIsLastBlockChangeIgnored; },
  2927. "__unstableIsSelectionCollapsed": function() { return __unstableIsSelectionCollapsed; },
  2928. "__unstableIsSelectionMergeable": function() { return __unstableIsSelectionMergeable; },
  2929. "__unstableIsWithinBlockOverlay": function() { return __unstableIsWithinBlockOverlay; },
  2930. "__unstableSelectionHasUnmergeableBlock": function() { return __unstableSelectionHasUnmergeableBlock; },
  2931. "areInnerBlocksControlled": function() { return areInnerBlocksControlled; },
  2932. "canEditBlock": function() { return canEditBlock; },
  2933. "canInsertBlockType": function() { return canInsertBlockType; },
  2934. "canInsertBlocks": function() { return canInsertBlocks; },
  2935. "canLockBlockType": function() { return canLockBlockType; },
  2936. "canMoveBlock": function() { return canMoveBlock; },
  2937. "canMoveBlocks": function() { return canMoveBlocks; },
  2938. "canRemoveBlock": function() { return canRemoveBlock; },
  2939. "canRemoveBlocks": function() { return canRemoveBlocks; },
  2940. "didAutomaticChange": function() { return didAutomaticChange; },
  2941. "getAdjacentBlockClientId": function() { return getAdjacentBlockClientId; },
  2942. "getBlock": function() { return getBlock; },
  2943. "getBlockAttributes": function() { return getBlockAttributes; },
  2944. "getBlockCount": function() { return getBlockCount; },
  2945. "getBlockHierarchyRootClientId": function() { return getBlockHierarchyRootClientId; },
  2946. "getBlockIndex": function() { return getBlockIndex; },
  2947. "getBlockInsertionPoint": function() { return getBlockInsertionPoint; },
  2948. "getBlockListSettings": function() { return getBlockListSettings; },
  2949. "getBlockMode": function() { return getBlockMode; },
  2950. "getBlockName": function() { return getBlockName; },
  2951. "getBlockOrder": function() { return getBlockOrder; },
  2952. "getBlockParents": function() { return getBlockParents; },
  2953. "getBlockParentsByBlockName": function() { return getBlockParentsByBlockName; },
  2954. "getBlockRootClientId": function() { return getBlockRootClientId; },
  2955. "getBlockSelectionEnd": function() { return getBlockSelectionEnd; },
  2956. "getBlockSelectionStart": function() { return getBlockSelectionStart; },
  2957. "getBlockTransformItems": function() { return getBlockTransformItems; },
  2958. "getBlocks": function() { return getBlocks; },
  2959. "getBlocksByClientId": function() { return getBlocksByClientId; },
  2960. "getClientIdsOfDescendants": function() { return getClientIdsOfDescendants; },
  2961. "getClientIdsWithDescendants": function() { return getClientIdsWithDescendants; },
  2962. "getDraggedBlockClientIds": function() { return getDraggedBlockClientIds; },
  2963. "getFirstMultiSelectedBlockClientId": function() { return getFirstMultiSelectedBlockClientId; },
  2964. "getGlobalBlockCount": function() { return getGlobalBlockCount; },
  2965. "getInserterItems": function() { return getInserterItems; },
  2966. "getLastMultiSelectedBlockClientId": function() { return getLastMultiSelectedBlockClientId; },
  2967. "getLowestCommonAncestorWithSelectedBlock": function() { return getLowestCommonAncestorWithSelectedBlock; },
  2968. "getMultiSelectedBlockClientIds": function() { return getMultiSelectedBlockClientIds; },
  2969. "getMultiSelectedBlocks": function() { return getMultiSelectedBlocks; },
  2970. "getMultiSelectedBlocksEndClientId": function() { return getMultiSelectedBlocksEndClientId; },
  2971. "getMultiSelectedBlocksStartClientId": function() { return getMultiSelectedBlocksStartClientId; },
  2972. "getNextBlockClientId": function() { return getNextBlockClientId; },
  2973. "getPreviousBlockClientId": function() { return getPreviousBlockClientId; },
  2974. "getSelectedBlock": function() { return getSelectedBlock; },
  2975. "getSelectedBlockClientId": function() { return getSelectedBlockClientId; },
  2976. "getSelectedBlockClientIds": function() { return getSelectedBlockClientIds; },
  2977. "getSelectedBlockCount": function() { return getSelectedBlockCount; },
  2978. "getSelectedBlocksInitialCaretPosition": function() { return getSelectedBlocksInitialCaretPosition; },
  2979. "getSelectionEnd": function() { return getSelectionEnd; },
  2980. "getSelectionStart": function() { return getSelectionStart; },
  2981. "getSettings": function() { return getSettings; },
  2982. "getTemplate": function() { return getTemplate; },
  2983. "getTemplateLock": function() { return getTemplateLock; },
  2984. "hasBlockMovingClientId": function() { return selectors_hasBlockMovingClientId; },
  2985. "hasInserterItems": function() { return hasInserterItems; },
  2986. "hasMultiSelection": function() { return hasMultiSelection; },
  2987. "hasSelectedBlock": function() { return hasSelectedBlock; },
  2988. "hasSelectedInnerBlock": function() { return hasSelectedInnerBlock; },
  2989. "isAncestorBeingDragged": function() { return isAncestorBeingDragged; },
  2990. "isAncestorMultiSelected": function() { return isAncestorMultiSelected; },
  2991. "isBlockBeingDragged": function() { return isBlockBeingDragged; },
  2992. "isBlockHighlighted": function() { return isBlockHighlighted; },
  2993. "isBlockInsertionPointVisible": function() { return isBlockInsertionPointVisible; },
  2994. "isBlockMultiSelected": function() { return isBlockMultiSelected; },
  2995. "isBlockSelected": function() { return isBlockSelected; },
  2996. "isBlockValid": function() { return isBlockValid; },
  2997. "isBlockVisible": function() { return isBlockVisible; },
  2998. "isBlockWithinSelection": function() { return isBlockWithinSelection; },
  2999. "isCaretWithinFormattedText": function() { return isCaretWithinFormattedText; },
  3000. "isDraggingBlocks": function() { return isDraggingBlocks; },
  3001. "isFirstMultiSelectedBlock": function() { return isFirstMultiSelectedBlock; },
  3002. "isLastBlockChangePersistent": function() { return isLastBlockChangePersistent; },
  3003. "isMultiSelecting": function() { return selectors_isMultiSelecting; },
  3004. "isNavigationMode": function() { return isNavigationMode; },
  3005. "isSelectionEnabled": function() { return selectors_isSelectionEnabled; },
  3006. "isTyping": function() { return selectors_isTyping; },
  3007. "isValidTemplate": function() { return isValidTemplate; },
  3008. "wasBlockJustInserted": function() { return wasBlockJustInserted; }
  3009. });
  3010. // NAMESPACE OBJECT: ./node_modules/@wordpress/block-editor/build-module/store/actions.js
  3011. var actions_namespaceObject = {};
  3012. __webpack_require__.r(actions_namespaceObject);
  3013. __webpack_require__.d(actions_namespaceObject, {
  3014. "__unstableDeleteSelection": function() { return __unstableDeleteSelection; },
  3015. "__unstableExpandSelection": function() { return __unstableExpandSelection; },
  3016. "__unstableMarkAutomaticChange": function() { return __unstableMarkAutomaticChange; },
  3017. "__unstableMarkLastChangeAsPersistent": function() { return __unstableMarkLastChangeAsPersistent; },
  3018. "__unstableMarkNextChangeAsNotPersistent": function() { return __unstableMarkNextChangeAsNotPersistent; },
  3019. "__unstableSaveReusableBlock": function() { return __unstableSaveReusableBlock; },
  3020. "__unstableSetEditorMode": function() { return __unstableSetEditorMode; },
  3021. "__unstableSetTemporarilyEditingAsBlocks": function() { return __unstableSetTemporarilyEditingAsBlocks; },
  3022. "__unstableSplitSelection": function() { return __unstableSplitSelection; },
  3023. "clearSelectedBlock": function() { return clearSelectedBlock; },
  3024. "duplicateBlocks": function() { return duplicateBlocks; },
  3025. "enterFormattedText": function() { return enterFormattedText; },
  3026. "exitFormattedText": function() { return exitFormattedText; },
  3027. "flashBlock": function() { return flashBlock; },
  3028. "hideInsertionPoint": function() { return hideInsertionPoint; },
  3029. "insertAfterBlock": function() { return insertAfterBlock; },
  3030. "insertBeforeBlock": function() { return insertBeforeBlock; },
  3031. "insertBlock": function() { return insertBlock; },
  3032. "insertBlocks": function() { return insertBlocks; },
  3033. "insertDefaultBlock": function() { return insertDefaultBlock; },
  3034. "mergeBlocks": function() { return mergeBlocks; },
  3035. "moveBlockToPosition": function() { return moveBlockToPosition; },
  3036. "moveBlocksDown": function() { return moveBlocksDown; },
  3037. "moveBlocksToPosition": function() { return moveBlocksToPosition; },
  3038. "moveBlocksUp": function() { return moveBlocksUp; },
  3039. "multiSelect": function() { return multiSelect; },
  3040. "receiveBlocks": function() { return receiveBlocks; },
  3041. "removeBlock": function() { return removeBlock; },
  3042. "removeBlocks": function() { return removeBlocks; },
  3043. "replaceBlock": function() { return replaceBlock; },
  3044. "replaceBlocks": function() { return replaceBlocks; },
  3045. "replaceInnerBlocks": function() { return replaceInnerBlocks; },
  3046. "resetBlocks": function() { return resetBlocks; },
  3047. "resetSelection": function() { return resetSelection; },
  3048. "selectBlock": function() { return selectBlock; },
  3049. "selectNextBlock": function() { return selectNextBlock; },
  3050. "selectPreviousBlock": function() { return selectPreviousBlock; },
  3051. "selectionChange": function() { return selectionChange; },
  3052. "setBlockMovingClientId": function() { return setBlockMovingClientId; },
  3053. "setBlockVisibility": function() { return setBlockVisibility; },
  3054. "setHasControlledInnerBlocks": function() { return setHasControlledInnerBlocks; },
  3055. "setNavigationMode": function() { return setNavigationMode; },
  3056. "setTemplateValidity": function() { return setTemplateValidity; },
  3057. "showInsertionPoint": function() { return showInsertionPoint; },
  3058. "startDraggingBlocks": function() { return startDraggingBlocks; },
  3059. "startMultiSelect": function() { return startMultiSelect; },
  3060. "startTyping": function() { return startTyping; },
  3061. "stopDraggingBlocks": function() { return stopDraggingBlocks; },
  3062. "stopMultiSelect": function() { return stopMultiSelect; },
  3063. "stopTyping": function() { return stopTyping; },
  3064. "synchronizeTemplate": function() { return synchronizeTemplate; },
  3065. "toggleBlockHighlight": function() { return toggleBlockHighlight; },
  3066. "toggleBlockMode": function() { return toggleBlockMode; },
  3067. "toggleSelection": function() { return toggleSelection; },
  3068. "updateBlock": function() { return updateBlock; },
  3069. "updateBlockAttributes": function() { return updateBlockAttributes; },
  3070. "updateBlockListSettings": function() { return updateBlockListSettings; },
  3071. "updateSettings": function() { return updateSettings; },
  3072. "validateBlocksToTemplate": function() { return validateBlocksToTemplate; }
  3073. });
  3074. ;// CONCATENATED MODULE: external ["wp","blocks"]
  3075. var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
  3076. ;// CONCATENATED MODULE: external ["wp","hooks"]
  3077. var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
  3078. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/compat.js
  3079. /**
  3080. * WordPress dependencies
  3081. */
  3082. function migrateLightBlockWrapper(settings) {
  3083. const {
  3084. apiVersion = 1
  3085. } = settings;
  3086. if (apiVersion < 2 && (0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'lightBlockWrapper', false)) {
  3087. settings.apiVersion = 2;
  3088. }
  3089. return settings;
  3090. }
  3091. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/compat/migrateLightBlockWrapper', migrateLightBlockWrapper);
  3092. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  3093. function _extends() {
  3094. _extends = Object.assign ? Object.assign.bind() : function (target) {
  3095. for (var i = 1; i < arguments.length; i++) {
  3096. var source = arguments[i];
  3097. for (var key in source) {
  3098. if (Object.prototype.hasOwnProperty.call(source, key)) {
  3099. target[key] = source[key];
  3100. }
  3101. }
  3102. }
  3103. return target;
  3104. };
  3105. return _extends.apply(this, arguments);
  3106. }
  3107. ;// CONCATENATED MODULE: external ["wp","element"]
  3108. var external_wp_element_namespaceObject = window["wp"]["element"];
  3109. // EXTERNAL MODULE: ./node_modules/classnames/index.js
  3110. var classnames = __webpack_require__(4403);
  3111. var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
  3112. ;// CONCATENATED MODULE: external "lodash"
  3113. var external_lodash_namespaceObject = window["lodash"];
  3114. ;// CONCATENATED MODULE: external ["wp","compose"]
  3115. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  3116. ;// CONCATENATED MODULE: external ["wp","data"]
  3117. var external_wp_data_namespaceObject = window["wp"]["data"];
  3118. ;// CONCATENATED MODULE: external ["wp","components"]
  3119. var external_wp_components_namespaceObject = window["wp"]["components"];
  3120. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/groups.js
  3121. /**
  3122. * WordPress dependencies
  3123. */
  3124. const BlockControlsDefault = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControls');
  3125. const BlockControlsBlock = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsBlock');
  3126. const BlockControlsInline = (0,external_wp_components_namespaceObject.createSlotFill)('BlockFormatControls');
  3127. const BlockControlsOther = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsOther');
  3128. const BlockControlsParent = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsParent');
  3129. const groups = {
  3130. default: BlockControlsDefault,
  3131. block: BlockControlsBlock,
  3132. inline: BlockControlsInline,
  3133. other: BlockControlsOther,
  3134. parent: BlockControlsParent
  3135. };
  3136. /* harmony default export */ var block_controls_groups = (groups);
  3137. ;// CONCATENATED MODULE: external ["wp","i18n"]
  3138. var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  3139. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/defaults.js
  3140. /**
  3141. * WordPress dependencies
  3142. */
  3143. const PREFERENCES_DEFAULTS = {
  3144. insertUsage: {}
  3145. };
  3146. /**
  3147. * The default editor settings
  3148. *
  3149. * @typedef {Object} SETTINGS_DEFAULT
  3150. * @property {boolean} alignWide Enable/Disable Wide/Full Alignments
  3151. * @property {boolean} supportsLayout Enable/disable layouts support in container blocks.
  3152. * @property {boolean} imageEditing Image Editing settings set to false to disable.
  3153. * @property {Array} imageSizes Available image sizes
  3154. * @property {number} maxWidth Max width to constraint resizing
  3155. * @property {boolean|Array} allowedBlockTypes Allowed block types
  3156. * @property {boolean} hasFixedToolbar Whether or not the editor toolbar is fixed
  3157. * @property {boolean} focusMode Whether the focus mode is enabled or not
  3158. * @property {Array} styles Editor Styles
  3159. * @property {boolean} keepCaretInsideBlock Whether caret should move between blocks in edit mode
  3160. * @property {string} bodyPlaceholder Empty post placeholder
  3161. * @property {string} titlePlaceholder Empty title placeholder
  3162. * @property {boolean} canLockBlocks Whether the user can manage Block Lock state
  3163. * @property {boolean} codeEditingEnabled Whether or not the user can switch to the code editor
  3164. * @property {boolean} generateAnchors Enable/Disable auto anchor generation for Heading blocks
  3165. * @property {boolean} __experimentalCanUserUseUnfilteredHTML Whether the user should be able to use unfiltered HTML or the HTML should be filtered e.g., to remove elements considered insecure like iframes.
  3166. * @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
  3167. * @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
  3168. * @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
  3169. * @property {boolean} __unstableGalleryWithImageBlocks Whether the user has enabled the refactored gallery block which uses InnerBlocks
  3170. */
  3171. const SETTINGS_DEFAULTS = {
  3172. alignWide: false,
  3173. supportsLayout: true,
  3174. // colors setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
  3175. // The setting is only kept for backward compatibility purposes.
  3176. colors: [{
  3177. name: (0,external_wp_i18n_namespaceObject.__)('Black'),
  3178. slug: 'black',
  3179. color: '#000000'
  3180. }, {
  3181. name: (0,external_wp_i18n_namespaceObject.__)('Cyan bluish gray'),
  3182. slug: 'cyan-bluish-gray',
  3183. color: '#abb8c3'
  3184. }, {
  3185. name: (0,external_wp_i18n_namespaceObject.__)('White'),
  3186. slug: 'white',
  3187. color: '#ffffff'
  3188. }, {
  3189. name: (0,external_wp_i18n_namespaceObject.__)('Pale pink'),
  3190. slug: 'pale-pink',
  3191. color: '#f78da7'
  3192. }, {
  3193. name: (0,external_wp_i18n_namespaceObject.__)('Vivid red'),
  3194. slug: 'vivid-red',
  3195. color: '#cf2e2e'
  3196. }, {
  3197. name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid orange'),
  3198. slug: 'luminous-vivid-orange',
  3199. color: '#ff6900'
  3200. }, {
  3201. name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid amber'),
  3202. slug: 'luminous-vivid-amber',
  3203. color: '#fcb900'
  3204. }, {
  3205. name: (0,external_wp_i18n_namespaceObject.__)('Light green cyan'),
  3206. slug: 'light-green-cyan',
  3207. color: '#7bdcb5'
  3208. }, {
  3209. name: (0,external_wp_i18n_namespaceObject.__)('Vivid green cyan'),
  3210. slug: 'vivid-green-cyan',
  3211. color: '#00d084'
  3212. }, {
  3213. name: (0,external_wp_i18n_namespaceObject.__)('Pale cyan blue'),
  3214. slug: 'pale-cyan-blue',
  3215. color: '#8ed1fc'
  3216. }, {
  3217. name: (0,external_wp_i18n_namespaceObject.__)('Vivid cyan blue'),
  3218. slug: 'vivid-cyan-blue',
  3219. color: '#0693e3'
  3220. }, {
  3221. name: (0,external_wp_i18n_namespaceObject.__)('Vivid purple'),
  3222. slug: 'vivid-purple',
  3223. color: '#9b51e0'
  3224. }],
  3225. // fontSizes setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
  3226. // The setting is only kept for backward compatibility purposes.
  3227. fontSizes: [{
  3228. name: (0,external_wp_i18n_namespaceObject._x)('Small', 'font size name'),
  3229. size: 13,
  3230. slug: 'small'
  3231. }, {
  3232. name: (0,external_wp_i18n_namespaceObject._x)('Normal', 'font size name'),
  3233. size: 16,
  3234. slug: 'normal'
  3235. }, {
  3236. name: (0,external_wp_i18n_namespaceObject._x)('Medium', 'font size name'),
  3237. size: 20,
  3238. slug: 'medium'
  3239. }, {
  3240. name: (0,external_wp_i18n_namespaceObject._x)('Large', 'font size name'),
  3241. size: 36,
  3242. slug: 'large'
  3243. }, {
  3244. name: (0,external_wp_i18n_namespaceObject._x)('Huge', 'font size name'),
  3245. size: 42,
  3246. slug: 'huge'
  3247. }],
  3248. // Image default size slug.
  3249. imageDefaultSize: 'large',
  3250. imageSizes: [{
  3251. slug: 'thumbnail',
  3252. name: (0,external_wp_i18n_namespaceObject.__)('Thumbnail')
  3253. }, {
  3254. slug: 'medium',
  3255. name: (0,external_wp_i18n_namespaceObject.__)('Medium')
  3256. }, {
  3257. slug: 'large',
  3258. name: (0,external_wp_i18n_namespaceObject.__)('Large')
  3259. }, {
  3260. slug: 'full',
  3261. name: (0,external_wp_i18n_namespaceObject.__)('Full Size')
  3262. }],
  3263. // Allow plugin to disable Image Editor if need be.
  3264. imageEditing: true,
  3265. // This is current max width of the block inner area
  3266. // It's used to constraint image resizing and this value could be overridden later by themes
  3267. maxWidth: 580,
  3268. // Allowed block types for the editor, defaulting to true (all supported).
  3269. allowedBlockTypes: true,
  3270. // Maximum upload size in bytes allowed for the site.
  3271. maxUploadFileSize: 0,
  3272. // List of allowed mime types and file extensions.
  3273. allowedMimeTypes: null,
  3274. // Allows to disable block locking interface.
  3275. canLockBlocks: true,
  3276. __experimentalCanUserUseUnfilteredHTML: false,
  3277. __experimentalBlockDirectory: false,
  3278. __mobileEnablePageTemplates: false,
  3279. __experimentalBlockPatterns: [],
  3280. __experimentalBlockPatternCategories: [],
  3281. __unstableGalleryWithImageBlocks: false,
  3282. generateAnchors: false,
  3283. // gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
  3284. // The setting is only kept for backward compatibility purposes.
  3285. gradients: [{
  3286. name: (0,external_wp_i18n_namespaceObject.__)('Vivid cyan blue to vivid purple'),
  3287. gradient: 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
  3288. slug: 'vivid-cyan-blue-to-vivid-purple'
  3289. }, {
  3290. name: (0,external_wp_i18n_namespaceObject.__)('Light green cyan to vivid green cyan'),
  3291. gradient: 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
  3292. slug: 'light-green-cyan-to-vivid-green-cyan'
  3293. }, {
  3294. name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid amber to luminous vivid orange'),
  3295. gradient: 'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)',
  3296. slug: 'luminous-vivid-amber-to-luminous-vivid-orange'
  3297. }, {
  3298. name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid orange to vivid red'),
  3299. gradient: 'linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)',
  3300. slug: 'luminous-vivid-orange-to-vivid-red'
  3301. }, {
  3302. name: (0,external_wp_i18n_namespaceObject.__)('Very light gray to cyan bluish gray'),
  3303. gradient: 'linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%)',
  3304. slug: 'very-light-gray-to-cyan-bluish-gray'
  3305. }, {
  3306. name: (0,external_wp_i18n_namespaceObject.__)('Cool to warm spectrum'),
  3307. gradient: 'linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%)',
  3308. slug: 'cool-to-warm-spectrum'
  3309. }, {
  3310. name: (0,external_wp_i18n_namespaceObject.__)('Blush light purple'),
  3311. gradient: 'linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)',
  3312. slug: 'blush-light-purple'
  3313. }, {
  3314. name: (0,external_wp_i18n_namespaceObject.__)('Blush bordeaux'),
  3315. gradient: 'linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)',
  3316. slug: 'blush-bordeaux'
  3317. }, {
  3318. name: (0,external_wp_i18n_namespaceObject.__)('Luminous dusk'),
  3319. gradient: 'linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%)',
  3320. slug: 'luminous-dusk'
  3321. }, {
  3322. name: (0,external_wp_i18n_namespaceObject.__)('Pale ocean'),
  3323. gradient: 'linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%)',
  3324. slug: 'pale-ocean'
  3325. }, {
  3326. name: (0,external_wp_i18n_namespaceObject.__)('Electric grass'),
  3327. gradient: 'linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%)',
  3328. slug: 'electric-grass'
  3329. }, {
  3330. name: (0,external_wp_i18n_namespaceObject.__)('Midnight'),
  3331. gradient: 'linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%)',
  3332. slug: 'midnight'
  3333. }],
  3334. __unstableResolvedAssets: {
  3335. styles: [],
  3336. scripts: []
  3337. }
  3338. };
  3339. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/array.js
  3340. /**
  3341. * External dependencies
  3342. */
  3343. /**
  3344. * Insert one or multiple elements into a given position of an array.
  3345. *
  3346. * @param {Array} array Source array.
  3347. * @param {*} elements Elements to insert.
  3348. * @param {number} index Insert Position.
  3349. *
  3350. * @return {Array} Result.
  3351. */
  3352. function insertAt(array, elements, index) {
  3353. return [...array.slice(0, index), ...(0,external_lodash_namespaceObject.castArray)(elements), ...array.slice(index)];
  3354. }
  3355. /**
  3356. * Moves an element in an array.
  3357. *
  3358. * @param {Array} array Source array.
  3359. * @param {number} from Source index.
  3360. * @param {number} to Destination index.
  3361. * @param {number} count Number of elements to move.
  3362. *
  3363. * @return {Array} Result.
  3364. */
  3365. function moveTo(array, from, to) {
  3366. let count = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
  3367. const withoutMovedElements = [...array];
  3368. withoutMovedElements.splice(from, count);
  3369. return insertAt(withoutMovedElements, array.slice(from, from + count), to);
  3370. }
  3371. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/reducer.js
  3372. /**
  3373. * External dependencies
  3374. */
  3375. /**
  3376. * WordPress dependencies
  3377. */
  3378. /**
  3379. * Internal dependencies
  3380. */
  3381. const identity = x => x;
  3382. /**
  3383. * Given an array of blocks, returns an object where each key is a nesting
  3384. * context, the value of which is an array of block client IDs existing within
  3385. * that nesting context.
  3386. *
  3387. * @param {Array} blocks Blocks to map.
  3388. * @param {?string} rootClientId Assumed root client ID.
  3389. *
  3390. * @return {Object} Block order map object.
  3391. */
  3392. function mapBlockOrder(blocks) {
  3393. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  3394. const result = {
  3395. [rootClientId]: []
  3396. };
  3397. blocks.forEach(block => {
  3398. const {
  3399. clientId,
  3400. innerBlocks
  3401. } = block;
  3402. result[rootClientId].push(clientId);
  3403. Object.assign(result, mapBlockOrder(innerBlocks, clientId));
  3404. });
  3405. return result;
  3406. }
  3407. /**
  3408. * Given an array of blocks, returns an object where each key contains
  3409. * the clientId of the block and the value is the parent of the block.
  3410. *
  3411. * @param {Array} blocks Blocks to map.
  3412. * @param {?string} rootClientId Assumed root client ID.
  3413. *
  3414. * @return {Object} Block order map object.
  3415. */
  3416. function mapBlockParents(blocks) {
  3417. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  3418. return blocks.reduce((result, block) => Object.assign(result, {
  3419. [block.clientId]: rootClientId
  3420. }, mapBlockParents(block.innerBlocks, block.clientId)), {});
  3421. }
  3422. /**
  3423. * Helper method to iterate through all blocks, recursing into inner blocks,
  3424. * applying a transformation function to each one.
  3425. * Returns a flattened object with the transformed blocks.
  3426. *
  3427. * @param {Array} blocks Blocks to flatten.
  3428. * @param {Function} transform Transforming function to be applied to each block.
  3429. *
  3430. * @return {Object} Flattened object.
  3431. */
  3432. function flattenBlocks(blocks) {
  3433. let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
  3434. const result = {};
  3435. const stack = [...blocks];
  3436. while (stack.length) {
  3437. const {
  3438. innerBlocks,
  3439. ...block
  3440. } = stack.shift();
  3441. stack.push(...innerBlocks);
  3442. result[block.clientId] = transform(block);
  3443. }
  3444. return result;
  3445. }
  3446. /**
  3447. * Given an array of blocks, returns an object containing all blocks, without
  3448. * attributes, recursing into inner blocks. Keys correspond to the block client
  3449. * ID, the value of which is the attributes object.
  3450. *
  3451. * @param {Array} blocks Blocks to flatten.
  3452. *
  3453. * @return {Object} Flattened block attributes object.
  3454. */
  3455. function getFlattenedBlocksWithoutAttributes(blocks) {
  3456. return flattenBlocks(blocks, block => (0,external_lodash_namespaceObject.omit)(block, 'attributes'));
  3457. }
  3458. /**
  3459. * Given an array of blocks, returns an object containing all block attributes,
  3460. * recursing into inner blocks. Keys correspond to the block client ID, the
  3461. * value of which is the attributes object.
  3462. *
  3463. * @param {Array} blocks Blocks to flatten.
  3464. *
  3465. * @return {Object} Flattened block attributes object.
  3466. */
  3467. function getFlattenedBlockAttributes(blocks) {
  3468. return flattenBlocks(blocks, block => block.attributes);
  3469. }
  3470. /**
  3471. * Returns an object against which it is safe to perform mutating operations,
  3472. * given the original object and its current working copy.
  3473. *
  3474. * @param {Object} original Original object.
  3475. * @param {Object} working Working object.
  3476. *
  3477. * @return {Object} Mutation-safe object.
  3478. */
  3479. function getMutateSafeObject(original, working) {
  3480. if (original === working) {
  3481. return { ...original
  3482. };
  3483. }
  3484. return working;
  3485. }
  3486. /**
  3487. * Returns true if the two object arguments have the same keys, or false
  3488. * otherwise.
  3489. *
  3490. * @param {Object} a First object.
  3491. * @param {Object} b Second object.
  3492. *
  3493. * @return {boolean} Whether the two objects have the same keys.
  3494. */
  3495. function hasSameKeys(a, b) {
  3496. return (0,external_lodash_namespaceObject.isEqual)(Object.keys(a), Object.keys(b));
  3497. }
  3498. /**
  3499. * Returns true if, given the currently dispatching action and the previously
  3500. * dispatched action, the two actions are updating the same block attribute, or
  3501. * false otherwise.
  3502. *
  3503. * @param {Object} action Currently dispatching action.
  3504. * @param {Object} lastAction Previously dispatched action.
  3505. *
  3506. * @return {boolean} Whether actions are updating the same block attribute.
  3507. */
  3508. function isUpdatingSameBlockAttribute(action, lastAction) {
  3509. return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && (0,external_lodash_namespaceObject.isEqual)(action.clientIds, lastAction.clientIds) && hasSameKeys(action.attributes, lastAction.attributes);
  3510. }
  3511. function buildBlockTree(state, blocks) {
  3512. const result = {};
  3513. const stack = [...blocks];
  3514. const flattenedBlocks = [...blocks];
  3515. while (stack.length) {
  3516. const block = stack.shift();
  3517. stack.push(...block.innerBlocks);
  3518. flattenedBlocks.push(...block.innerBlocks);
  3519. } // Create objects before mutating them, that way it's always defined.
  3520. for (const block of flattenedBlocks) {
  3521. result[block.clientId] = {};
  3522. }
  3523. for (const block of flattenedBlocks) {
  3524. result[block.clientId] = Object.assign(result[block.clientId], { ...state.byClientId[block.clientId],
  3525. attributes: state.attributes[block.clientId],
  3526. innerBlocks: block.innerBlocks.map(subBlock => result[subBlock.clientId])
  3527. });
  3528. }
  3529. return result;
  3530. }
  3531. function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
  3532. let updateChildrenOfUpdatedClientIds = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3533. const uncontrolledParents = new Set([]);
  3534. const controlledParents = new Set();
  3535. for (const clientId of updatedClientIds) {
  3536. let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents[clientId];
  3537. do {
  3538. if (state.controlledInnerBlocks[current]) {
  3539. // Should stop on controlled blocks.
  3540. // If we reach a controlled parent, break out of the loop.
  3541. controlledParents.add(current);
  3542. break;
  3543. } else {
  3544. // Else continue traversing up through parents.
  3545. uncontrolledParents.add(current);
  3546. current = state.parents[current];
  3547. }
  3548. } while (current !== undefined);
  3549. } // To make sure the order of assignments doesn't matter,
  3550. // we first create empty objects and mutates the inner blocks later.
  3551. for (const clientId of uncontrolledParents) {
  3552. tree[clientId] = { ...tree[clientId]
  3553. };
  3554. }
  3555. for (const clientId of uncontrolledParents) {
  3556. tree[clientId].innerBlocks = (state.order[clientId] || []).map(subClientId => tree[subClientId]);
  3557. } // Controlled parent blocks, need a dedicated key for their inner blocks
  3558. // to be used when doing getBlocks( controlledBlockClientId ).
  3559. for (const clientId of controlledParents) {
  3560. tree['controlled||' + clientId] = {
  3561. innerBlocks: (state.order[clientId] || []).map(subClientId => tree[subClientId])
  3562. };
  3563. }
  3564. return tree;
  3565. }
  3566. /**
  3567. * Higher-order reducer intended to compute full block objects key for each block in the post.
  3568. * This is a denormalization to optimize the performance of the getBlock selectors and avoid
  3569. * recomputing the block objects and avoid heavy memoization.
  3570. *
  3571. * @param {Function} reducer Original reducer function.
  3572. *
  3573. * @return {Function} Enhanced reducer function.
  3574. */
  3575. const withBlockTree = reducer => function () {
  3576. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3577. let action = arguments.length > 1 ? arguments[1] : undefined;
  3578. const newState = reducer(state, action);
  3579. if (newState === state) {
  3580. return state;
  3581. }
  3582. newState.tree = state.tree ? state.tree : {};
  3583. switch (action.type) {
  3584. case 'RECEIVE_BLOCKS':
  3585. case 'INSERT_BLOCKS':
  3586. {
  3587. const subTree = buildBlockTree(newState, action.blocks);
  3588. newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
  3589. ...subTree
  3590. }, action.rootClientId ? [action.rootClientId] : [''], true);
  3591. break;
  3592. }
  3593. case 'UPDATE_BLOCK':
  3594. newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
  3595. [action.clientId]: { ...newState.tree[action.clientId],
  3596. ...newState.byClientId[action.clientId],
  3597. attributes: newState.attributes[action.clientId]
  3598. }
  3599. }, [action.clientId], false);
  3600. break;
  3601. case 'UPDATE_BLOCK_ATTRIBUTES':
  3602. {
  3603. const newSubTree = action.clientIds.reduce((result, clientId) => {
  3604. result[clientId] = { ...newState.tree[clientId],
  3605. attributes: newState.attributes[clientId]
  3606. };
  3607. return result;
  3608. }, {});
  3609. newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
  3610. ...newSubTree
  3611. }, action.clientIds, false);
  3612. break;
  3613. }
  3614. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3615. {
  3616. const subTree = buildBlockTree(newState, action.blocks);
  3617. newState.tree = updateParentInnerBlocksInTree(newState, { ...(0,external_lodash_namespaceObject.omit)(newState.tree, action.replacedClientIds.concat( // Controlled inner blocks are only removed
  3618. // if the block doesn't move to another position
  3619. // otherwise their content will be lost.
  3620. action.replacedClientIds.filter(clientId => !subTree[clientId]).map(clientId => 'controlled||' + clientId))),
  3621. ...subTree
  3622. }, action.blocks.map(b => b.clientId), false); // If there are no replaced blocks, it means we're removing blocks so we need to update their parent.
  3623. const parentsOfRemovedBlocks = [];
  3624. for (const clientId of action.clientIds) {
  3625. if (state.parents[clientId] !== undefined && (state.parents[clientId] === '' || newState.byClientId[state.parents[clientId]])) {
  3626. parentsOfRemovedBlocks.push(state.parents[clientId]);
  3627. }
  3628. }
  3629. newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, parentsOfRemovedBlocks, true);
  3630. break;
  3631. }
  3632. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3633. const parentsOfRemovedBlocks = [];
  3634. for (const clientId of action.clientIds) {
  3635. if (state.parents[clientId] !== undefined && (state.parents[clientId] === '' || newState.byClientId[state.parents[clientId]])) {
  3636. parentsOfRemovedBlocks.push(state.parents[clientId]);
  3637. }
  3638. }
  3639. newState.tree = updateParentInnerBlocksInTree(newState, (0,external_lodash_namespaceObject.omit)(newState.tree, action.removedClientIds.concat(action.removedClientIds.map(clientId => 'controlled||' + clientId))), parentsOfRemovedBlocks, true);
  3640. break;
  3641. case 'MOVE_BLOCKS_TO_POSITION':
  3642. {
  3643. const updatedBlockUids = [];
  3644. if (action.fromRootClientId) {
  3645. updatedBlockUids.push(action.fromRootClientId);
  3646. } else {
  3647. updatedBlockUids.push('');
  3648. }
  3649. if (action.toRootClientId) {
  3650. updatedBlockUids.push(action.toRootClientId);
  3651. }
  3652. newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, updatedBlockUids, true);
  3653. break;
  3654. }
  3655. case 'MOVE_BLOCKS_UP':
  3656. case 'MOVE_BLOCKS_DOWN':
  3657. {
  3658. const updatedBlockUids = [action.rootClientId ? action.rootClientId : ''];
  3659. newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, updatedBlockUids, true);
  3660. break;
  3661. }
  3662. case 'SAVE_REUSABLE_BLOCK_SUCCESS':
  3663. {
  3664. const updatedBlockUids = Object.keys((0,external_lodash_namespaceObject.omitBy)(newState.attributes, (attributes, clientId) => {
  3665. return newState.byClientId[clientId].name !== 'core/block' || attributes.ref !== action.updatedId;
  3666. }));
  3667. newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
  3668. ...updatedBlockUids.reduce((result, clientId) => {
  3669. result[clientId] = { ...newState.byClientId[clientId],
  3670. attributes: newState.attributes[clientId],
  3671. innerBlocks: newState.tree[clientId].innerBlocks
  3672. };
  3673. return result;
  3674. }, {})
  3675. }, updatedBlockUids, false);
  3676. }
  3677. }
  3678. return newState;
  3679. };
  3680. /**
  3681. * Higher-order reducer intended to augment the blocks reducer, assigning an
  3682. * `isPersistentChange` property value corresponding to whether a change in
  3683. * state can be considered as persistent. All changes are considered persistent
  3684. * except when updating the same block attribute as in the previous action.
  3685. *
  3686. * @param {Function} reducer Original reducer function.
  3687. *
  3688. * @return {Function} Enhanced reducer function.
  3689. */
  3690. function withPersistentBlockChange(reducer) {
  3691. let lastAction;
  3692. let markNextChangeAsNotPersistent = false;
  3693. return (state, action) => {
  3694. let nextState = reducer(state, action);
  3695. const isExplicitPersistentChange = action.type === 'MARK_LAST_CHANGE_AS_PERSISTENT' || markNextChangeAsNotPersistent; // Defer to previous state value (or default) unless changing or
  3696. // explicitly marking as persistent.
  3697. if (state === nextState && !isExplicitPersistentChange) {
  3698. var _state$isPersistentCh;
  3699. markNextChangeAsNotPersistent = action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
  3700. const nextIsPersistentChange = (_state$isPersistentCh = state === null || state === void 0 ? void 0 : state.isPersistentChange) !== null && _state$isPersistentCh !== void 0 ? _state$isPersistentCh : true;
  3701. if (state.isPersistentChange === nextIsPersistentChange) {
  3702. return state;
  3703. }
  3704. return { ...nextState,
  3705. isPersistentChange: nextIsPersistentChange
  3706. };
  3707. }
  3708. nextState = { ...nextState,
  3709. isPersistentChange: isExplicitPersistentChange ? !markNextChangeAsNotPersistent : !isUpdatingSameBlockAttribute(action, lastAction)
  3710. }; // In comparing against the previous action, consider only those which
  3711. // would have qualified as one which would have been ignored or not
  3712. // have resulted in a changed state.
  3713. lastAction = action;
  3714. markNextChangeAsNotPersistent = action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
  3715. return nextState;
  3716. };
  3717. }
  3718. /**
  3719. * Higher-order reducer intended to augment the blocks reducer, assigning an
  3720. * `isIgnoredChange` property value corresponding to whether a change in state
  3721. * can be considered as ignored. A change is considered ignored when the result
  3722. * of an action not incurred by direct user interaction.
  3723. *
  3724. * @param {Function} reducer Original reducer function.
  3725. *
  3726. * @return {Function} Enhanced reducer function.
  3727. */
  3728. function withIgnoredBlockChange(reducer) {
  3729. /**
  3730. * Set of action types for which a blocks state change should be ignored.
  3731. *
  3732. * @type {Set}
  3733. */
  3734. const IGNORED_ACTION_TYPES = new Set(['RECEIVE_BLOCKS']);
  3735. return (state, action) => {
  3736. const nextState = reducer(state, action);
  3737. if (nextState !== state) {
  3738. nextState.isIgnoredChange = IGNORED_ACTION_TYPES.has(action.type);
  3739. }
  3740. return nextState;
  3741. };
  3742. }
  3743. /**
  3744. * Higher-order reducer targeting the combined blocks reducer, augmenting
  3745. * block client IDs in remove action to include cascade of inner blocks.
  3746. *
  3747. * @param {Function} reducer Original reducer function.
  3748. *
  3749. * @return {Function} Enhanced reducer function.
  3750. */
  3751. const withInnerBlocksRemoveCascade = reducer => (state, action) => {
  3752. // Gets all children which need to be removed.
  3753. const getAllChildren = clientIds => {
  3754. let result = clientIds;
  3755. for (let i = 0; i < result.length; i++) {
  3756. if (!state.order[result[i]] || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i]]) {
  3757. continue;
  3758. }
  3759. if (result === clientIds) {
  3760. result = [...result];
  3761. }
  3762. result.push(...state.order[result[i]]);
  3763. }
  3764. return result;
  3765. };
  3766. if (state) {
  3767. switch (action.type) {
  3768. case 'REMOVE_BLOCKS':
  3769. action = { ...action,
  3770. type: 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN',
  3771. removedClientIds: getAllChildren(action.clientIds)
  3772. };
  3773. break;
  3774. case 'REPLACE_BLOCKS':
  3775. action = { ...action,
  3776. type: 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN',
  3777. replacedClientIds: getAllChildren(action.clientIds)
  3778. };
  3779. break;
  3780. }
  3781. }
  3782. return reducer(state, action);
  3783. };
  3784. /**
  3785. * Higher-order reducer which targets the combined blocks reducer and handles
  3786. * the `RESET_BLOCKS` action. When dispatched, this action will replace all
  3787. * blocks that exist in the post, leaving blocks that exist only in state (e.g.
  3788. * reusable blocks and blocks controlled by inner blocks controllers) alone.
  3789. *
  3790. * @param {Function} reducer Original reducer function.
  3791. *
  3792. * @return {Function} Enhanced reducer function.
  3793. */
  3794. const withBlockReset = reducer => (state, action) => {
  3795. if (action.type === 'RESET_BLOCKS') {
  3796. const newState = { ...state,
  3797. byClientId: getFlattenedBlocksWithoutAttributes(action.blocks),
  3798. attributes: getFlattenedBlockAttributes(action.blocks),
  3799. order: mapBlockOrder(action.blocks),
  3800. parents: mapBlockParents(action.blocks),
  3801. controlledInnerBlocks: {},
  3802. visibility: {}
  3803. };
  3804. const subTree = buildBlockTree(newState, action.blocks);
  3805. newState.tree = { ...subTree,
  3806. // Root.
  3807. '': {
  3808. innerBlocks: action.blocks.map(subBlock => subTree[subBlock.clientId])
  3809. }
  3810. };
  3811. return newState;
  3812. }
  3813. return reducer(state, action);
  3814. };
  3815. /**
  3816. * Higher-order reducer which targets the combined blocks reducer and handles
  3817. * the `REPLACE_INNER_BLOCKS` action. When dispatched, this action the state
  3818. * should become equivalent to the execution of a `REMOVE_BLOCKS` action
  3819. * containing all the child's of the root block followed by the execution of
  3820. * `INSERT_BLOCKS` with the new blocks.
  3821. *
  3822. * @param {Function} reducer Original reducer function.
  3823. *
  3824. * @return {Function} Enhanced reducer function.
  3825. */
  3826. const withReplaceInnerBlocks = reducer => (state, action) => {
  3827. if (action.type !== 'REPLACE_INNER_BLOCKS') {
  3828. return reducer(state, action);
  3829. } // Finds every nested inner block controller. We must check the action blocks
  3830. // and not just the block parent state because some inner block controllers
  3831. // should be deleted if specified, whereas others should not be deleted. If
  3832. // a controlled should not be deleted, then we need to avoid deleting its
  3833. // inner blocks from the block state because its inner blocks will not be
  3834. // attached to the block in the action.
  3835. const nestedControllers = {};
  3836. if (Object.keys(state.controlledInnerBlocks).length) {
  3837. const stack = [...action.blocks];
  3838. while (stack.length) {
  3839. const {
  3840. innerBlocks,
  3841. ...block
  3842. } = stack.shift();
  3843. stack.push(...innerBlocks);
  3844. if (!!state.controlledInnerBlocks[block.clientId]) {
  3845. nestedControllers[block.clientId] = true;
  3846. }
  3847. }
  3848. } // The `keepControlledInnerBlocks` prop will keep the inner blocks of the
  3849. // marked block in the block state so that they can be reattached to the
  3850. // marked block when we re-insert everything a few lines below.
  3851. let stateAfterBlocksRemoval = state;
  3852. if (state.order[action.rootClientId]) {
  3853. stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, {
  3854. type: 'REMOVE_BLOCKS',
  3855. keepControlledInnerBlocks: nestedControllers,
  3856. clientIds: state.order[action.rootClientId]
  3857. });
  3858. }
  3859. let stateAfterInsert = stateAfterBlocksRemoval;
  3860. if (action.blocks.length) {
  3861. stateAfterInsert = reducer(stateAfterInsert, { ...action,
  3862. type: 'INSERT_BLOCKS',
  3863. index: 0
  3864. }); // We need to re-attach the controlled inner blocks to the blocks tree and
  3865. // preserve their block order. Otherwise, an inner block controller's blocks
  3866. // will be deleted entirely from its entity.
  3867. stateAfterInsert.order = { ...stateAfterInsert.order,
  3868. ...(0,external_lodash_namespaceObject.reduce)(nestedControllers, (result, value, key) => {
  3869. if (state.order[key]) {
  3870. result[key] = state.order[key];
  3871. }
  3872. return result;
  3873. }, {})
  3874. };
  3875. stateAfterInsert.tree = { ...stateAfterInsert.tree,
  3876. ...(0,external_lodash_namespaceObject.reduce)(nestedControllers, (result, value, _key) => {
  3877. const key = `controlled||${_key}`;
  3878. if (state.tree[key]) {
  3879. result[key] = state.tree[key];
  3880. }
  3881. return result;
  3882. }, {})
  3883. };
  3884. }
  3885. return stateAfterInsert;
  3886. };
  3887. /**
  3888. * Higher-order reducer which targets the combined blocks reducer and handles
  3889. * the `SAVE_REUSABLE_BLOCK_SUCCESS` action. This action can't be handled by
  3890. * regular reducers and needs a higher-order reducer since it needs access to
  3891. * both `byClientId` and `attributes` simultaneously.
  3892. *
  3893. * @param {Function} reducer Original reducer function.
  3894. *
  3895. * @return {Function} Enhanced reducer function.
  3896. */
  3897. const withSaveReusableBlock = reducer => (state, action) => {
  3898. if (state && action.type === 'SAVE_REUSABLE_BLOCK_SUCCESS') {
  3899. const {
  3900. id,
  3901. updatedId
  3902. } = action; // If a temporary reusable block is saved, we swap the temporary id with the final one.
  3903. if (id === updatedId) {
  3904. return state;
  3905. }
  3906. state = { ...state
  3907. };
  3908. state.attributes = (0,external_lodash_namespaceObject.mapValues)(state.attributes, (attributes, clientId) => {
  3909. const {
  3910. name
  3911. } = state.byClientId[clientId];
  3912. if (name === 'core/block' && attributes.ref === id) {
  3913. return { ...attributes,
  3914. ref: updatedId
  3915. };
  3916. }
  3917. return attributes;
  3918. });
  3919. }
  3920. return reducer(state, action);
  3921. };
  3922. /**
  3923. * Higher-order reducer which removes blocks from state when switching parent block controlled state.
  3924. *
  3925. * @param {Function} reducer Original reducer function.
  3926. *
  3927. * @return {Function} Enhanced reducer function.
  3928. */
  3929. const withResetControlledBlocks = reducer => (state, action) => {
  3930. if (action.type === 'SET_HAS_CONTROLLED_INNER_BLOCKS') {
  3931. // when switching a block from controlled to uncontrolled or inverse,
  3932. // we need to remove its content first.
  3933. const tempState = reducer(state, {
  3934. type: 'REPLACE_INNER_BLOCKS',
  3935. rootClientId: action.clientId,
  3936. blocks: []
  3937. });
  3938. return reducer(tempState, action);
  3939. }
  3940. return reducer(state, action);
  3941. };
  3942. /**
  3943. * Reducer returning the blocks state.
  3944. *
  3945. * @param {Object} state Current state.
  3946. * @param {Object} action Dispatched action.
  3947. *
  3948. * @return {Object} Updated state.
  3949. */
  3950. const blocks = (0,external_lodash_namespaceObject.flow)(external_wp_data_namespaceObject.combineReducers, withSaveReusableBlock, // Needs to be before withBlockCache.
  3951. withBlockTree, // Needs to be before withInnerBlocksRemoveCascade.
  3952. withInnerBlocksRemoveCascade, withReplaceInnerBlocks, // Needs to be after withInnerBlocksRemoveCascade.
  3953. withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetControlledBlocks)({
  3954. byClientId() {
  3955. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3956. let action = arguments.length > 1 ? arguments[1] : undefined;
  3957. switch (action.type) {
  3958. case 'RECEIVE_BLOCKS':
  3959. case 'INSERT_BLOCKS':
  3960. return { ...state,
  3961. ...getFlattenedBlocksWithoutAttributes(action.blocks)
  3962. };
  3963. case 'UPDATE_BLOCK':
  3964. // Ignore updates if block isn't known.
  3965. if (!state[action.clientId]) {
  3966. return state;
  3967. } // Do nothing if only attributes change.
  3968. const changes = (0,external_lodash_namespaceObject.omit)(action.updates, 'attributes');
  3969. if ((0,external_lodash_namespaceObject.isEmpty)(changes)) {
  3970. return state;
  3971. }
  3972. return { ...state,
  3973. [action.clientId]: { ...state[action.clientId],
  3974. ...changes
  3975. }
  3976. };
  3977. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3978. if (!action.blocks) {
  3979. return state;
  3980. }
  3981. return { ...(0,external_lodash_namespaceObject.omit)(state, action.replacedClientIds),
  3982. ...getFlattenedBlocksWithoutAttributes(action.blocks)
  3983. };
  3984. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3985. return (0,external_lodash_namespaceObject.omit)(state, action.removedClientIds);
  3986. }
  3987. return state;
  3988. },
  3989. attributes() {
  3990. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3991. let action = arguments.length > 1 ? arguments[1] : undefined;
  3992. switch (action.type) {
  3993. case 'RECEIVE_BLOCKS':
  3994. case 'INSERT_BLOCKS':
  3995. return { ...state,
  3996. ...getFlattenedBlockAttributes(action.blocks)
  3997. };
  3998. case 'UPDATE_BLOCK':
  3999. // Ignore updates if block isn't known or there are no attribute changes.
  4000. if (!state[action.clientId] || !action.updates.attributes) {
  4001. return state;
  4002. }
  4003. return { ...state,
  4004. [action.clientId]: { ...state[action.clientId],
  4005. ...action.updates.attributes
  4006. }
  4007. };
  4008. case 'UPDATE_BLOCK_ATTRIBUTES':
  4009. {
  4010. // Avoid a state change if none of the block IDs are known.
  4011. if (action.clientIds.every(id => !state[id])) {
  4012. return state;
  4013. }
  4014. const next = action.clientIds.reduce((accumulator, id) => ({ ...accumulator,
  4015. [id]: (0,external_lodash_namespaceObject.reduce)(action.uniqueByBlock ? action.attributes[id] : action.attributes, (result, value, key) => {
  4016. // Consider as updates only changed values.
  4017. if (value !== result[key]) {
  4018. result = getMutateSafeObject(state[id], result);
  4019. result[key] = value;
  4020. }
  4021. return result;
  4022. }, state[id])
  4023. }), {});
  4024. if (action.clientIds.every(id => next[id] === state[id])) {
  4025. return state;
  4026. }
  4027. return { ...state,
  4028. ...next
  4029. };
  4030. }
  4031. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  4032. if (!action.blocks) {
  4033. return state;
  4034. }
  4035. return { ...(0,external_lodash_namespaceObject.omit)(state, action.replacedClientIds),
  4036. ...getFlattenedBlockAttributes(action.blocks)
  4037. };
  4038. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  4039. return (0,external_lodash_namespaceObject.omit)(state, action.removedClientIds);
  4040. }
  4041. return state;
  4042. },
  4043. order() {
  4044. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4045. let action = arguments.length > 1 ? arguments[1] : undefined;
  4046. switch (action.type) {
  4047. case 'RECEIVE_BLOCKS':
  4048. {
  4049. const blockOrder = mapBlockOrder(action.blocks);
  4050. return { ...state,
  4051. ...(0,external_lodash_namespaceObject.omit)(blockOrder, ''),
  4052. '': ((state === null || state === void 0 ? void 0 : state['']) || []).concat(blockOrder[''])
  4053. };
  4054. }
  4055. case 'INSERT_BLOCKS':
  4056. {
  4057. const {
  4058. rootClientId = ''
  4059. } = action;
  4060. const subState = state[rootClientId] || [];
  4061. const mappedBlocks = mapBlockOrder(action.blocks, rootClientId);
  4062. const {
  4063. index = subState.length
  4064. } = action;
  4065. return { ...state,
  4066. ...mappedBlocks,
  4067. [rootClientId]: insertAt(subState, mappedBlocks[rootClientId], index)
  4068. };
  4069. }
  4070. case 'MOVE_BLOCKS_TO_POSITION':
  4071. {
  4072. const {
  4073. fromRootClientId = '',
  4074. toRootClientId = '',
  4075. clientIds
  4076. } = action;
  4077. const {
  4078. index = state[toRootClientId].length
  4079. } = action; // Moving inside the same parent block.
  4080. if (fromRootClientId === toRootClientId) {
  4081. const subState = state[toRootClientId];
  4082. const fromIndex = subState.indexOf(clientIds[0]);
  4083. return { ...state,
  4084. [toRootClientId]: moveTo(state[toRootClientId], fromIndex, index, clientIds.length)
  4085. };
  4086. } // Moving from a parent block to another.
  4087. return { ...state,
  4088. [fromRootClientId]: (0,external_lodash_namespaceObject.without)(state[fromRootClientId], ...clientIds),
  4089. [toRootClientId]: insertAt(state[toRootClientId], clientIds, index)
  4090. };
  4091. }
  4092. case 'MOVE_BLOCKS_UP':
  4093. {
  4094. const {
  4095. clientIds,
  4096. rootClientId = ''
  4097. } = action;
  4098. const firstClientId = clientIds[0];
  4099. const subState = state[rootClientId];
  4100. if (!subState.length || firstClientId === subState[0]) {
  4101. return state;
  4102. }
  4103. const firstIndex = subState.indexOf(firstClientId);
  4104. return { ...state,
  4105. [rootClientId]: moveTo(subState, firstIndex, firstIndex - 1, clientIds.length)
  4106. };
  4107. }
  4108. case 'MOVE_BLOCKS_DOWN':
  4109. {
  4110. const {
  4111. clientIds,
  4112. rootClientId = ''
  4113. } = action;
  4114. const firstClientId = clientIds[0];
  4115. const lastClientId = clientIds[clientIds.length - 1];
  4116. const subState = state[rootClientId];
  4117. if (!subState.length || lastClientId === subState[subState.length - 1]) {
  4118. return state;
  4119. }
  4120. const firstIndex = subState.indexOf(firstClientId);
  4121. return { ...state,
  4122. [rootClientId]: moveTo(subState, firstIndex, firstIndex + 1, clientIds.length)
  4123. };
  4124. }
  4125. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  4126. {
  4127. const {
  4128. clientIds
  4129. } = action;
  4130. if (!action.blocks) {
  4131. return state;
  4132. }
  4133. const mappedBlocks = mapBlockOrder(action.blocks);
  4134. return (0,external_lodash_namespaceObject.flow)([nextState => (0,external_lodash_namespaceObject.omit)(nextState, action.replacedClientIds), nextState => ({ ...nextState,
  4135. ...(0,external_lodash_namespaceObject.omit)(mappedBlocks, '')
  4136. }), nextState => (0,external_lodash_namespaceObject.mapValues)(nextState, subState => (0,external_lodash_namespaceObject.reduce)(subState, (result, clientId) => {
  4137. if (clientId === clientIds[0]) {
  4138. return [...result, ...mappedBlocks['']];
  4139. }
  4140. if (clientIds.indexOf(clientId) === -1) {
  4141. result.push(clientId);
  4142. }
  4143. return result;
  4144. }, []))])(state);
  4145. }
  4146. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  4147. return (0,external_lodash_namespaceObject.flow)([// Remove inner block ordering for removed blocks.
  4148. nextState => (0,external_lodash_namespaceObject.omit)(nextState, action.removedClientIds), // Remove deleted blocks from other blocks' orderings.
  4149. nextState => (0,external_lodash_namespaceObject.mapValues)(nextState, subState => (0,external_lodash_namespaceObject.without)(subState, ...action.removedClientIds))])(state);
  4150. }
  4151. return state;
  4152. },
  4153. // While technically redundant data as the inverse of `order`, it serves as
  4154. // an optimization for the selectors which derive the ancestry of a block.
  4155. parents() {
  4156. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4157. let action = arguments.length > 1 ? arguments[1] : undefined;
  4158. switch (action.type) {
  4159. case 'RECEIVE_BLOCKS':
  4160. return { ...state,
  4161. ...mapBlockParents(action.blocks)
  4162. };
  4163. case 'INSERT_BLOCKS':
  4164. return { ...state,
  4165. ...mapBlockParents(action.blocks, action.rootClientId || '')
  4166. };
  4167. case 'MOVE_BLOCKS_TO_POSITION':
  4168. {
  4169. return { ...state,
  4170. ...action.clientIds.reduce((accumulator, id) => {
  4171. accumulator[id] = action.toRootClientId || '';
  4172. return accumulator;
  4173. }, {})
  4174. };
  4175. }
  4176. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  4177. return { ...(0,external_lodash_namespaceObject.omit)(state, action.replacedClientIds),
  4178. ...mapBlockParents(action.blocks, state[action.clientIds[0]])
  4179. };
  4180. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  4181. return (0,external_lodash_namespaceObject.omit)(state, action.removedClientIds);
  4182. }
  4183. return state;
  4184. },
  4185. controlledInnerBlocks() {
  4186. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4187. let {
  4188. type,
  4189. clientId,
  4190. hasControlledInnerBlocks
  4191. } = arguments.length > 1 ? arguments[1] : undefined;
  4192. if (type === 'SET_HAS_CONTROLLED_INNER_BLOCKS') {
  4193. return { ...state,
  4194. [clientId]: hasControlledInnerBlocks
  4195. };
  4196. }
  4197. return state;
  4198. },
  4199. visibility() {
  4200. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4201. let action = arguments.length > 1 ? arguments[1] : undefined;
  4202. if (action.type === 'SET_BLOCK_VISIBILITY') {
  4203. return { ...state,
  4204. ...action.updates
  4205. };
  4206. }
  4207. return state;
  4208. }
  4209. });
  4210. /**
  4211. * Reducer returning typing state.
  4212. *
  4213. * @param {boolean} state Current state.
  4214. * @param {Object} action Dispatched action.
  4215. *
  4216. * @return {boolean} Updated state.
  4217. */
  4218. function isTyping() {
  4219. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4220. let action = arguments.length > 1 ? arguments[1] : undefined;
  4221. switch (action.type) {
  4222. case 'START_TYPING':
  4223. return true;
  4224. case 'STOP_TYPING':
  4225. return false;
  4226. }
  4227. return state;
  4228. }
  4229. /**
  4230. * Reducer returning dragged block client id.
  4231. *
  4232. * @param {string[]} state Current state.
  4233. * @param {Object} action Dispatched action.
  4234. *
  4235. * @return {string[]} Updated state.
  4236. */
  4237. function draggedBlocks() {
  4238. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  4239. let action = arguments.length > 1 ? arguments[1] : undefined;
  4240. switch (action.type) {
  4241. case 'START_DRAGGING_BLOCKS':
  4242. return action.clientIds;
  4243. case 'STOP_DRAGGING_BLOCKS':
  4244. return [];
  4245. }
  4246. return state;
  4247. }
  4248. /**
  4249. * Internal helper reducer for selectionStart and selectionEnd. Can hold a block
  4250. * selection, represented by an object with property clientId.
  4251. *
  4252. * @param {Object} state Current state.
  4253. * @param {Object} action Dispatched action.
  4254. *
  4255. * @return {Object} Updated state.
  4256. */
  4257. function selectionHelper() {
  4258. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4259. let action = arguments.length > 1 ? arguments[1] : undefined;
  4260. switch (action.type) {
  4261. case 'CLEAR_SELECTED_BLOCK':
  4262. {
  4263. if (state.clientId) {
  4264. return {};
  4265. }
  4266. return state;
  4267. }
  4268. case 'SELECT_BLOCK':
  4269. if (action.clientId === state.clientId) {
  4270. return state;
  4271. }
  4272. return {
  4273. clientId: action.clientId
  4274. };
  4275. case 'REPLACE_INNER_BLOCKS':
  4276. case 'INSERT_BLOCKS':
  4277. {
  4278. if (!action.updateSelection || !action.blocks.length) {
  4279. return state;
  4280. }
  4281. return {
  4282. clientId: action.blocks[0].clientId
  4283. };
  4284. }
  4285. case 'REMOVE_BLOCKS':
  4286. if (!action.clientIds || !action.clientIds.length || action.clientIds.indexOf(state.clientId) === -1) {
  4287. return state;
  4288. }
  4289. return {};
  4290. case 'REPLACE_BLOCKS':
  4291. {
  4292. if (action.clientIds.indexOf(state.clientId) === -1) {
  4293. return state;
  4294. }
  4295. const blockToSelect = action.blocks[action.indexToSelect] || action.blocks[action.blocks.length - 1];
  4296. if (!blockToSelect) {
  4297. return {};
  4298. }
  4299. if (blockToSelect.clientId === state.clientId) {
  4300. return state;
  4301. }
  4302. return {
  4303. clientId: blockToSelect.clientId
  4304. };
  4305. }
  4306. }
  4307. return state;
  4308. }
  4309. /**
  4310. * Reducer returning the selection state.
  4311. *
  4312. * @param {boolean} state Current state.
  4313. * @param {Object} action Dispatched action.
  4314. *
  4315. * @return {boolean} Updated state.
  4316. */
  4317. function selection() {
  4318. var _state$selectionStart, _state$selectionEnd, _state$selectionStart2, _state$selectionEnd2;
  4319. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4320. let action = arguments.length > 1 ? arguments[1] : undefined;
  4321. switch (action.type) {
  4322. case 'SELECTION_CHANGE':
  4323. if (action.clientId) {
  4324. return {
  4325. selectionStart: {
  4326. clientId: action.clientId,
  4327. attributeKey: action.attributeKey,
  4328. offset: action.startOffset
  4329. },
  4330. selectionEnd: {
  4331. clientId: action.clientId,
  4332. attributeKey: action.attributeKey,
  4333. offset: action.endOffset
  4334. }
  4335. };
  4336. }
  4337. return {
  4338. selectionStart: action.start || state.selectionStart,
  4339. selectionEnd: action.end || state.selectionEnd
  4340. };
  4341. case 'RESET_SELECTION':
  4342. const {
  4343. selectionStart,
  4344. selectionEnd
  4345. } = action;
  4346. return {
  4347. selectionStart,
  4348. selectionEnd
  4349. };
  4350. case 'MULTI_SELECT':
  4351. const {
  4352. start,
  4353. end
  4354. } = action;
  4355. if (start === ((_state$selectionStart = state.selectionStart) === null || _state$selectionStart === void 0 ? void 0 : _state$selectionStart.clientId) && end === ((_state$selectionEnd = state.selectionEnd) === null || _state$selectionEnd === void 0 ? void 0 : _state$selectionEnd.clientId)) {
  4356. return state;
  4357. }
  4358. return {
  4359. selectionStart: {
  4360. clientId: start
  4361. },
  4362. selectionEnd: {
  4363. clientId: end
  4364. }
  4365. };
  4366. case 'RESET_BLOCKS':
  4367. const startClientId = state === null || state === void 0 ? void 0 : (_state$selectionStart2 = state.selectionStart) === null || _state$selectionStart2 === void 0 ? void 0 : _state$selectionStart2.clientId;
  4368. const endClientId = state === null || state === void 0 ? void 0 : (_state$selectionEnd2 = state.selectionEnd) === null || _state$selectionEnd2 === void 0 ? void 0 : _state$selectionEnd2.clientId; // Do nothing if there's no selected block.
  4369. if (!startClientId && !endClientId) {
  4370. return state;
  4371. } // If the start of the selection won't exist after reset, remove selection.
  4372. if (!action.blocks.some(block => block.clientId === startClientId)) {
  4373. return {
  4374. selectionStart: {},
  4375. selectionEnd: {}
  4376. };
  4377. } // If the end of the selection won't exist after reset, collapse selection.
  4378. if (!action.blocks.some(block => block.clientId === endClientId)) {
  4379. return { ...state,
  4380. selectionEnd: state.selectionStart
  4381. };
  4382. }
  4383. }
  4384. return {
  4385. selectionStart: selectionHelper(state.selectionStart, action),
  4386. selectionEnd: selectionHelper(state.selectionEnd, action)
  4387. };
  4388. }
  4389. /**
  4390. * Reducer returning whether the user is multi-selecting.
  4391. *
  4392. * @param {boolean} state Current state.
  4393. * @param {Object} action Dispatched action.
  4394. *
  4395. * @return {boolean} Updated state.
  4396. */
  4397. function isMultiSelecting() {
  4398. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4399. let action = arguments.length > 1 ? arguments[1] : undefined;
  4400. switch (action.type) {
  4401. case 'START_MULTI_SELECT':
  4402. return true;
  4403. case 'STOP_MULTI_SELECT':
  4404. return false;
  4405. }
  4406. return state;
  4407. }
  4408. /**
  4409. * Reducer returning whether selection is enabled.
  4410. *
  4411. * @param {boolean} state Current state.
  4412. * @param {Object} action Dispatched action.
  4413. *
  4414. * @return {boolean} Updated state.
  4415. */
  4416. function isSelectionEnabled() {
  4417. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  4418. let action = arguments.length > 1 ? arguments[1] : undefined;
  4419. switch (action.type) {
  4420. case 'TOGGLE_SELECTION':
  4421. return action.isSelectionEnabled;
  4422. }
  4423. return state;
  4424. }
  4425. /**
  4426. * Reducer returning the initial block selection.
  4427. *
  4428. * Currently this in only used to restore the selection after block deletion and
  4429. * pasting new content.This reducer should eventually be removed in favour of setting
  4430. * selection directly.
  4431. *
  4432. * @param {boolean} state Current state.
  4433. * @param {Object} action Dispatched action.
  4434. *
  4435. * @return {number|null} Initial position: 0, -1 or null.
  4436. */
  4437. function initialPosition() {
  4438. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4439. let action = arguments.length > 1 ? arguments[1] : undefined;
  4440. if (action.type === 'REPLACE_BLOCKS' && action.initialPosition !== undefined) {
  4441. return action.initialPosition;
  4442. } else if (['MULTI_SELECT', 'SELECT_BLOCK', 'RESET_SELECTION', 'INSERT_BLOCKS', 'REPLACE_INNER_BLOCKS'].includes(action.type)) {
  4443. return action.initialPosition;
  4444. }
  4445. return state;
  4446. }
  4447. function blocksMode() {
  4448. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4449. let action = arguments.length > 1 ? arguments[1] : undefined;
  4450. if (action.type === 'TOGGLE_BLOCK_MODE') {
  4451. const {
  4452. clientId
  4453. } = action;
  4454. return { ...state,
  4455. [clientId]: state[clientId] && state[clientId] === 'html' ? 'visual' : 'html'
  4456. };
  4457. }
  4458. return state;
  4459. }
  4460. /**
  4461. * Reducer returning the block insertion point visibility, either null if there
  4462. * is not an explicit insertion point assigned, or an object of its `index` and
  4463. * `rootClientId`.
  4464. *
  4465. * @param {Object} state Current state.
  4466. * @param {Object} action Dispatched action.
  4467. *
  4468. * @return {Object} Updated state.
  4469. */
  4470. function insertionPoint() {
  4471. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4472. let action = arguments.length > 1 ? arguments[1] : undefined;
  4473. switch (action.type) {
  4474. case 'SHOW_INSERTION_POINT':
  4475. const {
  4476. rootClientId,
  4477. index,
  4478. __unstableWithInserter
  4479. } = action;
  4480. return {
  4481. rootClientId,
  4482. index,
  4483. __unstableWithInserter
  4484. };
  4485. case 'HIDE_INSERTION_POINT':
  4486. return null;
  4487. }
  4488. return state;
  4489. }
  4490. /**
  4491. * Reducer returning whether the post blocks match the defined template or not.
  4492. *
  4493. * @param {Object} state Current state.
  4494. * @param {Object} action Dispatched action.
  4495. *
  4496. * @return {boolean} Updated state.
  4497. */
  4498. function template() {
  4499. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  4500. isValid: true
  4501. };
  4502. let action = arguments.length > 1 ? arguments[1] : undefined;
  4503. switch (action.type) {
  4504. case 'SET_TEMPLATE_VALIDITY':
  4505. return { ...state,
  4506. isValid: action.isValid
  4507. };
  4508. }
  4509. return state;
  4510. }
  4511. /**
  4512. * Reducer returning the editor setting.
  4513. *
  4514. * @param {Object} state Current state.
  4515. * @param {Object} action Dispatched action.
  4516. *
  4517. * @return {Object} Updated state.
  4518. */
  4519. function settings() {
  4520. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SETTINGS_DEFAULTS;
  4521. let action = arguments.length > 1 ? arguments[1] : undefined;
  4522. switch (action.type) {
  4523. case 'UPDATE_SETTINGS':
  4524. return { ...state,
  4525. ...action.settings
  4526. };
  4527. }
  4528. return state;
  4529. }
  4530. /**
  4531. * Reducer returning the user preferences.
  4532. *
  4533. * @param {Object} state Current state.
  4534. * @param {Object} action Dispatched action.
  4535. *
  4536. * @return {string} Updated state.
  4537. */
  4538. function preferences() {
  4539. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PREFERENCES_DEFAULTS;
  4540. let action = arguments.length > 1 ? arguments[1] : undefined;
  4541. switch (action.type) {
  4542. case 'INSERT_BLOCKS':
  4543. case 'REPLACE_BLOCKS':
  4544. return action.blocks.reduce((prevState, block) => {
  4545. const {
  4546. attributes,
  4547. name: blockName
  4548. } = block;
  4549. const match = (0,external_wp_data_namespaceObject.select)(external_wp_blocks_namespaceObject.store).getActiveBlockVariation(blockName, attributes); // If a block variation match is found change the name to be the same with the
  4550. // one that is used for block variations in the Inserter (`getItemFromVariation`).
  4551. let id = match !== null && match !== void 0 && match.name ? `${blockName}/${match.name}` : blockName;
  4552. const insert = {
  4553. name: id
  4554. };
  4555. if (blockName === 'core/block') {
  4556. insert.ref = attributes.ref;
  4557. id += '/' + attributes.ref;
  4558. }
  4559. return { ...prevState,
  4560. insertUsage: { ...prevState.insertUsage,
  4561. [id]: {
  4562. time: action.time,
  4563. count: prevState.insertUsage[id] ? prevState.insertUsage[id].count + 1 : 1,
  4564. insert
  4565. }
  4566. }
  4567. };
  4568. }, state);
  4569. }
  4570. return state;
  4571. }
  4572. /**
  4573. * Reducer returning an object where each key is a block client ID, its value
  4574. * representing the settings for its nested blocks.
  4575. *
  4576. * @param {Object} state Current state.
  4577. * @param {Object} action Dispatched action.
  4578. *
  4579. * @return {Object} Updated state.
  4580. */
  4581. const blockListSettings = function () {
  4582. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4583. let action = arguments.length > 1 ? arguments[1] : undefined;
  4584. switch (action.type) {
  4585. // Even if the replaced blocks have the same client ID, our logic
  4586. // should correct the state.
  4587. case 'REPLACE_BLOCKS':
  4588. case 'REMOVE_BLOCKS':
  4589. {
  4590. return (0,external_lodash_namespaceObject.omit)(state, action.clientIds);
  4591. }
  4592. case 'UPDATE_BLOCK_LIST_SETTINGS':
  4593. {
  4594. const {
  4595. clientId
  4596. } = action;
  4597. if (!action.settings) {
  4598. if (state.hasOwnProperty(clientId)) {
  4599. return (0,external_lodash_namespaceObject.omit)(state, clientId);
  4600. }
  4601. return state;
  4602. }
  4603. if ((0,external_lodash_namespaceObject.isEqual)(state[clientId], action.settings)) {
  4604. return state;
  4605. }
  4606. return { ...state,
  4607. [clientId]: action.settings
  4608. };
  4609. }
  4610. }
  4611. return state;
  4612. };
  4613. /**
  4614. * Reducer returning which mode is enabled.
  4615. *
  4616. * @param {string} state Current state.
  4617. * @param {Object} action Dispatched action.
  4618. *
  4619. * @return {string} Updated state.
  4620. */
  4621. function editorMode() {
  4622. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'edit';
  4623. let action = arguments.length > 1 ? arguments[1] : undefined;
  4624. // Let inserting block in navigation mode always trigger Edit mode.
  4625. if (action.type === 'INSERT_BLOCKS' && state === 'navigation') {
  4626. return 'edit';
  4627. }
  4628. if (action.type === 'SET_EDITOR_MODE') {
  4629. return action.mode;
  4630. }
  4631. return state;
  4632. }
  4633. /**
  4634. * Reducer returning whether the block moving mode is enabled or not.
  4635. *
  4636. * @param {string|null} state Current state.
  4637. * @param {Object} action Dispatched action.
  4638. *
  4639. * @return {string|null} Updated state.
  4640. */
  4641. function hasBlockMovingClientId() {
  4642. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4643. let action = arguments.length > 1 ? arguments[1] : undefined;
  4644. if (action.type === 'SET_BLOCK_MOVING_MODE') {
  4645. return action.hasBlockMovingClientId;
  4646. }
  4647. if (action.type === 'SET_EDITOR_MODE') {
  4648. return null;
  4649. }
  4650. return state;
  4651. }
  4652. /**
  4653. * Reducer return an updated state representing the most recent block attribute
  4654. * update. The state is structured as an object where the keys represent the
  4655. * client IDs of blocks, the values a subset of attributes from the most recent
  4656. * block update. The state is always reset to null if the last action is
  4657. * anything other than an attributes update.
  4658. *
  4659. * @param {Object<string,Object>} state Current state.
  4660. * @param {Object} action Action object.
  4661. *
  4662. * @return {[string,Object]} Updated state.
  4663. */
  4664. function lastBlockAttributesChange(state, action) {
  4665. switch (action.type) {
  4666. case 'UPDATE_BLOCK':
  4667. if (!action.updates.attributes) {
  4668. break;
  4669. }
  4670. return {
  4671. [action.clientId]: action.updates.attributes
  4672. };
  4673. case 'UPDATE_BLOCK_ATTRIBUTES':
  4674. return action.clientIds.reduce((accumulator, id) => ({ ...accumulator,
  4675. [id]: action.uniqueByBlock ? action.attributes[id] : action.attributes
  4676. }), {});
  4677. }
  4678. return null;
  4679. }
  4680. /**
  4681. * Reducer returning automatic change state.
  4682. *
  4683. * @param {?string} state Current state.
  4684. * @param {Object} action Dispatched action.
  4685. *
  4686. * @return {string} Updated state.
  4687. */
  4688. function automaticChangeStatus(state, action) {
  4689. switch (action.type) {
  4690. case 'MARK_AUTOMATIC_CHANGE':
  4691. return 'pending';
  4692. case 'MARK_AUTOMATIC_CHANGE_FINAL':
  4693. if (state === 'pending') {
  4694. return 'final';
  4695. }
  4696. return;
  4697. case 'SELECTION_CHANGE':
  4698. // As long as the state is not final, ignore any selection changes.
  4699. if (state !== 'final') {
  4700. return state;
  4701. }
  4702. return;
  4703. // Undoing an automatic change should still be possible after mouse
  4704. // move or after visibility change.
  4705. case 'SET_BLOCK_VISIBILITY':
  4706. case 'START_TYPING':
  4707. case 'STOP_TYPING':
  4708. case 'UPDATE_BLOCK_LIST_SETTINGS':
  4709. return state;
  4710. } // TODO: This is a source of bug, as each time there's a change in timing,
  4711. // or a new action is added, this could break.
  4712. // Reset the state by default (for any action not handled).
  4713. }
  4714. /**
  4715. * Reducer returning current highlighted block.
  4716. *
  4717. * @param {boolean} state Current highlighted block.
  4718. * @param {Object} action Dispatched action.
  4719. *
  4720. * @return {string} Updated state.
  4721. */
  4722. function highlightedBlock(state, action) {
  4723. switch (action.type) {
  4724. case 'TOGGLE_BLOCK_HIGHLIGHT':
  4725. const {
  4726. clientId,
  4727. isHighlighted
  4728. } = action;
  4729. if (isHighlighted) {
  4730. return clientId;
  4731. } else if (state === clientId) {
  4732. return null;
  4733. }
  4734. return state;
  4735. case 'SELECT_BLOCK':
  4736. if (action.clientId !== state) {
  4737. return null;
  4738. }
  4739. }
  4740. return state;
  4741. }
  4742. /**
  4743. * Reducer returning the block insertion event list state.
  4744. *
  4745. * @param {Object} state Current state.
  4746. * @param {Object} action Dispatched action.
  4747. *
  4748. * @return {Object} Updated state.
  4749. */
  4750. function lastBlockInserted() {
  4751. var _action$meta;
  4752. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4753. let action = arguments.length > 1 ? arguments[1] : undefined;
  4754. switch (action.type) {
  4755. case 'INSERT_BLOCKS':
  4756. if (!action.blocks.length) {
  4757. return state;
  4758. }
  4759. const clientId = action.blocks[0].clientId;
  4760. const source = (_action$meta = action.meta) === null || _action$meta === void 0 ? void 0 : _action$meta.source;
  4761. return {
  4762. clientId,
  4763. source
  4764. };
  4765. case 'RESET_BLOCKS':
  4766. return {};
  4767. }
  4768. return state;
  4769. }
  4770. /**
  4771. * Reducer returning the block that is eding temporarily edited as blocks.
  4772. *
  4773. * @param {Object} state Current state.
  4774. * @param {Object} action Dispatched action.
  4775. *
  4776. * @return {Object} Updated state.
  4777. */
  4778. function temporarilyEditingAsBlocks() {
  4779. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  4780. let action = arguments.length > 1 ? arguments[1] : undefined;
  4781. if (action.type === 'SET_TEMPORARILY_EDITING_AS_BLOCKS') {
  4782. return action.temporarilyEditingAsBlocks;
  4783. }
  4784. return state;
  4785. }
  4786. /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  4787. blocks,
  4788. isTyping,
  4789. draggedBlocks,
  4790. selection,
  4791. isMultiSelecting,
  4792. isSelectionEnabled,
  4793. initialPosition,
  4794. blocksMode,
  4795. blockListSettings,
  4796. insertionPoint,
  4797. template,
  4798. settings,
  4799. preferences,
  4800. lastBlockAttributesChange,
  4801. editorMode,
  4802. hasBlockMovingClientId,
  4803. automaticChangeStatus,
  4804. highlightedBlock,
  4805. lastBlockInserted,
  4806. temporarilyEditingAsBlocks
  4807. }));
  4808. ;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js
  4809. /** @typedef {(...args: any[]) => *[]} GetDependants */
  4810. /** @typedef {() => void} Clear */
  4811. /**
  4812. * @typedef {{
  4813. * getDependants: GetDependants,
  4814. * clear: Clear
  4815. * }} EnhancedSelector
  4816. */
  4817. /**
  4818. * Internal cache entry.
  4819. *
  4820. * @typedef CacheNode
  4821. *
  4822. * @property {?CacheNode|undefined} [prev] Previous node.
  4823. * @property {?CacheNode|undefined} [next] Next node.
  4824. * @property {*[]} args Function arguments for cache entry.
  4825. * @property {*} val Function result.
  4826. */
  4827. /**
  4828. * @typedef Cache
  4829. *
  4830. * @property {Clear} clear Function to clear cache.
  4831. * @property {boolean} [isUniqueByDependants] Whether dependants are valid in
  4832. * considering cache uniqueness. A cache is unique if dependents are all arrays
  4833. * or objects.
  4834. * @property {CacheNode?} [head] Cache head.
  4835. * @property {*[]} [lastDependants] Dependants from previous invocation.
  4836. */
  4837. /**
  4838. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  4839. *
  4840. * @type {{}}
  4841. */
  4842. var LEAF_KEY = {};
  4843. /**
  4844. * Returns the first argument as the sole entry in an array.
  4845. *
  4846. * @template T
  4847. *
  4848. * @param {T} value Value to return.
  4849. *
  4850. * @return {[T]} Value returned as entry in array.
  4851. */
  4852. function arrayOf(value) {
  4853. return [value];
  4854. }
  4855. /**
  4856. * Returns true if the value passed is object-like, or false otherwise. A value
  4857. * is object-like if it can support property assignment, e.g. object or array.
  4858. *
  4859. * @param {*} value Value to test.
  4860. *
  4861. * @return {boolean} Whether value is object-like.
  4862. */
  4863. function isObjectLike(value) {
  4864. return !!value && 'object' === typeof value;
  4865. }
  4866. /**
  4867. * Creates and returns a new cache object.
  4868. *
  4869. * @return {Cache} Cache object.
  4870. */
  4871. function createCache() {
  4872. /** @type {Cache} */
  4873. var cache = {
  4874. clear: function () {
  4875. cache.head = null;
  4876. },
  4877. };
  4878. return cache;
  4879. }
  4880. /**
  4881. * Returns true if entries within the two arrays are strictly equal by
  4882. * reference from a starting index.
  4883. *
  4884. * @param {*[]} a First array.
  4885. * @param {*[]} b Second array.
  4886. * @param {number} fromIndex Index from which to start comparison.
  4887. *
  4888. * @return {boolean} Whether arrays are shallowly equal.
  4889. */
  4890. function isShallowEqual(a, b, fromIndex) {
  4891. var i;
  4892. if (a.length !== b.length) {
  4893. return false;
  4894. }
  4895. for (i = fromIndex; i < a.length; i++) {
  4896. if (a[i] !== b[i]) {
  4897. return false;
  4898. }
  4899. }
  4900. return true;
  4901. }
  4902. /**
  4903. * Returns a memoized selector function. The getDependants function argument is
  4904. * called before the memoized selector and is expected to return an immutable
  4905. * reference or array of references on which the selector depends for computing
  4906. * its own return value. The memoize cache is preserved only as long as those
  4907. * dependant references remain the same. If getDependants returns a different
  4908. * reference(s), the cache is cleared and the selector value regenerated.
  4909. *
  4910. * @template {(...args: *[]) => *} S
  4911. *
  4912. * @param {S} selector Selector function.
  4913. * @param {GetDependants=} getDependants Dependant getter returning an array of
  4914. * references used in cache bust consideration.
  4915. */
  4916. /* harmony default export */ function rememo(selector, getDependants) {
  4917. /** @type {WeakMap<*,*>} */
  4918. var rootCache;
  4919. /** @type {GetDependants} */
  4920. var normalizedGetDependants = getDependants ? getDependants : arrayOf;
  4921. /**
  4922. * Returns the cache for a given dependants array. When possible, a WeakMap
  4923. * will be used to create a unique cache for each set of dependants. This
  4924. * is feasible due to the nature of WeakMap in allowing garbage collection
  4925. * to occur on entries where the key object is no longer referenced. Since
  4926. * WeakMap requires the key to be an object, this is only possible when the
  4927. * dependant is object-like. The root cache is created as a hierarchy where
  4928. * each top-level key is the first entry in a dependants set, the value a
  4929. * WeakMap where each key is the next dependant, and so on. This continues
  4930. * so long as the dependants are object-like. If no dependants are object-
  4931. * like, then the cache is shared across all invocations.
  4932. *
  4933. * @see isObjectLike
  4934. *
  4935. * @param {*[]} dependants Selector dependants.
  4936. *
  4937. * @return {Cache} Cache object.
  4938. */
  4939. function getCache(dependants) {
  4940. var caches = rootCache,
  4941. isUniqueByDependants = true,
  4942. i,
  4943. dependant,
  4944. map,
  4945. cache;
  4946. for (i = 0; i < dependants.length; i++) {
  4947. dependant = dependants[i];
  4948. // Can only compose WeakMap from object-like key.
  4949. if (!isObjectLike(dependant)) {
  4950. isUniqueByDependants = false;
  4951. break;
  4952. }
  4953. // Does current segment of cache already have a WeakMap?
  4954. if (caches.has(dependant)) {
  4955. // Traverse into nested WeakMap.
  4956. caches = caches.get(dependant);
  4957. } else {
  4958. // Create, set, and traverse into a new one.
  4959. map = new WeakMap();
  4960. caches.set(dependant, map);
  4961. caches = map;
  4962. }
  4963. }
  4964. // We use an arbitrary (but consistent) object as key for the last item
  4965. // in the WeakMap to serve as our running cache.
  4966. if (!caches.has(LEAF_KEY)) {
  4967. cache = createCache();
  4968. cache.isUniqueByDependants = isUniqueByDependants;
  4969. caches.set(LEAF_KEY, cache);
  4970. }
  4971. return caches.get(LEAF_KEY);
  4972. }
  4973. /**
  4974. * Resets root memoization cache.
  4975. */
  4976. function clear() {
  4977. rootCache = new WeakMap();
  4978. }
  4979. /* eslint-disable jsdoc/check-param-names */
  4980. /**
  4981. * The augmented selector call, considering first whether dependants have
  4982. * changed before passing it to underlying memoize function.
  4983. *
  4984. * @param {*} source Source object for derivation.
  4985. * @param {...*} extraArgs Additional arguments to pass to selector.
  4986. *
  4987. * @return {*} Selector result.
  4988. */
  4989. /* eslint-enable jsdoc/check-param-names */
  4990. function callSelector(/* source, ...extraArgs */) {
  4991. var len = arguments.length,
  4992. cache,
  4993. node,
  4994. i,
  4995. args,
  4996. dependants;
  4997. // Create copy of arguments (avoid leaking deoptimization).
  4998. args = new Array(len);
  4999. for (i = 0; i < len; i++) {
  5000. args[i] = arguments[i];
  5001. }
  5002. dependants = normalizedGetDependants.apply(null, args);
  5003. cache = getCache(dependants);
  5004. // If not guaranteed uniqueness by dependants (primitive type), shallow
  5005. // compare against last dependants and, if references have changed,
  5006. // destroy cache to recalculate result.
  5007. if (!cache.isUniqueByDependants) {
  5008. if (
  5009. cache.lastDependants &&
  5010. !isShallowEqual(dependants, cache.lastDependants, 0)
  5011. ) {
  5012. cache.clear();
  5013. }
  5014. cache.lastDependants = dependants;
  5015. }
  5016. node = cache.head;
  5017. while (node) {
  5018. // Check whether node arguments match arguments
  5019. if (!isShallowEqual(node.args, args, 1)) {
  5020. node = node.next;
  5021. continue;
  5022. }
  5023. // At this point we can assume we've found a match
  5024. // Surface matched node to head if not already
  5025. if (node !== cache.head) {
  5026. // Adjust siblings to point to each other.
  5027. /** @type {CacheNode} */ (node.prev).next = node.next;
  5028. if (node.next) {
  5029. node.next.prev = node.prev;
  5030. }
  5031. node.next = cache.head;
  5032. node.prev = null;
  5033. /** @type {CacheNode} */ (cache.head).prev = node;
  5034. cache.head = node;
  5035. }
  5036. // Return immediately
  5037. return node.val;
  5038. }
  5039. // No cached value found. Continue to insertion phase:
  5040. node = /** @type {CacheNode} */ ({
  5041. // Generate the result from original function
  5042. val: selector.apply(null, args),
  5043. });
  5044. // Avoid including the source object in the cache.
  5045. args[0] = null;
  5046. node.args = args;
  5047. // Don't need to check whether node is already head, since it would
  5048. // have been returned above already if it was
  5049. // Shift existing head down list
  5050. if (cache.head) {
  5051. cache.head.prev = node;
  5052. node.next = cache.head;
  5053. }
  5054. cache.head = node;
  5055. return node.val;
  5056. }
  5057. callSelector.getDependants = normalizedGetDependants;
  5058. callSelector.clear = clear;
  5059. clear();
  5060. return /** @type {S & EnhancedSelector} */ (callSelector);
  5061. }
  5062. ;// CONCATENATED MODULE: external ["wp","primitives"]
  5063. var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
  5064. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js
  5065. /**
  5066. * WordPress dependencies
  5067. */
  5068. const symbol = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  5069. xmlns: "http://www.w3.org/2000/svg",
  5070. viewBox: "0 0 24 24"
  5071. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  5072. d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
  5073. }));
  5074. /* harmony default export */ var library_symbol = (symbol);
  5075. ;// CONCATENATED MODULE: external ["wp","richText"]
  5076. var external_wp_richText_namespaceObject = window["wp"]["richText"];
  5077. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  5078. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  5079. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  5080. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/utils.js
  5081. /**
  5082. * Helper function that maps attribute definition properties to the
  5083. * ones used by RichText utils like `create, toHTMLString, etc..`.
  5084. *
  5085. * @param {Object} attributeDefinition A block's attribute definition object.
  5086. * @return {Object} The mapped object.
  5087. */
  5088. function mapRichTextSettings(attributeDefinition) {
  5089. const {
  5090. multiline: multilineTag,
  5091. __unstableMultilineWrapperTags: multilineWrapperTags,
  5092. __unstablePreserveWhiteSpace: preserveWhiteSpace
  5093. } = attributeDefinition;
  5094. return {
  5095. multilineTag,
  5096. multilineWrapperTags,
  5097. preserveWhiteSpace
  5098. };
  5099. }
  5100. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js
  5101. /**
  5102. * External dependencies
  5103. */
  5104. /**
  5105. * WordPress dependencies
  5106. */
  5107. /**
  5108. * Internal dependencies
  5109. */
  5110. /**
  5111. * A block selection object.
  5112. *
  5113. * @typedef {Object} WPBlockSelection
  5114. *
  5115. * @property {string} clientId A block client ID.
  5116. * @property {string} attributeKey A block attribute key.
  5117. * @property {number} offset An attribute value offset, based on the rich
  5118. * text value. See `wp.richText.create`.
  5119. */
  5120. // Module constants.
  5121. const MILLISECONDS_PER_HOUR = 3600 * 1000;
  5122. const MILLISECONDS_PER_DAY = 24 * 3600 * 1000;
  5123. const MILLISECONDS_PER_WEEK = 7 * 24 * 3600 * 1000;
  5124. /**
  5125. * Shared reference to an empty array for cases where it is important to avoid
  5126. * returning a new array reference on every invocation, as in a connected or
  5127. * other pure component which performs `shouldComponentUpdate` check on props.
  5128. * This should be used as a last resort, since the normalized data should be
  5129. * maintained by the reducer result in state.
  5130. *
  5131. * @type {Array}
  5132. */
  5133. const EMPTY_ARRAY = [];
  5134. /**
  5135. * Returns a block's name given its client ID, or null if no block exists with
  5136. * the client ID.
  5137. *
  5138. * @param {Object} state Editor state.
  5139. * @param {string} clientId Block client ID.
  5140. *
  5141. * @return {string} Block name.
  5142. */
  5143. function getBlockName(state, clientId) {
  5144. const block = state.blocks.byClientId[clientId];
  5145. const socialLinkName = 'core/social-link';
  5146. if (external_wp_element_namespaceObject.Platform.OS !== 'web' && (block === null || block === void 0 ? void 0 : block.name) === socialLinkName) {
  5147. const attributes = state.blocks.attributes[clientId];
  5148. const {
  5149. service
  5150. } = attributes;
  5151. return service ? `${socialLinkName}-${service}` : socialLinkName;
  5152. }
  5153. return block ? block.name : null;
  5154. }
  5155. /**
  5156. * Returns whether a block is valid or not.
  5157. *
  5158. * @param {Object} state Editor state.
  5159. * @param {string} clientId Block client ID.
  5160. *
  5161. * @return {boolean} Is Valid.
  5162. */
  5163. function isBlockValid(state, clientId) {
  5164. const block = state.blocks.byClientId[clientId];
  5165. return !!block && block.isValid;
  5166. }
  5167. /**
  5168. * Returns a block's attributes given its client ID, or null if no block exists with
  5169. * the client ID.
  5170. *
  5171. * @param {Object} state Editor state.
  5172. * @param {string} clientId Block client ID.
  5173. *
  5174. * @return {Object?} Block attributes.
  5175. */
  5176. function getBlockAttributes(state, clientId) {
  5177. const block = state.blocks.byClientId[clientId];
  5178. if (!block) {
  5179. return null;
  5180. }
  5181. return state.blocks.attributes[clientId];
  5182. }
  5183. /**
  5184. * Returns a block given its client ID. This is a parsed copy of the block,
  5185. * containing its `blockName`, `clientId`, and current `attributes` state. This
  5186. * is not the block's registration settings, which must be retrieved from the
  5187. * blocks module registration store.
  5188. *
  5189. * getBlock recurses through its inner blocks until all its children blocks have
  5190. * been retrieved. Note that getBlock will not return the child inner blocks of
  5191. * an inner block controller. This is because an inner block controller syncs
  5192. * itself with its own entity, and should therefore not be included with the
  5193. * blocks of a different entity. For example, say you call `getBlocks( TP )` to
  5194. * get the blocks of a template part. If another template part is a child of TP,
  5195. * then the nested template part's child blocks will not be returned. This way,
  5196. * the template block itself is considered part of the parent, but the children
  5197. * are not.
  5198. *
  5199. * @param {Object} state Editor state.
  5200. * @param {string} clientId Block client ID.
  5201. *
  5202. * @return {Object} Parsed block object.
  5203. */
  5204. function getBlock(state, clientId) {
  5205. const block = state.blocks.byClientId[clientId];
  5206. if (!block) {
  5207. return null;
  5208. }
  5209. return state.blocks.tree[clientId];
  5210. }
  5211. const __unstableGetBlockWithoutInnerBlocks = rememo((state, clientId) => {
  5212. const block = state.blocks.byClientId[clientId];
  5213. if (!block) {
  5214. return null;
  5215. }
  5216. return { ...block,
  5217. attributes: getBlockAttributes(state, clientId)
  5218. };
  5219. }, (state, clientId) => [state.blocks.byClientId[clientId], state.blocks.attributes[clientId]]);
  5220. /**
  5221. * Returns all block objects for the current post being edited as an array in
  5222. * the order they appear in the post. Note that this will exclude child blocks
  5223. * of nested inner block controllers.
  5224. *
  5225. * @param {Object} state Editor state.
  5226. * @param {?string} rootClientId Optional root client ID of block list.
  5227. *
  5228. * @return {Object[]} Post blocks.
  5229. */
  5230. function getBlocks(state, rootClientId) {
  5231. var _state$blocks$tree$tr;
  5232. const treeKey = !rootClientId || !areInnerBlocksControlled(state, rootClientId) ? rootClientId || '' : 'controlled||' + rootClientId;
  5233. return ((_state$blocks$tree$tr = state.blocks.tree[treeKey]) === null || _state$blocks$tree$tr === void 0 ? void 0 : _state$blocks$tree$tr.innerBlocks) || EMPTY_ARRAY;
  5234. }
  5235. /**
  5236. * Returns a stripped down block object containing only its client ID,
  5237. * and its inner blocks' client IDs.
  5238. *
  5239. * @param {Object} state Editor state.
  5240. * @param {string} clientId Client ID of the block to get.
  5241. *
  5242. * @return {Object} Client IDs of the post blocks.
  5243. */
  5244. const __unstableGetClientIdWithClientIdsTree = rememo((state, clientId) => ({
  5245. clientId,
  5246. innerBlocks: __unstableGetClientIdsTree(state, clientId)
  5247. }), state => [state.blocks.order]);
  5248. /**
  5249. * Returns the block tree represented in the block-editor store from the
  5250. * given root, consisting of stripped down block objects containing only
  5251. * their client IDs, and their inner blocks' client IDs.
  5252. *
  5253. * @param {Object} state Editor state.
  5254. * @param {?string} rootClientId Optional root client ID of block list.
  5255. *
  5256. * @return {Object[]} Client IDs of the post blocks.
  5257. */
  5258. const __unstableGetClientIdsTree = rememo(function (state) {
  5259. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  5260. return (0,external_lodash_namespaceObject.map)(getBlockOrder(state, rootClientId), clientId => __unstableGetClientIdWithClientIdsTree(state, clientId));
  5261. }, state => [state.blocks.order]);
  5262. /**
  5263. * Returns an array containing the clientIds of all descendants of the blocks
  5264. * given. Returned ids are ordered first by the order of the ids given, then
  5265. * by the order that they appear in the editor.
  5266. *
  5267. * @param {Object} state Global application state.
  5268. * @param {Array} clientIds Array of blocks to inspect.
  5269. *
  5270. * @return {Array} ids of descendants.
  5271. */
  5272. const getClientIdsOfDescendants = rememo((state, clientIds) => {
  5273. const collectedIds = [];
  5274. for (const givenId of clientIds) {
  5275. for (const descendantId of getBlockOrder(state, givenId)) {
  5276. collectedIds.push(descendantId, ...getClientIdsOfDescendants(state, [descendantId]));
  5277. }
  5278. }
  5279. return collectedIds;
  5280. }, state => [state.blocks.order]);
  5281. /**
  5282. * Returns an array containing the clientIds of the top-level blocks and
  5283. * their descendants of any depth (for nested blocks). Ids are returned
  5284. * in the same order that they appear in the editor.
  5285. *
  5286. * @param {Object} state Global application state.
  5287. *
  5288. * @return {Array} ids of top-level and descendant blocks.
  5289. */
  5290. const getClientIdsWithDescendants = rememo(state => {
  5291. const collectedIds = [];
  5292. for (const topLevelId of getBlockOrder(state)) {
  5293. collectedIds.push(topLevelId, ...getClientIdsOfDescendants(state, [topLevelId]));
  5294. }
  5295. return collectedIds;
  5296. }, state => [state.blocks.order]);
  5297. /**
  5298. * Returns the total number of blocks, or the total number of blocks with a specific name in a post.
  5299. * The number returned includes nested blocks.
  5300. *
  5301. * @param {Object} state Global application state.
  5302. * @param {?string} blockName Optional block name, if specified only blocks of that type will be counted.
  5303. *
  5304. * @return {number} Number of blocks in the post, or number of blocks with name equal to blockName.
  5305. */
  5306. const getGlobalBlockCount = rememo((state, blockName) => {
  5307. const clientIds = getClientIdsWithDescendants(state);
  5308. if (!blockName) {
  5309. return clientIds.length;
  5310. }
  5311. return (0,external_lodash_namespaceObject.reduce)(clientIds, (accumulator, clientId) => {
  5312. const block = state.blocks.byClientId[clientId];
  5313. return block.name === blockName ? accumulator + 1 : accumulator;
  5314. }, 0);
  5315. }, state => [state.blocks.order, state.blocks.byClientId]);
  5316. /**
  5317. * Returns all global blocks that match a blockName. Results include nested blocks.
  5318. *
  5319. * @param {Object} state Global application state.
  5320. * @param {?string} blockName Optional block name, if not specified, returns an empty array.
  5321. *
  5322. * @return {Array} Array of clientIds of blocks with name equal to blockName.
  5323. */
  5324. const __experimentalGetGlobalBlocksByName = rememo((state, blockName) => {
  5325. if (!blockName) {
  5326. return EMPTY_ARRAY;
  5327. }
  5328. const clientIds = getClientIdsWithDescendants(state);
  5329. const foundBlocks = clientIds.filter(clientId => {
  5330. const block = state.blocks.byClientId[clientId];
  5331. return block.name === blockName;
  5332. });
  5333. return foundBlocks.length > 0 ? foundBlocks : EMPTY_ARRAY;
  5334. }, state => [state.blocks.order, state.blocks.byClientId]);
  5335. /**
  5336. * Given an array of block client IDs, returns the corresponding array of block
  5337. * objects.
  5338. *
  5339. * @param {Object} state Editor state.
  5340. * @param {string[]} clientIds Client IDs for which blocks are to be returned.
  5341. *
  5342. * @return {WPBlock[]} Block objects.
  5343. */
  5344. const getBlocksByClientId = rememo((state, clientIds) => (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.castArray)(clientIds), clientId => getBlock(state, clientId)), (state, clientIds) => (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.castArray)(clientIds), clientId => state.blocks.tree[clientId]));
  5345. /**
  5346. * Returns the number of blocks currently present in the post.
  5347. *
  5348. * @param {Object} state Editor state.
  5349. * @param {?string} rootClientId Optional root client ID of block list.
  5350. *
  5351. * @return {number} Number of blocks in the post.
  5352. */
  5353. function getBlockCount(state, rootClientId) {
  5354. return getBlockOrder(state, rootClientId).length;
  5355. }
  5356. /**
  5357. * Returns the current selection start block client ID, attribute key and text
  5358. * offset.
  5359. *
  5360. * @param {Object} state Block editor state.
  5361. *
  5362. * @return {WPBlockSelection} Selection start information.
  5363. */
  5364. function getSelectionStart(state) {
  5365. return state.selection.selectionStart;
  5366. }
  5367. /**
  5368. * Returns the current selection end block client ID, attribute key and text
  5369. * offset.
  5370. *
  5371. * @param {Object} state Block editor state.
  5372. *
  5373. * @return {WPBlockSelection} Selection end information.
  5374. */
  5375. function getSelectionEnd(state) {
  5376. return state.selection.selectionEnd;
  5377. }
  5378. /**
  5379. * Returns the current block selection start. This value may be null, and it
  5380. * may represent either a singular block selection or multi-selection start.
  5381. * A selection is singular if its start and end match.
  5382. *
  5383. * @param {Object} state Global application state.
  5384. *
  5385. * @return {?string} Client ID of block selection start.
  5386. */
  5387. function getBlockSelectionStart(state) {
  5388. return state.selection.selectionStart.clientId;
  5389. }
  5390. /**
  5391. * Returns the current block selection end. This value may be null, and it
  5392. * may represent either a singular block selection or multi-selection end.
  5393. * A selection is singular if its start and end match.
  5394. *
  5395. * @param {Object} state Global application state.
  5396. *
  5397. * @return {?string} Client ID of block selection end.
  5398. */
  5399. function getBlockSelectionEnd(state) {
  5400. return state.selection.selectionEnd.clientId;
  5401. }
  5402. /**
  5403. * Returns the number of blocks currently selected in the post.
  5404. *
  5405. * @param {Object} state Global application state.
  5406. *
  5407. * @return {number} Number of blocks selected in the post.
  5408. */
  5409. function getSelectedBlockCount(state) {
  5410. const multiSelectedBlockCount = getMultiSelectedBlockClientIds(state).length;
  5411. if (multiSelectedBlockCount) {
  5412. return multiSelectedBlockCount;
  5413. }
  5414. return state.selection.selectionStart.clientId ? 1 : 0;
  5415. }
  5416. /**
  5417. * Returns true if there is a single selected block, or false otherwise.
  5418. *
  5419. * @param {Object} state Editor state.
  5420. *
  5421. * @return {boolean} Whether a single block is selected.
  5422. */
  5423. function hasSelectedBlock(state) {
  5424. const {
  5425. selectionStart,
  5426. selectionEnd
  5427. } = state.selection;
  5428. return !!selectionStart.clientId && selectionStart.clientId === selectionEnd.clientId;
  5429. }
  5430. /**
  5431. * Returns the currently selected block client ID, or null if there is no
  5432. * selected block.
  5433. *
  5434. * @param {Object} state Editor state.
  5435. *
  5436. * @return {?string} Selected block client ID.
  5437. */
  5438. function getSelectedBlockClientId(state) {
  5439. const {
  5440. selectionStart,
  5441. selectionEnd
  5442. } = state.selection;
  5443. const {
  5444. clientId
  5445. } = selectionStart;
  5446. if (!clientId || clientId !== selectionEnd.clientId) {
  5447. return null;
  5448. }
  5449. return clientId;
  5450. }
  5451. /**
  5452. * Returns the currently selected block, or null if there is no selected block.
  5453. *
  5454. * @param {Object} state Global application state.
  5455. *
  5456. * @return {?Object} Selected block.
  5457. */
  5458. function getSelectedBlock(state) {
  5459. const clientId = getSelectedBlockClientId(state);
  5460. return clientId ? getBlock(state, clientId) : null;
  5461. }
  5462. /**
  5463. * Given a block client ID, returns the root block from which the block is
  5464. * nested, an empty string for top-level blocks, or null if the block does not
  5465. * exist.
  5466. *
  5467. * @param {Object} state Editor state.
  5468. * @param {string} clientId Block from which to find root client ID.
  5469. *
  5470. * @return {?string} Root client ID, if exists
  5471. */
  5472. function getBlockRootClientId(state, clientId) {
  5473. return state.blocks.parents[clientId] !== undefined ? state.blocks.parents[clientId] : null;
  5474. }
  5475. /**
  5476. * Given a block client ID, returns the list of all its parents from top to bottom.
  5477. *
  5478. * @param {Object} state Editor state.
  5479. * @param {string} clientId Block from which to find root client ID.
  5480. * @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false).
  5481. *
  5482. * @return {Array} ClientIDs of the parent blocks.
  5483. */
  5484. const getBlockParents = rememo(function (state, clientId) {
  5485. let ascending = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5486. const parents = [];
  5487. let current = clientId;
  5488. while (!!state.blocks.parents[current]) {
  5489. current = state.blocks.parents[current];
  5490. parents.push(current);
  5491. }
  5492. return ascending ? parents : parents.reverse();
  5493. }, state => [state.blocks.parents]);
  5494. /**
  5495. * Given a block client ID and a block name, returns the list of all its parents
  5496. * from top to bottom, filtered by the given name(s). For example, if passed
  5497. * 'core/group' as the blockName, it will only return parents which are group
  5498. * blocks. If passed `[ 'core/group', 'core/cover']`, as the blockName, it will
  5499. * return parents which are group blocks and parents which are cover blocks.
  5500. *
  5501. * @param {Object} state Editor state.
  5502. * @param {string} clientId Block from which to find root client ID.
  5503. * @param {string|string[]} blockName Block name(s) to filter.
  5504. * @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false).
  5505. *
  5506. * @return {Array} ClientIDs of the parent blocks.
  5507. */
  5508. const getBlockParentsByBlockName = rememo(function (state, clientId, blockName) {
  5509. let ascending = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5510. const parents = getBlockParents(state, clientId, ascending);
  5511. return (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.map)(parents, id => ({
  5512. id,
  5513. name: getBlockName(state, id)
  5514. })), _ref => {
  5515. let {
  5516. name
  5517. } = _ref;
  5518. if (Array.isArray(blockName)) {
  5519. return blockName.includes(name);
  5520. }
  5521. return name === blockName;
  5522. }), _ref2 => {
  5523. let {
  5524. id
  5525. } = _ref2;
  5526. return id;
  5527. });
  5528. }, state => [state.blocks.parents]);
  5529. /**
  5530. * Given a block client ID, returns the root of the hierarchy from which the block is nested, return the block itself for root level blocks.
  5531. *
  5532. * @param {Object} state Editor state.
  5533. * @param {string} clientId Block from which to find root client ID.
  5534. *
  5535. * @return {string} Root client ID
  5536. */
  5537. function getBlockHierarchyRootClientId(state, clientId) {
  5538. let current = clientId;
  5539. let parent;
  5540. do {
  5541. parent = current;
  5542. current = state.blocks.parents[current];
  5543. } while (current);
  5544. return parent;
  5545. }
  5546. /**
  5547. * Given a block client ID, returns the lowest common ancestor with selected client ID.
  5548. *
  5549. * @param {Object} state Editor state.
  5550. * @param {string} clientId Block from which to find common ancestor client ID.
  5551. *
  5552. * @return {string} Common ancestor client ID or undefined
  5553. */
  5554. function getLowestCommonAncestorWithSelectedBlock(state, clientId) {
  5555. const selectedId = getSelectedBlockClientId(state);
  5556. const clientParents = [...getBlockParents(state, clientId), clientId];
  5557. const selectedParents = [...getBlockParents(state, selectedId), selectedId];
  5558. let lowestCommonAncestor;
  5559. const maxDepth = Math.min(clientParents.length, selectedParents.length);
  5560. for (let index = 0; index < maxDepth; index++) {
  5561. if (clientParents[index] === selectedParents[index]) {
  5562. lowestCommonAncestor = clientParents[index];
  5563. } else {
  5564. break;
  5565. }
  5566. }
  5567. return lowestCommonAncestor;
  5568. }
  5569. /**
  5570. * Returns the client ID of the block adjacent one at the given reference
  5571. * startClientId and modifier directionality. Defaults start startClientId to
  5572. * the selected block, and direction as next block. Returns null if there is no
  5573. * adjacent block.
  5574. *
  5575. * @param {Object} state Editor state.
  5576. * @param {?string} startClientId Optional client ID of block from which to
  5577. * search.
  5578. * @param {?number} modifier Directionality multiplier (1 next, -1
  5579. * previous).
  5580. *
  5581. * @return {?string} Return the client ID of the block, or null if none exists.
  5582. */
  5583. function getAdjacentBlockClientId(state, startClientId) {
  5584. let modifier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
  5585. // Default to selected block.
  5586. if (startClientId === undefined) {
  5587. startClientId = getSelectedBlockClientId(state);
  5588. } // Try multi-selection starting at extent based on modifier.
  5589. if (startClientId === undefined) {
  5590. if (modifier < 0) {
  5591. startClientId = getFirstMultiSelectedBlockClientId(state);
  5592. } else {
  5593. startClientId = getLastMultiSelectedBlockClientId(state);
  5594. }
  5595. } // Validate working start client ID.
  5596. if (!startClientId) {
  5597. return null;
  5598. } // Retrieve start block root client ID, being careful to allow the falsey
  5599. // empty string top-level root by explicitly testing against null.
  5600. const rootClientId = getBlockRootClientId(state, startClientId);
  5601. if (rootClientId === null) {
  5602. return null;
  5603. }
  5604. const {
  5605. order
  5606. } = state.blocks;
  5607. const orderSet = order[rootClientId];
  5608. const index = orderSet.indexOf(startClientId);
  5609. const nextIndex = index + 1 * modifier; // Block was first in set and we're attempting to get previous.
  5610. if (nextIndex < 0) {
  5611. return null;
  5612. } // Block was last in set and we're attempting to get next.
  5613. if (nextIndex === orderSet.length) {
  5614. return null;
  5615. } // Assume incremented index is within the set.
  5616. return orderSet[nextIndex];
  5617. }
  5618. /**
  5619. * Returns the previous block's client ID from the given reference start ID.
  5620. * Defaults start to the selected block. Returns null if there is no previous
  5621. * block.
  5622. *
  5623. * @param {Object} state Editor state.
  5624. * @param {?string} startClientId Optional client ID of block from which to
  5625. * search.
  5626. *
  5627. * @return {?string} Adjacent block's client ID, or null if none exists.
  5628. */
  5629. function getPreviousBlockClientId(state, startClientId) {
  5630. return getAdjacentBlockClientId(state, startClientId, -1);
  5631. }
  5632. /**
  5633. * Returns the next block's client ID from the given reference start ID.
  5634. * Defaults start to the selected block. Returns null if there is no next
  5635. * block.
  5636. *
  5637. * @param {Object} state Editor state.
  5638. * @param {?string} startClientId Optional client ID of block from which to
  5639. * search.
  5640. *
  5641. * @return {?string} Adjacent block's client ID, or null if none exists.
  5642. */
  5643. function getNextBlockClientId(state, startClientId) {
  5644. return getAdjacentBlockClientId(state, startClientId, 1);
  5645. }
  5646. /* eslint-disable jsdoc/valid-types */
  5647. /**
  5648. * Returns the initial caret position for the selected block.
  5649. * This position is to used to position the caret properly when the selected block changes.
  5650. * If the current block is not a RichText, having initial position set to 0 means "focus block"
  5651. *
  5652. * @param {Object} state Global application state.
  5653. *
  5654. * @return {0|-1|null} Initial position.
  5655. */
  5656. function getSelectedBlocksInitialCaretPosition(state) {
  5657. /* eslint-enable jsdoc/valid-types */
  5658. return state.initialPosition;
  5659. }
  5660. /**
  5661. * Returns the current selection set of block client IDs (multiselection or single selection).
  5662. *
  5663. * @param {Object} state Editor state.
  5664. *
  5665. * @return {Array} Multi-selected block client IDs.
  5666. */
  5667. const getSelectedBlockClientIds = rememo(state => {
  5668. const {
  5669. selectionStart,
  5670. selectionEnd
  5671. } = state.selection;
  5672. if (selectionStart.clientId === undefined || selectionEnd.clientId === undefined) {
  5673. return EMPTY_ARRAY;
  5674. }
  5675. if (selectionStart.clientId === selectionEnd.clientId) {
  5676. return [selectionStart.clientId];
  5677. } // Retrieve root client ID to aid in retrieving relevant nested block
  5678. // order, being careful to allow the falsey empty string top-level root
  5679. // by explicitly testing against null.
  5680. const rootClientId = getBlockRootClientId(state, selectionStart.clientId);
  5681. if (rootClientId === null) {
  5682. return EMPTY_ARRAY;
  5683. }
  5684. const blockOrder = getBlockOrder(state, rootClientId);
  5685. const startIndex = blockOrder.indexOf(selectionStart.clientId);
  5686. const endIndex = blockOrder.indexOf(selectionEnd.clientId);
  5687. if (startIndex > endIndex) {
  5688. return blockOrder.slice(endIndex, startIndex + 1);
  5689. }
  5690. return blockOrder.slice(startIndex, endIndex + 1);
  5691. }, state => [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId]);
  5692. /**
  5693. * Returns the current multi-selection set of block client IDs, or an empty
  5694. * array if there is no multi-selection.
  5695. *
  5696. * @param {Object} state Editor state.
  5697. *
  5698. * @return {Array} Multi-selected block client IDs.
  5699. */
  5700. function getMultiSelectedBlockClientIds(state) {
  5701. const {
  5702. selectionStart,
  5703. selectionEnd
  5704. } = state.selection;
  5705. if (selectionStart.clientId === selectionEnd.clientId) {
  5706. return EMPTY_ARRAY;
  5707. }
  5708. return getSelectedBlockClientIds(state);
  5709. }
  5710. /**
  5711. * Returns the current multi-selection set of blocks, or an empty array if
  5712. * there is no multi-selection.
  5713. *
  5714. * @param {Object} state Editor state.
  5715. *
  5716. * @return {Array} Multi-selected block objects.
  5717. */
  5718. const getMultiSelectedBlocks = rememo(state => {
  5719. const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(state);
  5720. if (!multiSelectedBlockClientIds.length) {
  5721. return EMPTY_ARRAY;
  5722. }
  5723. return multiSelectedBlockClientIds.map(clientId => getBlock(state, clientId));
  5724. }, state => [...getSelectedBlockClientIds.getDependants(state), state.blocks.byClientId, state.blocks.order, state.blocks.attributes]);
  5725. /**
  5726. * Returns the client ID of the first block in the multi-selection set, or null
  5727. * if there is no multi-selection.
  5728. *
  5729. * @param {Object} state Editor state.
  5730. *
  5731. * @return {?string} First block client ID in the multi-selection set.
  5732. */
  5733. function getFirstMultiSelectedBlockClientId(state) {
  5734. return getMultiSelectedBlockClientIds(state)[0] || null;
  5735. }
  5736. /**
  5737. * Returns the client ID of the last block in the multi-selection set, or null
  5738. * if there is no multi-selection.
  5739. *
  5740. * @param {Object} state Editor state.
  5741. *
  5742. * @return {?string} Last block client ID in the multi-selection set.
  5743. */
  5744. function getLastMultiSelectedBlockClientId(state) {
  5745. const selectedClientIds = getMultiSelectedBlockClientIds(state);
  5746. return selectedClientIds[selectedClientIds.length - 1] || null;
  5747. }
  5748. /**
  5749. * Returns true if a multi-selection exists, and the block corresponding to the
  5750. * specified client ID is the first block of the multi-selection set, or false
  5751. * otherwise.
  5752. *
  5753. * @param {Object} state Editor state.
  5754. * @param {string} clientId Block client ID.
  5755. *
  5756. * @return {boolean} Whether block is first in multi-selection.
  5757. */
  5758. function isFirstMultiSelectedBlock(state, clientId) {
  5759. return getFirstMultiSelectedBlockClientId(state) === clientId;
  5760. }
  5761. /**
  5762. * Returns true if the client ID occurs within the block multi-selection, or
  5763. * false otherwise.
  5764. *
  5765. * @param {Object} state Editor state.
  5766. * @param {string} clientId Block client ID.
  5767. *
  5768. * @return {boolean} Whether block is in multi-selection set.
  5769. */
  5770. function isBlockMultiSelected(state, clientId) {
  5771. return getMultiSelectedBlockClientIds(state).indexOf(clientId) !== -1;
  5772. }
  5773. /**
  5774. * Returns true if an ancestor of the block is multi-selected, or false
  5775. * otherwise.
  5776. *
  5777. * @param {Object} state Editor state.
  5778. * @param {string} clientId Block client ID.
  5779. *
  5780. * @return {boolean} Whether an ancestor of the block is in multi-selection
  5781. * set.
  5782. */
  5783. const isAncestorMultiSelected = rememo((state, clientId) => {
  5784. let ancestorClientId = clientId;
  5785. let isMultiSelected = false;
  5786. while (ancestorClientId && !isMultiSelected) {
  5787. ancestorClientId = getBlockRootClientId(state, ancestorClientId);
  5788. isMultiSelected = isBlockMultiSelected(state, ancestorClientId);
  5789. }
  5790. return isMultiSelected;
  5791. }, state => [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId]);
  5792. /**
  5793. * Returns the client ID of the block which begins the multi-selection set, or
  5794. * null if there is no multi-selection.
  5795. *
  5796. * This is not necessarily the first client ID in the selection.
  5797. *
  5798. * @see getFirstMultiSelectedBlockClientId
  5799. *
  5800. * @param {Object} state Editor state.
  5801. *
  5802. * @return {?string} Client ID of block beginning multi-selection.
  5803. */
  5804. function getMultiSelectedBlocksStartClientId(state) {
  5805. const {
  5806. selectionStart,
  5807. selectionEnd
  5808. } = state.selection;
  5809. if (selectionStart.clientId === selectionEnd.clientId) {
  5810. return null;
  5811. }
  5812. return selectionStart.clientId || null;
  5813. }
  5814. /**
  5815. * Returns the client ID of the block which ends the multi-selection set, or
  5816. * null if there is no multi-selection.
  5817. *
  5818. * This is not necessarily the last client ID in the selection.
  5819. *
  5820. * @see getLastMultiSelectedBlockClientId
  5821. *
  5822. * @param {Object} state Editor state.
  5823. *
  5824. * @return {?string} Client ID of block ending multi-selection.
  5825. */
  5826. function getMultiSelectedBlocksEndClientId(state) {
  5827. const {
  5828. selectionStart,
  5829. selectionEnd
  5830. } = state.selection;
  5831. if (selectionStart.clientId === selectionEnd.clientId) {
  5832. return null;
  5833. }
  5834. return selectionEnd.clientId || null;
  5835. }
  5836. /**
  5837. * Returns true if the selection is not partial.
  5838. *
  5839. * @param {Object} state Editor state.
  5840. *
  5841. * @return {boolean} Whether the selection is mergeable.
  5842. */
  5843. function __unstableIsFullySelected(state) {
  5844. const selectionAnchor = getSelectionStart(state);
  5845. const selectionFocus = getSelectionEnd(state);
  5846. return !selectionAnchor.attributeKey && !selectionFocus.attributeKey && typeof selectionAnchor.offset === 'undefined' && typeof selectionFocus.offset === 'undefined';
  5847. }
  5848. /**
  5849. * Returns true if the selection is collapsed.
  5850. *
  5851. * @param {Object} state Editor state.
  5852. *
  5853. * @return {boolean} Whether the selection is collapsed.
  5854. */
  5855. function __unstableIsSelectionCollapsed(state) {
  5856. const selectionAnchor = getSelectionStart(state);
  5857. const selectionFocus = getSelectionEnd(state);
  5858. return !!selectionAnchor && !!selectionFocus && selectionAnchor.clientId === selectionFocus.clientId && selectionAnchor.attributeKey === selectionFocus.attributeKey && selectionAnchor.offset === selectionFocus.offset;
  5859. }
  5860. function __unstableSelectionHasUnmergeableBlock(state) {
  5861. return getSelectedBlockClientIds(state).some(clientId => {
  5862. const blockName = getBlockName(state, clientId);
  5863. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName);
  5864. return !blockType.merge;
  5865. });
  5866. }
  5867. /**
  5868. * Check whether the selection is mergeable.
  5869. *
  5870. * @param {Object} state Editor state.
  5871. * @param {boolean} isForward Whether to merge forwards.
  5872. *
  5873. * @return {boolean} Whether the selection is mergeable.
  5874. */
  5875. function __unstableIsSelectionMergeable(state, isForward) {
  5876. const selectionAnchor = getSelectionStart(state);
  5877. const selectionFocus = getSelectionEnd(state); // It's not mergeable if the start and end are within the same block.
  5878. if (selectionAnchor.clientId === selectionFocus.clientId) return false; // It's not mergeable if there's no rich text selection.
  5879. if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') return false;
  5880. const anchorRootClientId = getBlockRootClientId(state, selectionAnchor.clientId);
  5881. const focusRootClientId = getBlockRootClientId(state, selectionFocus.clientId); // It's not mergeable if the selection doesn't start and end in the same
  5882. // block list. Maybe in the future it should be allowed.
  5883. if (anchorRootClientId !== focusRootClientId) {
  5884. return false;
  5885. }
  5886. const blockOrder = getBlockOrder(state, anchorRootClientId);
  5887. const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
  5888. const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order.
  5889. let selectionStart, selectionEnd;
  5890. if (anchorIndex > focusIndex) {
  5891. selectionStart = selectionFocus;
  5892. selectionEnd = selectionAnchor;
  5893. } else {
  5894. selectionStart = selectionAnchor;
  5895. selectionEnd = selectionFocus;
  5896. }
  5897. const targetBlockClientId = isForward ? selectionEnd.clientId : selectionStart.clientId;
  5898. const blockToMergeClientId = isForward ? selectionStart.clientId : selectionEnd.clientId;
  5899. const targetBlockName = getBlockName(state, targetBlockClientId);
  5900. const targetBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(targetBlockName);
  5901. if (!targetBlockType.merge) return false;
  5902. const blockToMerge = getBlock(state, blockToMergeClientId); // It's mergeable if the blocks are of the same type.
  5903. if (blockToMerge.name === targetBlockName) return true; // If the blocks are of a different type, try to transform the block being
  5904. // merged into the same type of block.
  5905. const blocksToMerge = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blockToMerge, targetBlockName);
  5906. return blocksToMerge && blocksToMerge.length;
  5907. }
  5908. /**
  5909. * Get partial selected blocks with their content updated
  5910. * based on the selection.
  5911. *
  5912. * @param {Object} state Editor state.
  5913. *
  5914. * @return {Object[]} Updated partial selected blocks.
  5915. */
  5916. const __unstableGetSelectedBlocksWithPartialSelection = state => {
  5917. const selectionAnchor = getSelectionStart(state);
  5918. const selectionFocus = getSelectionEnd(state);
  5919. if (selectionAnchor.clientId === selectionFocus.clientId) {
  5920. return EMPTY_ARRAY;
  5921. } // Can't split if the selection is not set.
  5922. if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') {
  5923. return EMPTY_ARRAY;
  5924. }
  5925. const anchorRootClientId = getBlockRootClientId(state, selectionAnchor.clientId);
  5926. const focusRootClientId = getBlockRootClientId(state, selectionFocus.clientId); // It's not splittable if the selection doesn't start and end in the same
  5927. // block list. Maybe in the future it should be allowed.
  5928. if (anchorRootClientId !== focusRootClientId) {
  5929. return EMPTY_ARRAY;
  5930. }
  5931. const blockOrder = getBlockOrder(state, anchorRootClientId);
  5932. const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
  5933. const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order.
  5934. const [selectionStart, selectionEnd] = anchorIndex > focusIndex ? [selectionFocus, selectionAnchor] : [selectionAnchor, selectionFocus];
  5935. const blockA = getBlock(state, selectionStart.clientId);
  5936. const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name);
  5937. const blockB = getBlock(state, selectionEnd.clientId);
  5938. const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name);
  5939. const htmlA = blockA.attributes[selectionStart.attributeKey];
  5940. const htmlB = blockB.attributes[selectionEnd.attributeKey];
  5941. const attributeDefinitionA = blockAType.attributes[selectionStart.attributeKey];
  5942. const attributeDefinitionB = blockBType.attributes[selectionEnd.attributeKey];
  5943. let valueA = (0,external_wp_richText_namespaceObject.create)({
  5944. html: htmlA,
  5945. ...mapRichTextSettings(attributeDefinitionA)
  5946. });
  5947. let valueB = (0,external_wp_richText_namespaceObject.create)({
  5948. html: htmlB,
  5949. ...mapRichTextSettings(attributeDefinitionB)
  5950. });
  5951. valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, 0, selectionStart.offset);
  5952. valueB = (0,external_wp_richText_namespaceObject.remove)(valueB, selectionEnd.offset, valueB.text.length);
  5953. return [{ ...blockA,
  5954. attributes: { ...blockA.attributes,
  5955. [selectionStart.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  5956. value: valueA,
  5957. ...mapRichTextSettings(attributeDefinitionA)
  5958. })
  5959. }
  5960. }, { ...blockB,
  5961. attributes: { ...blockB.attributes,
  5962. [selectionEnd.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  5963. value: valueB,
  5964. ...mapRichTextSettings(attributeDefinitionB)
  5965. })
  5966. }
  5967. }];
  5968. };
  5969. /**
  5970. * Returns an array containing all block client IDs in the editor in the order
  5971. * they appear. Optionally accepts a root client ID of the block list for which
  5972. * the order should be returned, defaulting to the top-level block order.
  5973. *
  5974. * @param {Object} state Editor state.
  5975. * @param {?string} rootClientId Optional root client ID of block list.
  5976. *
  5977. * @return {Array} Ordered client IDs of editor blocks.
  5978. */
  5979. function getBlockOrder(state, rootClientId) {
  5980. return state.blocks.order[rootClientId || ''] || EMPTY_ARRAY;
  5981. }
  5982. /**
  5983. * Returns the index at which the block corresponding to the specified client
  5984. * ID occurs within the block order, or `-1` if the block does not exist.
  5985. *
  5986. * @param {Object} state Editor state.
  5987. * @param {string} clientId Block client ID.
  5988. *
  5989. * @return {number} Index at which block exists in order.
  5990. */
  5991. function getBlockIndex(state, clientId) {
  5992. const rootClientId = getBlockRootClientId(state, clientId);
  5993. return getBlockOrder(state, rootClientId).indexOf(clientId);
  5994. }
  5995. /**
  5996. * Returns true if the block corresponding to the specified client ID is
  5997. * currently selected and no multi-selection exists, or false otherwise.
  5998. *
  5999. * @param {Object} state Editor state.
  6000. * @param {string} clientId Block client ID.
  6001. *
  6002. * @return {boolean} Whether block is selected and multi-selection exists.
  6003. */
  6004. function isBlockSelected(state, clientId) {
  6005. const {
  6006. selectionStart,
  6007. selectionEnd
  6008. } = state.selection;
  6009. if (selectionStart.clientId !== selectionEnd.clientId) {
  6010. return false;
  6011. }
  6012. return selectionStart.clientId === clientId;
  6013. }
  6014. /**
  6015. * Returns true if one of the block's inner blocks is selected.
  6016. *
  6017. * @param {Object} state Editor state.
  6018. * @param {string} clientId Block client ID.
  6019. * @param {boolean} deep Perform a deep check.
  6020. *
  6021. * @return {boolean} Whether the block as an inner block selected
  6022. */
  6023. function hasSelectedInnerBlock(state, clientId) {
  6024. let deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6025. return (0,external_lodash_namespaceObject.some)(getBlockOrder(state, clientId), innerClientId => isBlockSelected(state, innerClientId) || isBlockMultiSelected(state, innerClientId) || deep && hasSelectedInnerBlock(state, innerClientId, deep));
  6026. }
  6027. /**
  6028. * Returns true if the block corresponding to the specified client ID is
  6029. * currently selected but isn't the last of the selected blocks. Here "last"
  6030. * refers to the block sequence in the document, _not_ the sequence of
  6031. * multi-selection, which is why `state.selectionEnd` isn't used.
  6032. *
  6033. * @param {Object} state Editor state.
  6034. * @param {string} clientId Block client ID.
  6035. *
  6036. * @return {boolean} Whether block is selected and not the last in the
  6037. * selection.
  6038. */
  6039. function isBlockWithinSelection(state, clientId) {
  6040. if (!clientId) {
  6041. return false;
  6042. }
  6043. const clientIds = getMultiSelectedBlockClientIds(state);
  6044. const index = clientIds.indexOf(clientId);
  6045. return index > -1 && index < clientIds.length - 1;
  6046. }
  6047. /**
  6048. * Returns true if a multi-selection has been made, or false otherwise.
  6049. *
  6050. * @param {Object} state Editor state.
  6051. *
  6052. * @return {boolean} Whether multi-selection has been made.
  6053. */
  6054. function hasMultiSelection(state) {
  6055. const {
  6056. selectionStart,
  6057. selectionEnd
  6058. } = state.selection;
  6059. return selectionStart.clientId !== selectionEnd.clientId;
  6060. }
  6061. /**
  6062. * Whether in the process of multi-selecting or not. This flag is only true
  6063. * while the multi-selection is being selected (by mouse move), and is false
  6064. * once the multi-selection has been settled.
  6065. *
  6066. * @see hasMultiSelection
  6067. *
  6068. * @param {Object} state Global application state.
  6069. *
  6070. * @return {boolean} True if multi-selecting, false if not.
  6071. */
  6072. function selectors_isMultiSelecting(state) {
  6073. return state.isMultiSelecting;
  6074. }
  6075. /**
  6076. * Selector that returns if multi-selection is enabled or not.
  6077. *
  6078. * @param {Object} state Global application state.
  6079. *
  6080. * @return {boolean} True if it should be possible to multi-select blocks, false if multi-selection is disabled.
  6081. */
  6082. function selectors_isSelectionEnabled(state) {
  6083. return state.isSelectionEnabled;
  6084. }
  6085. /**
  6086. * Returns the block's editing mode, defaulting to "visual" if not explicitly
  6087. * assigned.
  6088. *
  6089. * @param {Object} state Editor state.
  6090. * @param {string} clientId Block client ID.
  6091. *
  6092. * @return {Object} Block editing mode.
  6093. */
  6094. function getBlockMode(state, clientId) {
  6095. return state.blocksMode[clientId] || 'visual';
  6096. }
  6097. /**
  6098. * Returns true if the user is typing, or false otherwise.
  6099. *
  6100. * @param {Object} state Global application state.
  6101. *
  6102. * @return {boolean} Whether user is typing.
  6103. */
  6104. function selectors_isTyping(state) {
  6105. return state.isTyping;
  6106. }
  6107. /**
  6108. * Returns true if the user is dragging blocks, or false otherwise.
  6109. *
  6110. * @param {Object} state Global application state.
  6111. *
  6112. * @return {boolean} Whether user is dragging blocks.
  6113. */
  6114. function isDraggingBlocks(state) {
  6115. return !!state.draggedBlocks.length;
  6116. }
  6117. /**
  6118. * Returns the client ids of any blocks being directly dragged.
  6119. *
  6120. * This does not include children of a parent being dragged.
  6121. *
  6122. * @param {Object} state Global application state.
  6123. *
  6124. * @return {string[]} Array of dragged block client ids.
  6125. */
  6126. function getDraggedBlockClientIds(state) {
  6127. return state.draggedBlocks;
  6128. }
  6129. /**
  6130. * Returns whether the block is being dragged.
  6131. *
  6132. * Only returns true if the block is being directly dragged,
  6133. * not if the block is a child of a parent being dragged.
  6134. * See `isAncestorBeingDragged` for child blocks.
  6135. *
  6136. * @param {Object} state Global application state.
  6137. * @param {string} clientId Client id for block to check.
  6138. *
  6139. * @return {boolean} Whether the block is being dragged.
  6140. */
  6141. function isBlockBeingDragged(state, clientId) {
  6142. return state.draggedBlocks.includes(clientId);
  6143. }
  6144. /**
  6145. * Returns whether a parent/ancestor of the block is being dragged.
  6146. *
  6147. * @param {Object} state Global application state.
  6148. * @param {string} clientId Client id for block to check.
  6149. *
  6150. * @return {boolean} Whether the block's ancestor is being dragged.
  6151. */
  6152. function isAncestorBeingDragged(state, clientId) {
  6153. // Return early if no blocks are being dragged rather than
  6154. // the more expensive check for parents.
  6155. if (!isDraggingBlocks(state)) {
  6156. return false;
  6157. }
  6158. const parents = getBlockParents(state, clientId);
  6159. return (0,external_lodash_namespaceObject.some)(parents, parentClientId => isBlockBeingDragged(state, parentClientId));
  6160. }
  6161. /**
  6162. * Returns true if the caret is within formatted text, or false otherwise.
  6163. *
  6164. * @deprecated
  6165. *
  6166. * @return {boolean} Whether the caret is within formatted text.
  6167. */
  6168. function isCaretWithinFormattedText() {
  6169. external_wp_deprecated_default()('wp.data.select( "core/block-editor" ).isCaretWithinFormattedText', {
  6170. since: '6.1',
  6171. version: '6.3'
  6172. });
  6173. return false;
  6174. }
  6175. /**
  6176. * Returns the insertion point, the index at which the new inserted block would
  6177. * be placed. Defaults to the last index.
  6178. *
  6179. * @param {Object} state Editor state.
  6180. *
  6181. * @return {Object} Insertion point object with `rootClientId`, `index`.
  6182. */
  6183. function getBlockInsertionPoint(state) {
  6184. let rootClientId, index;
  6185. const {
  6186. insertionPoint,
  6187. selection: {
  6188. selectionEnd
  6189. }
  6190. } = state;
  6191. if (insertionPoint !== null) {
  6192. return insertionPoint;
  6193. }
  6194. const {
  6195. clientId
  6196. } = selectionEnd;
  6197. if (clientId) {
  6198. rootClientId = getBlockRootClientId(state, clientId) || undefined;
  6199. index = getBlockIndex(state, selectionEnd.clientId) + 1;
  6200. } else {
  6201. index = getBlockOrder(state).length;
  6202. }
  6203. return {
  6204. rootClientId,
  6205. index
  6206. };
  6207. }
  6208. /**
  6209. * Returns true if we should show the block insertion point.
  6210. *
  6211. * @param {Object} state Global application state.
  6212. *
  6213. * @return {?boolean} Whether the insertion point is visible or not.
  6214. */
  6215. function isBlockInsertionPointVisible(state) {
  6216. return state.insertionPoint !== null;
  6217. }
  6218. /**
  6219. * Returns whether the blocks matches the template or not.
  6220. *
  6221. * @param {boolean} state
  6222. * @return {?boolean} Whether the template is valid or not.
  6223. */
  6224. function isValidTemplate(state) {
  6225. return state.template.isValid;
  6226. }
  6227. /**
  6228. * Returns the defined block template
  6229. *
  6230. * @param {boolean} state
  6231. *
  6232. * @return {?Array} Block Template.
  6233. */
  6234. function getTemplate(state) {
  6235. return state.settings.template;
  6236. }
  6237. /**
  6238. * Returns the defined block template lock. Optionally accepts a root block
  6239. * client ID as context, otherwise defaulting to the global context.
  6240. *
  6241. * @param {Object} state Editor state.
  6242. * @param {?string} rootClientId Optional block root client ID.
  6243. *
  6244. * @return {?string} Block Template Lock
  6245. */
  6246. function getTemplateLock(state, rootClientId) {
  6247. if (!rootClientId) {
  6248. return state.settings.templateLock;
  6249. }
  6250. const blockListSettings = getBlockListSettings(state, rootClientId);
  6251. if (!blockListSettings) {
  6252. return undefined;
  6253. }
  6254. return blockListSettings.templateLock;
  6255. }
  6256. const checkAllowList = function (list, item) {
  6257. let defaultResult = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6258. if (typeof list === 'boolean') {
  6259. return list;
  6260. }
  6261. if (Array.isArray(list)) {
  6262. // TODO: when there is a canonical way to detect that we are editing a post
  6263. // the following check should be changed to something like:
  6264. // if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )
  6265. if (list.includes('core/post-content') && item === null) {
  6266. return true;
  6267. }
  6268. return list.includes(item);
  6269. }
  6270. return defaultResult;
  6271. };
  6272. /**
  6273. * Determines if the given block type is allowed to be inserted into the block list.
  6274. * This function is not exported and not memoized because using a memoized selector
  6275. * inside another memoized selector is just a waste of time.
  6276. *
  6277. * @param {Object} state Editor state.
  6278. * @param {string|Object} blockName The block type object, e.g., the response
  6279. * from the block directory; or a string name of
  6280. * an installed block type, e.g.' core/paragraph'.
  6281. * @param {?string} rootClientId Optional root client ID of block list.
  6282. *
  6283. * @return {boolean} Whether the given block type is allowed to be inserted.
  6284. */
  6285. const canInsertBlockTypeUnmemoized = function (state, blockName) {
  6286. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6287. let blockType;
  6288. if (blockName && 'object' === typeof blockName) {
  6289. blockType = blockName;
  6290. blockName = blockType.name;
  6291. } else {
  6292. blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName);
  6293. }
  6294. if (!blockType) {
  6295. return false;
  6296. }
  6297. const {
  6298. allowedBlockTypes
  6299. } = getSettings(state);
  6300. const isBlockAllowedInEditor = checkAllowList(allowedBlockTypes, blockName, true);
  6301. if (!isBlockAllowedInEditor) {
  6302. return false;
  6303. }
  6304. const isLocked = !!getTemplateLock(state, rootClientId);
  6305. if (isLocked) {
  6306. return false;
  6307. }
  6308. const parentBlockListSettings = getBlockListSettings(state, rootClientId); // The parent block doesn't have settings indicating it doesn't support
  6309. // inner blocks, return false.
  6310. if (rootClientId && parentBlockListSettings === undefined) {
  6311. return false;
  6312. }
  6313. const parentAllowedBlocks = parentBlockListSettings === null || parentBlockListSettings === void 0 ? void 0 : parentBlockListSettings.allowedBlocks;
  6314. const hasParentAllowedBlock = checkAllowList(parentAllowedBlocks, blockName);
  6315. const blockAllowedParentBlocks = blockType.parent;
  6316. const parentName = getBlockName(state, rootClientId);
  6317. const hasBlockAllowedParent = checkAllowList(blockAllowedParentBlocks, parentName);
  6318. let hasBlockAllowedAncestor = true;
  6319. const blockAllowedAncestorBlocks = blockType.ancestor;
  6320. if (blockAllowedAncestorBlocks) {
  6321. const ancestors = [rootClientId, ...getBlockParents(state, rootClientId)];
  6322. hasBlockAllowedAncestor = (0,external_lodash_namespaceObject.some)(ancestors, ancestorClientId => checkAllowList(blockAllowedAncestorBlocks, getBlockName(state, ancestorClientId)));
  6323. }
  6324. const canInsert = hasBlockAllowedAncestor && (hasParentAllowedBlock === null && hasBlockAllowedParent === null || hasParentAllowedBlock === true || hasBlockAllowedParent === true);
  6325. if (!canInsert) {
  6326. return canInsert;
  6327. }
  6328. /**
  6329. * This filter is an ad-hoc solution to prevent adding template parts inside post content.
  6330. * Conceptually, having a filter inside a selector is bad pattern so this code will be
  6331. * replaced by a declarative API that doesn't the following drawbacks:
  6332. *
  6333. * Filters are not reactive: Upon switching between "template mode" and non "template mode",
  6334. * the filter and selector won't necessarily be executed again. For now, it doesn't matter much
  6335. * because you can't switch between the two modes while the inserter stays open.
  6336. *
  6337. * Filters are global: Once they're defined, they will affect all editor instances and all registries.
  6338. * An ideal API would only affect specific editor instances.
  6339. */
  6340. return (0,external_wp_hooks_namespaceObject.applyFilters)('blockEditor.__unstableCanInsertBlockType', canInsert, blockType, rootClientId, {
  6341. // Pass bound selectors of the current registry. If we're in a nested
  6342. // context, the data will differ from the one selected from the root
  6343. // registry.
  6344. getBlock: getBlock.bind(null, state),
  6345. getBlockParentsByBlockName: getBlockParentsByBlockName.bind(null, state)
  6346. });
  6347. };
  6348. /**
  6349. * Determines if the given block type is allowed to be inserted into the block list.
  6350. *
  6351. * @param {Object} state Editor state.
  6352. * @param {string} blockName The name of the block type, e.g.' core/paragraph'.
  6353. * @param {?string} rootClientId Optional root client ID of block list.
  6354. *
  6355. * @return {boolean} Whether the given block type is allowed to be inserted.
  6356. */
  6357. const canInsertBlockType = rememo(canInsertBlockTypeUnmemoized, (state, blockName, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId[rootClientId], state.settings.allowedBlockTypes, state.settings.templateLock]);
  6358. /**
  6359. * Determines if the given blocks are allowed to be inserted into the block
  6360. * list.
  6361. *
  6362. * @param {Object} state Editor state.
  6363. * @param {string} clientIds The block client IDs to be inserted.
  6364. * @param {?string} rootClientId Optional root client ID of block list.
  6365. *
  6366. * @return {boolean} Whether the given blocks are allowed to be inserted.
  6367. */
  6368. function canInsertBlocks(state, clientIds) {
  6369. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6370. return clientIds.every(id => canInsertBlockType(state, getBlockName(state, id), rootClientId));
  6371. }
  6372. /**
  6373. * Determines if the given block is allowed to be deleted.
  6374. *
  6375. * @param {Object} state Editor state.
  6376. * @param {string} clientId The block client Id.
  6377. * @param {?string} rootClientId Optional root client ID of block list.
  6378. *
  6379. * @return {boolean} Whether the given block is allowed to be removed.
  6380. */
  6381. function canRemoveBlock(state, clientId) {
  6382. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6383. const attributes = getBlockAttributes(state, clientId); // attributes can be null if the block is already deleted.
  6384. if (attributes === null) {
  6385. return true;
  6386. }
  6387. const {
  6388. lock
  6389. } = attributes;
  6390. const parentIsLocked = !!getTemplateLock(state, rootClientId); // If we don't have a lock on the blockType level, we defer to the parent templateLock.
  6391. if (lock === undefined || (lock === null || lock === void 0 ? void 0 : lock.remove) === undefined) {
  6392. return !parentIsLocked;
  6393. } // When remove is true, it means we cannot remove it.
  6394. return !(lock !== null && lock !== void 0 && lock.remove);
  6395. }
  6396. /**
  6397. * Determines if the given blocks are allowed to be removed.
  6398. *
  6399. * @param {Object} state Editor state.
  6400. * @param {string} clientIds The block client IDs to be removed.
  6401. * @param {?string} rootClientId Optional root client ID of block list.
  6402. *
  6403. * @return {boolean} Whether the given blocks are allowed to be removed.
  6404. */
  6405. function canRemoveBlocks(state, clientIds) {
  6406. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6407. return clientIds.every(clientId => canRemoveBlock(state, clientId, rootClientId));
  6408. }
  6409. /**
  6410. * Determines if the given block is allowed to be moved.
  6411. *
  6412. * @param {Object} state Editor state.
  6413. * @param {string} clientId The block client Id.
  6414. * @param {?string} rootClientId Optional root client ID of block list.
  6415. *
  6416. * @return {boolean} Whether the given block is allowed to be moved.
  6417. */
  6418. function canMoveBlock(state, clientId) {
  6419. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6420. const attributes = getBlockAttributes(state, clientId);
  6421. if (attributes === null) {
  6422. return;
  6423. }
  6424. const {
  6425. lock
  6426. } = attributes;
  6427. const parentIsLocked = getTemplateLock(state, rootClientId) === 'all'; // If we don't have a lock on the blockType level, we defer to the parent templateLock.
  6428. if (lock === undefined || (lock === null || lock === void 0 ? void 0 : lock.move) === undefined) {
  6429. return !parentIsLocked;
  6430. } // When move is true, it means we cannot move it.
  6431. return !(lock !== null && lock !== void 0 && lock.move);
  6432. }
  6433. /**
  6434. * Determines if the given blocks are allowed to be moved.
  6435. *
  6436. * @param {Object} state Editor state.
  6437. * @param {string} clientIds The block client IDs to be moved.
  6438. * @param {?string} rootClientId Optional root client ID of block list.
  6439. *
  6440. * @return {boolean} Whether the given blocks are allowed to be moved.
  6441. */
  6442. function canMoveBlocks(state, clientIds) {
  6443. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6444. return clientIds.every(clientId => canMoveBlock(state, clientId, rootClientId));
  6445. }
  6446. /**
  6447. * Determines if the given block is allowed to be edited.
  6448. *
  6449. * @param {Object} state Editor state.
  6450. * @param {string} clientId The block client Id.
  6451. *
  6452. * @return {boolean} Whether the given block is allowed to be edited.
  6453. */
  6454. function canEditBlock(state, clientId) {
  6455. const attributes = getBlockAttributes(state, clientId);
  6456. if (attributes === null) {
  6457. return true;
  6458. }
  6459. const {
  6460. lock
  6461. } = attributes; // When the edit is true, we cannot edit the block.
  6462. return !(lock !== null && lock !== void 0 && lock.edit);
  6463. }
  6464. /**
  6465. * Determines if the given block type can be locked/unlocked by a user.
  6466. *
  6467. * @param {Object} state Editor state.
  6468. * @param {(string|Object)} nameOrType Block name or type object.
  6469. *
  6470. * @return {boolean} Whether a given block type can be locked/unlocked.
  6471. */
  6472. function canLockBlockType(state, nameOrType) {
  6473. var _state$settings;
  6474. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(nameOrType, 'lock', true)) {
  6475. return false;
  6476. } // Use block editor settings as the default value.
  6477. return !!((_state$settings = state.settings) !== null && _state$settings !== void 0 && _state$settings.canLockBlocks);
  6478. }
  6479. /**
  6480. * Returns information about how recently and frequently a block has been inserted.
  6481. *
  6482. * @param {Object} state Global application state.
  6483. * @param {string} id A string which identifies the insert, e.g. 'core/block/12'
  6484. *
  6485. * @return {?{ time: number, count: number }} An object containing `time` which is when the last
  6486. * insert occurred as a UNIX epoch, and `count` which is
  6487. * the number of inserts that have occurred.
  6488. */
  6489. function getInsertUsage(state, id) {
  6490. var _state$preferences$in, _state$preferences$in2;
  6491. return (_state$preferences$in = (_state$preferences$in2 = state.preferences.insertUsage) === null || _state$preferences$in2 === void 0 ? void 0 : _state$preferences$in2[id]) !== null && _state$preferences$in !== void 0 ? _state$preferences$in : null;
  6492. }
  6493. /**
  6494. * Returns whether we can show a block type in the inserter
  6495. *
  6496. * @param {Object} state Global State
  6497. * @param {Object} blockType BlockType
  6498. * @param {?string} rootClientId Optional root client ID of block list.
  6499. *
  6500. * @return {boolean} Whether the given block type is allowed to be shown in the inserter.
  6501. */
  6502. const canIncludeBlockTypeInInserter = (state, blockType, rootClientId) => {
  6503. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'inserter', true)) {
  6504. return false;
  6505. }
  6506. return canInsertBlockTypeUnmemoized(state, blockType.name, rootClientId);
  6507. };
  6508. /**
  6509. * Return a function to be used to tranform a block variation to an inserter item
  6510. *
  6511. * @param {Object} state Global State
  6512. * @param {Object} item Denormalized inserter item
  6513. * @return {Function} Function to transform a block variation to inserter item
  6514. */
  6515. const getItemFromVariation = (state, item) => variation => {
  6516. const variationId = `${item.id}/${variation.name}`;
  6517. const {
  6518. time,
  6519. count = 0
  6520. } = getInsertUsage(state, variationId) || {};
  6521. return { ...item,
  6522. id: variationId,
  6523. icon: variation.icon || item.icon,
  6524. title: variation.title || item.title,
  6525. description: variation.description || item.description,
  6526. category: variation.category || item.category,
  6527. // If `example` is explicitly undefined for the variation, the preview will not be shown.
  6528. example: variation.hasOwnProperty('example') ? variation.example : item.example,
  6529. initialAttributes: { ...item.initialAttributes,
  6530. ...variation.attributes
  6531. },
  6532. innerBlocks: variation.innerBlocks,
  6533. keywords: variation.keywords || item.keywords,
  6534. frecency: calculateFrecency(time, count)
  6535. };
  6536. };
  6537. /**
  6538. * Returns the calculated frecency.
  6539. *
  6540. * 'frecency' is a heuristic (https://en.wikipedia.org/wiki/Frecency)
  6541. * that combines block usage frequenty and recency.
  6542. *
  6543. * @param {number} time When the last insert occurred as a UNIX epoch
  6544. * @param {number} count The number of inserts that have occurred.
  6545. *
  6546. * @return {number} The calculated frecency.
  6547. */
  6548. const calculateFrecency = (time, count) => {
  6549. if (!time) {
  6550. return count;
  6551. } // The selector is cached, which means Date.now() is the last time that the
  6552. // relevant state changed. This suits our needs.
  6553. const duration = Date.now() - time;
  6554. switch (true) {
  6555. case duration < MILLISECONDS_PER_HOUR:
  6556. return count * 4;
  6557. case duration < MILLISECONDS_PER_DAY:
  6558. return count * 2;
  6559. case duration < MILLISECONDS_PER_WEEK:
  6560. return count / 2;
  6561. default:
  6562. return count / 4;
  6563. }
  6564. };
  6565. /**
  6566. * Returns a function that accepts a block type and builds an item to be shown
  6567. * in a specific context. It's used for building items for Inserter and available
  6568. * block Transfroms list.
  6569. *
  6570. * @param {Object} state Editor state.
  6571. * @param {Object} options Options object for handling the building of a block type.
  6572. * @param {string} options.buildScope The scope for which the item is going to be used.
  6573. * @return {Function} Function returns an item to be shown in a specific context (Inserter|Transforms list).
  6574. */
  6575. const buildBlockTypeItem = (state, _ref3) => {
  6576. let {
  6577. buildScope = 'inserter'
  6578. } = _ref3;
  6579. return blockType => {
  6580. const id = blockType.name;
  6581. let isDisabled = false;
  6582. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType.name, 'multiple', true)) {
  6583. isDisabled = (0,external_lodash_namespaceObject.some)(getBlocksByClientId(state, getClientIdsWithDescendants(state)), {
  6584. name: blockType.name
  6585. });
  6586. }
  6587. const {
  6588. time,
  6589. count = 0
  6590. } = getInsertUsage(state, id) || {};
  6591. const blockItemBase = {
  6592. id,
  6593. name: blockType.name,
  6594. title: blockType.title,
  6595. icon: blockType.icon,
  6596. isDisabled,
  6597. frecency: calculateFrecency(time, count)
  6598. };
  6599. if (buildScope === 'transform') return blockItemBase;
  6600. const inserterVariations = (0,external_wp_blocks_namespaceObject.getBlockVariations)(blockType.name, 'inserter');
  6601. return { ...blockItemBase,
  6602. initialAttributes: {},
  6603. description: blockType.description,
  6604. category: blockType.category,
  6605. keywords: blockType.keywords,
  6606. variations: inserterVariations,
  6607. example: blockType.example,
  6608. utility: 1 // Deprecated.
  6609. };
  6610. };
  6611. };
  6612. /**
  6613. * Determines the items that appear in the inserter. Includes both static
  6614. * items (e.g. a regular block type) and dynamic items (e.g. a reusable block).
  6615. *
  6616. * Each item object contains what's necessary to display a button in the
  6617. * inserter and handle its selection.
  6618. *
  6619. * The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency)
  6620. * that combines block usage frequenty and recency.
  6621. *
  6622. * Items are returned ordered descendingly by their 'utility' and 'frecency'.
  6623. *
  6624. * @param {Object} state Editor state.
  6625. * @param {?string} rootClientId Optional root client ID of block list.
  6626. *
  6627. * @return {WPEditorInserterItem[]} Items that appear in inserter.
  6628. *
  6629. * @typedef {Object} WPEditorInserterItem
  6630. * @property {string} id Unique identifier for the item.
  6631. * @property {string} name The type of block to create.
  6632. * @property {Object} initialAttributes Attributes to pass to the newly created block.
  6633. * @property {string} title Title of the item, as it appears in the inserter.
  6634. * @property {string} icon Dashicon for the item, as it appears in the inserter.
  6635. * @property {string} category Block category that the item is associated with.
  6636. * @property {string[]} keywords Keywords that can be searched to find this item.
  6637. * @property {boolean} isDisabled Whether or not the user should be prevented from inserting
  6638. * this item.
  6639. * @property {number} frecency Heuristic that combines frequency and recency.
  6640. */
  6641. const getInserterItems = rememo(function (state) {
  6642. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6643. const buildBlockTypeInserterItem = buildBlockTypeItem(state, {
  6644. buildScope: 'inserter'
  6645. });
  6646. /*
  6647. * Matches block comment delimiters amid serialized content.
  6648. *
  6649. * @see `tokenizer` in `@wordpress/block-serialization-default-parser`
  6650. * package
  6651. *
  6652. * blockParserTokenizer differs from the original tokenizer in the
  6653. * following ways:
  6654. *
  6655. * - removed global flag (/g)
  6656. * - prepended ^\s*
  6657. *
  6658. */
  6659. const blockParserTokenizer = /^\s*<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/;
  6660. const buildReusableBlockInserterItem = reusableBlock => {
  6661. let icon = library_symbol;
  6662. /*
  6663. * Instead of always displaying a generic "symbol" icon for every
  6664. * reusable block, try to use an icon that represents the first
  6665. * outermost block contained in the reusable block. This requires
  6666. * scanning the serialized form of the reusable block to find its
  6667. * first block delimiter, then looking up the corresponding block
  6668. * type, if available.
  6669. */
  6670. if (external_wp_element_namespaceObject.Platform.OS === 'web') {
  6671. const content = typeof reusableBlock.content.raw === 'string' ? reusableBlock.content.raw : reusableBlock.content;
  6672. const rawBlockMatch = content.match(blockParserTokenizer);
  6673. if (rawBlockMatch) {
  6674. const [,, namespace = 'core/', blockName] = rawBlockMatch;
  6675. const referencedBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(namespace + blockName);
  6676. if (referencedBlockType) {
  6677. icon = referencedBlockType.icon;
  6678. }
  6679. }
  6680. }
  6681. const id = `core/block/${reusableBlock.id}`;
  6682. const {
  6683. time,
  6684. count = 0
  6685. } = getInsertUsage(state, id) || {};
  6686. const frecency = calculateFrecency(time, count);
  6687. return {
  6688. id,
  6689. name: 'core/block',
  6690. initialAttributes: {
  6691. ref: reusableBlock.id
  6692. },
  6693. title: reusableBlock.title.raw,
  6694. icon,
  6695. category: 'reusable',
  6696. keywords: [],
  6697. isDisabled: false,
  6698. utility: 1,
  6699. // Deprecated.
  6700. frecency
  6701. };
  6702. };
  6703. const blockTypeInserterItems = (0,external_wp_blocks_namespaceObject.getBlockTypes)().filter(blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)).map(buildBlockTypeInserterItem);
  6704. const reusableBlockInserterItems = canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) ? getReusableBlocks(state).map(buildReusableBlockInserterItem) : [];
  6705. const items = blockTypeInserterItems.reduce((accumulator, item) => {
  6706. const {
  6707. variations = []
  6708. } = item; // Exclude any block type item that is to be replaced by a default variation.
  6709. if (!variations.some(_ref4 => {
  6710. let {
  6711. isDefault
  6712. } = _ref4;
  6713. return isDefault;
  6714. })) {
  6715. accumulator.push(item);
  6716. }
  6717. if (variations.length) {
  6718. const variationMapper = getItemFromVariation(state, item);
  6719. accumulator.push(...variations.map(variationMapper));
  6720. }
  6721. return accumulator;
  6722. }, []); // Ensure core blocks are prioritized in the returned results,
  6723. // because third party blocks can be registered earlier than
  6724. // the core blocks (usually by using the `init` action),
  6725. // thus affecting the display order.
  6726. // We don't sort reusable blocks as they are handled differently.
  6727. const groupByType = (blocks, block) => {
  6728. const {
  6729. core,
  6730. noncore
  6731. } = blocks;
  6732. const type = block.name.startsWith('core/') ? core : noncore;
  6733. type.push(block);
  6734. return blocks;
  6735. };
  6736. const {
  6737. core: coreItems,
  6738. noncore: nonCoreItems
  6739. } = items.reduce(groupByType, {
  6740. core: [],
  6741. noncore: []
  6742. });
  6743. const sortedBlockTypes = [...coreItems, ...nonCoreItems];
  6744. return [...sortedBlockTypes, ...reusableBlockInserterItems];
  6745. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.blocks.order, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), (0,external_wp_blocks_namespaceObject.getBlockTypes)()]);
  6746. /**
  6747. * Determines the items that appear in the available block transforms list.
  6748. *
  6749. * Each item object contains what's necessary to display a menu item in the
  6750. * transform list and handle its selection.
  6751. *
  6752. * The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency)
  6753. * that combines block usage frequenty and recency.
  6754. *
  6755. * Items are returned ordered descendingly by their 'frecency'.
  6756. *
  6757. * @param {Object} state Editor state.
  6758. * @param {Object|Object[]} blocks Block object or array objects.
  6759. * @param {?string} rootClientId Optional root client ID of block list.
  6760. *
  6761. * @return {WPEditorTransformItem[]} Items that appear in inserter.
  6762. *
  6763. * @typedef {Object} WPEditorTransformItem
  6764. * @property {string} id Unique identifier for the item.
  6765. * @property {string} name The type of block to create.
  6766. * @property {string} title Title of the item, as it appears in the inserter.
  6767. * @property {string} icon Dashicon for the item, as it appears in the inserter.
  6768. * @property {boolean} isDisabled Whether or not the user should be prevented from inserting
  6769. * this item.
  6770. * @property {number} frecency Heuristic that combines frequency and recency.
  6771. */
  6772. const getBlockTransformItems = rememo(function (state, blocks) {
  6773. var _itemsByName$sourceBl;
  6774. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6775. const normalizedBlocks = (0,external_lodash_namespaceObject.castArray)(blocks);
  6776. const [sourceBlock] = normalizedBlocks;
  6777. const buildBlockTypeTransformItem = buildBlockTypeItem(state, {
  6778. buildScope: 'transform'
  6779. });
  6780. const blockTypeTransformItems = (0,external_wp_blocks_namespaceObject.getBlockTypes)().filter(blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)).map(buildBlockTypeTransformItem);
  6781. const itemsByName = Object.fromEntries(Object.entries(blockTypeTransformItems).map(_ref5 => {
  6782. let [, value] = _ref5;
  6783. return [value.name, value];
  6784. })); // Consider unwraping the highest priority.
  6785. itemsByName['*'] = {
  6786. frecency: +Infinity,
  6787. id: '*',
  6788. isDisabled: false,
  6789. name: '*',
  6790. title: (0,external_wp_i18n_namespaceObject.__)('Unwrap'),
  6791. icon: (_itemsByName$sourceBl = itemsByName[sourceBlock === null || sourceBlock === void 0 ? void 0 : sourceBlock.name]) === null || _itemsByName$sourceBl === void 0 ? void 0 : _itemsByName$sourceBl.icon
  6792. };
  6793. const possibleTransforms = (0,external_wp_blocks_namespaceObject.getPossibleBlockTransformations)(normalizedBlocks).reduce((accumulator, block) => {
  6794. if (block === '*') {
  6795. accumulator.push(itemsByName['*']);
  6796. } else if (itemsByName[block === null || block === void 0 ? void 0 : block.name]) {
  6797. accumulator.push(itemsByName[block.name]);
  6798. }
  6799. return accumulator;
  6800. }, []);
  6801. return (0,external_lodash_namespaceObject.orderBy)(possibleTransforms, block => itemsByName[block.name].frecency, 'desc');
  6802. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, (0,external_wp_blocks_namespaceObject.getBlockTypes)()]);
  6803. /**
  6804. * Determines whether there are items to show in the inserter.
  6805. *
  6806. * @param {Object} state Editor state.
  6807. * @param {?string} rootClientId Optional root client ID of block list.
  6808. *
  6809. * @return {boolean} Items that appear in inserter.
  6810. */
  6811. const hasInserterItems = rememo(function (state) {
  6812. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6813. const hasBlockType = (0,external_lodash_namespaceObject.some)((0,external_wp_blocks_namespaceObject.getBlockTypes)(), blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId));
  6814. if (hasBlockType) {
  6815. return true;
  6816. }
  6817. const hasReusableBlock = canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) && getReusableBlocks(state).length > 0;
  6818. return hasReusableBlock;
  6819. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), (0,external_wp_blocks_namespaceObject.getBlockTypes)()]);
  6820. /**
  6821. * Returns the list of allowed inserter blocks for inner blocks children
  6822. *
  6823. * @param {Object} state Editor state.
  6824. * @param {?string} rootClientId Optional root client ID of block list.
  6825. *
  6826. * @return {Array?} The list of allowed block types.
  6827. */
  6828. const __experimentalGetAllowedBlocks = rememo(function (state) {
  6829. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6830. if (!rootClientId) {
  6831. return;
  6832. }
  6833. return (0,external_lodash_namespaceObject.filter)((0,external_wp_blocks_namespaceObject.getBlockTypes)(), blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId));
  6834. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, (0,external_wp_blocks_namespaceObject.getBlockTypes)()]);
  6835. /**
  6836. * Returns the block to be directly inserted by the block appender.
  6837. *
  6838. * @param {Object} state Editor state.
  6839. * @param {?string} rootClientId Optional root client ID of block list.
  6840. *
  6841. * @return {?WPDirectInsertBlock} The block type to be directly inserted.
  6842. *
  6843. * @typedef {Object} WPDirectInsertBlock
  6844. * @property {string} name The type of block.
  6845. * @property {?Object} attributes Attributes to pass to the newly created block.
  6846. * @property {?Array<string>} attributesToCopy Attributes to be copied from adjecent blocks when inserted.
  6847. */
  6848. const __experimentalGetDirectInsertBlock = rememo(function (state) {
  6849. var _state$blockListSetti, _state$blockListSetti2;
  6850. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6851. if (!rootClientId) {
  6852. return;
  6853. }
  6854. const defaultBlock = (_state$blockListSetti = state.blockListSettings[rootClientId]) === null || _state$blockListSetti === void 0 ? void 0 : _state$blockListSetti.__experimentalDefaultBlock;
  6855. const directInsert = (_state$blockListSetti2 = state.blockListSettings[rootClientId]) === null || _state$blockListSetti2 === void 0 ? void 0 : _state$blockListSetti2.__experimentalDirectInsert;
  6856. if (!defaultBlock || !directInsert) {
  6857. return;
  6858. }
  6859. if (typeof directInsert === 'function') {
  6860. return directInsert(getBlock(state, rootClientId)) ? defaultBlock : null;
  6861. }
  6862. return defaultBlock;
  6863. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.tree[rootClientId]]);
  6864. const checkAllowListRecursive = (blocks, allowedBlockTypes) => {
  6865. if (typeof allowedBlockTypes === 'boolean') {
  6866. return allowedBlockTypes;
  6867. }
  6868. const blocksQueue = [...blocks];
  6869. while (blocksQueue.length > 0) {
  6870. var _block$innerBlocks;
  6871. const block = blocksQueue.shift();
  6872. const isAllowed = checkAllowList(allowedBlockTypes, block.name || block.blockName, true);
  6873. if (!isAllowed) {
  6874. return false;
  6875. }
  6876. (_block$innerBlocks = block.innerBlocks) === null || _block$innerBlocks === void 0 ? void 0 : _block$innerBlocks.forEach(innerBlock => {
  6877. blocksQueue.push(innerBlock);
  6878. });
  6879. }
  6880. return true;
  6881. };
  6882. const __experimentalGetParsedPattern = rememo((state, patternName) => {
  6883. const patterns = state.settings.__experimentalBlockPatterns;
  6884. const pattern = patterns.find(_ref6 => {
  6885. let {
  6886. name
  6887. } = _ref6;
  6888. return name === patternName;
  6889. });
  6890. if (!pattern) {
  6891. return null;
  6892. }
  6893. return { ...pattern,
  6894. blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content, {
  6895. __unstableSkipMigrationLogs: true
  6896. })
  6897. };
  6898. }, state => [state.settings.__experimentalBlockPatterns]);
  6899. const getAllAllowedPatterns = rememo(state => {
  6900. const patterns = state.settings.__experimentalBlockPatterns;
  6901. const {
  6902. allowedBlockTypes
  6903. } = getSettings(state);
  6904. const parsedPatterns = patterns.filter(_ref7 => {
  6905. let {
  6906. inserter = true
  6907. } = _ref7;
  6908. return !!inserter;
  6909. }).map(_ref8 => {
  6910. let {
  6911. name
  6912. } = _ref8;
  6913. return __experimentalGetParsedPattern(state, name);
  6914. });
  6915. const allowedPatterns = parsedPatterns.filter(_ref9 => {
  6916. let {
  6917. blocks
  6918. } = _ref9;
  6919. return checkAllowListRecursive(blocks, allowedBlockTypes);
  6920. });
  6921. return allowedPatterns;
  6922. }, state => [state.settings.__experimentalBlockPatterns, state.settings.allowedBlockTypes]);
  6923. /**
  6924. * Returns the list of allowed patterns for inner blocks children.
  6925. *
  6926. * @param {Object} state Editor state.
  6927. * @param {?string} rootClientId Optional target root client ID.
  6928. *
  6929. * @return {Array?} The list of allowed patterns.
  6930. */
  6931. const __experimentalGetAllowedPatterns = rememo(function (state) {
  6932. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6933. const availableParsedPatterns = getAllAllowedPatterns(state);
  6934. const patternsAllowed = (0,external_lodash_namespaceObject.filter)(availableParsedPatterns, _ref10 => {
  6935. let {
  6936. blocks
  6937. } = _ref10;
  6938. return blocks.every(_ref11 => {
  6939. let {
  6940. name
  6941. } = _ref11;
  6942. return canInsertBlockType(state, name, rootClientId);
  6943. });
  6944. });
  6945. return patternsAllowed;
  6946. }, (state, rootClientId) => [state.settings.__experimentalBlockPatterns, state.settings.allowedBlockTypes, state.settings.templateLock, state.blockListSettings[rootClientId], state.blocks.byClientId[rootClientId]]);
  6947. /**
  6948. * Returns the list of patterns based on their declared `blockTypes`
  6949. * and a block's name.
  6950. * Patterns can use `blockTypes` to integrate in work flows like
  6951. * suggesting appropriate patterns in a Placeholder state(during insertion)
  6952. * or blocks transformations.
  6953. *
  6954. * @param {Object} state Editor state.
  6955. * @param {string|string[]} blockNames Block's name or array of block names to find matching pattens.
  6956. * @param {?string} rootClientId Optional target root client ID.
  6957. *
  6958. * @return {Array} The list of matched block patterns based on declared `blockTypes` and block name.
  6959. */
  6960. const __experimentalGetPatternsByBlockTypes = rememo(function (state, blockNames) {
  6961. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6962. if (!blockNames) return EMPTY_ARRAY;
  6963. const patterns = __experimentalGetAllowedPatterns(state, rootClientId);
  6964. const normalizedBlockNames = Array.isArray(blockNames) ? blockNames : [blockNames];
  6965. return patterns.filter(pattern => {
  6966. var _pattern$blockTypes, _pattern$blockTypes$s;
  6967. return pattern === null || pattern === void 0 ? void 0 : (_pattern$blockTypes = pattern.blockTypes) === null || _pattern$blockTypes === void 0 ? void 0 : (_pattern$blockTypes$s = _pattern$blockTypes.some) === null || _pattern$blockTypes$s === void 0 ? void 0 : _pattern$blockTypes$s.call(_pattern$blockTypes, blockName => normalizedBlockNames.includes(blockName));
  6968. });
  6969. }, (state, rootClientId) => [...__experimentalGetAllowedPatterns.getDependants(state, rootClientId)]);
  6970. /**
  6971. * Determines the items that appear in the available pattern transforms list.
  6972. *
  6973. * For now we only handle blocks without InnerBlocks and take into account
  6974. * the `__experimentalRole` property of blocks' attributes for the transformation.
  6975. *
  6976. * We return the first set of possible eligible block patterns,
  6977. * by checking the `blockTypes` property. We still have to recurse through
  6978. * block pattern's blocks and try to find matches from the selected blocks.
  6979. * Now this happens in the consumer to avoid heavy operations in the selector.
  6980. *
  6981. * @param {Object} state Editor state.
  6982. * @param {Object[]} blocks The selected blocks.
  6983. * @param {?string} rootClientId Optional root client ID of block list.
  6984. *
  6985. * @return {WPBlockPattern[]} Items that are eligible for a pattern transformation.
  6986. */
  6987. const __experimentalGetPatternTransformItems = rememo(function (state, blocks) {
  6988. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6989. if (!blocks) return EMPTY_ARRAY;
  6990. /**
  6991. * For now we only handle blocks without InnerBlocks and take into account
  6992. * the `__experimentalRole` property of blocks' attributes for the transformation.
  6993. * Note that the blocks have been retrieved through `getBlock`, which doesn't
  6994. * return the inner blocks of an inner block controller, so we still need
  6995. * to check for this case too.
  6996. */
  6997. if (blocks.some(_ref12 => {
  6998. let {
  6999. clientId,
  7000. innerBlocks
  7001. } = _ref12;
  7002. return innerBlocks.length || areInnerBlocksControlled(state, clientId);
  7003. })) {
  7004. return EMPTY_ARRAY;
  7005. } // Create a Set of the selected block names that is used in patterns filtering.
  7006. const selectedBlockNames = Array.from(new Set(blocks.map(_ref13 => {
  7007. let {
  7008. name
  7009. } = _ref13;
  7010. return name;
  7011. })));
  7012. /**
  7013. * Here we will return first set of possible eligible block patterns,
  7014. * by checking the `blockTypes` property. We still have to recurse through
  7015. * block pattern's blocks and try to find matches from the selected blocks.
  7016. * Now this happens in the consumer to avoid heavy operations in the selector.
  7017. */
  7018. return __experimentalGetPatternsByBlockTypes(state, selectedBlockNames, rootClientId);
  7019. }, (state, rootClientId) => [...__experimentalGetPatternsByBlockTypes.getDependants(state, rootClientId)]);
  7020. /**
  7021. * Returns the Block List settings of a block, if any exist.
  7022. *
  7023. * @param {Object} state Editor state.
  7024. * @param {?string} clientId Block client ID.
  7025. *
  7026. * @return {?Object} Block settings of the block if set.
  7027. */
  7028. function getBlockListSettings(state, clientId) {
  7029. return state.blockListSettings[clientId];
  7030. }
  7031. /**
  7032. * Returns the editor settings.
  7033. *
  7034. * @param {Object} state Editor state.
  7035. *
  7036. * @return {Object} The editor settings object.
  7037. */
  7038. function getSettings(state) {
  7039. return state.settings;
  7040. }
  7041. /**
  7042. * Returns true if the most recent block change is be considered persistent, or
  7043. * false otherwise. A persistent change is one committed by BlockEditorProvider
  7044. * via its `onChange` callback, in addition to `onInput`.
  7045. *
  7046. * @param {Object} state Block editor state.
  7047. *
  7048. * @return {boolean} Whether the most recent block change was persistent.
  7049. */
  7050. function isLastBlockChangePersistent(state) {
  7051. return state.blocks.isPersistentChange;
  7052. }
  7053. /**
  7054. * Returns the block list settings for an array of blocks, if any exist.
  7055. *
  7056. * @param {Object} state Editor state.
  7057. * @param {Array} clientIds Block client IDs.
  7058. *
  7059. * @return {Object} An object where the keys are client ids and the values are
  7060. * a block list setting object.
  7061. */
  7062. const __experimentalGetBlockListSettingsForBlocks = rememo(function (state) {
  7063. let clientIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  7064. return clientIds.reduce((blockListSettingsForBlocks, clientId) => {
  7065. if (!state.blockListSettings[clientId]) {
  7066. return blockListSettingsForBlocks;
  7067. }
  7068. return { ...blockListSettingsForBlocks,
  7069. [clientId]: state.blockListSettings[clientId]
  7070. };
  7071. }, {});
  7072. }, state => [state.blockListSettings]);
  7073. /**
  7074. * Returns the title of a given reusable block
  7075. *
  7076. * @param {Object} state Global application state.
  7077. * @param {number|string} ref The shared block's ID.
  7078. *
  7079. * @return {string} The reusable block saved title.
  7080. */
  7081. const __experimentalGetReusableBlockTitle = rememo((state, ref) => {
  7082. var _reusableBlock$title;
  7083. const reusableBlock = (0,external_lodash_namespaceObject.find)(getReusableBlocks(state), block => block.id === ref);
  7084. if (!reusableBlock) {
  7085. return null;
  7086. }
  7087. return (_reusableBlock$title = reusableBlock.title) === null || _reusableBlock$title === void 0 ? void 0 : _reusableBlock$title.raw;
  7088. }, state => [getReusableBlocks(state)]);
  7089. /**
  7090. * Returns true if the most recent block change is be considered ignored, or
  7091. * false otherwise. An ignored change is one not to be committed by
  7092. * BlockEditorProvider, neither via `onChange` nor `onInput`.
  7093. *
  7094. * @param {Object} state Block editor state.
  7095. *
  7096. * @return {boolean} Whether the most recent block change was ignored.
  7097. */
  7098. function __unstableIsLastBlockChangeIgnored(state) {
  7099. // TODO: Removal Plan: Changes incurred by RECEIVE_BLOCKS should not be
  7100. // ignored if in-fact they result in a change in blocks state. The current
  7101. // need to ignore changes not a result of user interaction should be
  7102. // accounted for in the refactoring of reusable blocks as occurring within
  7103. // their own separate block editor / state (#7119).
  7104. return state.blocks.isIgnoredChange;
  7105. }
  7106. /**
  7107. * Returns the block attributes changed as a result of the last dispatched
  7108. * action.
  7109. *
  7110. * @param {Object} state Block editor state.
  7111. *
  7112. * @return {Object<string,Object>} Subsets of block attributes changed, keyed
  7113. * by block client ID.
  7114. */
  7115. function __experimentalGetLastBlockAttributeChanges(state) {
  7116. return state.lastBlockAttributesChange;
  7117. }
  7118. /**
  7119. * Returns the available reusable blocks
  7120. *
  7121. * @param {Object} state Global application state.
  7122. *
  7123. * @return {Array} Reusable blocks
  7124. */
  7125. function getReusableBlocks(state) {
  7126. var _state$settings$__exp, _state$settings2;
  7127. return (_state$settings$__exp = state === null || state === void 0 ? void 0 : (_state$settings2 = state.settings) === null || _state$settings2 === void 0 ? void 0 : _state$settings2.__experimentalReusableBlocks) !== null && _state$settings$__exp !== void 0 ? _state$settings$__exp : EMPTY_ARRAY;
  7128. }
  7129. /**
  7130. * Returns whether the navigation mode is enabled.
  7131. *
  7132. * @param {Object} state Editor state.
  7133. *
  7134. * @return {boolean} Is navigation mode enabled.
  7135. */
  7136. function isNavigationMode(state) {
  7137. return state.editorMode === 'navigation';
  7138. }
  7139. /**
  7140. * Returns the current editor mode.
  7141. *
  7142. * @param {Object} state Editor state.
  7143. *
  7144. * @return {string} the editor mode.
  7145. */
  7146. function __unstableGetEditorMode(state) {
  7147. return state.editorMode;
  7148. }
  7149. /**
  7150. * Returns whether block moving mode is enabled.
  7151. *
  7152. * @param {Object} state Editor state.
  7153. *
  7154. * @return {string} Client Id of moving block.
  7155. */
  7156. function selectors_hasBlockMovingClientId(state) {
  7157. return state.hasBlockMovingClientId;
  7158. }
  7159. /**
  7160. * Returns true if the last change was an automatic change, false otherwise.
  7161. *
  7162. * @param {Object} state Global application state.
  7163. *
  7164. * @return {boolean} Whether the last change was automatic.
  7165. */
  7166. function didAutomaticChange(state) {
  7167. return !!state.automaticChangeStatus;
  7168. }
  7169. /**
  7170. * Returns true if the current highlighted block matches the block clientId.
  7171. *
  7172. * @param {Object} state Global application state.
  7173. * @param {string} clientId The block to check.
  7174. *
  7175. * @return {boolean} Whether the block is currently highlighted.
  7176. */
  7177. function isBlockHighlighted(state, clientId) {
  7178. return state.highlightedBlock === clientId;
  7179. }
  7180. /**
  7181. * Checks if a given block has controlled inner blocks.
  7182. *
  7183. * @param {Object} state Global application state.
  7184. * @param {string} clientId The block to check.
  7185. *
  7186. * @return {boolean} True if the block has controlled inner blocks.
  7187. */
  7188. function areInnerBlocksControlled(state, clientId) {
  7189. return !!state.blocks.controlledInnerBlocks[clientId];
  7190. }
  7191. /**
  7192. * Returns the clientId for the first 'active' block of a given array of block names.
  7193. * A block is 'active' if it (or a child) is the selected block.
  7194. * Returns the first match moving up the DOM from the selected block.
  7195. *
  7196. * @param {Object} state Global application state.
  7197. * @param {string[]} validBlocksNames The names of block types to check for.
  7198. *
  7199. * @return {string} The matching block's clientId.
  7200. */
  7201. const __experimentalGetActiveBlockIdByBlockNames = rememo((state, validBlockNames) => {
  7202. if (!validBlockNames.length) {
  7203. return null;
  7204. } // Check if selected block is a valid entity area.
  7205. const selectedBlockClientId = getSelectedBlockClientId(state);
  7206. if (validBlockNames.includes(getBlockName(state, selectedBlockClientId))) {
  7207. return selectedBlockClientId;
  7208. } // Check if first selected block is a child of a valid entity area.
  7209. const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(state);
  7210. const entityAreaParents = getBlockParentsByBlockName(state, selectedBlockClientId || multiSelectedBlockClientIds[0], validBlockNames);
  7211. if (entityAreaParents) {
  7212. // Last parent closest/most interior.
  7213. return entityAreaParents[entityAreaParents.length - 1];
  7214. }
  7215. return null;
  7216. }, (state, validBlockNames) => [state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId, validBlockNames]);
  7217. /**
  7218. * Tells if the block with the passed clientId was just inserted.
  7219. *
  7220. * @param {Object} state Global application state.
  7221. * @param {Object} clientId Client Id of the block.
  7222. * @param {?string} source Optional insertion source of the block.
  7223. * @return {boolean} True if the block matches the last block inserted from the specified source.
  7224. */
  7225. function wasBlockJustInserted(state, clientId, source) {
  7226. const {
  7227. lastBlockInserted
  7228. } = state;
  7229. return lastBlockInserted.clientId === clientId && lastBlockInserted.source === source;
  7230. }
  7231. /**
  7232. * Tells if the block is visible on the canvas or not.
  7233. *
  7234. * @param {Object} state Global application state.
  7235. * @param {Object} clientId Client Id of the block.
  7236. * @return {boolean} True if the block is visible.
  7237. */
  7238. function isBlockVisible(state, clientId) {
  7239. var _state$blocks$visibil, _state$blocks$visibil2;
  7240. return (_state$blocks$visibil = (_state$blocks$visibil2 = state.blocks.visibility) === null || _state$blocks$visibil2 === void 0 ? void 0 : _state$blocks$visibil2[clientId]) !== null && _state$blocks$visibil !== void 0 ? _state$blocks$visibil : true;
  7241. }
  7242. /**
  7243. * Returns the list of all hidden blocks.
  7244. *
  7245. * @param {Object} state Global application state.
  7246. * @return {[string]} List of hidden blocks.
  7247. */
  7248. const __unstableGetVisibleBlocks = rememo(state => {
  7249. return new Set(Object.keys(state.blocks.visibility).filter(key => state.blocks.visibility[key]));
  7250. }, state => [state.blocks.visibility]);
  7251. const __unstableGetContentLockingParent = rememo((state, clientId) => {
  7252. let current = clientId;
  7253. let result;
  7254. while (!!state.blocks.parents[current]) {
  7255. current = state.blocks.parents[current];
  7256. if (getTemplateLock(state, current) === 'contentOnly') {
  7257. result = current;
  7258. }
  7259. }
  7260. return result;
  7261. }, state => [state.blocks.parents, state.blockListSettings]);
  7262. function __unstableGetTemporarilyEditingAsBlocks(state) {
  7263. return state.temporarilyEditingAsBlocks;
  7264. }
  7265. function __unstableHasActiveBlockOverlayActive(state, clientId) {
  7266. // If the block editing is locked, the block overlay is always active.
  7267. if (!canEditBlock(state, clientId)) {
  7268. return true;
  7269. }
  7270. const editorMode = __unstableGetEditorMode(state); // In zoom-out mode, the block overlay is always active for top level blocks.
  7271. if (editorMode === 'zoom-out' && !getBlockRootClientId(state, clientId)) {
  7272. return true;
  7273. } // In navigation mode, the block overlay is active when the block is not
  7274. // selected (and doesn't contain a selected child). The same behavior is
  7275. // also enabled in all modes for blocks that have controlled children
  7276. // (reusable block, template part, navigation), unless explicitly disabled
  7277. // with `supports.__experimentalDisableBlockOverlay`.
  7278. const blockSupportDisable = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(getBlockName(state, clientId), '__experimentalDisableBlockOverlay', false);
  7279. const shouldEnableIfUnselected = editorMode === 'navigation' || (blockSupportDisable ? false : areInnerBlocksControlled(state, clientId));
  7280. return shouldEnableIfUnselected && !isBlockSelected(state, clientId) && !hasSelectedInnerBlock(state, clientId, true);
  7281. }
  7282. function __unstableIsWithinBlockOverlay(state, clientId) {
  7283. let parent = state.blocks.parents[clientId];
  7284. while (!!parent) {
  7285. if (__unstableHasActiveBlockOverlayActive(state, parent)) {
  7286. return true;
  7287. }
  7288. parent = state.blocks.parents[parent];
  7289. }
  7290. return false;
  7291. }
  7292. ;// CONCATENATED MODULE: external ["wp","a11y"]
  7293. var external_wp_a11y_namespaceObject = window["wp"]["a11y"];
  7294. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/selection.js
  7295. /**
  7296. * A robust way to retain selection position through various
  7297. * transforms is to insert a special character at the position and
  7298. * then recover it.
  7299. */
  7300. const START_OF_SELECTED_AREA = '\u0086';
  7301. /**
  7302. * Retrieve the block attribute that contains the selection position.
  7303. *
  7304. * @param {Object} blockAttributes Block attributes.
  7305. * @return {string|void} The name of the block attribute that was previously selected.
  7306. */
  7307. function retrieveSelectedAttribute(blockAttributes) {
  7308. if (!blockAttributes) {
  7309. return;
  7310. }
  7311. return Object.keys(blockAttributes).find(name => {
  7312. const value = blockAttributes[name];
  7313. return typeof value === 'string' && value.indexOf(START_OF_SELECTED_AREA) !== -1;
  7314. });
  7315. }
  7316. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/actions.js
  7317. /**
  7318. * WordPress dependencies
  7319. */
  7320. /**
  7321. * Internal dependencies
  7322. */
  7323. const castArray = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];
  7324. /**
  7325. * Action which will insert a default block insert action if there
  7326. * are no other blocks at the root of the editor. This action should be used
  7327. * in actions which may result in no blocks remaining in the editor (removal,
  7328. * replacement, etc).
  7329. */
  7330. const ensureDefaultBlock = () => _ref => {
  7331. let {
  7332. select,
  7333. dispatch
  7334. } = _ref;
  7335. // To avoid a focus loss when removing the last block, assure there is
  7336. // always a default block if the last of the blocks have been removed.
  7337. const count = select.getBlockCount();
  7338. if (count > 0) {
  7339. return;
  7340. } // If there's an custom appender, don't insert default block.
  7341. // We have to remember to manually move the focus elsewhere to
  7342. // prevent it from being lost though.
  7343. const {
  7344. __unstableHasCustomAppender
  7345. } = select.getSettings();
  7346. if (__unstableHasCustomAppender) {
  7347. return;
  7348. }
  7349. dispatch.insertDefaultBlock();
  7350. };
  7351. /**
  7352. * Action that resets blocks state to the specified array of blocks, taking precedence
  7353. * over any other content reflected as an edit in state.
  7354. *
  7355. * @param {Array} blocks Array of blocks.
  7356. */
  7357. const resetBlocks = blocks => _ref2 => {
  7358. let {
  7359. dispatch
  7360. } = _ref2;
  7361. dispatch({
  7362. type: 'RESET_BLOCKS',
  7363. blocks
  7364. });
  7365. dispatch(validateBlocksToTemplate(blocks));
  7366. };
  7367. /**
  7368. * Block validity is a function of blocks state (at the point of a
  7369. * reset) and the template setting. As a compromise to its placement
  7370. * across distinct parts of state, it is implemented here as a side-
  7371. * effect of the block reset action.
  7372. *
  7373. * @param {Array} blocks Array of blocks.
  7374. */
  7375. const validateBlocksToTemplate = blocks => _ref3 => {
  7376. let {
  7377. select,
  7378. dispatch
  7379. } = _ref3;
  7380. const template = select.getTemplate();
  7381. const templateLock = select.getTemplateLock(); // Unlocked templates are considered always valid because they act
  7382. // as default values only.
  7383. const isBlocksValidToTemplate = !template || templateLock !== 'all' || (0,external_wp_blocks_namespaceObject.doBlocksMatchTemplate)(blocks, template); // Update if validity has changed.
  7384. const isValidTemplate = select.isValidTemplate();
  7385. if (isBlocksValidToTemplate !== isValidTemplate) {
  7386. dispatch.setTemplateValidity(isBlocksValidToTemplate);
  7387. return isBlocksValidToTemplate;
  7388. }
  7389. };
  7390. /**
  7391. * A block selection object.
  7392. *
  7393. * @typedef {Object} WPBlockSelection
  7394. *
  7395. * @property {string} clientId A block client ID.
  7396. * @property {string} attributeKey A block attribute key.
  7397. * @property {number} offset An attribute value offset, based on the rich
  7398. * text value. See `wp.richText.create`.
  7399. */
  7400. /**
  7401. * A selection object.
  7402. *
  7403. * @typedef {Object} WPSelection
  7404. *
  7405. * @property {WPBlockSelection} start The selection start.
  7406. * @property {WPBlockSelection} end The selection end.
  7407. */
  7408. /* eslint-disable jsdoc/valid-types */
  7409. /**
  7410. * Returns an action object used in signalling that selection state should be
  7411. * reset to the specified selection.
  7412. *
  7413. * @param {WPBlockSelection} selectionStart The selection start.
  7414. * @param {WPBlockSelection} selectionEnd The selection end.
  7415. * @param {0|-1|null} initialPosition Initial block position.
  7416. *
  7417. * @return {Object} Action object.
  7418. */
  7419. function resetSelection(selectionStart, selectionEnd, initialPosition) {
  7420. /* eslint-enable jsdoc/valid-types */
  7421. return {
  7422. type: 'RESET_SELECTION',
  7423. selectionStart,
  7424. selectionEnd,
  7425. initialPosition
  7426. };
  7427. }
  7428. /**
  7429. * Returns an action object used in signalling that blocks have been received.
  7430. * Unlike resetBlocks, these should be appended to the existing known set, not
  7431. * replacing.
  7432. *
  7433. * @deprecated
  7434. *
  7435. * @param {Object[]} blocks Array of block objects.
  7436. *
  7437. * @return {Object} Action object.
  7438. */
  7439. function receiveBlocks(blocks) {
  7440. external_wp_deprecated_default()('wp.data.dispatch( "core/block-editor" ).receiveBlocks', {
  7441. since: '5.9',
  7442. alternative: 'resetBlocks or insertBlocks'
  7443. });
  7444. return {
  7445. type: 'RECEIVE_BLOCKS',
  7446. blocks
  7447. };
  7448. }
  7449. /**
  7450. * Action that updates attributes of multiple blocks with the specified client IDs.
  7451. *
  7452. * @param {string|string[]} clientIds Block client IDs.
  7453. * @param {Object} attributes Block attributes to be merged. Should be keyed by clientIds if
  7454. * uniqueByBlock is true.
  7455. * @param {boolean} uniqueByBlock true if each block in clientIds array has a unique set of attributes
  7456. * @return {Object} Action object.
  7457. */
  7458. function updateBlockAttributes(clientIds, attributes) {
  7459. let uniqueByBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7460. return {
  7461. type: 'UPDATE_BLOCK_ATTRIBUTES',
  7462. clientIds: castArray(clientIds),
  7463. attributes,
  7464. uniqueByBlock
  7465. };
  7466. }
  7467. /**
  7468. * Action that updates the block with the specified client ID.
  7469. *
  7470. * @param {string} clientId Block client ID.
  7471. * @param {Object} updates Block attributes to be merged.
  7472. *
  7473. * @return {Object} Action object.
  7474. */
  7475. function updateBlock(clientId, updates) {
  7476. return {
  7477. type: 'UPDATE_BLOCK',
  7478. clientId,
  7479. updates
  7480. };
  7481. }
  7482. /* eslint-disable jsdoc/valid-types */
  7483. /**
  7484. * Returns an action object used in signalling that the block with the
  7485. * specified client ID has been selected, optionally accepting a position
  7486. * value reflecting its selection directionality. An initialPosition of -1
  7487. * reflects a reverse selection.
  7488. *
  7489. * @param {string} clientId Block client ID.
  7490. * @param {0|-1|null} initialPosition Optional initial position. Pass as -1 to
  7491. * reflect reverse selection.
  7492. *
  7493. * @return {Object} Action object.
  7494. */
  7495. function selectBlock(clientId) {
  7496. let initialPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  7497. /* eslint-enable jsdoc/valid-types */
  7498. return {
  7499. type: 'SELECT_BLOCK',
  7500. initialPosition,
  7501. clientId
  7502. };
  7503. }
  7504. /**
  7505. * Yields action objects used in signalling that the block preceding the given
  7506. * clientId should be selected.
  7507. *
  7508. * @param {string} clientId Block client ID.
  7509. */
  7510. const selectPreviousBlock = clientId => _ref4 => {
  7511. let {
  7512. select,
  7513. dispatch
  7514. } = _ref4;
  7515. const previousBlockClientId = select.getPreviousBlockClientId(clientId);
  7516. if (previousBlockClientId) {
  7517. dispatch.selectBlock(previousBlockClientId, -1);
  7518. }
  7519. };
  7520. /**
  7521. * Yields action objects used in signalling that the block following the given
  7522. * clientId should be selected.
  7523. *
  7524. * @param {string} clientId Block client ID.
  7525. */
  7526. const selectNextBlock = clientId => _ref5 => {
  7527. let {
  7528. select,
  7529. dispatch
  7530. } = _ref5;
  7531. const nextBlockClientId = select.getNextBlockClientId(clientId);
  7532. if (nextBlockClientId) {
  7533. dispatch.selectBlock(nextBlockClientId);
  7534. }
  7535. };
  7536. /**
  7537. * Action that starts block multi-selection.
  7538. *
  7539. * @return {Object} Action object.
  7540. */
  7541. function startMultiSelect() {
  7542. return {
  7543. type: 'START_MULTI_SELECT'
  7544. };
  7545. }
  7546. /**
  7547. * Action that stops block multi-selection.
  7548. *
  7549. * @return {Object} Action object.
  7550. */
  7551. function stopMultiSelect() {
  7552. return {
  7553. type: 'STOP_MULTI_SELECT'
  7554. };
  7555. }
  7556. /**
  7557. * Action that changes block multi-selection.
  7558. *
  7559. * @param {string} start First block of the multi selection.
  7560. * @param {string} end Last block of the multiselection.
  7561. * @param {number|null} __experimentalInitialPosition Optional initial position. Pass as null to skip focus within editor canvas.
  7562. */
  7563. const multiSelect = function (start, end) {
  7564. let __experimentalInitialPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  7565. return _ref6 => {
  7566. let {
  7567. select,
  7568. dispatch
  7569. } = _ref6;
  7570. const startBlockRootClientId = select.getBlockRootClientId(start);
  7571. const endBlockRootClientId = select.getBlockRootClientId(end); // Only allow block multi-selections at the same level.
  7572. if (startBlockRootClientId !== endBlockRootClientId) {
  7573. return;
  7574. }
  7575. dispatch({
  7576. type: 'MULTI_SELECT',
  7577. start,
  7578. end,
  7579. initialPosition: __experimentalInitialPosition
  7580. });
  7581. const blockCount = select.getSelectedBlockCount();
  7582. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)(
  7583. /* translators: %s: number of selected blocks */
  7584. (0,external_wp_i18n_namespaceObject._n)('%s block selected.', '%s blocks selected.', blockCount), blockCount), 'assertive');
  7585. };
  7586. };
  7587. /**
  7588. * Action that clears the block selection.
  7589. *
  7590. * @return {Object} Action object.
  7591. */
  7592. function clearSelectedBlock() {
  7593. return {
  7594. type: 'CLEAR_SELECTED_BLOCK'
  7595. };
  7596. }
  7597. /**
  7598. * Action that enables or disables block selection.
  7599. *
  7600. * @param {boolean} [isSelectionEnabled=true] Whether block selection should
  7601. * be enabled.
  7602. *
  7603. * @return {Object} Action object.
  7604. */
  7605. function toggleSelection() {
  7606. let isSelectionEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  7607. return {
  7608. type: 'TOGGLE_SELECTION',
  7609. isSelectionEnabled
  7610. };
  7611. }
  7612. function getBlocksWithDefaultStylesApplied(blocks, blockEditorSettings) {
  7613. var _blockEditorSettings$, _blockEditorSettings$2;
  7614. const preferredStyleVariations = (_blockEditorSettings$ = blockEditorSettings === null || blockEditorSettings === void 0 ? void 0 : (_blockEditorSettings$2 = blockEditorSettings.__experimentalPreferredStyleVariations) === null || _blockEditorSettings$2 === void 0 ? void 0 : _blockEditorSettings$2.value) !== null && _blockEditorSettings$ !== void 0 ? _blockEditorSettings$ : {};
  7615. return blocks.map(block => {
  7616. var _block$attributes;
  7617. const blockName = block.name;
  7618. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'defaultStylePicker', true)) {
  7619. return block;
  7620. }
  7621. if (!preferredStyleVariations[blockName]) {
  7622. return block;
  7623. }
  7624. const className = (_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.className;
  7625. if (className !== null && className !== void 0 && className.includes('is-style-')) {
  7626. return block;
  7627. }
  7628. const {
  7629. attributes = {}
  7630. } = block;
  7631. const blockStyle = preferredStyleVariations[blockName];
  7632. return { ...block,
  7633. attributes: { ...attributes,
  7634. className: `${className || ''} is-style-${blockStyle}`.trim()
  7635. }
  7636. };
  7637. });
  7638. }
  7639. /* eslint-disable jsdoc/valid-types */
  7640. /**
  7641. * Action that replaces given blocks with one or more replacement blocks.
  7642. *
  7643. * @param {(string|string[])} clientIds Block client ID(s) to replace.
  7644. * @param {(Object|Object[])} blocks Replacement block(s).
  7645. * @param {number} indexToSelect Index of replacement block to select.
  7646. * @param {0|-1|null} initialPosition Index of caret after in the selected block after the operation.
  7647. * @param {?Object} meta Optional Meta values to be passed to the action object.
  7648. *
  7649. * @return {Object} Action object.
  7650. */
  7651. const replaceBlocks = function (clientIds, blocks, indexToSelect) {
  7652. let initialPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  7653. let meta = arguments.length > 4 ? arguments[4] : undefined;
  7654. return _ref7 => {
  7655. let {
  7656. select,
  7657. dispatch
  7658. } = _ref7;
  7659. /* eslint-enable jsdoc/valid-types */
  7660. clientIds = castArray(clientIds);
  7661. blocks = getBlocksWithDefaultStylesApplied(castArray(blocks), select.getSettings());
  7662. const rootClientId = select.getBlockRootClientId(clientIds[0]); // Replace is valid if the new blocks can be inserted in the root block.
  7663. for (let index = 0; index < blocks.length; index++) {
  7664. const block = blocks[index];
  7665. const canInsertBlock = select.canInsertBlockType(block.name, rootClientId);
  7666. if (!canInsertBlock) {
  7667. return;
  7668. }
  7669. }
  7670. dispatch({
  7671. type: 'REPLACE_BLOCKS',
  7672. clientIds,
  7673. blocks,
  7674. time: Date.now(),
  7675. indexToSelect,
  7676. initialPosition,
  7677. meta
  7678. });
  7679. dispatch(ensureDefaultBlock());
  7680. };
  7681. };
  7682. /**
  7683. * Action that replaces a single block with one or more replacement blocks.
  7684. *
  7685. * @param {(string|string[])} clientId Block client ID to replace.
  7686. * @param {(Object|Object[])} block Replacement block(s).
  7687. *
  7688. * @return {Object} Action object.
  7689. */
  7690. function replaceBlock(clientId, block) {
  7691. return replaceBlocks(clientId, block);
  7692. }
  7693. /**
  7694. * Higher-order action creator which, given the action type to dispatch creates
  7695. * an action creator for managing block movement.
  7696. *
  7697. * @param {string} type Action type to dispatch.
  7698. *
  7699. * @return {Function} Action creator.
  7700. */
  7701. const createOnMove = type => (clientIds, rootClientId) => _ref8 => {
  7702. let {
  7703. select,
  7704. dispatch
  7705. } = _ref8;
  7706. // If one of the blocks is locked or the parent is locked, we cannot move any block.
  7707. const canMoveBlocks = select.canMoveBlocks(clientIds, rootClientId);
  7708. if (!canMoveBlocks) {
  7709. return;
  7710. }
  7711. dispatch({
  7712. type,
  7713. clientIds: castArray(clientIds),
  7714. rootClientId
  7715. });
  7716. };
  7717. const moveBlocksDown = createOnMove('MOVE_BLOCKS_DOWN');
  7718. const moveBlocksUp = createOnMove('MOVE_BLOCKS_UP');
  7719. /**
  7720. * Action that moves given blocks to a new position.
  7721. *
  7722. * @param {?string} clientIds The client IDs of the blocks.
  7723. * @param {?string} fromRootClientId Root client ID source.
  7724. * @param {?string} toRootClientId Root client ID destination.
  7725. * @param {number} index The index to move the blocks to.
  7726. */
  7727. const moveBlocksToPosition = function (clientIds) {
  7728. let fromRootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  7729. let toRootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  7730. let index = arguments.length > 3 ? arguments[3] : undefined;
  7731. return _ref9 => {
  7732. let {
  7733. select,
  7734. dispatch
  7735. } = _ref9;
  7736. const canMoveBlocks = select.canMoveBlocks(clientIds, fromRootClientId); // If one of the blocks is locked or the parent is locked, we cannot move any block.
  7737. if (!canMoveBlocks) {
  7738. return;
  7739. } // If moving inside the same root block the move is always possible.
  7740. if (fromRootClientId !== toRootClientId) {
  7741. const canRemoveBlocks = select.canRemoveBlocks(clientIds, fromRootClientId); // If we're moving to another block, it means we're deleting blocks from
  7742. // the original block, so we need to check if removing is possible.
  7743. if (!canRemoveBlocks) {
  7744. return;
  7745. }
  7746. const canInsertBlocks = select.canInsertBlocks(clientIds, toRootClientId); // If moving to other parent block, the move is possible if we can insert a block of the same type inside the new parent block.
  7747. if (!canInsertBlocks) {
  7748. return;
  7749. }
  7750. }
  7751. dispatch({
  7752. type: 'MOVE_BLOCKS_TO_POSITION',
  7753. fromRootClientId,
  7754. toRootClientId,
  7755. clientIds,
  7756. index
  7757. });
  7758. };
  7759. };
  7760. /**
  7761. * Action that moves given block to a new position.
  7762. *
  7763. * @param {?string} clientId The client ID of the block.
  7764. * @param {?string} fromRootClientId Root client ID source.
  7765. * @param {?string} toRootClientId Root client ID destination.
  7766. * @param {number} index The index to move the block to.
  7767. */
  7768. function moveBlockToPosition(clientId) {
  7769. let fromRootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  7770. let toRootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  7771. let index = arguments.length > 3 ? arguments[3] : undefined;
  7772. return moveBlocksToPosition([clientId], fromRootClientId, toRootClientId, index);
  7773. }
  7774. /**
  7775. * Action that inserts a single block, optionally at a specific index respective a root block list.
  7776. *
  7777. * @param {Object} block Block object to insert.
  7778. * @param {?number} index Index at which block should be inserted.
  7779. * @param {?string} rootClientId Optional root client ID of block list on which to insert.
  7780. * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
  7781. * @param {?Object} meta Optional Meta values to be passed to the action object.
  7782. *
  7783. * @return {Object} Action object.
  7784. */
  7785. function insertBlock(block, index, rootClientId, updateSelection, meta) {
  7786. return insertBlocks([block], index, rootClientId, updateSelection, 0, meta);
  7787. }
  7788. /* eslint-disable jsdoc/valid-types */
  7789. /**
  7790. * Action that inserts an array of blocks, optionally at a specific index respective a root block list.
  7791. *
  7792. * @param {Object[]} blocks Block objects to insert.
  7793. * @param {?number} index Index at which block should be inserted.
  7794. * @param {?string} rootClientId Optional root client ID of block list on which to insert.
  7795. * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
  7796. * @param {0|-1|null} initialPosition Initial focus position. Setting it to null prevent focusing the inserted block.
  7797. * @param {?Object} meta Optional Meta values to be passed to the action object.
  7798. * @return {Object} Action object.
  7799. */
  7800. const insertBlocks = function (blocks, index, rootClientId) {
  7801. let updateSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  7802. let initialPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
  7803. let meta = arguments.length > 5 ? arguments[5] : undefined;
  7804. return _ref10 => {
  7805. let {
  7806. select,
  7807. dispatch
  7808. } = _ref10;
  7809. /* eslint-enable jsdoc/valid-types */
  7810. if (initialPosition !== null && typeof initialPosition === 'object') {
  7811. meta = initialPosition;
  7812. initialPosition = 0;
  7813. external_wp_deprecated_default()("meta argument in wp.data.dispatch('core/block-editor')", {
  7814. since: '5.8',
  7815. hint: 'The meta argument is now the 6th argument of the function'
  7816. });
  7817. }
  7818. blocks = getBlocksWithDefaultStylesApplied(castArray(blocks), select.getSettings());
  7819. const allowedBlocks = [];
  7820. for (const block of blocks) {
  7821. const isValid = select.canInsertBlockType(block.name, rootClientId);
  7822. if (isValid) {
  7823. allowedBlocks.push(block);
  7824. }
  7825. }
  7826. if (allowedBlocks.length) {
  7827. dispatch({
  7828. type: 'INSERT_BLOCKS',
  7829. blocks: allowedBlocks,
  7830. index,
  7831. rootClientId,
  7832. time: Date.now(),
  7833. updateSelection,
  7834. initialPosition: updateSelection ? initialPosition : null,
  7835. meta
  7836. });
  7837. }
  7838. };
  7839. };
  7840. /**
  7841. * Action that shows the insertion point.
  7842. *
  7843. * @param {?string} rootClientId Optional root client ID of block list on
  7844. * which to insert.
  7845. * @param {?number} index Index at which block should be inserted.
  7846. * @param {Object} __unstableOptions Whether or not to show an inserter button.
  7847. *
  7848. * @return {Object} Action object.
  7849. */
  7850. function showInsertionPoint(rootClientId, index) {
  7851. let __unstableOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  7852. const {
  7853. __unstableWithInserter
  7854. } = __unstableOptions;
  7855. return {
  7856. type: 'SHOW_INSERTION_POINT',
  7857. rootClientId,
  7858. index,
  7859. __unstableWithInserter
  7860. };
  7861. }
  7862. /**
  7863. * Action that hides the insertion point.
  7864. *
  7865. * @return {Object} Action object.
  7866. */
  7867. function hideInsertionPoint() {
  7868. return {
  7869. type: 'HIDE_INSERTION_POINT'
  7870. };
  7871. }
  7872. /**
  7873. * Action that resets the template validity.
  7874. *
  7875. * @param {boolean} isValid template validity flag.
  7876. *
  7877. * @return {Object} Action object.
  7878. */
  7879. function setTemplateValidity(isValid) {
  7880. return {
  7881. type: 'SET_TEMPLATE_VALIDITY',
  7882. isValid
  7883. };
  7884. }
  7885. /**
  7886. * Action that synchronizes the template with the list of blocks.
  7887. *
  7888. * @return {Object} Action object.
  7889. */
  7890. const synchronizeTemplate = () => _ref11 => {
  7891. let {
  7892. select,
  7893. dispatch
  7894. } = _ref11;
  7895. dispatch({
  7896. type: 'SYNCHRONIZE_TEMPLATE'
  7897. });
  7898. const blocks = select.getBlocks();
  7899. const template = select.getTemplate();
  7900. const updatedBlockList = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template);
  7901. dispatch.resetBlocks(updatedBlockList);
  7902. };
  7903. /**
  7904. * Delete the current selection.
  7905. *
  7906. * @param {boolean} isForward
  7907. */
  7908. const __unstableDeleteSelection = isForward => _ref12 => {
  7909. let {
  7910. registry,
  7911. select,
  7912. dispatch
  7913. } = _ref12;
  7914. const selectionAnchor = select.getSelectionStart();
  7915. const selectionFocus = select.getSelectionEnd();
  7916. if (selectionAnchor.clientId === selectionFocus.clientId) return; // It's not mergeable if there's no rich text selection.
  7917. if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') return false;
  7918. const anchorRootClientId = select.getBlockRootClientId(selectionAnchor.clientId);
  7919. const focusRootClientId = select.getBlockRootClientId(selectionFocus.clientId); // It's not mergeable if the selection doesn't start and end in the same
  7920. // block list. Maybe in the future it should be allowed.
  7921. if (anchorRootClientId !== focusRootClientId) {
  7922. return;
  7923. }
  7924. const blockOrder = select.getBlockOrder(anchorRootClientId);
  7925. const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
  7926. const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order.
  7927. let selectionStart, selectionEnd;
  7928. if (anchorIndex > focusIndex) {
  7929. selectionStart = selectionFocus;
  7930. selectionEnd = selectionAnchor;
  7931. } else {
  7932. selectionStart = selectionAnchor;
  7933. selectionEnd = selectionFocus;
  7934. }
  7935. const targetSelection = isForward ? selectionEnd : selectionStart;
  7936. const targetBlock = select.getBlock(targetSelection.clientId);
  7937. const targetBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(targetBlock.name);
  7938. if (!targetBlockType.merge) {
  7939. return;
  7940. }
  7941. const selectionA = selectionStart;
  7942. const selectionB = selectionEnd;
  7943. const blockA = select.getBlock(selectionA.clientId);
  7944. const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name);
  7945. const blockB = select.getBlock(selectionB.clientId);
  7946. const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name);
  7947. const htmlA = blockA.attributes[selectionA.attributeKey];
  7948. const htmlB = blockB.attributes[selectionB.attributeKey];
  7949. const attributeDefinitionA = blockAType.attributes[selectionA.attributeKey];
  7950. const attributeDefinitionB = blockBType.attributes[selectionB.attributeKey];
  7951. let valueA = (0,external_wp_richText_namespaceObject.create)({
  7952. html: htmlA,
  7953. ...mapRichTextSettings(attributeDefinitionA)
  7954. });
  7955. let valueB = (0,external_wp_richText_namespaceObject.create)({
  7956. html: htmlB,
  7957. ...mapRichTextSettings(attributeDefinitionB)
  7958. });
  7959. valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, selectionA.offset, valueA.text.length);
  7960. valueB = (0,external_wp_richText_namespaceObject.insert)(valueB, START_OF_SELECTED_AREA, 0, selectionB.offset); // Clone the blocks so we don't manipulate the original.
  7961. const cloneA = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockA, {
  7962. [selectionA.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  7963. value: valueA,
  7964. ...mapRichTextSettings(attributeDefinitionA)
  7965. })
  7966. });
  7967. const cloneB = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockB, {
  7968. [selectionB.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  7969. value: valueB,
  7970. ...mapRichTextSettings(attributeDefinitionB)
  7971. })
  7972. });
  7973. const followingBlock = isForward ? cloneA : cloneB; // We can only merge blocks with similar types
  7974. // thus, we transform the block to merge first
  7975. const blocksWithTheSameType = blockA.name === blockB.name ? [followingBlock] : (0,external_wp_blocks_namespaceObject.switchToBlockType)(followingBlock, targetBlockType.name); // If the block types can not match, do nothing
  7976. if (!blocksWithTheSameType || !blocksWithTheSameType.length) {
  7977. return;
  7978. }
  7979. let updatedAttributes;
  7980. if (isForward) {
  7981. const blockToMerge = blocksWithTheSameType.pop();
  7982. updatedAttributes = targetBlockType.merge(blockToMerge.attributes, cloneB.attributes);
  7983. } else {
  7984. const blockToMerge = blocksWithTheSameType.shift();
  7985. updatedAttributes = targetBlockType.merge(cloneA.attributes, blockToMerge.attributes);
  7986. }
  7987. const newAttributeKey = retrieveSelectedAttribute(updatedAttributes);
  7988. const convertedHtml = updatedAttributes[newAttributeKey];
  7989. const convertedValue = (0,external_wp_richText_namespaceObject.create)({
  7990. html: convertedHtml,
  7991. ...mapRichTextSettings(targetBlockType.attributes[newAttributeKey])
  7992. });
  7993. const newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA);
  7994. const newValue = (0,external_wp_richText_namespaceObject.remove)(convertedValue, newOffset, newOffset + 1);
  7995. const newHtml = (0,external_wp_richText_namespaceObject.toHTMLString)({
  7996. value: newValue,
  7997. ...mapRichTextSettings(targetBlockType.attributes[newAttributeKey])
  7998. });
  7999. updatedAttributes[newAttributeKey] = newHtml;
  8000. const selectedBlockClientIds = select.getSelectedBlockClientIds();
  8001. const replacement = [...(isForward ? blocksWithTheSameType : []), { // Preserve the original client ID.
  8002. ...targetBlock,
  8003. attributes: { ...targetBlock.attributes,
  8004. ...updatedAttributes
  8005. }
  8006. }, ...(isForward ? [] : blocksWithTheSameType)];
  8007. registry.batch(() => {
  8008. dispatch.selectionChange(targetBlock.clientId, newAttributeKey, newOffset, newOffset);
  8009. dispatch.replaceBlocks(selectedBlockClientIds, replacement, 0, // If we don't pass the `indexToSelect` it will default to the last block.
  8010. select.getSelectedBlocksInitialCaretPosition());
  8011. });
  8012. };
  8013. /**
  8014. * Split the current selection.
  8015. */
  8016. const __unstableSplitSelection = () => _ref13 => {
  8017. let {
  8018. select,
  8019. dispatch
  8020. } = _ref13;
  8021. const selectionAnchor = select.getSelectionStart();
  8022. const selectionFocus = select.getSelectionEnd();
  8023. if (selectionAnchor.clientId === selectionFocus.clientId) return; // Can't split if the selection is not set.
  8024. if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') return;
  8025. const anchorRootClientId = select.getBlockRootClientId(selectionAnchor.clientId);
  8026. const focusRootClientId = select.getBlockRootClientId(selectionFocus.clientId); // It's not splittable if the selection doesn't start and end in the same
  8027. // block list. Maybe in the future it should be allowed.
  8028. if (anchorRootClientId !== focusRootClientId) {
  8029. return;
  8030. }
  8031. const blockOrder = select.getBlockOrder(anchorRootClientId);
  8032. const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
  8033. const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order.
  8034. let selectionStart, selectionEnd;
  8035. if (anchorIndex > focusIndex) {
  8036. selectionStart = selectionFocus;
  8037. selectionEnd = selectionAnchor;
  8038. } else {
  8039. selectionStart = selectionAnchor;
  8040. selectionEnd = selectionFocus;
  8041. }
  8042. const selectionA = selectionStart;
  8043. const selectionB = selectionEnd;
  8044. const blockA = select.getBlock(selectionA.clientId);
  8045. const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name);
  8046. const blockB = select.getBlock(selectionB.clientId);
  8047. const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name);
  8048. const htmlA = blockA.attributes[selectionA.attributeKey];
  8049. const htmlB = blockB.attributes[selectionB.attributeKey];
  8050. const attributeDefinitionA = blockAType.attributes[selectionA.attributeKey];
  8051. const attributeDefinitionB = blockBType.attributes[selectionB.attributeKey];
  8052. let valueA = (0,external_wp_richText_namespaceObject.create)({
  8053. html: htmlA,
  8054. ...mapRichTextSettings(attributeDefinitionA)
  8055. });
  8056. let valueB = (0,external_wp_richText_namespaceObject.create)({
  8057. html: htmlB,
  8058. ...mapRichTextSettings(attributeDefinitionB)
  8059. });
  8060. valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, selectionA.offset, valueA.text.length);
  8061. valueB = (0,external_wp_richText_namespaceObject.remove)(valueB, 0, selectionB.offset);
  8062. dispatch.replaceBlocks(select.getSelectedBlockClientIds(), [{ // Preserve the original client ID.
  8063. ...blockA,
  8064. attributes: { ...blockA.attributes,
  8065. [selectionA.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  8066. value: valueA,
  8067. ...mapRichTextSettings(attributeDefinitionA)
  8068. })
  8069. }
  8070. }, (0,external_wp_blocks_namespaceObject.createBlock)((0,external_wp_blocks_namespaceObject.getDefaultBlockName)()), { // Preserve the original client ID.
  8071. ...blockB,
  8072. attributes: { ...blockB.attributes,
  8073. [selectionB.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  8074. value: valueB,
  8075. ...mapRichTextSettings(attributeDefinitionB)
  8076. })
  8077. }
  8078. }], 1, // If we don't pass the `indexToSelect` it will default to the last block.
  8079. select.getSelectedBlocksInitialCaretPosition());
  8080. };
  8081. /**
  8082. * Expand the selection to cover the entire blocks, removing partial selection.
  8083. */
  8084. const __unstableExpandSelection = () => _ref14 => {
  8085. let {
  8086. select,
  8087. dispatch
  8088. } = _ref14;
  8089. const selectionAnchor = select.getSelectionStart();
  8090. const selectionFocus = select.getSelectionEnd();
  8091. dispatch.selectionChange({
  8092. start: {
  8093. clientId: selectionAnchor.clientId
  8094. },
  8095. end: {
  8096. clientId: selectionFocus.clientId
  8097. }
  8098. });
  8099. };
  8100. /**
  8101. * Action that merges two blocks.
  8102. *
  8103. * @param {string} firstBlockClientId Client ID of the first block to merge.
  8104. * @param {string} secondBlockClientId Client ID of the second block to merge.
  8105. */
  8106. const mergeBlocks = (firstBlockClientId, secondBlockClientId) => _ref15 => {
  8107. let {
  8108. registry,
  8109. select,
  8110. dispatch
  8111. } = _ref15;
  8112. const blocks = [firstBlockClientId, secondBlockClientId];
  8113. dispatch({
  8114. type: 'MERGE_BLOCKS',
  8115. blocks
  8116. });
  8117. const [clientIdA, clientIdB] = blocks;
  8118. const blockA = select.getBlock(clientIdA);
  8119. const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name);
  8120. if (!blockAType) return;
  8121. const blockB = select.getBlock(clientIdB);
  8122. if (blockAType && !blockAType.merge) {
  8123. // If there's no merge function defined, attempt merging inner
  8124. // blocks.
  8125. const blocksWithTheSameType = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blockB, blockAType.name); // Only focus the previous block if it's not mergeable.
  8126. if ((blocksWithTheSameType === null || blocksWithTheSameType === void 0 ? void 0 : blocksWithTheSameType.length) !== 1) {
  8127. dispatch.selectBlock(blockA.clientId);
  8128. return;
  8129. }
  8130. const [blockWithSameType] = blocksWithTheSameType;
  8131. if (blockWithSameType.innerBlocks.length < 1) {
  8132. dispatch.selectBlock(blockA.clientId);
  8133. return;
  8134. }
  8135. registry.batch(() => {
  8136. dispatch.insertBlocks(blockWithSameType.innerBlocks, undefined, clientIdA);
  8137. dispatch.removeBlock(clientIdB);
  8138. dispatch.selectBlock(blockWithSameType.innerBlocks[0].clientId);
  8139. });
  8140. return;
  8141. }
  8142. const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name);
  8143. const {
  8144. clientId,
  8145. attributeKey,
  8146. offset
  8147. } = select.getSelectionStart();
  8148. const selectedBlockType = clientId === clientIdA ? blockAType : blockBType;
  8149. const attributeDefinition = selectedBlockType.attributes[attributeKey];
  8150. const canRestoreTextSelection = (clientId === clientIdA || clientId === clientIdB) && attributeKey !== undefined && offset !== undefined && // We cannot restore text selection if the RichText identifier
  8151. // is not a defined block attribute key. This can be the case if the
  8152. // fallback intance ID is used to store selection (and no RichText
  8153. // identifier is set), or when the identifier is wrong.
  8154. !!attributeDefinition;
  8155. if (!attributeDefinition) {
  8156. if (typeof attributeKey === 'number') {
  8157. window.console.error(`RichText needs an identifier prop that is the block attribute key of the attribute it controls. Its type is expected to be a string, but was ${typeof attributeKey}`);
  8158. } else {
  8159. window.console.error('The RichText identifier prop does not match any attributes defined by the block.');
  8160. }
  8161. } // Clone the blocks so we don't insert the character in a "live" block.
  8162. const cloneA = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockA);
  8163. const cloneB = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockB);
  8164. if (canRestoreTextSelection) {
  8165. const selectedBlock = clientId === clientIdA ? cloneA : cloneB;
  8166. const html = selectedBlock.attributes[attributeKey];
  8167. const value = (0,external_wp_richText_namespaceObject.insert)((0,external_wp_richText_namespaceObject.create)({
  8168. html,
  8169. ...mapRichTextSettings(attributeDefinition)
  8170. }), START_OF_SELECTED_AREA, offset, offset);
  8171. selectedBlock.attributes[attributeKey] = (0,external_wp_richText_namespaceObject.toHTMLString)({
  8172. value,
  8173. ...mapRichTextSettings(attributeDefinition)
  8174. });
  8175. } // We can only merge blocks with similar types
  8176. // thus, we transform the block to merge first.
  8177. const blocksWithTheSameType = blockA.name === blockB.name ? [cloneB] : (0,external_wp_blocks_namespaceObject.switchToBlockType)(cloneB, blockA.name); // If the block types can not match, do nothing.
  8178. if (!blocksWithTheSameType || !blocksWithTheSameType.length) {
  8179. return;
  8180. } // Calling the merge to update the attributes and remove the block to be merged.
  8181. const updatedAttributes = blockAType.merge(cloneA.attributes, blocksWithTheSameType[0].attributes);
  8182. if (canRestoreTextSelection) {
  8183. const newAttributeKey = retrieveSelectedAttribute(updatedAttributes);
  8184. const convertedHtml = updatedAttributes[newAttributeKey];
  8185. const convertedValue = (0,external_wp_richText_namespaceObject.create)({
  8186. html: convertedHtml,
  8187. ...mapRichTextSettings(blockAType.attributes[newAttributeKey])
  8188. });
  8189. const newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA);
  8190. const newValue = (0,external_wp_richText_namespaceObject.remove)(convertedValue, newOffset, newOffset + 1);
  8191. const newHtml = (0,external_wp_richText_namespaceObject.toHTMLString)({
  8192. value: newValue,
  8193. ...mapRichTextSettings(blockAType.attributes[newAttributeKey])
  8194. });
  8195. updatedAttributes[newAttributeKey] = newHtml;
  8196. dispatch.selectionChange(blockA.clientId, newAttributeKey, newOffset, newOffset);
  8197. }
  8198. dispatch.replaceBlocks([blockA.clientId, blockB.clientId], [{ ...blockA,
  8199. attributes: { ...blockA.attributes,
  8200. ...updatedAttributes
  8201. }
  8202. }, ...blocksWithTheSameType.slice(1)], 0 // If we don't pass the `indexToSelect` it will default to the last block.
  8203. );
  8204. };
  8205. /**
  8206. * Yields action objects used in signalling that the blocks corresponding to
  8207. * the set of specified client IDs are to be removed.
  8208. *
  8209. * @param {string|string[]} clientIds Client IDs of blocks to remove.
  8210. * @param {boolean} selectPrevious True if the previous block should be
  8211. * selected when a block is removed.
  8212. */
  8213. const removeBlocks = function (clientIds) {
  8214. let selectPrevious = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8215. return _ref16 => {
  8216. let {
  8217. select,
  8218. dispatch
  8219. } = _ref16;
  8220. if (!clientIds || !clientIds.length) {
  8221. return;
  8222. }
  8223. clientIds = castArray(clientIds);
  8224. const rootClientId = select.getBlockRootClientId(clientIds[0]);
  8225. const canRemoveBlocks = select.canRemoveBlocks(clientIds, rootClientId);
  8226. if (!canRemoveBlocks) {
  8227. return;
  8228. }
  8229. if (selectPrevious) {
  8230. dispatch.selectPreviousBlock(clientIds[0]);
  8231. }
  8232. dispatch({
  8233. type: 'REMOVE_BLOCKS',
  8234. clientIds
  8235. }); // To avoid a focus loss when removing the last block, assure there is
  8236. // always a default block if the last of the blocks have been removed.
  8237. dispatch(ensureDefaultBlock());
  8238. };
  8239. };
  8240. /**
  8241. * Returns an action object used in signalling that the block with the
  8242. * specified client ID is to be removed.
  8243. *
  8244. * @param {string} clientId Client ID of block to remove.
  8245. * @param {boolean} selectPrevious True if the previous block should be
  8246. * selected when a block is removed.
  8247. *
  8248. * @return {Object} Action object.
  8249. */
  8250. function removeBlock(clientId, selectPrevious) {
  8251. return removeBlocks([clientId], selectPrevious);
  8252. }
  8253. /* eslint-disable jsdoc/valid-types */
  8254. /**
  8255. * Returns an action object used in signalling that the inner blocks with the
  8256. * specified client ID should be replaced.
  8257. *
  8258. * @param {string} rootClientId Client ID of the block whose InnerBlocks will re replaced.
  8259. * @param {Object[]} blocks Block objects to insert as new InnerBlocks
  8260. * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to false.
  8261. * @param {0|-1|null} initialPosition Initial block position.
  8262. * @return {Object} Action object.
  8263. */
  8264. function replaceInnerBlocks(rootClientId, blocks) {
  8265. let updateSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8266. let initialPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  8267. /* eslint-enable jsdoc/valid-types */
  8268. return {
  8269. type: 'REPLACE_INNER_BLOCKS',
  8270. rootClientId,
  8271. blocks,
  8272. updateSelection,
  8273. initialPosition: updateSelection ? initialPosition : null,
  8274. time: Date.now()
  8275. };
  8276. }
  8277. /**
  8278. * Returns an action object used to toggle the block editing mode between
  8279. * visual and HTML modes.
  8280. *
  8281. * @param {string} clientId Block client ID.
  8282. *
  8283. * @return {Object} Action object.
  8284. */
  8285. function toggleBlockMode(clientId) {
  8286. return {
  8287. type: 'TOGGLE_BLOCK_MODE',
  8288. clientId
  8289. };
  8290. }
  8291. /**
  8292. * Returns an action object used in signalling that the user has begun to type.
  8293. *
  8294. * @return {Object} Action object.
  8295. */
  8296. function startTyping() {
  8297. return {
  8298. type: 'START_TYPING'
  8299. };
  8300. }
  8301. /**
  8302. * Returns an action object used in signalling that the user has stopped typing.
  8303. *
  8304. * @return {Object} Action object.
  8305. */
  8306. function stopTyping() {
  8307. return {
  8308. type: 'STOP_TYPING'
  8309. };
  8310. }
  8311. /**
  8312. * Returns an action object used in signalling that the user has begun to drag blocks.
  8313. *
  8314. * @param {string[]} clientIds An array of client ids being dragged
  8315. *
  8316. * @return {Object} Action object.
  8317. */
  8318. function startDraggingBlocks() {
  8319. let clientIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  8320. return {
  8321. type: 'START_DRAGGING_BLOCKS',
  8322. clientIds
  8323. };
  8324. }
  8325. /**
  8326. * Returns an action object used in signalling that the user has stopped dragging blocks.
  8327. *
  8328. * @return {Object} Action object.
  8329. */
  8330. function stopDraggingBlocks() {
  8331. return {
  8332. type: 'STOP_DRAGGING_BLOCKS'
  8333. };
  8334. }
  8335. /**
  8336. * Returns an action object used in signalling that the caret has entered formatted text.
  8337. *
  8338. * @deprecated
  8339. *
  8340. * @return {Object} Action object.
  8341. */
  8342. function enterFormattedText() {
  8343. external_wp_deprecated_default()('wp.data.dispatch( "core/block-editor" ).enterFormattedText', {
  8344. since: '6.1',
  8345. version: '6.3'
  8346. });
  8347. return {
  8348. type: 'DO_NOTHING'
  8349. };
  8350. }
  8351. /**
  8352. * Returns an action object used in signalling that the user caret has exited formatted text.
  8353. *
  8354. * @deprecated
  8355. *
  8356. * @return {Object} Action object.
  8357. */
  8358. function exitFormattedText() {
  8359. external_wp_deprecated_default()('wp.data.dispatch( "core/block-editor" ).exitFormattedText', {
  8360. since: '6.1',
  8361. version: '6.3'
  8362. });
  8363. return {
  8364. type: 'DO_NOTHING'
  8365. };
  8366. }
  8367. /**
  8368. * Action that changes the position of the user caret.
  8369. *
  8370. * @param {string|WPSelection} clientId The selected block client ID.
  8371. * @param {string} attributeKey The selected block attribute key.
  8372. * @param {number} startOffset The start offset.
  8373. * @param {number} endOffset The end offset.
  8374. *
  8375. * @return {Object} Action object.
  8376. */
  8377. function selectionChange(clientId, attributeKey, startOffset, endOffset) {
  8378. if (typeof clientId === 'string') {
  8379. return {
  8380. type: 'SELECTION_CHANGE',
  8381. clientId,
  8382. attributeKey,
  8383. startOffset,
  8384. endOffset
  8385. };
  8386. }
  8387. return {
  8388. type: 'SELECTION_CHANGE',
  8389. ...clientId
  8390. };
  8391. }
  8392. /**
  8393. * Action that adds a new block of the default type to the block list.
  8394. *
  8395. * @param {?Object} attributes Optional attributes of the block to assign.
  8396. * @param {?string} rootClientId Optional root client ID of block list on which
  8397. * to append.
  8398. * @param {?number} index Optional index where to insert the default block.
  8399. */
  8400. const insertDefaultBlock = (attributes, rootClientId, index) => _ref17 => {
  8401. let {
  8402. dispatch
  8403. } = _ref17;
  8404. // Abort if there is no default block type (if it has been unregistered).
  8405. const defaultBlockName = (0,external_wp_blocks_namespaceObject.getDefaultBlockName)();
  8406. if (!defaultBlockName) {
  8407. return;
  8408. }
  8409. const block = (0,external_wp_blocks_namespaceObject.createBlock)(defaultBlockName, attributes);
  8410. return dispatch.insertBlock(block, index, rootClientId);
  8411. };
  8412. /**
  8413. * Action that changes the nested settings of a given block.
  8414. *
  8415. * @param {string} clientId Client ID of the block whose nested setting are
  8416. * being received.
  8417. * @param {Object} settings Object with the new settings for the nested block.
  8418. *
  8419. * @return {Object} Action object
  8420. */
  8421. function updateBlockListSettings(clientId, settings) {
  8422. return {
  8423. type: 'UPDATE_BLOCK_LIST_SETTINGS',
  8424. clientId,
  8425. settings
  8426. };
  8427. }
  8428. /**
  8429. * Action that updates the block editor settings.
  8430. *
  8431. * @param {Object} settings Updated settings
  8432. *
  8433. * @return {Object} Action object
  8434. */
  8435. function updateSettings(settings) {
  8436. return {
  8437. type: 'UPDATE_SETTINGS',
  8438. settings
  8439. };
  8440. }
  8441. /**
  8442. * Action that signals that a temporary reusable block has been saved
  8443. * in order to switch its temporary id with the real id.
  8444. *
  8445. * @param {string} id Reusable block's id.
  8446. * @param {string} updatedId Updated block's id.
  8447. *
  8448. * @return {Object} Action object.
  8449. */
  8450. function __unstableSaveReusableBlock(id, updatedId) {
  8451. return {
  8452. type: 'SAVE_REUSABLE_BLOCK_SUCCESS',
  8453. id,
  8454. updatedId
  8455. };
  8456. }
  8457. /**
  8458. * Action that marks the last block change explicitly as persistent.
  8459. *
  8460. * @return {Object} Action object.
  8461. */
  8462. function __unstableMarkLastChangeAsPersistent() {
  8463. return {
  8464. type: 'MARK_LAST_CHANGE_AS_PERSISTENT'
  8465. };
  8466. }
  8467. /**
  8468. * Action that signals that the next block change should be marked explicitly as not persistent.
  8469. *
  8470. * @return {Object} Action object.
  8471. */
  8472. function __unstableMarkNextChangeAsNotPersistent() {
  8473. return {
  8474. type: 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT'
  8475. };
  8476. }
  8477. /**
  8478. * Action that marks the last block change as an automatic change, meaning it was not
  8479. * performed by the user, and can be undone using the `Escape` and `Backspace` keys.
  8480. * This action must be called after the change was made, and any actions that are a
  8481. * consequence of it, so it is recommended to be called at the next idle period to ensure all
  8482. * selection changes have been recorded.
  8483. */
  8484. const __unstableMarkAutomaticChange = () => _ref18 => {
  8485. let {
  8486. dispatch
  8487. } = _ref18;
  8488. dispatch({
  8489. type: 'MARK_AUTOMATIC_CHANGE'
  8490. });
  8491. const {
  8492. requestIdleCallback = cb => setTimeout(cb, 100)
  8493. } = window;
  8494. requestIdleCallback(() => {
  8495. dispatch({
  8496. type: 'MARK_AUTOMATIC_CHANGE_FINAL'
  8497. });
  8498. });
  8499. };
  8500. /**
  8501. * Action that enables or disables the navigation mode.
  8502. *
  8503. * @param {boolean} isNavigationMode Enable/Disable navigation mode.
  8504. */
  8505. const setNavigationMode = function () {
  8506. let isNavigationMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  8507. return _ref19 => {
  8508. let {
  8509. dispatch
  8510. } = _ref19;
  8511. dispatch.__unstableSetEditorMode(isNavigationMode ? 'navigation' : 'edit');
  8512. };
  8513. };
  8514. /**
  8515. * Action that sets the editor mode
  8516. *
  8517. * @param {string} mode Editor mode
  8518. */
  8519. const __unstableSetEditorMode = mode => _ref20 => {
  8520. let {
  8521. dispatch,
  8522. select
  8523. } = _ref20;
  8524. // When switching to zoom-out mode, we need to select the root block
  8525. if (mode === 'zoom-out') {
  8526. const firstSelectedClientId = select.getBlockSelectionStart();
  8527. if (firstSelectedClientId) {
  8528. dispatch.selectBlock(select.getBlockHierarchyRootClientId(firstSelectedClientId));
  8529. }
  8530. }
  8531. dispatch({
  8532. type: 'SET_EDITOR_MODE',
  8533. mode
  8534. });
  8535. if (mode === 'navigation') {
  8536. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('You are currently in navigation mode. Navigate blocks using the Tab key and Arrow keys. Use Left and Right Arrow keys to move between nesting levels. To exit navigation mode and edit the selected block, press Enter.'));
  8537. } else if (mode === 'edit') {
  8538. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('You are currently in edit mode. To return to the navigation mode, press Escape.'));
  8539. } else if (mode === 'zoom-out') {
  8540. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('You are currently in zoom-out mode.'));
  8541. }
  8542. };
  8543. /**
  8544. * Action that enables or disables the block moving mode.
  8545. *
  8546. * @param {string|null} hasBlockMovingClientId Enable/Disable block moving mode.
  8547. */
  8548. const setBlockMovingClientId = function () {
  8549. let hasBlockMovingClientId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  8550. return _ref21 => {
  8551. let {
  8552. dispatch
  8553. } = _ref21;
  8554. dispatch({
  8555. type: 'SET_BLOCK_MOVING_MODE',
  8556. hasBlockMovingClientId
  8557. });
  8558. if (hasBlockMovingClientId) {
  8559. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Use the Tab key and Arrow keys to choose new block location. Use Left and Right Arrow keys to move between nesting levels. Once location is selected press Enter or Space to move the block.'));
  8560. }
  8561. };
  8562. };
  8563. /**
  8564. * Action that duplicates a list of blocks.
  8565. *
  8566. * @param {string[]} clientIds
  8567. * @param {boolean} updateSelection
  8568. */
  8569. const duplicateBlocks = function (clientIds) {
  8570. let updateSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8571. return _ref22 => {
  8572. let {
  8573. select,
  8574. dispatch
  8575. } = _ref22;
  8576. if (!clientIds || !clientIds.length) {
  8577. return;
  8578. } // Return early if blocks don't exist.
  8579. const blocks = select.getBlocksByClientId(clientIds);
  8580. if (blocks.some(block => !block)) {
  8581. return;
  8582. } // Return early if blocks don't support multiple usage.
  8583. const blockNames = blocks.map(block => block.name);
  8584. if (blockNames.some(blockName => !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'multiple', true))) {
  8585. return;
  8586. }
  8587. const rootClientId = select.getBlockRootClientId(clientIds[0]);
  8588. const clientIdsArray = castArray(clientIds);
  8589. const lastSelectedIndex = select.getBlockIndex(clientIdsArray[clientIdsArray.length - 1]);
  8590. const clonedBlocks = blocks.map(block => (0,external_wp_blocks_namespaceObject.__experimentalCloneSanitizedBlock)(block));
  8591. dispatch.insertBlocks(clonedBlocks, lastSelectedIndex + 1, rootClientId, updateSelection);
  8592. if (clonedBlocks.length > 1 && updateSelection) {
  8593. dispatch.multiSelect(clonedBlocks[0].clientId, clonedBlocks[clonedBlocks.length - 1].clientId);
  8594. }
  8595. return clonedBlocks.map(block => block.clientId);
  8596. };
  8597. };
  8598. /**
  8599. * Action that inserts an empty block before a given block.
  8600. *
  8601. * @param {string} clientId
  8602. */
  8603. const insertBeforeBlock = clientId => _ref23 => {
  8604. let {
  8605. select,
  8606. dispatch
  8607. } = _ref23;
  8608. if (!clientId) {
  8609. return;
  8610. }
  8611. const rootClientId = select.getBlockRootClientId(clientId);
  8612. const isLocked = select.getTemplateLock(rootClientId);
  8613. if (isLocked) {
  8614. return;
  8615. }
  8616. const firstSelectedIndex = select.getBlockIndex(clientId);
  8617. return dispatch.insertDefaultBlock({}, rootClientId, firstSelectedIndex);
  8618. };
  8619. /**
  8620. * Action that inserts an empty block after a given block.
  8621. *
  8622. * @param {string} clientId
  8623. */
  8624. const insertAfterBlock = clientId => _ref24 => {
  8625. let {
  8626. select,
  8627. dispatch
  8628. } = _ref24;
  8629. if (!clientId) {
  8630. return;
  8631. }
  8632. const rootClientId = select.getBlockRootClientId(clientId);
  8633. const isLocked = select.getTemplateLock(rootClientId);
  8634. if (isLocked) {
  8635. return;
  8636. }
  8637. const firstSelectedIndex = select.getBlockIndex(clientId);
  8638. return dispatch.insertDefaultBlock({}, rootClientId, firstSelectedIndex + 1);
  8639. };
  8640. /**
  8641. * Action that toggles the highlighted block state.
  8642. *
  8643. * @param {string} clientId The block's clientId.
  8644. * @param {boolean} isHighlighted The highlight state.
  8645. */
  8646. function toggleBlockHighlight(clientId, isHighlighted) {
  8647. return {
  8648. type: 'TOGGLE_BLOCK_HIGHLIGHT',
  8649. clientId,
  8650. isHighlighted
  8651. };
  8652. }
  8653. /**
  8654. * Action that "flashes" the block with a given `clientId` by rhythmically highlighting it.
  8655. *
  8656. * @param {string} clientId Target block client ID.
  8657. */
  8658. const flashBlock = clientId => async _ref25 => {
  8659. let {
  8660. dispatch
  8661. } = _ref25;
  8662. dispatch(toggleBlockHighlight(clientId, true));
  8663. await new Promise(resolve => setTimeout(resolve, 150));
  8664. dispatch(toggleBlockHighlight(clientId, false));
  8665. };
  8666. /**
  8667. * Action that sets whether a block has controlled inner blocks.
  8668. *
  8669. * @param {string} clientId The block's clientId.
  8670. * @param {boolean} hasControlledInnerBlocks True if the block's inner blocks are controlled.
  8671. */
  8672. function setHasControlledInnerBlocks(clientId, hasControlledInnerBlocks) {
  8673. return {
  8674. type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
  8675. hasControlledInnerBlocks,
  8676. clientId
  8677. };
  8678. }
  8679. /**
  8680. * Action that sets whether given blocks are visible on the canvas.
  8681. *
  8682. * @param {Record<string,boolean>} updates For each block's clientId, its new visibility setting.
  8683. */
  8684. function setBlockVisibility(updates) {
  8685. return {
  8686. type: 'SET_BLOCK_VISIBILITY',
  8687. updates
  8688. };
  8689. }
  8690. /**
  8691. * Action that sets whether a block is being temporaritly edited as blocks.
  8692. *
  8693. * @param {?string} temporarilyEditingAsBlocks The block's clientId being temporaritly edited as blocks.
  8694. */
  8695. function __unstableSetTemporarilyEditingAsBlocks(temporarilyEditingAsBlocks) {
  8696. return {
  8697. type: 'SET_TEMPORARILY_EDITING_AS_BLOCKS',
  8698. temporarilyEditingAsBlocks
  8699. };
  8700. }
  8701. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/constants.js
  8702. const STORE_NAME = 'core/block-editor';
  8703. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/index.js
  8704. /**
  8705. * WordPress dependencies
  8706. */
  8707. /**
  8708. * Internal dependencies
  8709. */
  8710. /**
  8711. * Block editor data store configuration.
  8712. *
  8713. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
  8714. */
  8715. const storeConfig = {
  8716. reducer: reducer,
  8717. selectors: selectors_namespaceObject,
  8718. actions: actions_namespaceObject
  8719. };
  8720. /**
  8721. * Store definition for the block editor namespace.
  8722. *
  8723. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  8724. */
  8725. const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { ...storeConfig,
  8726. persist: ['preferences']
  8727. }); // Ideally we'd use register instead of register stores.
  8728. (0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, { ...storeConfig,
  8729. persist: ['preferences']
  8730. });
  8731. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/context.js
  8732. /**
  8733. * WordPress dependencies
  8734. */
  8735. const DEFAULT_BLOCK_EDIT_CONTEXT = {
  8736. name: '',
  8737. isSelected: false
  8738. };
  8739. const Context = (0,external_wp_element_namespaceObject.createContext)(DEFAULT_BLOCK_EDIT_CONTEXT);
  8740. const {
  8741. Provider
  8742. } = Context;
  8743. /**
  8744. * A hook that returns the block edit context.
  8745. *
  8746. * @return {Object} Block edit context
  8747. */
  8748. function useBlockEditContext() {
  8749. return (0,external_wp_element_namespaceObject.useContext)(Context);
  8750. }
  8751. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-display-block-controls/index.js
  8752. /**
  8753. * WordPress dependencies
  8754. */
  8755. /**
  8756. * Internal dependencies
  8757. */
  8758. function useDisplayBlockControls() {
  8759. const {
  8760. isSelected,
  8761. clientId,
  8762. name
  8763. } = useBlockEditContext();
  8764. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  8765. if (isSelected) {
  8766. return true;
  8767. }
  8768. const {
  8769. getBlockName,
  8770. isFirstMultiSelectedBlock,
  8771. getMultiSelectedBlockClientIds
  8772. } = select(store);
  8773. if (isFirstMultiSelectedBlock(clientId)) {
  8774. return getMultiSelectedBlockClientIds().every(id => getBlockName(id) === name);
  8775. }
  8776. return false;
  8777. }, [clientId, isSelected, name]);
  8778. }
  8779. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/hook.js
  8780. /**
  8781. * WordPress dependencies
  8782. */
  8783. /**
  8784. * Internal dependencies
  8785. */
  8786. function useBlockControlsFill(group, shareWithChildBlocks) {
  8787. const isDisplayed = useDisplayBlockControls();
  8788. const {
  8789. clientId
  8790. } = useBlockEditContext();
  8791. const isParentDisplayed = (0,external_wp_data_namespaceObject.useSelect)(select => {
  8792. const {
  8793. getBlockName,
  8794. hasSelectedInnerBlock
  8795. } = select(store);
  8796. const {
  8797. hasBlockSupport
  8798. } = select(external_wp_blocks_namespaceObject.store);
  8799. return shareWithChildBlocks && hasBlockSupport(getBlockName(clientId), '__experimentalExposeControlsToChildren', false) && hasSelectedInnerBlock(clientId);
  8800. }, [shareWithChildBlocks, clientId]);
  8801. if (isDisplayed) {
  8802. var _groups$group;
  8803. return (_groups$group = block_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill;
  8804. }
  8805. if (isParentDisplayed) {
  8806. return block_controls_groups.parent.Fill;
  8807. }
  8808. return null;
  8809. }
  8810. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/fill.js
  8811. /**
  8812. * External dependencies
  8813. */
  8814. /**
  8815. * WordPress dependencies
  8816. */
  8817. /**
  8818. * Internal dependencies
  8819. */
  8820. function BlockControlsFill(_ref) {
  8821. let {
  8822. group = 'default',
  8823. controls,
  8824. children,
  8825. __experimentalShareWithChildBlocks = false
  8826. } = _ref;
  8827. const Fill = useBlockControlsFill(group, __experimentalShareWithChildBlocks);
  8828. if (!Fill) {
  8829. return null;
  8830. }
  8831. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
  8832. document: document
  8833. }, (0,external_wp_element_namespaceObject.createElement)(Fill, null, fillProps => {
  8834. // Children passed to BlockControlsFill will not have access to any
  8835. // React Context whose Provider is part of the BlockControlsSlot tree.
  8836. // So we re-create the Provider in this subtree.
  8837. const value = !(0,external_lodash_namespaceObject.isEmpty)(fillProps) ? fillProps : null;
  8838. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolbarContext.Provider, {
  8839. value: value
  8840. }, group === 'default' && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
  8841. controls: controls
  8842. }), children);
  8843. }));
  8844. }
  8845. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/slot.js
  8846. /**
  8847. * WordPress dependencies
  8848. */
  8849. /**
  8850. * Internal dependencies
  8851. */
  8852. function BlockControlsSlot(_ref) {
  8853. let {
  8854. group = 'default',
  8855. ...props
  8856. } = _ref;
  8857. const accessibleToolbarState = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.__experimentalToolbarContext);
  8858. const Slot = block_controls_groups[group].Slot;
  8859. const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(Slot.__unstableName);
  8860. const hasFills = Boolean(slot.fills && slot.fills.length);
  8861. if (!hasFills) {
  8862. return null;
  8863. }
  8864. if (group === 'default') {
  8865. return (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, {
  8866. bubblesVirtually: true,
  8867. fillProps: accessibleToolbarState
  8868. }));
  8869. }
  8870. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, {
  8871. bubblesVirtually: true,
  8872. fillProps: accessibleToolbarState
  8873. })));
  8874. }
  8875. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/index.js
  8876. /**
  8877. * Internal dependencies
  8878. */
  8879. const BlockControls = BlockControlsFill;
  8880. BlockControls.Slot = BlockControlsSlot; // This is just here for backward compatibility.
  8881. const BlockFormatControls = props => {
  8882. return (0,external_wp_element_namespaceObject.createElement)(BlockControlsFill, _extends({
  8883. group: "inline"
  8884. }, props));
  8885. };
  8886. BlockFormatControls.Slot = props => {
  8887. return (0,external_wp_element_namespaceObject.createElement)(BlockControlsSlot, _extends({
  8888. group: "inline"
  8889. }, props));
  8890. };
  8891. /* harmony default export */ var block_controls = (BlockControls);
  8892. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-left.js
  8893. /**
  8894. * WordPress dependencies
  8895. */
  8896. const justifyLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8897. xmlns: "http://www.w3.org/2000/svg",
  8898. viewBox: "0 0 24 24"
  8899. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8900. d: "M9 9v6h11V9H9zM4 20h1.5V4H4v16z"
  8901. }));
  8902. /* harmony default export */ var justify_left = (justifyLeft);
  8903. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-center.js
  8904. /**
  8905. * WordPress dependencies
  8906. */
  8907. const justifyCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8908. xmlns: "http://www.w3.org/2000/svg",
  8909. viewBox: "0 0 24 24"
  8910. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8911. d: "M20 9h-7.2V4h-1.6v5H4v6h7.2v5h1.6v-5H20z"
  8912. }));
  8913. /* harmony default export */ var justify_center = (justifyCenter);
  8914. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-right.js
  8915. /**
  8916. * WordPress dependencies
  8917. */
  8918. const justifyRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8919. xmlns: "http://www.w3.org/2000/svg",
  8920. viewBox: "0 0 24 24"
  8921. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8922. d: "M4 15h11V9H4v6zM18.5 4v16H20V4h-1.5z"
  8923. }));
  8924. /* harmony default export */ var justify_right = (justifyRight);
  8925. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-space-between.js
  8926. /**
  8927. * WordPress dependencies
  8928. */
  8929. const justifySpaceBetween = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8930. xmlns: "http://www.w3.org/2000/svg",
  8931. viewBox: "0 0 24 24"
  8932. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8933. d: "M9 15h6V9H9v6zm-5 5h1.5V4H4v16zM18.5 4v16H20V4h-1.5z"
  8934. }));
  8935. /* harmony default export */ var justify_space_between = (justifySpaceBetween);
  8936. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-right.js
  8937. /**
  8938. * WordPress dependencies
  8939. */
  8940. const arrowRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8941. xmlns: "http://www.w3.org/2000/svg",
  8942. viewBox: "0 0 24 24"
  8943. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8944. d: "M14.3 6.7l-1.1 1.1 4 4H4v1.5h13.3l-4.1 4.4 1.1 1.1 5.8-6.3z"
  8945. }));
  8946. /* harmony default export */ var arrow_right = (arrowRight);
  8947. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-down.js
  8948. /**
  8949. * WordPress dependencies
  8950. */
  8951. const arrowDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8952. xmlns: "http://www.w3.org/2000/svg",
  8953. viewBox: "0 0 24 24"
  8954. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8955. d: "M16.2 13.2l-4 4V4h-1.5v13.3l-4.5-4.1-1 1.1 6.2 5.8 5.8-5.8-1-1.1z"
  8956. }));
  8957. /* harmony default export */ var arrow_down = (arrowDown);
  8958. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/utils.js
  8959. /**
  8960. * WordPress dependencies
  8961. */
  8962. /**
  8963. * Utility to generate the proper CSS selector for layout styles.
  8964. *
  8965. * @param {string} selectors CSS selector, also supports multiple comma-separated selectors.
  8966. * @param {string} append The string to append.
  8967. *
  8968. * @return {string} - CSS selector.
  8969. */
  8970. function appendSelectors(selectors) {
  8971. let append = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  8972. // Ideally we shouldn't need the `.editor-styles-wrapper` increased specificity here
  8973. // The problem though is that we have a `.editor-styles-wrapper p { margin: reset; }` style
  8974. // it's used to reset the default margin added by wp-admin to paragraphs
  8975. // so we need this to be higher speficity otherwise, it won't be applied to paragraphs inside containers
  8976. // When the post editor is fully iframed, this extra classname could be removed.
  8977. return selectors.split(',').map(subselector => `.editor-styles-wrapper ${subselector}${append ? ` ${append}` : ''}`).join(',');
  8978. }
  8979. /**
  8980. * Get generated blockGap CSS rules based on layout definitions provided in theme.json
  8981. * Falsy values in the layout definition's spacingStyles rules will be swapped out
  8982. * with the provided `blockGapValue`.
  8983. *
  8984. * @param {string} selector The CSS selector to target for the generated rules.
  8985. * @param {Object} layoutDefinitions Layout definitions object from theme.json.
  8986. * @param {string} layoutType The layout type (e.g. `default` or `flex`).
  8987. * @param {string} blockGapValue The current blockGap value to be applied.
  8988. * @return {string} The generated CSS rules.
  8989. */
  8990. function getBlockGapCSS(selector, layoutDefinitions, layoutType, blockGapValue) {
  8991. var _layoutDefinitions$la, _layoutDefinitions$la2;
  8992. let output = '';
  8993. if (layoutDefinitions !== null && layoutDefinitions !== void 0 && (_layoutDefinitions$la = layoutDefinitions[layoutType]) !== null && _layoutDefinitions$la !== void 0 && (_layoutDefinitions$la2 = _layoutDefinitions$la.spacingStyles) !== null && _layoutDefinitions$la2 !== void 0 && _layoutDefinitions$la2.length && blockGapValue) {
  8994. layoutDefinitions[layoutType].spacingStyles.forEach(gapStyle => {
  8995. output += `${appendSelectors(selector, gapStyle.selector.trim())} { `;
  8996. output += Object.entries(gapStyle.rules).map(_ref => {
  8997. let [cssProperty, value] = _ref;
  8998. return `${cssProperty}: ${value ? value : blockGapValue}`;
  8999. }).join('; ');
  9000. output += '; }';
  9001. });
  9002. }
  9003. return output;
  9004. }
  9005. /**
  9006. * Helper method to assign contextual info to clarify
  9007. * alignment settings.
  9008. *
  9009. * Besides checking if `contentSize` and `wideSize` have a
  9010. * value, we now show this information only if their values
  9011. * are not a `css var`. This needs to change when parsing
  9012. * css variables land.
  9013. *
  9014. * @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752
  9015. *
  9016. * @param {Object} layout The layout object.
  9017. * @return {Object} An object with contextual info per alignment.
  9018. */
  9019. function getAlignmentsInfo(layout) {
  9020. const {
  9021. contentSize,
  9022. wideSize
  9023. } = layout;
  9024. const alignmentInfo = {};
  9025. const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%)?$/i;
  9026. if (sizeRegex.test(contentSize)) {
  9027. // translators: %s: container size (i.e. 600px etc)
  9028. alignmentInfo.none = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Max %s wide'), contentSize);
  9029. }
  9030. if (sizeRegex.test(wideSize)) {
  9031. // translators: %s: container size (i.e. 600px etc)
  9032. alignmentInfo.wide = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Max %s wide'), wideSize);
  9033. }
  9034. return alignmentInfo;
  9035. }
  9036. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/block-refs-provider.js
  9037. /**
  9038. * WordPress dependencies
  9039. */
  9040. const BlockRefs = (0,external_wp_element_namespaceObject.createContext)({
  9041. refs: new Map(),
  9042. callbacks: new Map()
  9043. });
  9044. function BlockRefsProvider(_ref) {
  9045. let {
  9046. children
  9047. } = _ref;
  9048. const value = (0,external_wp_element_namespaceObject.useMemo)(() => ({
  9049. refs: new Map(),
  9050. callbacks: new Map()
  9051. }), []);
  9052. return (0,external_wp_element_namespaceObject.createElement)(BlockRefs.Provider, {
  9053. value: value
  9054. }, children);
  9055. }
  9056. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-refs.js
  9057. /**
  9058. * WordPress dependencies
  9059. */
  9060. /**
  9061. * Internal dependencies
  9062. */
  9063. /** @typedef {import('@wordpress/element').RefCallback} RefCallback */
  9064. /** @typedef {import('@wordpress/element').RefObject} RefObject */
  9065. /**
  9066. * Provides a ref to the BlockRefs context.
  9067. *
  9068. * @param {string} clientId The client ID of the element ref.
  9069. *
  9070. * @return {RefCallback} Ref callback.
  9071. */
  9072. function useBlockRefProvider(clientId) {
  9073. const {
  9074. refs,
  9075. callbacks
  9076. } = (0,external_wp_element_namespaceObject.useContext)(BlockRefs);
  9077. const ref = (0,external_wp_element_namespaceObject.useRef)();
  9078. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  9079. refs.set(ref, clientId);
  9080. return () => {
  9081. refs.delete(ref);
  9082. };
  9083. }, [clientId]);
  9084. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  9085. // Update the ref in the provider.
  9086. ref.current = element; // Call any update functions.
  9087. callbacks.forEach((id, setElement) => {
  9088. if (clientId === id) {
  9089. setElement(element);
  9090. }
  9091. });
  9092. }, [clientId]);
  9093. }
  9094. /**
  9095. * Gets a ref pointing to the current block element. Continues to return a
  9096. * stable ref even if the block client ID changes.
  9097. *
  9098. * @param {string} clientId The client ID to get a ref for.
  9099. *
  9100. * @return {RefObject} A ref containing the element.
  9101. */
  9102. function useBlockRef(clientId) {
  9103. const {
  9104. refs
  9105. } = (0,external_wp_element_namespaceObject.useContext)(BlockRefs);
  9106. const freshClientId = (0,external_wp_element_namespaceObject.useRef)();
  9107. freshClientId.current = clientId; // Always return an object, even if no ref exists for a given client ID, so
  9108. // that `current` works at a later point.
  9109. return (0,external_wp_element_namespaceObject.useMemo)(() => ({
  9110. get current() {
  9111. let element = null; // Multiple refs may be created for a single block. Find the
  9112. // first that has an element set.
  9113. for (const [ref, id] of refs.entries()) {
  9114. if (id === freshClientId.current && ref.current) {
  9115. element = ref.current;
  9116. }
  9117. }
  9118. return element;
  9119. }
  9120. }), []);
  9121. }
  9122. /**
  9123. * Return the element for a given client ID. Updates whenever the element
  9124. * changes, becomes available, or disappears.
  9125. *
  9126. * @param {string} clientId The client ID to an element for.
  9127. *
  9128. * @return {Element|null} The block's wrapper element.
  9129. */
  9130. function useBlockElement(clientId) {
  9131. const {
  9132. callbacks
  9133. } = (0,external_wp_element_namespaceObject.useContext)(BlockRefs);
  9134. const ref = useBlockRef(clientId);
  9135. const [element, setElement] = (0,external_wp_element_namespaceObject.useState)(null);
  9136. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  9137. if (!clientId) {
  9138. return;
  9139. }
  9140. callbacks.set(setElement, clientId);
  9141. return () => {
  9142. callbacks.delete(setElement);
  9143. };
  9144. }, [clientId]);
  9145. return ref.current || element;
  9146. }
  9147. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/spacing-sizes-control/utils.js
  9148. /**
  9149. * External dependencies
  9150. */
  9151. /**
  9152. * WordPress dependencies
  9153. */
  9154. /**
  9155. * Checks is given value is a spacing preset.
  9156. *
  9157. * @param {string} value Value to check
  9158. *
  9159. * @return {boolean} Return true if value is string in format var:preset|spacing|.
  9160. */
  9161. function isValueSpacingPreset(value) {
  9162. if (!(value !== null && value !== void 0 && value.includes)) {
  9163. return false;
  9164. }
  9165. return value === '0' || value.includes('var:preset|spacing|');
  9166. }
  9167. /**
  9168. * Converts a spacing preset into a custom value.
  9169. *
  9170. * @param {string} value Value to convert
  9171. * @param {Array} spacingSizes Array of the current spacing preset objects
  9172. *
  9173. * @return {string} Mapping of the spacing preset to its equivalent custom value.
  9174. */
  9175. function getCustomValueFromPreset(value, spacingSizes) {
  9176. if (!isValueSpacingPreset(value)) {
  9177. return value;
  9178. }
  9179. const slug = getSpacingPresetSlug(value);
  9180. const spacingSize = spacingSizes.find(size => String(size.slug) === slug);
  9181. return spacingSize === null || spacingSize === void 0 ? void 0 : spacingSize.size;
  9182. }
  9183. /**
  9184. * Converts a custom value to preset value if one can be found.
  9185. *
  9186. * Returns value as-is if no match is found.
  9187. *
  9188. * @param {string} value Value to convert
  9189. * @param {Array} spacingSizes Array of the current spacing preset objects
  9190. *
  9191. * @return {string} The preset value if it can be found.
  9192. */
  9193. function getPresetValueFromCustomValue(value, spacingSizes) {
  9194. // Return value as-is if it is already a preset;
  9195. if (isValueSpacingPreset(value)) {
  9196. return value;
  9197. }
  9198. const spacingMatch = spacingSizes.find(size => String(size.size) === String(value));
  9199. if (spacingMatch !== null && spacingMatch !== void 0 && spacingMatch.slug) {
  9200. return `var:preset|spacing|${spacingMatch.slug}`;
  9201. }
  9202. return value;
  9203. }
  9204. /**
  9205. * Converts a spacing preset into a custom value.
  9206. *
  9207. * @param {string} value Value to convert.
  9208. *
  9209. * @return {string} CSS var string for given spacing preset value.
  9210. */
  9211. function getSpacingPresetCssVar(value) {
  9212. if (!value) {
  9213. return;
  9214. }
  9215. const slug = value.match(/var:preset\|spacing\|(.+)/);
  9216. if (!slug) {
  9217. return value;
  9218. }
  9219. return `var(--wp--preset--spacing--${slug[1]})`;
  9220. }
  9221. /**
  9222. * Returns the slug section of the given spacing preset string.
  9223. *
  9224. * @param {string} value Value to extract slug from.
  9225. *
  9226. * @return {number} The int value of the slug from given spacing preset.
  9227. */
  9228. function getSpacingPresetSlug(value) {
  9229. if (!value) {
  9230. return;
  9231. }
  9232. if (value === '0' || value === 'default') {
  9233. return value;
  9234. }
  9235. const slug = value.match(/var:preset\|spacing\|(.+)/);
  9236. return slug ? slug[1] : undefined;
  9237. }
  9238. /**
  9239. * Converts spacing preset value into a Range component value .
  9240. *
  9241. * @param {string} presetValue Value to convert to Range value.
  9242. * @param {Array} spacingSizes Array of current spacing preset value objects.
  9243. *
  9244. * @return {number} The int value for use in Range control.
  9245. */
  9246. function getSliderValueFromPreset(presetValue, spacingSizes) {
  9247. if (presetValue === undefined) {
  9248. return 0;
  9249. }
  9250. const slug = parseFloat(presetValue, 10) === 0 ? '0' : getSpacingPresetSlug(presetValue);
  9251. const sliderValue = spacingSizes.findIndex(spacingSize => {
  9252. return String(spacingSize.slug) === slug;
  9253. }); // Returning NaN rather than undefined as undefined makes range control thumb sit in center
  9254. return sliderValue !== -1 ? sliderValue : NaN;
  9255. }
  9256. const LABELS = {
  9257. all: (0,external_wp_i18n_namespaceObject.__)('All sides'),
  9258. top: (0,external_wp_i18n_namespaceObject.__)('Top'),
  9259. bottom: (0,external_wp_i18n_namespaceObject.__)('Bottom'),
  9260. left: (0,external_wp_i18n_namespaceObject.__)('Left'),
  9261. right: (0,external_wp_i18n_namespaceObject.__)('Right'),
  9262. mixed: (0,external_wp_i18n_namespaceObject.__)('Mixed'),
  9263. vertical: (0,external_wp_i18n_namespaceObject.__)('Vertical'),
  9264. horizontal: (0,external_wp_i18n_namespaceObject.__)('Horizontal')
  9265. };
  9266. const DEFAULT_VALUES = {
  9267. top: undefined,
  9268. right: undefined,
  9269. bottom: undefined,
  9270. left: undefined
  9271. };
  9272. const ALL_SIDES = ['top', 'right', 'bottom', 'left'];
  9273. /**
  9274. * Gets an items with the most occurrence within an array
  9275. * https://stackoverflow.com/a/20762713
  9276. *
  9277. * @param {Array<any>} arr Array of items to check.
  9278. * @return {any} The item with the most occurrences.
  9279. */
  9280. function mode(arr) {
  9281. return arr.sort((a, b) => arr.filter(v => v === a).length - arr.filter(v => v === b).length).pop();
  9282. }
  9283. /**
  9284. * Gets the 'all' input value from values data.
  9285. *
  9286. * @param {Object} values Box spacing values
  9287. *
  9288. * @return {string} The most common value from all sides of box.
  9289. */
  9290. function getAllRawValue() {
  9291. let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9292. return mode(Object.values(values));
  9293. }
  9294. /**
  9295. * Checks to determine if values are mixed.
  9296. *
  9297. * @param {Object} values Box values.
  9298. * @param {Array} sides Sides that values relate to.
  9299. *
  9300. * @return {boolean} Whether values are mixed.
  9301. */
  9302. function isValuesMixed() {
  9303. let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9304. let sides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ALL_SIDES;
  9305. return Object.values(values).length >= 1 && Object.values(values).length < sides.length || new Set(Object.values(values)).size > 1;
  9306. }
  9307. /**
  9308. * Checks to determine if values are defined.
  9309. *
  9310. * @param {Object} values Box values.
  9311. *
  9312. * @return {boolean} Whether values are defined.
  9313. */
  9314. function isValuesDefined(values) {
  9315. if (values === undefined || values === null) {
  9316. return false;
  9317. }
  9318. return !(0,external_lodash_namespaceObject.isEmpty)(Object.values(values).filter(value => !!value));
  9319. }
  9320. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/settings.js
  9321. /**
  9322. * WordPress dependencies
  9323. */
  9324. const settings_settings = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  9325. xmlns: "http://www.w3.org/2000/svg",
  9326. viewBox: "0 0 24 24"
  9327. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  9328. d: "M14.5 13.8c-1.1 0-2.1.7-2.4 1.8H4V17h8.1c.3 1 1.3 1.8 2.4 1.8s2.1-.7 2.4-1.8H20v-1.5h-3.1c-.3-1-1.3-1.7-2.4-1.7zM11.9 7c-.3-1-1.3-1.8-2.4-1.8S7.4 6 7.1 7H4v1.5h3.1c.3 1 1.3 1.8 2.4 1.8s2.1-.7 2.4-1.8H20V7h-8.1z"
  9329. }));
  9330. /* harmony default export */ var library_settings = (settings_settings);
  9331. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-setting/index.js
  9332. /**
  9333. * External dependencies
  9334. */
  9335. /**
  9336. * WordPress dependencies
  9337. */
  9338. /**
  9339. * Internal dependencies
  9340. */
  9341. const blockedPaths = ['color', 'border', 'typography', 'spacing'];
  9342. const deprecatedFlags = {
  9343. 'color.palette': settings => settings.colors === undefined ? undefined : settings.colors,
  9344. 'color.gradients': settings => settings.gradients === undefined ? undefined : settings.gradients,
  9345. 'color.custom': settings => settings.disableCustomColors === undefined ? undefined : !settings.disableCustomColors,
  9346. 'color.customGradient': settings => settings.disableCustomGradients === undefined ? undefined : !settings.disableCustomGradients,
  9347. 'typography.fontSizes': settings => settings.fontSizes === undefined ? undefined : settings.fontSizes,
  9348. 'typography.customFontSize': settings => settings.disableCustomFontSizes === undefined ? undefined : !settings.disableCustomFontSizes,
  9349. 'typography.lineHeight': settings => settings.enableCustomLineHeight,
  9350. 'spacing.units': settings => {
  9351. if (settings.enableCustomUnits === undefined) {
  9352. return;
  9353. }
  9354. if (settings.enableCustomUnits === true) {
  9355. return ['px', 'em', 'rem', 'vh', 'vw', '%'];
  9356. }
  9357. return settings.enableCustomUnits;
  9358. },
  9359. 'spacing.padding': settings => settings.enableCustomSpacing
  9360. };
  9361. const prefixedFlags = {
  9362. /*
  9363. * These were only available in the plugin
  9364. * and can be removed when the minimum WordPress version
  9365. * for the plugin is 5.9.
  9366. */
  9367. 'border.customColor': 'border.color',
  9368. 'border.customStyle': 'border.style',
  9369. 'border.customWidth': 'border.width',
  9370. 'typography.customFontStyle': 'typography.fontStyle',
  9371. 'typography.customFontWeight': 'typography.fontWeight',
  9372. 'typography.customLetterSpacing': 'typography.letterSpacing',
  9373. 'typography.customTextDecorations': 'typography.textDecoration',
  9374. 'typography.customTextTransforms': 'typography.textTransform',
  9375. /*
  9376. * These were part of WordPress 5.8 and we need to keep them.
  9377. */
  9378. 'border.customRadius': 'border.radius',
  9379. 'spacing.customMargin': 'spacing.margin',
  9380. 'spacing.customPadding': 'spacing.padding',
  9381. 'typography.customLineHeight': 'typography.lineHeight'
  9382. };
  9383. /**
  9384. * Remove `custom` prefixes for flags that did not land in 5.8.
  9385. *
  9386. * This provides continued support for `custom` prefixed properties. It will
  9387. * be removed once third party devs have had sufficient time to update themes,
  9388. * plugins, etc.
  9389. *
  9390. * @see https://github.com/WordPress/gutenberg/pull/34485
  9391. *
  9392. * @param {string} path Path to desired value in settings.
  9393. * @return {string} The value for defined setting.
  9394. */
  9395. const removeCustomPrefixes = path => {
  9396. return prefixedFlags[path] || path;
  9397. };
  9398. /**
  9399. * Hook that retrieves the given setting for the block instance in use.
  9400. *
  9401. * It looks up the settings first in the block instance hierarchy.
  9402. * If none is found, it'll look it up in the block editor store.
  9403. *
  9404. * @param {string} path The path to the setting.
  9405. * @return {any} Returns the value defined for the setting.
  9406. * @example
  9407. * ```js
  9408. * const isEnabled = useSetting( 'typography.dropCap' );
  9409. * ```
  9410. */
  9411. function useSetting(path) {
  9412. const {
  9413. name: blockName,
  9414. clientId
  9415. } = useBlockEditContext();
  9416. const setting = (0,external_wp_data_namespaceObject.useSelect)(select => {
  9417. if (blockedPaths.includes(path)) {
  9418. // eslint-disable-next-line no-console
  9419. console.warn('Top level useSetting paths are disabled. Please use a subpath to query the information needed.');
  9420. return undefined;
  9421. }
  9422. let result;
  9423. const normalizedPath = removeCustomPrefixes(path); // 1. Take settings from the block instance or its ancestors.
  9424. const candidates = [...select(store).getBlockParents(clientId), clientId // The current block is added last, so it overwrites any ancestor.
  9425. ];
  9426. candidates.forEach(candidateClientId => {
  9427. const candidateBlockName = select(store).getBlockName(candidateClientId);
  9428. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(candidateBlockName, '__experimentalSettings', false)) {
  9429. var _get;
  9430. const candidateAtts = select(store).getBlockAttributes(candidateClientId);
  9431. const candidateResult = (_get = (0,external_lodash_namespaceObject.get)(candidateAtts, `settings.blocks.${blockName}.${normalizedPath}`)) !== null && _get !== void 0 ? _get : (0,external_lodash_namespaceObject.get)(candidateAtts, `settings.${normalizedPath}`);
  9432. if (candidateResult !== undefined) {
  9433. result = candidateResult;
  9434. }
  9435. }
  9436. }); // 2. Fall back to the settings from the block editor store (__experimentalFeatures).
  9437. const settings = select(store).getSettings();
  9438. if (result === undefined) {
  9439. var _get2;
  9440. const defaultsPath = `__experimentalFeatures.${normalizedPath}`;
  9441. const blockPath = `__experimentalFeatures.blocks.${blockName}.${normalizedPath}`;
  9442. result = (_get2 = (0,external_lodash_namespaceObject.get)(settings, blockPath)) !== null && _get2 !== void 0 ? _get2 : (0,external_lodash_namespaceObject.get)(settings, defaultsPath);
  9443. } // Return if the setting was found in either the block instance or the store.
  9444. if (result !== undefined) {
  9445. if (external_wp_blocks_namespaceObject.__EXPERIMENTAL_PATHS_WITH_MERGE[normalizedPath]) {
  9446. var _ref, _result$custom;
  9447. return (_ref = (_result$custom = result.custom) !== null && _result$custom !== void 0 ? _result$custom : result.theme) !== null && _ref !== void 0 ? _ref : result.default;
  9448. }
  9449. return result;
  9450. } // 3. Otherwise, use deprecated settings.
  9451. const deprecatedSettingsValue = deprecatedFlags[normalizedPath] ? deprecatedFlags[normalizedPath](settings) : undefined;
  9452. if (deprecatedSettingsValue !== undefined) {
  9453. return deprecatedSettingsValue;
  9454. } // 4. Fallback for typography.dropCap:
  9455. // This is only necessary to support typography.dropCap.
  9456. // when __experimentalFeatures are not present (core without plugin).
  9457. // To remove when __experimentalFeatures are ported to core.
  9458. return normalizedPath === 'typography.dropCap' ? true : undefined;
  9459. }, [blockName, clientId, path]);
  9460. return setting;
  9461. }
  9462. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/spacing-sizes-control/spacing-input-control.js
  9463. /**
  9464. * External dependencies
  9465. */
  9466. /**
  9467. * WordPress dependencies
  9468. */
  9469. /**
  9470. * Internal dependencies
  9471. */
  9472. function SpacingInputControl(_ref) {
  9473. var _spacingSizes$current;
  9474. let {
  9475. spacingSizes,
  9476. value,
  9477. side,
  9478. onChange,
  9479. isMixed = false,
  9480. type,
  9481. minimumCustomValue
  9482. } = _ref;
  9483. // Treat value as a preset value if the passed in value matches the value of one of the spacingSizes.
  9484. value = getPresetValueFromCustomValue(value, spacingSizes);
  9485. let selectListSizes = spacingSizes;
  9486. const showRangeControl = spacingSizes.length <= 8;
  9487. const disableCustomSpacingSizes = (0,external_wp_data_namespaceObject.useSelect)(select => {
  9488. const editorSettings = select(store).getSettings();
  9489. return editorSettings === null || editorSettings === void 0 ? void 0 : editorSettings.disableCustomSpacingSizes;
  9490. });
  9491. const [showCustomValueControl, setShowCustomValueControl] = (0,external_wp_element_namespaceObject.useState)(!disableCustomSpacingSizes && value !== undefined && !isValueSpacingPreset(value));
  9492. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  9493. availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem']
  9494. });
  9495. let currentValue = null;
  9496. const showCustomValueInSelectList = !showRangeControl && !showCustomValueControl && value !== undefined && (!isValueSpacingPreset(value) || isValueSpacingPreset(value) && isMixed);
  9497. if (showCustomValueInSelectList) {
  9498. selectListSizes = [...spacingSizes, {
  9499. name: !isMixed ? // translators: A custom measurement, eg. a number followed by a unit like 12px.
  9500. (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Custom (%s)'), value) : (0,external_wp_i18n_namespaceObject.__)('Mixed'),
  9501. slug: 'custom',
  9502. size: value
  9503. }];
  9504. currentValue = selectListSizes.length - 1;
  9505. } else if (!isMixed) {
  9506. currentValue = !showCustomValueControl ? getSliderValueFromPreset(value, spacingSizes) : getCustomValueFromPreset(value, spacingSizes);
  9507. }
  9508. const selectedUnit = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(currentValue), [currentValue])[1] || units[0].value;
  9509. const setInitialValue = () => {
  9510. if (value === undefined) {
  9511. onChange('0');
  9512. }
  9513. };
  9514. const customTooltipContent = newValue => {
  9515. var _spacingSizes$newValu;
  9516. return value === undefined ? undefined : (_spacingSizes$newValu = spacingSizes[newValue]) === null || _spacingSizes$newValu === void 0 ? void 0 : _spacingSizes$newValu.name;
  9517. };
  9518. const customRangeValue = parseInt(currentValue, 10);
  9519. const getNewCustomValue = newSize => {
  9520. const isNumeric = !isNaN(parseFloat(newSize));
  9521. const nextValue = isNumeric ? newSize : undefined;
  9522. return nextValue;
  9523. };
  9524. const getNewPresetValue = (newSize, controlType) => {
  9525. var _spacingSizes$newSize;
  9526. const size = parseInt(newSize, 10);
  9527. if (controlType === 'selectList') {
  9528. if (size === 0) {
  9529. return undefined;
  9530. }
  9531. if (size === 1) {
  9532. return '0';
  9533. }
  9534. } else if (size === 0) {
  9535. return '0';
  9536. }
  9537. return `var:preset|spacing|${(_spacingSizes$newSize = spacingSizes[newSize]) === null || _spacingSizes$newSize === void 0 ? void 0 : _spacingSizes$newSize.slug}`;
  9538. };
  9539. const handleCustomValueSliderChange = next => {
  9540. onChange([next, selectedUnit].join(''));
  9541. };
  9542. const allPlaceholder = isMixed ? (0,external_wp_i18n_namespaceObject.__)('Mixed') : null;
  9543. const currentValueHint = !isMixed ? customTooltipContent(currentValue) : (0,external_wp_i18n_namespaceObject.__)('Mixed');
  9544. const options = selectListSizes.map((size, index) => ({
  9545. key: index,
  9546. name: size.name
  9547. }));
  9548. const marks = spacingSizes.map((newValue, index) => ({
  9549. value: index,
  9550. label: undefined
  9551. }));
  9552. const ariaLabel = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: The side of the block being modified (top, bottom, left, etc.). 2. Type of spacing being modified (Padding, margin, etc)
  9553. (0,external_wp_i18n_namespaceObject.__)('%1$s %2$s'), LABELS[side], type === null || type === void 0 ? void 0 : type.toLowerCase());
  9554. const showHint = showRangeControl && !showCustomValueControl && currentValueHint !== undefined;
  9555. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, side !== 'all' && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
  9556. className: "components-spacing-sizes-control__side-labels"
  9557. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
  9558. className: "components-spacing-sizes-control__side-label"
  9559. }, LABELS[side]), showHint && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
  9560. className: "components-spacing-sizes-control__hint-single"
  9561. }, currentValueHint)), side === 'all' && showHint && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
  9562. className: "components-spacing-sizes-control__hint-all"
  9563. }, currentValueHint), !disableCustomSpacingSizes && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  9564. label: showCustomValueControl ? (0,external_wp_i18n_namespaceObject.__)('Use size preset') : (0,external_wp_i18n_namespaceObject.__)('Set custom size'),
  9565. icon: library_settings,
  9566. onClick: () => {
  9567. setShowCustomValueControl(!showCustomValueControl);
  9568. },
  9569. isPressed: showCustomValueControl,
  9570. isSmall: true,
  9571. className: classnames_default()({
  9572. 'components-spacing-sizes-control__custom-toggle-all': side === 'all',
  9573. 'components-spacing-sizes-control__custom-toggle-single': side !== 'all'
  9574. }),
  9575. iconSize: 24
  9576. }), showCustomValueControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
  9577. onChange: newSize => onChange(getNewCustomValue(newSize)),
  9578. value: currentValue,
  9579. units: units,
  9580. min: minimumCustomValue,
  9581. placeholder: allPlaceholder,
  9582. disableUnits: isMixed,
  9583. label: ariaLabel,
  9584. hideLabelFromVision: true,
  9585. className: "components-spacing-sizes-control__custom-value-input",
  9586. style: {
  9587. gridColumn: '1'
  9588. },
  9589. size: '__unstable-large'
  9590. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.RangeControl, {
  9591. value: customRangeValue,
  9592. min: 0,
  9593. max: 100,
  9594. withInputField: false,
  9595. onChange: handleCustomValueSliderChange,
  9596. className: "components-spacing-sizes-control__custom-value-range"
  9597. })), showRangeControl && !showCustomValueControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.RangeControl, {
  9598. className: "components-spacing-sizes-control__range-control",
  9599. value: currentValue,
  9600. onChange: newSize => onChange(getNewPresetValue(newSize)),
  9601. onMouseDown: event => {
  9602. var _event$nativeEvent;
  9603. // If mouse down is near start of range set initial value to 0, which
  9604. // prevents the user have to drag right then left to get 0 setting.
  9605. if ((event === null || event === void 0 ? void 0 : (_event$nativeEvent = event.nativeEvent) === null || _event$nativeEvent === void 0 ? void 0 : _event$nativeEvent.offsetX) < 35) {
  9606. setInitialValue();
  9607. }
  9608. },
  9609. withInputField: false,
  9610. "aria-valuenow": currentValue,
  9611. "aria-valuetext": (_spacingSizes$current = spacingSizes[currentValue]) === null || _spacingSizes$current === void 0 ? void 0 : _spacingSizes$current.name,
  9612. renderTooltipContent: customTooltipContent,
  9613. min: 0,
  9614. max: spacingSizes.length - 1,
  9615. marks: marks,
  9616. label: ariaLabel,
  9617. hideLabelFromVision: true,
  9618. __nextHasNoMarginBottom: true
  9619. }), !showRangeControl && !showCustomValueControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CustomSelectControl, {
  9620. className: "components-spacing-sizes-control__custom-select-control",
  9621. value: options.find(option => option.key === currentValue) || '' // passing undefined here causes a downshift controlled/uncontrolled warning
  9622. ,
  9623. onChange: selection => {
  9624. onChange(getNewPresetValue(selection.selectedItem.key, 'selectList'));
  9625. },
  9626. options: options,
  9627. label: ariaLabel,
  9628. hideLabelFromVision: true,
  9629. __nextUnconstrainedWidth: true,
  9630. size: '__unstable-large'
  9631. }));
  9632. }
  9633. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/spacing-sizes-control/all-input-control.js
  9634. /**
  9635. * WordPress dependencies
  9636. */
  9637. /**
  9638. * Internal dependencies
  9639. */
  9640. function AllInputControl(_ref) {
  9641. let {
  9642. onChange,
  9643. values,
  9644. sides,
  9645. spacingSizes,
  9646. type,
  9647. minimumCustomValue
  9648. } = _ref;
  9649. const allValue = getAllRawValue(values);
  9650. const hasValues = isValuesDefined(values);
  9651. const isMixed = hasValues && isValuesMixed(values, sides);
  9652. const handleOnChange = next => {
  9653. const nextValues = (0,external_wp_components_namespaceObject.__experimentalApplyValueToSides)(values, next, sides);
  9654. onChange(nextValues);
  9655. };
  9656. return (0,external_wp_element_namespaceObject.createElement)(SpacingInputControl, {
  9657. value: allValue,
  9658. onChange: handleOnChange,
  9659. side: 'all',
  9660. spacingSizes: spacingSizes,
  9661. isMixed: isMixed,
  9662. type: type,
  9663. minimumCustomValue: minimumCustomValue
  9664. });
  9665. }
  9666. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/spacing-sizes-control/input-controls.js
  9667. /**
  9668. * Internal dependencies
  9669. */
  9670. function BoxInputControls(_ref) {
  9671. let {
  9672. values,
  9673. sides,
  9674. onChange,
  9675. spacingSizes,
  9676. type,
  9677. minimumCustomValue
  9678. } = _ref;
  9679. // Filter sides if custom configuration provided, maintaining default order.
  9680. const filteredSides = sides !== null && sides !== void 0 && sides.length ? ALL_SIDES.filter(side => sides.includes(side)) : ALL_SIDES;
  9681. const createHandleOnChange = side => next => {
  9682. const nextValues = { ...values
  9683. };
  9684. nextValues[side] = next;
  9685. onChange(nextValues);
  9686. };
  9687. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, filteredSides.map(side => {
  9688. return (0,external_wp_element_namespaceObject.createElement)(SpacingInputControl, {
  9689. value: values[side],
  9690. label: LABELS[side],
  9691. key: `spacing-sizes-control-${side}`,
  9692. withInputField: false,
  9693. side: side,
  9694. onChange: createHandleOnChange(side),
  9695. spacingSizes: spacingSizes,
  9696. type: type,
  9697. minimumCustomValue: minimumCustomValue
  9698. });
  9699. }));
  9700. }
  9701. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/spacing-sizes-control/axial-input-controls.js
  9702. /**
  9703. * Internal dependencies
  9704. */
  9705. const groupedSides = ['vertical', 'horizontal'];
  9706. function AxialInputControls(_ref) {
  9707. let {
  9708. onChange,
  9709. values,
  9710. sides,
  9711. spacingSizes,
  9712. type,
  9713. minimumCustomValue
  9714. } = _ref;
  9715. const createHandleOnChange = side => next => {
  9716. if (!onChange) {
  9717. return;
  9718. }
  9719. const nextValues = { ...values
  9720. };
  9721. if (side === 'vertical') {
  9722. nextValues.top = next;
  9723. nextValues.bottom = next;
  9724. }
  9725. if (side === 'horizontal') {
  9726. nextValues.left = next;
  9727. nextValues.right = next;
  9728. }
  9729. onChange(nextValues);
  9730. }; // Filter sides if custom configuration provided, maintaining default order.
  9731. const filteredSides = sides !== null && sides !== void 0 && sides.length ? groupedSides.filter(side => sides.includes(side)) : groupedSides;
  9732. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, filteredSides.map(side => {
  9733. const axisValue = side === 'vertical' ? values.top : values.left;
  9734. return (0,external_wp_element_namespaceObject.createElement)(SpacingInputControl, {
  9735. value: axisValue,
  9736. onChange: createHandleOnChange(side),
  9737. label: LABELS[side],
  9738. key: `spacing-sizes-control-${side}`,
  9739. withInputField: false,
  9740. side: side,
  9741. spacingSizes: spacingSizes,
  9742. type: type,
  9743. minimumCustomValue: minimumCustomValue
  9744. });
  9745. }));
  9746. }
  9747. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link.js
  9748. /**
  9749. * WordPress dependencies
  9750. */
  9751. const link_link = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  9752. xmlns: "http://www.w3.org/2000/svg",
  9753. viewBox: "0 0 24 24"
  9754. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  9755. d: "M15.6 7.2H14v1.5h1.6c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.8 0 5.2-2.3 5.2-5.2 0-2.9-2.3-5.2-5.2-5.2zM4.7 12.4c0-2 1.7-3.7 3.7-3.7H10V7.2H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H10v-1.5H8.4c-2 0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z"
  9756. }));
  9757. /* harmony default export */ var library_link = (link_link);
  9758. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link-off.js
  9759. /**
  9760. * WordPress dependencies
  9761. */
  9762. const linkOff = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  9763. xmlns: "http://www.w3.org/2000/svg",
  9764. viewBox: "0 0 24 24"
  9765. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  9766. d: "M15.6 7.3h-.7l1.6-3.5-.9-.4-3.9 8.5H9v1.5h2l-1.3 2.8H8.4c-2 0-3.7-1.7-3.7-3.7s1.7-3.7 3.7-3.7H10V7.3H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H9l-1.4 3.2.9.4 5.7-12.5h1.4c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.9 0 5.2-2.3 5.2-5.2 0-2.9-2.4-5.2-5.2-5.2z"
  9767. }));
  9768. /* harmony default export */ var link_off = (linkOff);
  9769. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/spacing-sizes-control/linked-button.js
  9770. /**
  9771. * WordPress dependencies
  9772. */
  9773. function LinkedButton(_ref) {
  9774. let {
  9775. isLinked,
  9776. onClick
  9777. } = _ref;
  9778. const label = isLinked ? (0,external_wp_i18n_namespaceObject.__)('Unlink sides') : (0,external_wp_i18n_namespaceObject.__)('Link sides');
  9779. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
  9780. text: label
  9781. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  9782. className: "component-spacing-sizes-control__linked-button"
  9783. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  9784. isSmall: true,
  9785. icon: isLinked ? library_link : link_off,
  9786. iconSize: 24,
  9787. "aria-label": label,
  9788. onClick: onClick
  9789. })));
  9790. }
  9791. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/spacing-sizes-control/index.js
  9792. /**
  9793. * External dependencies
  9794. */
  9795. /**
  9796. * WordPress dependencies
  9797. */
  9798. /**
  9799. * Internal dependencies
  9800. */
  9801. function SpacingSizesControl(_ref) {
  9802. let {
  9803. inputProps,
  9804. onChange,
  9805. label = (0,external_wp_i18n_namespaceObject.__)('Spacing Control'),
  9806. values,
  9807. sides,
  9808. splitOnAxis = false,
  9809. useSelect,
  9810. minimumCustomValue = 0
  9811. } = _ref;
  9812. const spacingSizes = [{
  9813. name: 0,
  9814. slug: '0',
  9815. size: 0
  9816. }, ...(useSetting('spacing.spacingSizes') || [])];
  9817. if (spacingSizes.length > 8) {
  9818. spacingSizes.unshift({
  9819. name: (0,external_wp_i18n_namespaceObject.__)('Default'),
  9820. slug: 'default',
  9821. size: undefined
  9822. });
  9823. }
  9824. const inputValues = values || DEFAULT_VALUES;
  9825. const hasInitialValue = isValuesDefined(values);
  9826. const hasOneSide = (sides === null || sides === void 0 ? void 0 : sides.length) === 1;
  9827. const [isLinked, setIsLinked] = (0,external_wp_element_namespaceObject.useState)(!hasInitialValue || !isValuesMixed(inputValues, sides) || hasOneSide);
  9828. const toggleLinked = () => {
  9829. setIsLinked(!isLinked);
  9830. };
  9831. const handleOnChange = nextValue => {
  9832. const newValues = { ...values,
  9833. ...nextValue
  9834. };
  9835. onChange(newValues);
  9836. };
  9837. const inputControlProps = { ...inputProps,
  9838. onChange: handleOnChange,
  9839. isLinked,
  9840. sides,
  9841. values: inputValues,
  9842. spacingSizes,
  9843. useSelect,
  9844. type: label,
  9845. minimumCustomValue
  9846. };
  9847. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  9848. role: "region",
  9849. className: classnames_default()('component-spacing-sizes-control', {
  9850. 'is-unlinked': !isLinked
  9851. })
  9852. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
  9853. as: "legend"
  9854. }, label), !hasOneSide && (0,external_wp_element_namespaceObject.createElement)(LinkedButton, {
  9855. onClick: toggleLinked,
  9856. isLinked: isLinked
  9857. }), isLinked && (0,external_wp_element_namespaceObject.createElement)(AllInputControl, _extends({
  9858. "aria-label": label
  9859. }, inputControlProps)), !isLinked && splitOnAxis && (0,external_wp_element_namespaceObject.createElement)(AxialInputControls, inputControlProps), !isLinked && !splitOnAxis && (0,external_wp_element_namespaceObject.createElement)(BoxInputControls, inputControlProps));
  9860. }
  9861. ;// CONCATENATED MODULE: external ["wp","warning"]
  9862. var external_wp_warning_namespaceObject = window["wp"]["warning"];
  9863. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/groups.js
  9864. /**
  9865. * WordPress dependencies
  9866. */
  9867. const InspectorControlsDefault = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControls');
  9868. const InspectorControlsAdvanced = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorAdvancedControls');
  9869. const InspectorControlsBorder = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsBorder');
  9870. const InspectorControlsColor = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsColor');
  9871. const InspectorControlsDimensions = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsDimensions');
  9872. const InspectorControlsTypography = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsTypography');
  9873. const groups_groups = {
  9874. default: InspectorControlsDefault,
  9875. advanced: InspectorControlsAdvanced,
  9876. border: InspectorControlsBorder,
  9877. color: InspectorControlsColor,
  9878. dimensions: InspectorControlsDimensions,
  9879. typography: InspectorControlsTypography
  9880. };
  9881. /* harmony default export */ var inspector_controls_groups = (groups_groups);
  9882. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/fill.js
  9883. /**
  9884. * External dependencies
  9885. */
  9886. /**
  9887. * WordPress dependencies
  9888. */
  9889. /**
  9890. * Internal dependencies
  9891. */
  9892. function InspectorControlsFill(_ref) {
  9893. var _groups$group;
  9894. let {
  9895. __experimentalGroup: group = 'default',
  9896. children
  9897. } = _ref;
  9898. const isDisplayed = useDisplayBlockControls();
  9899. const Fill = (_groups$group = inspector_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill;
  9900. if (!Fill) {
  9901. typeof process !== "undefined" && process.env && "production" !== "production" ? 0 : void 0;
  9902. return null;
  9903. }
  9904. if (!isDisplayed) {
  9905. return null;
  9906. }
  9907. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
  9908. document: document
  9909. }, (0,external_wp_element_namespaceObject.createElement)(Fill, null, fillProps => {
  9910. // Children passed to InspectorControlsFill will not have
  9911. // access to any React Context whose Provider is part of
  9912. // the InspectorControlsSlot tree. So we re-create the
  9913. // Provider in this subtree.
  9914. const value = !(0,external_lodash_namespaceObject.isEmpty)(fillProps) ? fillProps : null;
  9915. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelContext.Provider, {
  9916. value: value
  9917. }, children);
  9918. }));
  9919. }
  9920. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/utils.js
  9921. /**
  9922. * External dependencies
  9923. */
  9924. /**
  9925. * WordPress dependencies
  9926. */
  9927. const utils_identity = x => x;
  9928. /**
  9929. * Removed falsy values from nested object.
  9930. *
  9931. * @param {*} object
  9932. * @return {*} Object cleaned from falsy values
  9933. */
  9934. const cleanEmptyObject = object => {
  9935. if (object === null || typeof object !== 'object' || Array.isArray(object)) {
  9936. return object;
  9937. }
  9938. const cleanedNestedObjects = (0,external_lodash_namespaceObject.pickBy)((0,external_lodash_namespaceObject.mapValues)(object, cleanEmptyObject), utils_identity);
  9939. return (0,external_lodash_namespaceObject.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
  9940. };
  9941. function immutableSet(object, path, value) {
  9942. return (0,external_lodash_namespaceObject.setWith)(object ? (0,external_lodash_namespaceObject.clone)(object) : {}, path, value, external_lodash_namespaceObject.clone);
  9943. }
  9944. function transformStyles(activeSupports, migrationPaths, result, source, index, results) {
  9945. var _source$;
  9946. // If there are no active supports return early.
  9947. if ((0,external_lodash_namespaceObject.every)(activeSupports, isActive => !isActive)) {
  9948. return result;
  9949. } // If the condition verifies we are probably in the presence of a wrapping transform
  9950. // e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.
  9951. if (results.length === 1 && result.innerBlocks.length === source.length) {
  9952. return result;
  9953. } // For cases where we have a transform from one block to multiple blocks
  9954. // or multiple blocks to one block we apply the styles of the first source block
  9955. // to the result(s).
  9956. let referenceBlockAttributes = (_source$ = source[0]) === null || _source$ === void 0 ? void 0 : _source$.attributes; // If we are in presence of transform between more than one block in the source
  9957. // that has more than one block in the result
  9958. // we apply the styles on source N to the result N,
  9959. // if source N does not exists we do nothing.
  9960. if (results.length > 1 && source.length > 1) {
  9961. if (source[index]) {
  9962. var _source$index;
  9963. referenceBlockAttributes = (_source$index = source[index]) === null || _source$index === void 0 ? void 0 : _source$index.attributes;
  9964. } else {
  9965. return result;
  9966. }
  9967. }
  9968. let returnBlock = result;
  9969. Object.entries(activeSupports).forEach(_ref => {
  9970. let [support, isActive] = _ref;
  9971. if (isActive) {
  9972. migrationPaths[support].forEach(path => {
  9973. const styleValue = (0,external_lodash_namespaceObject.get)(referenceBlockAttributes, path);
  9974. if (styleValue) {
  9975. returnBlock = { ...returnBlock,
  9976. attributes: immutableSet(returnBlock.attributes, path, styleValue)
  9977. };
  9978. }
  9979. });
  9980. }
  9981. });
  9982. return returnBlock;
  9983. }
  9984. /**
  9985. * Check whether serialization of specific block support feature or set should
  9986. * be skipped.
  9987. *
  9988. * @param {string|Object} blockType Block name or block type object.
  9989. * @param {string} featureSet Name of block support feature set.
  9990. * @param {string} feature Name of the individual feature to check.
  9991. *
  9992. * @return {boolean} Whether serialization should occur.
  9993. */
  9994. function shouldSkipSerialization(blockType, featureSet, feature) {
  9995. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, featureSet);
  9996. const skipSerialization = support === null || support === void 0 ? void 0 : support.__experimentalSkipSerialization;
  9997. if (Array.isArray(skipSerialization)) {
  9998. return skipSerialization.includes(feature);
  9999. }
  10000. return skipSerialization;
  10001. }
  10002. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/block-support-tools-panel.js
  10003. /**
  10004. * WordPress dependencies
  10005. */
  10006. /**
  10007. * Internal dependencies
  10008. */
  10009. function BlockSupportToolsPanel(_ref) {
  10010. let {
  10011. children,
  10012. group,
  10013. label
  10014. } = _ref;
  10015. const {
  10016. updateBlockAttributes
  10017. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  10018. const {
  10019. getBlockAttributes,
  10020. getMultiSelectedBlockClientIds,
  10021. getSelectedBlockClientId,
  10022. hasMultiSelection
  10023. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  10024. const panelId = getSelectedBlockClientId();
  10025. const resetAll = (0,external_wp_element_namespaceObject.useCallback)(function () {
  10026. let resetFilters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  10027. const newAttributes = {};
  10028. const clientIds = hasMultiSelection() ? getMultiSelectedBlockClientIds() : [panelId];
  10029. clientIds.forEach(clientId => {
  10030. const {
  10031. style
  10032. } = getBlockAttributes(clientId);
  10033. let newBlockAttributes = {
  10034. style
  10035. };
  10036. resetFilters.forEach(resetFilter => {
  10037. newBlockAttributes = { ...newBlockAttributes,
  10038. ...resetFilter(newBlockAttributes)
  10039. };
  10040. }); // Enforce a cleaned style object.
  10041. newBlockAttributes = { ...newBlockAttributes,
  10042. style: cleanEmptyObject(newBlockAttributes.style)
  10043. };
  10044. newAttributes[clientId] = newBlockAttributes;
  10045. });
  10046. updateBlockAttributes(clientIds, newAttributes, true);
  10047. }, [cleanEmptyObject, getBlockAttributes, getMultiSelectedBlockClientIds, hasMultiSelection, panelId, updateBlockAttributes]);
  10048. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, {
  10049. className: `${group}-block-support-panel`,
  10050. label: label,
  10051. resetAll: resetAll,
  10052. key: panelId,
  10053. panelId: panelId,
  10054. hasInnerWrapper: true,
  10055. shouldRenderPlaceholderItems: true // Required to maintain fills ordering.
  10056. ,
  10057. __experimentalFirstVisibleItemClass: "first",
  10058. __experimentalLastVisibleItemClass: "last"
  10059. }, children);
  10060. }
  10061. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/block-support-slot-container.js
  10062. /**
  10063. * WordPress dependencies
  10064. */
  10065. function BlockSupportSlotContainer(_ref) {
  10066. let {
  10067. Slot,
  10068. ...props
  10069. } = _ref;
  10070. const toolsPanelContext = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.__experimentalToolsPanelContext);
  10071. return (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, {
  10072. fillProps: toolsPanelContext,
  10073. bubblesVirtually: true
  10074. }));
  10075. }
  10076. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/slot.js
  10077. /**
  10078. * WordPress dependencies
  10079. */
  10080. /**
  10081. * Internal dependencies
  10082. */
  10083. function InspectorControlsSlot(_ref) {
  10084. var _groups$group;
  10085. let {
  10086. __experimentalGroup: group = 'default',
  10087. label,
  10088. ...props
  10089. } = _ref;
  10090. const Slot = (_groups$group = inspector_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Slot;
  10091. const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(Slot === null || Slot === void 0 ? void 0 : Slot.__unstableName);
  10092. if (!Slot || !slot) {
  10093. typeof process !== "undefined" && process.env && "production" !== "production" ? 0 : void 0;
  10094. return null;
  10095. }
  10096. const hasFills = Boolean(slot.fills && slot.fills.length);
  10097. if (!hasFills) {
  10098. return null;
  10099. }
  10100. if (label) {
  10101. return (0,external_wp_element_namespaceObject.createElement)(BlockSupportToolsPanel, {
  10102. group: group,
  10103. label: label
  10104. }, (0,external_wp_element_namespaceObject.createElement)(BlockSupportSlotContainer, _extends({}, props, {
  10105. Slot: Slot
  10106. })));
  10107. }
  10108. return (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, {
  10109. bubblesVirtually: true
  10110. }));
  10111. }
  10112. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/index.js
  10113. /**
  10114. * Internal dependencies
  10115. */
  10116. const InspectorControls = InspectorControlsFill;
  10117. InspectorControls.Slot = InspectorControlsSlot; // This is just here for backward compatibility.
  10118. const InspectorAdvancedControls = props => {
  10119. return (0,external_wp_element_namespaceObject.createElement)(InspectorControlsFill, _extends({}, props, {
  10120. __experimentalGroup: "advanced"
  10121. }));
  10122. };
  10123. InspectorAdvancedControls.Slot = props => {
  10124. return (0,external_wp_element_namespaceObject.createElement)(InspectorControlsSlot, _extends({}, props, {
  10125. __experimentalGroup: "advanced"
  10126. }));
  10127. };
  10128. InspectorAdvancedControls.slotName = 'InspectorAdvancedControls';
  10129. /**
  10130. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-controls/README.md
  10131. */
  10132. /* harmony default export */ var inspector_controls = (InspectorControls);
  10133. ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
  10134. var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
  10135. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
  10136. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-popover/use-popover-scroll.js
  10137. /**
  10138. * WordPress dependencies
  10139. */
  10140. /**
  10141. * Allow scrolling "through" popovers over the canvas. This is only called for
  10142. * as long as the pointer is over a popover. Do not use React events because it
  10143. * will bubble through portals.
  10144. *
  10145. * @param {Object} scrollableRef
  10146. */
  10147. function usePopoverScroll(scrollableRef) {
  10148. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  10149. if (!scrollableRef) {
  10150. return;
  10151. }
  10152. function onWheel(event) {
  10153. const {
  10154. deltaX,
  10155. deltaY
  10156. } = event;
  10157. scrollableRef.current.scrollBy(deltaX, deltaY);
  10158. } // Tell the browser that we do not call event.preventDefault
  10159. // See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners
  10160. const options = {
  10161. passive: true
  10162. };
  10163. node.addEventListener('wheel', onWheel, options);
  10164. return () => {
  10165. node.removeEventListener('wheel', onWheel, options);
  10166. };
  10167. }, [scrollableRef]);
  10168. }
  10169. /* harmony default export */ var use_popover_scroll = (usePopoverScroll);
  10170. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-popover/index.js
  10171. /**
  10172. * External dependencies
  10173. */
  10174. /**
  10175. * WordPress dependencies
  10176. */
  10177. /**
  10178. * Internal dependencies
  10179. */
  10180. const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
  10181. function BlockPopover(_ref, ref) {
  10182. let {
  10183. clientId,
  10184. bottomClientId,
  10185. children,
  10186. __unstableRefreshSize,
  10187. __unstableCoverTarget = false,
  10188. __unstablePopoverSlot,
  10189. __unstableContentRef,
  10190. ...props
  10191. } = _ref;
  10192. const selectedElement = useBlockElement(clientId);
  10193. const lastSelectedElement = useBlockElement(bottomClientId !== null && bottomClientId !== void 0 ? bottomClientId : clientId);
  10194. const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, use_popover_scroll(__unstableContentRef)]);
  10195. const [popoverDimensionsRecomputeCounter, forceRecomputePopoverDimensions] = (0,external_wp_element_namespaceObject.useReducer)( // Module is there to make sure that the counter doesn't overflow.
  10196. s => (s + 1) % MAX_POPOVER_RECOMPUTE_COUNTER, 0); // When blocks are moved up/down, they are animated to their new position by
  10197. // updating the `transform` property manually (i.e. without using CSS
  10198. // transitions or animations). The animation, which can also scroll the block
  10199. // editor, can sometimes cause the position of the Popover to get out of sync.
  10200. // A MutationObserver is therefore used to make sure that changes to the
  10201. // selectedElement's attribute (i.e. `transform`) can be tracked and used to
  10202. // trigger the Popover to rerender.
  10203. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  10204. if (!selectedElement) {
  10205. return;
  10206. }
  10207. const observer = new window.MutationObserver(forceRecomputePopoverDimensions);
  10208. observer.observe(selectedElement, {
  10209. attributes: true
  10210. });
  10211. return () => {
  10212. observer.disconnect();
  10213. };
  10214. }, [selectedElement]);
  10215. const style = (0,external_wp_element_namespaceObject.useMemo)(() => {
  10216. if ( // popoverDimensionsRecomputeCounter is by definition always equal or greater
  10217. // than 0. This check is only there to satisfy the correctness of the
  10218. // exhaustive-deps rule for the `useMemo` hook.
  10219. popoverDimensionsRecomputeCounter < 0 || !selectedElement || lastSelectedElement !== selectedElement) {
  10220. return {};
  10221. }
  10222. return {
  10223. position: 'absolute',
  10224. width: selectedElement.offsetWidth,
  10225. height: selectedElement.offsetHeight
  10226. };
  10227. }, [selectedElement, lastSelectedElement, __unstableRefreshSize, popoverDimensionsRecomputeCounter]);
  10228. const popoverAnchor = (0,external_wp_element_namespaceObject.useMemo)(() => {
  10229. if ( // popoverDimensionsRecomputeCounter is by definition always equal or greater
  10230. // than 0. This check is only there to satisfy the correctness of the
  10231. // exhaustive-deps rule for the `useMemo` hook.
  10232. popoverDimensionsRecomputeCounter < 0 || !selectedElement || bottomClientId && !lastSelectedElement) {
  10233. return undefined;
  10234. }
  10235. return {
  10236. getBoundingClientRect() {
  10237. var _lastSelectedBCR$left, _lastSelectedBCR$top, _lastSelectedBCR$righ, _lastSelectedBCR$bott;
  10238. const selectedBCR = selectedElement.getBoundingClientRect();
  10239. const lastSelectedBCR = lastSelectedElement === null || lastSelectedElement === void 0 ? void 0 : lastSelectedElement.getBoundingClientRect(); // Get the biggest rectangle that encompasses completely the currently
  10240. // selected element and the last selected element:
  10241. // - for top/left coordinates, use the smaller numbers
  10242. // - for the bottom/right coordinates, use the largest numbers
  10243. const left = Math.min(selectedBCR.left, (_lastSelectedBCR$left = lastSelectedBCR === null || lastSelectedBCR === void 0 ? void 0 : lastSelectedBCR.left) !== null && _lastSelectedBCR$left !== void 0 ? _lastSelectedBCR$left : Infinity);
  10244. const top = Math.min(selectedBCR.top, (_lastSelectedBCR$top = lastSelectedBCR === null || lastSelectedBCR === void 0 ? void 0 : lastSelectedBCR.top) !== null && _lastSelectedBCR$top !== void 0 ? _lastSelectedBCR$top : Infinity);
  10245. const right = Math.max(selectedBCR.right, (_lastSelectedBCR$righ = lastSelectedBCR.right) !== null && _lastSelectedBCR$righ !== void 0 ? _lastSelectedBCR$righ : -Infinity);
  10246. const bottom = Math.max(selectedBCR.bottom, (_lastSelectedBCR$bott = lastSelectedBCR.bottom) !== null && _lastSelectedBCR$bott !== void 0 ? _lastSelectedBCR$bott : -Infinity);
  10247. const width = right - left;
  10248. const height = bottom - top;
  10249. return new window.DOMRect(left, top, width, height);
  10250. },
  10251. ownerDocument: selectedElement.ownerDocument
  10252. };
  10253. }, [bottomClientId, lastSelectedElement, selectedElement, popoverDimensionsRecomputeCounter]);
  10254. if (!selectedElement || bottomClientId && !lastSelectedElement) {
  10255. return null;
  10256. }
  10257. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, _extends({
  10258. ref: mergedRefs,
  10259. animate: false,
  10260. position: "top right left",
  10261. focusOnMount: false,
  10262. anchor: popoverAnchor // Render in the old slot if needed for backward compatibility,
  10263. // otherwise render in place (not in the default popover slot).
  10264. ,
  10265. __unstableSlotName: __unstablePopoverSlot || null,
  10266. resize: false,
  10267. flip: false,
  10268. shift: true
  10269. }, props, {
  10270. className: classnames_default()('block-editor-block-popover', props.className)
  10271. }), __unstableCoverTarget && (0,external_wp_element_namespaceObject.createElement)("div", {
  10272. style: style
  10273. }, children), !__unstableCoverTarget && children);
  10274. }
  10275. /* harmony default export */ var block_popover = ((0,external_wp_element_namespaceObject.forwardRef)(BlockPopover));
  10276. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/margin.js
  10277. /**
  10278. * WordPress dependencies
  10279. */
  10280. /**
  10281. * Internal dependencies
  10282. */
  10283. /**
  10284. * Determines if there is margin support.
  10285. *
  10286. * @param {string|Object} blockType Block name or Block Type object.
  10287. *
  10288. * @return {boolean} Whether there is support.
  10289. */
  10290. function hasMarginSupport(blockType) {
  10291. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, SPACING_SUPPORT_KEY);
  10292. return !!(true === support || support !== null && support !== void 0 && support.margin);
  10293. }
  10294. /**
  10295. * Checks if there is a current value in the margin block support attributes.
  10296. *
  10297. * @param {Object} props Block props.
  10298. * @return {boolean} Whether or not the block has a margin value set.
  10299. */
  10300. function hasMarginValue(props) {
  10301. var _props$attributes$sty, _props$attributes$sty2;
  10302. return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.spacing) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.margin) !== undefined;
  10303. }
  10304. /**
  10305. * Resets the margin block support attributes. This can be used when disabling
  10306. * the margin support controls for a block via a `ToolsPanel`.
  10307. *
  10308. * @param {Object} props Block props.
  10309. * @param {Object} props.attributes Block's attributes.
  10310. * @param {Object} props.setAttributes Function to set block's attributes.
  10311. */
  10312. function resetMargin(_ref) {
  10313. let {
  10314. attributes = {},
  10315. setAttributes
  10316. } = _ref;
  10317. const {
  10318. style
  10319. } = attributes;
  10320. setAttributes({
  10321. style: cleanEmptyObject({ ...style,
  10322. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  10323. margin: undefined
  10324. }
  10325. })
  10326. });
  10327. }
  10328. /**
  10329. * Custom hook that checks if margin settings have been disabled.
  10330. *
  10331. * @param {string} name The name of the block.
  10332. *
  10333. * @return {boolean} Whether margin setting is disabled.
  10334. */
  10335. function useIsMarginDisabled() {
  10336. let {
  10337. name: blockName
  10338. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10339. const isDisabled = !useSetting('spacing.margin');
  10340. const isInvalid = !useIsDimensionsSupportValid(blockName, 'margin');
  10341. return !hasMarginSupport(blockName) || isDisabled || isInvalid;
  10342. }
  10343. /**
  10344. * Inspector control panel containing the margin related configuration
  10345. *
  10346. * @param {Object} props Block props.
  10347. *
  10348. * @return {WPElement} Margin edit element.
  10349. */
  10350. function MarginEdit(props) {
  10351. var _style$spacing, _style$spacing2;
  10352. const {
  10353. name: blockName,
  10354. attributes: {
  10355. style
  10356. },
  10357. setAttributes
  10358. } = props;
  10359. const spacingSizes = useSetting('spacing.spacingSizes');
  10360. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  10361. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  10362. });
  10363. const sides = useCustomSides(blockName, 'margin');
  10364. const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
  10365. if (useIsMarginDisabled(props)) {
  10366. return null;
  10367. }
  10368. const onChange = next => {
  10369. const newStyle = { ...style,
  10370. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  10371. margin: next
  10372. }
  10373. };
  10374. setAttributes({
  10375. style: cleanEmptyObject(newStyle)
  10376. });
  10377. };
  10378. return external_wp_element_namespaceObject.Platform.select({
  10379. web: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (!spacingSizes || (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) === 0) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
  10380. values: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.margin,
  10381. onChange: onChange,
  10382. label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
  10383. sides: sides,
  10384. units: units,
  10385. allowReset: false,
  10386. splitOnAxis: splitOnAxis
  10387. }), (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) > 0 && (0,external_wp_element_namespaceObject.createElement)(SpacingSizesControl, {
  10388. values: style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.margin,
  10389. onChange: onChange,
  10390. label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
  10391. sides: sides,
  10392. units: units,
  10393. allowReset: false,
  10394. splitOnAxis: false
  10395. })),
  10396. native: null
  10397. });
  10398. }
  10399. function MarginVisualizer(_ref2) {
  10400. var _attributes$style, _attributes$style$spa;
  10401. let {
  10402. clientId,
  10403. attributes
  10404. } = _ref2;
  10405. const margin = attributes === null || attributes === void 0 ? void 0 : (_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : (_attributes$style$spa = _attributes$style.spacing) === null || _attributes$style$spa === void 0 ? void 0 : _attributes$style$spa.margin;
  10406. const spacingSizes = useSetting('spacing.spacingSizes');
  10407. const style = (0,external_wp_element_namespaceObject.useMemo)(() => {
  10408. const marginTop = margin !== null && margin !== void 0 && margin.top ? getCustomValueFromPreset(margin === null || margin === void 0 ? void 0 : margin.top, spacingSizes) : 0;
  10409. const marginRight = margin !== null && margin !== void 0 && margin.right ? getCustomValueFromPreset(margin === null || margin === void 0 ? void 0 : margin.right, spacingSizes) : 0;
  10410. const marginBottom = margin !== null && margin !== void 0 && margin.bottom ? getCustomValueFromPreset(margin === null || margin === void 0 ? void 0 : margin.bottom, spacingSizes) : 0;
  10411. const marginLeft = margin !== null && margin !== void 0 && margin.left ? getCustomValueFromPreset(margin === null || margin === void 0 ? void 0 : margin.left, spacingSizes) : 0;
  10412. return {
  10413. borderTopWidth: marginTop,
  10414. borderRightWidth: marginRight,
  10415. borderBottomWidth: marginBottom,
  10416. borderLeftWidth: marginLeft,
  10417. top: marginTop !== 0 ? `calc(${marginTop} * -1)` : 0,
  10418. right: marginRight !== 0 ? `calc(${marginRight} * -1)` : 0,
  10419. bottom: marginBottom !== 0 ? `calc(${marginBottom} * -1)` : 0,
  10420. left: marginLeft !== 0 ? `calc(${marginLeft} * -1)` : 0
  10421. };
  10422. }, [margin]);
  10423. const [isActive, setIsActive] = (0,external_wp_element_namespaceObject.useState)(false);
  10424. const valueRef = (0,external_wp_element_namespaceObject.useRef)(margin);
  10425. const timeoutRef = (0,external_wp_element_namespaceObject.useRef)();
  10426. const clearTimer = () => {
  10427. if (timeoutRef.current) {
  10428. window.clearTimeout(timeoutRef.current);
  10429. }
  10430. };
  10431. (0,external_wp_element_namespaceObject.useEffect)(() => {
  10432. if (!external_wp_isShallowEqual_default()(margin, valueRef.current)) {
  10433. setIsActive(true);
  10434. valueRef.current = margin;
  10435. clearTimer();
  10436. timeoutRef.current = setTimeout(() => {
  10437. setIsActive(false);
  10438. }, 400);
  10439. }
  10440. return () => clearTimer();
  10441. }, [margin]);
  10442. if (!isActive) {
  10443. return null;
  10444. }
  10445. return (0,external_wp_element_namespaceObject.createElement)(block_popover, {
  10446. clientId: clientId,
  10447. __unstableCoverTarget: true,
  10448. __unstableRefreshSize: margin
  10449. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  10450. className: "block-editor__padding-visualizer",
  10451. style: style
  10452. }));
  10453. }
  10454. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/padding.js
  10455. /**
  10456. * WordPress dependencies
  10457. */
  10458. /**
  10459. * Internal dependencies
  10460. */
  10461. /**
  10462. * Determines if there is padding support.
  10463. *
  10464. * @param {string|Object} blockType Block name or Block Type object.
  10465. *
  10466. * @return {boolean} Whether there is support.
  10467. */
  10468. function hasPaddingSupport(blockType) {
  10469. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, SPACING_SUPPORT_KEY);
  10470. return !!(true === support || support !== null && support !== void 0 && support.padding);
  10471. }
  10472. /**
  10473. * Checks if there is a current value in the padding block support attributes.
  10474. *
  10475. * @param {Object} props Block props.
  10476. * @return {boolean} Whether or not the block has a padding value set.
  10477. */
  10478. function hasPaddingValue(props) {
  10479. var _props$attributes$sty, _props$attributes$sty2;
  10480. return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.spacing) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.padding) !== undefined;
  10481. }
  10482. /**
  10483. * Resets the padding block support attributes. This can be used when disabling
  10484. * the padding support controls for a block via a `ToolsPanel`.
  10485. *
  10486. * @param {Object} props Block props.
  10487. * @param {Object} props.attributes Block's attributes.
  10488. * @param {Object} props.setAttributes Function to set block's attributes.
  10489. */
  10490. function resetPadding(_ref) {
  10491. let {
  10492. attributes = {},
  10493. setAttributes
  10494. } = _ref;
  10495. const {
  10496. style
  10497. } = attributes;
  10498. setAttributes({
  10499. style: cleanEmptyObject({ ...style,
  10500. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  10501. padding: undefined
  10502. }
  10503. })
  10504. });
  10505. }
  10506. /**
  10507. * Custom hook that checks if padding settings have been disabled.
  10508. *
  10509. * @param {string} name The name of the block.
  10510. *
  10511. * @return {boolean} Whether padding setting is disabled.
  10512. */
  10513. function useIsPaddingDisabled() {
  10514. let {
  10515. name: blockName
  10516. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10517. const isDisabled = !useSetting('spacing.padding');
  10518. const isInvalid = !useIsDimensionsSupportValid(blockName, 'padding');
  10519. return !hasPaddingSupport(blockName) || isDisabled || isInvalid;
  10520. }
  10521. /**
  10522. * Inspector control panel containing the padding related configuration
  10523. *
  10524. * @param {Object} props
  10525. *
  10526. * @return {WPElement} Padding edit element.
  10527. */
  10528. function PaddingEdit(props) {
  10529. var _style$spacing, _style$spacing2;
  10530. const {
  10531. name: blockName,
  10532. attributes: {
  10533. style
  10534. },
  10535. setAttributes
  10536. } = props;
  10537. const spacingSizes = useSetting('spacing.spacingSizes');
  10538. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  10539. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  10540. });
  10541. const sides = useCustomSides(blockName, 'padding');
  10542. const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
  10543. if (useIsPaddingDisabled(props)) {
  10544. return null;
  10545. }
  10546. const onChange = next => {
  10547. const newStyle = { ...style,
  10548. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  10549. padding: next
  10550. }
  10551. };
  10552. setAttributes({
  10553. style: cleanEmptyObject(newStyle)
  10554. });
  10555. };
  10556. return external_wp_element_namespaceObject.Platform.select({
  10557. web: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (!spacingSizes || (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) === 0) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
  10558. values: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.padding,
  10559. onChange: onChange,
  10560. label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
  10561. sides: sides,
  10562. units: units,
  10563. allowReset: false,
  10564. splitOnAxis: splitOnAxis
  10565. }), (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) > 0 && (0,external_wp_element_namespaceObject.createElement)(SpacingSizesControl, {
  10566. values: style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.padding,
  10567. onChange: onChange,
  10568. label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
  10569. sides: sides,
  10570. units: units,
  10571. allowReset: false,
  10572. splitOnAxis: splitOnAxis
  10573. })),
  10574. native: null
  10575. });
  10576. }
  10577. function PaddingVisualizer(_ref2) {
  10578. var _attributes$style, _attributes$style$spa;
  10579. let {
  10580. clientId,
  10581. attributes
  10582. } = _ref2;
  10583. const padding = attributes === null || attributes === void 0 ? void 0 : (_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : (_attributes$style$spa = _attributes$style.spacing) === null || _attributes$style$spa === void 0 ? void 0 : _attributes$style$spa.padding;
  10584. const style = (0,external_wp_element_namespaceObject.useMemo)(() => {
  10585. return {
  10586. borderTopWidth: isValueSpacingPreset(padding === null || padding === void 0 ? void 0 : padding.top) ? getSpacingPresetCssVar(padding === null || padding === void 0 ? void 0 : padding.top) : padding === null || padding === void 0 ? void 0 : padding.top,
  10587. borderRightWidth: isValueSpacingPreset(padding === null || padding === void 0 ? void 0 : padding.right) ? getSpacingPresetCssVar(padding === null || padding === void 0 ? void 0 : padding.right) : padding === null || padding === void 0 ? void 0 : padding.right,
  10588. borderBottomWidth: isValueSpacingPreset(padding === null || padding === void 0 ? void 0 : padding.bottom) ? getSpacingPresetCssVar(padding === null || padding === void 0 ? void 0 : padding.bottom) : padding === null || padding === void 0 ? void 0 : padding.bottom,
  10589. borderLeftWidth: isValueSpacingPreset(padding === null || padding === void 0 ? void 0 : padding.left) ? getSpacingPresetCssVar(padding === null || padding === void 0 ? void 0 : padding.left) : padding === null || padding === void 0 ? void 0 : padding.left
  10590. };
  10591. }, [padding]);
  10592. const [isActive, setIsActive] = (0,external_wp_element_namespaceObject.useState)(false);
  10593. const valueRef = (0,external_wp_element_namespaceObject.useRef)(padding);
  10594. const timeoutRef = (0,external_wp_element_namespaceObject.useRef)();
  10595. const clearTimer = () => {
  10596. if (timeoutRef.current) {
  10597. window.clearTimeout(timeoutRef.current);
  10598. }
  10599. };
  10600. (0,external_wp_element_namespaceObject.useEffect)(() => {
  10601. if (!external_wp_isShallowEqual_default()(padding, valueRef.current)) {
  10602. setIsActive(true);
  10603. valueRef.current = padding;
  10604. clearTimer();
  10605. timeoutRef.current = setTimeout(() => {
  10606. setIsActive(false);
  10607. }, 400);
  10608. }
  10609. return () => clearTimer();
  10610. }, [padding]);
  10611. if (!isActive) {
  10612. return null;
  10613. }
  10614. return (0,external_wp_element_namespaceObject.createElement)(block_popover, {
  10615. clientId: clientId,
  10616. __unstableCoverTarget: true,
  10617. __unstableRefreshSize: padding
  10618. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  10619. className: "block-editor__padding-visualizer",
  10620. style: style
  10621. }));
  10622. }
  10623. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/dimensions.js
  10624. /**
  10625. * External dependencies
  10626. */
  10627. /**
  10628. * WordPress dependencies
  10629. */
  10630. /**
  10631. * Internal dependencies
  10632. */
  10633. const SPACING_SUPPORT_KEY = 'spacing';
  10634. const dimensions_ALL_SIDES = ['top', 'right', 'bottom', 'left'];
  10635. const AXIAL_SIDES = ['vertical', 'horizontal'];
  10636. /**
  10637. * Inspector controls for dimensions support.
  10638. *
  10639. * @param {Object} props Block props.
  10640. *
  10641. * @return {WPElement} Inspector controls for spacing support features.
  10642. */
  10643. function DimensionsPanel(props) {
  10644. const isGapDisabled = useIsGapDisabled(props);
  10645. const isPaddingDisabled = useIsPaddingDisabled(props);
  10646. const isMarginDisabled = useIsMarginDisabled(props);
  10647. const isDisabled = useIsDimensionsDisabled(props);
  10648. const isSupported = hasDimensionsSupport(props.name);
  10649. const spacingSizes = useSetting('spacing.spacingSizes');
  10650. if (isDisabled || !isSupported) {
  10651. return null;
  10652. }
  10653. const defaultSpacingControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [SPACING_SUPPORT_KEY, '__experimentalDefaultControls']);
  10654. const createResetAllFilter = attribute => newAttributes => {
  10655. var _newAttributes$style;
  10656. return { ...newAttributes,
  10657. style: { ...newAttributes.style,
  10658. spacing: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style.spacing),
  10659. [attribute]: undefined
  10660. }
  10661. }
  10662. };
  10663. };
  10664. const spacingClassnames = classnames_default()({
  10665. 'tools-panel-item-spacing': spacingSizes && spacingSizes.length > 0
  10666. });
  10667. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
  10668. __experimentalGroup: "dimensions"
  10669. }, !isPaddingDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  10670. className: spacingClassnames,
  10671. hasValue: () => hasPaddingValue(props),
  10672. label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
  10673. onDeselect: () => resetPadding(props),
  10674. resetAllFilter: createResetAllFilter('padding'),
  10675. isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.padding,
  10676. panelId: props.clientId
  10677. }, (0,external_wp_element_namespaceObject.createElement)(PaddingEdit, props)), !isMarginDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  10678. className: spacingClassnames,
  10679. hasValue: () => hasMarginValue(props),
  10680. label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
  10681. onDeselect: () => resetMargin(props),
  10682. resetAllFilter: createResetAllFilter('margin'),
  10683. isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.margin,
  10684. panelId: props.clientId
  10685. }, (0,external_wp_element_namespaceObject.createElement)(MarginEdit, props)), !isGapDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  10686. className: spacingClassnames,
  10687. hasValue: () => hasGapValue(props),
  10688. label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
  10689. onDeselect: () => resetGap(props),
  10690. resetAllFilter: createResetAllFilter('blockGap'),
  10691. isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.blockGap,
  10692. panelId: props.clientId
  10693. }, (0,external_wp_element_namespaceObject.createElement)(GapEdit, props))), !isPaddingDisabled && (0,external_wp_element_namespaceObject.createElement)(PaddingVisualizer, props), !isMarginDisabled && (0,external_wp_element_namespaceObject.createElement)(MarginVisualizer, props));
  10694. }
  10695. /**
  10696. * Determine whether there is dimensions related block support.
  10697. *
  10698. * @param {string} blockName Block name.
  10699. *
  10700. * @return {boolean} Whether there is support.
  10701. */
  10702. function hasDimensionsSupport(blockName) {
  10703. if (external_wp_element_namespaceObject.Platform.OS !== 'web') {
  10704. return false;
  10705. }
  10706. return hasGapSupport(blockName) || hasPaddingSupport(blockName) || hasMarginSupport(blockName);
  10707. }
  10708. /**
  10709. * Determines whether dimensions support has been disabled.
  10710. *
  10711. * @param {Object} props Block properties.
  10712. *
  10713. * @return {boolean} If spacing support is completely disabled.
  10714. */
  10715. const useIsDimensionsDisabled = function () {
  10716. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10717. const gapDisabled = useIsGapDisabled(props);
  10718. const paddingDisabled = useIsPaddingDisabled(props);
  10719. const marginDisabled = useIsMarginDisabled(props);
  10720. return gapDisabled && paddingDisabled && marginDisabled;
  10721. };
  10722. /**
  10723. * Custom hook to retrieve which padding/margin/blockGap is supported
  10724. * e.g. top, right, bottom or left.
  10725. *
  10726. * Sides are opted into by default. It is only if a specific side is set to
  10727. * false that it is omitted.
  10728. *
  10729. * @param {string} blockName Block name.
  10730. * @param {string} feature The feature custom sides relate to e.g. padding or margins.
  10731. *
  10732. * @return {?string[]} Strings representing the custom sides available.
  10733. */
  10734. function useCustomSides(blockName, feature) {
  10735. var _support$feature;
  10736. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, SPACING_SUPPORT_KEY); // Skip when setting is boolean as theme isn't setting arbitrary sides.
  10737. if (!support || typeof support[feature] === 'boolean') {
  10738. return;
  10739. } // Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).
  10740. if (Array.isArray(support[feature])) {
  10741. return support[feature];
  10742. } // Finally, attempt to return `.sides` if the setting is an object.
  10743. if ((_support$feature = support[feature]) !== null && _support$feature !== void 0 && _support$feature.sides) {
  10744. return support[feature].sides;
  10745. }
  10746. }
  10747. /**
  10748. * Custom hook to determine whether the sides configured in the
  10749. * block support are valid. A dimension property cannot declare
  10750. * support for a mix of axial and individual sides.
  10751. *
  10752. * @param {string} blockName Block name.
  10753. * @param {string} feature The feature custom sides relate to e.g. padding or margins.
  10754. *
  10755. * @return {boolean} If the feature has a valid configuration of sides.
  10756. */
  10757. function useIsDimensionsSupportValid(blockName, feature) {
  10758. const sides = useCustomSides(blockName, feature);
  10759. if (sides && sides.some(side => dimensions_ALL_SIDES.includes(side)) && sides.some(side => AXIAL_SIDES.includes(side))) {
  10760. // eslint-disable-next-line no-console
  10761. console.warn(`The ${feature} support for the "${blockName}" block can not be configured to support both axial and arbitrary sides.`);
  10762. return false;
  10763. }
  10764. return true;
  10765. }
  10766. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/gap.js
  10767. /**
  10768. * WordPress dependencies
  10769. */
  10770. /**
  10771. * Internal dependencies
  10772. */
  10773. /**
  10774. * Determines if there is gap support.
  10775. *
  10776. * @param {string|Object} blockType Block name or Block Type object.
  10777. * @return {boolean} Whether there is support.
  10778. */
  10779. function hasGapSupport(blockType) {
  10780. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, SPACING_SUPPORT_KEY);
  10781. return !!(true === support || support !== null && support !== void 0 && support.blockGap);
  10782. }
  10783. /**
  10784. * Checks if there is a current value in the gap block support attributes.
  10785. *
  10786. * @param {Object} props Block props.
  10787. * @return {boolean} Whether or not the block has a gap value set.
  10788. */
  10789. function hasGapValue(props) {
  10790. var _props$attributes$sty, _props$attributes$sty2;
  10791. return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.spacing) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.blockGap) !== undefined;
  10792. }
  10793. /**
  10794. * Returns a BoxControl object value from a given blockGap style value.
  10795. * The string check is for backwards compatibility before Gutenberg supported
  10796. * split gap values (row and column) and the value was a string n + unit.
  10797. *
  10798. * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
  10799. * @return {Object|null} A value to pass to the BoxControl component.
  10800. */
  10801. function getGapBoxControlValueFromStyle(blockGapValue) {
  10802. if (!blockGapValue) {
  10803. return null;
  10804. }
  10805. const isValueString = typeof blockGapValue === 'string';
  10806. return {
  10807. top: isValueString ? blockGapValue : blockGapValue === null || blockGapValue === void 0 ? void 0 : blockGapValue.top,
  10808. left: isValueString ? blockGapValue : blockGapValue === null || blockGapValue === void 0 ? void 0 : blockGapValue.left
  10809. };
  10810. }
  10811. /**
  10812. * Returns a CSS value for the `gap` property from a given blockGap style.
  10813. *
  10814. * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
  10815. * @param {string?} defaultValue A default gap value.
  10816. * @return {string|null} The concatenated gap value (row and column).
  10817. */
  10818. function getGapCSSValue(blockGapValue) {
  10819. let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
  10820. const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue);
  10821. if (!blockGapBoxControlValue) {
  10822. return null;
  10823. }
  10824. const row = getSpacingPresetCssVar(blockGapBoxControlValue === null || blockGapBoxControlValue === void 0 ? void 0 : blockGapBoxControlValue.top) || defaultValue;
  10825. const column = getSpacingPresetCssVar(blockGapBoxControlValue === null || blockGapBoxControlValue === void 0 ? void 0 : blockGapBoxControlValue.left) || defaultValue;
  10826. return row === column ? row : `${row} ${column}`;
  10827. }
  10828. /**
  10829. * Resets the gap block support attribute. This can be used when disabling
  10830. * the gap support controls for a block via a progressive discovery panel.
  10831. *
  10832. * @param {Object} props Block props.
  10833. * @param {Object} props.attributes Block's attributes.
  10834. * @param {Object} props.setAttributes Function to set block's attributes.
  10835. */
  10836. function resetGap(_ref) {
  10837. let {
  10838. attributes = {},
  10839. setAttributes
  10840. } = _ref;
  10841. const {
  10842. style
  10843. } = attributes;
  10844. setAttributes({
  10845. style: { ...style,
  10846. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  10847. blockGap: undefined
  10848. }
  10849. }
  10850. });
  10851. }
  10852. /**
  10853. * Custom hook that checks if gap settings have been disabled.
  10854. *
  10855. * @param {string} name The name of the block.
  10856. * @return {boolean} Whether the gap setting is disabled.
  10857. */
  10858. function useIsGapDisabled() {
  10859. let {
  10860. name: blockName
  10861. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10862. const isDisabled = !useSetting('spacing.blockGap');
  10863. return !hasGapSupport(blockName) || isDisabled;
  10864. }
  10865. /**
  10866. * Inspector control panel containing the gap related configuration
  10867. *
  10868. * @param {Object} props
  10869. *
  10870. * @return {WPElement} Gap edit element.
  10871. */
  10872. function GapEdit(props) {
  10873. var _style$spacing;
  10874. const {
  10875. clientId,
  10876. attributes: {
  10877. style
  10878. },
  10879. name: blockName,
  10880. setAttributes
  10881. } = props;
  10882. const spacingSizes = useSetting('spacing.spacingSizes');
  10883. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  10884. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  10885. });
  10886. const sides = useCustomSides(blockName, 'blockGap');
  10887. const ref = useBlockRef(clientId);
  10888. if (useIsGapDisabled(props)) {
  10889. return null;
  10890. }
  10891. const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
  10892. const onChange = next => {
  10893. var _window;
  10894. let blockGap = next; // If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.
  10895. if (!!next && splitOnAxis) {
  10896. blockGap = { ...getGapBoxControlValueFromStyle(next)
  10897. };
  10898. } else if (next !== null && next !== void 0 && next.hasOwnProperty('top')) {
  10899. // If splitOnAxis is not enabled, treat the 'top' value as the shorthand gap value.
  10900. blockGap = next.top;
  10901. }
  10902. const newStyle = { ...style,
  10903. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  10904. blockGap
  10905. }
  10906. };
  10907. setAttributes({
  10908. style: cleanEmptyObject(newStyle)
  10909. }); // In Safari, changing the `gap` CSS value on its own will not trigger the layout
  10910. // to be recalculated / re-rendered. To force the updated gap to re-render, here
  10911. // we replace the block's node with itself.
  10912. const isSafari = ((_window = window) === null || _window === void 0 ? void 0 : _window.navigator.userAgent) && window.navigator.userAgent.includes('Safari') && !window.navigator.userAgent.includes('Chrome ') && !window.navigator.userAgent.includes('Chromium ');
  10913. if (ref.current && isSafari) {
  10914. var _ref$current$parentNo;
  10915. (_ref$current$parentNo = ref.current.parentNode) === null || _ref$current$parentNo === void 0 ? void 0 : _ref$current$parentNo.replaceChild(ref.current, ref.current);
  10916. }
  10917. };
  10918. const gapValue = getGapBoxControlValueFromStyle(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap); // The BoxControl component expects a full complement of side values.
  10919. // Gap row and column values translate to top/bottom and left/right respectively.
  10920. const boxControlGapValue = splitOnAxis ? { ...gapValue,
  10921. right: gapValue === null || gapValue === void 0 ? void 0 : gapValue.left,
  10922. bottom: gapValue === null || gapValue === void 0 ? void 0 : gapValue.top
  10923. } : {
  10924. top: gapValue === null || gapValue === void 0 ? void 0 : gapValue.top
  10925. };
  10926. return external_wp_element_namespaceObject.Platform.select({
  10927. web: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (!spacingSizes || (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) === 0) && (splitOnAxis ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
  10928. label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
  10929. min: 0,
  10930. onChange: onChange,
  10931. units: units,
  10932. sides: sides,
  10933. values: boxControlGapValue,
  10934. allowReset: false,
  10935. splitOnAxis: splitOnAxis
  10936. }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
  10937. label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
  10938. __unstableInputWidth: "80px",
  10939. min: 0,
  10940. onChange: onChange,
  10941. units: units // Default to `row` for combined values.
  10942. ,
  10943. value: boxControlGapValue
  10944. })), (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) > 0 && (0,external_wp_element_namespaceObject.createElement)(SpacingSizesControl, {
  10945. values: boxControlGapValue,
  10946. onChange: onChange,
  10947. label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
  10948. sides: splitOnAxis ? sides : ['top'] // Use 'top' as the shorthand property in non-axial configurations.
  10949. ,
  10950. units: units,
  10951. allowReset: false,
  10952. splitOnAxis: splitOnAxis
  10953. })),
  10954. native: null
  10955. });
  10956. }
  10957. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/icons.js
  10958. /**
  10959. * WordPress dependencies
  10960. */
  10961. const alignBottom = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  10962. xmlns: "http://www.w3.org/2000/svg",
  10963. viewBox: "0 0 24 24"
  10964. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  10965. d: "M15 4H9v11h6V4zM4 18.5V20h16v-1.5H4z"
  10966. }));
  10967. const alignCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  10968. xmlns: "http://www.w3.org/2000/svg",
  10969. viewBox: "0 0 24 24"
  10970. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  10971. d: "M20 11h-5V4H9v7H4v1.5h5V20h6v-7.5h5z"
  10972. }));
  10973. const alignTop = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  10974. xmlns: "http://www.w3.org/2000/svg",
  10975. viewBox: "0 0 24 24"
  10976. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  10977. d: "M9 20h6V9H9v11zM4 4v1.5h16V4H4z"
  10978. }));
  10979. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/ui.js
  10980. /**
  10981. * WordPress dependencies
  10982. */
  10983. /**
  10984. * Internal dependencies
  10985. */
  10986. const BLOCK_ALIGNMENTS_CONTROLS = {
  10987. top: {
  10988. icon: alignTop,
  10989. title: (0,external_wp_i18n_namespaceObject._x)('Align top', 'Block vertical alignment setting')
  10990. },
  10991. center: {
  10992. icon: alignCenter,
  10993. title: (0,external_wp_i18n_namespaceObject._x)('Align middle', 'Block vertical alignment setting')
  10994. },
  10995. bottom: {
  10996. icon: alignBottom,
  10997. title: (0,external_wp_i18n_namespaceObject._x)('Align bottom', 'Block vertical alignment setting')
  10998. }
  10999. };
  11000. const DEFAULT_CONTROLS = ['top', 'center', 'bottom'];
  11001. const DEFAULT_CONTROL = 'top';
  11002. const POPOVER_PROPS = {
  11003. isAlternate: true
  11004. };
  11005. function BlockVerticalAlignmentUI(_ref) {
  11006. let {
  11007. value,
  11008. onChange,
  11009. controls = DEFAULT_CONTROLS,
  11010. isCollapsed = true,
  11011. isToolbar
  11012. } = _ref;
  11013. function applyOrUnset(align) {
  11014. return () => onChange(value === align ? undefined : align);
  11015. }
  11016. const activeAlignment = BLOCK_ALIGNMENTS_CONTROLS[value];
  11017. const defaultAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[DEFAULT_CONTROL];
  11018. const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
  11019. const extraProps = isToolbar ? {
  11020. isCollapsed
  11021. } : {
  11022. popoverProps: {
  11023. POPOVER_PROPS
  11024. }
  11025. };
  11026. return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({
  11027. icon: activeAlignment ? activeAlignment.icon : defaultAlignmentControl.icon,
  11028. label: (0,external_wp_i18n_namespaceObject._x)('Change vertical alignment', 'Block vertical alignment setting label'),
  11029. controls: controls.map(control => {
  11030. return { ...BLOCK_ALIGNMENTS_CONTROLS[control],
  11031. isActive: value === control,
  11032. role: isCollapsed ? 'menuitemradio' : undefined,
  11033. onClick: applyOrUnset(control)
  11034. };
  11035. })
  11036. }, extraProps));
  11037. }
  11038. /**
  11039. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-toolbar/README.md
  11040. */
  11041. /* harmony default export */ var ui = (BlockVerticalAlignmentUI);
  11042. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/index.js
  11043. /**
  11044. * Internal dependencies
  11045. */
  11046. const BlockVerticalAlignmentControl = props => {
  11047. return (0,external_wp_element_namespaceObject.createElement)(ui, _extends({}, props, {
  11048. isToolbar: false
  11049. }));
  11050. };
  11051. const BlockVerticalAlignmentToolbar = props => {
  11052. return (0,external_wp_element_namespaceObject.createElement)(ui, _extends({}, props, {
  11053. isToolbar: true
  11054. }));
  11055. };
  11056. /**
  11057. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-control/README.md
  11058. */
  11059. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/justify-content-control/ui.js
  11060. /**
  11061. * WordPress dependencies
  11062. */
  11063. const icons = {
  11064. left: justify_left,
  11065. center: justify_center,
  11066. right: justify_right,
  11067. 'space-between': justify_space_between
  11068. };
  11069. function JustifyContentUI(_ref) {
  11070. let {
  11071. allowedControls = ['left', 'center', 'right', 'space-between'],
  11072. isCollapsed = true,
  11073. onChange,
  11074. value,
  11075. popoverProps,
  11076. isToolbar
  11077. } = _ref;
  11078. // If the control is already selected we want a click
  11079. // again on the control to deselect the item, so we
  11080. // call onChange( undefined )
  11081. const handleClick = next => {
  11082. if (next === value) {
  11083. onChange(undefined);
  11084. } else {
  11085. onChange(next);
  11086. }
  11087. };
  11088. const icon = value ? icons[value] : icons.left;
  11089. const allControls = [{
  11090. name: 'left',
  11091. icon: justify_left,
  11092. title: (0,external_wp_i18n_namespaceObject.__)('Justify items left'),
  11093. isActive: 'left' === value,
  11094. onClick: () => handleClick('left')
  11095. }, {
  11096. name: 'center',
  11097. icon: justify_center,
  11098. title: (0,external_wp_i18n_namespaceObject.__)('Justify items center'),
  11099. isActive: 'center' === value,
  11100. onClick: () => handleClick('center')
  11101. }, {
  11102. name: 'right',
  11103. icon: justify_right,
  11104. title: (0,external_wp_i18n_namespaceObject.__)('Justify items right'),
  11105. isActive: 'right' === value,
  11106. onClick: () => handleClick('right')
  11107. }, {
  11108. name: 'space-between',
  11109. icon: justify_space_between,
  11110. title: (0,external_wp_i18n_namespaceObject.__)('Space between items'),
  11111. isActive: 'space-between' === value,
  11112. onClick: () => handleClick('space-between')
  11113. }];
  11114. const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
  11115. const extraProps = isToolbar ? {
  11116. isCollapsed
  11117. } : {};
  11118. return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({
  11119. icon: icon,
  11120. popoverProps: popoverProps,
  11121. label: (0,external_wp_i18n_namespaceObject.__)('Change items justification'),
  11122. controls: allControls.filter(elem => allowedControls.includes(elem.name))
  11123. }, extraProps));
  11124. }
  11125. /* harmony default export */ var justify_content_control_ui = (JustifyContentUI);
  11126. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/justify-content-control/index.js
  11127. /**
  11128. * Internal dependencies
  11129. */
  11130. const JustifyContentControl = props => {
  11131. return (0,external_wp_element_namespaceObject.createElement)(justify_content_control_ui, _extends({}, props, {
  11132. isToolbar: false
  11133. }));
  11134. };
  11135. const JustifyToolbar = props => {
  11136. return (0,external_wp_element_namespaceObject.createElement)(justify_content_control_ui, _extends({}, props, {
  11137. isToolbar: true
  11138. }));
  11139. };
  11140. /**
  11141. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/justify-content-control/README.md
  11142. */
  11143. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/flex.js
  11144. /**
  11145. * WordPress dependencies
  11146. */
  11147. /**
  11148. * Internal dependencies
  11149. */
  11150. // Used with the default, horizontal flex orientation.
  11151. const justifyContentMap = {
  11152. left: 'flex-start',
  11153. right: 'flex-end',
  11154. center: 'center',
  11155. 'space-between': 'space-between'
  11156. }; // Used with the vertical (column) flex orientation.
  11157. const alignItemsMap = {
  11158. left: 'flex-start',
  11159. right: 'flex-end',
  11160. center: 'center'
  11161. };
  11162. const verticalAlignmentMap = {
  11163. top: 'flex-start',
  11164. center: 'center',
  11165. bottom: 'flex-end'
  11166. };
  11167. const flexWrapOptions = ['wrap', 'nowrap'];
  11168. /* harmony default export */ var flex = ({
  11169. name: 'flex',
  11170. label: (0,external_wp_i18n_namespaceObject.__)('Flex'),
  11171. inspectorControls: function FlexLayoutInspectorControls(_ref) {
  11172. let {
  11173. layout = {},
  11174. onChange,
  11175. layoutBlockSupport = {}
  11176. } = _ref;
  11177. const {
  11178. allowOrientation = true
  11179. } = layoutBlockSupport;
  11180. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(FlexLayoutJustifyContentControl, {
  11181. layout: layout,
  11182. onChange: onChange
  11183. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, allowOrientation && (0,external_wp_element_namespaceObject.createElement)(OrientationControl, {
  11184. layout: layout,
  11185. onChange: onChange
  11186. }))), (0,external_wp_element_namespaceObject.createElement)(FlexWrapControl, {
  11187. layout: layout,
  11188. onChange: onChange
  11189. }));
  11190. },
  11191. toolBarControls: function FlexLayoutToolbarControls(_ref2) {
  11192. let {
  11193. layout = {},
  11194. onChange,
  11195. layoutBlockSupport
  11196. } = _ref2;
  11197. if (layoutBlockSupport !== null && layoutBlockSupport !== void 0 && layoutBlockSupport.allowSwitching) {
  11198. return null;
  11199. }
  11200. const {
  11201. allowVerticalAlignment = true
  11202. } = layoutBlockSupport;
  11203. return (0,external_wp_element_namespaceObject.createElement)(block_controls, {
  11204. group: "block",
  11205. __experimentalShareWithChildBlocks: true
  11206. }, (0,external_wp_element_namespaceObject.createElement)(FlexLayoutJustifyContentControl, {
  11207. layout: layout,
  11208. onChange: onChange,
  11209. isToolbar: true
  11210. }), allowVerticalAlignment && (layout === null || layout === void 0 ? void 0 : layout.orientation) !== 'vertical' && (0,external_wp_element_namespaceObject.createElement)(FlexLayoutVerticalAlignmentControl, {
  11211. layout: layout,
  11212. onChange: onChange,
  11213. isToolbar: true
  11214. }));
  11215. },
  11216. getLayoutStyle: function getLayoutStyle(_ref3) {
  11217. var _style$spacing, _style$spacing2;
  11218. let {
  11219. selector,
  11220. layout,
  11221. style,
  11222. blockName,
  11223. hasBlockGapSupport,
  11224. layoutDefinitions
  11225. } = _ref3;
  11226. const {
  11227. orientation = 'horizontal'
  11228. } = layout; // If a block's block.json skips serialization for spacing or spacing.blockGap,
  11229. // don't apply the user-defined value to the styles.
  11230. const blockGapValue = style !== null && style !== void 0 && (_style$spacing = style.spacing) !== null && _style$spacing !== void 0 && _style$spacing.blockGap && !shouldSkipSerialization(blockName, 'spacing', 'blockGap') ? getGapCSSValue(style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.blockGap, '0.5em') : undefined;
  11231. const justifyContent = justifyContentMap[layout.justifyContent];
  11232. const flexWrap = flexWrapOptions.includes(layout.flexWrap) ? layout.flexWrap : 'wrap';
  11233. const verticalAlignment = verticalAlignmentMap[layout.verticalAlignment];
  11234. const alignItems = alignItemsMap[layout.justifyContent] || alignItemsMap.left;
  11235. let output = '';
  11236. const rules = [];
  11237. if (flexWrap && flexWrap !== 'wrap') {
  11238. rules.push(`flex-wrap: ${flexWrap}`);
  11239. }
  11240. if (orientation === 'horizontal') {
  11241. if (verticalAlignment) {
  11242. rules.push(`align-items: ${verticalAlignment}`);
  11243. }
  11244. if (justifyContent) {
  11245. rules.push(`justify-content: ${justifyContent}`);
  11246. }
  11247. } else {
  11248. rules.push('flex-direction: column');
  11249. rules.push(`align-items: ${alignItems}`);
  11250. }
  11251. if (rules.length) {
  11252. output = `${appendSelectors(selector)} {
  11253. ${rules.join('; ')};
  11254. }`;
  11255. } // Output blockGap styles based on rules contained in layout definitions in theme.json.
  11256. if (hasBlockGapSupport && blockGapValue) {
  11257. output += getBlockGapCSS(selector, layoutDefinitions, 'flex', blockGapValue);
  11258. }
  11259. return output;
  11260. },
  11261. getOrientation(layout) {
  11262. const {
  11263. orientation = 'horizontal'
  11264. } = layout;
  11265. return orientation;
  11266. },
  11267. getAlignments() {
  11268. return [];
  11269. }
  11270. });
  11271. function FlexLayoutVerticalAlignmentControl(_ref4) {
  11272. let {
  11273. layout,
  11274. onChange,
  11275. isToolbar = false
  11276. } = _ref4;
  11277. const {
  11278. verticalAlignment = verticalAlignmentMap.center
  11279. } = layout;
  11280. const onVerticalAlignmentChange = value => {
  11281. onChange({ ...layout,
  11282. verticalAlignment: value
  11283. });
  11284. };
  11285. if (isToolbar) {
  11286. return (0,external_wp_element_namespaceObject.createElement)(BlockVerticalAlignmentControl, {
  11287. onChange: onVerticalAlignmentChange,
  11288. value: verticalAlignment
  11289. });
  11290. }
  11291. const verticalAlignmentOptions = [{
  11292. value: 'flex-start',
  11293. label: (0,external_wp_i18n_namespaceObject.__)('Align items top')
  11294. }, {
  11295. value: 'center',
  11296. label: (0,external_wp_i18n_namespaceObject.__)('Align items center')
  11297. }, {
  11298. value: 'flex-end',
  11299. label: (0,external_wp_i18n_namespaceObject.__)('Align items bottom')
  11300. }];
  11301. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  11302. className: "block-editor-hooks__flex-layout-vertical-alignment-control"
  11303. }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Vertical alignment')), (0,external_wp_element_namespaceObject.createElement)("div", null, verticalAlignmentOptions.map((value, icon, label) => {
  11304. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  11305. key: value,
  11306. label: label,
  11307. icon: icon,
  11308. isPressed: verticalAlignment === value,
  11309. onClick: () => onVerticalAlignmentChange(value)
  11310. });
  11311. })));
  11312. }
  11313. function FlexLayoutJustifyContentControl(_ref5) {
  11314. let {
  11315. layout,
  11316. onChange,
  11317. isToolbar = false
  11318. } = _ref5;
  11319. const {
  11320. justifyContent = 'left',
  11321. orientation = 'horizontal'
  11322. } = layout;
  11323. const onJustificationChange = value => {
  11324. onChange({ ...layout,
  11325. justifyContent: value
  11326. });
  11327. };
  11328. const allowedControls = ['left', 'center', 'right'];
  11329. if (orientation === 'horizontal') {
  11330. allowedControls.push('space-between');
  11331. }
  11332. if (isToolbar) {
  11333. return (0,external_wp_element_namespaceObject.createElement)(JustifyContentControl, {
  11334. allowedControls: allowedControls,
  11335. value: justifyContent,
  11336. onChange: onJustificationChange,
  11337. popoverProps: {
  11338. position: 'bottom right',
  11339. isAlternate: true
  11340. }
  11341. });
  11342. }
  11343. const justificationOptions = [{
  11344. value: 'left',
  11345. icon: justify_left,
  11346. label: (0,external_wp_i18n_namespaceObject.__)('Justify items left')
  11347. }, {
  11348. value: 'center',
  11349. icon: justify_center,
  11350. label: (0,external_wp_i18n_namespaceObject.__)('Justify items center')
  11351. }, {
  11352. value: 'right',
  11353. icon: justify_right,
  11354. label: (0,external_wp_i18n_namespaceObject.__)('Justify items right')
  11355. }];
  11356. if (orientation === 'horizontal') {
  11357. justificationOptions.push({
  11358. value: 'space-between',
  11359. icon: justify_space_between,
  11360. label: (0,external_wp_i18n_namespaceObject.__)('Space between items')
  11361. });
  11362. }
  11363. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  11364. className: "block-editor-hooks__flex-layout-justification-controls"
  11365. }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Justification')), (0,external_wp_element_namespaceObject.createElement)("div", null, justificationOptions.map(_ref6 => {
  11366. let {
  11367. value,
  11368. icon,
  11369. label
  11370. } = _ref6;
  11371. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  11372. key: value,
  11373. label: label,
  11374. icon: icon,
  11375. isPressed: justifyContent === value,
  11376. onClick: () => onJustificationChange(value)
  11377. });
  11378. })));
  11379. }
  11380. function FlexWrapControl(_ref7) {
  11381. let {
  11382. layout,
  11383. onChange
  11384. } = _ref7;
  11385. const {
  11386. flexWrap = 'wrap'
  11387. } = layout;
  11388. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  11389. label: (0,external_wp_i18n_namespaceObject.__)('Allow to wrap to multiple lines'),
  11390. onChange: value => {
  11391. onChange({ ...layout,
  11392. flexWrap: value ? 'wrap' : 'nowrap'
  11393. });
  11394. },
  11395. checked: flexWrap === 'wrap'
  11396. });
  11397. }
  11398. function OrientationControl(_ref8) {
  11399. let {
  11400. layout,
  11401. onChange
  11402. } = _ref8;
  11403. const {
  11404. orientation = 'horizontal'
  11405. } = layout;
  11406. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  11407. className: "block-editor-hooks__flex-layout-orientation-controls"
  11408. }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Orientation')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  11409. label: (0,external_wp_i18n_namespaceObject.__)('Horizontal'),
  11410. icon: arrow_right,
  11411. isPressed: orientation === 'horizontal',
  11412. onClick: () => onChange({ ...layout,
  11413. orientation: 'horizontal'
  11414. })
  11415. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  11416. label: (0,external_wp_i18n_namespaceObject.__)('Vertical'),
  11417. icon: arrow_down,
  11418. isPressed: orientation === 'vertical',
  11419. onClick: () => onChange({ ...layout,
  11420. orientation: 'vertical'
  11421. })
  11422. }));
  11423. }
  11424. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/flow.js
  11425. /**
  11426. * WordPress dependencies
  11427. */
  11428. /**
  11429. * Internal dependencies
  11430. */
  11431. /* harmony default export */ var flow = ({
  11432. name: 'default',
  11433. label: (0,external_wp_i18n_namespaceObject.__)('Flow'),
  11434. inspectorControls: function DefaultLayoutInspectorControls() {
  11435. return null;
  11436. },
  11437. toolBarControls: function DefaultLayoutToolbarControls() {
  11438. return null;
  11439. },
  11440. getLayoutStyle: function getLayoutStyle(_ref) {
  11441. var _style$spacing;
  11442. let {
  11443. selector,
  11444. style,
  11445. blockName,
  11446. hasBlockGapSupport,
  11447. layoutDefinitions
  11448. } = _ref;
  11449. const blockGapStyleValue = getGapCSSValue(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap); // If a block's block.json skips serialization for spacing or
  11450. // spacing.blockGap, don't apply the user-defined value to the styles.
  11451. let blockGapValue = '';
  11452. if (!shouldSkipSerialization(blockName, 'spacing', 'blockGap')) {
  11453. // If an object is provided only use the 'top' value for this kind of gap.
  11454. if (blockGapStyleValue !== null && blockGapStyleValue !== void 0 && blockGapStyleValue.top) {
  11455. blockGapValue = getGapCSSValue(blockGapStyleValue === null || blockGapStyleValue === void 0 ? void 0 : blockGapStyleValue.top);
  11456. } else if (typeof blockGapStyleValue === 'string') {
  11457. blockGapValue = getGapCSSValue(blockGapStyleValue);
  11458. }
  11459. }
  11460. let output = ''; // Output blockGap styles based on rules contained in layout definitions in theme.json.
  11461. if (hasBlockGapSupport && blockGapValue) {
  11462. output += getBlockGapCSS(selector, layoutDefinitions, 'default', blockGapValue);
  11463. }
  11464. return output;
  11465. },
  11466. getOrientation() {
  11467. return 'vertical';
  11468. },
  11469. getAlignments(layout) {
  11470. const alignmentInfo = getAlignmentsInfo(layout);
  11471. if (layout.alignments !== undefined) {
  11472. if (!layout.alignments.includes('none')) {
  11473. layout.alignments.unshift('none');
  11474. }
  11475. return layout.alignments.map(alignment => ({
  11476. name: alignment,
  11477. info: alignmentInfo[alignment]
  11478. }));
  11479. }
  11480. const {
  11481. contentSize,
  11482. wideSize
  11483. } = layout;
  11484. const alignments = [{
  11485. name: 'left'
  11486. }, {
  11487. name: 'center'
  11488. }, {
  11489. name: 'right'
  11490. }];
  11491. if (contentSize) {
  11492. alignments.unshift({
  11493. name: 'full'
  11494. });
  11495. }
  11496. if (wideSize) {
  11497. alignments.unshift({
  11498. name: 'wide',
  11499. info: alignmentInfo.wide
  11500. });
  11501. }
  11502. alignments.unshift({
  11503. name: 'none',
  11504. info: alignmentInfo.none
  11505. });
  11506. return alignments;
  11507. }
  11508. });
  11509. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js
  11510. /**
  11511. * WordPress dependencies
  11512. */
  11513. /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
  11514. /**
  11515. * Return an SVG icon.
  11516. *
  11517. * @param {IconProps} props icon is the SVG component to render
  11518. * size is a number specifiying the icon size in pixels
  11519. * Other props will be passed to wrapped SVG component
  11520. *
  11521. * @return {JSX.Element} Icon component
  11522. */
  11523. function Icon(_ref) {
  11524. let {
  11525. icon,
  11526. size = 24,
  11527. ...props
  11528. } = _ref;
  11529. return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
  11530. width: size,
  11531. height: size,
  11532. ...props
  11533. });
  11534. }
  11535. /* harmony default export */ var build_module_icon = (Icon);
  11536. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-center.js
  11537. /**
  11538. * WordPress dependencies
  11539. */
  11540. const positionCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  11541. xmlns: "http://www.w3.org/2000/svg",
  11542. viewBox: "0 0 24 24"
  11543. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  11544. d: "M7 9v6h10V9H7zM5 19.8h14v-1.5H5v1.5zM5 4.3v1.5h14V4.3H5z"
  11545. }));
  11546. /* harmony default export */ var position_center = (positionCenter);
  11547. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stretch-wide.js
  11548. /**
  11549. * WordPress dependencies
  11550. */
  11551. const stretchWide = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  11552. xmlns: "http://www.w3.org/2000/svg",
  11553. viewBox: "0 0 24 24"
  11554. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  11555. d: "M5 9v6h14V9H5zm11-4.8H8v1.5h8V4.2zM8 19.8h8v-1.5H8v1.5z"
  11556. }));
  11557. /* harmony default export */ var stretch_wide = (stretchWide);
  11558. ;// CONCATENATED MODULE: external ["wp","styleEngine"]
  11559. var external_wp_styleEngine_namespaceObject = window["wp"]["styleEngine"];
  11560. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/constrained.js
  11561. /**
  11562. * WordPress dependencies
  11563. */
  11564. /**
  11565. * Internal dependencies
  11566. */
  11567. /* harmony default export */ var constrained = ({
  11568. name: 'constrained',
  11569. label: (0,external_wp_i18n_namespaceObject.__)('Constrained'),
  11570. inspectorControls: function DefaultLayoutInspectorControls(_ref) {
  11571. let {
  11572. layout,
  11573. onChange
  11574. } = _ref;
  11575. const {
  11576. wideSize,
  11577. contentSize,
  11578. justifyContent = 'center'
  11579. } = layout;
  11580. const onJustificationChange = value => {
  11581. onChange({ ...layout,
  11582. justifyContent: value
  11583. });
  11584. };
  11585. const justificationOptions = [{
  11586. value: 'left',
  11587. icon: justify_left,
  11588. label: (0,external_wp_i18n_namespaceObject.__)('Justify items left')
  11589. }, {
  11590. value: 'center',
  11591. icon: justify_center,
  11592. label: (0,external_wp_i18n_namespaceObject.__)('Justify items center')
  11593. }, {
  11594. value: 'right',
  11595. icon: justify_right,
  11596. label: (0,external_wp_i18n_namespaceObject.__)('Justify items right')
  11597. }];
  11598. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  11599. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  11600. });
  11601. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  11602. className: "block-editor-hooks__layout-controls"
  11603. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  11604. className: "block-editor-hooks__layout-controls-unit"
  11605. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
  11606. label: (0,external_wp_i18n_namespaceObject.__)('Content'),
  11607. labelPosition: "top",
  11608. __unstableInputWidth: "80px",
  11609. value: contentSize || wideSize || '',
  11610. onChange: nextWidth => {
  11611. nextWidth = 0 > parseFloat(nextWidth) ? '0' : nextWidth;
  11612. onChange({ ...layout,
  11613. contentSize: nextWidth
  11614. });
  11615. },
  11616. units: units
  11617. }), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  11618. icon: position_center
  11619. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  11620. className: "block-editor-hooks__layout-controls-unit"
  11621. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
  11622. label: (0,external_wp_i18n_namespaceObject.__)('Wide'),
  11623. labelPosition: "top",
  11624. __unstableInputWidth: "80px",
  11625. value: wideSize || contentSize || '',
  11626. onChange: nextWidth => {
  11627. nextWidth = 0 > parseFloat(nextWidth) ? '0' : nextWidth;
  11628. onChange({ ...layout,
  11629. wideSize: nextWidth
  11630. });
  11631. },
  11632. units: units
  11633. }), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  11634. icon: stretch_wide
  11635. }))), (0,external_wp_element_namespaceObject.createElement)("p", {
  11636. className: "block-editor-hooks__layout-controls-helptext"
  11637. }, (0,external_wp_i18n_namespaceObject.__)('Customize the width for all elements that are assigned to the center or wide columns.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControl, {
  11638. __experimentalIsBorderless: true,
  11639. label: (0,external_wp_i18n_namespaceObject.__)('Justification'),
  11640. value: justifyContent,
  11641. onChange: onJustificationChange
  11642. }, justificationOptions.map(_ref2 => {
  11643. let {
  11644. value,
  11645. icon,
  11646. label
  11647. } = _ref2;
  11648. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOptionIcon, {
  11649. key: value,
  11650. value: value,
  11651. icon: icon,
  11652. label: label
  11653. });
  11654. })));
  11655. },
  11656. toolBarControls: function DefaultLayoutToolbarControls() {
  11657. return null;
  11658. },
  11659. getLayoutStyle: function getLayoutStyle(_ref3) {
  11660. var _style$spacing, _style$spacing2;
  11661. let {
  11662. selector,
  11663. layout = {},
  11664. style,
  11665. blockName,
  11666. hasBlockGapSupport,
  11667. layoutDefinitions
  11668. } = _ref3;
  11669. const {
  11670. contentSize,
  11671. wideSize,
  11672. justifyContent
  11673. } = layout;
  11674. const blockGapStyleValue = getGapCSSValue(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap); // If a block's block.json skips serialization for spacing or
  11675. // spacing.blockGap, don't apply the user-defined value to the styles.
  11676. let blockGapValue = '';
  11677. if (!shouldSkipSerialization(blockName, 'spacing', 'blockGap')) {
  11678. // If an object is provided only use the 'top' value for this kind of gap.
  11679. if (blockGapStyleValue !== null && blockGapStyleValue !== void 0 && blockGapStyleValue.top) {
  11680. blockGapValue = getGapCSSValue(blockGapStyleValue === null || blockGapStyleValue === void 0 ? void 0 : blockGapStyleValue.top);
  11681. } else if (typeof blockGapStyleValue === 'string') {
  11682. blockGapValue = getGapCSSValue(blockGapStyleValue);
  11683. }
  11684. }
  11685. const marginLeft = justifyContent === 'left' ? '0 !important' : 'auto !important';
  11686. const marginRight = justifyContent === 'right' ? '0 !important' : 'auto !important';
  11687. let output = !!contentSize || !!wideSize ? `
  11688. ${appendSelectors(selector, '> :where(:not(.alignleft):not(.alignright):not(.alignfull))')} {
  11689. max-width: ${contentSize !== null && contentSize !== void 0 ? contentSize : wideSize};
  11690. margin-left: ${marginLeft};
  11691. margin-right: ${marginRight};
  11692. }
  11693. ${appendSelectors(selector, '> .alignwide')} {
  11694. max-width: ${wideSize !== null && wideSize !== void 0 ? wideSize : contentSize};
  11695. }
  11696. ${appendSelectors(selector, '> .alignfull')} {
  11697. max-width: none;
  11698. }
  11699. ` : '';
  11700. if (justifyContent === 'left') {
  11701. output += `${appendSelectors(selector, '> :where(:not(.alignleft):not(.alignright):not(.alignfull))')}
  11702. { margin-left: ${marginLeft}; }`;
  11703. } else if (justifyContent === 'right') {
  11704. output += `${appendSelectors(selector, '> :where(:not(.alignleft):not(.alignright):not(.alignfull))')}
  11705. { margin-right: ${marginRight}; }`;
  11706. } // If there is custom padding, add negative margins for alignfull blocks.
  11707. if (style !== null && style !== void 0 && (_style$spacing2 = style.spacing) !== null && _style$spacing2 !== void 0 && _style$spacing2.padding) {
  11708. // The style object might be storing a preset so we need to make sure we get a usable value.
  11709. const paddingValues = (0,external_wp_styleEngine_namespaceObject.getCSSRules)(style);
  11710. paddingValues.forEach(rule => {
  11711. if (rule.key === 'paddingRight') {
  11712. output += `
  11713. ${appendSelectors(selector, '> .alignfull')} {
  11714. margin-right: calc(${rule.value} * -1);
  11715. }
  11716. `;
  11717. } else if (rule.key === 'paddingLeft') {
  11718. output += `
  11719. ${appendSelectors(selector, '> .alignfull')} {
  11720. margin-left: calc(${rule.value} * -1);
  11721. }
  11722. `;
  11723. }
  11724. });
  11725. } // Output blockGap styles based on rules contained in layout definitions in theme.json.
  11726. if (hasBlockGapSupport && blockGapValue) {
  11727. output += getBlockGapCSS(selector, layoutDefinitions, 'constrained', blockGapValue);
  11728. }
  11729. return output;
  11730. },
  11731. getOrientation() {
  11732. return 'vertical';
  11733. },
  11734. getAlignments(layout) {
  11735. const alignmentInfo = getAlignmentsInfo(layout);
  11736. if (layout.alignments !== undefined) {
  11737. if (!layout.alignments.includes('none')) {
  11738. layout.alignments.unshift('none');
  11739. }
  11740. return layout.alignments.map(alignment => ({
  11741. name: alignment,
  11742. info: alignmentInfo[alignment]
  11743. }));
  11744. }
  11745. const {
  11746. contentSize,
  11747. wideSize
  11748. } = layout;
  11749. const alignments = [{
  11750. name: 'left'
  11751. }, {
  11752. name: 'center'
  11753. }, {
  11754. name: 'right'
  11755. }];
  11756. if (contentSize) {
  11757. alignments.unshift({
  11758. name: 'full'
  11759. });
  11760. }
  11761. if (wideSize) {
  11762. alignments.unshift({
  11763. name: 'wide',
  11764. info: alignmentInfo.wide
  11765. });
  11766. }
  11767. alignments.unshift({
  11768. name: 'none',
  11769. info: alignmentInfo.none
  11770. });
  11771. return alignments;
  11772. }
  11773. });
  11774. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/index.js
  11775. /**
  11776. * Internal dependencies
  11777. */
  11778. const layoutTypes = [flow, flex, constrained];
  11779. /**
  11780. * Retrieves a layout type by name.
  11781. *
  11782. * @param {string} name - The name of the layout type.
  11783. * @return {Object} Layout type.
  11784. */
  11785. function getLayoutType() {
  11786. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
  11787. return layoutTypes.find(layoutType => layoutType.name === name);
  11788. }
  11789. /**
  11790. * Retrieves the available layout types.
  11791. *
  11792. * @return {Array} Layout types.
  11793. */
  11794. function getLayoutTypes() {
  11795. return layoutTypes;
  11796. }
  11797. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/layout.js
  11798. /**
  11799. * WordPress dependencies
  11800. */
  11801. /**
  11802. * Internal dependencies
  11803. */
  11804. const defaultLayout = {
  11805. type: 'default'
  11806. };
  11807. const Layout = (0,external_wp_element_namespaceObject.createContext)(defaultLayout);
  11808. /**
  11809. * Allows to define the layout.
  11810. */
  11811. const LayoutProvider = Layout.Provider;
  11812. /**
  11813. * React hook used to retrieve the layout config.
  11814. */
  11815. function useLayout() {
  11816. return (0,external_wp_element_namespaceObject.useContext)(Layout);
  11817. }
  11818. function LayoutStyle(_ref) {
  11819. let {
  11820. layout = {},
  11821. css,
  11822. ...props
  11823. } = _ref;
  11824. const layoutType = getLayoutType(layout.type);
  11825. const blockGapSupport = useSetting('spacing.blockGap');
  11826. const hasBlockGapSupport = blockGapSupport !== null;
  11827. if (layoutType) {
  11828. var _layoutType$getLayout;
  11829. if (css) {
  11830. return (0,external_wp_element_namespaceObject.createElement)("style", null, css);
  11831. }
  11832. const layoutStyle = (_layoutType$getLayout = layoutType.getLayoutStyle) === null || _layoutType$getLayout === void 0 ? void 0 : _layoutType$getLayout.call(layoutType, {
  11833. hasBlockGapSupport,
  11834. layout,
  11835. ...props
  11836. });
  11837. if (layoutStyle) {
  11838. return (0,external_wp_element_namespaceObject.createElement)("style", null, layoutStyle);
  11839. }
  11840. }
  11841. return null;
  11842. }
  11843. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/use-available-alignments.js
  11844. /**
  11845. * WordPress dependencies
  11846. */
  11847. /**
  11848. * Internal dependencies
  11849. */
  11850. const use_available_alignments_DEFAULT_CONTROLS = ['none', 'left', 'center', 'right', 'wide', 'full'];
  11851. const WIDE_CONTROLS = ['wide', 'full'];
  11852. function useAvailableAlignments() {
  11853. let controls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : use_available_alignments_DEFAULT_CONTROLS;
  11854. // Always add the `none` option if not exists.
  11855. if (!controls.includes('none')) {
  11856. controls = ['none', ...controls];
  11857. }
  11858. const {
  11859. wideControlsEnabled = false,
  11860. themeSupportsLayout
  11861. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  11862. const {
  11863. getSettings
  11864. } = select(store);
  11865. const settings = getSettings();
  11866. return {
  11867. wideControlsEnabled: settings.alignWide,
  11868. themeSupportsLayout: settings.supportsLayout
  11869. };
  11870. }, []);
  11871. const layout = useLayout();
  11872. const layoutType = getLayoutType(layout === null || layout === void 0 ? void 0 : layout.type);
  11873. const layoutAlignments = layoutType.getAlignments(layout);
  11874. if (themeSupportsLayout) {
  11875. const alignments = layoutAlignments.filter(_ref => {
  11876. let {
  11877. name: alignmentName
  11878. } = _ref;
  11879. return controls.includes(alignmentName);
  11880. }); // While we treat `none` as an alignment, we shouldn't return it if no
  11881. // other alignments exist.
  11882. if (alignments.length === 1 && alignments[0].name === 'none') {
  11883. return [];
  11884. }
  11885. return alignments;
  11886. } // Starting here, it's the fallback for themes not supporting the layout config.
  11887. if (layoutType.name !== 'default' && layoutType.name !== 'constrained') {
  11888. return [];
  11889. }
  11890. const {
  11891. alignments: availableAlignments = use_available_alignments_DEFAULT_CONTROLS
  11892. } = layout;
  11893. const enabledControls = controls.filter(control => (layout.alignments || // Ignore the global wideAlignment check if the layout explicitely defines alignments.
  11894. wideControlsEnabled || !WIDE_CONTROLS.includes(control)) && availableAlignments.includes(control)).map(enabledControl => ({
  11895. name: enabledControl
  11896. })); // While we treat `none` as an alignment, we shouldn't return it if no
  11897. // other alignments exist.
  11898. if (enabledControls.length === 1 && enabledControls[0].name === 'none') {
  11899. return [];
  11900. }
  11901. return enabledControls;
  11902. }
  11903. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-none.js
  11904. /**
  11905. * WordPress dependencies
  11906. */
  11907. const alignNone = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  11908. xmlns: "http://www.w3.org/2000/svg",
  11909. viewBox: "0 0 24 24"
  11910. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  11911. d: "M5 15h14V9H5v6zm0 4.8h14v-1.5H5v1.5zM5 4.2v1.5h14V4.2H5z"
  11912. }));
  11913. /* harmony default export */ var align_none = (alignNone);
  11914. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-left.js
  11915. /**
  11916. * WordPress dependencies
  11917. */
  11918. const positionLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  11919. xmlns: "http://www.w3.org/2000/svg",
  11920. viewBox: "0 0 24 24"
  11921. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  11922. d: "M4 9v6h14V9H4zm8-4.8H4v1.5h8V4.2zM4 19.8h8v-1.5H4v1.5z"
  11923. }));
  11924. /* harmony default export */ var position_left = (positionLeft);
  11925. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-right.js
  11926. /**
  11927. * WordPress dependencies
  11928. */
  11929. const positionRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  11930. xmlns: "http://www.w3.org/2000/svg",
  11931. viewBox: "0 0 24 24"
  11932. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  11933. d: "M6 15h14V9H6v6zm6-10.8v1.5h8V4.2h-8zm0 15.6h8v-1.5h-8v1.5z"
  11934. }));
  11935. /* harmony default export */ var position_right = (positionRight);
  11936. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stretch-full-width.js
  11937. /**
  11938. * WordPress dependencies
  11939. */
  11940. const stretchFullWidth = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  11941. xmlns: "http://www.w3.org/2000/svg",
  11942. viewBox: "0 0 24 24"
  11943. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  11944. d: "M5 4v11h14V4H5zm3 15.8h8v-1.5H8v1.5z"
  11945. }));
  11946. /* harmony default export */ var stretch_full_width = (stretchFullWidth);
  11947. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/constants.js
  11948. /**
  11949. * WordPress dependencies
  11950. */
  11951. const constants_BLOCK_ALIGNMENTS_CONTROLS = {
  11952. none: {
  11953. icon: align_none,
  11954. title: (0,external_wp_i18n_namespaceObject._x)('None', 'Alignment option')
  11955. },
  11956. left: {
  11957. icon: position_left,
  11958. title: (0,external_wp_i18n_namespaceObject.__)('Align left')
  11959. },
  11960. center: {
  11961. icon: position_center,
  11962. title: (0,external_wp_i18n_namespaceObject.__)('Align center')
  11963. },
  11964. right: {
  11965. icon: position_right,
  11966. title: (0,external_wp_i18n_namespaceObject.__)('Align right')
  11967. },
  11968. wide: {
  11969. icon: stretch_wide,
  11970. title: (0,external_wp_i18n_namespaceObject.__)('Wide width')
  11971. },
  11972. full: {
  11973. icon: stretch_full_width,
  11974. title: (0,external_wp_i18n_namespaceObject.__)('Full width')
  11975. }
  11976. };
  11977. const constants_DEFAULT_CONTROL = 'none';
  11978. const constants_POPOVER_PROPS = {
  11979. isAlternate: true
  11980. };
  11981. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/ui.js
  11982. /**
  11983. * External dependencies
  11984. */
  11985. /**
  11986. * WordPress dependencies
  11987. */
  11988. /**
  11989. * Internal dependencies
  11990. */
  11991. function BlockAlignmentUI(_ref) {
  11992. let {
  11993. value,
  11994. onChange,
  11995. controls,
  11996. isToolbar,
  11997. isCollapsed = true
  11998. } = _ref;
  11999. const enabledControls = useAvailableAlignments(controls);
  12000. const hasEnabledControls = !!enabledControls.length;
  12001. if (!hasEnabledControls) {
  12002. return null;
  12003. }
  12004. function onChangeAlignment(align) {
  12005. onChange([value, 'none'].includes(align) ? undefined : align);
  12006. }
  12007. const activeAlignmentControl = constants_BLOCK_ALIGNMENTS_CONTROLS[value];
  12008. const defaultAlignmentControl = constants_BLOCK_ALIGNMENTS_CONTROLS[constants_DEFAULT_CONTROL];
  12009. const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
  12010. const commonProps = {
  12011. icon: activeAlignmentControl ? activeAlignmentControl.icon : defaultAlignmentControl.icon,
  12012. label: (0,external_wp_i18n_namespaceObject.__)('Align')
  12013. };
  12014. const extraProps = isToolbar ? {
  12015. isCollapsed,
  12016. controls: enabledControls.map(_ref2 => {
  12017. let {
  12018. name: controlName
  12019. } = _ref2;
  12020. return { ...constants_BLOCK_ALIGNMENTS_CONTROLS[controlName],
  12021. isActive: value === controlName || !value && controlName === 'none',
  12022. role: isCollapsed ? 'menuitemradio' : undefined,
  12023. onClick: () => onChangeAlignment(controlName)
  12024. };
  12025. })
  12026. } : {
  12027. toggleProps: {
  12028. describedBy: (0,external_wp_i18n_namespaceObject.__)('Change alignment')
  12029. },
  12030. popoverProps: constants_POPOVER_PROPS,
  12031. children: _ref3 => {
  12032. let {
  12033. onClose
  12034. } = _ref3;
  12035. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  12036. className: "block-editor-block-alignment-control__menu-group"
  12037. }, enabledControls.map(_ref4 => {
  12038. let {
  12039. name: controlName,
  12040. info
  12041. } = _ref4;
  12042. const {
  12043. icon,
  12044. title
  12045. } = constants_BLOCK_ALIGNMENTS_CONTROLS[controlName]; // If no value is provided, mark as selected the `none` option.
  12046. const isSelected = controlName === value || !value && controlName === 'none';
  12047. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  12048. key: controlName,
  12049. icon: icon,
  12050. iconPosition: "left",
  12051. className: classnames_default()('components-dropdown-menu__menu-item', {
  12052. 'is-active': isSelected
  12053. }),
  12054. isSelected: isSelected,
  12055. onClick: () => {
  12056. onChangeAlignment(controlName);
  12057. onClose();
  12058. },
  12059. role: "menuitemradio",
  12060. info: info
  12061. }, title);
  12062. })));
  12063. }
  12064. };
  12065. return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({}, commonProps, extraProps));
  12066. }
  12067. /* harmony default export */ var block_alignment_control_ui = (BlockAlignmentUI);
  12068. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/index.js
  12069. /**
  12070. * Internal dependencies
  12071. */
  12072. const BlockAlignmentControl = props => {
  12073. return (0,external_wp_element_namespaceObject.createElement)(block_alignment_control_ui, _extends({}, props, {
  12074. isToolbar: false
  12075. }));
  12076. };
  12077. const BlockAlignmentToolbar = props => {
  12078. return (0,external_wp_element_namespaceObject.createElement)(block_alignment_control_ui, _extends({}, props, {
  12079. isToolbar: true
  12080. }));
  12081. };
  12082. /**
  12083. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-alignment-control/README.md
  12084. */
  12085. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/align.js
  12086. /**
  12087. * External dependencies
  12088. */
  12089. /**
  12090. * WordPress dependencies
  12091. */
  12092. /**
  12093. * Internal dependencies
  12094. */
  12095. /**
  12096. * An array which includes all possible valid alignments,
  12097. * used to validate if an alignment is valid or not.
  12098. *
  12099. * @constant
  12100. * @type {string[]}
  12101. */
  12102. const ALL_ALIGNMENTS = ['left', 'center', 'right', 'wide', 'full'];
  12103. /**
  12104. * An array which includes all wide alignments.
  12105. * In order for this alignments to be valid they need to be supported by the block,
  12106. * and by the theme.
  12107. *
  12108. * @constant
  12109. * @type {string[]}
  12110. */
  12111. const WIDE_ALIGNMENTS = ['wide', 'full'];
  12112. /**
  12113. * Returns the valid alignments.
  12114. * Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not.
  12115. * Exported just for testing purposes, not exported outside the module.
  12116. *
  12117. * @param {?boolean|string[]} blockAlign Aligns supported by the block.
  12118. * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise.
  12119. * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise.
  12120. *
  12121. * @return {string[]} Valid alignments.
  12122. */
  12123. function getValidAlignments(blockAlign) {
  12124. let hasWideBlockSupport = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  12125. let hasWideEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  12126. let validAlignments;
  12127. if (Array.isArray(blockAlign)) {
  12128. validAlignments = ALL_ALIGNMENTS.filter(value => blockAlign.includes(value));
  12129. } else if (blockAlign === true) {
  12130. // `true` includes all alignments...
  12131. validAlignments = [...ALL_ALIGNMENTS];
  12132. } else {
  12133. validAlignments = [];
  12134. }
  12135. if (!hasWideEnabled || blockAlign === true && !hasWideBlockSupport) {
  12136. return (0,external_lodash_namespaceObject.without)(validAlignments, ...WIDE_ALIGNMENTS);
  12137. }
  12138. return validAlignments;
  12139. }
  12140. /**
  12141. * Filters registered block settings, extending attributes to include `align`.
  12142. *
  12143. * @param {Object} settings Original block settings.
  12144. *
  12145. * @return {Object} Filtered block settings.
  12146. */
  12147. function addAttribute(settings) {
  12148. var _settings$attributes$, _settings$attributes;
  12149. // Allow blocks to specify their own attribute definition with default values if needed.
  12150. if ('type' in ((_settings$attributes$ = (_settings$attributes = settings.attributes) === null || _settings$attributes === void 0 ? void 0 : _settings$attributes.align) !== null && _settings$attributes$ !== void 0 ? _settings$attributes$ : {})) {
  12151. return settings;
  12152. }
  12153. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'align')) {
  12154. // Gracefully handle if settings.attributes is undefined.
  12155. settings.attributes = { ...settings.attributes,
  12156. align: {
  12157. type: 'string',
  12158. // Allow for '' since it is used by updateAlignment function
  12159. // in withToolbarControls for special cases with defined default values.
  12160. enum: [...ALL_ALIGNMENTS, '']
  12161. }
  12162. };
  12163. }
  12164. return settings;
  12165. }
  12166. /**
  12167. * Override the default edit UI to include new toolbar controls for block
  12168. * alignment, if block defines support.
  12169. *
  12170. * @param {Function} BlockEdit Original component.
  12171. *
  12172. * @return {Function} Wrapped component.
  12173. */
  12174. const withToolbarControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  12175. const blockEdit = (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
  12176. const {
  12177. name: blockName
  12178. } = props; // Compute the block valid alignments by taking into account,
  12179. // if the theme supports wide alignments or not and the layout's
  12180. // availble alignments. We do that for conditionally rendering
  12181. // Slot.
  12182. const blockAllowedAlignments = getValidAlignments((0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, 'align'), (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'alignWide', true));
  12183. const validAlignments = useAvailableAlignments(blockAllowedAlignments).map(_ref => {
  12184. let {
  12185. name
  12186. } = _ref;
  12187. return name;
  12188. });
  12189. const isContentLocked = (0,external_wp_data_namespaceObject.useSelect)(select => {
  12190. return select(store).__unstableGetContentLockingParent(props.clientId);
  12191. }, [props.clientId]);
  12192. if (!validAlignments.length || isContentLocked) {
  12193. return blockEdit;
  12194. }
  12195. const updateAlignment = nextAlign => {
  12196. if (!nextAlign) {
  12197. var _blockType$attributes, _blockType$attributes2;
  12198. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(props.name);
  12199. const blockDefaultAlign = blockType === null || blockType === void 0 ? void 0 : (_blockType$attributes = blockType.attributes) === null || _blockType$attributes === void 0 ? void 0 : (_blockType$attributes2 = _blockType$attributes.align) === null || _blockType$attributes2 === void 0 ? void 0 : _blockType$attributes2.default;
  12200. if (blockDefaultAlign) {
  12201. nextAlign = '';
  12202. }
  12203. }
  12204. props.setAttributes({
  12205. align: nextAlign
  12206. });
  12207. };
  12208. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_controls, {
  12209. group: "block",
  12210. __experimentalShareWithChildBlocks: true
  12211. }, (0,external_wp_element_namespaceObject.createElement)(BlockAlignmentControl, {
  12212. value: props.attributes.align,
  12213. onChange: updateAlignment,
  12214. controls: validAlignments
  12215. })), blockEdit);
  12216. }, 'withToolbarControls');
  12217. /**
  12218. * Override the default block element to add alignment wrapper props.
  12219. *
  12220. * @param {Function} BlockListBlock Original component.
  12221. *
  12222. * @return {Function} Wrapped component.
  12223. */
  12224. const withDataAlign = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  12225. const {
  12226. name,
  12227. attributes
  12228. } = props;
  12229. const {
  12230. align
  12231. } = attributes;
  12232. const blockAllowedAlignments = getValidAlignments((0,external_wp_blocks_namespaceObject.getBlockSupport)(name, 'align'), (0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, 'alignWide', true));
  12233. const validAlignments = useAvailableAlignments(blockAllowedAlignments); // If an alignment is not assigned, there's no need to go through the
  12234. // effort to validate or assign its value.
  12235. if (align === undefined) {
  12236. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
  12237. }
  12238. let wrapperProps = props.wrapperProps;
  12239. if (validAlignments.some(alignment => alignment.name === align)) {
  12240. wrapperProps = { ...wrapperProps,
  12241. 'data-align': align
  12242. };
  12243. }
  12244. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  12245. wrapperProps: wrapperProps
  12246. }));
  12247. });
  12248. /**
  12249. * Override props assigned to save component to inject alignment class name if
  12250. * block supports it.
  12251. *
  12252. * @param {Object} props Additional props applied to save element.
  12253. * @param {Object} blockType Block type.
  12254. * @param {Object} attributes Block attributes.
  12255. *
  12256. * @return {Object} Filtered props applied to save element.
  12257. */
  12258. function addAssignedAlign(props, blockType, attributes) {
  12259. const {
  12260. align
  12261. } = attributes;
  12262. const blockAlign = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, 'align');
  12263. const hasWideBlockSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'alignWide', true); // Compute valid alignments without taking into account if
  12264. // the theme supports wide alignments or not.
  12265. // This way changing themes does not impact the block save.
  12266. const isAlignValid = getValidAlignments(blockAlign, hasWideBlockSupport).includes(align);
  12267. if (isAlignValid) {
  12268. props.className = classnames_default()(`align${align}`, props.className);
  12269. }
  12270. return props;
  12271. }
  12272. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/align/addAttribute', addAttribute);
  12273. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/align/with-data-align', withDataAlign);
  12274. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/align/with-toolbar-controls', withToolbarControls);
  12275. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/align/addAssignedAlign', addAssignedAlign);
  12276. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/lock.js
  12277. /**
  12278. * WordPress dependencies
  12279. */
  12280. /**
  12281. * Filters registered block settings, extending attributes to include `lock`.
  12282. *
  12283. * @param {Object} settings Original block settings.
  12284. *
  12285. * @return {Object} Filtered block settings.
  12286. */
  12287. function lock_addAttribute(settings) {
  12288. var _settings$attributes$, _settings$attributes;
  12289. // Allow blocks to specify their own attribute definition with default values if needed.
  12290. if ('type' in ((_settings$attributes$ = (_settings$attributes = settings.attributes) === null || _settings$attributes === void 0 ? void 0 : _settings$attributes.lock) !== null && _settings$attributes$ !== void 0 ? _settings$attributes$ : {})) {
  12291. return settings;
  12292. } // Gracefully handle if settings.attributes is undefined.
  12293. settings.attributes = { ...settings.attributes,
  12294. lock: {
  12295. type: 'object'
  12296. }
  12297. };
  12298. return settings;
  12299. }
  12300. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/lock/addAttribute', lock_addAttribute);
  12301. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/anchor.js
  12302. /**
  12303. * WordPress dependencies
  12304. */
  12305. /**
  12306. * Internal dependencies
  12307. */
  12308. /**
  12309. * Regular expression matching invalid anchor characters for replacement.
  12310. *
  12311. * @type {RegExp}
  12312. */
  12313. const ANCHOR_REGEX = /[\s#]/g;
  12314. const ANCHOR_SCHEMA = {
  12315. type: 'string',
  12316. source: 'attribute',
  12317. attribute: 'id',
  12318. selector: '*'
  12319. };
  12320. /**
  12321. * Filters registered block settings, extending attributes with anchor using ID
  12322. * of the first node.
  12323. *
  12324. * @param {Object} settings Original block settings.
  12325. *
  12326. * @return {Object} Filtered block settings.
  12327. */
  12328. function anchor_addAttribute(settings) {
  12329. var _settings$attributes$, _settings$attributes;
  12330. // Allow blocks to specify their own attribute definition with default values if needed.
  12331. if ('type' in ((_settings$attributes$ = (_settings$attributes = settings.attributes) === null || _settings$attributes === void 0 ? void 0 : _settings$attributes.anchor) !== null && _settings$attributes$ !== void 0 ? _settings$attributes$ : {})) {
  12332. return settings;
  12333. }
  12334. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'anchor')) {
  12335. // Gracefully handle if settings.attributes is undefined.
  12336. settings.attributes = { ...settings.attributes,
  12337. anchor: ANCHOR_SCHEMA
  12338. };
  12339. }
  12340. return settings;
  12341. }
  12342. /**
  12343. * Override the default edit UI to include a new block inspector control for
  12344. * assigning the anchor ID, if block supports anchor.
  12345. *
  12346. * @param {WPComponent} BlockEdit Original component.
  12347. *
  12348. * @return {WPComponent} Wrapped component.
  12349. */
  12350. const withInspectorControl = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => {
  12351. return props => {
  12352. const hasAnchor = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'anchor');
  12353. if (hasAnchor && props.isSelected) {
  12354. const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web';
  12355. const textControl = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  12356. className: "html-anchor-control",
  12357. label: (0,external_wp_i18n_namespaceObject.__)('HTML anchor'),
  12358. help: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), isWeb && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  12359. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/page-jumps/')
  12360. }, (0,external_wp_i18n_namespaceObject.__)('Learn more about anchors'))),
  12361. value: props.attributes.anchor || '',
  12362. placeholder: !isWeb ? (0,external_wp_i18n_namespaceObject.__)('Add an anchor') : null,
  12363. onChange: nextValue => {
  12364. nextValue = nextValue.replace(ANCHOR_REGEX, '-');
  12365. props.setAttributes({
  12366. anchor: nextValue
  12367. });
  12368. },
  12369. autoCapitalize: "none",
  12370. autoComplete: "off"
  12371. });
  12372. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), isWeb && (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
  12373. __experimentalGroup: "advanced"
  12374. }, textControl), !isWeb && props.name === 'core/heading' && (0,external_wp_element_namespaceObject.createElement)(inspector_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  12375. title: (0,external_wp_i18n_namespaceObject.__)('Heading settings')
  12376. }, textControl)));
  12377. }
  12378. return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
  12379. };
  12380. }, 'withInspectorControl');
  12381. /**
  12382. * Override props assigned to save component to inject anchor ID, if block
  12383. * supports anchor. This is only applied if the block's save result is an
  12384. * element and not a markup string.
  12385. *
  12386. * @param {Object} extraProps Additional props applied to save element.
  12387. * @param {Object} blockType Block type.
  12388. * @param {Object} attributes Current block attributes.
  12389. *
  12390. * @return {Object} Filtered props applied to save element.
  12391. */
  12392. function addSaveProps(extraProps, blockType, attributes) {
  12393. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'anchor')) {
  12394. extraProps.id = attributes.anchor === '' ? null : attributes.anchor;
  12395. }
  12396. return extraProps;
  12397. }
  12398. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/anchor/attribute', anchor_addAttribute);
  12399. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/anchor/with-inspector-control', withInspectorControl);
  12400. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/anchor/save-props', addSaveProps);
  12401. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/aria-label.js
  12402. /**
  12403. * WordPress dependencies
  12404. */
  12405. const ARIA_LABEL_SCHEMA = {
  12406. type: 'string',
  12407. source: 'attribute',
  12408. attribute: 'aria-label',
  12409. selector: '*'
  12410. };
  12411. /**
  12412. * Filters registered block settings, extending attributes with ariaLabel using aria-label
  12413. * of the first node.
  12414. *
  12415. * @param {Object} settings Original block settings.
  12416. *
  12417. * @return {Object} Filtered block settings.
  12418. */
  12419. function aria_label_addAttribute(settings) {
  12420. var _settings$attributes, _settings$attributes$;
  12421. // Allow blocks to specify their own attribute definition with default values if needed.
  12422. if (settings !== null && settings !== void 0 && (_settings$attributes = settings.attributes) !== null && _settings$attributes !== void 0 && (_settings$attributes$ = _settings$attributes.ariaLabel) !== null && _settings$attributes$ !== void 0 && _settings$attributes$.type) {
  12423. return settings;
  12424. }
  12425. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'ariaLabel')) {
  12426. // Gracefully handle if settings.attributes is undefined.
  12427. settings.attributes = { ...settings.attributes,
  12428. ariaLabel: ARIA_LABEL_SCHEMA
  12429. };
  12430. }
  12431. return settings;
  12432. }
  12433. /**
  12434. * Override props assigned to save component to inject aria-label, if block
  12435. * supports ariaLabel. This is only applied if the block's save result is an
  12436. * element and not a markup string.
  12437. *
  12438. * @param {Object} extraProps Additional props applied to save element.
  12439. * @param {Object} blockType Block type.
  12440. * @param {Object} attributes Current block attributes.
  12441. *
  12442. * @return {Object} Filtered props applied to save element.
  12443. */
  12444. function aria_label_addSaveProps(extraProps, blockType, attributes) {
  12445. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'ariaLabel')) {
  12446. extraProps['aria-label'] = attributes.ariaLabel === '' ? null : attributes.ariaLabel;
  12447. }
  12448. return extraProps;
  12449. }
  12450. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/ariaLabel/attribute', aria_label_addAttribute);
  12451. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/ariaLabel/save-props', aria_label_addSaveProps);
  12452. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/custom-class-name.js
  12453. /**
  12454. * External dependencies
  12455. */
  12456. /**
  12457. * WordPress dependencies
  12458. */
  12459. /**
  12460. * Internal dependencies
  12461. */
  12462. /**
  12463. * Filters registered block settings, extending attributes with anchor using ID
  12464. * of the first node.
  12465. *
  12466. * @param {Object} settings Original block settings.
  12467. *
  12468. * @return {Object} Filtered block settings.
  12469. */
  12470. function custom_class_name_addAttribute(settings) {
  12471. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'customClassName', true)) {
  12472. // Gracefully handle if settings.attributes is undefined.
  12473. settings.attributes = { ...settings.attributes,
  12474. className: {
  12475. type: 'string'
  12476. }
  12477. };
  12478. }
  12479. return settings;
  12480. }
  12481. /**
  12482. * Override the default edit UI to include a new block inspector control for
  12483. * assigning the custom class name, if block supports custom class name.
  12484. *
  12485. * @param {WPComponent} BlockEdit Original component.
  12486. *
  12487. * @return {WPComponent} Wrapped component.
  12488. */
  12489. const custom_class_name_withInspectorControl = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => {
  12490. return props => {
  12491. const hasCustomClassName = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'customClassName', true);
  12492. if (hasCustomClassName && props.isSelected) {
  12493. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
  12494. __experimentalGroup: "advanced"
  12495. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  12496. autoComplete: "off",
  12497. label: (0,external_wp_i18n_namespaceObject.__)('Additional CSS class(es)'),
  12498. value: props.attributes.className || '',
  12499. onChange: nextValue => {
  12500. props.setAttributes({
  12501. className: nextValue !== '' ? nextValue : undefined
  12502. });
  12503. },
  12504. help: (0,external_wp_i18n_namespaceObject.__)('Separate multiple classes with spaces.')
  12505. })));
  12506. }
  12507. return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
  12508. };
  12509. }, 'withInspectorControl');
  12510. /**
  12511. * Override props assigned to save component to inject anchor ID, if block
  12512. * supports anchor. This is only applied if the block's save result is an
  12513. * element and not a markup string.
  12514. *
  12515. * @param {Object} extraProps Additional props applied to save element.
  12516. * @param {Object} blockType Block type.
  12517. * @param {Object} attributes Current block attributes.
  12518. *
  12519. * @return {Object} Filtered props applied to save element.
  12520. */
  12521. function custom_class_name_addSaveProps(extraProps, blockType, attributes) {
  12522. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'customClassName', true) && attributes.className) {
  12523. extraProps.className = classnames_default()(extraProps.className, attributes.className);
  12524. }
  12525. return extraProps;
  12526. }
  12527. function addTransforms(result, source, index, results) {
  12528. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(result.name, 'customClassName', true)) {
  12529. return result;
  12530. } // If the condition verifies we are probably in the presence of a wrapping transform
  12531. // e.g: nesting paragraphs in a group or columns and in that case the class should not be kept.
  12532. if (results.length === 1 && result.innerBlocks.length === source.length) {
  12533. return result;
  12534. } // If we are transforming one block to multiple blocks or multiple blocks to one block,
  12535. // we ignore the class during the transform.
  12536. if (results.length === 1 && source.length > 1 || results.length > 1 && source.length === 1) {
  12537. return result;
  12538. } // If we are in presence of transform between one or more block in the source
  12539. // that have one or more blocks in the result
  12540. // we apply the class on source N to the result N,
  12541. // if source N does not exists we do nothing.
  12542. if (source[index]) {
  12543. var _source$index;
  12544. const originClassName = (_source$index = source[index]) === null || _source$index === void 0 ? void 0 : _source$index.attributes.className;
  12545. if (originClassName) {
  12546. return { ...result,
  12547. attributes: { ...result.attributes,
  12548. className: originClassName
  12549. }
  12550. };
  12551. }
  12552. }
  12553. return result;
  12554. }
  12555. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/custom-class-name/attribute', custom_class_name_addAttribute);
  12556. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/custom-class-name/with-inspector-control', custom_class_name_withInspectorControl);
  12557. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/custom-class-name/save-props', custom_class_name_addSaveProps);
  12558. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.switchToBlockType.transformedBlock', 'core/color/addTransforms', addTransforms);
  12559. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/generated-class-name.js
  12560. /**
  12561. * WordPress dependencies
  12562. */
  12563. /**
  12564. * Override props assigned to save component to inject generated className if
  12565. * block supports it. This is only applied if the block's save result is an
  12566. * element and not a markup string.
  12567. *
  12568. * @param {Object} extraProps Additional props applied to save element.
  12569. * @param {Object} blockType Block type.
  12570. *
  12571. * @return {Object} Filtered props applied to save element.
  12572. */
  12573. function addGeneratedClassName(extraProps, blockType) {
  12574. // Adding the generated className.
  12575. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'className', true)) {
  12576. if (typeof extraProps.className === 'string') {
  12577. // We have some extra classes and want to add the default classname
  12578. // We use uniq to prevent duplicate classnames.
  12579. extraProps.className = [...new Set([(0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(blockType.name), ...extraProps.className.split(' ')])].join(' ').trim();
  12580. } else {
  12581. // There is no string in the className variable,
  12582. // so we just dump the default name in there.
  12583. extraProps.className = (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(blockType.name);
  12584. }
  12585. }
  12586. return extraProps;
  12587. }
  12588. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/generated-class-name/save-props', addGeneratedClassName);
  12589. ;// CONCATENATED MODULE: external ["wp","dom"]
  12590. var external_wp_dom_namespaceObject = window["wp"]["dom"];
  12591. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-context/index.js
  12592. /**
  12593. * WordPress dependencies
  12594. */
  12595. /** @typedef {import('react').ReactNode} ReactNode */
  12596. /**
  12597. * @typedef BlockContextProviderProps
  12598. *
  12599. * @property {Record<string,*>} value Context value to merge with current
  12600. * value.
  12601. * @property {ReactNode} children Component children.
  12602. */
  12603. /** @type {import('react').Context<Record<string,*>>} */
  12604. const block_context_Context = (0,external_wp_element_namespaceObject.createContext)({});
  12605. /**
  12606. * Component which merges passed value with current consumed block context.
  12607. *
  12608. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md
  12609. *
  12610. * @param {BlockContextProviderProps} props
  12611. */
  12612. function BlockContextProvider(_ref) {
  12613. let {
  12614. value,
  12615. children
  12616. } = _ref;
  12617. const context = (0,external_wp_element_namespaceObject.useContext)(block_context_Context);
  12618. const nextValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...context,
  12619. ...value
  12620. }), [context, value]);
  12621. return (0,external_wp_element_namespaceObject.createElement)(block_context_Context.Provider, {
  12622. value: nextValue,
  12623. children: children
  12624. });
  12625. }
  12626. /* harmony default export */ var block_context = (block_context_Context);
  12627. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/edit.js
  12628. /**
  12629. * External dependencies
  12630. */
  12631. /**
  12632. * WordPress dependencies
  12633. */
  12634. /**
  12635. * Internal dependencies
  12636. */
  12637. /**
  12638. * Default value used for blocks which do not define their own context needs,
  12639. * used to guarantee that a block's `context` prop will always be an object. It
  12640. * is assigned as a constant since it is always expected to be an empty object,
  12641. * and in order to avoid unnecessary React reconciliations of a changing object.
  12642. *
  12643. * @type {{}}
  12644. */
  12645. const DEFAULT_BLOCK_CONTEXT = {};
  12646. const Edit = props => {
  12647. const {
  12648. attributes = {},
  12649. name
  12650. } = props;
  12651. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
  12652. const blockContext = (0,external_wp_element_namespaceObject.useContext)(block_context); // Assign context values using the block type's declared context needs.
  12653. const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
  12654. return blockType && blockType.usesContext ? (0,external_lodash_namespaceObject.pick)(blockContext, blockType.usesContext) : DEFAULT_BLOCK_CONTEXT;
  12655. }, [blockType, blockContext]);
  12656. if (!blockType) {
  12657. return null;
  12658. } // `edit` and `save` are functions or components describing the markup
  12659. // with which a block is displayed. If `blockType` is valid, assign
  12660. // them preferentially as the render value for the block.
  12661. const Component = blockType.edit || blockType.save;
  12662. if (blockType.apiVersion > 1) {
  12663. return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({}, props, {
  12664. context: context
  12665. }));
  12666. } // Generate a class name for the block's editable form.
  12667. const generatedClassName = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'className', true) ? (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name) : null;
  12668. const className = classnames_default()(generatedClassName, attributes.className, props.className);
  12669. return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({}, props, {
  12670. context: context,
  12671. className: className
  12672. }));
  12673. };
  12674. /* harmony default export */ var edit = ((0,external_wp_components_namespaceObject.withFilters)('editor.BlockEdit')(Edit));
  12675. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/index.js
  12676. /**
  12677. * WordPress dependencies
  12678. */
  12679. /**
  12680. * Internal dependencies
  12681. */
  12682. /**
  12683. * The `useBlockEditContext` hook provides information about the block this hook is being used in.
  12684. * It returns an object with the `name`, `isSelected` state, and the `clientId` of the block.
  12685. * It is useful if you want to create custom hooks that need access to the current blocks clientId
  12686. * but don't want to rely on the data getting passed in as a parameter.
  12687. *
  12688. * @return {Object} Block edit context
  12689. */
  12690. function BlockEdit(props) {
  12691. const {
  12692. name,
  12693. isSelected,
  12694. clientId
  12695. } = props;
  12696. const context = {
  12697. name,
  12698. isSelected,
  12699. clientId
  12700. };
  12701. return (0,external_wp_element_namespaceObject.createElement)(Provider // It is important to return the same object if props haven't
  12702. // changed to avoid unnecessary rerenders.
  12703. // See https://reactjs.org/docs/context.html#caveats.
  12704. , {
  12705. value: (0,external_wp_element_namespaceObject.useMemo)(() => context, Object.values(context))
  12706. }, (0,external_wp_element_namespaceObject.createElement)(edit, props));
  12707. }
  12708. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-horizontal.js
  12709. /**
  12710. * WordPress dependencies
  12711. */
  12712. const moreHorizontal = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  12713. xmlns: "http://www.w3.org/2000/svg",
  12714. viewBox: "0 0 24 24"
  12715. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  12716. d: "M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"
  12717. }));
  12718. /* harmony default export */ var more_horizontal = (moreHorizontal);
  12719. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/warning/index.js
  12720. /**
  12721. * External dependencies
  12722. */
  12723. /**
  12724. * WordPress dependencies
  12725. */
  12726. function Warning(_ref) {
  12727. let {
  12728. className,
  12729. actions,
  12730. children,
  12731. secondaryActions
  12732. } = _ref;
  12733. return (0,external_wp_element_namespaceObject.createElement)("div", {
  12734. style: {
  12735. display: 'contents',
  12736. all: 'initial'
  12737. }
  12738. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  12739. className: classnames_default()(className, 'block-editor-warning')
  12740. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  12741. className: "block-editor-warning__contents"
  12742. }, (0,external_wp_element_namespaceObject.createElement)("p", {
  12743. className: "block-editor-warning__message"
  12744. }, children), (external_wp_element_namespaceObject.Children.count(actions) > 0 || secondaryActions) && (0,external_wp_element_namespaceObject.createElement)("div", {
  12745. className: "block-editor-warning__actions"
  12746. }, external_wp_element_namespaceObject.Children.count(actions) > 0 && external_wp_element_namespaceObject.Children.map(actions, (action, i) => (0,external_wp_element_namespaceObject.createElement)("span", {
  12747. key: i,
  12748. className: "block-editor-warning__action"
  12749. }, action)), secondaryActions && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
  12750. className: "block-editor-warning__secondary",
  12751. icon: more_horizontal,
  12752. label: (0,external_wp_i18n_namespaceObject.__)('More options'),
  12753. popoverProps: {
  12754. position: 'bottom left',
  12755. className: 'block-editor-warning__dropdown'
  12756. },
  12757. noIcons: true
  12758. }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, secondaryActions.map((item, pos) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  12759. onClick: item.onClick,
  12760. key: pos
  12761. }, item.title))))))));
  12762. }
  12763. /**
  12764. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
  12765. */
  12766. /* harmony default export */ var warning = (Warning);
  12767. // EXTERNAL MODULE: ./node_modules/diff/lib/diff/character.js
  12768. var character = __webpack_require__(1973);
  12769. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/block-view.js
  12770. /**
  12771. * WordPress dependencies
  12772. */
  12773. function BlockView(_ref) {
  12774. let {
  12775. title,
  12776. rawContent,
  12777. renderedContent,
  12778. action,
  12779. actionText,
  12780. className
  12781. } = _ref;
  12782. return (0,external_wp_element_namespaceObject.createElement)("div", {
  12783. className: className
  12784. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  12785. className: "block-editor-block-compare__content"
  12786. }, (0,external_wp_element_namespaceObject.createElement)("h2", {
  12787. className: "block-editor-block-compare__heading"
  12788. }, title), (0,external_wp_element_namespaceObject.createElement)("div", {
  12789. className: "block-editor-block-compare__html"
  12790. }, rawContent), (0,external_wp_element_namespaceObject.createElement)("div", {
  12791. className: "block-editor-block-compare__preview edit-post-visual-editor"
  12792. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, (0,external_wp_dom_namespaceObject.safeHTML)(renderedContent)))), (0,external_wp_element_namespaceObject.createElement)("div", {
  12793. className: "block-editor-block-compare__action"
  12794. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  12795. variant: "secondary",
  12796. tabIndex: "0",
  12797. onClick: action
  12798. }, actionText)));
  12799. }
  12800. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/index.js
  12801. /**
  12802. * External dependencies
  12803. */
  12804. // diff doesn't tree-shake correctly, so we import from the individual
  12805. // module here, to avoid including too much of the library
  12806. /**
  12807. * WordPress dependencies
  12808. */
  12809. /**
  12810. * Internal dependencies
  12811. */
  12812. function BlockCompare(_ref) {
  12813. let {
  12814. block,
  12815. onKeep,
  12816. onConvert,
  12817. convertor,
  12818. convertButtonText
  12819. } = _ref;
  12820. function getDifference(originalContent, newContent) {
  12821. const difference = (0,character/* diffChars */.Kx)(originalContent, newContent);
  12822. return difference.map((item, pos) => {
  12823. const classes = classnames_default()({
  12824. 'block-editor-block-compare__added': item.added,
  12825. 'block-editor-block-compare__removed': item.removed
  12826. });
  12827. return (0,external_wp_element_namespaceObject.createElement)("span", {
  12828. key: pos,
  12829. className: classes
  12830. }, item.value);
  12831. });
  12832. }
  12833. function getConvertedContent(convertedBlock) {
  12834. // The convertor may return an array of items or a single item.
  12835. const newBlocks = (0,external_lodash_namespaceObject.castArray)(convertedBlock); // Get converted block details.
  12836. const newContent = newBlocks.map(item => (0,external_wp_blocks_namespaceObject.getSaveContent)(item.name, item.attributes, item.innerBlocks));
  12837. return newContent.join('');
  12838. }
  12839. const converted = getConvertedContent(convertor(block));
  12840. const difference = getDifference(block.originalContent, converted);
  12841. return (0,external_wp_element_namespaceObject.createElement)("div", {
  12842. className: "block-editor-block-compare__wrapper"
  12843. }, (0,external_wp_element_namespaceObject.createElement)(BlockView, {
  12844. title: (0,external_wp_i18n_namespaceObject.__)('Current'),
  12845. className: "block-editor-block-compare__current",
  12846. action: onKeep,
  12847. actionText: (0,external_wp_i18n_namespaceObject.__)('Convert to HTML'),
  12848. rawContent: block.originalContent,
  12849. renderedContent: block.originalContent
  12850. }), (0,external_wp_element_namespaceObject.createElement)(BlockView, {
  12851. title: (0,external_wp_i18n_namespaceObject.__)('After Conversion'),
  12852. className: "block-editor-block-compare__converted",
  12853. action: onConvert,
  12854. actionText: convertButtonText,
  12855. rawContent: difference,
  12856. renderedContent: converted
  12857. }));
  12858. }
  12859. /* harmony default export */ var block_compare = (BlockCompare);
  12860. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-invalid-warning.js
  12861. /**
  12862. * WordPress dependencies
  12863. */
  12864. /**
  12865. * Internal dependencies
  12866. */
  12867. function BlockInvalidWarning(_ref) {
  12868. let {
  12869. convertToHTML,
  12870. convertToBlocks,
  12871. convertToClassic,
  12872. attemptBlockRecovery,
  12873. block
  12874. } = _ref;
  12875. const hasHTMLBlock = !!(0,external_wp_blocks_namespaceObject.getBlockType)('core/html');
  12876. const [compare, setCompare] = (0,external_wp_element_namespaceObject.useState)(false);
  12877. const onCompare = (0,external_wp_element_namespaceObject.useCallback)(() => setCompare(true), []);
  12878. const onCompareClose = (0,external_wp_element_namespaceObject.useCallback)(() => setCompare(false), []); // We memo the array here to prevent the children components from being updated unexpectedly.
  12879. const hiddenActions = (0,external_wp_element_namespaceObject.useMemo)(() => [{
  12880. // translators: Button to fix block content
  12881. title: (0,external_wp_i18n_namespaceObject._x)('Resolve', 'imperative verb'),
  12882. onClick: onCompare
  12883. }, hasHTMLBlock && {
  12884. title: (0,external_wp_i18n_namespaceObject.__)('Convert to HTML'),
  12885. onClick: convertToHTML
  12886. }, {
  12887. title: (0,external_wp_i18n_namespaceObject.__)('Convert to Classic Block'),
  12888. onClick: convertToClassic
  12889. }].filter(Boolean), [onCompare, convertToHTML, convertToClassic]);
  12890. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(warning, {
  12891. actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  12892. key: "recover",
  12893. onClick: attemptBlockRecovery,
  12894. variant: "primary"
  12895. }, (0,external_wp_i18n_namespaceObject.__)('Attempt Block Recovery'))],
  12896. secondaryActions: hiddenActions
  12897. }, (0,external_wp_i18n_namespaceObject.__)('This block contains unexpected or invalid content.')), compare && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
  12898. title: // translators: Dialog title to fix block content
  12899. (0,external_wp_i18n_namespaceObject.__)('Resolve Block'),
  12900. onRequestClose: onCompareClose,
  12901. className: "block-editor-block-compare"
  12902. }, (0,external_wp_element_namespaceObject.createElement)(block_compare, {
  12903. block: block,
  12904. onKeep: convertToHTML,
  12905. onConvert: convertToBlocks,
  12906. convertor: blockToBlocks,
  12907. convertButtonText: (0,external_wp_i18n_namespaceObject.__)('Convert to Blocks')
  12908. })));
  12909. }
  12910. const blockToClassic = block => (0,external_wp_blocks_namespaceObject.createBlock)('core/freeform', {
  12911. content: block.originalContent
  12912. });
  12913. const blockToHTML = block => (0,external_wp_blocks_namespaceObject.createBlock)('core/html', {
  12914. content: block.originalContent
  12915. });
  12916. const blockToBlocks = block => (0,external_wp_blocks_namespaceObject.rawHandler)({
  12917. HTML: block.originalContent
  12918. });
  12919. const recoverBlock = _ref2 => {
  12920. let {
  12921. name,
  12922. attributes,
  12923. innerBlocks
  12924. } = _ref2;
  12925. return (0,external_wp_blocks_namespaceObject.createBlock)(name, attributes, innerBlocks);
  12926. };
  12927. /* harmony default export */ var block_invalid_warning = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref3) => {
  12928. let {
  12929. clientId
  12930. } = _ref3;
  12931. return {
  12932. block: select(store).getBlock(clientId)
  12933. };
  12934. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref4) => {
  12935. let {
  12936. block
  12937. } = _ref4;
  12938. const {
  12939. replaceBlock
  12940. } = dispatch(store);
  12941. return {
  12942. convertToClassic() {
  12943. replaceBlock(block.clientId, blockToClassic(block));
  12944. },
  12945. convertToHTML() {
  12946. replaceBlock(block.clientId, blockToHTML(block));
  12947. },
  12948. convertToBlocks() {
  12949. replaceBlock(block.clientId, blockToBlocks(block));
  12950. },
  12951. attemptBlockRecovery() {
  12952. replaceBlock(block.clientId, recoverBlock(block));
  12953. }
  12954. };
  12955. })])(BlockInvalidWarning));
  12956. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-warning.js
  12957. /**
  12958. * WordPress dependencies
  12959. */
  12960. /**
  12961. * Internal dependencies
  12962. */
  12963. const block_crash_warning_warning = (0,external_wp_element_namespaceObject.createElement)(warning, {
  12964. className: "block-editor-block-list__block-crash-warning"
  12965. }, (0,external_wp_i18n_namespaceObject.__)('This block has encountered an error and cannot be previewed.'));
  12966. /* harmony default export */ var block_crash_warning = (() => block_crash_warning_warning);
  12967. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-boundary.js
  12968. /**
  12969. * WordPress dependencies
  12970. */
  12971. class BlockCrashBoundary extends external_wp_element_namespaceObject.Component {
  12972. constructor() {
  12973. super(...arguments);
  12974. this.state = {
  12975. hasError: false
  12976. };
  12977. }
  12978. componentDidCatch() {
  12979. this.setState({
  12980. hasError: true
  12981. });
  12982. }
  12983. render() {
  12984. if (this.state.hasError) {
  12985. return this.props.fallback;
  12986. }
  12987. return this.props.children;
  12988. }
  12989. }
  12990. /* harmony default export */ var block_crash_boundary = (BlockCrashBoundary);
  12991. // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
  12992. var lib = __webpack_require__(773);
  12993. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-html.js
  12994. /**
  12995. * External dependencies
  12996. */
  12997. /**
  12998. * WordPress dependencies
  12999. */
  13000. /**
  13001. * Internal dependencies
  13002. */
  13003. function BlockHTML(_ref) {
  13004. let {
  13005. clientId
  13006. } = _ref;
  13007. const [html, setHtml] = (0,external_wp_element_namespaceObject.useState)('');
  13008. const block = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlock(clientId), [clientId]);
  13009. const {
  13010. updateBlock
  13011. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  13012. const onChange = () => {
  13013. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
  13014. if (!blockType) {
  13015. return;
  13016. }
  13017. const attributes = (0,external_wp_blocks_namespaceObject.getBlockAttributes)(blockType, html, block.attributes); // If html is empty we reset the block to the default HTML and mark it as valid to avoid triggering an error
  13018. const content = html ? html : (0,external_wp_blocks_namespaceObject.getSaveContent)(blockType, attributes);
  13019. const [isValid] = html ? (0,external_wp_blocks_namespaceObject.validateBlock)({ ...block,
  13020. attributes,
  13021. originalContent: content
  13022. }) : [true];
  13023. updateBlock(clientId, {
  13024. attributes,
  13025. originalContent: content,
  13026. isValid
  13027. }); // Ensure the state is updated if we reset so it displays the default content.
  13028. if (!html) {
  13029. setHtml({
  13030. content
  13031. });
  13032. }
  13033. };
  13034. (0,external_wp_element_namespaceObject.useEffect)(() => {
  13035. setHtml((0,external_wp_blocks_namespaceObject.getBlockContent)(block));
  13036. }, [block]);
  13037. return (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, {
  13038. className: "block-editor-block-list__block-html-textarea",
  13039. value: html,
  13040. onBlur: onChange,
  13041. onChange: event => setHtml(event.target.value)
  13042. });
  13043. }
  13044. /* harmony default export */ var block_html = (BlockHTML);
  13045. ;// CONCATENATED MODULE: ./node_modules/@react-spring/rafz/dist/react-spring-rafz.esm.js
  13046. let updateQueue = makeQueue();
  13047. const raf = fn => schedule(fn, updateQueue);
  13048. let writeQueue = makeQueue();
  13049. raf.write = fn => schedule(fn, writeQueue);
  13050. let onStartQueue = makeQueue();
  13051. raf.onStart = fn => schedule(fn, onStartQueue);
  13052. let onFrameQueue = makeQueue();
  13053. raf.onFrame = fn => schedule(fn, onFrameQueue);
  13054. let onFinishQueue = makeQueue();
  13055. raf.onFinish = fn => schedule(fn, onFinishQueue);
  13056. let timeouts = [];
  13057. raf.setTimeout = (handler, ms) => {
  13058. let time = raf.now() + ms;
  13059. let cancel = () => {
  13060. let i = timeouts.findIndex(t => t.cancel == cancel);
  13061. if (~i) timeouts.splice(i, 1);
  13062. pendingCount -= ~i ? 1 : 0;
  13063. };
  13064. let timeout = {
  13065. time,
  13066. handler,
  13067. cancel
  13068. };
  13069. timeouts.splice(findTimeout(time), 0, timeout);
  13070. pendingCount += 1;
  13071. start();
  13072. return timeout;
  13073. };
  13074. let findTimeout = time => ~(~timeouts.findIndex(t => t.time > time) || ~timeouts.length);
  13075. raf.cancel = fn => {
  13076. onStartQueue.delete(fn);
  13077. onFrameQueue.delete(fn);
  13078. onFinishQueue.delete(fn);
  13079. updateQueue.delete(fn);
  13080. writeQueue.delete(fn);
  13081. };
  13082. raf.sync = fn => {
  13083. sync = true;
  13084. raf.batchedUpdates(fn);
  13085. sync = false;
  13086. };
  13087. raf.throttle = fn => {
  13088. let lastArgs;
  13089. function queuedFn() {
  13090. try {
  13091. fn(...lastArgs);
  13092. } finally {
  13093. lastArgs = null;
  13094. }
  13095. }
  13096. function throttled(...args) {
  13097. lastArgs = args;
  13098. raf.onStart(queuedFn);
  13099. }
  13100. throttled.handler = fn;
  13101. throttled.cancel = () => {
  13102. onStartQueue.delete(queuedFn);
  13103. lastArgs = null;
  13104. };
  13105. return throttled;
  13106. };
  13107. let nativeRaf = typeof window != 'undefined' ? window.requestAnimationFrame : () => {};
  13108. raf.use = impl => nativeRaf = impl;
  13109. raf.now = typeof performance != 'undefined' ? () => performance.now() : Date.now;
  13110. raf.batchedUpdates = fn => fn();
  13111. raf.catch = console.error;
  13112. raf.frameLoop = 'always';
  13113. raf.advance = () => {
  13114. if (raf.frameLoop !== 'demand') {
  13115. console.warn('Cannot call the manual advancement of rafz whilst frameLoop is not set as demand');
  13116. } else {
  13117. update();
  13118. }
  13119. };
  13120. let ts = -1;
  13121. let pendingCount = 0;
  13122. let sync = false;
  13123. function schedule(fn, queue) {
  13124. if (sync) {
  13125. queue.delete(fn);
  13126. fn(0);
  13127. } else {
  13128. queue.add(fn);
  13129. start();
  13130. }
  13131. }
  13132. function start() {
  13133. if (ts < 0) {
  13134. ts = 0;
  13135. if (raf.frameLoop !== 'demand') {
  13136. nativeRaf(loop);
  13137. }
  13138. }
  13139. }
  13140. function stop() {
  13141. ts = -1;
  13142. }
  13143. function loop() {
  13144. if (~ts) {
  13145. nativeRaf(loop);
  13146. raf.batchedUpdates(update);
  13147. }
  13148. }
  13149. function update() {
  13150. let prevTs = ts;
  13151. ts = raf.now();
  13152. let count = findTimeout(ts);
  13153. if (count) {
  13154. eachSafely(timeouts.splice(0, count), t => t.handler());
  13155. pendingCount -= count;
  13156. }
  13157. if (!pendingCount) {
  13158. stop();
  13159. return;
  13160. }
  13161. onStartQueue.flush();
  13162. updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
  13163. onFrameQueue.flush();
  13164. writeQueue.flush();
  13165. onFinishQueue.flush();
  13166. }
  13167. function makeQueue() {
  13168. let next = new Set();
  13169. let current = next;
  13170. return {
  13171. add(fn) {
  13172. pendingCount += current == next && !next.has(fn) ? 1 : 0;
  13173. next.add(fn);
  13174. },
  13175. delete(fn) {
  13176. pendingCount -= current == next && next.has(fn) ? 1 : 0;
  13177. return next.delete(fn);
  13178. },
  13179. flush(arg) {
  13180. if (current.size) {
  13181. next = new Set();
  13182. pendingCount -= current.size;
  13183. eachSafely(current, fn => fn(arg) && next.add(fn));
  13184. pendingCount += next.size;
  13185. current = next;
  13186. }
  13187. }
  13188. };
  13189. }
  13190. function eachSafely(values, each) {
  13191. values.forEach(value => {
  13192. try {
  13193. each(value);
  13194. } catch (e) {
  13195. raf.catch(e);
  13196. }
  13197. });
  13198. }
  13199. const __raf = {
  13200. count() {
  13201. return pendingCount;
  13202. },
  13203. isRunning() {
  13204. return ts >= 0;
  13205. },
  13206. clear() {
  13207. ts = -1;
  13208. timeouts = [];
  13209. onStartQueue = makeQueue();
  13210. updateQueue = makeQueue();
  13211. onFrameQueue = makeQueue();
  13212. writeQueue = makeQueue();
  13213. onFinishQueue = makeQueue();
  13214. pendingCount = 0;
  13215. }
  13216. };
  13217. // EXTERNAL MODULE: external "React"
  13218. var external_React_ = __webpack_require__(9196);
  13219. var external_React_default = /*#__PURE__*/__webpack_require__.n(external_React_);
  13220. ;// CONCATENATED MODULE: ./node_modules/@react-spring/shared/dist/react-spring-shared.esm.js
  13221. function noop() {}
  13222. const defineHidden = (obj, key, value) => Object.defineProperty(obj, key, {
  13223. value,
  13224. writable: true,
  13225. configurable: true
  13226. });
  13227. const react_spring_shared_esm_is = {
  13228. arr: Array.isArray,
  13229. obj: a => !!a && a.constructor.name === 'Object',
  13230. fun: a => typeof a === 'function',
  13231. str: a => typeof a === 'string',
  13232. num: a => typeof a === 'number',
  13233. und: a => a === undefined
  13234. };
  13235. function isEqual(a, b) {
  13236. if (react_spring_shared_esm_is.arr(a)) {
  13237. if (!react_spring_shared_esm_is.arr(b) || a.length !== b.length) return false;
  13238. for (let i = 0; i < a.length; i++) {
  13239. if (a[i] !== b[i]) return false;
  13240. }
  13241. return true;
  13242. }
  13243. return a === b;
  13244. }
  13245. const react_spring_shared_esm_each = (obj, fn) => obj.forEach(fn);
  13246. function eachProp(obj, fn, ctx) {
  13247. if (react_spring_shared_esm_is.arr(obj)) {
  13248. for (let i = 0; i < obj.length; i++) {
  13249. fn.call(ctx, obj[i], `${i}`);
  13250. }
  13251. return;
  13252. }
  13253. for (const key in obj) {
  13254. if (obj.hasOwnProperty(key)) {
  13255. fn.call(ctx, obj[key], key);
  13256. }
  13257. }
  13258. }
  13259. const react_spring_shared_esm_toArray = a => react_spring_shared_esm_is.und(a) ? [] : react_spring_shared_esm_is.arr(a) ? a : [a];
  13260. function flush(queue, iterator) {
  13261. if (queue.size) {
  13262. const items = Array.from(queue);
  13263. queue.clear();
  13264. react_spring_shared_esm_each(items, iterator);
  13265. }
  13266. }
  13267. const flushCalls = (queue, ...args) => flush(queue, fn => fn(...args));
  13268. const isSSR = () => typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
  13269. let createStringInterpolator$1;
  13270. let to;
  13271. let colors$1 = null;
  13272. let skipAnimation = false;
  13273. let willAdvance = noop;
  13274. const react_spring_shared_esm_assign = globals => {
  13275. if (globals.to) to = globals.to;
  13276. if (globals.now) raf.now = globals.now;
  13277. if (globals.colors !== undefined) colors$1 = globals.colors;
  13278. if (globals.skipAnimation != null) skipAnimation = globals.skipAnimation;
  13279. if (globals.createStringInterpolator) createStringInterpolator$1 = globals.createStringInterpolator;
  13280. if (globals.requestAnimationFrame) raf.use(globals.requestAnimationFrame);
  13281. if (globals.batchedUpdates) raf.batchedUpdates = globals.batchedUpdates;
  13282. if (globals.willAdvance) willAdvance = globals.willAdvance;
  13283. if (globals.frameLoop) raf.frameLoop = globals.frameLoop;
  13284. };
  13285. var globals = /*#__PURE__*/Object.freeze({
  13286. __proto__: null,
  13287. get createStringInterpolator () { return createStringInterpolator$1; },
  13288. get to () { return to; },
  13289. get colors () { return colors$1; },
  13290. get skipAnimation () { return skipAnimation; },
  13291. get willAdvance () { return willAdvance; },
  13292. assign: react_spring_shared_esm_assign
  13293. });
  13294. const startQueue = new Set();
  13295. let currentFrame = [];
  13296. let prevFrame = [];
  13297. let priority = 0;
  13298. const frameLoop = {
  13299. get idle() {
  13300. return !startQueue.size && !currentFrame.length;
  13301. },
  13302. start(animation) {
  13303. if (priority > animation.priority) {
  13304. startQueue.add(animation);
  13305. raf.onStart(flushStartQueue);
  13306. } else {
  13307. startSafely(animation);
  13308. raf(advance);
  13309. }
  13310. },
  13311. advance,
  13312. sort(animation) {
  13313. if (priority) {
  13314. raf.onFrame(() => frameLoop.sort(animation));
  13315. } else {
  13316. const prevIndex = currentFrame.indexOf(animation);
  13317. if (~prevIndex) {
  13318. currentFrame.splice(prevIndex, 1);
  13319. startUnsafely(animation);
  13320. }
  13321. }
  13322. },
  13323. clear() {
  13324. currentFrame = [];
  13325. startQueue.clear();
  13326. }
  13327. };
  13328. function flushStartQueue() {
  13329. startQueue.forEach(startSafely);
  13330. startQueue.clear();
  13331. raf(advance);
  13332. }
  13333. function startSafely(animation) {
  13334. if (!currentFrame.includes(animation)) startUnsafely(animation);
  13335. }
  13336. function startUnsafely(animation) {
  13337. currentFrame.splice(findIndex(currentFrame, other => other.priority > animation.priority), 0, animation);
  13338. }
  13339. function advance(dt) {
  13340. const nextFrame = prevFrame;
  13341. for (let i = 0; i < currentFrame.length; i++) {
  13342. const animation = currentFrame[i];
  13343. priority = animation.priority;
  13344. if (!animation.idle) {
  13345. willAdvance(animation);
  13346. animation.advance(dt);
  13347. if (!animation.idle) {
  13348. nextFrame.push(animation);
  13349. }
  13350. }
  13351. }
  13352. priority = 0;
  13353. prevFrame = currentFrame;
  13354. prevFrame.length = 0;
  13355. currentFrame = nextFrame;
  13356. return currentFrame.length > 0;
  13357. }
  13358. function findIndex(arr, test) {
  13359. const index = arr.findIndex(test);
  13360. return index < 0 ? arr.length : index;
  13361. }
  13362. const colors = {
  13363. transparent: 0x00000000,
  13364. aliceblue: 0xf0f8ffff,
  13365. antiquewhite: 0xfaebd7ff,
  13366. aqua: 0x00ffffff,
  13367. aquamarine: 0x7fffd4ff,
  13368. azure: 0xf0ffffff,
  13369. beige: 0xf5f5dcff,
  13370. bisque: 0xffe4c4ff,
  13371. black: 0x000000ff,
  13372. blanchedalmond: 0xffebcdff,
  13373. blue: 0x0000ffff,
  13374. blueviolet: 0x8a2be2ff,
  13375. brown: 0xa52a2aff,
  13376. burlywood: 0xdeb887ff,
  13377. burntsienna: 0xea7e5dff,
  13378. cadetblue: 0x5f9ea0ff,
  13379. chartreuse: 0x7fff00ff,
  13380. chocolate: 0xd2691eff,
  13381. coral: 0xff7f50ff,
  13382. cornflowerblue: 0x6495edff,
  13383. cornsilk: 0xfff8dcff,
  13384. crimson: 0xdc143cff,
  13385. cyan: 0x00ffffff,
  13386. darkblue: 0x00008bff,
  13387. darkcyan: 0x008b8bff,
  13388. darkgoldenrod: 0xb8860bff,
  13389. darkgray: 0xa9a9a9ff,
  13390. darkgreen: 0x006400ff,
  13391. darkgrey: 0xa9a9a9ff,
  13392. darkkhaki: 0xbdb76bff,
  13393. darkmagenta: 0x8b008bff,
  13394. darkolivegreen: 0x556b2fff,
  13395. darkorange: 0xff8c00ff,
  13396. darkorchid: 0x9932ccff,
  13397. darkred: 0x8b0000ff,
  13398. darksalmon: 0xe9967aff,
  13399. darkseagreen: 0x8fbc8fff,
  13400. darkslateblue: 0x483d8bff,
  13401. darkslategray: 0x2f4f4fff,
  13402. darkslategrey: 0x2f4f4fff,
  13403. darkturquoise: 0x00ced1ff,
  13404. darkviolet: 0x9400d3ff,
  13405. deeppink: 0xff1493ff,
  13406. deepskyblue: 0x00bfffff,
  13407. dimgray: 0x696969ff,
  13408. dimgrey: 0x696969ff,
  13409. dodgerblue: 0x1e90ffff,
  13410. firebrick: 0xb22222ff,
  13411. floralwhite: 0xfffaf0ff,
  13412. forestgreen: 0x228b22ff,
  13413. fuchsia: 0xff00ffff,
  13414. gainsboro: 0xdcdcdcff,
  13415. ghostwhite: 0xf8f8ffff,
  13416. gold: 0xffd700ff,
  13417. goldenrod: 0xdaa520ff,
  13418. gray: 0x808080ff,
  13419. green: 0x008000ff,
  13420. greenyellow: 0xadff2fff,
  13421. grey: 0x808080ff,
  13422. honeydew: 0xf0fff0ff,
  13423. hotpink: 0xff69b4ff,
  13424. indianred: 0xcd5c5cff,
  13425. indigo: 0x4b0082ff,
  13426. ivory: 0xfffff0ff,
  13427. khaki: 0xf0e68cff,
  13428. lavender: 0xe6e6faff,
  13429. lavenderblush: 0xfff0f5ff,
  13430. lawngreen: 0x7cfc00ff,
  13431. lemonchiffon: 0xfffacdff,
  13432. lightblue: 0xadd8e6ff,
  13433. lightcoral: 0xf08080ff,
  13434. lightcyan: 0xe0ffffff,
  13435. lightgoldenrodyellow: 0xfafad2ff,
  13436. lightgray: 0xd3d3d3ff,
  13437. lightgreen: 0x90ee90ff,
  13438. lightgrey: 0xd3d3d3ff,
  13439. lightpink: 0xffb6c1ff,
  13440. lightsalmon: 0xffa07aff,
  13441. lightseagreen: 0x20b2aaff,
  13442. lightskyblue: 0x87cefaff,
  13443. lightslategray: 0x778899ff,
  13444. lightslategrey: 0x778899ff,
  13445. lightsteelblue: 0xb0c4deff,
  13446. lightyellow: 0xffffe0ff,
  13447. lime: 0x00ff00ff,
  13448. limegreen: 0x32cd32ff,
  13449. linen: 0xfaf0e6ff,
  13450. magenta: 0xff00ffff,
  13451. maroon: 0x800000ff,
  13452. mediumaquamarine: 0x66cdaaff,
  13453. mediumblue: 0x0000cdff,
  13454. mediumorchid: 0xba55d3ff,
  13455. mediumpurple: 0x9370dbff,
  13456. mediumseagreen: 0x3cb371ff,
  13457. mediumslateblue: 0x7b68eeff,
  13458. mediumspringgreen: 0x00fa9aff,
  13459. mediumturquoise: 0x48d1ccff,
  13460. mediumvioletred: 0xc71585ff,
  13461. midnightblue: 0x191970ff,
  13462. mintcream: 0xf5fffaff,
  13463. mistyrose: 0xffe4e1ff,
  13464. moccasin: 0xffe4b5ff,
  13465. navajowhite: 0xffdeadff,
  13466. navy: 0x000080ff,
  13467. oldlace: 0xfdf5e6ff,
  13468. olive: 0x808000ff,
  13469. olivedrab: 0x6b8e23ff,
  13470. orange: 0xffa500ff,
  13471. orangered: 0xff4500ff,
  13472. orchid: 0xda70d6ff,
  13473. palegoldenrod: 0xeee8aaff,
  13474. palegreen: 0x98fb98ff,
  13475. paleturquoise: 0xafeeeeff,
  13476. palevioletred: 0xdb7093ff,
  13477. papayawhip: 0xffefd5ff,
  13478. peachpuff: 0xffdab9ff,
  13479. peru: 0xcd853fff,
  13480. pink: 0xffc0cbff,
  13481. plum: 0xdda0ddff,
  13482. powderblue: 0xb0e0e6ff,
  13483. purple: 0x800080ff,
  13484. rebeccapurple: 0x663399ff,
  13485. red: 0xff0000ff,
  13486. rosybrown: 0xbc8f8fff,
  13487. royalblue: 0x4169e1ff,
  13488. saddlebrown: 0x8b4513ff,
  13489. salmon: 0xfa8072ff,
  13490. sandybrown: 0xf4a460ff,
  13491. seagreen: 0x2e8b57ff,
  13492. seashell: 0xfff5eeff,
  13493. sienna: 0xa0522dff,
  13494. silver: 0xc0c0c0ff,
  13495. skyblue: 0x87ceebff,
  13496. slateblue: 0x6a5acdff,
  13497. slategray: 0x708090ff,
  13498. slategrey: 0x708090ff,
  13499. snow: 0xfffafaff,
  13500. springgreen: 0x00ff7fff,
  13501. steelblue: 0x4682b4ff,
  13502. tan: 0xd2b48cff,
  13503. teal: 0x008080ff,
  13504. thistle: 0xd8bfd8ff,
  13505. tomato: 0xff6347ff,
  13506. turquoise: 0x40e0d0ff,
  13507. violet: 0xee82eeff,
  13508. wheat: 0xf5deb3ff,
  13509. white: 0xffffffff,
  13510. whitesmoke: 0xf5f5f5ff,
  13511. yellow: 0xffff00ff,
  13512. yellowgreen: 0x9acd32ff
  13513. };
  13514. const NUMBER = '[-+]?\\d*\\.?\\d+';
  13515. const PERCENTAGE = NUMBER + '%';
  13516. function call(...parts) {
  13517. return '\\(\\s*(' + parts.join(')\\s*,\\s*(') + ')\\s*\\)';
  13518. }
  13519. const rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER));
  13520. const rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER));
  13521. const hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
  13522. const hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
  13523. const hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
  13524. const hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
  13525. const hex6 = /^#([0-9a-fA-F]{6})$/;
  13526. const hex8 = /^#([0-9a-fA-F]{8})$/;
  13527. function normalizeColor(color) {
  13528. let match;
  13529. if (typeof color === 'number') {
  13530. return color >>> 0 === color && color >= 0 && color <= 0xffffffff ? color : null;
  13531. }
  13532. if (match = hex6.exec(color)) return parseInt(match[1] + 'ff', 16) >>> 0;
  13533. if (colors$1 && colors$1[color] !== undefined) {
  13534. return colors$1[color];
  13535. }
  13536. if (match = rgb.exec(color)) {
  13537. return (parse255(match[1]) << 24 | parse255(match[2]) << 16 | parse255(match[3]) << 8 | 0x000000ff) >>> 0;
  13538. }
  13539. if (match = rgba.exec(color)) {
  13540. return (parse255(match[1]) << 24 | parse255(match[2]) << 16 | parse255(match[3]) << 8 | parse1(match[4])) >>> 0;
  13541. }
  13542. if (match = hex3.exec(color)) {
  13543. return parseInt(match[1] + match[1] + match[2] + match[2] + match[3] + match[3] + 'ff', 16) >>> 0;
  13544. }
  13545. if (match = hex8.exec(color)) return parseInt(match[1], 16) >>> 0;
  13546. if (match = hex4.exec(color)) {
  13547. return parseInt(match[1] + match[1] + match[2] + match[2] + match[3] + match[3] + match[4] + match[4], 16) >>> 0;
  13548. }
  13549. if (match = hsl.exec(color)) {
  13550. return (hslToRgb(parse360(match[1]), parsePercentage(match[2]), parsePercentage(match[3])) | 0x000000ff) >>> 0;
  13551. }
  13552. if (match = hsla.exec(color)) {
  13553. return (hslToRgb(parse360(match[1]), parsePercentage(match[2]), parsePercentage(match[3])) | parse1(match[4])) >>> 0;
  13554. }
  13555. return null;
  13556. }
  13557. function hue2rgb(p, q, t) {
  13558. if (t < 0) t += 1;
  13559. if (t > 1) t -= 1;
  13560. if (t < 1 / 6) return p + (q - p) * 6 * t;
  13561. if (t < 1 / 2) return q;
  13562. if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
  13563. return p;
  13564. }
  13565. function hslToRgb(h, s, l) {
  13566. const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  13567. const p = 2 * l - q;
  13568. const r = hue2rgb(p, q, h + 1 / 3);
  13569. const g = hue2rgb(p, q, h);
  13570. const b = hue2rgb(p, q, h - 1 / 3);
  13571. return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
  13572. }
  13573. function parse255(str) {
  13574. const int = parseInt(str, 10);
  13575. if (int < 0) return 0;
  13576. if (int > 255) return 255;
  13577. return int;
  13578. }
  13579. function parse360(str) {
  13580. const int = parseFloat(str);
  13581. return (int % 360 + 360) % 360 / 360;
  13582. }
  13583. function parse1(str) {
  13584. const num = parseFloat(str);
  13585. if (num < 0) return 0;
  13586. if (num > 1) return 255;
  13587. return Math.round(num * 255);
  13588. }
  13589. function parsePercentage(str) {
  13590. const int = parseFloat(str);
  13591. if (int < 0) return 0;
  13592. if (int > 100) return 1;
  13593. return int / 100;
  13594. }
  13595. function colorToRgba(input) {
  13596. let int32Color = normalizeColor(input);
  13597. if (int32Color === null) return input;
  13598. int32Color = int32Color || 0;
  13599. let r = (int32Color & 0xff000000) >>> 24;
  13600. let g = (int32Color & 0x00ff0000) >>> 16;
  13601. let b = (int32Color & 0x0000ff00) >>> 8;
  13602. let a = (int32Color & 0x000000ff) / 255;
  13603. return `rgba(${r}, ${g}, ${b}, ${a})`;
  13604. }
  13605. const createInterpolator = (range, output, extrapolate) => {
  13606. if (react_spring_shared_esm_is.fun(range)) {
  13607. return range;
  13608. }
  13609. if (react_spring_shared_esm_is.arr(range)) {
  13610. return createInterpolator({
  13611. range,
  13612. output: output,
  13613. extrapolate
  13614. });
  13615. }
  13616. if (react_spring_shared_esm_is.str(range.output[0])) {
  13617. return createStringInterpolator$1(range);
  13618. }
  13619. const config = range;
  13620. const outputRange = config.output;
  13621. const inputRange = config.range || [0, 1];
  13622. const extrapolateLeft = config.extrapolateLeft || config.extrapolate || 'extend';
  13623. const extrapolateRight = config.extrapolateRight || config.extrapolate || 'extend';
  13624. const easing = config.easing || (t => t);
  13625. return input => {
  13626. const range = findRange(input, inputRange);
  13627. return interpolate(input, inputRange[range], inputRange[range + 1], outputRange[range], outputRange[range + 1], easing, extrapolateLeft, extrapolateRight, config.map);
  13628. };
  13629. };
  13630. function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
  13631. let result = map ? map(input) : input;
  13632. if (result < inputMin) {
  13633. if (extrapolateLeft === 'identity') return result;else if (extrapolateLeft === 'clamp') result = inputMin;
  13634. }
  13635. if (result > inputMax) {
  13636. if (extrapolateRight === 'identity') return result;else if (extrapolateRight === 'clamp') result = inputMax;
  13637. }
  13638. if (outputMin === outputMax) return outputMin;
  13639. if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax;
  13640. if (inputMin === -Infinity) result = -result;else if (inputMax === Infinity) result = result - inputMin;else result = (result - inputMin) / (inputMax - inputMin);
  13641. result = easing(result);
  13642. if (outputMin === -Infinity) result = -result;else if (outputMax === Infinity) result = result + outputMin;else result = result * (outputMax - outputMin) + outputMin;
  13643. return result;
  13644. }
  13645. function findRange(input, inputRange) {
  13646. for (var i = 1; i < inputRange.length - 1; ++i) if (inputRange[i] >= input) break;
  13647. return i - 1;
  13648. }
  13649. function react_spring_shared_esm_extends() {
  13650. react_spring_shared_esm_extends = Object.assign ? Object.assign.bind() : function (target) {
  13651. for (var i = 1; i < arguments.length; i++) {
  13652. var source = arguments[i];
  13653. for (var key in source) {
  13654. if (Object.prototype.hasOwnProperty.call(source, key)) {
  13655. target[key] = source[key];
  13656. }
  13657. }
  13658. }
  13659. return target;
  13660. };
  13661. return react_spring_shared_esm_extends.apply(this, arguments);
  13662. }
  13663. const $get = Symbol.for('FluidValue.get');
  13664. const $observers = Symbol.for('FluidValue.observers');
  13665. const hasFluidValue = arg => Boolean(arg && arg[$get]);
  13666. const getFluidValue = arg => arg && arg[$get] ? arg[$get]() : arg;
  13667. const getFluidObservers = target => target[$observers] || null;
  13668. function callFluidObserver(observer, event) {
  13669. if (observer.eventObserved) {
  13670. observer.eventObserved(event);
  13671. } else {
  13672. observer(event);
  13673. }
  13674. }
  13675. function callFluidObservers(target, event) {
  13676. let observers = target[$observers];
  13677. if (observers) {
  13678. observers.forEach(observer => {
  13679. callFluidObserver(observer, event);
  13680. });
  13681. }
  13682. }
  13683. class FluidValue {
  13684. constructor(get) {
  13685. this[$get] = void 0;
  13686. this[$observers] = void 0;
  13687. if (!get && !(get = this.get)) {
  13688. throw Error('Unknown getter');
  13689. }
  13690. setFluidGetter(this, get);
  13691. }
  13692. }
  13693. const setFluidGetter = (target, get) => setHidden(target, $get, get);
  13694. function addFluidObserver(target, observer) {
  13695. if (target[$get]) {
  13696. let observers = target[$observers];
  13697. if (!observers) {
  13698. setHidden(target, $observers, observers = new Set());
  13699. }
  13700. if (!observers.has(observer)) {
  13701. observers.add(observer);
  13702. if (target.observerAdded) {
  13703. target.observerAdded(observers.size, observer);
  13704. }
  13705. }
  13706. }
  13707. return observer;
  13708. }
  13709. function removeFluidObserver(target, observer) {
  13710. let observers = target[$observers];
  13711. if (observers && observers.has(observer)) {
  13712. const count = observers.size - 1;
  13713. if (count) {
  13714. observers.delete(observer);
  13715. } else {
  13716. target[$observers] = null;
  13717. }
  13718. if (target.observerRemoved) {
  13719. target.observerRemoved(count, observer);
  13720. }
  13721. }
  13722. }
  13723. const setHidden = (target, key, value) => Object.defineProperty(target, key, {
  13724. value,
  13725. writable: true,
  13726. configurable: true
  13727. });
  13728. const numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
  13729. const colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
  13730. const unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, 'i');
  13731. const rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
  13732. const cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
  13733. const variableToRgba = input => {
  13734. const [token, fallback] = parseCSSVariable(input);
  13735. if (!token || isSSR()) {
  13736. return input;
  13737. }
  13738. const value = window.getComputedStyle(document.documentElement).getPropertyValue(token);
  13739. if (value) {
  13740. return value.trim();
  13741. } else if (fallback && fallback.startsWith('--')) {
  13742. const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback);
  13743. if (_value) {
  13744. return _value;
  13745. } else {
  13746. return input;
  13747. }
  13748. } else if (fallback && cssVariableRegex.test(fallback)) {
  13749. return variableToRgba(fallback);
  13750. } else if (fallback) {
  13751. return fallback;
  13752. }
  13753. return input;
  13754. };
  13755. const parseCSSVariable = current => {
  13756. const match = cssVariableRegex.exec(current);
  13757. if (!match) return [,];
  13758. const [, token, fallback] = match;
  13759. return [token, fallback];
  13760. };
  13761. let namedColorRegex;
  13762. const rgbaRound = (_, p1, p2, p3, p4) => `rgba(${Math.round(p1)}, ${Math.round(p2)}, ${Math.round(p3)}, ${p4})`;
  13763. const createStringInterpolator = config => {
  13764. if (!namedColorRegex) namedColorRegex = colors$1 ? new RegExp(`(${Object.keys(colors$1).join('|')})(?!\\w)`, 'g') : /^\b$/;
  13765. const output = config.output.map(value => {
  13766. return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba);
  13767. });
  13768. const keyframes = output.map(value => value.match(numberRegex).map(Number));
  13769. const outputRanges = keyframes[0].map((_, i) => keyframes.map(values => {
  13770. if (!(i in values)) {
  13771. throw Error('The arity of each "output" value must be equal');
  13772. }
  13773. return values[i];
  13774. }));
  13775. const interpolators = outputRanges.map(output => createInterpolator(react_spring_shared_esm_extends({}, config, {
  13776. output
  13777. })));
  13778. return input => {
  13779. var _output$find;
  13780. const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find(value => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, ''));
  13781. let i = 0;
  13782. return output[0].replace(numberRegex, () => `${interpolators[i++](input)}${missingUnit || ''}`).replace(rgbaRegex, rgbaRound);
  13783. };
  13784. };
  13785. const prefix = 'react-spring: ';
  13786. const once = fn => {
  13787. const func = fn;
  13788. let called = false;
  13789. if (typeof func != 'function') {
  13790. throw new TypeError(`${prefix}once requires a function parameter`);
  13791. }
  13792. return (...args) => {
  13793. if (!called) {
  13794. func(...args);
  13795. called = true;
  13796. }
  13797. };
  13798. };
  13799. const warnInterpolate = once(console.warn);
  13800. function react_spring_shared_esm_deprecateInterpolate() {
  13801. warnInterpolate(`${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`);
  13802. }
  13803. const warnDirectCall = once(console.warn);
  13804. function deprecateDirectCall() {
  13805. warnDirectCall(`${prefix}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`);
  13806. }
  13807. function isAnimatedString(value) {
  13808. return react_spring_shared_esm_is.str(value) && (value[0] == '#' || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {}));
  13809. }
  13810. const react_spring_shared_esm_useIsomorphicLayoutEffect = isSSR() ? external_React_.useEffect : external_React_.useLayoutEffect;
  13811. const useIsMounted = () => {
  13812. const isMounted = (0,external_React_.useRef)(false);
  13813. react_spring_shared_esm_useIsomorphicLayoutEffect(() => {
  13814. isMounted.current = true;
  13815. return () => {
  13816. isMounted.current = false;
  13817. };
  13818. }, []);
  13819. return isMounted;
  13820. };
  13821. function react_spring_shared_esm_useForceUpdate() {
  13822. const update = (0,external_React_.useState)()[1];
  13823. const isMounted = useIsMounted();
  13824. return () => {
  13825. if (isMounted.current) {
  13826. update(Math.random());
  13827. }
  13828. };
  13829. }
  13830. function useMemoOne(getResult, inputs) {
  13831. const [initial] = (0,external_React_.useState)(() => ({
  13832. inputs,
  13833. result: getResult()
  13834. }));
  13835. const committed = (0,external_React_.useRef)();
  13836. const prevCache = committed.current;
  13837. let cache = prevCache;
  13838. if (cache) {
  13839. const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs));
  13840. if (!useCache) {
  13841. cache = {
  13842. inputs,
  13843. result: getResult()
  13844. };
  13845. }
  13846. } else {
  13847. cache = initial;
  13848. }
  13849. (0,external_React_.useEffect)(() => {
  13850. committed.current = cache;
  13851. if (prevCache == initial) {
  13852. initial.inputs = initial.result = undefined;
  13853. }
  13854. }, [cache]);
  13855. return cache.result;
  13856. }
  13857. function areInputsEqual(next, prev) {
  13858. if (next.length !== prev.length) {
  13859. return false;
  13860. }
  13861. for (let i = 0; i < next.length; i++) {
  13862. if (next[i] !== prev[i]) {
  13863. return false;
  13864. }
  13865. }
  13866. return true;
  13867. }
  13868. const react_spring_shared_esm_useOnce = effect => (0,external_React_.useEffect)(effect, emptyDeps);
  13869. const emptyDeps = [];
  13870. function react_spring_shared_esm_usePrev(value) {
  13871. const prevRef = (0,external_React_.useRef)();
  13872. (0,external_React_.useEffect)(() => {
  13873. prevRef.current = value;
  13874. });
  13875. return prevRef.current;
  13876. }
  13877. const useReducedMotion = () => {
  13878. const [reducedMotion, setReducedMotion] = useState(null);
  13879. react_spring_shared_esm_useIsomorphicLayoutEffect(() => {
  13880. const mql = window.matchMedia('(prefers-reduced-motion)');
  13881. const handleMediaChange = e => {
  13882. setReducedMotion(e.matches);
  13883. react_spring_shared_esm_assign({
  13884. skipAnimation: e.matches
  13885. });
  13886. };
  13887. handleMediaChange(mql);
  13888. mql.addEventListener('change', handleMediaChange);
  13889. return () => {
  13890. mql.removeEventListener('change', handleMediaChange);
  13891. };
  13892. }, []);
  13893. return reducedMotion;
  13894. };
  13895. ;// CONCATENATED MODULE: ./node_modules/@react-spring/animated/dist/react-spring-animated.esm.js
  13896. const $node = Symbol.for('Animated:node');
  13897. const isAnimated = value => !!value && value[$node] === value;
  13898. const getAnimated = owner => owner && owner[$node];
  13899. const setAnimated = (owner, node) => defineHidden(owner, $node, node);
  13900. const getPayload = owner => owner && owner[$node] && owner[$node].getPayload();
  13901. class Animated {
  13902. constructor() {
  13903. this.payload = void 0;
  13904. setAnimated(this, this);
  13905. }
  13906. getPayload() {
  13907. return this.payload || [];
  13908. }
  13909. }
  13910. class AnimatedValue extends Animated {
  13911. constructor(_value) {
  13912. super();
  13913. this.done = true;
  13914. this.elapsedTime = void 0;
  13915. this.lastPosition = void 0;
  13916. this.lastVelocity = void 0;
  13917. this.v0 = void 0;
  13918. this.durationProgress = 0;
  13919. this._value = _value;
  13920. if (react_spring_shared_esm_is.num(this._value)) {
  13921. this.lastPosition = this._value;
  13922. }
  13923. }
  13924. static create(value) {
  13925. return new AnimatedValue(value);
  13926. }
  13927. getPayload() {
  13928. return [this];
  13929. }
  13930. getValue() {
  13931. return this._value;
  13932. }
  13933. setValue(value, step) {
  13934. if (react_spring_shared_esm_is.num(value)) {
  13935. this.lastPosition = value;
  13936. if (step) {
  13937. value = Math.round(value / step) * step;
  13938. if (this.done) {
  13939. this.lastPosition = value;
  13940. }
  13941. }
  13942. }
  13943. if (this._value === value) {
  13944. return false;
  13945. }
  13946. this._value = value;
  13947. return true;
  13948. }
  13949. reset() {
  13950. const {
  13951. done
  13952. } = this;
  13953. this.done = false;
  13954. if (react_spring_shared_esm_is.num(this._value)) {
  13955. this.elapsedTime = 0;
  13956. this.durationProgress = 0;
  13957. this.lastPosition = this._value;
  13958. if (done) this.lastVelocity = null;
  13959. this.v0 = null;
  13960. }
  13961. }
  13962. }
  13963. class AnimatedString extends AnimatedValue {
  13964. constructor(value) {
  13965. super(0);
  13966. this._string = null;
  13967. this._toString = void 0;
  13968. this._toString = createInterpolator({
  13969. output: [value, value]
  13970. });
  13971. }
  13972. static create(value) {
  13973. return new AnimatedString(value);
  13974. }
  13975. getValue() {
  13976. let value = this._string;
  13977. return value == null ? this._string = this._toString(this._value) : value;
  13978. }
  13979. setValue(value) {
  13980. if (react_spring_shared_esm_is.str(value)) {
  13981. if (value == this._string) {
  13982. return false;
  13983. }
  13984. this._string = value;
  13985. this._value = 1;
  13986. } else if (super.setValue(value)) {
  13987. this._string = null;
  13988. } else {
  13989. return false;
  13990. }
  13991. return true;
  13992. }
  13993. reset(goal) {
  13994. if (goal) {
  13995. this._toString = createInterpolator({
  13996. output: [this.getValue(), goal]
  13997. });
  13998. }
  13999. this._value = 0;
  14000. super.reset();
  14001. }
  14002. }
  14003. const TreeContext = {
  14004. dependencies: null
  14005. };
  14006. class AnimatedObject extends Animated {
  14007. constructor(source) {
  14008. super();
  14009. this.source = source;
  14010. this.setValue(source);
  14011. }
  14012. getValue(animated) {
  14013. const values = {};
  14014. eachProp(this.source, (source, key) => {
  14015. if (isAnimated(source)) {
  14016. values[key] = source.getValue(animated);
  14017. } else if (hasFluidValue(source)) {
  14018. values[key] = getFluidValue(source);
  14019. } else if (!animated) {
  14020. values[key] = source;
  14021. }
  14022. });
  14023. return values;
  14024. }
  14025. setValue(source) {
  14026. this.source = source;
  14027. this.payload = this._makePayload(source);
  14028. }
  14029. reset() {
  14030. if (this.payload) {
  14031. react_spring_shared_esm_each(this.payload, node => node.reset());
  14032. }
  14033. }
  14034. _makePayload(source) {
  14035. if (source) {
  14036. const payload = new Set();
  14037. eachProp(source, this._addToPayload, payload);
  14038. return Array.from(payload);
  14039. }
  14040. }
  14041. _addToPayload(source) {
  14042. if (TreeContext.dependencies && hasFluidValue(source)) {
  14043. TreeContext.dependencies.add(source);
  14044. }
  14045. const payload = getPayload(source);
  14046. if (payload) {
  14047. react_spring_shared_esm_each(payload, node => this.add(node));
  14048. }
  14049. }
  14050. }
  14051. class AnimatedArray extends AnimatedObject {
  14052. constructor(source) {
  14053. super(source);
  14054. }
  14055. static create(source) {
  14056. return new AnimatedArray(source);
  14057. }
  14058. getValue() {
  14059. return this.source.map(node => node.getValue());
  14060. }
  14061. setValue(source) {
  14062. const payload = this.getPayload();
  14063. if (source.length == payload.length) {
  14064. return payload.map((node, i) => node.setValue(source[i])).some(Boolean);
  14065. }
  14066. super.setValue(source.map(makeAnimated));
  14067. return true;
  14068. }
  14069. }
  14070. function makeAnimated(value) {
  14071. const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
  14072. return nodeType.create(value);
  14073. }
  14074. function getAnimatedType(value) {
  14075. const parentNode = getAnimated(value);
  14076. return parentNode ? parentNode.constructor : react_spring_shared_esm_is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
  14077. }
  14078. function react_spring_animated_esm_extends() {
  14079. react_spring_animated_esm_extends = Object.assign ? Object.assign.bind() : function (target) {
  14080. for (var i = 1; i < arguments.length; i++) {
  14081. var source = arguments[i];
  14082. for (var key in source) {
  14083. if (Object.prototype.hasOwnProperty.call(source, key)) {
  14084. target[key] = source[key];
  14085. }
  14086. }
  14087. }
  14088. return target;
  14089. };
  14090. return react_spring_animated_esm_extends.apply(this, arguments);
  14091. }
  14092. const withAnimated = (Component, host) => {
  14093. const hasInstance = !react_spring_shared_esm_is.fun(Component) || Component.prototype && Component.prototype.isReactComponent;
  14094. return (0,external_React_.forwardRef)((givenProps, givenRef) => {
  14095. const instanceRef = (0,external_React_.useRef)(null);
  14096. const ref = hasInstance && (0,external_React_.useCallback)(value => {
  14097. instanceRef.current = updateRef(givenRef, value);
  14098. }, [givenRef]);
  14099. const [props, deps] = getAnimatedState(givenProps, host);
  14100. const forceUpdate = react_spring_shared_esm_useForceUpdate();
  14101. const callback = () => {
  14102. const instance = instanceRef.current;
  14103. if (hasInstance && !instance) {
  14104. return;
  14105. }
  14106. const didUpdate = instance ? host.applyAnimatedValues(instance, props.getValue(true)) : false;
  14107. if (didUpdate === false) {
  14108. forceUpdate();
  14109. }
  14110. };
  14111. const observer = new PropsObserver(callback, deps);
  14112. const observerRef = (0,external_React_.useRef)();
  14113. react_spring_shared_esm_useIsomorphicLayoutEffect(() => {
  14114. observerRef.current = observer;
  14115. react_spring_shared_esm_each(deps, dep => addFluidObserver(dep, observer));
  14116. return () => {
  14117. if (observerRef.current) {
  14118. react_spring_shared_esm_each(observerRef.current.deps, dep => removeFluidObserver(dep, observerRef.current));
  14119. raf.cancel(observerRef.current.update);
  14120. }
  14121. };
  14122. });
  14123. (0,external_React_.useEffect)(callback, []);
  14124. react_spring_shared_esm_useOnce(() => () => {
  14125. const observer = observerRef.current;
  14126. react_spring_shared_esm_each(observer.deps, dep => removeFluidObserver(dep, observer));
  14127. });
  14128. const usedProps = host.getComponentProps(props.getValue());
  14129. return external_React_.createElement(Component, react_spring_animated_esm_extends({}, usedProps, {
  14130. ref: ref
  14131. }));
  14132. });
  14133. };
  14134. class PropsObserver {
  14135. constructor(update, deps) {
  14136. this.update = update;
  14137. this.deps = deps;
  14138. }
  14139. eventObserved(event) {
  14140. if (event.type == 'change') {
  14141. raf.write(this.update);
  14142. }
  14143. }
  14144. }
  14145. function getAnimatedState(props, host) {
  14146. const dependencies = new Set();
  14147. TreeContext.dependencies = dependencies;
  14148. if (props.style) props = react_spring_animated_esm_extends({}, props, {
  14149. style: host.createAnimatedStyle(props.style)
  14150. });
  14151. props = new AnimatedObject(props);
  14152. TreeContext.dependencies = null;
  14153. return [props, dependencies];
  14154. }
  14155. function updateRef(ref, value) {
  14156. if (ref) {
  14157. if (react_spring_shared_esm_is.fun(ref)) ref(value);else ref.current = value;
  14158. }
  14159. return value;
  14160. }
  14161. const cacheKey = Symbol.for('AnimatedComponent');
  14162. const createHost = (components, {
  14163. applyAnimatedValues: _applyAnimatedValues = () => false,
  14164. createAnimatedStyle: _createAnimatedStyle = style => new AnimatedObject(style),
  14165. getComponentProps: _getComponentProps = props => props
  14166. } = {}) => {
  14167. const hostConfig = {
  14168. applyAnimatedValues: _applyAnimatedValues,
  14169. createAnimatedStyle: _createAnimatedStyle,
  14170. getComponentProps: _getComponentProps
  14171. };
  14172. const animated = Component => {
  14173. const displayName = getDisplayName(Component) || 'Anonymous';
  14174. if (react_spring_shared_esm_is.str(Component)) {
  14175. Component = animated[Component] || (animated[Component] = withAnimated(Component, hostConfig));
  14176. } else {
  14177. Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig));
  14178. }
  14179. Component.displayName = `Animated(${displayName})`;
  14180. return Component;
  14181. };
  14182. eachProp(components, (Component, key) => {
  14183. if (react_spring_shared_esm_is.arr(components)) {
  14184. key = getDisplayName(Component);
  14185. }
  14186. animated[key] = animated(Component);
  14187. });
  14188. return {
  14189. animated
  14190. };
  14191. };
  14192. const getDisplayName = arg => react_spring_shared_esm_is.str(arg) ? arg : arg && react_spring_shared_esm_is.str(arg.displayName) ? arg.displayName : react_spring_shared_esm_is.fun(arg) && arg.name || null;
  14193. ;// CONCATENATED MODULE: ./node_modules/@react-spring/core/dist/react-spring-core.esm.js
  14194. function react_spring_core_esm_extends() {
  14195. react_spring_core_esm_extends = Object.assign ? Object.assign.bind() : function (target) {
  14196. for (var i = 1; i < arguments.length; i++) {
  14197. var source = arguments[i];
  14198. for (var key in source) {
  14199. if (Object.prototype.hasOwnProperty.call(source, key)) {
  14200. target[key] = source[key];
  14201. }
  14202. }
  14203. }
  14204. return target;
  14205. };
  14206. return react_spring_core_esm_extends.apply(this, arguments);
  14207. }
  14208. function callProp(value, ...args) {
  14209. return react_spring_shared_esm_is.fun(value) ? value(...args) : value;
  14210. }
  14211. const matchProp = (value, key) => value === true || !!(key && value && (react_spring_shared_esm_is.fun(value) ? value(key) : react_spring_shared_esm_toArray(value).includes(key)));
  14212. const resolveProp = (prop, key) => react_spring_shared_esm_is.obj(prop) ? key && prop[key] : prop;
  14213. const getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : undefined;
  14214. const noopTransform = value => value;
  14215. const getDefaultProps = (props, transform = noopTransform) => {
  14216. let keys = DEFAULT_PROPS;
  14217. if (props.default && props.default !== true) {
  14218. props = props.default;
  14219. keys = Object.keys(props);
  14220. }
  14221. const defaults = {};
  14222. for (const key of keys) {
  14223. const value = transform(props[key], key);
  14224. if (!react_spring_shared_esm_is.und(value)) {
  14225. defaults[key] = value;
  14226. }
  14227. }
  14228. return defaults;
  14229. };
  14230. const DEFAULT_PROPS = ['config', 'onProps', 'onStart', 'onChange', 'onPause', 'onResume', 'onRest'];
  14231. const RESERVED_PROPS = {
  14232. config: 1,
  14233. from: 1,
  14234. to: 1,
  14235. ref: 1,
  14236. loop: 1,
  14237. reset: 1,
  14238. pause: 1,
  14239. cancel: 1,
  14240. reverse: 1,
  14241. immediate: 1,
  14242. default: 1,
  14243. delay: 1,
  14244. onProps: 1,
  14245. onStart: 1,
  14246. onChange: 1,
  14247. onPause: 1,
  14248. onResume: 1,
  14249. onRest: 1,
  14250. onResolve: 1,
  14251. items: 1,
  14252. trail: 1,
  14253. sort: 1,
  14254. expires: 1,
  14255. initial: 1,
  14256. enter: 1,
  14257. update: 1,
  14258. leave: 1,
  14259. children: 1,
  14260. onDestroyed: 1,
  14261. keys: 1,
  14262. callId: 1,
  14263. parentId: 1
  14264. };
  14265. function getForwardProps(props) {
  14266. const forward = {};
  14267. let count = 0;
  14268. eachProp(props, (value, prop) => {
  14269. if (!RESERVED_PROPS[prop]) {
  14270. forward[prop] = value;
  14271. count++;
  14272. }
  14273. });
  14274. if (count) {
  14275. return forward;
  14276. }
  14277. }
  14278. function inferTo(props) {
  14279. const to = getForwardProps(props);
  14280. if (to) {
  14281. const out = {
  14282. to
  14283. };
  14284. eachProp(props, (val, key) => key in to || (out[key] = val));
  14285. return out;
  14286. }
  14287. return react_spring_core_esm_extends({}, props);
  14288. }
  14289. function computeGoal(value) {
  14290. value = getFluidValue(value);
  14291. return react_spring_shared_esm_is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({
  14292. range: [0, 1],
  14293. output: [value, value]
  14294. })(1) : value;
  14295. }
  14296. function hasProps(props) {
  14297. for (const _ in props) return true;
  14298. return false;
  14299. }
  14300. function isAsyncTo(to) {
  14301. return react_spring_shared_esm_is.fun(to) || react_spring_shared_esm_is.arr(to) && react_spring_shared_esm_is.obj(to[0]);
  14302. }
  14303. function detachRefs(ctrl, ref) {
  14304. var _ctrl$ref;
  14305. (_ctrl$ref = ctrl.ref) == null ? void 0 : _ctrl$ref.delete(ctrl);
  14306. ref == null ? void 0 : ref.delete(ctrl);
  14307. }
  14308. function replaceRef(ctrl, ref) {
  14309. if (ref && ctrl.ref !== ref) {
  14310. var _ctrl$ref2;
  14311. (_ctrl$ref2 = ctrl.ref) == null ? void 0 : _ctrl$ref2.delete(ctrl);
  14312. ref.add(ctrl);
  14313. ctrl.ref = ref;
  14314. }
  14315. }
  14316. function useChain(refs, timeSteps, timeFrame = 1000) {
  14317. useIsomorphicLayoutEffect(() => {
  14318. if (timeSteps) {
  14319. let prevDelay = 0;
  14320. each(refs, (ref, i) => {
  14321. const controllers = ref.current;
  14322. if (controllers.length) {
  14323. let delay = timeFrame * timeSteps[i];
  14324. if (isNaN(delay)) delay = prevDelay;else prevDelay = delay;
  14325. each(controllers, ctrl => {
  14326. each(ctrl.queue, props => {
  14327. const memoizedDelayProp = props.delay;
  14328. props.delay = key => delay + callProp(memoizedDelayProp || 0, key);
  14329. });
  14330. });
  14331. ref.start();
  14332. }
  14333. });
  14334. } else {
  14335. let p = Promise.resolve();
  14336. each(refs, ref => {
  14337. const controllers = ref.current;
  14338. if (controllers.length) {
  14339. const queues = controllers.map(ctrl => {
  14340. const q = ctrl.queue;
  14341. ctrl.queue = [];
  14342. return q;
  14343. });
  14344. p = p.then(() => {
  14345. each(controllers, (ctrl, i) => each(queues[i] || [], update => ctrl.queue.push(update)));
  14346. return Promise.all(ref.start());
  14347. });
  14348. }
  14349. });
  14350. }
  14351. });
  14352. }
  14353. const config = {
  14354. default: {
  14355. tension: 170,
  14356. friction: 26
  14357. },
  14358. gentle: {
  14359. tension: 120,
  14360. friction: 14
  14361. },
  14362. wobbly: {
  14363. tension: 180,
  14364. friction: 12
  14365. },
  14366. stiff: {
  14367. tension: 210,
  14368. friction: 20
  14369. },
  14370. slow: {
  14371. tension: 280,
  14372. friction: 60
  14373. },
  14374. molasses: {
  14375. tension: 280,
  14376. friction: 120
  14377. }
  14378. };
  14379. const c1 = 1.70158;
  14380. const c2 = c1 * 1.525;
  14381. const c3 = c1 + 1;
  14382. const c4 = 2 * Math.PI / 3;
  14383. const c5 = 2 * Math.PI / 4.5;
  14384. const bounceOut = x => {
  14385. const n1 = 7.5625;
  14386. const d1 = 2.75;
  14387. if (x < 1 / d1) {
  14388. return n1 * x * x;
  14389. } else if (x < 2 / d1) {
  14390. return n1 * (x -= 1.5 / d1) * x + 0.75;
  14391. } else if (x < 2.5 / d1) {
  14392. return n1 * (x -= 2.25 / d1) * x + 0.9375;
  14393. } else {
  14394. return n1 * (x -= 2.625 / d1) * x + 0.984375;
  14395. }
  14396. };
  14397. const easings = {
  14398. linear: x => x,
  14399. easeInQuad: x => x * x,
  14400. easeOutQuad: x => 1 - (1 - x) * (1 - x),
  14401. easeInOutQuad: x => x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2,
  14402. easeInCubic: x => x * x * x,
  14403. easeOutCubic: x => 1 - Math.pow(1 - x, 3),
  14404. easeInOutCubic: x => x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2,
  14405. easeInQuart: x => x * x * x * x,
  14406. easeOutQuart: x => 1 - Math.pow(1 - x, 4),
  14407. easeInOutQuart: x => x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2,
  14408. easeInQuint: x => x * x * x * x * x,
  14409. easeOutQuint: x => 1 - Math.pow(1 - x, 5),
  14410. easeInOutQuint: x => x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2,
  14411. easeInSine: x => 1 - Math.cos(x * Math.PI / 2),
  14412. easeOutSine: x => Math.sin(x * Math.PI / 2),
  14413. easeInOutSine: x => -(Math.cos(Math.PI * x) - 1) / 2,
  14414. easeInExpo: x => x === 0 ? 0 : Math.pow(2, 10 * x - 10),
  14415. easeOutExpo: x => x === 1 ? 1 : 1 - Math.pow(2, -10 * x),
  14416. easeInOutExpo: x => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? Math.pow(2, 20 * x - 10) / 2 : (2 - Math.pow(2, -20 * x + 10)) / 2,
  14417. easeInCirc: x => 1 - Math.sqrt(1 - Math.pow(x, 2)),
  14418. easeOutCirc: x => Math.sqrt(1 - Math.pow(x - 1, 2)),
  14419. easeInOutCirc: x => x < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2,
  14420. easeInBack: x => c3 * x * x * x - c1 * x * x,
  14421. easeOutBack: x => 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2),
  14422. easeInOutBack: x => x < 0.5 ? Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2) / 2 : (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2,
  14423. easeInElastic: x => x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4),
  14424. easeOutElastic: x => x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1,
  14425. easeInOutElastic: x => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1,
  14426. easeInBounce: x => 1 - bounceOut(1 - x),
  14427. easeOutBounce: bounceOut,
  14428. easeInOutBounce: x => x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2
  14429. };
  14430. const defaults = react_spring_core_esm_extends({}, config.default, {
  14431. mass: 1,
  14432. damping: 1,
  14433. easing: easings.linear,
  14434. clamp: false
  14435. });
  14436. class AnimationConfig {
  14437. constructor() {
  14438. this.tension = void 0;
  14439. this.friction = void 0;
  14440. this.frequency = void 0;
  14441. this.damping = void 0;
  14442. this.mass = void 0;
  14443. this.velocity = 0;
  14444. this.restVelocity = void 0;
  14445. this.precision = void 0;
  14446. this.progress = void 0;
  14447. this.duration = void 0;
  14448. this.easing = void 0;
  14449. this.clamp = void 0;
  14450. this.bounce = void 0;
  14451. this.decay = void 0;
  14452. this.round = void 0;
  14453. Object.assign(this, defaults);
  14454. }
  14455. }
  14456. function mergeConfig(config, newConfig, defaultConfig) {
  14457. if (defaultConfig) {
  14458. defaultConfig = react_spring_core_esm_extends({}, defaultConfig);
  14459. sanitizeConfig(defaultConfig, newConfig);
  14460. newConfig = react_spring_core_esm_extends({}, defaultConfig, newConfig);
  14461. }
  14462. sanitizeConfig(config, newConfig);
  14463. Object.assign(config, newConfig);
  14464. for (const key in defaults) {
  14465. if (config[key] == null) {
  14466. config[key] = defaults[key];
  14467. }
  14468. }
  14469. let {
  14470. mass,
  14471. frequency,
  14472. damping
  14473. } = config;
  14474. if (!react_spring_shared_esm_is.und(frequency)) {
  14475. if (frequency < 0.01) frequency = 0.01;
  14476. if (damping < 0) damping = 0;
  14477. config.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
  14478. config.friction = 4 * Math.PI * damping * mass / frequency;
  14479. }
  14480. return config;
  14481. }
  14482. function sanitizeConfig(config, props) {
  14483. if (!react_spring_shared_esm_is.und(props.decay)) {
  14484. config.duration = undefined;
  14485. } else {
  14486. const isTensionConfig = !react_spring_shared_esm_is.und(props.tension) || !react_spring_shared_esm_is.und(props.friction);
  14487. if (isTensionConfig || !react_spring_shared_esm_is.und(props.frequency) || !react_spring_shared_esm_is.und(props.damping) || !react_spring_shared_esm_is.und(props.mass)) {
  14488. config.duration = undefined;
  14489. config.decay = undefined;
  14490. }
  14491. if (isTensionConfig) {
  14492. config.frequency = undefined;
  14493. }
  14494. }
  14495. }
  14496. const emptyArray = [];
  14497. class Animation {
  14498. constructor() {
  14499. this.changed = false;
  14500. this.values = emptyArray;
  14501. this.toValues = null;
  14502. this.fromValues = emptyArray;
  14503. this.to = void 0;
  14504. this.from = void 0;
  14505. this.config = new AnimationConfig();
  14506. this.immediate = false;
  14507. }
  14508. }
  14509. function scheduleProps(callId, {
  14510. key,
  14511. props,
  14512. defaultProps,
  14513. state,
  14514. actions
  14515. }) {
  14516. return new Promise((resolve, reject) => {
  14517. var _props$cancel;
  14518. let delay;
  14519. let timeout;
  14520. let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps == null ? void 0 : defaultProps.cancel, key);
  14521. if (cancel) {
  14522. onStart();
  14523. } else {
  14524. if (!react_spring_shared_esm_is.und(props.pause)) {
  14525. state.paused = matchProp(props.pause, key);
  14526. }
  14527. let pause = defaultProps == null ? void 0 : defaultProps.pause;
  14528. if (pause !== true) {
  14529. pause = state.paused || matchProp(pause, key);
  14530. }
  14531. delay = callProp(props.delay || 0, key);
  14532. if (pause) {
  14533. state.resumeQueue.add(onResume);
  14534. actions.pause();
  14535. } else {
  14536. actions.resume();
  14537. onResume();
  14538. }
  14539. }
  14540. function onPause() {
  14541. state.resumeQueue.add(onResume);
  14542. state.timeouts.delete(timeout);
  14543. timeout.cancel();
  14544. delay = timeout.time - raf.now();
  14545. }
  14546. function onResume() {
  14547. if (delay > 0 && !globals.skipAnimation) {
  14548. state.delayed = true;
  14549. timeout = raf.setTimeout(onStart, delay);
  14550. state.pauseQueue.add(onPause);
  14551. state.timeouts.add(timeout);
  14552. } else {
  14553. onStart();
  14554. }
  14555. }
  14556. function onStart() {
  14557. if (state.delayed) {
  14558. state.delayed = false;
  14559. }
  14560. state.pauseQueue.delete(onPause);
  14561. state.timeouts.delete(timeout);
  14562. if (callId <= (state.cancelId || 0)) {
  14563. cancel = true;
  14564. }
  14565. try {
  14566. actions.start(react_spring_core_esm_extends({}, props, {
  14567. callId,
  14568. cancel
  14569. }), resolve);
  14570. } catch (err) {
  14571. reject(err);
  14572. }
  14573. }
  14574. });
  14575. }
  14576. const getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some(result => result.cancelled) ? getCancelledResult(target.get()) : results.every(result => result.noop) ? getNoopResult(target.get()) : getFinishedResult(target.get(), results.every(result => result.finished));
  14577. const getNoopResult = value => ({
  14578. value,
  14579. noop: true,
  14580. finished: true,
  14581. cancelled: false
  14582. });
  14583. const getFinishedResult = (value, finished, cancelled = false) => ({
  14584. value,
  14585. finished,
  14586. cancelled
  14587. });
  14588. const getCancelledResult = value => ({
  14589. value,
  14590. cancelled: true,
  14591. finished: false
  14592. });
  14593. function runAsync(to, props, state, target) {
  14594. const {
  14595. callId,
  14596. parentId,
  14597. onRest
  14598. } = props;
  14599. const {
  14600. asyncTo: prevTo,
  14601. promise: prevPromise
  14602. } = state;
  14603. if (!parentId && to === prevTo && !props.reset) {
  14604. return prevPromise;
  14605. }
  14606. return state.promise = (async () => {
  14607. state.asyncId = callId;
  14608. state.asyncTo = to;
  14609. const defaultProps = getDefaultProps(props, (value, key) => key === 'onRest' ? undefined : value);
  14610. let preventBail;
  14611. let bail;
  14612. const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject));
  14613. const bailIfEnded = bailSignal => {
  14614. const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false);
  14615. if (bailResult) {
  14616. bailSignal.result = bailResult;
  14617. bail(bailSignal);
  14618. throw bailSignal;
  14619. }
  14620. };
  14621. const animate = (arg1, arg2) => {
  14622. const bailSignal = new BailSignal();
  14623. const skipAnimationSignal = new SkipAniamtionSignal();
  14624. return (async () => {
  14625. if (globals.skipAnimation) {
  14626. stopAsync(state);
  14627. skipAnimationSignal.result = getFinishedResult(target, false);
  14628. bail(skipAnimationSignal);
  14629. throw skipAnimationSignal;
  14630. }
  14631. bailIfEnded(bailSignal);
  14632. const props = react_spring_shared_esm_is.obj(arg1) ? react_spring_core_esm_extends({}, arg1) : react_spring_core_esm_extends({}, arg2, {
  14633. to: arg1
  14634. });
  14635. props.parentId = callId;
  14636. eachProp(defaultProps, (value, key) => {
  14637. if (react_spring_shared_esm_is.und(props[key])) {
  14638. props[key] = value;
  14639. }
  14640. });
  14641. const result = await target.start(props);
  14642. bailIfEnded(bailSignal);
  14643. if (state.paused) {
  14644. await new Promise(resume => {
  14645. state.resumeQueue.add(resume);
  14646. });
  14647. }
  14648. return result;
  14649. })();
  14650. };
  14651. let result;
  14652. if (globals.skipAnimation) {
  14653. stopAsync(state);
  14654. return getFinishedResult(target, false);
  14655. }
  14656. try {
  14657. let animating;
  14658. if (react_spring_shared_esm_is.arr(to)) {
  14659. animating = (async queue => {
  14660. for (const props of queue) {
  14661. await animate(props);
  14662. }
  14663. })(to);
  14664. } else {
  14665. animating = Promise.resolve(to(animate, target.stop.bind(target)));
  14666. }
  14667. await Promise.all([animating.then(preventBail), bailPromise]);
  14668. result = getFinishedResult(target.get(), true, false);
  14669. } catch (err) {
  14670. if (err instanceof BailSignal) {
  14671. result = err.result;
  14672. } else if (err instanceof SkipAniamtionSignal) {
  14673. result = err.result;
  14674. } else {
  14675. throw err;
  14676. }
  14677. } finally {
  14678. if (callId == state.asyncId) {
  14679. state.asyncId = parentId;
  14680. state.asyncTo = parentId ? prevTo : undefined;
  14681. state.promise = parentId ? prevPromise : undefined;
  14682. }
  14683. }
  14684. if (react_spring_shared_esm_is.fun(onRest)) {
  14685. raf.batchedUpdates(() => {
  14686. onRest(result, target, target.item);
  14687. });
  14688. }
  14689. return result;
  14690. })();
  14691. }
  14692. function stopAsync(state, cancelId) {
  14693. flush(state.timeouts, t => t.cancel());
  14694. state.pauseQueue.clear();
  14695. state.resumeQueue.clear();
  14696. state.asyncId = state.asyncTo = state.promise = undefined;
  14697. if (cancelId) state.cancelId = cancelId;
  14698. }
  14699. class BailSignal extends Error {
  14700. constructor() {
  14701. super('An async animation has been interrupted. You see this error because you ' + 'forgot to use `await` or `.catch(...)` on its returned promise.');
  14702. this.result = void 0;
  14703. }
  14704. }
  14705. class SkipAniamtionSignal extends Error {
  14706. constructor() {
  14707. super('SkipAnimationSignal');
  14708. this.result = void 0;
  14709. }
  14710. }
  14711. const isFrameValue = value => value instanceof FrameValue;
  14712. let nextId$1 = 1;
  14713. class FrameValue extends FluidValue {
  14714. constructor(...args) {
  14715. super(...args);
  14716. this.id = nextId$1++;
  14717. this.key = void 0;
  14718. this._priority = 0;
  14719. }
  14720. get priority() {
  14721. return this._priority;
  14722. }
  14723. set priority(priority) {
  14724. if (this._priority != priority) {
  14725. this._priority = priority;
  14726. this._onPriorityChange(priority);
  14727. }
  14728. }
  14729. get() {
  14730. const node = getAnimated(this);
  14731. return node && node.getValue();
  14732. }
  14733. to(...args) {
  14734. return globals.to(this, args);
  14735. }
  14736. interpolate(...args) {
  14737. react_spring_shared_esm_deprecateInterpolate();
  14738. return globals.to(this, args);
  14739. }
  14740. toJSON() {
  14741. return this.get();
  14742. }
  14743. observerAdded(count) {
  14744. if (count == 1) this._attach();
  14745. }
  14746. observerRemoved(count) {
  14747. if (count == 0) this._detach();
  14748. }
  14749. _attach() {}
  14750. _detach() {}
  14751. _onChange(value, idle = false) {
  14752. callFluidObservers(this, {
  14753. type: 'change',
  14754. parent: this,
  14755. value,
  14756. idle
  14757. });
  14758. }
  14759. _onPriorityChange(priority) {
  14760. if (!this.idle) {
  14761. frameLoop.sort(this);
  14762. }
  14763. callFluidObservers(this, {
  14764. type: 'priority',
  14765. parent: this,
  14766. priority
  14767. });
  14768. }
  14769. }
  14770. const $P = Symbol.for('SpringPhase');
  14771. const HAS_ANIMATED = 1;
  14772. const IS_ANIMATING = 2;
  14773. const IS_PAUSED = 4;
  14774. const hasAnimated = target => (target[$P] & HAS_ANIMATED) > 0;
  14775. const isAnimating = target => (target[$P] & IS_ANIMATING) > 0;
  14776. const isPaused = target => (target[$P] & IS_PAUSED) > 0;
  14777. const setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING;
  14778. const setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED;
  14779. class SpringValue extends FrameValue {
  14780. constructor(arg1, arg2) {
  14781. super();
  14782. this.key = void 0;
  14783. this.animation = new Animation();
  14784. this.queue = void 0;
  14785. this.defaultProps = {};
  14786. this._state = {
  14787. paused: false,
  14788. delayed: false,
  14789. pauseQueue: new Set(),
  14790. resumeQueue: new Set(),
  14791. timeouts: new Set()
  14792. };
  14793. this._pendingCalls = new Set();
  14794. this._lastCallId = 0;
  14795. this._lastToId = 0;
  14796. this._memoizedDuration = 0;
  14797. if (!react_spring_shared_esm_is.und(arg1) || !react_spring_shared_esm_is.und(arg2)) {
  14798. const props = react_spring_shared_esm_is.obj(arg1) ? react_spring_core_esm_extends({}, arg1) : react_spring_core_esm_extends({}, arg2, {
  14799. from: arg1
  14800. });
  14801. if (react_spring_shared_esm_is.und(props.default)) {
  14802. props.default = true;
  14803. }
  14804. this.start(props);
  14805. }
  14806. }
  14807. get idle() {
  14808. return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
  14809. }
  14810. get goal() {
  14811. return getFluidValue(this.animation.to);
  14812. }
  14813. get velocity() {
  14814. const node = getAnimated(this);
  14815. return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map(node => node.lastVelocity || 0);
  14816. }
  14817. get hasAnimated() {
  14818. return hasAnimated(this);
  14819. }
  14820. get isAnimating() {
  14821. return isAnimating(this);
  14822. }
  14823. get isPaused() {
  14824. return isPaused(this);
  14825. }
  14826. get isDelayed() {
  14827. return this._state.delayed;
  14828. }
  14829. advance(dt) {
  14830. let idle = true;
  14831. let changed = false;
  14832. const anim = this.animation;
  14833. let {
  14834. config,
  14835. toValues
  14836. } = anim;
  14837. const payload = getPayload(anim.to);
  14838. if (!payload && hasFluidValue(anim.to)) {
  14839. toValues = react_spring_shared_esm_toArray(getFluidValue(anim.to));
  14840. }
  14841. anim.values.forEach((node, i) => {
  14842. if (node.done) return;
  14843. const to = node.constructor == AnimatedString ? 1 : payload ? payload[i].lastPosition : toValues[i];
  14844. let finished = anim.immediate;
  14845. let position = to;
  14846. if (!finished) {
  14847. position = node.lastPosition;
  14848. if (config.tension <= 0) {
  14849. node.done = true;
  14850. return;
  14851. }
  14852. let elapsed = node.elapsedTime += dt;
  14853. const from = anim.fromValues[i];
  14854. const v0 = node.v0 != null ? node.v0 : node.v0 = react_spring_shared_esm_is.arr(config.velocity) ? config.velocity[i] : config.velocity;
  14855. let velocity;
  14856. const precision = config.precision || (from == to ? 0.005 : Math.min(1, Math.abs(to - from) * 0.001));
  14857. if (!react_spring_shared_esm_is.und(config.duration)) {
  14858. let p = 1;
  14859. if (config.duration > 0) {
  14860. if (this._memoizedDuration !== config.duration) {
  14861. this._memoizedDuration = config.duration;
  14862. if (node.durationProgress > 0) {
  14863. node.elapsedTime = config.duration * node.durationProgress;
  14864. elapsed = node.elapsedTime += dt;
  14865. }
  14866. }
  14867. p = (config.progress || 0) + elapsed / this._memoizedDuration;
  14868. p = p > 1 ? 1 : p < 0 ? 0 : p;
  14869. node.durationProgress = p;
  14870. }
  14871. position = from + config.easing(p) * (to - from);
  14872. velocity = (position - node.lastPosition) / dt;
  14873. finished = p == 1;
  14874. } else if (config.decay) {
  14875. const decay = config.decay === true ? 0.998 : config.decay;
  14876. const e = Math.exp(-(1 - decay) * elapsed);
  14877. position = from + v0 / (1 - decay) * (1 - e);
  14878. finished = Math.abs(node.lastPosition - position) <= precision;
  14879. velocity = v0 * e;
  14880. } else {
  14881. velocity = node.lastVelocity == null ? v0 : node.lastVelocity;
  14882. const restVelocity = config.restVelocity || precision / 10;
  14883. const bounceFactor = config.clamp ? 0 : config.bounce;
  14884. const canBounce = !react_spring_shared_esm_is.und(bounceFactor);
  14885. const isGrowing = from == to ? node.v0 > 0 : from < to;
  14886. let isMoving;
  14887. let isBouncing = false;
  14888. const step = 1;
  14889. const numSteps = Math.ceil(dt / step);
  14890. for (let n = 0; n < numSteps; ++n) {
  14891. isMoving = Math.abs(velocity) > restVelocity;
  14892. if (!isMoving) {
  14893. finished = Math.abs(to - position) <= precision;
  14894. if (finished) {
  14895. break;
  14896. }
  14897. }
  14898. if (canBounce) {
  14899. isBouncing = position == to || position > to == isGrowing;
  14900. if (isBouncing) {
  14901. velocity = -velocity * bounceFactor;
  14902. position = to;
  14903. }
  14904. }
  14905. const springForce = -config.tension * 0.000001 * (position - to);
  14906. const dampingForce = -config.friction * 0.001 * velocity;
  14907. const acceleration = (springForce + dampingForce) / config.mass;
  14908. velocity = velocity + acceleration * step;
  14909. position = position + velocity * step;
  14910. }
  14911. }
  14912. node.lastVelocity = velocity;
  14913. if (Number.isNaN(position)) {
  14914. console.warn(`Got NaN while animating:`, this);
  14915. finished = true;
  14916. }
  14917. }
  14918. if (payload && !payload[i].done) {
  14919. finished = false;
  14920. }
  14921. if (finished) {
  14922. node.done = true;
  14923. } else {
  14924. idle = false;
  14925. }
  14926. if (node.setValue(position, config.round)) {
  14927. changed = true;
  14928. }
  14929. });
  14930. const node = getAnimated(this);
  14931. const currVal = node.getValue();
  14932. if (idle) {
  14933. const finalVal = getFluidValue(anim.to);
  14934. if ((currVal !== finalVal || changed) && !config.decay) {
  14935. node.setValue(finalVal);
  14936. this._onChange(finalVal);
  14937. } else if (changed && config.decay) {
  14938. this._onChange(currVal);
  14939. }
  14940. this._stop();
  14941. } else if (changed) {
  14942. this._onChange(currVal);
  14943. }
  14944. }
  14945. set(value) {
  14946. raf.batchedUpdates(() => {
  14947. this._stop();
  14948. this._focus(value);
  14949. this._set(value);
  14950. });
  14951. return this;
  14952. }
  14953. pause() {
  14954. this._update({
  14955. pause: true
  14956. });
  14957. }
  14958. resume() {
  14959. this._update({
  14960. pause: false
  14961. });
  14962. }
  14963. finish() {
  14964. if (isAnimating(this)) {
  14965. const {
  14966. to,
  14967. config
  14968. } = this.animation;
  14969. raf.batchedUpdates(() => {
  14970. this._onStart();
  14971. if (!config.decay) {
  14972. this._set(to, false);
  14973. }
  14974. this._stop();
  14975. });
  14976. }
  14977. return this;
  14978. }
  14979. update(props) {
  14980. const queue = this.queue || (this.queue = []);
  14981. queue.push(props);
  14982. return this;
  14983. }
  14984. start(to, arg2) {
  14985. let queue;
  14986. if (!react_spring_shared_esm_is.und(to)) {
  14987. queue = [react_spring_shared_esm_is.obj(to) ? to : react_spring_core_esm_extends({}, arg2, {
  14988. to
  14989. })];
  14990. } else {
  14991. queue = this.queue || [];
  14992. this.queue = [];
  14993. }
  14994. return Promise.all(queue.map(props => {
  14995. const up = this._update(props);
  14996. return up;
  14997. })).then(results => getCombinedResult(this, results));
  14998. }
  14999. stop(cancel) {
  15000. const {
  15001. to
  15002. } = this.animation;
  15003. this._focus(this.get());
  15004. stopAsync(this._state, cancel && this._lastCallId);
  15005. raf.batchedUpdates(() => this._stop(to, cancel));
  15006. return this;
  15007. }
  15008. reset() {
  15009. this._update({
  15010. reset: true
  15011. });
  15012. }
  15013. eventObserved(event) {
  15014. if (event.type == 'change') {
  15015. this._start();
  15016. } else if (event.type == 'priority') {
  15017. this.priority = event.priority + 1;
  15018. }
  15019. }
  15020. _prepareNode(props) {
  15021. const key = this.key || '';
  15022. let {
  15023. to,
  15024. from
  15025. } = props;
  15026. to = react_spring_shared_esm_is.obj(to) ? to[key] : to;
  15027. if (to == null || isAsyncTo(to)) {
  15028. to = undefined;
  15029. }
  15030. from = react_spring_shared_esm_is.obj(from) ? from[key] : from;
  15031. if (from == null) {
  15032. from = undefined;
  15033. }
  15034. const range = {
  15035. to,
  15036. from
  15037. };
  15038. if (!hasAnimated(this)) {
  15039. if (props.reverse) [to, from] = [from, to];
  15040. from = getFluidValue(from);
  15041. if (!react_spring_shared_esm_is.und(from)) {
  15042. this._set(from);
  15043. } else if (!getAnimated(this)) {
  15044. this._set(to);
  15045. }
  15046. }
  15047. return range;
  15048. }
  15049. _update(_ref, isLoop) {
  15050. let props = react_spring_core_esm_extends({}, _ref);
  15051. const {
  15052. key,
  15053. defaultProps
  15054. } = this;
  15055. if (props.default) Object.assign(defaultProps, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value));
  15056. mergeActiveFn(this, props, 'onProps');
  15057. sendEvent(this, 'onProps', props, this);
  15058. const range = this._prepareNode(props);
  15059. if (Object.isFrozen(this)) {
  15060. throw Error('Cannot animate a `SpringValue` object that is frozen. ' + 'Did you forget to pass your component to `animated(...)` before animating its props?');
  15061. }
  15062. const state = this._state;
  15063. return scheduleProps(++this._lastCallId, {
  15064. key,
  15065. props,
  15066. defaultProps,
  15067. state,
  15068. actions: {
  15069. pause: () => {
  15070. if (!isPaused(this)) {
  15071. setPausedBit(this, true);
  15072. flushCalls(state.pauseQueue);
  15073. sendEvent(this, 'onPause', getFinishedResult(this, checkFinished(this, this.animation.to)), this);
  15074. }
  15075. },
  15076. resume: () => {
  15077. if (isPaused(this)) {
  15078. setPausedBit(this, false);
  15079. if (isAnimating(this)) {
  15080. this._resume();
  15081. }
  15082. flushCalls(state.resumeQueue);
  15083. sendEvent(this, 'onResume', getFinishedResult(this, checkFinished(this, this.animation.to)), this);
  15084. }
  15085. },
  15086. start: this._merge.bind(this, range)
  15087. }
  15088. }).then(result => {
  15089. if (props.loop && result.finished && !(isLoop && result.noop)) {
  15090. const nextProps = createLoopUpdate(props);
  15091. if (nextProps) {
  15092. return this._update(nextProps, true);
  15093. }
  15094. }
  15095. return result;
  15096. });
  15097. }
  15098. _merge(range, props, resolve) {
  15099. if (props.cancel) {
  15100. this.stop(true);
  15101. return resolve(getCancelledResult(this));
  15102. }
  15103. const hasToProp = !react_spring_shared_esm_is.und(range.to);
  15104. const hasFromProp = !react_spring_shared_esm_is.und(range.from);
  15105. if (hasToProp || hasFromProp) {
  15106. if (props.callId > this._lastToId) {
  15107. this._lastToId = props.callId;
  15108. } else {
  15109. return resolve(getCancelledResult(this));
  15110. }
  15111. }
  15112. const {
  15113. key,
  15114. defaultProps,
  15115. animation: anim
  15116. } = this;
  15117. const {
  15118. to: prevTo,
  15119. from: prevFrom
  15120. } = anim;
  15121. let {
  15122. to = prevTo,
  15123. from = prevFrom
  15124. } = range;
  15125. if (hasFromProp && !hasToProp && (!props.default || react_spring_shared_esm_is.und(to))) {
  15126. to = from;
  15127. }
  15128. if (props.reverse) [to, from] = [from, to];
  15129. const hasFromChanged = !isEqual(from, prevFrom);
  15130. if (hasFromChanged) {
  15131. anim.from = from;
  15132. }
  15133. from = getFluidValue(from);
  15134. const hasToChanged = !isEqual(to, prevTo);
  15135. if (hasToChanged) {
  15136. this._focus(to);
  15137. }
  15138. const hasAsyncTo = isAsyncTo(props.to);
  15139. const {
  15140. config
  15141. } = anim;
  15142. const {
  15143. decay,
  15144. velocity
  15145. } = config;
  15146. if (hasToProp || hasFromProp) {
  15147. config.velocity = 0;
  15148. }
  15149. if (props.config && !hasAsyncTo) {
  15150. mergeConfig(config, callProp(props.config, key), props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0);
  15151. }
  15152. let node = getAnimated(this);
  15153. if (!node || react_spring_shared_esm_is.und(to)) {
  15154. return resolve(getFinishedResult(this, true));
  15155. }
  15156. const reset = react_spring_shared_esm_is.und(props.reset) ? hasFromProp && !props.default : !react_spring_shared_esm_is.und(from) && matchProp(props.reset, key);
  15157. const value = reset ? from : this.get();
  15158. const goal = computeGoal(to);
  15159. const isAnimatable = react_spring_shared_esm_is.num(goal) || react_spring_shared_esm_is.arr(goal) || isAnimatedString(goal);
  15160. const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key));
  15161. if (hasToChanged) {
  15162. const nodeType = getAnimatedType(to);
  15163. if (nodeType !== node.constructor) {
  15164. if (immediate) {
  15165. node = this._set(goal);
  15166. } else throw Error(`Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`);
  15167. }
  15168. }
  15169. const goalType = node.constructor;
  15170. let started = hasFluidValue(to);
  15171. let finished = false;
  15172. if (!started) {
  15173. const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
  15174. if (hasToChanged || hasValueChanged) {
  15175. finished = isEqual(computeGoal(value), goal);
  15176. started = !finished;
  15177. }
  15178. if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config.decay, decay) || !isEqual(config.velocity, velocity)) {
  15179. started = true;
  15180. }
  15181. }
  15182. if (finished && isAnimating(this)) {
  15183. if (anim.changed && !reset) {
  15184. started = true;
  15185. } else if (!started) {
  15186. this._stop(prevTo);
  15187. }
  15188. }
  15189. if (!hasAsyncTo) {
  15190. if (started || hasFluidValue(prevTo)) {
  15191. anim.values = node.getPayload();
  15192. anim.toValues = hasFluidValue(to) ? null : goalType == AnimatedString ? [1] : react_spring_shared_esm_toArray(goal);
  15193. }
  15194. if (anim.immediate != immediate) {
  15195. anim.immediate = immediate;
  15196. if (!immediate && !reset) {
  15197. this._set(prevTo);
  15198. }
  15199. }
  15200. if (started) {
  15201. const {
  15202. onRest
  15203. } = anim;
  15204. react_spring_shared_esm_each(ACTIVE_EVENTS, type => mergeActiveFn(this, props, type));
  15205. const result = getFinishedResult(this, checkFinished(this, prevTo));
  15206. flushCalls(this._pendingCalls, result);
  15207. this._pendingCalls.add(resolve);
  15208. if (anim.changed) raf.batchedUpdates(() => {
  15209. anim.changed = !reset;
  15210. onRest == null ? void 0 : onRest(result, this);
  15211. if (reset) {
  15212. callProp(defaultProps.onRest, result);
  15213. } else {
  15214. anim.onStart == null ? void 0 : anim.onStart(result, this);
  15215. }
  15216. });
  15217. }
  15218. }
  15219. if (reset) {
  15220. this._set(value);
  15221. }
  15222. if (hasAsyncTo) {
  15223. resolve(runAsync(props.to, props, this._state, this));
  15224. } else if (started) {
  15225. this._start();
  15226. } else if (isAnimating(this) && !hasToChanged) {
  15227. this._pendingCalls.add(resolve);
  15228. } else {
  15229. resolve(getNoopResult(value));
  15230. }
  15231. }
  15232. _focus(value) {
  15233. const anim = this.animation;
  15234. if (value !== anim.to) {
  15235. if (getFluidObservers(this)) {
  15236. this._detach();
  15237. }
  15238. anim.to = value;
  15239. if (getFluidObservers(this)) {
  15240. this._attach();
  15241. }
  15242. }
  15243. }
  15244. _attach() {
  15245. let priority = 0;
  15246. const {
  15247. to
  15248. } = this.animation;
  15249. if (hasFluidValue(to)) {
  15250. addFluidObserver(to, this);
  15251. if (isFrameValue(to)) {
  15252. priority = to.priority + 1;
  15253. }
  15254. }
  15255. this.priority = priority;
  15256. }
  15257. _detach() {
  15258. const {
  15259. to
  15260. } = this.animation;
  15261. if (hasFluidValue(to)) {
  15262. removeFluidObserver(to, this);
  15263. }
  15264. }
  15265. _set(arg, idle = true) {
  15266. const value = getFluidValue(arg);
  15267. if (!react_spring_shared_esm_is.und(value)) {
  15268. const oldNode = getAnimated(this);
  15269. if (!oldNode || !isEqual(value, oldNode.getValue())) {
  15270. const nodeType = getAnimatedType(value);
  15271. if (!oldNode || oldNode.constructor != nodeType) {
  15272. setAnimated(this, nodeType.create(value));
  15273. } else {
  15274. oldNode.setValue(value);
  15275. }
  15276. if (oldNode) {
  15277. raf.batchedUpdates(() => {
  15278. this._onChange(value, idle);
  15279. });
  15280. }
  15281. }
  15282. }
  15283. return getAnimated(this);
  15284. }
  15285. _onStart() {
  15286. const anim = this.animation;
  15287. if (!anim.changed) {
  15288. anim.changed = true;
  15289. sendEvent(this, 'onStart', getFinishedResult(this, checkFinished(this, anim.to)), this);
  15290. }
  15291. }
  15292. _onChange(value, idle) {
  15293. if (!idle) {
  15294. this._onStart();
  15295. callProp(this.animation.onChange, value, this);
  15296. }
  15297. callProp(this.defaultProps.onChange, value, this);
  15298. super._onChange(value, idle);
  15299. }
  15300. _start() {
  15301. const anim = this.animation;
  15302. getAnimated(this).reset(getFluidValue(anim.to));
  15303. if (!anim.immediate) {
  15304. anim.fromValues = anim.values.map(node => node.lastPosition);
  15305. }
  15306. if (!isAnimating(this)) {
  15307. setActiveBit(this, true);
  15308. if (!isPaused(this)) {
  15309. this._resume();
  15310. }
  15311. }
  15312. }
  15313. _resume() {
  15314. if (globals.skipAnimation) {
  15315. this.finish();
  15316. } else {
  15317. frameLoop.start(this);
  15318. }
  15319. }
  15320. _stop(goal, cancel) {
  15321. if (isAnimating(this)) {
  15322. setActiveBit(this, false);
  15323. const anim = this.animation;
  15324. react_spring_shared_esm_each(anim.values, node => {
  15325. node.done = true;
  15326. });
  15327. if (anim.toValues) {
  15328. anim.onChange = anim.onPause = anim.onResume = undefined;
  15329. }
  15330. callFluidObservers(this, {
  15331. type: 'idle',
  15332. parent: this
  15333. });
  15334. const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to));
  15335. flushCalls(this._pendingCalls, result);
  15336. if (anim.changed) {
  15337. anim.changed = false;
  15338. sendEvent(this, 'onRest', result, this);
  15339. }
  15340. }
  15341. }
  15342. }
  15343. function checkFinished(target, to) {
  15344. const goal = computeGoal(to);
  15345. const value = computeGoal(target.get());
  15346. return isEqual(value, goal);
  15347. }
  15348. function createLoopUpdate(props, loop = props.loop, to = props.to) {
  15349. let loopRet = callProp(loop);
  15350. if (loopRet) {
  15351. const overrides = loopRet !== true && inferTo(loopRet);
  15352. const reverse = (overrides || props).reverse;
  15353. const reset = !overrides || overrides.reset;
  15354. return createUpdate(react_spring_core_esm_extends({}, props, {
  15355. loop,
  15356. default: false,
  15357. pause: undefined,
  15358. to: !reverse || isAsyncTo(to) ? to : undefined,
  15359. from: reset ? props.from : undefined,
  15360. reset
  15361. }, overrides));
  15362. }
  15363. }
  15364. function createUpdate(props) {
  15365. const {
  15366. to,
  15367. from
  15368. } = props = inferTo(props);
  15369. const keys = new Set();
  15370. if (react_spring_shared_esm_is.obj(to)) findDefined(to, keys);
  15371. if (react_spring_shared_esm_is.obj(from)) findDefined(from, keys);
  15372. props.keys = keys.size ? Array.from(keys) : null;
  15373. return props;
  15374. }
  15375. function declareUpdate(props) {
  15376. const update = createUpdate(props);
  15377. if (react_spring_shared_esm_is.und(update.default)) {
  15378. update.default = getDefaultProps(update);
  15379. }
  15380. return update;
  15381. }
  15382. function findDefined(values, keys) {
  15383. eachProp(values, (value, key) => value != null && keys.add(key));
  15384. }
  15385. const ACTIVE_EVENTS = ['onStart', 'onRest', 'onChange', 'onPause', 'onResume'];
  15386. function mergeActiveFn(target, props, type) {
  15387. target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : undefined;
  15388. }
  15389. function sendEvent(target, type, ...args) {
  15390. var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps;
  15391. (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args);
  15392. (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args);
  15393. }
  15394. const BATCHED_EVENTS = ['onStart', 'onChange', 'onRest'];
  15395. let nextId = 1;
  15396. class Controller {
  15397. constructor(props, flush) {
  15398. this.id = nextId++;
  15399. this.springs = {};
  15400. this.queue = [];
  15401. this.ref = void 0;
  15402. this._flush = void 0;
  15403. this._initialProps = void 0;
  15404. this._lastAsyncId = 0;
  15405. this._active = new Set();
  15406. this._changed = new Set();
  15407. this._started = false;
  15408. this._item = void 0;
  15409. this._state = {
  15410. paused: false,
  15411. pauseQueue: new Set(),
  15412. resumeQueue: new Set(),
  15413. timeouts: new Set()
  15414. };
  15415. this._events = {
  15416. onStart: new Map(),
  15417. onChange: new Map(),
  15418. onRest: new Map()
  15419. };
  15420. this._onFrame = this._onFrame.bind(this);
  15421. if (flush) {
  15422. this._flush = flush;
  15423. }
  15424. if (props) {
  15425. this.start(react_spring_core_esm_extends({
  15426. default: true
  15427. }, props));
  15428. }
  15429. }
  15430. get idle() {
  15431. return !this._state.asyncTo && Object.values(this.springs).every(spring => {
  15432. return spring.idle && !spring.isDelayed && !spring.isPaused;
  15433. });
  15434. }
  15435. get item() {
  15436. return this._item;
  15437. }
  15438. set item(item) {
  15439. this._item = item;
  15440. }
  15441. get() {
  15442. const values = {};
  15443. this.each((spring, key) => values[key] = spring.get());
  15444. return values;
  15445. }
  15446. set(values) {
  15447. for (const key in values) {
  15448. const value = values[key];
  15449. if (!react_spring_shared_esm_is.und(value)) {
  15450. this.springs[key].set(value);
  15451. }
  15452. }
  15453. }
  15454. update(props) {
  15455. if (props) {
  15456. this.queue.push(createUpdate(props));
  15457. }
  15458. return this;
  15459. }
  15460. start(props) {
  15461. let {
  15462. queue
  15463. } = this;
  15464. if (props) {
  15465. queue = react_spring_shared_esm_toArray(props).map(createUpdate);
  15466. } else {
  15467. this.queue = [];
  15468. }
  15469. if (this._flush) {
  15470. return this._flush(this, queue);
  15471. }
  15472. prepareKeys(this, queue);
  15473. return flushUpdateQueue(this, queue);
  15474. }
  15475. stop(arg, keys) {
  15476. if (arg !== !!arg) {
  15477. keys = arg;
  15478. }
  15479. if (keys) {
  15480. const springs = this.springs;
  15481. react_spring_shared_esm_each(react_spring_shared_esm_toArray(keys), key => springs[key].stop(!!arg));
  15482. } else {
  15483. stopAsync(this._state, this._lastAsyncId);
  15484. this.each(spring => spring.stop(!!arg));
  15485. }
  15486. return this;
  15487. }
  15488. pause(keys) {
  15489. if (react_spring_shared_esm_is.und(keys)) {
  15490. this.start({
  15491. pause: true
  15492. });
  15493. } else {
  15494. const springs = this.springs;
  15495. react_spring_shared_esm_each(react_spring_shared_esm_toArray(keys), key => springs[key].pause());
  15496. }
  15497. return this;
  15498. }
  15499. resume(keys) {
  15500. if (react_spring_shared_esm_is.und(keys)) {
  15501. this.start({
  15502. pause: false
  15503. });
  15504. } else {
  15505. const springs = this.springs;
  15506. react_spring_shared_esm_each(react_spring_shared_esm_toArray(keys), key => springs[key].resume());
  15507. }
  15508. return this;
  15509. }
  15510. each(iterator) {
  15511. eachProp(this.springs, iterator);
  15512. }
  15513. _onFrame() {
  15514. const {
  15515. onStart,
  15516. onChange,
  15517. onRest
  15518. } = this._events;
  15519. const active = this._active.size > 0;
  15520. const changed = this._changed.size > 0;
  15521. if (active && !this._started || changed && !this._started) {
  15522. this._started = true;
  15523. flush(onStart, ([onStart, result]) => {
  15524. result.value = this.get();
  15525. onStart(result, this, this._item);
  15526. });
  15527. }
  15528. const idle = !active && this._started;
  15529. const values = changed || idle && onRest.size ? this.get() : null;
  15530. if (changed && onChange.size) {
  15531. flush(onChange, ([onChange, result]) => {
  15532. result.value = values;
  15533. onChange(result, this, this._item);
  15534. });
  15535. }
  15536. if (idle) {
  15537. this._started = false;
  15538. flush(onRest, ([onRest, result]) => {
  15539. result.value = values;
  15540. onRest(result, this, this._item);
  15541. });
  15542. }
  15543. }
  15544. eventObserved(event) {
  15545. if (event.type == 'change') {
  15546. this._changed.add(event.parent);
  15547. if (!event.idle) {
  15548. this._active.add(event.parent);
  15549. }
  15550. } else if (event.type == 'idle') {
  15551. this._active.delete(event.parent);
  15552. } else return;
  15553. raf.onFrame(this._onFrame);
  15554. }
  15555. }
  15556. function flushUpdateQueue(ctrl, queue) {
  15557. return Promise.all(queue.map(props => flushUpdate(ctrl, props))).then(results => getCombinedResult(ctrl, results));
  15558. }
  15559. async function flushUpdate(ctrl, props, isLoop) {
  15560. const {
  15561. keys,
  15562. to,
  15563. from,
  15564. loop,
  15565. onRest,
  15566. onResolve
  15567. } = props;
  15568. const defaults = react_spring_shared_esm_is.obj(props.default) && props.default;
  15569. if (loop) {
  15570. props.loop = false;
  15571. }
  15572. if (to === false) props.to = null;
  15573. if (from === false) props.from = null;
  15574. const asyncTo = react_spring_shared_esm_is.arr(to) || react_spring_shared_esm_is.fun(to) ? to : undefined;
  15575. if (asyncTo) {
  15576. props.to = undefined;
  15577. props.onRest = undefined;
  15578. if (defaults) {
  15579. defaults.onRest = undefined;
  15580. }
  15581. } else {
  15582. react_spring_shared_esm_each(BATCHED_EVENTS, key => {
  15583. const handler = props[key];
  15584. if (react_spring_shared_esm_is.fun(handler)) {
  15585. const queue = ctrl['_events'][key];
  15586. props[key] = ({
  15587. finished,
  15588. cancelled
  15589. }) => {
  15590. const result = queue.get(handler);
  15591. if (result) {
  15592. if (!finished) result.finished = false;
  15593. if (cancelled) result.cancelled = true;
  15594. } else {
  15595. queue.set(handler, {
  15596. value: null,
  15597. finished: finished || false,
  15598. cancelled: cancelled || false
  15599. });
  15600. }
  15601. };
  15602. if (defaults) {
  15603. defaults[key] = props[key];
  15604. }
  15605. }
  15606. });
  15607. }
  15608. const state = ctrl['_state'];
  15609. if (props.pause === !state.paused) {
  15610. state.paused = props.pause;
  15611. flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
  15612. } else if (state.paused) {
  15613. props.pause = true;
  15614. }
  15615. const promises = (keys || Object.keys(ctrl.springs)).map(key => ctrl.springs[key].start(props));
  15616. const cancel = props.cancel === true || getDefaultProp(props, 'cancel') === true;
  15617. if (asyncTo || cancel && state.asyncId) {
  15618. promises.push(scheduleProps(++ctrl['_lastAsyncId'], {
  15619. props,
  15620. state,
  15621. actions: {
  15622. pause: noop,
  15623. resume: noop,
  15624. start(props, resolve) {
  15625. if (cancel) {
  15626. stopAsync(state, ctrl['_lastAsyncId']);
  15627. resolve(getCancelledResult(ctrl));
  15628. } else {
  15629. props.onRest = onRest;
  15630. resolve(runAsync(asyncTo, props, state, ctrl));
  15631. }
  15632. }
  15633. }
  15634. }));
  15635. }
  15636. if (state.paused) {
  15637. await new Promise(resume => {
  15638. state.resumeQueue.add(resume);
  15639. });
  15640. }
  15641. const result = getCombinedResult(ctrl, await Promise.all(promises));
  15642. if (loop && result.finished && !(isLoop && result.noop)) {
  15643. const nextProps = createLoopUpdate(props, loop, to);
  15644. if (nextProps) {
  15645. prepareKeys(ctrl, [nextProps]);
  15646. return flushUpdate(ctrl, nextProps, true);
  15647. }
  15648. }
  15649. if (onResolve) {
  15650. raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
  15651. }
  15652. return result;
  15653. }
  15654. function getSprings(ctrl, props) {
  15655. const springs = react_spring_core_esm_extends({}, ctrl.springs);
  15656. if (props) {
  15657. react_spring_shared_esm_each(react_spring_shared_esm_toArray(props), props => {
  15658. if (react_spring_shared_esm_is.und(props.keys)) {
  15659. props = createUpdate(props);
  15660. }
  15661. if (!react_spring_shared_esm_is.obj(props.to)) {
  15662. props = react_spring_core_esm_extends({}, props, {
  15663. to: undefined
  15664. });
  15665. }
  15666. prepareSprings(springs, props, key => {
  15667. return createSpring(key);
  15668. });
  15669. });
  15670. }
  15671. setSprings(ctrl, springs);
  15672. return springs;
  15673. }
  15674. function setSprings(ctrl, springs) {
  15675. eachProp(springs, (spring, key) => {
  15676. if (!ctrl.springs[key]) {
  15677. ctrl.springs[key] = spring;
  15678. addFluidObserver(spring, ctrl);
  15679. }
  15680. });
  15681. }
  15682. function createSpring(key, observer) {
  15683. const spring = new SpringValue();
  15684. spring.key = key;
  15685. if (observer) {
  15686. addFluidObserver(spring, observer);
  15687. }
  15688. return spring;
  15689. }
  15690. function prepareSprings(springs, props, create) {
  15691. if (props.keys) {
  15692. react_spring_shared_esm_each(props.keys, key => {
  15693. const spring = springs[key] || (springs[key] = create(key));
  15694. spring['_prepareNode'](props);
  15695. });
  15696. }
  15697. }
  15698. function prepareKeys(ctrl, queue) {
  15699. react_spring_shared_esm_each(queue, props => {
  15700. prepareSprings(ctrl.springs, props, key => {
  15701. return createSpring(key, ctrl);
  15702. });
  15703. });
  15704. }
  15705. function _objectWithoutPropertiesLoose(source, excluded) {
  15706. if (source == null) return {};
  15707. var target = {};
  15708. var sourceKeys = Object.keys(source);
  15709. var key, i;
  15710. for (i = 0; i < sourceKeys.length; i++) {
  15711. key = sourceKeys[i];
  15712. if (excluded.indexOf(key) >= 0) continue;
  15713. target[key] = source[key];
  15714. }
  15715. return target;
  15716. }
  15717. const _excluded$3 = ["children"];
  15718. const SpringContext = _ref => {
  15719. let {
  15720. children
  15721. } = _ref,
  15722. props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
  15723. const inherited = (0,external_React_.useContext)(ctx);
  15724. const pause = props.pause || !!inherited.pause,
  15725. immediate = props.immediate || !!inherited.immediate;
  15726. props = useMemoOne(() => ({
  15727. pause,
  15728. immediate
  15729. }), [pause, immediate]);
  15730. const {
  15731. Provider
  15732. } = ctx;
  15733. return external_React_.createElement(Provider, {
  15734. value: props
  15735. }, children);
  15736. };
  15737. const ctx = makeContext(SpringContext, {});
  15738. SpringContext.Provider = ctx.Provider;
  15739. SpringContext.Consumer = ctx.Consumer;
  15740. function makeContext(target, init) {
  15741. Object.assign(target, external_React_.createContext(init));
  15742. target.Provider._context = target;
  15743. target.Consumer._context = target;
  15744. return target;
  15745. }
  15746. const SpringRef = () => {
  15747. const current = [];
  15748. const SpringRef = function SpringRef(props) {
  15749. deprecateDirectCall();
  15750. const results = [];
  15751. react_spring_shared_esm_each(current, (ctrl, i) => {
  15752. if (react_spring_shared_esm_is.und(props)) {
  15753. results.push(ctrl.start());
  15754. } else {
  15755. const update = _getProps(props, ctrl, i);
  15756. if (update) {
  15757. results.push(ctrl.start(update));
  15758. }
  15759. }
  15760. });
  15761. return results;
  15762. };
  15763. SpringRef.current = current;
  15764. SpringRef.add = function (ctrl) {
  15765. if (!current.includes(ctrl)) {
  15766. current.push(ctrl);
  15767. }
  15768. };
  15769. SpringRef.delete = function (ctrl) {
  15770. const i = current.indexOf(ctrl);
  15771. if (~i) current.splice(i, 1);
  15772. };
  15773. SpringRef.pause = function () {
  15774. react_spring_shared_esm_each(current, ctrl => ctrl.pause(...arguments));
  15775. return this;
  15776. };
  15777. SpringRef.resume = function () {
  15778. react_spring_shared_esm_each(current, ctrl => ctrl.resume(...arguments));
  15779. return this;
  15780. };
  15781. SpringRef.set = function (values) {
  15782. react_spring_shared_esm_each(current, ctrl => ctrl.set(values));
  15783. };
  15784. SpringRef.start = function (props) {
  15785. const results = [];
  15786. react_spring_shared_esm_each(current, (ctrl, i) => {
  15787. if (react_spring_shared_esm_is.und(props)) {
  15788. results.push(ctrl.start());
  15789. } else {
  15790. const update = this._getProps(props, ctrl, i);
  15791. if (update) {
  15792. results.push(ctrl.start(update));
  15793. }
  15794. }
  15795. });
  15796. return results;
  15797. };
  15798. SpringRef.stop = function () {
  15799. react_spring_shared_esm_each(current, ctrl => ctrl.stop(...arguments));
  15800. return this;
  15801. };
  15802. SpringRef.update = function (props) {
  15803. react_spring_shared_esm_each(current, (ctrl, i) => ctrl.update(this._getProps(props, ctrl, i)));
  15804. return this;
  15805. };
  15806. const _getProps = function _getProps(arg, ctrl, index) {
  15807. return react_spring_shared_esm_is.fun(arg) ? arg(index, ctrl) : arg;
  15808. };
  15809. SpringRef._getProps = _getProps;
  15810. return SpringRef;
  15811. };
  15812. function useSprings(length, props, deps) {
  15813. const propsFn = react_spring_shared_esm_is.fun(props) && props;
  15814. if (propsFn && !deps) deps = [];
  15815. const ref = (0,external_React_.useMemo)(() => propsFn || arguments.length == 3 ? SpringRef() : void 0, []);
  15816. const layoutId = (0,external_React_.useRef)(0);
  15817. const forceUpdate = react_spring_shared_esm_useForceUpdate();
  15818. const state = (0,external_React_.useMemo)(() => ({
  15819. ctrls: [],
  15820. queue: [],
  15821. flush(ctrl, updates) {
  15822. const springs = getSprings(ctrl, updates);
  15823. const canFlushSync = layoutId.current > 0 && !state.queue.length && !Object.keys(springs).some(key => !ctrl.springs[key]);
  15824. return canFlushSync ? flushUpdateQueue(ctrl, updates) : new Promise(resolve => {
  15825. setSprings(ctrl, springs);
  15826. state.queue.push(() => {
  15827. resolve(flushUpdateQueue(ctrl, updates));
  15828. });
  15829. forceUpdate();
  15830. });
  15831. }
  15832. }), []);
  15833. const ctrls = (0,external_React_.useRef)([...state.ctrls]);
  15834. const updates = [];
  15835. const prevLength = react_spring_shared_esm_usePrev(length) || 0;
  15836. (0,external_React_.useMemo)(() => {
  15837. react_spring_shared_esm_each(ctrls.current.slice(length, prevLength), ctrl => {
  15838. detachRefs(ctrl, ref);
  15839. ctrl.stop(true);
  15840. });
  15841. ctrls.current.length = length;
  15842. declareUpdates(prevLength, length);
  15843. }, [length]);
  15844. (0,external_React_.useMemo)(() => {
  15845. declareUpdates(0, Math.min(prevLength, length));
  15846. }, deps);
  15847. function declareUpdates(startIndex, endIndex) {
  15848. for (let i = startIndex; i < endIndex; i++) {
  15849. const ctrl = ctrls.current[i] || (ctrls.current[i] = new Controller(null, state.flush));
  15850. const update = propsFn ? propsFn(i, ctrl) : props[i];
  15851. if (update) {
  15852. updates[i] = declareUpdate(update);
  15853. }
  15854. }
  15855. }
  15856. const springs = ctrls.current.map((ctrl, i) => getSprings(ctrl, updates[i]));
  15857. const context = (0,external_React_.useContext)(SpringContext);
  15858. const prevContext = react_spring_shared_esm_usePrev(context);
  15859. const hasContext = context !== prevContext && hasProps(context);
  15860. react_spring_shared_esm_useIsomorphicLayoutEffect(() => {
  15861. layoutId.current++;
  15862. state.ctrls = ctrls.current;
  15863. const {
  15864. queue
  15865. } = state;
  15866. if (queue.length) {
  15867. state.queue = [];
  15868. react_spring_shared_esm_each(queue, cb => cb());
  15869. }
  15870. react_spring_shared_esm_each(ctrls.current, (ctrl, i) => {
  15871. ref == null ? void 0 : ref.add(ctrl);
  15872. if (hasContext) {
  15873. ctrl.start({
  15874. default: context
  15875. });
  15876. }
  15877. const update = updates[i];
  15878. if (update) {
  15879. replaceRef(ctrl, update.ref);
  15880. if (ctrl.ref) {
  15881. ctrl.queue.push(update);
  15882. } else {
  15883. ctrl.start(update);
  15884. }
  15885. }
  15886. });
  15887. });
  15888. react_spring_shared_esm_useOnce(() => () => {
  15889. react_spring_shared_esm_each(state.ctrls, ctrl => ctrl.stop(true));
  15890. });
  15891. const values = springs.map(x => react_spring_core_esm_extends({}, x));
  15892. return ref ? [values, ref] : values;
  15893. }
  15894. function useSpring(props, deps) {
  15895. const isFn = react_spring_shared_esm_is.fun(props);
  15896. const [[values], ref] = useSprings(1, isFn ? props : [props], isFn ? deps || [] : deps);
  15897. return isFn || arguments.length == 2 ? [values, ref] : values;
  15898. }
  15899. const initSpringRef = () => SpringRef();
  15900. const useSpringRef = () => useState(initSpringRef)[0];
  15901. function useTrail(length, propsArg, deps) {
  15902. var _passedRef;
  15903. const propsFn = is.fun(propsArg) && propsArg;
  15904. if (propsFn && !deps) deps = [];
  15905. let reverse = true;
  15906. let passedRef = undefined;
  15907. const result = useSprings(length, (i, ctrl) => {
  15908. const props = propsFn ? propsFn(i, ctrl) : propsArg;
  15909. passedRef = props.ref;
  15910. reverse = reverse && props.reverse;
  15911. return props;
  15912. }, deps || [{}]);
  15913. const ref = (_passedRef = passedRef) != null ? _passedRef : result[1];
  15914. useIsomorphicLayoutEffect(() => {
  15915. each(ref.current, (ctrl, i) => {
  15916. const parent = ref.current[i + (reverse ? 1 : -1)];
  15917. if (parent) {
  15918. ctrl.start({
  15919. to: parent.springs
  15920. });
  15921. } else {
  15922. ctrl.start();
  15923. }
  15924. });
  15925. }, deps);
  15926. if (propsFn || arguments.length == 3) {
  15927. ref['_getProps'] = (propsArg, ctrl, i) => {
  15928. const props = is.fun(propsArg) ? propsArg(i, ctrl) : propsArg;
  15929. if (props) {
  15930. const parent = ref.current[i + (props.reverse ? 1 : -1)];
  15931. if (parent) props.to = parent.springs;
  15932. return props;
  15933. }
  15934. };
  15935. return result;
  15936. }
  15937. ref['start'] = propsArg => {
  15938. const results = [];
  15939. each(ref.current, (ctrl, i) => {
  15940. const props = is.fun(propsArg) ? propsArg(i, ctrl) : propsArg;
  15941. const parent = ref.current[i + (reverse ? 1 : -1)];
  15942. if (parent) {
  15943. results.push(ctrl.start(react_spring_core_esm_extends({}, props, {
  15944. to: parent.springs
  15945. })));
  15946. } else {
  15947. results.push(ctrl.start(react_spring_core_esm_extends({}, props)));
  15948. }
  15949. });
  15950. return results;
  15951. };
  15952. return result[0];
  15953. }
  15954. let TransitionPhase;
  15955. (function (TransitionPhase) {
  15956. TransitionPhase["MOUNT"] = "mount";
  15957. TransitionPhase["ENTER"] = "enter";
  15958. TransitionPhase["UPDATE"] = "update";
  15959. TransitionPhase["LEAVE"] = "leave";
  15960. })(TransitionPhase || (TransitionPhase = {}));
  15961. function useTransition(data, props, deps) {
  15962. const propsFn = is.fun(props) && props;
  15963. const {
  15964. reset,
  15965. sort,
  15966. trail = 0,
  15967. expires = true,
  15968. exitBeforeEnter = false,
  15969. onDestroyed,
  15970. ref: propsRef,
  15971. config: propsConfig
  15972. } = propsFn ? propsFn() : props;
  15973. const ref = useMemo(() => propsFn || arguments.length == 3 ? SpringRef() : void 0, []);
  15974. const items = toArray(data);
  15975. const transitions = [];
  15976. const usedTransitions = useRef(null);
  15977. const prevTransitions = reset ? null : usedTransitions.current;
  15978. useIsomorphicLayoutEffect(() => {
  15979. usedTransitions.current = transitions;
  15980. });
  15981. useOnce(() => {
  15982. each(transitions, t => {
  15983. ref == null ? void 0 : ref.add(t.ctrl);
  15984. t.ctrl.ref = ref;
  15985. });
  15986. return () => {
  15987. each(usedTransitions.current, t => {
  15988. if (t.expired) {
  15989. clearTimeout(t.expirationId);
  15990. }
  15991. detachRefs(t.ctrl, ref);
  15992. t.ctrl.stop(true);
  15993. });
  15994. };
  15995. });
  15996. const keys = getKeys(items, propsFn ? propsFn() : props, prevTransitions);
  15997. const expired = reset && usedTransitions.current || [];
  15998. useIsomorphicLayoutEffect(() => each(expired, ({
  15999. ctrl,
  16000. item,
  16001. key
  16002. }) => {
  16003. detachRefs(ctrl, ref);
  16004. callProp(onDestroyed, item, key);
  16005. }));
  16006. const reused = [];
  16007. if (prevTransitions) each(prevTransitions, (t, i) => {
  16008. if (t.expired) {
  16009. clearTimeout(t.expirationId);
  16010. expired.push(t);
  16011. } else {
  16012. i = reused[i] = keys.indexOf(t.key);
  16013. if (~i) transitions[i] = t;
  16014. }
  16015. });
  16016. each(items, (item, i) => {
  16017. if (!transitions[i]) {
  16018. transitions[i] = {
  16019. key: keys[i],
  16020. item,
  16021. phase: TransitionPhase.MOUNT,
  16022. ctrl: new Controller()
  16023. };
  16024. transitions[i].ctrl.item = item;
  16025. }
  16026. });
  16027. if (reused.length) {
  16028. let i = -1;
  16029. const {
  16030. leave
  16031. } = propsFn ? propsFn() : props;
  16032. each(reused, (keyIndex, prevIndex) => {
  16033. const t = prevTransitions[prevIndex];
  16034. if (~keyIndex) {
  16035. i = transitions.indexOf(t);
  16036. transitions[i] = react_spring_core_esm_extends({}, t, {
  16037. item: items[keyIndex]
  16038. });
  16039. } else if (leave) {
  16040. transitions.splice(++i, 0, t);
  16041. }
  16042. });
  16043. }
  16044. if (is.fun(sort)) {
  16045. transitions.sort((a, b) => sort(a.item, b.item));
  16046. }
  16047. let delay = -trail;
  16048. const forceUpdate = useForceUpdate();
  16049. const defaultProps = getDefaultProps(props);
  16050. const changes = new Map();
  16051. const exitingTransitions = useRef(new Map());
  16052. const forceChange = useRef(false);
  16053. each(transitions, (t, i) => {
  16054. const key = t.key;
  16055. const prevPhase = t.phase;
  16056. const p = propsFn ? propsFn() : props;
  16057. let to;
  16058. let phase;
  16059. let propsDelay = callProp(p.delay || 0, key);
  16060. if (prevPhase == TransitionPhase.MOUNT) {
  16061. to = p.enter;
  16062. phase = TransitionPhase.ENTER;
  16063. } else {
  16064. const isLeave = keys.indexOf(key) < 0;
  16065. if (prevPhase != TransitionPhase.LEAVE) {
  16066. if (isLeave) {
  16067. to = p.leave;
  16068. phase = TransitionPhase.LEAVE;
  16069. } else if (to = p.update) {
  16070. phase = TransitionPhase.UPDATE;
  16071. } else return;
  16072. } else if (!isLeave) {
  16073. to = p.enter;
  16074. phase = TransitionPhase.ENTER;
  16075. } else return;
  16076. }
  16077. to = callProp(to, t.item, i);
  16078. to = is.obj(to) ? inferTo(to) : {
  16079. to
  16080. };
  16081. if (!to.config) {
  16082. const config = propsConfig || defaultProps.config;
  16083. to.config = callProp(config, t.item, i, phase);
  16084. }
  16085. delay += trail;
  16086. const payload = react_spring_core_esm_extends({}, defaultProps, {
  16087. delay: propsDelay + delay,
  16088. ref: propsRef,
  16089. immediate: p.immediate,
  16090. reset: false
  16091. }, to);
  16092. if (phase == TransitionPhase.ENTER && is.und(payload.from)) {
  16093. const _p = propsFn ? propsFn() : props;
  16094. const from = is.und(_p.initial) || prevTransitions ? _p.from : _p.initial;
  16095. payload.from = callProp(from, t.item, i);
  16096. }
  16097. const {
  16098. onResolve
  16099. } = payload;
  16100. payload.onResolve = result => {
  16101. callProp(onResolve, result);
  16102. const transitions = usedTransitions.current;
  16103. const t = transitions.find(t => t.key === key);
  16104. if (!t) return;
  16105. if (result.cancelled && t.phase != TransitionPhase.UPDATE) {
  16106. return;
  16107. }
  16108. if (t.ctrl.idle) {
  16109. const idle = transitions.every(t => t.ctrl.idle);
  16110. if (t.phase == TransitionPhase.LEAVE) {
  16111. const expiry = callProp(expires, t.item);
  16112. if (expiry !== false) {
  16113. const expiryMs = expiry === true ? 0 : expiry;
  16114. t.expired = true;
  16115. if (!idle && expiryMs > 0) {
  16116. if (expiryMs <= 0x7fffffff) t.expirationId = setTimeout(forceUpdate, expiryMs);
  16117. return;
  16118. }
  16119. }
  16120. }
  16121. if (idle && transitions.some(t => t.expired)) {
  16122. exitingTransitions.current.delete(t);
  16123. if (exitBeforeEnter) {
  16124. forceChange.current = true;
  16125. }
  16126. forceUpdate();
  16127. }
  16128. }
  16129. };
  16130. const springs = getSprings(t.ctrl, payload);
  16131. if (phase === TransitionPhase.LEAVE && exitBeforeEnter) {
  16132. exitingTransitions.current.set(t, {
  16133. phase,
  16134. springs,
  16135. payload
  16136. });
  16137. } else {
  16138. changes.set(t, {
  16139. phase,
  16140. springs,
  16141. payload
  16142. });
  16143. }
  16144. });
  16145. const context = useContext(SpringContext);
  16146. const prevContext = usePrev(context);
  16147. const hasContext = context !== prevContext && hasProps(context);
  16148. useIsomorphicLayoutEffect(() => {
  16149. if (hasContext) {
  16150. each(transitions, t => {
  16151. t.ctrl.start({
  16152. default: context
  16153. });
  16154. });
  16155. }
  16156. }, [context]);
  16157. each(changes, (_, t) => {
  16158. if (exitingTransitions.current.size) {
  16159. const ind = transitions.findIndex(state => state.key === t.key);
  16160. transitions.splice(ind, 1);
  16161. }
  16162. });
  16163. useIsomorphicLayoutEffect(() => {
  16164. each(exitingTransitions.current.size ? exitingTransitions.current : changes, ({
  16165. phase,
  16166. payload
  16167. }, t) => {
  16168. const {
  16169. ctrl
  16170. } = t;
  16171. t.phase = phase;
  16172. ref == null ? void 0 : ref.add(ctrl);
  16173. if (hasContext && phase == TransitionPhase.ENTER) {
  16174. ctrl.start({
  16175. default: context
  16176. });
  16177. }
  16178. if (payload) {
  16179. replaceRef(ctrl, payload.ref);
  16180. if ((ctrl.ref || ref) && !forceChange.current) {
  16181. ctrl.update(payload);
  16182. } else {
  16183. ctrl.start(payload);
  16184. if (forceChange.current) {
  16185. forceChange.current = false;
  16186. }
  16187. }
  16188. }
  16189. });
  16190. }, reset ? void 0 : deps);
  16191. const renderTransitions = render => React.createElement(React.Fragment, null, transitions.map((t, i) => {
  16192. const {
  16193. springs
  16194. } = changes.get(t) || t.ctrl;
  16195. const elem = render(react_spring_core_esm_extends({}, springs), t.item, t, i);
  16196. return elem && elem.type ? React.createElement(elem.type, react_spring_core_esm_extends({}, elem.props, {
  16197. key: is.str(t.key) || is.num(t.key) ? t.key : t.ctrl.id,
  16198. ref: elem.ref
  16199. })) : elem;
  16200. }));
  16201. return ref ? [renderTransitions, ref] : renderTransitions;
  16202. }
  16203. let nextKey = 1;
  16204. function getKeys(items, {
  16205. key,
  16206. keys = key
  16207. }, prevTransitions) {
  16208. if (keys === null) {
  16209. const reused = new Set();
  16210. return items.map(item => {
  16211. const t = prevTransitions && prevTransitions.find(t => t.item === item && t.phase !== TransitionPhase.LEAVE && !reused.has(t));
  16212. if (t) {
  16213. reused.add(t);
  16214. return t.key;
  16215. }
  16216. return nextKey++;
  16217. });
  16218. }
  16219. return is.und(keys) ? items : is.fun(keys) ? items.map(keys) : toArray(keys);
  16220. }
  16221. const _excluded$2 = (/* unused pure expression or super */ null && (["children"]));
  16222. function Spring(_ref) {
  16223. let {
  16224. children
  16225. } = _ref,
  16226. props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
  16227. return children(useSpring(props));
  16228. }
  16229. const _excluded$1 = (/* unused pure expression or super */ null && (["items", "children"]));
  16230. function Trail(_ref) {
  16231. let {
  16232. items,
  16233. children
  16234. } = _ref,
  16235. props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
  16236. const trails = useTrail(items.length, props);
  16237. return items.map((item, index) => {
  16238. const result = children(item, index);
  16239. return is.fun(result) ? result(trails[index]) : result;
  16240. });
  16241. }
  16242. const _excluded = (/* unused pure expression or super */ null && (["items", "children"]));
  16243. function Transition(_ref) {
  16244. let {
  16245. items,
  16246. children
  16247. } = _ref,
  16248. props = _objectWithoutPropertiesLoose(_ref, _excluded);
  16249. return useTransition(items, props)(children);
  16250. }
  16251. class Interpolation extends FrameValue {
  16252. constructor(source, args) {
  16253. super();
  16254. this.key = void 0;
  16255. this.idle = true;
  16256. this.calc = void 0;
  16257. this._active = new Set();
  16258. this.source = source;
  16259. this.calc = createInterpolator(...args);
  16260. const value = this._get();
  16261. const nodeType = getAnimatedType(value);
  16262. setAnimated(this, nodeType.create(value));
  16263. }
  16264. advance(_dt) {
  16265. const value = this._get();
  16266. const oldValue = this.get();
  16267. if (!isEqual(value, oldValue)) {
  16268. getAnimated(this).setValue(value);
  16269. this._onChange(value, this.idle);
  16270. }
  16271. if (!this.idle && checkIdle(this._active)) {
  16272. becomeIdle(this);
  16273. }
  16274. }
  16275. _get() {
  16276. const inputs = react_spring_shared_esm_is.arr(this.source) ? this.source.map(getFluidValue) : react_spring_shared_esm_toArray(getFluidValue(this.source));
  16277. return this.calc(...inputs);
  16278. }
  16279. _start() {
  16280. if (this.idle && !checkIdle(this._active)) {
  16281. this.idle = false;
  16282. react_spring_shared_esm_each(getPayload(this), node => {
  16283. node.done = false;
  16284. });
  16285. if (globals.skipAnimation) {
  16286. raf.batchedUpdates(() => this.advance());
  16287. becomeIdle(this);
  16288. } else {
  16289. frameLoop.start(this);
  16290. }
  16291. }
  16292. }
  16293. _attach() {
  16294. let priority = 1;
  16295. react_spring_shared_esm_each(react_spring_shared_esm_toArray(this.source), source => {
  16296. if (hasFluidValue(source)) {
  16297. addFluidObserver(source, this);
  16298. }
  16299. if (isFrameValue(source)) {
  16300. if (!source.idle) {
  16301. this._active.add(source);
  16302. }
  16303. priority = Math.max(priority, source.priority + 1);
  16304. }
  16305. });
  16306. this.priority = priority;
  16307. this._start();
  16308. }
  16309. _detach() {
  16310. react_spring_shared_esm_each(react_spring_shared_esm_toArray(this.source), source => {
  16311. if (hasFluidValue(source)) {
  16312. removeFluidObserver(source, this);
  16313. }
  16314. });
  16315. this._active.clear();
  16316. becomeIdle(this);
  16317. }
  16318. eventObserved(event) {
  16319. if (event.type == 'change') {
  16320. if (event.idle) {
  16321. this.advance();
  16322. } else {
  16323. this._active.add(event.parent);
  16324. this._start();
  16325. }
  16326. } else if (event.type == 'idle') {
  16327. this._active.delete(event.parent);
  16328. } else if (event.type == 'priority') {
  16329. this.priority = react_spring_shared_esm_toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0);
  16330. }
  16331. }
  16332. }
  16333. function isIdle(source) {
  16334. return source.idle !== false;
  16335. }
  16336. function checkIdle(active) {
  16337. return !active.size || Array.from(active).every(isIdle);
  16338. }
  16339. function becomeIdle(self) {
  16340. if (!self.idle) {
  16341. self.idle = true;
  16342. react_spring_shared_esm_each(getPayload(self), node => {
  16343. node.done = true;
  16344. });
  16345. callFluidObservers(self, {
  16346. type: 'idle',
  16347. parent: self
  16348. });
  16349. }
  16350. }
  16351. const react_spring_core_esm_to = (source, ...args) => new Interpolation(source, args);
  16352. const react_spring_core_esm_interpolate = (source, ...args) => (deprecateInterpolate(), new Interpolation(source, args));
  16353. globals.assign({
  16354. createStringInterpolator: createStringInterpolator,
  16355. to: (source, args) => new Interpolation(source, args)
  16356. });
  16357. const react_spring_core_esm_update = frameLoop.advance;
  16358. ;// CONCATENATED MODULE: external "ReactDOM"
  16359. var external_ReactDOM_namespaceObject = window["ReactDOM"];
  16360. ;// CONCATENATED MODULE: ./node_modules/@react-spring/web/dist/react-spring-web.esm.js
  16361. function react_spring_web_esm_objectWithoutPropertiesLoose(source, excluded) {
  16362. if (source == null) return {};
  16363. var target = {};
  16364. var sourceKeys = Object.keys(source);
  16365. var key, i;
  16366. for (i = 0; i < sourceKeys.length; i++) {
  16367. key = sourceKeys[i];
  16368. if (excluded.indexOf(key) >= 0) continue;
  16369. target[key] = source[key];
  16370. }
  16371. return target;
  16372. }
  16373. const react_spring_web_esm_excluded$2 = ["style", "children", "scrollTop", "scrollLeft"];
  16374. const isCustomPropRE = /^--/;
  16375. function dangerousStyleValue(name, value) {
  16376. if (value == null || typeof value === 'boolean' || value === '') return '';
  16377. if (typeof value === 'number' && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px';
  16378. return ('' + value).trim();
  16379. }
  16380. const attributeCache = {};
  16381. function applyAnimatedValues(instance, props) {
  16382. if (!instance.nodeType || !instance.setAttribute) {
  16383. return false;
  16384. }
  16385. const isFilterElement = instance.nodeName === 'filter' || instance.parentNode && instance.parentNode.nodeName === 'filter';
  16386. const _ref = props,
  16387. {
  16388. style,
  16389. children,
  16390. scrollTop,
  16391. scrollLeft
  16392. } = _ref,
  16393. attributes = react_spring_web_esm_objectWithoutPropertiesLoose(_ref, react_spring_web_esm_excluded$2);
  16394. const values = Object.values(attributes);
  16395. const names = Object.keys(attributes).map(name => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, n => '-' + n.toLowerCase())));
  16396. if (children !== void 0) {
  16397. instance.textContent = children;
  16398. }
  16399. for (let name in style) {
  16400. if (style.hasOwnProperty(name)) {
  16401. const value = dangerousStyleValue(name, style[name]);
  16402. if (isCustomPropRE.test(name)) {
  16403. instance.style.setProperty(name, value);
  16404. } else {
  16405. instance.style[name] = value;
  16406. }
  16407. }
  16408. }
  16409. names.forEach((name, i) => {
  16410. instance.setAttribute(name, values[i]);
  16411. });
  16412. if (scrollTop !== void 0) {
  16413. instance.scrollTop = scrollTop;
  16414. }
  16415. if (scrollLeft !== void 0) {
  16416. instance.scrollLeft = scrollLeft;
  16417. }
  16418. }
  16419. let isUnitlessNumber = {
  16420. animationIterationCount: true,
  16421. borderImageOutset: true,
  16422. borderImageSlice: true,
  16423. borderImageWidth: true,
  16424. boxFlex: true,
  16425. boxFlexGroup: true,
  16426. boxOrdinalGroup: true,
  16427. columnCount: true,
  16428. columns: true,
  16429. flex: true,
  16430. flexGrow: true,
  16431. flexPositive: true,
  16432. flexShrink: true,
  16433. flexNegative: true,
  16434. flexOrder: true,
  16435. gridRow: true,
  16436. gridRowEnd: true,
  16437. gridRowSpan: true,
  16438. gridRowStart: true,
  16439. gridColumn: true,
  16440. gridColumnEnd: true,
  16441. gridColumnSpan: true,
  16442. gridColumnStart: true,
  16443. fontWeight: true,
  16444. lineClamp: true,
  16445. lineHeight: true,
  16446. opacity: true,
  16447. order: true,
  16448. orphans: true,
  16449. tabSize: true,
  16450. widows: true,
  16451. zIndex: true,
  16452. zoom: true,
  16453. fillOpacity: true,
  16454. floodOpacity: true,
  16455. stopOpacity: true,
  16456. strokeDasharray: true,
  16457. strokeDashoffset: true,
  16458. strokeMiterlimit: true,
  16459. strokeOpacity: true,
  16460. strokeWidth: true
  16461. };
  16462. const prefixKey = (prefix, key) => prefix + key.charAt(0).toUpperCase() + key.substring(1);
  16463. const prefixes = ['Webkit', 'Ms', 'Moz', 'O'];
  16464. isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
  16465. prefixes.forEach(prefix => acc[prefixKey(prefix, prop)] = acc[prop]);
  16466. return acc;
  16467. }, isUnitlessNumber);
  16468. const react_spring_web_esm_excluded$1 = ["x", "y", "z"];
  16469. const domTransforms = /^(matrix|translate|scale|rotate|skew)/;
  16470. const pxTransforms = /^(translate)/;
  16471. const degTransforms = /^(rotate|skew)/;
  16472. const addUnit = (value, unit) => react_spring_shared_esm_is.num(value) && value !== 0 ? value + unit : value;
  16473. const isValueIdentity = (value, id) => react_spring_shared_esm_is.arr(value) ? value.every(v => isValueIdentity(v, id)) : react_spring_shared_esm_is.num(value) ? value === id : parseFloat(value) === id;
  16474. class AnimatedStyle extends AnimatedObject {
  16475. constructor(_ref) {
  16476. let {
  16477. x,
  16478. y,
  16479. z
  16480. } = _ref,
  16481. style = react_spring_web_esm_objectWithoutPropertiesLoose(_ref, react_spring_web_esm_excluded$1);
  16482. const inputs = [];
  16483. const transforms = [];
  16484. if (x || y || z) {
  16485. inputs.push([x || 0, y || 0, z || 0]);
  16486. transforms.push(xyz => [`translate3d(${xyz.map(v => addUnit(v, 'px')).join(',')})`, isValueIdentity(xyz, 0)]);
  16487. }
  16488. eachProp(style, (value, key) => {
  16489. if (key === 'transform') {
  16490. inputs.push([value || '']);
  16491. transforms.push(transform => [transform, transform === '']);
  16492. } else if (domTransforms.test(key)) {
  16493. delete style[key];
  16494. if (react_spring_shared_esm_is.und(value)) return;
  16495. const unit = pxTransforms.test(key) ? 'px' : degTransforms.test(key) ? 'deg' : '';
  16496. inputs.push(react_spring_shared_esm_toArray(value));
  16497. transforms.push(key === 'rotate3d' ? ([x, y, z, deg]) => [`rotate3d(${x},${y},${z},${addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : input => [`${key}(${input.map(v => addUnit(v, unit)).join(',')})`, isValueIdentity(input, key.startsWith('scale') ? 1 : 0)]);
  16498. }
  16499. });
  16500. if (inputs.length) {
  16501. style.transform = new FluidTransform(inputs, transforms);
  16502. }
  16503. super(style);
  16504. }
  16505. }
  16506. class FluidTransform extends FluidValue {
  16507. constructor(inputs, transforms) {
  16508. super();
  16509. this._value = null;
  16510. this.inputs = inputs;
  16511. this.transforms = transforms;
  16512. }
  16513. get() {
  16514. return this._value || (this._value = this._get());
  16515. }
  16516. _get() {
  16517. let transform = '';
  16518. let identity = true;
  16519. react_spring_shared_esm_each(this.inputs, (input, i) => {
  16520. const arg1 = getFluidValue(input[0]);
  16521. const [t, id] = this.transforms[i](react_spring_shared_esm_is.arr(arg1) ? arg1 : input.map(getFluidValue));
  16522. transform += ' ' + t;
  16523. identity = identity && id;
  16524. });
  16525. return identity ? 'none' : transform;
  16526. }
  16527. observerAdded(count) {
  16528. if (count == 1) react_spring_shared_esm_each(this.inputs, input => react_spring_shared_esm_each(input, value => hasFluidValue(value) && addFluidObserver(value, this)));
  16529. }
  16530. observerRemoved(count) {
  16531. if (count == 0) react_spring_shared_esm_each(this.inputs, input => react_spring_shared_esm_each(input, value => hasFluidValue(value) && removeFluidObserver(value, this)));
  16532. }
  16533. eventObserved(event) {
  16534. if (event.type == 'change') {
  16535. this._value = null;
  16536. }
  16537. callFluidObservers(this, event);
  16538. }
  16539. }
  16540. const primitives = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', 'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
  16541. const react_spring_web_esm_excluded = ["scrollTop", "scrollLeft"];
  16542. globals.assign({
  16543. batchedUpdates: external_ReactDOM_namespaceObject.unstable_batchedUpdates,
  16544. createStringInterpolator: createStringInterpolator,
  16545. colors: colors
  16546. });
  16547. const host = createHost(primitives, {
  16548. applyAnimatedValues,
  16549. createAnimatedStyle: style => new AnimatedStyle(style),
  16550. getComponentProps: _ref => {
  16551. let props = react_spring_web_esm_objectWithoutPropertiesLoose(_ref, react_spring_web_esm_excluded);
  16552. return props;
  16553. }
  16554. });
  16555. const animated = host.animated;
  16556. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-moving-animation/index.js
  16557. /**
  16558. * External dependencies
  16559. */
  16560. /**
  16561. * WordPress dependencies
  16562. */
  16563. /**
  16564. * Simple reducer used to increment a counter.
  16565. *
  16566. * @param {number} state Previous counter value.
  16567. * @return {number} New state value.
  16568. */
  16569. const counterReducer = state => state + 1;
  16570. const getAbsolutePosition = element => {
  16571. return {
  16572. top: element.offsetTop,
  16573. left: element.offsetLeft
  16574. };
  16575. };
  16576. /**
  16577. * Hook used to compute the styles required to move a div into a new position.
  16578. *
  16579. * The way this animation works is the following:
  16580. * - It first renders the element as if there was no animation.
  16581. * - It takes a snapshot of the position of the block to use it
  16582. * as a destination point for the animation.
  16583. * - It restores the element to the previous position using a CSS transform
  16584. * - It uses the "resetAnimation" flag to reset the animation
  16585. * from the beginning in order to animate to the new destination point.
  16586. *
  16587. * @param {Object} $1 Options
  16588. * @param {boolean} $1.isSelected Whether it's the current block or not.
  16589. * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.
  16590. * @param {boolean} $1.enableAnimation Enable/Disable animation.
  16591. * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.
  16592. */
  16593. function useMovingAnimation(_ref) {
  16594. let {
  16595. isSelected,
  16596. adjustScrolling,
  16597. enableAnimation,
  16598. triggerAnimationOnChange
  16599. } = _ref;
  16600. const ref = (0,external_wp_element_namespaceObject.useRef)();
  16601. const prefersReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)() || !enableAnimation;
  16602. const [triggeredAnimation, triggerAnimation] = (0,external_wp_element_namespaceObject.useReducer)(counterReducer, 0);
  16603. const [finishedAnimation, endAnimation] = (0,external_wp_element_namespaceObject.useReducer)(counterReducer, 0);
  16604. const [transform, setTransform] = (0,external_wp_element_namespaceObject.useState)({
  16605. x: 0,
  16606. y: 0
  16607. });
  16608. const previous = (0,external_wp_element_namespaceObject.useMemo)(() => ref.current ? getAbsolutePosition(ref.current) : null, [triggerAnimationOnChange]); // Calculate the previous position of the block relative to the viewport and
  16609. // return a function to maintain that position by scrolling.
  16610. const preserveScrollPosition = (0,external_wp_element_namespaceObject.useMemo)(() => {
  16611. if (!adjustScrolling || !ref.current) {
  16612. return () => {};
  16613. }
  16614. const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(ref.current);
  16615. if (!scrollContainer) {
  16616. return () => {};
  16617. }
  16618. const prevRect = ref.current.getBoundingClientRect();
  16619. return () => {
  16620. const blockRect = ref.current.getBoundingClientRect();
  16621. const diff = blockRect.top - prevRect.top;
  16622. if (diff) {
  16623. scrollContainer.scrollTop += diff;
  16624. }
  16625. };
  16626. }, [triggerAnimationOnChange, adjustScrolling]);
  16627. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  16628. if (triggeredAnimation) {
  16629. endAnimation();
  16630. }
  16631. }, [triggeredAnimation]);
  16632. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  16633. if (!previous) {
  16634. return;
  16635. }
  16636. if (prefersReducedMotion) {
  16637. // If the animation is disabled and the scroll needs to be adjusted,
  16638. // just move directly to the final scroll position.
  16639. preserveScrollPosition();
  16640. return;
  16641. }
  16642. ref.current.style.transform = undefined;
  16643. const destination = getAbsolutePosition(ref.current);
  16644. triggerAnimation();
  16645. setTransform({
  16646. x: Math.round(previous.left - destination.left),
  16647. y: Math.round(previous.top - destination.top)
  16648. });
  16649. }, [triggerAnimationOnChange]);
  16650. function onChange(_ref2) {
  16651. let {
  16652. value
  16653. } = _ref2;
  16654. if (!ref.current) {
  16655. return;
  16656. }
  16657. let {
  16658. x,
  16659. y
  16660. } = value;
  16661. x = Math.round(x);
  16662. y = Math.round(y);
  16663. const finishedMoving = x === 0 && y === 0;
  16664. ref.current.style.transformOrigin = 'center center';
  16665. ref.current.style.transform = finishedMoving ? undefined : `translate3d(${x}px,${y}px,0)`;
  16666. ref.current.style.zIndex = isSelected ? '1' : '';
  16667. preserveScrollPosition();
  16668. }
  16669. useSpring({
  16670. from: {
  16671. x: transform.x,
  16672. y: transform.y
  16673. },
  16674. to: {
  16675. x: 0,
  16676. y: 0
  16677. },
  16678. reset: triggeredAnimation !== finishedAnimation,
  16679. config: {
  16680. mass: 5,
  16681. tension: 2000,
  16682. friction: 200
  16683. },
  16684. immediate: prefersReducedMotion,
  16685. onChange
  16686. });
  16687. return ref;
  16688. }
  16689. /* harmony default export */ var use_moving_animation = (useMovingAnimation);
  16690. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/dom.js
  16691. const BLOCK_SELECTOR = '.block-editor-block-list__block';
  16692. const APPENDER_SELECTOR = '.block-list-appender';
  16693. const BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender';
  16694. /**
  16695. * Returns true if two elements are contained within the same block.
  16696. *
  16697. * @param {Element} a First element.
  16698. * @param {Element} b Second element.
  16699. *
  16700. * @return {boolean} Whether elements are in the same block.
  16701. */
  16702. function isInSameBlock(a, b) {
  16703. return a.closest(BLOCK_SELECTOR) === b.closest(BLOCK_SELECTOR);
  16704. }
  16705. /**
  16706. * Returns true if an element is considered part of the block and not its inner
  16707. * blocks or appender.
  16708. *
  16709. * @param {Element} blockElement Block container element.
  16710. * @param {Element} element Element.
  16711. *
  16712. * @return {boolean} Whether an element is considered part of the block and not
  16713. * its inner blocks or appender.
  16714. */
  16715. function isInsideRootBlock(blockElement, element) {
  16716. const parentBlock = element.closest([BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS].join(','));
  16717. return parentBlock === blockElement;
  16718. }
  16719. /**
  16720. * Finds the block client ID given any DOM node inside the block.
  16721. *
  16722. * @param {Node?} node DOM node.
  16723. *
  16724. * @return {string|undefined} Client ID or undefined if the node is not part of
  16725. * a block.
  16726. */
  16727. function getBlockClientId(node) {
  16728. while (node && node.nodeType !== node.ELEMENT_NODE) {
  16729. node = node.parentNode;
  16730. }
  16731. if (!node) {
  16732. return;
  16733. }
  16734. const elementNode =
  16735. /** @type {Element} */
  16736. node;
  16737. const blockNode = elementNode.closest(BLOCK_SELECTOR);
  16738. if (!blockNode) {
  16739. return;
  16740. }
  16741. return blockNode.id.slice('block-'.length);
  16742. }
  16743. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-focus-first-element.js
  16744. /**
  16745. * WordPress dependencies
  16746. */
  16747. /**
  16748. * Internal dependencies
  16749. */
  16750. /** @typedef {import('@wordpress/element').RefObject} RefObject */
  16751. /**
  16752. * Returns the initial position if the block needs to be focussed, `undefined`
  16753. * otherwise. The initial position is either 0 (start) or -1 (end).
  16754. *
  16755. * @param {string} clientId Block client ID.
  16756. *
  16757. * @return {number} The initial position, either 0 (start) or -1 (end).
  16758. */
  16759. function useInitialPosition(clientId) {
  16760. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  16761. const {
  16762. getSelectedBlocksInitialCaretPosition,
  16763. __unstableGetEditorMode,
  16764. isBlockSelected
  16765. } = select(store);
  16766. if (!isBlockSelected(clientId)) {
  16767. return;
  16768. }
  16769. if (__unstableGetEditorMode() !== 'edit') {
  16770. return;
  16771. } // If there's no initial position, return 0 to focus the start.
  16772. return getSelectedBlocksInitialCaretPosition();
  16773. }, [clientId]);
  16774. }
  16775. /**
  16776. * Transitions focus to the block or inner tabbable when the block becomes
  16777. * selected and an initial position is set.
  16778. *
  16779. * @param {string} clientId Block client ID.
  16780. *
  16781. * @return {RefObject} React ref with the block element.
  16782. */
  16783. function useFocusFirstElement(clientId) {
  16784. const ref = (0,external_wp_element_namespaceObject.useRef)();
  16785. const initialPosition = useInitialPosition(clientId);
  16786. const {
  16787. isBlockSelected,
  16788. isMultiSelecting
  16789. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  16790. (0,external_wp_element_namespaceObject.useEffect)(() => {
  16791. // Check if the block is still selected at the time this effect runs.
  16792. if (!isBlockSelected(clientId) || isMultiSelecting()) {
  16793. return;
  16794. }
  16795. if (initialPosition === undefined || initialPosition === null) {
  16796. return;
  16797. }
  16798. if (!ref.current) {
  16799. return;
  16800. }
  16801. const {
  16802. ownerDocument
  16803. } = ref.current; // Do not focus the block if it already contains the active element.
  16804. if (isInsideRootBlock(ref.current, ownerDocument.activeElement)) {
  16805. return;
  16806. } // Find all tabbables within node.
  16807. const textInputs = external_wp_dom_namespaceObject.focus.tabbable.find(ref.current).filter(node => (0,external_wp_dom_namespaceObject.isTextField)(node)); // If reversed (e.g. merge via backspace), use the last in the set of
  16808. // tabbables.
  16809. const isReverse = -1 === initialPosition;
  16810. const target = textInputs[isReverse ? textInputs.length - 1 : 0] || ref.current;
  16811. if (!isInsideRootBlock(ref.current, target)) {
  16812. ref.current.focus();
  16813. return;
  16814. } // Check to see if element is focussable before a generic caret insert.
  16815. if (!ref.current.getAttribute('contenteditable')) {
  16816. const focusElement = external_wp_dom_namespaceObject.focus.tabbable.findNext(ref.current); // Make sure focusElement is valid, contained in the same block, and a form field.
  16817. if (focusElement && isInsideRootBlock(ref.current, focusElement) && (0,external_wp_dom_namespaceObject.isFormElement)(focusElement)) {
  16818. focusElement.focus();
  16819. return;
  16820. }
  16821. }
  16822. (0,external_wp_dom_namespaceObject.placeCaretAtHorizontalEdge)(target, isReverse);
  16823. }, [initialPosition, clientId]);
  16824. return ref;
  16825. }
  16826. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-is-hovered.js
  16827. /**
  16828. * WordPress dependencies
  16829. */
  16830. /**
  16831. * Internal dependencies
  16832. */
  16833. function listener(event) {
  16834. if (event.defaultPrevented) {
  16835. return;
  16836. }
  16837. const action = event.type === 'mouseover' ? 'add' : 'remove';
  16838. event.preventDefault();
  16839. event.currentTarget.classList[action]('is-hovered');
  16840. }
  16841. /**
  16842. * Adds `is-hovered` class when the block is hovered and in navigation or
  16843. * outline mode.
  16844. */
  16845. function useIsHovered() {
  16846. const isEnabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
  16847. const {
  16848. getSettings
  16849. } = select(store);
  16850. return getSettings().outlineMode;
  16851. }, []);
  16852. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  16853. if (isEnabled) {
  16854. node.addEventListener('mouseout', listener);
  16855. node.addEventListener('mouseover', listener);
  16856. return () => {
  16857. node.removeEventListener('mouseout', listener);
  16858. node.removeEventListener('mouseover', listener); // Remove class in case it lingers.
  16859. node.classList.remove('is-hovered');
  16860. };
  16861. }
  16862. }, [isEnabled]);
  16863. }
  16864. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-class-names.js
  16865. /**
  16866. * External dependencies
  16867. */
  16868. /**
  16869. * WordPress dependencies
  16870. */
  16871. /**
  16872. * Internal dependencies
  16873. */
  16874. /**
  16875. * Returns the class names used for the different states of the block.
  16876. *
  16877. * @param {string} clientId The block client ID.
  16878. *
  16879. * @return {string} The class names.
  16880. */
  16881. function useBlockClassNames(clientId) {
  16882. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  16883. const {
  16884. isBlockBeingDragged,
  16885. isBlockHighlighted,
  16886. isBlockSelected,
  16887. isBlockMultiSelected,
  16888. getBlockName,
  16889. getSettings,
  16890. hasSelectedInnerBlock,
  16891. isTyping,
  16892. __unstableIsFullySelected,
  16893. __unstableSelectionHasUnmergeableBlock
  16894. } = select(store);
  16895. const {
  16896. outlineMode
  16897. } = getSettings();
  16898. const isDragging = isBlockBeingDragged(clientId);
  16899. const isSelected = isBlockSelected(clientId);
  16900. const name = getBlockName(clientId);
  16901. const checkDeep = true; // "ancestor" is the more appropriate label due to "deep" check.
  16902. const isAncestorOfSelectedBlock = hasSelectedInnerBlock(clientId, checkDeep);
  16903. const isMultiSelected = isBlockMultiSelected(clientId);
  16904. return classnames_default()({
  16905. 'is-selected': isSelected,
  16906. 'is-highlighted': isBlockHighlighted(clientId),
  16907. 'is-multi-selected': isMultiSelected,
  16908. 'is-partially-selected': isMultiSelected && !__unstableIsFullySelected() && !__unstableSelectionHasUnmergeableBlock(),
  16909. 'is-reusable': (0,external_wp_blocks_namespaceObject.isReusableBlock)((0,external_wp_blocks_namespaceObject.getBlockType)(name)),
  16910. 'is-dragging': isDragging,
  16911. 'has-child-selected': isAncestorOfSelectedBlock,
  16912. 'remove-outline': isSelected && outlineMode && isTyping()
  16913. });
  16914. }, [clientId]);
  16915. }
  16916. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-default-class-name.js
  16917. /**
  16918. * WordPress dependencies
  16919. */
  16920. /**
  16921. * Internal dependencies
  16922. */
  16923. /**
  16924. * Returns the default class name if the block is a light block and it supports
  16925. * `className`.
  16926. *
  16927. * @param {string} clientId The block client ID.
  16928. *
  16929. * @return {string} The class name, e.g. `wp-block-paragraph`.
  16930. */
  16931. function useBlockDefaultClassName(clientId) {
  16932. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  16933. const name = select(store).getBlockName(clientId);
  16934. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
  16935. const hasLightBlockWrapper = (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1;
  16936. if (!hasLightBlockWrapper) {
  16937. return;
  16938. }
  16939. return (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name);
  16940. }, [clientId]);
  16941. }
  16942. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-custom-class-name.js
  16943. /**
  16944. * WordPress dependencies
  16945. */
  16946. /**
  16947. * Internal dependencies
  16948. */
  16949. /**
  16950. * Returns the custom class name if the block is a light block.
  16951. *
  16952. * @param {string} clientId The block client ID.
  16953. *
  16954. * @return {string} The custom class name.
  16955. */
  16956. function useBlockCustomClassName(clientId) {
  16957. // It's good for this to be a separate selector because it will be executed
  16958. // on every attribute change, while the other selectors are not re-evaluated
  16959. // as much.
  16960. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  16961. const {
  16962. getBlockName,
  16963. getBlockAttributes
  16964. } = select(store);
  16965. const attributes = getBlockAttributes(clientId);
  16966. if (!(attributes !== null && attributes !== void 0 && attributes.className)) {
  16967. return;
  16968. }
  16969. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(getBlockName(clientId));
  16970. const hasLightBlockWrapper = (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1;
  16971. if (!hasLightBlockWrapper) {
  16972. return;
  16973. }
  16974. return attributes.className;
  16975. }, [clientId]);
  16976. }
  16977. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js
  16978. /**
  16979. * External dependencies
  16980. */
  16981. /**
  16982. * WordPress dependencies
  16983. */
  16984. /**
  16985. * Internal dependencies
  16986. */
  16987. /**
  16988. * Returns the class names used for block moving mode.
  16989. *
  16990. * @param {string} clientId The block client ID to insert above.
  16991. *
  16992. * @return {string} The class names.
  16993. */
  16994. function useBlockMovingModeClassNames(clientId) {
  16995. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  16996. const {
  16997. hasBlockMovingClientId,
  16998. canInsertBlockType,
  16999. getBlockName,
  17000. getBlockRootClientId,
  17001. isBlockSelected
  17002. } = select(store); // The classes are only relevant for the selected block. Avoid
  17003. // re-rendering all blocks!
  17004. if (!isBlockSelected(clientId)) {
  17005. return;
  17006. }
  17007. const movingClientId = hasBlockMovingClientId();
  17008. if (!movingClientId) {
  17009. return;
  17010. }
  17011. return classnames_default()('is-block-moving-mode', {
  17012. 'can-insert-moving-block': canInsertBlockType(getBlockName(movingClientId), getBlockRootClientId(clientId))
  17013. });
  17014. }, [clientId]);
  17015. }
  17016. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-focus-handler.js
  17017. /**
  17018. * WordPress dependencies
  17019. */
  17020. /**
  17021. * Internal dependencies
  17022. */
  17023. /**
  17024. * Selects the block if it receives focus.
  17025. *
  17026. * @param {string} clientId Block client ID.
  17027. */
  17028. function useFocusHandler(clientId) {
  17029. const {
  17030. isBlockSelected
  17031. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  17032. const {
  17033. selectBlock,
  17034. selectionChange
  17035. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  17036. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  17037. /**
  17038. * Marks the block as selected when focused and not already
  17039. * selected. This specifically handles the case where block does not
  17040. * set focus on its own (via `setFocus`), typically if there is no
  17041. * focusable input in the block.
  17042. *
  17043. * @param {FocusEvent} event Focus event.
  17044. */
  17045. function onFocus(event) {
  17046. // When the whole editor is editable, let writing flow handle
  17047. // selection.
  17048. if (node.parentElement.closest('[contenteditable="true"]')) {
  17049. return;
  17050. } // Check synchronously because a non-selected block might be
  17051. // getting data through `useSelect` asynchronously.
  17052. if (isBlockSelected(clientId)) {
  17053. // Potentially change selection away from rich text.
  17054. if (!event.target.isContentEditable) {
  17055. selectionChange(clientId);
  17056. }
  17057. return;
  17058. } // If an inner block is focussed, that block is resposible for
  17059. // setting the selected block.
  17060. if (!isInsideRootBlock(node, event.target)) {
  17061. return;
  17062. }
  17063. selectBlock(clientId);
  17064. }
  17065. node.addEventListener('focusin', onFocus);
  17066. return () => {
  17067. node.removeEventListener('focusin', onFocus);
  17068. };
  17069. }, [isBlockSelected, selectBlock]);
  17070. }
  17071. ;// CONCATENATED MODULE: external ["wp","keycodes"]
  17072. var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
  17073. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js
  17074. /**
  17075. * WordPress dependencies
  17076. */
  17077. /**
  17078. * Internal dependencies
  17079. */
  17080. /**
  17081. * Adds block behaviour:
  17082. * - Removes the block on BACKSPACE.
  17083. * - Inserts a default block on ENTER.
  17084. * - Disables dragging of block contents.
  17085. *
  17086. * @param {string} clientId Block client ID.
  17087. */
  17088. function useEventHandlers(clientId) {
  17089. const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isBlockSelected(clientId), [clientId]);
  17090. const {
  17091. getBlockRootClientId,
  17092. getBlockIndex
  17093. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  17094. const {
  17095. insertDefaultBlock,
  17096. removeBlock
  17097. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  17098. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  17099. if (!isSelected) {
  17100. return;
  17101. }
  17102. /**
  17103. * Interprets keydown event intent to remove or insert after block if
  17104. * key event occurs on wrapper node. This can occur when the block has
  17105. * no text fields of its own, particularly after initial insertion, to
  17106. * allow for easy deletion and continuous writing flow to add additional
  17107. * content.
  17108. *
  17109. * @param {KeyboardEvent} event Keydown event.
  17110. */
  17111. function onKeyDown(event) {
  17112. const {
  17113. keyCode,
  17114. target
  17115. } = event;
  17116. if (keyCode !== external_wp_keycodes_namespaceObject.ENTER && keyCode !== external_wp_keycodes_namespaceObject.BACKSPACE && keyCode !== external_wp_keycodes_namespaceObject.DELETE) {
  17117. return;
  17118. }
  17119. if (target !== node || (0,external_wp_dom_namespaceObject.isTextField)(target)) {
  17120. return;
  17121. }
  17122. event.preventDefault();
  17123. if (keyCode === external_wp_keycodes_namespaceObject.ENTER) {
  17124. insertDefaultBlock({}, getBlockRootClientId(clientId), getBlockIndex(clientId) + 1);
  17125. } else {
  17126. removeBlock(clientId);
  17127. }
  17128. }
  17129. /**
  17130. * Prevents default dragging behavior within a block. To do: we must
  17131. * handle this in the future and clean up the drag target.
  17132. *
  17133. * @param {DragEvent} event Drag event.
  17134. */
  17135. function onDragStart(event) {
  17136. event.preventDefault();
  17137. }
  17138. node.addEventListener('keydown', onKeyDown);
  17139. node.addEventListener('dragstart', onDragStart);
  17140. return () => {
  17141. node.removeEventListener('keydown', onKeyDown);
  17142. node.removeEventListener('dragstart', onDragStart);
  17143. };
  17144. }, [clientId, isSelected, getBlockRootClientId, getBlockIndex, insertDefaultBlock, removeBlock]);
  17145. }
  17146. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-nav-mode-exit.js
  17147. /**
  17148. * WordPress dependencies
  17149. */
  17150. /**
  17151. * Internal dependencies
  17152. */
  17153. /**
  17154. * Allows navigation mode to be exited by clicking in the selected block.
  17155. *
  17156. * @param {string} clientId Block client ID.
  17157. */
  17158. function useNavModeExit(clientId) {
  17159. const {
  17160. isNavigationMode,
  17161. isBlockSelected
  17162. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  17163. const {
  17164. setNavigationMode,
  17165. selectBlock
  17166. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  17167. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  17168. function onMouseDown(event) {
  17169. // Don't select a block if it's already handled by a child
  17170. // block.
  17171. if (isNavigationMode() && !event.defaultPrevented) {
  17172. // Prevent focus from moving to the block.
  17173. event.preventDefault(); // When clicking on a selected block, exit navigation mode.
  17174. if (isBlockSelected(clientId)) {
  17175. setNavigationMode(false);
  17176. } else {
  17177. selectBlock(clientId);
  17178. }
  17179. }
  17180. }
  17181. node.addEventListener('mousedown', onMouseDown);
  17182. return () => {
  17183. node.addEventListener('mousedown', onMouseDown);
  17184. };
  17185. }, [clientId, isNavigationMode, isBlockSelected, setNavigationMode]);
  17186. }
  17187. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-intersection-observer.js
  17188. /**
  17189. * WordPress dependencies
  17190. */
  17191. /**
  17192. * Internal dependencies
  17193. */
  17194. function useIntersectionObserver() {
  17195. const observer = (0,external_wp_element_namespaceObject.useContext)(IntersectionObserver);
  17196. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  17197. if (observer) {
  17198. observer.observe(node);
  17199. return () => {
  17200. observer.unobserve(node);
  17201. };
  17202. }
  17203. }, [observer]);
  17204. }
  17205. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-content-overlay/index.js
  17206. /**
  17207. * WordPress dependencies
  17208. */
  17209. /**
  17210. * Internal dependencies
  17211. */
  17212. function useBlockOverlayActive(clientId) {
  17213. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  17214. const {
  17215. __unstableHasActiveBlockOverlayActive
  17216. } = select(store);
  17217. return __unstableHasActiveBlockOverlayActive(clientId);
  17218. }, [clientId]);
  17219. }
  17220. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/index.js
  17221. /**
  17222. * External dependencies
  17223. */
  17224. /**
  17225. * WordPress dependencies
  17226. */
  17227. /**
  17228. * Internal dependencies
  17229. */
  17230. /**
  17231. * If the block count exceeds the threshold, we disable the reordering animation
  17232. * to avoid laginess.
  17233. */
  17234. const BLOCK_ANIMATION_THRESHOLD = 200;
  17235. /**
  17236. * This hook is used to lightly mark an element as a block element. The element
  17237. * should be the outermost element of a block. Call this hook and pass the
  17238. * returned props to the element to mark as a block. If you define a ref for the
  17239. * element, it is important to pass the ref to this hook, which the hook in turn
  17240. * will pass to the component through the props it returns. Optionally, you can
  17241. * also pass any other props through this hook, and they will be merged and
  17242. * returned.
  17243. *
  17244. * @param {Object} props Optional. Props to pass to the element. Must contain
  17245. * the ref if one is defined.
  17246. * @param {Object} options Options for internal use only.
  17247. * @param {boolean} options.__unstableIsHtml
  17248. *
  17249. * @return {Object} Props to pass to the element to mark as a block.
  17250. */
  17251. function useBlockProps() {
  17252. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  17253. let {
  17254. __unstableIsHtml
  17255. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  17256. const {
  17257. clientId,
  17258. className,
  17259. wrapperProps = {},
  17260. isAligned
  17261. } = (0,external_wp_element_namespaceObject.useContext)(BlockListBlockContext);
  17262. const {
  17263. index,
  17264. mode,
  17265. name,
  17266. blockApiVersion,
  17267. blockTitle,
  17268. isPartOfSelection,
  17269. adjustScrolling,
  17270. enableAnimation
  17271. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  17272. const {
  17273. getBlockIndex,
  17274. getBlockMode,
  17275. getBlockName,
  17276. isTyping,
  17277. getGlobalBlockCount,
  17278. isBlockSelected,
  17279. isBlockMultiSelected,
  17280. isAncestorMultiSelected,
  17281. isFirstMultiSelectedBlock
  17282. } = select(store);
  17283. const isSelected = isBlockSelected(clientId);
  17284. const isPartOfMultiSelection = isBlockMultiSelected(clientId) || isAncestorMultiSelected(clientId);
  17285. const blockName = getBlockName(clientId);
  17286. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName);
  17287. return {
  17288. index: getBlockIndex(clientId),
  17289. mode: getBlockMode(clientId),
  17290. name: blockName,
  17291. blockApiVersion: (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) || 1,
  17292. blockTitle: blockType === null || blockType === void 0 ? void 0 : blockType.title,
  17293. isPartOfSelection: isSelected || isPartOfMultiSelection,
  17294. adjustScrolling: isSelected || isFirstMultiSelectedBlock(clientId),
  17295. enableAnimation: !isTyping() && getGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD
  17296. };
  17297. }, [clientId]);
  17298. const hasOverlay = useBlockOverlayActive(clientId); // translators: %s: Type of block (i.e. Text, Image etc)
  17299. const blockLabel = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Block: %s'), blockTitle);
  17300. const htmlSuffix = mode === 'html' && !__unstableIsHtml ? '-visual' : '';
  17301. const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, useFocusFirstElement(clientId), useBlockRefProvider(clientId), useFocusHandler(clientId), useEventHandlers(clientId), useNavModeExit(clientId), useIsHovered(), useIntersectionObserver(), use_moving_animation({
  17302. isSelected: isPartOfSelection,
  17303. adjustScrolling,
  17304. enableAnimation,
  17305. triggerAnimationOnChange: index
  17306. }), (0,external_wp_compose_namespaceObject.useDisabled)({
  17307. isDisabled: !hasOverlay
  17308. })]);
  17309. const blockEditContext = useBlockEditContext(); // Ensures it warns only inside the `edit` implementation for the block.
  17310. if (blockApiVersion < 2 && clientId === blockEditContext.clientId) {
  17311. typeof process !== "undefined" && process.env && "production" !== "production" ? 0 : void 0;
  17312. }
  17313. return {
  17314. tabIndex: 0,
  17315. ...wrapperProps,
  17316. ...props,
  17317. ref: mergedRefs,
  17318. id: `block-${clientId}${htmlSuffix}`,
  17319. role: 'document',
  17320. 'aria-label': blockLabel,
  17321. 'data-block': clientId,
  17322. 'data-type': name,
  17323. 'data-title': blockTitle,
  17324. className: classnames_default()( // The wp-block className is important for editor styles.
  17325. classnames_default()('block-editor-block-list__block', {
  17326. 'wp-block': !isAligned,
  17327. 'has-block-overlay': hasOverlay
  17328. }), className, props.className, wrapperProps.className, useBlockClassNames(clientId), useBlockDefaultClassName(clientId), useBlockCustomClassName(clientId), useBlockMovingModeClassNames(clientId)),
  17329. style: { ...wrapperProps.style,
  17330. ...props.style
  17331. }
  17332. };
  17333. }
  17334. /**
  17335. * Call within a save function to get the props for the block wrapper.
  17336. *
  17337. * @param {Object} props Optional. Props to pass to the element.
  17338. */
  17339. useBlockProps.save = external_wp_blocks_namespaceObject.__unstableGetBlockProps;
  17340. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block.js
  17341. /**
  17342. * External dependencies
  17343. */
  17344. /**
  17345. * WordPress dependencies
  17346. */
  17347. /**
  17348. * Internal dependencies
  17349. */
  17350. const BlockListBlockContext = (0,external_wp_element_namespaceObject.createContext)();
  17351. /**
  17352. * Merges wrapper props with special handling for classNames and styles.
  17353. *
  17354. * @param {Object} propsA
  17355. * @param {Object} propsB
  17356. *
  17357. * @return {Object} Merged props.
  17358. */
  17359. function mergeWrapperProps(propsA, propsB) {
  17360. const newProps = { ...propsA,
  17361. ...propsB
  17362. };
  17363. if (propsA !== null && propsA !== void 0 && propsA.className && propsB !== null && propsB !== void 0 && propsB.className) {
  17364. newProps.className = classnames_default()(propsA.className, propsB.className);
  17365. }
  17366. if (propsA !== null && propsA !== void 0 && propsA.style && propsB !== null && propsB !== void 0 && propsB.style) {
  17367. newProps.style = { ...propsA.style,
  17368. ...propsB.style
  17369. };
  17370. }
  17371. return newProps;
  17372. }
  17373. function Block(_ref) {
  17374. let {
  17375. children,
  17376. isHtml,
  17377. ...props
  17378. } = _ref;
  17379. return (0,external_wp_element_namespaceObject.createElement)("div", useBlockProps(props, {
  17380. __unstableIsHtml: isHtml
  17381. }), children);
  17382. }
  17383. function BlockListBlock(_ref2) {
  17384. var _wrapperProps;
  17385. let {
  17386. block: {
  17387. __unstableBlockSource
  17388. },
  17389. mode,
  17390. isLocked,
  17391. canRemove,
  17392. clientId,
  17393. isSelected,
  17394. isSelectionEnabled,
  17395. className,
  17396. name,
  17397. isValid,
  17398. attributes,
  17399. wrapperProps,
  17400. setAttributes,
  17401. onReplace,
  17402. onInsertBlocksAfter,
  17403. onMerge,
  17404. toggleSelection
  17405. } = _ref2;
  17406. const {
  17407. themeSupportsLayout,
  17408. hasContentLockedParent,
  17409. isContentBlock,
  17410. isContentLocking,
  17411. isTemporarilyEditingAsBlocks
  17412. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  17413. const {
  17414. getSettings,
  17415. __unstableGetContentLockingParent,
  17416. getTemplateLock,
  17417. __unstableGetTemporarilyEditingAsBlocks
  17418. } = select(store);
  17419. const _hasContentLockedParent = !!__unstableGetContentLockingParent(clientId);
  17420. return {
  17421. themeSupportsLayout: getSettings().supportsLayout,
  17422. isContentBlock: select(external_wp_blocks_namespaceObject.store).__experimentalHasContentRoleAttribute(name),
  17423. hasContentLockedParent: _hasContentLockedParent,
  17424. isContentLocking: getTemplateLock(clientId) === 'contentOnly' && !_hasContentLockedParent,
  17425. isTemporarilyEditingAsBlocks: __unstableGetTemporarilyEditingAsBlocks() === clientId
  17426. };
  17427. }, [name, clientId]);
  17428. const {
  17429. removeBlock
  17430. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  17431. const onRemove = (0,external_wp_element_namespaceObject.useCallback)(() => removeBlock(clientId), [clientId]); // We wrap the BlockEdit component in a div that hides it when editing in
  17432. // HTML mode. This allows us to render all of the ancillary pieces
  17433. // (InspectorControls, etc.) which are inside `BlockEdit` but not
  17434. // `BlockHTML`, even in HTML mode.
  17435. let blockEdit = (0,external_wp_element_namespaceObject.createElement)(BlockEdit, {
  17436. name: name,
  17437. isSelected: isSelected,
  17438. attributes: attributes,
  17439. setAttributes: setAttributes,
  17440. insertBlocksAfter: isLocked ? undefined : onInsertBlocksAfter,
  17441. onReplace: canRemove ? onReplace : undefined,
  17442. onRemove: canRemove ? onRemove : undefined,
  17443. mergeBlocks: canRemove ? onMerge : undefined,
  17444. clientId: clientId,
  17445. isSelectionEnabled: isSelectionEnabled,
  17446. toggleSelection: toggleSelection
  17447. });
  17448. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
  17449. if (hasContentLockedParent && !isContentBlock) {
  17450. wrapperProps = { ...wrapperProps,
  17451. tabIndex: -1
  17452. };
  17453. } // Determine whether the block has props to apply to the wrapper.
  17454. if (blockType !== null && blockType !== void 0 && blockType.getEditWrapperProps) {
  17455. wrapperProps = mergeWrapperProps(wrapperProps, blockType.getEditWrapperProps(attributes));
  17456. }
  17457. const isAligned = wrapperProps && !!wrapperProps['data-align'] && !themeSupportsLayout; // For aligned blocks, provide a wrapper element so the block can be
  17458. // positioned relative to the block column.
  17459. // This is only kept for classic themes that don't support layout
  17460. // Historically we used to rely on extra divs and data-align to
  17461. // provide the alignments styles in the editor.
  17462. // Due to the differences between frontend and backend, we migrated
  17463. // to the layout feature, and we're now aligning the markup of frontend
  17464. // and backend.
  17465. if (isAligned) {
  17466. blockEdit = (0,external_wp_element_namespaceObject.createElement)("div", {
  17467. className: "wp-block",
  17468. "data-align": wrapperProps['data-align']
  17469. }, blockEdit);
  17470. }
  17471. let block;
  17472. if (!isValid) {
  17473. const saveContent = __unstableBlockSource ? (0,external_wp_blocks_namespaceObject.serializeRawBlock)(__unstableBlockSource) : (0,external_wp_blocks_namespaceObject.getSaveContent)(blockType, attributes);
  17474. block = (0,external_wp_element_namespaceObject.createElement)(Block, {
  17475. className: "has-warning"
  17476. }, (0,external_wp_element_namespaceObject.createElement)(block_invalid_warning, {
  17477. clientId: clientId
  17478. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, (0,external_wp_dom_namespaceObject.safeHTML)(saveContent)));
  17479. } else if (mode === 'html') {
  17480. // Render blockEdit so the inspector controls don't disappear.
  17481. // See #8969.
  17482. block = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  17483. style: {
  17484. display: 'none'
  17485. }
  17486. }, blockEdit), (0,external_wp_element_namespaceObject.createElement)(Block, {
  17487. isHtml: true
  17488. }, (0,external_wp_element_namespaceObject.createElement)(block_html, {
  17489. clientId: clientId
  17490. })));
  17491. } else if ((blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1) {
  17492. block = blockEdit;
  17493. } else {
  17494. block = (0,external_wp_element_namespaceObject.createElement)(Block, wrapperProps, blockEdit);
  17495. }
  17496. const {
  17497. 'data-align': dataAlign,
  17498. ...restWrapperProps
  17499. } = (_wrapperProps = wrapperProps) !== null && _wrapperProps !== void 0 ? _wrapperProps : {};
  17500. const value = {
  17501. clientId,
  17502. className: classnames_default()({
  17503. 'is-content-locked': isContentLocking,
  17504. 'is-content-locked-temporarily-editing-as-blocks': isTemporarilyEditingAsBlocks,
  17505. 'is-content-block': hasContentLockedParent && isContentBlock
  17506. }, dataAlign && themeSupportsLayout && `align${dataAlign}`, className),
  17507. wrapperProps: restWrapperProps,
  17508. isAligned
  17509. };
  17510. const memoizedValue = (0,external_wp_element_namespaceObject.useMemo)(() => value, Object.values(value));
  17511. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlockContext.Provider, {
  17512. value: memoizedValue
  17513. }, (0,external_wp_element_namespaceObject.createElement)(block_crash_boundary, {
  17514. fallback: (0,external_wp_element_namespaceObject.createElement)(Block, {
  17515. className: "has-warning"
  17516. }, (0,external_wp_element_namespaceObject.createElement)(block_crash_warning, null))
  17517. }, block));
  17518. }
  17519. const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)((select, _ref3) => {
  17520. let {
  17521. clientId,
  17522. rootClientId
  17523. } = _ref3;
  17524. const {
  17525. isBlockSelected,
  17526. getBlockMode,
  17527. isSelectionEnabled,
  17528. getTemplateLock,
  17529. __unstableGetBlockWithoutInnerBlocks,
  17530. canRemoveBlock,
  17531. canMoveBlock
  17532. } = select(store);
  17533. const block = __unstableGetBlockWithoutInnerBlocks(clientId);
  17534. const isSelected = isBlockSelected(clientId);
  17535. const templateLock = getTemplateLock(rootClientId);
  17536. const canRemove = canRemoveBlock(clientId, rootClientId);
  17537. const canMove = canMoveBlock(clientId, rootClientId); // The fallback to `{}` is a temporary fix.
  17538. // This function should never be called when a block is not present in
  17539. // the state. It happens now because the order in withSelect rendering
  17540. // is not correct.
  17541. const {
  17542. name,
  17543. attributes,
  17544. isValid
  17545. } = block || {}; // Do not add new properties here, use `useSelect` instead to avoid
  17546. // leaking new props to the public API (editor.BlockListBlock filter).
  17547. return {
  17548. mode: getBlockMode(clientId),
  17549. isSelectionEnabled: isSelectionEnabled(),
  17550. isLocked: !!templateLock,
  17551. canRemove,
  17552. canMove,
  17553. // Users of the editor.BlockListBlock filter used to be able to
  17554. // access the block prop.
  17555. // Ideally these blocks would rely on the clientId prop only.
  17556. // This is kept for backward compatibility reasons.
  17557. block,
  17558. name,
  17559. attributes,
  17560. isValid,
  17561. isSelected
  17562. };
  17563. });
  17564. const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps, registry) => {
  17565. const {
  17566. updateBlockAttributes,
  17567. insertBlocks,
  17568. mergeBlocks,
  17569. replaceBlocks,
  17570. toggleSelection,
  17571. __unstableMarkLastChangeAsPersistent,
  17572. moveBlocksToPosition,
  17573. removeBlock,
  17574. selectBlock
  17575. } = dispatch(store); // Do not add new properties here, use `useDispatch` instead to avoid
  17576. // leaking new props to the public API (editor.BlockListBlock filter).
  17577. return {
  17578. setAttributes(newAttributes) {
  17579. const {
  17580. getMultiSelectedBlockClientIds
  17581. } = registry.select(store);
  17582. const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds();
  17583. const {
  17584. clientId
  17585. } = ownProps;
  17586. const clientIds = multiSelectedBlockClientIds.length ? multiSelectedBlockClientIds : [clientId];
  17587. updateBlockAttributes(clientIds, newAttributes);
  17588. },
  17589. onInsertBlocks(blocks, index) {
  17590. const {
  17591. rootClientId
  17592. } = ownProps;
  17593. insertBlocks(blocks, index, rootClientId);
  17594. },
  17595. onInsertBlocksAfter(blocks) {
  17596. const {
  17597. clientId,
  17598. rootClientId
  17599. } = ownProps;
  17600. const {
  17601. getBlockIndex
  17602. } = registry.select(store);
  17603. const index = getBlockIndex(clientId);
  17604. insertBlocks(blocks, index + 1, rootClientId);
  17605. },
  17606. onMerge(forward) {
  17607. const {
  17608. clientId,
  17609. rootClientId
  17610. } = ownProps;
  17611. const {
  17612. getPreviousBlockClientId,
  17613. getNextBlockClientId,
  17614. getBlock,
  17615. getBlockAttributes,
  17616. getBlockName,
  17617. getBlockOrder
  17618. } = registry.select(store); // For `Delete` or forward merge, we should do the exact same thing
  17619. // as `Backspace`, but from the other block.
  17620. if (forward) {
  17621. if (rootClientId) {
  17622. const nextRootClientId = getNextBlockClientId(rootClientId);
  17623. if (nextRootClientId) {
  17624. // If there is a block that follows with the same parent
  17625. // block name and the same attributes, merge the inner
  17626. // blocks.
  17627. if (getBlockName(rootClientId) === getBlockName(nextRootClientId)) {
  17628. const rootAttributes = getBlockAttributes(rootClientId);
  17629. const previousRootAttributes = getBlockAttributes(nextRootClientId);
  17630. if (Object.keys(rootAttributes).every(key => rootAttributes[key] === previousRootAttributes[key])) {
  17631. registry.batch(() => {
  17632. moveBlocksToPosition(getBlockOrder(nextRootClientId), nextRootClientId, rootClientId);
  17633. removeBlock(nextRootClientId, false);
  17634. });
  17635. return;
  17636. }
  17637. } else {
  17638. mergeBlocks(rootClientId, nextRootClientId);
  17639. return;
  17640. }
  17641. }
  17642. }
  17643. const nextBlockClientId = getNextBlockClientId(clientId);
  17644. if (!nextBlockClientId) {
  17645. return;
  17646. } // Check if it's possibile to "unwrap" the following block
  17647. // before trying to merge.
  17648. const replacement = (0,external_wp_blocks_namespaceObject.switchToBlockType)(getBlock(nextBlockClientId), '*');
  17649. if (replacement && replacement.length) {
  17650. replaceBlocks(nextBlockClientId, replacement);
  17651. } else {
  17652. mergeBlocks(clientId, nextBlockClientId);
  17653. }
  17654. } else {
  17655. const previousBlockClientId = getPreviousBlockClientId(clientId);
  17656. if (previousBlockClientId) {
  17657. mergeBlocks(previousBlockClientId, clientId);
  17658. } else if (rootClientId) {
  17659. const previousRootClientId = getPreviousBlockClientId(rootClientId); // If there is a preceding block with the same parent block
  17660. // name and the same attributes, merge the inner blocks.
  17661. if (previousRootClientId && getBlockName(rootClientId) === getBlockName(previousRootClientId)) {
  17662. const rootAttributes = getBlockAttributes(rootClientId);
  17663. const previousRootAttributes = getBlockAttributes(previousRootClientId);
  17664. if (Object.keys(rootAttributes).every(key => rootAttributes[key] === previousRootAttributes[key])) {
  17665. registry.batch(() => {
  17666. moveBlocksToPosition(getBlockOrder(rootClientId), rootClientId, previousRootClientId);
  17667. removeBlock(rootClientId, false);
  17668. });
  17669. return;
  17670. }
  17671. } // Attempt to "unwrap" the block contents when there's no
  17672. // preceding block to merge with.
  17673. const replacement = (0,external_wp_blocks_namespaceObject.switchToBlockType)(getBlock(rootClientId), '*');
  17674. if (replacement && replacement.length) {
  17675. registry.batch(() => {
  17676. replaceBlocks(rootClientId, replacement);
  17677. selectBlock(replacement[0].clientId, 0);
  17678. });
  17679. }
  17680. }
  17681. }
  17682. },
  17683. onReplace(blocks, indexToSelect, initialPosition) {
  17684. if (blocks.length && !(0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(blocks[blocks.length - 1])) {
  17685. __unstableMarkLastChangeAsPersistent();
  17686. }
  17687. replaceBlocks([ownProps.clientId], blocks, indexToSelect, initialPosition);
  17688. },
  17689. toggleSelection(selectionEnabled) {
  17690. toggleSelection(selectionEnabled);
  17691. }
  17692. };
  17693. });
  17694. /* harmony default export */ var block = ((0,external_wp_compose_namespaceObject.compose)(external_wp_compose_namespaceObject.pure, applyWithSelect, applyWithDispatch, // Block is sometimes not mounted at the right time, causing it be undefined
  17695. // see issue for more info
  17696. // https://github.com/WordPress/gutenberg/issues/17013
  17697. (0,external_wp_compose_namespaceObject.ifCondition)(_ref4 => {
  17698. let {
  17699. block
  17700. } = _ref4;
  17701. return !!block;
  17702. }), (0,external_wp_components_namespaceObject.withFilters)('editor.BlockListBlock'))(BlockListBlock));
  17703. ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
  17704. var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  17705. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js
  17706. /**
  17707. * WordPress dependencies
  17708. */
  17709. const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  17710. xmlns: "http://www.w3.org/2000/svg",
  17711. viewBox: "0 0 24 24"
  17712. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  17713. d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
  17714. }));
  17715. /* harmony default export */ var library_plus = (plus);
  17716. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/tips.js
  17717. /**
  17718. * WordPress dependencies
  17719. */
  17720. const globalTips = [(0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('While writing, you can press <kbd>/</kbd> to quickly insert new blocks.'), {
  17721. kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
  17722. }), (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Indent a list by pressing <kbd>space</kbd> at the beginning of a line.'), {
  17723. kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
  17724. }), (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line.'), {
  17725. kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
  17726. }), (0,external_wp_i18n_namespaceObject.__)('Drag files into the editor to automatically insert media blocks.'), (0,external_wp_i18n_namespaceObject.__)("Change a block's type by pressing the block icon on the toolbar.")];
  17727. function Tips() {
  17728. const [randomIndex] = (0,external_wp_element_namespaceObject.useState)( // Disable Reason: I'm not generating an HTML id.
  17729. // eslint-disable-next-line no-restricted-syntax
  17730. Math.floor(Math.random() * globalTips.length));
  17731. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tip, null, globalTips[randomIndex]);
  17732. }
  17733. /* harmony default export */ var tips = (Tips);
  17734. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js
  17735. /**
  17736. * WordPress dependencies
  17737. */
  17738. const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  17739. xmlns: "http://www.w3.org/2000/svg",
  17740. viewBox: "0 0 24 24"
  17741. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  17742. d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"
  17743. }));
  17744. /* harmony default export */ var block_default = (blockDefault);
  17745. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-icon/index.js
  17746. /**
  17747. * External dependencies
  17748. */
  17749. /**
  17750. * WordPress dependencies
  17751. */
  17752. function BlockIcon(_ref) {
  17753. var _icon;
  17754. let {
  17755. icon,
  17756. showColors = false,
  17757. className
  17758. } = _ref;
  17759. if (((_icon = icon) === null || _icon === void 0 ? void 0 : _icon.src) === 'block-default') {
  17760. icon = {
  17761. src: block_default
  17762. };
  17763. }
  17764. const renderedIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
  17765. icon: icon && icon.src ? icon.src : icon
  17766. });
  17767. const style = showColors ? {
  17768. backgroundColor: icon && icon.background,
  17769. color: icon && icon.foreground
  17770. } : {};
  17771. return (0,external_wp_element_namespaceObject.createElement)("span", {
  17772. style: style,
  17773. className: classnames_default()('block-editor-block-icon', className, {
  17774. 'has-colors': showColors
  17775. })
  17776. }, renderedIcon);
  17777. }
  17778. /**
  17779. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-icon/README.md
  17780. */
  17781. /* harmony default export */ var block_icon = ((0,external_wp_element_namespaceObject.memo)(BlockIcon));
  17782. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-card/index.js
  17783. /**
  17784. * WordPress dependencies
  17785. */
  17786. /**
  17787. * Internal dependencies
  17788. */
  17789. function BlockCard(_ref) {
  17790. let {
  17791. title,
  17792. icon,
  17793. description,
  17794. blockType
  17795. } = _ref;
  17796. if (blockType) {
  17797. external_wp_deprecated_default()('`blockType` property in `BlockCard component`', {
  17798. since: '5.7',
  17799. alternative: '`title, icon and description` properties'
  17800. });
  17801. ({
  17802. title,
  17803. icon,
  17804. description
  17805. } = blockType);
  17806. }
  17807. return (0,external_wp_element_namespaceObject.createElement)("div", {
  17808. className: "block-editor-block-card"
  17809. }, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  17810. icon: icon,
  17811. showColors: true
  17812. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  17813. className: "block-editor-block-card__content"
  17814. }, (0,external_wp_element_namespaceObject.createElement)("h2", {
  17815. className: "block-editor-block-card__title"
  17816. }, title), (0,external_wp_element_namespaceObject.createElement)("span", {
  17817. className: "block-editor-block-card__description"
  17818. }, description)));
  17819. }
  17820. /* harmony default export */ var block_card = (BlockCard);
  17821. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/with-registry-provider.js
  17822. /**
  17823. * WordPress dependencies
  17824. */
  17825. /**
  17826. * Internal dependencies
  17827. */
  17828. const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => {
  17829. return (0,external_wp_data_namespaceObject.withRegistry)(_ref => {
  17830. let {
  17831. useSubRegistry = true,
  17832. registry,
  17833. ...props
  17834. } = _ref;
  17835. if (!useSubRegistry) {
  17836. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({
  17837. registry: registry
  17838. }, props));
  17839. }
  17840. const [subRegistry, setSubRegistry] = (0,external_wp_element_namespaceObject.useState)(null);
  17841. (0,external_wp_element_namespaceObject.useEffect)(() => {
  17842. const newRegistry = (0,external_wp_data_namespaceObject.createRegistry)({}, registry);
  17843. newRegistry.registerStore(STORE_NAME, storeConfig);
  17844. setSubRegistry(newRegistry);
  17845. }, [registry]);
  17846. if (!subRegistry) {
  17847. return null;
  17848. }
  17849. return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.RegistryProvider, {
  17850. value: subRegistry
  17851. }, (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({
  17852. registry: subRegistry
  17853. }, props)));
  17854. });
  17855. }, 'withRegistryProvider');
  17856. /* harmony default export */ var with_registry_provider = (withRegistryProvider);
  17857. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/use-block-sync.js
  17858. /**
  17859. * WordPress dependencies
  17860. */
  17861. /**
  17862. * Internal dependencies
  17863. */
  17864. const use_block_sync_noop = () => {};
  17865. /**
  17866. * A function to call when the block value has been updated in the block-editor
  17867. * store.
  17868. *
  17869. * @callback onBlockUpdate
  17870. * @param {Object[]} blocks The updated blocks.
  17871. * @param {Object} options The updated block options, such as selectionStart
  17872. * and selectionEnd.
  17873. */
  17874. /**
  17875. * useBlockSync is a side effect which handles bidirectional sync between the
  17876. * block-editor store and a controlling data source which provides blocks. This
  17877. * is most commonly used by the BlockEditorProvider to synchronize the contents
  17878. * of the block-editor store with the root entity, like a post.
  17879. *
  17880. * Another example would be the template part block, which provides blocks from
  17881. * a separate entity data source than a root entity. This hook syncs edits to
  17882. * the template part in the block editor back to the entity and vice-versa.
  17883. *
  17884. * Here are some of its basic functions:
  17885. * - Initalizes the block-editor store for the given clientID to the blocks
  17886. * given via props.
  17887. * - Adds incoming changes (like undo) to the block-editor store.
  17888. * - Adds outgoing changes (like editing content) to the controlling entity,
  17889. * determining if a change should be considered persistent or not.
  17890. * - Handles edge cases and race conditions which occur in those operations.
  17891. * - Ignores changes which happen to other entities (like nested inner block
  17892. * controllers.
  17893. * - Passes selection state from the block-editor store to the controlling entity.
  17894. *
  17895. * @param {Object} props Props for the block sync hook
  17896. * @param {string} props.clientId The client ID of the inner block controller.
  17897. * If none is passed, then it is assumed to be a
  17898. * root controller rather than an inner block
  17899. * controller.
  17900. * @param {Object[]} props.value The control value for the blocks. This value
  17901. * is used to initalize the block-editor store
  17902. * and for resetting the blocks to incoming
  17903. * changes like undo.
  17904. * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.
  17905. * @param {onBlockUpdate} props.onChange Function to call when a persistent
  17906. * change has been made in the block-editor blocks
  17907. * for the given clientId. For example, after
  17908. * this function is called, an entity is marked
  17909. * dirty because it has changes to save.
  17910. * @param {onBlockUpdate} props.onInput Function to call when a non-persistent
  17911. * change has been made in the block-editor blocks
  17912. * for the given clientId. When this is called,
  17913. * controlling sources do not become dirty.
  17914. */
  17915. function useBlockSync(_ref) {
  17916. let {
  17917. clientId = null,
  17918. value: controlledBlocks,
  17919. selection: controlledSelection,
  17920. onChange = use_block_sync_noop,
  17921. onInput = use_block_sync_noop
  17922. } = _ref;
  17923. const registry = (0,external_wp_data_namespaceObject.useRegistry)();
  17924. const {
  17925. resetBlocks,
  17926. resetSelection,
  17927. replaceInnerBlocks,
  17928. setHasControlledInnerBlocks,
  17929. __unstableMarkNextChangeAsNotPersistent
  17930. } = registry.dispatch(store);
  17931. const {
  17932. getBlockName,
  17933. getBlocks
  17934. } = registry.select(store);
  17935. const isControlled = (0,external_wp_data_namespaceObject.useSelect)(select => {
  17936. return !clientId || select(store).areInnerBlocksControlled(clientId);
  17937. }, [clientId]);
  17938. const pendingChanges = (0,external_wp_element_namespaceObject.useRef)({
  17939. incoming: null,
  17940. outgoing: []
  17941. });
  17942. const subscribed = (0,external_wp_element_namespaceObject.useRef)(false);
  17943. const setControlledBlocks = () => {
  17944. if (!controlledBlocks) {
  17945. return;
  17946. } // We don't need to persist this change because we only replace
  17947. // controlled inner blocks when the change was caused by an entity,
  17948. // and so it would already be persisted.
  17949. __unstableMarkNextChangeAsNotPersistent();
  17950. if (clientId) {
  17951. // It is important to batch here because otherwise,
  17952. // as soon as `setHasControlledInnerBlocks` is called
  17953. // the effect to restore might be triggered
  17954. // before the actual blocks get set properly in state.
  17955. registry.batch(() => {
  17956. setHasControlledInnerBlocks(clientId, true);
  17957. const storeBlocks = controlledBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
  17958. if (subscribed.current) {
  17959. pendingChanges.current.incoming = storeBlocks;
  17960. }
  17961. __unstableMarkNextChangeAsNotPersistent();
  17962. replaceInnerBlocks(clientId, storeBlocks);
  17963. });
  17964. } else {
  17965. if (subscribed.current) {
  17966. pendingChanges.current.incoming = controlledBlocks;
  17967. }
  17968. resetBlocks(controlledBlocks);
  17969. }
  17970. }; // Add a subscription to the block-editor registry to detect when changes
  17971. // have been made. This lets us inform the data source of changes. This
  17972. // is an effect so that the subscriber can run synchronously without
  17973. // waiting for React renders for changes.
  17974. const onInputRef = (0,external_wp_element_namespaceObject.useRef)(onInput);
  17975. const onChangeRef = (0,external_wp_element_namespaceObject.useRef)(onChange);
  17976. (0,external_wp_element_namespaceObject.useEffect)(() => {
  17977. onInputRef.current = onInput;
  17978. onChangeRef.current = onChange;
  17979. }, [onInput, onChange]); // Determine if blocks need to be reset when they change.
  17980. (0,external_wp_element_namespaceObject.useEffect)(() => {
  17981. if (pendingChanges.current.outgoing.includes(controlledBlocks)) {
  17982. // Skip block reset if the value matches expected outbound sync
  17983. // triggered by this component by a preceding change detection.
  17984. // Only skip if the value matches expectation, since a reset should
  17985. // still occur if the value is modified (not equal by reference),
  17986. // to allow that the consumer may apply modifications to reflect
  17987. // back on the editor.
  17988. if (pendingChanges.current.outgoing[pendingChanges.current.outgoing.length - 1] === controlledBlocks) {
  17989. pendingChanges.current.outgoing = [];
  17990. }
  17991. } else if (getBlocks(clientId) !== controlledBlocks) {
  17992. // Reset changing value in all other cases than the sync described
  17993. // above. Since this can be reached in an update following an out-
  17994. // bound sync, unset the outbound value to avoid considering it in
  17995. // subsequent renders.
  17996. pendingChanges.current.outgoing = [];
  17997. setControlledBlocks();
  17998. if (controlledSelection) {
  17999. resetSelection(controlledSelection.selectionStart, controlledSelection.selectionEnd, controlledSelection.initialPosition);
  18000. }
  18001. }
  18002. }, [controlledBlocks, clientId]);
  18003. (0,external_wp_element_namespaceObject.useEffect)(() => {
  18004. // When the block becomes uncontrolled, it means its inner state has been reset
  18005. // we need to take the blocks again from the external value property.
  18006. if (!isControlled) {
  18007. pendingChanges.current.outgoing = [];
  18008. setControlledBlocks();
  18009. }
  18010. }, [isControlled]);
  18011. (0,external_wp_element_namespaceObject.useEffect)(() => {
  18012. const {
  18013. getSelectionStart,
  18014. getSelectionEnd,
  18015. getSelectedBlocksInitialCaretPosition,
  18016. isLastBlockChangePersistent,
  18017. __unstableIsLastBlockChangeIgnored,
  18018. areInnerBlocksControlled
  18019. } = registry.select(store);
  18020. let blocks = getBlocks(clientId);
  18021. let isPersistent = isLastBlockChangePersistent();
  18022. let previousAreBlocksDifferent = false;
  18023. subscribed.current = true;
  18024. const unsubscribe = registry.subscribe(() => {
  18025. // Sometimes, when changing block lists, lingering subscriptions
  18026. // might trigger before they are cleaned up. If the block for which
  18027. // the subscription runs is no longer in the store, this would clear
  18028. // its parent entity's block list. To avoid this, we bail out if
  18029. // the subscription is triggering for a block (`clientId !== null`)
  18030. // and its block name can't be found because it's not on the list.
  18031. // (`getBlockName( clientId ) === null`).
  18032. if (clientId !== null && getBlockName(clientId) === null) return; // When RESET_BLOCKS on parent blocks get called, the controlled blocks
  18033. // can reset to uncontrolled, in these situations, it means we need to populate
  18034. // the blocks again from the external blocks (the value property here)
  18035. // and we should stop triggering onChange
  18036. const isStillControlled = !clientId || areInnerBlocksControlled(clientId);
  18037. if (!isStillControlled) {
  18038. return;
  18039. }
  18040. const newIsPersistent = isLastBlockChangePersistent();
  18041. const newBlocks = getBlocks(clientId);
  18042. const areBlocksDifferent = newBlocks !== blocks;
  18043. blocks = newBlocks;
  18044. if (areBlocksDifferent && (pendingChanges.current.incoming || __unstableIsLastBlockChangeIgnored())) {
  18045. pendingChanges.current.incoming = null;
  18046. isPersistent = newIsPersistent;
  18047. return;
  18048. } // Since we often dispatch an action to mark the previous action as
  18049. // persistent, we need to make sure that the blocks changed on the
  18050. // previous action before committing the change.
  18051. const didPersistenceChange = previousAreBlocksDifferent && !areBlocksDifferent && newIsPersistent && !isPersistent;
  18052. if (areBlocksDifferent || didPersistenceChange) {
  18053. isPersistent = newIsPersistent; // We know that onChange/onInput will update controlledBlocks.
  18054. // We need to be aware that it was caused by an outgoing change
  18055. // so that we do not treat it as an incoming change later on,
  18056. // which would cause a block reset.
  18057. pendingChanges.current.outgoing.push(blocks); // Inform the controlling entity that changes have been made to
  18058. // the block-editor store they should be aware about.
  18059. const updateParent = isPersistent ? onChangeRef.current : onInputRef.current;
  18060. updateParent(blocks, {
  18061. selection: {
  18062. selectionStart: getSelectionStart(),
  18063. selectionEnd: getSelectionEnd(),
  18064. initialPosition: getSelectedBlocksInitialCaretPosition()
  18065. }
  18066. });
  18067. }
  18068. previousAreBlocksDifferent = areBlocksDifferent;
  18069. });
  18070. return () => unsubscribe();
  18071. }, [registry, clientId]);
  18072. }
  18073. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/index.js
  18074. /**
  18075. * WordPress dependencies
  18076. */
  18077. /**
  18078. * Internal dependencies
  18079. */
  18080. /** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
  18081. function BlockEditorProvider(props) {
  18082. const {
  18083. children,
  18084. settings
  18085. } = props;
  18086. const {
  18087. updateSettings
  18088. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  18089. (0,external_wp_element_namespaceObject.useEffect)(() => {
  18090. updateSettings(settings);
  18091. }, [settings]); // Syncs the entity provider with changes in the block-editor store.
  18092. useBlockSync(props);
  18093. return (0,external_wp_element_namespaceObject.createElement)(BlockRefsProvider, null, children);
  18094. }
  18095. /* harmony default export */ var provider = (with_registry_provider(BlockEditorProvider));
  18096. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/live.js
  18097. /**
  18098. * WordPress dependencies
  18099. */
  18100. /**
  18101. * Internal dependencies
  18102. */
  18103. function LiveBlockPreview(_ref) {
  18104. let {
  18105. onClick
  18106. } = _ref;
  18107. return (0,external_wp_element_namespaceObject.createElement)("div", {
  18108. tabIndex: 0,
  18109. role: "button",
  18110. onClick: onClick,
  18111. onKeyPress: onClick
  18112. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, null, (0,external_wp_element_namespaceObject.createElement)(BlockList, null)));
  18113. }
  18114. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-selection-clearer/index.js
  18115. /**
  18116. * WordPress dependencies
  18117. */
  18118. /**
  18119. * Internal dependencies
  18120. */
  18121. /**
  18122. * Pass the returned ref callback to an element that should clear block
  18123. * selection. Selection will only be cleared if the element is clicked directly,
  18124. * not if a child element is clicked.
  18125. *
  18126. * @return {import('react').RefCallback} Ref callback.
  18127. */
  18128. function useBlockSelectionClearer() {
  18129. const {
  18130. hasSelectedBlock,
  18131. hasMultiSelection
  18132. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  18133. const {
  18134. clearSelectedBlock
  18135. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  18136. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  18137. function onMouseDown(event) {
  18138. if (!hasSelectedBlock() && !hasMultiSelection()) {
  18139. return;
  18140. } // Only handle clicks on the element, not the children.
  18141. if (event.target !== node) {
  18142. return;
  18143. }
  18144. clearSelectedBlock();
  18145. }
  18146. node.addEventListener('mousedown', onMouseDown);
  18147. return () => {
  18148. node.removeEventListener('mousedown', onMouseDown);
  18149. };
  18150. }, [hasSelectedBlock, hasMultiSelection, clearSelectedBlock]);
  18151. }
  18152. function BlockSelectionClearer(props) {
  18153. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  18154. ref: useBlockSelectionClearer()
  18155. }, props));
  18156. }
  18157. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-multi-selection.js
  18158. /**
  18159. * WordPress dependencies
  18160. */
  18161. /**
  18162. * Internal dependencies
  18163. */
  18164. function selector(select) {
  18165. const {
  18166. isMultiSelecting,
  18167. getMultiSelectedBlockClientIds,
  18168. hasMultiSelection,
  18169. getSelectedBlockClientId,
  18170. getSelectedBlocksInitialCaretPosition,
  18171. __unstableIsFullySelected
  18172. } = select(store);
  18173. return {
  18174. isMultiSelecting: isMultiSelecting(),
  18175. multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),
  18176. hasMultiSelection: hasMultiSelection(),
  18177. selectedBlockClientId: getSelectedBlockClientId(),
  18178. initialPosition: getSelectedBlocksInitialCaretPosition(),
  18179. isFullSelection: __unstableIsFullySelected()
  18180. };
  18181. }
  18182. function useMultiSelection() {
  18183. const {
  18184. initialPosition,
  18185. isMultiSelecting,
  18186. multiSelectedBlockClientIds,
  18187. hasMultiSelection,
  18188. selectedBlockClientId,
  18189. isFullSelection
  18190. } = (0,external_wp_data_namespaceObject.useSelect)(selector, []);
  18191. /**
  18192. * When the component updates, and there is multi selection, we need to
  18193. * select the entire block contents.
  18194. */
  18195. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  18196. const {
  18197. ownerDocument
  18198. } = node;
  18199. const {
  18200. defaultView
  18201. } = ownerDocument; // Allow initialPosition to bypass focus behavior. This is useful
  18202. // for the list view or other areas where we don't want to transfer
  18203. // focus to the editor canvas.
  18204. if (initialPosition === undefined || initialPosition === null) {
  18205. return;
  18206. }
  18207. if (!hasMultiSelection || isMultiSelecting) {
  18208. return;
  18209. }
  18210. const {
  18211. length
  18212. } = multiSelectedBlockClientIds;
  18213. if (length < 2) {
  18214. return;
  18215. }
  18216. if (!isFullSelection) {
  18217. return;
  18218. } // Allow cross contentEditable selection by temporarily making
  18219. // all content editable. We can't rely on using the store and
  18220. // React because re-rending happens too slowly. We need to be
  18221. // able to select across instances immediately.
  18222. node.contentEditable = true; // For some browsers, like Safari, it is important that focus
  18223. // happens BEFORE selection removal.
  18224. node.focus();
  18225. defaultView.getSelection().removeAllRanges();
  18226. }, [hasMultiSelection, isMultiSelecting, multiSelectedBlockClientIds, selectedBlockClientId, initialPosition, isFullSelection]);
  18227. }
  18228. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-tab-nav.js
  18229. /**
  18230. * WordPress dependencies
  18231. */
  18232. /**
  18233. * Internal dependencies
  18234. */
  18235. function useTabNav() {
  18236. const container = (0,external_wp_element_namespaceObject.useRef)();
  18237. const focusCaptureBeforeRef = (0,external_wp_element_namespaceObject.useRef)();
  18238. const focusCaptureAfterRef = (0,external_wp_element_namespaceObject.useRef)();
  18239. const lastFocus = (0,external_wp_element_namespaceObject.useRef)();
  18240. const {
  18241. hasMultiSelection,
  18242. getSelectedBlockClientId,
  18243. getBlockCount
  18244. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  18245. const {
  18246. setNavigationMode
  18247. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  18248. const isNavigationMode = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isNavigationMode(), []); // Don't allow tabbing to this element in Navigation mode.
  18249. const focusCaptureTabIndex = !isNavigationMode ? '0' : undefined; // Reference that holds the a flag for enabling or disabling
  18250. // capturing on the focus capture elements.
  18251. const noCapture = (0,external_wp_element_namespaceObject.useRef)();
  18252. function onFocusCapture(event) {
  18253. // Do not capture incoming focus if set by us in WritingFlow.
  18254. if (noCapture.current) {
  18255. noCapture.current = null;
  18256. } else if (hasMultiSelection()) {
  18257. container.current.focus();
  18258. } else if (getSelectedBlockClientId()) {
  18259. lastFocus.current.focus();
  18260. } else {
  18261. setNavigationMode(true);
  18262. const isBefore = // eslint-disable-next-line no-bitwise
  18263. event.target.compareDocumentPosition(container.current) & event.target.DOCUMENT_POSITION_FOLLOWING;
  18264. const action = isBefore ? 'findNext' : 'findPrevious';
  18265. external_wp_dom_namespaceObject.focus.tabbable[action](event.target).focus();
  18266. }
  18267. }
  18268. const before = (0,external_wp_element_namespaceObject.createElement)("div", {
  18269. ref: focusCaptureBeforeRef,
  18270. tabIndex: focusCaptureTabIndex,
  18271. onFocus: onFocusCapture
  18272. });
  18273. const after = (0,external_wp_element_namespaceObject.createElement)("div", {
  18274. ref: focusCaptureAfterRef,
  18275. tabIndex: focusCaptureTabIndex,
  18276. onFocus: onFocusCapture
  18277. });
  18278. const ref = (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  18279. function onKeyDown(event) {
  18280. if (event.defaultPrevented) {
  18281. return;
  18282. }
  18283. if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE) {
  18284. event.preventDefault();
  18285. setNavigationMode(true);
  18286. return;
  18287. } // In Edit mode, Tab should focus the first tabbable element after
  18288. // the content, which is normally the sidebar (with block controls)
  18289. // and Shift+Tab should focus the first tabbable element before the
  18290. // content, which is normally the block toolbar.
  18291. // Arrow keys can be used, and Tab and arrow keys can be used in
  18292. // Navigation mode (press Esc), to navigate through blocks.
  18293. if (event.keyCode !== external_wp_keycodes_namespaceObject.TAB) {
  18294. return;
  18295. }
  18296. const isShift = event.shiftKey;
  18297. const direction = isShift ? 'findPrevious' : 'findNext';
  18298. if (!hasMultiSelection() && !getSelectedBlockClientId()) {
  18299. // Preserve the behaviour of entering navigation mode when
  18300. // tabbing into the content without a block selection.
  18301. // `onFocusCapture` already did this previously, but we need to
  18302. // do it again here because after clearing block selection,
  18303. // focus land on the writing flow container and pressing Tab
  18304. // will no longer send focus through the focus capture element.
  18305. if (event.target === node) setNavigationMode(true);
  18306. return;
  18307. } // Allow tabbing from the block wrapper to a form element,
  18308. // and between form elements rendered in a block,
  18309. // such as inside a placeholder. Form elements are generally
  18310. // meant to be UI rather than part of the content. Ideally
  18311. // these are not rendered in the content and perhaps in the
  18312. // future they can be rendered in an iframe or shadow DOM.
  18313. if (((0,external_wp_dom_namespaceObject.isFormElement)(event.target) || event.target.getAttribute('data-block') === getSelectedBlockClientId()) && (0,external_wp_dom_namespaceObject.isFormElement)(external_wp_dom_namespaceObject.focus.tabbable[direction](event.target))) {
  18314. return;
  18315. }
  18316. const next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef; // Disable focus capturing on the focus capture element, so it
  18317. // doesn't refocus this block and so it allows default behaviour
  18318. // (moving focus to the next tabbable element).
  18319. noCapture.current = true; // Focusing the focus capture element, which is located above and
  18320. // below the editor, should not scroll the page all the way up or
  18321. // down.
  18322. next.current.focus({
  18323. preventScroll: true
  18324. });
  18325. }
  18326. function onFocusOut(event) {
  18327. lastFocus.current = event.target;
  18328. const {
  18329. ownerDocument
  18330. } = node; // If focus disappears due to there being no blocks, move focus to
  18331. // the writing flow wrapper.
  18332. if (!event.relatedTarget && ownerDocument.activeElement === ownerDocument.body && getBlockCount() === 0) {
  18333. node.focus();
  18334. }
  18335. } // When tabbing back to an element in block list, this event handler prevents scrolling if the
  18336. // focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph
  18337. // when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the
  18338. // top or bottom of the document.
  18339. //
  18340. // Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this
  18341. // earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.
  18342. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters
  18343. function preventScrollOnTab(event) {
  18344. var _event$target;
  18345. if (event.keyCode !== external_wp_keycodes_namespaceObject.TAB) {
  18346. return;
  18347. }
  18348. if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getAttribute('role')) === 'region') {
  18349. return;
  18350. }
  18351. if (container.current === event.target) {
  18352. return;
  18353. }
  18354. const isShift = event.shiftKey;
  18355. const direction = isShift ? 'findPrevious' : 'findNext';
  18356. const target = external_wp_dom_namespaceObject.focus.tabbable[direction](event.target); // Only do something when the next tabbable is a focus capture div (before/after)
  18357. if (target === focusCaptureBeforeRef.current || target === focusCaptureAfterRef.current) {
  18358. event.preventDefault();
  18359. target.focus({
  18360. preventScroll: true
  18361. });
  18362. }
  18363. }
  18364. const {
  18365. ownerDocument
  18366. } = node;
  18367. const {
  18368. defaultView
  18369. } = ownerDocument;
  18370. defaultView.addEventListener('keydown', preventScrollOnTab);
  18371. node.addEventListener('keydown', onKeyDown);
  18372. node.addEventListener('focusout', onFocusOut);
  18373. return () => {
  18374. defaultView.removeEventListener('keydown', preventScrollOnTab);
  18375. node.removeEventListener('keydown', onKeyDown);
  18376. node.removeEventListener('focusout', onFocusOut);
  18377. };
  18378. }, []);
  18379. const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([container, ref]);
  18380. return [before, mergedRefs, after];
  18381. }
  18382. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-arrow-nav.js
  18383. /**
  18384. * WordPress dependencies
  18385. */
  18386. /**
  18387. * Internal dependencies
  18388. */
  18389. /**
  18390. * Returns true if the element should consider edge navigation upon a keyboard
  18391. * event of the given directional key code, or false otherwise.
  18392. *
  18393. * @param {Element} element HTML element to test.
  18394. * @param {number} keyCode KeyboardEvent keyCode to test.
  18395. * @param {boolean} hasModifier Whether a modifier is pressed.
  18396. *
  18397. * @return {boolean} Whether element should consider edge navigation.
  18398. */
  18399. function isNavigationCandidate(element, keyCode, hasModifier) {
  18400. const isVertical = keyCode === external_wp_keycodes_namespaceObject.UP || keyCode === external_wp_keycodes_namespaceObject.DOWN; // Currently, all elements support unmodified vertical navigation.
  18401. if (isVertical && !hasModifier) {
  18402. return true;
  18403. }
  18404. const {
  18405. tagName
  18406. } = element; // Native inputs should not navigate horizontally, unless they are simple types that don't need left/right arrow keys.
  18407. if (tagName === 'INPUT') {
  18408. const simpleInputTypes = ['button', 'checkbox', 'color', 'file', 'image', 'radio', 'reset', 'submit'];
  18409. return simpleInputTypes.includes(element.getAttribute('type'));
  18410. } // Native textareas should not navigate horizontally.
  18411. return tagName !== 'TEXTAREA';
  18412. }
  18413. /**
  18414. * Returns the optimal tab target from the given focused element in the desired
  18415. * direction. A preference is made toward text fields, falling back to the block
  18416. * focus stop if no other candidates exist for the block.
  18417. *
  18418. * @param {Element} target Currently focused text field.
  18419. * @param {boolean} isReverse True if considering as the first field.
  18420. * @param {Element} containerElement Element containing all blocks.
  18421. * @param {boolean} onlyVertical Whether to only consider tabbable elements
  18422. * that are visually above or under the
  18423. * target.
  18424. *
  18425. * @return {?Element} Optimal tab target, if one exists.
  18426. */
  18427. function getClosestTabbable(target, isReverse, containerElement, onlyVertical) {
  18428. // Since the current focus target is not guaranteed to be a text field, find
  18429. // all focusables. Tabbability is considered later.
  18430. let focusableNodes = external_wp_dom_namespaceObject.focus.focusable.find(containerElement);
  18431. if (isReverse) {
  18432. focusableNodes.reverse();
  18433. } // Consider as candidates those focusables after the current target. It's
  18434. // assumed this can only be reached if the target is focusable (on its
  18435. // keydown event), so no need to verify it exists in the set.
  18436. focusableNodes = focusableNodes.slice(focusableNodes.indexOf(target) + 1);
  18437. let targetRect;
  18438. if (onlyVertical) {
  18439. targetRect = target.getBoundingClientRect();
  18440. }
  18441. function isTabCandidate(node) {
  18442. // Not a candidate if the node is not tabbable.
  18443. if (!external_wp_dom_namespaceObject.focus.tabbable.isTabbableIndex(node)) {
  18444. return false;
  18445. } // Skip focusable elements such as links within content editable nodes.
  18446. if (node.isContentEditable && node.contentEditable !== 'true') {
  18447. return false;
  18448. }
  18449. if (onlyVertical) {
  18450. const nodeRect = node.getBoundingClientRect();
  18451. if (nodeRect.left >= targetRect.right || nodeRect.right <= targetRect.left) {
  18452. return false;
  18453. }
  18454. }
  18455. return true;
  18456. }
  18457. return focusableNodes.find(isTabCandidate);
  18458. }
  18459. function useArrowNav() {
  18460. const {
  18461. getMultiSelectedBlocksStartClientId,
  18462. getMultiSelectedBlocksEndClientId,
  18463. getSettings,
  18464. hasMultiSelection,
  18465. __unstableIsFullySelected
  18466. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  18467. const {
  18468. selectBlock
  18469. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  18470. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  18471. // Here a DOMRect is stored while moving the caret vertically so
  18472. // vertical position of the start position can be restored. This is to
  18473. // recreate browser behaviour across blocks.
  18474. let verticalRect;
  18475. function onMouseDown() {
  18476. verticalRect = null;
  18477. }
  18478. function isClosestTabbableABlock(target, isReverse) {
  18479. const closestTabbable = getClosestTabbable(target, isReverse, node);
  18480. return closestTabbable && getBlockClientId(closestTabbable);
  18481. }
  18482. function onKeyDown(event) {
  18483. const {
  18484. keyCode,
  18485. target
  18486. } = event;
  18487. const isUp = keyCode === external_wp_keycodes_namespaceObject.UP;
  18488. const isDown = keyCode === external_wp_keycodes_namespaceObject.DOWN;
  18489. const isLeft = keyCode === external_wp_keycodes_namespaceObject.LEFT;
  18490. const isRight = keyCode === external_wp_keycodes_namespaceObject.RIGHT;
  18491. const isReverse = isUp || isLeft;
  18492. const isHorizontal = isLeft || isRight;
  18493. const isVertical = isUp || isDown;
  18494. const isNav = isHorizontal || isVertical;
  18495. const isShift = event.shiftKey;
  18496. const hasModifier = isShift || event.ctrlKey || event.altKey || event.metaKey;
  18497. const isNavEdge = isVertical ? external_wp_dom_namespaceObject.isVerticalEdge : external_wp_dom_namespaceObject.isHorizontalEdge;
  18498. const {
  18499. ownerDocument
  18500. } = node;
  18501. const {
  18502. defaultView
  18503. } = ownerDocument; // If there is a multi-selection, the arrow keys should collapse the
  18504. // selection to the start or end of the selection.
  18505. if (hasMultiSelection()) {
  18506. // Only handle if we have a full selection (not a native partial
  18507. // selection).
  18508. if (!__unstableIsFullySelected()) {
  18509. return;
  18510. }
  18511. if (event.defaultPrevented) {
  18512. return;
  18513. }
  18514. if (!isNav) {
  18515. return;
  18516. }
  18517. if (isShift) {
  18518. return;
  18519. }
  18520. event.preventDefault();
  18521. if (isReverse) {
  18522. selectBlock(getMultiSelectedBlocksStartClientId());
  18523. } else {
  18524. selectBlock(getMultiSelectedBlocksEndClientId(), -1);
  18525. }
  18526. return;
  18527. } // When presing any key other than up or down, the initial vertical
  18528. // position must ALWAYS be reset. The vertical position is saved so
  18529. // it can be restored as well as possible on sebsequent vertical
  18530. // arrow key presses. It may not always be possible to restore the
  18531. // exact same position (such as at an empty line), so it wouldn't be
  18532. // good to compute the position right before any vertical arrow key
  18533. // press.
  18534. if (!isVertical) {
  18535. verticalRect = null;
  18536. } else if (!verticalRect) {
  18537. verticalRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView);
  18538. } // Abort if navigation has already been handled (e.g. RichText
  18539. // inline boundaries).
  18540. if (event.defaultPrevented) {
  18541. return;
  18542. }
  18543. if (!isNav) {
  18544. return;
  18545. } // Abort if our current target is not a candidate for navigation
  18546. // (e.g. preserve native input behaviors).
  18547. if (!isNavigationCandidate(target, keyCode, hasModifier)) {
  18548. return;
  18549. } // In the case of RTL scripts, right means previous and left means
  18550. // next, which is the exact reverse of LTR.
  18551. const isReverseDir = (0,external_wp_dom_namespaceObject.isRTL)(target) ? !isReverse : isReverse;
  18552. const {
  18553. keepCaretInsideBlock
  18554. } = getSettings();
  18555. if (isShift) {
  18556. if (isClosestTabbableABlock(target, isReverse) && isNavEdge(target, isReverse)) {
  18557. node.contentEditable = true; // Firefox doesn't automatically move focus.
  18558. node.focus();
  18559. }
  18560. } else if (isVertical && (0,external_wp_dom_namespaceObject.isVerticalEdge)(target, isReverse) && !keepCaretInsideBlock) {
  18561. const closestTabbable = getClosestTabbable(target, isReverse, node, true);
  18562. if (closestTabbable) {
  18563. (0,external_wp_dom_namespaceObject.placeCaretAtVerticalEdge)(closestTabbable, isReverse, verticalRect);
  18564. event.preventDefault();
  18565. }
  18566. } else if (isHorizontal && defaultView.getSelection().isCollapsed && (0,external_wp_dom_namespaceObject.isHorizontalEdge)(target, isReverseDir) && !keepCaretInsideBlock) {
  18567. const closestTabbable = getClosestTabbable(target, isReverseDir, node);
  18568. (0,external_wp_dom_namespaceObject.placeCaretAtHorizontalEdge)(closestTabbable, isReverse);
  18569. event.preventDefault();
  18570. }
  18571. }
  18572. node.addEventListener('mousedown', onMouseDown);
  18573. node.addEventListener('keydown', onKeyDown);
  18574. return () => {
  18575. node.removeEventListener('mousedown', onMouseDown);
  18576. node.removeEventListener('keydown', onKeyDown);
  18577. };
  18578. }, []);
  18579. }
  18580. ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
  18581. var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
  18582. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-select-all.js
  18583. /**
  18584. * WordPress dependencies
  18585. */
  18586. /**
  18587. * Internal dependencies
  18588. */
  18589. function useSelectAll() {
  18590. const {
  18591. getBlockOrder,
  18592. getSelectedBlockClientIds,
  18593. getBlockRootClientId
  18594. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  18595. const {
  18596. multiSelect,
  18597. selectBlock
  18598. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  18599. const isMatch = (0,external_wp_keyboardShortcuts_namespaceObject.__unstableUseShortcutEventMatch)();
  18600. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  18601. function onKeyDown(event) {
  18602. if (!isMatch('core/block-editor/select-all', event)) {
  18603. return;
  18604. }
  18605. const selectedClientIds = getSelectedBlockClientIds();
  18606. if (selectedClientIds.length < 2 && !(0,external_wp_dom_namespaceObject.isEntirelySelected)(event.target)) {
  18607. return;
  18608. }
  18609. event.preventDefault();
  18610. const [firstSelectedClientId] = selectedClientIds;
  18611. const rootClientId = getBlockRootClientId(firstSelectedClientId);
  18612. const blockClientIds = getBlockOrder(rootClientId); // If we have selected all sibling nested blocks, try selecting up a
  18613. // level. See: https://github.com/WordPress/gutenberg/pull/31859/
  18614. if (selectedClientIds.length === blockClientIds.length) {
  18615. if (rootClientId) {
  18616. node.ownerDocument.defaultView.getSelection().removeAllRanges();
  18617. selectBlock(rootClientId);
  18618. }
  18619. return;
  18620. }
  18621. multiSelect(blockClientIds[0], blockClientIds[blockClientIds.length - 1]);
  18622. }
  18623. node.addEventListener('keydown', onKeyDown);
  18624. return () => {
  18625. node.removeEventListener('keydown', onKeyDown);
  18626. };
  18627. }, []);
  18628. }
  18629. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-drag-selection.js
  18630. /**
  18631. * WordPress dependencies
  18632. */
  18633. /**
  18634. * Internal dependencies
  18635. */
  18636. /**
  18637. * Sets the `contenteditable` wrapper element to `value`.
  18638. *
  18639. * @param {HTMLElement} node Block element.
  18640. * @param {boolean} value `contentEditable` value (true or false)
  18641. */
  18642. function setContentEditableWrapper(node, value) {
  18643. node.contentEditable = value; // Firefox doesn't automatically move focus.
  18644. if (value) node.focus();
  18645. }
  18646. /**
  18647. * Sets a multi-selection based on the native selection across blocks.
  18648. */
  18649. function useDragSelection() {
  18650. const {
  18651. startMultiSelect,
  18652. stopMultiSelect
  18653. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  18654. const {
  18655. isSelectionEnabled,
  18656. hasMultiSelection,
  18657. isDraggingBlocks
  18658. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  18659. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  18660. const {
  18661. ownerDocument
  18662. } = node;
  18663. const {
  18664. defaultView
  18665. } = ownerDocument;
  18666. let anchorElement;
  18667. let rafId;
  18668. function onMouseUp() {
  18669. stopMultiSelect(); // Equivalent to attaching the listener once.
  18670. defaultView.removeEventListener('mouseup', onMouseUp); // The browser selection won't have updated yet at this point,
  18671. // so wait until the next animation frame to get the browser
  18672. // selection.
  18673. rafId = defaultView.requestAnimationFrame(() => {
  18674. if (hasMultiSelection()) {
  18675. return;
  18676. } // If the selection is complete (on mouse up), and no
  18677. // multiple blocks have been selected, set focus back to the
  18678. // anchor element. if the anchor element contains the
  18679. // selection. Additionally, the contentEditable wrapper can
  18680. // now be disabled again.
  18681. setContentEditableWrapper(node, false);
  18682. const selection = defaultView.getSelection();
  18683. if (selection.rangeCount) {
  18684. const {
  18685. commonAncestorContainer
  18686. } = selection.getRangeAt(0);
  18687. if (anchorElement.contains(commonAncestorContainer)) {
  18688. anchorElement.focus();
  18689. }
  18690. }
  18691. });
  18692. }
  18693. function onMouseLeave(_ref) {
  18694. let {
  18695. buttons,
  18696. target
  18697. } = _ref;
  18698. // Avoid triggering a multi-selection if the user is already
  18699. // dragging blocks.
  18700. if (isDraggingBlocks()) {
  18701. return;
  18702. } // The primary button must be pressed to initiate selection.
  18703. // See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  18704. if (buttons !== 1) {
  18705. return;
  18706. } // Check the attribute, not the contentEditable attribute. All
  18707. // child elements of the content editable wrapper are editable
  18708. // and return true for this property. We only want to start
  18709. // multi selecting when the mouse leaves the wrapper.
  18710. if (!target.getAttribute('contenteditable')) {
  18711. return;
  18712. }
  18713. if (!isSelectionEnabled()) {
  18714. return;
  18715. }
  18716. anchorElement = ownerDocument.activeElement;
  18717. startMultiSelect(); // `onSelectionStart` is called after `mousedown` and
  18718. // `mouseleave` (from a block). The selection ends when
  18719. // `mouseup` happens anywhere in the window.
  18720. defaultView.addEventListener('mouseup', onMouseUp); // Allow cross contentEditable selection by temporarily making
  18721. // all content editable. We can't rely on using the store and
  18722. // React because re-rending happens too slowly. We need to be
  18723. // able to select across instances immediately.
  18724. setContentEditableWrapper(node, true);
  18725. }
  18726. node.addEventListener('mouseout', onMouseLeave);
  18727. return () => {
  18728. node.removeEventListener('mouseout', onMouseLeave);
  18729. defaultView.removeEventListener('mouseup', onMouseUp);
  18730. defaultView.cancelAnimationFrame(rafId);
  18731. };
  18732. }, [startMultiSelect, stopMultiSelect, isSelectionEnabled, hasMultiSelection]);
  18733. }
  18734. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-selection-observer.js
  18735. /**
  18736. * WordPress dependencies
  18737. */
  18738. /**
  18739. * Internal dependencies
  18740. */
  18741. /**
  18742. * Extract the selection start node from the selection. When the anchor node is
  18743. * not a text node, the selection offset is the index of a child node.
  18744. *
  18745. * @param {Selection} selection The selection.
  18746. *
  18747. * @return {Element} The selection start node.
  18748. */
  18749. function extractSelectionStartNode(selection) {
  18750. const {
  18751. anchorNode,
  18752. anchorOffset
  18753. } = selection;
  18754. if (anchorNode.nodeType === anchorNode.TEXT_NODE) {
  18755. return anchorNode;
  18756. }
  18757. if (anchorOffset === 0) {
  18758. return anchorNode;
  18759. }
  18760. return anchorNode.childNodes[anchorOffset - 1];
  18761. }
  18762. /**
  18763. * Extract the selection end node from the selection. When the focus node is not
  18764. * a text node, the selection offset is the index of a child node. The selection
  18765. * reaches up to but excluding that child node.
  18766. *
  18767. * @param {Selection} selection The selection.
  18768. *
  18769. * @return {Element} The selection start node.
  18770. */
  18771. function extractSelectionEndNode(selection) {
  18772. const {
  18773. focusNode,
  18774. focusOffset
  18775. } = selection;
  18776. if (focusNode.nodeType === focusNode.TEXT_NODE) {
  18777. return focusNode;
  18778. }
  18779. if (focusOffset === focusNode.childNodes.length) {
  18780. return focusNode;
  18781. }
  18782. return focusNode.childNodes[focusOffset];
  18783. }
  18784. function findDepth(a, b) {
  18785. let depth = 0;
  18786. while (a[depth] === b[depth]) {
  18787. depth++;
  18788. }
  18789. return depth;
  18790. }
  18791. /**
  18792. * Sets the `contenteditable` wrapper element to `value`.
  18793. *
  18794. * @param {HTMLElement} node Block element.
  18795. * @param {boolean} value `contentEditable` value (true or false)
  18796. */
  18797. function use_selection_observer_setContentEditableWrapper(node, value) {
  18798. node.contentEditable = value; // Firefox doesn't automatically move focus.
  18799. if (value) node.focus();
  18800. }
  18801. /**
  18802. * Sets a multi-selection based on the native selection across blocks.
  18803. */
  18804. function useSelectionObserver() {
  18805. const {
  18806. multiSelect,
  18807. selectBlock,
  18808. selectionChange
  18809. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  18810. const {
  18811. getBlockParents,
  18812. getBlockSelectionStart
  18813. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  18814. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  18815. const {
  18816. ownerDocument
  18817. } = node;
  18818. const {
  18819. defaultView
  18820. } = ownerDocument;
  18821. function onSelectionChange(event) {
  18822. const selection = defaultView.getSelection();
  18823. if (!selection.rangeCount) {
  18824. return;
  18825. } // If selection is collapsed and we haven't used `shift+click`,
  18826. // end multi selection and disable the contentEditable wrapper.
  18827. // We have to check about `shift+click` case because elements
  18828. // that don't support text selection might be involved, and we might
  18829. // update the clientIds to multi-select blocks.
  18830. // For now we check if the event is a `mouse` event.
  18831. const isClickShift = event.shiftKey && event.type === 'mouseup';
  18832. if (selection.isCollapsed && !isClickShift) {
  18833. use_selection_observer_setContentEditableWrapper(node, false);
  18834. return;
  18835. }
  18836. let startClientId = getBlockClientId(extractSelectionStartNode(selection));
  18837. let endClientId = getBlockClientId(extractSelectionEndNode(selection)); // If the selection has changed and we had pressed `shift+click`,
  18838. // we need to check if in an element that doesn't support
  18839. // text selection has been clicked.
  18840. if (isClickShift) {
  18841. const selectedClientId = getBlockSelectionStart();
  18842. const clickedClientId = getBlockClientId(event.target); // `endClientId` is not defined if we end the selection by clicking a non-selectable block.
  18843. // We need to check if there was already a selection with a non-selectable focusNode.
  18844. const focusNodeIsNonSelectable = clickedClientId !== endClientId;
  18845. if (startClientId === endClientId && selection.isCollapsed || !endClientId || focusNodeIsNonSelectable) {
  18846. endClientId = clickedClientId;
  18847. } // Handle the case when we have a non-selectable block
  18848. // selected and click another one.
  18849. if (startClientId !== selectedClientId) {
  18850. startClientId = selectedClientId;
  18851. }
  18852. } // If the selection did not involve a block, return.
  18853. if (startClientId === undefined && endClientId === undefined) {
  18854. use_selection_observer_setContentEditableWrapper(node, false);
  18855. return;
  18856. }
  18857. const isSingularSelection = startClientId === endClientId;
  18858. if (isSingularSelection) {
  18859. selectBlock(startClientId);
  18860. } else {
  18861. const startPath = [...getBlockParents(startClientId), startClientId];
  18862. const endPath = [...getBlockParents(endClientId), endClientId];
  18863. const depth = findDepth(startPath, endPath);
  18864. multiSelect(startPath[depth], endPath[depth]);
  18865. }
  18866. }
  18867. function addListeners() {
  18868. ownerDocument.addEventListener('selectionchange', onSelectionChange);
  18869. defaultView.addEventListener('mouseup', onSelectionChange);
  18870. }
  18871. function removeListeners() {
  18872. ownerDocument.removeEventListener('selectionchange', onSelectionChange);
  18873. defaultView.removeEventListener('mouseup', onSelectionChange);
  18874. }
  18875. function resetListeners() {
  18876. removeListeners();
  18877. addListeners();
  18878. }
  18879. addListeners(); // We must allow rich text to set selection first. This ensures that
  18880. // our `selectionchange` listener is always reset to be called after
  18881. // the rich text one.
  18882. node.addEventListener('focusin', resetListeners);
  18883. return () => {
  18884. removeListeners();
  18885. node.removeEventListener('focusin', resetListeners);
  18886. };
  18887. }, [multiSelect, selectBlock, selectionChange, getBlockParents]);
  18888. }
  18889. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-click-selection.js
  18890. /**
  18891. * WordPress dependencies
  18892. */
  18893. /**
  18894. * Internal dependencies
  18895. */
  18896. function useClickSelection() {
  18897. const {
  18898. selectBlock
  18899. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  18900. const {
  18901. isSelectionEnabled,
  18902. getBlockSelectionStart,
  18903. hasMultiSelection
  18904. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  18905. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  18906. function onMouseDown(event) {
  18907. // The main button.
  18908. // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
  18909. if (!isSelectionEnabled() || event.button !== 0) {
  18910. return;
  18911. }
  18912. const startClientId = getBlockSelectionStart();
  18913. const clickedClientId = getBlockClientId(event.target);
  18914. if (event.shiftKey) {
  18915. if (startClientId !== clickedClientId) {
  18916. node.contentEditable = true; // Firefox doesn't automatically move focus.
  18917. node.focus();
  18918. }
  18919. } else if (hasMultiSelection()) {
  18920. // Allow user to escape out of a multi-selection to a
  18921. // singular selection of a block via click. This is handled
  18922. // here since focus handling excludes blocks when there is
  18923. // multiselection, as focus can be incurred by starting a
  18924. // multiselection (focus moved to first block's multi-
  18925. // controls).
  18926. selectBlock(clickedClientId);
  18927. }
  18928. }
  18929. node.addEventListener('mousedown', onMouseDown);
  18930. return () => {
  18931. node.removeEventListener('mousedown', onMouseDown);
  18932. };
  18933. }, [selectBlock, isSelectionEnabled, getBlockSelectionStart, hasMultiSelection]);
  18934. }
  18935. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-input.js
  18936. /**
  18937. * WordPress dependencies
  18938. */
  18939. /**
  18940. * Internal dependencies
  18941. */
  18942. /**
  18943. * Handles input for selections across blocks.
  18944. */
  18945. function useInput() {
  18946. const {
  18947. __unstableIsFullySelected,
  18948. getSelectedBlockClientIds,
  18949. __unstableIsSelectionMergeable,
  18950. hasMultiSelection
  18951. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  18952. const {
  18953. replaceBlocks,
  18954. __unstableSplitSelection,
  18955. removeBlocks,
  18956. __unstableDeleteSelection,
  18957. __unstableExpandSelection
  18958. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  18959. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  18960. function onBeforeInput(event) {
  18961. var _event$inputType;
  18962. if (!hasMultiSelection()) {
  18963. return;
  18964. } // Prevent the browser to format something when we have multiselection.
  18965. if ((_event$inputType = event.inputType) !== null && _event$inputType !== void 0 && _event$inputType.startsWith('format')) {
  18966. event.preventDefault();
  18967. }
  18968. }
  18969. function onKeyDown(event) {
  18970. if (event.defaultPrevented) {
  18971. return;
  18972. }
  18973. if (!hasMultiSelection()) {
  18974. return;
  18975. }
  18976. if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
  18977. node.contentEditable = false;
  18978. event.preventDefault();
  18979. if (__unstableIsFullySelected()) {
  18980. replaceBlocks(getSelectedBlockClientIds(), (0,external_wp_blocks_namespaceObject.createBlock)((0,external_wp_blocks_namespaceObject.getDefaultBlockName)()));
  18981. } else {
  18982. __unstableSplitSelection();
  18983. }
  18984. } else if (event.keyCode === external_wp_keycodes_namespaceObject.BACKSPACE || event.keyCode === external_wp_keycodes_namespaceObject.DELETE) {
  18985. node.contentEditable = false;
  18986. event.preventDefault();
  18987. if (__unstableIsFullySelected()) {
  18988. removeBlocks(getSelectedBlockClientIds());
  18989. } else if (__unstableIsSelectionMergeable()) {
  18990. __unstableDeleteSelection(event.keyCode === external_wp_keycodes_namespaceObject.DELETE);
  18991. } else {
  18992. __unstableExpandSelection();
  18993. }
  18994. } else if ( // If key.length is longer than 1, it's a control key that doesn't
  18995. // input anything.
  18996. event.key.length === 1 && !(event.metaKey || event.ctrlKey)) {
  18997. node.contentEditable = false;
  18998. if (__unstableIsSelectionMergeable()) {
  18999. __unstableDeleteSelection(event.keyCode === external_wp_keycodes_namespaceObject.DELETE);
  19000. } else {
  19001. event.preventDefault(); // Safari does not stop default behaviour with either
  19002. // event.preventDefault() or node.contentEditable = false, so
  19003. // remove the selection to stop browser manipulation.
  19004. node.ownerDocument.defaultView.getSelection().removeAllRanges();
  19005. }
  19006. }
  19007. }
  19008. function onCompositionStart(event) {
  19009. if (!hasMultiSelection()) {
  19010. return;
  19011. }
  19012. node.contentEditable = false;
  19013. if (__unstableIsSelectionMergeable()) {
  19014. __unstableDeleteSelection();
  19015. } else {
  19016. event.preventDefault(); // Safari does not stop default behaviour with either
  19017. // event.preventDefault() or node.contentEditable = false, so
  19018. // remove the selection to stop browser manipulation.
  19019. node.ownerDocument.defaultView.getSelection().removeAllRanges();
  19020. }
  19021. }
  19022. node.addEventListener('beforeinput', onBeforeInput);
  19023. node.addEventListener('keydown', onKeyDown);
  19024. node.addEventListener('compositionstart', onCompositionStart);
  19025. return () => {
  19026. node.removeEventListener('beforeinput', onBeforeInput);
  19027. node.removeEventListener('keydown', onKeyDown);
  19028. node.removeEventListener('compositionstart', onCompositionStart);
  19029. };
  19030. }, []);
  19031. }
  19032. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/index.js
  19033. /**
  19034. * External dependencies
  19035. */
  19036. /**
  19037. * WordPress dependencies
  19038. */
  19039. /**
  19040. * Internal dependencies
  19041. */
  19042. function useWritingFlow() {
  19043. const [before, ref, after] = useTabNav();
  19044. const hasMultiSelection = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).hasMultiSelection(), []);
  19045. return [before, (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, useInput(), useDragSelection(), useSelectionObserver(), useClickSelection(), useMultiSelection(), useSelectAll(), useArrowNav(), (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  19046. node.tabIndex = -1;
  19047. node.contentEditable = hasMultiSelection;
  19048. if (!hasMultiSelection) {
  19049. return;
  19050. }
  19051. node.classList.add('has-multi-selection');
  19052. node.setAttribute('aria-label', (0,external_wp_i18n_namespaceObject.__)('Multiple selected blocks'));
  19053. return () => {
  19054. node.classList.remove('has-multi-selection');
  19055. node.removeAttribute('aria-label');
  19056. };
  19057. }, [hasMultiSelection])]), after];
  19058. }
  19059. function WritingFlow(_ref, forwardedRef) {
  19060. let {
  19061. children,
  19062. ...props
  19063. } = _ref;
  19064. const [before, ref, after] = useWritingFlow();
  19065. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, before, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, props, {
  19066. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, forwardedRef]),
  19067. className: classnames_default()(props.className, 'block-editor-writing-flow')
  19068. }), children), after);
  19069. }
  19070. /**
  19071. * Handles selection and navigation across blocks. This component should be
  19072. * wrapped around BlockList.
  19073. *
  19074. * @param {Object} props Component properties.
  19075. * @param {WPElement} props.children Children to be rendered.
  19076. */
  19077. /* harmony default export */ var writing_flow = ((0,external_wp_element_namespaceObject.forwardRef)(WritingFlow));
  19078. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/iframe/index.js
  19079. /**
  19080. * External dependencies
  19081. */
  19082. /**
  19083. * WordPress dependencies
  19084. */
  19085. /**
  19086. * Internal dependencies
  19087. */
  19088. const BODY_CLASS_NAME = 'editor-styles-wrapper';
  19089. const BLOCK_PREFIX = 'wp-block';
  19090. /**
  19091. * Clones stylesheets targetting the editor canvas to the given document. A
  19092. * stylesheet is considered targetting the editor a canvas if it contains the
  19093. * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.
  19094. *
  19095. * Ideally, this hook should be removed in the future and styles should be added
  19096. * explicitly as editor styles.
  19097. */
  19098. function useStylesCompatibility() {
  19099. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  19100. // Search the document for stylesheets targetting the editor canvas.
  19101. Array.from(document.styleSheets).forEach(styleSheet => {
  19102. try {
  19103. // May fail for external styles.
  19104. // eslint-disable-next-line no-unused-expressions
  19105. styleSheet.cssRules;
  19106. } catch (e) {
  19107. return;
  19108. }
  19109. const {
  19110. ownerNode,
  19111. cssRules
  19112. } = styleSheet;
  19113. if (!cssRules) {
  19114. return;
  19115. } // Generally, ignore inline styles. We add inline styles belonging to a
  19116. // stylesheet later, which may or may not match the selectors.
  19117. if (ownerNode.tagName !== 'LINK') {
  19118. return;
  19119. } // Don't try to add the reset styles, which were removed as a dependency
  19120. // from `edit-blocks` for the iframe since we don't need to reset admin
  19121. // styles.
  19122. if (ownerNode.id === 'wp-reset-editor-styles-css') {
  19123. return;
  19124. }
  19125. function matchFromRules(_cssRules) {
  19126. return Array.from(_cssRules).find(_ref => {
  19127. let {
  19128. selectorText,
  19129. conditionText,
  19130. cssRules: __cssRules
  19131. } = _ref;
  19132. // If the rule is conditional then it will not have selector text.
  19133. // Recurse into child CSS ruleset to determine selector eligibility.
  19134. if (conditionText) {
  19135. return matchFromRules(__cssRules);
  19136. }
  19137. return selectorText && (selectorText.includes(`.${BODY_CLASS_NAME}`) || selectorText.includes(`.${BLOCK_PREFIX}`));
  19138. });
  19139. }
  19140. const isMatch = matchFromRules(cssRules);
  19141. if (isMatch && !node.ownerDocument.getElementById(ownerNode.id)) {
  19142. // Display warning once we have a way to add style dependencies to the editor.
  19143. // See: https://github.com/WordPress/gutenberg/pull/37466.
  19144. node.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
  19145. const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
  19146. const inlineCssElement = document.getElementById(inlineCssId);
  19147. if (inlineCssElement) {
  19148. node.appendChild(inlineCssElement.cloneNode(true));
  19149. }
  19150. }
  19151. });
  19152. }, []);
  19153. }
  19154. /**
  19155. * Bubbles some event types (keydown, keypress, and dragover) to parent document
  19156. * document to ensure that the keyboard shortcuts and drag and drop work.
  19157. *
  19158. * Ideally, we should remove event bubbling in the future. Keyboard shortcuts
  19159. * should be context dependent, e.g. actions on blocks like Cmd+A should not
  19160. * work globally outside the block editor.
  19161. *
  19162. * @param {Document} doc Document to attach listeners to.
  19163. */
  19164. function bubbleEvents(doc) {
  19165. const {
  19166. defaultView
  19167. } = doc;
  19168. const {
  19169. frameElement
  19170. } = defaultView;
  19171. function bubbleEvent(event) {
  19172. const prototype = Object.getPrototypeOf(event);
  19173. const constructorName = prototype.constructor.name;
  19174. const Constructor = window[constructorName];
  19175. const init = {};
  19176. for (const key in event) {
  19177. init[key] = event[key];
  19178. }
  19179. if (event instanceof defaultView.MouseEvent) {
  19180. const rect = frameElement.getBoundingClientRect();
  19181. init.clientX += rect.left;
  19182. init.clientY += rect.top;
  19183. }
  19184. const newEvent = new Constructor(event.type, init);
  19185. const cancelled = !frameElement.dispatchEvent(newEvent);
  19186. if (cancelled) {
  19187. event.preventDefault();
  19188. }
  19189. }
  19190. const eventTypes = ['dragover'];
  19191. for (const name of eventTypes) {
  19192. doc.addEventListener(name, bubbleEvent);
  19193. }
  19194. }
  19195. function useParsedAssets(html) {
  19196. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  19197. const doc = document.implementation.createHTMLDocument('');
  19198. doc.body.innerHTML = html;
  19199. return Array.from(doc.body.children);
  19200. }, [html]);
  19201. }
  19202. async function loadScript(head, _ref2) {
  19203. let {
  19204. id,
  19205. src
  19206. } = _ref2;
  19207. return new Promise((resolve, reject) => {
  19208. const script = head.ownerDocument.createElement('script');
  19209. script.id = id;
  19210. if (src) {
  19211. script.src = src;
  19212. script.onload = () => resolve();
  19213. script.onerror = () => reject();
  19214. } else {
  19215. resolve();
  19216. }
  19217. head.appendChild(script);
  19218. });
  19219. }
  19220. function Iframe(_ref3, ref) {
  19221. let {
  19222. contentRef,
  19223. children,
  19224. head,
  19225. tabIndex = 0,
  19226. assets,
  19227. isZoomedOut,
  19228. ...props
  19229. } = _ref3;
  19230. const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(() => ({}));
  19231. const [iframeDocument, setIframeDocument] = (0,external_wp_element_namespaceObject.useState)();
  19232. const [bodyClasses, setBodyClasses] = (0,external_wp_element_namespaceObject.useState)([]);
  19233. const styles = useParsedAssets(assets === null || assets === void 0 ? void 0 : assets.styles);
  19234. const scripts = useParsedAssets(assets === null || assets === void 0 ? void 0 : assets.scripts);
  19235. const clearerRef = useBlockSelectionClearer();
  19236. const [before, writingFlowRef, after] = useWritingFlow();
  19237. const [contentResizeListener, {
  19238. height: contentHeight
  19239. }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
  19240. const setRef = (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  19241. let iFrameDocument; // Prevent the default browser action for files dropped outside of dropzones.
  19242. function preventFileDropDefault(event) {
  19243. event.preventDefault();
  19244. }
  19245. function setDocumentIfReady() {
  19246. const {
  19247. contentDocument,
  19248. ownerDocument
  19249. } = node;
  19250. const {
  19251. readyState,
  19252. documentElement
  19253. } = contentDocument;
  19254. iFrameDocument = contentDocument;
  19255. if (readyState !== 'interactive' && readyState !== 'complete') {
  19256. return false;
  19257. }
  19258. bubbleEvents(contentDocument);
  19259. setIframeDocument(contentDocument);
  19260. clearerRef(documentElement); // Ideally ALL classes that are added through get_body_class should
  19261. // be added in the editor too, which we'll somehow have to get from
  19262. // the server in the future (which will run the PHP filters).
  19263. setBodyClasses(Array.from(ownerDocument.body.classList).filter(name => name.startsWith('admin-color-') || name.startsWith('post-type-') || name === 'wp-embed-responsive'));
  19264. contentDocument.dir = ownerDocument.dir;
  19265. documentElement.removeChild(contentDocument.head);
  19266. documentElement.removeChild(contentDocument.body);
  19267. iFrameDocument.addEventListener('dragover', preventFileDropDefault, false);
  19268. iFrameDocument.addEventListener('drop', preventFileDropDefault, false);
  19269. return true;
  19270. } // Document set with srcDoc is not immediately ready.
  19271. node.addEventListener('load', setDocumentIfReady);
  19272. return () => {
  19273. var _iFrameDocument, _iFrameDocument2;
  19274. node.removeEventListener('load', setDocumentIfReady);
  19275. (_iFrameDocument = iFrameDocument) === null || _iFrameDocument === void 0 ? void 0 : _iFrameDocument.removeEventListener('dragover', preventFileDropDefault);
  19276. (_iFrameDocument2 = iFrameDocument) === null || _iFrameDocument2 === void 0 ? void 0 : _iFrameDocument2.removeEventListener('drop', preventFileDropDefault);
  19277. };
  19278. }, []);
  19279. const headRef = (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  19280. scripts.reduce((promise, script) => promise.then(() => loadScript(element, script)), Promise.resolve()).finally(() => {
  19281. // When script are loaded, re-render blocks to allow them
  19282. // to initialise.
  19283. forceRender();
  19284. });
  19285. }, []);
  19286. const bodyRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([contentRef, clearerRef, writingFlowRef]);
  19287. const styleCompatibilityRef = useStylesCompatibility();
  19288. head = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("style", null, 'html{height:auto!important;}body{margin:0}'), styles.map(_ref4 => {
  19289. let {
  19290. tagName,
  19291. href,
  19292. id,
  19293. rel,
  19294. media,
  19295. textContent
  19296. } = _ref4;
  19297. const TagName = tagName.toLowerCase();
  19298. if (TagName === 'style') {
  19299. return (0,external_wp_element_namespaceObject.createElement)(TagName, {
  19300. id,
  19301. key: id
  19302. }, textContent);
  19303. }
  19304. return (0,external_wp_element_namespaceObject.createElement)(TagName, {
  19305. href,
  19306. id,
  19307. rel,
  19308. media,
  19309. key: id
  19310. });
  19311. }), head);
  19312. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, tabIndex >= 0 && before, (0,external_wp_element_namespaceObject.createElement)("iframe", _extends({}, props, {
  19313. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, setRef]),
  19314. tabIndex: tabIndex // Correct doctype is required to enable rendering in standards mode
  19315. ,
  19316. srcDoc: "<!doctype html>",
  19317. title: (0,external_wp_i18n_namespaceObject.__)('Editor canvas')
  19318. }), iframeDocument && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("head", {
  19319. ref: headRef
  19320. }, head, (0,external_wp_element_namespaceObject.createElement)("style", null, `html { transition: background 5s; ${isZoomedOut ? 'background: #2f2f2f; transition: background 0s;' : ''} }`)), (0,external_wp_element_namespaceObject.createElement)("body", {
  19321. ref: bodyRef,
  19322. className: classnames_default()('block-editor-iframe__body', BODY_CLASS_NAME, ...bodyClasses, {
  19323. 'is-zoomed-out': isZoomedOut
  19324. }),
  19325. style: isZoomedOut ? {
  19326. // This is the remaining percentage from the scaling down
  19327. // of the iframe body(`scale(0.45)`). We also need to subtract
  19328. // the body's bottom margin.
  19329. marginBottom: `-${contentHeight * 0.55 - 100}px`
  19330. } : {}
  19331. }, contentResizeListener, (0,external_wp_element_namespaceObject.createElement)("div", {
  19332. style: {
  19333. display: 'none'
  19334. },
  19335. ref: styleCompatibilityRef
  19336. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
  19337. document: iframeDocument
  19338. }, children))), iframeDocument.documentElement)), tabIndex >= 0 && after);
  19339. }
  19340. /* harmony default export */ var iframe = ((0,external_wp_element_namespaceObject.forwardRef)(Iframe));
  19341. ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs
  19342. 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()})};
  19343. ;// CONCATENATED MODULE: ./node_modules/colord/plugins/names.mjs
  19344. /* 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"])}
  19345. ;// CONCATENATED MODULE: ./node_modules/colord/plugins/a11y.mjs
  19346. 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}}
  19347. // EXTERNAL MODULE: ./node_modules/traverse/index.js
  19348. var traverse = __webpack_require__(3124);
  19349. var traverse_default = /*#__PURE__*/__webpack_require__.n(traverse);
  19350. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/parse.js
  19351. /* eslint-disable @wordpress/no-unused-vars-before-return */
  19352. // Adapted from https://github.com/reworkcss/css
  19353. // because we needed to remove source map support.
  19354. // http://www.w3.org/TR/CSS21/grammar.htm
  19355. // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
  19356. const commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
  19357. /* harmony default export */ function parse(css, options) {
  19358. options = options || {};
  19359. /**
  19360. * Positional.
  19361. */
  19362. let lineno = 1;
  19363. let column = 1;
  19364. /**
  19365. * Update lineno and column based on `str`.
  19366. */
  19367. function updatePosition(str) {
  19368. const lines = str.match(/\n/g);
  19369. if (lines) {
  19370. lineno += lines.length;
  19371. }
  19372. const i = str.lastIndexOf('\n'); // eslint-disable-next-line no-bitwise
  19373. column = ~i ? str.length - i : column + str.length;
  19374. }
  19375. /**
  19376. * Mark position and patch `node.position`.
  19377. */
  19378. function position() {
  19379. const start = {
  19380. line: lineno,
  19381. column
  19382. };
  19383. return function (node) {
  19384. node.position = new Position(start);
  19385. whitespace();
  19386. return node;
  19387. };
  19388. }
  19389. /**
  19390. * Store position information for a node
  19391. */
  19392. function Position(start) {
  19393. this.start = start;
  19394. this.end = {
  19395. line: lineno,
  19396. column
  19397. };
  19398. this.source = options.source;
  19399. }
  19400. /**
  19401. * Non-enumerable source string
  19402. */
  19403. Position.prototype.content = css;
  19404. /**
  19405. * Error `msg`.
  19406. */
  19407. const errorsList = [];
  19408. function error(msg) {
  19409. const err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
  19410. err.reason = msg;
  19411. err.filename = options.source;
  19412. err.line = lineno;
  19413. err.column = column;
  19414. err.source = css;
  19415. if (options.silent) {
  19416. errorsList.push(err);
  19417. } else {
  19418. throw err;
  19419. }
  19420. }
  19421. /**
  19422. * Parse stylesheet.
  19423. */
  19424. function stylesheet() {
  19425. const rulesList = rules();
  19426. return {
  19427. type: 'stylesheet',
  19428. stylesheet: {
  19429. source: options.source,
  19430. rules: rulesList,
  19431. parsingErrors: errorsList
  19432. }
  19433. };
  19434. }
  19435. /**
  19436. * Opening brace.
  19437. */
  19438. function open() {
  19439. return match(/^{\s*/);
  19440. }
  19441. /**
  19442. * Closing brace.
  19443. */
  19444. function close() {
  19445. return match(/^}/);
  19446. }
  19447. /**
  19448. * Parse ruleset.
  19449. */
  19450. function rules() {
  19451. let node;
  19452. const accumulator = [];
  19453. whitespace();
  19454. comments(accumulator);
  19455. while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
  19456. if (node !== false) {
  19457. accumulator.push(node);
  19458. comments(accumulator);
  19459. }
  19460. }
  19461. return accumulator;
  19462. }
  19463. /**
  19464. * Match `re` and return captures.
  19465. */
  19466. function match(re) {
  19467. const m = re.exec(css);
  19468. if (!m) {
  19469. return;
  19470. }
  19471. const str = m[0];
  19472. updatePosition(str);
  19473. css = css.slice(str.length);
  19474. return m;
  19475. }
  19476. /**
  19477. * Parse whitespace.
  19478. */
  19479. function whitespace() {
  19480. match(/^\s*/);
  19481. }
  19482. /**
  19483. * Parse comments;
  19484. */
  19485. function comments(accumulator) {
  19486. let c;
  19487. accumulator = accumulator || []; // eslint-disable-next-line no-cond-assign
  19488. while (c = comment()) {
  19489. if (c !== false) {
  19490. accumulator.push(c);
  19491. }
  19492. }
  19493. return accumulator;
  19494. }
  19495. /**
  19496. * Parse comment.
  19497. */
  19498. function comment() {
  19499. const pos = position();
  19500. if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
  19501. return;
  19502. }
  19503. let i = 2;
  19504. while ('' !== css.charAt(i) && ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
  19505. ++i;
  19506. }
  19507. i += 2;
  19508. if ('' === css.charAt(i - 1)) {
  19509. return error('End of comment missing');
  19510. }
  19511. const str = css.slice(2, i - 2);
  19512. column += 2;
  19513. updatePosition(str);
  19514. css = css.slice(i);
  19515. column += 2;
  19516. return pos({
  19517. type: 'comment',
  19518. comment: str
  19519. });
  19520. }
  19521. /**
  19522. * Parse selector.
  19523. */
  19524. function selector() {
  19525. const m = match(/^([^{]+)/);
  19526. if (!m) {
  19527. return;
  19528. } // FIXME: Remove all comments from selectors http://ostermiller.org/findcomment.html
  19529. return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '').replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (matched) {
  19530. return matched.replace(/,/g, '\u200C');
  19531. }).split(/\s*(?![^(]*\)),\s*/).map(function (s) {
  19532. return s.replace(/\u200C/g, ',');
  19533. });
  19534. }
  19535. /**
  19536. * Parse declaration.
  19537. */
  19538. function declaration() {
  19539. const pos = position(); // prop.
  19540. let prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
  19541. if (!prop) {
  19542. return;
  19543. }
  19544. prop = trim(prop[0]); // :
  19545. if (!match(/^:\s*/)) {
  19546. return error("property missing ':'");
  19547. } // val.
  19548. const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
  19549. const ret = pos({
  19550. type: 'declaration',
  19551. property: prop.replace(commentre, ''),
  19552. value: val ? trim(val[0]).replace(commentre, '') : ''
  19553. }); // ;
  19554. match(/^[;\s]*/);
  19555. return ret;
  19556. }
  19557. /**
  19558. * Parse declarations.
  19559. */
  19560. function declarations() {
  19561. const decls = [];
  19562. if (!open()) {
  19563. return error("missing '{'");
  19564. }
  19565. comments(decls); // declarations.
  19566. let decl; // eslint-disable-next-line no-cond-assign
  19567. while (decl = declaration()) {
  19568. if (decl !== false) {
  19569. decls.push(decl);
  19570. comments(decls);
  19571. }
  19572. }
  19573. if (!close()) {
  19574. return error("missing '}'");
  19575. }
  19576. return decls;
  19577. }
  19578. /**
  19579. * Parse keyframe.
  19580. */
  19581. function keyframe() {
  19582. let m;
  19583. const vals = [];
  19584. const pos = position(); // eslint-disable-next-line no-cond-assign
  19585. while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
  19586. vals.push(m[1]);
  19587. match(/^,\s*/);
  19588. }
  19589. if (!vals.length) {
  19590. return;
  19591. }
  19592. return pos({
  19593. type: 'keyframe',
  19594. values: vals,
  19595. declarations: declarations()
  19596. });
  19597. }
  19598. /**
  19599. * Parse keyframes.
  19600. */
  19601. function atkeyframes() {
  19602. const pos = position();
  19603. let m = match(/^@([-\w]+)?keyframes\s*/);
  19604. if (!m) {
  19605. return;
  19606. }
  19607. const vendor = m[1]; // identifier
  19608. m = match(/^([-\w]+)\s*/);
  19609. if (!m) {
  19610. return error('@keyframes missing name');
  19611. }
  19612. const name = m[1];
  19613. if (!open()) {
  19614. return error("@keyframes missing '{'");
  19615. }
  19616. let frame;
  19617. let frames = comments(); // eslint-disable-next-line no-cond-assign
  19618. while (frame = keyframe()) {
  19619. frames.push(frame);
  19620. frames = frames.concat(comments());
  19621. }
  19622. if (!close()) {
  19623. return error("@keyframes missing '}'");
  19624. }
  19625. return pos({
  19626. type: 'keyframes',
  19627. name,
  19628. vendor,
  19629. keyframes: frames
  19630. });
  19631. }
  19632. /**
  19633. * Parse supports.
  19634. */
  19635. function atsupports() {
  19636. const pos = position();
  19637. const m = match(/^@supports *([^{]+)/);
  19638. if (!m) {
  19639. return;
  19640. }
  19641. const supports = trim(m[1]);
  19642. if (!open()) {
  19643. return error("@supports missing '{'");
  19644. }
  19645. const style = comments().concat(rules());
  19646. if (!close()) {
  19647. return error("@supports missing '}'");
  19648. }
  19649. return pos({
  19650. type: 'supports',
  19651. supports,
  19652. rules: style
  19653. });
  19654. }
  19655. /**
  19656. * Parse host.
  19657. */
  19658. function athost() {
  19659. const pos = position();
  19660. const m = match(/^@host\s*/);
  19661. if (!m) {
  19662. return;
  19663. }
  19664. if (!open()) {
  19665. return error("@host missing '{'");
  19666. }
  19667. const style = comments().concat(rules());
  19668. if (!close()) {
  19669. return error("@host missing '}'");
  19670. }
  19671. return pos({
  19672. type: 'host',
  19673. rules: style
  19674. });
  19675. }
  19676. /**
  19677. * Parse media.
  19678. */
  19679. function atmedia() {
  19680. const pos = position();
  19681. const m = match(/^@media *([^{]+)/);
  19682. if (!m) {
  19683. return;
  19684. }
  19685. const media = trim(m[1]);
  19686. if (!open()) {
  19687. return error("@media missing '{'");
  19688. }
  19689. const style = comments().concat(rules());
  19690. if (!close()) {
  19691. return error("@media missing '}'");
  19692. }
  19693. return pos({
  19694. type: 'media',
  19695. media,
  19696. rules: style
  19697. });
  19698. }
  19699. /**
  19700. * Parse custom-media.
  19701. */
  19702. function atcustommedia() {
  19703. const pos = position();
  19704. const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
  19705. if (!m) {
  19706. return;
  19707. }
  19708. return pos({
  19709. type: 'custom-media',
  19710. name: trim(m[1]),
  19711. media: trim(m[2])
  19712. });
  19713. }
  19714. /**
  19715. * Parse paged media.
  19716. */
  19717. function atpage() {
  19718. const pos = position();
  19719. const m = match(/^@page */);
  19720. if (!m) {
  19721. return;
  19722. }
  19723. const sel = selector() || [];
  19724. if (!open()) {
  19725. return error("@page missing '{'");
  19726. }
  19727. let decls = comments(); // declarations.
  19728. let decl; // eslint-disable-next-line no-cond-assign
  19729. while (decl = declaration()) {
  19730. decls.push(decl);
  19731. decls = decls.concat(comments());
  19732. }
  19733. if (!close()) {
  19734. return error("@page missing '}'");
  19735. }
  19736. return pos({
  19737. type: 'page',
  19738. selectors: sel,
  19739. declarations: decls
  19740. });
  19741. }
  19742. /**
  19743. * Parse document.
  19744. */
  19745. function atdocument() {
  19746. const pos = position();
  19747. const m = match(/^@([-\w]+)?document *([^{]+)/);
  19748. if (!m) {
  19749. return;
  19750. }
  19751. const vendor = trim(m[1]);
  19752. const doc = trim(m[2]);
  19753. if (!open()) {
  19754. return error("@document missing '{'");
  19755. }
  19756. const style = comments().concat(rules());
  19757. if (!close()) {
  19758. return error("@document missing '}'");
  19759. }
  19760. return pos({
  19761. type: 'document',
  19762. document: doc,
  19763. vendor,
  19764. rules: style
  19765. });
  19766. }
  19767. /**
  19768. * Parse font-face.
  19769. */
  19770. function atfontface() {
  19771. const pos = position();
  19772. const m = match(/^@font-face\s*/);
  19773. if (!m) {
  19774. return;
  19775. }
  19776. if (!open()) {
  19777. return error("@font-face missing '{'");
  19778. }
  19779. let decls = comments(); // declarations.
  19780. let decl; // eslint-disable-next-line no-cond-assign
  19781. while (decl = declaration()) {
  19782. decls.push(decl);
  19783. decls = decls.concat(comments());
  19784. }
  19785. if (!close()) {
  19786. return error("@font-face missing '}'");
  19787. }
  19788. return pos({
  19789. type: 'font-face',
  19790. declarations: decls
  19791. });
  19792. }
  19793. /**
  19794. * Parse import
  19795. */
  19796. const atimport = _compileAtrule('import');
  19797. /**
  19798. * Parse charset
  19799. */
  19800. const atcharset = _compileAtrule('charset');
  19801. /**
  19802. * Parse namespace
  19803. */
  19804. const atnamespace = _compileAtrule('namespace');
  19805. /**
  19806. * Parse non-block at-rules
  19807. */
  19808. function _compileAtrule(name) {
  19809. const re = new RegExp('^@' + name + '\\s*([^;]+);');
  19810. return function () {
  19811. const pos = position();
  19812. const m = match(re);
  19813. if (!m) {
  19814. return;
  19815. }
  19816. const ret = {
  19817. type: name
  19818. };
  19819. ret[name] = m[1].trim();
  19820. return pos(ret);
  19821. };
  19822. }
  19823. /**
  19824. * Parse at rule.
  19825. */
  19826. function atrule() {
  19827. if (css[0] !== '@') {
  19828. return;
  19829. }
  19830. return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface();
  19831. }
  19832. /**
  19833. * Parse rule.
  19834. */
  19835. function rule() {
  19836. const pos = position();
  19837. const sel = selector();
  19838. if (!sel) {
  19839. return error('selector missing');
  19840. }
  19841. comments();
  19842. return pos({
  19843. type: 'rule',
  19844. selectors: sel,
  19845. declarations: declarations()
  19846. });
  19847. }
  19848. return addParent(stylesheet());
  19849. }
  19850. /**
  19851. * Trim `str`.
  19852. */
  19853. function trim(str) {
  19854. return str ? str.replace(/^\s+|\s+$/g, '') : '';
  19855. }
  19856. /**
  19857. * Adds non-enumerable parent node reference to each node.
  19858. */
  19859. function addParent(obj, parent) {
  19860. const isNode = obj && typeof obj.type === 'string';
  19861. const childParent = isNode ? obj : parent;
  19862. for (const k in obj) {
  19863. const value = obj[k];
  19864. if (Array.isArray(value)) {
  19865. value.forEach(function (v) {
  19866. addParent(v, childParent);
  19867. });
  19868. } else if (value && typeof value === 'object') {
  19869. addParent(value, childParent);
  19870. }
  19871. }
  19872. if (isNode) {
  19873. Object.defineProperty(obj, 'parent', {
  19874. configurable: true,
  19875. writable: true,
  19876. enumerable: false,
  19877. value: parent || null
  19878. });
  19879. }
  19880. return obj;
  19881. }
  19882. /* eslint-enable @wordpress/no-unused-vars-before-return */
  19883. // EXTERNAL MODULE: ./node_modules/inherits/inherits_browser.js
  19884. var inherits_browser = __webpack_require__(8575);
  19885. var inherits_browser_default = /*#__PURE__*/__webpack_require__.n(inherits_browser);
  19886. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/compiler.js
  19887. // Adapted from https://github.com/reworkcss/css
  19888. // because we needed to remove source map support.
  19889. /**
  19890. * Expose `Compiler`.
  19891. */
  19892. /* harmony default export */ var compiler = (Compiler);
  19893. /**
  19894. * Initialize a compiler.
  19895. */
  19896. function Compiler(opts) {
  19897. this.options = opts || {};
  19898. }
  19899. /**
  19900. * Emit `str`
  19901. */
  19902. Compiler.prototype.emit = function (str) {
  19903. return str;
  19904. };
  19905. /**
  19906. * Visit `node`.
  19907. */
  19908. Compiler.prototype.visit = function (node) {
  19909. return this[node.type](node);
  19910. };
  19911. /**
  19912. * Map visit over array of `nodes`, optionally using a `delim`
  19913. */
  19914. Compiler.prototype.mapVisit = function (nodes, delim) {
  19915. let buf = '';
  19916. delim = delim || '';
  19917. for (let i = 0, length = nodes.length; i < length; i++) {
  19918. buf += this.visit(nodes[i]);
  19919. if (delim && i < length - 1) {
  19920. buf += this.emit(delim);
  19921. }
  19922. }
  19923. return buf;
  19924. };
  19925. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/compress.js
  19926. // Adapted from https://github.com/reworkcss/css
  19927. // because we needed to remove source map support.
  19928. /**
  19929. * External dependencies
  19930. */
  19931. /**
  19932. * Internal dependencies
  19933. */
  19934. /**
  19935. * Expose compiler.
  19936. */
  19937. /* harmony default export */ var compress = (compress_Compiler);
  19938. /**
  19939. * Initialize a new `Compiler`.
  19940. */
  19941. function compress_Compiler(options) {
  19942. compiler.call(this, options);
  19943. }
  19944. /**
  19945. * Inherit from `Base.prototype`.
  19946. */
  19947. inherits_browser_default()(compress_Compiler, compiler);
  19948. /**
  19949. * Compile `node`.
  19950. */
  19951. compress_Compiler.prototype.compile = function (node) {
  19952. return node.stylesheet.rules.map(this.visit, this).join('');
  19953. };
  19954. /**
  19955. * Visit comment node.
  19956. */
  19957. compress_Compiler.prototype.comment = function (node) {
  19958. return this.emit('', node.position);
  19959. };
  19960. /**
  19961. * Visit import node.
  19962. */
  19963. compress_Compiler.prototype.import = function (node) {
  19964. return this.emit('@import ' + node.import + ';', node.position);
  19965. };
  19966. /**
  19967. * Visit media node.
  19968. */
  19969. compress_Compiler.prototype.media = function (node) {
  19970. return this.emit('@media ' + node.media, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  19971. };
  19972. /**
  19973. * Visit document node.
  19974. */
  19975. compress_Compiler.prototype.document = function (node) {
  19976. const doc = '@' + (node.vendor || '') + 'document ' + node.document;
  19977. return this.emit(doc, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  19978. };
  19979. /**
  19980. * Visit charset node.
  19981. */
  19982. compress_Compiler.prototype.charset = function (node) {
  19983. return this.emit('@charset ' + node.charset + ';', node.position);
  19984. };
  19985. /**
  19986. * Visit namespace node.
  19987. */
  19988. compress_Compiler.prototype.namespace = function (node) {
  19989. return this.emit('@namespace ' + node.namespace + ';', node.position);
  19990. };
  19991. /**
  19992. * Visit supports node.
  19993. */
  19994. compress_Compiler.prototype.supports = function (node) {
  19995. return this.emit('@supports ' + node.supports, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  19996. };
  19997. /**
  19998. * Visit keyframes node.
  19999. */
  20000. compress_Compiler.prototype.keyframes = function (node) {
  20001. return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit('{') + this.mapVisit(node.keyframes) + this.emit('}');
  20002. };
  20003. /**
  20004. * Visit keyframe node.
  20005. */
  20006. compress_Compiler.prototype.keyframe = function (node) {
  20007. const decls = node.declarations;
  20008. return this.emit(node.values.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
  20009. };
  20010. /**
  20011. * Visit page node.
  20012. */
  20013. compress_Compiler.prototype.page = function (node) {
  20014. const sel = node.selectors.length ? node.selectors.join(', ') : '';
  20015. return this.emit('@page ' + sel, node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
  20016. };
  20017. /**
  20018. * Visit font-face node.
  20019. */
  20020. compress_Compiler.prototype['font-face'] = function (node) {
  20021. return this.emit('@font-face', node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
  20022. };
  20023. /**
  20024. * Visit host node.
  20025. */
  20026. compress_Compiler.prototype.host = function (node) {
  20027. return this.emit('@host', node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  20028. };
  20029. /**
  20030. * Visit custom-media node.
  20031. */
  20032. compress_Compiler.prototype['custom-media'] = function (node) {
  20033. return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
  20034. };
  20035. /**
  20036. * Visit rule node.
  20037. */
  20038. compress_Compiler.prototype.rule = function (node) {
  20039. const decls = node.declarations;
  20040. if (!decls.length) {
  20041. return '';
  20042. }
  20043. return this.emit(node.selectors.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
  20044. };
  20045. /**
  20046. * Visit declaration node.
  20047. */
  20048. compress_Compiler.prototype.declaration = function (node) {
  20049. return this.emit(node.property + ':' + node.value, node.position) + this.emit(';');
  20050. };
  20051. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/identity.js
  20052. /* eslint-disable @wordpress/no-unused-vars-before-return */
  20053. // Adapted from https://github.com/reworkcss/css
  20054. // because we needed to remove source map support.
  20055. /**
  20056. * External dependencies
  20057. */
  20058. /**
  20059. * Internal dependencies
  20060. */
  20061. /**
  20062. * Expose compiler.
  20063. */
  20064. /* harmony default export */ var stringify_identity = (identity_Compiler);
  20065. /**
  20066. * Initialize a new `Compiler`.
  20067. */
  20068. function identity_Compiler(options) {
  20069. options = options || {};
  20070. compiler.call(this, options);
  20071. this.indentation = options.indent;
  20072. }
  20073. /**
  20074. * Inherit from `Base.prototype`.
  20075. */
  20076. inherits_browser_default()(identity_Compiler, compiler);
  20077. /**
  20078. * Compile `node`.
  20079. */
  20080. identity_Compiler.prototype.compile = function (node) {
  20081. return this.stylesheet(node);
  20082. };
  20083. /**
  20084. * Visit stylesheet node.
  20085. */
  20086. identity_Compiler.prototype.stylesheet = function (node) {
  20087. return this.mapVisit(node.stylesheet.rules, '\n\n');
  20088. };
  20089. /**
  20090. * Visit comment node.
  20091. */
  20092. identity_Compiler.prototype.comment = function (node) {
  20093. return this.emit(this.indent() + '/*' + node.comment + '*/', node.position);
  20094. };
  20095. /**
  20096. * Visit import node.
  20097. */
  20098. identity_Compiler.prototype.import = function (node) {
  20099. return this.emit('@import ' + node.import + ';', node.position);
  20100. };
  20101. /**
  20102. * Visit media node.
  20103. */
  20104. identity_Compiler.prototype.media = function (node) {
  20105. return this.emit('@media ' + node.media, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  20106. };
  20107. /**
  20108. * Visit document node.
  20109. */
  20110. identity_Compiler.prototype.document = function (node) {
  20111. const doc = '@' + (node.vendor || '') + 'document ' + node.document;
  20112. return this.emit(doc, node.position) + this.emit(' ' + ' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  20113. };
  20114. /**
  20115. * Visit charset node.
  20116. */
  20117. identity_Compiler.prototype.charset = function (node) {
  20118. return this.emit('@charset ' + node.charset + ';', node.position);
  20119. };
  20120. /**
  20121. * Visit namespace node.
  20122. */
  20123. identity_Compiler.prototype.namespace = function (node) {
  20124. return this.emit('@namespace ' + node.namespace + ';', node.position);
  20125. };
  20126. /**
  20127. * Visit supports node.
  20128. */
  20129. identity_Compiler.prototype.supports = function (node) {
  20130. return this.emit('@supports ' + node.supports, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  20131. };
  20132. /**
  20133. * Visit keyframes node.
  20134. */
  20135. identity_Compiler.prototype.keyframes = function (node) {
  20136. return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.keyframes, '\n') + this.emit(this.indent(-1) + '}');
  20137. };
  20138. /**
  20139. * Visit keyframe node.
  20140. */
  20141. identity_Compiler.prototype.keyframe = function (node) {
  20142. const decls = node.declarations;
  20143. return this.emit(this.indent()) + this.emit(node.values.join(', '), node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1) + '\n' + this.indent() + '}\n');
  20144. };
  20145. /**
  20146. * Visit page node.
  20147. */
  20148. identity_Compiler.prototype.page = function (node) {
  20149. const sel = node.selectors.length ? node.selectors.join(', ') + ' ' : '';
  20150. return this.emit('@page ' + sel, node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}');
  20151. };
  20152. /**
  20153. * Visit font-face node.
  20154. */
  20155. identity_Compiler.prototype['font-face'] = function (node) {
  20156. return this.emit('@font-face ', node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}');
  20157. };
  20158. /**
  20159. * Visit host node.
  20160. */
  20161. identity_Compiler.prototype.host = function (node) {
  20162. return this.emit('@host', node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  20163. };
  20164. /**
  20165. * Visit custom-media node.
  20166. */
  20167. identity_Compiler.prototype['custom-media'] = function (node) {
  20168. return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
  20169. };
  20170. /**
  20171. * Visit rule node.
  20172. */
  20173. identity_Compiler.prototype.rule = function (node) {
  20174. const indent = this.indent();
  20175. const decls = node.declarations;
  20176. if (!decls.length) {
  20177. return '';
  20178. }
  20179. return this.emit(node.selectors.map(function (s) {
  20180. return indent + s;
  20181. }).join(',\n'), node.position) + this.emit(' {\n') + this.emit(this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1)) + this.emit('\n' + this.indent() + '}');
  20182. };
  20183. /**
  20184. * Visit declaration node.
  20185. */
  20186. identity_Compiler.prototype.declaration = function (node) {
  20187. return this.emit(this.indent()) + this.emit(node.property + ': ' + node.value, node.position) + this.emit(';');
  20188. };
  20189. /**
  20190. * Increase, decrease or return current indentation.
  20191. */
  20192. identity_Compiler.prototype.indent = function (level) {
  20193. this.level = this.level || 1;
  20194. if (null !== level) {
  20195. this.level += level;
  20196. return '';
  20197. }
  20198. return Array(this.level).join(this.indentation || ' ');
  20199. };
  20200. /* eslint-enable @wordpress/no-unused-vars-before-return */
  20201. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/index.js
  20202. // Adapted from https://github.com/reworkcss/css
  20203. // because we needed to remove source map support.
  20204. /**
  20205. * Internal dependencies
  20206. */
  20207. /**
  20208. * Stringfy the given AST `node`.
  20209. *
  20210. * Options:
  20211. *
  20212. * - `compress` space-optimized output
  20213. * - `sourcemap` return an object with `.code` and `.map`
  20214. *
  20215. * @param {Object} node
  20216. * @param {Object} [options]
  20217. * @return {string}
  20218. */
  20219. /* harmony default export */ function stringify(node, options) {
  20220. options = options || {};
  20221. const compiler = options.compress ? new compress(options) : new stringify_identity(options);
  20222. const code = compiler.compile(node);
  20223. return code;
  20224. }
  20225. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/traverse.js
  20226. /**
  20227. * External dependencies
  20228. */
  20229. /**
  20230. * Internal dependencies
  20231. */
  20232. function traverseCSS(css, callback) {
  20233. try {
  20234. const parsed = parse(css);
  20235. const updated = traverse_default().map(parsed, function (node) {
  20236. if (!node) {
  20237. return node;
  20238. }
  20239. const updatedNode = callback(node);
  20240. return this.update(updatedNode);
  20241. });
  20242. return stringify(updated);
  20243. } catch (err) {
  20244. // eslint-disable-next-line no-console
  20245. console.warn('Error while traversing the CSS: ' + err);
  20246. return null;
  20247. }
  20248. }
  20249. /* harmony default export */ var transform_styles_traverse = (traverseCSS);
  20250. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/transforms/url-rewrite.js
  20251. /**
  20252. * Return `true` if the given path is http/https.
  20253. *
  20254. * @param {string} filePath path
  20255. *
  20256. * @return {boolean} is remote path.
  20257. */
  20258. function isRemotePath(filePath) {
  20259. return /^(?:https?:)?\/\//.test(filePath);
  20260. }
  20261. /**
  20262. * Return `true` if the given filePath is an absolute url.
  20263. *
  20264. * @param {string} filePath path
  20265. *
  20266. * @return {boolean} is absolute path.
  20267. */
  20268. function isAbsolutePath(filePath) {
  20269. return /^\/(?!\/)/.test(filePath);
  20270. }
  20271. /**
  20272. * Whether or not the url should be inluded.
  20273. *
  20274. * @param {Object} meta url meta info
  20275. *
  20276. * @return {boolean} is valid.
  20277. */
  20278. function isValidURL(meta) {
  20279. // Ignore hashes or data uris.
  20280. if (meta.value.indexOf('data:') === 0 || meta.value.indexOf('#') === 0) {
  20281. return false;
  20282. }
  20283. if (isAbsolutePath(meta.value)) {
  20284. return false;
  20285. } // Do not handle the http/https urls if `includeRemote` is false.
  20286. if (isRemotePath(meta.value)) {
  20287. return false;
  20288. }
  20289. return true;
  20290. }
  20291. /**
  20292. * Get the absolute path of the url, relative to the basePath
  20293. *
  20294. * @param {string} str the url
  20295. * @param {string} baseURL base URL
  20296. *
  20297. * @return {string} the full path to the file
  20298. */
  20299. function getResourcePath(str, baseURL) {
  20300. return new URL(str, baseURL).toString();
  20301. }
  20302. /**
  20303. * Process the single `url()` pattern
  20304. *
  20305. * @param {string} baseURL the base URL for relative URLs.
  20306. *
  20307. * @return {Promise} the Promise.
  20308. */
  20309. function processURL(baseURL) {
  20310. return meta => ({ ...meta,
  20311. newUrl: 'url(' + meta.before + meta.quote + getResourcePath(meta.value, baseURL) + meta.quote + meta.after + ')'
  20312. });
  20313. }
  20314. /**
  20315. * Get all `url()`s, and return the meta info
  20316. *
  20317. * @param {string} value decl.value.
  20318. *
  20319. * @return {Array} the urls.
  20320. */
  20321. function getURLs(value) {
  20322. const reg = /url\((\s*)(['"]?)(.+?)\2(\s*)\)/g;
  20323. let match;
  20324. const URLs = [];
  20325. while ((match = reg.exec(value)) !== null) {
  20326. const meta = {
  20327. source: match[0],
  20328. before: match[1],
  20329. quote: match[2],
  20330. value: match[3],
  20331. after: match[4]
  20332. };
  20333. if (isValidURL(meta)) {
  20334. URLs.push(meta);
  20335. }
  20336. }
  20337. return URLs;
  20338. }
  20339. /**
  20340. * Replace the raw value's `url()` segment to the new value
  20341. *
  20342. * @param {string} raw the raw value.
  20343. * @param {Array} URLs the URLs to replace.
  20344. *
  20345. * @return {string} the new value.
  20346. */
  20347. function replaceURLs(raw, URLs) {
  20348. URLs.forEach(item => {
  20349. raw = raw.replace(item.source, item.newUrl);
  20350. });
  20351. return raw;
  20352. }
  20353. const rewrite = rootURL => node => {
  20354. if (node.type === 'declaration') {
  20355. const updatedURLs = getURLs(node.value).map(processURL(rootURL));
  20356. return { ...node,
  20357. value: replaceURLs(node.value, updatedURLs)
  20358. };
  20359. }
  20360. return node;
  20361. };
  20362. /* harmony default export */ var url_rewrite = (rewrite);
  20363. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/transforms/wrap.js
  20364. /**
  20365. * @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector.
  20366. */
  20367. const IS_ROOT_TAG = /^(body|html|:root).*$/;
  20368. /**
  20369. * Creates a callback to modify selectors so they only apply within a certain
  20370. * namespace.
  20371. *
  20372. * @param {string} namespace Namespace to prefix selectors with.
  20373. * @param {string[]} ignore Selectors to not prefix.
  20374. *
  20375. * @return {(node: Object) => Object} Callback to wrap selectors.
  20376. */
  20377. const wrap = function (namespace) {
  20378. let ignore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  20379. return node => {
  20380. /**
  20381. * Updates selector if necessary.
  20382. *
  20383. * @param {string} selector Selector to modify.
  20384. *
  20385. * @return {string} Updated selector.
  20386. */
  20387. const updateSelector = selector => {
  20388. if (ignore.includes(selector.trim())) {
  20389. return selector;
  20390. } // Anything other than a root tag is always prefixed.
  20391. {
  20392. if (!selector.match(IS_ROOT_TAG)) {
  20393. return namespace + ' ' + selector;
  20394. }
  20395. } // HTML and Body elements cannot be contained within our container so lets extract their styles.
  20396. return selector.replace(/^(body|html|:root)/, namespace);
  20397. };
  20398. if (node.type === 'rule') {
  20399. return { ...node,
  20400. selectors: node.selectors.map(updateSelector)
  20401. };
  20402. }
  20403. return node;
  20404. };
  20405. };
  20406. /* harmony default export */ var transforms_wrap = (wrap);
  20407. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/index.js
  20408. /**
  20409. * External dependencies
  20410. */
  20411. /**
  20412. * WordPress dependencies
  20413. */
  20414. /**
  20415. * Internal dependencies
  20416. */
  20417. /**
  20418. * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
  20419. *
  20420. * @param {Array} styles CSS rules.
  20421. * @param {string} wrapperClassName Wrapper Class Name.
  20422. * @return {Array} converted rules.
  20423. */
  20424. const transform_styles_transformStyles = function (styles) {
  20425. let wrapperClassName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  20426. return (0,external_lodash_namespaceObject.map)(styles, _ref => {
  20427. let {
  20428. css,
  20429. baseURL
  20430. } = _ref;
  20431. const transforms = [];
  20432. if (wrapperClassName) {
  20433. transforms.push(transforms_wrap(wrapperClassName));
  20434. }
  20435. if (baseURL) {
  20436. transforms.push(url_rewrite(baseURL));
  20437. }
  20438. if (transforms.length) {
  20439. return transform_styles_traverse(css, (0,external_wp_compose_namespaceObject.compose)(transforms));
  20440. }
  20441. return css;
  20442. });
  20443. };
  20444. /* harmony default export */ var transform_styles = (transform_styles_transformStyles);
  20445. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/editor-styles/index.js
  20446. /**
  20447. * External dependencies
  20448. */
  20449. /**
  20450. * WordPress dependencies
  20451. */
  20452. /**
  20453. * Internal dependencies
  20454. */
  20455. const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';
  20456. k([names, a11y]);
  20457. function useDarkThemeBodyClassName(styles) {
  20458. return (0,external_wp_element_namespaceObject.useCallback)(node => {
  20459. if (!node) {
  20460. return;
  20461. }
  20462. const {
  20463. ownerDocument
  20464. } = node;
  20465. const {
  20466. defaultView,
  20467. body
  20468. } = ownerDocument;
  20469. const canvas = ownerDocument.querySelector(EDITOR_STYLES_SELECTOR);
  20470. let backgroundColor;
  20471. if (!canvas) {
  20472. // The real .editor-styles-wrapper element might not exist in the
  20473. // DOM, so calculate the background color by creating a fake
  20474. // wrapper.
  20475. const tempCanvas = ownerDocument.createElement('div');
  20476. tempCanvas.classList.add('editor-styles-wrapper');
  20477. body.appendChild(tempCanvas);
  20478. backgroundColor = defaultView.getComputedStyle(tempCanvas, null).getPropertyValue('background-color');
  20479. body.removeChild(tempCanvas);
  20480. } else {
  20481. backgroundColor = defaultView.getComputedStyle(canvas, null).getPropertyValue('background-color');
  20482. }
  20483. const colordBackgroundColor = w(backgroundColor); // If background is transparent, it should be treated as light color.
  20484. if (colordBackgroundColor.luminance() > 0.5 || colordBackgroundColor.alpha() === 0) {
  20485. body.classList.remove('is-dark-theme');
  20486. } else {
  20487. body.classList.add('is-dark-theme');
  20488. }
  20489. }, [styles]);
  20490. }
  20491. function EditorStyles(_ref) {
  20492. let {
  20493. styles
  20494. } = _ref;
  20495. const transformedStyles = (0,external_wp_element_namespaceObject.useMemo)(() => transform_styles(styles, EDITOR_STYLES_SELECTOR), [styles]);
  20496. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("style", {
  20497. ref: useDarkThemeBodyClassName(styles)
  20498. }), transformedStyles.map((css, index) => (0,external_wp_element_namespaceObject.createElement)("style", {
  20499. key: index
  20500. }, css)));
  20501. }
  20502. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/duotone/utils.js
  20503. /**
  20504. * External dependencies
  20505. */
  20506. /**
  20507. * Convert a list of colors to an object of R, G, and B values.
  20508. *
  20509. * @param {string[]} colors Array of RBG color strings.
  20510. *
  20511. * @return {Object} R, G, and B values.
  20512. */
  20513. function getValuesFromColors() {
  20514. let colors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  20515. const values = {
  20516. r: [],
  20517. g: [],
  20518. b: [],
  20519. a: []
  20520. };
  20521. colors.forEach(color => {
  20522. const rgbColor = w(color).toRgb();
  20523. values.r.push(rgbColor.r / 255);
  20524. values.g.push(rgbColor.g / 255);
  20525. values.b.push(rgbColor.b / 255);
  20526. values.a.push(rgbColor.a);
  20527. });
  20528. return values;
  20529. }
  20530. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/duotone/components.js
  20531. /**
  20532. * WordPress dependencies
  20533. */
  20534. /**
  20535. * Internal dependencies
  20536. */
  20537. /**
  20538. * SVG and stylesheet needed for rendering the duotone filter.
  20539. *
  20540. * @param {Object} props Duotone props.
  20541. * @param {string} props.selector Selector to apply the filter to.
  20542. * @param {string} props.id Unique id for this duotone filter.
  20543. *
  20544. * @return {WPElement} Duotone element.
  20545. */
  20546. function DuotoneStylesheet(_ref) {
  20547. let {
  20548. selector,
  20549. id
  20550. } = _ref;
  20551. const css = `
  20552. ${selector} {
  20553. filter: url( #${id} );
  20554. }
  20555. `;
  20556. return (0,external_wp_element_namespaceObject.createElement)("style", null, css);
  20557. }
  20558. /**
  20559. * Stylesheet for disabling a global styles duotone filter.
  20560. *
  20561. * @param {Object} props Duotone props.
  20562. * @param {string} props.selector Selector to disable the filter for.
  20563. *
  20564. * @return {WPElement} Filter none style element.
  20565. */
  20566. function DuotoneUnsetStylesheet(_ref2) {
  20567. let {
  20568. selector
  20569. } = _ref2;
  20570. const css = `
  20571. ${selector} {
  20572. filter: none;
  20573. }
  20574. `;
  20575. return (0,external_wp_element_namespaceObject.createElement)("style", null, css);
  20576. }
  20577. /**
  20578. * The SVG part of the duotone filter.
  20579. *
  20580. * @param {Object} props Duotone props.
  20581. * @param {string} props.id Unique id for this duotone filter.
  20582. * @param {string[]} props.colors Color strings from dark to light.
  20583. *
  20584. * @return {WPElement} Duotone SVG.
  20585. */
  20586. function DuotoneFilter(_ref3) {
  20587. let {
  20588. id,
  20589. colors
  20590. } = _ref3;
  20591. const values = getValuesFromColors(colors);
  20592. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  20593. xmlnsXlink: "http://www.w3.org/1999/xlink",
  20594. viewBox: "0 0 0 0",
  20595. width: "0",
  20596. height: "0",
  20597. focusable: "false",
  20598. role: "none",
  20599. style: {
  20600. visibility: 'hidden',
  20601. position: 'absolute',
  20602. left: '-9999px',
  20603. overflow: 'hidden'
  20604. }
  20605. }, (0,external_wp_element_namespaceObject.createElement)("defs", null, (0,external_wp_element_namespaceObject.createElement)("filter", {
  20606. id: id
  20607. }, (0,external_wp_element_namespaceObject.createElement)("feColorMatrix", {
  20608. // Use sRGB instead of linearRGB so transparency looks correct.
  20609. colorInterpolationFilters: "sRGB",
  20610. type: "matrix" // Use perceptual brightness to convert to grayscale.
  20611. ,
  20612. values: " .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "
  20613. }), (0,external_wp_element_namespaceObject.createElement)("feComponentTransfer", {
  20614. // Use sRGB instead of linearRGB to be consistent with how CSS gradients work.
  20615. colorInterpolationFilters: "sRGB"
  20616. }, (0,external_wp_element_namespaceObject.createElement)("feFuncR", {
  20617. type: "table",
  20618. tableValues: values.r.join(' ')
  20619. }), (0,external_wp_element_namespaceObject.createElement)("feFuncG", {
  20620. type: "table",
  20621. tableValues: values.g.join(' ')
  20622. }), (0,external_wp_element_namespaceObject.createElement)("feFuncB", {
  20623. type: "table",
  20624. tableValues: values.b.join(' ')
  20625. }), (0,external_wp_element_namespaceObject.createElement)("feFuncA", {
  20626. type: "table",
  20627. tableValues: values.a.join(' ')
  20628. })), (0,external_wp_element_namespaceObject.createElement)("feComposite", {
  20629. // Re-mask the image with the original transparency since the feColorMatrix above loses that information.
  20630. in2: "SourceGraphic",
  20631. operator: "in"
  20632. }))));
  20633. }
  20634. /**
  20635. * SVG from a duotone preset
  20636. *
  20637. * @param {Object} props Duotone props.
  20638. * @param {Object} props.preset Duotone preset settings.
  20639. *
  20640. * @return {WPElement} Duotone element.
  20641. */
  20642. function PresetDuotoneFilter(_ref4) {
  20643. let {
  20644. preset
  20645. } = _ref4;
  20646. return (0,external_wp_element_namespaceObject.createElement)(DuotoneFilter, {
  20647. id: `wp-duotone-${preset.slug}`,
  20648. colors: preset.colors
  20649. });
  20650. }
  20651. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/auto.js
  20652. /**
  20653. * WordPress dependencies
  20654. */
  20655. /**
  20656. * Internal dependencies
  20657. */
  20658. // This is used to avoid rendering the block list if the sizes change.
  20659. let MemoizedBlockList;
  20660. const MAX_HEIGHT = 2000;
  20661. function AutoBlockPreview(_ref) {
  20662. let {
  20663. viewportWidth,
  20664. __experimentalPadding,
  20665. __experimentalMinHeight
  20666. } = _ref;
  20667. const [containerResizeListener, {
  20668. width: containerWidth
  20669. }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
  20670. const [contentResizeListener, {
  20671. height: contentHeight
  20672. }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
  20673. const {
  20674. styles,
  20675. assets,
  20676. duotone
  20677. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  20678. var _settings$__experimen, _settings$__experimen2;
  20679. const settings = select(store).getSettings();
  20680. return {
  20681. styles: settings.styles,
  20682. assets: settings.__unstableResolvedAssets,
  20683. duotone: (_settings$__experimen = settings.__experimentalFeatures) === null || _settings$__experimen === void 0 ? void 0 : (_settings$__experimen2 = _settings$__experimen.color) === null || _settings$__experimen2 === void 0 ? void 0 : _settings$__experimen2.duotone
  20684. };
  20685. }, []); // Avoid scrollbars for pattern previews.
  20686. const editorStyles = (0,external_wp_element_namespaceObject.useMemo)(() => {
  20687. if (styles) {
  20688. return [...styles, {
  20689. css: 'body{height:auto;overflow:hidden;}',
  20690. __unstableType: 'presets'
  20691. }];
  20692. }
  20693. return styles;
  20694. }, [styles]);
  20695. const svgFilters = (0,external_wp_element_namespaceObject.useMemo)(() => {
  20696. var _duotone$default, _duotone$theme;
  20697. return [...((_duotone$default = duotone === null || duotone === void 0 ? void 0 : duotone.default) !== null && _duotone$default !== void 0 ? _duotone$default : []), ...((_duotone$theme = duotone === null || duotone === void 0 ? void 0 : duotone.theme) !== null && _duotone$theme !== void 0 ? _duotone$theme : [])];
  20698. }, [duotone]); // Initialize on render instead of module top level, to avoid circular dependency issues.
  20699. MemoizedBlockList = MemoizedBlockList || (0,external_wp_compose_namespaceObject.pure)(BlockList);
  20700. const scale = containerWidth / viewportWidth;
  20701. return (0,external_wp_element_namespaceObject.createElement)("div", {
  20702. className: "block-editor-block-preview__container"
  20703. }, containerResizeListener, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, {
  20704. className: "block-editor-block-preview__content",
  20705. style: {
  20706. transform: `scale(${scale})`,
  20707. height: contentHeight * scale,
  20708. maxHeight: contentHeight > MAX_HEIGHT ? MAX_HEIGHT * scale : undefined,
  20709. minHeight: __experimentalMinHeight
  20710. }
  20711. }, (0,external_wp_element_namespaceObject.createElement)(iframe, {
  20712. head: (0,external_wp_element_namespaceObject.createElement)(EditorStyles, {
  20713. styles: editorStyles
  20714. }),
  20715. assets: assets,
  20716. contentRef: (0,external_wp_compose_namespaceObject.useRefEffect)(bodyElement => {
  20717. const {
  20718. ownerDocument: {
  20719. documentElement
  20720. }
  20721. } = bodyElement;
  20722. documentElement.classList.add('block-editor-block-preview__content-iframe');
  20723. documentElement.style.position = 'absolute';
  20724. documentElement.style.width = '100%';
  20725. bodyElement.style.padding = __experimentalPadding + 'px'; // Necessary for contentResizeListener to work.
  20726. bodyElement.style.boxSizing = 'border-box';
  20727. bodyElement.style.position = 'absolute';
  20728. bodyElement.style.width = '100%';
  20729. }, []),
  20730. "aria-hidden": true,
  20731. tabIndex: -1,
  20732. style: {
  20733. position: 'absolute',
  20734. width: viewportWidth,
  20735. height: contentHeight,
  20736. pointerEvents: 'none',
  20737. // This is a catch-all max-height for patterns.
  20738. // See: https://github.com/WordPress/gutenberg/pull/38175.
  20739. maxHeight: MAX_HEIGHT,
  20740. minHeight: scale !== 0 && scale < 1 && __experimentalMinHeight ? __experimentalMinHeight / scale : __experimentalMinHeight
  20741. }
  20742. }, contentResizeListener,
  20743. /* Filters need to be rendered before children to avoid Safari rendering issues. */
  20744. svgFilters.map(preset => (0,external_wp_element_namespaceObject.createElement)(PresetDuotoneFilter, {
  20745. preset: preset,
  20746. key: preset.slug
  20747. })), (0,external_wp_element_namespaceObject.createElement)(MemoizedBlockList, {
  20748. renderAppender: false
  20749. }))));
  20750. }
  20751. /* harmony default export */ var auto = (AutoBlockPreview);
  20752. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/index.js
  20753. /**
  20754. * External dependencies
  20755. */
  20756. /**
  20757. * WordPress dependencies
  20758. */
  20759. /**
  20760. * Internal dependencies
  20761. */
  20762. function BlockPreview(_ref) {
  20763. let {
  20764. blocks,
  20765. __experimentalPadding = 0,
  20766. viewportWidth = 1200,
  20767. __experimentalLive = false,
  20768. __experimentalOnClick,
  20769. __experimentalMinHeight
  20770. } = _ref;
  20771. const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings(), []);
  20772. const settings = (0,external_wp_element_namespaceObject.useMemo)(() => {
  20773. const _settings = { ...originalSettings
  20774. };
  20775. _settings.__experimentalBlockPatterns = [];
  20776. return _settings;
  20777. }, [originalSettings]);
  20778. const renderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.castArray)(blocks), [blocks]);
  20779. if (!blocks || blocks.length === 0) {
  20780. return null;
  20781. }
  20782. return (0,external_wp_element_namespaceObject.createElement)(provider, {
  20783. value: renderedBlocks,
  20784. settings: settings
  20785. }, __experimentalLive ? (0,external_wp_element_namespaceObject.createElement)(LiveBlockPreview, {
  20786. onClick: __experimentalOnClick
  20787. }) : (0,external_wp_element_namespaceObject.createElement)(auto, {
  20788. viewportWidth: viewportWidth,
  20789. __experimentalPadding: __experimentalPadding,
  20790. __experimentalMinHeight: __experimentalMinHeight
  20791. }));
  20792. }
  20793. /**
  20794. * BlockPreview renders a preview of a block or array of blocks.
  20795. *
  20796. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md
  20797. *
  20798. * @param {Object} preview options for how the preview should be shown
  20799. * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.
  20800. * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.
  20801. *
  20802. * @return {WPComponent} The component to be rendered.
  20803. */
  20804. /* harmony default export */ var block_preview = ((0,external_wp_element_namespaceObject.memo)(BlockPreview));
  20805. /**
  20806. * This hook is used to lightly mark an element as a block preview wrapper
  20807. * element. Call this hook and pass the returned props to the element to mark as
  20808. * a block preview wrapper, automatically rendering inner blocks as children. If
  20809. * you define a ref for the element, it is important to pass the ref to this
  20810. * hook, which the hook in turn will pass to the component through the props it
  20811. * returns. Optionally, you can also pass any other props through this hook, and
  20812. * they will be merged and returned.
  20813. *
  20814. * @param {Object} options Preview options.
  20815. * @param {WPBlock[]} options.blocks Block objects.
  20816. * @param {Object} options.props Optional. Props to pass to the element. Must contain
  20817. * the ref if one is defined.
  20818. * @param {Object} options.__experimentalLayout Layout settings to be used in the preview.
  20819. *
  20820. */
  20821. function useBlockPreview(_ref2) {
  20822. let {
  20823. blocks,
  20824. props = {},
  20825. __experimentalLayout
  20826. } = _ref2;
  20827. const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings(), []);
  20828. const disabledRef = (0,external_wp_compose_namespaceObject.useDisabled)();
  20829. const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, disabledRef]);
  20830. const settings = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...originalSettings,
  20831. __experimentalBlockPatterns: []
  20832. }), [originalSettings]);
  20833. const renderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.castArray)(blocks), [blocks]);
  20834. const children = (0,external_wp_element_namespaceObject.createElement)(provider, {
  20835. value: renderedBlocks,
  20836. settings: settings
  20837. }, (0,external_wp_element_namespaceObject.createElement)(BlockListItems, {
  20838. renderAppender: false,
  20839. __experimentalLayout: __experimentalLayout
  20840. }));
  20841. return { ...props,
  20842. ref,
  20843. className: classnames_default()(props.className, 'block-editor-block-preview__live-content', 'components-disabled'),
  20844. children: blocks !== null && blocks !== void 0 && blocks.length ? children : null
  20845. };
  20846. }
  20847. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/preview-panel.js
  20848. /**
  20849. * WordPress dependencies
  20850. */
  20851. /**
  20852. * Internal dependencies
  20853. */
  20854. function InserterPreviewPanel(_ref) {
  20855. var _example$viewportWidt;
  20856. let {
  20857. item
  20858. } = _ref;
  20859. const {
  20860. name,
  20861. title,
  20862. icon,
  20863. description,
  20864. initialAttributes,
  20865. example
  20866. } = item;
  20867. const isReusable = (0,external_wp_blocks_namespaceObject.isReusableBlock)(item);
  20868. return (0,external_wp_element_namespaceObject.createElement)("div", {
  20869. className: "block-editor-inserter__preview-container"
  20870. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  20871. className: "block-editor-inserter__preview"
  20872. }, isReusable || example ? (0,external_wp_element_namespaceObject.createElement)("div", {
  20873. className: "block-editor-inserter__preview-content"
  20874. }, (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  20875. __experimentalPadding: 16,
  20876. viewportWidth: (_example$viewportWidt = example === null || example === void 0 ? void 0 : example.viewportWidth) !== null && _example$viewportWidt !== void 0 ? _example$viewportWidt : 500,
  20877. blocks: example ? (0,external_wp_blocks_namespaceObject.getBlockFromExample)(name, {
  20878. attributes: { ...example.attributes,
  20879. ...initialAttributes
  20880. },
  20881. innerBlocks: example.innerBlocks
  20882. }) : (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes)
  20883. })) : (0,external_wp_element_namespaceObject.createElement)("div", {
  20884. className: "block-editor-inserter__preview-content-missing"
  20885. }, (0,external_wp_i18n_namespaceObject.__)('No Preview Available.'))), !isReusable && (0,external_wp_element_namespaceObject.createElement)(block_card, {
  20886. title: title,
  20887. icon: icon,
  20888. description: description
  20889. }));
  20890. }
  20891. /* harmony default export */ var preview_panel = (InserterPreviewPanel);
  20892. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/context.js
  20893. /**
  20894. * WordPress dependencies
  20895. */
  20896. const InserterListboxContext = (0,external_wp_element_namespaceObject.createContext)();
  20897. /* harmony default export */ var context = (InserterListboxContext);
  20898. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/item.js
  20899. /**
  20900. * WordPress dependencies
  20901. */
  20902. /**
  20903. * Internal dependencies
  20904. */
  20905. function InserterListboxItem(_ref, ref) {
  20906. let {
  20907. isFirst,
  20908. as: Component,
  20909. children,
  20910. ...props
  20911. } = _ref;
  20912. const state = (0,external_wp_element_namespaceObject.useContext)(context);
  20913. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
  20914. ref: ref,
  20915. state: state,
  20916. role: "option" // Use the CompositeItem `focusable` prop over Button's
  20917. // isFocusable. The latter was shown to cause an issue
  20918. // with tab order in the inserter list.
  20919. ,
  20920. focusable: true
  20921. }, props), htmlProps => {
  20922. const propsWithTabIndex = { ...htmlProps,
  20923. tabIndex: isFirst ? 0 : htmlProps.tabIndex
  20924. };
  20925. if (Component) {
  20926. return (0,external_wp_element_namespaceObject.createElement)(Component, propsWithTabIndex, children);
  20927. }
  20928. if (typeof children === 'function') {
  20929. return children(propsWithTabIndex);
  20930. }
  20931. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, propsWithTabIndex, children);
  20932. });
  20933. }
  20934. /* harmony default export */ var inserter_listbox_item = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxItem));
  20935. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drag-handle.js
  20936. /**
  20937. * WordPress dependencies
  20938. */
  20939. const dragHandle = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  20940. width: "24",
  20941. height: "24",
  20942. xmlns: "http://www.w3.org/2000/svg",
  20943. viewBox: "0 0 24 24"
  20944. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  20945. d: "M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z"
  20946. }));
  20947. /* harmony default export */ var drag_handle = (dragHandle);
  20948. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/draggable-chip.js
  20949. /**
  20950. * WordPress dependencies
  20951. */
  20952. /**
  20953. * Internal dependencies
  20954. */
  20955. function BlockDraggableChip(_ref) {
  20956. let {
  20957. count,
  20958. icon
  20959. } = _ref;
  20960. return (0,external_wp_element_namespaceObject.createElement)("div", {
  20961. className: "block-editor-block-draggable-chip-wrapper"
  20962. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  20963. className: "block-editor-block-draggable-chip",
  20964. "data-testid": "block-draggable-chip"
  20965. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
  20966. justify: "center",
  20967. className: "block-editor-block-draggable-chip__content"
  20968. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, icon ? (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  20969. icon: icon
  20970. }) : (0,external_wp_i18n_namespaceObject.sprintf)(
  20971. /* translators: %d: Number of blocks. */
  20972. (0,external_wp_i18n_namespaceObject._n)('%d block', '%d blocks', count), count)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  20973. icon: drag_handle
  20974. })))));
  20975. }
  20976. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-draggable-blocks/index.js
  20977. /**
  20978. * WordPress dependencies
  20979. */
  20980. /**
  20981. * Internal dependencies
  20982. */
  20983. const InserterDraggableBlocks = _ref => {
  20984. let {
  20985. isEnabled,
  20986. blocks,
  20987. icon,
  20988. children
  20989. } = _ref;
  20990. const transferData = {
  20991. type: 'inserter',
  20992. blocks
  20993. };
  20994. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Draggable, {
  20995. __experimentalTransferDataType: "wp-blocks",
  20996. transferData: transferData,
  20997. __experimentalDragComponent: (0,external_wp_element_namespaceObject.createElement)(BlockDraggableChip, {
  20998. count: blocks.length,
  20999. icon: icon
  21000. })
  21001. }, _ref2 => {
  21002. let {
  21003. onDraggableStart,
  21004. onDraggableEnd
  21005. } = _ref2;
  21006. return children({
  21007. draggable: isEnabled,
  21008. onDragStart: isEnabled ? onDraggableStart : undefined,
  21009. onDragEnd: isEnabled ? onDraggableEnd : undefined
  21010. });
  21011. });
  21012. };
  21013. /* harmony default export */ var inserter_draggable_blocks = (InserterDraggableBlocks);
  21014. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-list-item/index.js
  21015. /**
  21016. * External dependencies
  21017. */
  21018. /**
  21019. * WordPress dependencies
  21020. */
  21021. /**
  21022. * Internal dependencies
  21023. */
  21024. function InserterListItem(_ref) {
  21025. let {
  21026. className,
  21027. isFirst,
  21028. item,
  21029. onSelect,
  21030. onHover,
  21031. isDraggable,
  21032. ...props
  21033. } = _ref;
  21034. const isDragging = (0,external_wp_element_namespaceObject.useRef)(false);
  21035. const itemIconStyle = item.icon ? {
  21036. backgroundColor: item.icon.background,
  21037. color: item.icon.foreground
  21038. } : {};
  21039. const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
  21040. return [(0,external_wp_blocks_namespaceObject.createBlock)(item.name, item.initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(item.innerBlocks))];
  21041. }, [item.name, item.initialAttributes, item.initialAttributes]);
  21042. return (0,external_wp_element_namespaceObject.createElement)(inserter_draggable_blocks, {
  21043. isEnabled: isDraggable && !item.disabled,
  21044. blocks: blocks,
  21045. icon: item.icon
  21046. }, _ref2 => {
  21047. let {
  21048. draggable,
  21049. onDragStart,
  21050. onDragEnd
  21051. } = _ref2;
  21052. return (0,external_wp_element_namespaceObject.createElement)("div", {
  21053. className: "block-editor-block-types-list__list-item",
  21054. draggable: draggable,
  21055. onDragStart: event => {
  21056. isDragging.current = true;
  21057. if (onDragStart) {
  21058. onHover(null);
  21059. onDragStart(event);
  21060. }
  21061. },
  21062. onDragEnd: event => {
  21063. isDragging.current = false;
  21064. if (onDragEnd) {
  21065. onDragEnd(event);
  21066. }
  21067. }
  21068. }, (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_item, _extends({
  21069. isFirst: isFirst,
  21070. className: classnames_default()('block-editor-block-types-list__item', className),
  21071. disabled: item.isDisabled,
  21072. onClick: event => {
  21073. event.preventDefault();
  21074. onSelect(item, (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? event.metaKey : event.ctrlKey);
  21075. onHover(null);
  21076. },
  21077. onKeyDown: event => {
  21078. const {
  21079. keyCode
  21080. } = event;
  21081. if (keyCode === external_wp_keycodes_namespaceObject.ENTER) {
  21082. event.preventDefault();
  21083. onSelect(item, (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? event.metaKey : event.ctrlKey);
  21084. onHover(null);
  21085. }
  21086. },
  21087. onFocus: () => {
  21088. if (isDragging.current) {
  21089. return;
  21090. }
  21091. onHover(item);
  21092. },
  21093. onMouseEnter: () => {
  21094. if (isDragging.current) {
  21095. return;
  21096. }
  21097. onHover(item);
  21098. },
  21099. onMouseLeave: () => onHover(null),
  21100. onBlur: () => onHover(null)
  21101. }, props), (0,external_wp_element_namespaceObject.createElement)("span", {
  21102. className: "block-editor-block-types-list__item-icon",
  21103. style: itemIconStyle
  21104. }, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  21105. icon: item.icon,
  21106. showColors: true
  21107. })), (0,external_wp_element_namespaceObject.createElement)("span", {
  21108. className: "block-editor-block-types-list__item-title"
  21109. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, {
  21110. numberOfLines: 3
  21111. }, item.title))));
  21112. });
  21113. }
  21114. /* harmony default export */ var inserter_list_item = ((0,external_wp_element_namespaceObject.memo)(InserterListItem));
  21115. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/group.js
  21116. /**
  21117. * WordPress dependencies
  21118. */
  21119. function InserterListboxGroup(props, ref) {
  21120. const [shouldSpeak, setShouldSpeak] = (0,external_wp_element_namespaceObject.useState)(false);
  21121. (0,external_wp_element_namespaceObject.useEffect)(() => {
  21122. if (shouldSpeak) {
  21123. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to move through blocks'));
  21124. }
  21125. }, [shouldSpeak]);
  21126. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  21127. ref: ref,
  21128. role: "listbox",
  21129. "aria-orientation": "horizontal",
  21130. onFocus: () => {
  21131. setShouldSpeak(true);
  21132. },
  21133. onBlur: event => {
  21134. const focusingOutsideGroup = !event.currentTarget.contains(event.relatedTarget);
  21135. if (focusingOutsideGroup) {
  21136. setShouldSpeak(false);
  21137. }
  21138. }
  21139. }, props));
  21140. }
  21141. /* harmony default export */ var group = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxGroup));
  21142. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/row.js
  21143. /**
  21144. * WordPress dependencies
  21145. */
  21146. /**
  21147. * Internal dependencies
  21148. */
  21149. function InserterListboxRow(props, ref) {
  21150. const state = (0,external_wp_element_namespaceObject.useContext)(context);
  21151. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeGroup, _extends({
  21152. state: state,
  21153. role: "presentation",
  21154. ref: ref
  21155. }, props));
  21156. }
  21157. /* harmony default export */ var inserter_listbox_row = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxRow));
  21158. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-types-list/index.js
  21159. /**
  21160. * WordPress dependencies
  21161. */
  21162. /**
  21163. * Internal dependencies
  21164. */
  21165. function chunk(array, size) {
  21166. const chunks = [];
  21167. for (let i = 0, j = array.length; i < j; i += size) {
  21168. chunks.push(array.slice(i, i + size));
  21169. }
  21170. return chunks;
  21171. }
  21172. function BlockTypesList(_ref) {
  21173. let {
  21174. items = [],
  21175. onSelect,
  21176. onHover = () => {},
  21177. children,
  21178. label,
  21179. isDraggable = true
  21180. } = _ref;
  21181. return (0,external_wp_element_namespaceObject.createElement)(group, {
  21182. className: "block-editor-block-types-list",
  21183. "aria-label": label
  21184. }, chunk(items, 3).map((row, i) => (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_row, {
  21185. key: i
  21186. }, row.map((item, j) => (0,external_wp_element_namespaceObject.createElement)(inserter_list_item, {
  21187. key: item.id,
  21188. item: item,
  21189. className: (0,external_wp_blocks_namespaceObject.getBlockMenuDefaultClassName)(item.id),
  21190. onSelect: onSelect,
  21191. onHover: onHover,
  21192. isDraggable: isDraggable && !item.isDisabled,
  21193. isFirst: i === 0 && j === 0
  21194. })))), children);
  21195. }
  21196. /* harmony default export */ var block_types_list = (BlockTypesList);
  21197. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/panel.js
  21198. /**
  21199. * WordPress dependencies
  21200. */
  21201. function InserterPanel(_ref) {
  21202. let {
  21203. title,
  21204. icon,
  21205. children
  21206. } = _ref;
  21207. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  21208. className: "block-editor-inserter__panel-header"
  21209. }, (0,external_wp_element_namespaceObject.createElement)("h2", {
  21210. className: "block-editor-inserter__panel-title"
  21211. }, title), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
  21212. icon: icon
  21213. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  21214. className: "block-editor-inserter__panel-content"
  21215. }, children));
  21216. }
  21217. /* harmony default export */ var panel = (InserterPanel);
  21218. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-block-types-state.js
  21219. /**
  21220. * WordPress dependencies
  21221. */
  21222. /**
  21223. * Internal dependencies
  21224. */
  21225. /**
  21226. * Retrieves the block types inserter state.
  21227. *
  21228. * @param {string=} rootClientId Insertion's root client ID.
  21229. * @param {Function} onInsert function called when inserter a list of blocks.
  21230. * @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)
  21231. */
  21232. const useBlockTypesState = (rootClientId, onInsert) => {
  21233. const {
  21234. categories,
  21235. collections,
  21236. items
  21237. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  21238. const {
  21239. getInserterItems
  21240. } = select(store);
  21241. const {
  21242. getCategories,
  21243. getCollections
  21244. } = select(external_wp_blocks_namespaceObject.store);
  21245. return {
  21246. categories: getCategories(),
  21247. collections: getCollections(),
  21248. items: getInserterItems(rootClientId)
  21249. };
  21250. }, [rootClientId]);
  21251. const onSelectItem = (0,external_wp_element_namespaceObject.useCallback)((_ref, shouldFocusBlock) => {
  21252. let {
  21253. name,
  21254. initialAttributes,
  21255. innerBlocks
  21256. } = _ref;
  21257. const insertedBlock = (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(innerBlocks));
  21258. onInsert(insertedBlock, undefined, shouldFocusBlock);
  21259. }, [onInsert]);
  21260. return [items, categories, collections, onSelectItem];
  21261. };
  21262. /* harmony default export */ var use_block_types_state = (useBlockTypesState);
  21263. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/index.js
  21264. /**
  21265. * WordPress dependencies
  21266. */
  21267. /**
  21268. * Internal dependencies
  21269. */
  21270. function InserterListbox(_ref) {
  21271. let {
  21272. children
  21273. } = _ref;
  21274. const compositeState = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({
  21275. shift: true,
  21276. wrap: 'horizontal'
  21277. });
  21278. return (0,external_wp_element_namespaceObject.createElement)(context.Provider, {
  21279. value: compositeState
  21280. }, children);
  21281. }
  21282. /* harmony default export */ var inserter_listbox = (InserterListbox);
  21283. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-types-tab.js
  21284. /**
  21285. * External dependencies
  21286. */
  21287. /**
  21288. * WordPress dependencies
  21289. */
  21290. /**
  21291. * Internal dependencies
  21292. */
  21293. const getBlockNamespace = item => item.name.split('/')[0];
  21294. const MAX_SUGGESTED_ITEMS = 6;
  21295. /**
  21296. * Shared reference to an empty array for cases where it is important to avoid
  21297. * returning a new array reference on every invocation and rerendering the component.
  21298. *
  21299. * @type {Array}
  21300. */
  21301. const block_types_tab_EMPTY_ARRAY = [];
  21302. function BlockTypesTab(_ref) {
  21303. let {
  21304. rootClientId,
  21305. onInsert,
  21306. onHover,
  21307. showMostUsedBlocks
  21308. } = _ref;
  21309. const [items, categories, collections, onSelectItem] = use_block_types_state(rootClientId, onInsert);
  21310. const suggestedItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
  21311. return (0,external_lodash_namespaceObject.orderBy)(items, ['frecency'], ['desc']).slice(0, MAX_SUGGESTED_ITEMS);
  21312. }, [items]);
  21313. const uncategorizedItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
  21314. return items.filter(item => !item.category);
  21315. }, [items]);
  21316. const itemsPerCategory = (0,external_wp_element_namespaceObject.useMemo)(() => {
  21317. return (0,external_lodash_namespaceObject.flow)(itemList => itemList.filter(item => item.category && item.category !== 'reusable'), itemList => (0,external_lodash_namespaceObject.groupBy)(itemList, 'category'))(items);
  21318. }, [items]);
  21319. const itemsPerCollection = (0,external_wp_element_namespaceObject.useMemo)(() => {
  21320. // Create a new Object to avoid mutating collection.
  21321. const result = { ...collections
  21322. };
  21323. Object.keys(collections).forEach(namespace => {
  21324. result[namespace] = items.filter(item => getBlockNamespace(item) === namespace);
  21325. if (result[namespace].length === 0) {
  21326. delete result[namespace];
  21327. }
  21328. });
  21329. return result;
  21330. }, [items, collections]); // Hide block preview on unmount.
  21331. (0,external_wp_element_namespaceObject.useEffect)(() => () => onHover(null), []);
  21332. /**
  21333. * The inserter contains a big number of blocks and opening it is a costful operation.
  21334. * The rendering is the most costful part of it, in order to improve the responsiveness
  21335. * of the "opening" action, these lazy lists allow us to render the inserter category per category,
  21336. * once all the categories are rendered, we start rendering the collections and the uncategorized block types.
  21337. */
  21338. const currentlyRenderedCategories = (0,external_wp_compose_namespaceObject.useAsyncList)(categories);
  21339. const didRenderAllCategories = categories.length === currentlyRenderedCategories.length; // Async List requires an array.
  21340. const collectionEntries = (0,external_wp_element_namespaceObject.useMemo)(() => {
  21341. return Object.entries(collections);
  21342. }, [collections]);
  21343. const currentlyRenderedCollections = (0,external_wp_compose_namespaceObject.useAsyncList)(didRenderAllCategories ? collectionEntries : block_types_tab_EMPTY_ARRAY);
  21344. return (0,external_wp_element_namespaceObject.createElement)(inserter_listbox, null, (0,external_wp_element_namespaceObject.createElement)("div", null, showMostUsedBlocks && !!suggestedItems.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
  21345. title: (0,external_wp_i18n_namespaceObject._x)('Most used', 'blocks')
  21346. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  21347. items: suggestedItems,
  21348. onSelect: onSelectItem,
  21349. onHover: onHover,
  21350. label: (0,external_wp_i18n_namespaceObject._x)('Most used', 'blocks')
  21351. })), (0,external_lodash_namespaceObject.map)(currentlyRenderedCategories, category => {
  21352. const categoryItems = itemsPerCategory[category.slug];
  21353. if (!categoryItems || !categoryItems.length) {
  21354. return null;
  21355. }
  21356. return (0,external_wp_element_namespaceObject.createElement)(panel, {
  21357. key: category.slug,
  21358. title: category.title,
  21359. icon: category.icon
  21360. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  21361. items: categoryItems,
  21362. onSelect: onSelectItem,
  21363. onHover: onHover,
  21364. label: category.title
  21365. }));
  21366. }), didRenderAllCategories && uncategorizedItems.length > 0 && (0,external_wp_element_namespaceObject.createElement)(panel, {
  21367. className: "block-editor-inserter__uncategorized-blocks-panel",
  21368. title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized')
  21369. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  21370. items: uncategorizedItems,
  21371. onSelect: onSelectItem,
  21372. onHover: onHover,
  21373. label: (0,external_wp_i18n_namespaceObject.__)('Uncategorized')
  21374. })), (0,external_lodash_namespaceObject.map)(currentlyRenderedCollections, _ref2 => {
  21375. let [namespace, collection] = _ref2;
  21376. const collectionItems = itemsPerCollection[namespace];
  21377. if (!collectionItems || !collectionItems.length) {
  21378. return null;
  21379. }
  21380. return (0,external_wp_element_namespaceObject.createElement)(panel, {
  21381. key: namespace,
  21382. title: collection.title,
  21383. icon: collection.icon
  21384. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  21385. items: collectionItems,
  21386. onSelect: onSelectItem,
  21387. onHover: onHover,
  21388. label: collection.title
  21389. }));
  21390. })));
  21391. }
  21392. /* harmony default export */ var block_types_tab = (BlockTypesTab);
  21393. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/pattern-panel.js
  21394. /**
  21395. * External dependencies
  21396. */
  21397. /**
  21398. * WordPress dependencies
  21399. */
  21400. function PatternInserterPanel(_ref) {
  21401. let {
  21402. selectedCategory,
  21403. patternCategories,
  21404. onClickCategory,
  21405. openPatternExplorer
  21406. } = _ref;
  21407. const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
  21408. const categoryOptions = () => {
  21409. const options = [];
  21410. patternCategories.map(patternCategory => {
  21411. return options.push({
  21412. value: patternCategory.name,
  21413. label: patternCategory.label
  21414. });
  21415. });
  21416. return options;
  21417. };
  21418. const onChangeSelect = selected => {
  21419. onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name));
  21420. };
  21421. const className = classnames_default()('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns'); // In iOS-based mobile devices, the onBlur will fire when selecting an option
  21422. // from a Select element. To prevent closing the useDialog on iOS devices, we
  21423. // stop propagating the onBlur event if there is no relatedTarget, which means
  21424. // that the user most likely did not click on an element within the editor canvas.
  21425. const onBlur = event => {
  21426. if (!(event !== null && event !== void 0 && event.relatedTarget)) {
  21427. event.stopPropagation();
  21428. }
  21429. };
  21430. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
  21431. justify: "space-between",
  21432. align: "start",
  21433. gap: "4",
  21434. className: className
  21435. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
  21436. isBlock: true
  21437. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
  21438. className: "block-editor-inserter__panel-dropdown",
  21439. label: (0,external_wp_i18n_namespaceObject.__)('Filter patterns'),
  21440. hideLabelFromVision: true,
  21441. value: selectedCategory.name,
  21442. onChange: onChangeSelect,
  21443. onBlur: onBlur,
  21444. options: categoryOptions()
  21445. })), !isMobile && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  21446. variant: "secondary",
  21447. className: "block-editor-inserter__patterns-explorer-expand",
  21448. label: (0,external_wp_i18n_namespaceObject.__)('Explore all patterns'),
  21449. onClick: () => openPatternExplorer()
  21450. }, (0,external_wp_i18n_namespaceObject._x)('Explore', 'Label for showing all block patterns'))));
  21451. }
  21452. /* harmony default export */ var pattern_panel = (PatternInserterPanel);
  21453. ;// CONCATENATED MODULE: external ["wp","notices"]
  21454. var external_wp_notices_namespaceObject = window["wp"]["notices"];
  21455. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-patterns-state.js
  21456. /**
  21457. * External dependencies
  21458. */
  21459. /**
  21460. * WordPress dependencies
  21461. */
  21462. /**
  21463. * Internal dependencies
  21464. */
  21465. /**
  21466. * Retrieves the block patterns inserter state.
  21467. *
  21468. * @param {Function} onInsert function called when inserter a list of blocks.
  21469. * @param {string=} rootClientId Insertion's root client ID.
  21470. *
  21471. * @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)
  21472. */
  21473. const usePatternsState = (onInsert, rootClientId) => {
  21474. const {
  21475. patternCategories,
  21476. patterns
  21477. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  21478. const {
  21479. __experimentalGetAllowedPatterns,
  21480. getSettings
  21481. } = select(store);
  21482. return {
  21483. patterns: __experimentalGetAllowedPatterns(rootClientId),
  21484. patternCategories: getSettings().__experimentalBlockPatternCategories
  21485. };
  21486. }, [rootClientId]);
  21487. const {
  21488. createSuccessNotice
  21489. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
  21490. const onClickPattern = (0,external_wp_element_namespaceObject.useCallback)((pattern, blocks) => {
  21491. onInsert((0,external_lodash_namespaceObject.map)(blocks, block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block)), pattern.name);
  21492. createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
  21493. /* translators: %s: block pattern title. */
  21494. (0,external_wp_i18n_namespaceObject.__)('Block pattern "%s" inserted.'), pattern.title), {
  21495. type: 'snackbar'
  21496. });
  21497. }, []);
  21498. return [patterns, patternCategories, onClickPattern];
  21499. };
  21500. /* harmony default export */ var use_patterns_state = (usePatternsState);
  21501. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-patterns-list/index.js
  21502. /**
  21503. * WordPress dependencies
  21504. */
  21505. /**
  21506. * Internal dependencies
  21507. */
  21508. function BlockPattern(_ref) {
  21509. let {
  21510. isDraggable,
  21511. pattern,
  21512. onClick,
  21513. composite
  21514. } = _ref;
  21515. const {
  21516. blocks,
  21517. viewportWidth
  21518. } = pattern;
  21519. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockPattern);
  21520. const descriptionId = `block-editor-block-patterns-list__item-description-${instanceId}`;
  21521. return (0,external_wp_element_namespaceObject.createElement)(inserter_draggable_blocks, {
  21522. isEnabled: isDraggable,
  21523. blocks: blocks
  21524. }, _ref2 => {
  21525. let {
  21526. draggable,
  21527. onDragStart,
  21528. onDragEnd
  21529. } = _ref2;
  21530. return (0,external_wp_element_namespaceObject.createElement)("div", {
  21531. className: "block-editor-block-patterns-list__list-item",
  21532. "aria-label": pattern.title,
  21533. "aria-describedby": pattern.description ? descriptionId : undefined,
  21534. draggable: draggable,
  21535. onDragStart: onDragStart,
  21536. onDragEnd: onDragEnd
  21537. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
  21538. role: "option",
  21539. as: "div"
  21540. }, composite, {
  21541. className: "block-editor-block-patterns-list__item",
  21542. onClick: () => onClick(pattern, blocks)
  21543. }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  21544. blocks: blocks,
  21545. viewportWidth: viewportWidth
  21546. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  21547. className: "block-editor-block-patterns-list__item-title"
  21548. }, pattern.title), !!pattern.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  21549. id: descriptionId
  21550. }, pattern.description)));
  21551. });
  21552. }
  21553. function BlockPatternPlaceholder() {
  21554. return (0,external_wp_element_namespaceObject.createElement)("div", {
  21555. className: "block-editor-block-patterns-list__item is-placeholder"
  21556. });
  21557. }
  21558. function BlockPatternList(_ref3) {
  21559. let {
  21560. isDraggable,
  21561. blockPatterns,
  21562. shownPatterns,
  21563. onClickPattern,
  21564. orientation,
  21565. label = (0,external_wp_i18n_namespaceObject.__)('Block Patterns')
  21566. } = _ref3;
  21567. const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({
  21568. orientation
  21569. });
  21570. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
  21571. role: "listbox",
  21572. className: "block-editor-block-patterns-list",
  21573. "aria-label": label
  21574. }), blockPatterns.map(pattern => {
  21575. const isShown = shownPatterns.includes(pattern);
  21576. return isShown ? (0,external_wp_element_namespaceObject.createElement)(BlockPattern, {
  21577. key: pattern.name,
  21578. pattern: pattern,
  21579. onClick: onClickPattern,
  21580. isDraggable: isDraggable,
  21581. composite: composite
  21582. }) : (0,external_wp_element_namespaceObject.createElement)(BlockPatternPlaceholder, {
  21583. key: pattern.name
  21584. });
  21585. }));
  21586. }
  21587. /* harmony default export */ var block_patterns_list = (BlockPatternList);
  21588. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-explorer/sidebar.js
  21589. /**
  21590. * WordPress dependencies
  21591. */
  21592. function PatternCategoriesList(_ref) {
  21593. let {
  21594. selectedCategory,
  21595. patternCategories,
  21596. onClickCategory
  21597. } = _ref;
  21598. const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
  21599. return (0,external_wp_element_namespaceObject.createElement)("div", {
  21600. className: `${baseClassName}__categories-list`
  21601. }, patternCategories.map(_ref2 => {
  21602. let {
  21603. name,
  21604. label
  21605. } = _ref2;
  21606. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  21607. key: name,
  21608. label: label,
  21609. className: `${baseClassName}__categories-list__item`,
  21610. isPressed: selectedCategory === name,
  21611. onClick: () => {
  21612. onClickCategory(name);
  21613. }
  21614. }, label);
  21615. }));
  21616. }
  21617. function PatternsExplorerSearch(_ref3) {
  21618. let {
  21619. filterValue,
  21620. setFilterValue
  21621. } = _ref3;
  21622. const baseClassName = 'block-editor-block-patterns-explorer__search';
  21623. return (0,external_wp_element_namespaceObject.createElement)("div", {
  21624. className: baseClassName
  21625. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
  21626. onChange: setFilterValue,
  21627. value: filterValue,
  21628. label: (0,external_wp_i18n_namespaceObject.__)('Search for patterns'),
  21629. placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
  21630. }));
  21631. }
  21632. function PatternExplorerSidebar(_ref4) {
  21633. let {
  21634. selectedCategory,
  21635. patternCategories,
  21636. onClickCategory,
  21637. filterValue,
  21638. setFilterValue
  21639. } = _ref4;
  21640. const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
  21641. return (0,external_wp_element_namespaceObject.createElement)("div", {
  21642. className: baseClassName
  21643. }, (0,external_wp_element_namespaceObject.createElement)(PatternsExplorerSearch, {
  21644. filterValue: filterValue,
  21645. setFilterValue: setFilterValue
  21646. }), !filterValue && (0,external_wp_element_namespaceObject.createElement)(PatternCategoriesList, {
  21647. selectedCategory: selectedCategory,
  21648. patternCategories: patternCategories,
  21649. onClickCategory: onClickCategory
  21650. }));
  21651. }
  21652. /* harmony default export */ var sidebar = (PatternExplorerSidebar);
  21653. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/no-results.js
  21654. /**
  21655. * WordPress dependencies
  21656. */
  21657. function InserterNoResults() {
  21658. return (0,external_wp_element_namespaceObject.createElement)("div", {
  21659. className: "block-editor-inserter__no-results"
  21660. }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  21661. className: "block-editor-inserter__no-results-icon",
  21662. icon: block_default
  21663. }), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('No results found.')));
  21664. }
  21665. /* harmony default export */ var no_results = (InserterNoResults);
  21666. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-insertion-point.js
  21667. /**
  21668. * External dependencies
  21669. */
  21670. /**
  21671. * WordPress dependencies
  21672. */
  21673. /**
  21674. * Internal dependencies
  21675. */
  21676. /**
  21677. * @typedef WPInserterConfig
  21678. *
  21679. * @property {string=} rootClientId If set, insertion will be into the
  21680. * block with this ID.
  21681. * @property {number=} insertionIndex If set, insertion will be into this
  21682. * explicit position.
  21683. * @property {string=} clientId If set, insertion will be after the
  21684. * block with this ID.
  21685. * @property {boolean=} isAppender Whether the inserter is an appender
  21686. * or not.
  21687. * @property {Function=} onSelect Called after insertion.
  21688. */
  21689. /**
  21690. * Returns the insertion point state given the inserter config.
  21691. *
  21692. * @param {WPInserterConfig} config Inserter Config.
  21693. * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).
  21694. */
  21695. function useInsertionPoint(_ref) {
  21696. let {
  21697. rootClientId = '',
  21698. insertionIndex,
  21699. clientId,
  21700. isAppender,
  21701. onSelect,
  21702. shouldFocusBlock = true
  21703. } = _ref;
  21704. const {
  21705. getSelectedBlock
  21706. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  21707. const {
  21708. destinationRootClientId,
  21709. destinationIndex
  21710. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  21711. const {
  21712. getSelectedBlockClientId,
  21713. getBlockRootClientId,
  21714. getBlockIndex,
  21715. getBlockOrder
  21716. } = select(store);
  21717. const selectedBlockClientId = getSelectedBlockClientId();
  21718. let _destinationRootClientId = rootClientId;
  21719. let _destinationIndex;
  21720. if (insertionIndex !== undefined) {
  21721. // Insert into a specific index.
  21722. _destinationIndex = insertionIndex;
  21723. } else if (clientId) {
  21724. // Insert after a specific client ID.
  21725. _destinationIndex = getBlockIndex(clientId);
  21726. } else if (!isAppender && selectedBlockClientId) {
  21727. _destinationRootClientId = getBlockRootClientId(selectedBlockClientId);
  21728. _destinationIndex = getBlockIndex(selectedBlockClientId) + 1;
  21729. } else {
  21730. // Insert at the end of the list.
  21731. _destinationIndex = getBlockOrder(_destinationRootClientId).length;
  21732. }
  21733. return {
  21734. destinationRootClientId: _destinationRootClientId,
  21735. destinationIndex: _destinationIndex
  21736. };
  21737. }, [rootClientId, insertionIndex, clientId, isAppender]);
  21738. const {
  21739. replaceBlocks,
  21740. insertBlocks,
  21741. showInsertionPoint,
  21742. hideInsertionPoint
  21743. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  21744. const onInsertBlocks = (0,external_wp_element_namespaceObject.useCallback)(function (blocks, meta) {
  21745. let shouldForceFocusBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  21746. const selectedBlock = getSelectedBlock();
  21747. if (!isAppender && selectedBlock && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(selectedBlock)) {
  21748. replaceBlocks(selectedBlock.clientId, blocks, null, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
  21749. } else {
  21750. insertBlocks(blocks, destinationIndex, destinationRootClientId, true, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
  21751. }
  21752. const message = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %d: the name of the block that has been added
  21753. (0,external_wp_i18n_namespaceObject._n)('%d block added.', '%d blocks added.', (0,external_lodash_namespaceObject.castArray)(blocks).length), (0,external_lodash_namespaceObject.castArray)(blocks).length);
  21754. (0,external_wp_a11y_namespaceObject.speak)(message);
  21755. if (onSelect) {
  21756. onSelect();
  21757. }
  21758. }, [isAppender, getSelectedBlock, replaceBlocks, insertBlocks, destinationRootClientId, destinationIndex, onSelect, shouldFocusBlock]);
  21759. const onToggleInsertionPoint = (0,external_wp_element_namespaceObject.useCallback)(show => {
  21760. if (show) {
  21761. showInsertionPoint(destinationRootClientId, destinationIndex);
  21762. } else {
  21763. hideInsertionPoint();
  21764. }
  21765. }, [showInsertionPoint, hideInsertionPoint, destinationRootClientId, destinationIndex]);
  21766. return [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint];
  21767. }
  21768. /* harmony default export */ var use_insertion_point = (useInsertionPoint);
  21769. // EXTERNAL MODULE: ./node_modules/remove-accents/index.js
  21770. var remove_accents = __webpack_require__(4793);
  21771. var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents);
  21772. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-items.js
  21773. /**
  21774. * External dependencies
  21775. */
  21776. // Default search helpers.
  21777. const defaultGetName = item => item.name || '';
  21778. const defaultGetTitle = item => item.title;
  21779. const defaultGetDescription = item => item.description || '';
  21780. const defaultGetKeywords = item => item.keywords || [];
  21781. const defaultGetCategory = item => item.category;
  21782. const defaultGetCollection = () => null;
  21783. /**
  21784. * Sanitizes the search input string.
  21785. *
  21786. * @param {string} input The search input to normalize.
  21787. *
  21788. * @return {string} The normalized search input.
  21789. */
  21790. function normalizeSearchInput() {
  21791. let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  21792. // Disregard diacritics.
  21793. // Input: "média"
  21794. input = remove_accents_default()(input); // Accommodate leading slash, matching autocomplete expectations.
  21795. // Input: "/media"
  21796. input = input.replace(/^\//, ''); // Lowercase.
  21797. // Input: "MEDIA"
  21798. input = input.toLowerCase();
  21799. return input;
  21800. }
  21801. /**
  21802. * Converts the search term into a list of normalized terms.
  21803. *
  21804. * @param {string} input The search term to normalize.
  21805. *
  21806. * @return {string[]} The normalized list of search terms.
  21807. */
  21808. const getNormalizedSearchTerms = function () {
  21809. let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  21810. return (0,external_lodash_namespaceObject.words)(normalizeSearchInput(input));
  21811. };
  21812. const removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
  21813. return unmatchedTerms.filter(term => !getNormalizedSearchTerms(unprocessedTerms).some(unprocessedTerm => unprocessedTerm.includes(term)));
  21814. };
  21815. const searchBlockItems = (items, categories, collections, searchInput) => {
  21816. const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
  21817. if (normalizedSearchTerms.length === 0) {
  21818. return items;
  21819. }
  21820. const config = {
  21821. getCategory: item => {
  21822. var _find;
  21823. return (_find = (0,external_lodash_namespaceObject.find)(categories, {
  21824. slug: item.category
  21825. })) === null || _find === void 0 ? void 0 : _find.title;
  21826. },
  21827. getCollection: item => {
  21828. var _collections$item$nam;
  21829. return (_collections$item$nam = collections[item.name.split('/')[0]]) === null || _collections$item$nam === void 0 ? void 0 : _collections$item$nam.title;
  21830. }
  21831. };
  21832. return searchItems(items, searchInput, config);
  21833. };
  21834. /**
  21835. * Filters an item list given a search term.
  21836. *
  21837. * @param {Array} items Item list
  21838. * @param {string} searchInput Search input.
  21839. * @param {Object} config Search Config.
  21840. *
  21841. * @return {Array} Filtered item list.
  21842. */
  21843. const searchItems = function () {
  21844. let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  21845. let searchInput = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  21846. let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  21847. const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
  21848. if (normalizedSearchTerms.length === 0) {
  21849. return items;
  21850. }
  21851. const rankedItems = items.map(item => {
  21852. return [item, getItemSearchRank(item, searchInput, config)];
  21853. }).filter(_ref => {
  21854. let [, rank] = _ref;
  21855. return rank > 0;
  21856. });
  21857. rankedItems.sort((_ref2, _ref3) => {
  21858. let [, rank1] = _ref2;
  21859. let [, rank2] = _ref3;
  21860. return rank2 - rank1;
  21861. });
  21862. return rankedItems.map(_ref4 => {
  21863. let [item] = _ref4;
  21864. return item;
  21865. });
  21866. };
  21867. /**
  21868. * Get the search rank for a given item and a specific search term.
  21869. * The better the match, the higher the rank.
  21870. * If the rank equals 0, it should be excluded from the results.
  21871. *
  21872. * @param {Object} item Item to filter.
  21873. * @param {string} searchTerm Search term.
  21874. * @param {Object} config Search Config.
  21875. *
  21876. * @return {number} Search Rank.
  21877. */
  21878. function getItemSearchRank(item, searchTerm) {
  21879. let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  21880. const {
  21881. getName = defaultGetName,
  21882. getTitle = defaultGetTitle,
  21883. getDescription = defaultGetDescription,
  21884. getKeywords = defaultGetKeywords,
  21885. getCategory = defaultGetCategory,
  21886. getCollection = defaultGetCollection
  21887. } = config;
  21888. const name = getName(item);
  21889. const title = getTitle(item);
  21890. const description = getDescription(item);
  21891. const keywords = getKeywords(item);
  21892. const category = getCategory(item);
  21893. const collection = getCollection(item);
  21894. const normalizedSearchInput = normalizeSearchInput(searchTerm);
  21895. const normalizedTitle = normalizeSearchInput(title);
  21896. let rank = 0; // Prefers exact matches
  21897. // Then prefers if the beginning of the title matches the search term
  21898. // name, keywords, categories, collection, variations match come later.
  21899. if (normalizedSearchInput === normalizedTitle) {
  21900. rank += 30;
  21901. } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
  21902. rank += 20;
  21903. } else {
  21904. const terms = [name, title, description, ...keywords, category, collection].join(' ');
  21905. const normalizedSearchTerms = (0,external_lodash_namespaceObject.words)(normalizedSearchInput);
  21906. const unmatchedTerms = removeMatchingTerms(normalizedSearchTerms, terms);
  21907. if (unmatchedTerms.length === 0) {
  21908. rank += 10;
  21909. }
  21910. } // Give a better rank to "core" namespaced items.
  21911. if (rank !== 0 && name.startsWith('core/')) {
  21912. const isCoreBlockVariation = name !== item.id; // Give a bit better rank to "core" blocks over "core" block variations.
  21913. rank += isCoreBlockVariation ? 1 : 2;
  21914. }
  21915. return rank;
  21916. }
  21917. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-explorer/patterns-list.js
  21918. /**
  21919. * WordPress dependencies
  21920. */
  21921. /**
  21922. * Internal dependencies
  21923. */
  21924. const INITIAL_INSERTER_RESULTS = 2;
  21925. function PatternsListHeader(_ref) {
  21926. let {
  21927. filterValue,
  21928. filteredBlockPatternsLength
  21929. } = _ref;
  21930. if (!filterValue) {
  21931. return null;
  21932. }
  21933. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
  21934. level: 2,
  21935. lineHeight: '48px',
  21936. className: "block-editor-block-patterns-explorer__search-results-count"
  21937. }, (0,external_wp_i18n_namespaceObject.sprintf)(
  21938. /* translators: %d: number of patterns. %s: block pattern search query */
  21939. (0,external_wp_i18n_namespaceObject._n)('%1$d pattern found for "%2$s"', '%1$d patterns found for "%2$s"', filteredBlockPatternsLength), filteredBlockPatternsLength, filterValue));
  21940. }
  21941. function PatternList(_ref2) {
  21942. let {
  21943. filterValue,
  21944. selectedCategory,
  21945. patternCategories
  21946. } = _ref2;
  21947. const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
  21948. const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
  21949. shouldFocusBlock: true
  21950. });
  21951. const [allPatterns,, onSelectBlockPattern] = use_patterns_state(onInsertBlocks, destinationRootClientId);
  21952. const registeredPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => patternCategories.map(patternCategory => patternCategory.name), [patternCategories]);
  21953. const filteredBlockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => {
  21954. if (!filterValue) {
  21955. return allPatterns.filter(pattern => {
  21956. var _pattern$categories, _pattern$categories2;
  21957. return selectedCategory === 'uncategorized' ? !((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length) || pattern.categories.every(category => !registeredPatternCategories.includes(category)) : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory);
  21958. });
  21959. }
  21960. return searchItems(allPatterns, filterValue);
  21961. }, [filterValue, selectedCategory, allPatterns]); // Announce search results on change.
  21962. (0,external_wp_element_namespaceObject.useEffect)(() => {
  21963. if (!filterValue) {
  21964. return;
  21965. }
  21966. const count = filteredBlockPatterns.length;
  21967. const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
  21968. /* translators: %d: number of results. */
  21969. (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
  21970. debouncedSpeak(resultsFoundMessage);
  21971. }, [filterValue, debouncedSpeak]);
  21972. const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(filteredBlockPatterns, {
  21973. step: INITIAL_INSERTER_RESULTS
  21974. });
  21975. const hasItems = !!(filteredBlockPatterns !== null && filteredBlockPatterns !== void 0 && filteredBlockPatterns.length);
  21976. return (0,external_wp_element_namespaceObject.createElement)("div", {
  21977. className: "block-editor-block-patterns-explorer__list"
  21978. }, hasItems && (0,external_wp_element_namespaceObject.createElement)(PatternsListHeader, {
  21979. filterValue: filterValue,
  21980. filteredBlockPatternsLength: filteredBlockPatterns.length
  21981. }), (0,external_wp_element_namespaceObject.createElement)(inserter_listbox, null, !hasItems && (0,external_wp_element_namespaceObject.createElement)(no_results, null), hasItems && (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, {
  21982. shownPatterns: currentShownPatterns,
  21983. blockPatterns: filteredBlockPatterns,
  21984. onClickPattern: onSelectBlockPattern,
  21985. isDraggable: false
  21986. })));
  21987. }
  21988. /* harmony default export */ var patterns_list = (PatternList);
  21989. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-explorer/explorer.js
  21990. /**
  21991. * WordPress dependencies
  21992. */
  21993. /**
  21994. * Internal dependencies
  21995. */
  21996. function PatternsExplorer(_ref) {
  21997. let {
  21998. initialCategory,
  21999. patternCategories
  22000. } = _ref;
  22001. const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
  22002. const [selectedCategory, setSelectedCategory] = (0,external_wp_element_namespaceObject.useState)(initialCategory === null || initialCategory === void 0 ? void 0 : initialCategory.name);
  22003. return (0,external_wp_element_namespaceObject.createElement)("div", {
  22004. className: "block-editor-block-patterns-explorer"
  22005. }, (0,external_wp_element_namespaceObject.createElement)(sidebar, {
  22006. selectedCategory: selectedCategory,
  22007. patternCategories: patternCategories,
  22008. onClickCategory: setSelectedCategory,
  22009. filterValue: filterValue,
  22010. setFilterValue: setFilterValue
  22011. }), (0,external_wp_element_namespaceObject.createElement)(patterns_list, {
  22012. filterValue: filterValue,
  22013. selectedCategory: selectedCategory,
  22014. patternCategories: patternCategories
  22015. }));
  22016. }
  22017. function PatternsExplorerModal(_ref2) {
  22018. let {
  22019. onModalClose,
  22020. ...restProps
  22021. } = _ref2;
  22022. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
  22023. title: (0,external_wp_i18n_namespaceObject.__)('Patterns'),
  22024. closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
  22025. onRequestClose: onModalClose,
  22026. isFullScreen: true
  22027. }, (0,external_wp_element_namespaceObject.createElement)(PatternsExplorer, restProps));
  22028. }
  22029. /* harmony default export */ var explorer = (PatternsExplorerModal);
  22030. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-tab.js
  22031. /**
  22032. * WordPress dependencies
  22033. */
  22034. /**
  22035. * Internal dependencies
  22036. */
  22037. function BlockPatternsCategory(_ref) {
  22038. let {
  22039. rootClientId,
  22040. onInsert,
  22041. selectedCategory,
  22042. populatedCategories
  22043. } = _ref;
  22044. const [allPatterns,, onClick] = use_patterns_state(onInsert, rootClientId);
  22045. const getPatternIndex = (0,external_wp_element_namespaceObject.useCallback)(pattern => {
  22046. var _pattern$categories;
  22047. if (!((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length)) {
  22048. return Infinity;
  22049. }
  22050. const indexedCategories = populatedCategories.reduce((accumulator, _ref2, index) => {
  22051. let {
  22052. name
  22053. } = _ref2;
  22054. accumulator[name] = index;
  22055. return accumulator;
  22056. }, {});
  22057. return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity));
  22058. }, [populatedCategories]);
  22059. const currentCategoryPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => allPatterns.filter(pattern => {
  22060. var _pattern$categories2;
  22061. return selectedCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory.name);
  22062. }), [allPatterns, selectedCategory]); // Ordering the patterns is important for the async rendering.
  22063. const orderedPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => {
  22064. return currentCategoryPatterns.sort((a, b) => {
  22065. return getPatternIndex(a) - getPatternIndex(b);
  22066. });
  22067. }, [currentCategoryPatterns, getPatternIndex]);
  22068. const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(orderedPatterns);
  22069. if (!currentCategoryPatterns.length) {
  22070. return null;
  22071. }
  22072. return (0,external_wp_element_namespaceObject.createElement)("div", {
  22073. className: "block-editor-inserter__panel-content"
  22074. }, (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, {
  22075. shownPatterns: currentShownPatterns,
  22076. blockPatterns: currentCategoryPatterns,
  22077. onClickPattern: onClick,
  22078. label: selectedCategory.label,
  22079. orientation: "vertical",
  22080. isDraggable: true
  22081. }));
  22082. }
  22083. function BlockPatternsTabs(_ref3) {
  22084. let {
  22085. rootClientId,
  22086. onInsert,
  22087. onClickCategory,
  22088. selectedCategory
  22089. } = _ref3;
  22090. const [showPatternsExplorer, setShowPatternsExplorer] = (0,external_wp_element_namespaceObject.useState)(false);
  22091. const [allPatterns, allCategories] = use_patterns_state();
  22092. const hasRegisteredCategory = (0,external_wp_element_namespaceObject.useCallback)(pattern => {
  22093. if (!pattern.categories || !pattern.categories.length) {
  22094. return false;
  22095. }
  22096. return pattern.categories.some(cat => allCategories.some(category => category.name === cat));
  22097. }, [allCategories]); // Remove any empty categories.
  22098. const populatedCategories = (0,external_wp_element_namespaceObject.useMemo)(() => {
  22099. const categories = allCategories.filter(category => allPatterns.some(pattern => {
  22100. var _pattern$categories3;
  22101. return (_pattern$categories3 = pattern.categories) === null || _pattern$categories3 === void 0 ? void 0 : _pattern$categories3.includes(category.name);
  22102. })).sort((_ref4, _ref5) => {
  22103. let {
  22104. name: currentName
  22105. } = _ref4;
  22106. let {
  22107. name: nextName
  22108. } = _ref5;
  22109. if (![currentName, nextName].includes('featured')) {
  22110. return 0;
  22111. }
  22112. return currentName === 'featured' ? -1 : 1;
  22113. });
  22114. if (allPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
  22115. categories.push({
  22116. name: 'uncategorized',
  22117. label: (0,external_wp_i18n_namespaceObject._x)('Uncategorized')
  22118. });
  22119. }
  22120. return categories;
  22121. }, [allPatterns, allCategories]);
  22122. const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
  22123. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(pattern_panel, {
  22124. selectedCategory: patternCategory,
  22125. patternCategories: populatedCategories,
  22126. onClickCategory: onClickCategory,
  22127. openPatternExplorer: () => setShowPatternsExplorer(true)
  22128. }), !showPatternsExplorer && (0,external_wp_element_namespaceObject.createElement)(BlockPatternsCategory, {
  22129. rootClientId: rootClientId,
  22130. onInsert: onInsert,
  22131. selectedCategory: patternCategory,
  22132. populatedCategories: populatedCategories
  22133. }), showPatternsExplorer && (0,external_wp_element_namespaceObject.createElement)(explorer, {
  22134. initialCategory: patternCategory,
  22135. patternCategories: populatedCategories,
  22136. onModalClose: () => setShowPatternsExplorer(false)
  22137. }));
  22138. }
  22139. /* harmony default export */ var block_patterns_tab = (BlockPatternsTabs);
  22140. ;// CONCATENATED MODULE: external ["wp","url"]
  22141. var external_wp_url_namespaceObject = window["wp"]["url"];
  22142. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/reusable-blocks-tab.js
  22143. /**
  22144. * WordPress dependencies
  22145. */
  22146. /**
  22147. * Internal dependencies
  22148. */
  22149. function ReusableBlocksList(_ref) {
  22150. let {
  22151. onHover,
  22152. onInsert,
  22153. rootClientId
  22154. } = _ref;
  22155. const [items,,, onSelectItem] = use_block_types_state(rootClientId, onInsert);
  22156. const filteredItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
  22157. return items.filter(_ref2 => {
  22158. let {
  22159. category
  22160. } = _ref2;
  22161. return category === 'reusable';
  22162. });
  22163. }, [items]);
  22164. if (filteredItems.length === 0) {
  22165. return (0,external_wp_element_namespaceObject.createElement)(no_results, null);
  22166. }
  22167. return (0,external_wp_element_namespaceObject.createElement)(panel, {
  22168. title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
  22169. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  22170. items: filteredItems,
  22171. onSelect: onSelectItem,
  22172. onHover: onHover,
  22173. label: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
  22174. }));
  22175. } // The unwrapped component is only exported for use by unit tests.
  22176. /**
  22177. * List of reusable blocks shown in the "Reusable" tab of the inserter.
  22178. *
  22179. * @param {Object} props Component props.
  22180. * @param {?string} props.rootClientId Client id of block to insert into.
  22181. * @param {Function} props.onInsert Callback to run when item is inserted.
  22182. * @param {Function} props.onHover Callback to run when item is hovered.
  22183. *
  22184. * @return {WPComponent} The component.
  22185. */
  22186. function ReusableBlocksTab(_ref3) {
  22187. let {
  22188. rootClientId,
  22189. onInsert,
  22190. onHover
  22191. } = _ref3;
  22192. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ReusableBlocksList, {
  22193. onHover: onHover,
  22194. onInsert: onInsert,
  22195. rootClientId: rootClientId
  22196. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  22197. className: "block-editor-inserter__manage-reusable-blocks-container"
  22198. }, (0,external_wp_element_namespaceObject.createElement)("a", {
  22199. className: "block-editor-inserter__manage-reusable-blocks",
  22200. href: (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
  22201. post_type: 'wp_block'
  22202. })
  22203. }, (0,external_wp_i18n_namespaceObject.__)('Manage Reusable blocks'))));
  22204. }
  22205. /* harmony default export */ var reusable_blocks_tab = (ReusableBlocksTab);
  22206. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-menu-extension/index.js
  22207. /**
  22208. * WordPress dependencies
  22209. */
  22210. const {
  22211. Fill: __unstableInserterMenuExtension,
  22212. Slot
  22213. } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableInserterMenuExtension');
  22214. __unstableInserterMenuExtension.Slot = Slot;
  22215. /* harmony default export */ var inserter_menu_extension = (__unstableInserterMenuExtension);
  22216. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-results.js
  22217. /**
  22218. * External dependencies
  22219. */
  22220. /**
  22221. * WordPress dependencies
  22222. */
  22223. /**
  22224. * Internal dependencies
  22225. */
  22226. const search_results_INITIAL_INSERTER_RESULTS = 9;
  22227. /**
  22228. * Shared reference to an empty array for cases where it is important to avoid
  22229. * returning a new array reference on every invocation and rerendering the component.
  22230. *
  22231. * @type {Array}
  22232. */
  22233. const search_results_EMPTY_ARRAY = [];
  22234. function InserterSearchResults(_ref) {
  22235. let {
  22236. filterValue,
  22237. onSelect,
  22238. onHover,
  22239. rootClientId,
  22240. clientId,
  22241. isAppender,
  22242. __experimentalInsertionIndex,
  22243. maxBlockPatterns,
  22244. maxBlockTypes,
  22245. showBlockDirectory = false,
  22246. isDraggable = true,
  22247. shouldFocusBlock = true,
  22248. prioritizePatterns
  22249. } = _ref;
  22250. const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
  22251. const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
  22252. onSelect,
  22253. rootClientId,
  22254. clientId,
  22255. isAppender,
  22256. insertionIndex: __experimentalInsertionIndex,
  22257. shouldFocusBlock
  22258. });
  22259. const [blockTypes, blockTypeCategories, blockTypeCollections, onSelectBlockType] = use_block_types_state(destinationRootClientId, onInsertBlocks);
  22260. const [patterns,, onSelectBlockPattern] = use_patterns_state(onInsertBlocks, destinationRootClientId);
  22261. const filteredBlockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => {
  22262. if (maxBlockPatterns === 0) {
  22263. return [];
  22264. }
  22265. const results = searchItems(patterns, filterValue);
  22266. return maxBlockPatterns !== undefined ? results.slice(0, maxBlockPatterns) : results;
  22267. }, [filterValue, patterns, maxBlockPatterns]);
  22268. let maxBlockTypesToShow = maxBlockTypes;
  22269. if (prioritizePatterns && filteredBlockPatterns.length > 2) {
  22270. maxBlockTypesToShow = 0;
  22271. }
  22272. const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
  22273. if (maxBlockTypesToShow === 0) {
  22274. return [];
  22275. }
  22276. const results = searchBlockItems((0,external_lodash_namespaceObject.orderBy)(blockTypes, ['frecency'], ['desc']), blockTypeCategories, blockTypeCollections, filterValue);
  22277. return maxBlockTypesToShow !== undefined ? results.slice(0, maxBlockTypesToShow) : results;
  22278. }, [filterValue, blockTypes, blockTypeCategories, blockTypeCollections, maxBlockTypes]); // Announce search results on change.
  22279. (0,external_wp_element_namespaceObject.useEffect)(() => {
  22280. if (!filterValue) {
  22281. return;
  22282. }
  22283. const count = filteredBlockTypes.length + filteredBlockPatterns.length;
  22284. const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
  22285. /* translators: %d: number of results. */
  22286. (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
  22287. debouncedSpeak(resultsFoundMessage);
  22288. }, [filterValue, debouncedSpeak]);
  22289. const currentShownBlockTypes = (0,external_wp_compose_namespaceObject.useAsyncList)(filteredBlockTypes, {
  22290. step: search_results_INITIAL_INSERTER_RESULTS
  22291. });
  22292. const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(currentShownBlockTypes.length === filteredBlockTypes.length ? filteredBlockPatterns : search_results_EMPTY_ARRAY);
  22293. const hasItems = !(0,external_lodash_namespaceObject.isEmpty)(filteredBlockTypes) || !(0,external_lodash_namespaceObject.isEmpty)(filteredBlockPatterns);
  22294. const blocksUI = !!filteredBlockTypes.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
  22295. title: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Blocks'))
  22296. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  22297. items: currentShownBlockTypes,
  22298. onSelect: onSelectBlockType,
  22299. onHover: onHover,
  22300. label: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
  22301. isDraggable: isDraggable
  22302. }));
  22303. const patternsUI = !!filteredBlockPatterns.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
  22304. title: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Block Patterns'))
  22305. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  22306. className: "block-editor-inserter__quick-inserter-patterns"
  22307. }, (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, {
  22308. shownPatterns: currentShownPatterns,
  22309. blockPatterns: filteredBlockPatterns,
  22310. onClickPattern: onSelectBlockPattern,
  22311. isDraggable: isDraggable
  22312. })));
  22313. return (0,external_wp_element_namespaceObject.createElement)(inserter_listbox, null, !showBlockDirectory && !hasItems && (0,external_wp_element_namespaceObject.createElement)(no_results, null), prioritizePatterns ? patternsUI : blocksUI, !!filteredBlockTypes.length && !!filteredBlockPatterns.length && (0,external_wp_element_namespaceObject.createElement)("div", {
  22314. className: "block-editor-inserter__quick-inserter-separator"
  22315. }), prioritizePatterns ? blocksUI : patternsUI, showBlockDirectory && (0,external_wp_element_namespaceObject.createElement)(inserter_menu_extension.Slot, {
  22316. fillProps: {
  22317. onSelect: onSelectBlockType,
  22318. onHover,
  22319. filterValue,
  22320. hasItems,
  22321. rootClientId: destinationRootClientId
  22322. }
  22323. }, fills => {
  22324. if (fills.length) {
  22325. return fills;
  22326. }
  22327. if (!hasItems) {
  22328. return (0,external_wp_element_namespaceObject.createElement)(no_results, null);
  22329. }
  22330. return null;
  22331. }));
  22332. }
  22333. /* harmony default export */ var search_results = (InserterSearchResults);
  22334. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/tabs.js
  22335. /**
  22336. * WordPress dependencies
  22337. */
  22338. const blocksTab = {
  22339. name: 'blocks',
  22340. /* translators: Blocks tab title in the block inserter. */
  22341. title: (0,external_wp_i18n_namespaceObject.__)('Blocks')
  22342. };
  22343. const patternsTab = {
  22344. name: 'patterns',
  22345. /* translators: Patterns tab title in the block inserter. */
  22346. title: (0,external_wp_i18n_namespaceObject.__)('Patterns')
  22347. };
  22348. const reusableBlocksTab = {
  22349. name: 'reusable',
  22350. /* translators: Reusable blocks tab title in the block inserter. */
  22351. title: (0,external_wp_i18n_namespaceObject.__)('Reusable')
  22352. };
  22353. function InserterTabs(_ref) {
  22354. let {
  22355. children,
  22356. showPatterns = false,
  22357. showReusableBlocks = false,
  22358. onSelect,
  22359. prioritizePatterns
  22360. } = _ref;
  22361. const tabs = (0,external_wp_element_namespaceObject.useMemo)(() => {
  22362. const tempTabs = [];
  22363. if (prioritizePatterns && showPatterns) {
  22364. tempTabs.push(patternsTab);
  22365. }
  22366. tempTabs.push(blocksTab);
  22367. if (!prioritizePatterns && showPatterns) {
  22368. tempTabs.push(patternsTab);
  22369. }
  22370. if (showReusableBlocks) {
  22371. tempTabs.push(reusableBlocksTab);
  22372. }
  22373. return tempTabs;
  22374. }, [prioritizePatterns, blocksTab, showPatterns, patternsTab, showReusableBlocks, reusableBlocksTab]);
  22375. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
  22376. className: "block-editor-inserter__tabs",
  22377. tabs: tabs,
  22378. onSelect: onSelect
  22379. }, children);
  22380. }
  22381. /* harmony default export */ var tabs = (InserterTabs);
  22382. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/menu.js
  22383. /**
  22384. * External dependencies
  22385. */
  22386. /**
  22387. * WordPress dependencies
  22388. */
  22389. /**
  22390. * Internal dependencies
  22391. */
  22392. function InserterMenu(_ref, ref) {
  22393. let {
  22394. rootClientId,
  22395. clientId,
  22396. isAppender,
  22397. __experimentalInsertionIndex,
  22398. onSelect,
  22399. showInserterHelpPanel,
  22400. showMostUsedBlocks,
  22401. __experimentalFilterValue = '',
  22402. shouldFocusBlock = true,
  22403. prioritizePatterns
  22404. } = _ref;
  22405. const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(__experimentalFilterValue);
  22406. const [hoveredItem, setHoveredItem] = (0,external_wp_element_namespaceObject.useState)(null);
  22407. const [selectedPatternCategory, setSelectedPatternCategory] = (0,external_wp_element_namespaceObject.useState)(null);
  22408. const [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint] = use_insertion_point({
  22409. rootClientId,
  22410. clientId,
  22411. isAppender,
  22412. insertionIndex: __experimentalInsertionIndex,
  22413. shouldFocusBlock
  22414. });
  22415. const {
  22416. showPatterns,
  22417. hasReusableBlocks
  22418. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  22419. var _getSettings$__experi;
  22420. const {
  22421. __experimentalGetAllowedPatterns,
  22422. getSettings
  22423. } = select(store);
  22424. return {
  22425. showPatterns: !!__experimentalGetAllowedPatterns(destinationRootClientId).length,
  22426. hasReusableBlocks: !!((_getSettings$__experi = getSettings().__experimentalReusableBlocks) !== null && _getSettings$__experi !== void 0 && _getSettings$__experi.length)
  22427. };
  22428. }, [destinationRootClientId]);
  22429. const onInsert = (0,external_wp_element_namespaceObject.useCallback)((blocks, meta, shouldForceFocusBlock) => {
  22430. onInsertBlocks(blocks, meta, shouldForceFocusBlock);
  22431. onSelect();
  22432. }, [onInsertBlocks, onSelect]);
  22433. const onInsertPattern = (0,external_wp_element_namespaceObject.useCallback)((blocks, patternName) => {
  22434. onInsertBlocks(blocks, {
  22435. patternName
  22436. });
  22437. onSelect();
  22438. }, [onInsertBlocks, onSelect]);
  22439. const onHover = (0,external_wp_element_namespaceObject.useCallback)(item => {
  22440. onToggleInsertionPoint(!!item);
  22441. setHoveredItem(item);
  22442. }, [onToggleInsertionPoint, setHoveredItem]);
  22443. const onClickPatternCategory = (0,external_wp_element_namespaceObject.useCallback)(patternCategory => {
  22444. setSelectedPatternCategory(patternCategory);
  22445. }, [setSelectedPatternCategory]);
  22446. const blocksTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  22447. className: "block-editor-inserter__block-list"
  22448. }, (0,external_wp_element_namespaceObject.createElement)(block_types_tab, {
  22449. rootClientId: destinationRootClientId,
  22450. onInsert: onInsert,
  22451. onHover: onHover,
  22452. showMostUsedBlocks: showMostUsedBlocks
  22453. })), showInserterHelpPanel && (0,external_wp_element_namespaceObject.createElement)("div", {
  22454. className: "block-editor-inserter__tips"
  22455. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  22456. as: "h2"
  22457. }, (0,external_wp_i18n_namespaceObject.__)('A tip for using the block editor')), (0,external_wp_element_namespaceObject.createElement)(tips, null))), [destinationRootClientId, onInsert, onHover, filterValue, showMostUsedBlocks, showInserterHelpPanel]);
  22458. const patternsTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(block_patterns_tab, {
  22459. rootClientId: destinationRootClientId,
  22460. onInsert: onInsertPattern,
  22461. onClickCategory: onClickPatternCategory,
  22462. selectedCategory: selectedPatternCategory
  22463. }), [destinationRootClientId, onInsertPattern, onClickPatternCategory, selectedPatternCategory]);
  22464. const reusableBlocksTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(reusable_blocks_tab, {
  22465. rootClientId: destinationRootClientId,
  22466. onInsert: onInsert,
  22467. onHover: onHover
  22468. }), [destinationRootClientId, onInsert, onHover]);
  22469. const getCurrentTab = (0,external_wp_element_namespaceObject.useCallback)(tab => {
  22470. if (tab.name === 'blocks') {
  22471. return blocksTab;
  22472. } else if (tab.name === 'patterns') {
  22473. return patternsTab;
  22474. }
  22475. return reusableBlocksTab;
  22476. }, [blocksTab, patternsTab, reusableBlocksTab]);
  22477. const searchRef = (0,external_wp_element_namespaceObject.useRef)();
  22478. (0,external_wp_element_namespaceObject.useImperativeHandle)(ref, () => ({
  22479. focusSearch: () => {
  22480. searchRef.current.focus();
  22481. }
  22482. }));
  22483. const showAsTabs = !filterValue && (showPatterns || hasReusableBlocks);
  22484. return (0,external_wp_element_namespaceObject.createElement)("div", {
  22485. className: "block-editor-inserter__menu"
  22486. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  22487. className: classnames_default()('block-editor-inserter__main-area', {
  22488. 'show-as-tabs': showAsTabs
  22489. })
  22490. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
  22491. className: "block-editor-inserter__search",
  22492. onChange: value => {
  22493. if (hoveredItem) setHoveredItem(null);
  22494. setFilterValue(value);
  22495. },
  22496. value: filterValue,
  22497. label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks and patterns'),
  22498. placeholder: (0,external_wp_i18n_namespaceObject.__)('Search'),
  22499. ref: searchRef
  22500. }), !!filterValue && (0,external_wp_element_namespaceObject.createElement)("div", {
  22501. className: "block-editor-inserter__no-tab-container"
  22502. }, (0,external_wp_element_namespaceObject.createElement)(search_results, {
  22503. filterValue: filterValue,
  22504. onSelect: onSelect,
  22505. onHover: onHover,
  22506. rootClientId: rootClientId,
  22507. clientId: clientId,
  22508. isAppender: isAppender,
  22509. __experimentalInsertionIndex: __experimentalInsertionIndex,
  22510. showBlockDirectory: true,
  22511. shouldFocusBlock: shouldFocusBlock
  22512. })), showAsTabs && (0,external_wp_element_namespaceObject.createElement)(tabs, {
  22513. showPatterns: showPatterns,
  22514. showReusableBlocks: hasReusableBlocks,
  22515. prioritizePatterns: prioritizePatterns
  22516. }, getCurrentTab), !filterValue && !showAsTabs && (0,external_wp_element_namespaceObject.createElement)("div", {
  22517. className: "block-editor-inserter__no-tab-container"
  22518. }, blocksTab)), showInserterHelpPanel && hoveredItem && (0,external_wp_element_namespaceObject.createElement)(preview_panel, {
  22519. item: hoveredItem
  22520. }));
  22521. }
  22522. /* harmony default export */ var menu = ((0,external_wp_element_namespaceObject.forwardRef)(InserterMenu));
  22523. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/quick-inserter.js
  22524. /**
  22525. * External dependencies
  22526. */
  22527. /**
  22528. * WordPress dependencies
  22529. */
  22530. /**
  22531. * Internal dependencies
  22532. */
  22533. const SEARCH_THRESHOLD = 6;
  22534. const SHOWN_BLOCK_TYPES = 6;
  22535. const SHOWN_BLOCK_PATTERNS = 2;
  22536. const SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION = 4;
  22537. function QuickInserter(_ref) {
  22538. let {
  22539. onSelect,
  22540. rootClientId,
  22541. clientId,
  22542. isAppender,
  22543. prioritizePatterns
  22544. } = _ref;
  22545. const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
  22546. const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
  22547. onSelect,
  22548. rootClientId,
  22549. clientId,
  22550. isAppender
  22551. });
  22552. const [blockTypes] = use_block_types_state(destinationRootClientId, onInsertBlocks);
  22553. const [patterns] = use_patterns_state(onInsertBlocks, destinationRootClientId);
  22554. const {
  22555. setInserterIsOpened,
  22556. insertionIndex
  22557. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  22558. const {
  22559. getSettings,
  22560. getBlockIndex,
  22561. getBlockCount
  22562. } = select(store);
  22563. const settings = getSettings();
  22564. const index = getBlockIndex(clientId);
  22565. const blockCount = getBlockCount();
  22566. return {
  22567. setInserterIsOpened: settings.__experimentalSetIsInserterOpened,
  22568. insertionIndex: index === -1 ? blockCount : index
  22569. };
  22570. }, [clientId]);
  22571. const showPatterns = patterns.length && (!!filterValue || prioritizePatterns);
  22572. const showSearch = showPatterns && patterns.length > SEARCH_THRESHOLD || blockTypes.length > SEARCH_THRESHOLD;
  22573. (0,external_wp_element_namespaceObject.useEffect)(() => {
  22574. if (setInserterIsOpened) {
  22575. setInserterIsOpened(false);
  22576. }
  22577. }, [setInserterIsOpened]); // When clicking Browse All select the appropriate block so as
  22578. // the insertion point can work as expected.
  22579. const onBrowseAll = () => {
  22580. setInserterIsOpened({
  22581. rootClientId,
  22582. insertionIndex,
  22583. filterValue
  22584. });
  22585. };
  22586. let maxBlockPatterns = 0;
  22587. if (showPatterns) {
  22588. maxBlockPatterns = prioritizePatterns ? SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION : SHOWN_BLOCK_PATTERNS;
  22589. }
  22590. return (0,external_wp_element_namespaceObject.createElement)("div", {
  22591. className: classnames_default()('block-editor-inserter__quick-inserter', {
  22592. 'has-search': showSearch,
  22593. 'has-expand': setInserterIsOpened
  22594. })
  22595. }, showSearch && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
  22596. className: "block-editor-inserter__search",
  22597. value: filterValue,
  22598. onChange: value => {
  22599. setFilterValue(value);
  22600. },
  22601. label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks and patterns'),
  22602. placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
  22603. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  22604. className: "block-editor-inserter__quick-inserter-results"
  22605. }, (0,external_wp_element_namespaceObject.createElement)(search_results, {
  22606. filterValue: filterValue,
  22607. onSelect: onSelect,
  22608. rootClientId: rootClientId,
  22609. clientId: clientId,
  22610. isAppender: isAppender,
  22611. maxBlockPatterns: maxBlockPatterns,
  22612. maxBlockTypes: SHOWN_BLOCK_TYPES,
  22613. isDraggable: false,
  22614. prioritizePatterns: prioritizePatterns
  22615. })), setInserterIsOpened && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  22616. className: "block-editor-inserter__quick-inserter-expand",
  22617. onClick: onBrowseAll,
  22618. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Browse all. This will open the main inserter panel in the editor toolbar.')
  22619. }, (0,external_wp_i18n_namespaceObject.__)('Browse all')));
  22620. }
  22621. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/index.js
  22622. /**
  22623. * External dependencies
  22624. */
  22625. /**
  22626. * WordPress dependencies
  22627. */
  22628. /**
  22629. * Internal dependencies
  22630. */
  22631. const defaultRenderToggle = _ref => {
  22632. let {
  22633. onToggle,
  22634. disabled,
  22635. isOpen,
  22636. blockTitle,
  22637. hasSingleBlockType,
  22638. toggleProps = {},
  22639. prioritizePatterns
  22640. } = _ref;
  22641. let label;
  22642. if (hasSingleBlockType) {
  22643. label = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block when there is only one
  22644. (0,external_wp_i18n_namespaceObject._x)('Add %s', 'directly add the only allowed block'), blockTitle);
  22645. } else if (prioritizePatterns) {
  22646. label = (0,external_wp_i18n_namespaceObject.__)('Add pattern');
  22647. } else {
  22648. label = (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button');
  22649. }
  22650. const {
  22651. onClick,
  22652. ...rest
  22653. } = toggleProps; // Handle both onClick functions from the toggle and the parent component.
  22654. function handleClick(event) {
  22655. if (onToggle) {
  22656. onToggle(event);
  22657. }
  22658. if (onClick) {
  22659. onClick(event);
  22660. }
  22661. }
  22662. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
  22663. icon: library_plus,
  22664. label: label,
  22665. tooltipPosition: "bottom",
  22666. onClick: handleClick,
  22667. className: "block-editor-inserter__toggle",
  22668. "aria-haspopup": !hasSingleBlockType ? 'true' : false,
  22669. "aria-expanded": !hasSingleBlockType ? isOpen : false,
  22670. disabled: disabled
  22671. }, rest));
  22672. };
  22673. class Inserter extends external_wp_element_namespaceObject.Component {
  22674. constructor() {
  22675. super(...arguments);
  22676. this.onToggle = this.onToggle.bind(this);
  22677. this.renderToggle = this.renderToggle.bind(this);
  22678. this.renderContent = this.renderContent.bind(this);
  22679. }
  22680. onToggle(isOpen) {
  22681. const {
  22682. onToggle
  22683. } = this.props; // Surface toggle callback to parent component.
  22684. if (onToggle) {
  22685. onToggle(isOpen);
  22686. }
  22687. }
  22688. /**
  22689. * Render callback to display Dropdown toggle element.
  22690. *
  22691. * @param {Object} options
  22692. * @param {Function} options.onToggle Callback to invoke when toggle is
  22693. * pressed.
  22694. * @param {boolean} options.isOpen Whether dropdown is currently open.
  22695. *
  22696. * @return {WPElement} Dropdown toggle element.
  22697. */
  22698. renderToggle(_ref2) {
  22699. let {
  22700. onToggle,
  22701. isOpen
  22702. } = _ref2;
  22703. const {
  22704. disabled,
  22705. blockTitle,
  22706. hasSingleBlockType,
  22707. directInsertBlock,
  22708. toggleProps,
  22709. hasItems,
  22710. renderToggle = defaultRenderToggle,
  22711. prioritizePatterns
  22712. } = this.props;
  22713. return renderToggle({
  22714. onToggle,
  22715. isOpen,
  22716. disabled: disabled || !hasItems,
  22717. blockTitle,
  22718. hasSingleBlockType,
  22719. directInsertBlock,
  22720. toggleProps,
  22721. prioritizePatterns
  22722. });
  22723. }
  22724. /**
  22725. * Render callback to display Dropdown content element.
  22726. *
  22727. * @param {Object} options
  22728. * @param {Function} options.onClose Callback to invoke when dropdown is
  22729. * closed.
  22730. *
  22731. * @return {WPElement} Dropdown content element.
  22732. */
  22733. renderContent(_ref3) {
  22734. let {
  22735. onClose
  22736. } = _ref3;
  22737. const {
  22738. rootClientId,
  22739. clientId,
  22740. isAppender,
  22741. showInserterHelpPanel,
  22742. // This prop is experimental to give some time for the quick inserter to mature
  22743. // Feel free to make them stable after a few releases.
  22744. __experimentalIsQuick: isQuick,
  22745. prioritizePatterns
  22746. } = this.props;
  22747. if (isQuick) {
  22748. return (0,external_wp_element_namespaceObject.createElement)(QuickInserter, {
  22749. onSelect: () => {
  22750. onClose();
  22751. },
  22752. rootClientId: rootClientId,
  22753. clientId: clientId,
  22754. isAppender: isAppender,
  22755. prioritizePatterns: prioritizePatterns
  22756. });
  22757. }
  22758. return (0,external_wp_element_namespaceObject.createElement)(menu, {
  22759. onSelect: () => {
  22760. onClose();
  22761. },
  22762. rootClientId: rootClientId,
  22763. clientId: clientId,
  22764. isAppender: isAppender,
  22765. showInserterHelpPanel: showInserterHelpPanel,
  22766. prioritizePatterns: prioritizePatterns
  22767. });
  22768. }
  22769. render() {
  22770. const {
  22771. position,
  22772. hasSingleBlockType,
  22773. directInsertBlock,
  22774. insertOnlyAllowedBlock,
  22775. __experimentalIsQuick: isQuick,
  22776. onSelectOrClose
  22777. } = this.props;
  22778. if (hasSingleBlockType || directInsertBlock) {
  22779. return this.renderToggle({
  22780. onToggle: insertOnlyAllowedBlock
  22781. });
  22782. }
  22783. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  22784. className: "block-editor-inserter",
  22785. contentClassName: classnames_default()('block-editor-inserter__popover', {
  22786. 'is-quick': isQuick
  22787. }),
  22788. position: position,
  22789. onToggle: this.onToggle,
  22790. expandOnMobile: true,
  22791. headerTitle: (0,external_wp_i18n_namespaceObject.__)('Add a block'),
  22792. renderToggle: this.renderToggle,
  22793. renderContent: this.renderContent,
  22794. onClose: onSelectOrClose
  22795. });
  22796. }
  22797. }
  22798. /* harmony default export */ var inserter = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref4) => {
  22799. var _getBlockVariations;
  22800. let {
  22801. clientId,
  22802. rootClientId
  22803. } = _ref4;
  22804. const {
  22805. getBlockRootClientId,
  22806. hasInserterItems,
  22807. __experimentalGetAllowedBlocks,
  22808. __experimentalGetDirectInsertBlock,
  22809. getSettings
  22810. } = select(store);
  22811. const {
  22812. getBlockVariations
  22813. } = select(external_wp_blocks_namespaceObject.store);
  22814. rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
  22815. const allowedBlocks = __experimentalGetAllowedBlocks(rootClientId);
  22816. const directInsertBlock = __experimentalGetDirectInsertBlock(rootClientId);
  22817. const settings = getSettings();
  22818. const hasSingleBlockType = (allowedBlocks === null || allowedBlocks === void 0 ? void 0 : allowedBlocks.length) === 1 && ((_getBlockVariations = getBlockVariations(allowedBlocks[0].name, 'inserter')) === null || _getBlockVariations === void 0 ? void 0 : _getBlockVariations.length) === 0;
  22819. let allowedBlockType = false;
  22820. if (hasSingleBlockType) {
  22821. allowedBlockType = allowedBlocks[0];
  22822. }
  22823. return {
  22824. hasItems: hasInserterItems(rootClientId),
  22825. hasSingleBlockType,
  22826. blockTitle: allowedBlockType ? allowedBlockType.title : '',
  22827. allowedBlockType,
  22828. directInsertBlock,
  22829. rootClientId,
  22830. prioritizePatterns: settings.__experimentalPreferPatternsOnRoot && !rootClientId
  22831. };
  22832. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps, _ref5) => {
  22833. let {
  22834. select
  22835. } = _ref5;
  22836. return {
  22837. insertOnlyAllowedBlock() {
  22838. const {
  22839. rootClientId,
  22840. clientId,
  22841. isAppender,
  22842. hasSingleBlockType,
  22843. allowedBlockType,
  22844. directInsertBlock,
  22845. onSelectOrClose
  22846. } = ownProps;
  22847. if (!hasSingleBlockType && !directInsertBlock) {
  22848. return;
  22849. }
  22850. function getAdjacentBlockAttributes(attributesToCopy) {
  22851. const {
  22852. getBlock,
  22853. getPreviousBlockClientId
  22854. } = select(store);
  22855. if (!attributesToCopy || !clientId && !rootClientId) {
  22856. return {};
  22857. }
  22858. const result = {};
  22859. let adjacentAttributes = {}; // If there is no clientId, then attempt to get attributes
  22860. // from the last block within innerBlocks of the root block.
  22861. if (!clientId) {
  22862. var _parentBlock$innerBlo;
  22863. const parentBlock = getBlock(rootClientId);
  22864. if (parentBlock !== null && parentBlock !== void 0 && (_parentBlock$innerBlo = parentBlock.innerBlocks) !== null && _parentBlock$innerBlo !== void 0 && _parentBlock$innerBlo.length) {
  22865. const lastInnerBlock = parentBlock.innerBlocks[parentBlock.innerBlocks.length - 1];
  22866. if (directInsertBlock && (directInsertBlock === null || directInsertBlock === void 0 ? void 0 : directInsertBlock.name) === lastInnerBlock.name) {
  22867. adjacentAttributes = lastInnerBlock.attributes;
  22868. }
  22869. }
  22870. } else {
  22871. // Otherwise, attempt to get attributes from the
  22872. // previous block relative to the current clientId.
  22873. const currentBlock = getBlock(clientId);
  22874. const previousBlock = getBlock(getPreviousBlockClientId(clientId));
  22875. if ((currentBlock === null || currentBlock === void 0 ? void 0 : currentBlock.name) === (previousBlock === null || previousBlock === void 0 ? void 0 : previousBlock.name)) {
  22876. adjacentAttributes = (previousBlock === null || previousBlock === void 0 ? void 0 : previousBlock.attributes) || {};
  22877. }
  22878. } // Copy over only those attributes flagged to be copied.
  22879. attributesToCopy.forEach(attribute => {
  22880. if (adjacentAttributes.hasOwnProperty(attribute)) {
  22881. result[attribute] = adjacentAttributes[attribute];
  22882. }
  22883. });
  22884. return result;
  22885. }
  22886. function getInsertionIndex() {
  22887. const {
  22888. getBlockIndex,
  22889. getBlockSelectionEnd,
  22890. getBlockOrder,
  22891. getBlockRootClientId
  22892. } = select(store); // If the clientId is defined, we insert at the position of the block.
  22893. if (clientId) {
  22894. return getBlockIndex(clientId);
  22895. } // If there a selected block, we insert after the selected block.
  22896. const end = getBlockSelectionEnd();
  22897. if (!isAppender && end && getBlockRootClientId(end) === rootClientId) {
  22898. return getBlockIndex(end) + 1;
  22899. } // Otherwise, we insert at the end of the current rootClientId.
  22900. return getBlockOrder(rootClientId).length;
  22901. }
  22902. const {
  22903. insertBlock
  22904. } = dispatch(store);
  22905. let blockToInsert; // Attempt to augment the directInsertBlock with attributes from an adjacent block.
  22906. // This ensures styling from nearby blocks is preserved in the newly inserted block.
  22907. // See: https://github.com/WordPress/gutenberg/issues/37904
  22908. if (directInsertBlock) {
  22909. const newAttributes = getAdjacentBlockAttributes(directInsertBlock.attributesToCopy);
  22910. blockToInsert = (0,external_wp_blocks_namespaceObject.createBlock)(directInsertBlock.name, { ...(directInsertBlock.attributes || {}),
  22911. ...newAttributes
  22912. });
  22913. } else {
  22914. blockToInsert = (0,external_wp_blocks_namespaceObject.createBlock)(allowedBlockType.name);
  22915. }
  22916. insertBlock(blockToInsert, getInsertionIndex(), rootClientId);
  22917. if (onSelectOrClose) {
  22918. onSelectOrClose();
  22919. }
  22920. const message = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block that has been added
  22921. (0,external_wp_i18n_namespaceObject.__)('%s block added'), allowedBlockType.title);
  22922. (0,external_wp_a11y_namespaceObject.speak)(message);
  22923. }
  22924. };
  22925. }), // The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as
  22926. // a way to detect the global Inserter.
  22927. (0,external_wp_compose_namespaceObject.ifCondition)(_ref6 => {
  22928. let {
  22929. hasItems,
  22930. isAppender,
  22931. rootClientId,
  22932. clientId
  22933. } = _ref6;
  22934. return hasItems || !isAppender && !rootClientId && !clientId;
  22935. })])(Inserter));
  22936. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-block-appender/index.js
  22937. /**
  22938. * External dependencies
  22939. */
  22940. /**
  22941. * WordPress dependencies
  22942. */
  22943. /**
  22944. * Internal dependencies
  22945. */
  22946. /**
  22947. * Zero width non-breaking space, used as padding for the paragraph when it is
  22948. * empty.
  22949. */
  22950. const ZWNBSP = '\ufeff';
  22951. function DefaultBlockAppender(_ref) {
  22952. let {
  22953. isLocked,
  22954. onAppend,
  22955. showPrompt,
  22956. placeholder,
  22957. rootClientId
  22958. } = _ref;
  22959. if (isLocked) {
  22960. return null;
  22961. }
  22962. const value = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Type / to choose a block');
  22963. return (0,external_wp_element_namespaceObject.createElement)("div", {
  22964. "data-root-client-id": rootClientId || '',
  22965. className: classnames_default()('block-editor-default-block-appender', {
  22966. 'has-visible-prompt': showPrompt
  22967. })
  22968. }, (0,external_wp_element_namespaceObject.createElement)("p", {
  22969. tabIndex: "0" // We want this element to be styled as a paragraph by themes.
  22970. // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
  22971. ,
  22972. role: "button",
  22973. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Add default block') // A wrapping container for this one already has the wp-block className.
  22974. ,
  22975. className: "block-editor-default-block-appender__content",
  22976. onKeyDown: event => {
  22977. if (external_wp_keycodes_namespaceObject.ENTER === event.keyCode || external_wp_keycodes_namespaceObject.SPACE === event.keyCode) {
  22978. onAppend();
  22979. }
  22980. },
  22981. onClick: () => onAppend(),
  22982. onFocus: () => {
  22983. if (showPrompt) {
  22984. onAppend();
  22985. }
  22986. }
  22987. }, showPrompt ? value : ZWNBSP), (0,external_wp_element_namespaceObject.createElement)(inserter, {
  22988. rootClientId: rootClientId,
  22989. position: "bottom right",
  22990. isAppender: true,
  22991. __experimentalIsQuick: true
  22992. }));
  22993. }
  22994. /* harmony default export */ var default_block_appender = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
  22995. const {
  22996. getBlockCount,
  22997. getSettings,
  22998. getTemplateLock
  22999. } = select(store);
  23000. const isEmpty = !getBlockCount(ownProps.rootClientId);
  23001. const {
  23002. bodyPlaceholder
  23003. } = getSettings();
  23004. return {
  23005. showPrompt: isEmpty,
  23006. isLocked: !!getTemplateLock(ownProps.rootClientId),
  23007. placeholder: bodyPlaceholder
  23008. };
  23009. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => {
  23010. const {
  23011. insertDefaultBlock,
  23012. startTyping
  23013. } = dispatch(store);
  23014. return {
  23015. onAppend() {
  23016. const {
  23017. rootClientId
  23018. } = ownProps;
  23019. insertDefaultBlock(undefined, rootClientId);
  23020. startTyping();
  23021. }
  23022. };
  23023. }))(DefaultBlockAppender));
  23024. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/button-block-appender/index.js
  23025. /**
  23026. * External dependencies
  23027. */
  23028. /**
  23029. * WordPress dependencies
  23030. */
  23031. /**
  23032. * Internal dependencies
  23033. */
  23034. function ButtonBlockAppender(_ref, ref) {
  23035. let {
  23036. rootClientId,
  23037. className,
  23038. onFocus,
  23039. tabIndex
  23040. } = _ref;
  23041. return (0,external_wp_element_namespaceObject.createElement)(inserter, {
  23042. position: "bottom center",
  23043. rootClientId: rootClientId,
  23044. __experimentalIsQuick: true,
  23045. renderToggle: _ref2 => {
  23046. let {
  23047. onToggle,
  23048. disabled,
  23049. isOpen,
  23050. blockTitle,
  23051. hasSingleBlockType
  23052. } = _ref2;
  23053. let label;
  23054. if (hasSingleBlockType) {
  23055. label = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block when there is only one
  23056. (0,external_wp_i18n_namespaceObject._x)('Add %s', 'directly add the only allowed block'), blockTitle);
  23057. } else {
  23058. label = (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button');
  23059. }
  23060. const isToggleButton = !hasSingleBlockType;
  23061. let inserterButton = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  23062. ref: ref,
  23063. onFocus: onFocus,
  23064. tabIndex: tabIndex,
  23065. className: classnames_default()(className, 'block-editor-button-block-appender'),
  23066. onClick: onToggle,
  23067. "aria-haspopup": isToggleButton ? 'true' : undefined,
  23068. "aria-expanded": isToggleButton ? isOpen : undefined,
  23069. disabled: disabled,
  23070. label: label
  23071. }, !hasSingleBlockType && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  23072. as: "span"
  23073. }, label), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  23074. icon: library_plus
  23075. }));
  23076. if (isToggleButton || hasSingleBlockType) {
  23077. inserterButton = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
  23078. text: label
  23079. }, inserterButton);
  23080. }
  23081. return inserterButton;
  23082. },
  23083. isAppender: true
  23084. });
  23085. }
  23086. /**
  23087. * Use `ButtonBlockAppender` instead.
  23088. *
  23089. * @deprecated
  23090. */
  23091. const ButtonBlockerAppender = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  23092. external_wp_deprecated_default()(`wp.blockEditor.ButtonBlockerAppender`, {
  23093. alternative: 'wp.blockEditor.ButtonBlockAppender',
  23094. since: '5.9'
  23095. });
  23096. return ButtonBlockAppender(props, ref);
  23097. });
  23098. /**
  23099. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/button-block-appender/README.md
  23100. */
  23101. /* harmony default export */ var button_block_appender = ((0,external_wp_element_namespaceObject.forwardRef)(ButtonBlockAppender));
  23102. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list-appender/index.js
  23103. /**
  23104. * External dependencies
  23105. */
  23106. /**
  23107. * WordPress dependencies
  23108. */
  23109. /**
  23110. * Internal dependencies
  23111. */
  23112. function BlockListAppender(_ref) {
  23113. let {
  23114. rootClientId,
  23115. renderAppender: CustomAppender,
  23116. className,
  23117. tagName: TagName = 'div'
  23118. } = _ref;
  23119. const {
  23120. hideInserter,
  23121. canInsertDefaultBlock,
  23122. selectedBlockClientId
  23123. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  23124. const {
  23125. canInsertBlockType,
  23126. getTemplateLock,
  23127. getSelectedBlockClientId,
  23128. __unstableGetEditorMode
  23129. } = select(store);
  23130. return {
  23131. hideInserter: !!getTemplateLock(rootClientId) || __unstableGetEditorMode() === 'zoom-out',
  23132. canInsertDefaultBlock: canInsertBlockType((0,external_wp_blocks_namespaceObject.getDefaultBlockName)(), rootClientId),
  23133. selectedBlockClientId: getSelectedBlockClientId()
  23134. };
  23135. }, [rootClientId]);
  23136. if (hideInserter || CustomAppender === false) {
  23137. return null;
  23138. }
  23139. let appender;
  23140. if (CustomAppender) {
  23141. // Prefer custom render prop if provided.
  23142. appender = (0,external_wp_element_namespaceObject.createElement)(CustomAppender, null);
  23143. } else {
  23144. const isParentSelected = selectedBlockClientId === rootClientId || !rootClientId && !selectedBlockClientId;
  23145. if (!isParentSelected) {
  23146. return null;
  23147. }
  23148. if (canInsertDefaultBlock) {
  23149. // Render the default block appender when renderAppender has not been
  23150. // provided and the context supports use of the default appender.
  23151. appender = (0,external_wp_element_namespaceObject.createElement)(default_block_appender, {
  23152. rootClientId: rootClientId
  23153. });
  23154. } else {
  23155. // Fallback in the case no renderAppender has been provided and the
  23156. // default block can't be inserted.
  23157. appender = (0,external_wp_element_namespaceObject.createElement)(button_block_appender, {
  23158. rootClientId: rootClientId,
  23159. className: "block-list-appender__toggle"
  23160. });
  23161. }
  23162. }
  23163. return (0,external_wp_element_namespaceObject.createElement)(TagName // A `tabIndex` is used on the wrapping `div` element in order to
  23164. // force a focus event to occur when an appender `button` element
  23165. // is clicked. In some browsers (Firefox, Safari), button clicks do
  23166. // not emit a focus event, which could cause this event to propagate
  23167. // unexpectedly. The `tabIndex` ensures that the interaction is
  23168. // captured as a focus, without also adding an extra tab stop.
  23169. //
  23170. // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  23171. , {
  23172. tabIndex: -1,
  23173. className: classnames_default()('block-list-appender wp-block', className) // Needed in case the whole editor is content editable (for multi
  23174. // selection). It fixes an edge case where ArrowDown and ArrowRight
  23175. // should collapse the selection to the end of that selection and
  23176. // not into the appender.
  23177. ,
  23178. contentEditable: false // The appender exists to let you add the first Paragraph before
  23179. // any is inserted. To that end, this appender should visually be
  23180. // presented as a block. That means theme CSS should style it as if
  23181. // it were an empty paragraph block. That means a `wp-block` class to
  23182. // ensure the width is correct, and a [data-block] attribute to ensure
  23183. // the correct margin is applied, especially for classic themes which
  23184. // have commonly targeted that attribute for margins.
  23185. ,
  23186. "data-block": true
  23187. }, appender);
  23188. }
  23189. /* harmony default export */ var block_list_appender = (BlockListAppender);
  23190. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-popover/inbetween.js
  23191. /**
  23192. * External dependencies
  23193. */
  23194. /**
  23195. * WordPress dependencies
  23196. */
  23197. /**
  23198. * Internal dependencies
  23199. */
  23200. const inbetween_MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
  23201. const InsertionPointOpenRef = (0,external_wp_element_namespaceObject.createContext)();
  23202. function BlockPopoverInbetween(_ref) {
  23203. let {
  23204. previousClientId,
  23205. nextClientId,
  23206. children,
  23207. __unstablePopoverSlot,
  23208. __unstableContentRef,
  23209. ...props
  23210. } = _ref;
  23211. // This is a temporary hack to get the inbetween inserter to recompute properly.
  23212. const [popoverRecomputeCounter, forcePopoverRecompute] = (0,external_wp_element_namespaceObject.useReducer)( // Module is there to make sure that the counter doesn't overflow.
  23213. s => (s + 1) % inbetween_MAX_POPOVER_RECOMPUTE_COUNTER, 0);
  23214. const {
  23215. orientation,
  23216. rootClientId,
  23217. isVisible
  23218. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  23219. var _getBlockListSettings;
  23220. const {
  23221. getBlockListSettings,
  23222. getBlockRootClientId,
  23223. isBlockVisible
  23224. } = select(store);
  23225. const _rootClientId = getBlockRootClientId(previousClientId !== null && previousClientId !== void 0 ? previousClientId : nextClientId);
  23226. return {
  23227. orientation: ((_getBlockListSettings = getBlockListSettings(_rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical',
  23228. rootClientId: _rootClientId,
  23229. isVisible: isBlockVisible(previousClientId) && isBlockVisible(nextClientId)
  23230. };
  23231. }, [previousClientId, nextClientId]);
  23232. const previousElement = useBlockElement(previousClientId);
  23233. const nextElement = useBlockElement(nextClientId);
  23234. const isVertical = orientation === 'vertical';
  23235. const style = (0,external_wp_element_namespaceObject.useMemo)(() => {
  23236. if ( // popoverRecomputeCounter is by definition always equal or greater than 0.
  23237. // This check is only there to satisfy the correctness of the
  23238. // exhaustive-deps rule for the `useMemo` hook.
  23239. popoverRecomputeCounter < 0 || !previousElement && !nextElement || !isVisible) {
  23240. return {};
  23241. }
  23242. const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
  23243. const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
  23244. if (isVertical) {
  23245. return {
  23246. width: previousRect ? previousRect.width : nextRect.width,
  23247. height: nextRect && previousRect ? nextRect.top - previousRect.bottom : 0
  23248. };
  23249. }
  23250. let width = 0;
  23251. if (previousRect && nextRect) {
  23252. width = (0,external_wp_i18n_namespaceObject.isRTL)() ? previousRect.left - nextRect.right : nextRect.left - previousRect.right;
  23253. }
  23254. return {
  23255. width,
  23256. height: previousRect ? previousRect.height : nextRect.height
  23257. };
  23258. }, [previousElement, nextElement, isVertical, popoverRecomputeCounter, isVisible]);
  23259. const popoverAnchor = (0,external_wp_element_namespaceObject.useMemo)(() => {
  23260. if ( // popoverRecomputeCounter is by definition always equal or greater than 0.
  23261. // This check is only there to satisfy the correctness of the
  23262. // exhaustive-deps rule for the `useMemo` hook.
  23263. popoverRecomputeCounter < 0 || !previousElement && !nextElement || !isVisible) {
  23264. return undefined;
  23265. }
  23266. const {
  23267. ownerDocument
  23268. } = previousElement || nextElement;
  23269. return {
  23270. ownerDocument,
  23271. getBoundingClientRect() {
  23272. const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
  23273. const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
  23274. let left = 0;
  23275. let top = 0;
  23276. if (isVertical) {
  23277. // vertical
  23278. top = previousRect ? previousRect.bottom : nextRect.top;
  23279. if ((0,external_wp_i18n_namespaceObject.isRTL)()) {
  23280. // vertical, rtl
  23281. left = previousRect ? previousRect.right : nextRect.right;
  23282. } else {
  23283. // vertical, ltr
  23284. left = previousRect ? previousRect.left : nextRect.left;
  23285. }
  23286. } else {
  23287. top = previousRect ? previousRect.top : nextRect.top;
  23288. if ((0,external_wp_i18n_namespaceObject.isRTL)()) {
  23289. // non vertical, rtl
  23290. left = previousRect ? previousRect.left : nextRect.right;
  23291. } else {
  23292. // non vertical, ltr
  23293. left = previousRect ? previousRect.right : nextRect.left;
  23294. }
  23295. }
  23296. return new window.DOMRect(left, top, 0, 0);
  23297. }
  23298. };
  23299. }, [previousElement, nextElement, popoverRecomputeCounter, isVertical, isVisible]);
  23300. const popoverScrollRef = use_popover_scroll(__unstableContentRef); // This is only needed for a smooth transition when moving blocks.
  23301. // When blocks are moved up/down, their position can be set by
  23302. // updating the `transform` property manually (i.e. without using CSS
  23303. // transitions or animations). The animation, which can also scroll the block
  23304. // editor, can sometimes cause the position of the Popover to get out of sync.
  23305. // A MutationObserver is therefore used to make sure that changes to the
  23306. // selectedElement's attribute (i.e. `transform`) can be tracked and used to
  23307. // trigger the Popover to rerender.
  23308. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  23309. if (!previousElement) {
  23310. return;
  23311. }
  23312. const observer = new window.MutationObserver(forcePopoverRecompute);
  23313. observer.observe(previousElement, {
  23314. attributes: true
  23315. });
  23316. return () => {
  23317. observer.disconnect();
  23318. };
  23319. }, [previousElement]);
  23320. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  23321. if (!nextElement) {
  23322. return;
  23323. }
  23324. const observer = new window.MutationObserver(forcePopoverRecompute);
  23325. observer.observe(nextElement, {
  23326. attributes: true
  23327. });
  23328. return () => {
  23329. observer.disconnect();
  23330. };
  23331. }, [nextElement]);
  23332. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  23333. if (!previousElement) {
  23334. return;
  23335. }
  23336. previousElement.ownerDocument.defaultView.addEventListener('resize', forcePopoverRecompute);
  23337. return () => {
  23338. var _previousElement$owne;
  23339. (_previousElement$owne = previousElement.ownerDocument.defaultView) === null || _previousElement$owne === void 0 ? void 0 : _previousElement$owne.removeEventListener('resize', forcePopoverRecompute);
  23340. };
  23341. }, [previousElement]); // If there's either a previous or a next element, show the inbetween popover.
  23342. // Note that drag and drop uses the inbetween popover to show the drop indicator
  23343. // before the first block and after the last block.
  23344. if (!previousElement && !nextElement || !isVisible) {
  23345. return null;
  23346. }
  23347. /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
  23348. // While ideally it would be enough to capture the
  23349. // bubbling focus event from the Inserter, due to the
  23350. // characteristics of click focusing of `button`s in
  23351. // Firefox and Safari, it is not reliable.
  23352. //
  23353. // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  23354. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, _extends({
  23355. ref: popoverScrollRef,
  23356. animate: false,
  23357. anchor: popoverAnchor,
  23358. focusOnMount: false // Render in the old slot if needed for backward compatibility,
  23359. // otherwise render in place (not in the default popover slot).
  23360. ,
  23361. __unstableSlotName: __unstablePopoverSlot || null // Forces a remount of the popover when its position changes
  23362. // This makes sure the popover doesn't animate from its previous position.
  23363. ,
  23364. key: nextClientId + '--' + rootClientId
  23365. }, props, {
  23366. className: classnames_default()('block-editor-block-popover', 'block-editor-block-popover__inbetween', props.className),
  23367. resize: false,
  23368. flip: false,
  23369. placement: "bottom-start"
  23370. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  23371. className: "block-editor-block-popover__inbetween-container",
  23372. style: style
  23373. }, children));
  23374. /* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
  23375. }
  23376. /* harmony default export */ var inbetween = (BlockPopoverInbetween);
  23377. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/insertion-point.js
  23378. /**
  23379. * External dependencies
  23380. */
  23381. /**
  23382. * WordPress dependencies
  23383. */
  23384. /**
  23385. * Internal dependencies
  23386. */
  23387. const insertion_point_InsertionPointOpenRef = (0,external_wp_element_namespaceObject.createContext)();
  23388. function InsertionPointPopover(_ref) {
  23389. let {
  23390. __unstablePopoverSlot,
  23391. __unstableContentRef
  23392. } = _ref;
  23393. const {
  23394. selectBlock,
  23395. hideInsertionPoint
  23396. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  23397. const openRef = (0,external_wp_element_namespaceObject.useContext)(insertion_point_InsertionPointOpenRef);
  23398. const ref = (0,external_wp_element_namespaceObject.useRef)();
  23399. const {
  23400. orientation,
  23401. previousClientId,
  23402. nextClientId,
  23403. rootClientId,
  23404. isInserterShown
  23405. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  23406. var _getBlockListSettings;
  23407. const {
  23408. getBlockOrder,
  23409. getBlockListSettings,
  23410. getBlockInsertionPoint,
  23411. isBlockBeingDragged,
  23412. getPreviousBlockClientId,
  23413. getNextBlockClientId
  23414. } = select(store);
  23415. const insertionPoint = getBlockInsertionPoint();
  23416. const order = getBlockOrder(insertionPoint.rootClientId);
  23417. if (!order.length) {
  23418. return {};
  23419. }
  23420. let _previousClientId = order[insertionPoint.index - 1];
  23421. let _nextClientId = order[insertionPoint.index];
  23422. while (isBlockBeingDragged(_previousClientId)) {
  23423. _previousClientId = getPreviousBlockClientId(_previousClientId);
  23424. }
  23425. while (isBlockBeingDragged(_nextClientId)) {
  23426. _nextClientId = getNextBlockClientId(_nextClientId);
  23427. }
  23428. return {
  23429. previousClientId: _previousClientId,
  23430. nextClientId: _nextClientId,
  23431. orientation: ((_getBlockListSettings = getBlockListSettings(insertionPoint.rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical',
  23432. rootClientId: insertionPoint.rootClientId,
  23433. isInserterShown: insertionPoint === null || insertionPoint === void 0 ? void 0 : insertionPoint.__unstableWithInserter
  23434. };
  23435. }, []);
  23436. const isVertical = orientation === 'vertical';
  23437. const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
  23438. function onClick(event) {
  23439. if (event.target === ref.current && nextClientId) {
  23440. selectBlock(nextClientId, -1);
  23441. }
  23442. }
  23443. function onFocus(event) {
  23444. // Only handle click on the wrapper specifically, and not an event
  23445. // bubbled from the inserter itself.
  23446. if (event.target !== ref.current) {
  23447. openRef.current = true;
  23448. }
  23449. }
  23450. function maybeHideInserterPoint(event) {
  23451. // Only hide the inserter if it's triggered on the wrapper,
  23452. // and the inserter is not open.
  23453. if (event.target === ref.current && !openRef.current) {
  23454. hideInsertionPoint();
  23455. }
  23456. } // Define animation variants for the line element.
  23457. const horizontalLine = {
  23458. start: {
  23459. width: 0,
  23460. top: '50%',
  23461. bottom: '50%',
  23462. x: 0
  23463. },
  23464. rest: {
  23465. width: 4,
  23466. top: 0,
  23467. bottom: 0,
  23468. x: -2
  23469. },
  23470. hover: {
  23471. width: 4,
  23472. top: 0,
  23473. bottom: 0,
  23474. x: -2
  23475. }
  23476. };
  23477. const verticalLine = {
  23478. start: {
  23479. height: 0,
  23480. left: '50%',
  23481. right: '50%',
  23482. y: 0
  23483. },
  23484. rest: {
  23485. height: 4,
  23486. left: 0,
  23487. right: 0,
  23488. y: -2
  23489. },
  23490. hover: {
  23491. height: 4,
  23492. left: 0,
  23493. right: 0,
  23494. y: -2
  23495. }
  23496. };
  23497. const lineVariants = {
  23498. // Initial position starts from the center and invisible.
  23499. start: { ...(!isVertical ? horizontalLine.start : verticalLine.start),
  23500. opacity: 0
  23501. },
  23502. // The line expands to fill the container. If the inserter is visible it
  23503. // is delayed so it appears orchestrated.
  23504. rest: { ...(!isVertical ? horizontalLine.rest : verticalLine.rest),
  23505. opacity: 1,
  23506. borderRadius: '2px',
  23507. transition: {
  23508. delay: isInserterShown ? 0.4 : 0
  23509. }
  23510. },
  23511. hover: { ...(!isVertical ? horizontalLine.hover : verticalLine.hover),
  23512. opacity: 1,
  23513. borderRadius: '2px',
  23514. transition: {
  23515. delay: 0.4
  23516. }
  23517. }
  23518. };
  23519. const inserterVariants = {
  23520. start: {
  23521. scale: disableMotion ? 1 : 0
  23522. },
  23523. rest: {
  23524. scale: 1,
  23525. transition: {
  23526. delay: 0.2
  23527. }
  23528. }
  23529. };
  23530. const className = classnames_default()('block-editor-block-list__insertion-point', 'is-' + orientation);
  23531. return (0,external_wp_element_namespaceObject.createElement)(inbetween, {
  23532. previousClientId: previousClientId,
  23533. nextClientId: nextClientId,
  23534. __unstablePopoverSlot: __unstablePopoverSlot,
  23535. __unstableContentRef: __unstableContentRef
  23536. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
  23537. layout: !disableMotion,
  23538. initial: disableMotion ? 'rest' : 'start',
  23539. animate: "rest",
  23540. whileHover: "hover",
  23541. whileTap: "pressed",
  23542. exit: "start",
  23543. ref: ref,
  23544. tabIndex: -1,
  23545. onClick: onClick,
  23546. onFocus: onFocus,
  23547. className: classnames_default()(className, {
  23548. 'is-with-inserter': isInserterShown
  23549. }),
  23550. onHoverEnd: maybeHideInserterPoint
  23551. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
  23552. variants: lineVariants,
  23553. className: "block-editor-block-list__insertion-point-indicator",
  23554. "data-testid": "block-list-insertion-point-indicator"
  23555. }), isInserterShown && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
  23556. variants: inserterVariants,
  23557. className: classnames_default()('block-editor-block-list__insertion-point-inserter')
  23558. }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
  23559. position: "bottom center",
  23560. clientId: nextClientId,
  23561. rootClientId: rootClientId,
  23562. __experimentalIsQuick: true,
  23563. onToggle: isOpen => {
  23564. openRef.current = isOpen;
  23565. },
  23566. onSelectOrClose: () => {
  23567. openRef.current = false;
  23568. }
  23569. }))));
  23570. }
  23571. function InsertionPoint(props) {
  23572. const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
  23573. return select(store).isBlockInsertionPointVisible();
  23574. }, []);
  23575. return isVisible && (0,external_wp_element_namespaceObject.createElement)(InsertionPointPopover, props);
  23576. }
  23577. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-in-between-inserter.js
  23578. /**
  23579. * WordPress dependencies
  23580. */
  23581. /**
  23582. * Internal dependencies
  23583. */
  23584. function useInBetweenInserter() {
  23585. const openRef = (0,external_wp_element_namespaceObject.useContext)(insertion_point_InsertionPointOpenRef);
  23586. const isInBetweenInserterDisabled = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().hasReducedUI || select(store).__unstableGetEditorMode() === 'zoom-out', []);
  23587. const {
  23588. getBlockListSettings,
  23589. getBlockRootClientId,
  23590. getBlockIndex,
  23591. isBlockInsertionPointVisible,
  23592. isMultiSelecting,
  23593. getSelectedBlockClientIds,
  23594. getTemplateLock,
  23595. __unstableIsWithinBlockOverlay
  23596. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  23597. const {
  23598. showInsertionPoint,
  23599. hideInsertionPoint
  23600. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  23601. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  23602. if (isInBetweenInserterDisabled) {
  23603. return;
  23604. }
  23605. function onMouseMove(event) {
  23606. var _getBlockListSettings;
  23607. if (openRef.current) {
  23608. return;
  23609. }
  23610. if (isMultiSelecting()) {
  23611. return;
  23612. }
  23613. if (!event.target.classList.contains('block-editor-block-list__layout')) {
  23614. if (isBlockInsertionPointVisible()) {
  23615. hideInsertionPoint();
  23616. }
  23617. return;
  23618. }
  23619. let rootClientId;
  23620. if (!event.target.classList.contains('is-root-container')) {
  23621. const blockElement = !!event.target.getAttribute('data-block') ? event.target : event.target.closest('[data-block]');
  23622. rootClientId = blockElement.getAttribute('data-block');
  23623. } // Don't set the insertion point if the template is locked.
  23624. if (getTemplateLock(rootClientId)) {
  23625. return;
  23626. }
  23627. const orientation = ((_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical';
  23628. const rect = event.target.getBoundingClientRect();
  23629. const offsetTop = event.clientY - rect.top;
  23630. const offsetLeft = event.clientX - rect.left;
  23631. const children = Array.from(event.target.children);
  23632. let element = children.find(blockEl => {
  23633. return blockEl.classList.contains('wp-block') && orientation === 'vertical' && blockEl.offsetTop > offsetTop || blockEl.classList.contains('wp-block') && orientation === 'horizontal' && blockEl.offsetLeft > offsetLeft;
  23634. });
  23635. if (!element) {
  23636. return;
  23637. } // The block may be in an alignment wrapper, so check the first direct
  23638. // child if the element has no ID.
  23639. if (!element.id) {
  23640. element = element.firstElementChild;
  23641. if (!element) {
  23642. return;
  23643. }
  23644. } // Don't show the insertion point if a parent block has an "overlay"
  23645. // See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337
  23646. const clientId = element.id.slice('block-'.length);
  23647. if (!clientId || __unstableIsWithinBlockOverlay(clientId)) {
  23648. return;
  23649. } // Don't show the inserter when hovering above (conflicts with
  23650. // block toolbar) or inside selected block(s).
  23651. if (getSelectedBlockClientIds().includes(clientId)) {
  23652. return;
  23653. }
  23654. const elementRect = element.getBoundingClientRect();
  23655. if (orientation === 'horizontal' && (event.clientY > elementRect.bottom || event.clientY < elementRect.top) || orientation === 'vertical' && (event.clientX > elementRect.right || event.clientX < elementRect.left)) {
  23656. if (isBlockInsertionPointVisible()) {
  23657. hideInsertionPoint();
  23658. }
  23659. return;
  23660. }
  23661. const index = getBlockIndex(clientId); // Don't show the in-between inserter before the first block in
  23662. // the list (preserves the original behaviour).
  23663. if (index === 0) {
  23664. if (isBlockInsertionPointVisible()) {
  23665. hideInsertionPoint();
  23666. }
  23667. return;
  23668. }
  23669. showInsertionPoint(rootClientId, index, {
  23670. __unstableWithInserter: true
  23671. });
  23672. }
  23673. node.addEventListener('mousemove', onMouseMove);
  23674. return () => {
  23675. node.removeEventListener('mousemove', onMouseMove);
  23676. };
  23677. }, [openRef, getBlockListSettings, getBlockRootClientId, getBlockIndex, isBlockInsertionPointVisible, isMultiSelecting, showInsertionPoint, hideInsertionPoint, getSelectedBlockClientIds, isInBetweenInserterDisabled]);
  23678. }
  23679. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/pre-parse-patterns.js
  23680. /**
  23681. * WordPress dependencies
  23682. */
  23683. /**
  23684. * Internal dependencies
  23685. */
  23686. const requestIdleCallback = (() => {
  23687. if (typeof window === 'undefined') {
  23688. return callback => {
  23689. setTimeout(() => callback(Date.now()), 0);
  23690. };
  23691. }
  23692. return window.requestIdleCallback || window.requestAnimationFrame;
  23693. })();
  23694. const cancelIdleCallback = (() => {
  23695. if (typeof window === 'undefined') {
  23696. return clearTimeout;
  23697. }
  23698. return window.cancelIdleCallback || window.cancelAnimationFrame;
  23699. })();
  23700. function usePreParsePatterns() {
  23701. const patterns = (0,external_wp_data_namespaceObject.useSelect)(_select => _select(store).getSettings().__experimentalBlockPatterns, []);
  23702. (0,external_wp_element_namespaceObject.useEffect)(() => {
  23703. if (!(patterns !== null && patterns !== void 0 && patterns.length)) {
  23704. return;
  23705. }
  23706. let handle;
  23707. let index = -1;
  23708. const callback = () => {
  23709. index++;
  23710. if (index >= patterns.length) {
  23711. return;
  23712. }
  23713. (0,external_wp_data_namespaceObject.select)(store).__experimentalGetParsedPattern(patterns[index].name);
  23714. handle = requestIdleCallback(callback);
  23715. };
  23716. handle = requestIdleCallback(callback);
  23717. return () => cancelIdleCallback(handle);
  23718. }, [patterns]);
  23719. return null;
  23720. }
  23721. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-display-information/index.js
  23722. /**
  23723. * WordPress dependencies
  23724. */
  23725. /**
  23726. * Internal dependencies
  23727. */
  23728. /** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */
  23729. /**
  23730. * Contains basic block's information for display reasons.
  23731. *
  23732. * @typedef {Object} WPBlockDisplayInformation
  23733. *
  23734. * @property {string} title Human-readable block type label.
  23735. * @property {WPIcon} icon Block type icon.
  23736. * @property {string} description A detailed block type description.
  23737. * @property {string} anchor HTML anchor.
  23738. */
  23739. /**
  23740. * Hook used to try to find a matching block variation and return
  23741. * the appropriate information for display reasons. In order to
  23742. * to try to find a match we need to things:
  23743. * 1. Block's client id to extract it's current attributes.
  23744. * 2. A block variation should have set `isActive` prop to a proper function.
  23745. *
  23746. * If for any reason a block variaton match cannot be found,
  23747. * the returned information come from the Block Type.
  23748. * If no blockType is found with the provided clientId, returns null.
  23749. *
  23750. * @param {string} clientId Block's client id.
  23751. * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.
  23752. */
  23753. function useBlockDisplayInformation(clientId) {
  23754. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  23755. if (!clientId) return null;
  23756. const {
  23757. getBlockName,
  23758. getBlockAttributes
  23759. } = select(store);
  23760. const {
  23761. getBlockType,
  23762. getActiveBlockVariation
  23763. } = select(external_wp_blocks_namespaceObject.store);
  23764. const blockName = getBlockName(clientId);
  23765. const blockType = getBlockType(blockName);
  23766. if (!blockType) return null;
  23767. const attributes = getBlockAttributes(clientId);
  23768. const match = getActiveBlockVariation(blockName, attributes);
  23769. const blockTypeInfo = {
  23770. title: blockType.title,
  23771. icon: blockType.icon,
  23772. description: blockType.description,
  23773. anchor: attributes === null || attributes === void 0 ? void 0 : attributes.anchor
  23774. };
  23775. if (!match) return blockTypeInfo;
  23776. return {
  23777. title: match.title || blockType.title,
  23778. icon: match.icon || blockType.icon,
  23779. description: match.description || blockType.description,
  23780. anchor: attributes === null || attributes === void 0 ? void 0 : attributes.anchor
  23781. };
  23782. }, [clientId]);
  23783. }
  23784. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-title/use-block-display-title.js
  23785. /**
  23786. * WordPress dependencies
  23787. */
  23788. /**
  23789. * Internal dependencies
  23790. */
  23791. /**
  23792. * Returns the block's configured title as a string, or empty if the title
  23793. * cannot be determined.
  23794. *
  23795. * @example
  23796. *
  23797. * ```js
  23798. * useBlockDisplayTitle( { clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1', maximumLength: 17 } );
  23799. * ```
  23800. *
  23801. * @param {Object} props
  23802. * @param {string} props.clientId Client ID of block.
  23803. * @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated.
  23804. * @param {string|undefined} props.context The context to pass to `getBlockLabel`.
  23805. * @return {?string} Block title.
  23806. */
  23807. function useBlockDisplayTitle(_ref) {
  23808. let {
  23809. clientId,
  23810. maximumLength,
  23811. context
  23812. } = _ref;
  23813. const {
  23814. attributes,
  23815. name,
  23816. reusableBlockTitle
  23817. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  23818. if (!clientId) {
  23819. return {};
  23820. }
  23821. const {
  23822. getBlockName,
  23823. getBlockAttributes,
  23824. __experimentalGetReusableBlockTitle
  23825. } = select(store);
  23826. const blockName = getBlockName(clientId);
  23827. if (!blockName) {
  23828. return {};
  23829. }
  23830. const isReusable = (0,external_wp_blocks_namespaceObject.isReusableBlock)((0,external_wp_blocks_namespaceObject.getBlockType)(blockName));
  23831. return {
  23832. attributes: getBlockAttributes(clientId),
  23833. name: blockName,
  23834. reusableBlockTitle: isReusable && __experimentalGetReusableBlockTitle(getBlockAttributes(clientId).ref)
  23835. };
  23836. }, [clientId]);
  23837. const blockInformation = useBlockDisplayInformation(clientId);
  23838. if (!name || !blockInformation) {
  23839. return null;
  23840. }
  23841. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
  23842. const blockLabel = blockType ? (0,external_wp_blocks_namespaceObject.__experimentalGetBlockLabel)(blockType, attributes, context) : null;
  23843. const label = reusableBlockTitle || blockLabel; // Label will fallback to the title if no label is defined for the current
  23844. // label context. If the label is defined we prioritize it over a
  23845. // possible block variation title match.
  23846. const blockTitle = label && label !== blockType.title ? label : blockInformation.title;
  23847. if (maximumLength && maximumLength > 0 && blockTitle.length > maximumLength) {
  23848. const omission = '...';
  23849. return blockTitle.slice(0, maximumLength - omission.length) + omission;
  23850. }
  23851. return blockTitle;
  23852. }
  23853. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-title/index.js
  23854. /**
  23855. * Internal dependencies
  23856. */
  23857. /**
  23858. * Renders the block's configured title as a string, or empty if the title
  23859. * cannot be determined.
  23860. *
  23861. * @example
  23862. *
  23863. * ```jsx
  23864. * <BlockTitle clientId="afd1cb17-2c08-4e7a-91be-007ba7ddc3a1" maximumLength={ 17 }/>
  23865. * ```
  23866. *
  23867. * @param {Object} props
  23868. * @param {string} props.clientId Client ID of block.
  23869. * @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated.
  23870. * @param {string|undefined} props.context The context to pass to `getBlockLabel`.
  23871. *
  23872. * @return {JSX.Element} Block title.
  23873. */
  23874. function BlockTitle(_ref) {
  23875. let {
  23876. clientId,
  23877. maximumLength,
  23878. context
  23879. } = _ref;
  23880. return useBlockDisplayTitle({
  23881. clientId,
  23882. maximumLength,
  23883. context
  23884. });
  23885. }
  23886. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/use-scroll-when-dragging.js
  23887. /**
  23888. * WordPress dependencies
  23889. */
  23890. const SCROLL_INACTIVE_DISTANCE_PX = 50;
  23891. const SCROLL_INTERVAL_MS = 25;
  23892. const PIXELS_PER_SECOND_PER_PERCENTAGE = 1000;
  23893. const VELOCITY_MULTIPLIER = PIXELS_PER_SECOND_PER_PERCENTAGE * (SCROLL_INTERVAL_MS / 1000);
  23894. /**
  23895. * React hook that scrolls the scroll container when a block is being dragged.
  23896. *
  23897. * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`
  23898. * functions to be called in `onDragStart`, `onDragOver`
  23899. * and `onDragEnd` events respectively.
  23900. */
  23901. function useScrollWhenDragging() {
  23902. const dragStartY = (0,external_wp_element_namespaceObject.useRef)(null);
  23903. const velocityY = (0,external_wp_element_namespaceObject.useRef)(null);
  23904. const scrollParentY = (0,external_wp_element_namespaceObject.useRef)(null);
  23905. const scrollEditorInterval = (0,external_wp_element_namespaceObject.useRef)(null); // Clear interval when unmounting.
  23906. (0,external_wp_element_namespaceObject.useEffect)(() => () => {
  23907. if (scrollEditorInterval.current) {
  23908. clearInterval(scrollEditorInterval.current);
  23909. scrollEditorInterval.current = null;
  23910. }
  23911. }, []);
  23912. const startScrolling = (0,external_wp_element_namespaceObject.useCallback)(event => {
  23913. dragStartY.current = event.clientY; // Find nearest parent(s) to scroll.
  23914. scrollParentY.current = (0,external_wp_dom_namespaceObject.getScrollContainer)(event.target);
  23915. scrollEditorInterval.current = setInterval(() => {
  23916. if (scrollParentY.current && velocityY.current) {
  23917. const newTop = scrollParentY.current.scrollTop + velocityY.current; // Setting `behavior: 'smooth'` as a scroll property seems to hurt performance.
  23918. // Better to use a small scroll interval.
  23919. scrollParentY.current.scroll({
  23920. top: newTop
  23921. });
  23922. }
  23923. }, SCROLL_INTERVAL_MS);
  23924. }, []);
  23925. const scrollOnDragOver = (0,external_wp_element_namespaceObject.useCallback)(event => {
  23926. if (!scrollParentY.current) {
  23927. return;
  23928. }
  23929. const scrollParentHeight = scrollParentY.current.offsetHeight;
  23930. const offsetDragStartPosition = dragStartY.current - scrollParentY.current.offsetTop;
  23931. const offsetDragPosition = event.clientY - scrollParentY.current.offsetTop;
  23932. if (event.clientY > offsetDragStartPosition) {
  23933. // User is dragging downwards.
  23934. const moveableDistance = Math.max(scrollParentHeight - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  23935. const dragDistance = Math.max(offsetDragPosition - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  23936. const distancePercentage = dragDistance / moveableDistance;
  23937. velocityY.current = VELOCITY_MULTIPLIER * distancePercentage;
  23938. } else if (event.clientY < offsetDragStartPosition) {
  23939. // User is dragging upwards.
  23940. const moveableDistance = Math.max(offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  23941. const dragDistance = Math.max(offsetDragStartPosition - offsetDragPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  23942. const distancePercentage = dragDistance / moveableDistance;
  23943. velocityY.current = -VELOCITY_MULTIPLIER * distancePercentage;
  23944. } else {
  23945. velocityY.current = 0;
  23946. }
  23947. }, []);
  23948. const stopScrolling = () => {
  23949. dragStartY.current = null;
  23950. scrollParentY.current = null;
  23951. if (scrollEditorInterval.current) {
  23952. clearInterval(scrollEditorInterval.current);
  23953. scrollEditorInterval.current = null;
  23954. }
  23955. };
  23956. return [startScrolling, scrollOnDragOver, stopScrolling];
  23957. }
  23958. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/index.js
  23959. /**
  23960. * WordPress dependencies
  23961. */
  23962. /**
  23963. * Internal dependencies
  23964. */
  23965. const BlockDraggable = _ref => {
  23966. let {
  23967. children,
  23968. clientIds,
  23969. cloneClassname,
  23970. onDragStart,
  23971. onDragEnd
  23972. } = _ref;
  23973. const {
  23974. srcRootClientId,
  23975. isDraggable,
  23976. icon
  23977. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  23978. var _getBlockType;
  23979. const {
  23980. canMoveBlocks,
  23981. getBlockRootClientId,
  23982. getBlockName
  23983. } = select(store);
  23984. const rootClientId = getBlockRootClientId(clientIds[0]);
  23985. const blockName = getBlockName(clientIds[0]);
  23986. return {
  23987. srcRootClientId: rootClientId,
  23988. isDraggable: canMoveBlocks(clientIds, rootClientId),
  23989. icon: (_getBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon
  23990. };
  23991. }, [clientIds]);
  23992. const isDragging = (0,external_wp_element_namespaceObject.useRef)(false);
  23993. const [startScrolling, scrollOnDragOver, stopScrolling] = useScrollWhenDragging();
  23994. const {
  23995. startDraggingBlocks,
  23996. stopDraggingBlocks
  23997. } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Stop dragging blocks if the block draggable is unmounted.
  23998. (0,external_wp_element_namespaceObject.useEffect)(() => {
  23999. return () => {
  24000. if (isDragging.current) {
  24001. stopDraggingBlocks();
  24002. }
  24003. };
  24004. }, []);
  24005. if (!isDraggable) {
  24006. return children({
  24007. isDraggable: false
  24008. });
  24009. }
  24010. const transferData = {
  24011. type: 'block',
  24012. srcClientIds: clientIds,
  24013. srcRootClientId
  24014. };
  24015. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Draggable, {
  24016. cloneClassname: cloneClassname,
  24017. __experimentalTransferDataType: "wp-blocks",
  24018. transferData: transferData,
  24019. onDragStart: event => {
  24020. startDraggingBlocks(clientIds);
  24021. isDragging.current = true;
  24022. startScrolling(event);
  24023. if (onDragStart) {
  24024. onDragStart();
  24025. }
  24026. },
  24027. onDragOver: scrollOnDragOver,
  24028. onDragEnd: () => {
  24029. stopDraggingBlocks();
  24030. isDragging.current = false;
  24031. stopScrolling();
  24032. if (onDragEnd) {
  24033. onDragEnd();
  24034. }
  24035. },
  24036. __experimentalDragComponent: (0,external_wp_element_namespaceObject.createElement)(BlockDraggableChip, {
  24037. count: clientIds.length,
  24038. icon: icon
  24039. })
  24040. }, _ref2 => {
  24041. let {
  24042. onDraggableStart,
  24043. onDraggableEnd
  24044. } = _ref2;
  24045. return children({
  24046. draggable: true,
  24047. onDragStart: onDraggableStart,
  24048. onDragEnd: onDraggableEnd
  24049. });
  24050. });
  24051. };
  24052. /* harmony default export */ var block_draggable = (BlockDraggable);
  24053. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right.js
  24054. /**
  24055. * WordPress dependencies
  24056. */
  24057. const chevronRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  24058. xmlns: "http://www.w3.org/2000/svg",
  24059. viewBox: "0 0 24 24"
  24060. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  24061. d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
  24062. }));
  24063. /* harmony default export */ var chevron_right = (chevronRight);
  24064. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left.js
  24065. /**
  24066. * WordPress dependencies
  24067. */
  24068. const chevronLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  24069. xmlns: "http://www.w3.org/2000/svg",
  24070. viewBox: "0 0 24 24"
  24071. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  24072. d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
  24073. }));
  24074. /* harmony default export */ var chevron_left = (chevronLeft);
  24075. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-up.js
  24076. /**
  24077. * WordPress dependencies
  24078. */
  24079. const chevronUp = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  24080. viewBox: "0 0 24 24",
  24081. xmlns: "http://www.w3.org/2000/svg"
  24082. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  24083. d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"
  24084. }));
  24085. /* harmony default export */ var chevron_up = (chevronUp);
  24086. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-down.js
  24087. /**
  24088. * WordPress dependencies
  24089. */
  24090. const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  24091. viewBox: "0 0 24 24",
  24092. xmlns: "http://www.w3.org/2000/svg"
  24093. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  24094. d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
  24095. }));
  24096. /* harmony default export */ var chevron_down = (chevronDown);
  24097. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/mover-description.js
  24098. /**
  24099. * WordPress dependencies
  24100. */
  24101. const getMovementDirection = (moveDirection, orientation) => {
  24102. if (moveDirection === 'up') {
  24103. if (orientation === 'horizontal') {
  24104. return (0,external_wp_i18n_namespaceObject.isRTL)() ? 'right' : 'left';
  24105. }
  24106. return 'up';
  24107. } else if (moveDirection === 'down') {
  24108. if (orientation === 'horizontal') {
  24109. return (0,external_wp_i18n_namespaceObject.isRTL)() ? 'left' : 'right';
  24110. }
  24111. return 'down';
  24112. }
  24113. return null;
  24114. };
  24115. /**
  24116. * Return a label for the block movement controls depending on block position.
  24117. *
  24118. * @param {number} selectedCount Number of blocks selected.
  24119. * @param {string} type Block type - in the case of a single block, should
  24120. * define its 'type'. I.e. 'Text', 'Heading', 'Image' etc.
  24121. * @param {number} firstIndex The index (position - 1) of the first block selected.
  24122. * @param {boolean} isFirst This is the first block.
  24123. * @param {boolean} isLast This is the last block.
  24124. * @param {number} dir Direction of movement (> 0 is considered to be going
  24125. * down, < 0 is up).
  24126. * @param {string} orientation The orientation of the block movers, vertical or
  24127. * horizontal.
  24128. *
  24129. * @return {string} Label for the block movement controls.
  24130. */
  24131. function getBlockMoverDescription(selectedCount, type, firstIndex, isFirst, isLast, dir, orientation) {
  24132. const position = firstIndex + 1;
  24133. if (selectedCount > 1) {
  24134. return getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir, orientation);
  24135. }
  24136. if (isFirst && isLast) {
  24137. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Type of block (i.e. Text, Image etc)
  24138. (0,external_wp_i18n_namespaceObject.__)('Block %s is the only block, and cannot be moved'), type);
  24139. }
  24140. if (dir > 0 && !isLast) {
  24141. // Moving down.
  24142. const movementDirection = getMovementDirection('down', orientation);
  24143. if (movementDirection === 'down') {
  24144. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  24145. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d down to position %3$d'), type, position, position + 1);
  24146. }
  24147. if (movementDirection === 'left') {
  24148. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  24149. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d left to position %3$d'), type, position, position + 1);
  24150. }
  24151. if (movementDirection === 'right') {
  24152. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  24153. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d right to position %3$d'), type, position, position + 1);
  24154. }
  24155. }
  24156. if (dir > 0 && isLast) {
  24157. // Moving down, and is the last item.
  24158. const movementDirection = getMovementDirection('down', orientation);
  24159. if (movementDirection === 'down') {
  24160. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  24161. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved down'), type);
  24162. }
  24163. if (movementDirection === 'left') {
  24164. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  24165. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved left'), type);
  24166. }
  24167. if (movementDirection === 'right') {
  24168. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  24169. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved right'), type);
  24170. }
  24171. }
  24172. if (dir < 0 && !isFirst) {
  24173. // Moving up.
  24174. const movementDirection = getMovementDirection('up', orientation);
  24175. if (movementDirection === 'up') {
  24176. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  24177. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d up to position %3$d'), type, position, position - 1);
  24178. }
  24179. if (movementDirection === 'left') {
  24180. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  24181. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d left to position %3$d'), type, position, position - 1);
  24182. }
  24183. if (movementDirection === 'right') {
  24184. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  24185. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d right to position %3$d'), type, position, position - 1);
  24186. }
  24187. }
  24188. if (dir < 0 && isFirst) {
  24189. // Moving up, and is the first item.
  24190. const movementDirection = getMovementDirection('up', orientation);
  24191. if (movementDirection === 'up') {
  24192. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  24193. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved up'), type);
  24194. }
  24195. if (movementDirection === 'left') {
  24196. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  24197. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved left'), type);
  24198. }
  24199. if (movementDirection === 'right') {
  24200. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  24201. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved right'), type);
  24202. }
  24203. }
  24204. }
  24205. /**
  24206. * Return a label for the block movement controls depending on block position.
  24207. *
  24208. * @param {number} selectedCount Number of blocks selected.
  24209. * @param {number} firstIndex The index (position - 1) of the first block selected.
  24210. * @param {boolean} isFirst This is the first block.
  24211. * @param {boolean} isLast This is the last block.
  24212. * @param {number} dir Direction of movement (> 0 is considered to be going
  24213. * down, < 0 is up).
  24214. * @param {string} orientation The orientation of the block movers, vertical or
  24215. * horizontal.
  24216. *
  24217. * @return {string} Label for the block movement controls.
  24218. */
  24219. function getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir, orientation) {
  24220. const position = firstIndex + 1;
  24221. if (isFirst && isLast) {
  24222. // All blocks are selected
  24223. return (0,external_wp_i18n_namespaceObject.__)('All blocks are selected, and cannot be moved');
  24224. }
  24225. if (dir > 0 && !isLast) {
  24226. // moving down
  24227. const movementDirection = getMovementDirection('down', orientation);
  24228. if (movementDirection === 'down') {
  24229. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
  24230. (0,external_wp_i18n_namespaceObject.__)('Move %1$d blocks from position %2$d down by one place'), selectedCount, position);
  24231. }
  24232. if (movementDirection === 'left') {
  24233. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
  24234. (0,external_wp_i18n_namespaceObject.__)('Move %1$d blocks from position %2$d left by one place'), selectedCount, position);
  24235. }
  24236. if (movementDirection === 'right') {
  24237. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
  24238. (0,external_wp_i18n_namespaceObject.__)('Move %1$d blocks from position %2$d right by one place'), selectedCount, position);
  24239. }
  24240. }
  24241. if (dir > 0 && isLast) {
  24242. // moving down, and the selected blocks are the last item
  24243. const movementDirection = getMovementDirection('down', orientation);
  24244. if (movementDirection === 'down') {
  24245. return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved down as they are already at the bottom');
  24246. }
  24247. if (movementDirection === 'left') {
  24248. return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved left as they are already are at the leftmost position');
  24249. }
  24250. if (movementDirection === 'right') {
  24251. return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved right as they are already are at the rightmost position');
  24252. }
  24253. }
  24254. if (dir < 0 && !isFirst) {
  24255. // moving up
  24256. const movementDirection = getMovementDirection('up', orientation);
  24257. if (movementDirection === 'up') {
  24258. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
  24259. (0,external_wp_i18n_namespaceObject.__)('Move %1$d blocks from position %2$d up by one place'), selectedCount, position);
  24260. }
  24261. if (movementDirection === 'left') {
  24262. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
  24263. (0,external_wp_i18n_namespaceObject.__)('Move %1$d blocks from position %2$d left by one place'), selectedCount, position);
  24264. }
  24265. if (movementDirection === 'right') {
  24266. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
  24267. (0,external_wp_i18n_namespaceObject.__)('Move %1$d blocks from position %2$d right by one place'), selectedCount, position);
  24268. }
  24269. }
  24270. if (dir < 0 && isFirst) {
  24271. // moving up, and the selected blocks are the first item
  24272. const movementDirection = getMovementDirection('up', orientation);
  24273. if (movementDirection === 'up') {
  24274. return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved up as they are already at the top');
  24275. }
  24276. if (movementDirection === 'left') {
  24277. return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved left as they are already are at the leftmost position');
  24278. }
  24279. if (movementDirection === 'right') {
  24280. return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved right as they are already are at the rightmost position');
  24281. }
  24282. }
  24283. }
  24284. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/button.js
  24285. /**
  24286. * External dependencies
  24287. */
  24288. /**
  24289. * WordPress dependencies
  24290. */
  24291. /**
  24292. * Internal dependencies
  24293. */
  24294. const getArrowIcon = (direction, orientation) => {
  24295. if (direction === 'up') {
  24296. if (orientation === 'horizontal') {
  24297. return (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left;
  24298. }
  24299. return chevron_up;
  24300. } else if (direction === 'down') {
  24301. if (orientation === 'horizontal') {
  24302. return (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right;
  24303. }
  24304. return chevron_down;
  24305. }
  24306. return null;
  24307. };
  24308. const getMovementDirectionLabel = (moveDirection, orientation) => {
  24309. if (moveDirection === 'up') {
  24310. if (orientation === 'horizontal') {
  24311. return (0,external_wp_i18n_namespaceObject.isRTL)() ? (0,external_wp_i18n_namespaceObject.__)('Move right') : (0,external_wp_i18n_namespaceObject.__)('Move left');
  24312. }
  24313. return (0,external_wp_i18n_namespaceObject.__)('Move up');
  24314. } else if (moveDirection === 'down') {
  24315. if (orientation === 'horizontal') {
  24316. return (0,external_wp_i18n_namespaceObject.isRTL)() ? (0,external_wp_i18n_namespaceObject.__)('Move left') : (0,external_wp_i18n_namespaceObject.__)('Move right');
  24317. }
  24318. return (0,external_wp_i18n_namespaceObject.__)('Move down');
  24319. }
  24320. return null;
  24321. };
  24322. const BlockMoverButton = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => {
  24323. let {
  24324. clientIds,
  24325. direction,
  24326. orientation: moverOrientation,
  24327. ...props
  24328. } = _ref;
  24329. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockMoverButton);
  24330. const normalizedClientIds = Array.isArray(clientIds) ? clientIds : [clientIds];
  24331. const blocksCount = normalizedClientIds.length;
  24332. const {
  24333. blockType,
  24334. isDisabled,
  24335. rootClientId,
  24336. isFirst,
  24337. isLast,
  24338. firstIndex,
  24339. orientation = 'vertical'
  24340. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  24341. const {
  24342. getBlockIndex,
  24343. getBlockRootClientId,
  24344. getBlockOrder,
  24345. getBlock,
  24346. getBlockListSettings
  24347. } = select(store);
  24348. const firstClientId = normalizedClientIds[0];
  24349. const blockRootClientId = getBlockRootClientId(firstClientId);
  24350. const firstBlockIndex = getBlockIndex(firstClientId);
  24351. const lastBlockIndex = getBlockIndex(normalizedClientIds[normalizedClientIds.length - 1]);
  24352. const blockOrder = getBlockOrder(blockRootClientId);
  24353. const block = getBlock(firstClientId);
  24354. const isFirstBlock = firstBlockIndex === 0;
  24355. const isLastBlock = lastBlockIndex === blockOrder.length - 1;
  24356. const {
  24357. orientation: blockListOrientation
  24358. } = getBlockListSettings(blockRootClientId) || {};
  24359. return {
  24360. blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
  24361. isDisabled: direction === 'up' ? isFirstBlock : isLastBlock,
  24362. rootClientId: blockRootClientId,
  24363. firstIndex: firstBlockIndex,
  24364. isFirst: isFirstBlock,
  24365. isLast: isLastBlock,
  24366. orientation: moverOrientation || blockListOrientation
  24367. };
  24368. }, [clientIds, direction]);
  24369. const {
  24370. moveBlocksDown,
  24371. moveBlocksUp
  24372. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  24373. const moverFunction = direction === 'up' ? moveBlocksUp : moveBlocksDown;
  24374. const onClick = event => {
  24375. moverFunction(clientIds, rootClientId);
  24376. if (props.onClick) {
  24377. props.onClick(event);
  24378. }
  24379. };
  24380. const descriptionId = `block-editor-block-mover-button__description-${instanceId}`;
  24381. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
  24382. ref: ref,
  24383. className: classnames_default()('block-editor-block-mover-button', `is-${direction}-button`),
  24384. icon: getArrowIcon(direction, orientation),
  24385. label: getMovementDirectionLabel(direction, orientation),
  24386. "aria-describedby": descriptionId
  24387. }, props, {
  24388. onClick: isDisabled ? null : onClick,
  24389. disabled: isDisabled,
  24390. __experimentalIsFocusable: true
  24391. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  24392. id: descriptionId
  24393. }, getBlockMoverDescription(blocksCount, blockType && blockType.title, firstIndex, isFirst, isLast, direction === 'up' ? -1 : 1, orientation)));
  24394. });
  24395. const BlockMoverUpButton = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  24396. return (0,external_wp_element_namespaceObject.createElement)(BlockMoverButton, _extends({
  24397. direction: "up",
  24398. ref: ref
  24399. }, props));
  24400. });
  24401. const BlockMoverDownButton = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  24402. return (0,external_wp_element_namespaceObject.createElement)(BlockMoverButton, _extends({
  24403. direction: "down",
  24404. ref: ref
  24405. }, props));
  24406. });
  24407. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/index.js
  24408. /**
  24409. * External dependencies
  24410. */
  24411. /**
  24412. * WordPress dependencies
  24413. */
  24414. /**
  24415. * Internal dependencies
  24416. */
  24417. function BlockMover(_ref) {
  24418. let {
  24419. clientIds,
  24420. hideDragHandle
  24421. } = _ref;
  24422. const {
  24423. canMove,
  24424. rootClientId,
  24425. isFirst,
  24426. isLast,
  24427. orientation
  24428. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  24429. var _getBlockListSettings;
  24430. const {
  24431. getBlockIndex,
  24432. getBlockListSettings,
  24433. canMoveBlocks,
  24434. getBlockOrder,
  24435. getBlockRootClientId
  24436. } = select(store);
  24437. const normalizedClientIds = Array.isArray(clientIds) ? clientIds : [clientIds];
  24438. const firstClientId = normalizedClientIds[0];
  24439. const _rootClientId = getBlockRootClientId(firstClientId);
  24440. const firstIndex = getBlockIndex(firstClientId);
  24441. const lastIndex = getBlockIndex(normalizedClientIds[normalizedClientIds.length - 1]);
  24442. const blockOrder = getBlockOrder(_rootClientId);
  24443. return {
  24444. canMove: canMoveBlocks(clientIds, _rootClientId),
  24445. rootClientId: _rootClientId,
  24446. isFirst: firstIndex === 0,
  24447. isLast: lastIndex === blockOrder.length - 1,
  24448. orientation: (_getBlockListSettings = getBlockListSettings(_rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
  24449. };
  24450. }, [clientIds]);
  24451. if (!canMove || isFirst && isLast && !rootClientId) {
  24452. return null;
  24453. }
  24454. const dragHandleLabel = (0,external_wp_i18n_namespaceObject.__)('Drag');
  24455. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
  24456. className: classnames_default()('block-editor-block-mover', {
  24457. 'is-horizontal': orientation === 'horizontal'
  24458. })
  24459. }, !hideDragHandle && (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
  24460. clientIds: clientIds
  24461. }, draggableProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
  24462. icon: drag_handle,
  24463. className: "block-editor-block-mover__drag-handle",
  24464. "aria-hidden": "true",
  24465. label: dragHandleLabel // Should not be able to tab to drag handle as this
  24466. // button can only be used with a pointer device.
  24467. ,
  24468. tabIndex: "-1"
  24469. }, draggableProps))), (0,external_wp_element_namespaceObject.createElement)("div", {
  24470. className: "block-editor-block-mover__move-button-container"
  24471. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, itemProps => (0,external_wp_element_namespaceObject.createElement)(BlockMoverUpButton, _extends({
  24472. clientIds: clientIds
  24473. }, itemProps))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, itemProps => (0,external_wp_element_namespaceObject.createElement)(BlockMoverDownButton, _extends({
  24474. clientIds: clientIds
  24475. }, itemProps)))));
  24476. }
  24477. /**
  24478. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-mover/README.md
  24479. */
  24480. /* harmony default export */ var block_mover = (BlockMover);
  24481. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-selection-button.js
  24482. /**
  24483. * External dependencies
  24484. */
  24485. /**
  24486. * WordPress dependencies
  24487. */
  24488. /**
  24489. * Internal dependencies
  24490. */
  24491. /**
  24492. * Block selection button component, displaying the label of the block. If the block
  24493. * descends from a root block, a button is displayed enabling the user to select
  24494. * the root block.
  24495. *
  24496. * @param {string} props Component props.
  24497. * @param {string} props.clientId Client ID of block.
  24498. *
  24499. * @return {WPComponent} The component to be rendered.
  24500. */
  24501. function BlockSelectionButton(_ref) {
  24502. let {
  24503. clientId,
  24504. rootClientId
  24505. } = _ref;
  24506. const blockInformation = useBlockDisplayInformation(clientId);
  24507. const selected = (0,external_wp_data_namespaceObject.useSelect)(select => {
  24508. var _getBlockListSettings;
  24509. const {
  24510. getBlock,
  24511. getBlockIndex,
  24512. hasBlockMovingClientId,
  24513. getBlockListSettings,
  24514. __unstableGetEditorMode
  24515. } = select(store);
  24516. const index = getBlockIndex(clientId);
  24517. const {
  24518. name,
  24519. attributes
  24520. } = getBlock(clientId);
  24521. const blockMovingMode = hasBlockMovingClientId();
  24522. return {
  24523. index,
  24524. name,
  24525. attributes,
  24526. blockMovingMode,
  24527. orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation,
  24528. editorMode: __unstableGetEditorMode()
  24529. };
  24530. }, [clientId, rootClientId]);
  24531. const {
  24532. index,
  24533. name,
  24534. attributes,
  24535. blockMovingMode,
  24536. orientation,
  24537. editorMode
  24538. } = selected;
  24539. const {
  24540. setNavigationMode,
  24541. removeBlock
  24542. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  24543. const ref = (0,external_wp_element_namespaceObject.useRef)();
  24544. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
  24545. const label = (0,external_wp_blocks_namespaceObject.__experimentalGetAccessibleBlockLabel)(blockType, attributes, index + 1, orientation); // Focus the breadcrumb in navigation mode.
  24546. (0,external_wp_element_namespaceObject.useEffect)(() => {
  24547. ref.current.focus();
  24548. (0,external_wp_a11y_namespaceObject.speak)(label);
  24549. }, [label]);
  24550. const blockElement = useBlockElement(clientId);
  24551. const {
  24552. hasBlockMovingClientId,
  24553. getBlockIndex,
  24554. getBlockRootClientId,
  24555. getClientIdsOfDescendants,
  24556. getSelectedBlockClientId,
  24557. getMultiSelectedBlocksEndClientId,
  24558. getPreviousBlockClientId,
  24559. getNextBlockClientId
  24560. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  24561. const {
  24562. selectBlock,
  24563. clearSelectedBlock,
  24564. setBlockMovingClientId,
  24565. moveBlockToPosition
  24566. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  24567. function onKeyDown(event) {
  24568. const {
  24569. keyCode
  24570. } = event;
  24571. const isUp = keyCode === external_wp_keycodes_namespaceObject.UP;
  24572. const isDown = keyCode === external_wp_keycodes_namespaceObject.DOWN;
  24573. const isLeft = keyCode === external_wp_keycodes_namespaceObject.LEFT;
  24574. const isRight = keyCode === external_wp_keycodes_namespaceObject.RIGHT;
  24575. const isTab = keyCode === external_wp_keycodes_namespaceObject.TAB;
  24576. const isEscape = keyCode === external_wp_keycodes_namespaceObject.ESCAPE;
  24577. const isEnter = keyCode === external_wp_keycodes_namespaceObject.ENTER;
  24578. const isSpace = keyCode === external_wp_keycodes_namespaceObject.SPACE;
  24579. const isShift = event.shiftKey;
  24580. if (keyCode === external_wp_keycodes_namespaceObject.BACKSPACE || keyCode === external_wp_keycodes_namespaceObject.DELETE) {
  24581. removeBlock(clientId);
  24582. event.preventDefault();
  24583. return;
  24584. }
  24585. const selectedBlockClientId = getSelectedBlockClientId();
  24586. const selectionEndClientId = getMultiSelectedBlocksEndClientId();
  24587. const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
  24588. const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
  24589. const navigateUp = isTab && isShift || isUp;
  24590. const navigateDown = isTab && !isShift || isDown; // Move out of current nesting level (no effect if at root level).
  24591. const navigateOut = isLeft; // Move into next nesting level (no effect if the current block has no innerBlocks).
  24592. const navigateIn = isRight;
  24593. let focusedBlockUid;
  24594. if (navigateUp) {
  24595. focusedBlockUid = selectionBeforeEndClientId;
  24596. } else if (navigateDown) {
  24597. focusedBlockUid = selectionAfterEndClientId;
  24598. } else if (navigateOut) {
  24599. var _getBlockRootClientId;
  24600. focusedBlockUid = (_getBlockRootClientId = getBlockRootClientId(selectedBlockClientId)) !== null && _getBlockRootClientId !== void 0 ? _getBlockRootClientId : selectedBlockClientId;
  24601. } else if (navigateIn) {
  24602. var _getClientIdsOfDescen;
  24603. focusedBlockUid = (_getClientIdsOfDescen = getClientIdsOfDescendants([selectedBlockClientId])[0]) !== null && _getClientIdsOfDescen !== void 0 ? _getClientIdsOfDescen : selectedBlockClientId;
  24604. }
  24605. const startingBlockClientId = hasBlockMovingClientId();
  24606. if (isEscape && startingBlockClientId && !event.defaultPrevented) {
  24607. setBlockMovingClientId(null);
  24608. event.preventDefault();
  24609. }
  24610. if ((isEnter || isSpace) && startingBlockClientId) {
  24611. const sourceRoot = getBlockRootClientId(startingBlockClientId);
  24612. const destRoot = getBlockRootClientId(selectedBlockClientId);
  24613. const sourceBlockIndex = getBlockIndex(startingBlockClientId);
  24614. let destinationBlockIndex = getBlockIndex(selectedBlockClientId);
  24615. if (sourceBlockIndex < destinationBlockIndex && sourceRoot === destRoot) {
  24616. destinationBlockIndex -= 1;
  24617. }
  24618. moveBlockToPosition(startingBlockClientId, sourceRoot, destRoot, destinationBlockIndex);
  24619. selectBlock(startingBlockClientId);
  24620. setBlockMovingClientId(null);
  24621. }
  24622. if (navigateDown || navigateUp || navigateOut || navigateIn) {
  24623. if (focusedBlockUid) {
  24624. event.preventDefault();
  24625. selectBlock(focusedBlockUid);
  24626. } else if (isTab && selectedBlockClientId) {
  24627. let nextTabbable;
  24628. if (navigateDown) {
  24629. nextTabbable = blockElement;
  24630. do {
  24631. nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findNext(nextTabbable);
  24632. } while (nextTabbable && blockElement.contains(nextTabbable));
  24633. if (!nextTabbable) {
  24634. nextTabbable = blockElement.ownerDocument.defaultView.frameElement;
  24635. nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findNext(nextTabbable);
  24636. }
  24637. } else {
  24638. nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findPrevious(blockElement);
  24639. }
  24640. if (nextTabbable) {
  24641. event.preventDefault();
  24642. nextTabbable.focus();
  24643. clearSelectedBlock();
  24644. }
  24645. }
  24646. }
  24647. }
  24648. const classNames = classnames_default()('block-editor-block-list__block-selection-button', {
  24649. 'is-block-moving-mode': !!blockMovingMode
  24650. });
  24651. const dragHandleLabel = (0,external_wp_i18n_namespaceObject.__)('Drag');
  24652. return (0,external_wp_element_namespaceObject.createElement)("div", {
  24653. className: classNames
  24654. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
  24655. justify: "center",
  24656. className: "block-editor-block-list__block-selection-button__content"
  24657. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  24658. icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
  24659. showColors: true
  24660. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, editorMode === 'zoom-out' && (0,external_wp_element_namespaceObject.createElement)(block_mover, {
  24661. clientIds: [clientId],
  24662. hideDragHandle: true
  24663. }), editorMode === 'navigation' && (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
  24664. clientIds: [clientId]
  24665. }, draggableProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
  24666. icon: drag_handle,
  24667. className: "block-selection-button_drag-handle",
  24668. "aria-hidden": "true",
  24669. label: dragHandleLabel // Should not be able to tab to drag handle as this
  24670. // button can only be used with a pointer device.
  24671. ,
  24672. tabIndex: "-1"
  24673. }, draggableProps)))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  24674. ref: ref,
  24675. onClick: editorMode === 'navigation' ? () => setNavigationMode(false) : undefined,
  24676. onKeyDown: onKeyDown,
  24677. label: label,
  24678. showTooltip: false,
  24679. className: "block-selection-button_select-button"
  24680. }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
  24681. clientId: clientId,
  24682. maximumLength: 35
  24683. })))));
  24684. }
  24685. /* harmony default export */ var block_selection_button = (BlockSelectionButton);
  24686. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/navigable-toolbar/index.js
  24687. /**
  24688. * WordPress dependencies
  24689. */
  24690. function hasOnlyToolbarItem(elements) {
  24691. const dataProp = 'toolbarItem';
  24692. return !elements.some(element => !(dataProp in element.dataset));
  24693. }
  24694. function getAllToolbarItemsIn(container) {
  24695. return Array.from(container.querySelectorAll('[data-toolbar-item]'));
  24696. }
  24697. function hasFocusWithin(container) {
  24698. return container.contains(container.ownerDocument.activeElement);
  24699. }
  24700. function focusFirstTabbableIn(container) {
  24701. const [firstTabbable] = external_wp_dom_namespaceObject.focus.tabbable.find(container);
  24702. if (firstTabbable) {
  24703. firstTabbable.focus({
  24704. // When focusing newly mounted toolbars,
  24705. // the position of the popover is often not right on the first render
  24706. // This prevents the layout shifts when focusing the dialogs.
  24707. preventScroll: true
  24708. });
  24709. }
  24710. }
  24711. function useIsAccessibleToolbar(ref) {
  24712. /*
  24713. * By default, we'll assume the starting accessible state of the Toolbar
  24714. * is true, as it seems to be the most common case.
  24715. *
  24716. * Transitioning from an (initial) false to true state causes the
  24717. * <Toolbar /> component to mount twice, which is causing undesired
  24718. * side-effects. These side-effects appear to only affect certain
  24719. * E2E tests.
  24720. *
  24721. * This was initial discovered in this pull-request:
  24722. * https://github.com/WordPress/gutenberg/pull/23425
  24723. */
  24724. const initialAccessibleToolbarState = true; // By default, it's gonna render NavigableMenu. If all the tabbable elements
  24725. // inside the toolbar are ToolbarItem components (or derived components like
  24726. // ToolbarButton), then we can wrap them with the accessible Toolbar
  24727. // component.
  24728. const [isAccessibleToolbar, setIsAccessibleToolbar] = (0,external_wp_element_namespaceObject.useState)(initialAccessibleToolbarState);
  24729. const determineIsAccessibleToolbar = (0,external_wp_element_namespaceObject.useCallback)(() => {
  24730. const tabbables = external_wp_dom_namespaceObject.focus.tabbable.find(ref.current);
  24731. const onlyToolbarItem = hasOnlyToolbarItem(tabbables);
  24732. if (!onlyToolbarItem) {
  24733. external_wp_deprecated_default()('Using custom components as toolbar controls', {
  24734. since: '5.6',
  24735. alternative: 'ToolbarItem, ToolbarButton or ToolbarDropdownMenu components',
  24736. link: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols'
  24737. });
  24738. }
  24739. setIsAccessibleToolbar(onlyToolbarItem);
  24740. }, []);
  24741. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  24742. // Toolbar buttons may be rendered asynchronously, so we use
  24743. // MutationObserver to check if the toolbar subtree has been modified.
  24744. const observer = new window.MutationObserver(determineIsAccessibleToolbar);
  24745. observer.observe(ref.current, {
  24746. childList: true,
  24747. subtree: true
  24748. });
  24749. return () => observer.disconnect();
  24750. }, [isAccessibleToolbar]);
  24751. return isAccessibleToolbar;
  24752. }
  24753. function useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, defaultIndex, onIndexChange) {
  24754. // Make sure we don't use modified versions of this prop.
  24755. const [initialFocusOnMount] = (0,external_wp_element_namespaceObject.useState)(focusOnMount);
  24756. const [initialIndex] = (0,external_wp_element_namespaceObject.useState)(defaultIndex);
  24757. const focusToolbar = (0,external_wp_element_namespaceObject.useCallback)(() => {
  24758. focusFirstTabbableIn(ref.current);
  24759. }, []); // Focus on toolbar when pressing alt+F10 when the toolbar is visible.
  24760. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/block-editor/focus-toolbar', focusToolbar);
  24761. (0,external_wp_element_namespaceObject.useEffect)(() => {
  24762. if (initialFocusOnMount) {
  24763. focusToolbar();
  24764. }
  24765. }, [isAccessibleToolbar, initialFocusOnMount, focusToolbar]);
  24766. (0,external_wp_element_namespaceObject.useEffect)(() => {
  24767. // If initialIndex is passed, we focus on that toolbar item when the
  24768. // toolbar gets mounted and initial focus is not forced.
  24769. // We have to wait for the next browser paint because block controls aren't
  24770. // rendered right away when the toolbar gets mounted.
  24771. let raf = 0;
  24772. if (initialIndex && !initialFocusOnMount) {
  24773. raf = window.requestAnimationFrame(() => {
  24774. const items = getAllToolbarItemsIn(ref.current);
  24775. const index = initialIndex || 0;
  24776. if (items[index] && hasFocusWithin(ref.current)) {
  24777. items[index].focus({
  24778. // When focusing newly mounted toolbars,
  24779. // the position of the popover is often not right on the first render
  24780. // This prevents the layout shifts when focusing the dialogs.
  24781. preventScroll: true
  24782. });
  24783. }
  24784. });
  24785. }
  24786. return () => {
  24787. window.cancelAnimationFrame(raf);
  24788. if (!onIndexChange || !ref.current) return; // When the toolbar element is unmounted and onIndexChange is passed, we
  24789. // pass the focused toolbar item index so it can be hydrated later.
  24790. const items = getAllToolbarItemsIn(ref.current);
  24791. const index = items.findIndex(item => item.tabIndex === 0);
  24792. onIndexChange(index);
  24793. };
  24794. }, [initialIndex, initialFocusOnMount]);
  24795. }
  24796. function NavigableToolbar(_ref) {
  24797. let {
  24798. children,
  24799. focusOnMount,
  24800. __experimentalInitialIndex: initialIndex,
  24801. __experimentalOnIndexChange: onIndexChange,
  24802. ...props
  24803. } = _ref;
  24804. const ref = (0,external_wp_element_namespaceObject.useRef)();
  24805. const isAccessibleToolbar = useIsAccessibleToolbar(ref);
  24806. useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, initialIndex, onIndexChange);
  24807. if (isAccessibleToolbar) {
  24808. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Toolbar, _extends({
  24809. label: props['aria-label'],
  24810. ref: ref
  24811. }, props), children);
  24812. }
  24813. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, _extends({
  24814. orientation: "horizontal",
  24815. role: "toolbar",
  24816. ref: ref
  24817. }, props), children);
  24818. }
  24819. /* harmony default export */ var navigable_toolbar = (NavigableToolbar);
  24820. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/utils.js
  24821. /**
  24822. * WordPress dependencies
  24823. */
  24824. const {
  24825. clearTimeout: utils_clearTimeout,
  24826. setTimeout: utils_setTimeout
  24827. } = window;
  24828. const utils_noop = () => {};
  24829. const DEBOUNCE_TIMEOUT = 200;
  24830. /**
  24831. * Hook that creates a showMover state, as well as debounced show/hide callbacks.
  24832. *
  24833. * @param {Object} props Component props.
  24834. * @param {Object} props.ref Element reference.
  24835. * @param {boolean} props.isFocused Whether the component has current focus.
  24836. * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
  24837. * @param {Function} [props.onChange=noop] Callback function.
  24838. */
  24839. function useDebouncedShowMovers(_ref) {
  24840. let {
  24841. ref,
  24842. isFocused,
  24843. debounceTimeout = DEBOUNCE_TIMEOUT,
  24844. onChange = utils_noop
  24845. } = _ref;
  24846. const [showMovers, setShowMovers] = (0,external_wp_element_namespaceObject.useState)(false);
  24847. const timeoutRef = (0,external_wp_element_namespaceObject.useRef)();
  24848. const handleOnChange = nextIsFocused => {
  24849. if (ref !== null && ref !== void 0 && ref.current) {
  24850. setShowMovers(nextIsFocused);
  24851. }
  24852. onChange(nextIsFocused);
  24853. };
  24854. const getIsHovered = () => {
  24855. return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.matches(':hover');
  24856. };
  24857. const shouldHideMovers = () => {
  24858. const isHovered = getIsHovered();
  24859. return !isFocused && !isHovered;
  24860. };
  24861. const clearTimeoutRef = () => {
  24862. const timeout = timeoutRef.current;
  24863. if (timeout && utils_clearTimeout) {
  24864. utils_clearTimeout(timeout);
  24865. }
  24866. };
  24867. const debouncedShowMovers = event => {
  24868. if (event) {
  24869. event.stopPropagation();
  24870. }
  24871. clearTimeoutRef();
  24872. if (!showMovers) {
  24873. handleOnChange(true);
  24874. }
  24875. };
  24876. const debouncedHideMovers = event => {
  24877. if (event) {
  24878. event.stopPropagation();
  24879. }
  24880. clearTimeoutRef();
  24881. timeoutRef.current = utils_setTimeout(() => {
  24882. if (shouldHideMovers()) {
  24883. handleOnChange(false);
  24884. }
  24885. }, debounceTimeout);
  24886. };
  24887. (0,external_wp_element_namespaceObject.useEffect)(() => () => {
  24888. /**
  24889. * We need to call the change handler with `isFocused`
  24890. * set to false on unmount because we also clear the
  24891. * timeout that would handle that.
  24892. */
  24893. handleOnChange(false);
  24894. clearTimeoutRef();
  24895. }, []);
  24896. return {
  24897. showMovers,
  24898. debouncedShowMovers,
  24899. debouncedHideMovers
  24900. };
  24901. }
  24902. /**
  24903. * Hook that provides a showMovers state and gesture events for DOM elements
  24904. * that interact with the showMovers state.
  24905. *
  24906. * @param {Object} props Component props.
  24907. * @param {Object} props.ref Element reference.
  24908. * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
  24909. * @param {Function} [props.onChange=noop] Callback function.
  24910. */
  24911. function useShowMoversGestures(_ref2) {
  24912. let {
  24913. ref,
  24914. debounceTimeout = DEBOUNCE_TIMEOUT,
  24915. onChange = utils_noop
  24916. } = _ref2;
  24917. const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false);
  24918. const {
  24919. showMovers,
  24920. debouncedShowMovers,
  24921. debouncedHideMovers
  24922. } = useDebouncedShowMovers({
  24923. ref,
  24924. debounceTimeout,
  24925. isFocused,
  24926. onChange
  24927. });
  24928. const registerRef = (0,external_wp_element_namespaceObject.useRef)(false);
  24929. const isFocusedWithin = () => {
  24930. return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.contains(ref.current.ownerDocument.activeElement);
  24931. };
  24932. (0,external_wp_element_namespaceObject.useEffect)(() => {
  24933. const node = ref.current;
  24934. const handleOnFocus = () => {
  24935. if (isFocusedWithin()) {
  24936. setIsFocused(true);
  24937. debouncedShowMovers();
  24938. }
  24939. };
  24940. const handleOnBlur = () => {
  24941. if (!isFocusedWithin()) {
  24942. setIsFocused(false);
  24943. debouncedHideMovers();
  24944. }
  24945. };
  24946. /**
  24947. * Events are added via DOM events (vs. React synthetic events),
  24948. * as the child React components swallow mouse events.
  24949. */
  24950. if (node && !registerRef.current) {
  24951. node.addEventListener('focus', handleOnFocus, true);
  24952. node.addEventListener('blur', handleOnBlur, true);
  24953. registerRef.current = true;
  24954. }
  24955. return () => {
  24956. if (node) {
  24957. node.removeEventListener('focus', handleOnFocus);
  24958. node.removeEventListener('blur', handleOnBlur);
  24959. }
  24960. };
  24961. }, [ref, registerRef, setIsFocused, debouncedShowMovers, debouncedHideMovers]);
  24962. return {
  24963. showMovers,
  24964. gestures: {
  24965. onMouseMove: debouncedShowMovers,
  24966. onMouseLeave: debouncedHideMovers
  24967. }
  24968. };
  24969. }
  24970. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-parent-selector/index.js
  24971. /**
  24972. * WordPress dependencies
  24973. */
  24974. /**
  24975. * Internal dependencies
  24976. */
  24977. /**
  24978. * Block parent selector component, displaying the hierarchy of the
  24979. * current block selection as a single icon to "go up" a level.
  24980. *
  24981. * @return {WPComponent} Parent block selector.
  24982. */
  24983. function BlockParentSelector() {
  24984. const {
  24985. selectBlock,
  24986. toggleBlockHighlight
  24987. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  24988. const {
  24989. firstParentClientId,
  24990. shouldHide,
  24991. hasReducedUI
  24992. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  24993. const {
  24994. getBlockName,
  24995. getBlockParents,
  24996. getSelectedBlockClientId,
  24997. getSettings
  24998. } = select(store);
  24999. const {
  25000. hasBlockSupport
  25001. } = select(external_wp_blocks_namespaceObject.store);
  25002. const selectedBlockClientId = getSelectedBlockClientId();
  25003. const parents = getBlockParents(selectedBlockClientId);
  25004. const _firstParentClientId = parents[parents.length - 1];
  25005. const parentBlockName = getBlockName(_firstParentClientId);
  25006. const _parentBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(parentBlockName);
  25007. const settings = getSettings();
  25008. return {
  25009. firstParentClientId: _firstParentClientId,
  25010. shouldHide: !hasBlockSupport(_parentBlockType, '__experimentalParentSelector', true),
  25011. hasReducedUI: settings.hasReducedUI
  25012. };
  25013. }, []);
  25014. const blockInformation = useBlockDisplayInformation(firstParentClientId); // Allows highlighting the parent block outline when focusing or hovering
  25015. // the parent block selector within the child.
  25016. const nodeRef = (0,external_wp_element_namespaceObject.useRef)();
  25017. const {
  25018. gestures: showMoversGestures
  25019. } = useShowMoversGestures({
  25020. ref: nodeRef,
  25021. onChange(isFocused) {
  25022. if (isFocused && hasReducedUI) {
  25023. return;
  25024. }
  25025. toggleBlockHighlight(firstParentClientId, isFocused);
  25026. }
  25027. });
  25028. if (shouldHide || firstParentClientId === undefined) {
  25029. return null;
  25030. }
  25031. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  25032. className: "block-editor-block-parent-selector",
  25033. key: firstParentClientId,
  25034. ref: nodeRef
  25035. }, showMoversGestures), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  25036. className: "block-editor-block-parent-selector__button",
  25037. onClick: () => selectBlock(firstParentClientId),
  25038. label: (0,external_wp_i18n_namespaceObject.sprintf)(
  25039. /* translators: %s: Name of the block's parent. */
  25040. (0,external_wp_i18n_namespaceObject.__)('Select %s'), blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.title),
  25041. showTooltip: true,
  25042. icon: (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  25043. icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon
  25044. })
  25045. }));
  25046. }
  25047. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/copy.js
  25048. /**
  25049. * WordPress dependencies
  25050. */
  25051. const copy = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  25052. xmlns: "http://www.w3.org/2000/svg",
  25053. viewBox: "0 0 24 24"
  25054. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  25055. d: "M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"
  25056. }));
  25057. /* harmony default export */ var library_copy = (copy);
  25058. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/preview-block-popover.js
  25059. /**
  25060. * WordPress dependencies
  25061. */
  25062. /**
  25063. * Internal dependencies
  25064. */
  25065. function PreviewBlockPopover(_ref) {
  25066. let {
  25067. blocks
  25068. } = _ref;
  25069. return (0,external_wp_element_namespaceObject.createElement)("div", {
  25070. className: "block-editor-block-switcher__popover__preview__parent"
  25071. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  25072. className: "block-editor-block-switcher__popover__preview__container"
  25073. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  25074. className: "block-editor-block-switcher__preview__popover",
  25075. position: "bottom right",
  25076. focusOnMount: false
  25077. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  25078. className: "block-editor-block-switcher__preview"
  25079. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  25080. className: "block-editor-block-switcher__preview-title"
  25081. }, (0,external_wp_i18n_namespaceObject.__)('Preview')), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  25082. viewportWidth: 500,
  25083. blocks: blocks
  25084. })))));
  25085. }
  25086. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-transformations-menu.js
  25087. /**
  25088. * WordPress dependencies
  25089. */
  25090. /**
  25091. * Internal dependencies
  25092. */
  25093. /**
  25094. * Helper hook to group transformations to display them in a specific order in the UI.
  25095. * For now we group only priority content driven transformations(ex. paragraph -> heading).
  25096. *
  25097. * Later on we could also group 'layout' transformations(ex. paragraph -> group) and
  25098. * display them in different sections.
  25099. *
  25100. * @param {Object[]} possibleBlockTransformations The available block transformations.
  25101. * @return {Record<string, Object[]>} The grouped block transformations.
  25102. */
  25103. function useGroupedTransforms(possibleBlockTransformations) {
  25104. const priorityContentTranformationBlocks = {
  25105. 'core/paragraph': 1,
  25106. 'core/heading': 2,
  25107. 'core/list': 3,
  25108. 'core/quote': 4
  25109. };
  25110. const transformations = (0,external_wp_element_namespaceObject.useMemo)(() => {
  25111. const priorityTextTranformsNames = Object.keys(priorityContentTranformationBlocks);
  25112. return possibleBlockTransformations.reduce((accumulator, item) => {
  25113. const {
  25114. name
  25115. } = item;
  25116. if (priorityTextTranformsNames.includes(name)) {
  25117. accumulator.priorityTextTransformations.push(item);
  25118. } else {
  25119. accumulator.restTransformations.push(item);
  25120. }
  25121. return accumulator;
  25122. }, {
  25123. priorityTextTransformations: [],
  25124. restTransformations: []
  25125. });
  25126. }, [possibleBlockTransformations]); // Order the priority text transformations.
  25127. transformations.priorityTextTransformations.sort((_ref, _ref2) => {
  25128. let {
  25129. name: currentName
  25130. } = _ref;
  25131. let {
  25132. name: nextName
  25133. } = _ref2;
  25134. return priorityContentTranformationBlocks[currentName] < priorityContentTranformationBlocks[nextName] ? -1 : 1;
  25135. });
  25136. return transformations;
  25137. }
  25138. const BlockTransformationsMenu = _ref3 => {
  25139. let {
  25140. className,
  25141. possibleBlockTransformations,
  25142. onSelect,
  25143. blocks
  25144. } = _ref3;
  25145. const [hoveredTransformItemName, setHoveredTransformItemName] = (0,external_wp_element_namespaceObject.useState)();
  25146. const {
  25147. priorityTextTransformations,
  25148. restTransformations
  25149. } = useGroupedTransforms(possibleBlockTransformations); // We have to check if both content transformations(priority and rest) are set
  25150. // in order to create a separate MenuGroup for them.
  25151. const hasBothContentTransformations = priorityTextTransformations.length && restTransformations.length;
  25152. const restTransformItems = !!restTransformations.length && (0,external_wp_element_namespaceObject.createElement)(RestTransformationItems, {
  25153. restTransformations: restTransformations,
  25154. onSelect: onSelect,
  25155. setHoveredTransformItemName: setHoveredTransformItemName
  25156. });
  25157. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  25158. label: (0,external_wp_i18n_namespaceObject.__)('Transform to'),
  25159. className: className
  25160. }, hoveredTransformItemName && (0,external_wp_element_namespaceObject.createElement)(PreviewBlockPopover, {
  25161. blocks: (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, hoveredTransformItemName)
  25162. }), priorityTextTransformations.map(item => (0,external_wp_element_namespaceObject.createElement)(BlockTranformationItem, {
  25163. key: item.name,
  25164. item: item,
  25165. onSelect: onSelect,
  25166. setHoveredTransformItemName: setHoveredTransformItemName
  25167. })), !hasBothContentTransformations && restTransformItems), !!hasBothContentTransformations && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  25168. className: className
  25169. }, restTransformItems));
  25170. };
  25171. function RestTransformationItems(_ref4) {
  25172. let {
  25173. restTransformations,
  25174. onSelect,
  25175. setHoveredTransformItemName
  25176. } = _ref4;
  25177. return restTransformations.map(item => (0,external_wp_element_namespaceObject.createElement)(BlockTranformationItem, {
  25178. key: item.name,
  25179. item: item,
  25180. onSelect: onSelect,
  25181. setHoveredTransformItemName: setHoveredTransformItemName
  25182. }));
  25183. }
  25184. function BlockTranformationItem(_ref5) {
  25185. let {
  25186. item,
  25187. onSelect,
  25188. setHoveredTransformItemName
  25189. } = _ref5;
  25190. const {
  25191. name,
  25192. icon,
  25193. title,
  25194. isDisabled
  25195. } = item;
  25196. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  25197. className: (0,external_wp_blocks_namespaceObject.getBlockMenuDefaultClassName)(name),
  25198. onClick: event => {
  25199. event.preventDefault();
  25200. onSelect(name);
  25201. },
  25202. disabled: isDisabled,
  25203. onMouseLeave: () => setHoveredTransformItemName(null),
  25204. onMouseEnter: () => setHoveredTransformItemName(name)
  25205. }, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  25206. icon: icon,
  25207. showColors: true
  25208. }), title);
  25209. }
  25210. /* harmony default export */ var block_transformations_menu = (BlockTransformationsMenu);
  25211. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js
  25212. /**
  25213. * WordPress dependencies
  25214. */
  25215. const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  25216. xmlns: "http://www.w3.org/2000/svg",
  25217. viewBox: "0 0 24 24"
  25218. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  25219. d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
  25220. }));
  25221. /* harmony default export */ var library_check = (check);
  25222. ;// CONCATENATED MODULE: external ["wp","tokenList"]
  25223. var external_wp_tokenList_namespaceObject = window["wp"]["tokenList"];
  25224. var external_wp_tokenList_default = /*#__PURE__*/__webpack_require__.n(external_wp_tokenList_namespaceObject);
  25225. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/utils.js
  25226. /**
  25227. * External dependencies
  25228. */
  25229. /**
  25230. * WordPress dependencies
  25231. */
  25232. /**
  25233. * Returns the active style from the given className.
  25234. *
  25235. * @param {Array} styles Block style variations.
  25236. * @param {string} className Class name
  25237. *
  25238. * @return {Object?} The active style.
  25239. */
  25240. function getActiveStyle(styles, className) {
  25241. for (const style of new (external_wp_tokenList_default())(className).values()) {
  25242. if (style.indexOf('is-style-') === -1) {
  25243. continue;
  25244. }
  25245. const potentialStyleName = style.substring(9);
  25246. const activeStyle = (0,external_lodash_namespaceObject.find)(styles, {
  25247. name: potentialStyleName
  25248. });
  25249. if (activeStyle) {
  25250. return activeStyle;
  25251. }
  25252. }
  25253. return (0,external_lodash_namespaceObject.find)(styles, 'isDefault');
  25254. }
  25255. /**
  25256. * Replaces the active style in the block's className.
  25257. *
  25258. * @param {string} className Class name.
  25259. * @param {Object?} activeStyle The replaced style.
  25260. * @param {Object} newStyle The replacing style.
  25261. *
  25262. * @return {string} The updated className.
  25263. */
  25264. function replaceActiveStyle(className, activeStyle, newStyle) {
  25265. const list = new (external_wp_tokenList_default())(className);
  25266. if (activeStyle) {
  25267. list.remove('is-style-' + activeStyle.name);
  25268. }
  25269. list.add('is-style-' + newStyle.name);
  25270. return list.value;
  25271. }
  25272. /**
  25273. * Returns a collection of styles that can be represented on the frontend.
  25274. * The function checks a style collection for a default style. If none is found, it adds one to
  25275. * act as a fallback for when there is no active style applied to a block. The default item also serves
  25276. * as a switch on the frontend to deactivate non-default styles.
  25277. *
  25278. * @param {Array} styles Block style variations.
  25279. *
  25280. * @return {Array<Object?>} The style collection.
  25281. */
  25282. function getRenderedStyles(styles) {
  25283. if (!styles || styles.length === 0) {
  25284. return [];
  25285. }
  25286. return getDefaultStyle(styles) ? styles : [{
  25287. name: 'default',
  25288. label: (0,external_wp_i18n_namespaceObject._x)('Default', 'block style'),
  25289. isDefault: true
  25290. }, ...styles];
  25291. }
  25292. /**
  25293. * Returns a style object from a collection of styles where that style object is the default block style.
  25294. *
  25295. * @param {Array} styles Block style variations.
  25296. *
  25297. * @return {Object?} The default style object, if found.
  25298. */
  25299. function getDefaultStyle(styles) {
  25300. return (0,external_lodash_namespaceObject.find)(styles, 'isDefault');
  25301. }
  25302. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/use-styles-for-block.js
  25303. /**
  25304. * WordPress dependencies
  25305. */
  25306. /**
  25307. * Internal dependencies
  25308. */
  25309. /**
  25310. *
  25311. * @param {WPBlock} block Block object.
  25312. * @param {WPBlockType} type Block type settings.
  25313. * @return {WPBlock} A generic block ready for styles preview.
  25314. */
  25315. function useGenericPreviewBlock(block, type) {
  25316. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  25317. const example = type === null || type === void 0 ? void 0 : type.example;
  25318. const blockName = type === null || type === void 0 ? void 0 : type.name;
  25319. if (example && blockName) {
  25320. return (0,external_wp_blocks_namespaceObject.getBlockFromExample)(blockName, {
  25321. attributes: example.attributes,
  25322. innerBlocks: example.innerBlocks
  25323. });
  25324. }
  25325. if (block) {
  25326. return (0,external_wp_blocks_namespaceObject.cloneBlock)(block);
  25327. }
  25328. }, [type !== null && type !== void 0 && type.example ? block === null || block === void 0 ? void 0 : block.name : block, type]);
  25329. }
  25330. /**
  25331. * @typedef useStylesForBlocksArguments
  25332. * @property {string} clientId Block client ID.
  25333. * @property {() => void} onSwitch Block style switch callback function.
  25334. */
  25335. /**
  25336. *
  25337. * @param {useStylesForBlocksArguments} useStylesForBlocks arguments.
  25338. * @return {Object} Results of the select methods.
  25339. */
  25340. function useStylesForBlocks(_ref) {
  25341. let {
  25342. clientId,
  25343. onSwitch
  25344. } = _ref;
  25345. const selector = select => {
  25346. const {
  25347. getBlock
  25348. } = select(store);
  25349. const block = getBlock(clientId);
  25350. if (!block) {
  25351. return {};
  25352. }
  25353. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
  25354. const {
  25355. getBlockStyles
  25356. } = select(external_wp_blocks_namespaceObject.store);
  25357. return {
  25358. block,
  25359. blockType,
  25360. styles: getBlockStyles(block.name),
  25361. className: block.attributes.className || ''
  25362. };
  25363. };
  25364. const {
  25365. styles,
  25366. block,
  25367. blockType,
  25368. className
  25369. } = (0,external_wp_data_namespaceObject.useSelect)(selector, [clientId]);
  25370. const {
  25371. updateBlockAttributes
  25372. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  25373. const stylesToRender = getRenderedStyles(styles);
  25374. const activeStyle = getActiveStyle(stylesToRender, className);
  25375. const genericPreviewBlock = useGenericPreviewBlock(block, blockType);
  25376. const onSelect = style => {
  25377. const styleClassName = replaceActiveStyle(className, activeStyle, style);
  25378. updateBlockAttributes(clientId, {
  25379. className: styleClassName
  25380. });
  25381. onSwitch();
  25382. };
  25383. return {
  25384. onSelect,
  25385. stylesToRender,
  25386. activeStyle,
  25387. genericPreviewBlock,
  25388. className
  25389. };
  25390. }
  25391. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/menu-items.js
  25392. /**
  25393. * WordPress dependencies
  25394. */
  25395. /**
  25396. * Internal dependencies
  25397. */
  25398. const menu_items_noop = () => {};
  25399. function BlockStylesMenuItems(_ref) {
  25400. let {
  25401. clientId,
  25402. onSwitch = menu_items_noop
  25403. } = _ref;
  25404. const {
  25405. onSelect,
  25406. stylesToRender,
  25407. activeStyle
  25408. } = useStylesForBlocks({
  25409. clientId,
  25410. onSwitch
  25411. });
  25412. if (!stylesToRender || stylesToRender.length === 0) {
  25413. return null;
  25414. }
  25415. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, stylesToRender.map(style => {
  25416. const menuItemText = style.label || style.name;
  25417. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  25418. key: style.name,
  25419. icon: activeStyle.name === style.name ? library_check : null,
  25420. onClick: () => onSelect(style)
  25421. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
  25422. as: "span",
  25423. limit: 18,
  25424. ellipsizeMode: "tail",
  25425. truncate: true
  25426. }, menuItemText));
  25427. }));
  25428. }
  25429. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-styles-menu.js
  25430. /**
  25431. * WordPress dependencies
  25432. */
  25433. /**
  25434. * Internal dependencies
  25435. */
  25436. function BlockStylesMenu(_ref) {
  25437. let {
  25438. hoveredBlock,
  25439. onSwitch
  25440. } = _ref;
  25441. const {
  25442. clientId
  25443. } = hoveredBlock;
  25444. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  25445. label: (0,external_wp_i18n_namespaceObject.__)('Styles'),
  25446. className: "block-editor-block-switcher__styles__menugroup"
  25447. }, (0,external_wp_element_namespaceObject.createElement)(BlockStylesMenuItems, {
  25448. clientId: clientId,
  25449. onSwitch: onSwitch
  25450. }));
  25451. }
  25452. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/utils.js
  25453. /**
  25454. * WordPress dependencies
  25455. */
  25456. /**
  25457. * Try to find a matching block by a block's name in a provided
  25458. * block. We recurse through InnerBlocks and return the reference
  25459. * of the matched block (it could be an InnerBlock).
  25460. * If no match is found return nothing.
  25461. *
  25462. * @param {WPBlock} block The block to try to find a match.
  25463. * @param {string} selectedBlockName The block's name to use for matching condition.
  25464. * @param {Set} consumedBlocks A set holding the previously matched/consumed blocks.
  25465. *
  25466. * @return {WPBlock?} The matched block if found or nothing(`undefined`).
  25467. */
  25468. const getMatchingBlockByName = function (block, selectedBlockName) {
  25469. let consumedBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
  25470. const {
  25471. clientId,
  25472. name,
  25473. innerBlocks = []
  25474. } = block; // Check if block has been consumed already.
  25475. if (consumedBlocks.has(clientId)) return;
  25476. if (name === selectedBlockName) return block; // Try to find a matching block from InnerBlocks recursively.
  25477. for (const innerBlock of innerBlocks) {
  25478. const match = getMatchingBlockByName(innerBlock, selectedBlockName, consumedBlocks);
  25479. if (match) return match;
  25480. }
  25481. };
  25482. /**
  25483. * Find and return the block attributes to retain through
  25484. * the transformation, based on Block Type's `role:content`
  25485. * attributes. If no `role:content` attributes exist,
  25486. * return selected block's attributes.
  25487. *
  25488. * @param {string} name Block type's namespaced name.
  25489. * @param {Object} attributes Selected block's attributes.
  25490. * @return {Object} The block's attributes to retain.
  25491. */
  25492. const getRetainedBlockAttributes = (name, attributes) => {
  25493. const contentAttributes = (0,external_wp_blocks_namespaceObject.__experimentalGetBlockAttributesNamesByRole)(name, 'content');
  25494. if (!(contentAttributes !== null && contentAttributes !== void 0 && contentAttributes.length)) return attributes;
  25495. return contentAttributes.reduce((_accumulator, attribute) => {
  25496. if (attributes[attribute]) _accumulator[attribute] = attributes[attribute];
  25497. return _accumulator;
  25498. }, {});
  25499. };
  25500. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/use-transformed-patterns.js
  25501. /**
  25502. * WordPress dependencies
  25503. */
  25504. /**
  25505. * Internal dependencies
  25506. */
  25507. /**
  25508. * Mutate the matched block's attributes by getting
  25509. * which block type's attributes to retain and prioritize
  25510. * them in the merging of the attributes.
  25511. *
  25512. * @param {WPBlock} match The matched block.
  25513. * @param {WPBlock} selectedBlock The selected block.
  25514. * @return {void}
  25515. */
  25516. const transformMatchingBlock = (match, selectedBlock) => {
  25517. // Get the block attributes to retain through the transformation.
  25518. const retainedBlockAttributes = getRetainedBlockAttributes(selectedBlock.name, selectedBlock.attributes);
  25519. match.attributes = { ...match.attributes,
  25520. ...retainedBlockAttributes
  25521. };
  25522. };
  25523. /**
  25524. * By providing the selected blocks and pattern's blocks
  25525. * find the matching blocks, transform them and return them.
  25526. * If not all selected blocks are matched, return nothing.
  25527. *
  25528. * @param {WPBlock[]} selectedBlocks The selected blocks.
  25529. * @param {WPBlock[]} patternBlocks The pattern's blocks.
  25530. * @return {WPBlock[]|void} The transformed pattern's blocks or undefined if not all selected blocks have been matched.
  25531. */
  25532. const getPatternTransformedBlocks = (selectedBlocks, patternBlocks) => {
  25533. // Clone Pattern's blocks to produce new clientIds and be able to mutate the matches.
  25534. const _patternBlocks = patternBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
  25535. /**
  25536. * Keep track of the consumed pattern blocks.
  25537. * This is needed because we loop the selected blocks
  25538. * and for example we may have selected two paragraphs and
  25539. * the pattern's blocks could have more `paragraphs`.
  25540. */
  25541. const consumedBlocks = new Set();
  25542. for (const selectedBlock of selectedBlocks) {
  25543. let isMatch = false;
  25544. for (const patternBlock of _patternBlocks) {
  25545. const match = getMatchingBlockByName(patternBlock, selectedBlock.name, consumedBlocks);
  25546. if (!match) continue;
  25547. isMatch = true;
  25548. consumedBlocks.add(match.clientId); // We update (mutate) the matching pattern block.
  25549. transformMatchingBlock(match, selectedBlock); // No need to loop through other pattern's blocks.
  25550. break;
  25551. } // Bail eary if a selected block has not been matched.
  25552. if (!isMatch) return;
  25553. }
  25554. return _patternBlocks;
  25555. };
  25556. /**
  25557. * @typedef {WPBlockPattern & {transformedBlocks: WPBlock[]}} TransformedBlockPattern
  25558. */
  25559. /**
  25560. * Custom hook that accepts patterns from state and the selected
  25561. * blocks and tries to match these with the pattern's blocks.
  25562. * If all selected blocks are matched with a Pattern's block,
  25563. * we transform them by retaining block's attributes with `role:content`.
  25564. * The transformed pattern's blocks are set to a new pattern
  25565. * property `transformedBlocks`.
  25566. *
  25567. * @param {WPBlockPattern[]} patterns Patterns from state.
  25568. * @param {WPBlock[]} selectedBlocks The currently selected blocks.
  25569. * @return {TransformedBlockPattern[]} Returns the eligible matched patterns with all the selected blocks.
  25570. */
  25571. const useTransformedPatterns = (patterns, selectedBlocks) => {
  25572. return (0,external_wp_element_namespaceObject.useMemo)(() => patterns.reduce((accumulator, _pattern) => {
  25573. const transformedBlocks = getPatternTransformedBlocks(selectedBlocks, _pattern.blocks);
  25574. if (transformedBlocks) {
  25575. accumulator.push({ ..._pattern,
  25576. transformedBlocks
  25577. });
  25578. }
  25579. return accumulator;
  25580. }, []), [patterns, selectedBlocks]);
  25581. };
  25582. /* harmony default export */ var use_transformed_patterns = (useTransformedPatterns);
  25583. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/pattern-transformations-menu.js
  25584. /**
  25585. * WordPress dependencies
  25586. */
  25587. /**
  25588. * Internal dependencies
  25589. */
  25590. function PatternTransformationsMenu(_ref) {
  25591. let {
  25592. blocks,
  25593. patterns: statePatterns,
  25594. onSelect
  25595. } = _ref;
  25596. const [showTransforms, setShowTransforms] = (0,external_wp_element_namespaceObject.useState)(false);
  25597. const patterns = use_transformed_patterns(statePatterns, blocks);
  25598. if (!patterns.length) return null;
  25599. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  25600. className: "block-editor-block-switcher__pattern__transforms__menugroup"
  25601. }, showTransforms && (0,external_wp_element_namespaceObject.createElement)(PreviewPatternsPopover, {
  25602. patterns: patterns,
  25603. onSelect: onSelect
  25604. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  25605. onClick: event => {
  25606. event.preventDefault();
  25607. setShowTransforms(!showTransforms);
  25608. },
  25609. icon: chevron_right
  25610. }, (0,external_wp_i18n_namespaceObject.__)('Patterns')));
  25611. }
  25612. function PreviewPatternsPopover(_ref2) {
  25613. let {
  25614. patterns,
  25615. onSelect
  25616. } = _ref2;
  25617. return (0,external_wp_element_namespaceObject.createElement)("div", {
  25618. className: "block-editor-block-switcher__popover__preview__parent"
  25619. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  25620. className: "block-editor-block-switcher__popover__preview__container"
  25621. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  25622. className: "block-editor-block-switcher__preview__popover",
  25623. position: "bottom right"
  25624. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  25625. className: "block-editor-block-switcher__preview"
  25626. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  25627. className: "block-editor-block-switcher__preview-title"
  25628. }, (0,external_wp_i18n_namespaceObject.__)('Preview')), (0,external_wp_element_namespaceObject.createElement)(BlockPatternsList, {
  25629. patterns: patterns,
  25630. onSelect: onSelect
  25631. })))));
  25632. }
  25633. function BlockPatternsList(_ref3) {
  25634. let {
  25635. patterns,
  25636. onSelect
  25637. } = _ref3;
  25638. const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)();
  25639. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
  25640. role: "listbox",
  25641. className: "block-editor-block-switcher__preview-patterns-container",
  25642. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Patterns list')
  25643. }), patterns.map(pattern => (0,external_wp_element_namespaceObject.createElement)(pattern_transformations_menu_BlockPattern, {
  25644. key: pattern.name,
  25645. pattern: pattern,
  25646. onSelect: onSelect,
  25647. composite: composite
  25648. })));
  25649. }
  25650. function pattern_transformations_menu_BlockPattern(_ref4) {
  25651. let {
  25652. pattern,
  25653. onSelect,
  25654. composite
  25655. } = _ref4;
  25656. // TODO check pattern/preview width...
  25657. const baseClassName = 'block-editor-block-switcher__preview-patterns-container';
  25658. const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(pattern_transformations_menu_BlockPattern, `${baseClassName}-list__item-description`);
  25659. return (0,external_wp_element_namespaceObject.createElement)("div", {
  25660. className: `${baseClassName}-list__list-item`,
  25661. "aria-label": pattern.title,
  25662. "aria-describedby": pattern.description ? descriptionId : undefined
  25663. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
  25664. role: "option",
  25665. as: "div"
  25666. }, composite, {
  25667. className: `${baseClassName}-list__item`,
  25668. onClick: () => onSelect(pattern.transformedBlocks)
  25669. }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  25670. blocks: pattern.transformedBlocks,
  25671. viewportWidth: pattern.viewportWidth || 500
  25672. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  25673. className: `${baseClassName}-list__item-title`
  25674. }, pattern.title)), !!pattern.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  25675. id: descriptionId
  25676. }, pattern.description));
  25677. }
  25678. /* harmony default export */ var pattern_transformations_menu = (PatternTransformationsMenu);
  25679. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/index.js
  25680. /**
  25681. * External dependencies
  25682. */
  25683. /**
  25684. * WordPress dependencies
  25685. */
  25686. /**
  25687. * Internal dependencies
  25688. */
  25689. const BlockSwitcherDropdownMenu = _ref => {
  25690. let {
  25691. clientIds,
  25692. blocks
  25693. } = _ref;
  25694. const {
  25695. replaceBlocks
  25696. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  25697. const blockInformation = useBlockDisplayInformation(blocks[0].clientId);
  25698. const {
  25699. possibleBlockTransformations,
  25700. canRemove,
  25701. hasBlockStyles,
  25702. icon,
  25703. patterns
  25704. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  25705. const {
  25706. getBlockRootClientId,
  25707. getBlockTransformItems,
  25708. __experimentalGetPatternTransformItems
  25709. } = select(store);
  25710. const {
  25711. getBlockStyles,
  25712. getBlockType
  25713. } = select(external_wp_blocks_namespaceObject.store);
  25714. const {
  25715. canRemoveBlocks
  25716. } = select(store);
  25717. const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.castArray)(clientIds)[0]);
  25718. const [{
  25719. name: firstBlockName
  25720. }] = blocks;
  25721. const _isSingleBlockSelected = blocks.length === 1;
  25722. const styles = _isSingleBlockSelected && getBlockStyles(firstBlockName);
  25723. let _icon;
  25724. if (_isSingleBlockSelected) {
  25725. _icon = blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon; // Take into account active block variations.
  25726. } else {
  25727. var _getBlockType;
  25728. const isSelectionOfSameType = new Set(blocks.map(_ref2 => {
  25729. let {
  25730. name
  25731. } = _ref2;
  25732. return name;
  25733. })).size === 1; // When selection consists of blocks of multiple types, display an
  25734. // appropriate icon to communicate the non-uniformity.
  25735. _icon = isSelectionOfSameType ? (_getBlockType = getBlockType(firstBlockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon : library_copy;
  25736. }
  25737. return {
  25738. possibleBlockTransformations: getBlockTransformItems(blocks, rootClientId),
  25739. canRemove: canRemoveBlocks(clientIds, rootClientId),
  25740. hasBlockStyles: !!(styles !== null && styles !== void 0 && styles.length),
  25741. icon: _icon,
  25742. patterns: __experimentalGetPatternTransformItems(blocks, rootClientId)
  25743. };
  25744. }, [clientIds, blocks, blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon]);
  25745. const blockTitle = useBlockDisplayTitle({
  25746. clientId: Array.isArray(clientIds) ? clientIds[0] : clientIds,
  25747. maximumLength: 35
  25748. });
  25749. const isReusable = blocks.length === 1 && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]);
  25750. const isTemplate = blocks.length === 1 && (0,external_wp_blocks_namespaceObject.isTemplatePart)(blocks[0]); // Simple block tranformation based on the `Block Transforms` API.
  25751. const onBlockTransform = name => replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, name)); // Pattern transformation through the `Patterns` API.
  25752. const onPatternTransform = transformedBlocks => replaceBlocks(clientIds, transformedBlocks);
  25753. /**
  25754. * The `isTemplate` check is a stopgap solution here.
  25755. * Ideally, the Transforms API should handle this
  25756. * by allowing to exclude blocks from wildcard transformations.
  25757. */
  25758. const hasPossibleBlockTransformations = !!possibleBlockTransformations.length && canRemove && !isTemplate;
  25759. const hasPatternTransformation = !!(patterns !== null && patterns !== void 0 && patterns.length) && canRemove;
  25760. if (!hasBlockStyles && !hasPossibleBlockTransformations) {
  25761. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  25762. disabled: true,
  25763. className: "block-editor-block-switcher__no-switcher-icon",
  25764. title: blockTitle,
  25765. icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  25766. icon: icon,
  25767. showColors: true
  25768. }), (isReusable || isTemplate) && (0,external_wp_element_namespaceObject.createElement)("span", {
  25769. className: "block-editor-block-switcher__toggle-text"
  25770. }, blockTitle))
  25771. }));
  25772. }
  25773. const blockSwitcherLabel = blockTitle;
  25774. const blockSwitcherDescription = 1 === blocks.length ? (0,external_wp_i18n_namespaceObject.sprintf)(
  25775. /* translators: %s: block title. */
  25776. (0,external_wp_i18n_namespaceObject.__)('%s: Change block type or style'), blockTitle) : (0,external_wp_i18n_namespaceObject.sprintf)(
  25777. /* translators: %d: number of blocks. */
  25778. (0,external_wp_i18n_namespaceObject._n)('Change type of %d block', 'Change type of %d blocks', blocks.length), blocks.length);
  25779. const showDropDown = hasBlockStyles || hasPossibleBlockTransformations || hasPatternTransformation;
  25780. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
  25781. className: "block-editor-block-switcher",
  25782. label: blockSwitcherLabel,
  25783. popoverProps: {
  25784. position: 'bottom right',
  25785. isAlternate: true,
  25786. className: 'block-editor-block-switcher__popover'
  25787. },
  25788. icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  25789. icon: icon,
  25790. className: "block-editor-block-switcher__toggle",
  25791. showColors: true
  25792. }), (isReusable || isTemplate) && (0,external_wp_element_namespaceObject.createElement)("span", {
  25793. className: "block-editor-block-switcher__toggle-text"
  25794. }, blockTitle)),
  25795. toggleProps: {
  25796. describedBy: blockSwitcherDescription,
  25797. ...toggleProps
  25798. },
  25799. menuProps: {
  25800. orientation: 'both'
  25801. }
  25802. }, _ref3 => {
  25803. let {
  25804. onClose
  25805. } = _ref3;
  25806. return showDropDown && (0,external_wp_element_namespaceObject.createElement)("div", {
  25807. className: "block-editor-block-switcher__container"
  25808. }, hasPatternTransformation && (0,external_wp_element_namespaceObject.createElement)(pattern_transformations_menu, {
  25809. blocks: blocks,
  25810. patterns: patterns,
  25811. onSelect: transformedBlocks => {
  25812. onPatternTransform(transformedBlocks);
  25813. onClose();
  25814. }
  25815. }), hasPossibleBlockTransformations && (0,external_wp_element_namespaceObject.createElement)(block_transformations_menu, {
  25816. className: "block-editor-block-switcher__transforms__menugroup",
  25817. possibleBlockTransformations: possibleBlockTransformations,
  25818. blocks: blocks,
  25819. onSelect: name => {
  25820. onBlockTransform(name);
  25821. onClose();
  25822. }
  25823. }), hasBlockStyles && (0,external_wp_element_namespaceObject.createElement)(BlockStylesMenu, {
  25824. hoveredBlock: blocks[0],
  25825. onSwitch: onClose
  25826. }));
  25827. })));
  25828. };
  25829. const BlockSwitcher = _ref4 => {
  25830. let {
  25831. clientIds
  25832. } = _ref4;
  25833. const blocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlocksByClientId(clientIds), [clientIds]);
  25834. if (!blocks.length || blocks.some(block => !block)) {
  25835. return null;
  25836. }
  25837. return (0,external_wp_element_namespaceObject.createElement)(BlockSwitcherDropdownMenu, {
  25838. clientIds: clientIds,
  25839. blocks: blocks
  25840. });
  25841. };
  25842. /* harmony default export */ var block_switcher = (BlockSwitcher);
  25843. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/block-toolbar-last-item.js
  25844. /**
  25845. * WordPress dependencies
  25846. */
  25847. const {
  25848. Fill: __unstableBlockToolbarLastItem,
  25849. Slot: block_toolbar_last_item_Slot
  25850. } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableBlockToolbarLastItem');
  25851. __unstableBlockToolbarLastItem.Slot = block_toolbar_last_item_Slot;
  25852. /* harmony default export */ var block_toolbar_last_item = (__unstableBlockToolbarLastItem);
  25853. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-vertical.js
  25854. /**
  25855. * WordPress dependencies
  25856. */
  25857. const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  25858. xmlns: "http://www.w3.org/2000/svg",
  25859. viewBox: "0 0 24 24"
  25860. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  25861. d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
  25862. }));
  25863. /* harmony default export */ var more_vertical = (moreVertical);
  25864. ;// CONCATENATED MODULE: external ["wp","blob"]
  25865. var external_wp_blob_namespaceObject = window["wp"]["blob"];
  25866. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/pasting.js
  25867. /**
  25868. * WordPress dependencies
  25869. */
  25870. function getPasteEventData(_ref) {
  25871. let {
  25872. clipboardData
  25873. } = _ref;
  25874. let plainText = '';
  25875. let html = ''; // IE11 only supports `Text` as an argument for `getData` and will
  25876. // otherwise throw an invalid argument error, so we try the standard
  25877. // arguments first, then fallback to `Text` if they fail.
  25878. try {
  25879. plainText = clipboardData.getData('text/plain');
  25880. html = clipboardData.getData('text/html');
  25881. } catch (error1) {
  25882. try {
  25883. html = clipboardData.getData('Text');
  25884. } catch (error2) {
  25885. // Some browsers like UC Browser paste plain text by default and
  25886. // don't support clipboardData at all, so allow default
  25887. // behaviour.
  25888. return;
  25889. }
  25890. }
  25891. const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(clipboardData).filter(_ref2 => {
  25892. let {
  25893. type
  25894. } = _ref2;
  25895. return /^image\/(?:jpe?g|png|gif|webp)$/.test(type);
  25896. });
  25897. if (files.length && !shouldDismissPastedFiles(files, html, plainText)) {
  25898. html = files.map(file => `<img src="${(0,external_wp_blob_namespaceObject.createBlobURL)(file)}">`).join('');
  25899. plainText = '';
  25900. }
  25901. return {
  25902. html,
  25903. plainText
  25904. };
  25905. }
  25906. /**
  25907. * Given a collection of DataTransfer files and HTML and plain text strings,
  25908. * determine whether the files are to be dismissed in favor of the HTML.
  25909. *
  25910. * Certain office-type programs, like Microsoft Word or Apple Numbers,
  25911. * will, upon copy, generate a screenshot of the content being copied and
  25912. * attach it to the clipboard alongside the actual rich text that the user
  25913. * sought to copy. In those cases, we should let Gutenberg handle the rich text
  25914. * content and not the screenshot, since this allows Gutenberg to insert
  25915. * meaningful blocks, like paragraphs, lists or even tables.
  25916. *
  25917. * @param {File[]} files File objects obtained from a paste event
  25918. * @param {string} html HTML content obtained from a paste event
  25919. * @return {boolean} True if the files should be dismissed
  25920. */
  25921. function shouldDismissPastedFiles(files, html
  25922. /*, plainText */
  25923. ) {
  25924. // The question is only relevant when there is actual HTML content and when
  25925. // there is exactly one image file.
  25926. if (html && (files === null || files === void 0 ? void 0 : files.length) === 1 && files[0].type.indexOf('image/') === 0) {
  25927. var _html$match;
  25928. // A single <img> tag found in the HTML source suggests that the
  25929. // content being pasted revolves around an image. Sometimes there are
  25930. // other elements found, like <figure>, but we assume that the user's
  25931. // intention is to paste the actual image file.
  25932. const IMAGE_TAG = /<\s*img\b/gi;
  25933. if (((_html$match = html.match(IMAGE_TAG)) === null || _html$match === void 0 ? void 0 : _html$match.length) !== 1) return true; // Even when there is exactly one <img> tag in the HTML payload, we
  25934. // choose to weed out local images, i.e. those whose source starts with
  25935. // "file://". These payloads occur in specific configurations, such as
  25936. // when copying an entire document from Microsoft Word, that contains
  25937. // text and exactly one image, and pasting that content using Google
  25938. // Chrome.
  25939. const IMG_WITH_LOCAL_SRC = /<\s*img\b[^>]*\bsrc="file:\/\//i;
  25940. if (html.match(IMG_WITH_LOCAL_SRC)) return true;
  25941. }
  25942. return false;
  25943. }
  25944. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/copy-handler/index.js
  25945. /**
  25946. * WordPress dependencies
  25947. */
  25948. /**
  25949. * Internal dependencies
  25950. */
  25951. function useNotifyCopy() {
  25952. const {
  25953. getBlockName
  25954. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  25955. const {
  25956. getBlockType
  25957. } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
  25958. const {
  25959. createSuccessNotice
  25960. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
  25961. return (0,external_wp_element_namespaceObject.useCallback)((eventType, selectedBlockClientIds) => {
  25962. let notice = '';
  25963. if (selectedBlockClientIds.length === 1) {
  25964. var _getBlockType;
  25965. const clientId = selectedBlockClientIds[0];
  25966. const title = (_getBlockType = getBlockType(getBlockName(clientId))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
  25967. notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: Name of the block being copied, e.g. "Paragraph".
  25968. (0,external_wp_i18n_namespaceObject.__)('Copied "%s" to clipboard.'), title) : (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: Name of the block being cut, e.g. "Paragraph".
  25969. (0,external_wp_i18n_namespaceObject.__)('Moved "%s" to clipboard.'), title);
  25970. } else {
  25971. notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of blocks being copied.
  25972. (0,external_wp_i18n_namespaceObject._n)('Copied %d block to clipboard.', 'Copied %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length) : (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of blocks being cut.
  25973. (0,external_wp_i18n_namespaceObject._n)('Moved %d block to clipboard.', 'Moved %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length);
  25974. }
  25975. createSuccessNotice(notice, {
  25976. type: 'snackbar'
  25977. });
  25978. }, []);
  25979. }
  25980. function useClipboardHandler() {
  25981. const {
  25982. getBlocksByClientId,
  25983. getSelectedBlockClientIds,
  25984. hasMultiSelection,
  25985. getSettings,
  25986. __unstableIsFullySelected,
  25987. __unstableIsSelectionCollapsed,
  25988. __unstableIsSelectionMergeable,
  25989. __unstableGetSelectedBlocksWithPartialSelection
  25990. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  25991. const {
  25992. flashBlock,
  25993. removeBlocks,
  25994. replaceBlocks,
  25995. __unstableDeleteSelection,
  25996. __unstableExpandSelection
  25997. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  25998. const notifyCopy = useNotifyCopy();
  25999. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  26000. function handler(event) {
  26001. const selectedBlockClientIds = getSelectedBlockClientIds();
  26002. if (selectedBlockClientIds.length === 0) {
  26003. return;
  26004. } // Always handle multiple selected blocks.
  26005. if (!hasMultiSelection()) {
  26006. const {
  26007. target
  26008. } = event;
  26009. const {
  26010. ownerDocument
  26011. } = target; // If copying, only consider actual text selection as selection.
  26012. // Otherwise, any focus on an input field is considered.
  26013. const hasSelection = event.type === 'copy' || event.type === 'cut' ? (0,external_wp_dom_namespaceObject.documentHasUncollapsedSelection)(ownerDocument) : (0,external_wp_dom_namespaceObject.documentHasSelection)(ownerDocument); // Let native copy behaviour take over in input fields.
  26014. if (hasSelection) {
  26015. return;
  26016. }
  26017. }
  26018. if (!node.contains(event.target.ownerDocument.activeElement)) {
  26019. return;
  26020. }
  26021. const eventDefaultPrevented = event.defaultPrevented;
  26022. event.preventDefault();
  26023. const isSelectionMergeable = __unstableIsSelectionMergeable();
  26024. const shouldHandleWholeBlocks = __unstableIsSelectionCollapsed() || __unstableIsFullySelected();
  26025. const expandSelectionIsNeeded = !shouldHandleWholeBlocks && !isSelectionMergeable;
  26026. if (event.type === 'copy' || event.type === 'cut') {
  26027. if (selectedBlockClientIds.length === 1) {
  26028. flashBlock(selectedBlockClientIds[0]);
  26029. } // If we have a partial selection that is not mergeable, just
  26030. // expand the selection to the whole blocks.
  26031. if (expandSelectionIsNeeded) {
  26032. __unstableExpandSelection();
  26033. } else {
  26034. notifyCopy(event.type, selectedBlockClientIds);
  26035. let blocks; // Check if we have partial selection.
  26036. if (shouldHandleWholeBlocks) {
  26037. blocks = getBlocksByClientId(selectedBlockClientIds);
  26038. } else {
  26039. const [head, tail] = __unstableGetSelectedBlocksWithPartialSelection();
  26040. const inBetweenBlocks = getBlocksByClientId(selectedBlockClientIds.slice(1, selectedBlockClientIds.length - 1));
  26041. blocks = [head, ...inBetweenBlocks, tail];
  26042. }
  26043. const wrapperBlockName = event.clipboardData.getData('__unstableWrapperBlockName');
  26044. if (wrapperBlockName) {
  26045. blocks = (0,external_wp_blocks_namespaceObject.createBlock)(wrapperBlockName, JSON.parse(event.clipboardData.getData('__unstableWrapperBlockAttributes')), blocks);
  26046. }
  26047. const serialized = (0,external_wp_blocks_namespaceObject.serialize)(blocks);
  26048. event.clipboardData.setData('text/plain', toPlainText(serialized));
  26049. event.clipboardData.setData('text/html', serialized);
  26050. }
  26051. }
  26052. if (event.type === 'cut') {
  26053. // We need to also check if at the start we needed to
  26054. // expand the selection, as in this point we might have
  26055. // programmatically fully selected the blocks above.
  26056. if (shouldHandleWholeBlocks && !expandSelectionIsNeeded) {
  26057. removeBlocks(selectedBlockClientIds);
  26058. } else {
  26059. __unstableDeleteSelection();
  26060. }
  26061. } else if (event.type === 'paste') {
  26062. if (eventDefaultPrevented) {
  26063. // This was likely already handled in rich-text/use-paste-handler.js.
  26064. return;
  26065. }
  26066. const {
  26067. __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML
  26068. } = getSettings();
  26069. const {
  26070. plainText,
  26071. html
  26072. } = getPasteEventData(event);
  26073. const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({
  26074. HTML: html,
  26075. plainText,
  26076. mode: 'BLOCKS',
  26077. canUserUseUnfilteredHTML
  26078. });
  26079. replaceBlocks(selectedBlockClientIds, blocks, blocks.length - 1, -1);
  26080. }
  26081. }
  26082. node.ownerDocument.addEventListener('copy', handler);
  26083. node.ownerDocument.addEventListener('cut', handler);
  26084. node.ownerDocument.addEventListener('paste', handler);
  26085. return () => {
  26086. node.ownerDocument.removeEventListener('copy', handler);
  26087. node.ownerDocument.removeEventListener('cut', handler);
  26088. node.ownerDocument.removeEventListener('paste', handler);
  26089. };
  26090. }, []);
  26091. }
  26092. function CopyHandler(_ref) {
  26093. let {
  26094. children
  26095. } = _ref;
  26096. return (0,external_wp_element_namespaceObject.createElement)("div", {
  26097. ref: useClipboardHandler()
  26098. }, children);
  26099. }
  26100. /**
  26101. * Given a string of HTML representing serialized blocks, returns the plain
  26102. * text extracted after stripping the HTML of any tags and fixing line breaks.
  26103. *
  26104. * @param {string} html Serialized blocks.
  26105. * @return {string} The plain-text content with any html removed.
  26106. */
  26107. function toPlainText(html) {
  26108. // Manually handle BR tags as line breaks prior to `stripHTML` call
  26109. html = html.replace(/<br>/g, '\n');
  26110. const plainText = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(html).trim(); // Merge any consecutive line breaks
  26111. return plainText.replace(/\n\n+/g, '\n\n');
  26112. }
  26113. /**
  26114. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/copy-handler/README.md
  26115. */
  26116. /* harmony default export */ var copy_handler = (CopyHandler);
  26117. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-actions/index.js
  26118. /**
  26119. * WordPress dependencies
  26120. */
  26121. /**
  26122. * Internal dependencies
  26123. */
  26124. function BlockActions(_ref) {
  26125. let {
  26126. clientIds,
  26127. children,
  26128. __experimentalUpdateSelection: updateSelection
  26129. } = _ref;
  26130. const {
  26131. canInsertBlockType,
  26132. getBlockRootClientId,
  26133. getBlocksByClientId,
  26134. canMoveBlocks,
  26135. canRemoveBlocks
  26136. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  26137. const {
  26138. getDefaultBlockName,
  26139. getGroupingBlockName
  26140. } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
  26141. const blocks = getBlocksByClientId(clientIds);
  26142. const rootClientId = getBlockRootClientId(clientIds[0]);
  26143. const canDuplicate = blocks.every(block => {
  26144. return !!block && (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'multiple', true) && canInsertBlockType(block.name, rootClientId);
  26145. });
  26146. const canInsertDefaultBlock = canInsertBlockType(getDefaultBlockName(), rootClientId);
  26147. const canMove = canMoveBlocks(clientIds, rootClientId);
  26148. const canRemove = canRemoveBlocks(clientIds, rootClientId);
  26149. const {
  26150. removeBlocks,
  26151. replaceBlocks,
  26152. duplicateBlocks,
  26153. insertAfterBlock,
  26154. insertBeforeBlock,
  26155. flashBlock,
  26156. setBlockMovingClientId,
  26157. setNavigationMode,
  26158. selectBlock
  26159. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  26160. const notifyCopy = useNotifyCopy();
  26161. return children({
  26162. canDuplicate,
  26163. canInsertDefaultBlock,
  26164. canMove,
  26165. canRemove,
  26166. rootClientId,
  26167. blocks,
  26168. onDuplicate() {
  26169. return duplicateBlocks(clientIds, updateSelection);
  26170. },
  26171. onRemove() {
  26172. return removeBlocks(clientIds, updateSelection);
  26173. },
  26174. onInsertBefore() {
  26175. const clientId = Array.isArray(clientIds) ? clientIds[0] : clientId;
  26176. insertBeforeBlock(clientId);
  26177. },
  26178. onInsertAfter() {
  26179. const clientId = Array.isArray(clientIds) ? clientIds[clientIds.length - 1] : clientId;
  26180. insertAfterBlock(clientId);
  26181. },
  26182. onMoveTo() {
  26183. setNavigationMode(true);
  26184. selectBlock(clientIds[0]);
  26185. setBlockMovingClientId(clientIds[0]);
  26186. },
  26187. onGroup() {
  26188. if (!blocks.length) {
  26189. return;
  26190. }
  26191. const groupingBlockName = getGroupingBlockName(); // Activate the `transform` on `core/group` which does the conversion.
  26192. const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, groupingBlockName);
  26193. if (!newBlocks) {
  26194. return;
  26195. }
  26196. replaceBlocks(clientIds, newBlocks);
  26197. },
  26198. onUngroup() {
  26199. if (!blocks.length) {
  26200. return;
  26201. }
  26202. const innerBlocks = blocks[0].innerBlocks;
  26203. if (!innerBlocks.length) {
  26204. return;
  26205. }
  26206. replaceBlocks(clientIds, innerBlocks);
  26207. },
  26208. onCopy() {
  26209. const selectedBlockClientIds = blocks.map(_ref2 => {
  26210. let {
  26211. clientId
  26212. } = _ref2;
  26213. return clientId;
  26214. });
  26215. if (blocks.length === 1) {
  26216. flashBlock(selectedBlockClientIds[0]);
  26217. }
  26218. notifyCopy('copy', selectedBlockClientIds);
  26219. }
  26220. });
  26221. }
  26222. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-mode-toggle.js
  26223. /**
  26224. * WordPress dependencies
  26225. */
  26226. /**
  26227. * Internal dependencies
  26228. */
  26229. const block_mode_toggle_noop = () => {};
  26230. function BlockModeToggle(_ref) {
  26231. let {
  26232. blockType,
  26233. mode,
  26234. onToggleMode,
  26235. small = false,
  26236. isCodeEditingEnabled = true
  26237. } = _ref;
  26238. if (!blockType || !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'html', true) || !isCodeEditingEnabled) {
  26239. return null;
  26240. }
  26241. const label = mode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Edit as HTML') : (0,external_wp_i18n_namespaceObject.__)('Edit visually');
  26242. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26243. onClick: onToggleMode
  26244. }, !small && label);
  26245. }
  26246. /* harmony default export */ var block_mode_toggle = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => {
  26247. let {
  26248. clientId
  26249. } = _ref2;
  26250. const {
  26251. getBlock,
  26252. getBlockMode,
  26253. getSettings
  26254. } = select(store);
  26255. const block = getBlock(clientId);
  26256. const isCodeEditingEnabled = getSettings().codeEditingEnabled;
  26257. return {
  26258. mode: getBlockMode(clientId),
  26259. blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
  26260. isCodeEditingEnabled
  26261. };
  26262. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref3) => {
  26263. let {
  26264. onToggle = block_mode_toggle_noop,
  26265. clientId
  26266. } = _ref3;
  26267. return {
  26268. onToggleMode() {
  26269. dispatch(store).toggleBlockMode(clientId);
  26270. onToggle();
  26271. }
  26272. };
  26273. })])(BlockModeToggle));
  26274. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-convert-button.js
  26275. /**
  26276. * WordPress dependencies
  26277. */
  26278. function BlockConvertButton(_ref) {
  26279. let {
  26280. shouldRender,
  26281. onClick,
  26282. small
  26283. } = _ref;
  26284. if (!shouldRender) {
  26285. return null;
  26286. }
  26287. const label = (0,external_wp_i18n_namespaceObject.__)('Convert to Blocks');
  26288. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26289. onClick: onClick
  26290. }, !small && label);
  26291. }
  26292. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-html-convert-button.js
  26293. /**
  26294. * WordPress dependencies
  26295. */
  26296. /**
  26297. * Internal dependencies
  26298. */
  26299. /* harmony default export */ var block_html_convert_button = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, _ref) => {
  26300. let {
  26301. clientId
  26302. } = _ref;
  26303. const block = select(store).getBlock(clientId);
  26304. return {
  26305. block,
  26306. shouldRender: block && block.name === 'core/html'
  26307. };
  26308. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref2) => {
  26309. let {
  26310. block
  26311. } = _ref2;
  26312. return {
  26313. onClick: () => dispatch(store).replaceBlocks(block.clientId, (0,external_wp_blocks_namespaceObject.rawHandler)({
  26314. HTML: (0,external_wp_blocks_namespaceObject.getBlockContent)(block)
  26315. }))
  26316. };
  26317. }))(BlockConvertButton));
  26318. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-menu-first-item.js
  26319. /**
  26320. * WordPress dependencies
  26321. */
  26322. const {
  26323. Fill: __unstableBlockSettingsMenuFirstItem,
  26324. Slot: block_settings_menu_first_item_Slot
  26325. } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableBlockSettingsMenuFirstItem');
  26326. __unstableBlockSettingsMenuFirstItem.Slot = block_settings_menu_first_item_Slot;
  26327. /* harmony default export */ var block_settings_menu_first_item = (__unstableBlockSettingsMenuFirstItem);
  26328. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js
  26329. /**
  26330. * WordPress dependencies
  26331. */
  26332. /**
  26333. * Internal dependencies
  26334. */
  26335. /**
  26336. * Contains the properties `ConvertToGroupButton` component needs.
  26337. *
  26338. * @typedef {Object} ConvertToGroupButtonProps
  26339. * @property {string[]} clientIds An array of the selected client ids.
  26340. * @property {boolean} isGroupable Indicates if the selected blocks can be grouped.
  26341. * @property {boolean} isUngroupable Indicates if the selected blocks can be ungrouped.
  26342. * @property {WPBlock[]} blocksSelection An array of the selected blocks.
  26343. * @property {string} groupingBlockName The name of block used for handling grouping interactions.
  26344. */
  26345. /**
  26346. * Returns the properties `ConvertToGroupButton` component needs to work properly.
  26347. * It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton`
  26348. * should be rendered, to avoid ending up with an empty MenuGroup.
  26349. *
  26350. * @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.
  26351. */
  26352. function useConvertToGroupButtonProps() {
  26353. const {
  26354. clientIds,
  26355. isGroupable,
  26356. isUngroupable,
  26357. blocksSelection,
  26358. groupingBlockName
  26359. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  26360. var _blocksSelection$;
  26361. const {
  26362. getBlockRootClientId,
  26363. getBlocksByClientId,
  26364. canInsertBlockType,
  26365. getSelectedBlockClientIds
  26366. } = select(store);
  26367. const {
  26368. getGroupingBlockName
  26369. } = select(external_wp_blocks_namespaceObject.store);
  26370. const _clientIds = getSelectedBlockClientIds();
  26371. const _groupingBlockName = getGroupingBlockName();
  26372. const rootClientId = !!(_clientIds !== null && _clientIds !== void 0 && _clientIds.length) ? getBlockRootClientId(_clientIds[0]) : undefined;
  26373. const groupingBlockAvailable = canInsertBlockType(_groupingBlockName, rootClientId);
  26374. const _blocksSelection = getBlocksByClientId(_clientIds);
  26375. const isSingleGroupingBlock = _blocksSelection.length === 1 && ((_blocksSelection$ = _blocksSelection[0]) === null || _blocksSelection$ === void 0 ? void 0 : _blocksSelection$.name) === _groupingBlockName; // Do we have
  26376. // 1. Grouping block available to be inserted?
  26377. // 2. One or more blocks selected
  26378. const _isGroupable = groupingBlockAvailable && _blocksSelection.length; // Do we have a single Group Block selected and does that group have inner blocks?
  26379. const _isUngroupable = isSingleGroupingBlock && !!_blocksSelection[0].innerBlocks.length;
  26380. return {
  26381. clientIds: _clientIds,
  26382. isGroupable: _isGroupable,
  26383. isUngroupable: _isUngroupable,
  26384. blocksSelection: _blocksSelection,
  26385. groupingBlockName: _groupingBlockName
  26386. };
  26387. }, []);
  26388. return {
  26389. clientIds,
  26390. isGroupable,
  26391. isUngroupable,
  26392. blocksSelection,
  26393. groupingBlockName
  26394. };
  26395. }
  26396. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/index.js
  26397. /**
  26398. * WordPress dependencies
  26399. */
  26400. /**
  26401. * Internal dependencies
  26402. */
  26403. function ConvertToGroupButton(_ref) {
  26404. let {
  26405. clientIds,
  26406. isGroupable,
  26407. isUngroupable,
  26408. blocksSelection,
  26409. groupingBlockName,
  26410. onClose = () => {}
  26411. } = _ref;
  26412. const {
  26413. replaceBlocks
  26414. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  26415. const onConvertToGroup = () => {
  26416. // Activate the `transform` on the Grouping Block which does the conversion.
  26417. const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocksSelection, groupingBlockName);
  26418. if (newBlocks) {
  26419. replaceBlocks(clientIds, newBlocks);
  26420. }
  26421. };
  26422. const onConvertFromGroup = () => {
  26423. const innerBlocks = blocksSelection[0].innerBlocks;
  26424. if (!innerBlocks.length) {
  26425. return;
  26426. }
  26427. replaceBlocks(clientIds, innerBlocks);
  26428. };
  26429. if (!isGroupable && !isUngroupable) {
  26430. return null;
  26431. }
  26432. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isGroupable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26433. onClick: () => {
  26434. onConvertToGroup();
  26435. onClose();
  26436. }
  26437. }, (0,external_wp_i18n_namespaceObject._x)('Group', 'verb')), isUngroupable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26438. onClick: () => {
  26439. onConvertFromGroup();
  26440. onClose();
  26441. }
  26442. }, (0,external_wp_i18n_namespaceObject._x)('Ungroup', 'Ungrouping blocks from within a Group block back into individual blocks within the Editor ')));
  26443. }
  26444. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/use-block-lock.js
  26445. /**
  26446. * WordPress dependencies
  26447. */
  26448. /**
  26449. * Internal dependencies
  26450. */
  26451. /**
  26452. * Return details about the block lock status.
  26453. *
  26454. * @param {string} clientId The block client Id.
  26455. *
  26456. * @return {Object} Block lock status
  26457. */
  26458. function useBlockLock(clientId) {
  26459. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  26460. const {
  26461. canEditBlock,
  26462. canMoveBlock,
  26463. canRemoveBlock,
  26464. canLockBlockType,
  26465. getBlockName,
  26466. getBlockRootClientId,
  26467. getTemplateLock
  26468. } = select(store);
  26469. const rootClientId = getBlockRootClientId(clientId);
  26470. const canEdit = canEditBlock(clientId);
  26471. const canMove = canMoveBlock(clientId, rootClientId);
  26472. const canRemove = canRemoveBlock(clientId, rootClientId);
  26473. return {
  26474. canEdit,
  26475. canMove,
  26476. canRemove,
  26477. canLock: canLockBlockType(getBlockName(clientId)),
  26478. isContentLocked: getTemplateLock(clientId) === 'contentOnly',
  26479. isLocked: !canEdit || !canMove || !canRemove
  26480. };
  26481. }, [clientId]);
  26482. }
  26483. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/unlock.js
  26484. /**
  26485. * WordPress dependencies
  26486. */
  26487. const unlock = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  26488. viewBox: "0 0 24 24",
  26489. xmlns: "http://www.w3.org/2000/svg"
  26490. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  26491. d: "M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8h1.5c0-1.2 1-2.2 2.2-2.2s2.2 1 2.2 2.2v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1z"
  26492. }));
  26493. /* harmony default export */ var library_unlock = (unlock);
  26494. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/lock.js
  26495. /**
  26496. * WordPress dependencies
  26497. */
  26498. const lock = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  26499. viewBox: "0 0 24 24",
  26500. xmlns: "http://www.w3.org/2000/svg"
  26501. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  26502. d: "M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1zm-2.8 0H9.8V7c0-1.2 1-2.2 2.2-2.2s2.2 1 2.2 2.2v3z"
  26503. }));
  26504. /* harmony default export */ var library_lock = (lock);
  26505. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/modal.js
  26506. /**
  26507. * WordPress dependencies
  26508. */
  26509. /**
  26510. * Internal dependencies
  26511. */
  26512. function getTemplateLockValue(lock) {
  26513. // Prevents all operations.
  26514. if (lock.remove && lock.move) {
  26515. return 'all';
  26516. } // Prevents inserting or removing blocks, but allows moving existing blocks.
  26517. if (lock.remove && !lock.move) {
  26518. return 'insert';
  26519. }
  26520. return false;
  26521. }
  26522. function BlockLockModal(_ref) {
  26523. let {
  26524. clientId,
  26525. onClose
  26526. } = _ref;
  26527. const [lock, setLock] = (0,external_wp_element_namespaceObject.useState)({
  26528. move: false,
  26529. remove: false
  26530. });
  26531. const {
  26532. canEdit,
  26533. canMove,
  26534. canRemove
  26535. } = useBlockLock(clientId);
  26536. const {
  26537. isReusable,
  26538. templateLock,
  26539. hasTemplateLock
  26540. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  26541. var _getBlockAttributes, _blockType$attributes;
  26542. const {
  26543. getBlockName,
  26544. getBlockAttributes
  26545. } = select(store);
  26546. const blockName = getBlockName(clientId);
  26547. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName);
  26548. return {
  26549. isReusable: (0,external_wp_blocks_namespaceObject.isReusableBlock)(blockType),
  26550. templateLock: (_getBlockAttributes = getBlockAttributes(clientId)) === null || _getBlockAttributes === void 0 ? void 0 : _getBlockAttributes.templateLock,
  26551. hasTemplateLock: !!(blockType !== null && blockType !== void 0 && (_blockType$attributes = blockType.attributes) !== null && _blockType$attributes !== void 0 && _blockType$attributes.templateLock)
  26552. };
  26553. }, [clientId]);
  26554. const [applyTemplateLock, setApplyTemplateLock] = (0,external_wp_element_namespaceObject.useState)(!!templateLock);
  26555. const {
  26556. updateBlockAttributes
  26557. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  26558. const blockInformation = useBlockDisplayInformation(clientId);
  26559. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockLockModal, 'block-editor-block-lock-modal__options-title');
  26560. (0,external_wp_element_namespaceObject.useEffect)(() => {
  26561. setLock({
  26562. move: !canMove,
  26563. remove: !canRemove,
  26564. ...(isReusable ? {
  26565. edit: !canEdit
  26566. } : {})
  26567. });
  26568. }, [canEdit, canMove, canRemove, isReusable]);
  26569. const isAllChecked = Object.values(lock).every(Boolean);
  26570. const isMixed = Object.values(lock).some(Boolean) && !isAllChecked;
  26571. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
  26572. title: (0,external_wp_i18n_namespaceObject.sprintf)(
  26573. /* translators: %s: Name of the block. */
  26574. (0,external_wp_i18n_namespaceObject.__)('Lock %s'), blockInformation.title),
  26575. overlayClassName: "block-editor-block-lock-modal",
  26576. closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
  26577. onRequestClose: onClose
  26578. }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Choose specific attributes to restrict or lock all available options.')), (0,external_wp_element_namespaceObject.createElement)("form", {
  26579. onSubmit: event => {
  26580. event.preventDefault();
  26581. updateBlockAttributes([clientId], {
  26582. lock,
  26583. templateLock: applyTemplateLock ? getTemplateLockValue(lock) : undefined
  26584. });
  26585. onClose();
  26586. }
  26587. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  26588. role: "group",
  26589. "aria-labelledby": instanceId,
  26590. className: "block-editor-block-lock-modal__options"
  26591. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  26592. className: "block-editor-block-lock-modal__options-title",
  26593. label: (0,external_wp_element_namespaceObject.createElement)("span", {
  26594. id: instanceId
  26595. }, (0,external_wp_i18n_namespaceObject.__)('Lock all')),
  26596. checked: isAllChecked,
  26597. indeterminate: isMixed,
  26598. onChange: newValue => setLock({
  26599. move: newValue,
  26600. remove: newValue,
  26601. ...(isReusable ? {
  26602. edit: newValue
  26603. } : {})
  26604. })
  26605. }), (0,external_wp_element_namespaceObject.createElement)("ul", {
  26606. className: "block-editor-block-lock-modal__checklist"
  26607. }, isReusable && (0,external_wp_element_namespaceObject.createElement)("li", {
  26608. className: "block-editor-block-lock-modal__checklist-item"
  26609. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  26610. label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Restrict editing'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
  26611. icon: lock.edit ? library_lock : library_unlock
  26612. })),
  26613. checked: !!lock.edit,
  26614. onChange: edit => setLock(prevLock => ({ ...prevLock,
  26615. edit
  26616. }))
  26617. })), (0,external_wp_element_namespaceObject.createElement)("li", {
  26618. className: "block-editor-block-lock-modal__checklist-item"
  26619. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  26620. label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Disable movement'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
  26621. icon: lock.move ? library_lock : library_unlock
  26622. })),
  26623. checked: lock.move,
  26624. onChange: move => setLock(prevLock => ({ ...prevLock,
  26625. move
  26626. }))
  26627. })), (0,external_wp_element_namespaceObject.createElement)("li", {
  26628. className: "block-editor-block-lock-modal__checklist-item"
  26629. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  26630. label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Prevent removal'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
  26631. icon: lock.remove ? library_lock : library_unlock
  26632. })),
  26633. checked: lock.remove,
  26634. onChange: remove => setLock(prevLock => ({ ...prevLock,
  26635. remove
  26636. }))
  26637. }))), hasTemplateLock && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  26638. className: "block-editor-block-lock-modal__template-lock",
  26639. label: (0,external_wp_i18n_namespaceObject.__)('Apply to all blocks inside'),
  26640. checked: applyTemplateLock,
  26641. disabled: lock.move && !lock.remove,
  26642. onChange: () => setApplyTemplateLock(!applyTemplateLock)
  26643. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
  26644. className: "block-editor-block-lock-modal__actions",
  26645. justify: "flex-end",
  26646. expanded: false
  26647. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  26648. variant: "tertiary",
  26649. onClick: onClose
  26650. }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  26651. variant: "primary",
  26652. type: "submit"
  26653. }, (0,external_wp_i18n_namespaceObject.__)('Apply'))))));
  26654. }
  26655. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/menu-item.js
  26656. /**
  26657. * WordPress dependencies
  26658. */
  26659. /**
  26660. * Internal dependencies
  26661. */
  26662. function BlockLockMenuItem(_ref) {
  26663. let {
  26664. clientId
  26665. } = _ref;
  26666. const {
  26667. canLock,
  26668. isLocked
  26669. } = useBlockLock(clientId);
  26670. const [isModalOpen, toggleModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false);
  26671. if (!canLock) {
  26672. return null;
  26673. }
  26674. const label = isLocked ? (0,external_wp_i18n_namespaceObject.__)('Unlock') : (0,external_wp_i18n_namespaceObject.__)('Lock');
  26675. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26676. icon: isLocked ? library_unlock : library_lock,
  26677. onClick: toggleModal
  26678. }, label), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(BlockLockModal, {
  26679. clientId: clientId,
  26680. onClose: toggleModal
  26681. }));
  26682. }
  26683. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu-controls/index.js
  26684. /**
  26685. * External dependencies
  26686. */
  26687. /**
  26688. * WordPress dependencies
  26689. */
  26690. /**
  26691. * Internal dependencies
  26692. */
  26693. const {
  26694. Fill,
  26695. Slot: block_settings_menu_controls_Slot
  26696. } = (0,external_wp_components_namespaceObject.createSlotFill)('BlockSettingsMenuControls');
  26697. const BlockSettingsMenuControlsSlot = _ref => {
  26698. let {
  26699. fillProps,
  26700. clientIds = null,
  26701. __unstableDisplayLocation
  26702. } = _ref;
  26703. const {
  26704. selectedBlocks,
  26705. selectedClientIds,
  26706. canRemove
  26707. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  26708. const {
  26709. getBlocksByClientId,
  26710. getSelectedBlockClientIds,
  26711. canRemoveBlocks
  26712. } = select(store);
  26713. const ids = clientIds !== null ? clientIds : getSelectedBlockClientIds();
  26714. return {
  26715. selectedBlocks: (0,external_lodash_namespaceObject.map)(getBlocksByClientId(ids).filter(Boolean), block => block.name),
  26716. selectedClientIds: ids,
  26717. canRemove: canRemoveBlocks(ids)
  26718. };
  26719. }, [clientIds]);
  26720. const {
  26721. canLock
  26722. } = useBlockLock(selectedClientIds[0]);
  26723. const showLockButton = selectedClientIds.length === 1 && canLock; // Check if current selection of blocks is Groupable or Ungroupable
  26724. // and pass this props down to ConvertToGroupButton.
  26725. const convertToGroupButtonProps = useConvertToGroupButtonProps();
  26726. const {
  26727. isGroupable,
  26728. isUngroupable
  26729. } = convertToGroupButtonProps;
  26730. const showConvertToGroupButton = (isGroupable || isUngroupable) && canRemove;
  26731. return (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls_Slot, {
  26732. fillProps: { ...fillProps,
  26733. __unstableDisplayLocation,
  26734. selectedBlocks,
  26735. selectedClientIds
  26736. }
  26737. }, fills => {
  26738. if (!(fills !== null && fills !== void 0 && fills.length) > 0 && !showConvertToGroupButton && !showLockButton) {
  26739. return null;
  26740. }
  26741. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, showLockButton && (0,external_wp_element_namespaceObject.createElement)(BlockLockMenuItem, {
  26742. clientId: selectedClientIds[0]
  26743. }), fills, showConvertToGroupButton && (0,external_wp_element_namespaceObject.createElement)(ConvertToGroupButton, _extends({}, convertToGroupButtonProps, {
  26744. onClose: fillProps === null || fillProps === void 0 ? void 0 : fillProps.onClose
  26745. })));
  26746. });
  26747. };
  26748. /**
  26749. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-settings-menu-controls/README.md
  26750. *
  26751. * @param {Object} props Fill props.
  26752. * @return {WPElement} Element.
  26753. */
  26754. function BlockSettingsMenuControls(_ref2) {
  26755. let { ...props
  26756. } = _ref2;
  26757. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
  26758. document: document
  26759. }, (0,external_wp_element_namespaceObject.createElement)(Fill, props));
  26760. }
  26761. BlockSettingsMenuControls.Slot = BlockSettingsMenuControlsSlot;
  26762. /* harmony default export */ var block_settings_menu_controls = (BlockSettingsMenuControls);
  26763. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-dropdown.js
  26764. /**
  26765. * External dependencies
  26766. */
  26767. /**
  26768. * WordPress dependencies
  26769. */
  26770. /**
  26771. * Internal dependencies
  26772. */
  26773. const block_settings_dropdown_noop = () => {};
  26774. const block_settings_dropdown_POPOVER_PROPS = {
  26775. className: 'block-editor-block-settings-menu__popover',
  26776. position: 'bottom right',
  26777. isAlternate: true
  26778. };
  26779. function CopyMenuItem(_ref) {
  26780. let {
  26781. blocks,
  26782. onCopy
  26783. } = _ref;
  26784. const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(() => (0,external_wp_blocks_namespaceObject.serialize)(blocks), onCopy);
  26785. const copyMenuItemLabel = blocks.length > 1 ? (0,external_wp_i18n_namespaceObject.__)('Copy blocks') : (0,external_wp_i18n_namespaceObject.__)('Copy block');
  26786. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26787. ref: ref
  26788. }, copyMenuItemLabel);
  26789. }
  26790. function BlockSettingsDropdown(_ref2) {
  26791. let {
  26792. clientIds,
  26793. __experimentalSelectBlock,
  26794. children,
  26795. __unstableDisplayLocation,
  26796. ...props
  26797. } = _ref2;
  26798. const blockClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
  26799. const count = blockClientIds.length;
  26800. const firstBlockClientId = blockClientIds[0];
  26801. const {
  26802. firstParentClientId,
  26803. hasReducedUI,
  26804. onlyBlock,
  26805. parentBlockType,
  26806. previousBlockClientId,
  26807. nextBlockClientId,
  26808. selectedBlockClientIds
  26809. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  26810. const {
  26811. getBlockCount,
  26812. getBlockName,
  26813. getBlockParents,
  26814. getPreviousBlockClientId,
  26815. getNextBlockClientId,
  26816. getSelectedBlockClientIds,
  26817. getSettings
  26818. } = select(store);
  26819. const parents = getBlockParents(firstBlockClientId);
  26820. const _firstParentClientId = parents[parents.length - 1];
  26821. const parentBlockName = getBlockName(_firstParentClientId);
  26822. return {
  26823. firstParentClientId: _firstParentClientId,
  26824. hasReducedUI: getSettings().hasReducedUI,
  26825. onlyBlock: 1 === getBlockCount(),
  26826. parentBlockType: (0,external_wp_blocks_namespaceObject.getBlockType)(parentBlockName),
  26827. previousBlockClientId: getPreviousBlockClientId(firstBlockClientId),
  26828. nextBlockClientId: getNextBlockClientId(firstBlockClientId),
  26829. selectedBlockClientIds: getSelectedBlockClientIds()
  26830. };
  26831. }, [firstBlockClientId]);
  26832. const shortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
  26833. const {
  26834. getShortcutRepresentation
  26835. } = select(external_wp_keyboardShortcuts_namespaceObject.store);
  26836. return {
  26837. duplicate: getShortcutRepresentation('core/block-editor/duplicate'),
  26838. remove: getShortcutRepresentation('core/block-editor/remove'),
  26839. insertAfter: getShortcutRepresentation('core/block-editor/insert-after'),
  26840. insertBefore: getShortcutRepresentation('core/block-editor/insert-before')
  26841. };
  26842. }, []);
  26843. const {
  26844. selectBlock,
  26845. toggleBlockHighlight
  26846. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  26847. const updateSelectionAfterDuplicate = (0,external_wp_element_namespaceObject.useCallback)(__experimentalSelectBlock ? async clientIdsPromise => {
  26848. const ids = await clientIdsPromise;
  26849. if (ids && ids[0]) {
  26850. __experimentalSelectBlock(ids[0]);
  26851. }
  26852. } : block_settings_dropdown_noop, [__experimentalSelectBlock]);
  26853. const blockTitle = useBlockDisplayTitle({
  26854. clientId: firstBlockClientId,
  26855. maximumLength: 25
  26856. });
  26857. const updateSelectionAfterRemove = (0,external_wp_element_namespaceObject.useCallback)(__experimentalSelectBlock ? () => {
  26858. const blockToSelect = previousBlockClientId || nextBlockClientId;
  26859. if (blockToSelect && // From the block options dropdown, it's possible to remove a block that is not selected,
  26860. // in this case, it's not necessary to update the selection since the selected block wasn't removed.
  26861. selectedBlockClientIds.includes(firstBlockClientId) && // Don't update selection when next/prev block also is in the selection ( and gets removed ),
  26862. // In case someone selects all blocks and removes them at once.
  26863. !selectedBlockClientIds.includes(blockToSelect)) {
  26864. __experimentalSelectBlock(blockToSelect);
  26865. }
  26866. } : block_settings_dropdown_noop, [__experimentalSelectBlock, previousBlockClientId, nextBlockClientId, selectedBlockClientIds]);
  26867. const label = (0,external_wp_i18n_namespaceObject.sprintf)(
  26868. /* translators: %s: block name */
  26869. (0,external_wp_i18n_namespaceObject.__)('Remove %s'), blockTitle);
  26870. const removeBlockLabel = count === 1 ? label : (0,external_wp_i18n_namespaceObject.__)('Remove blocks'); // Allows highlighting the parent block outline when focusing or hovering
  26871. // the parent block selector within the child.
  26872. const selectParentButtonRef = (0,external_wp_element_namespaceObject.useRef)();
  26873. const {
  26874. gestures: showParentOutlineGestures
  26875. } = useShowMoversGestures({
  26876. ref: selectParentButtonRef,
  26877. onChange(isFocused) {
  26878. if (isFocused && hasReducedUI) {
  26879. return;
  26880. }
  26881. toggleBlockHighlight(firstParentClientId, isFocused);
  26882. }
  26883. });
  26884. return (0,external_wp_element_namespaceObject.createElement)(BlockActions, {
  26885. clientIds: clientIds,
  26886. __experimentalUpdateSelection: !__experimentalSelectBlock
  26887. }, _ref3 => {
  26888. let {
  26889. canDuplicate,
  26890. canInsertDefaultBlock,
  26891. canMove,
  26892. canRemove,
  26893. onDuplicate,
  26894. onInsertAfter,
  26895. onInsertBefore,
  26896. onRemove,
  26897. onCopy,
  26898. onMoveTo,
  26899. blocks
  26900. } = _ref3;
  26901. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, _extends({
  26902. icon: more_vertical,
  26903. label: (0,external_wp_i18n_namespaceObject.__)('Options'),
  26904. className: "block-editor-block-settings-menu",
  26905. popoverProps: block_settings_dropdown_POPOVER_PROPS,
  26906. noIcons: true
  26907. }, props), _ref4 => {
  26908. let {
  26909. onClose
  26910. } = _ref4;
  26911. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_first_item.Slot, {
  26912. fillProps: {
  26913. onClose
  26914. }
  26915. }), firstParentClientId !== undefined && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, _extends({}, showParentOutlineGestures, {
  26916. ref: selectParentButtonRef,
  26917. icon: (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  26918. icon: parentBlockType.icon
  26919. }),
  26920. onClick: () => selectBlock(firstParentClientId)
  26921. }), (0,external_wp_i18n_namespaceObject.sprintf)(
  26922. /* translators: %s: Name of the block's parent. */
  26923. (0,external_wp_i18n_namespaceObject.__)('Select parent block (%s)'), parentBlockType.title)), count === 1 && (0,external_wp_element_namespaceObject.createElement)(block_html_convert_button, {
  26924. clientId: firstBlockClientId
  26925. }), (0,external_wp_element_namespaceObject.createElement)(CopyMenuItem, {
  26926. blocks: blocks,
  26927. onCopy: onCopy
  26928. }), canDuplicate && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26929. onClick: (0,external_lodash_namespaceObject.flow)(onClose, onDuplicate, updateSelectionAfterDuplicate),
  26930. shortcut: shortcuts.duplicate
  26931. }, (0,external_wp_i18n_namespaceObject.__)('Duplicate')), canInsertDefaultBlock && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26932. onClick: (0,external_lodash_namespaceObject.flow)(onClose, onInsertBefore),
  26933. shortcut: shortcuts.insertBefore
  26934. }, (0,external_wp_i18n_namespaceObject.__)('Insert before')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26935. onClick: (0,external_lodash_namespaceObject.flow)(onClose, onInsertAfter),
  26936. shortcut: shortcuts.insertAfter
  26937. }, (0,external_wp_i18n_namespaceObject.__)('Insert after'))), canMove && !onlyBlock && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26938. onClick: (0,external_lodash_namespaceObject.flow)(onClose, onMoveTo)
  26939. }, (0,external_wp_i18n_namespaceObject.__)('Move to')), count === 1 && (0,external_wp_element_namespaceObject.createElement)(block_mode_toggle, {
  26940. clientId: firstBlockClientId,
  26941. onToggle: onClose
  26942. })), (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls.Slot, {
  26943. fillProps: {
  26944. onClose
  26945. },
  26946. clientIds: clientIds,
  26947. __unstableDisplayLocation: __unstableDisplayLocation
  26948. }), typeof children === 'function' ? children({
  26949. onClose
  26950. }) : external_wp_element_namespaceObject.Children.map(child => (0,external_wp_element_namespaceObject.cloneElement)(child, {
  26951. onClose
  26952. })), canRemove && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  26953. onClick: (0,external_lodash_namespaceObject.flow)(onClose, onRemove, updateSelectionAfterRemove),
  26954. shortcut: shortcuts.remove
  26955. }, removeBlockLabel)));
  26956. });
  26957. });
  26958. }
  26959. /* harmony default export */ var block_settings_dropdown = (BlockSettingsDropdown);
  26960. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/index.js
  26961. /**
  26962. * WordPress dependencies
  26963. */
  26964. /**
  26965. * Internal dependencies
  26966. */
  26967. function BlockSettingsMenu(_ref) {
  26968. let {
  26969. clientIds,
  26970. ...props
  26971. } = _ref;
  26972. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(block_settings_dropdown, _extends({
  26973. clientIds: clientIds,
  26974. toggleProps: toggleProps
  26975. }, props))));
  26976. }
  26977. /* harmony default export */ var block_settings_menu = (BlockSettingsMenu);
  26978. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/toolbar.js
  26979. /**
  26980. * WordPress dependencies
  26981. */
  26982. /**
  26983. * Internal dependencies
  26984. */
  26985. function BlockLockToolbar(_ref) {
  26986. let {
  26987. clientId
  26988. } = _ref;
  26989. const blockInformation = useBlockDisplayInformation(clientId);
  26990. const {
  26991. canEdit,
  26992. canMove,
  26993. canRemove,
  26994. canLock
  26995. } = useBlockLock(clientId);
  26996. const [isModalOpen, toggleModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false);
  26997. if (!canLock) {
  26998. return null;
  26999. }
  27000. if (canEdit && canMove && canRemove) {
  27001. return null;
  27002. }
  27003. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
  27004. className: "block-editor-block-lock-toolbar"
  27005. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  27006. icon: library_lock,
  27007. label: (0,external_wp_i18n_namespaceObject.sprintf)(
  27008. /* translators: %s: block name */
  27009. (0,external_wp_i18n_namespaceObject.__)('Unlock %s'), blockInformation.title),
  27010. onClick: toggleModal
  27011. })), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(BlockLockModal, {
  27012. clientId: clientId,
  27013. onClose: toggleModal
  27014. }));
  27015. }
  27016. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/group.js
  27017. /**
  27018. * WordPress dependencies
  27019. */
  27020. const group_group = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  27021. viewBox: "0 0 24 24",
  27022. xmlns: "http://www.w3.org/2000/svg"
  27023. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  27024. d: "M18 4h-7c-1.1 0-2 .9-2 2v3H6c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2v-3h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4.5 14c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h3V13c0 1.1.9 2 2 2h2.5v3zm0-4.5H11c-.3 0-.5-.2-.5-.5v-2.5H13c.3 0 .5.2.5.5v2.5zm5-.5c0 .3-.2.5-.5.5h-3V11c0-1.1-.9-2-2-2h-2.5V6c0-.3.2-.5.5-.5h7c.3 0 .5.2.5.5v7z"
  27025. }));
  27026. /* harmony default export */ var library_group = (group_group);
  27027. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/row.js
  27028. /**
  27029. * WordPress dependencies
  27030. */
  27031. const row = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  27032. xmlns: "http://www.w3.org/2000/svg",
  27033. viewBox: "0 0 24 24"
  27034. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  27035. d: "M9.2 6.5H4V8h5.2c.3 0 .5.2.5.5v7c0 .3-.2.5-.5.5H4v1.5h5.2c1.1 0 2-.9 2-2v-7c0-1.1-.8-2-2-2zM14.8 8H20V6.5h-5.2c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2H20V16h-5.2c-.3 0-.5-.2-.5-.5v-7c-.1-.3.2-.5.5-.5z"
  27036. }));
  27037. /* harmony default export */ var library_row = (row);
  27038. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stack.js
  27039. /**
  27040. * WordPress dependencies
  27041. */
  27042. const stack = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  27043. xmlns: "http://www.w3.org/2000/svg",
  27044. viewBox: "0 0 24 24"
  27045. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  27046. d: "M16 4v5.2c0 .3-.2.5-.5.5h-7c-.3.1-.5-.2-.5-.5V4H6.5v5.2c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2V4H16zm-.5 8.8h-7c-1.1 0-2 .9-2 2V20H8v-5.2c0-.3.2-.5.5-.5h7c.3 0 .5.2.5.5V20h1.5v-5.2c0-1.2-.9-2-2-2z"
  27047. }));
  27048. /* harmony default export */ var library_stack = (stack);
  27049. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/toolbar.js
  27050. /**
  27051. * WordPress dependencies
  27052. */
  27053. /**
  27054. * Internal dependencies
  27055. */
  27056. const layouts = {
  27057. group: {
  27058. type: 'constrained'
  27059. },
  27060. row: {
  27061. type: 'flex',
  27062. flexWrap: 'nowrap'
  27063. },
  27064. stack: {
  27065. type: 'flex',
  27066. orientation: 'vertical'
  27067. }
  27068. };
  27069. function BlockGroupToolbar() {
  27070. const {
  27071. blocksSelection,
  27072. clientIds,
  27073. groupingBlockName,
  27074. isGroupable
  27075. } = useConvertToGroupButtonProps();
  27076. const {
  27077. replaceBlocks
  27078. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  27079. const {
  27080. canRemove,
  27081. variations
  27082. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  27083. const {
  27084. canRemoveBlocks
  27085. } = select(store);
  27086. const {
  27087. getBlockVariations
  27088. } = select(external_wp_blocks_namespaceObject.store);
  27089. return {
  27090. canRemove: canRemoveBlocks(clientIds),
  27091. variations: getBlockVariations(groupingBlockName, 'transform')
  27092. };
  27093. }, [clientIds, groupingBlockName]);
  27094. const onConvertToGroup = layout => {
  27095. const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocksSelection, groupingBlockName);
  27096. if (typeof layout !== 'string') {
  27097. layout = 'group';
  27098. }
  27099. if (newBlocks && newBlocks.length > 0) {
  27100. // Because the block is not in the store yet we can't use
  27101. // updateBlockAttributes so need to manually update attributes.
  27102. newBlocks[0].attributes.layout = layouts[layout];
  27103. replaceBlocks(clientIds, newBlocks);
  27104. }
  27105. };
  27106. const onConvertToRow = () => onConvertToGroup('row');
  27107. const onConvertToStack = () => onConvertToGroup('stack'); // Don't render the button if the current selection cannot be grouped.
  27108. // A good example is selecting multiple button blocks within a Buttons block:
  27109. // The group block is not a valid child of Buttons, so we should not show the button.
  27110. // Any blocks that are locked against removal also cannot be grouped.
  27111. if (!isGroupable || !canRemove) {
  27112. return null;
  27113. }
  27114. const canInsertRow = !!variations.find(_ref => {
  27115. let {
  27116. name
  27117. } = _ref;
  27118. return name === 'group-row';
  27119. });
  27120. const canInsertStack = !!variations.find(_ref2 => {
  27121. let {
  27122. name
  27123. } = _ref2;
  27124. return name === 'group-stack';
  27125. });
  27126. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  27127. icon: library_group,
  27128. label: (0,external_wp_i18n_namespaceObject._x)('Group', 'verb'),
  27129. onClick: onConvertToGroup
  27130. }), canInsertRow && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  27131. icon: library_row,
  27132. label: (0,external_wp_i18n_namespaceObject._x)('Row', 'single horizontal line'),
  27133. onClick: onConvertToRow
  27134. }), canInsertStack && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  27135. icon: library_stack,
  27136. label: (0,external_wp_i18n_namespaceObject._x)('Stack', 'verb'),
  27137. onClick: onConvertToStack
  27138. }));
  27139. }
  27140. /* harmony default export */ var toolbar = (BlockGroupToolbar);
  27141. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit-visually-button/index.js
  27142. /**
  27143. * WordPress dependencies
  27144. */
  27145. /**
  27146. * Internal dependencies
  27147. */
  27148. function BlockEditVisuallyButton(_ref) {
  27149. let {
  27150. clientIds
  27151. } = _ref;
  27152. // Edit visually only works for single block selection.
  27153. const clientId = clientIds.length === 1 ? clientIds[0] : undefined;
  27154. const canEditVisually = (0,external_wp_data_namespaceObject.useSelect)(select => !!clientId && select(store).getBlockMode(clientId) === 'html', [clientId]);
  27155. const {
  27156. toggleBlockMode
  27157. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  27158. if (!canEditVisually) {
  27159. return null;
  27160. }
  27161. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  27162. onClick: () => {
  27163. toggleBlockMode(clientId);
  27164. }
  27165. }, (0,external_wp_i18n_namespaceObject.__)('Edit visually')));
  27166. }
  27167. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/block-name-context.js
  27168. /**
  27169. * WordPress dependencies
  27170. */
  27171. const __unstableBlockNameContext = (0,external_wp_element_namespaceObject.createContext)('');
  27172. /* harmony default export */ var block_name_context = (__unstableBlockNameContext);
  27173. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/index.js
  27174. /**
  27175. * External dependencies
  27176. */
  27177. /**
  27178. * WordPress dependencies
  27179. */
  27180. /**
  27181. * Internal dependencies
  27182. */
  27183. const BlockToolbar = _ref => {
  27184. let {
  27185. hideDragHandle
  27186. } = _ref;
  27187. const {
  27188. blockClientIds,
  27189. blockClientId,
  27190. blockType,
  27191. hasFixedToolbar,
  27192. hasReducedUI,
  27193. isValid,
  27194. isVisual,
  27195. isContentLocked
  27196. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  27197. const {
  27198. getBlockName,
  27199. getBlockMode,
  27200. getSelectedBlockClientIds,
  27201. isBlockValid,
  27202. getBlockRootClientId,
  27203. getSettings,
  27204. __unstableGetContentLockingParent
  27205. } = select(store);
  27206. const selectedBlockClientIds = getSelectedBlockClientIds();
  27207. const selectedBlockClientId = selectedBlockClientIds[0];
  27208. const blockRootClientId = getBlockRootClientId(selectedBlockClientId);
  27209. const settings = getSettings();
  27210. return {
  27211. blockClientIds: selectedBlockClientIds,
  27212. blockClientId: selectedBlockClientId,
  27213. blockType: selectedBlockClientId && (0,external_wp_blocks_namespaceObject.getBlockType)(getBlockName(selectedBlockClientId)),
  27214. hasFixedToolbar: settings.hasFixedToolbar,
  27215. hasReducedUI: settings.hasReducedUI,
  27216. rootClientId: blockRootClientId,
  27217. isValid: selectedBlockClientIds.every(id => isBlockValid(id)),
  27218. isVisual: selectedBlockClientIds.every(id => getBlockMode(id) === 'visual'),
  27219. isContentLocked: !!__unstableGetContentLockingParent(selectedBlockClientId)
  27220. };
  27221. }, []); // Handles highlighting the current block outline on hover or focus of the
  27222. // block type toolbar area.
  27223. const {
  27224. toggleBlockHighlight
  27225. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  27226. const nodeRef = (0,external_wp_element_namespaceObject.useRef)();
  27227. const {
  27228. showMovers,
  27229. gestures: showMoversGestures
  27230. } = useShowMoversGestures({
  27231. ref: nodeRef,
  27232. onChange(isFocused) {
  27233. if (isFocused && hasReducedUI) {
  27234. return;
  27235. }
  27236. toggleBlockHighlight(blockClientId, isFocused);
  27237. }
  27238. }); // Account for the cases where the block toolbar is rendered within the
  27239. // header area and not contextually to the block.
  27240. const displayHeaderToolbar = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<') || hasFixedToolbar;
  27241. if (blockType) {
  27242. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalToolbar', true)) {
  27243. return null;
  27244. }
  27245. }
  27246. const shouldShowMovers = displayHeaderToolbar || showMovers;
  27247. if (blockClientIds.length === 0) {
  27248. return null;
  27249. }
  27250. const shouldShowVisualToolbar = isValid && isVisual;
  27251. const isMultiToolbar = blockClientIds.length > 1;
  27252. const classes = classnames_default()('block-editor-block-toolbar', shouldShowMovers && 'is-showing-movers');
  27253. return (0,external_wp_element_namespaceObject.createElement)("div", {
  27254. className: classes
  27255. }, !isMultiToolbar && !displayHeaderToolbar && !isContentLocked && (0,external_wp_element_namespaceObject.createElement)(BlockParentSelector, null), (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  27256. ref: nodeRef
  27257. }, showMoversGestures), (shouldShowVisualToolbar || isMultiToolbar) && !isContentLocked && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
  27258. className: "block-editor-block-toolbar__block-controls"
  27259. }, (0,external_wp_element_namespaceObject.createElement)(block_switcher, {
  27260. clientIds: blockClientIds
  27261. }), !isMultiToolbar && (0,external_wp_element_namespaceObject.createElement)(BlockLockToolbar, {
  27262. clientId: blockClientIds[0]
  27263. }), (0,external_wp_element_namespaceObject.createElement)(block_mover, {
  27264. clientIds: blockClientIds,
  27265. hideDragHandle: hideDragHandle || hasReducedUI
  27266. }))), shouldShowVisualToolbar && isMultiToolbar && (0,external_wp_element_namespaceObject.createElement)(toolbar, null), shouldShowVisualToolbar && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
  27267. group: "parent",
  27268. className: "block-editor-block-toolbar__slot"
  27269. }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
  27270. group: "block",
  27271. className: "block-editor-block-toolbar__slot"
  27272. }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
  27273. className: "block-editor-block-toolbar__slot"
  27274. }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
  27275. group: "inline",
  27276. className: "block-editor-block-toolbar__slot"
  27277. }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
  27278. group: "other",
  27279. className: "block-editor-block-toolbar__slot"
  27280. }), (0,external_wp_element_namespaceObject.createElement)(block_name_context.Provider, {
  27281. value: blockType === null || blockType === void 0 ? void 0 : blockType.name
  27282. }, (0,external_wp_element_namespaceObject.createElement)(block_toolbar_last_item.Slot, null))), (0,external_wp_element_namespaceObject.createElement)(BlockEditVisuallyButton, {
  27283. clientIds: blockClientIds
  27284. }), !isContentLocked && (0,external_wp_element_namespaceObject.createElement)(block_settings_menu, {
  27285. clientIds: blockClientIds
  27286. }));
  27287. };
  27288. /**
  27289. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md
  27290. */
  27291. /* harmony default export */ var block_toolbar = (BlockToolbar);
  27292. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-contextual-toolbar.js
  27293. /**
  27294. * External dependencies
  27295. */
  27296. /**
  27297. * WordPress dependencies
  27298. */
  27299. /**
  27300. * Internal dependencies
  27301. */
  27302. function BlockContextualToolbar(_ref) {
  27303. let {
  27304. focusOnMount,
  27305. isFixed,
  27306. ...props
  27307. } = _ref;
  27308. const {
  27309. blockType,
  27310. hasParents,
  27311. showParentSelector
  27312. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  27313. const {
  27314. getBlockName,
  27315. getBlockParents,
  27316. getSelectedBlockClientIds,
  27317. __unstableGetContentLockingParent
  27318. } = select(store);
  27319. const {
  27320. getBlockType
  27321. } = select(external_wp_blocks_namespaceObject.store);
  27322. const selectedBlockClientIds = getSelectedBlockClientIds();
  27323. const selectedBlockClientId = selectedBlockClientIds[0];
  27324. const parents = getBlockParents(selectedBlockClientId);
  27325. const firstParentClientId = parents[parents.length - 1];
  27326. const parentBlockName = getBlockName(firstParentClientId);
  27327. const parentBlockType = getBlockType(parentBlockName);
  27328. return {
  27329. blockType: selectedBlockClientId && getBlockType(getBlockName(selectedBlockClientId)),
  27330. hasParents: parents.length,
  27331. showParentSelector: parentBlockType && (0,external_wp_blocks_namespaceObject.hasBlockSupport)(parentBlockType, '__experimentalParentSelector', true) && selectedBlockClientIds.length <= 1 && !__unstableGetContentLockingParent(selectedBlockClientId)
  27332. };
  27333. }, []);
  27334. if (blockType) {
  27335. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalToolbar', true)) {
  27336. return null;
  27337. }
  27338. } // Shifts the toolbar to make room for the parent block selector.
  27339. const classes = classnames_default()('block-editor-block-contextual-toolbar', {
  27340. 'has-parent': hasParents && showParentSelector,
  27341. 'is-fixed': isFixed
  27342. });
  27343. return (0,external_wp_element_namespaceObject.createElement)(navigable_toolbar, _extends({
  27344. focusOnMount: focusOnMount,
  27345. className: classes
  27346. /* translators: accessibility text for the block toolbar */
  27347. ,
  27348. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block tools')
  27349. }, props), (0,external_wp_element_namespaceObject.createElement)(block_toolbar, {
  27350. hideDragHandle: isFixed
  27351. }));
  27352. }
  27353. /* harmony default export */ var block_contextual_toolbar = (BlockContextualToolbar);
  27354. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/use-block-toolbar-popover-props.js
  27355. /**
  27356. * WordPress dependencies
  27357. */
  27358. /**
  27359. * Internal dependencies
  27360. */
  27361. // By default the toolbar sets the `shift` prop. If the user scrolls the page
  27362. // down the toolbar will stay on screen by adopting a sticky position at the
  27363. // top of the viewport.
  27364. const use_block_toolbar_popover_props_DEFAULT_PROPS = {
  27365. flip: false,
  27366. shift: true
  27367. }; // When there isn't enough height between the top of the block and the editor
  27368. // canvas, the `shift` prop is set to `false`, as it will cause the block to be
  27369. // obscured. The `flip` behavior is enabled, which positions the toolbar below
  27370. // the block. This only happens if the block is smaller than the viewport, as
  27371. // otherwise the toolbar will be off-screen.
  27372. const RESTRICTED_HEIGHT_PROPS = {
  27373. flip: true,
  27374. shift: false
  27375. };
  27376. /**
  27377. * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.
  27378. *
  27379. * @param {Element} contentElement The DOM element that represents the editor content or canvas.
  27380. * @param {Element} selectedBlockElement The outer DOM element of the first selected block.
  27381. * @param {number} toolbarHeight The height of the toolbar in pixels.
  27382. *
  27383. * @return {Object} The popover props used to determine the position of the toolbar.
  27384. */
  27385. function getProps(contentElement, selectedBlockElement, toolbarHeight) {
  27386. if (!contentElement || !selectedBlockElement) {
  27387. return use_block_toolbar_popover_props_DEFAULT_PROPS;
  27388. }
  27389. const blockRect = selectedBlockElement.getBoundingClientRect();
  27390. const contentRect = contentElement.getBoundingClientRect(); // The document element's clientHeight represents the viewport height.
  27391. const viewportHeight = contentElement.ownerDocument.documentElement.clientHeight;
  27392. const hasSpaceForToolbarAbove = blockRect.top - contentRect.top > toolbarHeight;
  27393. const isBlockTallerThanViewport = blockRect.height > viewportHeight - toolbarHeight;
  27394. if (hasSpaceForToolbarAbove || isBlockTallerThanViewport) {
  27395. return use_block_toolbar_popover_props_DEFAULT_PROPS;
  27396. }
  27397. return RESTRICTED_HEIGHT_PROPS;
  27398. }
  27399. /**
  27400. * Determines the desired popover positioning behavior, returning a set of appropriate props.
  27401. *
  27402. * @param {Object} elements
  27403. * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.
  27404. * @param {string} elements.clientId The clientId of the first selected block.
  27405. *
  27406. * @return {Object} The popover props used to determine the position of the toolbar.
  27407. */
  27408. function useBlockToolbarPopoverProps(_ref) {
  27409. let {
  27410. contentElement,
  27411. clientId
  27412. } = _ref;
  27413. const selectedBlockElement = useBlockElement(clientId);
  27414. const [toolbarHeight, setToolbarHeight] = (0,external_wp_element_namespaceObject.useState)(0);
  27415. const [props, setProps] = (0,external_wp_element_namespaceObject.useState)(() => getProps(contentElement, selectedBlockElement, toolbarHeight));
  27416. const blockIndex = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlockIndex(clientId), [clientId]);
  27417. const popoverRef = (0,external_wp_compose_namespaceObject.useRefEffect)(popoverNode => {
  27418. setToolbarHeight(popoverNode.offsetHeight);
  27419. }, []);
  27420. const updateProps = (0,external_wp_element_namespaceObject.useCallback)(() => setProps(getProps(contentElement, selectedBlockElement, toolbarHeight)), [contentElement, selectedBlockElement, toolbarHeight]); // Update props when the block is moved. This also ensures the props are
  27421. // correct on initial mount, and when the selected block or content element
  27422. // changes (since the callback ref will update).
  27423. (0,external_wp_element_namespaceObject.useLayoutEffect)(updateProps, [blockIndex, updateProps]); // Update props when the viewport is resized or the block is resized.
  27424. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  27425. var _contentElement$owner, _contentView$addEvent, _selectedBlockElement;
  27426. if (!contentElement || !selectedBlockElement) {
  27427. return;
  27428. } // Update the toolbar props on viewport resize.
  27429. const contentView = contentElement === null || contentElement === void 0 ? void 0 : (_contentElement$owner = contentElement.ownerDocument) === null || _contentElement$owner === void 0 ? void 0 : _contentElement$owner.defaultView;
  27430. contentView === null || contentView === void 0 ? void 0 : (_contentView$addEvent = contentView.addEventHandler) === null || _contentView$addEvent === void 0 ? void 0 : _contentView$addEvent.call(contentView, 'resize', updateProps); // Update the toolbar props on block resize.
  27431. let resizeObserver;
  27432. const blockView = selectedBlockElement === null || selectedBlockElement === void 0 ? void 0 : (_selectedBlockElement = selectedBlockElement.ownerDocument) === null || _selectedBlockElement === void 0 ? void 0 : _selectedBlockElement.defaultView;
  27433. if (blockView.ResizeObserver) {
  27434. resizeObserver = new blockView.ResizeObserver(updateProps);
  27435. resizeObserver.observe(selectedBlockElement);
  27436. }
  27437. return () => {
  27438. var _contentView$removeEv;
  27439. contentView === null || contentView === void 0 ? void 0 : (_contentView$removeEv = contentView.removeEventHandler) === null || _contentView$removeEv === void 0 ? void 0 : _contentView$removeEv.call(contentView, 'resize', updateProps);
  27440. if (resizeObserver) {
  27441. resizeObserver.disconnect();
  27442. }
  27443. };
  27444. }, [updateProps, contentElement, selectedBlockElement]);
  27445. return { ...props,
  27446. ref: popoverRef
  27447. };
  27448. }
  27449. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/selected-block-popover.js
  27450. /**
  27451. * External dependencies
  27452. */
  27453. /**
  27454. * WordPress dependencies
  27455. */
  27456. /**
  27457. * Internal dependencies
  27458. */
  27459. function selected_block_popover_selector(select) {
  27460. const {
  27461. __unstableGetEditorMode,
  27462. isMultiSelecting,
  27463. hasMultiSelection,
  27464. isTyping,
  27465. getSettings,
  27466. getLastMultiSelectedBlockClientId
  27467. } = select(store);
  27468. return {
  27469. editorMode: __unstableGetEditorMode(),
  27470. isMultiSelecting: isMultiSelecting(),
  27471. isTyping: isTyping(),
  27472. hasFixedToolbar: getSettings().hasFixedToolbar,
  27473. lastClientId: hasMultiSelection() ? getLastMultiSelectedBlockClientId() : null
  27474. };
  27475. }
  27476. function SelectedBlockPopover(_ref) {
  27477. let {
  27478. clientId,
  27479. rootClientId,
  27480. isEmptyDefaultBlock,
  27481. capturingClientId,
  27482. __unstablePopoverSlot,
  27483. __unstableContentRef
  27484. } = _ref;
  27485. const {
  27486. editorMode,
  27487. isMultiSelecting,
  27488. isTyping,
  27489. hasFixedToolbar,
  27490. lastClientId
  27491. } = (0,external_wp_data_namespaceObject.useSelect)(selected_block_popover_selector, []);
  27492. const isInsertionPointVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
  27493. const {
  27494. isBlockInsertionPointVisible,
  27495. getBlockInsertionPoint,
  27496. getBlockOrder
  27497. } = select(store);
  27498. if (!isBlockInsertionPointVisible()) {
  27499. return false;
  27500. }
  27501. const insertionPoint = getBlockInsertionPoint();
  27502. const order = getBlockOrder(insertionPoint.rootClientId);
  27503. return order[insertionPoint.index] === clientId;
  27504. }, [clientId]);
  27505. const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
  27506. const isToolbarForced = (0,external_wp_element_namespaceObject.useRef)(false);
  27507. const {
  27508. stopTyping
  27509. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  27510. const showEmptyBlockSideInserter = !isTyping && editorMode === 'edit' && isEmptyDefaultBlock;
  27511. const shouldShowBreadcrumb = editorMode === 'navigation' || editorMode === 'zoom-out';
  27512. const shouldShowContextualToolbar = editorMode === 'edit' && !hasFixedToolbar && isLargeViewport && !isMultiSelecting && !showEmptyBlockSideInserter && !isTyping;
  27513. const canFocusHiddenToolbar = editorMode === 'edit' && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock;
  27514. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/block-editor/focus-toolbar', () => {
  27515. isToolbarForced.current = true;
  27516. stopTyping(true);
  27517. }, {
  27518. isDisabled: !canFocusHiddenToolbar
  27519. });
  27520. (0,external_wp_element_namespaceObject.useEffect)(() => {
  27521. isToolbarForced.current = false;
  27522. }); // Stores the active toolbar item index so the block toolbar can return focus
  27523. // to it when re-mounting.
  27524. const initialToolbarItemIndexRef = (0,external_wp_element_namespaceObject.useRef)();
  27525. const popoverProps = useBlockToolbarPopoverProps({
  27526. contentElement: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current,
  27527. clientId
  27528. });
  27529. if (!shouldShowBreadcrumb && !shouldShowContextualToolbar && !showEmptyBlockSideInserter) {
  27530. return null;
  27531. }
  27532. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, showEmptyBlockSideInserter && (0,external_wp_element_namespaceObject.createElement)(block_popover, _extends({
  27533. clientId: capturingClientId || clientId,
  27534. __unstableCoverTarget: true,
  27535. bottomClientId: lastClientId,
  27536. className: classnames_default()('block-editor-block-list__block-side-inserter-popover', {
  27537. 'is-insertion-point-visible': isInsertionPointVisible
  27538. }),
  27539. __unstablePopoverSlot: __unstablePopoverSlot,
  27540. __unstableContentRef: __unstableContentRef,
  27541. resize: false,
  27542. shift: false
  27543. }, popoverProps), (0,external_wp_element_namespaceObject.createElement)("div", {
  27544. className: "block-editor-block-list__empty-block-inserter"
  27545. }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
  27546. position: "bottom right",
  27547. rootClientId: rootClientId,
  27548. clientId: clientId,
  27549. __experimentalIsQuick: true
  27550. }))), (shouldShowBreadcrumb || shouldShowContextualToolbar) && (0,external_wp_element_namespaceObject.createElement)(block_popover, _extends({
  27551. clientId: capturingClientId || clientId,
  27552. bottomClientId: lastClientId,
  27553. className: classnames_default()('block-editor-block-list__block-popover', {
  27554. 'is-insertion-point-visible': isInsertionPointVisible
  27555. }),
  27556. __unstablePopoverSlot: __unstablePopoverSlot,
  27557. __unstableContentRef: __unstableContentRef,
  27558. resize: false
  27559. }, popoverProps), shouldShowContextualToolbar && (0,external_wp_element_namespaceObject.createElement)(block_contextual_toolbar // If the toolbar is being shown because of being forced
  27560. // it should focus the toolbar right after the mount.
  27561. , {
  27562. focusOnMount: isToolbarForced.current,
  27563. __experimentalInitialIndex: initialToolbarItemIndexRef.current,
  27564. __experimentalOnIndexChange: index => {
  27565. initialToolbarItemIndexRef.current = index;
  27566. } // Resets the index whenever the active block changes so
  27567. // this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
  27568. ,
  27569. key: clientId
  27570. }), shouldShowBreadcrumb && (0,external_wp_element_namespaceObject.createElement)(block_selection_button, {
  27571. clientId: clientId,
  27572. rootClientId: rootClientId
  27573. })));
  27574. }
  27575. function wrapperSelector(select) {
  27576. const {
  27577. getSelectedBlockClientId,
  27578. getFirstMultiSelectedBlockClientId,
  27579. getBlockRootClientId,
  27580. getBlock,
  27581. getBlockParents,
  27582. __experimentalGetBlockListSettingsForBlocks
  27583. } = select(store);
  27584. const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
  27585. if (!clientId) {
  27586. return;
  27587. }
  27588. const {
  27589. name,
  27590. attributes = {}
  27591. } = getBlock(clientId) || {};
  27592. const blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId.
  27593. const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(blockParentsClientIds); // Get the clientId of the topmost parent with the capture toolbars setting.
  27594. const capturingClientId = (0,external_lodash_namespaceObject.find)(blockParentsClientIds, parentClientId => {
  27595. var _parentBlockListSetti;
  27596. return (_parentBlockListSetti = parentBlockListSettings[parentClientId]) === null || _parentBlockListSetti === void 0 ? void 0 : _parentBlockListSetti.__experimentalCaptureToolbars;
  27597. });
  27598. return {
  27599. clientId,
  27600. rootClientId: getBlockRootClientId(clientId),
  27601. name,
  27602. isEmptyDefaultBlock: name && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)({
  27603. name,
  27604. attributes
  27605. }),
  27606. capturingClientId
  27607. };
  27608. }
  27609. function WrappedBlockPopover(_ref2) {
  27610. let {
  27611. __unstablePopoverSlot,
  27612. __unstableContentRef
  27613. } = _ref2;
  27614. const selected = (0,external_wp_data_namespaceObject.useSelect)(wrapperSelector, []);
  27615. if (!selected) {
  27616. return null;
  27617. }
  27618. const {
  27619. clientId,
  27620. rootClientId,
  27621. name,
  27622. isEmptyDefaultBlock,
  27623. capturingClientId
  27624. } = selected;
  27625. if (!name) {
  27626. return null;
  27627. }
  27628. return (0,external_wp_element_namespaceObject.createElement)(SelectedBlockPopover, {
  27629. clientId: clientId,
  27630. rootClientId: rootClientId,
  27631. isEmptyDefaultBlock: isEmptyDefaultBlock,
  27632. capturingClientId: capturingClientId,
  27633. __unstablePopoverSlot: __unstablePopoverSlot,
  27634. __unstableContentRef: __unstableContentRef
  27635. });
  27636. }
  27637. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/back-compat.js
  27638. /**
  27639. * WordPress dependencies
  27640. */
  27641. /**
  27642. * Internal dependencies
  27643. */
  27644. function BlockToolsBackCompat(_ref) {
  27645. let {
  27646. children
  27647. } = _ref;
  27648. const openRef = (0,external_wp_element_namespaceObject.useContext)(insertion_point_InsertionPointOpenRef);
  27649. const isDisabled = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.Disabled.Context); // If context is set, `BlockTools` is a parent component.
  27650. if (openRef || isDisabled) {
  27651. return children;
  27652. }
  27653. external_wp_deprecated_default()('wp.components.Popover.Slot name="block-toolbar"', {
  27654. alternative: 'wp.blockEditor.BlockTools',
  27655. since: '5.8'
  27656. });
  27657. return (0,external_wp_element_namespaceObject.createElement)(InsertionPoint, {
  27658. __unstablePopoverSlot: "block-toolbar"
  27659. }, (0,external_wp_element_namespaceObject.createElement)(WrappedBlockPopover, {
  27660. __unstablePopoverSlot: "block-toolbar"
  27661. }), children);
  27662. }
  27663. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/with-client-id.js
  27664. /**
  27665. * WordPress dependencies
  27666. */
  27667. /**
  27668. * Internal dependencies
  27669. */
  27670. const withClientId = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
  27671. const {
  27672. clientId
  27673. } = useBlockEditContext();
  27674. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  27675. clientId: clientId
  27676. }));
  27677. }, 'withClientId');
  27678. /* harmony default export */ var with_client_id = (withClientId);
  27679. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/button-block-appender.js
  27680. /**
  27681. * External dependencies
  27682. */
  27683. /**
  27684. * Internal dependencies
  27685. */
  27686. const button_block_appender_ButtonBlockAppender = _ref => {
  27687. let {
  27688. clientId,
  27689. showSeparator,
  27690. isFloating,
  27691. onAddBlock,
  27692. isToggle
  27693. } = _ref;
  27694. return (0,external_wp_element_namespaceObject.createElement)(button_block_appender, {
  27695. className: classnames_default()({
  27696. 'block-list-appender__toggle': isToggle
  27697. }),
  27698. rootClientId: clientId,
  27699. showSeparator: showSeparator,
  27700. isFloating: isFloating,
  27701. onAddBlock: onAddBlock
  27702. });
  27703. };
  27704. /* harmony default export */ var inner_blocks_button_block_appender = (with_client_id(button_block_appender_ButtonBlockAppender));
  27705. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/default-block-appender.js
  27706. /**
  27707. * WordPress dependencies
  27708. */
  27709. /**
  27710. * Internal dependencies
  27711. */
  27712. const default_block_appender_DefaultBlockAppender = _ref => {
  27713. let {
  27714. clientId
  27715. } = _ref;
  27716. return (0,external_wp_element_namespaceObject.createElement)(default_block_appender, {
  27717. rootClientId: clientId
  27718. });
  27719. };
  27720. /* harmony default export */ var inner_blocks_default_block_appender = ((0,external_wp_compose_namespaceObject.compose)([with_client_id, (0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => {
  27721. let {
  27722. clientId
  27723. } = _ref2;
  27724. const {
  27725. getBlockOrder
  27726. } = select(store);
  27727. const blockClientIds = getBlockOrder(clientId);
  27728. return {
  27729. lastBlockClientId: blockClientIds[blockClientIds.length - 1]
  27730. };
  27731. })])(default_block_appender_DefaultBlockAppender));
  27732. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-nested-settings-update.js
  27733. /**
  27734. * WordPress dependencies
  27735. */
  27736. /**
  27737. * Internal dependencies
  27738. */
  27739. /** @typedef {import('../../selectors').WPDirectInsertBlock } WPDirectInsertBlock */
  27740. const pendingSettingsUpdates = new WeakMap();
  27741. /**
  27742. * This hook is a side effect which updates the block-editor store when changes
  27743. * happen to inner block settings. The given props are transformed into a
  27744. * settings object, and if that is different from the current settings object in
  27745. * the block-editor store, then the store is updated with the new settings which
  27746. * came from props.
  27747. *
  27748. * @param {string} clientId The client ID of the block to update.
  27749. * @param {string[]} allowedBlocks An array of block names which are permitted
  27750. * in inner blocks.
  27751. * @param {?WPDirectInsertBlock} __experimentalDefaultBlock The default block to insert: [ blockName, { blockAttributes } ].
  27752. * @param {?Function|boolean} __experimentalDirectInsert If a default block should be inserted directly by the
  27753. * appender.
  27754. * @param {string} [templateLock] The template lock specified for the inner
  27755. * blocks component. (e.g. "all")
  27756. * @param {boolean} captureToolbars Whether or children toolbars should be shown
  27757. * in the inner blocks component rather than on
  27758. * the child block.
  27759. * @param {string} orientation The direction in which the block
  27760. * should face.
  27761. * @param {Object} layout The layout object for the block container.
  27762. */
  27763. function useNestedSettingsUpdate(clientId, allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout) {
  27764. const {
  27765. updateBlockListSettings
  27766. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  27767. const registry = (0,external_wp_data_namespaceObject.useRegistry)();
  27768. const {
  27769. blockListSettings,
  27770. parentLock
  27771. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  27772. const rootClientId = select(store).getBlockRootClientId(clientId);
  27773. return {
  27774. blockListSettings: select(store).getBlockListSettings(clientId),
  27775. parentLock: select(store).getTemplateLock(rootClientId)
  27776. };
  27777. }, [clientId]); // Memoize as inner blocks implementors often pass a new array on every
  27778. // render.
  27779. const _allowedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => allowedBlocks, allowedBlocks);
  27780. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  27781. const newSettings = {
  27782. allowedBlocks: _allowedBlocks,
  27783. templateLock: templateLock === undefined || parentLock === 'contentOnly' ? parentLock : templateLock
  27784. }; // These values are not defined for RN, so only include them if they
  27785. // are defined.
  27786. if (captureToolbars !== undefined) {
  27787. newSettings.__experimentalCaptureToolbars = captureToolbars;
  27788. } // Orientation depends on layout,
  27789. // ideally the separate orientation prop should be deprecated.
  27790. if (orientation !== undefined) {
  27791. newSettings.orientation = orientation;
  27792. } else {
  27793. const layoutType = getLayoutType(layout === null || layout === void 0 ? void 0 : layout.type);
  27794. newSettings.orientation = layoutType.getOrientation(layout);
  27795. }
  27796. if (__experimentalDefaultBlock !== undefined) {
  27797. newSettings.__experimentalDefaultBlock = __experimentalDefaultBlock;
  27798. }
  27799. if (__experimentalDirectInsert !== undefined) {
  27800. newSettings.__experimentalDirectInsert = __experimentalDirectInsert;
  27801. }
  27802. if (!external_wp_isShallowEqual_default()(blockListSettings, newSettings)) {
  27803. // Batch updates to block list settings to avoid triggering cascading renders
  27804. // for each container block included in a tree and optimize initial render.
  27805. // To avoid triggering updateBlockListSettings for each container block
  27806. // causing X re-renderings for X container blocks,
  27807. // we batch all the updatedBlockListSettings in a single "data" batch
  27808. // which results in a single re-render.
  27809. if (!pendingSettingsUpdates.get(registry)) {
  27810. pendingSettingsUpdates.set(registry, []);
  27811. }
  27812. pendingSettingsUpdates.get(registry).push([clientId, newSettings]);
  27813. window.queueMicrotask(() => {
  27814. var _pendingSettingsUpdat;
  27815. if ((_pendingSettingsUpdat = pendingSettingsUpdates.get(registry)) !== null && _pendingSettingsUpdat !== void 0 && _pendingSettingsUpdat.length) {
  27816. registry.batch(() => {
  27817. pendingSettingsUpdates.get(registry).forEach(args => {
  27818. updateBlockListSettings(...args);
  27819. });
  27820. pendingSettingsUpdates.set(registry, []);
  27821. });
  27822. }
  27823. });
  27824. }
  27825. }, [clientId, blockListSettings, _allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings, layout, registry]);
  27826. }
  27827. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-inner-block-template-sync.js
  27828. /**
  27829. * External dependencies
  27830. */
  27831. /**
  27832. * WordPress dependencies
  27833. */
  27834. /**
  27835. * Internal dependencies
  27836. */
  27837. /**
  27838. * This hook makes sure that a block's inner blocks stay in sync with the given
  27839. * block "template". The template is a block hierarchy to which inner blocks must
  27840. * conform. If the blocks get "out of sync" with the template and the template
  27841. * is meant to be locked (e.g. templateLock = "all" or templateLock = "contentOnly"),
  27842. * then we replace the inner blocks with the correct value after synchronizing it with the template.
  27843. *
  27844. * @param {string} clientId The block client ID.
  27845. * @param {Object} template The template to match.
  27846. * @param {string} templateLock The template lock state for the inner blocks. For
  27847. * example, if the template lock is set to "all",
  27848. * then the inner blocks will stay in sync with the
  27849. * template. If not defined or set to false, then
  27850. * the inner blocks will not be synchronized with
  27851. * the given template.
  27852. * @param {boolean} templateInsertUpdatesSelection Whether or not to update the
  27853. * block-editor selection state when inner blocks
  27854. * are replaced after template synchronization.
  27855. */
  27856. function useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection) {
  27857. const {
  27858. getSelectedBlocksInitialCaretPosition,
  27859. isBlockSelected
  27860. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  27861. const {
  27862. replaceInnerBlocks
  27863. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  27864. const innerBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlocks(clientId), [clientId]);
  27865. const {
  27866. getBlocks
  27867. } = (0,external_wp_data_namespaceObject.useSelect)(store); // Maintain a reference to the previous value so we can do a deep equality check.
  27868. const existingTemplate = (0,external_wp_element_namespaceObject.useRef)(null);
  27869. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  27870. // There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate
  27871. // The former needs to happen after the latter and since the latter is using microtasks to batch updates (performance optimization),
  27872. // we need to schedule this one in a microtask as well.
  27873. // Exemple: If you remove queueMicrotask here, ctrl + click to insert quote block won't close the inserter.
  27874. window.queueMicrotask(() => {
  27875. // Only synchronize innerBlocks with template if innerBlocks are empty
  27876. // or a locking "all" or "contentOnly" exists directly on the block.
  27877. const currentInnerBlocks = getBlocks(clientId);
  27878. const shouldApplyTemplate = currentInnerBlocks.length === 0 || templateLock === 'all' || templateLock === 'contentOnly';
  27879. const hasTemplateChanged = !(0,external_lodash_namespaceObject.isEqual)(template, existingTemplate.current);
  27880. if (!shouldApplyTemplate || !hasTemplateChanged) {
  27881. return;
  27882. }
  27883. existingTemplate.current = template;
  27884. const nextBlocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(currentInnerBlocks, template);
  27885. if (!(0,external_lodash_namespaceObject.isEqual)(nextBlocks, currentInnerBlocks)) {
  27886. replaceInnerBlocks(clientId, nextBlocks, currentInnerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0 && isBlockSelected(clientId), // This ensures the "initialPosition" doesn't change when applying the template
  27887. // If we're supposed to focus the block, we'll focus the first inner block
  27888. // otherwise, we won't apply any auto-focus.
  27889. // This ensures for instance that the focus stays in the inserter when inserting the "buttons" block.
  27890. getSelectedBlocksInitialCaretPosition());
  27891. }
  27892. });
  27893. }, [innerBlocks, template, templateLock, clientId]);
  27894. }
  27895. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/get-block-context.js
  27896. /**
  27897. * External dependencies
  27898. */
  27899. /**
  27900. * Block context cache, implemented as a WeakMap mapping block types to a
  27901. * WeakMap mapping attributes object to context value.
  27902. *
  27903. * @type {WeakMap<string,WeakMap<string,*>>}
  27904. */
  27905. const BLOCK_CONTEXT_CACHE = new WeakMap();
  27906. /**
  27907. * Returns a cached context object value for a given set of attributes for the
  27908. * block type.
  27909. *
  27910. * @param {Record<string,*>} attributes Block attributes object.
  27911. * @param {WPBlockType} blockType Block type settings.
  27912. *
  27913. * @return {Record<string,*>} Context value.
  27914. */
  27915. function getBlockContext(attributes, blockType) {
  27916. if (!BLOCK_CONTEXT_CACHE.has(blockType)) {
  27917. BLOCK_CONTEXT_CACHE.set(blockType, new WeakMap());
  27918. }
  27919. const blockTypeCache = BLOCK_CONTEXT_CACHE.get(blockType);
  27920. if (!blockTypeCache.has(attributes)) {
  27921. const context = (0,external_lodash_namespaceObject.mapValues)(blockType.providesContext, attributeName => attributes[attributeName]);
  27922. blockTypeCache.set(attributes, context);
  27923. }
  27924. return blockTypeCache.get(attributes);
  27925. }
  27926. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-on-block-drop/index.js
  27927. /**
  27928. * WordPress dependencies
  27929. */
  27930. /**
  27931. * Internal dependencies
  27932. */
  27933. /** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */
  27934. /**
  27935. * Retrieve the data for a block drop event.
  27936. *
  27937. * @param {WPSyntheticEvent} event The drop event.
  27938. *
  27939. * @return {Object} An object with block drag and drop data.
  27940. */
  27941. function parseDropEvent(event) {
  27942. let result = {
  27943. srcRootClientId: null,
  27944. srcClientIds: null,
  27945. srcIndex: null,
  27946. type: null,
  27947. blocks: null
  27948. };
  27949. if (!event.dataTransfer) {
  27950. return result;
  27951. }
  27952. try {
  27953. result = Object.assign(result, JSON.parse(event.dataTransfer.getData('wp-blocks')));
  27954. } catch (err) {
  27955. return result;
  27956. }
  27957. return result;
  27958. }
  27959. /**
  27960. * A function that returns an event handler function for block drop events.
  27961. *
  27962. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  27963. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  27964. * @param {Function} getBlockIndex A function that gets the index of a block.
  27965. * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
  27966. * @param {Function} moveBlocksToPosition A function that moves blocks.
  27967. * @param {Function} insertBlocks A function that inserts blocks.
  27968. * @param {Function} clearSelectedBlock A function that clears block selection.
  27969. * @return {Function} The event handler for a block drop event.
  27970. */
  27971. function onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock) {
  27972. return event => {
  27973. const {
  27974. srcRootClientId: sourceRootClientId,
  27975. srcClientIds: sourceClientIds,
  27976. type: dropType,
  27977. blocks
  27978. } = parseDropEvent(event); // If the user is inserting a block.
  27979. if (dropType === 'inserter') {
  27980. clearSelectedBlock();
  27981. const blocksToInsert = blocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
  27982. insertBlocks(blocksToInsert, targetBlockIndex, targetRootClientId, true, null);
  27983. } // If the user is moving a block.
  27984. if (dropType === 'block') {
  27985. const sourceBlockIndex = getBlockIndex(sourceClientIds[0]); // If the user is dropping to the same position, return early.
  27986. if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) {
  27987. return;
  27988. } // If the user is attempting to drop a block within its own
  27989. // nested blocks, return early as this would create infinite
  27990. // recursion.
  27991. if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants(sourceClientIds).some(id => id === targetRootClientId)) {
  27992. return;
  27993. }
  27994. const isAtSameLevel = sourceRootClientId === targetRootClientId;
  27995. const draggedBlockCount = sourceClientIds.length; // If the block is kept at the same level and moved downwards,
  27996. // subtract to take into account that the blocks being dragged
  27997. // were removed from the block list above the insertion point.
  27998. const insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex;
  27999. moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex);
  28000. }
  28001. };
  28002. }
  28003. /**
  28004. * A function that returns an event handler function for block-related file drop events.
  28005. *
  28006. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  28007. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  28008. * @param {boolean} hasUploadPermissions Whether the user has upload permissions.
  28009. * @param {Function} updateBlockAttributes A function that updates a block's attributes.
  28010. * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.
  28011. * @param {Function} insertBlocks A function that inserts blocks.
  28012. *
  28013. * @return {Function} The event handler for a block-related file drop event.
  28014. */
  28015. function onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks) {
  28016. return files => {
  28017. if (!hasUploadPermissions) {
  28018. return;
  28019. }
  28020. const transformation = (0,external_wp_blocks_namespaceObject.findTransform)((0,external_wp_blocks_namespaceObject.getBlockTransforms)('from'), transform => transform.type === 'files' && canInsertBlockType(transform.blockName, targetRootClientId) && transform.isMatch(files));
  28021. if (transformation) {
  28022. const blocks = transformation.transform(files, updateBlockAttributes);
  28023. insertBlocks(blocks, targetBlockIndex, targetRootClientId);
  28024. }
  28025. };
  28026. }
  28027. /**
  28028. * A function that returns an event handler function for block-related HTML drop events.
  28029. *
  28030. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  28031. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  28032. * @param {Function} insertBlocks A function that inserts blocks.
  28033. *
  28034. * @return {Function} The event handler for a block-related HTML drop event.
  28035. */
  28036. function onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks) {
  28037. return HTML => {
  28038. const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({
  28039. HTML,
  28040. mode: 'BLOCKS'
  28041. });
  28042. if (blocks.length) {
  28043. insertBlocks(blocks, targetBlockIndex, targetRootClientId);
  28044. }
  28045. };
  28046. }
  28047. /**
  28048. * A React hook for handling block drop events.
  28049. *
  28050. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  28051. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  28052. *
  28053. * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.
  28054. */
  28055. function useOnBlockDrop(targetRootClientId, targetBlockIndex) {
  28056. const hasUploadPermissions = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().mediaUpload, []);
  28057. const {
  28058. canInsertBlockType,
  28059. getBlockIndex,
  28060. getClientIdsOfDescendants
  28061. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  28062. const {
  28063. insertBlocks,
  28064. moveBlocksToPosition,
  28065. updateBlockAttributes,
  28066. clearSelectedBlock
  28067. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  28068. const _onDrop = onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock);
  28069. const _onFilesDrop = onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks);
  28070. const _onHTMLDrop = onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks);
  28071. return event => {
  28072. const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(event.dataTransfer);
  28073. const html = event.dataTransfer.getData('text/html');
  28074. /**
  28075. * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
  28076. * The order of the checks is important to recognise the HTML drop.
  28077. */
  28078. if (html) {
  28079. _onHTMLDrop(html);
  28080. } else if (files.length) {
  28081. _onFilesDrop(files);
  28082. } else {
  28083. _onDrop(event);
  28084. }
  28085. };
  28086. }
  28087. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/math.js
  28088. /**
  28089. * A string representing the name of an edge.
  28090. *
  28091. * @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName
  28092. */
  28093. /**
  28094. * @typedef {Object} WPPoint
  28095. * @property {number} x The horizontal position.
  28096. * @property {number} y The vertical position.
  28097. */
  28098. /**
  28099. * Given a point, a DOMRect and the name of an edge, returns the distance to
  28100. * that edge of the rect.
  28101. *
  28102. * This function works for edges that are horizontal or vertical (e.g. not
  28103. * rotated), the following terms are used so that the function works in both
  28104. * orientations:
  28105. *
  28106. * - Forward, meaning the axis running horizontally when an edge is vertical
  28107. * and vertically when an edge is horizontal.
  28108. * - Lateral, meaning the axis running vertically when an edge is vertical
  28109. * and horizontally when an edge is horizontal.
  28110. *
  28111. * @param {WPPoint} point The point to measure distance from.
  28112. * @param {DOMRect} rect A DOM Rect containing edge positions.
  28113. * @param {WPEdgeName} edge The edge to measure to.
  28114. */
  28115. function getDistanceFromPointToEdge(point, rect, edge) {
  28116. const isHorizontal = edge === 'top' || edge === 'bottom';
  28117. const {
  28118. x,
  28119. y
  28120. } = point;
  28121. const pointLateralPosition = isHorizontal ? x : y;
  28122. const pointForwardPosition = isHorizontal ? y : x;
  28123. const edgeStart = isHorizontal ? rect.left : rect.top;
  28124. const edgeEnd = isHorizontal ? rect.right : rect.bottom;
  28125. const edgeForwardPosition = rect[edge]; // Measure the straight line distance to the edge of the rect, when the
  28126. // point is adjacent to the edge.
  28127. // Else, if the point is positioned diagonally to the edge of the rect,
  28128. // measure diagonally to the nearest corner that the edge meets.
  28129. let edgeLateralPosition;
  28130. if (pointLateralPosition >= edgeStart && pointLateralPosition <= edgeEnd) {
  28131. edgeLateralPosition = pointLateralPosition;
  28132. } else if (pointLateralPosition < edgeEnd) {
  28133. edgeLateralPosition = edgeStart;
  28134. } else {
  28135. edgeLateralPosition = edgeEnd;
  28136. }
  28137. return Math.sqrt((pointLateralPosition - edgeLateralPosition) ** 2 + (pointForwardPosition - edgeForwardPosition) ** 2);
  28138. }
  28139. /**
  28140. * Given a point, a DOMRect and a list of allowed edges returns the name of and
  28141. * distance to the nearest edge.
  28142. *
  28143. * @param {WPPoint} point The point to measure distance from.
  28144. * @param {DOMRect} rect A DOM Rect containing edge positions.
  28145. * @param {WPEdgeName[]} allowedEdges A list of the edges included in the
  28146. * calculation. Defaults to all edges.
  28147. *
  28148. * @return {[number, string]} An array where the first value is the distance
  28149. * and a second is the edge name.
  28150. */
  28151. function getDistanceToNearestEdge(point, rect) {
  28152. let allowedEdges = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ['top', 'bottom', 'left', 'right'];
  28153. let candidateDistance;
  28154. let candidateEdge;
  28155. allowedEdges.forEach(edge => {
  28156. const distance = getDistanceFromPointToEdge(point, rect, edge);
  28157. if (candidateDistance === undefined || distance < candidateDistance) {
  28158. candidateDistance = distance;
  28159. candidateEdge = edge;
  28160. }
  28161. });
  28162. return [candidateDistance, candidateEdge];
  28163. }
  28164. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-drop-zone/index.js
  28165. /**
  28166. * WordPress dependencies
  28167. */
  28168. /**
  28169. * Internal dependencies
  28170. */
  28171. /** @typedef {import('../../utils/math').WPPoint} WPPoint */
  28172. /**
  28173. * The orientation of a block list.
  28174. *
  28175. * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
  28176. */
  28177. /**
  28178. * Given a list of block DOM elements finds the index that a block should be dropped
  28179. * at.
  28180. *
  28181. * @param {Element[]} elements Array of DOM elements that represent each block in a block list.
  28182. * @param {WPPoint} position The position of the item being dragged.
  28183. * @param {WPBlockListOrientation} orientation The orientation of a block list.
  28184. *
  28185. * @return {number|undefined} The block index that's closest to the drag position.
  28186. */
  28187. function getNearestBlockIndex(elements, position, orientation) {
  28188. const allowedEdges = orientation === 'horizontal' ? ['left', 'right'] : ['top', 'bottom'];
  28189. const isRightToLeft = (0,external_wp_i18n_namespaceObject.isRTL)();
  28190. let candidateIndex;
  28191. let candidateDistance;
  28192. elements.forEach((element, index) => {
  28193. const rect = element.getBoundingClientRect();
  28194. const [distance, edge] = getDistanceToNearestEdge(position, rect, allowedEdges);
  28195. if (candidateDistance === undefined || distance < candidateDistance) {
  28196. // If the user is dropping to the trailing edge of the block
  28197. // add 1 to the index to represent dragging after.
  28198. // Take RTL languages into account where the left edge is
  28199. // the trailing edge.
  28200. const isTrailingEdge = edge === 'bottom' || !isRightToLeft && edge === 'right' || isRightToLeft && edge === 'left';
  28201. const offset = isTrailingEdge ? 1 : 0; // Update the currently known best candidate.
  28202. candidateDistance = distance;
  28203. candidateIndex = index + offset;
  28204. }
  28205. });
  28206. return candidateIndex;
  28207. }
  28208. /**
  28209. * @typedef {Object} WPBlockDropZoneConfig
  28210. * @property {string} rootClientId The root client id for the block list.
  28211. */
  28212. /**
  28213. * A React hook that can be used to make a block list handle drag and drop.
  28214. *
  28215. * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
  28216. */
  28217. function useBlockDropZone() {
  28218. let {
  28219. // An undefined value represents a top-level block. Default to an empty
  28220. // string for this so that `targetRootClientId` can be easily compared to
  28221. // values returned by the `getRootBlockClientId` selector, which also uses
  28222. // an empty string to represent top-level blocks.
  28223. rootClientId: targetRootClientId = ''
  28224. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  28225. const [targetBlockIndex, setTargetBlockIndex] = (0,external_wp_element_namespaceObject.useState)(null);
  28226. const isDisabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
  28227. const {
  28228. getTemplateLock,
  28229. __unstableIsWithinBlockOverlay,
  28230. __unstableHasActiveBlockOverlayActive
  28231. } = select(store);
  28232. const templateLock = getTemplateLock(targetRootClientId);
  28233. return ['all', 'contentOnly'].some(lock => lock === templateLock) || __unstableHasActiveBlockOverlayActive(targetRootClientId) || __unstableIsWithinBlockOverlay(targetRootClientId);
  28234. }, [targetRootClientId]);
  28235. const {
  28236. getBlockListSettings
  28237. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  28238. const {
  28239. showInsertionPoint,
  28240. hideInsertionPoint
  28241. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  28242. const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex);
  28243. const throttled = (0,external_wp_compose_namespaceObject.useThrottle)((0,external_wp_element_namespaceObject.useCallback)((event, currentTarget) => {
  28244. var _getBlockListSettings;
  28245. const blockElements = Array.from(currentTarget.children).filter( // Ensure the element is a block. It should have the `wp-block` class.
  28246. element => element.classList.contains('wp-block'));
  28247. const targetIndex = getNearestBlockIndex(blockElements, {
  28248. x: event.clientX,
  28249. y: event.clientY
  28250. }, (_getBlockListSettings = getBlockListSettings(targetRootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation);
  28251. setTargetBlockIndex(targetIndex === undefined ? 0 : targetIndex);
  28252. if (targetIndex !== null) {
  28253. showInsertionPoint(targetRootClientId, targetIndex);
  28254. }
  28255. }, []), 200);
  28256. return (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({
  28257. isDisabled,
  28258. onDrop: onBlockDrop,
  28259. onDragOver(event) {
  28260. // `currentTarget` is only available while the event is being
  28261. // handled, so get it now and pass it to the thottled function.
  28262. // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
  28263. throttled(event, event.currentTarget);
  28264. },
  28265. onDragLeave() {
  28266. throttled.cancel();
  28267. hideInsertionPoint();
  28268. setTargetBlockIndex(null);
  28269. },
  28270. onDragEnd() {
  28271. throttled.cancel();
  28272. hideInsertionPoint();
  28273. setTargetBlockIndex(null);
  28274. }
  28275. });
  28276. }
  28277. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/index.js
  28278. /**
  28279. * External dependencies
  28280. */
  28281. /**
  28282. * WordPress dependencies
  28283. */
  28284. /**
  28285. * Internal dependencies
  28286. */
  28287. /**
  28288. * InnerBlocks is a component which allows a single block to have multiple blocks
  28289. * as children. The UncontrolledInnerBlocks component is used whenever the inner
  28290. * blocks are not controlled by another entity. In other words, it is normally
  28291. * used for inner blocks in the post editor
  28292. *
  28293. * @param {Object} props The component props.
  28294. */
  28295. function UncontrolledInnerBlocks(props) {
  28296. const {
  28297. clientId,
  28298. allowedBlocks,
  28299. __experimentalDefaultBlock,
  28300. __experimentalDirectInsert,
  28301. template,
  28302. templateLock,
  28303. wrapperRef,
  28304. templateInsertUpdatesSelection,
  28305. __experimentalCaptureToolbars: captureToolbars,
  28306. __experimentalAppenderTagName,
  28307. renderAppender,
  28308. orientation,
  28309. placeholder,
  28310. __experimentalLayout
  28311. } = props;
  28312. useNestedSettingsUpdate(clientId, allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, __experimentalLayout);
  28313. useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection);
  28314. const context = (0,external_wp_data_namespaceObject.useSelect)(select => {
  28315. const block = select(store).getBlock(clientId); // This check is here to avoid the Redux zombie bug where a child subscription
  28316. // is called before a parent, causing potential JS errors when the child has been removed.
  28317. if (!block) {
  28318. return;
  28319. }
  28320. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
  28321. if (!blockType || !blockType.providesContext) {
  28322. return;
  28323. }
  28324. return getBlockContext(block.attributes, blockType);
  28325. }, [clientId]); // This component needs to always be synchronous as it's the one changing
  28326. // the async mode depending on the block selection.
  28327. return (0,external_wp_element_namespaceObject.createElement)(BlockContextProvider, {
  28328. value: context
  28329. }, (0,external_wp_element_namespaceObject.createElement)(BlockListItems, {
  28330. rootClientId: clientId,
  28331. renderAppender: renderAppender,
  28332. __experimentalAppenderTagName: __experimentalAppenderTagName,
  28333. __experimentalLayout: __experimentalLayout,
  28334. wrapperRef: wrapperRef,
  28335. placeholder: placeholder
  28336. }));
  28337. }
  28338. /**
  28339. * The controlled inner blocks component wraps the uncontrolled inner blocks
  28340. * component with the blockSync hook. This keeps the innerBlocks of the block in
  28341. * the block-editor store in sync with the blocks of the controlling entity. An
  28342. * example of an inner block controller is a template part block, which provides
  28343. * its own blocks from the template part entity data source.
  28344. *
  28345. * @param {Object} props The component props.
  28346. */
  28347. function ControlledInnerBlocks(props) {
  28348. useBlockSync(props);
  28349. return (0,external_wp_element_namespaceObject.createElement)(UncontrolledInnerBlocks, props);
  28350. }
  28351. const ForwardedInnerBlocks = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  28352. const innerBlocksProps = useInnerBlocksProps({
  28353. ref
  28354. }, props);
  28355. return (0,external_wp_element_namespaceObject.createElement)("div", {
  28356. className: "block-editor-inner-blocks"
  28357. }, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps));
  28358. });
  28359. /**
  28360. * This hook is used to lightly mark an element as an inner blocks wrapper
  28361. * element. Call this hook and pass the returned props to the element to mark as
  28362. * an inner blocks wrapper, automatically rendering inner blocks as children. If
  28363. * you define a ref for the element, it is important to pass the ref to this
  28364. * hook, which the hook in turn will pass to the component through the props it
  28365. * returns. Optionally, you can also pass any other props through this hook, and
  28366. * they will be merged and returned.
  28367. *
  28368. * @param {Object} props Optional. Props to pass to the element. Must contain
  28369. * the ref if one is defined.
  28370. * @param {Object} options Optional. Inner blocks options.
  28371. *
  28372. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
  28373. */
  28374. function useInnerBlocksProps() {
  28375. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  28376. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  28377. const {
  28378. __unstableDisableDropZone
  28379. } = options;
  28380. const {
  28381. clientId
  28382. } = useBlockEditContext();
  28383. const isSmallScreen = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
  28384. const {
  28385. __experimentalCaptureToolbars,
  28386. hasOverlay
  28387. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  28388. if (!clientId) {
  28389. return {};
  28390. }
  28391. const {
  28392. getBlockName,
  28393. isBlockSelected,
  28394. hasSelectedInnerBlock,
  28395. __unstableGetEditorMode
  28396. } = select(store);
  28397. const blockName = getBlockName(clientId);
  28398. const enableClickThrough = __unstableGetEditorMode() === 'navigation' || isSmallScreen;
  28399. return {
  28400. __experimentalCaptureToolbars: select(external_wp_blocks_namespaceObject.store).hasBlockSupport(blockName, '__experimentalExposeControlsToChildren', false),
  28401. hasOverlay: blockName !== 'core/template' && !isBlockSelected(clientId) && !hasSelectedInnerBlock(clientId, true) && enableClickThrough
  28402. };
  28403. }, [clientId, isSmallScreen]);
  28404. const blockDropZoneRef = useBlockDropZone({
  28405. rootClientId: clientId
  28406. });
  28407. const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, __unstableDisableDropZone ? null : blockDropZoneRef]);
  28408. const innerBlocksProps = {
  28409. __experimentalCaptureToolbars,
  28410. ...options
  28411. };
  28412. const InnerBlocks = innerBlocksProps.value && innerBlocksProps.onChange ? ControlledInnerBlocks : UncontrolledInnerBlocks;
  28413. return { ...props,
  28414. ref,
  28415. className: classnames_default()(props.className, 'block-editor-block-list__layout', {
  28416. 'has-overlay': hasOverlay
  28417. }),
  28418. children: clientId ? (0,external_wp_element_namespaceObject.createElement)(InnerBlocks, _extends({}, innerBlocksProps, {
  28419. clientId: clientId
  28420. })) : (0,external_wp_element_namespaceObject.createElement)(BlockListItems, options)
  28421. };
  28422. }
  28423. useInnerBlocksProps.save = external_wp_blocks_namespaceObject.__unstableGetInnerBlocksProps; // Expose default appender placeholders as components.
  28424. ForwardedInnerBlocks.DefaultBlockAppender = inner_blocks_default_block_appender;
  28425. ForwardedInnerBlocks.ButtonBlockAppender = inner_blocks_button_block_appender;
  28426. ForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;
  28427. /**
  28428. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
  28429. */
  28430. /* harmony default export */ var inner_blocks = (ForwardedInnerBlocks);
  28431. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/index.js
  28432. /**
  28433. * External dependencies
  28434. */
  28435. /**
  28436. * WordPress dependencies
  28437. */
  28438. /**
  28439. * Internal dependencies
  28440. */
  28441. const elementContext = (0,external_wp_element_namespaceObject.createContext)();
  28442. const IntersectionObserver = (0,external_wp_element_namespaceObject.createContext)();
  28443. function Root(_ref) {
  28444. let {
  28445. className,
  28446. ...settings
  28447. } = _ref;
  28448. const [element, setElement] = (0,external_wp_element_namespaceObject.useState)();
  28449. const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
  28450. const {
  28451. isOutlineMode,
  28452. isFocusMode,
  28453. editorMode
  28454. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  28455. const {
  28456. getSettings,
  28457. __unstableGetEditorMode
  28458. } = select(store);
  28459. const {
  28460. outlineMode,
  28461. focusMode
  28462. } = getSettings();
  28463. return {
  28464. isOutlineMode: outlineMode,
  28465. isFocusMode: focusMode,
  28466. editorMode: __unstableGetEditorMode()
  28467. };
  28468. }, []);
  28469. const {
  28470. setBlockVisibility
  28471. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  28472. const intersectionObserver = (0,external_wp_element_namespaceObject.useMemo)(() => {
  28473. const {
  28474. IntersectionObserver: Observer
  28475. } = window;
  28476. if (!Observer) {
  28477. return;
  28478. }
  28479. return new Observer(entries => {
  28480. const updates = {};
  28481. for (const entry of entries) {
  28482. const clientId = entry.target.getAttribute('data-block');
  28483. updates[clientId] = entry.isIntersecting;
  28484. }
  28485. setBlockVisibility(updates);
  28486. });
  28487. }, []);
  28488. const innerBlocksProps = useInnerBlocksProps({
  28489. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([useBlockSelectionClearer(), useInBetweenInserter(), setElement]),
  28490. className: classnames_default()('is-root-container', className, {
  28491. 'is-outline-mode': isOutlineMode,
  28492. 'is-focus-mode': isFocusMode && isLargeViewport,
  28493. 'is-navigate-mode': editorMode === 'navigation'
  28494. })
  28495. }, settings);
  28496. return (0,external_wp_element_namespaceObject.createElement)(elementContext.Provider, {
  28497. value: element
  28498. }, (0,external_wp_element_namespaceObject.createElement)(IntersectionObserver.Provider, {
  28499. value: intersectionObserver
  28500. }, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps)));
  28501. }
  28502. function BlockList(settings) {
  28503. usePreParsePatterns();
  28504. return (0,external_wp_element_namespaceObject.createElement)(BlockToolsBackCompat, null, (0,external_wp_element_namespaceObject.createElement)(Provider, {
  28505. value: DEFAULT_BLOCK_EDIT_CONTEXT
  28506. }, (0,external_wp_element_namespaceObject.createElement)(Root, settings)));
  28507. }
  28508. BlockList.__unstableElementContext = elementContext;
  28509. function Items(_ref2) {
  28510. let {
  28511. placeholder,
  28512. rootClientId,
  28513. renderAppender,
  28514. __experimentalAppenderTagName,
  28515. __experimentalLayout: layout = defaultLayout
  28516. } = _ref2;
  28517. const {
  28518. order,
  28519. selectedBlocks,
  28520. visibleBlocks
  28521. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  28522. const {
  28523. getBlockOrder,
  28524. getSelectedBlockClientIds,
  28525. __unstableGetVisibleBlocks
  28526. } = select(store);
  28527. return {
  28528. order: getBlockOrder(rootClientId),
  28529. selectedBlocks: getSelectedBlockClientIds(),
  28530. visibleBlocks: __unstableGetVisibleBlocks()
  28531. };
  28532. }, [rootClientId]);
  28533. return (0,external_wp_element_namespaceObject.createElement)(LayoutProvider, {
  28534. value: layout
  28535. }, order.map(clientId => (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
  28536. key: clientId,
  28537. value: // Only provide data asynchronously if the block is
  28538. // not visible and not selected.
  28539. !visibleBlocks.has(clientId) && !selectedBlocks.includes(clientId)
  28540. }, (0,external_wp_element_namespaceObject.createElement)(block, {
  28541. rootClientId: rootClientId,
  28542. clientId: clientId
  28543. }))), order.length < 1 && placeholder, (0,external_wp_element_namespaceObject.createElement)(block_list_appender, {
  28544. tagName: __experimentalAppenderTagName,
  28545. rootClientId: rootClientId,
  28546. renderAppender: renderAppender
  28547. }));
  28548. }
  28549. function BlockListItems(props) {
  28550. // This component needs to always be synchronous as it's the one changing
  28551. // the async mode depending on the block selection.
  28552. return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
  28553. value: false
  28554. }, (0,external_wp_element_namespaceObject.createElement)(Items, props));
  28555. }
  28556. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/utils.js
  28557. /**
  28558. * WordPress dependencies
  28559. */
  28560. /**
  28561. * Gets the (non-undefined) item with the highest occurrence within an array
  28562. * Based in part on: https://stackoverflow.com/a/20762713
  28563. *
  28564. * Undefined values are always sorted to the end by `sort`, so this function
  28565. * returns the first element, to always prioritize real values over undefined
  28566. * values.
  28567. *
  28568. * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description
  28569. *
  28570. * @param {Array<any>} inputArray Array of items to check.
  28571. * @return {any} The item with the most occurrences.
  28572. */
  28573. function utils_mode(inputArray) {
  28574. const arr = [...inputArray];
  28575. return arr.sort((a, b) => inputArray.filter(v => v === b).length - inputArray.filter(v => v === a).length).shift();
  28576. }
  28577. /**
  28578. * Returns the most common CSS unit from the current CSS unit selections.
  28579. *
  28580. * - If a single flat border radius is set, its unit will be used
  28581. * - If individual corner selections, the most common of those will be used
  28582. * - Failing any unit selections a default of 'px' is returned.
  28583. *
  28584. * @param {Object} selectedUnits Unit selections for flat radius & each corner.
  28585. * @return {string} Most common CSS unit from current selections. Default: `px`.
  28586. */
  28587. function getAllUnit() {
  28588. let selectedUnits = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  28589. const {
  28590. flat,
  28591. ...cornerUnits
  28592. } = selectedUnits;
  28593. return flat || utils_mode(Object.values(cornerUnits).filter(Boolean)) || 'px';
  28594. }
  28595. /**
  28596. * Gets the 'all' input value and unit from values data.
  28597. *
  28598. * @param {Object|string} values Radius values.
  28599. * @return {string} A value + unit for the 'all' input.
  28600. */
  28601. function getAllValue() {
  28602. let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  28603. /**
  28604. * Border radius support was originally a single pixel value.
  28605. *
  28606. * To maintain backwards compatibility treat this case as the all value.
  28607. */
  28608. if (typeof values === 'string') {
  28609. return values;
  28610. }
  28611. const parsedQuantitiesAndUnits = Object.values(values).map(value => (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(value));
  28612. const allValues = parsedQuantitiesAndUnits.map(value => {
  28613. var _value$;
  28614. return (_value$ = value[0]) !== null && _value$ !== void 0 ? _value$ : '';
  28615. });
  28616. const allUnits = parsedQuantitiesAndUnits.map(value => value[1]);
  28617. const value = allValues.every(v => v === allValues[0]) ? allValues[0] : '';
  28618. const unit = utils_mode(allUnits);
  28619. const allValue = value === 0 || value ? `${value}${unit}` : undefined;
  28620. return allValue;
  28621. }
  28622. /**
  28623. * Checks to determine if values are mixed.
  28624. *
  28625. * @param {Object} values Radius values.
  28626. * @return {boolean} Whether values are mixed.
  28627. */
  28628. function hasMixedValues() {
  28629. let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  28630. const allValue = getAllValue(values);
  28631. const isMixed = typeof values === 'string' ? false : isNaN(parseFloat(allValue));
  28632. return isMixed;
  28633. }
  28634. /**
  28635. * Checks to determine if values are defined.
  28636. *
  28637. * @param {Object} values Radius values.
  28638. * @return {boolean} Whether values are mixed.
  28639. */
  28640. function hasDefinedValues(values) {
  28641. if (!values) {
  28642. return false;
  28643. } // A string value represents a shorthand value.
  28644. if (typeof values === 'string') {
  28645. return true;
  28646. } // An object represents longhand border radius values, if any are set
  28647. // flag values as being defined.
  28648. const filteredValues = Object.values(values).filter(value => {
  28649. return !!value || value === 0;
  28650. });
  28651. return !!filteredValues.length;
  28652. }
  28653. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/all-input-control.js
  28654. /**
  28655. * WordPress dependencies
  28656. */
  28657. /**
  28658. * Internal dependencies
  28659. */
  28660. function all_input_control_AllInputControl(_ref) {
  28661. let {
  28662. onChange,
  28663. selectedUnits,
  28664. setSelectedUnits,
  28665. values,
  28666. ...props
  28667. } = _ref;
  28668. let allValue = getAllValue(values);
  28669. if (allValue === undefined) {
  28670. // If we don't have any value set the unit to any current selection
  28671. // or the most common unit from the individual radii values.
  28672. allValue = getAllUnit(selectedUnits);
  28673. }
  28674. const hasValues = hasDefinedValues(values);
  28675. const isMixed = hasValues && hasMixedValues(values);
  28676. const allPlaceholder = isMixed ? (0,external_wp_i18n_namespaceObject.__)('Mixed') : null; // Filter out CSS-unit-only values to prevent invalid styles.
  28677. const handleOnChange = next => {
  28678. const isNumeric = !isNaN(parseFloat(next));
  28679. const nextValue = isNumeric ? next : undefined;
  28680. onChange(nextValue);
  28681. }; // Store current unit selection for use as fallback for individual
  28682. // radii controls.
  28683. const handleOnUnitChange = unit => {
  28684. setSelectedUnits({
  28685. topLeft: unit,
  28686. topRight: unit,
  28687. bottomLeft: unit,
  28688. bottomRight: unit
  28689. });
  28690. };
  28691. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, _extends({}, props, {
  28692. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Border radius'),
  28693. disableUnits: isMixed,
  28694. isOnly: true,
  28695. value: allValue,
  28696. onChange: handleOnChange,
  28697. onUnitChange: handleOnUnitChange,
  28698. placeholder: allPlaceholder
  28699. }));
  28700. }
  28701. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/input-controls.js
  28702. /**
  28703. * WordPress dependencies
  28704. */
  28705. const CORNERS = {
  28706. topLeft: (0,external_wp_i18n_namespaceObject.__)('Top left'),
  28707. topRight: (0,external_wp_i18n_namespaceObject.__)('Top right'),
  28708. bottomLeft: (0,external_wp_i18n_namespaceObject.__)('Bottom left'),
  28709. bottomRight: (0,external_wp_i18n_namespaceObject.__)('Bottom right')
  28710. };
  28711. function input_controls_BoxInputControls(_ref) {
  28712. let {
  28713. onChange,
  28714. selectedUnits,
  28715. setSelectedUnits,
  28716. values: valuesProp,
  28717. ...props
  28718. } = _ref;
  28719. const createHandleOnChange = corner => next => {
  28720. if (!onChange) {
  28721. return;
  28722. } // Filter out CSS-unit-only values to prevent invalid styles.
  28723. const isNumeric = !isNaN(parseFloat(next));
  28724. const nextValue = isNumeric ? next : undefined;
  28725. onChange({ ...values,
  28726. [corner]: nextValue
  28727. });
  28728. };
  28729. const createHandleOnUnitChange = side => next => {
  28730. const newUnits = { ...selectedUnits
  28731. };
  28732. newUnits[side] = next;
  28733. setSelectedUnits(newUnits);
  28734. }; // For shorthand style & backwards compatibility, handle flat string value.
  28735. const values = typeof valuesProp !== 'string' ? valuesProp : {
  28736. topLeft: valuesProp,
  28737. topRight: valuesProp,
  28738. bottomLeft: valuesProp,
  28739. bottomRight: valuesProp
  28740. }; // Controls are wrapped in tooltips as visible labels aren't desired here.
  28741. // Tooltip rendering also requires the UnitControl to be wrapped. See:
  28742. // https://github.com/WordPress/gutenberg/pull/24966#issuecomment-685875026
  28743. return (0,external_wp_element_namespaceObject.createElement)("div", {
  28744. className: "components-border-radius-control__input-controls-wrapper"
  28745. }, Object.entries(CORNERS).map(_ref2 => {
  28746. let [corner, label] = _ref2;
  28747. const [parsedQuantity, parsedUnit] = (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(values[corner]);
  28748. const computedUnit = values[corner] ? parsedUnit : selectedUnits[corner] || selectedUnits.flat;
  28749. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
  28750. text: label,
  28751. position: "top",
  28752. key: corner
  28753. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  28754. className: "components-border-radius-control__tooltip-wrapper"
  28755. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, _extends({}, props, {
  28756. "aria-label": label,
  28757. value: [parsedQuantity, computedUnit].join(''),
  28758. onChange: createHandleOnChange(corner),
  28759. onUnitChange: createHandleOnUnitChange(corner)
  28760. }))));
  28761. }));
  28762. }
  28763. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/linked-button.js
  28764. /**
  28765. * WordPress dependencies
  28766. */
  28767. function linked_button_LinkedButton(_ref) {
  28768. let {
  28769. isLinked,
  28770. ...props
  28771. } = _ref;
  28772. const label = isLinked ? (0,external_wp_i18n_namespaceObject.__)('Unlink radii') : (0,external_wp_i18n_namespaceObject.__)('Link radii'); // TODO: Remove span after merging https://github.com/WordPress/gutenberg/pull/44198
  28773. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
  28774. text: label
  28775. }, (0,external_wp_element_namespaceObject.createElement)("span", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
  28776. className: "component-border-radius-control__linked-button",
  28777. isSmall: true,
  28778. icon: isLinked ? library_link : link_off,
  28779. iconSize: 24,
  28780. "aria-label": label
  28781. }))));
  28782. }
  28783. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/index.js
  28784. /**
  28785. * WordPress dependencies
  28786. */
  28787. /**
  28788. * Internal dependencies
  28789. */
  28790. const border_radius_control_DEFAULT_VALUES = {
  28791. topLeft: undefined,
  28792. topRight: undefined,
  28793. bottomLeft: undefined,
  28794. bottomRight: undefined
  28795. };
  28796. const MIN_BORDER_RADIUS_VALUE = 0;
  28797. const MAX_BORDER_RADIUS_VALUES = {
  28798. px: 100,
  28799. em: 20,
  28800. rem: 20
  28801. };
  28802. /**
  28803. * Control to display border radius options.
  28804. *
  28805. * @param {Object} props Component props.
  28806. * @param {Function} props.onChange Callback to handle onChange.
  28807. * @param {Object} props.values Border radius values.
  28808. *
  28809. * @return {WPElement} Custom border radius control.
  28810. */
  28811. function BorderRadiusControl(_ref) {
  28812. let {
  28813. onChange,
  28814. values
  28815. } = _ref;
  28816. const [isLinked, setIsLinked] = (0,external_wp_element_namespaceObject.useState)(!hasDefinedValues(values) || !hasMixedValues(values)); // Tracking selected units via internal state allows filtering of CSS unit
  28817. // only values from being saved while maintaining preexisting unit selection
  28818. // behaviour. Filtering CSS unit only values prevents invalid style values.
  28819. const [selectedUnits, setSelectedUnits] = (0,external_wp_element_namespaceObject.useState)({
  28820. flat: typeof values === 'string' ? (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(values)[1] : undefined,
  28821. topLeft: (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(values === null || values === void 0 ? void 0 : values.topLeft)[1],
  28822. topRight: (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(values === null || values === void 0 ? void 0 : values.topRight)[1],
  28823. bottomLeft: (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(values === null || values === void 0 ? void 0 : values.bottomLeft)[1],
  28824. bottomRight: (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(values === null || values === void 0 ? void 0 : values.bottomRight)[1]
  28825. });
  28826. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  28827. availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem']
  28828. });
  28829. const unit = getAllUnit(selectedUnits);
  28830. const unitConfig = units && units.find(item => item.value === unit);
  28831. const step = (unitConfig === null || unitConfig === void 0 ? void 0 : unitConfig.step) || 1;
  28832. const [allValue] = (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(getAllValue(values));
  28833. const toggleLinked = () => setIsLinked(!isLinked);
  28834. const handleSliderChange = next => {
  28835. onChange(next !== undefined ? `${next}${unit}` : undefined);
  28836. };
  28837. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  28838. className: "components-border-radius-control"
  28839. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
  28840. as: "legend"
  28841. }, (0,external_wp_i18n_namespaceObject.__)('Radius')), (0,external_wp_element_namespaceObject.createElement)("div", {
  28842. className: "components-border-radius-control__wrapper"
  28843. }, isLinked ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(all_input_control_AllInputControl, {
  28844. className: "components-border-radius-control__unit-control",
  28845. values: values,
  28846. min: MIN_BORDER_RADIUS_VALUE,
  28847. onChange: onChange,
  28848. selectedUnits: selectedUnits,
  28849. setSelectedUnits: setSelectedUnits,
  28850. units: units
  28851. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.RangeControl, {
  28852. label: (0,external_wp_i18n_namespaceObject.__)('Border radius'),
  28853. hideLabelFromVision: true,
  28854. className: "components-border-radius-control__range-control",
  28855. value: allValue !== null && allValue !== void 0 ? allValue : '',
  28856. min: MIN_BORDER_RADIUS_VALUE,
  28857. max: MAX_BORDER_RADIUS_VALUES[unit],
  28858. initialPosition: 0,
  28859. withInputField: false,
  28860. onChange: handleSliderChange,
  28861. step: step
  28862. })) : (0,external_wp_element_namespaceObject.createElement)(input_controls_BoxInputControls, {
  28863. min: MIN_BORDER_RADIUS_VALUE,
  28864. onChange: onChange,
  28865. selectedUnits: selectedUnits,
  28866. setSelectedUnits: setSelectedUnits,
  28867. values: values || border_radius_control_DEFAULT_VALUES,
  28868. units: units
  28869. }), (0,external_wp_element_namespaceObject.createElement)(linked_button_LinkedButton, {
  28870. onClick: toggleLinked,
  28871. isLinked: isLinked
  28872. })));
  28873. }
  28874. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-radius.js
  28875. /**
  28876. * Internal dependencies
  28877. */
  28878. /**
  28879. * Inspector control panel containing the border radius related configuration.
  28880. *
  28881. * @param {Object} props Block properties.
  28882. *
  28883. * @return {WPElement} Border radius edit element.
  28884. */
  28885. function BorderRadiusEdit(props) {
  28886. var _style$border;
  28887. const {
  28888. attributes: {
  28889. style
  28890. },
  28891. setAttributes
  28892. } = props;
  28893. const onChange = newRadius => {
  28894. const newStyle = cleanEmptyObject({ ...style,
  28895. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  28896. radius: newRadius
  28897. }
  28898. });
  28899. setAttributes({
  28900. style: newStyle
  28901. });
  28902. };
  28903. return (0,external_wp_element_namespaceObject.createElement)(BorderRadiusControl, {
  28904. values: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius,
  28905. onChange: onChange
  28906. });
  28907. }
  28908. /**
  28909. * Checks if there is a current value in the border radius block support
  28910. * attributes.
  28911. *
  28912. * @param {Object} props Block props.
  28913. * @return {boolean} Whether or not the block has a border radius value set.
  28914. */
  28915. function hasBorderRadiusValue(props) {
  28916. var _props$attributes$sty, _props$attributes$sty2;
  28917. const borderRadius = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.border) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.radius;
  28918. if (typeof borderRadius === 'object') {
  28919. return Object.entries(borderRadius).some(Boolean);
  28920. }
  28921. return !!borderRadius;
  28922. }
  28923. /**
  28924. * Resets the border radius block support attributes. This can be used when
  28925. * disabling the border radius support controls for a block via a progressive
  28926. * discovery panel.
  28927. *
  28928. * @param {Object} props Block props.
  28929. * @param {Object} props.attributes Block's attributes.
  28930. * @param {Object} props.setAttributes Function to set block's attributes.
  28931. */
  28932. function resetBorderRadius(_ref) {
  28933. let {
  28934. attributes = {},
  28935. setAttributes
  28936. } = _ref;
  28937. const {
  28938. style
  28939. } = attributes;
  28940. setAttributes({
  28941. style: removeBorderAttribute(style, 'radius')
  28942. });
  28943. }
  28944. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/utils.js
  28945. /**
  28946. * External dependencies
  28947. */
  28948. k([names, a11y]);
  28949. /**
  28950. * Provided an array of color objects as set by the theme or by the editor defaults,
  28951. * and the values of the defined color or custom color returns a color object describing the color.
  28952. *
  28953. * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
  28954. * @param {?string} definedColor A string containing the color slug.
  28955. * @param {?string} customColor A string containing the customColor value.
  28956. *
  28957. * @return {?Object} If definedColor is passed and the name is found in colors,
  28958. * the color object exactly as set by the theme or editor defaults is returned.
  28959. * Otherwise, an object that just sets the color is defined.
  28960. */
  28961. const getColorObjectByAttributeValues = (colors, definedColor, customColor) => {
  28962. if (definedColor) {
  28963. const colorObj = (0,external_lodash_namespaceObject.find)(colors, {
  28964. slug: definedColor
  28965. });
  28966. if (colorObj) {
  28967. return colorObj;
  28968. }
  28969. }
  28970. return {
  28971. color: customColor
  28972. };
  28973. };
  28974. /**
  28975. * Provided an array of color objects as set by the theme or by the editor defaults, and a color value returns the color object matching that value or undefined.
  28976. *
  28977. * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
  28978. * @param {?string} colorValue A string containing the color value.
  28979. *
  28980. * @return {?Object} Color object included in the colors array whose color property equals colorValue.
  28981. * Returns undefined if no color object matches this requirement.
  28982. */
  28983. const getColorObjectByColorValue = (colors, colorValue) => {
  28984. return (0,external_lodash_namespaceObject.find)(colors, {
  28985. color: colorValue
  28986. });
  28987. };
  28988. /**
  28989. * Returns a class based on the context a color is being used and its slug.
  28990. *
  28991. * @param {string} colorContextName Context/place where color is being used e.g: background, text etc...
  28992. * @param {string} colorSlug Slug of the color.
  28993. *
  28994. * @return {?string} String with the class corresponding to the color in the provided context.
  28995. * Returns undefined if either colorContextName or colorSlug are not provided.
  28996. */
  28997. function getColorClassName(colorContextName, colorSlug) {
  28998. if (!colorContextName || !colorSlug) {
  28999. return undefined;
  29000. }
  29001. return `has-${(0,external_lodash_namespaceObject.kebabCase)(colorSlug)}-${colorContextName}`;
  29002. }
  29003. /**
  29004. * Given an array of color objects and a color value returns the color value of the most readable color in the array.
  29005. *
  29006. * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
  29007. * @param {?string} colorValue A string containing the color value.
  29008. *
  29009. * @return {string} String with the color value of the most readable color.
  29010. */
  29011. function getMostReadableColor(colors, colorValue) {
  29012. const colordColor = w(colorValue);
  29013. const getColorContrast = _ref => {
  29014. let {
  29015. color
  29016. } = _ref;
  29017. return colordColor.contrast(color);
  29018. };
  29019. const maxContrast = Math.max(...colors.map(getColorContrast));
  29020. return colors.find(color => getColorContrast(color) === maxContrast).color;
  29021. }
  29022. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/use-common-single-multiple-selects.js
  29023. /**
  29024. * Internal dependencies
  29025. */
  29026. function useCommonSingleMultipleSelects() {
  29027. return {
  29028. disableCustomColors: !useSetting('color.custom'),
  29029. disableCustomGradients: !useSetting('color.customGradient')
  29030. };
  29031. }
  29032. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js
  29033. /**
  29034. * WordPress dependencies
  29035. */
  29036. /**
  29037. * Internal dependencies
  29038. */
  29039. /**
  29040. * Retrieves color and gradient related settings.
  29041. *
  29042. * The arrays for colors and gradients are made up of color palettes from each
  29043. * origin i.e. "Core", "Theme", and "User".
  29044. *
  29045. * @return {Object} Color and gradient related settings.
  29046. */
  29047. function useMultipleOriginColorsAndGradients() {
  29048. const colorGradientSettings = useCommonSingleMultipleSelects();
  29049. const customColors = useSetting('color.palette.custom');
  29050. const themeColors = useSetting('color.palette.theme');
  29051. const defaultColors = useSetting('color.palette.default');
  29052. const shouldDisplayDefaultColors = useSetting('color.defaultPalette');
  29053. colorGradientSettings.colors = (0,external_wp_element_namespaceObject.useMemo)(() => {
  29054. const result = [];
  29055. if (themeColors && themeColors.length) {
  29056. result.push({
  29057. name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'),
  29058. colors: themeColors
  29059. });
  29060. }
  29061. if (shouldDisplayDefaultColors && defaultColors && defaultColors.length) {
  29062. result.push({
  29063. name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'),
  29064. colors: defaultColors
  29065. });
  29066. }
  29067. if (customColors && customColors.length) {
  29068. result.push({
  29069. name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette comes from the theme.'),
  29070. colors: customColors
  29071. });
  29072. }
  29073. return result;
  29074. }, [defaultColors, themeColors, customColors]);
  29075. const customGradients = useSetting('color.gradients.custom');
  29076. const themeGradients = useSetting('color.gradients.theme');
  29077. const defaultGradients = useSetting('color.gradients.default');
  29078. const shouldDisplayDefaultGradients = useSetting('color.defaultGradients');
  29079. colorGradientSettings.gradients = (0,external_wp_element_namespaceObject.useMemo)(() => {
  29080. const result = [];
  29081. if (themeGradients && themeGradients.length) {
  29082. result.push({
  29083. name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'),
  29084. gradients: themeGradients
  29085. });
  29086. }
  29087. if (shouldDisplayDefaultGradients && defaultGradients && defaultGradients.length) {
  29088. result.push({
  29089. name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'),
  29090. gradients: defaultGradients
  29091. });
  29092. }
  29093. if (customGradients && customGradients.length) {
  29094. result.push({
  29095. name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette is created by the user.'),
  29096. gradients: customGradients
  29097. });
  29098. }
  29099. return result;
  29100. }, [customGradients, themeGradients, defaultGradients]);
  29101. return colorGradientSettings;
  29102. }
  29103. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border.js
  29104. /**
  29105. * External dependencies
  29106. */
  29107. /**
  29108. * WordPress dependencies
  29109. */
  29110. /**
  29111. * Internal dependencies
  29112. */
  29113. const BORDER_SUPPORT_KEY = '__experimentalBorder';
  29114. const borderSides = ['top', 'right', 'bottom', 'left'];
  29115. const hasBorderValue = props => {
  29116. const {
  29117. borderColor,
  29118. style
  29119. } = props.attributes;
  29120. return (0,external_wp_components_namespaceObject.__experimentalIsDefinedBorder)(style === null || style === void 0 ? void 0 : style.border) || !!borderColor;
  29121. }; // The border color, style, and width are omitted so they get undefined. The
  29122. // border radius is separate and must retain its selection.
  29123. const resetBorder = _ref => {
  29124. var _style$border;
  29125. let {
  29126. attributes = {},
  29127. setAttributes
  29128. } = _ref;
  29129. const {
  29130. style
  29131. } = attributes;
  29132. setAttributes({
  29133. borderColor: undefined,
  29134. style: { ...style,
  29135. border: cleanEmptyObject({
  29136. radius: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius
  29137. })
  29138. }
  29139. });
  29140. };
  29141. const resetBorderFilter = newAttributes => {
  29142. var _newAttributes$style, _newAttributes$style$;
  29143. return { ...newAttributes,
  29144. borderColor: undefined,
  29145. style: { ...newAttributes.style,
  29146. border: {
  29147. radius: (_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : (_newAttributes$style$ = _newAttributes$style.border) === null || _newAttributes$style$ === void 0 ? void 0 : _newAttributes$style$.radius
  29148. }
  29149. }
  29150. };
  29151. };
  29152. const getColorByProperty = (colors, property, value) => {
  29153. let matchedColor;
  29154. colors.some(origin => origin.colors.some(color => {
  29155. if (color[property] === value) {
  29156. matchedColor = color;
  29157. return true;
  29158. }
  29159. return false;
  29160. }));
  29161. return matchedColor;
  29162. };
  29163. const getMultiOriginColor = _ref2 => {
  29164. let {
  29165. colors,
  29166. namedColor,
  29167. customColor
  29168. } = _ref2;
  29169. // Search each origin (default, theme, or user) for matching color by name.
  29170. if (namedColor) {
  29171. const colorObject = getColorByProperty(colors, 'slug', namedColor);
  29172. if (colorObject) {
  29173. return colorObject;
  29174. }
  29175. } // Skip if no custom color or matching named color.
  29176. if (!customColor) {
  29177. return {
  29178. color: undefined
  29179. };
  29180. } // Attempt to find color via custom color value or build new object.
  29181. const colorObject = getColorByProperty(colors, 'color', customColor);
  29182. return colorObject ? colorObject : {
  29183. color: customColor
  29184. };
  29185. };
  29186. const getBorderObject = (attributes, colors) => {
  29187. const {
  29188. borderColor,
  29189. style
  29190. } = attributes;
  29191. const {
  29192. border: borderStyles
  29193. } = style || {}; // If we have a named color for a flat border. Fetch that color object and
  29194. // apply that color's value to the color property within the style object.
  29195. if (borderColor) {
  29196. const {
  29197. color
  29198. } = getMultiOriginColor({
  29199. colors,
  29200. namedColor: borderColor
  29201. });
  29202. return color ? { ...borderStyles,
  29203. color
  29204. } : borderStyles;
  29205. } // Individual side border color slugs are stored within the border style
  29206. // object. If we don't have a border styles object we have nothing further
  29207. // to hydrate.
  29208. if (!borderStyles) {
  29209. return borderStyles;
  29210. } // If we have named colors for the individual side borders, retrieve their
  29211. // related color objects and apply the real color values to the split
  29212. // border objects.
  29213. const hydratedBorderStyles = { ...borderStyles
  29214. };
  29215. borderSides.forEach(side => {
  29216. var _hydratedBorderStyles;
  29217. const colorSlug = getColorSlugFromVariable((_hydratedBorderStyles = hydratedBorderStyles[side]) === null || _hydratedBorderStyles === void 0 ? void 0 : _hydratedBorderStyles.color);
  29218. if (colorSlug) {
  29219. const {
  29220. color
  29221. } = getMultiOriginColor({
  29222. colors,
  29223. namedColor: colorSlug
  29224. });
  29225. hydratedBorderStyles[side] = { ...hydratedBorderStyles[side],
  29226. color
  29227. };
  29228. }
  29229. });
  29230. return hydratedBorderStyles;
  29231. };
  29232. function getColorSlugFromVariable(value) {
  29233. const namedColor = /var:preset\|color\|(.+)/.exec(value);
  29234. if (namedColor && namedColor[1]) {
  29235. return namedColor[1];
  29236. }
  29237. return null;
  29238. }
  29239. function BorderPanel(props) {
  29240. const {
  29241. attributes,
  29242. clientId,
  29243. setAttributes
  29244. } = props;
  29245. const {
  29246. style
  29247. } = attributes;
  29248. const {
  29249. colors
  29250. } = useMultipleOriginColorsAndGradients();
  29251. const isSupported = hasBorderSupport(props.name);
  29252. const isColorSupported = useSetting('border.color') && hasBorderSupport(props.name, 'color');
  29253. const isRadiusSupported = useSetting('border.radius') && hasBorderSupport(props.name, 'radius');
  29254. const isStyleSupported = useSetting('border.style') && hasBorderSupport(props.name, 'style');
  29255. const isWidthSupported = useSetting('border.width') && hasBorderSupport(props.name, 'width');
  29256. const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
  29257. if (isDisabled || !isSupported) {
  29258. return null;
  29259. }
  29260. const defaultBorderControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
  29261. const showBorderByDefault = (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color) || (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.width);
  29262. const onBorderChange = newBorder => {
  29263. var _style$border2;
  29264. // Filter out named colors and apply them to appropriate block
  29265. // attributes so that CSS classes can be used to apply those colors.
  29266. // e.g. has-primary-border-top-color.
  29267. let newBorderStyles = { ...newBorder
  29268. };
  29269. let newBorderColor;
  29270. if ((0,external_wp_components_namespaceObject.__experimentalHasSplitBorders)(newBorder)) {
  29271. // For each side check if the side has a color value set
  29272. // If so, determine if it belongs to a named color, in which case
  29273. // we update the color property.
  29274. //
  29275. // This deliberately overwrites `newBorderStyles` to avoid mutating
  29276. // the passed object which causes problems otherwise.
  29277. newBorderStyles = {
  29278. top: { ...newBorder.top
  29279. },
  29280. right: { ...newBorder.right
  29281. },
  29282. bottom: { ...newBorder.bottom
  29283. },
  29284. left: { ...newBorder.left
  29285. }
  29286. };
  29287. borderSides.forEach(side => {
  29288. var _newBorder$side;
  29289. if ((_newBorder$side = newBorder[side]) !== null && _newBorder$side !== void 0 && _newBorder$side.color) {
  29290. var _newBorder$side2;
  29291. const colorObject = getMultiOriginColor({
  29292. colors,
  29293. customColor: (_newBorder$side2 = newBorder[side]) === null || _newBorder$side2 === void 0 ? void 0 : _newBorder$side2.color
  29294. });
  29295. if (colorObject.slug) {
  29296. newBorderStyles[side].color = `var:preset|color|${colorObject.slug}`;
  29297. }
  29298. }
  29299. });
  29300. } else if (newBorder !== null && newBorder !== void 0 && newBorder.color) {
  29301. // We have a flat border configuration. Apply named color slug to
  29302. // `borderColor` attribute and clear color style property if found.
  29303. const customColor = newBorder === null || newBorder === void 0 ? void 0 : newBorder.color;
  29304. const colorObject = getMultiOriginColor({
  29305. colors,
  29306. customColor
  29307. });
  29308. if (colorObject.slug) {
  29309. newBorderColor = colorObject.slug;
  29310. newBorderStyles.color = undefined;
  29311. }
  29312. } // Ensure previous border radius styles are maintained and clean
  29313. // overall result for empty objects or properties.
  29314. const newStyle = cleanEmptyObject({ ...style,
  29315. border: {
  29316. radius: style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.radius,
  29317. ...newBorderStyles
  29318. }
  29319. });
  29320. setAttributes({
  29321. style: newStyle,
  29322. borderColor: newBorderColor
  29323. });
  29324. };
  29325. const hydratedBorder = getBorderObject(attributes, colors);
  29326. return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
  29327. __experimentalGroup: "border"
  29328. }, (isWidthSupported || isColorSupported) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  29329. hasValue: () => hasBorderValue(props),
  29330. label: (0,external_wp_i18n_namespaceObject.__)('Border'),
  29331. onDeselect: () => resetBorder(props),
  29332. isShownByDefault: showBorderByDefault,
  29333. resetAllFilter: resetBorderFilter,
  29334. panelId: clientId
  29335. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBorderBoxControl, {
  29336. colors: colors,
  29337. enableAlpha: true,
  29338. enableStyle: isStyleSupported,
  29339. onChange: onBorderChange,
  29340. popoverOffset: 40,
  29341. popoverPlacement: "left-start",
  29342. value: hydratedBorder,
  29343. __experimentalHasMultipleOrigins: true,
  29344. __experimentalIsRenderedInSidebar: true
  29345. })), isRadiusSupported && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  29346. hasValue: () => hasBorderRadiusValue(props),
  29347. label: (0,external_wp_i18n_namespaceObject.__)('Radius'),
  29348. onDeselect: () => resetBorderRadius(props),
  29349. isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.radius,
  29350. resetAllFilter: newAttributes => {
  29351. var _newAttributes$style2;
  29352. return { ...newAttributes,
  29353. style: { ...newAttributes.style,
  29354. border: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.border),
  29355. radius: undefined
  29356. }
  29357. }
  29358. };
  29359. },
  29360. panelId: clientId
  29361. }, (0,external_wp_element_namespaceObject.createElement)(BorderRadiusEdit, props)));
  29362. }
  29363. /**
  29364. * Determine whether there is block support for border properties.
  29365. *
  29366. * @param {string} blockName Block name.
  29367. * @param {string} feature Border feature to check support for.
  29368. *
  29369. * @return {boolean} Whether there is support.
  29370. */
  29371. function hasBorderSupport(blockName) {
  29372. let feature = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'any';
  29373. if (external_wp_element_namespaceObject.Platform.OS !== 'web') {
  29374. return false;
  29375. }
  29376. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, BORDER_SUPPORT_KEY);
  29377. if (support === true) {
  29378. return true;
  29379. }
  29380. if (feature === 'any') {
  29381. return !!(support !== null && support !== void 0 && support.color || support !== null && support !== void 0 && support.radius || support !== null && support !== void 0 && support.width || support !== null && support !== void 0 && support.style);
  29382. }
  29383. return !!(support !== null && support !== void 0 && support[feature]);
  29384. }
  29385. /**
  29386. * Returns a new style object where the specified border attribute has been
  29387. * removed.
  29388. *
  29389. * @param {Object} style Styles from block attributes.
  29390. * @param {string} attribute The border style attribute to clear.
  29391. *
  29392. * @return {Object} Style object with the specified attribute removed.
  29393. */
  29394. function removeBorderAttribute(style, attribute) {
  29395. return cleanEmptyObject({ ...style,
  29396. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  29397. [attribute]: undefined
  29398. }
  29399. });
  29400. }
  29401. /**
  29402. * Filters registered block settings, extending attributes to include
  29403. * `borderColor` if needed.
  29404. *
  29405. * @param {Object} settings Original block settings.
  29406. *
  29407. * @return {Object} Updated block settings.
  29408. */
  29409. function addAttributes(settings) {
  29410. if (!hasBorderSupport(settings, 'color')) {
  29411. return settings;
  29412. } // Allow blocks to specify default value if needed.
  29413. if (settings.attributes.borderColor) {
  29414. return settings;
  29415. } // Add new borderColor attribute to block settings.
  29416. return { ...settings,
  29417. attributes: { ...settings.attributes,
  29418. borderColor: {
  29419. type: 'string'
  29420. }
  29421. }
  29422. };
  29423. }
  29424. /**
  29425. * Override props assigned to save component to inject border color.
  29426. *
  29427. * @param {Object} props Additional props applied to save element.
  29428. * @param {Object} blockType Block type definition.
  29429. * @param {Object} attributes Block's attributes.
  29430. *
  29431. * @return {Object} Filtered props to apply to save element.
  29432. */
  29433. function border_addSaveProps(props, blockType, attributes) {
  29434. if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType, BORDER_SUPPORT_KEY, 'color')) {
  29435. return props;
  29436. }
  29437. const borderClasses = getBorderClasses(attributes);
  29438. const newClassName = classnames_default()(props.className, borderClasses); // If we are clearing the last of the previous classes in `className`
  29439. // set it to `undefined` to avoid rendering empty DOM attributes.
  29440. props.className = newClassName ? newClassName : undefined;
  29441. return props;
  29442. }
  29443. /**
  29444. * Generates a CSS class name consisting of all the applicable border color
  29445. * classes given the current block attributes.
  29446. *
  29447. * @param {Object} attributes Block's attributes.
  29448. *
  29449. * @return {string} CSS class name.
  29450. */
  29451. function getBorderClasses(attributes) {
  29452. var _style$border3;
  29453. const {
  29454. borderColor,
  29455. style
  29456. } = attributes;
  29457. const borderColorClass = getColorClassName('border-color', borderColor);
  29458. return classnames_default()({
  29459. 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border3 = style.border) === null || _style$border3 === void 0 ? void 0 : _style$border3.color),
  29460. [borderColorClass]: !!borderColorClass
  29461. });
  29462. }
  29463. /**
  29464. * Filters the registered block settings to apply border color styles and
  29465. * classnames to the block edit wrapper.
  29466. *
  29467. * @param {Object} settings Original block settings.
  29468. *
  29469. * @return {Object} Filtered block settings.
  29470. */
  29471. function addEditProps(settings) {
  29472. if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings, BORDER_SUPPORT_KEY, 'color')) {
  29473. return settings;
  29474. }
  29475. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  29476. settings.getEditWrapperProps = attributes => {
  29477. let props = {};
  29478. if (existingGetEditWrapperProps) {
  29479. props = existingGetEditWrapperProps(attributes);
  29480. }
  29481. return border_addSaveProps(props, settings, attributes);
  29482. };
  29483. return settings;
  29484. }
  29485. /**
  29486. * This adds inline styles for color palette colors.
  29487. * Ideally, this is not needed and themes should load their palettes on the editor.
  29488. *
  29489. * @param {Function} BlockListBlock Original component.
  29490. *
  29491. * @return {Function} Wrapped component.
  29492. */
  29493. const withBorderColorPaletteStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  29494. var _style$border4, _style$border4$top, _style$border5, _style$border5$right, _style$border6, _style$border6$bottom, _style$border7, _style$border7$left, _props$wrapperProps;
  29495. const {
  29496. name,
  29497. attributes
  29498. } = props;
  29499. const {
  29500. borderColor,
  29501. style
  29502. } = attributes;
  29503. const {
  29504. colors
  29505. } = useMultipleOriginColorsAndGradients();
  29506. if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name, BORDER_SUPPORT_KEY, 'color')) {
  29507. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
  29508. }
  29509. const {
  29510. color: borderColorValue
  29511. } = getMultiOriginColor({
  29512. colors,
  29513. namedColor: borderColor
  29514. });
  29515. const {
  29516. color: borderTopColor
  29517. } = getMultiOriginColor({
  29518. colors,
  29519. namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border4 = style.border) === null || _style$border4 === void 0 ? void 0 : (_style$border4$top = _style$border4.top) === null || _style$border4$top === void 0 ? void 0 : _style$border4$top.color)
  29520. });
  29521. const {
  29522. color: borderRightColor
  29523. } = getMultiOriginColor({
  29524. colors,
  29525. namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border5 = style.border) === null || _style$border5 === void 0 ? void 0 : (_style$border5$right = _style$border5.right) === null || _style$border5$right === void 0 ? void 0 : _style$border5$right.color)
  29526. });
  29527. const {
  29528. color: borderBottomColor
  29529. } = getMultiOriginColor({
  29530. colors,
  29531. namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border6 = style.border) === null || _style$border6 === void 0 ? void 0 : (_style$border6$bottom = _style$border6.bottom) === null || _style$border6$bottom === void 0 ? void 0 : _style$border6$bottom.color)
  29532. });
  29533. const {
  29534. color: borderLeftColor
  29535. } = getMultiOriginColor({
  29536. colors,
  29537. namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border7 = style.border) === null || _style$border7 === void 0 ? void 0 : (_style$border7$left = _style$border7.left) === null || _style$border7$left === void 0 ? void 0 : _style$border7$left.color)
  29538. });
  29539. const extraStyles = {
  29540. borderTopColor: borderTopColor || borderColorValue,
  29541. borderRightColor: borderRightColor || borderColorValue,
  29542. borderBottomColor: borderBottomColor || borderColorValue,
  29543. borderLeftColor: borderLeftColor || borderColorValue
  29544. };
  29545. let wrapperProps = props.wrapperProps;
  29546. wrapperProps = { ...props.wrapperProps,
  29547. style: { ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style),
  29548. ...extraStyles
  29549. }
  29550. };
  29551. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  29552. wrapperProps: wrapperProps
  29553. }));
  29554. });
  29555. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
  29556. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', border_addSaveProps);
  29557. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
  29558. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
  29559. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradients/use-gradient.js
  29560. /**
  29561. * External dependencies
  29562. */
  29563. /**
  29564. * WordPress dependencies
  29565. */
  29566. /**
  29567. * Internal dependencies
  29568. */
  29569. function __experimentalGetGradientClass(gradientSlug) {
  29570. if (!gradientSlug) {
  29571. return undefined;
  29572. }
  29573. return `has-${gradientSlug}-gradient-background`;
  29574. }
  29575. /**
  29576. * Retrieves the gradient value per slug.
  29577. *
  29578. * @param {Array} gradients Gradient Palette
  29579. * @param {string} slug Gradient slug
  29580. *
  29581. * @return {string} Gradient value.
  29582. */
  29583. function getGradientValueBySlug(gradients, slug) {
  29584. const gradient = (0,external_lodash_namespaceObject.find)(gradients, ['slug', slug]);
  29585. return gradient && gradient.gradient;
  29586. }
  29587. function __experimentalGetGradientObjectByGradientValue(gradients, value) {
  29588. const gradient = (0,external_lodash_namespaceObject.find)(gradients, ['gradient', value]);
  29589. return gradient;
  29590. }
  29591. /**
  29592. * Retrieves the gradient slug per slug.
  29593. *
  29594. * @param {Array} gradients Gradient Palette
  29595. * @param {string} value Gradient value
  29596. * @return {string} Gradient slug.
  29597. */
  29598. function getGradientSlugByValue(gradients, value) {
  29599. const gradient = __experimentalGetGradientObjectByGradientValue(gradients, value);
  29600. return gradient && gradient.slug;
  29601. }
  29602. function __experimentalUseGradient() {
  29603. let {
  29604. gradientAttribute = 'gradient',
  29605. customGradientAttribute = 'customGradient'
  29606. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  29607. const {
  29608. clientId
  29609. } = useBlockEditContext();
  29610. const userGradientPalette = useSetting('color.gradients.custom');
  29611. const themeGradientPalette = useSetting('color.gradients.theme');
  29612. const defaultGradientPalette = useSetting('color.gradients.default');
  29613. const allGradients = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userGradientPalette || []), ...(themeGradientPalette || []), ...(defaultGradientPalette || [])], [userGradientPalette, themeGradientPalette, defaultGradientPalette]);
  29614. const {
  29615. gradient,
  29616. customGradient
  29617. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  29618. const {
  29619. getBlockAttributes
  29620. } = select(store);
  29621. const attributes = getBlockAttributes(clientId) || {};
  29622. return {
  29623. customGradient: attributes[customGradientAttribute],
  29624. gradient: attributes[gradientAttribute]
  29625. };
  29626. }, [clientId, gradientAttribute, customGradientAttribute]);
  29627. const {
  29628. updateBlockAttributes
  29629. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  29630. const setGradient = (0,external_wp_element_namespaceObject.useCallback)(newGradientValue => {
  29631. const slug = getGradientSlugByValue(allGradients, newGradientValue);
  29632. if (slug) {
  29633. updateBlockAttributes(clientId, {
  29634. [gradientAttribute]: slug,
  29635. [customGradientAttribute]: undefined
  29636. });
  29637. return;
  29638. }
  29639. updateBlockAttributes(clientId, {
  29640. [gradientAttribute]: undefined,
  29641. [customGradientAttribute]: newGradientValue
  29642. });
  29643. }, [allGradients, clientId, updateBlockAttributes]);
  29644. const gradientClass = __experimentalGetGradientClass(gradient);
  29645. let gradientValue;
  29646. if (gradient) {
  29647. gradientValue = getGradientValueBySlug(allGradients, gradient);
  29648. } else {
  29649. gradientValue = customGradient;
  29650. }
  29651. return {
  29652. gradientClass,
  29653. gradientValue,
  29654. setGradient
  29655. };
  29656. }
  29657. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/control.js
  29658. /**
  29659. * External dependencies
  29660. */
  29661. /**
  29662. * WordPress dependencies
  29663. */
  29664. /**
  29665. * Internal dependencies
  29666. */
  29667. const colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients'];
  29668. const TAB_COLOR = {
  29669. name: 'color',
  29670. title: 'Solid',
  29671. value: 'color'
  29672. };
  29673. const TAB_GRADIENT = {
  29674. name: 'gradient',
  29675. title: 'Gradient',
  29676. value: 'gradient'
  29677. };
  29678. const TABS_SETTINGS = [TAB_COLOR, TAB_GRADIENT];
  29679. function ColorGradientControlInner(_ref) {
  29680. let {
  29681. colors,
  29682. gradients,
  29683. disableCustomColors,
  29684. disableCustomGradients,
  29685. __experimentalHasMultipleOrigins,
  29686. __experimentalIsRenderedInSidebar,
  29687. className,
  29688. label,
  29689. onColorChange,
  29690. onGradientChange,
  29691. colorValue,
  29692. gradientValue,
  29693. clearable,
  29694. showTitle = true,
  29695. enableAlpha
  29696. } = _ref;
  29697. const canChooseAColor = onColorChange && (!(0,external_lodash_namespaceObject.isEmpty)(colors) || !disableCustomColors);
  29698. const canChooseAGradient = onGradientChange && (!(0,external_lodash_namespaceObject.isEmpty)(gradients) || !disableCustomGradients);
  29699. if (!canChooseAColor && !canChooseAGradient) {
  29700. return null;
  29701. }
  29702. const tabPanels = {
  29703. [TAB_COLOR.value]: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorPalette, {
  29704. value: colorValue,
  29705. onChange: canChooseAGradient ? newColor => {
  29706. onColorChange(newColor);
  29707. onGradientChange();
  29708. } : onColorChange,
  29709. colors,
  29710. disableCustomColors,
  29711. __experimentalHasMultipleOrigins: __experimentalHasMultipleOrigins,
  29712. __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,
  29713. clearable: clearable,
  29714. enableAlpha: enableAlpha
  29715. }),
  29716. [TAB_GRADIENT.value]: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.GradientPicker, {
  29717. __nextHasNoMargin: true,
  29718. value: gradientValue,
  29719. onChange: canChooseAColor ? newGradient => {
  29720. onGradientChange(newGradient);
  29721. onColorChange();
  29722. } : onGradientChange,
  29723. gradients,
  29724. disableCustomGradients,
  29725. __experimentalHasMultipleOrigins: __experimentalHasMultipleOrigins,
  29726. __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,
  29727. clearable: clearable
  29728. })
  29729. };
  29730. const renderPanelType = type => (0,external_wp_element_namespaceObject.createElement)("div", {
  29731. className: "block-editor-color-gradient-control__panel"
  29732. }, tabPanels[type]);
  29733. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, {
  29734. __nextHasNoMarginBottom: true,
  29735. className: classnames_default()('block-editor-color-gradient-control', className)
  29736. }, (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  29737. className: "block-editor-color-gradient-control__fieldset"
  29738. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
  29739. spacing: 1
  29740. }, showTitle && (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_element_namespaceObject.createElement)("div", {
  29741. className: "block-editor-color-gradient-control__color-indicator"
  29742. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, null, label))), canChooseAColor && canChooseAGradient && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
  29743. className: "block-editor-color-gradient-control__tabs",
  29744. tabs: TABS_SETTINGS,
  29745. initialTabName: gradientValue ? TAB_GRADIENT.value : !!canChooseAColor && TAB_COLOR.value
  29746. }, tab => renderPanelType(tab.value)), !canChooseAGradient && renderPanelType(TAB_COLOR.value), !canChooseAColor && renderPanelType(TAB_GRADIENT.value))));
  29747. }
  29748. function ColorGradientControlSelect(props) {
  29749. const colorGradientSettings = {};
  29750. colorGradientSettings.colors = useSetting('color.palette');
  29751. colorGradientSettings.gradients = useSetting('color.gradients');
  29752. colorGradientSettings.disableCustomColors = !useSetting('color.custom');
  29753. colorGradientSettings.disableCustomGradients = !useSetting('color.customGradient');
  29754. return (0,external_wp_element_namespaceObject.createElement)(ColorGradientControlInner, _extends({}, colorGradientSettings, props));
  29755. }
  29756. function ColorGradientControl(props) {
  29757. if ((0,external_lodash_namespaceObject.every)(colorsAndGradientKeys, key => props.hasOwnProperty(key))) {
  29758. return (0,external_wp_element_namespaceObject.createElement)(ColorGradientControlInner, props);
  29759. }
  29760. return (0,external_wp_element_namespaceObject.createElement)(ColorGradientControlSelect, props);
  29761. }
  29762. /* harmony default export */ var control = (ColorGradientControl);
  29763. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/dropdown.js
  29764. /**
  29765. * External dependencies
  29766. */
  29767. /**
  29768. * WordPress dependencies
  29769. */
  29770. /**
  29771. * Internal dependencies
  29772. */
  29773. // When the `ColorGradientSettingsDropdown` controls are being rendered to a
  29774. // `ToolsPanel` they must be wrapped in a `ToolsPanelItem`.
  29775. const WithToolsPanelItem = _ref => {
  29776. let {
  29777. setting,
  29778. children,
  29779. panelId,
  29780. ...props
  29781. } = _ref;
  29782. const clearValue = () => {
  29783. if (setting.colorValue) {
  29784. setting.onColorChange();
  29785. } else if (setting.gradientValue) {
  29786. setting.onGradientChange();
  29787. }
  29788. };
  29789. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, _extends({
  29790. hasValue: () => {
  29791. return !!setting.colorValue || !!setting.gradientValue;
  29792. },
  29793. label: setting.label,
  29794. onDeselect: clearValue,
  29795. isShownByDefault: setting.isShownByDefault !== undefined ? setting.isShownByDefault : true
  29796. }, props, {
  29797. className: "block-editor-tools-panel-color-gradient-settings__item",
  29798. panelId: panelId // Pass resetAllFilter if supplied due to rendering via SlotFill
  29799. // into parent ToolsPanel.
  29800. ,
  29801. resetAllFilter: setting.resetAllFilter
  29802. }), children);
  29803. };
  29804. const LabeledColorIndicator = _ref2 => {
  29805. let {
  29806. colorValue,
  29807. label
  29808. } = _ref2;
  29809. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
  29810. justify: "flex-start"
  29811. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
  29812. className: "block-editor-panel-color-gradient-settings__color-indicator",
  29813. colorValue: colorValue
  29814. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
  29815. className: "block-editor-panel-color-gradient-settings__color-name",
  29816. title: label
  29817. }, label));
  29818. }; // Renders a color dropdown's toggle as an `Item` if it is within an `ItemGroup`
  29819. // or as a `Button` if it isn't e.g. the controls are being rendered in
  29820. // a `ToolsPanel`.
  29821. const renderToggle = settings => _ref3 => {
  29822. let {
  29823. onToggle,
  29824. isOpen
  29825. } = _ref3;
  29826. const {
  29827. colorValue,
  29828. label
  29829. } = settings;
  29830. const toggleProps = {
  29831. onClick: onToggle,
  29832. className: classnames_default()('block-editor-panel-color-gradient-settings__dropdown', {
  29833. 'is-open': isOpen
  29834. }),
  29835. 'aria-expanded': isOpen
  29836. };
  29837. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, toggleProps, (0,external_wp_element_namespaceObject.createElement)(LabeledColorIndicator, {
  29838. colorValue: colorValue,
  29839. label: label
  29840. }));
  29841. }; // Renders a collection of color controls as dropdowns. Depending upon the
  29842. // context in which these dropdowns are being rendered, they may be wrapped
  29843. // in an `ItemGroup` with each dropdown's toggle as an `Item`, or alternatively,
  29844. // the may be individually wrapped in a `ToolsPanelItem` with the toggle as
  29845. // a regular `Button`.
  29846. //
  29847. // For more context see: https://github.com/WordPress/gutenberg/pull/40084
  29848. function ColorGradientSettingsDropdown(_ref4) {
  29849. let {
  29850. colors,
  29851. disableCustomColors,
  29852. disableCustomGradients,
  29853. enableAlpha,
  29854. gradients,
  29855. settings,
  29856. __experimentalHasMultipleOrigins,
  29857. __experimentalIsRenderedInSidebar,
  29858. ...props
  29859. } = _ref4;
  29860. let popoverProps;
  29861. if (__experimentalIsRenderedInSidebar) {
  29862. popoverProps = {
  29863. placement: 'left-start',
  29864. offset: 36,
  29865. shift: true
  29866. };
  29867. }
  29868. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, settings.map((setting, index) => {
  29869. var _setting$gradientValu;
  29870. const controlProps = {
  29871. clearable: false,
  29872. colorValue: setting.colorValue,
  29873. colors,
  29874. disableCustomColors,
  29875. disableCustomGradients,
  29876. enableAlpha,
  29877. gradientValue: setting.gradientValue,
  29878. gradients,
  29879. label: setting.label,
  29880. onColorChange: setting.onColorChange,
  29881. onGradientChange: setting.onGradientChange,
  29882. showTitle: false,
  29883. __experimentalHasMultipleOrigins,
  29884. __experimentalIsRenderedInSidebar,
  29885. ...setting
  29886. };
  29887. const toggleSettings = {
  29888. colorValue: (_setting$gradientValu = setting.gradientValue) !== null && _setting$gradientValu !== void 0 ? _setting$gradientValu : setting.colorValue,
  29889. label: setting.label
  29890. };
  29891. return setting && // If not in an `ItemGroup` wrap the dropdown in a
  29892. // `ToolsPanelItem`
  29893. (0,external_wp_element_namespaceObject.createElement)(WithToolsPanelItem, _extends({
  29894. key: index,
  29895. setting: setting
  29896. }, props), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  29897. popoverProps: popoverProps,
  29898. className: "block-editor-tools-panel-color-gradient-settings__dropdown",
  29899. renderToggle: renderToggle(toggleSettings),
  29900. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalDropdownContentWrapper, {
  29901. paddingSize: "none"
  29902. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  29903. className: "block-editor-panel-color-gradient-settings__dropdown-content"
  29904. }, (0,external_wp_element_namespaceObject.createElement)(control, controlProps)))
  29905. }));
  29906. }));
  29907. }
  29908. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/contrast-checker/index.js
  29909. /**
  29910. * External dependencies
  29911. */
  29912. /**
  29913. * WordPress dependencies
  29914. */
  29915. k([names, a11y]);
  29916. function ContrastChecker(_ref) {
  29917. let {
  29918. backgroundColor,
  29919. fallbackBackgroundColor,
  29920. fallbackTextColor,
  29921. fallbackLinkColor,
  29922. fontSize,
  29923. // Font size value in pixels.
  29924. isLargeText,
  29925. textColor,
  29926. linkColor,
  29927. enableAlphaChecker = false
  29928. } = _ref;
  29929. const currentBackgroundColor = backgroundColor || fallbackBackgroundColor; // Must have a background color.
  29930. if (!currentBackgroundColor) {
  29931. return null;
  29932. }
  29933. const currentTextColor = textColor || fallbackTextColor;
  29934. const currentLinkColor = linkColor || fallbackLinkColor; // Must have at least one text color.
  29935. if (!currentTextColor && !currentLinkColor) {
  29936. return null;
  29937. }
  29938. const textColors = [{
  29939. color: currentTextColor,
  29940. description: (0,external_wp_i18n_namespaceObject.__)('text color')
  29941. }, {
  29942. color: currentLinkColor,
  29943. description: (0,external_wp_i18n_namespaceObject.__)('link color')
  29944. }];
  29945. const colordBackgroundColor = w(currentBackgroundColor);
  29946. const backgroundColorHasTransparency = colordBackgroundColor.alpha() < 1;
  29947. const backgroundColorBrightness = colordBackgroundColor.brightness();
  29948. const isReadableOptions = {
  29949. level: 'AA',
  29950. size: isLargeText || isLargeText !== false && fontSize >= 24 ? 'large' : 'small'
  29951. };
  29952. let message = '';
  29953. let speakMessage = '';
  29954. for (const item of textColors) {
  29955. // If there is no color, go no further.
  29956. if (!item.color) {
  29957. continue;
  29958. }
  29959. const colordTextColor = w(item.color);
  29960. const isColordTextReadable = colordTextColor.isReadable(colordBackgroundColor, isReadableOptions);
  29961. const textHasTransparency = colordTextColor.alpha() < 1; // If the contrast is not readable.
  29962. if (!isColordTextReadable) {
  29963. // Don't show the message if the background or text is transparent.
  29964. if (backgroundColorHasTransparency || textHasTransparency) {
  29965. continue;
  29966. }
  29967. message = backgroundColorBrightness < colordTextColor.brightness() ? (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s is a type of text color, e.g., "text color" or "link color".
  29968. (0,external_wp_i18n_namespaceObject.__)('This color combination may be hard for people to read. Try using a darker background color and/or a brighter %s.'), item.description) : (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s is a type of text color, e.g., "text color" or "link color".
  29969. (0,external_wp_i18n_namespaceObject.__)('This color combination may be hard for people to read. Try using a brighter background color and/or a darker %s.'), item.description);
  29970. speakMessage = (0,external_wp_i18n_namespaceObject.__)('This color combination may be hard for people to read.'); // Break from the loop when we have a contrast warning.
  29971. // These messages take priority over the transparency warning.
  29972. break;
  29973. } // If there is no contrast warning and the text is transparent,
  29974. // show the transparent warning if alpha check is enabled.
  29975. if (textHasTransparency && enableAlphaChecker) {
  29976. message = (0,external_wp_i18n_namespaceObject.__)('Transparent text may be hard for people to read.');
  29977. speakMessage = (0,external_wp_i18n_namespaceObject.__)('Transparent text may be hard for people to read.');
  29978. }
  29979. }
  29980. if (!message) {
  29981. return null;
  29982. } // Note: The `Notice` component can speak messages via its `spokenMessage`
  29983. // prop, but the contrast checker requires granular control over when the
  29984. // announcements are made. Notably, the message will be re-announced if a
  29985. // new color combination is selected and the contrast is still insufficient.
  29986. (0,external_wp_a11y_namespaceObject.speak)(speakMessage);
  29987. return (0,external_wp_element_namespaceObject.createElement)("div", {
  29988. className: "block-editor-contrast-checker"
  29989. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
  29990. spokenMessage: null,
  29991. status: "warning",
  29992. isDismissible: false
  29993. }, message));
  29994. }
  29995. /**
  29996. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/contrast-checker/README.md
  29997. */
  29998. /* harmony default export */ var contrast_checker = (ContrastChecker);
  29999. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/color-panel.js
  30000. /**
  30001. * WordPress dependencies
  30002. */
  30003. /**
  30004. * Internal dependencies
  30005. */
  30006. function getComputedStyle(node) {
  30007. return node.ownerDocument.defaultView.getComputedStyle(node);
  30008. }
  30009. function ColorPanel(_ref) {
  30010. let {
  30011. enableAlpha = false,
  30012. settings,
  30013. clientId,
  30014. enableContrastChecking = true
  30015. } = _ref;
  30016. const [detectedBackgroundColor, setDetectedBackgroundColor] = (0,external_wp_element_namespaceObject.useState)();
  30017. const [detectedColor, setDetectedColor] = (0,external_wp_element_namespaceObject.useState)();
  30018. const [detectedLinkColor, setDetectedLinkColor] = (0,external_wp_element_namespaceObject.useState)();
  30019. const ref = useBlockRef(clientId);
  30020. const definedColors = settings.filter(setting => setting === null || setting === void 0 ? void 0 : setting.colorValue);
  30021. (0,external_wp_element_namespaceObject.useEffect)(() => {
  30022. var _ref$current;
  30023. if (!enableContrastChecking || !definedColors.length) {
  30024. return;
  30025. }
  30026. if (!ref.current) {
  30027. return;
  30028. }
  30029. setDetectedColor(getComputedStyle(ref.current).color);
  30030. const firstLinkElement = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector('a');
  30031. if (firstLinkElement && !!firstLinkElement.innerText) {
  30032. setDetectedLinkColor(getComputedStyle(firstLinkElement).color);
  30033. }
  30034. let backgroundColorNode = ref.current;
  30035. let backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor;
  30036. while (backgroundColor === 'rgba(0, 0, 0, 0)' && backgroundColorNode.parentNode && backgroundColorNode.parentNode.nodeType === backgroundColorNode.parentNode.ELEMENT_NODE) {
  30037. backgroundColorNode = backgroundColorNode.parentNode;
  30038. backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor;
  30039. }
  30040. setDetectedBackgroundColor(backgroundColor);
  30041. });
  30042. const colorGradientSettings = useMultipleOriginColorsAndGradients();
  30043. return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
  30044. __experimentalGroup: "color"
  30045. }, (0,external_wp_element_namespaceObject.createElement)(ColorGradientSettingsDropdown, _extends({
  30046. enableAlpha: enableAlpha,
  30047. panelId: clientId,
  30048. settings: settings,
  30049. __experimentalIsItemGroup: false,
  30050. __experimentalHasMultipleOrigins: true,
  30051. __experimentalIsRenderedInSidebar: true
  30052. }, colorGradientSettings)), enableContrastChecking && (0,external_wp_element_namespaceObject.createElement)(contrast_checker, {
  30053. backgroundColor: detectedBackgroundColor,
  30054. textColor: detectedColor,
  30055. enableAlphaChecker: enableAlpha,
  30056. linkColor: detectedLinkColor
  30057. }));
  30058. }
  30059. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/color.js
  30060. /**
  30061. * External dependencies
  30062. */
  30063. /**
  30064. * WordPress dependencies
  30065. */
  30066. /**
  30067. * Internal dependencies
  30068. */
  30069. const COLOR_SUPPORT_KEY = 'color';
  30070. const hasColorSupport = blockType => {
  30071. const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
  30072. return colorSupport && (colorSupport.link === true || colorSupport.gradient === true || colorSupport.background !== false || colorSupport.text !== false);
  30073. };
  30074. const hasLinkColorSupport = blockType => {
  30075. if (external_wp_element_namespaceObject.Platform.OS !== 'web') {
  30076. return false;
  30077. }
  30078. const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
  30079. return colorSupport !== null && typeof colorSupport === 'object' && !!colorSupport.link;
  30080. };
  30081. const hasGradientSupport = blockType => {
  30082. const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
  30083. return colorSupport !== null && typeof colorSupport === 'object' && !!colorSupport.gradients;
  30084. };
  30085. const hasBackgroundColorSupport = blockType => {
  30086. const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
  30087. return colorSupport && colorSupport.background !== false;
  30088. };
  30089. const hasTextColorSupport = blockType => {
  30090. const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
  30091. return colorSupport && colorSupport.text !== false;
  30092. };
  30093. /**
  30094. * Clears a single color property from a style object.
  30095. *
  30096. * @param {Array} path Path to color property to clear within styles object.
  30097. * @param {Object} style Block attributes style object.
  30098. * @return {Object} Styles with the color property omitted.
  30099. */
  30100. const clearColorFromStyles = (path, style) => cleanEmptyObject(immutableSet(style, path, undefined));
  30101. /**
  30102. * Clears text color related properties from supplied attributes.
  30103. *
  30104. * @param {Object} attributes Block attributes.
  30105. * @return {Object} Update block attributes with text color properties omitted.
  30106. */
  30107. const resetAllTextFilter = attributes => ({
  30108. textColor: undefined,
  30109. style: clearColorFromStyles(['color', 'text'], attributes.style)
  30110. });
  30111. /**
  30112. * Clears link color related properties from supplied attributes.
  30113. *
  30114. * @param {Object} attributes Block attributes.
  30115. * @return {Object} Update block attributes with link color properties omitted.
  30116. */
  30117. const resetAllLinkFilter = attributes => ({
  30118. style: clearColorFromStyles(['elements', 'link', 'color', 'text'], attributes.style)
  30119. });
  30120. /**
  30121. * Clears all background color related properties including gradients from
  30122. * supplied block attributes.
  30123. *
  30124. * @param {Object} attributes Block attributes.
  30125. * @return {Object} Block attributes with background and gradient omitted.
  30126. */
  30127. const clearBackgroundAndGradient = attributes => {
  30128. var _attributes$style;
  30129. return {
  30130. backgroundColor: undefined,
  30131. gradient: undefined,
  30132. style: { ...attributes.style,
  30133. color: { ...((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.color),
  30134. background: undefined,
  30135. gradient: undefined
  30136. }
  30137. }
  30138. };
  30139. };
  30140. /**
  30141. * Filters registered block settings, extending attributes to include
  30142. * `backgroundColor` and `textColor` attribute.
  30143. *
  30144. * @param {Object} settings Original block settings.
  30145. *
  30146. * @return {Object} Filtered block settings.
  30147. */
  30148. function color_addAttributes(settings) {
  30149. if (!hasColorSupport(settings)) {
  30150. return settings;
  30151. } // Allow blocks to specify their own attribute definition with default values if needed.
  30152. if (!settings.attributes.backgroundColor) {
  30153. Object.assign(settings.attributes, {
  30154. backgroundColor: {
  30155. type: 'string'
  30156. }
  30157. });
  30158. }
  30159. if (!settings.attributes.textColor) {
  30160. Object.assign(settings.attributes, {
  30161. textColor: {
  30162. type: 'string'
  30163. }
  30164. });
  30165. }
  30166. if (hasGradientSupport(settings) && !settings.attributes.gradient) {
  30167. Object.assign(settings.attributes, {
  30168. gradient: {
  30169. type: 'string'
  30170. }
  30171. });
  30172. }
  30173. return settings;
  30174. }
  30175. /**
  30176. * Override props assigned to save component to inject colors classnames.
  30177. *
  30178. * @param {Object} props Additional props applied to save element.
  30179. * @param {Object} blockType Block type.
  30180. * @param {Object} attributes Block attributes.
  30181. *
  30182. * @return {Object} Filtered props applied to save element.
  30183. */
  30184. function color_addSaveProps(props, blockType, attributes) {
  30185. var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link;
  30186. if (!hasColorSupport(blockType) || shouldSkipSerialization(blockType, COLOR_SUPPORT_KEY)) {
  30187. return props;
  30188. }
  30189. const hasGradient = hasGradientSupport(blockType); // I'd have preferred to avoid the "style" attribute usage here
  30190. const {
  30191. backgroundColor,
  30192. textColor,
  30193. gradient,
  30194. style
  30195. } = attributes;
  30196. const shouldSerialize = feature => !shouldSkipSerialization(blockType, COLOR_SUPPORT_KEY, feature); // Primary color classes must come before the `has-text-color`,
  30197. // `has-background` and `has-link-color` classes to maintain backwards
  30198. // compatibility and avoid block invalidations.
  30199. const textClass = shouldSerialize('text') ? getColorClassName('color', textColor) : undefined;
  30200. const gradientClass = shouldSerialize('gradients') ? __experimentalGetGradientClass(gradient) : undefined;
  30201. const backgroundClass = shouldSerialize('background') ? getColorClassName('background-color', backgroundColor) : undefined;
  30202. const serializeHasBackground = shouldSerialize('background') || shouldSerialize('gradients');
  30203. const hasBackground = backgroundColor || (style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.background) || hasGradient && (gradient || (style === null || style === void 0 ? void 0 : (_style$color2 = style.color) === null || _style$color2 === void 0 ? void 0 : _style$color2.gradient));
  30204. const newClassName = classnames_default()(props.className, textClass, gradientClass, {
  30205. // Don't apply the background class if there's a custom gradient.
  30206. [backgroundClass]: (!hasGradient || !(style !== null && style !== void 0 && (_style$color3 = style.color) !== null && _style$color3 !== void 0 && _style$color3.gradient)) && !!backgroundClass,
  30207. 'has-text-color': shouldSerialize('text') && (textColor || (style === null || style === void 0 ? void 0 : (_style$color4 = style.color) === null || _style$color4 === void 0 ? void 0 : _style$color4.text)),
  30208. 'has-background': serializeHasBackground && hasBackground,
  30209. 'has-link-color': shouldSerialize('link') && (style === null || style === void 0 ? void 0 : (_style$elements = style.elements) === null || _style$elements === void 0 ? void 0 : (_style$elements$link = _style$elements.link) === null || _style$elements$link === void 0 ? void 0 : _style$elements$link.color)
  30210. });
  30211. props.className = newClassName ? newClassName : undefined;
  30212. return props;
  30213. }
  30214. /**
  30215. * Filters registered block settings to extend the block edit wrapper
  30216. * to apply the desired styles and classnames properly.
  30217. *
  30218. * @param {Object} settings Original block settings.
  30219. *
  30220. * @return {Object} Filtered block settings.
  30221. */
  30222. function color_addEditProps(settings) {
  30223. if (!hasColorSupport(settings) || shouldSkipSerialization(settings, COLOR_SUPPORT_KEY)) {
  30224. return settings;
  30225. }
  30226. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  30227. settings.getEditWrapperProps = attributes => {
  30228. let props = {};
  30229. if (existingGetEditWrapperProps) {
  30230. props = existingGetEditWrapperProps(attributes);
  30231. }
  30232. return color_addSaveProps(props, settings, attributes);
  30233. };
  30234. return settings;
  30235. }
  30236. const getLinkColorFromAttributeValue = (colors, value) => {
  30237. const attributeParsed = /var:preset\|color\|(.+)/.exec(value);
  30238. if (attributeParsed && attributeParsed[1]) {
  30239. return getColorObjectByAttributeValues(colors, attributeParsed[1]).color;
  30240. }
  30241. return value;
  30242. };
  30243. /**
  30244. * Inspector control panel containing the color related configuration
  30245. *
  30246. * @param {Object} props
  30247. *
  30248. * @return {WPElement} Color edit element.
  30249. */
  30250. function ColorEdit(props) {
  30251. var _style$color6, _style$color7, _style$color8, _style$elements2, _style$elements2$link, _style$elements2$link2, _style$elements3, _style$elements3$link, _style$elements3$link2;
  30252. const {
  30253. name: blockName,
  30254. attributes
  30255. } = props; // Some color settings have a special handling for deprecated flags in `useSetting`,
  30256. // so we can't unwrap them by doing const { ... } = useSetting('color')
  30257. // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
  30258. const userPalette = useSetting('color.palette.custom');
  30259. const themePalette = useSetting('color.palette.theme');
  30260. const defaultPalette = useSetting('color.palette.default');
  30261. const allSolids = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
  30262. const userGradientPalette = useSetting('color.gradients.custom');
  30263. const themeGradientPalette = useSetting('color.gradients.theme');
  30264. const defaultGradientPalette = useSetting('color.gradients.default');
  30265. const allGradients = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userGradientPalette || []), ...(themeGradientPalette || []), ...(defaultGradientPalette || [])], [userGradientPalette, themeGradientPalette, defaultGradientPalette]);
  30266. const areCustomSolidsEnabled = useSetting('color.custom');
  30267. const areCustomGradientsEnabled = useSetting('color.customGradient');
  30268. const isBackgroundEnabled = useSetting('color.background');
  30269. const isLinkEnabled = useSetting('color.link');
  30270. const isTextEnabled = useSetting('color.text');
  30271. const solidsEnabled = areCustomSolidsEnabled || !themePalette || (themePalette === null || themePalette === void 0 ? void 0 : themePalette.length) > 0;
  30272. const gradientsEnabled = areCustomGradientsEnabled || !themeGradientPalette || (themeGradientPalette === null || themeGradientPalette === void 0 ? void 0 : themeGradientPalette.length) > 0; // Shouldn't be needed but right now the ColorGradientsPanel
  30273. // can trigger both onChangeColor and onChangeBackground
  30274. // synchronously causing our two callbacks to override changes
  30275. // from each other.
  30276. const localAttributes = (0,external_wp_element_namespaceObject.useRef)(attributes);
  30277. (0,external_wp_element_namespaceObject.useEffect)(() => {
  30278. localAttributes.current = attributes;
  30279. }, [attributes]);
  30280. if (!hasColorSupport(blockName)) {
  30281. return null;
  30282. }
  30283. const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && solidsEnabled;
  30284. const hasTextColor = hasTextColorSupport(blockName) && isTextEnabled && solidsEnabled;
  30285. const hasBackgroundColor = hasBackgroundColorSupport(blockName) && isBackgroundEnabled && solidsEnabled;
  30286. const hasGradientColor = hasGradientSupport(blockName) && gradientsEnabled;
  30287. if (!hasLinkColor && !hasTextColor && !hasBackgroundColor && !hasGradientColor) {
  30288. return null;
  30289. }
  30290. const {
  30291. style,
  30292. textColor,
  30293. backgroundColor,
  30294. gradient
  30295. } = attributes;
  30296. let gradientValue;
  30297. if (hasGradientColor && gradient) {
  30298. gradientValue = getGradientValueBySlug(allGradients, gradient);
  30299. } else if (hasGradientColor) {
  30300. var _style$color5;
  30301. gradientValue = style === null || style === void 0 ? void 0 : (_style$color5 = style.color) === null || _style$color5 === void 0 ? void 0 : _style$color5.gradient;
  30302. }
  30303. const onChangeColor = name => value => {
  30304. var _localAttributes$curr, _localAttributes$curr2;
  30305. const colorObject = getColorObjectByColorValue(allSolids, value);
  30306. const attributeName = name + 'Color';
  30307. const newStyle = { ...localAttributes.current.style,
  30308. color: { ...((_localAttributes$curr = localAttributes.current) === null || _localAttributes$curr === void 0 ? void 0 : (_localAttributes$curr2 = _localAttributes$curr.style) === null || _localAttributes$curr2 === void 0 ? void 0 : _localAttributes$curr2.color),
  30309. [name]: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
  30310. }
  30311. };
  30312. const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
  30313. const newAttributes = {
  30314. style: cleanEmptyObject(newStyle),
  30315. [attributeName]: newNamedColor
  30316. };
  30317. props.setAttributes(newAttributes);
  30318. localAttributes.current = { ...localAttributes.current,
  30319. ...newAttributes
  30320. };
  30321. };
  30322. const onChangeGradient = value => {
  30323. const slug = getGradientSlugByValue(allGradients, value);
  30324. let newAttributes;
  30325. if (slug) {
  30326. var _localAttributes$curr3, _localAttributes$curr4, _localAttributes$curr5;
  30327. const newStyle = { ...((_localAttributes$curr3 = localAttributes.current) === null || _localAttributes$curr3 === void 0 ? void 0 : _localAttributes$curr3.style),
  30328. color: { ...((_localAttributes$curr4 = localAttributes.current) === null || _localAttributes$curr4 === void 0 ? void 0 : (_localAttributes$curr5 = _localAttributes$curr4.style) === null || _localAttributes$curr5 === void 0 ? void 0 : _localAttributes$curr5.color),
  30329. gradient: undefined
  30330. }
  30331. };
  30332. newAttributes = {
  30333. style: cleanEmptyObject(newStyle),
  30334. gradient: slug
  30335. };
  30336. } else {
  30337. var _localAttributes$curr6, _localAttributes$curr7, _localAttributes$curr8;
  30338. const newStyle = { ...((_localAttributes$curr6 = localAttributes.current) === null || _localAttributes$curr6 === void 0 ? void 0 : _localAttributes$curr6.style),
  30339. color: { ...((_localAttributes$curr7 = localAttributes.current) === null || _localAttributes$curr7 === void 0 ? void 0 : (_localAttributes$curr8 = _localAttributes$curr7.style) === null || _localAttributes$curr8 === void 0 ? void 0 : _localAttributes$curr8.color),
  30340. gradient: value
  30341. }
  30342. };
  30343. newAttributes = {
  30344. style: cleanEmptyObject(newStyle),
  30345. gradient: undefined
  30346. };
  30347. }
  30348. props.setAttributes(newAttributes);
  30349. localAttributes.current = { ...localAttributes.current,
  30350. ...newAttributes
  30351. };
  30352. };
  30353. const onChangeLinkColor = value => {
  30354. var _localAttributes$curr9;
  30355. const colorObject = getColorObjectByColorValue(allSolids, value);
  30356. const newLinkColorValue = colorObject !== null && colorObject !== void 0 && colorObject.slug ? `var:preset|color|${colorObject.slug}` : value;
  30357. const newStyle = cleanEmptyObject(immutableSet((_localAttributes$curr9 = localAttributes.current) === null || _localAttributes$curr9 === void 0 ? void 0 : _localAttributes$curr9.style, ['elements', 'link', 'color', 'text'], newLinkColorValue));
  30358. props.setAttributes({
  30359. style: newStyle
  30360. });
  30361. localAttributes.current = { ...localAttributes.current,
  30362. ...{
  30363. style: newStyle
  30364. }
  30365. };
  30366. };
  30367. const defaultColorControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [COLOR_SUPPORT_KEY, '__experimentalDefaultControls']);
  30368. const enableContrastChecking = external_wp_element_namespaceObject.Platform.OS === 'web' && !gradient && !(style !== null && style !== void 0 && (_style$color6 = style.color) !== null && _style$color6 !== void 0 && _style$color6.gradient) && // Contrast checking is enabled by default.
  30369. // Deactivating it requires `enableContrastChecker` to have
  30370. // an explicit value of `false`.
  30371. false !== (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [COLOR_SUPPORT_KEY, 'enableContrastChecker']);
  30372. return (0,external_wp_element_namespaceObject.createElement)(ColorPanel, {
  30373. enableContrastChecking: enableContrastChecking,
  30374. clientId: props.clientId,
  30375. enableAlpha: true,
  30376. settings: [...(hasTextColor ? [{
  30377. label: (0,external_wp_i18n_namespaceObject.__)('Text'),
  30378. onColorChange: onChangeColor('text'),
  30379. colorValue: getColorObjectByAttributeValues(allSolids, textColor, style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.text).color,
  30380. isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.text,
  30381. resetAllFilter: resetAllTextFilter
  30382. }] : []), ...(hasBackgroundColor || hasGradientColor ? [{
  30383. label: (0,external_wp_i18n_namespaceObject.__)('Background'),
  30384. onColorChange: hasBackgroundColor ? onChangeColor('background') : undefined,
  30385. colorValue: getColorObjectByAttributeValues(allSolids, backgroundColor, style === null || style === void 0 ? void 0 : (_style$color8 = style.color) === null || _style$color8 === void 0 ? void 0 : _style$color8.background).color,
  30386. gradientValue,
  30387. onGradientChange: hasGradientColor ? onChangeGradient : undefined,
  30388. isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.background,
  30389. resetAllFilter: clearBackgroundAndGradient
  30390. }] : []), ...(hasLinkColor ? [{
  30391. label: (0,external_wp_i18n_namespaceObject.__)('Link'),
  30392. onColorChange: onChangeLinkColor,
  30393. colorValue: getLinkColorFromAttributeValue(allSolids, style === null || style === void 0 ? void 0 : (_style$elements2 = style.elements) === null || _style$elements2 === void 0 ? void 0 : (_style$elements2$link = _style$elements2.link) === null || _style$elements2$link === void 0 ? void 0 : (_style$elements2$link2 = _style$elements2$link.color) === null || _style$elements2$link2 === void 0 ? void 0 : _style$elements2$link2.text),
  30394. clearable: !!(style !== null && style !== void 0 && (_style$elements3 = style.elements) !== null && _style$elements3 !== void 0 && (_style$elements3$link = _style$elements3.link) !== null && _style$elements3$link !== void 0 && (_style$elements3$link2 = _style$elements3$link.color) !== null && _style$elements3$link2 !== void 0 && _style$elements3$link2.text),
  30395. isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.link,
  30396. resetAllFilter: resetAllLinkFilter
  30397. }] : [])]
  30398. });
  30399. }
  30400. /**
  30401. * This adds inline styles for color palette colors.
  30402. * Ideally, this is not needed and themes should load their palettes on the editor.
  30403. *
  30404. * @param {Function} BlockListBlock Original component.
  30405. *
  30406. * @return {Function} Wrapped component.
  30407. */
  30408. const withColorPaletteStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  30409. var _props$wrapperProps;
  30410. const {
  30411. name,
  30412. attributes
  30413. } = props;
  30414. const {
  30415. backgroundColor,
  30416. textColor
  30417. } = attributes;
  30418. const userPalette = useSetting('color.palette.custom') || [];
  30419. const themePalette = useSetting('color.palette.theme') || [];
  30420. const defaultPalette = useSetting('color.palette.default') || [];
  30421. const colors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
  30422. if (!hasColorSupport(name) || shouldSkipSerialization(name, COLOR_SUPPORT_KEY)) {
  30423. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
  30424. }
  30425. const extraStyles = {};
  30426. if (textColor && !shouldSkipSerialization(name, COLOR_SUPPORT_KEY, 'text')) {
  30427. var _getColorObjectByAttr;
  30428. extraStyles.color = (_getColorObjectByAttr = getColorObjectByAttributeValues(colors, textColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
  30429. }
  30430. if (backgroundColor && !shouldSkipSerialization(name, COLOR_SUPPORT_KEY, 'background')) {
  30431. var _getColorObjectByAttr2;
  30432. extraStyles.backgroundColor = (_getColorObjectByAttr2 = getColorObjectByAttributeValues(colors, backgroundColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color;
  30433. }
  30434. let wrapperProps = props.wrapperProps;
  30435. wrapperProps = { ...props.wrapperProps,
  30436. style: { ...extraStyles,
  30437. ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style)
  30438. }
  30439. };
  30440. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  30441. wrapperProps: wrapperProps
  30442. }));
  30443. });
  30444. const MIGRATION_PATHS = {
  30445. linkColor: [['style', 'elements', 'link', 'color', 'text']],
  30446. textColor: [['textColor'], ['style', 'color', 'text']],
  30447. backgroundColor: [['backgroundColor'], ['style', 'color', 'background']],
  30448. gradient: [['gradient'], ['style', 'color', 'gradient']]
  30449. };
  30450. function color_addTransforms(result, source, index, results) {
  30451. const destinationBlockType = result.name;
  30452. const activeSupports = {
  30453. linkColor: hasLinkColorSupport(destinationBlockType),
  30454. textColor: hasTextColorSupport(destinationBlockType),
  30455. backgroundColor: hasBackgroundColorSupport(destinationBlockType),
  30456. gradient: hasGradientSupport(destinationBlockType)
  30457. };
  30458. return transformStyles(activeSupports, MIGRATION_PATHS, result, source, index, results);
  30459. }
  30460. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/color/addAttribute', color_addAttributes);
  30461. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/color/addSaveProps', color_addSaveProps);
  30462. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/color/addEditProps', color_addEditProps);
  30463. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/color/with-color-palette-styles', withColorPaletteStyles);
  30464. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.switchToBlockType.transformedBlock', 'core/color/addTransforms', color_addTransforms);
  30465. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-appearance-control/index.js
  30466. /**
  30467. * WordPress dependencies
  30468. */
  30469. const FONT_STYLES = [{
  30470. name: (0,external_wp_i18n_namespaceObject._x)('Regular', 'font style'),
  30471. value: 'normal'
  30472. }, {
  30473. name: (0,external_wp_i18n_namespaceObject._x)('Italic', 'font style'),
  30474. value: 'italic'
  30475. }];
  30476. const FONT_WEIGHTS = [{
  30477. name: (0,external_wp_i18n_namespaceObject._x)('Thin', 'font weight'),
  30478. value: '100'
  30479. }, {
  30480. name: (0,external_wp_i18n_namespaceObject._x)('Extra Light', 'font weight'),
  30481. value: '200'
  30482. }, {
  30483. name: (0,external_wp_i18n_namespaceObject._x)('Light', 'font weight'),
  30484. value: '300'
  30485. }, {
  30486. name: (0,external_wp_i18n_namespaceObject._x)('Regular', 'font weight'),
  30487. value: '400'
  30488. }, {
  30489. name: (0,external_wp_i18n_namespaceObject._x)('Medium', 'font weight'),
  30490. value: '500'
  30491. }, {
  30492. name: (0,external_wp_i18n_namespaceObject._x)('Semi Bold', 'font weight'),
  30493. value: '600'
  30494. }, {
  30495. name: (0,external_wp_i18n_namespaceObject._x)('Bold', 'font weight'),
  30496. value: '700'
  30497. }, {
  30498. name: (0,external_wp_i18n_namespaceObject._x)('Extra Bold', 'font weight'),
  30499. value: '800'
  30500. }, {
  30501. name: (0,external_wp_i18n_namespaceObject._x)('Black', 'font weight'),
  30502. value: '900'
  30503. }];
  30504. /**
  30505. * Adjusts font appearance field label in case either font styles or weights
  30506. * are disabled.
  30507. *
  30508. * @param {boolean} hasFontStyles Whether font styles are enabled and present.
  30509. * @param {boolean} hasFontWeights Whether font weights are enabled and present.
  30510. * @return {string} A label representing what font appearance is being edited.
  30511. */
  30512. const getFontAppearanceLabel = (hasFontStyles, hasFontWeights) => {
  30513. if (!hasFontStyles) {
  30514. return (0,external_wp_i18n_namespaceObject.__)('Font weight');
  30515. }
  30516. if (!hasFontWeights) {
  30517. return (0,external_wp_i18n_namespaceObject.__)('Font style');
  30518. }
  30519. return (0,external_wp_i18n_namespaceObject.__)('Appearance');
  30520. };
  30521. /**
  30522. * Control to display unified font style and weight options.
  30523. *
  30524. * @param {Object} props Component props.
  30525. *
  30526. * @return {WPElement} Font appearance control.
  30527. */
  30528. function FontAppearanceControl(props) {
  30529. const {
  30530. onChange,
  30531. hasFontStyles = true,
  30532. hasFontWeights = true,
  30533. value: {
  30534. fontStyle,
  30535. fontWeight
  30536. },
  30537. ...otherProps
  30538. } = props;
  30539. const hasStylesOrWeights = hasFontStyles || hasFontWeights;
  30540. const label = getFontAppearanceLabel(hasFontStyles, hasFontWeights);
  30541. const defaultOption = {
  30542. key: 'default',
  30543. name: (0,external_wp_i18n_namespaceObject.__)('Default'),
  30544. style: {
  30545. fontStyle: undefined,
  30546. fontWeight: undefined
  30547. }
  30548. }; // Combines both font style and weight options into a single dropdown.
  30549. const combineOptions = () => {
  30550. const combinedOptions = [defaultOption];
  30551. FONT_STYLES.forEach(_ref => {
  30552. let {
  30553. name: styleName,
  30554. value: styleValue
  30555. } = _ref;
  30556. FONT_WEIGHTS.forEach(_ref2 => {
  30557. let {
  30558. name: weightName,
  30559. value: weightValue
  30560. } = _ref2;
  30561. const optionName = styleValue === 'normal' ? weightName : (0,external_wp_i18n_namespaceObject.sprintf)(
  30562. /* translators: 1: Font weight name. 2: Font style name. */
  30563. (0,external_wp_i18n_namespaceObject.__)('%1$s %2$s'), weightName, styleName);
  30564. combinedOptions.push({
  30565. key: `${styleValue}-${weightValue}`,
  30566. name: optionName,
  30567. style: {
  30568. fontStyle: styleValue,
  30569. fontWeight: weightValue
  30570. }
  30571. });
  30572. });
  30573. });
  30574. return combinedOptions;
  30575. }; // Generates select options for font styles only.
  30576. const styleOptions = () => {
  30577. const combinedOptions = [defaultOption];
  30578. FONT_STYLES.forEach(_ref3 => {
  30579. let {
  30580. name,
  30581. value
  30582. } = _ref3;
  30583. combinedOptions.push({
  30584. key: value,
  30585. name,
  30586. style: {
  30587. fontStyle: value,
  30588. fontWeight: undefined
  30589. }
  30590. });
  30591. });
  30592. return combinedOptions;
  30593. }; // Generates select options for font weights only.
  30594. const weightOptions = () => {
  30595. const combinedOptions = [defaultOption];
  30596. FONT_WEIGHTS.forEach(_ref4 => {
  30597. let {
  30598. name,
  30599. value
  30600. } = _ref4;
  30601. combinedOptions.push({
  30602. key: value,
  30603. name,
  30604. style: {
  30605. fontStyle: undefined,
  30606. fontWeight: value
  30607. }
  30608. });
  30609. });
  30610. return combinedOptions;
  30611. }; // Map font styles and weights to select options.
  30612. const selectOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
  30613. if (hasFontStyles && hasFontWeights) {
  30614. return combineOptions();
  30615. }
  30616. return hasFontStyles ? styleOptions() : weightOptions();
  30617. }, [props.options]); // Find current selection by comparing font style & weight against options,
  30618. // and fall back to the Default option if there is no matching option.
  30619. const currentSelection = selectOptions.find(option => option.style.fontStyle === fontStyle && option.style.fontWeight === fontWeight) || selectOptions[0]; // Adjusts screen reader description based on styles or weights.
  30620. const getDescribedBy = () => {
  30621. if (!currentSelection) {
  30622. return (0,external_wp_i18n_namespaceObject.__)('No selected font appearance');
  30623. }
  30624. if (!hasFontStyles) {
  30625. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Currently selected font weight.
  30626. (0,external_wp_i18n_namespaceObject.__)('Currently selected font weight: %s'), currentSelection.name);
  30627. }
  30628. if (!hasFontWeights) {
  30629. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Currently selected font style.
  30630. (0,external_wp_i18n_namespaceObject.__)('Currently selected font style: %s'), currentSelection.name);
  30631. }
  30632. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Currently selected font appearance.
  30633. (0,external_wp_i18n_namespaceObject.__)('Currently selected font appearance: %s'), currentSelection.name);
  30634. };
  30635. return hasStylesOrWeights && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CustomSelectControl, _extends({}, otherProps, {
  30636. className: "components-font-appearance-control",
  30637. label: label,
  30638. describedBy: getDescribedBy(),
  30639. options: selectOptions,
  30640. value: currentSelection,
  30641. onChange: _ref5 => {
  30642. let {
  30643. selectedItem
  30644. } = _ref5;
  30645. return onChange(selectedItem.style);
  30646. },
  30647. __nextUnconstrainedWidth: true
  30648. }));
  30649. }
  30650. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/line-height-control/utils.js
  30651. const BASE_DEFAULT_VALUE = 1.5;
  30652. const STEP = 0.1;
  30653. /**
  30654. * There are varying value types within LineHeightControl:
  30655. *
  30656. * {undefined} Initial value. No changes from the user.
  30657. * {string} Input value. Value consumed/outputted by the input. Empty would be ''.
  30658. * {number} Block attribute type. Input value needs to be converted for attribute setting.
  30659. *
  30660. * Note: If the value is undefined, the input requires it to be an empty string ('')
  30661. * in order to be considered "controlled" by props (rather than internal state).
  30662. */
  30663. const RESET_VALUE = '';
  30664. /**
  30665. * Determines if the lineHeight attribute has been properly defined.
  30666. *
  30667. * @param {any} lineHeight The value to check.
  30668. *
  30669. * @return {boolean} Whether the lineHeight attribute is valid.
  30670. */
  30671. function isLineHeightDefined(lineHeight) {
  30672. return lineHeight !== undefined && lineHeight !== RESET_VALUE;
  30673. }
  30674. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/line-height-control/index.js
  30675. /**
  30676. * WordPress dependencies
  30677. */
  30678. /**
  30679. * Internal dependencies
  30680. */
  30681. const LineHeightControl = _ref => {
  30682. let {
  30683. value: lineHeight,
  30684. onChange,
  30685. /** Start opting into the new margin-free styles that will become the default in a future version. */
  30686. __nextHasNoMarginBottom = false,
  30687. __unstableInputWidth = '60px',
  30688. ...otherProps
  30689. } = _ref;
  30690. const isDefined = isLineHeightDefined(lineHeight);
  30691. const adjustNextValue = (nextValue, wasTypedOrPasted) => {
  30692. // Set the next value without modification if lineHeight has been defined.
  30693. if (isDefined) return nextValue;
  30694. /**
  30695. * The following logic handles the initial step up/down action
  30696. * (from an undefined value state) so that the next values are better suited for
  30697. * line-height rendering. For example, the first step up should immediately
  30698. * go to 1.6, rather than the normally expected 0.1.
  30699. *
  30700. * Step up/down actions can be triggered by keydowns of the up/down arrow keys,
  30701. * or by clicking the spin buttons.
  30702. */
  30703. switch (`${nextValue}`) {
  30704. case `${STEP}`:
  30705. // Increment by step value.
  30706. return BASE_DEFAULT_VALUE + STEP;
  30707. case '0':
  30708. {
  30709. // This means the user explicitly input '0', rather than stepped down
  30710. // from an undefined value state.
  30711. if (wasTypedOrPasted) return nextValue; // Decrement by step value.
  30712. return BASE_DEFAULT_VALUE - STEP;
  30713. }
  30714. case '':
  30715. return BASE_DEFAULT_VALUE;
  30716. default:
  30717. return nextValue;
  30718. }
  30719. };
  30720. const stateReducer = (state, action) => {
  30721. var _action$payload$event;
  30722. // Be careful when changing this — cross-browser behavior of the
  30723. // `inputType` field in `input` events are inconsistent.
  30724. // For example, Firefox emits an input event with inputType="insertReplacementText"
  30725. // on spin button clicks, while other browsers do not even emit an input event.
  30726. const wasTypedOrPasted = ['insertText', 'insertFromPaste'].includes((_action$payload$event = action.payload.event.nativeEvent) === null || _action$payload$event === void 0 ? void 0 : _action$payload$event.inputType);
  30727. const value = adjustNextValue(state.value, wasTypedOrPasted);
  30728. return { ...state,
  30729. value
  30730. };
  30731. };
  30732. const value = isDefined ? lineHeight : RESET_VALUE;
  30733. if (!__nextHasNoMarginBottom) {
  30734. external_wp_deprecated_default()('Bottom margin styles for wp.blockEditor.LineHeightControl', {
  30735. since: '6.0',
  30736. version: '6.4',
  30737. hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version'
  30738. });
  30739. }
  30740. const deprecatedStyles = __nextHasNoMarginBottom ? undefined : {
  30741. marginBottom: 24
  30742. };
  30743. return (0,external_wp_element_namespaceObject.createElement)("div", {
  30744. className: "block-editor-line-height-control",
  30745. style: deprecatedStyles
  30746. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNumberControl, _extends({}, otherProps, {
  30747. __unstableInputWidth: __unstableInputWidth,
  30748. __unstableStateReducer: stateReducer,
  30749. onChange: onChange,
  30750. label: (0,external_wp_i18n_namespaceObject.__)('Line height'),
  30751. placeholder: BASE_DEFAULT_VALUE,
  30752. step: STEP,
  30753. value: value,
  30754. min: 0
  30755. })));
  30756. };
  30757. /**
  30758. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/line-height-control/README.md
  30759. */
  30760. /* harmony default export */ var line_height_control = (LineHeightControl);
  30761. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/line-height.js
  30762. /**
  30763. * WordPress dependencies
  30764. */
  30765. /**
  30766. * Internal dependencies
  30767. */
  30768. const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';
  30769. /**
  30770. * Inspector control panel containing the line height related configuration
  30771. *
  30772. * @param {Object} props
  30773. *
  30774. * @return {WPElement} Line height edit element.
  30775. */
  30776. function LineHeightEdit(props) {
  30777. var _style$typography;
  30778. const {
  30779. attributes: {
  30780. style
  30781. },
  30782. setAttributes
  30783. } = props;
  30784. const onChange = newLineHeightValue => {
  30785. const newStyle = { ...style,
  30786. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  30787. lineHeight: newLineHeightValue
  30788. }
  30789. };
  30790. setAttributes({
  30791. style: cleanEmptyObject(newStyle)
  30792. });
  30793. };
  30794. return (0,external_wp_element_namespaceObject.createElement)(line_height_control, {
  30795. __unstableInputWidth: "100%",
  30796. __nextHasNoMarginBottom: true,
  30797. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.lineHeight,
  30798. onChange: onChange,
  30799. size: "__unstable-large"
  30800. });
  30801. }
  30802. /**
  30803. * Custom hook that checks if line-height settings have been disabled.
  30804. *
  30805. * @param {string} name The name of the block.
  30806. * @return {boolean} Whether setting is disabled.
  30807. */
  30808. function useIsLineHeightDisabled() {
  30809. let {
  30810. name: blockName
  30811. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  30812. const isDisabled = !useSetting('typography.lineHeight');
  30813. return !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, LINE_HEIGHT_SUPPORT_KEY) || isDisabled;
  30814. }
  30815. /**
  30816. * Checks if there is a current value set for the line height block support.
  30817. *
  30818. * @param {Object} props Block props.
  30819. * @return {boolean} Whether or not the block has a line height value set.
  30820. */
  30821. function hasLineHeightValue(props) {
  30822. var _props$attributes$sty, _props$attributes$sty2;
  30823. return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.lineHeight);
  30824. }
  30825. /**
  30826. * Resets the line height block support attribute. This can be used when
  30827. * disabling the line height support controls for a block via a progressive
  30828. * discovery panel.
  30829. *
  30830. * @param {Object} props Block props.
  30831. * @param {Object} props.attributes Block's attributes.
  30832. * @param {Object} props.setAttributes Function to set block's attributes.
  30833. */
  30834. function resetLineHeight(_ref) {
  30835. let {
  30836. attributes = {},
  30837. setAttributes
  30838. } = _ref;
  30839. const {
  30840. style
  30841. } = attributes;
  30842. setAttributes({
  30843. style: cleanEmptyObject({ ...style,
  30844. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  30845. lineHeight: undefined
  30846. }
  30847. })
  30848. });
  30849. }
  30850. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-appearance.js
  30851. /**
  30852. * WordPress dependencies
  30853. */
  30854. /**
  30855. * Internal dependencies
  30856. */
  30857. /**
  30858. * Key within block settings' support array indicating support for font style.
  30859. */
  30860. const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
  30861. /**
  30862. * Key within block settings' support array indicating support for font weight.
  30863. */
  30864. const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
  30865. /**
  30866. * Inspector control panel containing the font appearance options.
  30867. *
  30868. * @param {Object} props Block properties.
  30869. *
  30870. * @return {WPElement} Font appearance edit element.
  30871. */
  30872. function FontAppearanceEdit(props) {
  30873. var _style$typography, _style$typography2;
  30874. const {
  30875. attributes: {
  30876. style
  30877. },
  30878. setAttributes
  30879. } = props;
  30880. const hasFontStyles = !useIsFontStyleDisabled(props);
  30881. const hasFontWeights = !useIsFontWeightDisabled(props);
  30882. const onChange = newStyles => {
  30883. setAttributes({
  30884. style: cleanEmptyObject({ ...style,
  30885. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  30886. fontStyle: newStyles.fontStyle,
  30887. fontWeight: newStyles.fontWeight
  30888. }
  30889. })
  30890. });
  30891. };
  30892. const fontStyle = style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontStyle;
  30893. const fontWeight = style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontWeight;
  30894. return (0,external_wp_element_namespaceObject.createElement)(FontAppearanceControl, {
  30895. onChange: onChange,
  30896. hasFontStyles: hasFontStyles,
  30897. hasFontWeights: hasFontWeights,
  30898. value: {
  30899. fontStyle,
  30900. fontWeight
  30901. },
  30902. size: "__unstable-large"
  30903. });
  30904. }
  30905. /**
  30906. * Checks if font style support has been disabled either by not opting in for
  30907. * support or by failing to provide preset styles.
  30908. *
  30909. * @param {Object} props Block properties.
  30910. * @param {string} props.name Name for the block type.
  30911. *
  30912. * @return {boolean} Whether font style support has been disabled.
  30913. */
  30914. function useIsFontStyleDisabled() {
  30915. let {
  30916. name: blockName
  30917. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  30918. const styleSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_STYLE_SUPPORT_KEY);
  30919. const hasFontStyles = useSetting('typography.fontStyle');
  30920. return !styleSupport || !hasFontStyles;
  30921. }
  30922. /**
  30923. * Checks if font weight support has been disabled either by not opting in for
  30924. * support or by failing to provide preset weights.
  30925. *
  30926. * @param {Object} props Block properties.
  30927. * @param {string} props.name Name for the block type.
  30928. *
  30929. * @return {boolean} Whether font weight support has been disabled.
  30930. */
  30931. function useIsFontWeightDisabled() {
  30932. let {
  30933. name: blockName
  30934. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  30935. const weightSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_WEIGHT_SUPPORT_KEY);
  30936. const hasFontWeights = useSetting('typography.fontWeight');
  30937. return !weightSupport || !hasFontWeights;
  30938. }
  30939. /**
  30940. * Checks if font appearance support has been disabled.
  30941. *
  30942. * @param {Object} props Block properties.
  30943. *
  30944. * @return {boolean} Whether font appearance support has been disabled.
  30945. */
  30946. function useIsFontAppearanceDisabled(props) {
  30947. const stylesDisabled = useIsFontStyleDisabled(props);
  30948. const weightsDisabled = useIsFontWeightDisabled(props);
  30949. return stylesDisabled && weightsDisabled;
  30950. }
  30951. /**
  30952. * Checks if there is either a font style or weight value set within the
  30953. * typography styles.
  30954. *
  30955. * @param {Object} props Block props.
  30956. * @return {boolean} Whether or not the block has a font style or weight.
  30957. */
  30958. function hasFontAppearanceValue(props) {
  30959. var _props$attributes$sty;
  30960. const {
  30961. fontStyle,
  30962. fontWeight
  30963. } = ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.typography) || {};
  30964. return !!fontStyle || !!fontWeight;
  30965. }
  30966. /**
  30967. * Resets the font style and weight block support attributes. This can be used
  30968. * when disabling the font appearance support controls for a block via a
  30969. * progressive discovery panel.
  30970. *
  30971. * @param {Object} props Block props.
  30972. * @param {Object} props.attributes Block's attributes.
  30973. * @param {Object} props.setAttributes Function to set block's attributes.
  30974. */
  30975. function resetFontAppearance(_ref) {
  30976. let {
  30977. attributes = {},
  30978. setAttributes
  30979. } = _ref;
  30980. const {
  30981. style
  30982. } = attributes;
  30983. setAttributes({
  30984. style: cleanEmptyObject({ ...style,
  30985. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  30986. fontStyle: undefined,
  30987. fontWeight: undefined
  30988. }
  30989. })
  30990. });
  30991. }
  30992. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-family/index.js
  30993. /**
  30994. * External dependencies
  30995. */
  30996. /**
  30997. * WordPress dependencies
  30998. */
  30999. /**
  31000. * Internal dependencies
  31001. */
  31002. function FontFamilyControl(_ref) {
  31003. let {
  31004. value = '',
  31005. onChange,
  31006. fontFamilies,
  31007. ...props
  31008. } = _ref;
  31009. const blockLevelFontFamilies = useSetting('typography.fontFamilies');
  31010. if (!fontFamilies) {
  31011. fontFamilies = blockLevelFontFamilies;
  31012. }
  31013. if ((0,external_lodash_namespaceObject.isEmpty)(fontFamilies)) {
  31014. return null;
  31015. }
  31016. const options = [{
  31017. value: '',
  31018. label: (0,external_wp_i18n_namespaceObject.__)('Default')
  31019. }, ...fontFamilies.map(_ref2 => {
  31020. let {
  31021. fontFamily,
  31022. name
  31023. } = _ref2;
  31024. return {
  31025. value: fontFamily,
  31026. label: name || fontFamily
  31027. };
  31028. })];
  31029. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, _extends({
  31030. label: (0,external_wp_i18n_namespaceObject.__)('Font'),
  31031. options: options,
  31032. value: value,
  31033. onChange: onChange,
  31034. labelPosition: "top"
  31035. }, props));
  31036. }
  31037. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-family.js
  31038. /**
  31039. * External dependencies
  31040. */
  31041. /**
  31042. * WordPress dependencies
  31043. */
  31044. /**
  31045. * Internal dependencies
  31046. */
  31047. const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';
  31048. /**
  31049. * Filters registered block settings, extending attributes to include
  31050. * the `fontFamily` attribute.
  31051. *
  31052. * @param {Object} settings Original block settings
  31053. * @return {Object} Filtered block settings
  31054. */
  31055. function font_family_addAttributes(settings) {
  31056. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_FAMILY_SUPPORT_KEY)) {
  31057. return settings;
  31058. } // Allow blocks to specify a default value if needed.
  31059. if (!settings.attributes.fontFamily) {
  31060. Object.assign(settings.attributes, {
  31061. fontFamily: {
  31062. type: 'string'
  31063. }
  31064. });
  31065. }
  31066. return settings;
  31067. }
  31068. /**
  31069. * Override props assigned to save component to inject font family.
  31070. *
  31071. * @param {Object} props Additional props applied to save element
  31072. * @param {Object} blockType Block type
  31073. * @param {Object} attributes Block attributes
  31074. * @return {Object} Filtered props applied to save element
  31075. */
  31076. function font_family_addSaveProps(props, blockType, attributes) {
  31077. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, FONT_FAMILY_SUPPORT_KEY)) {
  31078. return props;
  31079. }
  31080. if (shouldSkipSerialization(blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontFamily')) {
  31081. return props;
  31082. }
  31083. if (!(attributes !== null && attributes !== void 0 && attributes.fontFamily)) {
  31084. return props;
  31085. } // Use TokenList to dedupe classes.
  31086. const classes = new (external_wp_tokenList_default())(props.className);
  31087. classes.add(`has-${(0,external_lodash_namespaceObject.kebabCase)(attributes === null || attributes === void 0 ? void 0 : attributes.fontFamily)}-font-family`);
  31088. const newClassName = classes.value;
  31089. props.className = newClassName ? newClassName : undefined;
  31090. return props;
  31091. }
  31092. /**
  31093. * Filters registered block settings to expand the block edit wrapper
  31094. * by applying the desired styles and classnames.
  31095. *
  31096. * @param {Object} settings Original block settings.
  31097. *
  31098. * @return {Object} Filtered block settings.
  31099. */
  31100. function font_family_addEditProps(settings) {
  31101. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_FAMILY_SUPPORT_KEY)) {
  31102. return settings;
  31103. }
  31104. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  31105. settings.getEditWrapperProps = attributes => {
  31106. let props = {};
  31107. if (existingGetEditWrapperProps) {
  31108. props = existingGetEditWrapperProps(attributes);
  31109. }
  31110. return font_family_addSaveProps(props, settings, attributes);
  31111. };
  31112. return settings;
  31113. }
  31114. function FontFamilyEdit(_ref) {
  31115. var _find;
  31116. let {
  31117. setAttributes,
  31118. attributes: {
  31119. fontFamily
  31120. }
  31121. } = _ref;
  31122. const fontFamilies = useSetting('typography.fontFamilies');
  31123. const value = (_find = (0,external_lodash_namespaceObject.find)(fontFamilies, _ref2 => {
  31124. let {
  31125. slug
  31126. } = _ref2;
  31127. return fontFamily === slug;
  31128. })) === null || _find === void 0 ? void 0 : _find.fontFamily;
  31129. function onChange(newValue) {
  31130. const predefinedFontFamily = (0,external_lodash_namespaceObject.find)(fontFamilies, _ref3 => {
  31131. let {
  31132. fontFamily: f
  31133. } = _ref3;
  31134. return f === newValue;
  31135. });
  31136. setAttributes({
  31137. fontFamily: predefinedFontFamily === null || predefinedFontFamily === void 0 ? void 0 : predefinedFontFamily.slug
  31138. });
  31139. }
  31140. return (0,external_wp_element_namespaceObject.createElement)(FontFamilyControl, {
  31141. className: "block-editor-hooks-font-family-control",
  31142. fontFamilies: fontFamilies,
  31143. value: value,
  31144. onChange: onChange,
  31145. size: "__unstable-large",
  31146. __nextHasNoMarginBottom: true
  31147. });
  31148. }
  31149. /**
  31150. * Custom hook that checks if font-family functionality is disabled.
  31151. *
  31152. * @param {string} name The name of the block.
  31153. * @return {boolean} Whether setting is disabled.
  31154. */
  31155. function useIsFontFamilyDisabled(_ref4) {
  31156. let {
  31157. name
  31158. } = _ref4;
  31159. const fontFamilies = useSetting('typography.fontFamilies');
  31160. return !fontFamilies || fontFamilies.length === 0 || !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, FONT_FAMILY_SUPPORT_KEY);
  31161. }
  31162. /**
  31163. * Checks if there is a current value set for the font family block support.
  31164. *
  31165. * @param {Object} props Block props.
  31166. * @return {boolean} Whether or not the block has a font family value set.
  31167. */
  31168. function hasFontFamilyValue(props) {
  31169. return !!props.attributes.fontFamily;
  31170. }
  31171. /**
  31172. * Resets the font family block support attribute. This can be used when
  31173. * disabling the font family support controls for a block via a progressive
  31174. * discovery panel.
  31175. *
  31176. * @param {Object} props Block props.
  31177. * @param {Object} props.setAttributes Function to set block's attributes.
  31178. */
  31179. function resetFontFamily(_ref5) {
  31180. let {
  31181. setAttributes
  31182. } = _ref5;
  31183. setAttributes({
  31184. fontFamily: undefined
  31185. });
  31186. }
  31187. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/fontFamily/addAttribute', font_family_addAttributes);
  31188. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/fontFamily/addSaveProps', font_family_addSaveProps);
  31189. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/fontFamily/addEditProps', font_family_addEditProps);
  31190. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/utils.js
  31191. /**
  31192. * External dependencies
  31193. */
  31194. /**
  31195. * Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values.
  31196. * If namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned.
  31197. *
  31198. * @param {Array} fontSizes Array of font size objects containing at least the "name" and "size" values as properties.
  31199. * @param {?string} fontSizeAttribute Content of the font size attribute (slug).
  31200. * @param {?number} customFontSizeAttribute Contents of the custom font size attribute (value).
  31201. *
  31202. * @return {?Object} If fontSizeAttribute is set and an equal slug is found in fontSizes it returns the font size object for that slug.
  31203. * Otherwise, an object with just the size value based on customFontSize is returned.
  31204. */
  31205. const getFontSize = (fontSizes, fontSizeAttribute, customFontSizeAttribute) => {
  31206. if (fontSizeAttribute) {
  31207. const fontSizeObject = (0,external_lodash_namespaceObject.find)(fontSizes, {
  31208. slug: fontSizeAttribute
  31209. });
  31210. if (fontSizeObject) {
  31211. return fontSizeObject;
  31212. }
  31213. }
  31214. return {
  31215. size: customFontSizeAttribute
  31216. };
  31217. };
  31218. /**
  31219. * Returns the corresponding font size object for a given value.
  31220. *
  31221. * @param {Array} fontSizes Array of font size objects.
  31222. * @param {number} value Font size value.
  31223. *
  31224. * @return {Object} Font size object.
  31225. */
  31226. function getFontSizeObjectByValue(fontSizes, value) {
  31227. const fontSizeObject = (0,external_lodash_namespaceObject.find)(fontSizes, {
  31228. size: value
  31229. });
  31230. if (fontSizeObject) {
  31231. return fontSizeObject;
  31232. }
  31233. return {
  31234. size: value
  31235. };
  31236. }
  31237. /**
  31238. * Returns a class based on fontSizeName.
  31239. *
  31240. * @param {string} fontSizeSlug Slug of the fontSize.
  31241. *
  31242. * @return {string} String with the class corresponding to the fontSize passed.
  31243. * The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'.
  31244. */
  31245. function getFontSizeClass(fontSizeSlug) {
  31246. if (!fontSizeSlug) {
  31247. return;
  31248. }
  31249. return `has-${(0,external_lodash_namespaceObject.kebabCase)(fontSizeSlug)}-font-size`;
  31250. }
  31251. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/font-size-picker.js
  31252. /**
  31253. * WordPress dependencies
  31254. */
  31255. /**
  31256. * Internal dependencies
  31257. */
  31258. function FontSizePicker(props) {
  31259. const fontSizes = useSetting('typography.fontSizes');
  31260. const disableCustomFontSizes = !useSetting('typography.customFontSize');
  31261. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FontSizePicker, _extends({}, props, {
  31262. fontSizes: fontSizes,
  31263. disableCustomFontSizes: disableCustomFontSizes
  31264. }));
  31265. }
  31266. /**
  31267. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/font-sizes/README.md
  31268. */
  31269. /* harmony default export */ var font_size_picker = (FontSizePicker);
  31270. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/fluid-utils.js
  31271. /**
  31272. * The fluid utilities must match the backend equivalent.
  31273. * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php
  31274. * ---------------------------------------------------------------
  31275. */
  31276. // Defaults.
  31277. const DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';
  31278. const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';
  31279. const DEFAULT_SCALE_FACTOR = 1;
  31280. const DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;
  31281. const DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';
  31282. /**
  31283. * Computes a fluid font-size value that uses clamp(). A minimum and maxinmum
  31284. * font size OR a single font size can be specified.
  31285. *
  31286. * If a single font size is specified, it is scaled up and down by
  31287. * minimumFontSizeFactor and maximumFontSizeFactor to arrive at the minimum and
  31288. * maximum sizes.
  31289. *
  31290. * @example
  31291. * ```js
  31292. * // Calculate fluid font-size value from a minimum and maximum value.
  31293. * const fontSize = getComputedFluidTypographyValue( {
  31294. * minimumFontSize: '20px',
  31295. * maximumFontSize: '45px'
  31296. * } );
  31297. * // Calculate fluid font-size value from a single font size.
  31298. * const fontSize = getComputedFluidTypographyValue( {
  31299. * fontSize: '30px',
  31300. * } );
  31301. * ```
  31302. *
  31303. * @param {Object} args
  31304. * @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.
  31305. * @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.
  31306. * @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.
  31307. * @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.
  31308. * @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.
  31309. * @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.
  31310. * @param {?number} args.minimumFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.
  31311. *
  31312. * @return {string|null} A font-size value using clamp().
  31313. */
  31314. function getComputedFluidTypographyValue(_ref) {
  31315. let {
  31316. minimumFontSize,
  31317. maximumFontSize,
  31318. fontSize,
  31319. minimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
  31320. maximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
  31321. scaleFactor = DEFAULT_SCALE_FACTOR,
  31322. minimumFontSizeFactor = DEFAULT_MINIMUM_FONT_SIZE_FACTOR,
  31323. minimumFontSizeLimit = DEFAULT_MINIMUM_FONT_SIZE_LIMIT
  31324. } = _ref;
  31325. /*
  31326. * Calculates missing minimumFontSize and maximumFontSize from
  31327. * defaultFontSize if provided.
  31328. */
  31329. if (fontSize) {
  31330. // Parses default font size.
  31331. const fontSizeParsed = getTypographyValueAndUnit(fontSize); // Protect against invalid units.
  31332. if (!(fontSizeParsed !== null && fontSizeParsed !== void 0 && fontSizeParsed.unit)) {
  31333. return null;
  31334. } // Parses the minimum font size limit, so we can perform checks using it.
  31335. const minimumFontSizeLimitParsed = getTypographyValueAndUnit(minimumFontSizeLimit, {
  31336. coerceTo: fontSizeParsed.unit
  31337. }); // Don't enforce minimum font size if a font size has explicitly set a min and max value.
  31338. if (!!(minimumFontSizeLimitParsed !== null && minimumFontSizeLimitParsed !== void 0 && minimumFontSizeLimitParsed.value) && !minimumFontSize && !maximumFontSize) {
  31339. /*
  31340. * If a minimum size was not passed to this function
  31341. * and the user-defined font size is lower than $minimum_font_size_limit,
  31342. * do not calculate a fluid value.
  31343. */
  31344. if ((fontSizeParsed === null || fontSizeParsed === void 0 ? void 0 : fontSizeParsed.value) <= (minimumFontSizeLimitParsed === null || minimumFontSizeLimitParsed === void 0 ? void 0 : minimumFontSizeLimitParsed.value)) {
  31345. return null;
  31346. }
  31347. } // If no fluid max font size is available use the incoming value.
  31348. if (!maximumFontSize) {
  31349. maximumFontSize = `${fontSizeParsed.value}${fontSizeParsed.unit}`;
  31350. }
  31351. /*
  31352. * If no minimumFontSize is provided, create one using
  31353. * the given font size multiplied by the min font size scale factor.
  31354. */
  31355. if (!minimumFontSize) {
  31356. const calculatedMinimumFontSize = roundToPrecision(fontSizeParsed.value * minimumFontSizeFactor, 3); // Only use calculated min font size if it's > $minimum_font_size_limit value.
  31357. if (!!(minimumFontSizeLimitParsed !== null && minimumFontSizeLimitParsed !== void 0 && minimumFontSizeLimitParsed.value) && calculatedMinimumFontSize < (minimumFontSizeLimitParsed === null || minimumFontSizeLimitParsed === void 0 ? void 0 : minimumFontSizeLimitParsed.value)) {
  31358. minimumFontSize = `${minimumFontSizeLimitParsed.value}${minimumFontSizeLimitParsed.unit}`;
  31359. } else {
  31360. minimumFontSize = `${calculatedMinimumFontSize}${fontSizeParsed.unit}`;
  31361. }
  31362. }
  31363. } // Grab the minimum font size and normalize it in order to use the value for calculations.
  31364. const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize); // We get a 'preferred' unit to keep units consistent when calculating,
  31365. // otherwise the result will not be accurate.
  31366. const fontSizeUnit = (minimumFontSizeParsed === null || minimumFontSizeParsed === void 0 ? void 0 : minimumFontSizeParsed.unit) || 'rem'; // Grabs the maximum font size and normalize it in order to use the value for calculations.
  31367. const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, {
  31368. coerceTo: fontSizeUnit
  31369. }); // Checks for mandatory min and max sizes, and protects against unsupported units.
  31370. if (!minimumFontSizeParsed || !maximumFontSizeParsed) {
  31371. return null;
  31372. } // Uses rem for accessible fluid target font scaling.
  31373. const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, {
  31374. coerceTo: 'rem'
  31375. }); // Viewport widths defined for fluid typography. Normalize units
  31376. const maximumViewPortWidthParsed = getTypographyValueAndUnit(maximumViewPortWidth, {
  31377. coerceTo: fontSizeUnit
  31378. });
  31379. const minumumViewPortWidthParsed = getTypographyValueAndUnit(minimumViewPortWidth, {
  31380. coerceTo: fontSizeUnit
  31381. }); // Protect against unsupported units.
  31382. if (!maximumViewPortWidthParsed || !minumumViewPortWidthParsed || !minimumFontSizeRem) {
  31383. return null;
  31384. } // Build CSS rule.
  31385. // Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.
  31386. const minViewPortWidthOffsetValue = roundToPrecision(minumumViewPortWidthParsed.value / 100, 3);
  31387. const viewPortWidthOffset = roundToPrecision(minViewPortWidthOffsetValue, 3) + fontSizeUnit;
  31388. const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / (maximumViewPortWidthParsed.value - minumumViewPortWidthParsed.value));
  31389. const linearFactorScaled = roundToPrecision((linearFactor || 1) * scaleFactor, 3);
  31390. const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewPortWidthOffset}) * ${linearFactorScaled})`;
  31391. return `clamp(${minimumFontSize}, ${fluidTargetFontSize}, ${maximumFontSize})`;
  31392. }
  31393. /**
  31394. * Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].
  31395. * A raw font size of `value + unit` is expected. If the value is an integer, it will convert to `value + 'px'`.
  31396. *
  31397. * @param {string|number} rawValue Raw size value from theme.json.
  31398. * @param {Object|undefined} options Calculation options.
  31399. *
  31400. * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.
  31401. */
  31402. function getTypographyValueAndUnit(rawValue) {
  31403. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  31404. if (typeof rawValue !== 'string' && typeof rawValue !== 'number') {
  31405. return null;
  31406. } // Converts numeric values to pixel values by default.
  31407. if (isFinite(rawValue)) {
  31408. rawValue = `${rawValue}px`;
  31409. }
  31410. const {
  31411. coerceTo,
  31412. rootSizeValue,
  31413. acceptableUnits
  31414. } = {
  31415. coerceTo: '',
  31416. // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`.
  31417. rootSizeValue: 16,
  31418. acceptableUnits: ['rem', 'px', 'em'],
  31419. ...options
  31420. };
  31421. const acceptableUnitsGroup = acceptableUnits === null || acceptableUnits === void 0 ? void 0 : acceptableUnits.join('|');
  31422. const regexUnits = new RegExp(`^(\\d*\\.?\\d+)(${acceptableUnitsGroup}){1,1}$`);
  31423. const matches = rawValue.match(regexUnits); // We need a number value and a unit.
  31424. if (!matches || matches.length < 3) {
  31425. return null;
  31426. }
  31427. let [, value, unit] = matches;
  31428. let returnValue = parseFloat(value);
  31429. if ('px' === coerceTo && ('em' === unit || 'rem' === unit)) {
  31430. returnValue = returnValue * rootSizeValue;
  31431. unit = coerceTo;
  31432. }
  31433. if ('px' === unit && ('em' === coerceTo || 'rem' === coerceTo)) {
  31434. returnValue = returnValue / rootSizeValue;
  31435. unit = coerceTo;
  31436. }
  31437. /*
  31438. * No calculation is required if swapping between em and rem yet,
  31439. * since we assume a root size value. Later we might like to differentiate between
  31440. * :root font size (rem) and parent element font size (em) relativity.
  31441. */
  31442. if (('em' === coerceTo || 'rem' === coerceTo) && ('em' === unit || 'rem' === unit)) {
  31443. unit = coerceTo;
  31444. }
  31445. return {
  31446. value: roundToPrecision(returnValue, 3),
  31447. unit
  31448. };
  31449. }
  31450. /**
  31451. * Returns a value rounded to defined precision.
  31452. * Returns `undefined` if the value is not a valid finite number.
  31453. *
  31454. * @param {number} value Raw value.
  31455. * @param {number} digits The number of digits to appear after the decimal point
  31456. *
  31457. * @return {number|undefined} Value rounded to standard precision.
  31458. */
  31459. function roundToPrecision(value) {
  31460. let digits = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
  31461. const base = Math.pow(10, digits);
  31462. return Number.isFinite(value) ? parseFloat(Math.round(value * base) / base) : undefined;
  31463. }
  31464. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-size.js
  31465. /**
  31466. * WordPress dependencies
  31467. */
  31468. /**
  31469. * Internal dependencies
  31470. */
  31471. const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
  31472. /**
  31473. * Filters registered block settings, extending attributes to include
  31474. * `fontSize` and `fontWeight` attributes.
  31475. *
  31476. * @param {Object} settings Original block settings.
  31477. *
  31478. * @return {Object} Filtered block settings.
  31479. */
  31480. function font_size_addAttributes(settings) {
  31481. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_SIZE_SUPPORT_KEY)) {
  31482. return settings;
  31483. } // Allow blocks to specify a default value if needed.
  31484. if (!settings.attributes.fontSize) {
  31485. Object.assign(settings.attributes, {
  31486. fontSize: {
  31487. type: 'string'
  31488. }
  31489. });
  31490. }
  31491. return settings;
  31492. }
  31493. /**
  31494. * Override props assigned to save component to inject font size.
  31495. *
  31496. * @param {Object} props Additional props applied to save element.
  31497. * @param {Object} blockType Block type.
  31498. * @param {Object} attributes Block attributes.
  31499. *
  31500. * @return {Object} Filtered props applied to save element.
  31501. */
  31502. function font_size_addSaveProps(props, blockType, attributes) {
  31503. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, FONT_SIZE_SUPPORT_KEY)) {
  31504. return props;
  31505. }
  31506. if (shouldSkipSerialization(blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontSize')) {
  31507. return props;
  31508. } // Use TokenList to dedupe classes.
  31509. const classes = new (external_wp_tokenList_default())(props.className);
  31510. classes.add(getFontSizeClass(attributes.fontSize));
  31511. const newClassName = classes.value;
  31512. props.className = newClassName ? newClassName : undefined;
  31513. return props;
  31514. }
  31515. /**
  31516. * Filters registered block settings to expand the block edit wrapper
  31517. * by applying the desired styles and classnames.
  31518. *
  31519. * @param {Object} settings Original block settings.
  31520. *
  31521. * @return {Object} Filtered block settings.
  31522. */
  31523. function font_size_addEditProps(settings) {
  31524. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_SIZE_SUPPORT_KEY)) {
  31525. return settings;
  31526. }
  31527. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  31528. settings.getEditWrapperProps = attributes => {
  31529. let props = {};
  31530. if (existingGetEditWrapperProps) {
  31531. props = existingGetEditWrapperProps(attributes);
  31532. }
  31533. return font_size_addSaveProps(props, settings, attributes);
  31534. };
  31535. return settings;
  31536. }
  31537. /**
  31538. * Inspector control panel containing the font size related configuration
  31539. *
  31540. * @param {Object} props
  31541. *
  31542. * @return {WPElement} Font size edit element.
  31543. */
  31544. function FontSizeEdit(props) {
  31545. var _style$typography, _style$typography2;
  31546. const {
  31547. attributes: {
  31548. fontSize,
  31549. style
  31550. },
  31551. setAttributes
  31552. } = props;
  31553. const fontSizes = useSetting('typography.fontSizes');
  31554. const onChange = value => {
  31555. const fontSizeSlug = getFontSizeObjectByValue(fontSizes, value).slug;
  31556. setAttributes({
  31557. style: cleanEmptyObject({ ...style,
  31558. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  31559. fontSize: fontSizeSlug ? undefined : value
  31560. }
  31561. }),
  31562. fontSize: fontSizeSlug
  31563. });
  31564. };
  31565. const fontSizeObject = getFontSize(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontSize);
  31566. const fontSizeValue = (fontSizeObject === null || fontSizeObject === void 0 ? void 0 : fontSizeObject.size) || (style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontSize) || fontSize;
  31567. return (0,external_wp_element_namespaceObject.createElement)(font_size_picker, {
  31568. onChange: onChange,
  31569. value: fontSizeValue,
  31570. withReset: false,
  31571. size: "__unstable-large",
  31572. __nextHasNoMarginBottom: true
  31573. });
  31574. }
  31575. /**
  31576. * Checks if there is a current value set for the font size block support.
  31577. *
  31578. * @param {Object} props Block props.
  31579. * @return {boolean} Whether or not the block has a font size value set.
  31580. */
  31581. function hasFontSizeValue(props) {
  31582. var _style$typography3;
  31583. const {
  31584. fontSize,
  31585. style
  31586. } = props.attributes;
  31587. return !!fontSize || !!(style !== null && style !== void 0 && (_style$typography3 = style.typography) !== null && _style$typography3 !== void 0 && _style$typography3.fontSize);
  31588. }
  31589. /**
  31590. * Resets the font size block support attribute. This can be used when
  31591. * disabling the font size support controls for a block via a progressive
  31592. * discovery panel.
  31593. *
  31594. * @param {Object} props Block props.
  31595. * @param {Object} props.attributes Block's attributes.
  31596. * @param {Object} props.setAttributes Function to set block's attributes.
  31597. */
  31598. function resetFontSize(_ref) {
  31599. let {
  31600. attributes = {},
  31601. setAttributes
  31602. } = _ref;
  31603. const {
  31604. style
  31605. } = attributes;
  31606. setAttributes({
  31607. fontSize: undefined,
  31608. style: cleanEmptyObject({ ...style,
  31609. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  31610. fontSize: undefined
  31611. }
  31612. })
  31613. });
  31614. }
  31615. /**
  31616. * Custom hook that checks if font-size settings have been disabled.
  31617. *
  31618. * @param {string} name The name of the block.
  31619. * @return {boolean} Whether setting is disabled.
  31620. */
  31621. function useIsFontSizeDisabled() {
  31622. let {
  31623. name: blockName
  31624. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  31625. const fontSizes = useSetting('typography.fontSizes');
  31626. const hasFontSizes = !!(fontSizes !== null && fontSizes !== void 0 && fontSizes.length);
  31627. return !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_SIZE_SUPPORT_KEY) || !hasFontSizes;
  31628. }
  31629. /**
  31630. * Add inline styles for font sizes.
  31631. * Ideally, this is not needed and themes load the font-size classes on the
  31632. * editor.
  31633. *
  31634. * @param {Function} BlockListBlock Original component.
  31635. *
  31636. * @return {Function} Wrapped component.
  31637. */
  31638. const withFontSizeInlineStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  31639. var _style$typography4, _style$typography5;
  31640. const fontSizes = useSetting('typography.fontSizes');
  31641. const {
  31642. name: blockName,
  31643. attributes: {
  31644. fontSize,
  31645. style
  31646. },
  31647. wrapperProps
  31648. } = props; // Only add inline styles if the block supports font sizes,
  31649. // doesn't skip serialization of font sizes,
  31650. // doesn't already have an inline font size,
  31651. // and does have a class to extract the font size from.
  31652. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_SIZE_SUPPORT_KEY) || shouldSkipSerialization(blockName, TYPOGRAPHY_SUPPORT_KEY, 'fontSize') || !fontSize || style !== null && style !== void 0 && (_style$typography4 = style.typography) !== null && _style$typography4 !== void 0 && _style$typography4.fontSize) {
  31653. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
  31654. }
  31655. const fontSizeValue = getFontSize(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography5 = style.typography) === null || _style$typography5 === void 0 ? void 0 : _style$typography5.fontSize).size;
  31656. const newProps = { ...props,
  31657. wrapperProps: { ...wrapperProps,
  31658. style: {
  31659. fontSize: fontSizeValue,
  31660. ...(wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.style)
  31661. }
  31662. }
  31663. };
  31664. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, newProps);
  31665. }, 'withFontSizeInlineStyles');
  31666. const font_size_MIGRATION_PATHS = {
  31667. fontSize: [['fontSize'], ['style', 'typography', 'fontSize']]
  31668. };
  31669. function font_size_addTransforms(result, source, index, results) {
  31670. const destinationBlockType = result.name;
  31671. const activeSupports = {
  31672. fontSize: (0,external_wp_blocks_namespaceObject.hasBlockSupport)(destinationBlockType, FONT_SIZE_SUPPORT_KEY)
  31673. };
  31674. return transformStyles(activeSupports, font_size_MIGRATION_PATHS, result, source, index, results);
  31675. }
  31676. /**
  31677. * Allow custom font sizes to appear fluid when fluid typography is enabled at
  31678. * the theme level.
  31679. *
  31680. * Adds a custom getEditWrapperProps() callback to all block types that support
  31681. * font sizes. Then, if fluid typography is enabled, this callback will swap any
  31682. * custom font size in style.fontSize with a fluid font size (i.e. one that uses
  31683. * clamp()).
  31684. *
  31685. * It's important that this hook runs after 'core/style/addEditProps' sets
  31686. * style.fontSize as otherwise fontSize will be overwritten.
  31687. *
  31688. * @param {Object} blockType Block settings object.
  31689. */
  31690. function addEditPropsForFluidCustomFontSizes(blockType) {
  31691. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, FONT_SIZE_SUPPORT_KEY) || shouldSkipSerialization(blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontSize')) {
  31692. return blockType;
  31693. }
  31694. const existingGetEditWrapperProps = blockType.getEditWrapperProps;
  31695. blockType.getEditWrapperProps = attributes => {
  31696. var _wrapperProps$style, _select$getSettings$_, _select$getSettings$_2;
  31697. const wrapperProps = existingGetEditWrapperProps ? existingGetEditWrapperProps(attributes) : {};
  31698. const fontSize = wrapperProps === null || wrapperProps === void 0 ? void 0 : (_wrapperProps$style = wrapperProps.style) === null || _wrapperProps$style === void 0 ? void 0 : _wrapperProps$style.fontSize; // TODO: This sucks! We should be using useSetting( 'typography.fluid' )
  31699. // or even useSelect( blockEditorStore ). We can't do either here
  31700. // because getEditWrapperProps is a plain JavaScript function called by
  31701. // BlockListBlock and not a React component rendered within
  31702. // BlockListContext.Provider. If we set fontSize using editor.
  31703. // BlockListBlock instead of using getEditWrapperProps then the value is
  31704. // clobbered when the core/style/addEditProps filter runs.
  31705. const isFluidTypographyEnabled = !!((_select$getSettings$_ = (0,external_wp_data_namespaceObject.select)(store).getSettings().__experimentalFeatures) !== null && _select$getSettings$_ !== void 0 && (_select$getSettings$_2 = _select$getSettings$_.typography) !== null && _select$getSettings$_2 !== void 0 && _select$getSettings$_2.fluid);
  31706. const newFontSize = fontSize && isFluidTypographyEnabled ? getComputedFluidTypographyValue({
  31707. fontSize
  31708. }) : null;
  31709. if (newFontSize === null) {
  31710. return wrapperProps;
  31711. }
  31712. return { ...wrapperProps,
  31713. style: { ...(wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.style),
  31714. fontSize: newFontSize
  31715. }
  31716. };
  31717. };
  31718. return blockType;
  31719. }
  31720. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/font/addAttribute', font_size_addAttributes);
  31721. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/font/addSaveProps', font_size_addSaveProps);
  31722. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/font/addEditProps', font_size_addEditProps);
  31723. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/font-size/with-font-size-inline-styles', withFontSizeInlineStyles);
  31724. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.switchToBlockType.transformedBlock', 'core/font-size/addTransforms', font_size_addTransforms);
  31725. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/font-size/addEditPropsForFluidCustomFontSizes', addEditPropsForFluidCustomFontSizes, // Run after 'core/style/addEditProps' so that the style object has already
  31726. // been translated into inline CSS.
  31727. 11);
  31728. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/reset.js
  31729. /**
  31730. * WordPress dependencies
  31731. */
  31732. const reset_reset = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31733. xmlns: "http://www.w3.org/2000/svg",
  31734. viewBox: "0 0 24 24"
  31735. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31736. d: "M7 11.5h10V13H7z"
  31737. }));
  31738. /* harmony default export */ var library_reset = (reset_reset);
  31739. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-underline.js
  31740. /**
  31741. * WordPress dependencies
  31742. */
  31743. const formatUnderline = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31744. xmlns: "http://www.w3.org/2000/svg",
  31745. viewBox: "0 0 24 24"
  31746. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31747. d: "M7 18v1h10v-1H7zm5-2c1.5 0 2.6-.4 3.4-1.2.8-.8 1.1-2 1.1-3.5V5H15v5.8c0 1.2-.2 2.1-.6 2.8-.4.7-1.2 1-2.4 1s-2-.3-2.4-1c-.4-.7-.6-1.6-.6-2.8V5H7.5v6.2c0 1.5.4 2.7 1.1 3.5.8.9 1.9 1.3 3.4 1.3z"
  31748. }));
  31749. /* harmony default export */ var format_underline = (formatUnderline);
  31750. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-strikethrough.js
  31751. /**
  31752. * WordPress dependencies
  31753. */
  31754. const formatStrikethrough = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31755. xmlns: "http://www.w3.org/2000/svg",
  31756. viewBox: "0 0 24 24"
  31757. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31758. d: "M9.1 9v-.5c0-.6.2-1.1.7-1.4.5-.3 1.2-.5 2-.5.7 0 1.4.1 2.1.3.7.2 1.4.5 2.1.9l.2-1.9c-.6-.3-1.2-.5-1.9-.7-.8-.1-1.6-.2-2.4-.2-1.5 0-2.7.3-3.6 1-.8.7-1.2 1.5-1.2 2.6V9h2zM20 12H4v1h8.3c.3.1.6.2.8.3.5.2.9.5 1.1.8.3.3.4.7.4 1.2 0 .7-.2 1.1-.8 1.5-.5.3-1.2.5-2.1.5-.8 0-1.6-.1-2.4-.3-.8-.2-1.5-.5-2.2-.8L7 18.1c.5.2 1.2.4 2 .6.8.2 1.6.3 2.4.3 1.7 0 3-.3 3.9-1 .9-.7 1.3-1.6 1.3-2.8 0-.9-.2-1.7-.7-2.2H20v-1z"
  31759. }));
  31760. /* harmony default export */ var format_strikethrough = (formatStrikethrough);
  31761. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-decoration-control/index.js
  31762. /**
  31763. * External dependencies
  31764. */
  31765. /**
  31766. * WordPress dependencies
  31767. */
  31768. const TEXT_DECORATIONS = [{
  31769. name: (0,external_wp_i18n_namespaceObject.__)('None'),
  31770. value: 'none',
  31771. icon: library_reset
  31772. }, {
  31773. name: (0,external_wp_i18n_namespaceObject.__)('Underline'),
  31774. value: 'underline',
  31775. icon: format_underline
  31776. }, {
  31777. name: (0,external_wp_i18n_namespaceObject.__)('Strikethrough'),
  31778. value: 'line-through',
  31779. icon: format_strikethrough
  31780. }];
  31781. /**
  31782. * Control to facilitate text decoration selections.
  31783. *
  31784. * @param {Object} props Component props.
  31785. * @param {string} props.value Currently selected text decoration.
  31786. * @param {Function} props.onChange Handles change in text decoration selection.
  31787. * @param {string} [props.className] Additional class name to apply.
  31788. *
  31789. * @return {WPElement} Text decoration control.
  31790. */
  31791. function TextDecorationControl(_ref) {
  31792. let {
  31793. value,
  31794. onChange,
  31795. className
  31796. } = _ref;
  31797. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  31798. className: classnames_default()('block-editor-text-decoration-control', className)
  31799. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
  31800. as: "legend"
  31801. }, (0,external_wp_i18n_namespaceObject.__)('Decoration')), (0,external_wp_element_namespaceObject.createElement)("div", {
  31802. className: "block-editor-text-decoration-control__buttons"
  31803. }, TEXT_DECORATIONS.map(textDecoration => {
  31804. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  31805. key: textDecoration.value,
  31806. icon: textDecoration.icon,
  31807. label: textDecoration.name,
  31808. isPressed: textDecoration.value === value,
  31809. onClick: () => {
  31810. onChange(textDecoration.value === value ? undefined : textDecoration.value);
  31811. }
  31812. });
  31813. })));
  31814. }
  31815. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/text-decoration.js
  31816. /**
  31817. * WordPress dependencies
  31818. */
  31819. /**
  31820. * Internal dependencies
  31821. */
  31822. /**
  31823. * Key within block settings' supports array indicating support for text
  31824. * decorations e.g. settings found in `block.json`.
  31825. */
  31826. const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
  31827. /**
  31828. * Inspector control panel containing the text decoration options.
  31829. *
  31830. * @param {Object} props Block properties.
  31831. *
  31832. * @return {WPElement} Text decoration edit element.
  31833. */
  31834. function TextDecorationEdit(props) {
  31835. var _style$typography;
  31836. const {
  31837. attributes: {
  31838. style
  31839. },
  31840. setAttributes
  31841. } = props;
  31842. function onChange(newDecoration) {
  31843. setAttributes({
  31844. style: cleanEmptyObject({ ...style,
  31845. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  31846. textDecoration: newDecoration
  31847. }
  31848. })
  31849. });
  31850. }
  31851. return (0,external_wp_element_namespaceObject.createElement)(TextDecorationControl, {
  31852. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textDecoration,
  31853. onChange: onChange,
  31854. size: "__unstable-large"
  31855. });
  31856. }
  31857. /**
  31858. * Checks if text-decoration settings have been disabled.
  31859. *
  31860. * @param {string} name Name of the block.
  31861. *
  31862. * @return {boolean} Whether or not the setting is disabled.
  31863. */
  31864. function useIsTextDecorationDisabled() {
  31865. let {
  31866. name: blockName
  31867. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  31868. const notSupported = !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, TEXT_DECORATION_SUPPORT_KEY);
  31869. const hasTextDecoration = useSetting('typography.textDecoration');
  31870. return notSupported || !hasTextDecoration;
  31871. }
  31872. /**
  31873. * Checks if there is a current value set for the text decoration block support.
  31874. *
  31875. * @param {Object} props Block props.
  31876. * @return {boolean} Whether or not the block has a text decoration set.
  31877. */
  31878. function hasTextDecorationValue(props) {
  31879. var _props$attributes$sty, _props$attributes$sty2;
  31880. return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.textDecoration);
  31881. }
  31882. /**
  31883. * Resets the text decoration block support attribute. This can be used when
  31884. * disabling the text decoration support controls for a block via a progressive
  31885. * discovery panel.
  31886. *
  31887. * @param {Object} props Block props.
  31888. * @param {Object} props.attributes Block's attributes.
  31889. * @param {Object} props.setAttributes Function to set block's attributes.
  31890. */
  31891. function resetTextDecoration(_ref) {
  31892. let {
  31893. attributes = {},
  31894. setAttributes
  31895. } = _ref;
  31896. const {
  31897. style
  31898. } = attributes;
  31899. setAttributes({
  31900. style: cleanEmptyObject({ ...style,
  31901. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  31902. textDecoration: undefined
  31903. }
  31904. })
  31905. });
  31906. }
  31907. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-uppercase.js
  31908. /**
  31909. * WordPress dependencies
  31910. */
  31911. const formatUppercase = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31912. xmlns: "http://www.w3.org/2000/svg",
  31913. viewBox: "0 0 24 24"
  31914. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31915. d: "M6.1 6.8L2.1 18h1.6l1.1-3h4.3l1.1 3h1.6l-4-11.2H6.1zm-.8 6.8L7 8.9l1.7 4.7H5.3zm15.1-.7c-.4-.5-.9-.8-1.6-1 .4-.2.7-.5.8-.9.2-.4.3-.9.3-1.4 0-.9-.3-1.6-.8-2-.6-.5-1.3-.7-2.4-.7h-3.5V18h4.2c1.1 0 2-.3 2.6-.8.6-.6 1-1.4 1-2.4-.1-.8-.3-1.4-.6-1.9zm-5.7-4.7h1.8c.6 0 1.1.1 1.4.4.3.2.5.7.5 1.3 0 .6-.2 1.1-.5 1.3-.3.2-.8.4-1.4.4h-1.8V8.2zm4 8c-.4.3-.9.5-1.5.5h-2.6v-3.8h2.6c1.4 0 2 .6 2 1.9.1.6-.1 1-.5 1.4z"
  31916. }));
  31917. /* harmony default export */ var format_uppercase = (formatUppercase);
  31918. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-lowercase.js
  31919. /**
  31920. * WordPress dependencies
  31921. */
  31922. const formatLowercase = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31923. xmlns: "http://www.w3.org/2000/svg",
  31924. viewBox: "0 0 24 24"
  31925. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31926. d: "M11 16.8c-.1-.1-.2-.3-.3-.5v-2.6c0-.9-.1-1.7-.3-2.2-.2-.5-.5-.9-.9-1.2-.4-.2-.9-.3-1.6-.3-.5 0-1 .1-1.5.2s-.9.3-1.2.6l.2 1.2c.4-.3.7-.4 1.1-.5.3-.1.7-.2 1-.2.6 0 1 .1 1.3.4.3.2.4.7.4 1.4-1.2 0-2.3.2-3.3.7s-1.4 1.1-1.4 2.1c0 .7.2 1.2.7 1.6.4.4 1 .6 1.8.6.9 0 1.7-.4 2.4-1.2.1.3.2.5.4.7.1.2.3.3.6.4.3.1.6.1 1.1.1h.1l.2-1.2h-.1c-.4.1-.6 0-.7-.1zM9.2 16c-.2.3-.5.6-.9.8-.3.1-.7.2-1.1.2-.4 0-.7-.1-.9-.3-.2-.2-.3-.5-.3-.9 0-.6.2-1 .7-1.3.5-.3 1.3-.4 2.5-.5v2zm10.6-3.9c-.3-.6-.7-1.1-1.2-1.5-.6-.4-1.2-.6-1.9-.6-.5 0-.9.1-1.4.3-.4.2-.8.5-1.1.8V6h-1.4v12h1.3l.2-1c.2.4.6.6 1 .8.4.2.9.3 1.4.3.7 0 1.2-.2 1.8-.5.5-.4 1-.9 1.3-1.5.3-.6.5-1.3.5-2.1-.1-.6-.2-1.3-.5-1.9zm-1.7 4c-.4.5-.9.8-1.6.8s-1.2-.2-1.7-.7c-.4-.5-.7-1.2-.7-2.1 0-.9.2-1.6.7-2.1.4-.5 1-.7 1.7-.7s1.2.3 1.6.8c.4.5.6 1.2.6 2s-.2 1.4-.6 2z"
  31927. }));
  31928. /* harmony default export */ var format_lowercase = (formatLowercase);
  31929. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-capitalize.js
  31930. /**
  31931. * WordPress dependencies
  31932. */
  31933. const formatCapitalize = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31934. xmlns: "http://www.w3.org/2000/svg",
  31935. viewBox: "0 0 24 24"
  31936. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31937. d: "M7.1 6.8L3.1 18h1.6l1.1-3h4.3l1.1 3h1.6l-4-11.2H7.1zm-.8 6.8L8 8.9l1.7 4.7H6.3zm14.5-1.5c-.3-.6-.7-1.1-1.2-1.5-.6-.4-1.2-.6-1.9-.6-.5 0-.9.1-1.4.3-.4.2-.8.5-1.1.8V6h-1.4v12h1.3l.2-1c.2.4.6.6 1 .8.4.2.9.3 1.4.3.7 0 1.2-.2 1.8-.5.5-.4 1-.9 1.3-1.5.3-.6.5-1.3.5-2.1-.1-.6-.2-1.3-.5-1.9zm-1.7 4c-.4.5-.9.8-1.6.8s-1.2-.2-1.7-.7c-.4-.5-.7-1.2-.7-2.1 0-.9.2-1.6.7-2.1.4-.5 1-.7 1.7-.7s1.2.3 1.6.8c.4.5.6 1.2.6 2 .1.8-.2 1.4-.6 2z"
  31938. }));
  31939. /* harmony default export */ var format_capitalize = (formatCapitalize);
  31940. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-transform-control/index.js
  31941. /**
  31942. * External dependencies
  31943. */
  31944. /**
  31945. * WordPress dependencies
  31946. */
  31947. const TEXT_TRANSFORMS = [{
  31948. name: (0,external_wp_i18n_namespaceObject.__)('None'),
  31949. value: 'none',
  31950. icon: library_reset
  31951. }, {
  31952. name: (0,external_wp_i18n_namespaceObject.__)('Uppercase'),
  31953. value: 'uppercase',
  31954. icon: format_uppercase
  31955. }, {
  31956. name: (0,external_wp_i18n_namespaceObject.__)('Lowercase'),
  31957. value: 'lowercase',
  31958. icon: format_lowercase
  31959. }, {
  31960. name: (0,external_wp_i18n_namespaceObject.__)('Capitalize'),
  31961. value: 'capitalize',
  31962. icon: format_capitalize
  31963. }];
  31964. /**
  31965. * Control to facilitate text transform selections.
  31966. *
  31967. * @param {Object} props Component props.
  31968. * @param {string} props.className Class name to add to the control.
  31969. * @param {string} props.value Currently selected text transform.
  31970. * @param {Function} props.onChange Handles change in text transform selection.
  31971. *
  31972. * @return {WPElement} Text transform control.
  31973. */
  31974. function TextTransformControl(_ref) {
  31975. let {
  31976. className,
  31977. value,
  31978. onChange
  31979. } = _ref;
  31980. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  31981. className: classnames_default()('block-editor-text-transform-control', className)
  31982. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
  31983. as: "legend"
  31984. }, (0,external_wp_i18n_namespaceObject.__)('Letter case')), (0,external_wp_element_namespaceObject.createElement)("div", {
  31985. className: "block-editor-text-transform-control__buttons"
  31986. }, TEXT_TRANSFORMS.map(textTransform => {
  31987. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  31988. key: textTransform.value,
  31989. icon: textTransform.icon,
  31990. label: textTransform.name,
  31991. isPressed: textTransform.value === value,
  31992. onClick: () => {
  31993. onChange(textTransform.value === value ? undefined : textTransform.value);
  31994. }
  31995. });
  31996. })));
  31997. }
  31998. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/text-transform.js
  31999. /**
  32000. * WordPress dependencies
  32001. */
  32002. /**
  32003. * Internal dependencies
  32004. */
  32005. /**
  32006. * Key within block settings' supports array indicating support for text
  32007. * transforms e.g. settings found in `block.json`.
  32008. */
  32009. const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
  32010. /**
  32011. * Inspector control panel containing the text transform options.
  32012. *
  32013. * @param {Object} props Block properties.
  32014. *
  32015. * @return {WPElement} Text transform edit element.
  32016. */
  32017. function TextTransformEdit(props) {
  32018. var _style$typography;
  32019. const {
  32020. attributes: {
  32021. style
  32022. },
  32023. setAttributes
  32024. } = props;
  32025. function onChange(newTransform) {
  32026. setAttributes({
  32027. style: cleanEmptyObject({ ...style,
  32028. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  32029. textTransform: newTransform
  32030. }
  32031. })
  32032. });
  32033. }
  32034. return (0,external_wp_element_namespaceObject.createElement)(TextTransformControl, {
  32035. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textTransform,
  32036. onChange: onChange,
  32037. size: "__unstable-large"
  32038. });
  32039. }
  32040. /**
  32041. * Checks if text-transform settings have been disabled.
  32042. *
  32043. * @param {string} name Name of the block.
  32044. *
  32045. * @return {boolean} Whether or not the setting is disabled.
  32046. */
  32047. function useIsTextTransformDisabled() {
  32048. let {
  32049. name: blockName
  32050. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  32051. const notSupported = !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, TEXT_TRANSFORM_SUPPORT_KEY);
  32052. const hasTextTransforms = useSetting('typography.textTransform');
  32053. return notSupported || !hasTextTransforms;
  32054. }
  32055. /**
  32056. * Checks if there is a current value set for the text transform block support.
  32057. *
  32058. * @param {Object} props Block props.
  32059. * @return {boolean} Whether or not the block has a text transform set.
  32060. */
  32061. function hasTextTransformValue(props) {
  32062. var _props$attributes$sty, _props$attributes$sty2;
  32063. return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.textTransform);
  32064. }
  32065. /**
  32066. * Resets the text transform block support attribute. This can be used when
  32067. * disabling the text transform support controls for a block via a progressive
  32068. * discovery panel.
  32069. *
  32070. * @param {Object} props Block props.
  32071. * @param {Object} props.attributes Block's attributes.
  32072. * @param {Object} props.setAttributes Function to set block's attributes.
  32073. */
  32074. function resetTextTransform(_ref) {
  32075. let {
  32076. attributes = {},
  32077. setAttributes
  32078. } = _ref;
  32079. const {
  32080. style
  32081. } = attributes;
  32082. setAttributes({
  32083. style: cleanEmptyObject({ ...style,
  32084. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  32085. textTransform: undefined
  32086. }
  32087. })
  32088. });
  32089. }
  32090. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/letter-spacing-control/index.js
  32091. /**
  32092. * WordPress dependencies
  32093. */
  32094. /**
  32095. * Internal dependencies
  32096. */
  32097. /**
  32098. * Control for letter-spacing.
  32099. *
  32100. * @param {Object} props Component props.
  32101. * @param {string} props.value Currently selected letter-spacing.
  32102. * @param {Function} props.onChange Handles change in letter-spacing selection.
  32103. * @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS value.
  32104. *
  32105. * @return {WPElement} Letter-spacing control.
  32106. */
  32107. function LetterSpacingControl(_ref) {
  32108. let {
  32109. value,
  32110. onChange,
  32111. __unstableInputWidth = '60px',
  32112. ...otherProps
  32113. } = _ref;
  32114. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  32115. availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem'],
  32116. defaultValues: {
  32117. px: 2,
  32118. em: 0.2,
  32119. rem: 0.2
  32120. }
  32121. });
  32122. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, _extends({}, otherProps, {
  32123. label: (0,external_wp_i18n_namespaceObject.__)('Letter spacing'),
  32124. value: value,
  32125. __unstableInputWidth: __unstableInputWidth,
  32126. units: units,
  32127. onChange: onChange
  32128. }));
  32129. }
  32130. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/letter-spacing.js
  32131. /**
  32132. * WordPress dependencies
  32133. */
  32134. /**
  32135. * Internal dependencies
  32136. */
  32137. /**
  32138. * Key within block settings' supports array indicating support for letter-spacing
  32139. * e.g. settings found in `block.json`.
  32140. */
  32141. const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
  32142. /**
  32143. * Inspector control panel containing the letter-spacing options.
  32144. *
  32145. * @param {Object} props Block properties.
  32146. * @return {WPElement} Letter-spacing edit element.
  32147. */
  32148. function LetterSpacingEdit(props) {
  32149. var _style$typography;
  32150. const {
  32151. attributes: {
  32152. style
  32153. },
  32154. setAttributes
  32155. } = props;
  32156. function onChange(newSpacing) {
  32157. setAttributes({
  32158. style: cleanEmptyObject({ ...style,
  32159. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  32160. letterSpacing: newSpacing
  32161. }
  32162. })
  32163. });
  32164. }
  32165. return (0,external_wp_element_namespaceObject.createElement)(LetterSpacingControl, {
  32166. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.letterSpacing,
  32167. onChange: onChange,
  32168. __unstableInputWidth: '100%',
  32169. size: "__unstable-large"
  32170. });
  32171. }
  32172. /**
  32173. * Checks if letter-spacing settings have been disabled.
  32174. *
  32175. * @param {string} name Name of the block.
  32176. * @return {boolean} Whether or not the setting is disabled.
  32177. */
  32178. function useIsLetterSpacingDisabled() {
  32179. let {
  32180. name: blockName
  32181. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  32182. const notSupported = !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, LETTER_SPACING_SUPPORT_KEY);
  32183. const hasLetterSpacing = useSetting('typography.letterSpacing');
  32184. return notSupported || !hasLetterSpacing;
  32185. }
  32186. /**
  32187. * Checks if there is a current value set for the letter spacing block support.
  32188. *
  32189. * @param {Object} props Block props.
  32190. * @return {boolean} Whether or not the block has a letter spacing set.
  32191. */
  32192. function hasLetterSpacingValue(props) {
  32193. var _props$attributes$sty, _props$attributes$sty2;
  32194. return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.letterSpacing);
  32195. }
  32196. /**
  32197. * Resets the letter spacing block support attribute. This can be used when
  32198. * disabling the letter spacing support controls for a block via a progressive
  32199. * discovery panel.
  32200. *
  32201. * @param {Object} props Block props.
  32202. * @param {Object} props.attributes Block's attributes.
  32203. * @param {Object} props.setAttributes Function to set block's attributes.
  32204. */
  32205. function resetLetterSpacing(_ref) {
  32206. let {
  32207. attributes = {},
  32208. setAttributes
  32209. } = _ref;
  32210. const {
  32211. style
  32212. } = attributes;
  32213. setAttributes({
  32214. style: cleanEmptyObject({ ...style,
  32215. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  32216. letterSpacing: undefined
  32217. }
  32218. })
  32219. });
  32220. }
  32221. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/typography.js
  32222. /**
  32223. * WordPress dependencies
  32224. */
  32225. /**
  32226. * Internal dependencies
  32227. */
  32228. const TYPOGRAPHY_SUPPORT_KEY = 'typography';
  32229. const TYPOGRAPHY_SUPPORT_KEYS = [LINE_HEIGHT_SUPPORT_KEY, FONT_SIZE_SUPPORT_KEY, FONT_STYLE_SUPPORT_KEY, FONT_WEIGHT_SUPPORT_KEY, FONT_FAMILY_SUPPORT_KEY, TEXT_DECORATION_SUPPORT_KEY, TEXT_TRANSFORM_SUPPORT_KEY, LETTER_SPACING_SUPPORT_KEY];
  32230. function TypographyPanel(props) {
  32231. const {
  32232. clientId
  32233. } = props;
  32234. const isFontFamilyDisabled = useIsFontFamilyDisabled(props);
  32235. const isFontSizeDisabled = useIsFontSizeDisabled(props);
  32236. const isFontAppearanceDisabled = useIsFontAppearanceDisabled(props);
  32237. const isLineHeightDisabled = useIsLineHeightDisabled(props);
  32238. const isTextDecorationDisabled = useIsTextDecorationDisabled(props);
  32239. const isTextTransformDisabled = useIsTextTransformDisabled(props);
  32240. const isLetterSpacingDisabled = useIsLetterSpacingDisabled(props);
  32241. const hasFontStyles = !useIsFontStyleDisabled(props);
  32242. const hasFontWeights = !useIsFontWeightDisabled(props);
  32243. const isDisabled = useIsTypographyDisabled(props);
  32244. const isSupported = hasTypographySupport(props.name);
  32245. if (isDisabled || !isSupported) return null;
  32246. const defaultControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [TYPOGRAPHY_SUPPORT_KEY, '__experimentalDefaultControls']);
  32247. const createResetAllFilter = attribute => newAttributes => {
  32248. var _newAttributes$style;
  32249. return { ...newAttributes,
  32250. style: { ...newAttributes.style,
  32251. typography: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style.typography),
  32252. [attribute]: undefined
  32253. }
  32254. }
  32255. };
  32256. };
  32257. return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
  32258. __experimentalGroup: "typography"
  32259. }, !isFontFamilyDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  32260. hasValue: () => hasFontFamilyValue(props),
  32261. label: (0,external_wp_i18n_namespaceObject.__)('Font family'),
  32262. onDeselect: () => resetFontFamily(props),
  32263. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.fontFamily,
  32264. resetAllFilter: newAttributes => ({ ...newAttributes,
  32265. fontFamily: undefined
  32266. }),
  32267. panelId: clientId
  32268. }, (0,external_wp_element_namespaceObject.createElement)(FontFamilyEdit, props)), !isFontSizeDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  32269. hasValue: () => hasFontSizeValue(props)
  32270. /* translators: Ensure translation is distinct from "Letter case" */
  32271. ,
  32272. label: (0,external_wp_i18n_namespaceObject.__)('Font size'),
  32273. onDeselect: () => resetFontSize(props),
  32274. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.fontSize,
  32275. resetAllFilter: newAttributes => {
  32276. var _newAttributes$style2;
  32277. return { ...newAttributes,
  32278. fontSize: undefined,
  32279. style: { ...newAttributes.style,
  32280. typography: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.typography),
  32281. fontSize: undefined
  32282. }
  32283. }
  32284. };
  32285. },
  32286. panelId: clientId
  32287. }, (0,external_wp_element_namespaceObject.createElement)(FontSizeEdit, props)), !isFontAppearanceDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  32288. className: "single-column",
  32289. hasValue: () => hasFontAppearanceValue(props),
  32290. label: getFontAppearanceLabel(hasFontStyles, hasFontWeights),
  32291. onDeselect: () => resetFontAppearance(props),
  32292. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.fontAppearance,
  32293. resetAllFilter: newAttributes => {
  32294. var _newAttributes$style3;
  32295. return { ...newAttributes,
  32296. style: { ...newAttributes.style,
  32297. typography: { ...((_newAttributes$style3 = newAttributes.style) === null || _newAttributes$style3 === void 0 ? void 0 : _newAttributes$style3.typography),
  32298. fontStyle: undefined,
  32299. fontWeight: undefined
  32300. }
  32301. }
  32302. };
  32303. },
  32304. panelId: clientId
  32305. }, (0,external_wp_element_namespaceObject.createElement)(FontAppearanceEdit, props)), !isLineHeightDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  32306. className: "single-column",
  32307. hasValue: () => hasLineHeightValue(props),
  32308. label: (0,external_wp_i18n_namespaceObject.__)('Line height'),
  32309. onDeselect: () => resetLineHeight(props),
  32310. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.lineHeight,
  32311. resetAllFilter: createResetAllFilter('lineHeight'),
  32312. panelId: clientId
  32313. }, (0,external_wp_element_namespaceObject.createElement)(LineHeightEdit, props)), !isLetterSpacingDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  32314. className: "single-column",
  32315. hasValue: () => hasLetterSpacingValue(props),
  32316. label: (0,external_wp_i18n_namespaceObject.__)('Letter spacing'),
  32317. onDeselect: () => resetLetterSpacing(props),
  32318. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.letterSpacing,
  32319. resetAllFilter: createResetAllFilter('letterSpacing'),
  32320. panelId: clientId
  32321. }, (0,external_wp_element_namespaceObject.createElement)(LetterSpacingEdit, props)), !isTextDecorationDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  32322. className: "single-column",
  32323. hasValue: () => hasTextDecorationValue(props),
  32324. label: (0,external_wp_i18n_namespaceObject.__)('Decoration'),
  32325. onDeselect: () => resetTextDecoration(props),
  32326. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.textDecoration,
  32327. resetAllFilter: createResetAllFilter('textDecoration'),
  32328. panelId: clientId
  32329. }, (0,external_wp_element_namespaceObject.createElement)(TextDecorationEdit, props)), !isTextTransformDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  32330. hasValue: () => hasTextTransformValue(props)
  32331. /* translators: Ensure translation is distinct from "Font size" */
  32332. ,
  32333. label: (0,external_wp_i18n_namespaceObject.__)('Letter case'),
  32334. onDeselect: () => resetTextTransform(props),
  32335. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.textTransform,
  32336. resetAllFilter: createResetAllFilter('textTransform'),
  32337. panelId: clientId
  32338. }, (0,external_wp_element_namespaceObject.createElement)(TextTransformEdit, props)));
  32339. }
  32340. const hasTypographySupport = blockName => {
  32341. return TYPOGRAPHY_SUPPORT_KEYS.some(key => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, key));
  32342. };
  32343. function useIsTypographyDisabled() {
  32344. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  32345. const configs = [useIsFontAppearanceDisabled(props), useIsFontSizeDisabled(props), useIsLineHeightDisabled(props), useIsFontFamilyDisabled(props), useIsTextDecorationDisabled(props), useIsTextTransformDisabled(props), useIsLetterSpacingDisabled(props)];
  32346. return configs.filter(Boolean).length === configs.length;
  32347. }
  32348. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/style.js
  32349. /**
  32350. * External dependencies
  32351. */
  32352. /**
  32353. * WordPress dependencies
  32354. */
  32355. /**
  32356. * Internal dependencies
  32357. */
  32358. const styleSupportKeys = [...TYPOGRAPHY_SUPPORT_KEYS, BORDER_SUPPORT_KEY, COLOR_SUPPORT_KEY, SPACING_SUPPORT_KEY];
  32359. const hasStyleSupport = blockType => styleSupportKeys.some(key => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, key));
  32360. /**
  32361. * Returns the inline styles to add depending on the style object
  32362. *
  32363. * @param {Object} styles Styles configuration.
  32364. *
  32365. * @return {Object} Flattened CSS variables declaration.
  32366. */
  32367. function getInlineStyles() {
  32368. let styles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  32369. const output = {}; // The goal is to move everything to server side generated engine styles
  32370. // This is temporary as we absorb more and more styles into the engine.
  32371. (0,external_wp_styleEngine_namespaceObject.getCSSRules)(styles).forEach(rule => {
  32372. output[rule.key] = rule.value;
  32373. });
  32374. return output;
  32375. }
  32376. /**
  32377. * Filters registered block settings, extending attributes to include `style` attribute.
  32378. *
  32379. * @param {Object} settings Original block settings.
  32380. *
  32381. * @return {Object} Filtered block settings.
  32382. */
  32383. function style_addAttribute(settings) {
  32384. if (!hasStyleSupport(settings)) {
  32385. return settings;
  32386. } // Allow blocks to specify their own attribute definition with default values if needed.
  32387. if (!settings.attributes.style) {
  32388. Object.assign(settings.attributes, {
  32389. style: {
  32390. type: 'object'
  32391. }
  32392. });
  32393. }
  32394. return settings;
  32395. }
  32396. /**
  32397. * A dictionary of paths to flag skipping block support serialization as the key,
  32398. * with values providing the style paths to be omitted from serialization.
  32399. *
  32400. * @constant
  32401. * @type {Record<string, string[]>}
  32402. */
  32403. const skipSerializationPathsEdit = {
  32404. [`${BORDER_SUPPORT_KEY}.__experimentalSkipSerialization`]: ['border'],
  32405. [`${COLOR_SUPPORT_KEY}.__experimentalSkipSerialization`]: [COLOR_SUPPORT_KEY],
  32406. [`${TYPOGRAPHY_SUPPORT_KEY}.__experimentalSkipSerialization`]: [TYPOGRAPHY_SUPPORT_KEY],
  32407. [`${SPACING_SUPPORT_KEY}.__experimentalSkipSerialization`]: ['spacing']
  32408. };
  32409. /**
  32410. * A dictionary of paths to flag skipping block support serialization as the key,
  32411. * with values providing the style paths to be omitted from serialization.
  32412. *
  32413. * Extends the Edit skip paths to enable skipping additional paths in just
  32414. * the Save component. This allows a block support to be serialized within the
  32415. * editor, while using an alternate approach, such as server-side rendering, when
  32416. * the support is saved.
  32417. *
  32418. * @constant
  32419. * @type {Record<string, string[]>}
  32420. */
  32421. const skipSerializationPathsSave = { ...skipSerializationPathsEdit,
  32422. [`${SPACING_SUPPORT_KEY}`]: ['spacing.blockGap']
  32423. };
  32424. /**
  32425. * A dictionary used to normalize feature names between support flags, style
  32426. * object properties and __experimentSkipSerialization configuration arrays.
  32427. *
  32428. * This allows not having to provide a migration for a support flag and possible
  32429. * backwards compatibility bridges, while still achieving consistency between
  32430. * the support flag and the skip serialization array.
  32431. *
  32432. * @constant
  32433. * @type {Record<string, string>}
  32434. */
  32435. const renamedFeatures = {
  32436. gradients: 'gradient'
  32437. };
  32438. /**
  32439. * Override props assigned to save component to inject the CSS variables definition.
  32440. *
  32441. * @param {Object} props Additional props applied to save element.
  32442. * @param {Object} blockType Block type.
  32443. * @param {Object} attributes Block attributes.
  32444. * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization.
  32445. *
  32446. * @return {Object} Filtered props applied to save element.
  32447. */
  32448. function style_addSaveProps(props, blockType, attributes) {
  32449. let skipPaths = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : skipSerializationPathsSave;
  32450. if (!hasStyleSupport(blockType)) {
  32451. return props;
  32452. }
  32453. let {
  32454. style
  32455. } = attributes;
  32456. Object.entries(skipPaths).forEach(_ref => {
  32457. let [indicator, path] = _ref;
  32458. const skipSerialization = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, indicator);
  32459. if (skipSerialization === true) {
  32460. style = (0,external_lodash_namespaceObject.omit)(style, path);
  32461. }
  32462. if (Array.isArray(skipSerialization)) {
  32463. skipSerialization.forEach(featureName => {
  32464. const feature = renamedFeatures[featureName] || featureName;
  32465. style = (0,external_lodash_namespaceObject.omit)(style, [[...path, feature]]);
  32466. });
  32467. }
  32468. });
  32469. props.style = { ...getInlineStyles(style),
  32470. ...props.style
  32471. };
  32472. return props;
  32473. }
  32474. /**
  32475. * Filters registered block settings to extend the block edit wrapper
  32476. * to apply the desired styles and classnames properly.
  32477. *
  32478. * @param {Object} settings Original block settings.
  32479. *
  32480. * @return {Object}.Filtered block settings.
  32481. */
  32482. function style_addEditProps(settings) {
  32483. if (!hasStyleSupport(settings)) {
  32484. return settings;
  32485. }
  32486. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  32487. settings.getEditWrapperProps = attributes => {
  32488. let props = {};
  32489. if (existingGetEditWrapperProps) {
  32490. props = existingGetEditWrapperProps(attributes);
  32491. }
  32492. return style_addSaveProps(props, settings, attributes, skipSerializationPathsEdit);
  32493. };
  32494. return settings;
  32495. }
  32496. /**
  32497. * Override the default edit UI to include new inspector controls for
  32498. * all the custom styles configs.
  32499. *
  32500. * @param {Function} BlockEdit Original component.
  32501. *
  32502. * @return {Function} Wrapped component.
  32503. */
  32504. const withBlockControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  32505. const shouldDisplayControls = useDisplayBlockControls();
  32506. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, shouldDisplayControls && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ColorEdit, props), (0,external_wp_element_namespaceObject.createElement)(TypographyPanel, props), (0,external_wp_element_namespaceObject.createElement)(BorderPanel, props), (0,external_wp_element_namespaceObject.createElement)(DimensionsPanel, props)), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props));
  32507. }, 'withToolbarControls');
  32508. /**
  32509. * Override the default block element to include elements styles.
  32510. *
  32511. * @param {Function} BlockListBlock Original component
  32512. * @return {Function} Wrapped component
  32513. */
  32514. const withElementsStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  32515. var _props$attributes$sty2, _props$attributes$sty3;
  32516. const blockElementsContainerIdentifier = `wp-elements-${(0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock)}`;
  32517. const skipLinkColorSerialization = shouldSkipSerialization(props.name, COLOR_SUPPORT_KEY, 'link');
  32518. const styles = (0,external_wp_element_namespaceObject.useMemo)(() => {
  32519. var _props$attributes$sty;
  32520. const rawElementsStyles = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.elements;
  32521. const elementCssRules = [];
  32522. if (rawElementsStyles && Object.keys(rawElementsStyles).length > 0) {
  32523. var _rawElementsStyles$li;
  32524. // Remove values based on whether serialization has been skipped for a specific style.
  32525. const filteredElementsStyles = { ...rawElementsStyles,
  32526. link: { ...rawElementsStyles.link,
  32527. color: !skipLinkColorSerialization ? (_rawElementsStyles$li = rawElementsStyles.link) === null || _rawElementsStyles$li === void 0 ? void 0 : _rawElementsStyles$li.color : undefined
  32528. }
  32529. };
  32530. for (const [elementName, elementStyles] of Object.entries(filteredElementsStyles)) {
  32531. const cssRule = (0,external_wp_styleEngine_namespaceObject.compileCSS)(elementStyles, {
  32532. // The .editor-styles-wrapper selector is required on elements styles. As it is
  32533. // added to all other editor styles, not providing it causes reset and global
  32534. // styles to override element styles because of higher specificity.
  32535. selector: `.editor-styles-wrapper .${blockElementsContainerIdentifier} ${external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[elementName]}`
  32536. });
  32537. if (!!cssRule) {
  32538. elementCssRules.push(cssRule);
  32539. }
  32540. }
  32541. }
  32542. return elementCssRules.length > 0 ? elementCssRules : undefined;
  32543. }, [(_props$attributes$sty2 = props.attributes.style) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.elements]);
  32544. const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext);
  32545. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, styles && element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)("style", {
  32546. dangerouslySetInnerHTML: {
  32547. __html: styles
  32548. }
  32549. }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  32550. className: (_props$attributes$sty3 = props.attributes.style) !== null && _props$attributes$sty3 !== void 0 && _props$attributes$sty3.elements ? classnames_default()(props.className, blockElementsContainerIdentifier) : props.className
  32551. })));
  32552. });
  32553. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/style/addAttribute', style_addAttribute);
  32554. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/style/addSaveProps', style_addSaveProps);
  32555. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/style/addEditProps', style_addEditProps);
  32556. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/style/with-block-controls', withBlockControls);
  32557. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/with-elements-styles', withElementsStyles);
  32558. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/settings.js
  32559. /**
  32560. * WordPress dependencies
  32561. */
  32562. const hasSettingsSupport = blockType => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalSettings', false);
  32563. function settings_addAttribute(settings) {
  32564. var _settings$attributes;
  32565. if (!hasSettingsSupport(settings)) {
  32566. return settings;
  32567. } // Allow blocks to specify their own attribute definition with default values if needed.
  32568. if (!(settings !== null && settings !== void 0 && (_settings$attributes = settings.attributes) !== null && _settings$attributes !== void 0 && _settings$attributes.settings)) {
  32569. settings.attributes = { ...settings.attributes,
  32570. settings: {
  32571. type: 'object'
  32572. }
  32573. };
  32574. }
  32575. return settings;
  32576. }
  32577. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/settings/addAttribute', settings_addAttribute);
  32578. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/filter.js
  32579. /**
  32580. * WordPress dependencies
  32581. */
  32582. const filter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  32583. xmlns: "http://www.w3.org/2000/svg",
  32584. viewBox: "0 0 24 24"
  32585. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  32586. d: "M12 4 4 19h16L12 4zm0 3.2 5.5 10.3H12V7.2z"
  32587. }));
  32588. /* harmony default export */ var library_filter = (filter);
  32589. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/duotone-control/index.js
  32590. /**
  32591. * WordPress dependencies
  32592. */
  32593. function DuotoneControl(_ref) {
  32594. let {
  32595. colorPalette,
  32596. duotonePalette,
  32597. disableCustomColors,
  32598. disableCustomDuotone,
  32599. value,
  32600. onChange
  32601. } = _ref;
  32602. let toolbarIcon;
  32603. if (value === 'unset') {
  32604. toolbarIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
  32605. className: "block-editor-duotone-control__unset-indicator"
  32606. });
  32607. } else if (value) {
  32608. toolbarIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DuotoneSwatch, {
  32609. values: value
  32610. });
  32611. } else {
  32612. toolbarIcon = (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  32613. icon: library_filter
  32614. });
  32615. }
  32616. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  32617. popoverProps: {
  32618. className: 'block-editor-duotone-control__popover',
  32619. headerTitle: (0,external_wp_i18n_namespaceObject.__)('Duotone'),
  32620. isAlternate: true
  32621. },
  32622. renderToggle: _ref2 => {
  32623. let {
  32624. isOpen,
  32625. onToggle
  32626. } = _ref2;
  32627. const openOnArrowDown = event => {
  32628. if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
  32629. event.preventDefault();
  32630. onToggle();
  32631. }
  32632. };
  32633. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  32634. showTooltip: true,
  32635. onClick: onToggle,
  32636. "aria-haspopup": "true",
  32637. "aria-expanded": isOpen,
  32638. onKeyDown: openOnArrowDown,
  32639. label: (0,external_wp_i18n_namespaceObject.__)('Apply duotone filter'),
  32640. icon: toolbarIcon
  32641. });
  32642. },
  32643. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  32644. label: (0,external_wp_i18n_namespaceObject.__)('Duotone')
  32645. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  32646. className: "block-editor-duotone-control__description"
  32647. }, (0,external_wp_i18n_namespaceObject.__)('Create a two-tone color effect without losing your original image.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DuotonePicker, {
  32648. colorPalette: colorPalette,
  32649. duotonePalette: duotonePalette,
  32650. disableCustomColors: disableCustomColors,
  32651. disableCustomDuotone: disableCustomDuotone,
  32652. value: value,
  32653. onChange: onChange
  32654. }))
  32655. });
  32656. }
  32657. /* harmony default export */ var duotone_control = (DuotoneControl);
  32658. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/duotone.js
  32659. /**
  32660. * External dependencies
  32661. */
  32662. /**
  32663. * WordPress dependencies
  32664. */
  32665. /**
  32666. * Internal dependencies
  32667. */
  32668. const duotone_EMPTY_ARRAY = [];
  32669. k([names]);
  32670. /**
  32671. * SVG and stylesheet needed for rendering the duotone filter.
  32672. *
  32673. * @param {Object} props Duotone props.
  32674. * @param {string} props.selector Selector to apply the filter to.
  32675. * @param {string} props.id Unique id for this duotone filter.
  32676. * @param {string[]|"unset"} props.colors Array of RGB color strings ordered from dark to light.
  32677. *
  32678. * @return {WPElement} Duotone element.
  32679. */
  32680. function InlineDuotone(_ref) {
  32681. let {
  32682. selector,
  32683. id,
  32684. colors
  32685. } = _ref;
  32686. if (colors === 'unset') {
  32687. return (0,external_wp_element_namespaceObject.createElement)(DuotoneUnsetStylesheet, {
  32688. selector: selector
  32689. });
  32690. }
  32691. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(DuotoneFilter, {
  32692. id: id,
  32693. colors: colors
  32694. }), (0,external_wp_element_namespaceObject.createElement)(DuotoneStylesheet, {
  32695. id: id,
  32696. selector: selector
  32697. }));
  32698. }
  32699. function useMultiOriginPresets(_ref2) {
  32700. let {
  32701. presetSetting,
  32702. defaultSetting
  32703. } = _ref2;
  32704. const disableDefault = !useSetting(defaultSetting);
  32705. const userPresets = useSetting(`${presetSetting}.custom`) || duotone_EMPTY_ARRAY;
  32706. const themePresets = useSetting(`${presetSetting}.theme`) || duotone_EMPTY_ARRAY;
  32707. const defaultPresets = useSetting(`${presetSetting}.default`) || duotone_EMPTY_ARRAY;
  32708. return (0,external_wp_element_namespaceObject.useMemo)(() => [...userPresets, ...themePresets, ...(disableDefault ? duotone_EMPTY_ARRAY : defaultPresets)], [disableDefault, userPresets, themePresets, defaultPresets]);
  32709. }
  32710. function DuotonePanel(_ref3) {
  32711. var _style$color;
  32712. let {
  32713. attributes,
  32714. setAttributes
  32715. } = _ref3;
  32716. const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
  32717. const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
  32718. const duotonePalette = useMultiOriginPresets({
  32719. presetSetting: 'color.duotone',
  32720. defaultSetting: 'color.defaultDuotone'
  32721. });
  32722. const colorPalette = useMultiOriginPresets({
  32723. presetSetting: 'color.palette',
  32724. defaultSetting: 'color.defaultPalette'
  32725. });
  32726. const disableCustomColors = !useSetting('color.custom');
  32727. const disableCustomDuotone = !useSetting('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors;
  32728. if ((duotonePalette === null || duotonePalette === void 0 ? void 0 : duotonePalette.length) === 0 && disableCustomDuotone) {
  32729. return null;
  32730. }
  32731. return (0,external_wp_element_namespaceObject.createElement)(block_controls, {
  32732. group: "block",
  32733. __experimentalShareWithChildBlocks: true
  32734. }, (0,external_wp_element_namespaceObject.createElement)(duotone_control, {
  32735. duotonePalette: duotonePalette,
  32736. colorPalette: colorPalette,
  32737. disableCustomDuotone: disableCustomDuotone,
  32738. disableCustomColors: disableCustomColors,
  32739. value: duotone,
  32740. onChange: newDuotone => {
  32741. const newStyle = { ...style,
  32742. color: { ...(style === null || style === void 0 ? void 0 : style.color),
  32743. duotone: newDuotone
  32744. }
  32745. };
  32746. setAttributes({
  32747. style: newStyle
  32748. });
  32749. }
  32750. }));
  32751. }
  32752. /**
  32753. * Filters registered block settings, extending attributes to include
  32754. * the `duotone` attribute.
  32755. *
  32756. * @param {Object} settings Original block settings.
  32757. *
  32758. * @return {Object} Filtered block settings.
  32759. */
  32760. function addDuotoneAttributes(settings) {
  32761. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'color.__experimentalDuotone')) {
  32762. return settings;
  32763. } // Allow blocks to specify their own attribute definition with default
  32764. // values if needed.
  32765. if (!settings.attributes.style) {
  32766. Object.assign(settings.attributes, {
  32767. style: {
  32768. type: 'object'
  32769. }
  32770. });
  32771. }
  32772. return settings;
  32773. }
  32774. /**
  32775. * Override the default edit UI to include toolbar controls for duotone if the
  32776. * block supports duotone.
  32777. *
  32778. * @param {Function} BlockEdit Original component.
  32779. *
  32780. * @return {Function} Wrapped component.
  32781. */
  32782. const withDuotoneControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  32783. const hasDuotoneSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'color.__experimentalDuotone');
  32784. const isContentLocked = (0,external_wp_data_namespaceObject.useSelect)(select => {
  32785. return select(store).__unstableGetContentLockingParent(props.clientId);
  32786. }, [props.clientId]);
  32787. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), hasDuotoneSupport && !isContentLocked && (0,external_wp_element_namespaceObject.createElement)(DuotonePanel, props));
  32788. }, 'withDuotoneControls');
  32789. /**
  32790. * Function that scopes a selector with another one. This works a bit like
  32791. * SCSS nesting except the `&` operator isn't supported.
  32792. *
  32793. * @example
  32794. * ```js
  32795. * const scope = '.a, .b .c';
  32796. * const selector = '> .x, .y';
  32797. * const merged = scopeSelector( scope, selector );
  32798. * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'
  32799. * ```
  32800. *
  32801. * @param {string} scope Selector to scope to.
  32802. * @param {string} selector Original selector.
  32803. *
  32804. * @return {string} Scoped selector.
  32805. */
  32806. function scopeSelector(scope, selector) {
  32807. const scopes = scope.split(',');
  32808. const selectors = selector.split(',');
  32809. const selectorsScoped = [];
  32810. scopes.forEach(outer => {
  32811. selectors.forEach(inner => {
  32812. selectorsScoped.push(`${outer.trim()} ${inner.trim()}`);
  32813. });
  32814. });
  32815. return selectorsScoped.join(', ');
  32816. }
  32817. /**
  32818. * Override the default block element to include duotone styles.
  32819. *
  32820. * @param {Function} BlockListBlock Original component.
  32821. *
  32822. * @return {Function} Wrapped component.
  32823. */
  32824. const withDuotoneStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  32825. var _props$attributes, _props$attributes$sty, _props$attributes$sty2;
  32826. const duotoneSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, 'color.__experimentalDuotone');
  32827. const colors = props === null || props === void 0 ? void 0 : (_props$attributes = props.attributes) === null || _props$attributes === void 0 ? void 0 : (_props$attributes$sty = _props$attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.color) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.duotone;
  32828. if (!duotoneSupport || !colors) {
  32829. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
  32830. }
  32831. const id = `wp-duotone-${(0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock)}`; // Extra .editor-styles-wrapper specificity is needed in the editor
  32832. // since we're not using inline styles to apply the filter. We need to
  32833. // override duotone applied by global styles and theme.json.
  32834. const selectorsGroup = scopeSelector(`.editor-styles-wrapper .${id}`, duotoneSupport);
  32835. const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, id);
  32836. const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext);
  32837. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(InlineDuotone, {
  32838. selector: selectorsGroup,
  32839. id: id,
  32840. colors: colors
  32841. }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  32842. className: className
  32843. })));
  32844. }, 'withDuotoneStyles');
  32845. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/duotone/add-attributes', addDuotoneAttributes);
  32846. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/duotone/with-editor-controls', withDuotoneControls);
  32847. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/duotone/with-styles', withDuotoneStyles);
  32848. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/layout.js
  32849. /**
  32850. * External dependencies
  32851. */
  32852. /**
  32853. * WordPress dependencies
  32854. */
  32855. /**
  32856. * Internal dependencies
  32857. */
  32858. const layoutBlockSupportKey = '__experimentalLayout';
  32859. /**
  32860. * Generates the utility classnames for the given block's layout attributes.
  32861. *
  32862. * @param { Object } block Block object.
  32863. *
  32864. * @return { Array } Array of CSS classname strings.
  32865. */
  32866. function useLayoutClasses() {
  32867. var _globalLayoutSettings, _globalLayoutSettings2;
  32868. let block = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  32869. const rootPaddingAlignment = (0,external_wp_data_namespaceObject.useSelect)(select => {
  32870. var _getSettings$__experi;
  32871. const {
  32872. getSettings
  32873. } = select(store);
  32874. return (_getSettings$__experi = getSettings().__experimentalFeatures) === null || _getSettings$__experi === void 0 ? void 0 : _getSettings$__experi.useRootPaddingAwareAlignments;
  32875. }, []);
  32876. const globalLayoutSettings = useSetting('layout') || {};
  32877. const {
  32878. attributes = {},
  32879. name
  32880. } = block;
  32881. const {
  32882. layout
  32883. } = attributes;
  32884. const {
  32885. default: defaultBlockLayout
  32886. } = (0,external_wp_blocks_namespaceObject.getBlockSupport)(name, layoutBlockSupportKey) || {};
  32887. const usedLayout = layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize ? { ...layout,
  32888. type: 'constrained'
  32889. } : layout || defaultBlockLayout || {};
  32890. const layoutClassnames = [];
  32891. if (globalLayoutSettings !== null && globalLayoutSettings !== void 0 && (_globalLayoutSettings = globalLayoutSettings.definitions) !== null && _globalLayoutSettings !== void 0 && (_globalLayoutSettings2 = _globalLayoutSettings[(usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) || 'default']) !== null && _globalLayoutSettings2 !== void 0 && _globalLayoutSettings2.className) {
  32892. var _globalLayoutSettings3, _globalLayoutSettings4;
  32893. layoutClassnames.push(globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : (_globalLayoutSettings3 = globalLayoutSettings.definitions) === null || _globalLayoutSettings3 === void 0 ? void 0 : (_globalLayoutSettings4 = _globalLayoutSettings3[(usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) || 'default']) === null || _globalLayoutSettings4 === void 0 ? void 0 : _globalLayoutSettings4.className);
  32894. }
  32895. if ((usedLayout !== null && usedLayout !== void 0 && usedLayout.inherit || usedLayout !== null && usedLayout !== void 0 && usedLayout.contentSize || (usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) === 'constrained') && rootPaddingAlignment) {
  32896. layoutClassnames.push('has-global-padding');
  32897. }
  32898. if (usedLayout !== null && usedLayout !== void 0 && usedLayout.orientation) {
  32899. layoutClassnames.push(`is-${(0,external_lodash_namespaceObject.kebabCase)(usedLayout.orientation)}`);
  32900. }
  32901. if (usedLayout !== null && usedLayout !== void 0 && usedLayout.justifyContent) {
  32902. layoutClassnames.push(`is-content-justification-${(0,external_lodash_namespaceObject.kebabCase)(usedLayout.justifyContent)}`);
  32903. }
  32904. if (usedLayout !== null && usedLayout !== void 0 && usedLayout.flexWrap && usedLayout.flexWrap === 'nowrap') {
  32905. layoutClassnames.push('is-nowrap');
  32906. }
  32907. return layoutClassnames;
  32908. }
  32909. /**
  32910. * Generates a CSS rule with the given block's layout styles.
  32911. *
  32912. * @param { Object } block Block object.
  32913. * @param { string } selector A selector to use in generating the CSS rule.
  32914. *
  32915. * @return { string } CSS rule.
  32916. */
  32917. function useLayoutStyles() {
  32918. var _fullLayoutType$getLa;
  32919. let block = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  32920. let selector = arguments.length > 1 ? arguments[1] : undefined;
  32921. const {
  32922. attributes = {},
  32923. name
  32924. } = block;
  32925. const {
  32926. layout = {},
  32927. style = {}
  32928. } = attributes; // Update type for blocks using legacy layouts.
  32929. const usedLayout = layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize ? { ...layout,
  32930. type: 'constrained'
  32931. } : layout || {};
  32932. const fullLayoutType = getLayoutType((usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) || 'default');
  32933. const globalLayoutSettings = useSetting('layout') || {};
  32934. const blockGapSupport = useSetting('spacing.blockGap');
  32935. const hasBlockGapSupport = blockGapSupport !== null;
  32936. const css = fullLayoutType === null || fullLayoutType === void 0 ? void 0 : (_fullLayoutType$getLa = fullLayoutType.getLayoutStyle) === null || _fullLayoutType$getLa === void 0 ? void 0 : _fullLayoutType$getLa.call(fullLayoutType, {
  32937. blockName: name,
  32938. selector,
  32939. layout,
  32940. layoutDefinitions: globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : globalLayoutSettings.definitions,
  32941. style,
  32942. hasBlockGapSupport
  32943. });
  32944. return css;
  32945. }
  32946. function LayoutPanel(_ref) {
  32947. let {
  32948. setAttributes,
  32949. attributes,
  32950. name: blockName
  32951. } = _ref;
  32952. const {
  32953. layout
  32954. } = attributes;
  32955. const defaultThemeLayout = useSetting('layout');
  32956. const themeSupportsLayout = (0,external_wp_data_namespaceObject.useSelect)(select => {
  32957. const {
  32958. getSettings
  32959. } = select(store);
  32960. return getSettings().supportsLayout;
  32961. }, []);
  32962. const layoutBlockSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, layoutBlockSupportKey, {});
  32963. const {
  32964. allowSwitching,
  32965. allowEditing = true,
  32966. allowInheriting = true,
  32967. default: defaultBlockLayout
  32968. } = layoutBlockSupport;
  32969. if (!allowEditing) {
  32970. return null;
  32971. } // Only show the inherit toggle if it's supported,
  32972. // a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),
  32973. // and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.
  32974. const showInheritToggle = !!(allowInheriting && !!defaultThemeLayout && (!(layout !== null && layout !== void 0 && layout.type) || (layout === null || layout === void 0 ? void 0 : layout.type) === 'default' || (layout === null || layout === void 0 ? void 0 : layout.type) === 'constrained' || layout !== null && layout !== void 0 && layout.inherit));
  32975. const usedLayout = layout || defaultBlockLayout || {};
  32976. const {
  32977. inherit = false,
  32978. type = 'default',
  32979. contentSize = null
  32980. } = usedLayout;
  32981. /**
  32982. * `themeSupportsLayout` is only relevant to the `default/flow` or
  32983. * `constrained` layouts and it should not be taken into account when other
  32984. * `layout` types are used.
  32985. */
  32986. if ((type === 'default' || type === 'constrained') && !themeSupportsLayout) {
  32987. return null;
  32988. }
  32989. const layoutType = getLayoutType(type);
  32990. const constrainedType = getLayoutType('constrained');
  32991. const displayControlsForLegacyLayouts = !usedLayout.type && (contentSize || inherit);
  32992. const hasContentSizeOrLegacySettings = !!inherit || !!contentSize;
  32993. const onChangeType = newType => setAttributes({
  32994. layout: {
  32995. type: newType
  32996. }
  32997. });
  32998. const onChangeLayout = newLayout => setAttributes({
  32999. layout: newLayout
  33000. });
  33001. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(inspector_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  33002. title: (0,external_wp_i18n_namespaceObject.__)('Layout')
  33003. }, showInheritToggle && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  33004. className: "block-editor-hooks__toggle-control",
  33005. label: (0,external_wp_i18n_namespaceObject.__)('Inner blocks use content width'),
  33006. checked: (layoutType === null || layoutType === void 0 ? void 0 : layoutType.name) === 'constrained' || hasContentSizeOrLegacySettings,
  33007. onChange: () => setAttributes({
  33008. layout: {
  33009. type: (layoutType === null || layoutType === void 0 ? void 0 : layoutType.name) === 'constrained' || hasContentSizeOrLegacySettings ? 'default' : 'constrained'
  33010. }
  33011. }),
  33012. help: (layoutType === null || layoutType === void 0 ? void 0 : layoutType.name) === 'constrained' || hasContentSizeOrLegacySettings ? (0,external_wp_i18n_namespaceObject.__)('Nested blocks use content width with options for full and wide widths.') : (0,external_wp_i18n_namespaceObject.__)('Nested blocks will fill the width of this container. Toggle to constrain.')
  33013. })), !inherit && allowSwitching && (0,external_wp_element_namespaceObject.createElement)(LayoutTypeSwitcher, {
  33014. type: type,
  33015. onChange: onChangeType
  33016. }), layoutType && layoutType.name !== 'default' && (0,external_wp_element_namespaceObject.createElement)(layoutType.inspectorControls, {
  33017. layout: usedLayout,
  33018. onChange: onChangeLayout,
  33019. layoutBlockSupport: layoutBlockSupport
  33020. }), constrainedType && displayControlsForLegacyLayouts && (0,external_wp_element_namespaceObject.createElement)(constrainedType.inspectorControls, {
  33021. layout: usedLayout,
  33022. onChange: onChangeLayout,
  33023. layoutBlockSupport: layoutBlockSupport
  33024. }))), !inherit && layoutType && (0,external_wp_element_namespaceObject.createElement)(layoutType.toolBarControls, {
  33025. layout: usedLayout,
  33026. onChange: onChangeLayout,
  33027. layoutBlockSupport: layoutBlockSupport
  33028. }));
  33029. }
  33030. function LayoutTypeSwitcher(_ref2) {
  33031. let {
  33032. type,
  33033. onChange
  33034. } = _ref2;
  33035. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ButtonGroup, null, getLayoutTypes().map(_ref3 => {
  33036. let {
  33037. name,
  33038. label
  33039. } = _ref3;
  33040. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33041. key: name,
  33042. isPressed: type === name,
  33043. onClick: () => onChange(name)
  33044. }, label);
  33045. }));
  33046. }
  33047. /**
  33048. * Filters registered block settings, extending attributes to include `layout`.
  33049. *
  33050. * @param {Object} settings Original block settings.
  33051. *
  33052. * @return {Object} Filtered block settings.
  33053. */
  33054. function layout_addAttribute(settings) {
  33055. var _settings$attributes$, _settings$attributes;
  33056. if ('type' in ((_settings$attributes$ = (_settings$attributes = settings.attributes) === null || _settings$attributes === void 0 ? void 0 : _settings$attributes.layout) !== null && _settings$attributes$ !== void 0 ? _settings$attributes$ : {})) {
  33057. return settings;
  33058. }
  33059. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, layoutBlockSupportKey)) {
  33060. settings.attributes = { ...settings.attributes,
  33061. layout: {
  33062. type: 'object'
  33063. }
  33064. };
  33065. }
  33066. return settings;
  33067. }
  33068. /**
  33069. * Override the default edit UI to include layout controls
  33070. *
  33071. * @param {Function} BlockEdit Original component.
  33072. *
  33073. * @return {Function} Wrapped component.
  33074. */
  33075. const withInspectorControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  33076. const {
  33077. name: blockName
  33078. } = props;
  33079. const supportLayout = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, layoutBlockSupportKey);
  33080. return [supportLayout && (0,external_wp_element_namespaceObject.createElement)(LayoutPanel, _extends({
  33081. key: "layout"
  33082. }, props)), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({
  33083. key: "edit"
  33084. }, props))];
  33085. }, 'withInspectorControls');
  33086. /**
  33087. * Override the default block element to add the layout styles.
  33088. *
  33089. * @param {Function} BlockListBlock Original component.
  33090. *
  33091. * @return {Function} Wrapped component.
  33092. */
  33093. const withLayoutStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  33094. const {
  33095. name,
  33096. attributes,
  33097. block
  33098. } = props;
  33099. const hasLayoutBlockSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, layoutBlockSupportKey);
  33100. const disableLayoutStyles = (0,external_wp_data_namespaceObject.useSelect)(select => {
  33101. const {
  33102. getSettings
  33103. } = select(store);
  33104. return !!getSettings().disableLayoutStyles;
  33105. });
  33106. const shouldRenderLayoutStyles = hasLayoutBlockSupport && !disableLayoutStyles;
  33107. const id = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock);
  33108. const defaultThemeLayout = useSetting('layout') || {};
  33109. const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext);
  33110. const {
  33111. layout
  33112. } = attributes;
  33113. const {
  33114. default: defaultBlockLayout
  33115. } = (0,external_wp_blocks_namespaceObject.getBlockSupport)(name, layoutBlockSupportKey) || {};
  33116. const usedLayout = layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize ? { ...layout,
  33117. type: 'constrained'
  33118. } : layout || defaultBlockLayout || {};
  33119. const layoutClasses = hasLayoutBlockSupport ? useLayoutClasses(block) : null;
  33120. const selector = `.${(0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name)}.wp-container-${id}`;
  33121. const blockGapSupport = useSetting('spacing.blockGap');
  33122. const hasBlockGapSupport = blockGapSupport !== null; // Get CSS string for the current layout type.
  33123. // The CSS and `style` element is only output if it is not empty.
  33124. let css;
  33125. if (shouldRenderLayoutStyles) {
  33126. var _fullLayoutType$getLa2;
  33127. const fullLayoutType = getLayoutType((usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) || 'default');
  33128. css = fullLayoutType === null || fullLayoutType === void 0 ? void 0 : (_fullLayoutType$getLa2 = fullLayoutType.getLayoutStyle) === null || _fullLayoutType$getLa2 === void 0 ? void 0 : _fullLayoutType$getLa2.call(fullLayoutType, {
  33129. blockName: name,
  33130. selector,
  33131. layout: usedLayout,
  33132. layoutDefinitions: defaultThemeLayout === null || defaultThemeLayout === void 0 ? void 0 : defaultThemeLayout.definitions,
  33133. style: attributes === null || attributes === void 0 ? void 0 : attributes.style,
  33134. hasBlockGapSupport
  33135. });
  33136. } // Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.
  33137. const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, {
  33138. [`wp-container-${id}`]: shouldRenderLayoutStyles && !!css // Only attach a container class if there is generated CSS to be attached.
  33139. }, layoutClasses);
  33140. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, shouldRenderLayoutStyles && element && !!css && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(LayoutStyle, {
  33141. blockName: name,
  33142. selector: selector,
  33143. css: css,
  33144. layout: usedLayout,
  33145. style: attributes === null || attributes === void 0 ? void 0 : attributes.style
  33146. }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  33147. className: className
  33148. })));
  33149. });
  33150. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/layout/addAttribute', layout_addAttribute);
  33151. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/layout/with-layout-styles', withLayoutStyles);
  33152. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/layout/with-inspector-controls', withInspectorControls);
  33153. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/content-lock-ui.js
  33154. /**
  33155. * WordPress dependencies
  33156. */
  33157. /**
  33158. * Internal dependencies
  33159. */
  33160. /**
  33161. * External dependencies
  33162. */
  33163. function StopEditingAsBlocksOnOutsideSelect(_ref) {
  33164. let {
  33165. clientId,
  33166. stopEditingAsBlock
  33167. } = _ref;
  33168. const isBlockOrDescendantSelected = (0,external_wp_data_namespaceObject.useSelect)(select => {
  33169. const {
  33170. isBlockSelected,
  33171. hasSelectedInnerBlock
  33172. } = select(store);
  33173. return isBlockSelected(clientId) || hasSelectedInnerBlock(clientId, true);
  33174. }, [clientId]);
  33175. (0,external_wp_element_namespaceObject.useEffect)(() => {
  33176. if (!isBlockOrDescendantSelected) {
  33177. stopEditingAsBlock();
  33178. }
  33179. }, [isBlockOrDescendantSelected]);
  33180. return null;
  33181. }
  33182. const content_lock_ui_withBlockControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  33183. const {
  33184. getBlockListSettings,
  33185. getSettings
  33186. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  33187. const focusModeToRevert = (0,external_wp_element_namespaceObject.useRef)();
  33188. const {
  33189. templateLock,
  33190. isLockedByParent,
  33191. isEditingAsBlocks
  33192. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  33193. const {
  33194. __unstableGetContentLockingParent,
  33195. getTemplateLock,
  33196. __unstableGetTemporarilyEditingAsBlocks
  33197. } = select(store);
  33198. return {
  33199. templateLock: getTemplateLock(props.clientId),
  33200. isLockedByParent: !!__unstableGetContentLockingParent(props.clientId),
  33201. isEditingAsBlocks: __unstableGetTemporarilyEditingAsBlocks() === props.clientId
  33202. };
  33203. }, [props.clientId]);
  33204. const {
  33205. updateSettings,
  33206. updateBlockListSettings,
  33207. __unstableSetTemporarilyEditingAsBlocks
  33208. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  33209. const isContentLocked = !isLockedByParent && templateLock === 'contentOnly';
  33210. const {
  33211. __unstableMarkNextChangeAsNotPersistent,
  33212. updateBlockAttributes
  33213. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  33214. const stopEditingAsBlock = (0,external_wp_element_namespaceObject.useCallback)(() => {
  33215. __unstableMarkNextChangeAsNotPersistent();
  33216. updateBlockAttributes(props.clientId, {
  33217. templateLock: 'contentOnly'
  33218. });
  33219. updateBlockListSettings(props.clientId, { ...getBlockListSettings(props.clientId),
  33220. templateLock: 'contentOnly'
  33221. });
  33222. updateSettings({
  33223. focusMode: focusModeToRevert.current
  33224. });
  33225. __unstableSetTemporarilyEditingAsBlocks();
  33226. }, [props.clientId, focusModeToRevert, updateSettings, updateBlockListSettings, getBlockListSettings, __unstableMarkNextChangeAsNotPersistent, updateBlockAttributes, __unstableSetTemporarilyEditingAsBlocks]);
  33227. if (!isContentLocked && !isEditingAsBlocks) {
  33228. return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
  33229. }
  33230. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isEditingAsBlocks && !isContentLocked && (0,external_wp_element_namespaceObject.createElement)(StopEditingAsBlocksOnOutsideSelect, {
  33231. clientId: props.clientId,
  33232. stopEditingAsBlock: stopEditingAsBlock
  33233. }), (0,external_wp_element_namespaceObject.createElement)(block_controls, {
  33234. group: "other"
  33235. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  33236. onClick: () => {
  33237. if (isEditingAsBlocks && !isContentLocked) {
  33238. stopEditingAsBlock();
  33239. } else {
  33240. __unstableMarkNextChangeAsNotPersistent();
  33241. updateBlockAttributes(props.clientId, {
  33242. templateLock: undefined
  33243. });
  33244. updateBlockListSettings(props.clientId, { ...getBlockListSettings(props.clientId),
  33245. templateLock: false
  33246. });
  33247. focusModeToRevert.current = getSettings().focusMode;
  33248. updateSettings({
  33249. focusMode: true
  33250. });
  33251. __unstableSetTemporarilyEditingAsBlocks(props.clientId);
  33252. }
  33253. }
  33254. }, isEditingAsBlocks && !isContentLocked ? (0,external_wp_i18n_namespaceObject.__)('Done') : (0,external_wp_i18n_namespaceObject.__)('Modify'))), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, {
  33255. className: classnames_default()(props.className, isEditingAsBlocks && 'is-content-locked-editing-as-blocks')
  33256. })));
  33257. }, 'withToolbarControls');
  33258. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/style/with-block-controls', content_lock_ui_withBlockControls);
  33259. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/metadata.js
  33260. /**
  33261. * WordPress dependencies
  33262. */
  33263. const META_ATTRIBUTE_NAME = 'metadata';
  33264. function hasBlockMetadataSupport(blockType) {
  33265. let feature = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  33266. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, '__experimentalMetadata');
  33267. return !!(true === support || support !== null && support !== void 0 && support[feature]);
  33268. }
  33269. /**
  33270. * Filters registered block settings, extending attributes to include `metadata`.
  33271. *
  33272. * see: https://github.com/WordPress/gutenberg/pull/40393/files#r864632012
  33273. *
  33274. * @param {Object} blockTypeSettings Original block settings.
  33275. * @return {Object} Filtered block settings.
  33276. */
  33277. function addMetaAttribute(blockTypeSettings) {
  33278. var _blockTypeSettings$at, _blockTypeSettings$at2;
  33279. // Allow blocks to specify their own attribute definition with default values if needed.
  33280. if (blockTypeSettings !== null && blockTypeSettings !== void 0 && (_blockTypeSettings$at = blockTypeSettings.attributes) !== null && _blockTypeSettings$at !== void 0 && (_blockTypeSettings$at2 = _blockTypeSettings$at[META_ATTRIBUTE_NAME]) !== null && _blockTypeSettings$at2 !== void 0 && _blockTypeSettings$at2.type) {
  33281. return blockTypeSettings;
  33282. }
  33283. const supportsBlockNaming = hasBlockMetadataSupport(blockTypeSettings, 'name', false);
  33284. if (supportsBlockNaming) {
  33285. blockTypeSettings.attributes = { ...blockTypeSettings.attributes,
  33286. [META_ATTRIBUTE_NAME]: {
  33287. type: 'object'
  33288. }
  33289. };
  33290. }
  33291. return blockTypeSettings;
  33292. }
  33293. function metadata_addSaveProps(extraProps, blockType, attributes) {
  33294. if (hasBlockMetadataSupport(blockType)) {
  33295. extraProps[META_ATTRIBUTE_NAME] = attributes[META_ATTRIBUTE_NAME];
  33296. }
  33297. return extraProps;
  33298. }
  33299. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/metadata/addMetaAttribute', addMetaAttribute);
  33300. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/metadata/save-props', metadata_addSaveProps);
  33301. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/metadata-name.js
  33302. /**
  33303. * WordPress dependencies
  33304. */
  33305. /**
  33306. * Internal dependencies
  33307. */
  33308. /**
  33309. * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.
  33310. *
  33311. * @param {Object} settings Original block settings.
  33312. *
  33313. * @return {Object} Filtered block settings.
  33314. */
  33315. function addLabelCallback(settings) {
  33316. // If blocks provide their own label callback, do not override it.
  33317. if (settings.__experimentalLabel) {
  33318. return settings;
  33319. }
  33320. const supportsBlockNaming = hasBlockMetadataSupport(settings, 'name', false // default value
  33321. ); // Check whether block metadata is supported before using it.
  33322. if (supportsBlockNaming) {
  33323. settings.__experimentalLabel = (attributes, _ref) => {
  33324. let {
  33325. context
  33326. } = _ref;
  33327. const {
  33328. metadata
  33329. } = attributes; // In the list view, use the block's name attribute as the label.
  33330. if (context === 'list-view' && metadata !== null && metadata !== void 0 && metadata.name) {
  33331. return metadata.name;
  33332. }
  33333. };
  33334. }
  33335. return settings;
  33336. }
  33337. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/metadata/addLabelCallback', addLabelCallback);
  33338. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-border-props.js
  33339. /**
  33340. * Internal dependencies
  33341. */
  33342. // This utility is intended to assist where the serialization of the border
  33343. // block support is being skipped for a block but the border related CSS classes
  33344. // & styles still need to be generated so they can be applied to inner elements.
  33345. /**
  33346. * Provides the CSS class names and inline styles for a block's border support
  33347. * attributes.
  33348. *
  33349. * @param {Object} attributes Block attributes.
  33350. * @return {Object} Border block support derived CSS classes & styles.
  33351. */
  33352. function getBorderClassesAndStyles(attributes) {
  33353. var _attributes$style;
  33354. const border = ((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.border) || {};
  33355. const className = getBorderClasses(attributes);
  33356. return {
  33357. className: className || undefined,
  33358. style: getInlineStyles({
  33359. border
  33360. })
  33361. };
  33362. }
  33363. /**
  33364. * Derives the border related props for a block from its border block support
  33365. * attributes.
  33366. *
  33367. * Inline styles are forced for named colors to ensure these selections are
  33368. * reflected when themes do not load their color stylesheets in the editor.
  33369. *
  33370. * @param {Object} attributes Block attributes.
  33371. *
  33372. * @return {Object} ClassName & style props from border block support.
  33373. */
  33374. function useBorderProps(attributes) {
  33375. const {
  33376. colors
  33377. } = useMultipleOriginColorsAndGradients();
  33378. const borderProps = getBorderClassesAndStyles(attributes);
  33379. const {
  33380. borderColor
  33381. } = attributes; // Force inline styles to apply named border colors when themes do not load
  33382. // their color stylesheets in the editor.
  33383. if (borderColor) {
  33384. const borderColorObject = getMultiOriginColor({
  33385. colors,
  33386. namedColor: borderColor
  33387. });
  33388. borderProps.style.borderColor = borderColorObject.color;
  33389. }
  33390. return borderProps;
  33391. }
  33392. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-color-props.js
  33393. /**
  33394. * External dependencies
  33395. */
  33396. /**
  33397. * WordPress dependencies
  33398. */
  33399. /**
  33400. * Internal dependencies
  33401. */
  33402. // The code in this file has largely been lifted from the color block support
  33403. // hook.
  33404. //
  33405. // This utility is intended to assist where the serialization of the colors
  33406. // block support is being skipped for a block but the color related CSS classes
  33407. // & styles still need to be generated so they can be applied to inner elements.
  33408. /**
  33409. * Provides the CSS class names and inline styles for a block's color support
  33410. * attributes.
  33411. *
  33412. * @param {Object} attributes Block attributes.
  33413. *
  33414. * @return {Object} Color block support derived CSS classes & styles.
  33415. */
  33416. function getColorClassesAndStyles(attributes) {
  33417. var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link;
  33418. const {
  33419. backgroundColor,
  33420. textColor,
  33421. gradient,
  33422. style
  33423. } = attributes; // Collect color CSS classes.
  33424. const backgroundClass = getColorClassName('background-color', backgroundColor);
  33425. const textClass = getColorClassName('color', textColor);
  33426. const gradientClass = __experimentalGetGradientClass(gradient);
  33427. const hasGradient = gradientClass || (style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.gradient); // Determine color CSS class name list.
  33428. const className = classnames_default()(textClass, gradientClass, {
  33429. // Don't apply the background class if there's a gradient.
  33430. [backgroundClass]: !hasGradient && !!backgroundClass,
  33431. 'has-text-color': textColor || (style === null || style === void 0 ? void 0 : (_style$color2 = style.color) === null || _style$color2 === void 0 ? void 0 : _style$color2.text),
  33432. 'has-background': backgroundColor || (style === null || style === void 0 ? void 0 : (_style$color3 = style.color) === null || _style$color3 === void 0 ? void 0 : _style$color3.background) || gradient || (style === null || style === void 0 ? void 0 : (_style$color4 = style.color) === null || _style$color4 === void 0 ? void 0 : _style$color4.gradient),
  33433. 'has-link-color': style === null || style === void 0 ? void 0 : (_style$elements = style.elements) === null || _style$elements === void 0 ? void 0 : (_style$elements$link = _style$elements.link) === null || _style$elements$link === void 0 ? void 0 : _style$elements$link.color
  33434. }); // Collect inline styles for colors.
  33435. const colorStyles = (style === null || style === void 0 ? void 0 : style.color) || {};
  33436. const styleProp = getInlineStyles({
  33437. color: colorStyles
  33438. });
  33439. return {
  33440. className: className || undefined,
  33441. style: styleProp
  33442. };
  33443. }
  33444. const EMPTY_OBJECT = {};
  33445. /**
  33446. * Determines the color related props for a block derived from its color block
  33447. * support attributes.
  33448. *
  33449. * Inline styles are forced for named colors to ensure these selections are
  33450. * reflected when themes do not load their color stylesheets in the editor.
  33451. *
  33452. * @param {Object} attributes Block attributes.
  33453. *
  33454. * @return {Object} ClassName & style props from colors block support.
  33455. */
  33456. function useColorProps(attributes) {
  33457. const {
  33458. backgroundColor,
  33459. textColor,
  33460. gradient
  33461. } = attributes; // Some color settings have a special handling for deprecated flags in `useSetting`,
  33462. // so we can't unwrap them by doing const { ... } = useSetting('color')
  33463. // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
  33464. const userPalette = useSetting('color.palette.custom') || [];
  33465. const themePalette = useSetting('color.palette.theme') || [];
  33466. const defaultPalette = useSetting('color.palette.default') || [];
  33467. const gradientsPerOrigin = useSetting('color.gradients') || EMPTY_OBJECT;
  33468. const colors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
  33469. const gradients = (0,external_wp_element_namespaceObject.useMemo)(() => [...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.custom) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.theme) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.default) || [])], [gradientsPerOrigin]);
  33470. const colorProps = getColorClassesAndStyles(attributes); // Force inline styles to apply colors when themes do not load their color
  33471. // stylesheets in the editor.
  33472. if (backgroundColor) {
  33473. const backgroundColorObject = getColorObjectByAttributeValues(colors, backgroundColor);
  33474. colorProps.style.backgroundColor = backgroundColorObject.color;
  33475. }
  33476. if (gradient) {
  33477. colorProps.style.background = getGradientValueBySlug(gradients, gradient);
  33478. }
  33479. if (textColor) {
  33480. const textColorObject = getColorObjectByAttributeValues(colors, textColor);
  33481. colorProps.style.color = textColorObject.color;
  33482. }
  33483. return colorProps;
  33484. }
  33485. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-spacing-props.js
  33486. /**
  33487. * Internal dependencies
  33488. */
  33489. // This utility is intended to assist where the serialization of the spacing
  33490. // block support is being skipped for a block but the spacing related CSS
  33491. // styles still need to be generated so they can be applied to inner elements.
  33492. /**
  33493. * Provides the CSS class names and inline styles for a block's spacing support
  33494. * attributes.
  33495. *
  33496. * @param {Object} attributes Block attributes.
  33497. *
  33498. * @return {Object} Spacing block support derived CSS classes & styles.
  33499. */
  33500. function getSpacingClassesAndStyles(attributes) {
  33501. const {
  33502. style
  33503. } = attributes; // Collect inline styles for spacing.
  33504. const spacingStyles = (style === null || style === void 0 ? void 0 : style.spacing) || {};
  33505. const styleProp = getInlineStyles({
  33506. spacing: spacingStyles
  33507. });
  33508. return {
  33509. style: styleProp
  33510. };
  33511. }
  33512. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-typography-props.js
  33513. /**
  33514. * External dependencies
  33515. */
  33516. /**
  33517. * Internal dependencies
  33518. */
  33519. // This utility is intended to assist where the serialization of the typography
  33520. // block support is being skipped for a block but the typography related CSS
  33521. // styles still need to be generated so they can be applied to inner elements.
  33522. /**
  33523. * Provides the CSS class names and inline styles for a block's typography support
  33524. * attributes.
  33525. *
  33526. * @param {Object} attributes Block attributes.
  33527. * @param {boolean} isFluidFontSizeActive Whether the function should try to convert font sizes to fluid values.
  33528. *
  33529. * @return {Object} Typography block support derived CSS classes & styles.
  33530. */
  33531. function getTypographyClassesAndStyles(attributes, isFluidFontSizeActive) {
  33532. var _attributes$style;
  33533. let typographyStyles = (attributes === null || attributes === void 0 ? void 0 : (_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.typography) || {};
  33534. if (isFluidFontSizeActive) {
  33535. var _attributes$style2, _attributes$style2$ty;
  33536. typographyStyles = { ...typographyStyles,
  33537. fontSize: getComputedFluidTypographyValue({
  33538. fontSize: attributes === null || attributes === void 0 ? void 0 : (_attributes$style2 = attributes.style) === null || _attributes$style2 === void 0 ? void 0 : (_attributes$style2$ty = _attributes$style2.typography) === null || _attributes$style2$ty === void 0 ? void 0 : _attributes$style2$ty.fontSize
  33539. })
  33540. };
  33541. }
  33542. const style = getInlineStyles({
  33543. typography: typographyStyles
  33544. });
  33545. const fontFamilyClassName = !!(attributes !== null && attributes !== void 0 && attributes.fontFamily) ? `has-${(0,external_lodash_namespaceObject.kebabCase)(attributes.fontFamily)}-font-family` : '';
  33546. const className = classnames_default()(fontFamilyClassName, getFontSizeClass(attributes === null || attributes === void 0 ? void 0 : attributes.fontSize));
  33547. return {
  33548. className,
  33549. style
  33550. };
  33551. }
  33552. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-cached-truthy.js
  33553. /**
  33554. * WordPress dependencies
  33555. */
  33556. /**
  33557. * Keeps an up-to-date copy of the passed value and returns it. If value becomes falsy, it will return the last truthy copy.
  33558. *
  33559. * @param {any} value
  33560. * @return {any} value
  33561. */
  33562. function useCachedTruthy(value) {
  33563. const [cachedValue, setCachedValue] = (0,external_wp_element_namespaceObject.useState)(value);
  33564. (0,external_wp_element_namespaceObject.useEffect)(() => {
  33565. if (value) {
  33566. setCachedValue(value);
  33567. }
  33568. }, [value]);
  33569. return cachedValue;
  33570. }
  33571. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/index.js
  33572. /**
  33573. * Internal dependencies
  33574. */
  33575. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/with-colors.js
  33576. /**
  33577. * External dependencies
  33578. */
  33579. /**
  33580. * WordPress dependencies
  33581. */
  33582. /**
  33583. * Internal dependencies
  33584. */
  33585. /**
  33586. * Capitalizes the first letter in a string.
  33587. *
  33588. * @param {string} str The string whose first letter the function will capitalize.
  33589. *
  33590. * @return {string} Capitalized string.
  33591. */
  33592. const upperFirst = _ref => {
  33593. let [firstLetter, ...rest] = _ref;
  33594. return firstLetter.toUpperCase() + rest.join('');
  33595. };
  33596. /**
  33597. * Higher order component factory for injecting the `colorsArray` argument as
  33598. * the colors prop in the `withCustomColors` HOC.
  33599. *
  33600. * @param {Array} colorsArray An array of color objects.
  33601. *
  33602. * @return {Function} The higher order component.
  33603. */
  33604. const withCustomColorPalette = colorsArray => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  33605. colors: colorsArray
  33606. })), 'withCustomColorPalette');
  33607. /**
  33608. * Higher order component factory for injecting the editor colors as the
  33609. * `colors` prop in the `withColors` HOC.
  33610. *
  33611. * @return {Function} The higher order component.
  33612. */
  33613. const withEditorColorPalette = () => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
  33614. // Some color settings have a special handling for deprecated flags in `useSetting`,
  33615. // so we can't unwrap them by doing const { ... } = useSetting('color')
  33616. // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
  33617. const userPalette = useSetting('color.palette.custom');
  33618. const themePalette = useSetting('color.palette.theme');
  33619. const defaultPalette = useSetting('color.palette.default');
  33620. const allColors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
  33621. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  33622. colors: allColors
  33623. }));
  33624. }, 'withEditorColorPalette');
  33625. /**
  33626. * Helper function used with `createHigherOrderComponent` to create
  33627. * higher order components for managing color logic.
  33628. *
  33629. * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).
  33630. * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.
  33631. *
  33632. * @return {WPComponent} The component that can be used as a HOC.
  33633. */
  33634. function createColorHOC(colorTypes, withColorPalette) {
  33635. const colorMap = (0,external_lodash_namespaceObject.reduce)(colorTypes, (colorObject, colorType) => {
  33636. return { ...colorObject,
  33637. ...(typeof colorType === 'string' ? {
  33638. [colorType]: (0,external_lodash_namespaceObject.kebabCase)(colorType)
  33639. } : colorType)
  33640. };
  33641. }, {});
  33642. return (0,external_wp_compose_namespaceObject.compose)([withColorPalette, WrappedComponent => {
  33643. return class extends external_wp_element_namespaceObject.Component {
  33644. constructor(props) {
  33645. super(props);
  33646. this.setters = this.createSetters();
  33647. this.colorUtils = {
  33648. getMostReadableColor: this.getMostReadableColor.bind(this)
  33649. };
  33650. this.state = {};
  33651. }
  33652. getMostReadableColor(colorValue) {
  33653. const {
  33654. colors
  33655. } = this.props;
  33656. return getMostReadableColor(colors, colorValue);
  33657. }
  33658. createSetters() {
  33659. return (0,external_lodash_namespaceObject.reduce)(colorMap, (settersAccumulator, colorContext, colorAttributeName) => {
  33660. const upperFirstColorAttributeName = upperFirst(colorAttributeName);
  33661. const customColorAttributeName = `custom${upperFirstColorAttributeName}`;
  33662. settersAccumulator[`set${upperFirstColorAttributeName}`] = this.createSetColor(colorAttributeName, customColorAttributeName);
  33663. return settersAccumulator;
  33664. }, {});
  33665. }
  33666. createSetColor(colorAttributeName, customColorAttributeName) {
  33667. return colorValue => {
  33668. const colorObject = getColorObjectByColorValue(this.props.colors, colorValue);
  33669. this.props.setAttributes({
  33670. [colorAttributeName]: colorObject && colorObject.slug ? colorObject.slug : undefined,
  33671. [customColorAttributeName]: colorObject && colorObject.slug ? undefined : colorValue
  33672. });
  33673. };
  33674. }
  33675. static getDerivedStateFromProps(_ref2, previousState) {
  33676. let {
  33677. attributes,
  33678. colors
  33679. } = _ref2;
  33680. return (0,external_lodash_namespaceObject.reduce)(colorMap, (newState, colorContext, colorAttributeName) => {
  33681. const colorObject = getColorObjectByAttributeValues(colors, attributes[colorAttributeName], attributes[`custom${upperFirst(colorAttributeName)}`]);
  33682. const previousColorObject = previousState[colorAttributeName];
  33683. const previousColor = previousColorObject === null || previousColorObject === void 0 ? void 0 : previousColorObject.color;
  33684. /**
  33685. * The "and previousColorObject" condition checks that a previous color object was already computed.
  33686. * At the start previousColorObject and colorValue are both equal to undefined
  33687. * bus as previousColorObject does not exist we should compute the object.
  33688. */
  33689. if (previousColor === colorObject.color && previousColorObject) {
  33690. newState[colorAttributeName] = previousColorObject;
  33691. } else {
  33692. newState[colorAttributeName] = { ...colorObject,
  33693. class: getColorClassName(colorContext, colorObject.slug)
  33694. };
  33695. }
  33696. return newState;
  33697. }, {});
  33698. }
  33699. render() {
  33700. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props, {
  33701. colors: undefined
  33702. }, this.state, this.setters, {
  33703. colorUtils: this.colorUtils
  33704. }));
  33705. }
  33706. };
  33707. }]);
  33708. }
  33709. /**
  33710. * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic
  33711. * for class generation color value, retrieval and color attribute setting.
  33712. *
  33713. * Use this higher-order component to work with a custom set of colors.
  33714. *
  33715. * @example
  33716. *
  33717. * ```jsx
  33718. * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];
  33719. * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );
  33720. * // ...
  33721. * export default compose(
  33722. * withCustomColors( 'backgroundColor', 'borderColor' ),
  33723. * MyColorfulComponent,
  33724. * );
  33725. * ```
  33726. *
  33727. * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).
  33728. *
  33729. * @return {Function} Higher-order component.
  33730. */
  33731. function createCustomColorsHOC(colorsArray) {
  33732. return function () {
  33733. const withColorPalette = withCustomColorPalette(colorsArray);
  33734. for (var _len = arguments.length, colorTypes = new Array(_len), _key = 0; _key < _len; _key++) {
  33735. colorTypes[_key] = arguments[_key];
  33736. }
  33737. return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(createColorHOC(colorTypes, withColorPalette), 'withCustomColors');
  33738. };
  33739. }
  33740. /**
  33741. * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.
  33742. *
  33743. * For use with the default editor/theme color palette.
  33744. *
  33745. * @example
  33746. *
  33747. * ```jsx
  33748. * export default compose(
  33749. * withColors( 'backgroundColor', { textColor: 'color' } ),
  33750. * MyColorfulComponent,
  33751. * );
  33752. * ```
  33753. *
  33754. * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,
  33755. * it should contain the color attribute name as key and the color context as value.
  33756. * If the argument is a string the value should be the color attribute name,
  33757. * the color context is computed by applying a kebab case transform to the value.
  33758. * Color context represents the context/place where the color is going to be used.
  33759. * The class name of the color is generated using 'has' followed by the color name
  33760. * and ending with the color context all in kebab case e.g: has-green-background-color.
  33761. *
  33762. * @return {Function} Higher-order component.
  33763. */
  33764. function withColors() {
  33765. const withColorPalette = withEditorColorPalette();
  33766. for (var _len2 = arguments.length, colorTypes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  33767. colorTypes[_key2] = arguments[_key2];
  33768. }
  33769. return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(createColorHOC(colorTypes, withColorPalette), 'withColors');
  33770. }
  33771. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/index.js
  33772. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradients/index.js
  33773. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/with-font-sizes.js
  33774. /**
  33775. * External dependencies
  33776. */
  33777. /**
  33778. * WordPress dependencies
  33779. */
  33780. /**
  33781. * Internal dependencies
  33782. */
  33783. const DEFAULT_FONT_SIZES = [];
  33784. /**
  33785. * Capitalizes the first letter in a string.
  33786. *
  33787. * @param {string} str The string whose first letter the function will capitalize.
  33788. *
  33789. * @return {string} Capitalized string.
  33790. */
  33791. const with_font_sizes_upperFirst = _ref => {
  33792. let [firstLetter, ...rest] = _ref;
  33793. return firstLetter.toUpperCase() + rest.join('');
  33794. };
  33795. /**
  33796. * Higher-order component, which handles font size logic for class generation,
  33797. * font size value retrieval, and font size change handling.
  33798. *
  33799. * @param {...(Object|string)} fontSizeNames The arguments should all be strings.
  33800. * Each string contains the font size
  33801. * attribute name e.g: 'fontSize'.
  33802. *
  33803. * @return {Function} Higher-order component.
  33804. */
  33805. /* harmony default export */ var with_font_sizes = (function () {
  33806. for (var _len = arguments.length, fontSizeNames = new Array(_len), _key = 0; _key < _len; _key++) {
  33807. fontSizeNames[_key] = arguments[_key];
  33808. }
  33809. /*
  33810. * Computes an object whose key is the font size attribute name as passed in the array,
  33811. * and the value is the custom font size attribute name.
  33812. * Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized.
  33813. */
  33814. const fontSizeAttributeNames = (0,external_lodash_namespaceObject.reduce)(fontSizeNames, (fontSizeAttributeNamesAccumulator, fontSizeAttributeName) => {
  33815. fontSizeAttributeNamesAccumulator[fontSizeAttributeName] = `custom${with_font_sizes_upperFirst(fontSizeAttributeName)}`;
  33816. return fontSizeAttributeNamesAccumulator;
  33817. }, {});
  33818. return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
  33819. const fontSizes = useSetting('typography.fontSizes') || DEFAULT_FONT_SIZES;
  33820. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  33821. fontSizes: fontSizes
  33822. }));
  33823. }, 'withFontSizes'), WrappedComponent => {
  33824. return class extends external_wp_element_namespaceObject.Component {
  33825. constructor(props) {
  33826. super(props);
  33827. this.setters = this.createSetters();
  33828. this.state = {};
  33829. }
  33830. createSetters() {
  33831. return (0,external_lodash_namespaceObject.reduce)(fontSizeAttributeNames, (settersAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => {
  33832. const upperFirstFontSizeAttributeName = with_font_sizes_upperFirst(fontSizeAttributeName);
  33833. settersAccumulator[`set${upperFirstFontSizeAttributeName}`] = this.createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName);
  33834. return settersAccumulator;
  33835. }, {});
  33836. }
  33837. createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName) {
  33838. return fontSizeValue => {
  33839. const fontSizeObject = (0,external_lodash_namespaceObject.find)(this.props.fontSizes, {
  33840. size: Number(fontSizeValue)
  33841. });
  33842. this.props.setAttributes({
  33843. [fontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? fontSizeObject.slug : undefined,
  33844. [customFontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? undefined : fontSizeValue
  33845. });
  33846. };
  33847. }
  33848. static getDerivedStateFromProps(_ref2, previousState) {
  33849. let {
  33850. attributes,
  33851. fontSizes
  33852. } = _ref2;
  33853. const didAttributesChange = (customFontSizeAttributeName, fontSizeAttributeName) => {
  33854. if (previousState[fontSizeAttributeName]) {
  33855. // If new font size is name compare with the previous slug.
  33856. if (attributes[fontSizeAttributeName]) {
  33857. return attributes[fontSizeAttributeName] !== previousState[fontSizeAttributeName].slug;
  33858. } // If font size is not named, update when the font size value changes.
  33859. return previousState[fontSizeAttributeName].size !== attributes[customFontSizeAttributeName];
  33860. } // In this case we need to build the font size object.
  33861. return true;
  33862. };
  33863. if (!(0,external_lodash_namespaceObject.some)(fontSizeAttributeNames, didAttributesChange)) {
  33864. return null;
  33865. }
  33866. const newState = (0,external_lodash_namespaceObject.reduce)((0,external_lodash_namespaceObject.pickBy)(fontSizeAttributeNames, didAttributesChange), (newStateAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => {
  33867. const fontSizeAttributeValue = attributes[fontSizeAttributeName];
  33868. const fontSizeObject = getFontSize(fontSizes, fontSizeAttributeValue, attributes[customFontSizeAttributeName]);
  33869. newStateAccumulator[fontSizeAttributeName] = { ...fontSizeObject,
  33870. class: getFontSizeClass(fontSizeAttributeValue)
  33871. };
  33872. return newStateAccumulator;
  33873. }, {});
  33874. return { ...previousState,
  33875. ...newState
  33876. };
  33877. }
  33878. render() {
  33879. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props, {
  33880. fontSizes: undefined
  33881. }, this.state, this.setters));
  33882. }
  33883. };
  33884. }]), 'withFontSizes');
  33885. });
  33886. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/index.js
  33887. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/duotone/index.js
  33888. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-left.js
  33889. /**
  33890. * WordPress dependencies
  33891. */
  33892. const alignLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  33893. xmlns: "http://www.w3.org/2000/svg",
  33894. viewBox: "0 0 24 24"
  33895. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  33896. d: "M4 19.8h8.9v-1.5H4v1.5zm8.9-15.6H4v1.5h8.9V4.2zm-8.9 7v1.5h16v-1.5H4z"
  33897. }));
  33898. /* harmony default export */ var align_left = (alignLeft);
  33899. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-center.js
  33900. /**
  33901. * WordPress dependencies
  33902. */
  33903. const align_center_alignCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  33904. xmlns: "http://www.w3.org/2000/svg",
  33905. viewBox: "0 0 24 24"
  33906. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  33907. d: "M16.4 4.2H7.6v1.5h8.9V4.2zM4 11.2v1.5h16v-1.5H4zm3.6 8.6h8.9v-1.5H7.6v1.5z"
  33908. }));
  33909. /* harmony default export */ var align_center = (align_center_alignCenter);
  33910. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-right.js
  33911. /**
  33912. * WordPress dependencies
  33913. */
  33914. const alignRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  33915. xmlns: "http://www.w3.org/2000/svg",
  33916. viewBox: "0 0 24 24"
  33917. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  33918. d: "M11.1 19.8H20v-1.5h-8.9v1.5zm0-15.6v1.5H20V4.2h-8.9zM4 12.8h16v-1.5H4v1.5z"
  33919. }));
  33920. /* harmony default export */ var align_right = (alignRight);
  33921. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/alignment-control/ui.js
  33922. /**
  33923. * External dependencies
  33924. */
  33925. /**
  33926. * WordPress dependencies
  33927. */
  33928. const DEFAULT_ALIGNMENT_CONTROLS = [{
  33929. icon: align_left,
  33930. title: (0,external_wp_i18n_namespaceObject.__)('Align text left'),
  33931. align: 'left'
  33932. }, {
  33933. icon: align_center,
  33934. title: (0,external_wp_i18n_namespaceObject.__)('Align text center'),
  33935. align: 'center'
  33936. }, {
  33937. icon: align_right,
  33938. title: (0,external_wp_i18n_namespaceObject.__)('Align text right'),
  33939. align: 'right'
  33940. }];
  33941. const ui_POPOVER_PROPS = {
  33942. position: 'bottom right',
  33943. isAlternate: true
  33944. };
  33945. function AlignmentUI(_ref) {
  33946. let {
  33947. value,
  33948. onChange,
  33949. alignmentControls = DEFAULT_ALIGNMENT_CONTROLS,
  33950. label = (0,external_wp_i18n_namespaceObject.__)('Align'),
  33951. describedBy = (0,external_wp_i18n_namespaceObject.__)('Change text alignment'),
  33952. isCollapsed = true,
  33953. isToolbar
  33954. } = _ref;
  33955. function applyOrUnset(align) {
  33956. return () => onChange(value === align ? undefined : align);
  33957. }
  33958. const activeAlignment = (0,external_lodash_namespaceObject.find)(alignmentControls, control => control.align === value);
  33959. function setIcon() {
  33960. if (activeAlignment) return activeAlignment.icon;
  33961. return (0,external_wp_i18n_namespaceObject.isRTL)() ? align_right : align_left;
  33962. }
  33963. const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
  33964. const extraProps = isToolbar ? {
  33965. isCollapsed
  33966. } : {
  33967. toggleProps: {
  33968. describedBy
  33969. },
  33970. popoverProps: ui_POPOVER_PROPS
  33971. };
  33972. return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({
  33973. icon: setIcon(),
  33974. label: label,
  33975. controls: alignmentControls.map(control => {
  33976. const {
  33977. align
  33978. } = control;
  33979. const isActive = value === align;
  33980. return { ...control,
  33981. isActive,
  33982. role: isCollapsed ? 'menuitemradio' : undefined,
  33983. onClick: applyOrUnset(align)
  33984. };
  33985. })
  33986. }, extraProps));
  33987. }
  33988. /* harmony default export */ var alignment_control_ui = (AlignmentUI);
  33989. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/alignment-control/index.js
  33990. /**
  33991. * Internal dependencies
  33992. */
  33993. const AlignmentControl = props => {
  33994. return (0,external_wp_element_namespaceObject.createElement)(alignment_control_ui, _extends({}, props, {
  33995. isToolbar: false
  33996. }));
  33997. };
  33998. const AlignmentToolbar = props => {
  33999. return (0,external_wp_element_namespaceObject.createElement)(alignment_control_ui, _extends({}, props, {
  34000. isToolbar: true
  34001. }));
  34002. };
  34003. /**
  34004. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/alignment-control/README.md
  34005. */
  34006. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/autocompleters/block.js
  34007. /**
  34008. * External dependencies
  34009. */
  34010. /**
  34011. * WordPress dependencies
  34012. */
  34013. /**
  34014. * Internal dependencies
  34015. */
  34016. const block_noop = () => {};
  34017. const block_SHOWN_BLOCK_TYPES = 9;
  34018. /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
  34019. /**
  34020. * Creates a blocks repeater for replacing the current block with a selected block type.
  34021. *
  34022. * @return {WPCompleter} A blocks completer.
  34023. */
  34024. function createBlockCompleter() {
  34025. return {
  34026. name: 'blocks',
  34027. className: 'block-editor-autocompleters__block',
  34028. triggerPrefix: '/',
  34029. useItems(filterValue) {
  34030. const {
  34031. rootClientId,
  34032. selectedBlockName
  34033. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  34034. const {
  34035. getSelectedBlockClientId,
  34036. getBlockName,
  34037. getBlockInsertionPoint
  34038. } = select(store);
  34039. const selectedBlockClientId = getSelectedBlockClientId();
  34040. return {
  34041. selectedBlockName: selectedBlockClientId ? getBlockName(selectedBlockClientId) : null,
  34042. rootClientId: getBlockInsertionPoint().rootClientId
  34043. };
  34044. }, []);
  34045. const [items, categories, collections] = use_block_types_state(rootClientId, block_noop);
  34046. const filteredItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
  34047. const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : (0,external_lodash_namespaceObject.orderBy)(items, ['frecency'], ['desc']);
  34048. return initialFilteredItems.filter(item => item.name !== selectedBlockName).slice(0, block_SHOWN_BLOCK_TYPES);
  34049. }, [filterValue, selectedBlockName, items, categories, collections]);
  34050. const options = (0,external_wp_element_namespaceObject.useMemo)(() => filteredItems.map(blockItem => {
  34051. const {
  34052. title,
  34053. icon,
  34054. isDisabled
  34055. } = blockItem;
  34056. return {
  34057. key: `block-${blockItem.id}`,
  34058. value: blockItem,
  34059. label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  34060. key: "icon",
  34061. icon: icon,
  34062. showColors: true
  34063. }), title),
  34064. isDisabled
  34065. };
  34066. }), [filteredItems]);
  34067. return [options];
  34068. },
  34069. allowContext(before, after) {
  34070. return !(/\S/.test(before) || /\S/.test(after));
  34071. },
  34072. getOptionCompletion(inserterItem) {
  34073. const {
  34074. name,
  34075. initialAttributes,
  34076. innerBlocks
  34077. } = inserterItem;
  34078. return {
  34079. action: 'replace',
  34080. value: (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(innerBlocks))
  34081. };
  34082. }
  34083. };
  34084. }
  34085. /**
  34086. * Creates a blocks repeater for replacing the current block with a selected block type.
  34087. *
  34088. * @return {WPCompleter} A blocks completer.
  34089. */
  34090. /* harmony default export */ var autocompleters_block = (createBlockCompleter());
  34091. ;// CONCATENATED MODULE: external ["wp","apiFetch"]
  34092. var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
  34093. var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
  34094. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js
  34095. /**
  34096. * WordPress dependencies
  34097. */
  34098. const page = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  34099. xmlns: "http://www.w3.org/2000/svg",
  34100. viewBox: "0 0 24 24"
  34101. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  34102. d: "M7 5.5h10a.5.5 0 01.5.5v12a.5.5 0 01-.5.5H7a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM17 4H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V6a2 2 0 00-2-2zm-1 3.75H8v1.5h8v-1.5zM8 11h8v1.5H8V11zm6 3.25H8v1.5h6v-1.5z"
  34103. }));
  34104. /* harmony default export */ var library_page = (page);
  34105. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post.js
  34106. /**
  34107. * WordPress dependencies
  34108. */
  34109. const post = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  34110. xmlns: "http://www.w3.org/2000/svg",
  34111. viewBox: "0 0 24 24"
  34112. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  34113. d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z"
  34114. }));
  34115. /* harmony default export */ var library_post = (post);
  34116. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/autocompleters/link.js
  34117. /**
  34118. * WordPress dependencies
  34119. */
  34120. const SHOWN_SUGGESTIONS = 10;
  34121. /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
  34122. /**
  34123. * Creates a suggestion list for links to posts or pages.
  34124. *
  34125. * @return {WPCompleter} A links completer.
  34126. */
  34127. function createLinkCompleter() {
  34128. return {
  34129. name: 'links',
  34130. className: 'block-editor-autocompleters__link',
  34131. triggerPrefix: '[[',
  34132. options: async letters => {
  34133. let options = await external_wp_apiFetch_default()({
  34134. path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
  34135. per_page: SHOWN_SUGGESTIONS,
  34136. search: letters,
  34137. type: 'post',
  34138. order_by: 'menu_order'
  34139. })
  34140. });
  34141. options = options.filter(option => option.title !== '');
  34142. return options;
  34143. },
  34144. getOptionKeywords(item) {
  34145. const expansionWords = item.title.split(/\s+/);
  34146. return [...expansionWords];
  34147. },
  34148. getOptionLabel(item) {
  34149. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  34150. key: "icon",
  34151. icon: item.subtype === 'page' ? library_page : library_post
  34152. }), item.title);
  34153. },
  34154. getOptionCompletion(item) {
  34155. return (0,external_wp_element_namespaceObject.createElement)("a", {
  34156. href: item.url
  34157. }, item.title);
  34158. }
  34159. };
  34160. }
  34161. /**
  34162. * Creates a suggestion list for links to posts or pages..
  34163. *
  34164. * @return {WPCompleter} A link completer.
  34165. */
  34166. /* harmony default export */ var autocompleters_link = (createLinkCompleter());
  34167. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/autocomplete/index.js
  34168. /**
  34169. * External dependencies
  34170. */
  34171. /**
  34172. * WordPress dependencies
  34173. */
  34174. /**
  34175. * Internal dependencies
  34176. */
  34177. /**
  34178. * Shared reference to an empty array for cases where it is important to avoid
  34179. * returning a new array reference on every invocation.
  34180. *
  34181. * @type {Array}
  34182. */
  34183. const autocomplete_EMPTY_ARRAY = [];
  34184. function useCompleters(_ref) {
  34185. let {
  34186. completers = autocomplete_EMPTY_ARRAY
  34187. } = _ref;
  34188. const {
  34189. name
  34190. } = useBlockEditContext();
  34191. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  34192. let filteredCompleters = [...completers, autocompleters_link];
  34193. if (name === (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() || (0,external_wp_blocks_namespaceObject.getBlockSupport)(name, '__experimentalSlashInserter', false)) {
  34194. filteredCompleters = [...filteredCompleters, autocompleters_block];
  34195. }
  34196. if ((0,external_wp_hooks_namespaceObject.hasFilter)('editor.Autocomplete.completers')) {
  34197. // Provide copies so filters may directly modify them.
  34198. if (filteredCompleters === completers) {
  34199. filteredCompleters = filteredCompleters.map(external_lodash_namespaceObject.clone);
  34200. }
  34201. filteredCompleters = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.Autocomplete.completers', filteredCompleters, name);
  34202. }
  34203. return filteredCompleters;
  34204. }, [completers, name]);
  34205. }
  34206. function useBlockEditorAutocompleteProps(props) {
  34207. return (0,external_wp_components_namespaceObject.__unstableUseAutocompleteProps)({ ...props,
  34208. completers: useCompleters(props)
  34209. });
  34210. }
  34211. /**
  34212. * Wrap the default Autocomplete component with one that supports a filter hook
  34213. * for customizing its list of autocompleters.
  34214. *
  34215. * @type {import('react').FC}
  34216. */
  34217. function BlockEditorAutocomplete(props) {
  34218. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Autocomplete, _extends({}, props, {
  34219. completers: useCompleters(props)
  34220. }));
  34221. }
  34222. /**
  34223. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/autocomplete/README.md
  34224. */
  34225. /* harmony default export */ var autocomplete = (BlockEditorAutocomplete);
  34226. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/fullscreen.js
  34227. /**
  34228. * WordPress dependencies
  34229. */
  34230. const fullscreen = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  34231. xmlns: "http://www.w3.org/2000/svg",
  34232. viewBox: "0 0 24 24"
  34233. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  34234. d: "M4.2 9h1.5V5.8H9V4.2H4.2V9zm14 9.2H15v1.5h4.8V15h-1.5v3.2zM15 4.2v1.5h3.2V9h1.5V4.2H15zM5.8 15H4.2v4.8H9v-1.5H5.8V15z"
  34235. }));
  34236. /* harmony default export */ var library_fullscreen = (fullscreen);
  34237. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-full-height-alignment-control/index.js
  34238. /**
  34239. * WordPress dependencies
  34240. */
  34241. function BlockFullHeightAlignmentControl(_ref) {
  34242. let {
  34243. isActive,
  34244. label = (0,external_wp_i18n_namespaceObject.__)('Toggle full height'),
  34245. onToggle,
  34246. isDisabled
  34247. } = _ref;
  34248. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  34249. isActive: isActive,
  34250. icon: library_fullscreen,
  34251. label: label,
  34252. onClick: () => onToggle(!isActive),
  34253. disabled: isDisabled
  34254. });
  34255. }
  34256. /* harmony default export */ var block_full_height_alignment_control = (BlockFullHeightAlignmentControl);
  34257. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-matrix-control/index.js
  34258. /**
  34259. * WordPress dependencies
  34260. */
  34261. const block_alignment_matrix_control_noop = () => {};
  34262. function BlockAlignmentMatrixControl(props) {
  34263. const {
  34264. label = (0,external_wp_i18n_namespaceObject.__)('Change matrix alignment'),
  34265. onChange = block_alignment_matrix_control_noop,
  34266. value = 'center',
  34267. isDisabled
  34268. } = props;
  34269. const icon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalAlignmentMatrixControl.Icon, {
  34270. value: value
  34271. });
  34272. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  34273. position: "bottom right",
  34274. popoverProps: {
  34275. isAlternate: true
  34276. },
  34277. renderToggle: _ref => {
  34278. let {
  34279. onToggle,
  34280. isOpen
  34281. } = _ref;
  34282. const openOnArrowDown = event => {
  34283. if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
  34284. event.preventDefault();
  34285. onToggle();
  34286. }
  34287. };
  34288. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  34289. onClick: onToggle,
  34290. "aria-haspopup": "true",
  34291. "aria-expanded": isOpen,
  34292. onKeyDown: openOnArrowDown,
  34293. label: label,
  34294. icon: icon,
  34295. showTooltip: true,
  34296. disabled: isDisabled
  34297. });
  34298. },
  34299. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalAlignmentMatrixControl, {
  34300. hasFocusBorder: false,
  34301. onChange: onChange,
  34302. value: value
  34303. })
  34304. });
  34305. }
  34306. /* harmony default export */ var block_alignment_matrix_control = (BlockAlignmentMatrixControl);
  34307. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right-small.js
  34308. /**
  34309. * WordPress dependencies
  34310. */
  34311. const chevronRightSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  34312. xmlns: "http://www.w3.org/2000/svg",
  34313. viewBox: "0 0 24 24"
  34314. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  34315. d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"
  34316. }));
  34317. /* harmony default export */ var chevron_right_small = (chevronRightSmall);
  34318. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-breadcrumb/index.js
  34319. /**
  34320. * WordPress dependencies
  34321. */
  34322. /**
  34323. * Internal dependencies
  34324. */
  34325. /**
  34326. * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.
  34327. *
  34328. * @param {Object} props Component props.
  34329. * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.
  34330. * @return {WPElement} Block Breadcrumb.
  34331. */
  34332. function BlockBreadcrumb(_ref) {
  34333. let {
  34334. rootLabelText
  34335. } = _ref;
  34336. const {
  34337. selectBlock,
  34338. clearSelectedBlock
  34339. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  34340. const {
  34341. clientId,
  34342. parents,
  34343. hasSelection
  34344. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  34345. const {
  34346. getSelectionStart,
  34347. getSelectedBlockClientId,
  34348. getBlockParents
  34349. } = select(store);
  34350. const selectedBlockClientId = getSelectedBlockClientId();
  34351. return {
  34352. parents: getBlockParents(selectedBlockClientId),
  34353. clientId: selectedBlockClientId,
  34354. hasSelection: !!getSelectionStart().clientId
  34355. };
  34356. }, []);
  34357. const rootLabel = rootLabelText || (0,external_wp_i18n_namespaceObject.__)('Document');
  34358. /*
  34359. * Disable reason: The `list` ARIA role is redundant but
  34360. * Safari+VoiceOver won't announce the list otherwise.
  34361. */
  34362. /* eslint-disable jsx-a11y/no-redundant-roles */
  34363. return (0,external_wp_element_namespaceObject.createElement)("ul", {
  34364. className: "block-editor-block-breadcrumb",
  34365. role: "list",
  34366. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block breadcrumb')
  34367. }, (0,external_wp_element_namespaceObject.createElement)("li", {
  34368. className: !hasSelection ? 'block-editor-block-breadcrumb__current' : undefined,
  34369. "aria-current": !hasSelection ? 'true' : undefined
  34370. }, hasSelection && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  34371. className: "block-editor-block-breadcrumb__button",
  34372. variant: "tertiary",
  34373. onClick: clearSelectedBlock
  34374. }, rootLabel), !hasSelection && rootLabel, !!clientId && (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  34375. icon: chevron_right_small,
  34376. className: "block-editor-block-breadcrumb__separator"
  34377. })), parents.map(parentClientId => (0,external_wp_element_namespaceObject.createElement)("li", {
  34378. key: parentClientId
  34379. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  34380. className: "block-editor-block-breadcrumb__button",
  34381. variant: "tertiary",
  34382. onClick: () => selectBlock(parentClientId)
  34383. }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
  34384. clientId: parentClientId,
  34385. maximumLength: 35
  34386. })), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  34387. icon: chevron_right_small,
  34388. className: "block-editor-block-breadcrumb__separator"
  34389. }))), !!clientId && (0,external_wp_element_namespaceObject.createElement)("li", {
  34390. className: "block-editor-block-breadcrumb__current",
  34391. "aria-current": "true"
  34392. }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
  34393. clientId: clientId,
  34394. maximumLength: 35
  34395. })))
  34396. /* eslint-enable jsx-a11y/no-redundant-roles */
  34397. ;
  34398. }
  34399. /* harmony default export */ var block_breadcrumb = (BlockBreadcrumb);
  34400. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-style-selector/index.js
  34401. /**
  34402. * WordPress dependencies
  34403. */
  34404. const ColorSelectorSVGIcon = () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  34405. xmlns: "https://www.w3.org/2000/svg",
  34406. viewBox: "0 0 20 20"
  34407. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  34408. d: "M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z"
  34409. }));
  34410. /**
  34411. * Color Selector Icon component.
  34412. *
  34413. * @param {Object} props Component properties.
  34414. * @param {Object} props.style Style object.
  34415. * @param {string} props.className Class name for component.
  34416. *
  34417. * @return {*} React Icon component.
  34418. */
  34419. const ColorSelectorIcon = _ref => {
  34420. let {
  34421. style,
  34422. className
  34423. } = _ref;
  34424. return (0,external_wp_element_namespaceObject.createElement)("div", {
  34425. className: "block-library-colors-selector__icon-container"
  34426. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  34427. className: `${className} block-library-colors-selector__state-selection`,
  34428. style: style
  34429. }, (0,external_wp_element_namespaceObject.createElement)(ColorSelectorSVGIcon, null)));
  34430. };
  34431. /**
  34432. * Renders the Colors Selector Toolbar with the icon button.
  34433. *
  34434. * @param {Object} props Component properties.
  34435. * @param {Object} props.TextColor Text color component that wraps icon.
  34436. * @param {Object} props.BackgroundColor Background color component that wraps icon.
  34437. *
  34438. * @return {*} React toggle button component.
  34439. */
  34440. const renderToggleComponent = _ref2 => {
  34441. let {
  34442. TextColor,
  34443. BackgroundColor
  34444. } = _ref2;
  34445. return _ref3 => {
  34446. let {
  34447. onToggle,
  34448. isOpen
  34449. } = _ref3;
  34450. const openOnArrowDown = event => {
  34451. if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
  34452. event.preventDefault();
  34453. onToggle();
  34454. }
  34455. };
  34456. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  34457. className: "components-toolbar__control block-library-colors-selector__toggle",
  34458. label: (0,external_wp_i18n_namespaceObject.__)('Open Colors Selector'),
  34459. onClick: onToggle,
  34460. onKeyDown: openOnArrowDown,
  34461. icon: (0,external_wp_element_namespaceObject.createElement)(BackgroundColor, null, (0,external_wp_element_namespaceObject.createElement)(TextColor, null, (0,external_wp_element_namespaceObject.createElement)(ColorSelectorIcon, null)))
  34462. }));
  34463. };
  34464. };
  34465. const BlockColorsStyleSelector = _ref4 => {
  34466. let {
  34467. children,
  34468. ...other
  34469. } = _ref4;
  34470. external_wp_deprecated_default()(`wp.blockEditor.BlockColorsStyleSelector`, {
  34471. alternative: 'block supports API',
  34472. since: '6.1',
  34473. version: '6.3'
  34474. });
  34475. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  34476. position: "bottom right",
  34477. className: "block-library-colors-selector",
  34478. contentClassName: "block-library-colors-selector__popover",
  34479. renderToggle: renderToggleComponent(other),
  34480. renderContent: () => children
  34481. });
  34482. };
  34483. /* harmony default export */ var color_style_selector = (BlockColorsStyleSelector);
  34484. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/list-view.js
  34485. /**
  34486. * WordPress dependencies
  34487. */
  34488. const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  34489. viewBox: "0 0 24 24",
  34490. xmlns: "http://www.w3.org/2000/svg"
  34491. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  34492. d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
  34493. }));
  34494. /* harmony default export */ var list_view = (listView);
  34495. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/leaf.js
  34496. /**
  34497. * External dependencies
  34498. */
  34499. /**
  34500. * WordPress dependencies
  34501. */
  34502. /**
  34503. * Internal dependencies
  34504. */
  34505. const AnimatedTreeGridRow = animated(external_wp_components_namespaceObject.__experimentalTreeGridRow);
  34506. function ListViewLeaf(_ref) {
  34507. let {
  34508. isSelected,
  34509. position,
  34510. level,
  34511. rowCount,
  34512. children,
  34513. className,
  34514. path,
  34515. ...props
  34516. } = _ref;
  34517. const ref = use_moving_animation({
  34518. isSelected,
  34519. adjustScrolling: false,
  34520. enableAnimation: true,
  34521. triggerAnimationOnChange: path
  34522. });
  34523. return (0,external_wp_element_namespaceObject.createElement)(AnimatedTreeGridRow, _extends({
  34524. ref: ref,
  34525. className: classnames_default()('block-editor-list-view-leaf', className),
  34526. level: level,
  34527. positionInSet: position,
  34528. setSize: rowCount
  34529. }, props), children);
  34530. }
  34531. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left-small.js
  34532. /**
  34533. * WordPress dependencies
  34534. */
  34535. const chevronLeftSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  34536. xmlns: "http://www.w3.org/2000/svg",
  34537. viewBox: "0 0 24 24"
  34538. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  34539. d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z"
  34540. }));
  34541. /* harmony default export */ var chevron_left_small = (chevronLeftSmall);
  34542. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/expander.js
  34543. /**
  34544. * WordPress dependencies
  34545. */
  34546. function ListViewExpander(_ref) {
  34547. let {
  34548. onClick
  34549. } = _ref;
  34550. return (// Keyboard events are handled by TreeGrid see: components/src/tree-grid/index.js
  34551. //
  34552. // The expander component is implemented as a pseudo element in the w3 example
  34553. // https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html
  34554. //
  34555. // We've mimicked this by adding an icon with aria-hidden set to true to hide this from the accessibility tree.
  34556. // For the current tree grid implementation, please do not try to make this a button.
  34557. //
  34558. // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
  34559. (0,external_wp_element_namespaceObject.createElement)("span", {
  34560. className: "block-editor-list-view__expander",
  34561. onClick: event => onClick(event, {
  34562. forceToggle: true
  34563. }),
  34564. "aria-hidden": "true"
  34565. }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  34566. icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left_small : chevron_right_small
  34567. }))
  34568. );
  34569. }
  34570. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/block-select-button.js
  34571. /**
  34572. * External dependencies
  34573. */
  34574. /**
  34575. * WordPress dependencies
  34576. */
  34577. /**
  34578. * Internal dependencies
  34579. */
  34580. function ListViewBlockSelectButton(_ref, ref) {
  34581. let {
  34582. className,
  34583. block: {
  34584. clientId
  34585. },
  34586. onClick,
  34587. onToggleExpanded,
  34588. tabIndex,
  34589. onFocus,
  34590. onDragStart,
  34591. onDragEnd,
  34592. draggable
  34593. } = _ref;
  34594. const blockInformation = useBlockDisplayInformation(clientId);
  34595. const blockTitle = useBlockDisplayTitle({
  34596. clientId,
  34597. context: 'list-view'
  34598. });
  34599. const {
  34600. isLocked
  34601. } = useBlockLock(clientId); // The `href` attribute triggers the browser's native HTML drag operations.
  34602. // When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
  34603. // We need to clear any HTML drag data to prevent `pasteHandler` from firing
  34604. // inside the `useOnBlockDrop` hook.
  34605. const onDragStartHandler = event => {
  34606. event.dataTransfer.clearData();
  34607. onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(event);
  34608. };
  34609. function onKeyDownHandler(event) {
  34610. if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER || event.keyCode === external_wp_keycodes_namespaceObject.SPACE) {
  34611. onClick(event);
  34612. }
  34613. }
  34614. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  34615. className: classnames_default()('block-editor-list-view-block-select-button', className),
  34616. onClick: onClick,
  34617. onKeyDown: onKeyDownHandler,
  34618. ref: ref,
  34619. tabIndex: tabIndex,
  34620. onFocus: onFocus,
  34621. onDragStart: onDragStartHandler,
  34622. onDragEnd: onDragEnd,
  34623. draggable: draggable,
  34624. href: `#block-${clientId}`,
  34625. "aria-hidden": true
  34626. }, (0,external_wp_element_namespaceObject.createElement)(ListViewExpander, {
  34627. onClick: onToggleExpanded
  34628. }), (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  34629. icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
  34630. showColors: true
  34631. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
  34632. alignment: "center",
  34633. className: "block-editor-list-view-block-select-button__label-wrapper",
  34634. justify: "flex-start",
  34635. spacing: 1
  34636. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  34637. className: "block-editor-list-view-block-select-button__title"
  34638. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, {
  34639. ellipsizeMode: "auto"
  34640. }, blockTitle)), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && (0,external_wp_element_namespaceObject.createElement)("span", {
  34641. className: "block-editor-list-view-block-select-button__anchor-wrapper"
  34642. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, {
  34643. className: "block-editor-list-view-block-select-button__anchor",
  34644. ellipsizeMode: "auto"
  34645. }, blockInformation.anchor)), isLocked && (0,external_wp_element_namespaceObject.createElement)("span", {
  34646. className: "block-editor-list-view-block-select-button__lock"
  34647. }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  34648. icon: library_lock
  34649. })))));
  34650. }
  34651. /* harmony default export */ var block_select_button = ((0,external_wp_element_namespaceObject.forwardRef)(ListViewBlockSelectButton));
  34652. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/block-contents.js
  34653. /**
  34654. * External dependencies
  34655. */
  34656. /**
  34657. * WordPress dependencies
  34658. */
  34659. /**
  34660. * Internal dependencies
  34661. */
  34662. const ListViewBlockContents = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => {
  34663. let {
  34664. onClick,
  34665. onToggleExpanded,
  34666. block,
  34667. isSelected,
  34668. position,
  34669. siblingBlockCount,
  34670. level,
  34671. isExpanded,
  34672. selectedClientIds,
  34673. ...props
  34674. } = _ref;
  34675. const {
  34676. clientId
  34677. } = block;
  34678. const {
  34679. blockMovingClientId,
  34680. selectedBlockInBlockEditor
  34681. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  34682. const {
  34683. hasBlockMovingClientId,
  34684. getSelectedBlockClientId
  34685. } = select(store);
  34686. return {
  34687. blockMovingClientId: hasBlockMovingClientId(),
  34688. selectedBlockInBlockEditor: getSelectedBlockClientId()
  34689. };
  34690. }, [clientId]);
  34691. const isBlockMoveTarget = blockMovingClientId && selectedBlockInBlockEditor === clientId;
  34692. const className = classnames_default()('block-editor-list-view-block-contents', {
  34693. 'is-dropping-before': isBlockMoveTarget
  34694. }); // Only include all selected blocks if the currently clicked on block
  34695. // is one of the selected blocks. This ensures that if a user attempts
  34696. // to drag a block that isn't part of the selection, they're still able
  34697. // to drag it and rearrange its position.
  34698. const draggableClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
  34699. return (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
  34700. clientIds: draggableClientIds
  34701. }, _ref2 => {
  34702. let {
  34703. draggable,
  34704. onDragStart,
  34705. onDragEnd
  34706. } = _ref2;
  34707. return (0,external_wp_element_namespaceObject.createElement)(block_select_button, _extends({
  34708. ref: ref,
  34709. className: className,
  34710. block: block,
  34711. onClick: onClick,
  34712. onToggleExpanded: onToggleExpanded,
  34713. isSelected: isSelected,
  34714. position: position,
  34715. siblingBlockCount: siblingBlockCount,
  34716. level: level,
  34717. draggable: draggable,
  34718. onDragStart: onDragStart,
  34719. onDragEnd: onDragEnd,
  34720. isExpanded: isExpanded
  34721. }, props));
  34722. });
  34723. });
  34724. /* harmony default export */ var block_contents = (ListViewBlockContents);
  34725. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/context.js
  34726. /**
  34727. * WordPress dependencies
  34728. */
  34729. const ListViewContext = (0,external_wp_element_namespaceObject.createContext)({});
  34730. const useListViewContext = () => (0,external_wp_element_namespaceObject.useContext)(ListViewContext);
  34731. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/utils.js
  34732. /**
  34733. * WordPress dependencies
  34734. */
  34735. const getBlockPositionDescription = (position, siblingCount, level) => (0,external_wp_i18n_namespaceObject.sprintf)(
  34736. /* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */
  34737. (0,external_wp_i18n_namespaceObject.__)('Block %1$d of %2$d, Level %3$d'), position, siblingCount, level);
  34738. /**
  34739. * Returns true if the client ID occurs within the block selection or multi-selection,
  34740. * or false otherwise.
  34741. *
  34742. * @param {string} clientId Block client ID.
  34743. * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.
  34744. *
  34745. * @return {boolean} Whether the block is in multi-selection set.
  34746. */
  34747. const isClientIdSelected = (clientId, selectedBlockClientIds) => Array.isArray(selectedBlockClientIds) && selectedBlockClientIds.length ? selectedBlockClientIds.indexOf(clientId) !== -1 : selectedBlockClientIds === clientId;
  34748. /**
  34749. * From a start and end clientId of potentially different nesting levels,
  34750. * return the nearest-depth ids that have a common level of depth in the
  34751. * nesting hierarchy. For multiple block selection, this ensure that the
  34752. * selection is always at the same nesting level, and not split across
  34753. * separate levels.
  34754. *
  34755. * @param {string} startId The first id of a selection.
  34756. * @param {string} endId The end id of a selection, usually one that has been clicked on.
  34757. * @param {string[]} startParents An array of ancestor ids for the start id, in descending order.
  34758. * @param {string[]} endParents An array of ancestor ids for the end id, in descending order.
  34759. * @return {Object} An object containing the start and end ids.
  34760. */
  34761. function getCommonDepthClientIds(startId, endId, startParents, endParents) {
  34762. const startPath = [...startParents, startId];
  34763. const endPath = [...endParents, endId];
  34764. const depth = Math.min(startPath.length, endPath.length) - 1;
  34765. const start = startPath[depth];
  34766. const end = endPath[depth];
  34767. return {
  34768. start,
  34769. end
  34770. };
  34771. }
  34772. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/block.js
  34773. /**
  34774. * External dependencies
  34775. */
  34776. /**
  34777. * WordPress dependencies
  34778. */
  34779. /**
  34780. * Internal dependencies
  34781. */
  34782. function ListViewBlock(_ref) {
  34783. let {
  34784. block,
  34785. isDragged,
  34786. isSelected,
  34787. isBranchSelected,
  34788. selectBlock,
  34789. position,
  34790. level,
  34791. rowCount,
  34792. siblingBlockCount,
  34793. showBlockMovers,
  34794. path,
  34795. isExpanded,
  34796. selectedClientIds,
  34797. preventAnnouncement
  34798. } = _ref;
  34799. const cellRef = (0,external_wp_element_namespaceObject.useRef)(null);
  34800. const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false);
  34801. const {
  34802. clientId
  34803. } = block;
  34804. const {
  34805. isLocked,
  34806. isContentLocked
  34807. } = useBlockLock(clientId);
  34808. const forceSelectionContentLock = (0,external_wp_data_namespaceObject.useSelect)(select => {
  34809. if (isSelected) {
  34810. return false;
  34811. }
  34812. if (!isContentLocked) {
  34813. return false;
  34814. }
  34815. return select(store).hasSelectedInnerBlock(clientId, true);
  34816. }, [isContentLocked, clientId, isSelected]);
  34817. const isFirstSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[0] === clientId;
  34818. const isLastSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[selectedClientIds.length - 1] === clientId;
  34819. const {
  34820. toggleBlockHighlight
  34821. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  34822. const blockInformation = useBlockDisplayInformation(clientId);
  34823. const blockName = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlockName(clientId), [clientId]); // When a block hides its toolbar it also hides the block settings menu,
  34824. // since that menu is part of the toolbar in the editor canvas.
  34825. // List View respects this by also hiding the block settings menu.
  34826. const showBlockActions = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, '__experimentalToolbar', true);
  34827. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewBlock);
  34828. const descriptionId = `list-view-block-select-button__${instanceId}`;
  34829. const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
  34830. let blockAriaLabel = (0,external_wp_i18n_namespaceObject.__)('Link');
  34831. if (blockInformation) {
  34832. blockAriaLabel = isLocked ? (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: The title of the block. This string indicates a link to select the locked block.
  34833. (0,external_wp_i18n_namespaceObject.__)('%s link (locked)'), blockInformation.title) : (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: The title of the block. This string indicates a link to select the block.
  34834. (0,external_wp_i18n_namespaceObject.__)('%s link'), blockInformation.title);
  34835. }
  34836. const settingsAriaLabel = blockInformation ? (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: The title of the block.
  34837. (0,external_wp_i18n_namespaceObject.__)('Options for %s block'), blockInformation.title) : (0,external_wp_i18n_namespaceObject.__)('Options');
  34838. const {
  34839. isTreeGridMounted,
  34840. expand,
  34841. collapse
  34842. } = useListViewContext();
  34843. const hasSiblings = siblingBlockCount > 0;
  34844. const hasRenderedMovers = showBlockMovers && hasSiblings;
  34845. const moverCellClassName = classnames_default()('block-editor-list-view-block__mover-cell', {
  34846. 'is-visible': isHovered || isSelected
  34847. });
  34848. const listViewBlockSettingsClassName = classnames_default()('block-editor-list-view-block__menu-cell', {
  34849. 'is-visible': isHovered || isFirstSelectedBlock
  34850. }); // If ListView has experimental features related to the Persistent List View,
  34851. // only focus the selected list item on mount; otherwise the list would always
  34852. // try to steal the focus from the editor canvas.
  34853. (0,external_wp_element_namespaceObject.useEffect)(() => {
  34854. if (!isTreeGridMounted && isSelected) {
  34855. cellRef.current.focus();
  34856. }
  34857. }, []);
  34858. const onMouseEnter = (0,external_wp_element_namespaceObject.useCallback)(() => {
  34859. setIsHovered(true);
  34860. toggleBlockHighlight(clientId, true);
  34861. }, [clientId, setIsHovered, toggleBlockHighlight]);
  34862. const onMouseLeave = (0,external_wp_element_namespaceObject.useCallback)(() => {
  34863. setIsHovered(false);
  34864. toggleBlockHighlight(clientId, false);
  34865. }, [clientId, setIsHovered, toggleBlockHighlight]);
  34866. const selectEditorBlock = (0,external_wp_element_namespaceObject.useCallback)(event => {
  34867. selectBlock(event, clientId);
  34868. event.preventDefault();
  34869. }, [clientId, selectBlock]);
  34870. const updateSelection = (0,external_wp_element_namespaceObject.useCallback)(newClientId => {
  34871. selectBlock(undefined, newClientId);
  34872. }, [selectBlock]);
  34873. const toggleExpanded = (0,external_wp_element_namespaceObject.useCallback)(event => {
  34874. // Prevent shift+click from opening link in a new window when toggling.
  34875. event.preventDefault();
  34876. event.stopPropagation();
  34877. if (isExpanded === true) {
  34878. collapse(clientId);
  34879. } else if (isExpanded === false) {
  34880. expand(clientId);
  34881. }
  34882. }, [clientId, expand, collapse, isExpanded]);
  34883. let colSpan;
  34884. if (hasRenderedMovers) {
  34885. colSpan = 2;
  34886. } else if (!showBlockActions) {
  34887. colSpan = 3;
  34888. }
  34889. const classes = classnames_default()({
  34890. 'is-selected': isSelected || forceSelectionContentLock,
  34891. 'is-first-selected': isFirstSelectedBlock,
  34892. 'is-last-selected': isLastSelectedBlock,
  34893. 'is-branch-selected': isBranchSelected,
  34894. 'is-dragging': isDragged,
  34895. 'has-single-cell': !showBlockActions
  34896. }); // Only include all selected blocks if the currently clicked on block
  34897. // is one of the selected blocks. This ensures that if a user attempts
  34898. // to alter a block that isn't part of the selection, they're still able
  34899. // to do so.
  34900. const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
  34901. return (0,external_wp_element_namespaceObject.createElement)(ListViewLeaf, {
  34902. className: classes,
  34903. onMouseEnter: onMouseEnter,
  34904. onMouseLeave: onMouseLeave,
  34905. onFocus: onMouseEnter,
  34906. onBlur: onMouseLeave,
  34907. level: level,
  34908. position: position,
  34909. rowCount: rowCount,
  34910. path: path,
  34911. id: `list-view-block-${clientId}`,
  34912. "data-block": clientId,
  34913. isExpanded: isContentLocked ? undefined : isExpanded,
  34914. "aria-selected": !!isSelected || forceSelectionContentLock
  34915. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
  34916. className: "block-editor-list-view-block__contents-cell",
  34917. colSpan: colSpan,
  34918. ref: cellRef,
  34919. "aria-label": blockAriaLabel,
  34920. "aria-selected": !!isSelected || forceSelectionContentLock,
  34921. "aria-expanded": isContentLocked ? undefined : isExpanded,
  34922. "aria-describedby": descriptionId
  34923. }, _ref2 => {
  34924. let {
  34925. ref,
  34926. tabIndex,
  34927. onFocus
  34928. } = _ref2;
  34929. return (0,external_wp_element_namespaceObject.createElement)("div", {
  34930. className: "block-editor-list-view-block__contents-container"
  34931. }, (0,external_wp_element_namespaceObject.createElement)(block_contents, {
  34932. block: block,
  34933. onClick: selectEditorBlock,
  34934. onToggleExpanded: toggleExpanded,
  34935. isSelected: isSelected,
  34936. position: position,
  34937. siblingBlockCount: siblingBlockCount,
  34938. level: level,
  34939. ref: ref,
  34940. tabIndex: tabIndex,
  34941. onFocus: onFocus,
  34942. isExpanded: isExpanded,
  34943. selectedClientIds: selectedClientIds,
  34944. preventAnnouncement: preventAnnouncement
  34945. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  34946. className: "block-editor-list-view-block-select-button__description",
  34947. id: descriptionId
  34948. }, blockPositionDescription));
  34949. }), hasRenderedMovers && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
  34950. className: moverCellClassName,
  34951. withoutGridItem: true
  34952. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridItem, null, _ref3 => {
  34953. let {
  34954. ref,
  34955. tabIndex,
  34956. onFocus
  34957. } = _ref3;
  34958. return (0,external_wp_element_namespaceObject.createElement)(BlockMoverUpButton, {
  34959. orientation: "vertical",
  34960. clientIds: [clientId],
  34961. ref: ref,
  34962. tabIndex: tabIndex,
  34963. onFocus: onFocus
  34964. });
  34965. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridItem, null, _ref4 => {
  34966. let {
  34967. ref,
  34968. tabIndex,
  34969. onFocus
  34970. } = _ref4;
  34971. return (0,external_wp_element_namespaceObject.createElement)(BlockMoverDownButton, {
  34972. orientation: "vertical",
  34973. clientIds: [clientId],
  34974. ref: ref,
  34975. tabIndex: tabIndex,
  34976. onFocus: onFocus
  34977. });
  34978. }))), showBlockActions && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
  34979. className: listViewBlockSettingsClassName,
  34980. "aria-selected": !!isSelected || forceSelectionContentLock
  34981. }, _ref5 => {
  34982. let {
  34983. ref,
  34984. tabIndex,
  34985. onFocus
  34986. } = _ref5;
  34987. return (0,external_wp_element_namespaceObject.createElement)(block_settings_dropdown, {
  34988. clientIds: dropdownClientIds,
  34989. icon: more_vertical,
  34990. label: settingsAriaLabel,
  34991. toggleProps: {
  34992. ref,
  34993. className: 'block-editor-list-view-block__menu',
  34994. tabIndex,
  34995. onFocus
  34996. },
  34997. disableOpenOnArrowDown: true,
  34998. __experimentalSelectBlock: updateSelection
  34999. });
  35000. }));
  35001. }
  35002. /* harmony default export */ var list_view_block = ((0,external_wp_element_namespaceObject.memo)(ListViewBlock));
  35003. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/branch.js
  35004. /**
  35005. * WordPress dependencies
  35006. */
  35007. /**
  35008. * Internal dependencies
  35009. */
  35010. /**
  35011. * Internal dependencies
  35012. */
  35013. /**
  35014. * Given a block, returns the total number of blocks in that subtree. This is used to help determine
  35015. * the list position of a block.
  35016. *
  35017. * When a block is collapsed, we do not count their children as part of that total. In the current drag
  35018. * implementation dragged blocks and their children are not counted.
  35019. *
  35020. * @param {Object} block block tree
  35021. * @param {Object} expandedState state that notes which branches are collapsed
  35022. * @param {Array} draggedClientIds a list of dragged client ids
  35023. * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.
  35024. * @return {number} block count
  35025. */
  35026. function countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault) {
  35027. var _expandedState$block$;
  35028. const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
  35029. if (isDragged) {
  35030. return 0;
  35031. }
  35032. const isExpanded = (_expandedState$block$ = expandedState[block.clientId]) !== null && _expandedState$block$ !== void 0 ? _expandedState$block$ : isExpandedByDefault;
  35033. if (isExpanded) {
  35034. return 1 + block.innerBlocks.reduce(countReducer(expandedState, draggedClientIds, isExpandedByDefault), 0);
  35035. }
  35036. return 1;
  35037. }
  35038. const countReducer = (expandedState, draggedClientIds, isExpandedByDefault) => (count, block) => {
  35039. var _expandedState$block$2;
  35040. const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
  35041. if (isDragged) {
  35042. return count;
  35043. }
  35044. const isExpanded = (_expandedState$block$2 = expandedState[block.clientId]) !== null && _expandedState$block$2 !== void 0 ? _expandedState$block$2 : isExpandedByDefault;
  35045. if (isExpanded && block.innerBlocks.length > 0) {
  35046. return count + countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault);
  35047. }
  35048. return count + 1;
  35049. };
  35050. function ListViewBranch(props) {
  35051. const {
  35052. blocks,
  35053. selectBlock,
  35054. showBlockMovers,
  35055. selectedClientIds,
  35056. level = 1,
  35057. path = '',
  35058. isBranchSelected = false,
  35059. listPosition = 0,
  35060. fixedListWindow,
  35061. isExpanded,
  35062. parentId,
  35063. shouldShowInnerBlocks = true
  35064. } = props;
  35065. const isContentLocked = (0,external_wp_data_namespaceObject.useSelect)(select => {
  35066. return !!(parentId && select(store).getTemplateLock(parentId) === 'contentOnly');
  35067. }, [parentId]);
  35068. const {
  35069. expandedState,
  35070. draggedClientIds
  35071. } = useListViewContext();
  35072. if (isContentLocked) {
  35073. return null;
  35074. }
  35075. const filteredBlocks = blocks.filter(Boolean);
  35076. const blockCount = filteredBlocks.length;
  35077. let nextPosition = listPosition;
  35078. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, filteredBlocks.map((block, index) => {
  35079. var _expandedState$client;
  35080. const {
  35081. clientId,
  35082. innerBlocks
  35083. } = block;
  35084. if (index > 0) {
  35085. nextPosition += countBlocks(filteredBlocks[index - 1], expandedState, draggedClientIds, isExpanded);
  35086. }
  35087. const {
  35088. itemInView
  35089. } = fixedListWindow;
  35090. const blockInView = itemInView(nextPosition);
  35091. const position = index + 1;
  35092. const updatedPath = path.length > 0 ? `${path}_${position}` : `${position}`;
  35093. const hasNestedBlocks = !!(innerBlocks !== null && innerBlocks !== void 0 && innerBlocks.length);
  35094. const shouldExpand = hasNestedBlocks && shouldShowInnerBlocks ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : isExpanded : undefined;
  35095. const isDragged = !!(draggedClientIds !== null && draggedClientIds !== void 0 && draggedClientIds.includes(clientId));
  35096. const showBlock = isDragged || blockInView; // Make updates to the selected or dragged blocks synchronous,
  35097. // but asynchronous for any other block.
  35098. const isSelected = isClientIdSelected(clientId, selectedClientIds);
  35099. const isSelectedBranch = isBranchSelected || isSelected && hasNestedBlocks;
  35100. return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
  35101. key: clientId,
  35102. value: !isSelected
  35103. }, showBlock && (0,external_wp_element_namespaceObject.createElement)(list_view_block, {
  35104. block: block,
  35105. selectBlock: selectBlock,
  35106. isSelected: isSelected,
  35107. isBranchSelected: isSelectedBranch,
  35108. isDragged: isDragged,
  35109. level: level,
  35110. position: position,
  35111. rowCount: blockCount,
  35112. siblingBlockCount: blockCount,
  35113. showBlockMovers: showBlockMovers,
  35114. path: updatedPath,
  35115. isExpanded: shouldExpand,
  35116. listPosition: nextPosition,
  35117. selectedClientIds: selectedClientIds
  35118. }), !showBlock && (0,external_wp_element_namespaceObject.createElement)("tr", null, (0,external_wp_element_namespaceObject.createElement)("td", {
  35119. className: "block-editor-list-view-placeholder"
  35120. })), hasNestedBlocks && shouldExpand && !isDragged && (0,external_wp_element_namespaceObject.createElement)(ListViewBranch, {
  35121. parentId: clientId,
  35122. blocks: innerBlocks,
  35123. selectBlock: selectBlock,
  35124. showBlockMovers: showBlockMovers,
  35125. level: level + 1,
  35126. path: updatedPath,
  35127. listPosition: nextPosition + 1,
  35128. fixedListWindow: fixedListWindow,
  35129. isBranchSelected: isSelectedBranch,
  35130. selectedClientIds: selectedClientIds,
  35131. isExpanded: isExpanded
  35132. }));
  35133. }));
  35134. }
  35135. ListViewBranch.defaultProps = {
  35136. selectBlock: () => {}
  35137. };
  35138. /* harmony default export */ var branch = ((0,external_wp_element_namespaceObject.memo)(ListViewBranch));
  35139. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/drop-indicator.js
  35140. /**
  35141. * WordPress dependencies
  35142. */
  35143. function ListViewDropIndicator(_ref) {
  35144. let {
  35145. listViewRef,
  35146. blockDropTarget
  35147. } = _ref;
  35148. const {
  35149. rootClientId,
  35150. clientId,
  35151. dropPosition
  35152. } = blockDropTarget || {};
  35153. const [rootBlockElement, blockElement] = (0,external_wp_element_namespaceObject.useMemo)(() => {
  35154. if (!listViewRef.current) {
  35155. return [];
  35156. } // The rootClientId will be defined whenever dropping into inner
  35157. // block lists, but is undefined when dropping at the root level.
  35158. const _rootBlockElement = rootClientId ? listViewRef.current.querySelector(`[data-block="${rootClientId}"]`) : undefined; // The clientId represents the sibling block, the dragged block will
  35159. // usually be inserted adjacent to it. It will be undefined when
  35160. // dropping a block into an empty block list.
  35161. const _blockElement = clientId ? listViewRef.current.querySelector(`[data-block="${clientId}"]`) : undefined;
  35162. return [_rootBlockElement, _blockElement];
  35163. }, [rootClientId, clientId]); // The targetElement is the element that the drop indicator will appear
  35164. // before or after. When dropping into an empty block list, blockElement
  35165. // is undefined, so the indicator will appear after the rootBlockElement.
  35166. const targetElement = blockElement || rootBlockElement;
  35167. const getDropIndicatorIndent = (0,external_wp_element_namespaceObject.useCallback)(() => {
  35168. if (!rootBlockElement) {
  35169. return 0;
  35170. } // Calculate the indent using the block icon of the root block.
  35171. // Using a classname selector here might be flaky and could be
  35172. // improved.
  35173. const targetElementRect = targetElement.getBoundingClientRect();
  35174. const rootBlockIconElement = rootBlockElement.querySelector('.block-editor-block-icon');
  35175. const rootBlockIconRect = rootBlockIconElement.getBoundingClientRect();
  35176. return rootBlockIconRect.right - targetElementRect.left;
  35177. }, [rootBlockElement, targetElement]);
  35178. const style = (0,external_wp_element_namespaceObject.useMemo)(() => {
  35179. if (!targetElement) {
  35180. return {};
  35181. }
  35182. const indent = getDropIndicatorIndent();
  35183. return {
  35184. width: targetElement.offsetWidth - indent
  35185. };
  35186. }, [getDropIndicatorIndent, targetElement]);
  35187. const popoverAnchor = (0,external_wp_element_namespaceObject.useMemo)(() => {
  35188. const isValidDropPosition = dropPosition === 'top' || dropPosition === 'bottom' || dropPosition === 'inside';
  35189. if (!targetElement || !isValidDropPosition) {
  35190. return undefined;
  35191. }
  35192. return {
  35193. ownerDocument: targetElement.ownerDocument,
  35194. getBoundingClientRect() {
  35195. const rect = targetElement.getBoundingClientRect();
  35196. const indent = getDropIndicatorIndent();
  35197. const left = rect.left + indent;
  35198. const right = rect.right;
  35199. let top = 0;
  35200. let bottom = 0;
  35201. if (dropPosition === 'top') {
  35202. top = rect.top;
  35203. bottom = rect.top;
  35204. } else {
  35205. // `dropPosition` is either `bottom` or `inside`
  35206. top = rect.bottom;
  35207. bottom = rect.bottom;
  35208. }
  35209. const width = right - left;
  35210. const height = bottom - top;
  35211. return new window.DOMRect(left, top, width, height);
  35212. }
  35213. };
  35214. }, [targetElement, dropPosition, getDropIndicatorIndent]);
  35215. if (!targetElement) {
  35216. return null;
  35217. }
  35218. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  35219. animate: false,
  35220. anchor: popoverAnchor,
  35221. focusOnMount: false,
  35222. className: "block-editor-list-view-drop-indicator"
  35223. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  35224. style: style,
  35225. className: "block-editor-list-view-drop-indicator__line"
  35226. }));
  35227. }
  35228. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-block-selection.js
  35229. /**
  35230. * WordPress dependencies
  35231. */
  35232. /**
  35233. * Internal dependencies
  35234. */
  35235. function useBlockSelection() {
  35236. const {
  35237. clearSelectedBlock,
  35238. multiSelect,
  35239. selectBlock
  35240. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  35241. const {
  35242. getBlockName,
  35243. getBlockParents,
  35244. getBlockSelectionStart,
  35245. getBlockSelectionEnd,
  35246. getSelectedBlockClientIds,
  35247. hasMultiSelection,
  35248. hasSelectedBlock
  35249. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  35250. const {
  35251. getBlockType
  35252. } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
  35253. const updateBlockSelection = (0,external_wp_element_namespaceObject.useCallback)(async (event, clientId, destinationClientId) => {
  35254. if (!(event !== null && event !== void 0 && event.shiftKey)) {
  35255. selectBlock(clientId);
  35256. return;
  35257. } // To handle multiple block selection via the `SHIFT` key, prevent
  35258. // the browser default behavior of opening the link in a new window.
  35259. event.preventDefault();
  35260. const isKeyPress = event.type === 'keydown' && (event.keyCode === external_wp_keycodes_namespaceObject.UP || event.keyCode === external_wp_keycodes_namespaceObject.DOWN || event.keyCode === external_wp_keycodes_namespaceObject.HOME || event.keyCode === external_wp_keycodes_namespaceObject.END); // Handle clicking on a block when no blocks are selected, and return early.
  35261. if (!isKeyPress && !hasSelectedBlock() && !hasMultiSelection()) {
  35262. selectBlock(clientId, null);
  35263. return;
  35264. }
  35265. const selectedBlocks = getSelectedBlockClientIds();
  35266. const clientIdWithParents = [...getBlockParents(clientId), clientId];
  35267. if (isKeyPress && !selectedBlocks.some(blockId => clientIdWithParents.includes(blockId))) {
  35268. // Ensure that shift-selecting blocks via the keyboard only
  35269. // expands the current selection if focusing over already
  35270. // selected blocks. Otherwise, clear the selection so that
  35271. // a user can create a new selection entirely by keyboard.
  35272. await clearSelectedBlock();
  35273. }
  35274. let startTarget = getBlockSelectionStart();
  35275. let endTarget = clientId; // Handle keyboard behavior for selecting multiple blocks.
  35276. if (isKeyPress) {
  35277. if (!hasSelectedBlock() && !hasMultiSelection()) {
  35278. // Set the starting point of the selection to the currently
  35279. // focused block, if there are no blocks currently selected.
  35280. // This ensures that as the selection is expanded or contracted,
  35281. // the starting point of the selection is anchored to that block.
  35282. startTarget = clientId;
  35283. }
  35284. if (destinationClientId) {
  35285. // If the user presses UP or DOWN, we want to ensure that the block they're
  35286. // moving to is the target for selection, and not the currently focused one.
  35287. endTarget = destinationClientId;
  35288. }
  35289. }
  35290. const startParents = getBlockParents(startTarget);
  35291. const endParents = getBlockParents(endTarget);
  35292. const {
  35293. start,
  35294. end
  35295. } = getCommonDepthClientIds(startTarget, endTarget, startParents, endParents);
  35296. await multiSelect(start, end, null); // Announce deselected block, or number of deselected blocks if
  35297. // the total number of blocks deselected is greater than one.
  35298. const updatedSelectedBlocks = getSelectedBlockClientIds(); // If the selection is greater than 1 and the Home or End keys
  35299. // were used to generate the selection, then skip announcing the
  35300. // deselected blocks.
  35301. if ((event.keyCode === external_wp_keycodes_namespaceObject.HOME || event.keyCode === external_wp_keycodes_namespaceObject.END) && updatedSelectedBlocks.length > 1) {
  35302. return;
  35303. }
  35304. const selectionDiff = selectedBlocks.filter(blockId => !updatedSelectedBlocks.includes(blockId));
  35305. let label;
  35306. if (selectionDiff.length === 1) {
  35307. var _getBlockType;
  35308. const title = (_getBlockType = getBlockType(getBlockName(selectionDiff[0]))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
  35309. if (title) {
  35310. label = (0,external_wp_i18n_namespaceObject.sprintf)(
  35311. /* translators: %s: block name */
  35312. (0,external_wp_i18n_namespaceObject.__)('%s deselected.'), title);
  35313. }
  35314. } else if (selectionDiff.length > 1) {
  35315. label = (0,external_wp_i18n_namespaceObject.sprintf)(
  35316. /* translators: %s: number of deselected blocks */
  35317. (0,external_wp_i18n_namespaceObject.__)('%s blocks deselected.'), selectionDiff.length);
  35318. }
  35319. if (label) {
  35320. (0,external_wp_a11y_namespaceObject.speak)(label);
  35321. }
  35322. }, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart, getBlockSelectionEnd, getSelectedBlockClientIds, hasMultiSelection, hasSelectedBlock, multiSelect, selectBlock]);
  35323. return {
  35324. updateBlockSelection
  35325. };
  35326. }
  35327. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-client-ids.js
  35328. /**
  35329. * WordPress dependencies
  35330. */
  35331. /**
  35332. * Internal dependencies
  35333. */
  35334. function useListViewClientIds(blocks) {
  35335. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  35336. const {
  35337. getDraggedBlockClientIds,
  35338. getSelectedBlockClientIds,
  35339. __unstableGetClientIdsTree
  35340. } = select(store);
  35341. return {
  35342. selectedClientIds: getSelectedBlockClientIds(),
  35343. draggedClientIds: getDraggedBlockClientIds(),
  35344. clientIdsTree: blocks ? blocks : __unstableGetClientIdsTree()
  35345. };
  35346. }, [blocks]);
  35347. }
  35348. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-drop-zone.js
  35349. /**
  35350. * WordPress dependencies
  35351. */
  35352. /**
  35353. * Internal dependencies
  35354. */
  35355. /** @typedef {import('../../utils/math').WPPoint} WPPoint */
  35356. /**
  35357. * The type of a drag event.
  35358. *
  35359. * @typedef {'default'|'file'|'html'} WPDragEventType
  35360. */
  35361. /**
  35362. * An array representing data for blocks in the DOM used by drag and drop.
  35363. *
  35364. * @typedef {Object} WPListViewDropZoneBlocks
  35365. * @property {string} clientId The client id for the block.
  35366. * @property {string} rootClientId The root client id for the block.
  35367. * @property {number} blockIndex The block's index.
  35368. * @property {Element} element The DOM element representing the block.
  35369. * @property {number} innerBlockCount The number of inner blocks the block has.
  35370. * @property {boolean} isDraggedBlock Whether the block is currently being dragged.
  35371. * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.
  35372. * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.
  35373. */
  35374. /**
  35375. * An object containing details of a drop target.
  35376. *
  35377. * @typedef {Object} WPListViewDropZoneTarget
  35378. * @property {string} blockIndex The insertion index.
  35379. * @property {string} rootClientId The root client id for the block.
  35380. * @property {string|undefined} clientId The client id for the block.
  35381. * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.
  35382. * 'inside' refers to nesting as an inner block.
  35383. */
  35384. /**
  35385. * Is the point contained by the rectangle.
  35386. *
  35387. * @param {WPPoint} point The point.
  35388. * @param {DOMRect} rect The rectangle.
  35389. *
  35390. * @return {boolean} True if the point is contained by the rectangle, false otherwise.
  35391. */
  35392. function isPointContainedByRect(point, rect) {
  35393. return rect.left <= point.x && rect.right >= point.x && rect.top <= point.y && rect.bottom >= point.y;
  35394. }
  35395. /**
  35396. * Determines whether the user positioning the dragged block to nest as an
  35397. * inner block.
  35398. *
  35399. * Presently this is determined by whether the cursor is on the right hand side
  35400. * of the block.
  35401. *
  35402. * @param {WPPoint} point The point representing the cursor position when dragging.
  35403. * @param {DOMRect} rect The rectangle.
  35404. */
  35405. function isNestingGesture(point, rect) {
  35406. const blockCenterX = rect.left + rect.width / 2;
  35407. return point.x > blockCenterX;
  35408. } // Block navigation is always a vertical list, so only allow dropping
  35409. // to the above or below a block.
  35410. const ALLOWED_DROP_EDGES = ['top', 'bottom'];
  35411. /**
  35412. * Given blocks data and the cursor position, compute the drop target.
  35413. *
  35414. * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.
  35415. * @param {WPPoint} position The point representing the cursor position when dragging.
  35416. *
  35417. * @return {WPListViewDropZoneTarget} An object containing data about the drop target.
  35418. */
  35419. function getListViewDropTarget(blocksData, position) {
  35420. let candidateEdge;
  35421. let candidateBlockData;
  35422. let candidateDistance;
  35423. let candidateRect;
  35424. for (const blockData of blocksData) {
  35425. if (blockData.isDraggedBlock) {
  35426. continue;
  35427. }
  35428. const rect = blockData.element.getBoundingClientRect();
  35429. const [distance, edge] = getDistanceToNearestEdge(position, rect, ALLOWED_DROP_EDGES);
  35430. const isCursorWithinBlock = isPointContainedByRect(position, rect);
  35431. if (candidateDistance === undefined || distance < candidateDistance || isCursorWithinBlock) {
  35432. candidateDistance = distance;
  35433. const index = blocksData.indexOf(blockData);
  35434. const previousBlockData = blocksData[index - 1]; // If dragging near the top of a block and the preceding block
  35435. // is at the same level, use the preceding block as the candidate
  35436. // instead, as later it makes determining a nesting drop easier.
  35437. if (edge === 'top' && previousBlockData && previousBlockData.rootClientId === blockData.rootClientId && !previousBlockData.isDraggedBlock) {
  35438. candidateBlockData = previousBlockData;
  35439. candidateEdge = 'bottom';
  35440. candidateRect = previousBlockData.element.getBoundingClientRect();
  35441. } else {
  35442. candidateBlockData = blockData;
  35443. candidateEdge = edge;
  35444. candidateRect = rect;
  35445. } // If the mouse position is within the block, break early
  35446. // as the user would intend to drop either before or after
  35447. // this block.
  35448. //
  35449. // This solves an issue where some rows in the list view
  35450. // tree overlap slightly due to sub-pixel rendering.
  35451. if (isCursorWithinBlock) {
  35452. break;
  35453. }
  35454. }
  35455. }
  35456. if (!candidateBlockData) {
  35457. return;
  35458. }
  35459. const isDraggingBelow = candidateEdge === 'bottom'; // If the user is dragging towards the bottom of the block check whether
  35460. // they might be trying to nest the block as a child.
  35461. // If the block already has inner blocks, this should always be treated
  35462. // as nesting since the next block in the tree will be the first child.
  35463. if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 || isNestingGesture(position, candidateRect))) {
  35464. return {
  35465. rootClientId: candidateBlockData.clientId,
  35466. blockIndex: 0,
  35467. dropPosition: 'inside'
  35468. };
  35469. } // If dropping as a sibling, but block cannot be inserted in
  35470. // this context, return early.
  35471. if (!candidateBlockData.canInsertDraggedBlocksAsSibling) {
  35472. return;
  35473. }
  35474. const offset = isDraggingBelow ? 1 : 0;
  35475. return {
  35476. rootClientId: candidateBlockData.rootClientId,
  35477. clientId: candidateBlockData.clientId,
  35478. blockIndex: candidateBlockData.blockIndex + offset,
  35479. dropPosition: candidateEdge
  35480. };
  35481. }
  35482. /**
  35483. * A react hook for implementing a drop zone in list view.
  35484. *
  35485. * @return {WPListViewDropZoneTarget} The drop target.
  35486. */
  35487. function useListViewDropZone() {
  35488. const {
  35489. getBlockRootClientId,
  35490. getBlockIndex,
  35491. getBlockCount,
  35492. getDraggedBlockClientIds,
  35493. canInsertBlocks
  35494. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  35495. const [target, setTarget] = (0,external_wp_element_namespaceObject.useState)();
  35496. const {
  35497. rootClientId: targetRootClientId,
  35498. blockIndex: targetBlockIndex
  35499. } = target || {};
  35500. const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex);
  35501. const draggedBlockClientIds = getDraggedBlockClientIds();
  35502. const throttled = (0,external_wp_compose_namespaceObject.useThrottle)((0,external_wp_element_namespaceObject.useCallback)((event, currentTarget) => {
  35503. const position = {
  35504. x: event.clientX,
  35505. y: event.clientY
  35506. };
  35507. const isBlockDrag = !!(draggedBlockClientIds !== null && draggedBlockClientIds !== void 0 && draggedBlockClientIds.length);
  35508. const blockElements = Array.from(currentTarget.querySelectorAll('[data-block]'));
  35509. const blocksData = blockElements.map(blockElement => {
  35510. const clientId = blockElement.dataset.block;
  35511. const rootClientId = getBlockRootClientId(clientId);
  35512. return {
  35513. clientId,
  35514. rootClientId,
  35515. blockIndex: getBlockIndex(clientId),
  35516. element: blockElement,
  35517. isDraggedBlock: isBlockDrag ? draggedBlockClientIds.includes(clientId) : false,
  35518. innerBlockCount: getBlockCount(clientId),
  35519. canInsertDraggedBlocksAsSibling: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, rootClientId) : true,
  35520. canInsertDraggedBlocksAsChild: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, clientId) : true
  35521. };
  35522. });
  35523. const newTarget = getListViewDropTarget(blocksData, position);
  35524. if (newTarget) {
  35525. setTarget(newTarget);
  35526. }
  35527. }, [draggedBlockClientIds]), 200);
  35528. const ref = (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({
  35529. onDrop: onBlockDrop,
  35530. onDragOver(event) {
  35531. // `currentTarget` is only available while the event is being
  35532. // handled, so get it now and pass it to the thottled function.
  35533. // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
  35534. throttled(event, event.currentTarget);
  35535. },
  35536. onDragEnd() {
  35537. throttled.cancel();
  35538. setTarget(null);
  35539. }
  35540. });
  35541. return {
  35542. ref,
  35543. target
  35544. };
  35545. }
  35546. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-expand-selected-item.js
  35547. /**
  35548. * WordPress dependencies
  35549. */
  35550. /**
  35551. * Internal dependencies
  35552. */
  35553. function useListViewExpandSelectedItem(_ref) {
  35554. let {
  35555. firstSelectedBlockClientId,
  35556. setExpandedState
  35557. } = _ref;
  35558. const [selectedTreeId, setSelectedTreeId] = (0,external_wp_element_namespaceObject.useState)(null);
  35559. const {
  35560. selectedBlockParentClientIds
  35561. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  35562. const {
  35563. getBlockParents
  35564. } = select(store);
  35565. return {
  35566. selectedBlockParentClientIds: getBlockParents(firstSelectedBlockClientId, false)
  35567. };
  35568. }, [firstSelectedBlockClientId]);
  35569. const parentClientIds = Array.isArray(selectedBlockParentClientIds) && selectedBlockParentClientIds.length ? selectedBlockParentClientIds : null; // Expand tree when a block is selected.
  35570. (0,external_wp_element_namespaceObject.useEffect)(() => {
  35571. // If the selectedTreeId is the same as the selected block,
  35572. // it means that the block was selected using the block list tree.
  35573. if (selectedTreeId === firstSelectedBlockClientId) {
  35574. return;
  35575. } // If the selected block has parents, get the top-level parent.
  35576. if (parentClientIds) {
  35577. // If the selected block has parents,
  35578. // expand the tree branch.
  35579. setExpandedState({
  35580. type: 'expand',
  35581. clientIds: selectedBlockParentClientIds
  35582. });
  35583. }
  35584. }, [firstSelectedBlockClientId]);
  35585. return {
  35586. setSelectedTreeId
  35587. };
  35588. }
  35589. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/index.js
  35590. /**
  35591. * WordPress dependencies
  35592. */
  35593. /**
  35594. * Internal dependencies
  35595. */
  35596. const expanded = (state, action) => {
  35597. if (Array.isArray(action.clientIds)) {
  35598. return { ...state,
  35599. ...action.clientIds.reduce((newState, id) => ({ ...newState,
  35600. [id]: action.type === 'expand'
  35601. }), {})
  35602. };
  35603. }
  35604. return state;
  35605. };
  35606. const BLOCK_LIST_ITEM_HEIGHT = 36;
  35607. /**
  35608. * Show a hierarchical list of blocks.
  35609. *
  35610. * @param {Object} props Components props.
  35611. * @param {string} props.id An HTML element id for the root element of ListView.
  35612. * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
  35613. * @param {boolean} props.showBlockMovers Flag to enable block movers
  35614. * @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
  35615. * @param {Object} ref Forwarded ref
  35616. */
  35617. function ListView(_ref, ref) {
  35618. let {
  35619. id,
  35620. blocks,
  35621. showBlockMovers = false,
  35622. isExpanded = false
  35623. } = _ref;
  35624. const {
  35625. clientIdsTree,
  35626. draggedClientIds,
  35627. selectedClientIds
  35628. } = useListViewClientIds(blocks);
  35629. const {
  35630. visibleBlockCount,
  35631. shouldShowInnerBlocks
  35632. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  35633. const {
  35634. getGlobalBlockCount,
  35635. getClientIdsOfDescendants,
  35636. __unstableGetEditorMode
  35637. } = select(store);
  35638. const draggedBlockCount = (draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.length) > 0 ? getClientIdsOfDescendants(draggedClientIds).length + 1 : 0;
  35639. return {
  35640. visibleBlockCount: getGlobalBlockCount() - draggedBlockCount,
  35641. shouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out'
  35642. };
  35643. }, [draggedClientIds]);
  35644. const {
  35645. updateBlockSelection
  35646. } = useBlockSelection();
  35647. const [expandedState, setExpandedState] = (0,external_wp_element_namespaceObject.useReducer)(expanded, {});
  35648. const {
  35649. ref: dropZoneRef,
  35650. target: blockDropTarget
  35651. } = useListViewDropZone();
  35652. const elementRef = (0,external_wp_element_namespaceObject.useRef)();
  35653. const treeGridRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([elementRef, dropZoneRef, ref]);
  35654. const isMounted = (0,external_wp_element_namespaceObject.useRef)(false);
  35655. const {
  35656. setSelectedTreeId
  35657. } = useListViewExpandSelectedItem({
  35658. firstSelectedBlockClientId: selectedClientIds[0],
  35659. setExpandedState
  35660. });
  35661. const selectEditorBlock = (0,external_wp_element_namespaceObject.useCallback)((event, clientId) => {
  35662. updateBlockSelection(event, clientId);
  35663. setSelectedTreeId(clientId);
  35664. }, [setSelectedTreeId, updateBlockSelection]);
  35665. (0,external_wp_element_namespaceObject.useEffect)(() => {
  35666. isMounted.current = true;
  35667. }, []); // List View renders a fixed number of items and relies on each having a fixed item height of 36px.
  35668. // If this value changes, we should also change the itemHeight value set in useFixedWindowList.
  35669. // See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
  35670. const [fixedListWindow] = (0,external_wp_compose_namespaceObject.__experimentalUseFixedWindowList)(elementRef, BLOCK_LIST_ITEM_HEIGHT, visibleBlockCount, {
  35671. useWindowing: true,
  35672. windowOverscan: 40
  35673. });
  35674. const expand = (0,external_wp_element_namespaceObject.useCallback)(clientId => {
  35675. if (!clientId) {
  35676. return;
  35677. }
  35678. setExpandedState({
  35679. type: 'expand',
  35680. clientIds: [clientId]
  35681. });
  35682. }, [setExpandedState]);
  35683. const collapse = (0,external_wp_element_namespaceObject.useCallback)(clientId => {
  35684. if (!clientId) {
  35685. return;
  35686. }
  35687. setExpandedState({
  35688. type: 'collapse',
  35689. clientIds: [clientId]
  35690. });
  35691. }, [setExpandedState]);
  35692. const expandRow = (0,external_wp_element_namespaceObject.useCallback)(row => {
  35693. var _row$dataset;
  35694. expand(row === null || row === void 0 ? void 0 : (_row$dataset = row.dataset) === null || _row$dataset === void 0 ? void 0 : _row$dataset.block);
  35695. }, [expand]);
  35696. const collapseRow = (0,external_wp_element_namespaceObject.useCallback)(row => {
  35697. var _row$dataset2;
  35698. collapse(row === null || row === void 0 ? void 0 : (_row$dataset2 = row.dataset) === null || _row$dataset2 === void 0 ? void 0 : _row$dataset2.block);
  35699. }, [collapse]);
  35700. const focusRow = (0,external_wp_element_namespaceObject.useCallback)((event, startRow, endRow) => {
  35701. if (event.shiftKey) {
  35702. var _startRow$dataset, _endRow$dataset;
  35703. updateBlockSelection(event, startRow === null || startRow === void 0 ? void 0 : (_startRow$dataset = startRow.dataset) === null || _startRow$dataset === void 0 ? void 0 : _startRow$dataset.block, endRow === null || endRow === void 0 ? void 0 : (_endRow$dataset = endRow.dataset) === null || _endRow$dataset === void 0 ? void 0 : _endRow$dataset.block);
  35704. }
  35705. }, [updateBlockSelection]);
  35706. const contextValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({
  35707. isTreeGridMounted: isMounted.current,
  35708. draggedClientIds,
  35709. expandedState,
  35710. expand,
  35711. collapse
  35712. }), [isMounted.current, draggedClientIds, expandedState, expand, collapse]);
  35713. return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
  35714. value: true
  35715. }, (0,external_wp_element_namespaceObject.createElement)(ListViewDropIndicator, {
  35716. listViewRef: elementRef,
  35717. blockDropTarget: blockDropTarget
  35718. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGrid, {
  35719. id: id,
  35720. className: "block-editor-list-view-tree",
  35721. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block navigation structure'),
  35722. ref: treeGridRef,
  35723. onCollapseRow: collapseRow,
  35724. onExpandRow: expandRow,
  35725. onFocusRow: focusRow,
  35726. applicationAriaLabel: (0,external_wp_i18n_namespaceObject.__)('Block navigation structure')
  35727. }, (0,external_wp_element_namespaceObject.createElement)(ListViewContext.Provider, {
  35728. value: contextValue
  35729. }, (0,external_wp_element_namespaceObject.createElement)(branch, {
  35730. blocks: clientIdsTree,
  35731. selectBlock: selectEditorBlock,
  35732. showBlockMovers: showBlockMovers,
  35733. fixedListWindow: fixedListWindow,
  35734. selectedClientIds: selectedClientIds,
  35735. isExpanded: isExpanded,
  35736. shouldShowInnerBlocks: shouldShowInnerBlocks
  35737. }))));
  35738. }
  35739. /* harmony default export */ var components_list_view = ((0,external_wp_element_namespaceObject.forwardRef)(ListView));
  35740. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/dropdown.js
  35741. /**
  35742. * WordPress dependencies
  35743. */
  35744. /**
  35745. * WordPress dependencies
  35746. */
  35747. /**
  35748. * Internal dependencies
  35749. */
  35750. function BlockNavigationDropdownToggle(_ref) {
  35751. let {
  35752. isEnabled,
  35753. onToggle,
  35754. isOpen,
  35755. innerRef,
  35756. ...props
  35757. } = _ref;
  35758. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
  35759. ref: innerRef,
  35760. icon: list_view,
  35761. "aria-expanded": isOpen,
  35762. "aria-haspopup": "true",
  35763. onClick: isEnabled ? onToggle : undefined
  35764. /* translators: button label text should, if possible, be under 16 characters. */
  35765. ,
  35766. label: (0,external_wp_i18n_namespaceObject.__)('List view'),
  35767. className: "block-editor-block-navigation",
  35768. "aria-disabled": !isEnabled
  35769. }));
  35770. }
  35771. function BlockNavigationDropdown(_ref2, ref) {
  35772. let {
  35773. isDisabled,
  35774. ...props
  35775. } = _ref2;
  35776. external_wp_deprecated_default()('wp.blockEditor.BlockNavigationDropdown', {
  35777. since: '6.1',
  35778. alternative: 'wp.components.Dropdown and wp.blockEditor.ListView'
  35779. });
  35780. const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).getBlockCount(), []);
  35781. const isEnabled = hasBlocks && !isDisabled;
  35782. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  35783. contentClassName: "block-editor-block-navigation__popover",
  35784. position: "bottom right",
  35785. renderToggle: _ref3 => {
  35786. let {
  35787. isOpen,
  35788. onToggle
  35789. } = _ref3;
  35790. return (0,external_wp_element_namespaceObject.createElement)(BlockNavigationDropdownToggle, _extends({}, props, {
  35791. innerRef: ref,
  35792. isOpen: isOpen,
  35793. onToggle: onToggle,
  35794. isEnabled: isEnabled
  35795. }));
  35796. },
  35797. renderContent: () => (0,external_wp_element_namespaceObject.createElement)("div", {
  35798. className: "block-editor-block-navigation__container"
  35799. }, (0,external_wp_element_namespaceObject.createElement)("p", {
  35800. className: "block-editor-block-navigation__label"
  35801. }, (0,external_wp_i18n_namespaceObject.__)('List view')), (0,external_wp_element_namespaceObject.createElement)(components_list_view, null))
  35802. });
  35803. }
  35804. /* harmony default export */ var dropdown = ((0,external_wp_element_namespaceObject.forwardRef)(BlockNavigationDropdown));
  35805. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/preview-panel.js
  35806. /**
  35807. * WordPress dependencies
  35808. */
  35809. /**
  35810. * Internal dependencies
  35811. */
  35812. function BlockStylesPreviewPanel(_ref) {
  35813. var _getBlockType;
  35814. let {
  35815. genericPreviewBlock,
  35816. style,
  35817. className,
  35818. activeStyle
  35819. } = _ref;
  35820. const example = (_getBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(genericPreviewBlock.name)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.example;
  35821. const styleClassName = replaceActiveStyle(className, activeStyle, style);
  35822. const previewBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
  35823. return { ...genericPreviewBlock,
  35824. title: style.label || style.name,
  35825. description: style.description,
  35826. initialAttributes: { ...genericPreviewBlock.attributes,
  35827. className: styleClassName + ' block-editor-block-styles__block-preview-container'
  35828. },
  35829. example
  35830. };
  35831. }, [genericPreviewBlock, styleClassName]);
  35832. return (0,external_wp_element_namespaceObject.createElement)(preview_panel, {
  35833. item: previewBlocks,
  35834. isStylePreview: true
  35835. });
  35836. }
  35837. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/index.js
  35838. /**
  35839. * External dependencies
  35840. */
  35841. /**
  35842. * WordPress dependencies
  35843. */
  35844. /**
  35845. * Internal dependencies
  35846. */
  35847. function BlockStylesPreviewPanelSlot(_ref) {
  35848. let {
  35849. scope
  35850. } = _ref;
  35851. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
  35852. name: `BlockStylesPreviewPanel/${scope}`
  35853. });
  35854. }
  35855. function BlockStylesPreviewPanelFill(_ref2) {
  35856. let {
  35857. children,
  35858. scope,
  35859. ...props
  35860. } = _ref2;
  35861. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
  35862. name: `BlockStylesPreviewPanel/${scope}`
  35863. }, (0,external_wp_element_namespaceObject.createElement)("div", props, children));
  35864. } // Top position (in px) of the Block Styles container
  35865. // relative to the editor pane.
  35866. // The value is the equivalent of the container's right position.
  35867. const DEFAULT_POSITION_TOP = 16;
  35868. const block_styles_noop = () => {}; // Block Styles component for the Settings Sidebar.
  35869. function BlockStyles(_ref3) {
  35870. let {
  35871. clientId,
  35872. onSwitch = block_styles_noop,
  35873. onHoverClassName = block_styles_noop,
  35874. scope
  35875. } = _ref3;
  35876. const {
  35877. onSelect,
  35878. stylesToRender,
  35879. activeStyle,
  35880. genericPreviewBlock,
  35881. className: previewClassName
  35882. } = useStylesForBlocks({
  35883. clientId,
  35884. onSwitch
  35885. });
  35886. const [hoveredStyle, setHoveredStyle] = (0,external_wp_element_namespaceObject.useState)(null);
  35887. const [containerScrollTop, setContainerScrollTop] = (0,external_wp_element_namespaceObject.useState)(0);
  35888. const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
  35889. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  35890. const scrollContainer = document.querySelector('.interface-interface-skeleton__content');
  35891. const scrollTop = (scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTop) || 0;
  35892. setContainerScrollTop(scrollTop + DEFAULT_POSITION_TOP);
  35893. }, [hoveredStyle]);
  35894. if (!stylesToRender || stylesToRender.length === 0) {
  35895. return null;
  35896. }
  35897. const debouncedSetHoveredStyle = (0,external_lodash_namespaceObject.debounce)(setHoveredStyle, 250);
  35898. const onSelectStylePreview = style => {
  35899. onSelect(style);
  35900. onHoverClassName(null);
  35901. setHoveredStyle(null);
  35902. debouncedSetHoveredStyle.cancel();
  35903. };
  35904. const styleItemHandler = item => {
  35905. var _item$name;
  35906. if (hoveredStyle === item) {
  35907. debouncedSetHoveredStyle.cancel();
  35908. return;
  35909. }
  35910. debouncedSetHoveredStyle(item);
  35911. onHoverClassName((_item$name = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name !== void 0 ? _item$name : null);
  35912. };
  35913. return (0,external_wp_element_namespaceObject.createElement)("div", {
  35914. className: "block-editor-block-styles"
  35915. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  35916. className: "block-editor-block-styles__variants"
  35917. }, stylesToRender.map(style => {
  35918. const buttonText = style.label || style.name;
  35919. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  35920. className: classnames_default()('block-editor-block-styles__item', {
  35921. 'is-active': activeStyle.name === style.name
  35922. }),
  35923. key: style.name,
  35924. variant: "secondary",
  35925. label: buttonText,
  35926. onMouseEnter: () => styleItemHandler(style),
  35927. onFocus: () => styleItemHandler(style),
  35928. onMouseLeave: () => styleItemHandler(null),
  35929. onBlur: () => styleItemHandler(null),
  35930. onClick: () => onSelectStylePreview(style),
  35931. "aria-current": activeStyle.name === style.name
  35932. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, {
  35933. numberOfLines: 1,
  35934. className: "block-editor-block-styles__item-text"
  35935. }, buttonText));
  35936. })), hoveredStyle && !isMobileViewport && (0,external_wp_element_namespaceObject.createElement)(BlockStylesPreviewPanelFill, {
  35937. scope: scope,
  35938. className: "block-editor-block-styles__preview-panel",
  35939. style: {
  35940. top: containerScrollTop
  35941. },
  35942. onMouseLeave: () => styleItemHandler(null)
  35943. }, (0,external_wp_element_namespaceObject.createElement)(BlockStylesPreviewPanel, {
  35944. activeStyle: activeStyle,
  35945. className: previewClassName,
  35946. genericPreviewBlock: genericPreviewBlock,
  35947. style: hoveredStyle
  35948. })));
  35949. }
  35950. BlockStyles.Slot = BlockStylesPreviewPanelSlot;
  35951. /* harmony default export */ var block_styles = (BlockStyles);
  35952. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js
  35953. /**
  35954. * WordPress dependencies
  35955. */
  35956. const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  35957. xmlns: "http://www.w3.org/2000/svg",
  35958. viewBox: "0 0 24 24"
  35959. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  35960. d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
  35961. }));
  35962. /* harmony default export */ var library_layout = (layout);
  35963. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-variation-picker/index.js
  35964. /**
  35965. * External dependencies
  35966. */
  35967. /**
  35968. * WordPress dependencies
  35969. */
  35970. function BlockVariationPicker(_ref) {
  35971. let {
  35972. icon = library_layout,
  35973. label = (0,external_wp_i18n_namespaceObject.__)('Choose variation'),
  35974. instructions = (0,external_wp_i18n_namespaceObject.__)('Select a variation to start with.'),
  35975. variations,
  35976. onSelect,
  35977. allowSkip
  35978. } = _ref;
  35979. const classes = classnames_default()('block-editor-block-variation-picker', {
  35980. 'has-many-variations': variations.length > 4
  35981. });
  35982. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
  35983. icon: icon,
  35984. label: label,
  35985. instructions: instructions,
  35986. className: classes
  35987. }, (0,external_wp_element_namespaceObject.createElement)("ul", {
  35988. className: "block-editor-block-variation-picker__variations",
  35989. role: "list",
  35990. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block variations')
  35991. }, variations.map(variation => (0,external_wp_element_namespaceObject.createElement)("li", {
  35992. key: variation.name
  35993. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  35994. variant: "secondary",
  35995. icon: variation.icon,
  35996. iconSize: 48,
  35997. onClick: () => onSelect(variation),
  35998. className: "block-editor-block-variation-picker__variation",
  35999. label: variation.description || variation.title
  36000. }), (0,external_wp_element_namespaceObject.createElement)("span", {
  36001. className: "block-editor-block-variation-picker__variation-label",
  36002. role: "presentation"
  36003. }, variation.title)))), allowSkip && (0,external_wp_element_namespaceObject.createElement)("div", {
  36004. className: "block-editor-block-variation-picker__skip"
  36005. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  36006. variant: "link",
  36007. onClick: () => onSelect()
  36008. }, (0,external_wp_i18n_namespaceObject.__)('Skip'))));
  36009. }
  36010. /* harmony default export */ var block_variation_picker = (BlockVariationPicker);
  36011. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/grid.js
  36012. /**
  36013. * WordPress dependencies
  36014. */
  36015. const grid = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  36016. xmlns: "http://www.w3.org/2000/svg",
  36017. viewBox: "0 0 24 24"
  36018. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  36019. d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7.8 16.5H5c-.3 0-.5-.2-.5-.5v-6.2h6.8v6.7zm0-8.3H4.5V5c0-.3.2-.5.5-.5h6.2v6.7zm8.3 7.8c0 .3-.2.5-.5.5h-6.2v-6.8h6.8V19zm0-7.8h-6.8V4.5H19c.3 0 .5.2.5.5v6.2z",
  36020. fillRule: "evenodd",
  36021. clipRule: "evenodd"
  36022. }));
  36023. /* harmony default export */ var library_grid = (grid);
  36024. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/constants.js
  36025. const VIEWMODES = {
  36026. carousel: 'carousel',
  36027. grid: 'grid'
  36028. };
  36029. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/setup-toolbar.js
  36030. /**
  36031. * WordPress dependencies
  36032. */
  36033. /**
  36034. * Internal dependencies
  36035. */
  36036. const Actions = _ref => {
  36037. let {
  36038. onBlockPatternSelect
  36039. } = _ref;
  36040. return (0,external_wp_element_namespaceObject.createElement)("div", {
  36041. className: "block-editor-block-pattern-setup__actions"
  36042. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  36043. variant: "primary",
  36044. onClick: onBlockPatternSelect
  36045. }, (0,external_wp_i18n_namespaceObject.__)('Choose')));
  36046. };
  36047. const CarouselNavigation = _ref2 => {
  36048. let {
  36049. handlePrevious,
  36050. handleNext,
  36051. activeSlide,
  36052. totalSlides
  36053. } = _ref2;
  36054. return (0,external_wp_element_namespaceObject.createElement)("div", {
  36055. className: "block-editor-block-pattern-setup__navigation"
  36056. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  36057. icon: chevron_left,
  36058. label: (0,external_wp_i18n_namespaceObject.__)('Previous pattern'),
  36059. onClick: handlePrevious,
  36060. disabled: activeSlide === 0
  36061. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  36062. icon: chevron_right,
  36063. label: (0,external_wp_i18n_namespaceObject.__)('Next pattern'),
  36064. onClick: handleNext,
  36065. disabled: activeSlide === totalSlides - 1
  36066. }));
  36067. };
  36068. const SetupToolbar = _ref3 => {
  36069. let {
  36070. viewMode,
  36071. setViewMode,
  36072. handlePrevious,
  36073. handleNext,
  36074. activeSlide,
  36075. totalSlides,
  36076. onBlockPatternSelect
  36077. } = _ref3;
  36078. const isCarouselView = viewMode === VIEWMODES.carousel;
  36079. const displayControls = (0,external_wp_element_namespaceObject.createElement)("div", {
  36080. className: "block-editor-block-pattern-setup__display-controls"
  36081. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  36082. icon: stretch_full_width,
  36083. label: (0,external_wp_i18n_namespaceObject.__)('Carousel view'),
  36084. onClick: () => setViewMode(VIEWMODES.carousel),
  36085. isPressed: isCarouselView
  36086. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  36087. icon: library_grid,
  36088. label: (0,external_wp_i18n_namespaceObject.__)('Grid view'),
  36089. onClick: () => setViewMode(VIEWMODES.grid),
  36090. isPressed: viewMode === VIEWMODES.grid
  36091. }));
  36092. return (0,external_wp_element_namespaceObject.createElement)("div", {
  36093. className: "block-editor-block-pattern-setup__toolbar"
  36094. }, isCarouselView && (0,external_wp_element_namespaceObject.createElement)(CarouselNavigation, {
  36095. handlePrevious: handlePrevious,
  36096. handleNext: handleNext,
  36097. activeSlide: activeSlide,
  36098. totalSlides: totalSlides
  36099. }), displayControls, isCarouselView && (0,external_wp_element_namespaceObject.createElement)(Actions, {
  36100. onBlockPatternSelect: onBlockPatternSelect
  36101. }));
  36102. };
  36103. /* harmony default export */ var setup_toolbar = (SetupToolbar);
  36104. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/use-patterns-setup.js
  36105. /**
  36106. * WordPress dependencies
  36107. */
  36108. /**
  36109. * Internal dependencies
  36110. */
  36111. function usePatternsSetup(clientId, blockName, filterPatternsFn) {
  36112. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  36113. const {
  36114. getBlockRootClientId,
  36115. __experimentalGetPatternsByBlockTypes,
  36116. __experimentalGetAllowedPatterns
  36117. } = select(store);
  36118. const rootClientId = getBlockRootClientId(clientId);
  36119. if (filterPatternsFn) {
  36120. return __experimentalGetAllowedPatterns(rootClientId).filter(filterPatternsFn);
  36121. }
  36122. return __experimentalGetPatternsByBlockTypes(blockName, rootClientId);
  36123. }, [clientId, blockName, filterPatternsFn]);
  36124. }
  36125. /* harmony default export */ var use_patterns_setup = (usePatternsSetup);
  36126. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/index.js
  36127. /**
  36128. * WordPress dependencies
  36129. */
  36130. /**
  36131. * Internal dependencies
  36132. */
  36133. const SetupContent = _ref => {
  36134. let {
  36135. viewMode,
  36136. activeSlide,
  36137. patterns,
  36138. onBlockPatternSelect
  36139. } = _ref;
  36140. const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)();
  36141. const containerClass = 'block-editor-block-pattern-setup__container';
  36142. if (viewMode === VIEWMODES.carousel) {
  36143. const slideClass = new Map([[activeSlide, 'active-slide'], [activeSlide - 1, 'previous-slide'], [activeSlide + 1, 'next-slide']]);
  36144. return (0,external_wp_element_namespaceObject.createElement)("div", {
  36145. className: "block-editor-block-pattern-setup__carousel"
  36146. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  36147. className: containerClass
  36148. }, (0,external_wp_element_namespaceObject.createElement)("ul", {
  36149. className: "carousel-container"
  36150. }, patterns.map((pattern, index) => (0,external_wp_element_namespaceObject.createElement)(BlockPatternSlide, {
  36151. className: slideClass.get(index) || '',
  36152. key: pattern.name,
  36153. pattern: pattern
  36154. })))));
  36155. }
  36156. return (0,external_wp_element_namespaceObject.createElement)("div", {
  36157. className: "block-editor-block-pattern-setup__grid"
  36158. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
  36159. role: "listbox",
  36160. className: containerClass,
  36161. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Patterns list')
  36162. }), patterns.map(pattern => (0,external_wp_element_namespaceObject.createElement)(block_pattern_setup_BlockPattern, {
  36163. key: pattern.name,
  36164. pattern: pattern,
  36165. onSelect: onBlockPatternSelect,
  36166. composite: composite
  36167. }))));
  36168. };
  36169. function block_pattern_setup_BlockPattern(_ref2) {
  36170. let {
  36171. pattern,
  36172. onSelect,
  36173. composite
  36174. } = _ref2;
  36175. const baseClassName = 'block-editor-block-pattern-setup-list';
  36176. const {
  36177. blocks,
  36178. description,
  36179. viewportWidth = 700
  36180. } = pattern;
  36181. const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(block_pattern_setup_BlockPattern, `${baseClassName}__item-description`);
  36182. return (0,external_wp_element_namespaceObject.createElement)("div", {
  36183. className: `${baseClassName}__list-item`,
  36184. "aria-label": pattern.title,
  36185. "aria-describedby": pattern.description ? descriptionId : undefined
  36186. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
  36187. role: "option",
  36188. as: "div"
  36189. }, composite, {
  36190. className: `${baseClassName}__item`,
  36191. onClick: () => onSelect(blocks)
  36192. }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  36193. blocks: blocks,
  36194. viewportWidth: viewportWidth
  36195. })), !!description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  36196. id: descriptionId
  36197. }, description));
  36198. }
  36199. function BlockPatternSlide(_ref3) {
  36200. let {
  36201. className,
  36202. pattern,
  36203. minHeight
  36204. } = _ref3;
  36205. const {
  36206. blocks,
  36207. title,
  36208. description
  36209. } = pattern;
  36210. const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockPatternSlide, 'block-editor-block-pattern-setup-list__item-description');
  36211. return (0,external_wp_element_namespaceObject.createElement)("li", {
  36212. className: `pattern-slide ${className}`,
  36213. "aria-label": title,
  36214. "aria-describedby": description ? descriptionId : undefined
  36215. }, (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  36216. blocks: blocks,
  36217. __experimentalMinHeight: minHeight
  36218. }), !!description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  36219. id: descriptionId
  36220. }, description));
  36221. }
  36222. const BlockPatternSetup = _ref4 => {
  36223. let {
  36224. clientId,
  36225. blockName,
  36226. filterPatternsFn,
  36227. onBlockPatternSelect
  36228. } = _ref4;
  36229. const [viewMode, setViewMode] = (0,external_wp_element_namespaceObject.useState)(VIEWMODES.carousel);
  36230. const [activeSlide, setActiveSlide] = (0,external_wp_element_namespaceObject.useState)(0);
  36231. const {
  36232. replaceBlock
  36233. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  36234. const patterns = use_patterns_setup(clientId, blockName, filterPatternsFn);
  36235. if (!(patterns !== null && patterns !== void 0 && patterns.length)) {
  36236. return null;
  36237. }
  36238. const onBlockPatternSelectDefault = blocks => {
  36239. const clonedBlocks = blocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
  36240. replaceBlock(clientId, clonedBlocks);
  36241. };
  36242. const onPatternSelectCallback = onBlockPatternSelect || onBlockPatternSelectDefault;
  36243. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  36244. className: `block-editor-block-pattern-setup view-mode-${viewMode}`
  36245. }, (0,external_wp_element_namespaceObject.createElement)(SetupContent, {
  36246. viewMode: viewMode,
  36247. activeSlide: activeSlide,
  36248. patterns: patterns,
  36249. onBlockPatternSelect: onPatternSelectCallback
  36250. }), (0,external_wp_element_namespaceObject.createElement)(setup_toolbar, {
  36251. viewMode: viewMode,
  36252. setViewMode: setViewMode,
  36253. activeSlide: activeSlide,
  36254. totalSlides: patterns.length,
  36255. handleNext: () => {
  36256. setActiveSlide(active => active + 1);
  36257. },
  36258. handlePrevious: () => {
  36259. setActiveSlide(active => active - 1);
  36260. },
  36261. onBlockPatternSelect: () => {
  36262. onPatternSelectCallback(patterns[activeSlide].blocks);
  36263. }
  36264. })));
  36265. };
  36266. /* harmony default export */ var block_pattern_setup = (BlockPatternSetup);
  36267. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-variation-transforms/index.js
  36268. /**
  36269. * WordPress dependencies
  36270. */
  36271. /**
  36272. * Internal dependencies
  36273. */
  36274. function VariationsButtons(_ref) {
  36275. let {
  36276. className,
  36277. onSelectVariation,
  36278. selectedValue,
  36279. variations
  36280. } = _ref;
  36281. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  36282. className: className
  36283. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  36284. as: "legend"
  36285. }, (0,external_wp_i18n_namespaceObject.__)('Transform to variation')), variations.map(variation => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  36286. key: variation.name,
  36287. icon: (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  36288. icon: variation.icon,
  36289. showColors: true
  36290. }),
  36291. isPressed: selectedValue === variation.name,
  36292. label: selectedValue === variation.name ? variation.title : (0,external_wp_i18n_namespaceObject.sprintf)(
  36293. /* translators: %s: Name of the block variation */
  36294. (0,external_wp_i18n_namespaceObject.__)('Transform to %s'), variation.title),
  36295. onClick: () => onSelectVariation(variation.name),
  36296. "aria-label": variation.title,
  36297. showTooltip: true
  36298. })));
  36299. }
  36300. function VariationsDropdown(_ref2) {
  36301. let {
  36302. className,
  36303. onSelectVariation,
  36304. selectedValue,
  36305. variations
  36306. } = _ref2;
  36307. const selectOptions = variations.map(_ref3 => {
  36308. let {
  36309. name,
  36310. title,
  36311. description
  36312. } = _ref3;
  36313. return {
  36314. value: name,
  36315. label: title,
  36316. info: description
  36317. };
  36318. });
  36319. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
  36320. className: className,
  36321. label: (0,external_wp_i18n_namespaceObject.__)('Transform to variation'),
  36322. text: (0,external_wp_i18n_namespaceObject.__)('Transform to variation'),
  36323. popoverProps: {
  36324. position: 'bottom center',
  36325. className: `${className}__popover`
  36326. },
  36327. icon: chevron_down,
  36328. toggleProps: {
  36329. iconPosition: 'right'
  36330. }
  36331. }, () => (0,external_wp_element_namespaceObject.createElement)("div", {
  36332. className: `${className}__container`
  36333. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
  36334. choices: selectOptions,
  36335. value: selectedValue,
  36336. onSelect: onSelectVariation
  36337. }))));
  36338. }
  36339. function __experimentalBlockVariationTransforms(_ref4) {
  36340. let {
  36341. blockClientId
  36342. } = _ref4;
  36343. const {
  36344. updateBlockAttributes
  36345. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  36346. const {
  36347. activeBlockVariation,
  36348. variations
  36349. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  36350. const {
  36351. getActiveBlockVariation,
  36352. getBlockVariations
  36353. } = select(external_wp_blocks_namespaceObject.store);
  36354. const {
  36355. getBlockName,
  36356. getBlockAttributes
  36357. } = select(store);
  36358. const name = blockClientId && getBlockName(blockClientId);
  36359. return {
  36360. activeBlockVariation: getActiveBlockVariation(name, getBlockAttributes(blockClientId)),
  36361. variations: name && getBlockVariations(name, 'transform')
  36362. };
  36363. }, [blockClientId]);
  36364. const selectedValue = activeBlockVariation === null || activeBlockVariation === void 0 ? void 0 : activeBlockVariation.name; // Check if each variation has a unique icon.
  36365. const hasUniqueIcons = (0,external_wp_element_namespaceObject.useMemo)(() => {
  36366. const variationIcons = new Set();
  36367. if (!variations) {
  36368. return false;
  36369. }
  36370. variations.forEach(variation => {
  36371. if (variation.icon) {
  36372. var _variation$icon;
  36373. variationIcons.add(((_variation$icon = variation.icon) === null || _variation$icon === void 0 ? void 0 : _variation$icon.src) || variation.icon);
  36374. }
  36375. });
  36376. return variationIcons.size === variations.length;
  36377. }, [variations]);
  36378. const onSelectVariation = variationName => {
  36379. updateBlockAttributes(blockClientId, { ...variations.find(_ref5 => {
  36380. let {
  36381. name
  36382. } = _ref5;
  36383. return name === variationName;
  36384. }).attributes
  36385. });
  36386. };
  36387. const baseClass = 'block-editor-block-variation-transforms'; // Skip rendering if there are no variations
  36388. if (!(variations !== null && variations !== void 0 && variations.length)) return null;
  36389. const Component = hasUniqueIcons ? VariationsButtons : VariationsDropdown;
  36390. return (0,external_wp_element_namespaceObject.createElement)(Component, {
  36391. className: baseClass,
  36392. onSelectVariation: onSelectVariation,
  36393. selectedValue: selectedValue,
  36394. variations: variations
  36395. });
  36396. }
  36397. /* harmony default export */ var block_variation_transforms = (__experimentalBlockVariationTransforms);
  36398. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/with-color-context.js
  36399. /**
  36400. * External dependencies
  36401. */
  36402. /**
  36403. * WordPress dependencies
  36404. */
  36405. /**
  36406. * Internal dependencies
  36407. */
  36408. /* harmony default export */ var with_color_context = ((0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => {
  36409. return props => {
  36410. const colorsFeature = useSetting('color.palette');
  36411. const disableCustomColorsFeature = !useSetting('color.custom');
  36412. const colors = props.colors === undefined ? colorsFeature : props.colors;
  36413. const disableCustomColors = props.disableCustomColors === undefined ? disableCustomColorsFeature : props.disableCustomColors;
  36414. const hasColorsToChoose = !(0,external_lodash_namespaceObject.isEmpty)(colors) || !disableCustomColors;
  36415. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  36416. colors,
  36417. disableCustomColors,
  36418. hasColorsToChoose
  36419. }));
  36420. };
  36421. }, 'withColorContext'));
  36422. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/index.js
  36423. /**
  36424. * WordPress dependencies
  36425. */
  36426. /**
  36427. * Internal dependencies
  36428. */
  36429. /* harmony default export */ var color_palette = (with_color_context(external_wp_components_namespaceObject.ColorPalette));
  36430. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/control.js
  36431. /**
  36432. * Internal dependencies
  36433. */
  36434. function ColorPaletteControl(_ref) {
  36435. let {
  36436. onChange,
  36437. value,
  36438. ...otherProps
  36439. } = _ref;
  36440. return (0,external_wp_element_namespaceObject.createElement)(control, _extends({}, otherProps, {
  36441. onColorChange: onChange,
  36442. colorValue: value,
  36443. gradients: [],
  36444. disableCustomGradients: true
  36445. }));
  36446. }
  36447. ;// CONCATENATED MODULE: external ["wp","date"]
  36448. var external_wp_date_namespaceObject = window["wp"]["date"];
  36449. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/date-format-picker/index.js
  36450. /**
  36451. * WordPress dependencies
  36452. */
  36453. // So that we can illustrate the different formats in the dropdown properly,
  36454. // show a date that has a day greater than 12 and a month with more than three
  36455. // letters. Here we're using 2022-01-25 which is when WordPress 5.9 was
  36456. // released.
  36457. const EXAMPLE_DATE = new Date(2022, 0, 25);
  36458. /**
  36459. * The `DateFormatPicker` component renders controls that let the user choose a
  36460. * _date format_. That is, how they want their dates to be formatted.
  36461. *
  36462. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/date-format-picker/README.md
  36463. *
  36464. * @param {Object} props
  36465. * @param {string|null} props.format The selected date
  36466. * format. If
  36467. * `null`,
  36468. * _Default_ is
  36469. * selected.
  36470. * @param {string} props.defaultFormat The date format that
  36471. * will be used if the
  36472. * user selects
  36473. * 'Default'.
  36474. * @param {( format: string|null ) => void} props.onChange Called when a
  36475. * selection is
  36476. * made. If `null`,
  36477. * _Default_ is
  36478. * selected.
  36479. */
  36480. function DateFormatPicker(_ref) {
  36481. let {
  36482. format,
  36483. defaultFormat,
  36484. onChange
  36485. } = _ref;
  36486. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  36487. className: "block-editor-date-format-picker"
  36488. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  36489. as: "legend"
  36490. }, (0,external_wp_i18n_namespaceObject.__)('Date format')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  36491. label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Default format'), (0,external_wp_element_namespaceObject.createElement)("span", {
  36492. className: "block-editor-date-format-picker__default-format-toggle-control__hint"
  36493. }, (0,external_wp_date_namespaceObject.dateI18n)(defaultFormat, EXAMPLE_DATE))),
  36494. checked: !format,
  36495. onChange: checked => onChange(checked ? null : defaultFormat)
  36496. }), format && (0,external_wp_element_namespaceObject.createElement)(NonDefaultControls, {
  36497. format: format,
  36498. onChange: onChange
  36499. }));
  36500. }
  36501. function NonDefaultControls(_ref2) {
  36502. var _suggestedOptions$fin;
  36503. let {
  36504. format,
  36505. onChange
  36506. } = _ref2;
  36507. // Suggest a short format, medium format, long format, and a standardised
  36508. // (YYYY-MM-DD) format. The short, medium, and long formats are localised as
  36509. // different languages have different ways of writing these. For example, 'F
  36510. // j, Y' (April 20, 2022) in American English (en_US) is 'j. F Y' (20. April
  36511. // 2022) in German (de). The resultant array is de-duplicated as some
  36512. // languages will use the same format string for short, medium, and long
  36513. // formats.
  36514. const suggestedFormats = [...new Set(['Y-m-d', (0,external_wp_i18n_namespaceObject._x)('n/j/Y', 'short date format'), (0,external_wp_i18n_namespaceObject._x)('n/j/Y g:i A', 'short date format with time'), (0,external_wp_i18n_namespaceObject._x)('M j, Y', 'medium date format'), (0,external_wp_i18n_namespaceObject._x)('M j, Y g:i A', 'medium date format with time'), (0,external_wp_i18n_namespaceObject._x)('F j, Y', 'long date format'), (0,external_wp_i18n_namespaceObject._x)('M j', 'short date format without the year')])];
  36515. const suggestedOptions = suggestedFormats.map((suggestedFormat, index) => ({
  36516. key: `suggested-${index}`,
  36517. name: (0,external_wp_date_namespaceObject.dateI18n)(suggestedFormat, EXAMPLE_DATE),
  36518. format: suggestedFormat
  36519. }));
  36520. const customOption = {
  36521. key: 'custom',
  36522. name: (0,external_wp_i18n_namespaceObject.__)('Custom'),
  36523. className: 'block-editor-date-format-picker__custom-format-select-control__custom-option',
  36524. __experimentalHint: (0,external_wp_i18n_namespaceObject.__)('Enter your own date format')
  36525. };
  36526. const [isCustom, setIsCustom] = (0,external_wp_element_namespaceObject.useState)(() => !!format && !suggestedFormats.includes(format));
  36527. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, {
  36528. className: "block-editor-date-format-picker__custom-format-select-control"
  36529. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CustomSelectControl, {
  36530. __nextUnconstrainedWidth: true,
  36531. label: (0,external_wp_i18n_namespaceObject.__)('Choose a format'),
  36532. options: [...suggestedOptions, customOption],
  36533. value: isCustom ? customOption : (_suggestedOptions$fin = suggestedOptions.find(option => option.format === format)) !== null && _suggestedOptions$fin !== void 0 ? _suggestedOptions$fin : customOption,
  36534. onChange: _ref3 => {
  36535. let {
  36536. selectedItem
  36537. } = _ref3;
  36538. if (selectedItem === customOption) {
  36539. setIsCustom(true);
  36540. } else {
  36541. setIsCustom(false);
  36542. onChange(selectedItem.format);
  36543. }
  36544. }
  36545. })), isCustom && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  36546. label: (0,external_wp_i18n_namespaceObject.__)('Custom format'),
  36547. hideLabelFromVision: true,
  36548. help: (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Enter a date or time <Link>format string</Link>.'), {
  36549. Link: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  36550. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/formatting-date-and-time/')
  36551. })
  36552. }),
  36553. value: format,
  36554. onChange: value => onChange(value)
  36555. }));
  36556. }
  36557. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/panel-color-gradient-settings.js
  36558. /**
  36559. * External dependencies
  36560. */
  36561. /**
  36562. * WordPress dependencies
  36563. */
  36564. /**
  36565. * Internal dependencies
  36566. */
  36567. const panel_color_gradient_settings_colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients'];
  36568. const PanelColorGradientSettingsInner = _ref => {
  36569. let {
  36570. className,
  36571. colors,
  36572. gradients,
  36573. disableCustomColors,
  36574. disableCustomGradients,
  36575. children,
  36576. settings,
  36577. title,
  36578. showTitle = true,
  36579. __experimentalHasMultipleOrigins,
  36580. __experimentalIsRenderedInSidebar,
  36581. enableAlpha
  36582. } = _ref;
  36583. const panelId = (0,external_wp_compose_namespaceObject.useInstanceId)(PanelColorGradientSettingsInner);
  36584. const {
  36585. batch
  36586. } = (0,external_wp_data_namespaceObject.useRegistry)();
  36587. if ((0,external_lodash_namespaceObject.isEmpty)(colors) && (0,external_lodash_namespaceObject.isEmpty)(gradients) && disableCustomColors && disableCustomGradients && (0,external_lodash_namespaceObject.every)(settings, setting => (0,external_lodash_namespaceObject.isEmpty)(setting.colors) && (0,external_lodash_namespaceObject.isEmpty)(setting.gradients) && (setting.disableCustomColors === undefined || setting.disableCustomColors) && (setting.disableCustomGradients === undefined || setting.disableCustomGradients))) {
  36588. return null;
  36589. }
  36590. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, {
  36591. className: classnames_default()('block-editor-panel-color-gradient-settings', className),
  36592. label: showTitle ? title : undefined,
  36593. resetAll: () => {
  36594. batch(() => {
  36595. settings.forEach(_ref2 => {
  36596. let {
  36597. colorValue,
  36598. gradientValue,
  36599. onColorChange,
  36600. onGradientChange
  36601. } = _ref2;
  36602. if (colorValue) {
  36603. onColorChange();
  36604. } else if (gradientValue) {
  36605. onGradientChange();
  36606. }
  36607. });
  36608. });
  36609. },
  36610. panelId: panelId,
  36611. __experimentalFirstVisibleItemClass: "first",
  36612. __experimentalLastVisibleItemClass: "last"
  36613. }, (0,external_wp_element_namespaceObject.createElement)(ColorGradientSettingsDropdown, {
  36614. settings: settings,
  36615. panelId: panelId,
  36616. colors,
  36617. gradients,
  36618. disableCustomColors,
  36619. disableCustomGradients,
  36620. __experimentalHasMultipleOrigins,
  36621. __experimentalIsRenderedInSidebar,
  36622. enableAlpha
  36623. }), !!children && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
  36624. marginY: 4
  36625. }), " ", children));
  36626. };
  36627. const PanelColorGradientSettingsSingleSelect = props => {
  36628. const colorGradientSettings = useCommonSingleMultipleSelects();
  36629. colorGradientSettings.colors = useSetting('color.palette');
  36630. colorGradientSettings.gradients = useSetting('color.gradients');
  36631. return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsInner, _extends({}, colorGradientSettings, props));
  36632. };
  36633. const PanelColorGradientSettingsMultipleSelect = props => {
  36634. const colorGradientSettings = useMultipleOriginColorsAndGradients();
  36635. return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsInner, _extends({}, colorGradientSettings, props));
  36636. };
  36637. const PanelColorGradientSettings = props => {
  36638. if ((0,external_lodash_namespaceObject.every)(panel_color_gradient_settings_colorsAndGradientKeys, key => props.hasOwnProperty(key))) {
  36639. return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsInner, props);
  36640. }
  36641. if (props.__experimentalHasMultipleOrigins) {
  36642. return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsMultipleSelect, props);
  36643. }
  36644. return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsSingleSelect, props);
  36645. };
  36646. /* harmony default export */ var panel_color_gradient_settings = (PanelColorGradientSettings);
  36647. ;// CONCATENATED MODULE: ./node_modules/react-easy-crop/node_modules/tslib/tslib.es6.js
  36648. /*! *****************************************************************************
  36649. Copyright (c) Microsoft Corporation.
  36650. Permission to use, copy, modify, and/or distribute this software for any
  36651. purpose with or without fee is hereby granted.
  36652. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  36653. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  36654. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  36655. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  36656. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  36657. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  36658. PERFORMANCE OF THIS SOFTWARE.
  36659. ***************************************************************************** */
  36660. /* global Reflect, Promise */
  36661. var extendStatics = function(d, b) {
  36662. extendStatics = Object.setPrototypeOf ||
  36663. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36664. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  36665. return extendStatics(d, b);
  36666. };
  36667. function __extends(d, b) {
  36668. extendStatics(d, b);
  36669. function __() { this.constructor = d; }
  36670. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36671. }
  36672. var __assign = function() {
  36673. __assign = Object.assign || function __assign(t) {
  36674. for (var s, i = 1, n = arguments.length; i < n; i++) {
  36675. s = arguments[i];
  36676. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  36677. }
  36678. return t;
  36679. }
  36680. return __assign.apply(this, arguments);
  36681. }
  36682. function __rest(s, e) {
  36683. var t = {};
  36684. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  36685. t[p] = s[p];
  36686. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  36687. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  36688. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  36689. t[p[i]] = s[p[i]];
  36690. }
  36691. return t;
  36692. }
  36693. function __decorate(decorators, target, key, desc) {
  36694. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  36695. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  36696. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  36697. return c > 3 && r && Object.defineProperty(target, key, r), r;
  36698. }
  36699. function __param(paramIndex, decorator) {
  36700. return function (target, key) { decorator(target, key, paramIndex); }
  36701. }
  36702. function __metadata(metadataKey, metadataValue) {
  36703. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  36704. }
  36705. function __awaiter(thisArg, _arguments, P, generator) {
  36706. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  36707. return new (P || (P = Promise))(function (resolve, reject) {
  36708. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  36709. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  36710. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  36711. step((generator = generator.apply(thisArg, _arguments || [])).next());
  36712. });
  36713. }
  36714. function __generator(thisArg, body) {
  36715. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  36716. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  36717. function verb(n) { return function (v) { return step([n, v]); }; }
  36718. function step(op) {
  36719. if (f) throw new TypeError("Generator is already executing.");
  36720. while (_) try {
  36721. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  36722. if (y = 0, t) op = [op[0] & 2, t.value];
  36723. switch (op[0]) {
  36724. case 0: case 1: t = op; break;
  36725. case 4: _.label++; return { value: op[1], done: false };
  36726. case 5: _.label++; y = op[1]; op = [0]; continue;
  36727. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  36728. default:
  36729. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  36730. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  36731. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  36732. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  36733. if (t[2]) _.ops.pop();
  36734. _.trys.pop(); continue;
  36735. }
  36736. op = body.call(thisArg, _);
  36737. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  36738. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  36739. }
  36740. }
  36741. var __createBinding = Object.create ? (function(o, m, k, k2) {
  36742. if (k2 === undefined) k2 = k;
  36743. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  36744. }) : (function(o, m, k, k2) {
  36745. if (k2 === undefined) k2 = k;
  36746. o[k2] = m[k];
  36747. });
  36748. function __exportStar(m, o) {
  36749. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
  36750. }
  36751. function __values(o) {
  36752. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  36753. if (m) return m.call(o);
  36754. if (o && typeof o.length === "number") return {
  36755. next: function () {
  36756. if (o && i >= o.length) o = void 0;
  36757. return { value: o && o[i++], done: !o };
  36758. }
  36759. };
  36760. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  36761. }
  36762. function __read(o, n) {
  36763. var m = typeof Symbol === "function" && o[Symbol.iterator];
  36764. if (!m) return o;
  36765. var i = m.call(o), r, ar = [], e;
  36766. try {
  36767. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  36768. }
  36769. catch (error) { e = { error: error }; }
  36770. finally {
  36771. try {
  36772. if (r && !r.done && (m = i["return"])) m.call(i);
  36773. }
  36774. finally { if (e) throw e.error; }
  36775. }
  36776. return ar;
  36777. }
  36778. function __spread() {
  36779. for (var ar = [], i = 0; i < arguments.length; i++)
  36780. ar = ar.concat(__read(arguments[i]));
  36781. return ar;
  36782. }
  36783. function __spreadArrays() {
  36784. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  36785. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  36786. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  36787. r[k] = a[j];
  36788. return r;
  36789. };
  36790. function __await(v) {
  36791. return this instanceof __await ? (this.v = v, this) : new __await(v);
  36792. }
  36793. function __asyncGenerator(thisArg, _arguments, generator) {
  36794. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  36795. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  36796. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  36797. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  36798. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  36799. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  36800. function fulfill(value) { resume("next", value); }
  36801. function reject(value) { resume("throw", value); }
  36802. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  36803. }
  36804. function __asyncDelegator(o) {
  36805. var i, p;
  36806. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  36807. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  36808. }
  36809. function __asyncValues(o) {
  36810. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  36811. var m = o[Symbol.asyncIterator], i;
  36812. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  36813. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  36814. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  36815. }
  36816. function __makeTemplateObject(cooked, raw) {
  36817. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  36818. return cooked;
  36819. };
  36820. var __setModuleDefault = Object.create ? (function(o, v) {
  36821. Object.defineProperty(o, "default", { enumerable: true, value: v });
  36822. }) : function(o, v) {
  36823. o["default"] = v;
  36824. };
  36825. function __importStar(mod) {
  36826. if (mod && mod.__esModule) return mod;
  36827. var result = {};
  36828. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  36829. __setModuleDefault(result, mod);
  36830. return result;
  36831. }
  36832. function __importDefault(mod) {
  36833. return (mod && mod.__esModule) ? mod : { default: mod };
  36834. }
  36835. function __classPrivateFieldGet(receiver, privateMap) {
  36836. if (!privateMap.has(receiver)) {
  36837. throw new TypeError("attempted to get private field on non-instance");
  36838. }
  36839. return privateMap.get(receiver);
  36840. }
  36841. function __classPrivateFieldSet(receiver, privateMap, value) {
  36842. if (!privateMap.has(receiver)) {
  36843. throw new TypeError("attempted to set private field on non-instance");
  36844. }
  36845. privateMap.set(receiver, value);
  36846. return value;
  36847. }
  36848. // EXTERNAL MODULE: ./node_modules/normalize-wheel/index.js
  36849. var normalize_wheel = __webpack_require__(7970);
  36850. var normalize_wheel_default = /*#__PURE__*/__webpack_require__.n(normalize_wheel);
  36851. ;// CONCATENATED MODULE: ./node_modules/react-easy-crop/index.module.js
  36852. /**
  36853. * Compute the dimension of the crop area based on media size,
  36854. * aspect ratio and optionally rotation
  36855. */
  36856. function getCropSize(mediaWidth, mediaHeight, containerWidth, containerHeight, aspect, rotation) {
  36857. if (rotation === void 0) {
  36858. rotation = 0;
  36859. }
  36860. var _a = rotateSize(mediaWidth, mediaHeight, rotation),
  36861. width = _a.width,
  36862. height = _a.height;
  36863. var fittingWidth = Math.min(width, containerWidth);
  36864. var fittingHeight = Math.min(height, containerHeight);
  36865. if (fittingWidth > fittingHeight * aspect) {
  36866. return {
  36867. width: fittingHeight * aspect,
  36868. height: fittingHeight
  36869. };
  36870. }
  36871. return {
  36872. width: fittingWidth,
  36873. height: fittingWidth / aspect
  36874. };
  36875. }
  36876. /**
  36877. * Compute media zoom.
  36878. * We fit the media into the container with "max-width: 100%; max-height: 100%;"
  36879. */
  36880. function getMediaZoom(mediaSize) {
  36881. // Take the axis with more pixels to improve accuracy
  36882. return mediaSize.width > mediaSize.height ? mediaSize.width / mediaSize.naturalWidth : mediaSize.height / mediaSize.naturalHeight;
  36883. }
  36884. /**
  36885. * Ensure a new media position stays in the crop area.
  36886. */
  36887. function restrictPosition(position, mediaSize, cropSize, zoom, rotation) {
  36888. if (rotation === void 0) {
  36889. rotation = 0;
  36890. }
  36891. var _a = rotateSize(mediaSize.width, mediaSize.height, rotation),
  36892. width = _a.width,
  36893. height = _a.height;
  36894. return {
  36895. x: restrictPositionCoord(position.x, width, cropSize.width, zoom),
  36896. y: restrictPositionCoord(position.y, height, cropSize.height, zoom)
  36897. };
  36898. }
  36899. function restrictPositionCoord(position, mediaSize, cropSize, zoom) {
  36900. var maxPosition = mediaSize * zoom / 2 - cropSize / 2;
  36901. return clamp(position, -maxPosition, maxPosition);
  36902. }
  36903. function getDistanceBetweenPoints(pointA, pointB) {
  36904. return Math.sqrt(Math.pow(pointA.y - pointB.y, 2) + Math.pow(pointA.x - pointB.x, 2));
  36905. }
  36906. function getRotationBetweenPoints(pointA, pointB) {
  36907. return Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x) * 180 / Math.PI;
  36908. }
  36909. /**
  36910. * Compute the output cropped area of the media in percentages and pixels.
  36911. * x/y are the top-left coordinates on the src media
  36912. */
  36913. function computeCroppedArea(crop, mediaSize, cropSize, aspect, zoom, rotation, restrictPosition) {
  36914. if (rotation === void 0) {
  36915. rotation = 0;
  36916. }
  36917. if (restrictPosition === void 0) {
  36918. restrictPosition = true;
  36919. } // if the media is rotated by the user, we cannot limit the position anymore
  36920. // as it might need to be negative.
  36921. var limitAreaFn = restrictPosition ? limitArea : noOp;
  36922. var mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation);
  36923. var mediaNaturalBBoxSize = rotateSize(mediaSize.naturalWidth, mediaSize.naturalHeight, rotation); // calculate the crop area in percentages
  36924. // in the rotated space
  36925. var croppedAreaPercentages = {
  36926. x: limitAreaFn(100, ((mediaBBoxSize.width - cropSize.width / zoom) / 2 - crop.x / zoom) / mediaBBoxSize.width * 100),
  36927. y: limitAreaFn(100, ((mediaBBoxSize.height - cropSize.height / zoom) / 2 - crop.y / zoom) / mediaBBoxSize.height * 100),
  36928. width: limitAreaFn(100, cropSize.width / mediaBBoxSize.width * 100 / zoom),
  36929. height: limitAreaFn(100, cropSize.height / mediaBBoxSize.height * 100 / zoom)
  36930. }; // we compute the pixels size naively
  36931. var widthInPixels = Math.round(limitAreaFn(mediaNaturalBBoxSize.width, croppedAreaPercentages.width * mediaNaturalBBoxSize.width / 100));
  36932. var heightInPixels = Math.round(limitAreaFn(mediaNaturalBBoxSize.height, croppedAreaPercentages.height * mediaNaturalBBoxSize.height / 100));
  36933. var isImgWiderThanHigh = mediaNaturalBBoxSize.width >= mediaNaturalBBoxSize.height * aspect; // then we ensure the width and height exactly match the aspect (to avoid rounding approximations)
  36934. // if the media is wider than high, when zoom is 0, the crop height will be equals to image height
  36935. // thus we want to compute the width from the height and aspect for accuracy.
  36936. // Otherwise, we compute the height from width and aspect.
  36937. var sizePixels = isImgWiderThanHigh ? {
  36938. width: Math.round(heightInPixels * aspect),
  36939. height: heightInPixels
  36940. } : {
  36941. width: widthInPixels,
  36942. height: Math.round(widthInPixels / aspect)
  36943. };
  36944. var croppedAreaPixels = __assign(__assign({}, sizePixels), {
  36945. x: Math.round(limitAreaFn(mediaNaturalBBoxSize.width - sizePixels.width, croppedAreaPercentages.x * mediaNaturalBBoxSize.width / 100)),
  36946. y: Math.round(limitAreaFn(mediaNaturalBBoxSize.height - sizePixels.height, croppedAreaPercentages.y * mediaNaturalBBoxSize.height / 100))
  36947. });
  36948. return {
  36949. croppedAreaPercentages: croppedAreaPercentages,
  36950. croppedAreaPixels: croppedAreaPixels
  36951. };
  36952. }
  36953. /**
  36954. * Ensure the returned value is between 0 and max
  36955. */
  36956. function limitArea(max, value) {
  36957. return Math.min(max, Math.max(0, value));
  36958. }
  36959. function noOp(_max, value) {
  36960. return value;
  36961. }
  36962. /**
  36963. * Compute crop and zoom from the croppedAreaPercentages.
  36964. */
  36965. function getInitialCropFromCroppedAreaPercentages(croppedAreaPercentages, mediaSize, rotation, cropSize, minZoom, maxZoom) {
  36966. var mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation); // This is the inverse process of computeCroppedArea
  36967. var zoom = clamp(cropSize.width / mediaBBoxSize.width * (100 / croppedAreaPercentages.width), minZoom, maxZoom);
  36968. var crop = {
  36969. x: zoom * mediaBBoxSize.width / 2 - cropSize.width / 2 - mediaBBoxSize.width * zoom * (croppedAreaPercentages.x / 100),
  36970. y: zoom * mediaBBoxSize.height / 2 - cropSize.height / 2 - mediaBBoxSize.height * zoom * (croppedAreaPercentages.y / 100)
  36971. };
  36972. return {
  36973. crop: crop,
  36974. zoom: zoom
  36975. };
  36976. }
  36977. /**
  36978. * Compute zoom from the croppedAreaPixels
  36979. */
  36980. function getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize) {
  36981. var mediaZoom = getMediaZoom(mediaSize);
  36982. return cropSize.height > cropSize.width ? cropSize.height / (croppedAreaPixels.height * mediaZoom) : cropSize.width / (croppedAreaPixels.width * mediaZoom);
  36983. }
  36984. /**
  36985. * Compute crop and zoom from the croppedAreaPixels
  36986. */
  36987. function getInitialCropFromCroppedAreaPixels(croppedAreaPixels, mediaSize, rotation, cropSize, minZoom, maxZoom) {
  36988. if (rotation === void 0) {
  36989. rotation = 0;
  36990. }
  36991. var mediaNaturalBBoxSize = rotateSize(mediaSize.naturalWidth, mediaSize.naturalHeight, rotation);
  36992. var zoom = clamp(getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize), minZoom, maxZoom);
  36993. var cropZoom = cropSize.height > cropSize.width ? cropSize.height / croppedAreaPixels.height : cropSize.width / croppedAreaPixels.width;
  36994. var crop = {
  36995. x: ((mediaNaturalBBoxSize.width - croppedAreaPixels.width) / 2 - croppedAreaPixels.x) * cropZoom,
  36996. y: ((mediaNaturalBBoxSize.height - croppedAreaPixels.height) / 2 - croppedAreaPixels.y) * cropZoom
  36997. };
  36998. return {
  36999. crop: crop,
  37000. zoom: zoom
  37001. };
  37002. }
  37003. /**
  37004. * Return the point that is the center of point a and b
  37005. */
  37006. function getCenter(a, b) {
  37007. return {
  37008. x: (b.x + a.x) / 2,
  37009. y: (b.y + a.y) / 2
  37010. };
  37011. }
  37012. function getRadianAngle(degreeValue) {
  37013. return degreeValue * Math.PI / 180;
  37014. }
  37015. /**
  37016. * Returns the new bounding area of a rotated rectangle.
  37017. */
  37018. function rotateSize(width, height, rotation) {
  37019. var rotRad = getRadianAngle(rotation);
  37020. return {
  37021. width: Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height),
  37022. height: Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height)
  37023. };
  37024. }
  37025. /**
  37026. * Clamp value between min and max
  37027. */
  37028. function clamp(value, min, max) {
  37029. return Math.min(Math.max(value, min), max);
  37030. }
  37031. /**
  37032. * Combine multiple class names into a single string.
  37033. */
  37034. function classNames() {
  37035. var args = [];
  37036. for (var _i = 0; _i < arguments.length; _i++) {
  37037. args[_i] = arguments[_i];
  37038. }
  37039. return args.filter(function (value) {
  37040. if (typeof value === 'string' && value.length > 0) {
  37041. return true;
  37042. }
  37043. return false;
  37044. }).join(' ').trim();
  37045. }
  37046. var css_248z = ".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n";
  37047. var MIN_ZOOM = 1;
  37048. var MAX_ZOOM = 3;
  37049. var Cropper =
  37050. /** @class */
  37051. function (_super) {
  37052. __extends(Cropper, _super);
  37053. function Cropper() {
  37054. var _this = _super !== null && _super.apply(this, arguments) || this;
  37055. _this.imageRef = /*#__PURE__*/external_React_default().createRef();
  37056. _this.videoRef = /*#__PURE__*/external_React_default().createRef();
  37057. _this.containerRef = null;
  37058. _this.styleRef = null;
  37059. _this.containerRect = null;
  37060. _this.mediaSize = {
  37061. width: 0,
  37062. height: 0,
  37063. naturalWidth: 0,
  37064. naturalHeight: 0
  37065. };
  37066. _this.dragStartPosition = {
  37067. x: 0,
  37068. y: 0
  37069. };
  37070. _this.dragStartCrop = {
  37071. x: 0,
  37072. y: 0
  37073. };
  37074. _this.gestureZoomStart = 0;
  37075. _this.gestureRotationStart = 0;
  37076. _this.isTouching = false;
  37077. _this.lastPinchDistance = 0;
  37078. _this.lastPinchRotation = 0;
  37079. _this.rafDragTimeout = null;
  37080. _this.rafPinchTimeout = null;
  37081. _this.wheelTimer = null;
  37082. _this.currentDoc = document;
  37083. _this.currentWindow = window;
  37084. _this.state = {
  37085. cropSize: null,
  37086. hasWheelJustStarted: false
  37087. }; // this is to prevent Safari on iOS >= 10 to zoom the page
  37088. _this.preventZoomSafari = function (e) {
  37089. return e.preventDefault();
  37090. };
  37091. _this.cleanEvents = function () {
  37092. _this.currentDoc.removeEventListener('mousemove', _this.onMouseMove);
  37093. _this.currentDoc.removeEventListener('mouseup', _this.onDragStopped);
  37094. _this.currentDoc.removeEventListener('touchmove', _this.onTouchMove);
  37095. _this.currentDoc.removeEventListener('touchend', _this.onDragStopped);
  37096. _this.currentDoc.removeEventListener('gesturemove', _this.onGestureMove);
  37097. _this.currentDoc.removeEventListener('gestureend', _this.onGestureEnd);
  37098. };
  37099. _this.clearScrollEvent = function () {
  37100. if (_this.containerRef) _this.containerRef.removeEventListener('wheel', _this.onWheel);
  37101. if (_this.wheelTimer) {
  37102. clearTimeout(_this.wheelTimer);
  37103. }
  37104. };
  37105. _this.onMediaLoad = function () {
  37106. var cropSize = _this.computeSizes();
  37107. if (cropSize) {
  37108. _this.emitCropData();
  37109. _this.setInitialCrop(cropSize);
  37110. }
  37111. if (_this.props.onMediaLoaded) {
  37112. _this.props.onMediaLoaded(_this.mediaSize);
  37113. }
  37114. };
  37115. _this.setInitialCrop = function (cropSize) {
  37116. if (_this.props.initialCroppedAreaPercentages) {
  37117. var _a = getInitialCropFromCroppedAreaPercentages(_this.props.initialCroppedAreaPercentages, _this.mediaSize, _this.props.rotation, cropSize, _this.props.minZoom, _this.props.maxZoom),
  37118. crop = _a.crop,
  37119. zoom = _a.zoom;
  37120. _this.props.onCropChange(crop);
  37121. _this.props.onZoomChange && _this.props.onZoomChange(zoom);
  37122. } else if (_this.props.initialCroppedAreaPixels) {
  37123. var _b = getInitialCropFromCroppedAreaPixels(_this.props.initialCroppedAreaPixels, _this.mediaSize, _this.props.rotation, cropSize, _this.props.minZoom, _this.props.maxZoom),
  37124. crop = _b.crop,
  37125. zoom = _b.zoom;
  37126. _this.props.onCropChange(crop);
  37127. _this.props.onZoomChange && _this.props.onZoomChange(zoom);
  37128. }
  37129. };
  37130. _this.computeSizes = function () {
  37131. var _a, _b, _c, _d, _e, _f;
  37132. var mediaRef = _this.imageRef.current || _this.videoRef.current;
  37133. if (mediaRef && _this.containerRef) {
  37134. _this.containerRect = _this.containerRef.getBoundingClientRect();
  37135. var containerAspect = _this.containerRect.width / _this.containerRect.height;
  37136. var naturalWidth = ((_a = _this.imageRef.current) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = _this.videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0;
  37137. var naturalHeight = ((_c = _this.imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = _this.videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0;
  37138. var isMediaScaledDown = mediaRef.offsetWidth < naturalWidth || mediaRef.offsetHeight < naturalHeight;
  37139. var mediaAspect = naturalWidth / naturalHeight; // We do not rely on the offsetWidth/offsetHeight if the media is scaled down
  37140. // as the values they report are rounded. That will result in precision losses
  37141. // when calculating zoom. We use the fact that the media is positionned relative
  37142. // to the container. That allows us to use the container's dimensions
  37143. // and natural aspect ratio of the media to calculate accurate media size.
  37144. // However, for this to work, the container should not be rotated
  37145. var renderedMediaSize = void 0;
  37146. if (isMediaScaledDown) {
  37147. switch (_this.props.objectFit) {
  37148. default:
  37149. case 'contain':
  37150. renderedMediaSize = containerAspect > mediaAspect ? {
  37151. width: _this.containerRect.height * mediaAspect,
  37152. height: _this.containerRect.height
  37153. } : {
  37154. width: _this.containerRect.width,
  37155. height: _this.containerRect.width / mediaAspect
  37156. };
  37157. break;
  37158. case 'horizontal-cover':
  37159. renderedMediaSize = {
  37160. width: _this.containerRect.width,
  37161. height: _this.containerRect.width / mediaAspect
  37162. };
  37163. break;
  37164. case 'vertical-cover':
  37165. renderedMediaSize = {
  37166. width: _this.containerRect.height * mediaAspect,
  37167. height: _this.containerRect.height
  37168. };
  37169. break;
  37170. case 'auto-cover':
  37171. renderedMediaSize = naturalWidth > naturalHeight ? {
  37172. width: _this.containerRect.width,
  37173. height: _this.containerRect.width / mediaAspect
  37174. } : {
  37175. width: _this.containerRect.height * mediaAspect,
  37176. height: _this.containerRect.height
  37177. };
  37178. break;
  37179. }
  37180. } else {
  37181. renderedMediaSize = {
  37182. width: mediaRef.offsetWidth,
  37183. height: mediaRef.offsetHeight
  37184. };
  37185. }
  37186. _this.mediaSize = __assign(__assign({}, renderedMediaSize), {
  37187. naturalWidth: naturalWidth,
  37188. naturalHeight: naturalHeight
  37189. }); // set media size in the parent
  37190. if (_this.props.setMediaSize) {
  37191. _this.props.setMediaSize(_this.mediaSize);
  37192. }
  37193. var cropSize = _this.props.cropSize ? _this.props.cropSize : getCropSize(_this.mediaSize.width, _this.mediaSize.height, _this.containerRect.width, _this.containerRect.height, _this.props.aspect, _this.props.rotation);
  37194. if (((_e = _this.state.cropSize) === null || _e === void 0 ? void 0 : _e.height) !== cropSize.height || ((_f = _this.state.cropSize) === null || _f === void 0 ? void 0 : _f.width) !== cropSize.width) {
  37195. _this.props.onCropSizeChange && _this.props.onCropSizeChange(cropSize);
  37196. }
  37197. _this.setState({
  37198. cropSize: cropSize
  37199. }, _this.recomputeCropPosition); // pass crop size to parent
  37200. if (_this.props.setCropSize) {
  37201. _this.props.setCropSize(cropSize);
  37202. }
  37203. return cropSize;
  37204. }
  37205. };
  37206. _this.onMouseDown = function (e) {
  37207. e.preventDefault();
  37208. _this.currentDoc.addEventListener('mousemove', _this.onMouseMove);
  37209. _this.currentDoc.addEventListener('mouseup', _this.onDragStopped);
  37210. _this.onDragStart(Cropper.getMousePoint(e));
  37211. };
  37212. _this.onMouseMove = function (e) {
  37213. return _this.onDrag(Cropper.getMousePoint(e));
  37214. };
  37215. _this.onTouchStart = function (e) {
  37216. _this.isTouching = true;
  37217. if (_this.props.onTouchRequest && !_this.props.onTouchRequest(e)) {
  37218. return;
  37219. }
  37220. _this.currentDoc.addEventListener('touchmove', _this.onTouchMove, {
  37221. passive: false
  37222. }); // iOS 11 now defaults to passive: true
  37223. _this.currentDoc.addEventListener('touchend', _this.onDragStopped);
  37224. if (e.touches.length === 2) {
  37225. _this.onPinchStart(e);
  37226. } else if (e.touches.length === 1) {
  37227. _this.onDragStart(Cropper.getTouchPoint(e.touches[0]));
  37228. }
  37229. };
  37230. _this.onTouchMove = function (e) {
  37231. // Prevent whole page from scrolling on iOS.
  37232. e.preventDefault();
  37233. if (e.touches.length === 2) {
  37234. _this.onPinchMove(e);
  37235. } else if (e.touches.length === 1) {
  37236. _this.onDrag(Cropper.getTouchPoint(e.touches[0]));
  37237. }
  37238. };
  37239. _this.onGestureStart = function (e) {
  37240. e.preventDefault();
  37241. _this.currentDoc.addEventListener('gesturechange', _this.onGestureMove);
  37242. _this.currentDoc.addEventListener('gestureend', _this.onGestureEnd);
  37243. _this.gestureZoomStart = _this.props.zoom;
  37244. _this.gestureRotationStart = _this.props.rotation;
  37245. };
  37246. _this.onGestureMove = function (e) {
  37247. e.preventDefault();
  37248. if (_this.isTouching) {
  37249. // this is to avoid conflict between gesture and touch events
  37250. return;
  37251. }
  37252. var point = Cropper.getMousePoint(e);
  37253. var newZoom = _this.gestureZoomStart - 1 + e.scale;
  37254. _this.setNewZoom(newZoom, point, {
  37255. shouldUpdatePosition: true
  37256. });
  37257. if (_this.props.onRotationChange) {
  37258. var newRotation = _this.gestureRotationStart + e.rotation;
  37259. _this.props.onRotationChange(newRotation);
  37260. }
  37261. };
  37262. _this.onGestureEnd = function (e) {
  37263. _this.cleanEvents();
  37264. };
  37265. _this.onDragStart = function (_a) {
  37266. var _b, _c;
  37267. var x = _a.x,
  37268. y = _a.y;
  37269. _this.dragStartPosition = {
  37270. x: x,
  37271. y: y
  37272. };
  37273. _this.dragStartCrop = __assign({}, _this.props.crop);
  37274. (_c = (_b = _this.props).onInteractionStart) === null || _c === void 0 ? void 0 : _c.call(_b);
  37275. };
  37276. _this.onDrag = function (_a) {
  37277. var x = _a.x,
  37278. y = _a.y;
  37279. if (_this.rafDragTimeout) _this.currentWindow.cancelAnimationFrame(_this.rafDragTimeout);
  37280. _this.rafDragTimeout = _this.currentWindow.requestAnimationFrame(function () {
  37281. if (!_this.state.cropSize) return;
  37282. if (x === undefined || y === undefined) return;
  37283. var offsetX = x - _this.dragStartPosition.x;
  37284. var offsetY = y - _this.dragStartPosition.y;
  37285. var requestedPosition = {
  37286. x: _this.dragStartCrop.x + offsetX,
  37287. y: _this.dragStartCrop.y + offsetY
  37288. };
  37289. var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : requestedPosition;
  37290. _this.props.onCropChange(newPosition);
  37291. });
  37292. };
  37293. _this.onDragStopped = function () {
  37294. var _a, _b;
  37295. _this.isTouching = false;
  37296. _this.cleanEvents();
  37297. _this.emitCropData();
  37298. (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
  37299. };
  37300. _this.onWheel = function (e) {
  37301. if (_this.props.onWheelRequest && !_this.props.onWheelRequest(e)) {
  37302. return;
  37303. }
  37304. e.preventDefault();
  37305. var point = Cropper.getMousePoint(e);
  37306. var pixelY = normalize_wheel_default()(e).pixelY;
  37307. var newZoom = _this.props.zoom - pixelY * _this.props.zoomSpeed / 200;
  37308. _this.setNewZoom(newZoom, point, {
  37309. shouldUpdatePosition: true
  37310. });
  37311. if (!_this.state.hasWheelJustStarted) {
  37312. _this.setState({
  37313. hasWheelJustStarted: true
  37314. }, function () {
  37315. var _a, _b;
  37316. return (_b = (_a = _this.props).onInteractionStart) === null || _b === void 0 ? void 0 : _b.call(_a);
  37317. });
  37318. }
  37319. if (_this.wheelTimer) {
  37320. clearTimeout(_this.wheelTimer);
  37321. }
  37322. _this.wheelTimer = _this.currentWindow.setTimeout(function () {
  37323. return _this.setState({
  37324. hasWheelJustStarted: false
  37325. }, function () {
  37326. var _a, _b;
  37327. return (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
  37328. });
  37329. }, 250);
  37330. };
  37331. _this.getPointOnContainer = function (_a) {
  37332. var x = _a.x,
  37333. y = _a.y;
  37334. if (!_this.containerRect) {
  37335. throw new Error('The Cropper is not mounted');
  37336. }
  37337. return {
  37338. x: _this.containerRect.width / 2 - (x - _this.containerRect.left),
  37339. y: _this.containerRect.height / 2 - (y - _this.containerRect.top)
  37340. };
  37341. };
  37342. _this.getPointOnMedia = function (_a) {
  37343. var x = _a.x,
  37344. y = _a.y;
  37345. var _b = _this.props,
  37346. crop = _b.crop,
  37347. zoom = _b.zoom;
  37348. return {
  37349. x: (x + crop.x) / zoom,
  37350. y: (y + crop.y) / zoom
  37351. };
  37352. };
  37353. _this.setNewZoom = function (zoom, point, _a) {
  37354. var _b = (_a === void 0 ? {} : _a).shouldUpdatePosition,
  37355. shouldUpdatePosition = _b === void 0 ? true : _b;
  37356. if (!_this.state.cropSize || !_this.props.onZoomChange) return;
  37357. var newZoom = clamp(zoom, _this.props.minZoom, _this.props.maxZoom);
  37358. if (shouldUpdatePosition) {
  37359. var zoomPoint = _this.getPointOnContainer(point);
  37360. var zoomTarget = _this.getPointOnMedia(zoomPoint);
  37361. var requestedPosition = {
  37362. x: zoomTarget.x * newZoom - zoomPoint.x,
  37363. y: zoomTarget.y * newZoom - zoomPoint.y
  37364. };
  37365. var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, newZoom, _this.props.rotation) : requestedPosition;
  37366. _this.props.onCropChange(newPosition);
  37367. }
  37368. _this.props.onZoomChange(newZoom);
  37369. };
  37370. _this.getCropData = function () {
  37371. if (!_this.state.cropSize) {
  37372. return null;
  37373. } // this is to ensure the crop is correctly restricted after a zoom back (https://github.com/ValentinH/react-easy-crop/issues/6)
  37374. var restrictedPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop;
  37375. return computeCroppedArea(restrictedPosition, _this.mediaSize, _this.state.cropSize, _this.getAspect(), _this.props.zoom, _this.props.rotation, _this.props.restrictPosition);
  37376. };
  37377. _this.emitCropData = function () {
  37378. var cropData = _this.getCropData();
  37379. if (!cropData) return;
  37380. var croppedAreaPercentages = cropData.croppedAreaPercentages,
  37381. croppedAreaPixels = cropData.croppedAreaPixels;
  37382. if (_this.props.onCropComplete) {
  37383. _this.props.onCropComplete(croppedAreaPercentages, croppedAreaPixels);
  37384. }
  37385. if (_this.props.onCropAreaChange) {
  37386. _this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels);
  37387. }
  37388. };
  37389. _this.emitCropAreaChange = function () {
  37390. var cropData = _this.getCropData();
  37391. if (!cropData) return;
  37392. var croppedAreaPercentages = cropData.croppedAreaPercentages,
  37393. croppedAreaPixels = cropData.croppedAreaPixels;
  37394. if (_this.props.onCropAreaChange) {
  37395. _this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels);
  37396. }
  37397. };
  37398. _this.recomputeCropPosition = function () {
  37399. if (!_this.state.cropSize) return;
  37400. var newPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop;
  37401. _this.props.onCropChange(newPosition);
  37402. _this.emitCropData();
  37403. };
  37404. return _this;
  37405. }
  37406. Cropper.prototype.componentDidMount = function () {
  37407. if (this.containerRef) {
  37408. if (this.containerRef.ownerDocument) {
  37409. this.currentDoc = this.containerRef.ownerDocument;
  37410. }
  37411. if (this.currentDoc.defaultView) {
  37412. this.currentWindow = this.currentDoc.defaultView;
  37413. }
  37414. this.currentWindow.addEventListener('resize', this.computeSizes);
  37415. this.props.zoomWithScroll && this.containerRef.addEventListener('wheel', this.onWheel, {
  37416. passive: false
  37417. });
  37418. this.containerRef.addEventListener('gesturestart', this.onGestureStart);
  37419. }
  37420. if (!this.props.disableAutomaticStylesInjection) {
  37421. this.styleRef = this.currentDoc.createElement('style');
  37422. this.styleRef.setAttribute('type', 'text/css');
  37423. if (this.props.nonce) {
  37424. this.styleRef.setAttribute('nonce', this.props.nonce);
  37425. }
  37426. this.styleRef.innerHTML = css_248z;
  37427. this.currentDoc.head.appendChild(this.styleRef);
  37428. } // when rendered via SSR, the image can already be loaded and its onLoad callback will never be called
  37429. if (this.imageRef.current && this.imageRef.current.complete) {
  37430. this.onMediaLoad();
  37431. } // set image and video refs in the parent if the callbacks exist
  37432. if (this.props.setImageRef) {
  37433. this.props.setImageRef(this.imageRef);
  37434. }
  37435. if (this.props.setVideoRef) {
  37436. this.props.setVideoRef(this.videoRef);
  37437. }
  37438. };
  37439. Cropper.prototype.componentWillUnmount = function () {
  37440. var _a;
  37441. this.currentWindow.removeEventListener('resize', this.computeSizes);
  37442. if (this.containerRef) {
  37443. this.containerRef.removeEventListener('gesturestart', this.preventZoomSafari);
  37444. }
  37445. if (this.styleRef) {
  37446. (_a = this.styleRef.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.styleRef);
  37447. }
  37448. this.cleanEvents();
  37449. this.props.zoomWithScroll && this.clearScrollEvent();
  37450. };
  37451. Cropper.prototype.componentDidUpdate = function (prevProps) {
  37452. var _a, _b, _c, _d, _e, _f, _g, _h, _j;
  37453. if (prevProps.rotation !== this.props.rotation) {
  37454. this.computeSizes();
  37455. this.recomputeCropPosition();
  37456. } else if (prevProps.aspect !== this.props.aspect) {
  37457. this.computeSizes();
  37458. } else if (prevProps.zoom !== this.props.zoom) {
  37459. this.recomputeCropPosition();
  37460. } else if (((_a = prevProps.cropSize) === null || _a === void 0 ? void 0 : _a.height) !== ((_b = this.props.cropSize) === null || _b === void 0 ? void 0 : _b.height) || ((_c = prevProps.cropSize) === null || _c === void 0 ? void 0 : _c.width) !== ((_d = this.props.cropSize) === null || _d === void 0 ? void 0 : _d.width)) {
  37461. this.computeSizes();
  37462. } else if (((_e = prevProps.crop) === null || _e === void 0 ? void 0 : _e.x) !== ((_f = this.props.crop) === null || _f === void 0 ? void 0 : _f.x) || ((_g = prevProps.crop) === null || _g === void 0 ? void 0 : _g.y) !== ((_h = this.props.crop) === null || _h === void 0 ? void 0 : _h.y)) {
  37463. this.emitCropAreaChange();
  37464. }
  37465. if (prevProps.zoomWithScroll !== this.props.zoomWithScroll && this.containerRef) {
  37466. this.props.zoomWithScroll ? this.containerRef.addEventListener('wheel', this.onWheel, {
  37467. passive: false
  37468. }) : this.clearScrollEvent();
  37469. }
  37470. if (prevProps.video !== this.props.video) {
  37471. (_j = this.videoRef.current) === null || _j === void 0 ? void 0 : _j.load();
  37472. }
  37473. };
  37474. Cropper.prototype.getAspect = function () {
  37475. var _a = this.props,
  37476. cropSize = _a.cropSize,
  37477. aspect = _a.aspect;
  37478. if (cropSize) {
  37479. return cropSize.width / cropSize.height;
  37480. }
  37481. return aspect;
  37482. };
  37483. Cropper.prototype.onPinchStart = function (e) {
  37484. var pointA = Cropper.getTouchPoint(e.touches[0]);
  37485. var pointB = Cropper.getTouchPoint(e.touches[1]);
  37486. this.lastPinchDistance = getDistanceBetweenPoints(pointA, pointB);
  37487. this.lastPinchRotation = getRotationBetweenPoints(pointA, pointB);
  37488. this.onDragStart(getCenter(pointA, pointB));
  37489. };
  37490. Cropper.prototype.onPinchMove = function (e) {
  37491. var _this = this;
  37492. var pointA = Cropper.getTouchPoint(e.touches[0]);
  37493. var pointB = Cropper.getTouchPoint(e.touches[1]);
  37494. var center = getCenter(pointA, pointB);
  37495. this.onDrag(center);
  37496. if (this.rafPinchTimeout) this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout);
  37497. this.rafPinchTimeout = this.currentWindow.requestAnimationFrame(function () {
  37498. var distance = getDistanceBetweenPoints(pointA, pointB);
  37499. var newZoom = _this.props.zoom * (distance / _this.lastPinchDistance);
  37500. _this.setNewZoom(newZoom, center, {
  37501. shouldUpdatePosition: false
  37502. });
  37503. _this.lastPinchDistance = distance;
  37504. var rotation = getRotationBetweenPoints(pointA, pointB);
  37505. var newRotation = _this.props.rotation + (rotation - _this.lastPinchRotation);
  37506. _this.props.onRotationChange && _this.props.onRotationChange(newRotation);
  37507. _this.lastPinchRotation = rotation;
  37508. });
  37509. };
  37510. Cropper.prototype.render = function () {
  37511. var _this = this;
  37512. var _a = this.props,
  37513. image = _a.image,
  37514. video = _a.video,
  37515. mediaProps = _a.mediaProps,
  37516. transform = _a.transform,
  37517. _b = _a.crop,
  37518. x = _b.x,
  37519. y = _b.y,
  37520. rotation = _a.rotation,
  37521. zoom = _a.zoom,
  37522. cropShape = _a.cropShape,
  37523. showGrid = _a.showGrid,
  37524. _c = _a.style,
  37525. containerStyle = _c.containerStyle,
  37526. cropAreaStyle = _c.cropAreaStyle,
  37527. mediaStyle = _c.mediaStyle,
  37528. _d = _a.classes,
  37529. containerClassName = _d.containerClassName,
  37530. cropAreaClassName = _d.cropAreaClassName,
  37531. mediaClassName = _d.mediaClassName,
  37532. objectFit = _a.objectFit;
  37533. return /*#__PURE__*/external_React_default().createElement("div", {
  37534. onMouseDown: this.onMouseDown,
  37535. onTouchStart: this.onTouchStart,
  37536. ref: function ref(el) {
  37537. return _this.containerRef = el;
  37538. },
  37539. "data-testid": "container",
  37540. style: containerStyle,
  37541. className: classNames('reactEasyCrop_Container', containerClassName)
  37542. }, image ? /*#__PURE__*/external_React_default().createElement("img", __assign({
  37543. alt: "",
  37544. className: classNames('reactEasyCrop_Image', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', objectFit === 'auto-cover' && (this.mediaSize.naturalWidth > this.mediaSize.naturalHeight ? 'reactEasyCrop_Cover_Horizontal' : 'reactEasyCrop_Cover_Vertical'), mediaClassName)
  37545. }, mediaProps, {
  37546. src: image,
  37547. ref: this.imageRef,
  37548. style: __assign(__assign({}, mediaStyle), {
  37549. transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")"
  37550. }),
  37551. onLoad: this.onMediaLoad
  37552. })) : video && /*#__PURE__*/external_React_default().createElement("video", __assign({
  37553. autoPlay: true,
  37554. loop: true,
  37555. muted: true,
  37556. className: classNames('reactEasyCrop_Video', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', objectFit === 'auto-cover' && (this.mediaSize.naturalWidth > this.mediaSize.naturalHeight ? 'reactEasyCrop_Cover_Horizontal' : 'reactEasyCrop_Cover_Vertical'), mediaClassName)
  37557. }, mediaProps, {
  37558. ref: this.videoRef,
  37559. onLoadedMetadata: this.onMediaLoad,
  37560. style: __assign(__assign({}, mediaStyle), {
  37561. transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")"
  37562. }),
  37563. controls: false
  37564. }), (Array.isArray(video) ? video : [{
  37565. src: video
  37566. }]).map(function (item) {
  37567. return /*#__PURE__*/external_React_default().createElement("source", __assign({
  37568. key: item.src
  37569. }, item));
  37570. })), this.state.cropSize && /*#__PURE__*/external_React_default().createElement("div", {
  37571. style: __assign(__assign({}, cropAreaStyle), {
  37572. width: this.state.cropSize.width,
  37573. height: this.state.cropSize.height
  37574. }),
  37575. "data-testid": "cropper",
  37576. className: classNames('reactEasyCrop_CropArea', cropShape === 'round' && 'reactEasyCrop_CropAreaRound', showGrid && 'reactEasyCrop_CropAreaGrid', cropAreaClassName)
  37577. }));
  37578. };
  37579. Cropper.defaultProps = {
  37580. zoom: 1,
  37581. rotation: 0,
  37582. aspect: 4 / 3,
  37583. maxZoom: MAX_ZOOM,
  37584. minZoom: MIN_ZOOM,
  37585. cropShape: 'rect',
  37586. objectFit: 'contain',
  37587. showGrid: true,
  37588. style: {},
  37589. classes: {},
  37590. mediaProps: {},
  37591. zoomSpeed: 1,
  37592. restrictPosition: true,
  37593. zoomWithScroll: true
  37594. };
  37595. Cropper.getMousePoint = function (e) {
  37596. return {
  37597. x: Number(e.clientX),
  37598. y: Number(e.clientY)
  37599. };
  37600. };
  37601. Cropper.getTouchPoint = function (touch) {
  37602. return {
  37603. x: Number(touch.clientX),
  37604. y: Number(touch.clientY)
  37605. };
  37606. };
  37607. return Cropper;
  37608. }((external_React_default()).Component);
  37609. /* harmony default export */ var index_module = (Cropper);
  37610. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/constants.js
  37611. const constants_MIN_ZOOM = 100;
  37612. const constants_MAX_ZOOM = 300;
  37613. const image_editor_constants_POPOVER_PROPS = {
  37614. position: 'bottom right',
  37615. isAlternate: true
  37616. };
  37617. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/use-save-image.js
  37618. /**
  37619. * WordPress dependencies
  37620. */
  37621. function useSaveImage(_ref) {
  37622. let {
  37623. crop,
  37624. rotation,
  37625. height,
  37626. width,
  37627. aspect,
  37628. url,
  37629. id,
  37630. onSaveImage,
  37631. onFinishEditing
  37632. } = _ref;
  37633. const {
  37634. createErrorNotice
  37635. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
  37636. const [isInProgress, setIsInProgress] = (0,external_wp_element_namespaceObject.useState)(false);
  37637. const cancel = (0,external_wp_element_namespaceObject.useCallback)(() => {
  37638. setIsInProgress(false);
  37639. onFinishEditing();
  37640. }, [setIsInProgress, onFinishEditing]);
  37641. const apply = (0,external_wp_element_namespaceObject.useCallback)(() => {
  37642. setIsInProgress(true);
  37643. let attrs = {}; // The crop script may return some very small, sub-pixel values when the image was not cropped.
  37644. // Crop only when the new size has changed by more than 0.1%.
  37645. if (crop.width < 99.9 || crop.height < 99.9) {
  37646. attrs = crop;
  37647. }
  37648. if (rotation > 0) {
  37649. attrs.rotation = rotation;
  37650. }
  37651. attrs.src = url;
  37652. external_wp_apiFetch_default()({
  37653. path: `/wp/v2/media/${id}/edit`,
  37654. method: 'POST',
  37655. data: attrs
  37656. }).then(response => {
  37657. onSaveImage({
  37658. id: response.id,
  37659. url: response.source_url,
  37660. height: height && width ? width / aspect : undefined
  37661. });
  37662. }).catch(error => {
  37663. createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)(
  37664. /* translators: 1. Error message */
  37665. (0,external_wp_i18n_namespaceObject.__)('Could not edit image. %s'), (0,external_wp_dom_namespaceObject.__unstableStripHTML)(error.message)), {
  37666. id: 'image-editing-error',
  37667. type: 'snackbar'
  37668. });
  37669. }).finally(() => {
  37670. setIsInProgress(false);
  37671. onFinishEditing();
  37672. });
  37673. }, [setIsInProgress, crop, rotation, height, width, aspect, url, onSaveImage, createErrorNotice, setIsInProgress, onFinishEditing]);
  37674. return (0,external_wp_element_namespaceObject.useMemo)(() => ({
  37675. isInProgress,
  37676. apply,
  37677. cancel
  37678. }), [isInProgress, apply, cancel]);
  37679. }
  37680. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/use-transform-image.js
  37681. /**
  37682. * WordPress dependencies
  37683. */
  37684. function useTransformState(_ref) {
  37685. let {
  37686. url,
  37687. naturalWidth,
  37688. naturalHeight
  37689. } = _ref;
  37690. const [editedUrl, setEditedUrl] = (0,external_wp_element_namespaceObject.useState)();
  37691. const [crop, setCrop] = (0,external_wp_element_namespaceObject.useState)();
  37692. const [position, setPosition] = (0,external_wp_element_namespaceObject.useState)({
  37693. x: 0,
  37694. y: 0
  37695. });
  37696. const [zoom, setZoom] = (0,external_wp_element_namespaceObject.useState)();
  37697. const [rotation, setRotation] = (0,external_wp_element_namespaceObject.useState)();
  37698. const [aspect, setAspect] = (0,external_wp_element_namespaceObject.useState)();
  37699. const [defaultAspect, setDefaultAspect] = (0,external_wp_element_namespaceObject.useState)();
  37700. const initializeTransformValues = (0,external_wp_element_namespaceObject.useCallback)(() => {
  37701. setPosition({
  37702. x: 0,
  37703. y: 0
  37704. });
  37705. setZoom(100);
  37706. setRotation(0);
  37707. setAspect(naturalWidth / naturalHeight);
  37708. setDefaultAspect(naturalWidth / naturalHeight);
  37709. }, [naturalWidth, naturalHeight, setPosition, setZoom, setRotation, setAspect, setDefaultAspect]);
  37710. const rotateClockwise = (0,external_wp_element_namespaceObject.useCallback)(() => {
  37711. const angle = (rotation + 90) % 360;
  37712. let naturalAspectRatio = naturalWidth / naturalHeight;
  37713. if (rotation % 180 === 90) {
  37714. naturalAspectRatio = naturalHeight / naturalWidth;
  37715. }
  37716. if (angle === 0) {
  37717. setEditedUrl();
  37718. setRotation(angle);
  37719. setAspect(naturalWidth / naturalHeight);
  37720. setPosition({
  37721. x: -(position.y * naturalAspectRatio),
  37722. y: position.x * naturalAspectRatio
  37723. });
  37724. return;
  37725. }
  37726. function editImage(event) {
  37727. const canvas = document.createElement('canvas');
  37728. let translateX = 0;
  37729. let translateY = 0;
  37730. if (angle % 180) {
  37731. canvas.width = event.target.height;
  37732. canvas.height = event.target.width;
  37733. } else {
  37734. canvas.width = event.target.width;
  37735. canvas.height = event.target.height;
  37736. }
  37737. if (angle === 90 || angle === 180) {
  37738. translateX = canvas.width;
  37739. }
  37740. if (angle === 270 || angle === 180) {
  37741. translateY = canvas.height;
  37742. }
  37743. const context = canvas.getContext('2d');
  37744. context.translate(translateX, translateY);
  37745. context.rotate(angle * Math.PI / 180);
  37746. context.drawImage(event.target, 0, 0);
  37747. canvas.toBlob(blob => {
  37748. setEditedUrl(URL.createObjectURL(blob));
  37749. setRotation(angle);
  37750. setAspect(canvas.width / canvas.height);
  37751. setPosition({
  37752. x: -(position.y * naturalAspectRatio),
  37753. y: position.x * naturalAspectRatio
  37754. });
  37755. });
  37756. }
  37757. const el = new window.Image();
  37758. el.src = url;
  37759. el.onload = editImage;
  37760. const imgCrossOrigin = (0,external_wp_hooks_namespaceObject.applyFilters)('media.crossOrigin', undefined, url);
  37761. if (typeof imgCrossOrigin === 'string') {
  37762. el.crossOrigin = imgCrossOrigin;
  37763. }
  37764. }, [rotation, naturalWidth, naturalHeight, setEditedUrl, setRotation, setAspect, setPosition]);
  37765. return (0,external_wp_element_namespaceObject.useMemo)(() => ({
  37766. editedUrl,
  37767. setEditedUrl,
  37768. crop,
  37769. setCrop,
  37770. position,
  37771. setPosition,
  37772. zoom,
  37773. setZoom,
  37774. rotation,
  37775. setRotation,
  37776. rotateClockwise,
  37777. aspect,
  37778. setAspect,
  37779. defaultAspect,
  37780. initializeTransformValues
  37781. }), [editedUrl, setEditedUrl, crop, setCrop, position, setPosition, zoom, setZoom, rotation, setRotation, rotateClockwise, aspect, setAspect, defaultAspect, initializeTransformValues]);
  37782. }
  37783. function useTransformImage(imageProperties, isEditing) {
  37784. const transformState = useTransformState(imageProperties);
  37785. const {
  37786. initializeTransformValues
  37787. } = transformState;
  37788. (0,external_wp_element_namespaceObject.useEffect)(() => {
  37789. if (isEditing) {
  37790. initializeTransformValues();
  37791. }
  37792. }, [isEditing, initializeTransformValues]);
  37793. return transformState;
  37794. }
  37795. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/context.js
  37796. /**
  37797. * WordPress dependencies
  37798. */
  37799. /**
  37800. * Internal dependencies
  37801. */
  37802. const ImageEditingContext = (0,external_wp_element_namespaceObject.createContext)({});
  37803. const useImageEditingContext = () => (0,external_wp_element_namespaceObject.useContext)(ImageEditingContext);
  37804. function ImageEditingProvider(_ref) {
  37805. let {
  37806. id,
  37807. url,
  37808. naturalWidth,
  37809. naturalHeight,
  37810. isEditing,
  37811. onFinishEditing,
  37812. onSaveImage,
  37813. children
  37814. } = _ref;
  37815. const transformImage = useTransformImage({
  37816. url,
  37817. naturalWidth,
  37818. naturalHeight
  37819. }, isEditing);
  37820. const saveImage = useSaveImage({
  37821. id,
  37822. url,
  37823. onSaveImage,
  37824. onFinishEditing,
  37825. ...transformImage
  37826. });
  37827. const providerValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...transformImage,
  37828. ...saveImage
  37829. }), [transformImage, saveImage]);
  37830. return (0,external_wp_element_namespaceObject.createElement)(ImageEditingContext.Provider, {
  37831. value: providerValue
  37832. }, children);
  37833. }
  37834. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/cropper.js
  37835. /**
  37836. * External dependencies
  37837. */
  37838. /**
  37839. * WordPress dependencies
  37840. */
  37841. /**
  37842. * Internal dependencies
  37843. */
  37844. function ImageCropper(_ref) {
  37845. let {
  37846. url,
  37847. width,
  37848. height,
  37849. clientWidth,
  37850. naturalHeight,
  37851. naturalWidth,
  37852. borderProps
  37853. } = _ref;
  37854. const {
  37855. isInProgress,
  37856. editedUrl,
  37857. position,
  37858. zoom,
  37859. aspect,
  37860. setPosition,
  37861. setCrop,
  37862. setZoom,
  37863. rotation
  37864. } = useImageEditingContext();
  37865. let editedHeight = height || clientWidth * naturalHeight / naturalWidth;
  37866. if (rotation % 180 === 90) {
  37867. editedHeight = clientWidth * naturalWidth / naturalHeight;
  37868. }
  37869. return (0,external_wp_element_namespaceObject.createElement)("div", {
  37870. className: classnames_default()('wp-block-image__crop-area', borderProps === null || borderProps === void 0 ? void 0 : borderProps.className, {
  37871. 'is-applying': isInProgress
  37872. }),
  37873. style: { ...(borderProps === null || borderProps === void 0 ? void 0 : borderProps.style),
  37874. width: width || clientWidth,
  37875. height: editedHeight
  37876. }
  37877. }, (0,external_wp_element_namespaceObject.createElement)(index_module, {
  37878. image: editedUrl || url,
  37879. disabled: isInProgress,
  37880. minZoom: constants_MIN_ZOOM / 100,
  37881. maxZoom: constants_MAX_ZOOM / 100,
  37882. crop: position,
  37883. zoom: zoom / 100,
  37884. aspect: aspect,
  37885. onCropChange: setPosition,
  37886. onCropComplete: newCropPercent => {
  37887. setCrop(newCropPercent);
  37888. },
  37889. onZoomChange: newZoom => {
  37890. setZoom(newZoom * 100);
  37891. }
  37892. }), isInProgress && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null));
  37893. }
  37894. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/search.js
  37895. /**
  37896. * WordPress dependencies
  37897. */
  37898. const search = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  37899. xmlns: "http://www.w3.org/2000/svg",
  37900. viewBox: "0 0 24 24"
  37901. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  37902. d: "M13.5 6C10.5 6 8 8.5 8 11.5c0 1.1.3 2.1.9 3l-3.4 3 1 1.1 3.4-2.9c1 .9 2.2 1.4 3.6 1.4 3 0 5.5-2.5 5.5-5.5C19 8.5 16.5 6 13.5 6zm0 9.5c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z"
  37903. }));
  37904. /* harmony default export */ var library_search = (search);
  37905. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/zoom-dropdown.js
  37906. /**
  37907. * WordPress dependencies
  37908. */
  37909. /**
  37910. * Internal dependencies
  37911. */
  37912. function ZoomDropdown() {
  37913. const {
  37914. isInProgress,
  37915. zoom,
  37916. setZoom
  37917. } = useImageEditingContext();
  37918. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  37919. contentClassName: "wp-block-image__zoom",
  37920. popoverProps: image_editor_constants_POPOVER_PROPS,
  37921. renderToggle: _ref => {
  37922. let {
  37923. isOpen,
  37924. onToggle
  37925. } = _ref;
  37926. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  37927. icon: library_search,
  37928. label: (0,external_wp_i18n_namespaceObject.__)('Zoom'),
  37929. onClick: onToggle,
  37930. "aria-expanded": isOpen,
  37931. disabled: isInProgress
  37932. });
  37933. },
  37934. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.RangeControl, {
  37935. label: (0,external_wp_i18n_namespaceObject.__)('Zoom'),
  37936. min: constants_MIN_ZOOM,
  37937. max: constants_MAX_ZOOM,
  37938. value: Math.round(zoom),
  37939. onChange: setZoom
  37940. })
  37941. });
  37942. }
  37943. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/aspect-ratio.js
  37944. /**
  37945. * WordPress dependencies
  37946. */
  37947. const aspectRatio = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  37948. xmlns: "http://www.w3.org/2000/svg",
  37949. viewBox: "0 0 24 24"
  37950. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  37951. d: "M18.5 5.5h-13c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2h13c1.1 0 2-.9 2-2v-9c0-1.1-.9-2-2-2zm.5 11c0 .3-.2.5-.5.5h-13c-.3 0-.5-.2-.5-.5v-9c0-.3.2-.5.5-.5h13c.3 0 .5.2.5.5v9zM6.5 12H8v-2h2V8.5H6.5V12zm9.5 2h-2v1.5h3.5V12H16v2z"
  37952. }));
  37953. /* harmony default export */ var aspect_ratio = (aspectRatio);
  37954. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/aspect-ratio-dropdown.js
  37955. /**
  37956. * WordPress dependencies
  37957. */
  37958. /**
  37959. * Internal dependencies
  37960. */
  37961. function AspectGroup(_ref) {
  37962. let {
  37963. aspectRatios,
  37964. isDisabled,
  37965. label,
  37966. onClick,
  37967. value
  37968. } = _ref;
  37969. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  37970. label: label
  37971. }, aspectRatios.map(_ref2 => {
  37972. let {
  37973. title,
  37974. aspect
  37975. } = _ref2;
  37976. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  37977. key: aspect,
  37978. disabled: isDisabled,
  37979. onClick: () => {
  37980. onClick(aspect);
  37981. },
  37982. role: "menuitemradio",
  37983. isSelected: aspect === value,
  37984. icon: aspect === value ? library_check : undefined
  37985. }, title);
  37986. }));
  37987. }
  37988. function AspectRatioDropdown(_ref3) {
  37989. let {
  37990. toggleProps
  37991. } = _ref3;
  37992. const {
  37993. isInProgress,
  37994. aspect,
  37995. setAspect,
  37996. defaultAspect
  37997. } = useImageEditingContext();
  37998. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
  37999. icon: aspect_ratio,
  38000. label: (0,external_wp_i18n_namespaceObject.__)('Aspect Ratio'),
  38001. popoverProps: image_editor_constants_POPOVER_PROPS,
  38002. toggleProps: toggleProps,
  38003. className: "wp-block-image__aspect-ratio"
  38004. }, _ref4 => {
  38005. let {
  38006. onClose
  38007. } = _ref4;
  38008. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(AspectGroup, {
  38009. isDisabled: isInProgress,
  38010. onClick: newAspect => {
  38011. setAspect(newAspect);
  38012. onClose();
  38013. },
  38014. value: aspect,
  38015. aspectRatios: [{
  38016. title: (0,external_wp_i18n_namespaceObject.__)('Original'),
  38017. aspect: defaultAspect
  38018. }, {
  38019. title: (0,external_wp_i18n_namespaceObject.__)('Square'),
  38020. aspect: 1
  38021. }]
  38022. }), (0,external_wp_element_namespaceObject.createElement)(AspectGroup, {
  38023. label: (0,external_wp_i18n_namespaceObject.__)('Landscape'),
  38024. isDisabled: isInProgress,
  38025. onClick: newAspect => {
  38026. setAspect(newAspect);
  38027. onClose();
  38028. },
  38029. value: aspect,
  38030. aspectRatios: [{
  38031. title: (0,external_wp_i18n_namespaceObject.__)('16:10'),
  38032. aspect: 16 / 10
  38033. }, {
  38034. title: (0,external_wp_i18n_namespaceObject.__)('16:9'),
  38035. aspect: 16 / 9
  38036. }, {
  38037. title: (0,external_wp_i18n_namespaceObject.__)('4:3'),
  38038. aspect: 4 / 3
  38039. }, {
  38040. title: (0,external_wp_i18n_namespaceObject.__)('3:2'),
  38041. aspect: 3 / 2
  38042. }]
  38043. }), (0,external_wp_element_namespaceObject.createElement)(AspectGroup, {
  38044. label: (0,external_wp_i18n_namespaceObject.__)('Portrait'),
  38045. isDisabled: isInProgress,
  38046. onClick: newAspect => {
  38047. setAspect(newAspect);
  38048. onClose();
  38049. },
  38050. value: aspect,
  38051. aspectRatios: [{
  38052. title: (0,external_wp_i18n_namespaceObject.__)('10:16'),
  38053. aspect: 10 / 16
  38054. }, {
  38055. title: (0,external_wp_i18n_namespaceObject.__)('9:16'),
  38056. aspect: 9 / 16
  38057. }, {
  38058. title: (0,external_wp_i18n_namespaceObject.__)('3:4'),
  38059. aspect: 3 / 4
  38060. }, {
  38061. title: (0,external_wp_i18n_namespaceObject.__)('2:3'),
  38062. aspect: 2 / 3
  38063. }]
  38064. }));
  38065. });
  38066. }
  38067. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/rotate-right.js
  38068. /**
  38069. * WordPress dependencies
  38070. */
  38071. const rotateRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  38072. xmlns: "http://www.w3.org/2000/svg",
  38073. viewBox: "0 0 24 24"
  38074. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  38075. d: "M15.1 4.8l-3-2.5V4c-4.4 0-8 3.6-8 8 0 3.7 2.5 6.9 6 7.7.3.1.6.1 1 .2l.2-1.5c-.4 0-.7-.1-1.1-.2l-.1.2v-.2c-2.6-.8-4.5-3.3-4.5-6.2 0-3.6 2.9-6.5 6.5-6.5v1.8l3-2.5zM20 11c-.2-1.4-.7-2.7-1.6-3.8l-1.2.8c.7.9 1.1 2 1.3 3.1L20 11zm-1.5 1.8c-.1.5-.2 1.1-.4 1.6s-.5 1-.8 1.5l1.2.9c.4-.5.8-1.1 1-1.8s.5-1.3.5-2l-1.5-.2zm-5.6 5.6l.2 1.5c1.4-.2 2.7-.7 3.8-1.6l-.9-1.1c-.9.7-2 1.1-3.1 1.2z"
  38076. }));
  38077. /* harmony default export */ var rotate_right = (rotateRight);
  38078. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/rotation-button.js
  38079. /**
  38080. * WordPress dependencies
  38081. */
  38082. /**
  38083. * Internal dependencies
  38084. */
  38085. function RotationButton() {
  38086. const {
  38087. isInProgress,
  38088. rotateClockwise
  38089. } = useImageEditingContext();
  38090. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  38091. icon: rotate_right,
  38092. label: (0,external_wp_i18n_namespaceObject.__)('Rotate'),
  38093. onClick: rotateClockwise,
  38094. disabled: isInProgress
  38095. });
  38096. }
  38097. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/form-controls.js
  38098. /**
  38099. * WordPress dependencies
  38100. */
  38101. /**
  38102. * Internal dependencies
  38103. */
  38104. function FormControls() {
  38105. const {
  38106. isInProgress,
  38107. apply,
  38108. cancel
  38109. } = useImageEditingContext();
  38110. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  38111. onClick: apply,
  38112. disabled: isInProgress
  38113. }, (0,external_wp_i18n_namespaceObject.__)('Apply')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  38114. onClick: cancel
  38115. }, (0,external_wp_i18n_namespaceObject.__)('Cancel')));
  38116. }
  38117. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/index.js
  38118. /**
  38119. * WordPress dependencies
  38120. */
  38121. /**
  38122. * Internal dependencies
  38123. */
  38124. function ImageEditor(_ref) {
  38125. let {
  38126. url,
  38127. width,
  38128. height,
  38129. clientWidth,
  38130. naturalHeight,
  38131. naturalWidth,
  38132. borderProps
  38133. } = _ref;
  38134. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ImageCropper, {
  38135. borderProps: borderProps,
  38136. url: url,
  38137. width: width,
  38138. height: height,
  38139. clientWidth: clientWidth,
  38140. naturalHeight: naturalHeight,
  38141. naturalWidth: naturalWidth
  38142. }), (0,external_wp_element_namespaceObject.createElement)(block_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(ZoomDropdown, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(AspectRatioDropdown, {
  38143. toggleProps: toggleProps
  38144. })), (0,external_wp_element_namespaceObject.createElement)(RotationButton, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(FormControls, null))));
  38145. }
  38146. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-size-control/use-dimension-handler.js
  38147. /**
  38148. * WordPress dependencies
  38149. */
  38150. function useDimensionHandler(customHeight, customWidth, defaultHeight, defaultWidth, onChange) {
  38151. var _ref, _ref2;
  38152. const [currentWidth, setCurrentWidth] = (0,external_wp_element_namespaceObject.useState)((_ref = customWidth !== null && customWidth !== void 0 ? customWidth : defaultWidth) !== null && _ref !== void 0 ? _ref : '');
  38153. const [currentHeight, setCurrentHeight] = (0,external_wp_element_namespaceObject.useState)((_ref2 = customHeight !== null && customHeight !== void 0 ? customHeight : defaultHeight) !== null && _ref2 !== void 0 ? _ref2 : ''); // When an image is first inserted, the default dimensions are initially
  38154. // undefined. This effect updates the dimensions when the default values
  38155. // come through.
  38156. (0,external_wp_element_namespaceObject.useEffect)(() => {
  38157. if (customWidth === undefined && defaultWidth !== undefined) {
  38158. setCurrentWidth(defaultWidth);
  38159. }
  38160. if (customHeight === undefined && defaultHeight !== undefined) {
  38161. setCurrentHeight(defaultHeight);
  38162. }
  38163. }, [defaultWidth, defaultHeight]); // If custom values change, it means an outsider has resized the image using some other method (eg resize box)
  38164. // this keeps track of these values too. We need to parse before comparing; custom values can be strings.
  38165. (0,external_wp_element_namespaceObject.useEffect)(() => {
  38166. if (customWidth !== undefined && Number.parseInt(customWidth) !== Number.parseInt(currentWidth)) {
  38167. setCurrentWidth(customWidth);
  38168. }
  38169. if (customHeight !== undefined && Number.parseInt(customHeight) !== Number.parseInt(currentHeight)) {
  38170. setCurrentHeight(customHeight);
  38171. }
  38172. }, [customWidth, customHeight]);
  38173. const updateDimension = (dimension, value) => {
  38174. if (dimension === 'width') {
  38175. setCurrentWidth(value);
  38176. } else {
  38177. setCurrentHeight(value);
  38178. }
  38179. onChange({
  38180. [dimension]: value === '' ? undefined : parseInt(value, 10)
  38181. });
  38182. };
  38183. const updateDimensions = (nextHeight, nextWidth) => {
  38184. setCurrentHeight(nextHeight !== null && nextHeight !== void 0 ? nextHeight : defaultHeight);
  38185. setCurrentWidth(nextWidth !== null && nextWidth !== void 0 ? nextWidth : defaultWidth);
  38186. onChange({
  38187. height: nextHeight,
  38188. width: nextWidth
  38189. });
  38190. };
  38191. return {
  38192. currentHeight,
  38193. currentWidth,
  38194. updateDimension,
  38195. updateDimensions
  38196. };
  38197. }
  38198. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-size-control/index.js
  38199. /**
  38200. * External dependencies
  38201. */
  38202. /**
  38203. * WordPress dependencies
  38204. */
  38205. /**
  38206. * Internal dependencies
  38207. */
  38208. const IMAGE_SIZE_PRESETS = [25, 50, 75, 100];
  38209. const image_size_control_noop = () => {};
  38210. function ImageSizeControl(_ref) {
  38211. let {
  38212. imageSizeHelp,
  38213. imageWidth,
  38214. imageHeight,
  38215. imageSizeOptions = [],
  38216. isResizable = true,
  38217. slug,
  38218. width,
  38219. height,
  38220. onChange,
  38221. onChangeImage = image_size_control_noop
  38222. } = _ref;
  38223. const {
  38224. currentHeight,
  38225. currentWidth,
  38226. updateDimension,
  38227. updateDimensions
  38228. } = useDimensionHandler(height, width, imageHeight, imageWidth, onChange);
  38229. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !(0,external_lodash_namespaceObject.isEmpty)(imageSizeOptions) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
  38230. label: (0,external_wp_i18n_namespaceObject.__)('Image size'),
  38231. value: slug,
  38232. options: imageSizeOptions,
  38233. onChange: onChangeImage,
  38234. help: imageSizeHelp
  38235. }), isResizable && (0,external_wp_element_namespaceObject.createElement)("div", {
  38236. className: "block-editor-image-size-control"
  38237. }, (0,external_wp_element_namespaceObject.createElement)("p", {
  38238. className: "block-editor-image-size-control__row"
  38239. }, (0,external_wp_i18n_namespaceObject.__)('Image dimensions')), (0,external_wp_element_namespaceObject.createElement)("div", {
  38240. className: "block-editor-image-size-control__row"
  38241. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  38242. type: "number",
  38243. className: "block-editor-image-size-control__width",
  38244. label: (0,external_wp_i18n_namespaceObject.__)('Width'),
  38245. value: currentWidth,
  38246. min: 1,
  38247. onChange: value => updateDimension('width', value)
  38248. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  38249. type: "number",
  38250. className: "block-editor-image-size-control__height",
  38251. label: (0,external_wp_i18n_namespaceObject.__)('Height'),
  38252. value: currentHeight,
  38253. min: 1,
  38254. onChange: value => updateDimension('height', value)
  38255. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  38256. className: "block-editor-image-size-control__row"
  38257. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ButtonGroup, {
  38258. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Image size presets')
  38259. }, IMAGE_SIZE_PRESETS.map(scale => {
  38260. const scaledWidth = Math.round(imageWidth * (scale / 100));
  38261. const scaledHeight = Math.round(imageHeight * (scale / 100));
  38262. const isCurrent = currentWidth === scaledWidth && currentHeight === scaledHeight;
  38263. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  38264. key: scale,
  38265. isSmall: true,
  38266. variant: isCurrent ? 'primary' : undefined,
  38267. isPressed: isCurrent,
  38268. onClick: () => updateDimensions(scaledHeight, scaledWidth)
  38269. }, scale, "%");
  38270. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  38271. isSmall: true,
  38272. onClick: () => updateDimensions()
  38273. }, (0,external_wp_i18n_namespaceObject.__)('Reset')))));
  38274. }
  38275. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard-return.js
  38276. /**
  38277. * WordPress dependencies
  38278. */
  38279. const keyboardReturn = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  38280. xmlns: "http://www.w3.org/2000/svg",
  38281. viewBox: "-2 -2 24 24"
  38282. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  38283. d: "M6.734 16.106l2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.157 1.093-1.027-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734z"
  38284. }));
  38285. /* harmony default export */ var keyboard_return = (keyboardReturn);
  38286. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/settings-drawer.js
  38287. /**
  38288. * WordPress dependencies
  38289. */
  38290. const settings_drawer_noop = () => {};
  38291. const LinkControlSettingsDrawer = _ref => {
  38292. let {
  38293. value,
  38294. onChange = settings_drawer_noop,
  38295. settings
  38296. } = _ref;
  38297. if (!settings || !settings.length) {
  38298. return null;
  38299. }
  38300. const handleSettingChange = setting => newValue => {
  38301. onChange({ ...value,
  38302. [setting.id]: newValue
  38303. });
  38304. };
  38305. const theSettings = settings.map(setting => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  38306. className: "block-editor-link-control__setting",
  38307. key: setting.id,
  38308. label: setting.title,
  38309. onChange: handleSettingChange(setting),
  38310. checked: value ? !!value[setting.id] : false
  38311. }));
  38312. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  38313. className: "block-editor-link-control__settings"
  38314. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  38315. as: "legend"
  38316. }, (0,external_wp_i18n_namespaceObject.__)('Currently selected link settings')), theSettings);
  38317. };
  38318. /* harmony default export */ var settings_drawer = (LinkControlSettingsDrawer);
  38319. // EXTERNAL MODULE: ./node_modules/dom-scroll-into-view/lib/index.js
  38320. var dom_scroll_into_view_lib = __webpack_require__(5425);
  38321. var lib_default = /*#__PURE__*/__webpack_require__.n(dom_scroll_into_view_lib);
  38322. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/index.js
  38323. /**
  38324. * External dependencies
  38325. */
  38326. /**
  38327. * WordPress dependencies
  38328. */
  38329. /**
  38330. * Internal dependencies
  38331. */
  38332. /**
  38333. * Whether the argument is a function.
  38334. *
  38335. * @param {*} maybeFunc The argument to check.
  38336. * @return {boolean} True if the argument is a function, false otherwise.
  38337. */
  38338. function isFunction(maybeFunc) {
  38339. return typeof maybeFunc === 'function';
  38340. }
  38341. class URLInput extends external_wp_element_namespaceObject.Component {
  38342. constructor(props) {
  38343. super(props);
  38344. this.onChange = this.onChange.bind(this);
  38345. this.onFocus = this.onFocus.bind(this);
  38346. this.onKeyDown = this.onKeyDown.bind(this);
  38347. this.selectLink = this.selectLink.bind(this);
  38348. this.handleOnClick = this.handleOnClick.bind(this);
  38349. this.bindSuggestionNode = this.bindSuggestionNode.bind(this);
  38350. this.autocompleteRef = props.autocompleteRef || (0,external_wp_element_namespaceObject.createRef)();
  38351. this.inputRef = (0,external_wp_element_namespaceObject.createRef)();
  38352. this.updateSuggestions = (0,external_lodash_namespaceObject.debounce)(this.updateSuggestions.bind(this), 200);
  38353. this.suggestionNodes = [];
  38354. this.isUpdatingSuggestions = false;
  38355. this.state = {
  38356. suggestions: [],
  38357. showSuggestions: false,
  38358. selectedSuggestion: null,
  38359. suggestionsListboxId: '',
  38360. suggestionOptionIdPrefix: ''
  38361. };
  38362. }
  38363. componentDidUpdate(prevProps) {
  38364. const {
  38365. showSuggestions,
  38366. selectedSuggestion
  38367. } = this.state;
  38368. const {
  38369. value,
  38370. __experimentalShowInitialSuggestions = false
  38371. } = this.props; // Only have to worry about scrolling selected suggestion into view
  38372. // when already expanded.
  38373. if (showSuggestions && selectedSuggestion !== null && this.suggestionNodes[selectedSuggestion] && !this.scrollingIntoView) {
  38374. this.scrollingIntoView = true;
  38375. lib_default()(this.suggestionNodes[selectedSuggestion], this.autocompleteRef.current, {
  38376. onlyScrollIfNeeded: true
  38377. });
  38378. this.props.setTimeout(() => {
  38379. this.scrollingIntoView = false;
  38380. }, 100);
  38381. } // Update suggestions when the value changes.
  38382. if (prevProps.value !== value && !this.props.disableSuggestions && !this.isUpdatingSuggestions) {
  38383. if (value !== null && value !== void 0 && value.length) {
  38384. // If the new value is not empty we need to update with suggestions for it.
  38385. this.updateSuggestions(value);
  38386. } else if (__experimentalShowInitialSuggestions) {
  38387. // If the new value is empty and we can show initial suggestions, then show initial suggestions.
  38388. this.updateSuggestions();
  38389. }
  38390. }
  38391. }
  38392. componentDidMount() {
  38393. if (this.shouldShowInitialSuggestions()) {
  38394. this.updateSuggestions();
  38395. }
  38396. }
  38397. componentWillUnmount() {
  38398. var _this$suggestionsRequ, _this$suggestionsRequ2;
  38399. (_this$suggestionsRequ = this.suggestionsRequest) === null || _this$suggestionsRequ === void 0 ? void 0 : (_this$suggestionsRequ2 = _this$suggestionsRequ.cancel) === null || _this$suggestionsRequ2 === void 0 ? void 0 : _this$suggestionsRequ2.call(_this$suggestionsRequ);
  38400. delete this.suggestionsRequest;
  38401. }
  38402. bindSuggestionNode(index) {
  38403. return ref => {
  38404. this.suggestionNodes[index] = ref;
  38405. };
  38406. }
  38407. shouldShowInitialSuggestions() {
  38408. const {
  38409. suggestions
  38410. } = this.state;
  38411. const {
  38412. __experimentalShowInitialSuggestions = false,
  38413. value
  38414. } = this.props;
  38415. return !this.isUpdatingSuggestions && __experimentalShowInitialSuggestions && !(value && value.length) && !(suggestions && suggestions.length);
  38416. }
  38417. updateSuggestions() {
  38418. var _value;
  38419. let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  38420. const {
  38421. __experimentalFetchLinkSuggestions: fetchLinkSuggestions,
  38422. __experimentalHandleURLSuggestions: handleURLSuggestions
  38423. } = this.props;
  38424. if (!fetchLinkSuggestions) {
  38425. return;
  38426. } // Initial suggestions may only show if there is no value
  38427. // (note: this includes whitespace).
  38428. const isInitialSuggestions = !((_value = value) !== null && _value !== void 0 && _value.length); // Trim only now we've determined whether or not it originally had a "length"
  38429. // (even if that value was all whitespace).
  38430. value = value.trim(); // Allow a suggestions request if:
  38431. // - there are at least 2 characters in the search input (except manual searches where
  38432. // search input length is not required to trigger a fetch)
  38433. // - this is a direct entry (eg: a URL)
  38434. if (!isInitialSuggestions && (value.length < 2 || !handleURLSuggestions && (0,external_wp_url_namespaceObject.isURL)(value))) {
  38435. this.setState({
  38436. showSuggestions: false,
  38437. selectedSuggestion: null,
  38438. loading: false
  38439. });
  38440. return;
  38441. }
  38442. this.isUpdatingSuggestions = true;
  38443. this.setState({
  38444. selectedSuggestion: null,
  38445. loading: true
  38446. });
  38447. const request = fetchLinkSuggestions(value, {
  38448. isInitialSuggestions
  38449. });
  38450. request.then(suggestions => {
  38451. // A fetch Promise doesn't have an abort option. It's mimicked by
  38452. // comparing the request reference in on the instance, which is
  38453. // reset or deleted on subsequent requests or unmounting.
  38454. if (this.suggestionsRequest !== request) {
  38455. return;
  38456. }
  38457. this.setState({
  38458. suggestions,
  38459. loading: false,
  38460. showSuggestions: !!suggestions.length
  38461. });
  38462. if (!!suggestions.length) {
  38463. this.props.debouncedSpeak((0,external_wp_i18n_namespaceObject.sprintf)(
  38464. /* translators: %s: number of results. */
  38465. (0,external_wp_i18n_namespaceObject._n)('%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', suggestions.length), suggestions.length), 'assertive');
  38466. } else {
  38467. this.props.debouncedSpeak((0,external_wp_i18n_namespaceObject.__)('No results.'), 'assertive');
  38468. }
  38469. this.isUpdatingSuggestions = false;
  38470. }).catch(() => {
  38471. if (this.suggestionsRequest === request) {
  38472. this.setState({
  38473. loading: false
  38474. });
  38475. this.isUpdatingSuggestions = false;
  38476. }
  38477. }); // Note that this assignment is handled *before* the async search request
  38478. // as a Promise always resolves on the next tick of the event loop.
  38479. this.suggestionsRequest = request;
  38480. }
  38481. onChange(event) {
  38482. const inputValue = event.target.value;
  38483. this.props.onChange(inputValue);
  38484. if (!this.props.disableSuggestions) {
  38485. this.updateSuggestions(inputValue);
  38486. }
  38487. }
  38488. onFocus() {
  38489. const {
  38490. suggestions
  38491. } = this.state;
  38492. const {
  38493. disableSuggestions,
  38494. value
  38495. } = this.props; // When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value
  38496. // Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)
  38497. if (value && !disableSuggestions && !this.isUpdatingSuggestions && !(suggestions && suggestions.length)) {
  38498. // Ensure the suggestions are updated with the current input value.
  38499. this.updateSuggestions(value);
  38500. }
  38501. }
  38502. onKeyDown(event) {
  38503. const {
  38504. showSuggestions,
  38505. selectedSuggestion,
  38506. suggestions,
  38507. loading
  38508. } = this.state; // If the suggestions are not shown or loading, we shouldn't handle the arrow keys
  38509. // We shouldn't preventDefault to allow block arrow keys navigation.
  38510. if (!showSuggestions || !suggestions.length || loading) {
  38511. // In the Windows version of Firefox the up and down arrows don't move the caret
  38512. // within an input field like they do for Mac Firefox/Chrome/Safari. This causes
  38513. // a form of focus trapping that is disruptive to the user experience. This disruption
  38514. // only happens if the caret is not in the first or last position in the text input.
  38515. // See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747
  38516. switch (event.keyCode) {
  38517. // When UP is pressed, if the caret is at the start of the text, move it to the 0
  38518. // position.
  38519. case external_wp_keycodes_namespaceObject.UP:
  38520. {
  38521. if (0 !== event.target.selectionStart) {
  38522. event.preventDefault(); // Set the input caret to position 0.
  38523. event.target.setSelectionRange(0, 0);
  38524. }
  38525. break;
  38526. }
  38527. // When DOWN is pressed, if the caret is not at the end of the text, move it to the
  38528. // last position.
  38529. case external_wp_keycodes_namespaceObject.DOWN:
  38530. {
  38531. if (this.props.value.length !== event.target.selectionStart) {
  38532. event.preventDefault(); // Set the input caret to the last position.
  38533. event.target.setSelectionRange(this.props.value.length, this.props.value.length);
  38534. }
  38535. break;
  38536. }
  38537. // Submitting while loading should trigger onSubmit.
  38538. case external_wp_keycodes_namespaceObject.ENTER:
  38539. {
  38540. event.preventDefault();
  38541. if (this.props.onSubmit) {
  38542. this.props.onSubmit(null, event);
  38543. }
  38544. break;
  38545. }
  38546. }
  38547. return;
  38548. }
  38549. const suggestion = this.state.suggestions[this.state.selectedSuggestion];
  38550. switch (event.keyCode) {
  38551. case external_wp_keycodes_namespaceObject.UP:
  38552. {
  38553. event.preventDefault();
  38554. const previousIndex = !selectedSuggestion ? suggestions.length - 1 : selectedSuggestion - 1;
  38555. this.setState({
  38556. selectedSuggestion: previousIndex
  38557. });
  38558. break;
  38559. }
  38560. case external_wp_keycodes_namespaceObject.DOWN:
  38561. {
  38562. event.preventDefault();
  38563. const nextIndex = selectedSuggestion === null || selectedSuggestion === suggestions.length - 1 ? 0 : selectedSuggestion + 1;
  38564. this.setState({
  38565. selectedSuggestion: nextIndex
  38566. });
  38567. break;
  38568. }
  38569. case external_wp_keycodes_namespaceObject.TAB:
  38570. {
  38571. if (this.state.selectedSuggestion !== null) {
  38572. this.selectLink(suggestion); // Announce a link has been selected when tabbing away from the input field.
  38573. this.props.speak((0,external_wp_i18n_namespaceObject.__)('Link selected.'));
  38574. }
  38575. break;
  38576. }
  38577. case external_wp_keycodes_namespaceObject.ENTER:
  38578. {
  38579. event.preventDefault();
  38580. if (this.state.selectedSuggestion !== null) {
  38581. this.selectLink(suggestion);
  38582. if (this.props.onSubmit) {
  38583. this.props.onSubmit(suggestion, event);
  38584. }
  38585. } else if (this.props.onSubmit) {
  38586. this.props.onSubmit(null, event);
  38587. }
  38588. break;
  38589. }
  38590. }
  38591. }
  38592. selectLink(suggestion) {
  38593. this.props.onChange(suggestion.url, suggestion);
  38594. this.setState({
  38595. selectedSuggestion: null,
  38596. showSuggestions: false
  38597. });
  38598. }
  38599. handleOnClick(suggestion) {
  38600. this.selectLink(suggestion); // Move focus to the input field when a link suggestion is clicked.
  38601. this.inputRef.current.focus();
  38602. }
  38603. static getDerivedStateFromProps(_ref, _ref2) {
  38604. let {
  38605. value,
  38606. instanceId,
  38607. disableSuggestions,
  38608. __experimentalShowInitialSuggestions = false
  38609. } = _ref;
  38610. let {
  38611. showSuggestions
  38612. } = _ref2;
  38613. let shouldShowSuggestions = showSuggestions;
  38614. const hasValue = value && value.length;
  38615. if (!__experimentalShowInitialSuggestions && !hasValue) {
  38616. shouldShowSuggestions = false;
  38617. }
  38618. if (disableSuggestions === true) {
  38619. shouldShowSuggestions = false;
  38620. }
  38621. return {
  38622. showSuggestions: shouldShowSuggestions,
  38623. suggestionsListboxId: `block-editor-url-input-suggestions-${instanceId}`,
  38624. suggestionOptionIdPrefix: `block-editor-url-input-suggestion-${instanceId}`
  38625. };
  38626. }
  38627. render() {
  38628. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, this.renderControl(), this.renderSuggestions());
  38629. }
  38630. renderControl() {
  38631. const {
  38632. label = null,
  38633. className,
  38634. isFullWidth,
  38635. instanceId,
  38636. placeholder = (0,external_wp_i18n_namespaceObject.__)('Paste URL or type to search'),
  38637. __experimentalRenderControl: renderControl,
  38638. value = ''
  38639. } = this.props;
  38640. const {
  38641. loading,
  38642. showSuggestions,
  38643. selectedSuggestion,
  38644. suggestionsListboxId,
  38645. suggestionOptionIdPrefix
  38646. } = this.state;
  38647. const inputId = `url-input-control-${instanceId}`;
  38648. const controlProps = {
  38649. id: inputId,
  38650. // Passes attribute to label for the for attribute
  38651. label,
  38652. className: classnames_default()('block-editor-url-input', className, {
  38653. 'is-full-width': isFullWidth
  38654. })
  38655. };
  38656. const inputProps = {
  38657. id: inputId,
  38658. value,
  38659. required: true,
  38660. className: 'block-editor-url-input__input',
  38661. type: 'text',
  38662. onChange: this.onChange,
  38663. onFocus: this.onFocus,
  38664. placeholder,
  38665. onKeyDown: this.onKeyDown,
  38666. role: 'combobox',
  38667. 'aria-label': label ? undefined : (0,external_wp_i18n_namespaceObject.__)('URL'),
  38668. // Ensure input always has an accessible label
  38669. 'aria-expanded': showSuggestions,
  38670. 'aria-autocomplete': 'list',
  38671. 'aria-controls': suggestionsListboxId,
  38672. 'aria-activedescendant': selectedSuggestion !== null ? `${suggestionOptionIdPrefix}-${selectedSuggestion}` : undefined,
  38673. ref: this.inputRef
  38674. };
  38675. if (renderControl) {
  38676. return renderControl(controlProps, inputProps, loading);
  38677. }
  38678. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, controlProps, (0,external_wp_element_namespaceObject.createElement)("input", inputProps), loading && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null));
  38679. }
  38680. renderSuggestions() {
  38681. const {
  38682. className,
  38683. __experimentalRenderSuggestions: renderSuggestions,
  38684. value = '',
  38685. __experimentalShowInitialSuggestions = false
  38686. } = this.props;
  38687. const {
  38688. showSuggestions,
  38689. suggestions,
  38690. selectedSuggestion,
  38691. suggestionsListboxId,
  38692. suggestionOptionIdPrefix,
  38693. loading
  38694. } = this.state;
  38695. const suggestionsListProps = {
  38696. id: suggestionsListboxId,
  38697. ref: this.autocompleteRef,
  38698. role: 'listbox'
  38699. };
  38700. const buildSuggestionItemProps = (suggestion, index) => {
  38701. return {
  38702. role: 'option',
  38703. tabIndex: '-1',
  38704. id: `${suggestionOptionIdPrefix}-${index}`,
  38705. ref: this.bindSuggestionNode(index),
  38706. 'aria-selected': index === selectedSuggestion
  38707. };
  38708. };
  38709. if (isFunction(renderSuggestions) && showSuggestions && !!suggestions.length) {
  38710. return renderSuggestions({
  38711. suggestions,
  38712. selectedSuggestion,
  38713. suggestionsListProps,
  38714. buildSuggestionItemProps,
  38715. isLoading: loading,
  38716. handleSuggestionClick: this.handleOnClick,
  38717. isInitialSuggestions: __experimentalShowInitialSuggestions && !(value && value.length)
  38718. });
  38719. }
  38720. if (!isFunction(renderSuggestions) && showSuggestions && !!suggestions.length) {
  38721. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  38722. position: "bottom",
  38723. focusOnMount: false
  38724. }, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, suggestionsListProps, {
  38725. className: classnames_default()('block-editor-url-input__suggestions', `${className}__suggestions`)
  38726. }), suggestions.map((suggestion, index) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, buildSuggestionItemProps(suggestion, index), {
  38727. key: suggestion.id,
  38728. className: classnames_default()('block-editor-url-input__suggestion', {
  38729. 'is-selected': index === selectedSuggestion
  38730. }),
  38731. onClick: () => this.handleOnClick(suggestion)
  38732. }), suggestion.title))));
  38733. }
  38734. return null;
  38735. }
  38736. }
  38737. /**
  38738. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md
  38739. */
  38740. /* harmony default export */ var url_input = ((0,external_wp_compose_namespaceObject.compose)(external_wp_compose_namespaceObject.withSafeTimeout, external_wp_components_namespaceObject.withSpokenMessages, external_wp_compose_namespaceObject.withInstanceId, (0,external_wp_data_namespaceObject.withSelect)((select, props) => {
  38741. // If a link suggestions handler is already provided then
  38742. // bail.
  38743. if (isFunction(props.__experimentalFetchLinkSuggestions)) {
  38744. return;
  38745. }
  38746. const {
  38747. getSettings
  38748. } = select(store);
  38749. return {
  38750. __experimentalFetchLinkSuggestions: getSettings().__experimentalFetchLinkSuggestions
  38751. };
  38752. }))(URLInput));
  38753. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-create-button.js
  38754. /**
  38755. * External dependencies
  38756. */
  38757. /**
  38758. * WordPress dependencies
  38759. */
  38760. const LinkControlSearchCreate = _ref => {
  38761. let {
  38762. searchTerm,
  38763. onClick,
  38764. itemProps,
  38765. isSelected,
  38766. buttonText
  38767. } = _ref;
  38768. if (!searchTerm) {
  38769. return null;
  38770. }
  38771. let text;
  38772. if (buttonText) {
  38773. text = typeof buttonText === 'function' ? buttonText(searchTerm) : buttonText;
  38774. } else {
  38775. text = (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(
  38776. /* translators: %s: search term. */
  38777. (0,external_wp_i18n_namespaceObject.__)('Create: <mark>%s</mark>'), searchTerm), {
  38778. mark: (0,external_wp_element_namespaceObject.createElement)("mark", null)
  38779. });
  38780. }
  38781. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, itemProps, {
  38782. className: classnames_default()('block-editor-link-control__search-create block-editor-link-control__search-item', {
  38783. 'is-selected': isSelected
  38784. }),
  38785. onClick: onClick
  38786. }), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  38787. className: "block-editor-link-control__search-item-icon",
  38788. icon: library_plus
  38789. }), (0,external_wp_element_namespaceObject.createElement)("span", {
  38790. className: "block-editor-link-control__search-item-header"
  38791. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  38792. className: "block-editor-link-control__search-item-title"
  38793. }, text)));
  38794. };
  38795. /* harmony default export */ var search_create_button = (LinkControlSearchCreate);
  38796. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post-list.js
  38797. /**
  38798. * WordPress dependencies
  38799. */
  38800. const postList = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  38801. viewBox: "0 0 24 24",
  38802. xmlns: "http://www.w3.org/2000/svg"
  38803. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  38804. d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v12zM7 11h2V9H7v2zm0 4h2v-2H7v2zm3-4h7V9h-7v2zm0 4h7v-2h-7v2z"
  38805. }));
  38806. /* harmony default export */ var post_list = (postList);
  38807. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/tag.js
  38808. /**
  38809. * WordPress dependencies
  38810. */
  38811. const tag = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  38812. xmlns: "http://www.w3.org/2000/svg",
  38813. viewBox: "0 0 24 24"
  38814. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  38815. d: "M20.1 11.2l-6.7-6.7c-.1-.1-.3-.2-.5-.2H5c-.4-.1-.8.3-.8.7v7.8c0 .2.1.4.2.5l6.7 6.7c.2.2.5.4.7.5s.6.2.9.2c.3 0 .6-.1.9-.2.3-.1.5-.3.8-.5l5.6-5.6c.4-.4.7-1 .7-1.6.1-.6-.2-1.2-.6-1.6zM19 13.4L13.4 19c-.1.1-.2.1-.3.2-.2.1-.4.1-.6 0-.1 0-.2-.1-.3-.2l-6.5-6.5V5.8h6.8l6.5 6.5c.2.2.2.4.2.6 0 .1 0 .3-.2.5zM9 8c-.6 0-1 .4-1 1s.4 1 1 1 1-.4 1-1-.4-1-1-1z"
  38816. }));
  38817. /* harmony default export */ var library_tag = (tag);
  38818. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/category.js
  38819. /**
  38820. * WordPress dependencies
  38821. */
  38822. const category = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  38823. viewBox: "0 0 24 24",
  38824. xmlns: "http://www.w3.org/2000/svg"
  38825. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  38826. d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z",
  38827. fillRule: "evenodd",
  38828. clipRule: "evenodd"
  38829. }));
  38830. /* harmony default export */ var library_category = (category);
  38831. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/file.js
  38832. /**
  38833. * WordPress dependencies
  38834. */
  38835. const file = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  38836. viewBox: "0 0 24 24",
  38837. xmlns: "http://www.w3.org/2000/svg"
  38838. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  38839. d: "M19 6.2h-5.9l-.6-1.1c-.3-.7-1-1.1-1.8-1.1H5c-1.1 0-2 .9-2 2v11.8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8.2c0-1.1-.9-2-2-2zm.5 11.6c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h5.8c.2 0 .4.1.4.3l1 2H19c.3 0 .5.2.5.5v9.5z"
  38840. }));
  38841. /* harmony default export */ var library_file = (file);
  38842. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/globe.js
  38843. /**
  38844. * WordPress dependencies
  38845. */
  38846. const globe = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  38847. xmlns: "http://www.w3.org/2000/svg",
  38848. viewBox: "0 0 24 24"
  38849. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  38850. d: "M12 3.3c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8s-4-8.8-8.8-8.8zm6.5 5.5h-2.6C15.4 7.3 14.8 6 14 5c2 .6 3.6 2 4.5 3.8zm.7 3.2c0 .6-.1 1.2-.2 1.8h-2.9c.1-.6.1-1.2.1-1.8s-.1-1.2-.1-1.8H19c.2.6.2 1.2.2 1.8zM12 18.7c-1-.7-1.8-1.9-2.3-3.5h4.6c-.5 1.6-1.3 2.9-2.3 3.5zm-2.6-4.9c-.1-.6-.1-1.1-.1-1.8 0-.6.1-1.2.1-1.8h5.2c.1.6.1 1.1.1 1.8s-.1 1.2-.1 1.8H9.4zM4.8 12c0-.6.1-1.2.2-1.8h2.9c-.1.6-.1 1.2-.1 1.8 0 .6.1 1.2.1 1.8H5c-.2-.6-.2-1.2-.2-1.8zM12 5.3c1 .7 1.8 1.9 2.3 3.5H9.7c.5-1.6 1.3-2.9 2.3-3.5zM10 5c-.8 1-1.4 2.3-1.8 3.8H5.5C6.4 7 8 5.6 10 5zM5.5 15.3h2.6c.4 1.5 1 2.8 1.8 3.7-1.8-.6-3.5-2-4.4-3.7zM14 19c.8-1 1.4-2.2 1.8-3.7h2.6C17.6 17 16 18.4 14 19z"
  38851. }));
  38852. /* harmony default export */ var library_globe = (globe);
  38853. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-item.js
  38854. /**
  38855. * External dependencies
  38856. */
  38857. /**
  38858. * WordPress dependencies
  38859. */
  38860. const ICONS_MAP = {
  38861. post: post_list,
  38862. page: library_page,
  38863. post_tag: library_tag,
  38864. category: library_category,
  38865. attachment: library_file
  38866. };
  38867. function SearchItemIcon(_ref) {
  38868. let {
  38869. isURL,
  38870. suggestion
  38871. } = _ref;
  38872. let icon = null;
  38873. if (isURL) {
  38874. icon = library_globe;
  38875. } else if (suggestion.type in ICONS_MAP) {
  38876. icon = ICONS_MAP[suggestion.type];
  38877. }
  38878. if (icon) {
  38879. return (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  38880. className: "block-editor-link-control__search-item-icon",
  38881. icon: icon
  38882. });
  38883. }
  38884. return null;
  38885. }
  38886. const LinkControlSearchItem = _ref2 => {
  38887. let {
  38888. itemProps,
  38889. suggestion,
  38890. isSelected = false,
  38891. onClick,
  38892. isURL = false,
  38893. searchTerm = '',
  38894. shouldShowType = false
  38895. } = _ref2;
  38896. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, itemProps, {
  38897. onClick: onClick,
  38898. className: classnames_default()('block-editor-link-control__search-item', {
  38899. 'is-selected': isSelected,
  38900. 'is-url': isURL,
  38901. 'is-entity': !isURL
  38902. })
  38903. }), (0,external_wp_element_namespaceObject.createElement)(SearchItemIcon, {
  38904. suggestion: suggestion,
  38905. isURL: isURL
  38906. }), (0,external_wp_element_namespaceObject.createElement)("span", {
  38907. className: "block-editor-link-control__search-item-header"
  38908. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  38909. className: "block-editor-link-control__search-item-title"
  38910. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextHighlight, {
  38911. text: suggestion.title,
  38912. highlight: searchTerm
  38913. })), (0,external_wp_element_namespaceObject.createElement)("span", {
  38914. "aria-hidden": !isURL,
  38915. className: "block-editor-link-control__search-item-info"
  38916. }, !isURL && ((0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURI)(suggestion.url)) || ''), isURL && (0,external_wp_i18n_namespaceObject.__)('Press ENTER to add this link'))), shouldShowType && suggestion.type && (0,external_wp_element_namespaceObject.createElement)("span", {
  38917. className: "block-editor-link-control__search-item-type"
  38918. }, getVisualTypeName(suggestion)));
  38919. };
  38920. function getVisualTypeName(suggestion) {
  38921. if (suggestion.isFrontPage) {
  38922. return 'front page';
  38923. } // Rename 'post_tag' to 'tag'. Ideally, the API would return the localised CPT or taxonomy label.
  38924. return suggestion.type === 'post_tag' ? 'tag' : suggestion.type;
  38925. }
  38926. /* harmony default export */ var search_item = (LinkControlSearchItem);
  38927. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/constants.js
  38928. /**
  38929. * WordPress dependencies
  38930. */
  38931. // Used as a unique identifier for the "Create" option within search results.
  38932. // Used to help distinguish the "Create" suggestion within the search results in
  38933. // order to handle it as a unique case.
  38934. const CREATE_TYPE = '__CREATE__';
  38935. const TEL_TYPE = 'tel';
  38936. const URL_TYPE = 'URL';
  38937. const MAILTO_TYPE = 'mailto';
  38938. const INTERNAL_TYPE = 'internal';
  38939. const LINK_ENTRY_TYPES = [URL_TYPE, MAILTO_TYPE, TEL_TYPE, INTERNAL_TYPE];
  38940. const DEFAULT_LINK_SETTINGS = [{
  38941. id: 'opensInNewTab',
  38942. title: (0,external_wp_i18n_namespaceObject.__)('Open in new tab')
  38943. }];
  38944. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-results.js
  38945. /**
  38946. * WordPress dependencies
  38947. */
  38948. /**
  38949. * External dependencies
  38950. */
  38951. /**
  38952. * Internal dependencies
  38953. */
  38954. function LinkControlSearchResults(_ref) {
  38955. let {
  38956. instanceId,
  38957. withCreateSuggestion,
  38958. currentInputValue,
  38959. handleSuggestionClick,
  38960. suggestionsListProps,
  38961. buildSuggestionItemProps,
  38962. suggestions,
  38963. selectedSuggestion,
  38964. isLoading,
  38965. isInitialSuggestions,
  38966. createSuggestionButtonText,
  38967. suggestionsQuery
  38968. } = _ref;
  38969. const resultsListClasses = classnames_default()('block-editor-link-control__search-results', {
  38970. 'is-loading': isLoading
  38971. });
  38972. const isSingleDirectEntryResult = suggestions.length === 1 && LINK_ENTRY_TYPES.includes(suggestions[0].type);
  38973. const shouldShowCreateSuggestion = withCreateSuggestion && !isSingleDirectEntryResult && !isInitialSuggestions; // If the query has a specified type, then we can skip showing them in the result. See #24839.
  38974. const shouldShowSuggestionsTypes = !(suggestionsQuery !== null && suggestionsQuery !== void 0 && suggestionsQuery.type); // According to guidelines aria-label should be added if the label
  38975. // itself is not visible.
  38976. // See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role
  38977. const searchResultsLabelId = `block-editor-link-control-search-results-label-${instanceId}`;
  38978. const labelText = isInitialSuggestions ? (0,external_wp_i18n_namespaceObject.__)('Recently updated') : (0,external_wp_i18n_namespaceObject.sprintf)(
  38979. /* translators: %s: search term. */
  38980. (0,external_wp_i18n_namespaceObject.__)('Search results for "%s"'), currentInputValue); // VisuallyHidden rightly doesn't accept custom classNames
  38981. // so we conditionally render it as a wrapper to visually hide the label
  38982. // when that is required.
  38983. const searchResultsLabel = (0,external_wp_element_namespaceObject.createElement)(isInitialSuggestions ? external_wp_element_namespaceObject.Fragment : external_wp_components_namespaceObject.VisuallyHidden, {}, // Empty props.
  38984. (0,external_wp_element_namespaceObject.createElement)("span", {
  38985. className: "block-editor-link-control__search-results-label",
  38986. id: searchResultsLabelId
  38987. }, labelText));
  38988. return (0,external_wp_element_namespaceObject.createElement)("div", {
  38989. className: "block-editor-link-control__search-results-wrapper"
  38990. }, searchResultsLabel, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, suggestionsListProps, {
  38991. className: resultsListClasses,
  38992. "aria-labelledby": searchResultsLabelId
  38993. }), suggestions.map((suggestion, index) => {
  38994. if (shouldShowCreateSuggestion && CREATE_TYPE === suggestion.type) {
  38995. return (0,external_wp_element_namespaceObject.createElement)(search_create_button, {
  38996. searchTerm: currentInputValue,
  38997. buttonText: createSuggestionButtonText,
  38998. onClick: () => handleSuggestionClick(suggestion) // Intentionally only using `type` here as
  38999. // the constant is enough to uniquely
  39000. // identify the single "CREATE" suggestion.
  39001. ,
  39002. key: suggestion.type,
  39003. itemProps: buildSuggestionItemProps(suggestion, index),
  39004. isSelected: index === selectedSuggestion
  39005. });
  39006. } // If we're not handling "Create" suggestions above then
  39007. // we don't want them in the main results so exit early.
  39008. if (CREATE_TYPE === suggestion.type) {
  39009. return null;
  39010. }
  39011. return (0,external_wp_element_namespaceObject.createElement)(search_item, {
  39012. key: `${suggestion.id}-${suggestion.type}`,
  39013. itemProps: buildSuggestionItemProps(suggestion, index),
  39014. suggestion: suggestion,
  39015. index: index,
  39016. onClick: () => {
  39017. handleSuggestionClick(suggestion);
  39018. },
  39019. isSelected: index === selectedSuggestion,
  39020. isURL: LINK_ENTRY_TYPES.includes(suggestion.type),
  39021. searchTerm: currentInputValue,
  39022. shouldShowType: shouldShowSuggestionsTypes,
  39023. isFrontPage: suggestion === null || suggestion === void 0 ? void 0 : suggestion.isFrontPage
  39024. });
  39025. })));
  39026. }
  39027. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/is-url-like.js
  39028. /**
  39029. * WordPress dependencies
  39030. */
  39031. /**
  39032. * Determines whether a given value could be a URL. Note this does not
  39033. * guarantee the value is a URL only that it looks like it might be one. For
  39034. * example, just because a string has `www.` in it doesn't make it a URL,
  39035. * but it does make it highly likely that it will be so in the context of
  39036. * creating a link it makes sense to treat it like one.
  39037. *
  39038. * @param {string} val the candidate for being URL-like (or not).
  39039. *
  39040. * @return {boolean} whether or not the value is potentially a URL.
  39041. */
  39042. function isURLLike(val) {
  39043. const isInternal = val === null || val === void 0 ? void 0 : val.startsWith('#');
  39044. return (0,external_wp_url_namespaceObject.isURL)(val) || val && val.includes('www.') || isInternal;
  39045. }
  39046. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-search-handler.js
  39047. /**
  39048. * WordPress dependencies
  39049. */
  39050. /**
  39051. * Internal dependencies
  39052. */
  39053. const handleNoop = () => Promise.resolve([]);
  39054. const handleDirectEntry = val => {
  39055. let type = URL_TYPE;
  39056. const protocol = (0,external_wp_url_namespaceObject.getProtocol)(val) || '';
  39057. if (protocol.includes('mailto')) {
  39058. type = MAILTO_TYPE;
  39059. }
  39060. if (protocol.includes('tel')) {
  39061. type = TEL_TYPE;
  39062. }
  39063. if (val !== null && val !== void 0 && val.startsWith('#')) {
  39064. type = INTERNAL_TYPE;
  39065. }
  39066. return Promise.resolve([{
  39067. id: val,
  39068. title: val,
  39069. url: type === 'URL' ? (0,external_wp_url_namespaceObject.prependHTTP)(val) : val,
  39070. type
  39071. }]);
  39072. };
  39073. const handleEntitySearch = async (val, suggestionsQuery, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion, pageOnFront) => {
  39074. const {
  39075. isInitialSuggestions
  39076. } = suggestionsQuery;
  39077. let resultsIncludeFrontPage = false;
  39078. let results = await Promise.all([fetchSearchSuggestions(val, suggestionsQuery), directEntryHandler(val)]); // Identify front page and update type to match.
  39079. results[0] = results[0].map(result => {
  39080. if (Number(result.id) === pageOnFront) {
  39081. resultsIncludeFrontPage = true;
  39082. result.isFrontPage = true;
  39083. return result;
  39084. }
  39085. return result;
  39086. });
  39087. const couldBeURL = !val.includes(' '); // If it's potentially a URL search then concat on a URL search suggestion
  39088. // just for good measure. That way once the actual results run out we always
  39089. // have a URL option to fallback on.
  39090. if (!resultsIncludeFrontPage && couldBeURL && withURLSuggestion && !isInitialSuggestions) {
  39091. results = results[0].concat(results[1]);
  39092. } else {
  39093. results = results[0];
  39094. } // If displaying initial suggestions just return plain results.
  39095. if (isInitialSuggestions) {
  39096. return results;
  39097. } // Here we append a faux suggestion to represent a "CREATE" option. This
  39098. // is detected in the rendering of the search results and handled as a
  39099. // special case. This is currently necessary because the suggestions
  39100. // dropdown will only appear if there are valid suggestions and
  39101. // therefore unless the create option is a suggestion it will not
  39102. // display in scenarios where there are no results returned from the
  39103. // API. In addition promoting CREATE to a first class suggestion affords
  39104. // the a11y benefits afforded by `URLInput` to all suggestions (eg:
  39105. // keyboard handling, ARIA roles...etc).
  39106. //
  39107. // Note also that the value of the `title` and `url` properties must correspond
  39108. // to the text value of the `<input>`. This is because `title` is used
  39109. // when creating the suggestion. Similarly `url` is used when using keyboard to select
  39110. // the suggestion (the <form> `onSubmit` handler falls-back to `url`).
  39111. return isURLLike(val) || !withCreateSuggestion ? results : results.concat({
  39112. // the `id` prop is intentionally ommitted here because it
  39113. // is never exposed as part of the component's public API.
  39114. // see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.
  39115. title: val,
  39116. // Must match the existing `<input>`s text value.
  39117. url: val,
  39118. // Must match the existing `<input>`s text value.
  39119. type: CREATE_TYPE
  39120. });
  39121. };
  39122. function useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion) {
  39123. const {
  39124. fetchSearchSuggestions,
  39125. pageOnFront
  39126. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  39127. const {
  39128. getSettings
  39129. } = select(store);
  39130. return {
  39131. pageOnFront: getSettings().pageOnFront,
  39132. fetchSearchSuggestions: getSettings().__experimentalFetchLinkSuggestions
  39133. };
  39134. }, []);
  39135. const directEntryHandler = allowDirectEntry ? handleDirectEntry : handleNoop;
  39136. return (0,external_wp_element_namespaceObject.useCallback)((val, _ref) => {
  39137. let {
  39138. isInitialSuggestions
  39139. } = _ref;
  39140. return isURLLike(val) ? directEntryHandler(val, {
  39141. isInitialSuggestions
  39142. }) : handleEntitySearch(val, { ...suggestionsQuery,
  39143. isInitialSuggestions
  39144. }, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion, pageOnFront);
  39145. }, [directEntryHandler, fetchSearchSuggestions, withCreateSuggestion]);
  39146. }
  39147. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-input.js
  39148. /**
  39149. * External dependencies
  39150. */
  39151. /**
  39152. * WordPress dependencies
  39153. */
  39154. /**
  39155. * Internal dependencies
  39156. */
  39157. // Must be a function as otherwise URLInput will default
  39158. // to the fetchLinkSuggestions passed in block editor settings
  39159. // which will cause an unintended http request.
  39160. const noopSearchHandler = () => Promise.resolve([]);
  39161. const search_input_noop = () => {};
  39162. const LinkControlSearchInput = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => {
  39163. let {
  39164. value,
  39165. children,
  39166. currentLink = {},
  39167. className = null,
  39168. placeholder = null,
  39169. withCreateSuggestion = false,
  39170. onCreateSuggestion = search_input_noop,
  39171. onChange = search_input_noop,
  39172. onSelect = search_input_noop,
  39173. showSuggestions = true,
  39174. renderSuggestions = props => (0,external_wp_element_namespaceObject.createElement)(LinkControlSearchResults, props),
  39175. fetchSuggestions = null,
  39176. allowDirectEntry = true,
  39177. showInitialSuggestions = false,
  39178. suggestionsQuery = {},
  39179. withURLSuggestion = true,
  39180. createSuggestionButtonText,
  39181. useLabel = false
  39182. } = _ref;
  39183. const genericSearchHandler = useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion);
  39184. const searchHandler = showSuggestions ? fetchSuggestions || genericSearchHandler : noopSearchHandler;
  39185. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(LinkControlSearchInput);
  39186. const [focusedSuggestion, setFocusedSuggestion] = (0,external_wp_element_namespaceObject.useState)();
  39187. /**
  39188. * Handles the user moving between different suggestions. Does not handle
  39189. * choosing an individual item.
  39190. *
  39191. * @param {string} selection the url of the selected suggestion.
  39192. * @param {Object} suggestion the suggestion object.
  39193. */
  39194. const onInputChange = (selection, suggestion) => {
  39195. onChange(selection);
  39196. setFocusedSuggestion(suggestion);
  39197. };
  39198. const handleRenderSuggestions = props => renderSuggestions({ ...props,
  39199. instanceId,
  39200. withCreateSuggestion,
  39201. currentInputValue: value,
  39202. createSuggestionButtonText,
  39203. suggestionsQuery,
  39204. handleSuggestionClick: suggestion => {
  39205. if (props.handleSuggestionClick) {
  39206. props.handleSuggestionClick(suggestion);
  39207. }
  39208. onSuggestionSelected(suggestion);
  39209. }
  39210. });
  39211. const onSuggestionSelected = async selectedSuggestion => {
  39212. let suggestion = selectedSuggestion;
  39213. if (CREATE_TYPE === selectedSuggestion.type) {
  39214. // Create a new page and call onSelect with the output from the onCreateSuggestion callback.
  39215. try {
  39216. var _suggestion;
  39217. suggestion = await onCreateSuggestion(selectedSuggestion.title);
  39218. if ((_suggestion = suggestion) !== null && _suggestion !== void 0 && _suggestion.url) {
  39219. onSelect(suggestion);
  39220. }
  39221. } catch (e) {}
  39222. return;
  39223. }
  39224. if (allowDirectEntry || suggestion && Object.keys(suggestion).length >= 1) {
  39225. const {
  39226. id,
  39227. url,
  39228. ...restLinkProps
  39229. } = currentLink;
  39230. onSelect( // Some direct entries don't have types or IDs, and we still need to clear the previous ones.
  39231. { ...restLinkProps,
  39232. ...suggestion
  39233. }, suggestion);
  39234. }
  39235. };
  39236. const inputClasses = classnames_default()(className, {
  39237. 'has-no-label': !useLabel
  39238. });
  39239. return (0,external_wp_element_namespaceObject.createElement)("div", {
  39240. className: "block-editor-link-control__search-input-container"
  39241. }, (0,external_wp_element_namespaceObject.createElement)(url_input, {
  39242. label: useLabel ? 'URL' : undefined,
  39243. className: inputClasses,
  39244. value: value,
  39245. onChange: onInputChange,
  39246. placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : (0,external_wp_i18n_namespaceObject.__)('Search or type url'),
  39247. __experimentalRenderSuggestions: showSuggestions ? handleRenderSuggestions : null,
  39248. __experimentalFetchLinkSuggestions: searchHandler,
  39249. __experimentalHandleURLSuggestions: true,
  39250. __experimentalShowInitialSuggestions: showInitialSuggestions,
  39251. onSubmit: (suggestion, event) => {
  39252. var _value$trim;
  39253. const hasSuggestion = suggestion || focusedSuggestion; // If there is no suggestion and the value (ie: any manually entered URL) is empty
  39254. // then don't allow submission otherwise we get empty links.
  39255. if (!hasSuggestion && !(value !== null && value !== void 0 && (_value$trim = value.trim()) !== null && _value$trim !== void 0 && _value$trim.length)) {
  39256. event.preventDefault();
  39257. } else {
  39258. onSuggestionSelected(hasSuggestion || {
  39259. url: value
  39260. });
  39261. }
  39262. },
  39263. ref: ref
  39264. }), children);
  39265. });
  39266. /* harmony default export */ var search_input = (LinkControlSearchInput);
  39267. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/info.js
  39268. /**
  39269. * WordPress dependencies
  39270. */
  39271. const info = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  39272. xmlns: "http://www.w3.org/2000/svg",
  39273. viewBox: "0 0 24 24"
  39274. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  39275. d: "M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"
  39276. }));
  39277. /* harmony default export */ var library_info = (info);
  39278. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pencil.js
  39279. /**
  39280. * WordPress dependencies
  39281. */
  39282. const pencil = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  39283. xmlns: "http://www.w3.org/2000/svg",
  39284. viewBox: "0 0 24 24"
  39285. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  39286. d: "M20.1 5.1L16.9 2 6.2 12.7l-1.3 4.4 4.5-1.3L20.1 5.1zM4 20.8h8v-1.5H4v1.5z"
  39287. }));
  39288. /* harmony default export */ var library_pencil = (pencil);
  39289. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/edit.js
  39290. /**
  39291. * Internal dependencies
  39292. */
  39293. /* harmony default export */ var library_edit = (library_pencil);
  39294. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/viewer-slot.js
  39295. /**
  39296. * WordPress dependencies
  39297. */
  39298. const {
  39299. Slot: ViewerSlot,
  39300. Fill: ViewerFill
  39301. } = (0,external_wp_components_namespaceObject.createSlotFill)('BlockEditorLinkControlViewer');
  39302. /* harmony default export */ var viewer_slot = ((/* unused pure expression or super */ null && (ViewerSlot)));
  39303. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-rich-url-data.js
  39304. /**
  39305. * Internal dependencies
  39306. */
  39307. /**
  39308. * WordPress dependencies
  39309. */
  39310. function use_rich_url_data_reducer(state, action) {
  39311. switch (action.type) {
  39312. case 'RESOLVED':
  39313. return { ...state,
  39314. isFetching: false,
  39315. richData: action.richData
  39316. };
  39317. case 'ERROR':
  39318. return { ...state,
  39319. isFetching: false,
  39320. richData: null
  39321. };
  39322. case 'LOADING':
  39323. return { ...state,
  39324. isFetching: true
  39325. };
  39326. default:
  39327. throw new Error(`Unexpected action type ${action.type}`);
  39328. }
  39329. }
  39330. function useRemoteUrlData(url) {
  39331. const [state, dispatch] = (0,external_wp_element_namespaceObject.useReducer)(use_rich_url_data_reducer, {
  39332. richData: null,
  39333. isFetching: false
  39334. });
  39335. const {
  39336. fetchRichUrlData
  39337. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  39338. const {
  39339. getSettings
  39340. } = select(store);
  39341. return {
  39342. fetchRichUrlData: getSettings().__experimentalFetchRichUrlData
  39343. };
  39344. }, []);
  39345. (0,external_wp_element_namespaceObject.useEffect)(() => {
  39346. // Only make the request if we have an actual URL
  39347. // and the fetching util is available. In some editors
  39348. // there may not be such a util.
  39349. if (url !== null && url !== void 0 && url.length && fetchRichUrlData && typeof AbortController !== 'undefined') {
  39350. dispatch({
  39351. type: 'LOADING'
  39352. });
  39353. const controller = new window.AbortController();
  39354. const signal = controller.signal;
  39355. fetchRichUrlData(url, {
  39356. signal
  39357. }).then(urlData => {
  39358. dispatch({
  39359. type: 'RESOLVED',
  39360. richData: urlData
  39361. });
  39362. }).catch(() => {
  39363. // Avoid setting state on unmounted component
  39364. if (!signal.aborted) {
  39365. dispatch({
  39366. type: 'ERROR'
  39367. });
  39368. }
  39369. }); // Cleanup: when the URL changes the abort the current request.
  39370. return () => {
  39371. controller.abort();
  39372. };
  39373. }
  39374. }, [url]);
  39375. return state;
  39376. }
  39377. /* harmony default export */ var use_rich_url_data = (useRemoteUrlData);
  39378. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/link-preview.js
  39379. /**
  39380. * External dependencies
  39381. */
  39382. /**
  39383. * WordPress dependencies
  39384. */
  39385. /**
  39386. * Internal dependencies
  39387. */
  39388. function LinkPreview(_ref) {
  39389. var _value$url;
  39390. let {
  39391. value,
  39392. onEditClick,
  39393. hasRichPreviews = false,
  39394. hasUnlinkControl = false,
  39395. onRemove
  39396. } = _ref;
  39397. // Avoid fetching if rich previews are not desired.
  39398. const showRichPreviews = hasRichPreviews ? value === null || value === void 0 ? void 0 : value.url : null;
  39399. const {
  39400. richData,
  39401. isFetching
  39402. } = use_rich_url_data(showRichPreviews); // Rich data may be an empty object so test for that.
  39403. const hasRichData = richData && Object.keys(richData).length;
  39404. const displayURL = value && (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURI)(value.url), 16) || '';
  39405. const displayTitle = (richData === null || richData === void 0 ? void 0 : richData.title) || (value === null || value === void 0 ? void 0 : value.title) || displayURL; // url can be undefined if the href attribute is unset
  39406. const isEmptyURL = !(value !== null && value !== void 0 && (_value$url = value.url) !== null && _value$url !== void 0 && _value$url.length);
  39407. let icon;
  39408. if (richData !== null && richData !== void 0 && richData.icon) {
  39409. icon = (0,external_wp_element_namespaceObject.createElement)("img", {
  39410. src: richData === null || richData === void 0 ? void 0 : richData.icon,
  39411. alt: ""
  39412. });
  39413. } else if (isEmptyURL) {
  39414. icon = (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  39415. icon: library_info,
  39416. size: 32
  39417. });
  39418. } else {
  39419. icon = (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  39420. icon: library_globe
  39421. });
  39422. }
  39423. return (0,external_wp_element_namespaceObject.createElement)("div", {
  39424. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Currently selected'),
  39425. className: classnames_default()('block-editor-link-control__search-item', {
  39426. 'is-current': true,
  39427. 'is-rich': hasRichData,
  39428. 'is-fetching': !!isFetching,
  39429. 'is-preview': true,
  39430. 'is-error': isEmptyURL
  39431. })
  39432. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  39433. className: "block-editor-link-control__search-item-top"
  39434. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  39435. className: "block-editor-link-control__search-item-header"
  39436. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  39437. className: classnames_default()('block-editor-link-control__search-item-icon', {
  39438. 'is-image': richData === null || richData === void 0 ? void 0 : richData.icon
  39439. })
  39440. }, icon), (0,external_wp_element_namespaceObject.createElement)("span", {
  39441. className: "block-editor-link-control__search-item-details"
  39442. }, !isEmptyURL ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  39443. className: "block-editor-link-control__search-item-title",
  39444. href: value.url
  39445. }, (0,external_wp_dom_namespaceObject.__unstableStripHTML)(displayTitle)), (value === null || value === void 0 ? void 0 : value.url) && (0,external_wp_element_namespaceObject.createElement)("span", {
  39446. className: "block-editor-link-control__search-item-info"
  39447. }, displayURL)) : (0,external_wp_element_namespaceObject.createElement)("span", {
  39448. className: "block-editor-link-control__search-item-error-notice"
  39449. }, (0,external_wp_i18n_namespaceObject.__)('Link is empty')))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  39450. icon: library_edit,
  39451. label: (0,external_wp_i18n_namespaceObject.__)('Edit'),
  39452. className: "block-editor-link-control__search-item-action",
  39453. onClick: onEditClick,
  39454. iconSize: 24
  39455. }), hasUnlinkControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  39456. icon: link_off,
  39457. label: (0,external_wp_i18n_namespaceObject.__)('Unlink'),
  39458. className: "block-editor-link-control__search-item-action block-editor-link-control__unlink",
  39459. onClick: onRemove,
  39460. iconSize: 24
  39461. }), (0,external_wp_element_namespaceObject.createElement)(ViewerSlot, {
  39462. fillProps: value
  39463. })), !!(hasRichData && (richData !== null && richData !== void 0 && richData.image || richData !== null && richData !== void 0 && richData.description) || isFetching) && (0,external_wp_element_namespaceObject.createElement)("div", {
  39464. className: "block-editor-link-control__search-item-bottom"
  39465. }, ((richData === null || richData === void 0 ? void 0 : richData.image) || isFetching) && (0,external_wp_element_namespaceObject.createElement)("div", {
  39466. "aria-hidden": !(richData !== null && richData !== void 0 && richData.image),
  39467. className: classnames_default()('block-editor-link-control__search-item-image', {
  39468. 'is-placeholder': !(richData !== null && richData !== void 0 && richData.image)
  39469. })
  39470. }, (richData === null || richData === void 0 ? void 0 : richData.image) && (0,external_wp_element_namespaceObject.createElement)("img", {
  39471. src: richData === null || richData === void 0 ? void 0 : richData.image,
  39472. alt: ""
  39473. })), ((richData === null || richData === void 0 ? void 0 : richData.description) || isFetching) && (0,external_wp_element_namespaceObject.createElement)("div", {
  39474. "aria-hidden": !(richData !== null && richData !== void 0 && richData.description),
  39475. className: classnames_default()('block-editor-link-control__search-item-description', {
  39476. 'is-placeholder': !(richData !== null && richData !== void 0 && richData.description)
  39477. })
  39478. }, (richData === null || richData === void 0 ? void 0 : richData.description) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
  39479. truncate: true,
  39480. numberOfLines: "2"
  39481. }, richData.description))));
  39482. }
  39483. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-create-page.js
  39484. /**
  39485. * WordPress dependencies
  39486. */
  39487. function useCreatePage(handleCreatePage) {
  39488. const cancelableCreateSuggestion = (0,external_wp_element_namespaceObject.useRef)();
  39489. const [isCreatingPage, setIsCreatingPage] = (0,external_wp_element_namespaceObject.useState)(false);
  39490. const [errorMessage, setErrorMessage] = (0,external_wp_element_namespaceObject.useState)(null);
  39491. const createPage = async function (suggestionTitle) {
  39492. setIsCreatingPage(true);
  39493. setErrorMessage(null);
  39494. try {
  39495. // Make cancellable in order that we can avoid setting State
  39496. // if the component unmounts during the call to `createSuggestion`
  39497. cancelableCreateSuggestion.current = makeCancelable( // Using Promise.resolve to allow createSuggestion to return a
  39498. // non-Promise based value.
  39499. Promise.resolve(handleCreatePage(suggestionTitle)));
  39500. return await cancelableCreateSuggestion.current.promise;
  39501. } catch (error) {
  39502. if (error && error.isCanceled) {
  39503. return; // bail if canceled to avoid setting state
  39504. }
  39505. setErrorMessage(error.message || (0,external_wp_i18n_namespaceObject.__)('An unknown error occurred during creation. Please try again.'));
  39506. throw error;
  39507. } finally {
  39508. setIsCreatingPage(false);
  39509. }
  39510. };
  39511. /**
  39512. * Handles cancelling any pending Promises that have been made cancelable.
  39513. */
  39514. (0,external_wp_element_namespaceObject.useEffect)(() => {
  39515. return () => {
  39516. // componentDidUnmount
  39517. if (cancelableCreateSuggestion.current) {
  39518. cancelableCreateSuggestion.current.cancel();
  39519. }
  39520. };
  39521. }, []);
  39522. return {
  39523. createPage,
  39524. isCreatingPage,
  39525. errorMessage
  39526. };
  39527. }
  39528. /**
  39529. * Creates a wrapper around a promise which allows it to be programmatically
  39530. * cancelled.
  39531. * See: https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html
  39532. *
  39533. * @param {Promise} promise the Promise to make cancelable
  39534. */
  39535. const makeCancelable = promise => {
  39536. let hasCanceled_ = false;
  39537. const wrappedPromise = new Promise((resolve, reject) => {
  39538. promise.then(val => hasCanceled_ ? reject({
  39539. isCanceled: true
  39540. }) : resolve(val), error => hasCanceled_ ? reject({
  39541. isCanceled: true
  39542. }) : reject(error));
  39543. });
  39544. return {
  39545. promise: wrappedPromise,
  39546. cancel() {
  39547. hasCanceled_ = true;
  39548. }
  39549. };
  39550. };
  39551. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/index.js
  39552. /**
  39553. * External dependencies
  39554. */
  39555. /**
  39556. * WordPress dependencies
  39557. */
  39558. /**
  39559. * Internal dependencies
  39560. */
  39561. /**
  39562. * Default properties associated with a link control value.
  39563. *
  39564. * @typedef WPLinkControlDefaultValue
  39565. *
  39566. * @property {string} url Link URL.
  39567. * @property {string=} title Link title.
  39568. * @property {boolean=} opensInNewTab Whether link should open in a new browser
  39569. * tab. This value is only assigned if not
  39570. * providing a custom `settings` prop.
  39571. */
  39572. /* eslint-disable jsdoc/valid-types */
  39573. /**
  39574. * Custom settings values associated with a link.
  39575. *
  39576. * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue
  39577. */
  39578. /* eslint-enable */
  39579. /**
  39580. * Custom settings values associated with a link.
  39581. *
  39582. * @typedef WPLinkControlSetting
  39583. *
  39584. * @property {string} id Identifier to use as property for setting value.
  39585. * @property {string} title Human-readable label to show in user interface.
  39586. */
  39587. /**
  39588. * Properties associated with a link control value, composed as a union of the
  39589. * default properties and any custom settings values.
  39590. *
  39591. * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue
  39592. */
  39593. /** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */
  39594. /**
  39595. * Properties associated with a search suggestion used within the LinkControl.
  39596. *
  39597. * @typedef WPLinkControlSuggestion
  39598. *
  39599. * @property {string} id Identifier to use to uniquely identify the suggestion.
  39600. * @property {string} type Identifies the type of the suggestion (eg: `post`,
  39601. * `page`, `url`...etc)
  39602. * @property {string} title Human-readable label to show in user interface.
  39603. * @property {string} url A URL for the suggestion.
  39604. */
  39605. /** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */
  39606. /**
  39607. * @typedef WPLinkControlProps
  39608. *
  39609. * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to
  39610. * render a `ToggleControl` for that setting.
  39611. * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the
  39612. * internal editing state of the component to respective
  39613. * show or not show the URL input field.
  39614. * @property {WPLinkControlValue=} value Current link value.
  39615. * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if
  39616. * the user selects a new link or updates settings.
  39617. * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.
  39618. * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.
  39619. * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.
  39620. * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.
  39621. * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.
  39622. * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.
  39623. * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.
  39624. * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.
  39625. */
  39626. const link_control_noop = () => {};
  39627. /**
  39628. * Renders a link control. A link control is a controlled input which maintains
  39629. * a value associated with a link (HTML anchor element) and relevant settings
  39630. * for how that link is expected to behave.
  39631. *
  39632. * @param {WPLinkControlProps} props Component props.
  39633. */
  39634. function LinkControl(_ref) {
  39635. var _currentInputValue$tr, _value$url, _value$url$trim;
  39636. let {
  39637. searchInputPlaceholder,
  39638. value,
  39639. settings = DEFAULT_LINK_SETTINGS,
  39640. onChange = link_control_noop,
  39641. onRemove,
  39642. noDirectEntry = false,
  39643. showSuggestions = true,
  39644. showInitialSuggestions,
  39645. forceIsEditingLink,
  39646. createSuggestion,
  39647. withCreateSuggestion,
  39648. inputValue: propInputValue = '',
  39649. suggestionsQuery = {},
  39650. noURLSuggestion = false,
  39651. createSuggestionButtonText,
  39652. hasRichPreviews = false,
  39653. hasTextControl = false,
  39654. renderControlBottom = null
  39655. } = _ref;
  39656. if (withCreateSuggestion === undefined && createSuggestion) {
  39657. withCreateSuggestion = true;
  39658. }
  39659. const isMounting = (0,external_wp_element_namespaceObject.useRef)(true);
  39660. const wrapperNode = (0,external_wp_element_namespaceObject.useRef)();
  39661. const textInputRef = (0,external_wp_element_namespaceObject.useRef)();
  39662. const [internalInputValue, setInternalInputValue] = (0,external_wp_element_namespaceObject.useState)((value === null || value === void 0 ? void 0 : value.url) || '');
  39663. const [internalTextValue, setInternalTextValue] = (0,external_wp_element_namespaceObject.useState)((value === null || value === void 0 ? void 0 : value.title) || '');
  39664. const currentInputValue = propInputValue || internalInputValue;
  39665. const [isEditingLink, setIsEditingLink] = (0,external_wp_element_namespaceObject.useState)(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url);
  39666. const isEndingEditWithFocus = (0,external_wp_element_namespaceObject.useRef)(false);
  39667. const currentInputIsEmpty = !(currentInputValue !== null && currentInputValue !== void 0 && (_currentInputValue$tr = currentInputValue.trim()) !== null && _currentInputValue$tr !== void 0 && _currentInputValue$tr.length);
  39668. const {
  39669. createPage,
  39670. isCreatingPage,
  39671. errorMessage
  39672. } = useCreatePage(createSuggestion);
  39673. (0,external_wp_element_namespaceObject.useEffect)(() => {
  39674. if (forceIsEditingLink !== undefined && forceIsEditingLink !== isEditingLink) {
  39675. setIsEditingLink(forceIsEditingLink);
  39676. }
  39677. }, [forceIsEditingLink]);
  39678. (0,external_wp_element_namespaceObject.useEffect)(() => {
  39679. // We don't auto focus into the Link UI on mount
  39680. // because otherwise using the keyboard to select text
  39681. // *within* the link format is not possible.
  39682. if (isMounting.current) {
  39683. isMounting.current = false;
  39684. return;
  39685. } // Unless we are mounting, we always want to focus either:
  39686. // - the URL input
  39687. // - the first focusable element in the Link UI.
  39688. // But in editing mode if there is a text input present then
  39689. // the URL input is at index 1. If not then it is at index 0.
  39690. const whichFocusTargetIndex = textInputRef !== null && textInputRef !== void 0 && textInputRef.current ? 1 : 0; // Scenario - when:
  39691. // - switching between editable and non editable LinkControl
  39692. // - clicking on a link
  39693. // ...then move focus to the *first* element to avoid focus loss
  39694. // and to ensure focus is *within* the Link UI.
  39695. const nextFocusTarget = external_wp_dom_namespaceObject.focus.focusable.find(wrapperNode.current)[whichFocusTargetIndex] || wrapperNode.current;
  39696. nextFocusTarget.focus();
  39697. isEndingEditWithFocus.current = false;
  39698. }, [isEditingLink, isCreatingPage]);
  39699. (0,external_wp_element_namespaceObject.useEffect)(() => {
  39700. /**
  39701. * If the value's `text` property changes then sync this
  39702. * back up with state.
  39703. */
  39704. if (value !== null && value !== void 0 && value.title && value.title !== internalTextValue) {
  39705. setInternalTextValue(value.title);
  39706. }
  39707. /**
  39708. * Update the state value internalInputValue if the url value changes
  39709. * for example when clicking on another anchor
  39710. */
  39711. if (value !== null && value !== void 0 && value.url) {
  39712. setInternalInputValue(value.url);
  39713. }
  39714. }, [value]);
  39715. /**
  39716. * Cancels editing state and marks that focus may need to be restored after
  39717. * the next render, if focus was within the wrapper when editing finished.
  39718. */
  39719. function stopEditing() {
  39720. var _wrapperNode$current;
  39721. isEndingEditWithFocus.current = !!((_wrapperNode$current = wrapperNode.current) !== null && _wrapperNode$current !== void 0 && _wrapperNode$current.contains(wrapperNode.current.ownerDocument.activeElement));
  39722. setIsEditingLink(false);
  39723. }
  39724. const handleSelectSuggestion = updatedValue => {
  39725. onChange({ ...updatedValue,
  39726. title: internalTextValue || (updatedValue === null || updatedValue === void 0 ? void 0 : updatedValue.title)
  39727. });
  39728. stopEditing();
  39729. };
  39730. const handleSubmit = () => {
  39731. if (currentInputValue !== (value === null || value === void 0 ? void 0 : value.url) || internalTextValue !== (value === null || value === void 0 ? void 0 : value.title)) {
  39732. onChange({ ...value,
  39733. url: currentInputValue,
  39734. title: internalTextValue
  39735. });
  39736. }
  39737. stopEditing();
  39738. };
  39739. const handleSubmitWithEnter = event => {
  39740. const {
  39741. keyCode
  39742. } = event;
  39743. if (keyCode === external_wp_keycodes_namespaceObject.ENTER && !currentInputIsEmpty // Disallow submitting empty values.
  39744. ) {
  39745. event.preventDefault();
  39746. handleSubmit();
  39747. }
  39748. };
  39749. const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage;
  39750. const showSettingsDrawer = !!(settings !== null && settings !== void 0 && settings.length); // Only show text control once a URL value has been committed
  39751. // and it isn't just empty whitespace.
  39752. // See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
  39753. const showTextControl = (value === null || value === void 0 ? void 0 : (_value$url = value.url) === null || _value$url === void 0 ? void 0 : (_value$url$trim = _value$url.trim()) === null || _value$url$trim === void 0 ? void 0 : _value$url$trim.length) > 0 && hasTextControl;
  39754. return (0,external_wp_element_namespaceObject.createElement)("div", {
  39755. tabIndex: -1,
  39756. ref: wrapperNode,
  39757. className: "block-editor-link-control"
  39758. }, isCreatingPage && (0,external_wp_element_namespaceObject.createElement)("div", {
  39759. className: "block-editor-link-control__loading"
  39760. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null), " ", (0,external_wp_i18n_namespaceObject.__)('Creating'), "\u2026"), (isEditingLink || !value) && !isCreatingPage && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  39761. className: classnames_default()({
  39762. 'block-editor-link-control__search-input-wrapper': true,
  39763. 'has-text-control': showTextControl
  39764. })
  39765. }, showTextControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  39766. ref: textInputRef,
  39767. className: "block-editor-link-control__field block-editor-link-control__text-content",
  39768. label: "Text",
  39769. value: internalTextValue,
  39770. onChange: setInternalTextValue,
  39771. onKeyDown: handleSubmitWithEnter
  39772. }), (0,external_wp_element_namespaceObject.createElement)(search_input, {
  39773. currentLink: value,
  39774. className: "block-editor-link-control__field block-editor-link-control__search-input",
  39775. placeholder: searchInputPlaceholder,
  39776. value: currentInputValue,
  39777. withCreateSuggestion: withCreateSuggestion,
  39778. onCreateSuggestion: createPage,
  39779. onChange: setInternalInputValue,
  39780. onSelect: handleSelectSuggestion,
  39781. showInitialSuggestions: showInitialSuggestions,
  39782. allowDirectEntry: !noDirectEntry,
  39783. showSuggestions: showSuggestions,
  39784. suggestionsQuery: suggestionsQuery,
  39785. withURLSuggestion: !noURLSuggestion,
  39786. createSuggestionButtonText: createSuggestionButtonText,
  39787. useLabel: showTextControl
  39788. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  39789. className: "block-editor-link-control__search-actions"
  39790. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  39791. onClick: handleSubmit,
  39792. label: (0,external_wp_i18n_namespaceObject.__)('Submit'),
  39793. icon: keyboard_return,
  39794. className: "block-editor-link-control__search-submit",
  39795. disabled: currentInputIsEmpty // Disallow submitting empty values.
  39796. })))), errorMessage && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
  39797. className: "block-editor-link-control__search-error",
  39798. status: "error",
  39799. isDismissible: false
  39800. }, errorMessage)), value && !isEditingLink && !isCreatingPage && (0,external_wp_element_namespaceObject.createElement)(LinkPreview, {
  39801. key: value === null || value === void 0 ? void 0 : value.url // force remount when URL changes to avoid race conditions for rich previews
  39802. ,
  39803. value: value,
  39804. onEditClick: () => setIsEditingLink(true),
  39805. hasRichPreviews: hasRichPreviews,
  39806. hasUnlinkControl: shownUnlinkControl,
  39807. onRemove: onRemove
  39808. }), showSettingsDrawer && (0,external_wp_element_namespaceObject.createElement)("div", {
  39809. className: "block-editor-link-control__tools"
  39810. }, (0,external_wp_element_namespaceObject.createElement)(settings_drawer, {
  39811. value: value,
  39812. settings: settings,
  39813. onChange: onChange
  39814. })), renderControlBottom && renderControlBottom());
  39815. }
  39816. LinkControl.ViewerFill = ViewerFill;
  39817. /* harmony default export */ var link_control = (LinkControl);
  39818. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/media.js
  39819. /**
  39820. * WordPress dependencies
  39821. */
  39822. const media = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  39823. xmlns: "http://www.w3.org/2000/svg",
  39824. viewBox: "0 0 24 24"
  39825. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  39826. d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z"
  39827. }));
  39828. /* harmony default export */ var library_media = (media);
  39829. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/upload.js
  39830. /**
  39831. * WordPress dependencies
  39832. */
  39833. const upload = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  39834. xmlns: "http://www.w3.org/2000/svg",
  39835. viewBox: "0 0 24 24"
  39836. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  39837. d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"
  39838. }));
  39839. /* harmony default export */ var library_upload = (upload);
  39840. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post-featured-image.js
  39841. /**
  39842. * WordPress dependencies
  39843. */
  39844. const postFeaturedImage = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  39845. xmlns: "http://www.w3.org/2000/svg",
  39846. viewBox: "0 0 24 24"
  39847. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  39848. d: "M19 3H5c-.6 0-1 .4-1 1v7c0 .5.4 1 1 1h14c.5 0 1-.4 1-1V4c0-.6-.4-1-1-1zM5.5 10.5v-.4l1.8-1.3 1.3.8c.3.2.7.2.9-.1L11 8.1l2.4 2.4H5.5zm13 0h-2.9l-4-4c-.3-.3-.8-.3-1.1 0L8.9 8l-1.2-.8c-.3-.2-.6-.2-.9 0l-1.3 1V4.5h13v6zM4 20h9v-1.5H4V20zm0-4h16v-1.5H4V16z"
  39849. }));
  39850. /* harmony default export */ var post_featured_image = (postFeaturedImage);
  39851. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/index.js
  39852. /**
  39853. * WordPress dependencies
  39854. */
  39855. /**
  39856. * This is a placeholder for the media upload component necessary to make it possible to provide
  39857. * an integration with the core blocks that handle media files. By default it renders nothing but
  39858. * it provides a way to have it overridden with the `editor.MediaUpload` filter.
  39859. *
  39860. * @return {WPComponent} The component to be rendered.
  39861. */
  39862. const MediaUpload = () => null;
  39863. /**
  39864. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md
  39865. */
  39866. /* harmony default export */ var media_upload = ((0,external_wp_components_namespaceObject.withFilters)('editor.MediaUpload')(MediaUpload));
  39867. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/check.js
  39868. /**
  39869. * WordPress dependencies
  39870. */
  39871. /**
  39872. * Internal dependencies
  39873. */
  39874. function MediaUploadCheck(_ref) {
  39875. let {
  39876. fallback = null,
  39877. children
  39878. } = _ref;
  39879. const hasUploadPermissions = (0,external_wp_data_namespaceObject.useSelect)(select => {
  39880. const {
  39881. getSettings
  39882. } = select(store);
  39883. return !!getSettings().mediaUpload;
  39884. }, []);
  39885. return hasUploadPermissions ? children : fallback;
  39886. }
  39887. /**
  39888. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md
  39889. */
  39890. /* harmony default export */ var media_upload_check = (MediaUploadCheck);
  39891. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-replace-flow/index.js
  39892. /**
  39893. * WordPress dependencies
  39894. */
  39895. /**
  39896. * Internal dependencies
  39897. */
  39898. const media_replace_flow_noop = () => {};
  39899. let uniqueId = 0;
  39900. const MediaReplaceFlow = _ref => {
  39901. let {
  39902. mediaURL,
  39903. mediaId,
  39904. mediaIds,
  39905. allowedTypes,
  39906. accept,
  39907. onError,
  39908. onSelect,
  39909. onSelectURL,
  39910. onToggleFeaturedImage,
  39911. useFeaturedImage,
  39912. onFilesUpload = media_replace_flow_noop,
  39913. name = (0,external_wp_i18n_namespaceObject.__)('Replace'),
  39914. createNotice,
  39915. removeNotice,
  39916. children,
  39917. multiple = false,
  39918. addToGallery,
  39919. handleUpload = true
  39920. } = _ref;
  39921. const mediaUpload = (0,external_wp_data_namespaceObject.useSelect)(select => {
  39922. return select(store).getSettings().mediaUpload;
  39923. }, []);
  39924. const editMediaButtonRef = (0,external_wp_element_namespaceObject.useRef)();
  39925. const errorNoticeID = `block-editor/media-replace-flow/error-notice/${++uniqueId}`;
  39926. const onUploadError = message => {
  39927. const safeMessage = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(message);
  39928. if (onError) {
  39929. onError(safeMessage);
  39930. return;
  39931. } // We need to set a timeout for showing the notice
  39932. // so that VoiceOver and possibly other screen readers
  39933. // can announce the error afer the toolbar button
  39934. // regains focus once the upload dialog closes.
  39935. // Otherwise VO simply skips over the notice and announces
  39936. // the focused element and the open menu.
  39937. setTimeout(() => {
  39938. createNotice('error', safeMessage, {
  39939. speak: true,
  39940. id: errorNoticeID,
  39941. isDismissible: true
  39942. });
  39943. }, 1000);
  39944. };
  39945. const selectMedia = (media, closeMenu) => {
  39946. if (useFeaturedImage && onToggleFeaturedImage) {
  39947. onToggleFeaturedImage();
  39948. }
  39949. closeMenu(); // Calling `onSelect` after the state update since it might unmount the component.
  39950. onSelect(media);
  39951. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('The media file has been replaced'));
  39952. removeNotice(errorNoticeID);
  39953. };
  39954. const uploadFiles = (event, closeMenu) => {
  39955. const files = event.target.files;
  39956. if (!handleUpload) {
  39957. closeMenu();
  39958. return onSelect(files);
  39959. }
  39960. onFilesUpload(files);
  39961. mediaUpload({
  39962. allowedTypes,
  39963. filesList: files,
  39964. onFileChange: _ref2 => {
  39965. let [media] = _ref2;
  39966. selectMedia(media, closeMenu);
  39967. },
  39968. onError: onUploadError
  39969. });
  39970. };
  39971. const openOnArrowDown = event => {
  39972. if (event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
  39973. event.preventDefault();
  39974. event.target.click();
  39975. }
  39976. };
  39977. const onlyAllowsImages = () => {
  39978. if (!allowedTypes || allowedTypes.length === 0) {
  39979. return false;
  39980. }
  39981. return allowedTypes.every(allowedType => allowedType === 'image' || allowedType.startsWith('image/'));
  39982. };
  39983. const gallery = multiple && onlyAllowsImages();
  39984. const POPOVER_PROPS = {
  39985. isAlternate: true
  39986. };
  39987. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  39988. popoverProps: POPOVER_PROPS,
  39989. contentClassName: "block-editor-media-replace-flow__options",
  39990. renderToggle: _ref3 => {
  39991. let {
  39992. isOpen,
  39993. onToggle
  39994. } = _ref3;
  39995. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  39996. ref: editMediaButtonRef,
  39997. "aria-expanded": isOpen,
  39998. "aria-haspopup": "true",
  39999. onClick: onToggle,
  40000. onKeyDown: openOnArrowDown
  40001. }, name);
  40002. },
  40003. renderContent: _ref4 => {
  40004. let {
  40005. onClose
  40006. } = _ref4;
  40007. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, {
  40008. className: "block-editor-media-replace-flow__media-upload-menu"
  40009. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(media_upload, {
  40010. gallery: gallery,
  40011. addToGallery: addToGallery,
  40012. multiple: multiple,
  40013. value: multiple ? mediaIds : mediaId,
  40014. onSelect: media => selectMedia(media, onClose),
  40015. allowedTypes: allowedTypes,
  40016. render: _ref5 => {
  40017. let {
  40018. open
  40019. } = _ref5;
  40020. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  40021. icon: library_media,
  40022. onClick: open
  40023. }, (0,external_wp_i18n_namespaceObject.__)('Open Media Library'));
  40024. }
  40025. }), (0,external_wp_element_namespaceObject.createElement)(media_upload_check, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormFileUpload, {
  40026. onChange: event => {
  40027. uploadFiles(event, onClose);
  40028. },
  40029. accept: accept,
  40030. multiple: multiple,
  40031. render: _ref6 => {
  40032. let {
  40033. openFileDialog
  40034. } = _ref6;
  40035. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  40036. icon: library_upload,
  40037. onClick: () => {
  40038. openFileDialog();
  40039. }
  40040. }, (0,external_wp_i18n_namespaceObject.__)('Upload'));
  40041. }
  40042. }))), onToggleFeaturedImage && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  40043. icon: post_featured_image,
  40044. onClick: onToggleFeaturedImage,
  40045. isPressed: useFeaturedImage
  40046. }, (0,external_wp_i18n_namespaceObject.__)('Use featured image')), children), onSelectURL && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
  40047. (0,external_wp_element_namespaceObject.createElement)("form", {
  40048. className: "block-editor-media-flow__url-input"
  40049. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  40050. className: "block-editor-media-replace-flow__image-url-label"
  40051. }, (0,external_wp_i18n_namespaceObject.__)('Current media URL:')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
  40052. text: mediaURL,
  40053. position: "bottom"
  40054. }, (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(link_control, {
  40055. value: {
  40056. url: mediaURL
  40057. },
  40058. settings: [],
  40059. showSuggestions: false,
  40060. onChange: _ref7 => {
  40061. let {
  40062. url
  40063. } = _ref7;
  40064. onSelectURL(url);
  40065. editMediaButtonRef.current.focus();
  40066. }
  40067. })))));
  40068. }
  40069. });
  40070. };
  40071. /**
  40072. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md
  40073. */
  40074. /* harmony default export */ var media_replace_flow = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
  40075. const {
  40076. createNotice,
  40077. removeNotice
  40078. } = dispatch(external_wp_notices_namespaceObject.store);
  40079. return {
  40080. createNotice,
  40081. removeNotice
  40082. };
  40083. }), (0,external_wp_components_namespaceObject.withFilters)('editor.MediaReplaceFlow')])(MediaReplaceFlow));
  40084. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-viewer-url.js
  40085. /**
  40086. * External dependencies
  40087. */
  40088. /**
  40089. * WordPress dependencies
  40090. */
  40091. function LinkViewerURL(_ref) {
  40092. let {
  40093. url,
  40094. urlLabel,
  40095. className
  40096. } = _ref;
  40097. const linkClassName = classnames_default()(className, 'block-editor-url-popover__link-viewer-url');
  40098. if (!url) {
  40099. return (0,external_wp_element_namespaceObject.createElement)("span", {
  40100. className: linkClassName
  40101. });
  40102. }
  40103. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  40104. className: linkClassName,
  40105. href: url
  40106. }, urlLabel || (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURI)(url)));
  40107. }
  40108. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-viewer.js
  40109. /**
  40110. * External dependencies
  40111. */
  40112. /**
  40113. * WordPress dependencies
  40114. */
  40115. /**
  40116. * Internal dependencies
  40117. */
  40118. function LinkViewer(_ref) {
  40119. let {
  40120. className,
  40121. linkClassName,
  40122. onEditLinkClick,
  40123. url,
  40124. urlLabel,
  40125. ...props
  40126. } = _ref;
  40127. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  40128. className: classnames_default()('block-editor-url-popover__link-viewer', className)
  40129. }, props), (0,external_wp_element_namespaceObject.createElement)(LinkViewerURL, {
  40130. url: url,
  40131. urlLabel: urlLabel,
  40132. className: linkClassName
  40133. }), onEditLinkClick && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  40134. icon: library_edit,
  40135. label: (0,external_wp_i18n_namespaceObject.__)('Edit'),
  40136. onClick: onEditLinkClick
  40137. }));
  40138. }
  40139. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-editor.js
  40140. /**
  40141. * External dependencies
  40142. */
  40143. /**
  40144. * WordPress dependencies
  40145. */
  40146. /**
  40147. * Internal dependencies
  40148. */
  40149. function LinkEditor(_ref) {
  40150. let {
  40151. autocompleteRef,
  40152. className,
  40153. onChangeInputValue,
  40154. value,
  40155. ...props
  40156. } = _ref;
  40157. return (0,external_wp_element_namespaceObject.createElement)("form", _extends({
  40158. className: classnames_default()('block-editor-url-popover__link-editor', className)
  40159. }, props), (0,external_wp_element_namespaceObject.createElement)(url_input, {
  40160. value: value,
  40161. onChange: onChangeInputValue,
  40162. autocompleteRef: autocompleteRef
  40163. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  40164. icon: keyboard_return,
  40165. label: (0,external_wp_i18n_namespaceObject.__)('Apply'),
  40166. type: "submit"
  40167. }));
  40168. }
  40169. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/index.js
  40170. /**
  40171. * WordPress dependencies
  40172. */
  40173. /**
  40174. * Internal dependencies
  40175. */
  40176. function URLPopover(_ref) {
  40177. let {
  40178. additionalControls,
  40179. children,
  40180. renderSettings,
  40181. position = 'bottom center',
  40182. focusOnMount = 'firstElement',
  40183. ...popoverProps
  40184. } = _ref;
  40185. const [isSettingsExpanded, setIsSettingsExpanded] = (0,external_wp_element_namespaceObject.useState)(false);
  40186. const showSettings = !!renderSettings && isSettingsExpanded;
  40187. const toggleSettingsVisibility = () => {
  40188. setIsSettingsExpanded(!isSettingsExpanded);
  40189. };
  40190. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, _extends({
  40191. className: "block-editor-url-popover",
  40192. focusOnMount: focusOnMount,
  40193. position: position,
  40194. shift: true
  40195. }, popoverProps), (0,external_wp_element_namespaceObject.createElement)("div", {
  40196. className: "block-editor-url-popover__input-container"
  40197. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  40198. className: "block-editor-url-popover__row"
  40199. }, children, !!renderSettings && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  40200. className: "block-editor-url-popover__settings-toggle",
  40201. icon: chevron_down,
  40202. label: (0,external_wp_i18n_namespaceObject.__)('Link settings'),
  40203. onClick: toggleSettingsVisibility,
  40204. "aria-expanded": isSettingsExpanded
  40205. })), showSettings && (0,external_wp_element_namespaceObject.createElement)("div", {
  40206. className: "block-editor-url-popover__row block-editor-url-popover__settings"
  40207. }, renderSettings())), additionalControls && !showSettings && (0,external_wp_element_namespaceObject.createElement)("div", {
  40208. className: "block-editor-url-popover__additional-controls"
  40209. }, additionalControls));
  40210. }
  40211. URLPopover.LinkEditor = LinkEditor;
  40212. URLPopover.LinkViewer = LinkViewer;
  40213. /**
  40214. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-popover/README.md
  40215. */
  40216. /* harmony default export */ var url_popover = (URLPopover);
  40217. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-placeholder/index.js
  40218. /**
  40219. * External dependencies
  40220. */
  40221. /**
  40222. * WordPress dependencies
  40223. */
  40224. /**
  40225. * Internal dependencies
  40226. */
  40227. const media_placeholder_noop = () => {};
  40228. const InsertFromURLPopover = _ref => {
  40229. let {
  40230. src,
  40231. onChange,
  40232. onSubmit,
  40233. onClose
  40234. } = _ref;
  40235. return (0,external_wp_element_namespaceObject.createElement)(url_popover, {
  40236. onClose: onClose
  40237. }, (0,external_wp_element_namespaceObject.createElement)("form", {
  40238. className: "block-editor-media-placeholder__url-input-form",
  40239. onSubmit: onSubmit
  40240. }, (0,external_wp_element_namespaceObject.createElement)("input", {
  40241. className: "block-editor-media-placeholder__url-input-field",
  40242. type: "text",
  40243. "aria-label": (0,external_wp_i18n_namespaceObject.__)('URL'),
  40244. placeholder: (0,external_wp_i18n_namespaceObject.__)('Paste or type URL'),
  40245. onChange: onChange,
  40246. value: src
  40247. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  40248. className: "block-editor-media-placeholder__url-input-submit-button",
  40249. icon: keyboard_return,
  40250. label: (0,external_wp_i18n_namespaceObject.__)('Apply'),
  40251. type: "submit"
  40252. })));
  40253. };
  40254. function MediaPlaceholder(_ref2) {
  40255. let {
  40256. value = {},
  40257. allowedTypes,
  40258. className,
  40259. icon,
  40260. labels = {},
  40261. mediaPreview,
  40262. notices,
  40263. isAppender,
  40264. accept,
  40265. addToGallery,
  40266. multiple = false,
  40267. handleUpload = true,
  40268. disableDropZone,
  40269. disableMediaButtons,
  40270. onError,
  40271. onSelect,
  40272. onCancel,
  40273. onSelectURL,
  40274. onToggleFeaturedImage,
  40275. onDoubleClick,
  40276. onFilesPreUpload = media_placeholder_noop,
  40277. onHTMLDrop = media_placeholder_noop,
  40278. children,
  40279. mediaLibraryButton,
  40280. placeholder,
  40281. style
  40282. } = _ref2;
  40283. const mediaUpload = (0,external_wp_data_namespaceObject.useSelect)(select => {
  40284. const {
  40285. getSettings
  40286. } = select(store);
  40287. return getSettings().mediaUpload;
  40288. }, []);
  40289. const [src, setSrc] = (0,external_wp_element_namespaceObject.useState)('');
  40290. const [isURLInputVisible, setIsURLInputVisible] = (0,external_wp_element_namespaceObject.useState)(false);
  40291. (0,external_wp_element_namespaceObject.useEffect)(() => {
  40292. var _value$src;
  40293. setSrc((_value$src = value === null || value === void 0 ? void 0 : value.src) !== null && _value$src !== void 0 ? _value$src : '');
  40294. }, [value === null || value === void 0 ? void 0 : value.src]);
  40295. const onlyAllowsImages = () => {
  40296. if (!allowedTypes || allowedTypes.length === 0) {
  40297. return false;
  40298. }
  40299. return allowedTypes.every(allowedType => allowedType === 'image' || allowedType.startsWith('image/'));
  40300. };
  40301. const onChangeSrc = event => {
  40302. setSrc(event.target.value);
  40303. };
  40304. const openURLInput = () => {
  40305. setIsURLInputVisible(true);
  40306. };
  40307. const closeURLInput = () => {
  40308. setIsURLInputVisible(false);
  40309. };
  40310. const onSubmitSrc = event => {
  40311. event.preventDefault();
  40312. if (src && onSelectURL) {
  40313. onSelectURL(src);
  40314. closeURLInput();
  40315. }
  40316. };
  40317. const onFilesUpload = files => {
  40318. if (!handleUpload) {
  40319. return onSelect(files);
  40320. }
  40321. onFilesPreUpload(files);
  40322. let setMedia;
  40323. if (multiple) {
  40324. if (addToGallery) {
  40325. // Since the setMedia function runs multiple times per upload group
  40326. // and is passed newMedia containing every item in its group each time, we must
  40327. // filter out whatever this upload group had previously returned to the
  40328. // gallery before adding and returning the image array with replacement newMedia
  40329. // values.
  40330. // Define an array to store urls from newMedia between subsequent function calls.
  40331. let lastMediaPassed = [];
  40332. setMedia = newMedia => {
  40333. // Remove any images this upload group is responsible for (lastMediaPassed).
  40334. // Their replacements are contained in newMedia.
  40335. const filteredMedia = (value !== null && value !== void 0 ? value : []).filter(item => {
  40336. // If Item has id, only remove it if lastMediaPassed has an item with that id.
  40337. if (item.id) {
  40338. return !lastMediaPassed.some( // Be sure to convert to number for comparison.
  40339. _ref3 => {
  40340. let {
  40341. id
  40342. } = _ref3;
  40343. return Number(id) === Number(item.id);
  40344. });
  40345. } // Compare transient images via .includes since gallery may append extra info onto the url.
  40346. return !lastMediaPassed.some(_ref4 => {
  40347. let {
  40348. urlSlug
  40349. } = _ref4;
  40350. return item.url.includes(urlSlug);
  40351. });
  40352. }); // Return the filtered media array along with newMedia.
  40353. onSelect(filteredMedia.concat(newMedia)); // Reset lastMediaPassed and set it with ids and urls from newMedia.
  40354. lastMediaPassed = newMedia.map(media => {
  40355. // Add everything up to '.fileType' to compare via .includes.
  40356. const cutOffIndex = media.url.lastIndexOf('.');
  40357. const urlSlug = media.url.slice(0, cutOffIndex);
  40358. return {
  40359. id: media.id,
  40360. urlSlug
  40361. };
  40362. });
  40363. };
  40364. } else {
  40365. setMedia = onSelect;
  40366. }
  40367. } else {
  40368. setMedia = _ref5 => {
  40369. let [media] = _ref5;
  40370. return onSelect(media);
  40371. };
  40372. }
  40373. mediaUpload({
  40374. allowedTypes,
  40375. filesList: files,
  40376. onFileChange: setMedia,
  40377. onError
  40378. });
  40379. };
  40380. const onUpload = event => {
  40381. onFilesUpload(event.target.files);
  40382. };
  40383. const defaultRenderPlaceholder = content => {
  40384. let {
  40385. instructions,
  40386. title
  40387. } = labels;
  40388. if (!mediaUpload && !onSelectURL) {
  40389. instructions = (0,external_wp_i18n_namespaceObject.__)('To edit this block, you need permission to upload media.');
  40390. }
  40391. if (instructions === undefined || title === undefined) {
  40392. const typesAllowed = allowedTypes !== null && allowedTypes !== void 0 ? allowedTypes : [];
  40393. const [firstAllowedType] = typesAllowed;
  40394. const isOneType = 1 === typesAllowed.length;
  40395. const isAudio = isOneType && 'audio' === firstAllowedType;
  40396. const isImage = isOneType && 'image' === firstAllowedType;
  40397. const isVideo = isOneType && 'video' === firstAllowedType;
  40398. if (instructions === undefined && mediaUpload) {
  40399. instructions = (0,external_wp_i18n_namespaceObject.__)('Upload a media file or pick one from your media library.');
  40400. if (isAudio) {
  40401. instructions = (0,external_wp_i18n_namespaceObject.__)('Upload an audio file, pick one from your media library, or add one with a URL.');
  40402. } else if (isImage) {
  40403. instructions = (0,external_wp_i18n_namespaceObject.__)('Upload an image file, pick one from your media library, or add one with a URL.');
  40404. } else if (isVideo) {
  40405. instructions = (0,external_wp_i18n_namespaceObject.__)('Upload a video file, pick one from your media library, or add one with a URL.');
  40406. }
  40407. }
  40408. if (title === undefined) {
  40409. title = (0,external_wp_i18n_namespaceObject.__)('Media');
  40410. if (isAudio) {
  40411. title = (0,external_wp_i18n_namespaceObject.__)('Audio');
  40412. } else if (isImage) {
  40413. title = (0,external_wp_i18n_namespaceObject.__)('Image');
  40414. } else if (isVideo) {
  40415. title = (0,external_wp_i18n_namespaceObject.__)('Video');
  40416. }
  40417. }
  40418. }
  40419. const placeholderClassName = classnames_default()('block-editor-media-placeholder', className, {
  40420. 'is-appender': isAppender
  40421. });
  40422. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
  40423. icon: icon,
  40424. label: title,
  40425. instructions: instructions,
  40426. className: placeholderClassName,
  40427. notices: notices,
  40428. onDoubleClick: onDoubleClick,
  40429. preview: mediaPreview,
  40430. style: style
  40431. }, content, children);
  40432. };
  40433. const renderPlaceholder = placeholder !== null && placeholder !== void 0 ? placeholder : defaultRenderPlaceholder;
  40434. const renderDropZone = () => {
  40435. if (disableDropZone) {
  40436. return null;
  40437. }
  40438. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropZone, {
  40439. onFilesDrop: onFilesUpload,
  40440. onHTMLDrop: onHTMLDrop
  40441. });
  40442. };
  40443. const renderCancelLink = () => {
  40444. return onCancel && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  40445. className: "block-editor-media-placeholder__cancel-button",
  40446. title: (0,external_wp_i18n_namespaceObject.__)('Cancel'),
  40447. variant: "link",
  40448. onClick: onCancel
  40449. }, (0,external_wp_i18n_namespaceObject.__)('Cancel'));
  40450. };
  40451. const renderUrlSelectionUI = () => {
  40452. return onSelectURL && (0,external_wp_element_namespaceObject.createElement)("div", {
  40453. className: "block-editor-media-placeholder__url-input-container"
  40454. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  40455. className: "block-editor-media-placeholder__button",
  40456. onClick: openURLInput,
  40457. isPressed: isURLInputVisible,
  40458. variant: "tertiary"
  40459. }, (0,external_wp_i18n_namespaceObject.__)('Insert from URL')), isURLInputVisible && (0,external_wp_element_namespaceObject.createElement)(InsertFromURLPopover, {
  40460. src: src,
  40461. onChange: onChangeSrc,
  40462. onSubmit: onSubmitSrc,
  40463. onClose: closeURLInput
  40464. }));
  40465. };
  40466. const renderFeaturedImageToggle = () => {
  40467. return onToggleFeaturedImage && (0,external_wp_element_namespaceObject.createElement)("div", {
  40468. className: "block-editor-media-placeholder__url-input-container"
  40469. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  40470. className: "block-editor-media-placeholder__button",
  40471. onClick: onToggleFeaturedImage,
  40472. variant: "tertiary"
  40473. }, (0,external_wp_i18n_namespaceObject.__)('Use featured image')));
  40474. };
  40475. const renderMediaUploadChecked = () => {
  40476. const defaultButton = _ref6 => {
  40477. let {
  40478. open
  40479. } = _ref6;
  40480. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  40481. variant: "tertiary",
  40482. onClick: () => {
  40483. open();
  40484. }
  40485. }, (0,external_wp_i18n_namespaceObject.__)('Media Library'));
  40486. };
  40487. const libraryButton = mediaLibraryButton !== null && mediaLibraryButton !== void 0 ? mediaLibraryButton : defaultButton;
  40488. const uploadMediaLibraryButton = (0,external_wp_element_namespaceObject.createElement)(media_upload, {
  40489. addToGallery: addToGallery,
  40490. gallery: multiple && onlyAllowsImages(),
  40491. multiple: multiple,
  40492. onSelect: onSelect,
  40493. allowedTypes: allowedTypes,
  40494. mode: 'browse',
  40495. value: Array.isArray(value) ? value.map(_ref7 => {
  40496. let {
  40497. id
  40498. } = _ref7;
  40499. return id;
  40500. }) : value.id,
  40501. render: libraryButton
  40502. });
  40503. if (mediaUpload && isAppender) {
  40504. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, renderDropZone(), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormFileUpload, {
  40505. onChange: onUpload,
  40506. accept: accept,
  40507. multiple: multiple,
  40508. render: _ref8 => {
  40509. let {
  40510. openFileDialog
  40511. } = _ref8;
  40512. const content = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  40513. variant: "primary",
  40514. className: classnames_default()('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button'),
  40515. onClick: openFileDialog
  40516. }, (0,external_wp_i18n_namespaceObject.__)('Upload')), uploadMediaLibraryButton, renderUrlSelectionUI(), renderFeaturedImageToggle(), renderCancelLink());
  40517. return renderPlaceholder(content);
  40518. }
  40519. }));
  40520. }
  40521. if (mediaUpload) {
  40522. const content = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, renderDropZone(), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormFileUpload, {
  40523. variant: "primary",
  40524. className: classnames_default()('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button'),
  40525. onChange: onUpload,
  40526. accept: accept,
  40527. multiple: multiple
  40528. }, (0,external_wp_i18n_namespaceObject.__)('Upload')), uploadMediaLibraryButton, renderUrlSelectionUI(), renderFeaturedImageToggle(), renderCancelLink());
  40529. return renderPlaceholder(content);
  40530. }
  40531. return renderPlaceholder(uploadMediaLibraryButton);
  40532. };
  40533. if (disableMediaButtons) {
  40534. return (0,external_wp_element_namespaceObject.createElement)(media_upload_check, null, renderDropZone());
  40535. }
  40536. return (0,external_wp_element_namespaceObject.createElement)(media_upload_check, {
  40537. fallback: renderPlaceholder(renderUrlSelectionUI())
  40538. }, renderMediaUploadChecked());
  40539. }
  40540. /**
  40541. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md
  40542. */
  40543. /* harmony default export */ var media_placeholder = ((0,external_wp_components_namespaceObject.withFilters)('editor.MediaPlaceholder')(MediaPlaceholder));
  40544. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/panel-color-settings/index.js
  40545. /**
  40546. * Internal dependencies
  40547. */
  40548. const PanelColorSettings = _ref => {
  40549. let {
  40550. colorSettings,
  40551. ...props
  40552. } = _ref;
  40553. const settings = colorSettings.map(setting => {
  40554. if (!setting) {
  40555. return setting;
  40556. }
  40557. const {
  40558. value,
  40559. onChange,
  40560. ...otherSettings
  40561. } = setting;
  40562. return { ...otherSettings,
  40563. colorValue: value,
  40564. onColorChange: onChange
  40565. };
  40566. });
  40567. return (0,external_wp_element_namespaceObject.createElement)(panel_color_gradient_settings, _extends({
  40568. settings: settings,
  40569. gradients: [],
  40570. disableCustomGradients: true
  40571. }, props));
  40572. };
  40573. /* harmony default export */ var panel_color_settings = (PanelColorSettings);
  40574. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar/index.js
  40575. /**
  40576. * External dependencies
  40577. */
  40578. /**
  40579. * WordPress dependencies
  40580. */
  40581. const format_toolbar_POPOVER_PROPS = {
  40582. position: 'bottom right',
  40583. isAlternate: true
  40584. };
  40585. const FormatToolbar = () => {
  40586. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, ['bold', 'italic', 'link'].map(format => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
  40587. name: `RichText.ToolbarControls.${format}`,
  40588. key: format
  40589. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
  40590. name: "RichText.ToolbarControls"
  40591. }, fills => {
  40592. if (!fills.length) {
  40593. return null;
  40594. }
  40595. const allProps = fills.map(_ref => {
  40596. let [{
  40597. props
  40598. }] = _ref;
  40599. return props;
  40600. });
  40601. const hasActive = allProps.some(_ref2 => {
  40602. let {
  40603. isActive
  40604. } = _ref2;
  40605. return isActive;
  40606. });
  40607. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
  40608. icon: chevron_down
  40609. /* translators: button label text should, if possible, be under 16 characters. */
  40610. ,
  40611. label: (0,external_wp_i18n_namespaceObject.__)('More'),
  40612. toggleProps: { ...toggleProps,
  40613. className: classnames_default()(toggleProps.className, {
  40614. 'is-pressed': hasActive
  40615. }),
  40616. describedBy: (0,external_wp_i18n_namespaceObject.__)('Displays more block tools')
  40617. },
  40618. controls: (0,external_lodash_namespaceObject.orderBy)(fills.map(_ref3 => {
  40619. let [{
  40620. props
  40621. }] = _ref3;
  40622. return props;
  40623. }), 'title'),
  40624. popoverProps: format_toolbar_POPOVER_PROPS
  40625. }));
  40626. }));
  40627. };
  40628. /* harmony default export */ var format_toolbar = (FormatToolbar);
  40629. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar-container.js
  40630. /**
  40631. * WordPress dependencies
  40632. */
  40633. /**
  40634. * Internal dependencies
  40635. */
  40636. function InlineSelectionToolbar(_ref) {
  40637. let {
  40638. value,
  40639. editableContentElement,
  40640. activeFormats
  40641. } = _ref;
  40642. const lastFormat = activeFormats[activeFormats.length - 1];
  40643. const lastFormatType = lastFormat === null || lastFormat === void 0 ? void 0 : lastFormat.type;
  40644. const settings = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_richText_namespaceObject.store).getFormatType(lastFormatType), [lastFormatType]);
  40645. const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({
  40646. editableContentElement,
  40647. value,
  40648. settings
  40649. });
  40650. return (0,external_wp_element_namespaceObject.createElement)(InlineToolbar, {
  40651. popoverAnchor: popoverAnchor
  40652. });
  40653. }
  40654. function InlineToolbar(_ref2) {
  40655. let {
  40656. popoverAnchor
  40657. } = _ref2;
  40658. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  40659. position: "top center",
  40660. focusOnMount: false,
  40661. anchor: popoverAnchor,
  40662. className: "block-editor-rich-text__inline-format-toolbar",
  40663. __unstableSlotName: "block-toolbar"
  40664. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  40665. className: "block-editor-rich-text__inline-format-toolbar-group"
  40666. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(format_toolbar, null))));
  40667. }
  40668. const FormatToolbarContainer = _ref3 => {
  40669. let {
  40670. inline,
  40671. editableContentElement,
  40672. value
  40673. } = _ref3;
  40674. const hasInlineToolbar = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().hasInlineToolbar, []);
  40675. if (inline) {
  40676. return (0,external_wp_element_namespaceObject.createElement)(InlineToolbar, {
  40677. popoverAnchor: editableContentElement
  40678. });
  40679. }
  40680. if (hasInlineToolbar) {
  40681. const activeFormats = (0,external_wp_richText_namespaceObject.getActiveFormats)(value);
  40682. if ((0,external_wp_richText_namespaceObject.isCollapsed)(value) && !activeFormats.length) {
  40683. return null;
  40684. }
  40685. return (0,external_wp_element_namespaceObject.createElement)(InlineSelectionToolbar, {
  40686. editableContentElement: editableContentElement,
  40687. value: value,
  40688. activeFormats: activeFormats
  40689. });
  40690. } // Render regular toolbar.
  40691. return (0,external_wp_element_namespaceObject.createElement)(block_controls, {
  40692. group: "inline"
  40693. }, (0,external_wp_element_namespaceObject.createElement)(format_toolbar, null));
  40694. };
  40695. /* harmony default export */ var format_toolbar_container = (FormatToolbarContainer);
  40696. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-undo-automatic-change.js
  40697. /**
  40698. * WordPress dependencies
  40699. */
  40700. /**
  40701. * Internal dependencies
  40702. */
  40703. function useUndoAutomaticChange() {
  40704. const {
  40705. didAutomaticChange,
  40706. getSettings
  40707. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  40708. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  40709. function onKeyDown(event) {
  40710. const {
  40711. keyCode
  40712. } = event;
  40713. if (event.defaultPrevented) {
  40714. return;
  40715. }
  40716. if (keyCode !== external_wp_keycodes_namespaceObject.DELETE && keyCode !== external_wp_keycodes_namespaceObject.BACKSPACE && keyCode !== external_wp_keycodes_namespaceObject.ESCAPE) {
  40717. return;
  40718. }
  40719. if (!didAutomaticChange()) {
  40720. return;
  40721. }
  40722. event.preventDefault();
  40723. getSettings().__experimentalUndo();
  40724. }
  40725. element.addEventListener('keydown', onKeyDown);
  40726. return () => {
  40727. element.removeEventListener('keydown', onKeyDown);
  40728. };
  40729. }, []);
  40730. }
  40731. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-mark-persistent.js
  40732. /**
  40733. * WordPress dependencies
  40734. */
  40735. /**
  40736. * Internal dependencies
  40737. */
  40738. function useMarkPersistent(_ref) {
  40739. let {
  40740. html,
  40741. value
  40742. } = _ref;
  40743. const previousText = (0,external_wp_element_namespaceObject.useRef)();
  40744. const hasActiveFormats = value.activeFormats && !!value.activeFormats.length;
  40745. const {
  40746. __unstableMarkLastChangeAsPersistent
  40747. } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Must be set synchronously to make sure it applies to the last change.
  40748. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  40749. // Ignore mount.
  40750. if (!previousText.current) {
  40751. previousText.current = value.text;
  40752. return;
  40753. } // Text input, so don't create an undo level for every character.
  40754. // Create an undo level after 1 second of no input.
  40755. if (previousText.current !== value.text) {
  40756. const timeout = window.setTimeout(() => {
  40757. __unstableMarkLastChangeAsPersistent();
  40758. }, 1000);
  40759. previousText.current = value.text;
  40760. return () => {
  40761. window.clearTimeout(timeout);
  40762. };
  40763. }
  40764. __unstableMarkLastChangeAsPersistent();
  40765. }, [html, hasActiveFormats]);
  40766. }
  40767. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/file-paste-handler.js
  40768. /**
  40769. * WordPress dependencies
  40770. */
  40771. function filePasteHandler(files) {
  40772. return files.filter(_ref => {
  40773. let {
  40774. type
  40775. } = _ref;
  40776. return /^image\/(?:jpe?g|png|gif|webp)$/.test(type);
  40777. }).map(file => `<img src="${(0,external_wp_blob_namespaceObject.createBlobURL)(file)}">`).join('');
  40778. }
  40779. ;// CONCATENATED MODULE: external ["wp","shortcode"]
  40780. var external_wp_shortcode_namespaceObject = window["wp"]["shortcode"];
  40781. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/utils.js
  40782. /**
  40783. * WordPress dependencies
  40784. */
  40785. function addActiveFormats(value, activeFormats) {
  40786. if (activeFormats !== null && activeFormats !== void 0 && activeFormats.length) {
  40787. let index = value.formats.length;
  40788. while (index--) {
  40789. value.formats[index] = [...activeFormats, ...(value.formats[index] || [])];
  40790. }
  40791. }
  40792. }
  40793. /**
  40794. * Get the multiline tag based on the multiline prop.
  40795. *
  40796. * @param {?(string|boolean)} multiline The multiline prop.
  40797. *
  40798. * @return {?string} The multiline tag.
  40799. */
  40800. function getMultilineTag(multiline) {
  40801. if (multiline !== true && multiline !== 'p' && multiline !== 'li') {
  40802. return;
  40803. }
  40804. return multiline === true ? 'p' : multiline;
  40805. }
  40806. function getAllowedFormats(_ref) {
  40807. let {
  40808. allowedFormats,
  40809. formattingControls,
  40810. disableFormats
  40811. } = _ref;
  40812. if (disableFormats) {
  40813. return getAllowedFormats.EMPTY_ARRAY;
  40814. }
  40815. if (!allowedFormats && !formattingControls) {
  40816. return;
  40817. }
  40818. if (allowedFormats) {
  40819. return allowedFormats;
  40820. }
  40821. external_wp_deprecated_default()('wp.blockEditor.RichText formattingControls prop', {
  40822. since: '5.4',
  40823. alternative: 'allowedFormats',
  40824. version: '6.2'
  40825. });
  40826. return formattingControls.map(name => `core/${name}`);
  40827. }
  40828. getAllowedFormats.EMPTY_ARRAY = [];
  40829. const isShortcode = text => (0,external_wp_shortcode_namespaceObject.regexp)('.*').test(text);
  40830. /**
  40831. * Creates a link from pasted URL.
  40832. * Creates a paragraph block containing a link to the URL, and calls `onReplace`.
  40833. *
  40834. * @param {string} url The URL that could not be embedded.
  40835. * @param {Function} onReplace Function to call with the created fallback block.
  40836. */
  40837. function createLinkInParagraph(url, onReplace) {
  40838. const link = createElement("a", {
  40839. href: url
  40840. }, url);
  40841. onReplace(createBlock('core/paragraph', {
  40842. content: renderToString(link)
  40843. }));
  40844. }
  40845. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/split-value.js
  40846. /**
  40847. * WordPress dependencies
  40848. */
  40849. /*
  40850. * Signals to the RichText owner that the block can be replaced with two blocks
  40851. * as a result of splitting the block by pressing enter, or with blocks as a
  40852. * result of splitting the block by pasting block content in the instance.
  40853. */
  40854. function splitValue(_ref) {
  40855. let {
  40856. value,
  40857. pastedBlocks = [],
  40858. onReplace,
  40859. onSplit,
  40860. onSplitMiddle,
  40861. multilineTag
  40862. } = _ref;
  40863. if (!onReplace || !onSplit) {
  40864. return;
  40865. } // Ensure the value has a selection. This might happen when trying to split
  40866. // an empty value before there was a `selectionchange` event.
  40867. const {
  40868. start = 0,
  40869. end = 0
  40870. } = value;
  40871. const valueWithEnsuredSelection = { ...value,
  40872. start,
  40873. end
  40874. };
  40875. const blocks = [];
  40876. const [before, after] = (0,external_wp_richText_namespaceObject.split)(valueWithEnsuredSelection);
  40877. const hasPastedBlocks = pastedBlocks.length > 0;
  40878. let lastPastedBlockIndex = -1; // Consider the after value to be the original it is not empty and the
  40879. // before value *is* empty.
  40880. const isAfterOriginal = (0,external_wp_richText_namespaceObject.isEmpty)(before) && !(0,external_wp_richText_namespaceObject.isEmpty)(after); // Create a block with the content before the caret if there's no pasted
  40881. // blocks, or if there are pasted blocks and the value is not empty. We do
  40882. // not want a leading empty block on paste, but we do if split with e.g. the
  40883. // enter key.
  40884. if (!hasPastedBlocks || !(0,external_wp_richText_namespaceObject.isEmpty)(before)) {
  40885. blocks.push(onSplit((0,external_wp_richText_namespaceObject.toHTMLString)({
  40886. value: before,
  40887. multilineTag
  40888. }), !isAfterOriginal));
  40889. lastPastedBlockIndex += 1;
  40890. }
  40891. if (hasPastedBlocks) {
  40892. blocks.push(...pastedBlocks);
  40893. lastPastedBlockIndex += pastedBlocks.length;
  40894. } else if (onSplitMiddle) {
  40895. blocks.push(onSplitMiddle());
  40896. } // If there's pasted blocks, append a block with non empty content / after
  40897. // the caret. Otherwise, do append an empty block if there is no
  40898. // `onSplitMiddle` prop, but if there is and the content is empty, the
  40899. // middle block is enough to set focus in.
  40900. if (hasPastedBlocks ? !(0,external_wp_richText_namespaceObject.isEmpty)(after) : !onSplitMiddle || !(0,external_wp_richText_namespaceObject.isEmpty)(after)) {
  40901. blocks.push(onSplit((0,external_wp_richText_namespaceObject.toHTMLString)({
  40902. value: after,
  40903. multilineTag
  40904. }), isAfterOriginal));
  40905. } // If there are pasted blocks, set the selection to the last one. Otherwise,
  40906. // set the selection to the second block.
  40907. const indexToSelect = hasPastedBlocks ? lastPastedBlockIndex : 1; // If there are pasted blocks, move the caret to the end of the selected
  40908. // block Otherwise, retain the default value.
  40909. const initialPosition = hasPastedBlocks ? -1 : 0;
  40910. onReplace(blocks, indexToSelect, initialPosition);
  40911. }
  40912. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-paste-handler.js
  40913. /**
  40914. * WordPress dependencies
  40915. */
  40916. /**
  40917. * Internal dependencies
  40918. */
  40919. /** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */
  40920. /**
  40921. * Replaces line separators with line breaks if not multiline.
  40922. * Replaces line breaks with line separators if multiline.
  40923. *
  40924. * @param {RichTextValue} value Value to adjust.
  40925. * @param {boolean} isMultiline Whether to adjust to multiline or not.
  40926. *
  40927. * @return {RichTextValue} Adjusted value.
  40928. */
  40929. function adjustLines(value, isMultiline) {
  40930. if (isMultiline) {
  40931. return (0,external_wp_richText_namespaceObject.replace)(value, /\n+/g, external_wp_richText_namespaceObject.__UNSTABLE_LINE_SEPARATOR);
  40932. }
  40933. return (0,external_wp_richText_namespaceObject.replace)(value, new RegExp(external_wp_richText_namespaceObject.__UNSTABLE_LINE_SEPARATOR, 'g'), '\n');
  40934. }
  40935. function usePasteHandler(props) {
  40936. const propsRef = (0,external_wp_element_namespaceObject.useRef)(props);
  40937. propsRef.current = props;
  40938. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  40939. function _onPaste(event) {
  40940. const {
  40941. isSelected,
  40942. disableFormats,
  40943. onChange,
  40944. value,
  40945. formatTypes,
  40946. tagName,
  40947. onReplace,
  40948. onSplit,
  40949. onSplitMiddle,
  40950. __unstableEmbedURLOnPaste,
  40951. multilineTag,
  40952. preserveWhiteSpace,
  40953. pastePlainText
  40954. } = propsRef.current;
  40955. if (!isSelected) {
  40956. return;
  40957. }
  40958. const {
  40959. clipboardData
  40960. } = event;
  40961. let plainText = '';
  40962. let html = ''; // IE11 only supports `Text` as an argument for `getData` and will
  40963. // otherwise throw an invalid argument error, so we try the standard
  40964. // arguments first, then fallback to `Text` if they fail.
  40965. try {
  40966. plainText = clipboardData.getData('text/plain');
  40967. html = clipboardData.getData('text/html');
  40968. } catch (error1) {
  40969. try {
  40970. html = clipboardData.getData('Text');
  40971. } catch (error2) {
  40972. // Some browsers like UC Browser paste plain text by default and
  40973. // don't support clipboardData at all, so allow default
  40974. // behaviour.
  40975. return;
  40976. }
  40977. } // Remove Windows-specific metadata appended within copied HTML text.
  40978. html = removeWindowsFragments(html); // Strip meta tag.
  40979. html = removeCharsetMetaTag(html);
  40980. event.preventDefault(); // Allows us to ask for this information when we get a report.
  40981. window.console.log('Received HTML:\n\n', html);
  40982. window.console.log('Received plain text:\n\n', plainText);
  40983. if (disableFormats) {
  40984. onChange((0,external_wp_richText_namespaceObject.insert)(value, plainText));
  40985. return;
  40986. }
  40987. const transformed = formatTypes.reduce((accumlator, _ref) => {
  40988. let {
  40989. __unstablePasteRule
  40990. } = _ref;
  40991. // Only allow one transform.
  40992. if (__unstablePasteRule && accumlator === value) {
  40993. accumlator = __unstablePasteRule(value, {
  40994. html,
  40995. plainText
  40996. });
  40997. }
  40998. return accumlator;
  40999. }, value);
  41000. if (transformed !== value) {
  41001. onChange(transformed);
  41002. return;
  41003. }
  41004. const files = [...(0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(clipboardData)];
  41005. const isInternal = clipboardData.getData('rich-text') === 'true'; // If the data comes from a rich text instance, we can directly use it
  41006. // without filtering the data. The filters are only meant for externally
  41007. // pasted content and remove inline styles.
  41008. if (isInternal) {
  41009. const pastedMultilineTag = clipboardData.getData('rich-text-multi-line-tag') || undefined;
  41010. let pastedValue = (0,external_wp_richText_namespaceObject.create)({
  41011. html,
  41012. multilineTag: pastedMultilineTag,
  41013. multilineWrapperTags: pastedMultilineTag === 'li' ? ['ul', 'ol'] : undefined,
  41014. preserveWhiteSpace
  41015. });
  41016. pastedValue = adjustLines(pastedValue, !!multilineTag);
  41017. addActiveFormats(pastedValue, value.activeFormats);
  41018. onChange((0,external_wp_richText_namespaceObject.insert)(value, pastedValue));
  41019. return;
  41020. }
  41021. if (pastePlainText) {
  41022. onChange((0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.create)({
  41023. text: plainText
  41024. })));
  41025. return;
  41026. } // Process any attached files, unless we infer that the files in
  41027. // question are redundant "screenshots" of the actual HTML payload,
  41028. // as created by certain office-type programs.
  41029. //
  41030. // @see shouldDismissPastedFiles
  41031. if (files !== null && files !== void 0 && files.length && !shouldDismissPastedFiles(files, html, plainText)) {
  41032. const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
  41033. HTML: filePasteHandler(files),
  41034. mode: 'BLOCKS',
  41035. tagName,
  41036. preserveWhiteSpace
  41037. }); // Allows us to ask for this information when we get a report.
  41038. // eslint-disable-next-line no-console
  41039. window.console.log('Received items:\n\n', files);
  41040. if (onReplace && (0,external_wp_richText_namespaceObject.isEmpty)(value)) {
  41041. onReplace(content);
  41042. } else {
  41043. splitValue({
  41044. value,
  41045. pastedBlocks: content,
  41046. onReplace,
  41047. onSplit,
  41048. onSplitMiddle,
  41049. multilineTag
  41050. });
  41051. }
  41052. return;
  41053. }
  41054. let mode = onReplace && onSplit ? 'AUTO' : 'INLINE'; // Force the blocks mode when the user is pasting
  41055. // on a new line & the content resembles a shortcode.
  41056. // Otherwise it's going to be detected as inline
  41057. // and the shortcode won't be replaced.
  41058. if (mode === 'AUTO' && (0,external_wp_richText_namespaceObject.isEmpty)(value) && isShortcode(plainText)) {
  41059. mode = 'BLOCKS';
  41060. }
  41061. if (__unstableEmbedURLOnPaste && (0,external_wp_richText_namespaceObject.isEmpty)(value) && (0,external_wp_url_namespaceObject.isURL)(plainText.trim())) {
  41062. mode = 'BLOCKS';
  41063. }
  41064. const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
  41065. HTML: html,
  41066. plainText,
  41067. mode,
  41068. tagName,
  41069. preserveWhiteSpace
  41070. });
  41071. if (typeof content === 'string') {
  41072. let valueToInsert = (0,external_wp_richText_namespaceObject.create)({
  41073. html: content
  41074. }); // If the content should be multiline, we should process text
  41075. // separated by a line break as separate lines.
  41076. valueToInsert = adjustLines(valueToInsert, !!multilineTag);
  41077. addActiveFormats(valueToInsert, value.activeFormats);
  41078. onChange((0,external_wp_richText_namespaceObject.insert)(value, valueToInsert));
  41079. } else if (content.length > 0) {
  41080. if (onReplace && (0,external_wp_richText_namespaceObject.isEmpty)(value)) {
  41081. onReplace(content, content.length - 1, -1);
  41082. } else {
  41083. splitValue({
  41084. value,
  41085. pastedBlocks: content,
  41086. onReplace,
  41087. onSplit,
  41088. onSplitMiddle,
  41089. multilineTag
  41090. });
  41091. }
  41092. }
  41093. }
  41094. element.addEventListener('paste', _onPaste);
  41095. return () => {
  41096. element.removeEventListener('paste', _onPaste);
  41097. };
  41098. }, []);
  41099. }
  41100. /**
  41101. * Normalizes a given string of HTML to remove the Windows-specific "Fragment"
  41102. * comments and any preceeding and trailing content.
  41103. *
  41104. * @param {string} html the html to be normalized
  41105. * @return {string} the normalized html
  41106. */
  41107. function removeWindowsFragments(html) {
  41108. const startStr = '<!--StartFragment-->';
  41109. const startIdx = html.indexOf(startStr);
  41110. if (startIdx > -1) {
  41111. html = html.substring(startIdx + startStr.length);
  41112. } else {
  41113. // No point looking for EndFragment
  41114. return html;
  41115. }
  41116. const endStr = '<!--EndFragment-->';
  41117. const endIdx = html.indexOf(endStr);
  41118. if (endIdx > -1) {
  41119. html = html.substring(0, endIdx);
  41120. }
  41121. return html;
  41122. }
  41123. /**
  41124. * Removes the charset meta tag inserted by Chromium.
  41125. * See:
  41126. * - https://github.com/WordPress/gutenberg/issues/33585
  41127. * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4
  41128. *
  41129. * @param {string} html the html to be stripped of the meta tag.
  41130. * @return {string} the cleaned html
  41131. */
  41132. function removeCharsetMetaTag(html) {
  41133. const metaTag = `<meta charset='utf-8'>`;
  41134. if (html.startsWith(metaTag)) {
  41135. return html.slice(metaTag.length);
  41136. }
  41137. return html;
  41138. }
  41139. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-before-input-rules.js
  41140. /**
  41141. * WordPress dependencies
  41142. */
  41143. /**
  41144. * Internal dependencies
  41145. */
  41146. /**
  41147. * When typing over a selection, the selection will we wrapped by a matching
  41148. * character pair. The second character is optional, it defaults to the first
  41149. * character.
  41150. *
  41151. * @type {string[]} Array of character pairs.
  41152. */
  41153. const wrapSelectionSettings = ['`', '"', "'", '“”', '‘’'];
  41154. function useBeforeInputRules(props) {
  41155. const {
  41156. __unstableMarkLastChangeAsPersistent,
  41157. __unstableMarkAutomaticChange
  41158. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  41159. const propsRef = (0,external_wp_element_namespaceObject.useRef)(props);
  41160. propsRef.current = props;
  41161. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  41162. function onInput(event) {
  41163. const {
  41164. inputType,
  41165. data
  41166. } = event;
  41167. const {
  41168. value,
  41169. onChange
  41170. } = propsRef.current; // Only run the rules when inserting text.
  41171. if (inputType !== 'insertText') {
  41172. return;
  41173. }
  41174. if ((0,external_wp_richText_namespaceObject.isCollapsed)(value)) {
  41175. return;
  41176. }
  41177. const pair = (0,external_wp_hooks_namespaceObject.applyFilters)('blockEditor.wrapSelectionSettings', wrapSelectionSettings).find(_ref => {
  41178. let [startChar, endChar] = _ref;
  41179. return startChar === data || endChar === data;
  41180. });
  41181. if (!pair) {
  41182. return;
  41183. }
  41184. const [startChar, endChar = startChar] = pair;
  41185. const start = value.start;
  41186. const end = value.end + startChar.length;
  41187. let newValue = (0,external_wp_richText_namespaceObject.insert)(value, startChar, start, start);
  41188. newValue = (0,external_wp_richText_namespaceObject.insert)(newValue, endChar, end, end);
  41189. __unstableMarkLastChangeAsPersistent();
  41190. onChange(newValue);
  41191. __unstableMarkAutomaticChange();
  41192. const init = {};
  41193. for (const key in event) {
  41194. init[key] = event[key];
  41195. }
  41196. init.data = endChar;
  41197. const {
  41198. ownerDocument
  41199. } = element;
  41200. const {
  41201. defaultView
  41202. } = ownerDocument;
  41203. const newEvent = new defaultView.InputEvent('input', init); // Dispatch an input event with the new data. This will trigger the
  41204. // input rules.
  41205. event.target.dispatchEvent(newEvent);
  41206. event.preventDefault();
  41207. }
  41208. element.addEventListener('beforeinput', onInput);
  41209. return () => {
  41210. element.removeEventListener('beforeinput', onInput);
  41211. };
  41212. }, []);
  41213. }
  41214. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/prevent-event-discovery.js
  41215. /**
  41216. * WordPress dependencies
  41217. */
  41218. function preventEventDiscovery(value) {
  41219. const searchText = 'tales of gutenberg';
  41220. const addText = ' 🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️';
  41221. const {
  41222. start,
  41223. text
  41224. } = value;
  41225. if (start < searchText.length) {
  41226. return value;
  41227. }
  41228. const charactersBefore = text.slice(start - searchText.length, start);
  41229. if (charactersBefore.toLowerCase() !== searchText) {
  41230. return value;
  41231. }
  41232. return (0,external_wp_richText_namespaceObject.insert)(value, addText);
  41233. }
  41234. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-input-rules.js
  41235. /**
  41236. * WordPress dependencies
  41237. */
  41238. /**
  41239. * Internal dependencies
  41240. */
  41241. function findSelection(blocks) {
  41242. let i = blocks.length;
  41243. while (i--) {
  41244. const attributeKey = retrieveSelectedAttribute(blocks[i].attributes);
  41245. if (attributeKey) {
  41246. blocks[i].attributes[attributeKey] = blocks[i].attributes[attributeKey].replace(START_OF_SELECTED_AREA, '');
  41247. return blocks[i].clientId;
  41248. }
  41249. const nestedSelection = findSelection(blocks[i].innerBlocks);
  41250. if (nestedSelection) {
  41251. return nestedSelection;
  41252. }
  41253. }
  41254. }
  41255. function useInputRules(props) {
  41256. const {
  41257. __unstableMarkLastChangeAsPersistent,
  41258. __unstableMarkAutomaticChange
  41259. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  41260. const propsRef = (0,external_wp_element_namespaceObject.useRef)(props);
  41261. propsRef.current = props;
  41262. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  41263. function inputRule() {
  41264. const {
  41265. value,
  41266. onReplace,
  41267. selectionChange
  41268. } = propsRef.current;
  41269. if (!onReplace) {
  41270. return;
  41271. }
  41272. const {
  41273. start,
  41274. text
  41275. } = value;
  41276. const characterBefore = text.slice(start - 1, start); // The character right before the caret must be a plain space.
  41277. if (characterBefore !== ' ') {
  41278. return;
  41279. }
  41280. const trimmedTextBefore = text.slice(0, start).trim();
  41281. const prefixTransforms = (0,external_wp_blocks_namespaceObject.getBlockTransforms)('from').filter(_ref => {
  41282. let {
  41283. type
  41284. } = _ref;
  41285. return type === 'prefix';
  41286. });
  41287. const transformation = (0,external_wp_blocks_namespaceObject.findTransform)(prefixTransforms, _ref2 => {
  41288. let {
  41289. prefix
  41290. } = _ref2;
  41291. return trimmedTextBefore === prefix;
  41292. });
  41293. if (!transformation) {
  41294. return;
  41295. }
  41296. const content = (0,external_wp_richText_namespaceObject.toHTMLString)({
  41297. value: (0,external_wp_richText_namespaceObject.insert)(value, START_OF_SELECTED_AREA, 0, start)
  41298. });
  41299. const block = transformation.transform(content);
  41300. selectionChange(findSelection([block]));
  41301. onReplace([block]);
  41302. __unstableMarkAutomaticChange();
  41303. }
  41304. function onInput(event) {
  41305. const {
  41306. inputType,
  41307. type
  41308. } = event;
  41309. const {
  41310. value,
  41311. onChange,
  41312. __unstableAllowPrefixTransformations,
  41313. formatTypes
  41314. } = propsRef.current; // Only run input rules when inserting text.
  41315. if (inputType !== 'insertText' && type !== 'compositionend') {
  41316. return;
  41317. }
  41318. if (__unstableAllowPrefixTransformations && inputRule) {
  41319. inputRule();
  41320. }
  41321. const transformed = formatTypes.reduce((accumlator, _ref3) => {
  41322. let {
  41323. __unstableInputRule
  41324. } = _ref3;
  41325. if (__unstableInputRule) {
  41326. accumlator = __unstableInputRule(accumlator);
  41327. }
  41328. return accumlator;
  41329. }, preventEventDiscovery(value));
  41330. if (transformed !== value) {
  41331. __unstableMarkLastChangeAsPersistent();
  41332. onChange({ ...transformed,
  41333. activeFormats: value.activeFormats
  41334. });
  41335. __unstableMarkAutomaticChange();
  41336. }
  41337. }
  41338. element.addEventListener('input', onInput);
  41339. element.addEventListener('compositionend', onInput);
  41340. return () => {
  41341. element.removeEventListener('input', onInput);
  41342. element.removeEventListener('compositionend', onInput);
  41343. };
  41344. }, []);
  41345. }
  41346. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-enter.js
  41347. /**
  41348. * WordPress dependencies
  41349. */
  41350. /**
  41351. * Internal dependencies
  41352. */
  41353. function useEnter(props) {
  41354. const {
  41355. __unstableMarkAutomaticChange
  41356. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  41357. const propsRef = (0,external_wp_element_namespaceObject.useRef)(props);
  41358. propsRef.current = props;
  41359. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  41360. function onKeyDown(event) {
  41361. if (event.defaultPrevented) {
  41362. return;
  41363. }
  41364. const {
  41365. removeEditorOnlyFormats,
  41366. value,
  41367. onReplace,
  41368. onSplit,
  41369. onSplitMiddle,
  41370. multilineTag,
  41371. onChange,
  41372. disableLineBreaks,
  41373. onSplitAtEnd
  41374. } = propsRef.current;
  41375. if (event.keyCode !== external_wp_keycodes_namespaceObject.ENTER) {
  41376. return;
  41377. }
  41378. event.preventDefault();
  41379. const _value = { ...value
  41380. };
  41381. _value.formats = removeEditorOnlyFormats(value);
  41382. const canSplit = onReplace && onSplit;
  41383. if (onReplace) {
  41384. const transforms = (0,external_wp_blocks_namespaceObject.getBlockTransforms)('from').filter(_ref => {
  41385. let {
  41386. type
  41387. } = _ref;
  41388. return type === 'enter';
  41389. });
  41390. const transformation = (0,external_wp_blocks_namespaceObject.findTransform)(transforms, item => {
  41391. return item.regExp.test(_value.text);
  41392. });
  41393. if (transformation) {
  41394. onReplace([transformation.transform({
  41395. content: _value.text
  41396. })]);
  41397. __unstableMarkAutomaticChange();
  41398. }
  41399. }
  41400. if (multilineTag) {
  41401. if (event.shiftKey) {
  41402. if (!disableLineBreaks) {
  41403. onChange((0,external_wp_richText_namespaceObject.insert)(_value, '\n'));
  41404. }
  41405. } else if (canSplit && (0,external_wp_richText_namespaceObject.__unstableIsEmptyLine)(_value)) {
  41406. splitValue({
  41407. value: _value,
  41408. onReplace,
  41409. onSplit,
  41410. onSplitMiddle,
  41411. multilineTag
  41412. });
  41413. } else {
  41414. onChange((0,external_wp_richText_namespaceObject.__unstableInsertLineSeparator)(_value));
  41415. }
  41416. } else {
  41417. const {
  41418. text,
  41419. start,
  41420. end
  41421. } = _value;
  41422. const canSplitAtEnd = onSplitAtEnd && start === end && end === text.length;
  41423. if (event.shiftKey || !canSplit && !canSplitAtEnd) {
  41424. if (!disableLineBreaks) {
  41425. onChange((0,external_wp_richText_namespaceObject.insert)(_value, '\n'));
  41426. }
  41427. } else if (!canSplit && canSplitAtEnd) {
  41428. onSplitAtEnd();
  41429. } else if (canSplit) {
  41430. splitValue({
  41431. value: _value,
  41432. onReplace,
  41433. onSplit,
  41434. onSplitMiddle,
  41435. multilineTag
  41436. });
  41437. }
  41438. }
  41439. }
  41440. element.addEventListener('keydown', onKeyDown);
  41441. return () => {
  41442. element.removeEventListener('keydown', onKeyDown);
  41443. };
  41444. }, []);
  41445. }
  41446. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-format-types.js
  41447. /**
  41448. * WordPress dependencies
  41449. */
  41450. function formatTypesSelector(select) {
  41451. return select(external_wp_richText_namespaceObject.store).getFormatTypes();
  41452. }
  41453. /**
  41454. * Set of all interactive content tags.
  41455. *
  41456. * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content
  41457. */
  41458. const interactiveContentTags = new Set(['a', 'audio', 'button', 'details', 'embed', 'iframe', 'input', 'label', 'select', 'textarea', 'video']);
  41459. function prefixSelectKeys(selected, prefix) {
  41460. if (typeof selected !== 'object') return {
  41461. [prefix]: selected
  41462. };
  41463. return Object.fromEntries(Object.entries(selected).map(_ref => {
  41464. let [key, value] = _ref;
  41465. return [`${prefix}.${key}`, value];
  41466. }));
  41467. }
  41468. function getPrefixedSelectKeys(selected, prefix) {
  41469. if (selected[prefix]) return selected[prefix];
  41470. return Object.keys(selected).filter(key => key.startsWith(prefix + '.')).reduce((accumulator, key) => {
  41471. accumulator[key.slice(prefix.length + 1)] = selected[key];
  41472. return accumulator;
  41473. }, {});
  41474. }
  41475. /**
  41476. * This hook provides RichText with the `formatTypes` and its derived props from
  41477. * experimental format type settings.
  41478. *
  41479. * @param {Object} $0 Options
  41480. * @param {string} $0.clientId Block client ID.
  41481. * @param {string} $0.identifier Block attribute.
  41482. * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.
  41483. * @param {Array} $0.allowedFormats Allowed formats
  41484. */
  41485. function useFormatTypes(_ref2) {
  41486. let {
  41487. clientId,
  41488. identifier,
  41489. withoutInteractiveFormatting,
  41490. allowedFormats
  41491. } = _ref2;
  41492. const allFormatTypes = (0,external_wp_data_namespaceObject.useSelect)(formatTypesSelector, []);
  41493. const formatTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
  41494. return allFormatTypes.filter(_ref3 => {
  41495. let {
  41496. name,
  41497. tagName
  41498. } = _ref3;
  41499. if (allowedFormats && !allowedFormats.includes(name)) {
  41500. return false;
  41501. }
  41502. if (withoutInteractiveFormatting && interactiveContentTags.has(tagName)) {
  41503. return false;
  41504. }
  41505. return true;
  41506. });
  41507. }, [allFormatTypes, allowedFormats, interactiveContentTags]);
  41508. const keyedSelected = (0,external_wp_data_namespaceObject.useSelect)(select => formatTypes.reduce((accumulator, type) => {
  41509. if (!type.__experimentalGetPropsForEditableTreePreparation) {
  41510. return accumulator;
  41511. }
  41512. return { ...accumulator,
  41513. ...prefixSelectKeys(type.__experimentalGetPropsForEditableTreePreparation(select, {
  41514. richTextIdentifier: identifier,
  41515. blockClientId: clientId
  41516. }), type.name)
  41517. };
  41518. }, {}), [formatTypes, clientId, identifier]);
  41519. const dispatch = (0,external_wp_data_namespaceObject.useDispatch)();
  41520. const prepareHandlers = [];
  41521. const valueHandlers = [];
  41522. const changeHandlers = [];
  41523. const dependencies = [];
  41524. for (const key in keyedSelected) {
  41525. dependencies.push(keyedSelected[key]);
  41526. }
  41527. formatTypes.forEach(type => {
  41528. if (type.__experimentalCreatePrepareEditableTree) {
  41529. const handler = type.__experimentalCreatePrepareEditableTree(getPrefixedSelectKeys(keyedSelected, type.name), {
  41530. richTextIdentifier: identifier,
  41531. blockClientId: clientId
  41532. });
  41533. if (type.__experimentalCreateOnChangeEditableValue) {
  41534. valueHandlers.push(handler);
  41535. } else {
  41536. prepareHandlers.push(handler);
  41537. }
  41538. }
  41539. if (type.__experimentalCreateOnChangeEditableValue) {
  41540. let dispatchers = {};
  41541. if (type.__experimentalGetPropsForEditableTreeChangeHandler) {
  41542. dispatchers = type.__experimentalGetPropsForEditableTreeChangeHandler(dispatch, {
  41543. richTextIdentifier: identifier,
  41544. blockClientId: clientId
  41545. });
  41546. }
  41547. const selected = getPrefixedSelectKeys(keyedSelected, type.name);
  41548. changeHandlers.push(type.__experimentalCreateOnChangeEditableValue({ ...(typeof selected === 'object' ? selected : {}),
  41549. ...dispatchers
  41550. }, {
  41551. richTextIdentifier: identifier,
  41552. blockClientId: clientId
  41553. }));
  41554. }
  41555. });
  41556. return {
  41557. formatTypes,
  41558. prepareHandlers,
  41559. valueHandlers,
  41560. changeHandlers,
  41561. dependencies
  41562. };
  41563. }
  41564. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-remove-browser-shortcuts.js
  41565. /**
  41566. * WordPress dependencies
  41567. */
  41568. /**
  41569. * Hook to prevent default behaviors for key combinations otherwise handled
  41570. * internally by RichText.
  41571. *
  41572. * @return {import('react').RefObject} The component to be rendered.
  41573. */
  41574. function useRemoveBrowserShortcuts() {
  41575. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  41576. function onKeydown(event) {
  41577. if (external_wp_keycodes_namespaceObject.isKeyboardEvent.primary(event, 'z') || external_wp_keycodes_namespaceObject.isKeyboardEvent.primary(event, 'y') || external_wp_keycodes_namespaceObject.isKeyboardEvent.primaryShift(event, 'z')) {
  41578. event.preventDefault();
  41579. }
  41580. }
  41581. node.addEventListener('keydown', onKeydown);
  41582. return () => {
  41583. node.addEventListener('keydown', onKeydown);
  41584. };
  41585. }, []);
  41586. }
  41587. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-shortcuts.js
  41588. /**
  41589. * WordPress dependencies
  41590. */
  41591. function useShortcuts(keyboardShortcuts) {
  41592. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  41593. function onKeyDown(event) {
  41594. for (const keyboardShortcut of keyboardShortcuts.current) {
  41595. keyboardShortcut(event);
  41596. }
  41597. }
  41598. element.addEventListener('keydown', onKeyDown);
  41599. return () => {
  41600. element.removeEventListener('keydown', onKeyDown);
  41601. };
  41602. }, []);
  41603. }
  41604. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-input-events.js
  41605. /**
  41606. * WordPress dependencies
  41607. */
  41608. function useInputEvents(inputEvents) {
  41609. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  41610. function onInput(event) {
  41611. for (const keyboardShortcut of inputEvents.current) {
  41612. keyboardShortcut(event);
  41613. }
  41614. }
  41615. element.addEventListener('input', onInput);
  41616. return () => {
  41617. element.removeEventListener('input', onInput);
  41618. };
  41619. }, []);
  41620. }
  41621. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-firefox-compat.js
  41622. /**
  41623. * WordPress dependencies
  41624. */
  41625. /**
  41626. * Internal dependencies
  41627. */
  41628. function useFirefoxCompat() {
  41629. const {
  41630. isMultiSelecting
  41631. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  41632. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  41633. function onFocus() {
  41634. if (!isMultiSelecting()) {
  41635. return;
  41636. } // This is a little hack to work around focus issues with nested
  41637. // editable elements in Firefox. For some reason the editable child
  41638. // element sometimes regains focus, while it should not be focusable
  41639. // and focus should remain on the editable parent element.
  41640. // To do: try to find the cause of the shifting focus.
  41641. const parentEditable = element.parentElement.closest('[contenteditable="true"]');
  41642. if (parentEditable) {
  41643. parentEditable.focus();
  41644. }
  41645. }
  41646. element.addEventListener('focus', onFocus);
  41647. return () => {
  41648. element.removeEventListener('focus', onFocus);
  41649. };
  41650. }, []);
  41651. }
  41652. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-edit.js
  41653. /**
  41654. * WordPress dependencies
  41655. */
  41656. /**
  41657. * External dependencies
  41658. */
  41659. function FormatEdit(_ref) {
  41660. let {
  41661. formatTypes,
  41662. onChange,
  41663. onFocus,
  41664. value,
  41665. forwardedRef
  41666. } = _ref;
  41667. return formatTypes.map(settings => {
  41668. const {
  41669. name,
  41670. edit: Edit
  41671. } = settings;
  41672. if (!Edit) {
  41673. return null;
  41674. }
  41675. const activeFormat = (0,external_wp_richText_namespaceObject.getActiveFormat)(value, name);
  41676. let isActive = activeFormat !== undefined;
  41677. const activeObject = (0,external_wp_richText_namespaceObject.getActiveObject)(value);
  41678. const isObjectActive = activeObject !== undefined && activeObject.type === name; // Edge case: un-collapsed link formats.
  41679. // If there is a missing link format at either end of the selection
  41680. // then we shouldn't show the Edit UI because the selection has exceeded
  41681. // the bounds of the link format.
  41682. // Also if the format objects don't match then we're dealing with two separate
  41683. // links so we should not allow the link to be modified over the top.
  41684. if (name === 'core/link' && !(0,external_wp_richText_namespaceObject.isCollapsed)(value)) {
  41685. const formats = value.formats;
  41686. const linkFormatAtStart = (0,external_lodash_namespaceObject.find)(formats[value.start], {
  41687. type: 'core/link'
  41688. });
  41689. const linkFormatAtEnd = (0,external_lodash_namespaceObject.find)(formats[value.end - 1], {
  41690. type: 'core/link'
  41691. });
  41692. if (!linkFormatAtStart || !linkFormatAtEnd || linkFormatAtStart !== linkFormatAtEnd) {
  41693. isActive = false;
  41694. }
  41695. }
  41696. return (0,external_wp_element_namespaceObject.createElement)(Edit, {
  41697. key: name,
  41698. isActive: isActive,
  41699. activeAttributes: isActive ? activeFormat.attributes || {} : {},
  41700. isObjectActive: isObjectActive,
  41701. activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
  41702. value: value,
  41703. onChange: onChange,
  41704. onFocus: onFocus,
  41705. contentRef: forwardedRef
  41706. });
  41707. });
  41708. }
  41709. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/index.js
  41710. /**
  41711. * External dependencies
  41712. */
  41713. /**
  41714. * WordPress dependencies
  41715. */
  41716. /**
  41717. * Internal dependencies
  41718. */
  41719. const keyboardShortcutContext = (0,external_wp_element_namespaceObject.createContext)();
  41720. const inputEventContext = (0,external_wp_element_namespaceObject.createContext)();
  41721. /**
  41722. * Removes props used for the native version of RichText so that they are not
  41723. * passed to the DOM element and log warnings.
  41724. *
  41725. * @param {Object} props Props to filter.
  41726. *
  41727. * @return {Object} Filtered props.
  41728. */
  41729. function removeNativeProps(props) {
  41730. const {
  41731. __unstableMobileNoFocusOnMount,
  41732. deleteEnter,
  41733. placeholderTextColor,
  41734. textAlign,
  41735. selectionColor,
  41736. tagsToEliminate,
  41737. rootTagsToEliminate,
  41738. disableEditingMenu,
  41739. fontSize,
  41740. fontFamily,
  41741. fontWeight,
  41742. fontStyle,
  41743. minWidth,
  41744. maxWidth,
  41745. setRef,
  41746. disableSuggestions,
  41747. disableAutocorrection,
  41748. ...restProps
  41749. } = props;
  41750. return restProps;
  41751. }
  41752. function RichTextWrapper(_ref, forwardedRef) {
  41753. let {
  41754. children,
  41755. tagName = 'div',
  41756. value: originalValue = '',
  41757. onChange: originalOnChange,
  41758. isSelected: originalIsSelected,
  41759. multiline,
  41760. inlineToolbar,
  41761. wrapperClassName,
  41762. autocompleters,
  41763. onReplace,
  41764. placeholder,
  41765. allowedFormats,
  41766. formattingControls,
  41767. withoutInteractiveFormatting,
  41768. onRemove,
  41769. onMerge,
  41770. onSplit,
  41771. __unstableOnSplitAtEnd: onSplitAtEnd,
  41772. __unstableOnSplitMiddle: onSplitMiddle,
  41773. identifier,
  41774. preserveWhiteSpace,
  41775. __unstablePastePlainText: pastePlainText,
  41776. __unstableEmbedURLOnPaste,
  41777. __unstableDisableFormats: disableFormats,
  41778. disableLineBreaks,
  41779. unstableOnFocus,
  41780. __unstableAllowPrefixTransformations,
  41781. ...props
  41782. } = _ref;
  41783. if (multiline) {
  41784. external_wp_deprecated_default()('wp.blockEditor.RichText multiline prop', {
  41785. since: '6.1',
  41786. version: '6.3',
  41787. alternative: 'nested blocks (InnerBlocks)',
  41788. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/'
  41789. });
  41790. }
  41791. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(RichTextWrapper);
  41792. identifier = identifier || instanceId;
  41793. props = removeNativeProps(props);
  41794. const anchorRef = (0,external_wp_element_namespaceObject.useRef)();
  41795. const {
  41796. clientId
  41797. } = useBlockEditContext();
  41798. const selector = select => {
  41799. const {
  41800. getSelectionStart,
  41801. getSelectionEnd
  41802. } = select(store);
  41803. const selectionStart = getSelectionStart();
  41804. const selectionEnd = getSelectionEnd();
  41805. let isSelected;
  41806. if (originalIsSelected === undefined) {
  41807. isSelected = selectionStart.clientId === clientId && selectionEnd.clientId === clientId && selectionStart.attributeKey === identifier;
  41808. } else if (originalIsSelected) {
  41809. isSelected = selectionStart.clientId === clientId;
  41810. }
  41811. return {
  41812. selectionStart: isSelected ? selectionStart.offset : undefined,
  41813. selectionEnd: isSelected ? selectionEnd.offset : undefined,
  41814. isSelected
  41815. };
  41816. }; // This selector must run on every render so the right selection state is
  41817. // retreived from the store on merge.
  41818. // To do: fix this somehow.
  41819. const {
  41820. selectionStart,
  41821. selectionEnd,
  41822. isSelected
  41823. } = (0,external_wp_data_namespaceObject.useSelect)(selector);
  41824. const {
  41825. selectionChange
  41826. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  41827. const multilineTag = getMultilineTag(multiline);
  41828. const adjustedAllowedFormats = getAllowedFormats({
  41829. allowedFormats,
  41830. formattingControls,
  41831. disableFormats
  41832. });
  41833. const hasFormats = !adjustedAllowedFormats || adjustedAllowedFormats.length > 0;
  41834. let adjustedValue = originalValue;
  41835. let adjustedOnChange = originalOnChange; // Handle deprecated format.
  41836. if (Array.isArray(originalValue)) {
  41837. external_wp_deprecated_default()('wp.blockEditor.RichText value prop as children type', {
  41838. since: '6.1',
  41839. version: '6.3',
  41840. alternative: 'value prop as string',
  41841. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  41842. });
  41843. adjustedValue = external_wp_blocks_namespaceObject.children.toHTML(originalValue);
  41844. adjustedOnChange = newValue => originalOnChange(external_wp_blocks_namespaceObject.children.fromDOM((0,external_wp_richText_namespaceObject.__unstableCreateElement)(document, newValue).childNodes));
  41845. }
  41846. const onSelectionChange = (0,external_wp_element_namespaceObject.useCallback)((start, end) => {
  41847. const selection = {};
  41848. const unset = start === undefined && end === undefined;
  41849. if (typeof start === 'number' || unset) {
  41850. selection.start = {
  41851. clientId,
  41852. attributeKey: identifier,
  41853. offset: start
  41854. };
  41855. }
  41856. if (typeof end === 'number' || unset) {
  41857. selection.end = {
  41858. clientId,
  41859. attributeKey: identifier,
  41860. offset: end
  41861. };
  41862. }
  41863. selectionChange(selection);
  41864. }, [clientId, identifier]);
  41865. const {
  41866. formatTypes,
  41867. prepareHandlers,
  41868. valueHandlers,
  41869. changeHandlers,
  41870. dependencies
  41871. } = useFormatTypes({
  41872. clientId,
  41873. identifier,
  41874. withoutInteractiveFormatting,
  41875. allowedFormats: adjustedAllowedFormats
  41876. });
  41877. function addEditorOnlyFormats(value) {
  41878. return valueHandlers.reduce((accumulator, fn) => fn(accumulator, value.text), value.formats);
  41879. }
  41880. function removeEditorOnlyFormats(value) {
  41881. formatTypes.forEach(formatType => {
  41882. // Remove formats created by prepareEditableTree, because they are editor only.
  41883. if (formatType.__experimentalCreatePrepareEditableTree) {
  41884. value = (0,external_wp_richText_namespaceObject.removeFormat)(value, formatType.name, 0, value.text.length);
  41885. }
  41886. });
  41887. return value.formats;
  41888. }
  41889. function addInvisibleFormats(value) {
  41890. return prepareHandlers.reduce((accumulator, fn) => fn(accumulator, value.text), value.formats);
  41891. }
  41892. const {
  41893. value,
  41894. onChange,
  41895. ref: richTextRef
  41896. } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({
  41897. value: adjustedValue,
  41898. onChange(html, _ref2) {
  41899. let {
  41900. __unstableFormats,
  41901. __unstableText
  41902. } = _ref2;
  41903. adjustedOnChange(html);
  41904. Object.values(changeHandlers).forEach(changeHandler => {
  41905. changeHandler(__unstableFormats, __unstableText);
  41906. });
  41907. },
  41908. selectionStart,
  41909. selectionEnd,
  41910. onSelectionChange,
  41911. placeholder,
  41912. __unstableIsSelected: isSelected,
  41913. __unstableMultilineTag: multilineTag,
  41914. __unstableDisableFormats: disableFormats,
  41915. preserveWhiteSpace,
  41916. __unstableDependencies: [...dependencies, tagName],
  41917. __unstableAfterParse: addEditorOnlyFormats,
  41918. __unstableBeforeSerialize: removeEditorOnlyFormats,
  41919. __unstableAddInvisibleFormats: addInvisibleFormats
  41920. });
  41921. const autocompleteProps = useBlockEditorAutocompleteProps({
  41922. onReplace,
  41923. completers: autocompleters,
  41924. record: value,
  41925. onChange
  41926. });
  41927. useMarkPersistent({
  41928. html: adjustedValue,
  41929. value
  41930. });
  41931. const keyboardShortcuts = (0,external_wp_element_namespaceObject.useRef)(new Set());
  41932. const inputEvents = (0,external_wp_element_namespaceObject.useRef)(new Set());
  41933. function onKeyDown(event) {
  41934. const {
  41935. keyCode
  41936. } = event;
  41937. if (event.defaultPrevented) {
  41938. return;
  41939. }
  41940. if (keyCode === external_wp_keycodes_namespaceObject.DELETE || keyCode === external_wp_keycodes_namespaceObject.BACKSPACE) {
  41941. const {
  41942. start,
  41943. end,
  41944. text
  41945. } = value;
  41946. const isReverse = keyCode === external_wp_keycodes_namespaceObject.BACKSPACE;
  41947. const hasActiveFormats = value.activeFormats && !!value.activeFormats.length; // Only process delete if the key press occurs at an uncollapsed edge.
  41948. if (!(0,external_wp_richText_namespaceObject.isCollapsed)(value) || hasActiveFormats || isReverse && start !== 0 || !isReverse && end !== text.length) {
  41949. return;
  41950. }
  41951. if (onMerge) {
  41952. onMerge(!isReverse);
  41953. } // Only handle remove on Backspace. This serves dual-purpose of being
  41954. // an intentional user interaction distinguishing between Backspace and
  41955. // Delete to remove the empty field, but also to avoid merge & remove
  41956. // causing destruction of two fields (merge, then removed merged).
  41957. if (onRemove && (0,external_wp_richText_namespaceObject.isEmpty)(value) && isReverse) {
  41958. onRemove(!isReverse);
  41959. }
  41960. event.preventDefault();
  41961. }
  41962. }
  41963. function onFocus() {
  41964. var _anchorRef$current;
  41965. (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.focus();
  41966. }
  41967. const TagName = tagName;
  41968. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isSelected && (0,external_wp_element_namespaceObject.createElement)(keyboardShortcutContext.Provider, {
  41969. value: keyboardShortcuts
  41970. }, (0,external_wp_element_namespaceObject.createElement)(inputEventContext.Provider, {
  41971. value: inputEvents
  41972. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.__unstableSlotNameProvider, {
  41973. value: "__unstable-block-tools-after"
  41974. }, children && children({
  41975. value,
  41976. onChange,
  41977. onFocus
  41978. }), (0,external_wp_element_namespaceObject.createElement)(FormatEdit, {
  41979. value: value,
  41980. onChange: onChange,
  41981. onFocus: onFocus,
  41982. formatTypes: formatTypes,
  41983. forwardedRef: anchorRef
  41984. })))), isSelected && hasFormats && (0,external_wp_element_namespaceObject.createElement)(format_toolbar_container, {
  41985. inline: inlineToolbar,
  41986. editableContentElement: anchorRef.current,
  41987. value: value
  41988. }), (0,external_wp_element_namespaceObject.createElement)(TagName // Overridable props.
  41989. , _extends({
  41990. role: "textbox",
  41991. "aria-multiline": !disableLineBreaks,
  41992. "aria-label": placeholder
  41993. }, props, autocompleteProps, {
  41994. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([forwardedRef, autocompleteProps.ref, props.ref, richTextRef, useBeforeInputRules({
  41995. value,
  41996. onChange
  41997. }), useInputRules({
  41998. value,
  41999. onChange,
  42000. __unstableAllowPrefixTransformations,
  42001. formatTypes,
  42002. onReplace,
  42003. selectionChange
  42004. }), useRemoveBrowserShortcuts(), useShortcuts(keyboardShortcuts), useInputEvents(inputEvents), useUndoAutomaticChange(), usePasteHandler({
  42005. isSelected,
  42006. disableFormats,
  42007. onChange,
  42008. value,
  42009. formatTypes,
  42010. tagName,
  42011. onReplace,
  42012. onSplit,
  42013. onSplitMiddle,
  42014. __unstableEmbedURLOnPaste,
  42015. multilineTag,
  42016. preserveWhiteSpace,
  42017. pastePlainText
  42018. }), useEnter({
  42019. removeEditorOnlyFormats,
  42020. value,
  42021. onReplace,
  42022. onSplit,
  42023. onSplitMiddle,
  42024. multilineTag,
  42025. onChange,
  42026. disableLineBreaks,
  42027. onSplitAtEnd
  42028. }), useFirefoxCompat(), anchorRef]),
  42029. contentEditable: true,
  42030. suppressContentEditableWarning: true,
  42031. className: classnames_default()('block-editor-rich-text__editable', props.className, 'rich-text'),
  42032. onFocus: unstableOnFocus,
  42033. onKeyDown: onKeyDown
  42034. })));
  42035. }
  42036. const ForwardedRichTextContainer = (0,external_wp_element_namespaceObject.forwardRef)(RichTextWrapper);
  42037. ForwardedRichTextContainer.Content = _ref3 => {
  42038. let {
  42039. value,
  42040. tagName: Tag,
  42041. multiline,
  42042. ...props
  42043. } = _ref3;
  42044. // Handle deprecated `children` and `node` sources.
  42045. if (Array.isArray(value)) {
  42046. external_wp_deprecated_default()('wp.blockEditor.RichText value prop as children type', {
  42047. since: '6.1',
  42048. version: '6.3',
  42049. alternative: 'value prop as string',
  42050. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  42051. });
  42052. value = external_wp_blocks_namespaceObject.children.toHTML(value);
  42053. }
  42054. const MultilineTag = getMultilineTag(multiline);
  42055. if (!value && MultilineTag) {
  42056. value = `<${MultilineTag}></${MultilineTag}>`;
  42057. }
  42058. const content = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, value);
  42059. if (Tag) {
  42060. const {
  42061. format,
  42062. ...restProps
  42063. } = props;
  42064. return (0,external_wp_element_namespaceObject.createElement)(Tag, restProps, content);
  42065. }
  42066. return content;
  42067. };
  42068. ForwardedRichTextContainer.isEmpty = value => {
  42069. return !value || value.length === 0;
  42070. };
  42071. /**
  42072. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
  42073. */
  42074. /* harmony default export */ var rich_text = (ForwardedRichTextContainer);
  42075. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/editable-text/index.js
  42076. /**
  42077. * WordPress dependencies
  42078. */
  42079. /**
  42080. * Internal dependencies
  42081. */
  42082. const EditableText = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  42083. return (0,external_wp_element_namespaceObject.createElement)(rich_text, _extends({
  42084. ref: ref
  42085. }, props, {
  42086. __unstableDisableFormats: true,
  42087. preserveWhiteSpace: true
  42088. }));
  42089. });
  42090. EditableText.Content = _ref => {
  42091. let {
  42092. value = '',
  42093. tagName: Tag = 'div',
  42094. ...props
  42095. } = _ref;
  42096. return (0,external_wp_element_namespaceObject.createElement)(Tag, props, value);
  42097. };
  42098. /**
  42099. * Renders an editable text input in which text formatting is not allowed.
  42100. */
  42101. /* harmony default export */ var editable_text = (EditableText);
  42102. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/plain-text/index.js
  42103. /**
  42104. * External dependencies
  42105. */
  42106. /**
  42107. * WordPress dependencies
  42108. */
  42109. /**
  42110. * Internal dependencies
  42111. */
  42112. /**
  42113. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/plain-text/README.md
  42114. */
  42115. const PlainText = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => {
  42116. let {
  42117. __experimentalVersion,
  42118. ...props
  42119. } = _ref;
  42120. if (__experimentalVersion === 2) {
  42121. return (0,external_wp_element_namespaceObject.createElement)(editable_text, _extends({
  42122. ref: ref
  42123. }, props));
  42124. }
  42125. const {
  42126. className,
  42127. onChange,
  42128. ...remainingProps
  42129. } = props;
  42130. return (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, _extends({
  42131. ref: ref,
  42132. className: classnames_default()('block-editor-plain-text', className),
  42133. onChange: event => onChange(event.target.value)
  42134. }, remainingProps));
  42135. });
  42136. /* harmony default export */ var plain_text = (PlainText);
  42137. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/responsive-block-control/label.js
  42138. /**
  42139. * WordPress dependencies
  42140. */
  42141. function ResponsiveBlockControlLabel(_ref) {
  42142. let {
  42143. property,
  42144. viewport,
  42145. desc
  42146. } = _ref;
  42147. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ResponsiveBlockControlLabel);
  42148. const accessibleLabel = desc || (0,external_wp_i18n_namespaceObject.sprintf)(
  42149. /* translators: 1: property name. 2: viewport name. */
  42150. (0,external_wp_i18n_namespaceObject._x)('Controls the %1$s property for %2$s viewports.', 'Text labelling a interface as controlling a given layout property (eg: margin) for a given screen size.'), property, viewport.label);
  42151. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("span", {
  42152. "aria-describedby": `rbc-desc-${instanceId}`
  42153. }, viewport.label), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  42154. as: "span",
  42155. id: `rbc-desc-${instanceId}`
  42156. }, accessibleLabel));
  42157. }
  42158. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/responsive-block-control/index.js
  42159. /**
  42160. * External dependencies
  42161. */
  42162. /**
  42163. * WordPress dependencies
  42164. */
  42165. /**
  42166. * Internal dependencies
  42167. */
  42168. function ResponsiveBlockControl(props) {
  42169. const {
  42170. title,
  42171. property,
  42172. toggleLabel,
  42173. onIsResponsiveChange,
  42174. renderDefaultControl,
  42175. renderResponsiveControls,
  42176. isResponsive = false,
  42177. defaultLabel = {
  42178. id: 'all',
  42179. /* translators: 'Label. Used to signify a layout property (eg: margin, padding) will apply uniformly to all screensizes.' */
  42180. label: (0,external_wp_i18n_namespaceObject.__)('All')
  42181. },
  42182. viewports = [{
  42183. id: 'small',
  42184. label: (0,external_wp_i18n_namespaceObject.__)('Small screens')
  42185. }, {
  42186. id: 'medium',
  42187. label: (0,external_wp_i18n_namespaceObject.__)('Medium screens')
  42188. }, {
  42189. id: 'large',
  42190. label: (0,external_wp_i18n_namespaceObject.__)('Large screens')
  42191. }]
  42192. } = props;
  42193. if (!title || !property || !renderDefaultControl) {
  42194. return null;
  42195. }
  42196. const toggleControlLabel = toggleLabel || (0,external_wp_i18n_namespaceObject.sprintf)(
  42197. /* translators: 'Toggle control label. Should the property be the same across all screen sizes or unique per screen size.'. %s property value for the control (eg: margin, padding...etc) */
  42198. (0,external_wp_i18n_namespaceObject.__)('Use the same %s on all screensizes.'), property);
  42199. /* translators: 'Help text for the responsive mode toggle control.' */
  42200. const toggleHelpText = (0,external_wp_i18n_namespaceObject.__)('Toggle between using the same value for all screen sizes or using a unique value per screen size.');
  42201. const defaultControl = renderDefaultControl((0,external_wp_element_namespaceObject.createElement)(ResponsiveBlockControlLabel, {
  42202. property: property,
  42203. viewport: defaultLabel
  42204. }), defaultLabel);
  42205. const defaultResponsiveControls = () => {
  42206. return viewports.map(viewport => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
  42207. key: viewport.id
  42208. }, renderDefaultControl((0,external_wp_element_namespaceObject.createElement)(ResponsiveBlockControlLabel, {
  42209. property: property,
  42210. viewport: viewport
  42211. }), viewport)));
  42212. };
  42213. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  42214. className: "block-editor-responsive-block-control"
  42215. }, (0,external_wp_element_namespaceObject.createElement)("legend", {
  42216. className: "block-editor-responsive-block-control__title"
  42217. }, title), (0,external_wp_element_namespaceObject.createElement)("div", {
  42218. className: "block-editor-responsive-block-control__inner"
  42219. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  42220. className: "block-editor-responsive-block-control__toggle",
  42221. label: toggleControlLabel,
  42222. checked: !isResponsive,
  42223. onChange: onIsResponsiveChange,
  42224. help: toggleHelpText
  42225. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  42226. className: classnames_default()('block-editor-responsive-block-control__group', {
  42227. 'is-responsive': isResponsive
  42228. })
  42229. }, !isResponsive && defaultControl, isResponsive && (renderResponsiveControls ? renderResponsiveControls(viewports) : defaultResponsiveControls()))));
  42230. }
  42231. /* harmony default export */ var responsive_block_control = (ResponsiveBlockControl);
  42232. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/shortcut.js
  42233. /**
  42234. * WordPress dependencies
  42235. */
  42236. /**
  42237. * Internal dependencies
  42238. */
  42239. function RichTextShortcut(_ref) {
  42240. let {
  42241. character,
  42242. type,
  42243. onUse
  42244. } = _ref;
  42245. const keyboardShortcuts = (0,external_wp_element_namespaceObject.useContext)(keyboardShortcutContext);
  42246. const onUseRef = (0,external_wp_element_namespaceObject.useRef)();
  42247. onUseRef.current = onUse;
  42248. (0,external_wp_element_namespaceObject.useEffect)(() => {
  42249. function callback(event) {
  42250. if (external_wp_keycodes_namespaceObject.isKeyboardEvent[type](event, character)) {
  42251. onUseRef.current();
  42252. event.preventDefault();
  42253. }
  42254. }
  42255. keyboardShortcuts.current.add(callback);
  42256. return () => {
  42257. keyboardShortcuts.current.delete(callback);
  42258. };
  42259. }, [character, type]);
  42260. return null;
  42261. }
  42262. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/toolbar-button.js
  42263. /**
  42264. * WordPress dependencies
  42265. */
  42266. function RichTextToolbarButton(_ref) {
  42267. let {
  42268. name,
  42269. shortcutType,
  42270. shortcutCharacter,
  42271. ...props
  42272. } = _ref;
  42273. let shortcut;
  42274. let fillName = 'RichText.ToolbarControls';
  42275. if (name) {
  42276. fillName += `.${name}`;
  42277. }
  42278. if (shortcutType && shortcutCharacter) {
  42279. shortcut = external_wp_keycodes_namespaceObject.displayShortcut[shortcutType](shortcutCharacter);
  42280. }
  42281. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
  42282. name: fillName
  42283. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, _extends({}, props, {
  42284. shortcut: shortcut
  42285. })));
  42286. }
  42287. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/input-event.js
  42288. /**
  42289. * WordPress dependencies
  42290. */
  42291. /**
  42292. * Internal dependencies
  42293. */
  42294. function __unstableRichTextInputEvent(_ref) {
  42295. let {
  42296. inputType,
  42297. onInput
  42298. } = _ref;
  42299. const callbacks = (0,external_wp_element_namespaceObject.useContext)(inputEventContext);
  42300. const onInputRef = (0,external_wp_element_namespaceObject.useRef)();
  42301. onInputRef.current = onInput;
  42302. (0,external_wp_element_namespaceObject.useEffect)(() => {
  42303. function callback(event) {
  42304. if (event.inputType === inputType) {
  42305. onInputRef.current();
  42306. event.preventDefault();
  42307. }
  42308. }
  42309. callbacks.current.add(callback);
  42310. return () => {
  42311. callbacks.current.delete(callback);
  42312. };
  42313. }, [inputType]);
  42314. return null;
  42315. }
  42316. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/tool-selector/index.js
  42317. /**
  42318. * WordPress dependencies
  42319. */
  42320. /**
  42321. * Internal dependencies
  42322. */
  42323. const selectIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  42324. xmlns: "http://www.w3.org/2000/svg",
  42325. width: "24",
  42326. height: "24",
  42327. viewBox: "0 0 24 24"
  42328. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  42329. d: "M9.4 20.5L5.2 3.8l14.6 9-2 .3c-.2 0-.4.1-.7.1-.9.2-1.6.3-2.2.5-.8.3-1.4.5-1.8.8-.4.3-.8.8-1.3 1.5-.4.5-.8 1.2-1.2 2l-.3.6-.9 1.9zM7.6 7.1l2.4 9.3c.2-.4.5-.8.7-1.1.6-.8 1.1-1.4 1.6-1.8.5-.4 1.3-.8 2.2-1.1l1.2-.3-8.1-5z"
  42330. }));
  42331. function ToolSelector(props, ref) {
  42332. const mode = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).__unstableGetEditorMode(), []);
  42333. const {
  42334. __unstableSetEditorMode
  42335. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  42336. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  42337. renderToggle: _ref => {
  42338. let {
  42339. isOpen,
  42340. onToggle
  42341. } = _ref;
  42342. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
  42343. ref: ref,
  42344. icon: mode === 'navigation' ? selectIcon : library_edit,
  42345. "aria-expanded": isOpen,
  42346. "aria-haspopup": "true",
  42347. onClick: onToggle
  42348. /* translators: button label text should, if possible, be under 16 characters. */
  42349. ,
  42350. label: (0,external_wp_i18n_namespaceObject.__)('Tools')
  42351. }));
  42352. },
  42353. position: "bottom right",
  42354. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, {
  42355. role: "menu",
  42356. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Tools')
  42357. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
  42358. value: mode === 'navigation' ? 'navigation' : 'edit',
  42359. onSelect: __unstableSetEditorMode,
  42360. choices: [{
  42361. value: 'edit',
  42362. label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  42363. icon: library_edit
  42364. }), (0,external_wp_i18n_namespaceObject.__)('Edit'))
  42365. }, {
  42366. value: 'navigation',
  42367. label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, selectIcon, (0,external_wp_i18n_namespaceObject.__)('Select'))
  42368. }]
  42369. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  42370. className: "block-editor-tool-selector__help"
  42371. }, (0,external_wp_i18n_namespaceObject.__)('Tools provide different interactions for selecting, navigating, and editing blocks. Toggle between select and edit by pressing Escape and Enter.')))
  42372. });
  42373. }
  42374. /* harmony default export */ var tool_selector = ((0,external_wp_element_namespaceObject.forwardRef)(ToolSelector));
  42375. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/unit-control/index.js
  42376. /**
  42377. * WordPress dependencies
  42378. */
  42379. /**
  42380. * Internal dependencies
  42381. */
  42382. function UnitControl(_ref) {
  42383. let {
  42384. units: unitsProp,
  42385. ...props
  42386. } = _ref;
  42387. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  42388. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw'],
  42389. units: unitsProp
  42390. });
  42391. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, _extends({
  42392. units: units
  42393. }, props));
  42394. }
  42395. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-left.js
  42396. /**
  42397. * WordPress dependencies
  42398. */
  42399. const arrowLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  42400. xmlns: "http://www.w3.org/2000/svg",
  42401. viewBox: "0 0 24 24"
  42402. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  42403. d: "M20 10.8H6.7l4.1-4.5-1.1-1.1-5.8 6.3 5.8 5.8 1.1-1.1-4-3.9H20z"
  42404. }));
  42405. /* harmony default export */ var arrow_left = (arrowLeft);
  42406. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/button.js
  42407. /**
  42408. * WordPress dependencies
  42409. */
  42410. /**
  42411. * Internal dependencies
  42412. */
  42413. class URLInputButton extends external_wp_element_namespaceObject.Component {
  42414. constructor() {
  42415. super(...arguments);
  42416. this.toggle = this.toggle.bind(this);
  42417. this.submitLink = this.submitLink.bind(this);
  42418. this.state = {
  42419. expanded: false
  42420. };
  42421. }
  42422. toggle() {
  42423. this.setState({
  42424. expanded: !this.state.expanded
  42425. });
  42426. }
  42427. submitLink(event) {
  42428. event.preventDefault();
  42429. this.toggle();
  42430. }
  42431. render() {
  42432. const {
  42433. url,
  42434. onChange
  42435. } = this.props;
  42436. const {
  42437. expanded
  42438. } = this.state;
  42439. const buttonLabel = url ? (0,external_wp_i18n_namespaceObject.__)('Edit link') : (0,external_wp_i18n_namespaceObject.__)('Insert link');
  42440. return (0,external_wp_element_namespaceObject.createElement)("div", {
  42441. className: "block-editor-url-input__button"
  42442. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  42443. icon: library_link,
  42444. label: buttonLabel,
  42445. onClick: this.toggle,
  42446. className: "components-toolbar__control",
  42447. isPressed: !!url
  42448. }), expanded && (0,external_wp_element_namespaceObject.createElement)("form", {
  42449. className: "block-editor-url-input__button-modal",
  42450. onSubmit: this.submitLink
  42451. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  42452. className: "block-editor-url-input__button-modal-line"
  42453. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  42454. className: "block-editor-url-input__back",
  42455. icon: arrow_left,
  42456. label: (0,external_wp_i18n_namespaceObject.__)('Close'),
  42457. onClick: this.toggle
  42458. }), (0,external_wp_element_namespaceObject.createElement)(url_input, {
  42459. value: url || '',
  42460. onChange: onChange
  42461. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  42462. icon: keyboard_return,
  42463. label: (0,external_wp_i18n_namespaceObject.__)('Submit'),
  42464. type: "submit"
  42465. }))));
  42466. }
  42467. }
  42468. /**
  42469. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md
  42470. */
  42471. /* harmony default export */ var url_input_button = (URLInputButton);
  42472. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js
  42473. /**
  42474. * WordPress dependencies
  42475. */
  42476. const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  42477. xmlns: "http://www.w3.org/2000/svg",
  42478. viewBox: "0 0 24 24"
  42479. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  42480. d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"
  42481. }));
  42482. /* harmony default export */ var library_close = (close_close);
  42483. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/image-url-input-ui.js
  42484. /**
  42485. * External dependencies
  42486. */
  42487. /**
  42488. * WordPress dependencies
  42489. */
  42490. /**
  42491. * Internal dependencies
  42492. */
  42493. const LINK_DESTINATION_NONE = 'none';
  42494. const LINK_DESTINATION_CUSTOM = 'custom';
  42495. const LINK_DESTINATION_MEDIA = 'media';
  42496. const LINK_DESTINATION_ATTACHMENT = 'attachment';
  42497. const NEW_TAB_REL = ['noreferrer', 'noopener'];
  42498. const icon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  42499. viewBox: "0 0 24 24",
  42500. xmlns: "http://www.w3.org/2000/svg"
  42501. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  42502. d: "M0,0h24v24H0V0z",
  42503. fill: "none"
  42504. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  42505. d: "m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z"
  42506. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  42507. d: "m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z"
  42508. }));
  42509. const ImageURLInputUI = _ref => {
  42510. let {
  42511. linkDestination,
  42512. onChangeUrl,
  42513. url,
  42514. mediaType = 'image',
  42515. mediaUrl,
  42516. mediaLink,
  42517. linkTarget,
  42518. linkClass,
  42519. rel
  42520. } = _ref;
  42521. const [isOpen, setIsOpen] = (0,external_wp_element_namespaceObject.useState)(false); // Use internal state instead of a ref to make sure that the component
  42522. // re-renders when the popover's anchor updates.
  42523. const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
  42524. const openLinkUI = (0,external_wp_element_namespaceObject.useCallback)(() => {
  42525. setIsOpen(true);
  42526. });
  42527. const [isEditingLink, setIsEditingLink] = (0,external_wp_element_namespaceObject.useState)(false);
  42528. const [urlInput, setUrlInput] = (0,external_wp_element_namespaceObject.useState)(null);
  42529. const autocompleteRef = (0,external_wp_element_namespaceObject.useRef)(null);
  42530. const startEditLink = (0,external_wp_element_namespaceObject.useCallback)(() => {
  42531. if (linkDestination === LINK_DESTINATION_MEDIA || linkDestination === LINK_DESTINATION_ATTACHMENT) {
  42532. setUrlInput('');
  42533. }
  42534. setIsEditingLink(true);
  42535. });
  42536. const stopEditLink = (0,external_wp_element_namespaceObject.useCallback)(() => {
  42537. setIsEditingLink(false);
  42538. });
  42539. const closeLinkUI = (0,external_wp_element_namespaceObject.useCallback)(() => {
  42540. setUrlInput(null);
  42541. stopEditLink();
  42542. setIsOpen(false);
  42543. });
  42544. const getUpdatedLinkTargetSettings = value => {
  42545. const newLinkTarget = value ? '_blank' : undefined;
  42546. let updatedRel;
  42547. if (newLinkTarget) {
  42548. const rels = (rel !== null && rel !== void 0 ? rel : '').split(' ');
  42549. NEW_TAB_REL.forEach(relVal => {
  42550. if (!rels.includes(relVal)) {
  42551. rels.push(relVal);
  42552. }
  42553. });
  42554. updatedRel = rels.join(' ');
  42555. } else {
  42556. const rels = (rel !== null && rel !== void 0 ? rel : '').split(' ').filter(relVal => NEW_TAB_REL.includes(relVal) === false);
  42557. updatedRel = rels.length ? rels.join(' ') : undefined;
  42558. }
  42559. return {
  42560. linkTarget: newLinkTarget,
  42561. rel: updatedRel
  42562. };
  42563. };
  42564. const onFocusOutside = (0,external_wp_element_namespaceObject.useCallback)(() => {
  42565. return event => {
  42566. // The autocomplete suggestions list renders in a separate popover (in a portal),
  42567. // so onFocusOutside fails to detect that a click on a suggestion occurred in the
  42568. // LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and
  42569. // return to avoid the popover being closed.
  42570. const autocompleteElement = autocompleteRef.current;
  42571. if (autocompleteElement && autocompleteElement.contains(event.target)) {
  42572. return;
  42573. }
  42574. setIsOpen(false);
  42575. setUrlInput(null);
  42576. stopEditLink();
  42577. };
  42578. });
  42579. const onSubmitLinkChange = (0,external_wp_element_namespaceObject.useCallback)(() => {
  42580. return event => {
  42581. if (urlInput) {
  42582. var _getLinkDestinations$;
  42583. // It is possible the entered URL actually matches a named link destination.
  42584. // This check will ensure our link destination is correct.
  42585. const selectedDestination = ((_getLinkDestinations$ = getLinkDestinations().find(destination => destination.url === urlInput)) === null || _getLinkDestinations$ === void 0 ? void 0 : _getLinkDestinations$.linkDestination) || LINK_DESTINATION_CUSTOM;
  42586. onChangeUrl({
  42587. href: urlInput,
  42588. linkDestination: selectedDestination
  42589. });
  42590. }
  42591. stopEditLink();
  42592. setUrlInput(null);
  42593. event.preventDefault();
  42594. };
  42595. });
  42596. const onLinkRemove = (0,external_wp_element_namespaceObject.useCallback)(() => {
  42597. onChangeUrl({
  42598. linkDestination: LINK_DESTINATION_NONE,
  42599. href: ''
  42600. });
  42601. });
  42602. const getLinkDestinations = () => {
  42603. const linkDestinations = [{
  42604. linkDestination: LINK_DESTINATION_MEDIA,
  42605. title: (0,external_wp_i18n_namespaceObject.__)('Media File'),
  42606. url: mediaType === 'image' ? mediaUrl : undefined,
  42607. icon
  42608. }];
  42609. if (mediaType === 'image' && mediaLink) {
  42610. linkDestinations.push({
  42611. linkDestination: LINK_DESTINATION_ATTACHMENT,
  42612. title: (0,external_wp_i18n_namespaceObject.__)('Attachment Page'),
  42613. url: mediaType === 'image' ? mediaLink : undefined,
  42614. icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  42615. viewBox: "0 0 24 24",
  42616. xmlns: "http://www.w3.org/2000/svg"
  42617. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  42618. d: "M0 0h24v24H0V0z",
  42619. fill: "none"
  42620. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  42621. d: "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z"
  42622. }))
  42623. });
  42624. }
  42625. return linkDestinations;
  42626. };
  42627. const onSetHref = value => {
  42628. const linkDestinations = getLinkDestinations();
  42629. let linkDestinationInput;
  42630. if (!value) {
  42631. linkDestinationInput = LINK_DESTINATION_NONE;
  42632. } else {
  42633. linkDestinationInput = ((0,external_lodash_namespaceObject.find)(linkDestinations, destination => {
  42634. return destination.url === value;
  42635. }) || {
  42636. linkDestination: LINK_DESTINATION_CUSTOM
  42637. }).linkDestination;
  42638. }
  42639. onChangeUrl({
  42640. linkDestination: linkDestinationInput,
  42641. href: value
  42642. });
  42643. };
  42644. const onSetNewTab = value => {
  42645. const updatedLinkTarget = getUpdatedLinkTargetSettings(value);
  42646. onChangeUrl(updatedLinkTarget);
  42647. };
  42648. const onSetLinkRel = value => {
  42649. onChangeUrl({
  42650. rel: value
  42651. });
  42652. };
  42653. const onSetLinkClass = value => {
  42654. onChangeUrl({
  42655. linkClass: value
  42656. });
  42657. };
  42658. const advancedOptions = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  42659. label: (0,external_wp_i18n_namespaceObject.__)('Open in new tab'),
  42660. onChange: onSetNewTab,
  42661. checked: linkTarget === '_blank'
  42662. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  42663. label: (0,external_wp_i18n_namespaceObject.__)('Link Rel'),
  42664. value: rel !== null && rel !== void 0 ? rel : '',
  42665. onChange: onSetLinkRel
  42666. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  42667. label: (0,external_wp_i18n_namespaceObject.__)('Link CSS Class'),
  42668. value: linkClass || '',
  42669. onChange: onSetLinkClass
  42670. }));
  42671. const linkEditorValue = urlInput !== null ? urlInput : url;
  42672. const urlLabel = ((0,external_lodash_namespaceObject.find)(getLinkDestinations(), ['linkDestination', linkDestination]) || {}).title;
  42673. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  42674. icon: library_link,
  42675. className: "components-toolbar__control",
  42676. label: url ? (0,external_wp_i18n_namespaceObject.__)('Edit link') : (0,external_wp_i18n_namespaceObject.__)('Insert link'),
  42677. "aria-expanded": isOpen,
  42678. onClick: openLinkUI,
  42679. ref: setPopoverAnchor
  42680. }), isOpen && (0,external_wp_element_namespaceObject.createElement)(url_popover, {
  42681. anchor: popoverAnchor,
  42682. onFocusOutside: onFocusOutside(),
  42683. onClose: closeLinkUI,
  42684. renderSettings: () => advancedOptions,
  42685. additionalControls: !linkEditorValue && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, null, (0,external_lodash_namespaceObject.map)(getLinkDestinations(), link => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  42686. key: link.linkDestination,
  42687. icon: link.icon,
  42688. onClick: () => {
  42689. setUrlInput(null);
  42690. onSetHref(link.url);
  42691. stopEditLink();
  42692. }
  42693. }, link.title)))
  42694. }, (!url || isEditingLink) && (0,external_wp_element_namespaceObject.createElement)(url_popover.LinkEditor, {
  42695. className: "block-editor-format-toolbar__link-container-content",
  42696. value: linkEditorValue,
  42697. onChangeInputValue: setUrlInput,
  42698. onSubmit: onSubmitLinkChange(),
  42699. autocompleteRef: autocompleteRef
  42700. }), url && !isEditingLink && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(url_popover.LinkViewer, {
  42701. className: "block-editor-format-toolbar__link-container-content",
  42702. url: url,
  42703. onEditLinkClick: startEditLink,
  42704. urlLabel: urlLabel
  42705. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  42706. icon: library_close,
  42707. label: (0,external_wp_i18n_namespaceObject.__)('Remove link'),
  42708. onClick: onLinkRemove
  42709. }))));
  42710. };
  42711. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/preview-options/index.js
  42712. /**
  42713. * External dependencies
  42714. */
  42715. /**
  42716. * WordPress dependencies
  42717. */
  42718. function PreviewOptions(_ref) {
  42719. let {
  42720. children,
  42721. viewLabel,
  42722. className,
  42723. isEnabled = true,
  42724. deviceType,
  42725. setDeviceType
  42726. } = _ref;
  42727. const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
  42728. if (isMobile) return null;
  42729. const popoverProps = {
  42730. className: classnames_default()(className, 'block-editor-post-preview__dropdown-content'),
  42731. position: 'bottom left'
  42732. };
  42733. const toggleProps = {
  42734. variant: 'tertiary',
  42735. className: 'block-editor-post-preview__button-toggle',
  42736. disabled: !isEnabled,
  42737. children: viewLabel
  42738. };
  42739. const menuProps = {
  42740. 'aria-label': (0,external_wp_i18n_namespaceObject.__)('View options')
  42741. };
  42742. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
  42743. className: "block-editor-post-preview__dropdown",
  42744. popoverProps: popoverProps,
  42745. toggleProps: toggleProps,
  42746. menuProps: menuProps,
  42747. icon: null
  42748. }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  42749. className: "block-editor-post-preview__button-resize",
  42750. onClick: () => setDeviceType('Desktop'),
  42751. icon: deviceType === 'Desktop' && library_check
  42752. }, (0,external_wp_i18n_namespaceObject.__)('Desktop')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  42753. className: "block-editor-post-preview__button-resize",
  42754. onClick: () => setDeviceType('Tablet'),
  42755. icon: deviceType === 'Tablet' && library_check
  42756. }, (0,external_wp_i18n_namespaceObject.__)('Tablet')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  42757. className: "block-editor-post-preview__button-resize",
  42758. onClick: () => setDeviceType('Mobile'),
  42759. icon: deviceType === 'Mobile' && library_check
  42760. }, (0,external_wp_i18n_namespaceObject.__)('Mobile'))), children));
  42761. }
  42762. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-resize-canvas/index.js
  42763. /**
  42764. * WordPress dependencies
  42765. */
  42766. /**
  42767. * Function to resize the editor window.
  42768. *
  42769. * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)
  42770. *
  42771. * @return {Object} Inline styles to be added to resizable container.
  42772. */
  42773. function useResizeCanvas(deviceType) {
  42774. const [actualWidth, updateActualWidth] = (0,external_wp_element_namespaceObject.useState)(window.innerWidth);
  42775. (0,external_wp_element_namespaceObject.useEffect)(() => {
  42776. if (deviceType === 'Desktop') {
  42777. return;
  42778. }
  42779. const resizeListener = () => updateActualWidth(window.innerWidth);
  42780. window.addEventListener('resize', resizeListener);
  42781. return () => {
  42782. window.removeEventListener('resize', resizeListener);
  42783. };
  42784. }, [deviceType]);
  42785. const getCanvasWidth = device => {
  42786. let deviceWidth;
  42787. switch (device) {
  42788. case 'Tablet':
  42789. deviceWidth = 780;
  42790. break;
  42791. case 'Mobile':
  42792. deviceWidth = 360;
  42793. break;
  42794. default:
  42795. return null;
  42796. }
  42797. return deviceWidth < actualWidth ? deviceWidth : actualWidth;
  42798. };
  42799. const marginValue = () => window.innerHeight < 800 ? 36 : 72;
  42800. const contentInlineStyles = device => {
  42801. const height = device === 'Mobile' ? '768px' : '1024px';
  42802. switch (device) {
  42803. case 'Tablet':
  42804. case 'Mobile':
  42805. return {
  42806. width: getCanvasWidth(device),
  42807. margin: marginValue() + 'px auto',
  42808. height,
  42809. borderRadius: '2px 2px 2px 2px',
  42810. border: '1px solid #ddd',
  42811. overflowY: 'auto'
  42812. };
  42813. default:
  42814. return null;
  42815. }
  42816. };
  42817. return contentInlineStyles(deviceType);
  42818. }
  42819. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/skip-to-selected-block/index.js
  42820. /**
  42821. * WordPress dependencies
  42822. */
  42823. /**
  42824. * Internal dependencies
  42825. */
  42826. const SkipToSelectedBlock = _ref => {
  42827. let {
  42828. selectedBlockClientId
  42829. } = _ref;
  42830. const ref = useBlockRef(selectedBlockClientId);
  42831. const onClick = () => {
  42832. ref.current.focus();
  42833. };
  42834. return selectedBlockClientId ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  42835. variant: "secondary",
  42836. className: "block-editor-skip-to-selected-block",
  42837. onClick: onClick
  42838. }, (0,external_wp_i18n_namespaceObject.__)('Skip to the selected block')) : null;
  42839. };
  42840. /**
  42841. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/skip-to-selected-block/README.md
  42842. */
  42843. /* harmony default export */ var skip_to_selected_block = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  42844. return {
  42845. selectedBlockClientId: select(store).getBlockSelectionStart()
  42846. };
  42847. })(SkipToSelectedBlock));
  42848. ;// CONCATENATED MODULE: external ["wp","wordcount"]
  42849. var external_wp_wordcount_namespaceObject = window["wp"]["wordcount"];
  42850. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/multi-selection-inspector/index.js
  42851. /**
  42852. * WordPress dependencies
  42853. */
  42854. /**
  42855. * Internal dependencies
  42856. */
  42857. function MultiSelectionInspector(_ref) {
  42858. let {
  42859. blocks
  42860. } = _ref;
  42861. const words = (0,external_wp_wordcount_namespaceObject.count)((0,external_wp_blocks_namespaceObject.serialize)(blocks), 'words');
  42862. return (0,external_wp_element_namespaceObject.createElement)("div", {
  42863. className: "block-editor-multi-selection-inspector__card"
  42864. }, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  42865. icon: library_copy,
  42866. showColors: true
  42867. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  42868. className: "block-editor-multi-selection-inspector__card-content"
  42869. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  42870. className: "block-editor-multi-selection-inspector__card-title"
  42871. }, (0,external_wp_i18n_namespaceObject.sprintf)(
  42872. /* translators: %d: number of blocks */
  42873. (0,external_wp_i18n_namespaceObject._n)('%d block', '%d blocks', blocks.length), blocks.length)), (0,external_wp_element_namespaceObject.createElement)("div", {
  42874. className: "block-editor-multi-selection-inspector__card-description"
  42875. }, (0,external_wp_i18n_namespaceObject.sprintf)(
  42876. /* translators: %d: number of words */
  42877. (0,external_wp_i18n_namespaceObject._n)('%d word', '%d words', words), words))));
  42878. }
  42879. /* harmony default export */ var multi_selection_inspector = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  42880. const {
  42881. getMultiSelectedBlocks
  42882. } = select(store);
  42883. return {
  42884. blocks: getMultiSelectedBlocks()
  42885. };
  42886. })(MultiSelectionInspector));
  42887. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-style-picker/index.js
  42888. /**
  42889. * WordPress dependencies
  42890. */
  42891. /**
  42892. * Internal dependencies
  42893. */
  42894. function DefaultStylePicker(_ref) {
  42895. let {
  42896. blockName
  42897. } = _ref;
  42898. const {
  42899. preferredStyle,
  42900. onUpdatePreferredStyleVariations,
  42901. styles
  42902. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  42903. var _preferredStyleVariat, _preferredStyleVariat2;
  42904. const settings = select(store).getSettings();
  42905. const preferredStyleVariations = settings.__experimentalPreferredStyleVariations;
  42906. return {
  42907. preferredStyle: preferredStyleVariations === null || preferredStyleVariations === void 0 ? void 0 : (_preferredStyleVariat = preferredStyleVariations.value) === null || _preferredStyleVariat === void 0 ? void 0 : _preferredStyleVariat[blockName],
  42908. onUpdatePreferredStyleVariations: (_preferredStyleVariat2 = preferredStyleVariations === null || preferredStyleVariations === void 0 ? void 0 : preferredStyleVariations.onChange) !== null && _preferredStyleVariat2 !== void 0 ? _preferredStyleVariat2 : null,
  42909. styles: select(external_wp_blocks_namespaceObject.store).getBlockStyles(blockName)
  42910. };
  42911. }, [blockName]);
  42912. const selectOptions = (0,external_wp_element_namespaceObject.useMemo)(() => [{
  42913. label: (0,external_wp_i18n_namespaceObject.__)('Not set'),
  42914. value: ''
  42915. }, ...styles.map(_ref2 => {
  42916. let {
  42917. label,
  42918. name
  42919. } = _ref2;
  42920. return {
  42921. label,
  42922. value: name
  42923. };
  42924. })], [styles]);
  42925. const defaultStyleName = (0,external_wp_element_namespaceObject.useMemo)(() => {
  42926. var _getDefaultStyle;
  42927. return (_getDefaultStyle = getDefaultStyle(styles)) === null || _getDefaultStyle === void 0 ? void 0 : _getDefaultStyle.name;
  42928. }, [styles]);
  42929. const selectOnChange = (0,external_wp_element_namespaceObject.useCallback)(blockStyle => {
  42930. onUpdatePreferredStyleVariations(blockName, blockStyle);
  42931. }, [blockName, onUpdatePreferredStyleVariations]); // Until the functionality is migrated to global styles,
  42932. // only show the default style picker if a non-default style has already been selected.
  42933. if (!preferredStyle || preferredStyle === defaultStyleName) {
  42934. return null;
  42935. }
  42936. return onUpdatePreferredStyleVariations && (0,external_wp_element_namespaceObject.createElement)("div", {
  42937. className: "default-style-picker__default-switcher"
  42938. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
  42939. options: selectOptions,
  42940. value: preferredStyle || '',
  42941. label: (0,external_wp_i18n_namespaceObject.__)('Default Style'),
  42942. onChange: selectOnChange
  42943. }));
  42944. }
  42945. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-inspector/index.js
  42946. /**
  42947. * WordPress dependencies
  42948. */
  42949. /**
  42950. * Internal dependencies
  42951. */
  42952. function useContentBlocks(blockTypes, block) {
  42953. const contenBlocksObjectAux = (0,external_wp_element_namespaceObject.useMemo)(() => {
  42954. return blockTypes.reduce((result, blockType) => {
  42955. if (blockType.name !== 'core/list-item' && Object.entries(blockType.attributes).some(_ref => {
  42956. let [, {
  42957. __experimentalRole
  42958. }] = _ref;
  42959. return __experimentalRole === 'content';
  42960. })) {
  42961. result[blockType.name] = true;
  42962. }
  42963. return result;
  42964. }, {});
  42965. }, [blockTypes]);
  42966. const isContentBlock = (0,external_wp_element_namespaceObject.useCallback)(blockName => {
  42967. return !!contenBlocksObjectAux[blockName];
  42968. }, [blockTypes]);
  42969. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  42970. return getContentBlocks([block], isContentBlock);
  42971. }, [block, isContentBlock]);
  42972. }
  42973. function getContentBlocks(blocks, isContentBlock) {
  42974. const result = [];
  42975. for (const block of blocks) {
  42976. if (isContentBlock(block.name)) {
  42977. result.push(block);
  42978. }
  42979. result.push(...getContentBlocks(block.innerBlocks, isContentBlock));
  42980. }
  42981. return result;
  42982. }
  42983. function BlockNavigationButton(_ref2) {
  42984. let {
  42985. blockTypes,
  42986. block,
  42987. selectedBlock
  42988. } = _ref2;
  42989. const {
  42990. selectBlock
  42991. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  42992. const blockType = blockTypes.find(_ref3 => {
  42993. let {
  42994. name
  42995. } = _ref3;
  42996. return name === block.name;
  42997. });
  42998. const isSelected = selectedBlock && selectedBlock.clientId === block.clientId;
  42999. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  43000. isPressed: isSelected,
  43001. onClick: () => selectBlock(block.clientId)
  43002. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
  43003. justify: "flex-start"
  43004. }, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  43005. icon: blockType.icon
  43006. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, blockType.title)));
  43007. }
  43008. function BlockInspectorLockedBlocks(_ref4) {
  43009. let {
  43010. topLevelLockedBlock
  43011. } = _ref4;
  43012. const {
  43013. blockTypes,
  43014. block,
  43015. selectedBlock
  43016. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  43017. return {
  43018. blockTypes: select(external_wp_blocks_namespaceObject.store).getBlockTypes(),
  43019. block: select(store).getBlock(topLevelLockedBlock),
  43020. selectedBlock: select(store).getSelectedBlock()
  43021. };
  43022. }, [topLevelLockedBlock]);
  43023. const blockInformation = useBlockDisplayInformation(topLevelLockedBlock);
  43024. const contentBlocks = useContentBlocks(blockTypes, block);
  43025. return (0,external_wp_element_namespaceObject.createElement)("div", {
  43026. className: "block-editor-block-inspector"
  43027. }, (0,external_wp_element_namespaceObject.createElement)(block_card, blockInformation), (0,external_wp_element_namespaceObject.createElement)(block_variation_transforms, {
  43028. blockClientId: topLevelLockedBlock
  43029. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
  43030. spacing: 1,
  43031. padding: 4,
  43032. className: "block-editor-block-inspector__block-buttons-container"
  43033. }, (0,external_wp_element_namespaceObject.createElement)("h2", {
  43034. className: "block-editor-block-card__title"
  43035. }, (0,external_wp_i18n_namespaceObject.__)('Content')), contentBlocks.map(contentBlock => (0,external_wp_element_namespaceObject.createElement)(BlockNavigationButton, {
  43036. selectedBlock: selectedBlock,
  43037. key: contentBlock.clientId,
  43038. block: contentBlock,
  43039. blockTypes: blockTypes
  43040. }))));
  43041. }
  43042. const BlockInspector = _ref5 => {
  43043. let {
  43044. showNoBlockSelectedMessage = true
  43045. } = _ref5;
  43046. const {
  43047. count,
  43048. selectedBlockName,
  43049. selectedBlockClientId,
  43050. blockType,
  43051. topLevelLockedBlock
  43052. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  43053. const {
  43054. getSelectedBlockClientId,
  43055. getSelectedBlockCount,
  43056. getBlockName,
  43057. __unstableGetContentLockingParent,
  43058. getTemplateLock
  43059. } = select(store);
  43060. const _selectedBlockClientId = getSelectedBlockClientId();
  43061. const _selectedBlockName = _selectedBlockClientId && getBlockName(_selectedBlockClientId);
  43062. const _blockType = _selectedBlockName && (0,external_wp_blocks_namespaceObject.getBlockType)(_selectedBlockName);
  43063. return {
  43064. count: getSelectedBlockCount(),
  43065. selectedBlockClientId: _selectedBlockClientId,
  43066. selectedBlockName: _selectedBlockName,
  43067. blockType: _blockType,
  43068. topLevelLockedBlock: __unstableGetContentLockingParent(_selectedBlockClientId) || (getTemplateLock(_selectedBlockClientId) === 'contentOnly' ? _selectedBlockClientId : undefined)
  43069. };
  43070. }, []);
  43071. if (count > 1) {
  43072. return (0,external_wp_element_namespaceObject.createElement)("div", {
  43073. className: "block-editor-block-inspector"
  43074. }, (0,external_wp_element_namespaceObject.createElement)(multi_selection_inspector, null), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, null), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  43075. __experimentalGroup: "color",
  43076. label: (0,external_wp_i18n_namespaceObject.__)('Color'),
  43077. className: "color-block-support-panel__inner-wrapper"
  43078. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  43079. __experimentalGroup: "typography",
  43080. label: (0,external_wp_i18n_namespaceObject.__)('Typography')
  43081. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  43082. __experimentalGroup: "dimensions",
  43083. label: (0,external_wp_i18n_namespaceObject.__)('Dimensions')
  43084. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  43085. __experimentalGroup: "border",
  43086. label: (0,external_wp_i18n_namespaceObject.__)('Border')
  43087. }));
  43088. }
  43089. const isSelectedBlockUnregistered = selectedBlockName === (0,external_wp_blocks_namespaceObject.getUnregisteredTypeHandlerName)();
  43090. /*
  43091. * If the selected block is of an unregistered type, avoid showing it as an actual selection
  43092. * because we want the user to focus on the unregistered block warning, not block settings.
  43093. */
  43094. if (!blockType || !selectedBlockClientId || isSelectedBlockUnregistered) {
  43095. if (showNoBlockSelectedMessage) {
  43096. return (0,external_wp_element_namespaceObject.createElement)("span", {
  43097. className: "block-editor-block-inspector__no-blocks"
  43098. }, (0,external_wp_i18n_namespaceObject.__)('No block selected.'));
  43099. }
  43100. return null;
  43101. }
  43102. if (topLevelLockedBlock) {
  43103. return (0,external_wp_element_namespaceObject.createElement)(BlockInspectorLockedBlocks, {
  43104. topLevelLockedBlock: topLevelLockedBlock
  43105. });
  43106. }
  43107. return (0,external_wp_element_namespaceObject.createElement)(BlockInspectorSingleBlock, {
  43108. clientId: selectedBlockClientId,
  43109. blockName: blockType.name
  43110. });
  43111. };
  43112. const BlockInspectorSingleBlock = _ref6 => {
  43113. let {
  43114. clientId,
  43115. blockName
  43116. } = _ref6;
  43117. const hasBlockStyles = (0,external_wp_data_namespaceObject.useSelect)(select => {
  43118. const {
  43119. getBlockStyles
  43120. } = select(external_wp_blocks_namespaceObject.store);
  43121. const blockStyles = getBlockStyles(blockName);
  43122. return blockStyles && blockStyles.length > 0;
  43123. }, [blockName]);
  43124. const blockInformation = useBlockDisplayInformation(clientId);
  43125. return (0,external_wp_element_namespaceObject.createElement)("div", {
  43126. className: "block-editor-block-inspector"
  43127. }, (0,external_wp_element_namespaceObject.createElement)(block_card, blockInformation), (0,external_wp_element_namespaceObject.createElement)(block_variation_transforms, {
  43128. blockClientId: clientId
  43129. }), hasBlockStyles && (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  43130. title: (0,external_wp_i18n_namespaceObject.__)('Styles')
  43131. }, (0,external_wp_element_namespaceObject.createElement)(block_styles, {
  43132. scope: "core/block-inspector",
  43133. clientId: clientId
  43134. }), (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'defaultStylePicker', true) && (0,external_wp_element_namespaceObject.createElement)(DefaultStylePicker, {
  43135. blockName: blockName
  43136. }))), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, null), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  43137. __experimentalGroup: "color",
  43138. label: (0,external_wp_i18n_namespaceObject.__)('Color'),
  43139. className: "color-block-support-panel__inner-wrapper"
  43140. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  43141. __experimentalGroup: "typography",
  43142. label: (0,external_wp_i18n_namespaceObject.__)('Typography')
  43143. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  43144. __experimentalGroup: "dimensions",
  43145. label: (0,external_wp_i18n_namespaceObject.__)('Dimensions')
  43146. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  43147. __experimentalGroup: "border",
  43148. label: (0,external_wp_i18n_namespaceObject.__)('Border')
  43149. }), (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(AdvancedControls, null)), (0,external_wp_element_namespaceObject.createElement)(skip_to_selected_block, {
  43150. key: "back"
  43151. }));
  43152. };
  43153. const AdvancedControls = () => {
  43154. const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(InspectorAdvancedControls.slotName);
  43155. const hasFills = Boolean(slot.fills && slot.fills.length);
  43156. if (!hasFills) {
  43157. return null;
  43158. }
  43159. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  43160. className: "block-editor-block-inspector__advanced",
  43161. title: (0,external_wp_i18n_namespaceObject.__)('Advanced'),
  43162. initialOpen: false
  43163. }, (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  43164. __experimentalGroup: "advanced"
  43165. }));
  43166. };
  43167. /**
  43168. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-inspector/README.md
  43169. */
  43170. /* harmony default export */ var block_inspector = (BlockInspector);
  43171. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/zoom-out-mode-inserters.js
  43172. /**
  43173. * WordPress dependencies
  43174. */
  43175. /**
  43176. * Internal dependencies
  43177. */
  43178. function ZoomOutModeInserters(_ref) {
  43179. let {
  43180. __unstableContentRef
  43181. } = _ref;
  43182. const [isReady, setIsReady] = (0,external_wp_element_namespaceObject.useState)(false);
  43183. const blockOrder = (0,external_wp_data_namespaceObject.useSelect)(select => {
  43184. return select(store).getBlockOrder();
  43185. }, []); // Defer the initial rendering to avoid the jumps due to the animation.
  43186. (0,external_wp_element_namespaceObject.useEffect)(() => {
  43187. const timeout = setTimeout(() => {
  43188. setIsReady(true);
  43189. }, 500);
  43190. return () => {
  43191. clearTimeout(timeout);
  43192. };
  43193. }, []);
  43194. if (!isReady) {
  43195. return null;
  43196. }
  43197. return blockOrder.map((clientId, index) => {
  43198. if (index === blockOrder.length - 1) {
  43199. return null;
  43200. }
  43201. return (0,external_wp_element_namespaceObject.createElement)(inbetween, {
  43202. key: clientId,
  43203. previousClientId: clientId,
  43204. nextClientId: blockOrder[index + 1],
  43205. __unstableContentRef: __unstableContentRef
  43206. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  43207. className: "block-editor-block-list__insertion-point-inserter is-with-inserter"
  43208. }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
  43209. position: "bottom center",
  43210. clientId: blockOrder[index + 1],
  43211. __experimentalIsQuick: true
  43212. })));
  43213. });
  43214. }
  43215. /* harmony default export */ var zoom_out_mode_inserters = (ZoomOutModeInserters);
  43216. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/index.js
  43217. /**
  43218. * WordPress dependencies
  43219. */
  43220. /**
  43221. * Internal dependencies
  43222. */
  43223. /**
  43224. * Renders block tools (the block toolbar, select/navigation mode toolbar, the
  43225. * insertion point and a slot for the inline rich text toolbar). Must be wrapped
  43226. * around the block content and editor styles wrapper or iframe.
  43227. *
  43228. * @param {Object} $0 Props.
  43229. * @param {Object} $0.children The block content and style container.
  43230. * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.
  43231. */
  43232. function BlockTools(_ref) {
  43233. let {
  43234. children,
  43235. __unstableContentRef,
  43236. ...props
  43237. } = _ref;
  43238. const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
  43239. const {
  43240. hasFixedToolbar,
  43241. isZoomOutMode
  43242. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  43243. const {
  43244. __unstableGetEditorMode,
  43245. getSettings
  43246. } = select(store);
  43247. return {
  43248. isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
  43249. hasFixedToolbar: getSettings().hasFixedToolbar
  43250. };
  43251. }, []);
  43252. const isMatch = (0,external_wp_keyboardShortcuts_namespaceObject.__unstableUseShortcutEventMatch)();
  43253. const {
  43254. getSelectedBlockClientIds,
  43255. getBlockRootClientId
  43256. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  43257. const {
  43258. duplicateBlocks,
  43259. removeBlocks,
  43260. insertAfterBlock,
  43261. insertBeforeBlock,
  43262. clearSelectedBlock,
  43263. moveBlocksUp,
  43264. moveBlocksDown
  43265. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  43266. function onKeyDown(event) {
  43267. if (event.defaultPrevented) return;
  43268. if (isMatch('core/block-editor/move-up', event)) {
  43269. const clientIds = getSelectedBlockClientIds();
  43270. if (clientIds.length) {
  43271. event.preventDefault();
  43272. const rootClientId = getBlockRootClientId(clientIds[0]);
  43273. moveBlocksUp(clientIds, rootClientId);
  43274. }
  43275. } else if (isMatch('core/block-editor/move-down', event)) {
  43276. const clientIds = getSelectedBlockClientIds();
  43277. if (clientIds.length) {
  43278. event.preventDefault();
  43279. const rootClientId = getBlockRootClientId(clientIds[0]);
  43280. moveBlocksDown(clientIds, rootClientId);
  43281. }
  43282. } else if (isMatch('core/block-editor/duplicate', event)) {
  43283. const clientIds = getSelectedBlockClientIds();
  43284. if (clientIds.length) {
  43285. event.preventDefault();
  43286. duplicateBlocks(clientIds);
  43287. }
  43288. } else if (isMatch('core/block-editor/remove', event)) {
  43289. const clientIds = getSelectedBlockClientIds();
  43290. if (clientIds.length) {
  43291. event.preventDefault();
  43292. removeBlocks(clientIds);
  43293. }
  43294. } else if (isMatch('core/block-editor/insert-after', event)) {
  43295. const clientIds = getSelectedBlockClientIds();
  43296. if (clientIds.length) {
  43297. event.preventDefault();
  43298. insertAfterBlock(clientIds[clientIds.length - 1]);
  43299. }
  43300. } else if (isMatch('core/block-editor/insert-before', event)) {
  43301. const clientIds = getSelectedBlockClientIds();
  43302. if (clientIds.length) {
  43303. event.preventDefault();
  43304. insertBeforeBlock(clientIds[0]);
  43305. }
  43306. } else if (isMatch('core/block-editor/unselect', event)) {
  43307. const clientIds = getSelectedBlockClientIds();
  43308. if (clientIds.length) {
  43309. event.preventDefault();
  43310. clearSelectedBlock();
  43311. event.target.ownerDocument.defaultView.getSelection().removeAllRanges();
  43312. __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current.focus();
  43313. }
  43314. }
  43315. }
  43316. const blockToolbarRef = use_popover_scroll(__unstableContentRef);
  43317. const blockToolbarAfterRef = use_popover_scroll(__unstableContentRef);
  43318. return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions
  43319. (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, props, {
  43320. onKeyDown: onKeyDown
  43321. }), (0,external_wp_element_namespaceObject.createElement)(insertion_point_InsertionPointOpenRef.Provider, {
  43322. value: (0,external_wp_element_namespaceObject.useRef)(false)
  43323. }, !isZoomOutMode && (0,external_wp_element_namespaceObject.createElement)(InsertionPoint, {
  43324. __unstableContentRef: __unstableContentRef
  43325. }), !isZoomOutMode && (hasFixedToolbar || !isLargeViewport) && (0,external_wp_element_namespaceObject.createElement)(block_contextual_toolbar, {
  43326. isFixed: true
  43327. }), (0,external_wp_element_namespaceObject.createElement)(WrappedBlockPopover, {
  43328. __unstableContentRef: __unstableContentRef
  43329. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, {
  43330. name: "block-toolbar",
  43331. ref: blockToolbarRef
  43332. }), children, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, {
  43333. name: "__unstable-block-tools-after",
  43334. ref: blockToolbarAfterRef
  43335. }), isZoomOutMode && (0,external_wp_element_namespaceObject.createElement)(zoom_out_mode_inserters, {
  43336. __unstableContentRef: __unstableContentRef
  43337. })))
  43338. );
  43339. }
  43340. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/library.js
  43341. /**
  43342. * WordPress dependencies
  43343. */
  43344. /**
  43345. * Internal dependencies
  43346. */
  43347. const library_noop = () => {};
  43348. function InserterLibrary(_ref, ref) {
  43349. let {
  43350. rootClientId,
  43351. clientId,
  43352. isAppender,
  43353. showInserterHelpPanel,
  43354. showMostUsedBlocks = false,
  43355. __experimentalInsertionIndex,
  43356. __experimentalFilterValue,
  43357. onSelect = library_noop,
  43358. shouldFocusBlock = false
  43359. } = _ref;
  43360. const {
  43361. destinationRootClientId,
  43362. prioritizePatterns
  43363. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  43364. const {
  43365. getBlockRootClientId,
  43366. getSettings
  43367. } = select(store);
  43368. const _rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
  43369. return {
  43370. destinationRootClientId: _rootClientId,
  43371. prioritizePatterns: getSettings().__experimentalPreferPatternsOnRoot
  43372. };
  43373. }, [clientId, rootClientId]);
  43374. return (0,external_wp_element_namespaceObject.createElement)(menu, {
  43375. onSelect: onSelect,
  43376. rootClientId: destinationRootClientId,
  43377. clientId: clientId,
  43378. isAppender: isAppender,
  43379. showInserterHelpPanel: showInserterHelpPanel,
  43380. showMostUsedBlocks: showMostUsedBlocks,
  43381. __experimentalInsertionIndex: __experimentalInsertionIndex,
  43382. __experimentalFilterValue: __experimentalFilterValue,
  43383. shouldFocusBlock: shouldFocusBlock,
  43384. prioritizePatterns: prioritizePatterns,
  43385. ref: ref
  43386. });
  43387. }
  43388. /* harmony default export */ var library = ((0,external_wp_element_namespaceObject.forwardRef)(InserterLibrary));
  43389. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/keyboard-shortcuts/index.js
  43390. /**
  43391. * WordPress dependencies
  43392. */
  43393. function KeyboardShortcuts() {
  43394. return null;
  43395. }
  43396. function KeyboardShortcutsRegister() {
  43397. // Registering the shortcuts.
  43398. const {
  43399. registerShortcut
  43400. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
  43401. (0,external_wp_element_namespaceObject.useEffect)(() => {
  43402. registerShortcut({
  43403. name: 'core/block-editor/duplicate',
  43404. category: 'block',
  43405. description: (0,external_wp_i18n_namespaceObject.__)('Duplicate the selected block(s).'),
  43406. keyCombination: {
  43407. modifier: 'primaryShift',
  43408. character: 'd'
  43409. }
  43410. });
  43411. registerShortcut({
  43412. name: 'core/block-editor/remove',
  43413. category: 'block',
  43414. description: (0,external_wp_i18n_namespaceObject.__)('Remove the selected block(s).'),
  43415. keyCombination: {
  43416. modifier: 'access',
  43417. character: 'z'
  43418. }
  43419. });
  43420. registerShortcut({
  43421. name: 'core/block-editor/insert-before',
  43422. category: 'block',
  43423. description: (0,external_wp_i18n_namespaceObject.__)('Insert a new block before the selected block(s).'),
  43424. keyCombination: {
  43425. modifier: 'primaryAlt',
  43426. character: 't'
  43427. }
  43428. });
  43429. registerShortcut({
  43430. name: 'core/block-editor/insert-after',
  43431. category: 'block',
  43432. description: (0,external_wp_i18n_namespaceObject.__)('Insert a new block after the selected block(s).'),
  43433. keyCombination: {
  43434. modifier: 'primaryAlt',
  43435. character: 'y'
  43436. }
  43437. });
  43438. registerShortcut({
  43439. name: 'core/block-editor/delete-multi-selection',
  43440. category: 'block',
  43441. description: (0,external_wp_i18n_namespaceObject.__)('Delete selection.'),
  43442. keyCombination: {
  43443. character: 'del'
  43444. },
  43445. aliases: [{
  43446. character: 'backspace'
  43447. }]
  43448. });
  43449. registerShortcut({
  43450. name: 'core/block-editor/select-all',
  43451. category: 'selection',
  43452. description: (0,external_wp_i18n_namespaceObject.__)('Select all text when typing. Press again to select all blocks.'),
  43453. keyCombination: {
  43454. modifier: 'primary',
  43455. character: 'a'
  43456. }
  43457. });
  43458. registerShortcut({
  43459. name: 'core/block-editor/unselect',
  43460. category: 'selection',
  43461. description: (0,external_wp_i18n_namespaceObject.__)('Clear selection.'),
  43462. keyCombination: {
  43463. character: 'escape'
  43464. }
  43465. });
  43466. registerShortcut({
  43467. name: 'core/block-editor/focus-toolbar',
  43468. category: 'global',
  43469. description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the nearest toolbar.'),
  43470. keyCombination: {
  43471. modifier: 'alt',
  43472. character: 'F10'
  43473. }
  43474. });
  43475. registerShortcut({
  43476. name: 'core/block-editor/move-up',
  43477. category: 'block',
  43478. description: (0,external_wp_i18n_namespaceObject.__)('Move the selected block(s) up.'),
  43479. keyCombination: {
  43480. modifier: 'secondary',
  43481. character: 't'
  43482. }
  43483. });
  43484. registerShortcut({
  43485. name: 'core/block-editor/move-down',
  43486. category: 'block',
  43487. description: (0,external_wp_i18n_namespaceObject.__)('Move the selected block(s) down.'),
  43488. keyCombination: {
  43489. modifier: 'secondary',
  43490. character: 'y'
  43491. }
  43492. });
  43493. }, [registerShortcut]);
  43494. return null;
  43495. }
  43496. KeyboardShortcuts.Register = KeyboardShortcutsRegister;
  43497. /* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts);
  43498. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/selection-scroll-into-view/index.js
  43499. /**
  43500. * WordPress dependencies
  43501. */
  43502. /**
  43503. * Scrolls the multi block selection end into view if not in view already. This
  43504. * is important to do after selection by keyboard.
  43505. *
  43506. * @deprecated
  43507. */
  43508. function MultiSelectScrollIntoView() {
  43509. external_wp_deprecated_default()('wp.blockEditor.MultiSelectScrollIntoView', {
  43510. hint: 'This behaviour is now built-in.',
  43511. since: '5.8'
  43512. });
  43513. return null;
  43514. }
  43515. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/observe-typing/index.js
  43516. /**
  43517. * WordPress dependencies
  43518. */
  43519. /**
  43520. * Internal dependencies
  43521. */
  43522. /**
  43523. * Set of key codes upon which typing is to be initiated on a keydown event.
  43524. *
  43525. * @type {Set<number>}
  43526. */
  43527. const KEY_DOWN_ELIGIBLE_KEY_CODES = new Set([external_wp_keycodes_namespaceObject.UP, external_wp_keycodes_namespaceObject.RIGHT, external_wp_keycodes_namespaceObject.DOWN, external_wp_keycodes_namespaceObject.LEFT, external_wp_keycodes_namespaceObject.ENTER, external_wp_keycodes_namespaceObject.BACKSPACE]);
  43528. /**
  43529. * Returns true if a given keydown event can be inferred as intent to start
  43530. * typing, or false otherwise. A keydown is considered eligible if it is a
  43531. * text navigation without shift active.
  43532. *
  43533. * @param {KeyboardEvent} event Keydown event to test.
  43534. *
  43535. * @return {boolean} Whether event is eligible to start typing.
  43536. */
  43537. function isKeyDownEligibleForStartTyping(event) {
  43538. const {
  43539. keyCode,
  43540. shiftKey
  43541. } = event;
  43542. return !shiftKey && KEY_DOWN_ELIGIBLE_KEY_CODES.has(keyCode);
  43543. }
  43544. /**
  43545. * Removes the `isTyping` flag when the mouse moves in the document of the given
  43546. * element.
  43547. */
  43548. function useMouseMoveTypingReset() {
  43549. const isTyping = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isTyping(), []);
  43550. const {
  43551. stopTyping
  43552. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  43553. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  43554. if (!isTyping) {
  43555. return;
  43556. }
  43557. const {
  43558. ownerDocument
  43559. } = node;
  43560. let lastClientX;
  43561. let lastClientY;
  43562. /**
  43563. * On mouse move, unset typing flag if user has moved cursor.
  43564. *
  43565. * @param {MouseEvent} event Mousemove event.
  43566. */
  43567. function stopTypingOnMouseMove(event) {
  43568. const {
  43569. clientX,
  43570. clientY
  43571. } = event; // We need to check that the mouse really moved because Safari
  43572. // triggers mousemove events when shift or ctrl are pressed.
  43573. if (lastClientX && lastClientY && (lastClientX !== clientX || lastClientY !== clientY)) {
  43574. stopTyping();
  43575. }
  43576. lastClientX = clientX;
  43577. lastClientY = clientY;
  43578. }
  43579. ownerDocument.addEventListener('mousemove', stopTypingOnMouseMove);
  43580. return () => {
  43581. ownerDocument.removeEventListener('mousemove', stopTypingOnMouseMove);
  43582. };
  43583. }, [isTyping, stopTyping]);
  43584. }
  43585. /**
  43586. * Sets and removes the `isTyping` flag based on user actions:
  43587. *
  43588. * - Sets the flag if the user types within the given element.
  43589. * - Removes the flag when the user selects some text, focusses a non-text
  43590. * field, presses ESC or TAB, or moves the mouse in the document.
  43591. */
  43592. function useTypingObserver() {
  43593. const {
  43594. isTyping,
  43595. hasInlineToolbar
  43596. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  43597. const {
  43598. isTyping: _isTyping,
  43599. getSettings
  43600. } = select(store);
  43601. return {
  43602. isTyping: _isTyping(),
  43603. hasInlineToolbar: getSettings().hasInlineToolbar
  43604. };
  43605. }, []);
  43606. const {
  43607. startTyping,
  43608. stopTyping
  43609. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  43610. const ref1 = useMouseMoveTypingReset();
  43611. const ref2 = (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  43612. const {
  43613. ownerDocument
  43614. } = node;
  43615. const {
  43616. defaultView
  43617. } = ownerDocument;
  43618. const selection = defaultView.getSelection(); // Listeners to stop typing should only be added when typing.
  43619. // Listeners to start typing should only be added when not typing.
  43620. if (isTyping) {
  43621. let timerId;
  43622. /**
  43623. * Stops typing when focus transitions to a non-text field element.
  43624. *
  43625. * @param {FocusEvent} event Focus event.
  43626. */
  43627. function stopTypingOnNonTextField(event) {
  43628. const {
  43629. target
  43630. } = event; // Since focus to a non-text field via arrow key will trigger
  43631. // before the keydown event, wait until after current stack
  43632. // before evaluating whether typing is to be stopped. Otherwise,
  43633. // typing will re-start.
  43634. timerId = defaultView.setTimeout(() => {
  43635. if (!(0,external_wp_dom_namespaceObject.isTextField)(target)) {
  43636. stopTyping();
  43637. }
  43638. });
  43639. }
  43640. /**
  43641. * Unsets typing flag if user presses Escape while typing flag is
  43642. * active.
  43643. *
  43644. * @param {KeyboardEvent} event Keypress or keydown event to
  43645. * interpret.
  43646. */
  43647. function stopTypingOnEscapeKey(event) {
  43648. const {
  43649. keyCode
  43650. } = event;
  43651. if (keyCode === external_wp_keycodes_namespaceObject.ESCAPE || keyCode === external_wp_keycodes_namespaceObject.TAB) {
  43652. stopTyping();
  43653. }
  43654. }
  43655. /**
  43656. * On selection change, unset typing flag if user has made an
  43657. * uncollapsed (shift) selection.
  43658. */
  43659. function stopTypingOnSelectionUncollapse() {
  43660. if (!selection.isCollapsed) {
  43661. stopTyping();
  43662. }
  43663. }
  43664. node.addEventListener('focus', stopTypingOnNonTextField);
  43665. node.addEventListener('keydown', stopTypingOnEscapeKey);
  43666. if (!hasInlineToolbar) {
  43667. ownerDocument.addEventListener('selectionchange', stopTypingOnSelectionUncollapse);
  43668. }
  43669. return () => {
  43670. defaultView.clearTimeout(timerId);
  43671. node.removeEventListener('focus', stopTypingOnNonTextField);
  43672. node.removeEventListener('keydown', stopTypingOnEscapeKey);
  43673. ownerDocument.removeEventListener('selectionchange', stopTypingOnSelectionUncollapse);
  43674. };
  43675. }
  43676. /**
  43677. * Handles a keypress or keydown event to infer intention to start
  43678. * typing.
  43679. *
  43680. * @param {KeyboardEvent} event Keypress or keydown event to interpret.
  43681. */
  43682. function startTypingInTextField(event) {
  43683. const {
  43684. type,
  43685. target
  43686. } = event; // Abort early if already typing, or key press is incurred outside a
  43687. // text field (e.g. arrow-ing through toolbar buttons).
  43688. // Ignore typing if outside the current DOM container
  43689. if (!(0,external_wp_dom_namespaceObject.isTextField)(target) || !node.contains(target)) {
  43690. return;
  43691. } // Special-case keydown because certain keys do not emit a keypress
  43692. // event. Conversely avoid keydown as the canonical event since
  43693. // there are many keydown which are explicitly not targeted for
  43694. // typing.
  43695. if (type === 'keydown' && !isKeyDownEligibleForStartTyping(event)) {
  43696. return;
  43697. }
  43698. startTyping();
  43699. }
  43700. node.addEventListener('keypress', startTypingInTextField);
  43701. node.addEventListener('keydown', startTypingInTextField);
  43702. return () => {
  43703. node.removeEventListener('keypress', startTypingInTextField);
  43704. node.removeEventListener('keydown', startTypingInTextField);
  43705. };
  43706. }, [isTyping, hasInlineToolbar, startTyping, stopTyping]);
  43707. return (0,external_wp_compose_namespaceObject.useMergeRefs)([ref1, ref2]);
  43708. }
  43709. function ObserveTyping(_ref) {
  43710. let {
  43711. children
  43712. } = _ref;
  43713. return (0,external_wp_element_namespaceObject.createElement)("div", {
  43714. ref: useTypingObserver()
  43715. }, children);
  43716. }
  43717. /**
  43718. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md
  43719. */
  43720. /* harmony default export */ var observe_typing = (ObserveTyping);
  43721. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/typewriter/index.js
  43722. /**
  43723. * WordPress dependencies
  43724. */
  43725. /**
  43726. * Internal dependencies
  43727. */
  43728. const isIE = window.navigator.userAgent.indexOf('Trident') !== -1;
  43729. const arrowKeyCodes = new Set([external_wp_keycodes_namespaceObject.UP, external_wp_keycodes_namespaceObject.DOWN, external_wp_keycodes_namespaceObject.LEFT, external_wp_keycodes_namespaceObject.RIGHT]);
  43730. const initialTriggerPercentage = 0.75;
  43731. function useTypewriter() {
  43732. const hasSelectedBlock = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).hasSelectedBlock(), []);
  43733. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  43734. if (!hasSelectedBlock) {
  43735. return;
  43736. }
  43737. const {
  43738. ownerDocument
  43739. } = node;
  43740. const {
  43741. defaultView
  43742. } = ownerDocument;
  43743. let scrollResizeRafId;
  43744. let onKeyDownRafId;
  43745. let caretRect;
  43746. function onScrollResize() {
  43747. if (scrollResizeRafId) {
  43748. return;
  43749. }
  43750. scrollResizeRafId = defaultView.requestAnimationFrame(() => {
  43751. computeCaretRectangle();
  43752. scrollResizeRafId = null;
  43753. });
  43754. }
  43755. function onKeyDown(event) {
  43756. // Ensure the any remaining request is cancelled.
  43757. if (onKeyDownRafId) {
  43758. defaultView.cancelAnimationFrame(onKeyDownRafId);
  43759. } // Use an animation frame for a smooth result.
  43760. onKeyDownRafId = defaultView.requestAnimationFrame(() => {
  43761. maintainCaretPosition(event);
  43762. onKeyDownRafId = null;
  43763. });
  43764. }
  43765. /**
  43766. * Maintains the scroll position after a selection change caused by a
  43767. * keyboard event.
  43768. *
  43769. * @param {KeyboardEvent} event Keyboard event.
  43770. */
  43771. function maintainCaretPosition(_ref) {
  43772. let {
  43773. keyCode
  43774. } = _ref;
  43775. if (!isSelectionEligibleForScroll()) {
  43776. return;
  43777. }
  43778. const currentCaretRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView);
  43779. if (!currentCaretRect) {
  43780. return;
  43781. } // If for some reason there is no position set to be scrolled to, let
  43782. // this be the position to be scrolled to in the future.
  43783. if (!caretRect) {
  43784. caretRect = currentCaretRect;
  43785. return;
  43786. } // Even though enabling the typewriter effect for arrow keys results in
  43787. // a pleasant experience, it may not be the case for everyone, so, for
  43788. // now, let's disable it.
  43789. if (arrowKeyCodes.has(keyCode)) {
  43790. // Reset the caret position to maintain.
  43791. caretRect = currentCaretRect;
  43792. return;
  43793. }
  43794. const diff = currentCaretRect.top - caretRect.top;
  43795. if (diff === 0) {
  43796. return;
  43797. }
  43798. const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(node); // The page must be scrollable.
  43799. if (!scrollContainer) {
  43800. return;
  43801. }
  43802. const windowScroll = scrollContainer === ownerDocument.body;
  43803. const scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop;
  43804. const scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top;
  43805. const relativeScrollPosition = windowScroll ? caretRect.top / defaultView.innerHeight : (caretRect.top - scrollContainerY) / (defaultView.innerHeight - scrollContainerY); // If the scroll position is at the start, the active editable element
  43806. // is the last one, and the caret is positioned within the initial
  43807. // trigger percentage of the page, do not scroll the page.
  43808. // The typewriter effect should not kick in until an empty page has been
  43809. // filled with the initial trigger percentage or the user scrolls
  43810. // intentionally down.
  43811. if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) {
  43812. // Reset the caret position to maintain.
  43813. caretRect = currentCaretRect;
  43814. return;
  43815. }
  43816. const scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight; // Abort if the target scroll position would scroll the caret out of
  43817. // view.
  43818. if ( // The caret is under the lower fold.
  43819. caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold.
  43820. caretRect.top < scrollContainerY) {
  43821. // Reset the caret position to maintain.
  43822. caretRect = currentCaretRect;
  43823. return;
  43824. }
  43825. if (windowScroll) {
  43826. defaultView.scrollBy(0, diff);
  43827. } else {
  43828. scrollContainer.scrollTop += diff;
  43829. }
  43830. }
  43831. /**
  43832. * Adds a `selectionchange` listener to reset the scroll position to be
  43833. * maintained.
  43834. */
  43835. function addSelectionChangeListener() {
  43836. ownerDocument.addEventListener('selectionchange', computeCaretRectOnSelectionChange);
  43837. }
  43838. /**
  43839. * Resets the scroll position to be maintained during a `selectionchange`
  43840. * event. Also removes the listener, so it acts as a one-time listener.
  43841. */
  43842. function computeCaretRectOnSelectionChange() {
  43843. ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange);
  43844. computeCaretRectangle();
  43845. }
  43846. /**
  43847. * Resets the scroll position to be maintained.
  43848. */
  43849. function computeCaretRectangle() {
  43850. if (isSelectionEligibleForScroll()) {
  43851. caretRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView);
  43852. }
  43853. }
  43854. /**
  43855. * Checks if the current situation is elegible for scroll:
  43856. * - There should be one and only one block selected.
  43857. * - The component must contain the selection.
  43858. * - The active element must be contenteditable.
  43859. */
  43860. function isSelectionEligibleForScroll() {
  43861. return node.contains(ownerDocument.activeElement) && ownerDocument.activeElement.isContentEditable;
  43862. }
  43863. function isLastEditableNode() {
  43864. const editableNodes = node.querySelectorAll('[contenteditable="true"]');
  43865. const lastEditableNode = editableNodes[editableNodes.length - 1];
  43866. return lastEditableNode === ownerDocument.activeElement;
  43867. } // When the user scrolls or resizes, the scroll position should be
  43868. // reset.
  43869. defaultView.addEventListener('scroll', onScrollResize, true);
  43870. defaultView.addEventListener('resize', onScrollResize, true);
  43871. node.addEventListener('keydown', onKeyDown);
  43872. node.addEventListener('keyup', maintainCaretPosition);
  43873. node.addEventListener('mousedown', addSelectionChangeListener);
  43874. node.addEventListener('touchstart', addSelectionChangeListener);
  43875. return () => {
  43876. defaultView.removeEventListener('scroll', onScrollResize, true);
  43877. defaultView.removeEventListener('resize', onScrollResize, true);
  43878. node.removeEventListener('keydown', onKeyDown);
  43879. node.removeEventListener('keyup', maintainCaretPosition);
  43880. node.removeEventListener('mousedown', addSelectionChangeListener);
  43881. node.removeEventListener('touchstart', addSelectionChangeListener);
  43882. ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange);
  43883. defaultView.cancelAnimationFrame(scrollResizeRafId);
  43884. defaultView.cancelAnimationFrame(onKeyDownRafId);
  43885. };
  43886. }, [hasSelectedBlock]);
  43887. }
  43888. function Typewriter(_ref2) {
  43889. let {
  43890. children
  43891. } = _ref2;
  43892. return (0,external_wp_element_namespaceObject.createElement)("div", {
  43893. ref: useTypewriter(),
  43894. className: "block-editor__typewriter"
  43895. }, children);
  43896. }
  43897. /**
  43898. * The exported component. The implementation of Typewriter faced technical
  43899. * challenges in Internet Explorer, and is simply skipped, rendering the given
  43900. * props children instead.
  43901. *
  43902. * @type {WPComponent}
  43903. */
  43904. const TypewriterOrIEBypass = isIE ? props => props.children : Typewriter;
  43905. /**
  43906. * Ensures that the text selection keeps the same vertical distance from the
  43907. * viewport during keyboard events within this component. The vertical distance
  43908. * can vary. It is the last clicked or scrolled to position.
  43909. */
  43910. /* harmony default export */ var typewriter = (TypewriterOrIEBypass);
  43911. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/recursion-provider/index.js
  43912. /**
  43913. * WordPress dependencies
  43914. */
  43915. /**
  43916. * Internal dependencies
  43917. */
  43918. const RenderedRefsContext = (0,external_wp_element_namespaceObject.createContext)({});
  43919. /**
  43920. * Immutably adds an unique identifier to a set scoped for a given block type.
  43921. *
  43922. * @param {Object} renderedBlocks Rendered blocks grouped by block name
  43923. * @param {string} blockName Name of the block.
  43924. * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.
  43925. *
  43926. * @return {Object} The list of rendered blocks grouped by block name.
  43927. */
  43928. function addToBlockType(renderedBlocks, blockName, uniqueId) {
  43929. const result = { ...renderedBlocks,
  43930. [blockName]: renderedBlocks[blockName] ? new Set(renderedBlocks[blockName]) : new Set()
  43931. };
  43932. result[blockName].add(uniqueId);
  43933. return result;
  43934. }
  43935. /**
  43936. * A React context provider for use with the `useHasRecursion` hook to prevent recursive
  43937. * renders.
  43938. *
  43939. * Wrap block content with this provider and provide the same `uniqueId` prop as used
  43940. * with `useHasRecursion`.
  43941. *
  43942. * @param {Object} props
  43943. * @param {*} props.uniqueId Any value that acts as a unique identifier for a block instance.
  43944. * @param {string} props.blockName Optional block name.
  43945. * @param {JSX.Element} props.children React children.
  43946. *
  43947. * @return {JSX.Element} A React element.
  43948. */
  43949. function RecursionProvider(_ref) {
  43950. let {
  43951. children,
  43952. uniqueId,
  43953. blockName = ''
  43954. } = _ref;
  43955. const previouslyRenderedBlocks = (0,external_wp_element_namespaceObject.useContext)(RenderedRefsContext);
  43956. const {
  43957. name
  43958. } = useBlockEditContext();
  43959. blockName = blockName || name;
  43960. const newRenderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => addToBlockType(previouslyRenderedBlocks, blockName, uniqueId), [previouslyRenderedBlocks, blockName, uniqueId]);
  43961. return (0,external_wp_element_namespaceObject.createElement)(RenderedRefsContext.Provider, {
  43962. value: newRenderedBlocks
  43963. }, children);
  43964. }
  43965. /**
  43966. * A React hook for keeping track of blocks previously rendered up in the block
  43967. * tree. Blocks susceptible to recursion can use this hook in their `Edit`
  43968. * function to prevent said recursion.
  43969. *
  43970. * Use this with the `RecursionProvider` component, using the same `uniqueId` value
  43971. * for both the hook and the provider.
  43972. *
  43973. * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.
  43974. * @param {string} blockName Optional block name.
  43975. *
  43976. * @return {boolean} A boolean describing whether the provided id has already been rendered.
  43977. */
  43978. function useHasRecursion(uniqueId) {
  43979. var _previouslyRenderedBl;
  43980. let blockName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  43981. const previouslyRenderedBlocks = (0,external_wp_element_namespaceObject.useContext)(RenderedRefsContext);
  43982. const {
  43983. name
  43984. } = useBlockEditContext();
  43985. blockName = blockName || name;
  43986. return Boolean((_previouslyRenderedBl = previouslyRenderedBlocks[blockName]) === null || _previouslyRenderedBl === void 0 ? void 0 : _previouslyRenderedBl.has(uniqueId));
  43987. }
  43988. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js
  43989. /**
  43990. * WordPress dependencies
  43991. */
  43992. const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  43993. xmlns: "http://www.w3.org/2000/svg",
  43994. viewBox: "0 0 24 24"
  43995. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  43996. d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"
  43997. }));
  43998. /* harmony default export */ var close_small = (closeSmall);
  43999. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-popover-header/index.js
  44000. /**
  44001. * WordPress dependencies
  44002. */
  44003. function InspectorPopoverHeader(_ref) {
  44004. let {
  44005. title,
  44006. help,
  44007. actions = [],
  44008. onClose
  44009. } = _ref;
  44010. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
  44011. className: "block-editor-inspector-popover-header",
  44012. spacing: 4
  44013. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
  44014. alignment: "center"
  44015. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
  44016. className: "block-editor-inspector-popover-header__heading",
  44017. level: 2,
  44018. size: 13
  44019. }, title), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null), actions.map(_ref2 => {
  44020. let {
  44021. label,
  44022. icon,
  44023. onClick
  44024. } = _ref2;
  44025. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  44026. key: label,
  44027. className: "block-editor-inspector-popover-header__action",
  44028. label: label,
  44029. icon: icon,
  44030. variant: !icon && 'tertiary',
  44031. onClick: onClick
  44032. }, !icon && label);
  44033. }), onClose && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  44034. className: "block-editor-inspector-popover-header__action",
  44035. label: (0,external_wp_i18n_namespaceObject.__)('Close'),
  44036. icon: close_small,
  44037. onClick: onClose
  44038. })), help && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, null, help));
  44039. }
  44040. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/publish-date-time-picker/index.js
  44041. /**
  44042. * WordPress dependencies
  44043. */
  44044. /**
  44045. * Internal dependencies
  44046. */
  44047. function PublishDateTimePicker(_ref, ref) {
  44048. let {
  44049. onClose,
  44050. onChange,
  44051. ...additionalProps
  44052. } = _ref;
  44053. return (0,external_wp_element_namespaceObject.createElement)("div", {
  44054. ref: ref,
  44055. className: "block-editor-publish-date-time-picker"
  44056. }, (0,external_wp_element_namespaceObject.createElement)(InspectorPopoverHeader, {
  44057. title: (0,external_wp_i18n_namespaceObject.__)('Publish'),
  44058. actions: [{
  44059. label: (0,external_wp_i18n_namespaceObject.__)('Now'),
  44060. onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(null)
  44061. }],
  44062. onClose: onClose
  44063. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DateTimePicker, _extends({
  44064. startOfWeek: (0,external_wp_date_namespaceObject.getSettings)().l10n.startOfWeek,
  44065. __nextRemoveHelpButton: true,
  44066. __nextRemoveResetButton: true,
  44067. onChange: onChange
  44068. }, additionalProps)));
  44069. }
  44070. /* harmony default export */ var publish_date_time_picker = ((0,external_wp_element_namespaceObject.forwardRef)(PublishDateTimePicker));
  44071. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/index.js
  44072. /*
  44073. * Block Creation Components
  44074. */
  44075. /*
  44076. * Content Related Components
  44077. */
  44078. /*
  44079. * State Related Components
  44080. */
  44081. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/elements/index.js
  44082. const ELEMENT_CLASS_NAMES = {
  44083. button: 'wp-element-button',
  44084. caption: 'wp-element-caption'
  44085. };
  44086. const __experimentalGetElementClassName = element => {
  44087. return ELEMENT_CLASS_NAMES[element] ? ELEMENT_CLASS_NAMES[element] : '';
  44088. };
  44089. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/block-variation-transforms.js
  44090. /** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
  44091. function matchesAttributes(blockAttributes, variation) {
  44092. return Object.entries(variation).every(_ref => {
  44093. let [key, value] = _ref;
  44094. if (typeof value === 'object' && typeof blockAttributes[key] === 'object') {
  44095. return matchesAttributes(blockAttributes[key], value);
  44096. }
  44097. return blockAttributes[key] === value;
  44098. });
  44099. }
  44100. /**
  44101. * Matches the provided block variations with a block's attributes. If no match
  44102. * or more than one matches are found it returns `undefined`. If a single match is
  44103. * found it returns it.
  44104. *
  44105. * This is a simple implementation for now as it takes into account only the attributes
  44106. * of a block variation and not `InnerBlocks`.
  44107. *
  44108. * @param {Object} blockAttributes - The block attributes to try to find a match.
  44109. * @param {WPBlockVariation[]} variations - A list of block variations to test for a match.
  44110. * @return {?WPBlockVariation} - If a match is found returns it. If not or more than one matches are found returns `undefined`.
  44111. */
  44112. const __experimentalGetMatchingVariation = (blockAttributes, variations) => {
  44113. if (!variations || !blockAttributes) return;
  44114. const matches = variations.filter(_ref2 => {
  44115. let {
  44116. attributes
  44117. } = _ref2;
  44118. if (!attributes || !Object.keys(attributes).length) return false;
  44119. return matchesAttributes(blockAttributes, attributes);
  44120. });
  44121. if (matches.length !== 1) return;
  44122. return matches[0];
  44123. };
  44124. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/parse-css-unit-to-px.js
  44125. /**
  44126. * Converts string to object { value, unit }.
  44127. *
  44128. * @param {string} cssUnit
  44129. * @return {Object} parsedUnit
  44130. */
  44131. function parseUnit(cssUnit) {
  44132. const match = cssUnit === null || cssUnit === void 0 ? void 0 : cssUnit.trim().match(/^(0?[-.]?\d*\.?\d+)(r?e[m|x]|v[h|w|min|max]+|p[x|t|c]|[c|m]m|%|in|ch|Q|lh)$/);
  44133. if (!isNaN(cssUnit) && !isNaN(parseFloat(cssUnit))) {
  44134. return {
  44135. value: parseFloat(cssUnit),
  44136. unit: 'px'
  44137. };
  44138. }
  44139. return match ? {
  44140. value: parseFloat(match[1]) || match[1],
  44141. unit: match[2]
  44142. } : {
  44143. value: cssUnit,
  44144. unit: undefined
  44145. };
  44146. }
  44147. /**
  44148. * Evaluate a math expression.
  44149. *
  44150. * @param {string} expression
  44151. * @return {number} evaluated expression.
  44152. */
  44153. function calculate(expression) {
  44154. return Function(`'use strict'; return (${expression})`)();
  44155. }
  44156. /**
  44157. * Calculates the css function value for the supported css functions such as max, min, clamp and calc.
  44158. *
  44159. * @param {string} functionUnitValue string should be in a particular format (for example min(12px,12px) ) no nested loops.
  44160. * @param {Object} options
  44161. * @return {string} unit containing the unit in PX.
  44162. */
  44163. function getFunctionUnitValue(functionUnitValue, options) {
  44164. const functionUnit = functionUnitValue.split(/[(),]/g).filter(Boolean);
  44165. const units = functionUnit.slice(1).map(unit => parseUnit(getPxFromCssUnit(unit, options)).value).filter(Boolean);
  44166. switch (functionUnit[0]) {
  44167. case 'min':
  44168. return Math.min(...units) + 'px';
  44169. case 'max':
  44170. return Math.max(...units) + 'px';
  44171. case 'clamp':
  44172. if (units.length !== 3) {
  44173. return null;
  44174. }
  44175. if (units[1] < units[0]) {
  44176. return units[0] + 'px';
  44177. }
  44178. if (units[1] > units[2]) {
  44179. return units[2] + 'px';
  44180. }
  44181. return units[1] + 'px';
  44182. case 'calc':
  44183. return units[0] + 'px';
  44184. }
  44185. }
  44186. /**
  44187. * Take a css function such as min, max, calc, clamp and returns parsedUnit
  44188. *
  44189. * How this works for the nested function is that it first replaces the inner function call.
  44190. * Then it tackles the outer onces.
  44191. * So for example: min( max(25px, 35px), 40px )
  44192. * in the first pass we would replace max(25px, 35px) with 35px.
  44193. * then we would try to evaluate min( 35px, 40px )
  44194. * and then finally return 35px.
  44195. *
  44196. * @param {string} cssUnit
  44197. * @return {Object} parsedUnit object.
  44198. */
  44199. function parseUnitFunction(cssUnit) {
  44200. while (true) {
  44201. const currentCssUnit = cssUnit;
  44202. const regExp = /(max|min|calc|clamp)\(([^()]*)\)/g;
  44203. const matches = regExp.exec(cssUnit) || [];
  44204. if (matches[0]) {
  44205. const functionUnitValue = getFunctionUnitValue(matches[0]);
  44206. cssUnit = cssUnit.replace(matches[0], functionUnitValue);
  44207. } // If the unit hasn't been modified or we have a single value break free.
  44208. if (cssUnit === currentCssUnit || parseFloat(cssUnit)) {
  44209. break;
  44210. }
  44211. }
  44212. return parseUnit(cssUnit);
  44213. }
  44214. /**
  44215. * Return true if we think this is a math expression.
  44216. *
  44217. * @param {string} cssUnit the cssUnit value being evaluted.
  44218. * @return {boolean} Whether the cssUnit is a math expression.
  44219. */
  44220. function isMathExpression(cssUnit) {
  44221. for (let i = 0; i < cssUnit.length; i++) {
  44222. if (['+', '-', '/', '*'].includes(cssUnit[i])) {
  44223. return true;
  44224. }
  44225. }
  44226. return false;
  44227. }
  44228. /**
  44229. * Evaluates the math expression and return a px value.
  44230. *
  44231. * @param {string} cssUnit the cssUnit value being evaluted.
  44232. * @return {string} return a converfted value to px.
  44233. */
  44234. function evalMathExpression(cssUnit) {
  44235. let errorFound = false; // Convert every part of the expression to px values.
  44236. const cssUnitsBits = cssUnit.split(/[+-/*/]/g).filter(Boolean);
  44237. for (const unit of cssUnitsBits) {
  44238. // Standardize the unit to px and extract the value.
  44239. const parsedUnit = parseUnit(getPxFromCssUnit(unit));
  44240. if (!parseFloat(parsedUnit.value)) {
  44241. errorFound = true; // End early since we are dealing with a null value.
  44242. break;
  44243. }
  44244. cssUnit = cssUnit.replace(unit, parsedUnit.value);
  44245. }
  44246. return errorFound ? null : calculate(cssUnit).toFixed(0) + 'px';
  44247. }
  44248. /**
  44249. * Convert a parsedUnit object to px value.
  44250. *
  44251. * @param {Object} parsedUnit
  44252. * @param {Object} options
  44253. * @return {string} or {null} returns the converted with in a px value format.
  44254. */
  44255. function convertParsedUnitToPx(parsedUnit, options) {
  44256. const PIXELS_PER_INCH = 96;
  44257. const ONE_PERCENT = 0.01;
  44258. const defaultProperties = {
  44259. fontSize: 16,
  44260. lineHeight: 16,
  44261. width: 375,
  44262. height: 812,
  44263. type: 'font'
  44264. };
  44265. const setOptions = Object.assign({}, defaultProperties, options);
  44266. const relativeUnits = {
  44267. em: setOptions.fontSize,
  44268. rem: setOptions.fontSize,
  44269. vh: setOptions.height * ONE_PERCENT,
  44270. vw: setOptions.width * ONE_PERCENT,
  44271. vmin: (setOptions.width < setOptions.height ? setOptions.width : setOptions.height) * ONE_PERCENT,
  44272. vmax: (setOptions.width > setOptions.height ? setOptions.width : setOptions.height) * ONE_PERCENT,
  44273. '%': (setOptions.type === 'font' ? setOptions.fontSize : setOptions.width) * ONE_PERCENT,
  44274. ch: 8,
  44275. // The advance measure (width) of the glyph "0" of the element's font. Approximate
  44276. ex: 7.15625,
  44277. // X-height of the element's font. Approximate.
  44278. lh: setOptions.lineHeight
  44279. };
  44280. const absoluteUnits = {
  44281. in: PIXELS_PER_INCH,
  44282. cm: PIXELS_PER_INCH / 2.54,
  44283. mm: PIXELS_PER_INCH / 25.4,
  44284. pt: PIXELS_PER_INCH / 72,
  44285. pc: PIXELS_PER_INCH / 6,
  44286. px: 1,
  44287. Q: PIXELS_PER_INCH / 2.54 / 40
  44288. };
  44289. if (relativeUnits[parsedUnit.unit]) {
  44290. return (relativeUnits[parsedUnit.unit] * parsedUnit.value).toFixed(0) + 'px';
  44291. }
  44292. if (absoluteUnits[parsedUnit.unit]) {
  44293. return (absoluteUnits[parsedUnit.unit] * parsedUnit.value).toFixed(0) + 'px';
  44294. }
  44295. return null;
  44296. }
  44297. /**
  44298. * Returns the px value of a cssUnit.
  44299. *
  44300. * @param {string} cssUnit
  44301. * @param {Object} options
  44302. * @return {string} returns the cssUnit value in a simple px format.
  44303. */
  44304. function getPxFromCssUnit(cssUnit) {
  44305. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  44306. if (Number.isFinite(cssUnit)) {
  44307. return cssUnit.toFixed(0) + 'px';
  44308. }
  44309. if (cssUnit === undefined) {
  44310. return null;
  44311. }
  44312. let parsedUnit = parseUnit(cssUnit);
  44313. if (!parsedUnit.unit) {
  44314. parsedUnit = parseUnitFunction(cssUnit);
  44315. }
  44316. if (isMathExpression(cssUnit) && !parsedUnit.unit) {
  44317. return evalMathExpression(cssUnit);
  44318. }
  44319. return convertParsedUnitToPx(parsedUnit, options);
  44320. } // Use simple cache.
  44321. const cache = {};
  44322. /**
  44323. * Returns the px value of a cssUnit. The memoized version of getPxFromCssUnit;
  44324. *
  44325. * @param {string} cssUnit
  44326. * @param {Object} options
  44327. * @return {string} returns the cssUnit value in a simple px format.
  44328. */
  44329. function memoizedGetPxFromCssUnit(cssUnit) {
  44330. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  44331. const hash = cssUnit + hashOptions(options);
  44332. if (!cache[hash]) {
  44333. cache[hash] = getPxFromCssUnit(cssUnit, options);
  44334. }
  44335. return cache[hash];
  44336. }
  44337. function hashOptions(options) {
  44338. let hash = '';
  44339. if (options.hasOwnProperty('fontSize')) {
  44340. hash = ':' + options.width;
  44341. }
  44342. if (options.hasOwnProperty('lineHeight')) {
  44343. hash = ':' + options.lineHeight;
  44344. }
  44345. if (options.hasOwnProperty('width')) {
  44346. hash = ':' + options.width;
  44347. }
  44348. if (options.hasOwnProperty('height')) {
  44349. hash = ':' + options.height;
  44350. }
  44351. if (options.hasOwnProperty('type')) {
  44352. hash = ':' + options.type;
  44353. }
  44354. return hash;
  44355. }
  44356. /* harmony default export */ var parse_css_unit_to_px = (memoizedGetPxFromCssUnit);
  44357. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/index.js
  44358. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/index.js
  44359. /**
  44360. * Internal dependencies
  44361. */
  44362. }();
  44363. (window.wp = window.wp || {}).blockEditor = __webpack_exports__;
  44364. /******/ })()
  44365. ;