block-editor.js 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850
  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. function classNames() {
  262. var classes = [];
  263. for (var i = 0; i < arguments.length; i++) {
  264. var arg = arguments[i];
  265. if (!arg) continue;
  266. var argType = typeof arg;
  267. if (argType === 'string' || argType === 'number') {
  268. classes.push(arg);
  269. } else if (Array.isArray(arg)) {
  270. if (arg.length) {
  271. var inner = classNames.apply(null, arg);
  272. if (inner) {
  273. classes.push(inner);
  274. }
  275. }
  276. } else if (argType === 'object') {
  277. if (arg.toString === Object.prototype.toString) {
  278. for (var key in arg) {
  279. if (hasOwn.call(arg, key) && arg[key]) {
  280. classes.push(key);
  281. }
  282. }
  283. } else {
  284. classes.push(arg.toString());
  285. }
  286. }
  287. }
  288. return classes.join(' ');
  289. }
  290. if ( true && module.exports) {
  291. classNames.default = classNames;
  292. module.exports = classNames;
  293. } else if (true) {
  294. // register as 'classnames', consistent with npm package name
  295. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  296. return classNames;
  297. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  298. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  299. } else {}
  300. }());
  301. /***/ }),
  302. /***/ 4827:
  303. /***/ (function(module) {
  304. // This code has been refactored for 140 bytes
  305. // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js
  306. var computedStyle = function (el, prop, getComputedStyle) {
  307. getComputedStyle = window.getComputedStyle;
  308. // In one fell swoop
  309. return (
  310. // If we have getComputedStyle
  311. getComputedStyle ?
  312. // Query it
  313. // TODO: From CSS-Query notes, we might need (node, null) for FF
  314. getComputedStyle(el) :
  315. // Otherwise, we are in IE and use currentStyle
  316. el.currentStyle
  317. )[
  318. // Switch to camelCase for CSSOM
  319. // DEV: Grabbed from jQuery
  320. // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
  321. // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
  322. prop.replace(/-(\w)/gi, function (word, letter) {
  323. return letter.toUpperCase();
  324. })
  325. ];
  326. };
  327. module.exports = computedStyle;
  328. /***/ }),
  329. /***/ 1198:
  330. /***/ (function(__unused_webpack_module, exports) {
  331. "use strict";
  332. /*istanbul ignore start*/
  333. Object.defineProperty(exports, "__esModule", ({
  334. value: true
  335. }));
  336. exports["default"] = Diff;
  337. /*istanbul ignore end*/
  338. function Diff() {}
  339. Diff.prototype = {
  340. /*istanbul ignore start*/
  341. /*istanbul ignore end*/
  342. diff: function diff(oldString, newString) {
  343. /*istanbul ignore start*/
  344. var
  345. /*istanbul ignore end*/
  346. options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  347. var callback = options.callback;
  348. if (typeof options === 'function') {
  349. callback = options;
  350. options = {};
  351. }
  352. this.options = options;
  353. var self = this;
  354. function done(value) {
  355. if (callback) {
  356. setTimeout(function () {
  357. callback(undefined, value);
  358. }, 0);
  359. return true;
  360. } else {
  361. return value;
  362. }
  363. } // Allow subclasses to massage the input prior to running
  364. oldString = this.castInput(oldString);
  365. newString = this.castInput(newString);
  366. oldString = this.removeEmpty(this.tokenize(oldString));
  367. newString = this.removeEmpty(this.tokenize(newString));
  368. var newLen = newString.length,
  369. oldLen = oldString.length;
  370. var editLength = 1;
  371. var maxEditLength = newLen + oldLen;
  372. var bestPath = [{
  373. newPos: -1,
  374. components: []
  375. }]; // Seed editLength = 0, i.e. the content starts with the same values
  376. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  377. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  378. // Identity per the equality and tokenizer
  379. return done([{
  380. value: this.join(newString),
  381. count: newString.length
  382. }]);
  383. } // Main worker method. checks all permutations of a given edit length for acceptance.
  384. function execEditLength() {
  385. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  386. var basePath =
  387. /*istanbul ignore start*/
  388. void 0
  389. /*istanbul ignore end*/
  390. ;
  391. var addPath = bestPath[diagonalPath - 1],
  392. removePath = bestPath[diagonalPath + 1],
  393. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  394. if (addPath) {
  395. // No one else is going to attempt to use this value, clear it
  396. bestPath[diagonalPath - 1] = undefined;
  397. }
  398. var canAdd = addPath && addPath.newPos + 1 < newLen,
  399. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  400. if (!canAdd && !canRemove) {
  401. // If this path is a terminal then prune
  402. bestPath[diagonalPath] = undefined;
  403. continue;
  404. } // Select the diagonal that we want to branch from. We select the prior
  405. // path whose position in the new string is the farthest from the origin
  406. // and does not pass the bounds of the diff graph
  407. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  408. basePath = clonePath(removePath);
  409. self.pushComponent(basePath.components, undefined, true);
  410. } else {
  411. basePath = addPath; // No need to clone, we've pulled it from the list
  412. basePath.newPos++;
  413. self.pushComponent(basePath.components, true, undefined);
  414. }
  415. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  416. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  417. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  418. } else {
  419. // Otherwise track this path as a potential candidate and continue.
  420. bestPath[diagonalPath] = basePath;
  421. }
  422. }
  423. editLength++;
  424. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  425. // sync and async mode which is never fun. Loops over execEditLength until a value
  426. // is produced.
  427. if (callback) {
  428. (function exec() {
  429. setTimeout(function () {
  430. // This should not happen, but we want to be safe.
  431. /* istanbul ignore next */
  432. if (editLength > maxEditLength) {
  433. return callback();
  434. }
  435. if (!execEditLength()) {
  436. exec();
  437. }
  438. }, 0);
  439. })();
  440. } else {
  441. while (editLength <= maxEditLength) {
  442. var ret = execEditLength();
  443. if (ret) {
  444. return ret;
  445. }
  446. }
  447. }
  448. },
  449. /*istanbul ignore start*/
  450. /*istanbul ignore end*/
  451. pushComponent: function pushComponent(components, added, removed) {
  452. var last = components[components.length - 1];
  453. if (last && last.added === added && last.removed === removed) {
  454. // We need to clone here as the component clone operation is just
  455. // as shallow array clone
  456. components[components.length - 1] = {
  457. count: last.count + 1,
  458. added: added,
  459. removed: removed
  460. };
  461. } else {
  462. components.push({
  463. count: 1,
  464. added: added,
  465. removed: removed
  466. });
  467. }
  468. },
  469. /*istanbul ignore start*/
  470. /*istanbul ignore end*/
  471. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  472. var newLen = newString.length,
  473. oldLen = oldString.length,
  474. newPos = basePath.newPos,
  475. oldPos = newPos - diagonalPath,
  476. commonCount = 0;
  477. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  478. newPos++;
  479. oldPos++;
  480. commonCount++;
  481. }
  482. if (commonCount) {
  483. basePath.components.push({
  484. count: commonCount
  485. });
  486. }
  487. basePath.newPos = newPos;
  488. return oldPos;
  489. },
  490. /*istanbul ignore start*/
  491. /*istanbul ignore end*/
  492. equals: function equals(left, right) {
  493. if (this.options.comparator) {
  494. return this.options.comparator(left, right);
  495. } else {
  496. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  497. }
  498. },
  499. /*istanbul ignore start*/
  500. /*istanbul ignore end*/
  501. removeEmpty: function removeEmpty(array) {
  502. var ret = [];
  503. for (var i = 0; i < array.length; i++) {
  504. if (array[i]) {
  505. ret.push(array[i]);
  506. }
  507. }
  508. return ret;
  509. },
  510. /*istanbul ignore start*/
  511. /*istanbul ignore end*/
  512. castInput: function castInput(value) {
  513. return value;
  514. },
  515. /*istanbul ignore start*/
  516. /*istanbul ignore end*/
  517. tokenize: function tokenize(value) {
  518. return value.split('');
  519. },
  520. /*istanbul ignore start*/
  521. /*istanbul ignore end*/
  522. join: function join(chars) {
  523. return chars.join('');
  524. }
  525. };
  526. function buildValues(diff, components, newString, oldString, useLongestToken) {
  527. var componentPos = 0,
  528. componentLen = components.length,
  529. newPos = 0,
  530. oldPos = 0;
  531. for (; componentPos < componentLen; componentPos++) {
  532. var component = components[componentPos];
  533. if (!component.removed) {
  534. if (!component.added && useLongestToken) {
  535. var value = newString.slice(newPos, newPos + component.count);
  536. value = value.map(function (value, i) {
  537. var oldValue = oldString[oldPos + i];
  538. return oldValue.length > value.length ? oldValue : value;
  539. });
  540. component.value = diff.join(value);
  541. } else {
  542. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  543. }
  544. newPos += component.count; // Common case
  545. if (!component.added) {
  546. oldPos += component.count;
  547. }
  548. } else {
  549. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  550. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  551. // The diffing algorithm is tied to add then remove output and this is the simplest
  552. // route to get the desired output with minimal overhead.
  553. if (componentPos && components[componentPos - 1].added) {
  554. var tmp = components[componentPos - 1];
  555. components[componentPos - 1] = components[componentPos];
  556. components[componentPos] = tmp;
  557. }
  558. }
  559. } // Special case handle for when one terminal is ignored (i.e. whitespace).
  560. // For this case we merge the terminal into the prior string and drop the change.
  561. // This is only available for string mode.
  562. var lastComponent = components[componentLen - 1];
  563. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  564. components[componentLen - 2].value += lastComponent.value;
  565. components.pop();
  566. }
  567. return components;
  568. }
  569. function clonePath(path) {
  570. return {
  571. newPos: path.newPos,
  572. components: path.components.slice(0)
  573. };
  574. }
  575. /***/ }),
  576. /***/ 1973:
  577. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  578. "use strict";
  579. var __webpack_unused_export__;
  580. /*istanbul ignore start*/
  581. __webpack_unused_export__ = ({
  582. value: true
  583. });
  584. exports.Kx = diffChars;
  585. __webpack_unused_export__ = void 0;
  586. /*istanbul ignore end*/
  587. var
  588. /*istanbul ignore start*/
  589. _base = _interopRequireDefault(__webpack_require__(1198))
  590. /*istanbul ignore end*/
  591. ;
  592. /*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  593. /*istanbul ignore end*/
  594. var characterDiff = new
  595. /*istanbul ignore start*/
  596. _base
  597. /*istanbul ignore end*/
  598. .
  599. /*istanbul ignore start*/
  600. default
  601. /*istanbul ignore end*/
  602. ();
  603. /*istanbul ignore start*/
  604. __webpack_unused_export__ = characterDiff;
  605. /*istanbul ignore end*/
  606. function diffChars(oldStr, newStr, options) {
  607. return characterDiff.diff(oldStr, newStr, options);
  608. }
  609. /***/ }),
  610. /***/ 1345:
  611. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  612. "use strict";
  613. var util = __webpack_require__(5022);
  614. function scrollIntoView(elem, container, config) {
  615. config = config || {};
  616. // document 归一化到 window
  617. if (container.nodeType === 9) {
  618. container = util.getWindow(container);
  619. }
  620. var allowHorizontalScroll = config.allowHorizontalScroll;
  621. var onlyScrollIfNeeded = config.onlyScrollIfNeeded;
  622. var alignWithTop = config.alignWithTop;
  623. var alignWithLeft = config.alignWithLeft;
  624. var offsetTop = config.offsetTop || 0;
  625. var offsetLeft = config.offsetLeft || 0;
  626. var offsetBottom = config.offsetBottom || 0;
  627. var offsetRight = config.offsetRight || 0;
  628. allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll;
  629. var isWin = util.isWindow(container);
  630. var elemOffset = util.offset(elem);
  631. var eh = util.outerHeight(elem);
  632. var ew = util.outerWidth(elem);
  633. var containerOffset = undefined;
  634. var ch = undefined;
  635. var cw = undefined;
  636. var containerScroll = undefined;
  637. var diffTop = undefined;
  638. var diffBottom = undefined;
  639. var win = undefined;
  640. var winScroll = undefined;
  641. var ww = undefined;
  642. var wh = undefined;
  643. if (isWin) {
  644. win = container;
  645. wh = util.height(win);
  646. ww = util.width(win);
  647. winScroll = {
  648. left: util.scrollLeft(win),
  649. top: util.scrollTop(win)
  650. };
  651. // elem 相对 container 可视视窗的距离
  652. diffTop = {
  653. left: elemOffset.left - winScroll.left - offsetLeft,
  654. top: elemOffset.top - winScroll.top - offsetTop
  655. };
  656. diffBottom = {
  657. left: elemOffset.left + ew - (winScroll.left + ww) + offsetRight,
  658. top: elemOffset.top + eh - (winScroll.top + wh) + offsetBottom
  659. };
  660. containerScroll = winScroll;
  661. } else {
  662. containerOffset = util.offset(container);
  663. ch = container.clientHeight;
  664. cw = container.clientWidth;
  665. containerScroll = {
  666. left: container.scrollLeft,
  667. top: container.scrollTop
  668. };
  669. // elem 相对 container 可视视窗的距离
  670. // 注意边框, offset 是边框到根节点
  671. diffTop = {
  672. left: elemOffset.left - (containerOffset.left + (parseFloat(util.css(container, 'borderLeftWidth')) || 0)) - offsetLeft,
  673. top: elemOffset.top - (containerOffset.top + (parseFloat(util.css(container, 'borderTopWidth')) || 0)) - offsetTop
  674. };
  675. diffBottom = {
  676. left: elemOffset.left + ew - (containerOffset.left + cw + (parseFloat(util.css(container, 'borderRightWidth')) || 0)) + offsetRight,
  677. top: elemOffset.top + eh - (containerOffset.top + ch + (parseFloat(util.css(container, 'borderBottomWidth')) || 0)) + offsetBottom
  678. };
  679. }
  680. if (diffTop.top < 0 || diffBottom.top > 0) {
  681. // 强制向上
  682. if (alignWithTop === true) {
  683. util.scrollTop(container, containerScroll.top + diffTop.top);
  684. } else if (alignWithTop === false) {
  685. util.scrollTop(container, containerScroll.top + diffBottom.top);
  686. } else {
  687. // 自动调整
  688. if (diffTop.top < 0) {
  689. util.scrollTop(container, containerScroll.top + diffTop.top);
  690. } else {
  691. util.scrollTop(container, containerScroll.top + diffBottom.top);
  692. }
  693. }
  694. } else {
  695. if (!onlyScrollIfNeeded) {
  696. alignWithTop = alignWithTop === undefined ? true : !!alignWithTop;
  697. if (alignWithTop) {
  698. util.scrollTop(container, containerScroll.top + diffTop.top);
  699. } else {
  700. util.scrollTop(container, containerScroll.top + diffBottom.top);
  701. }
  702. }
  703. }
  704. if (allowHorizontalScroll) {
  705. if (diffTop.left < 0 || diffBottom.left > 0) {
  706. // 强制向上
  707. if (alignWithLeft === true) {
  708. util.scrollLeft(container, containerScroll.left + diffTop.left);
  709. } else if (alignWithLeft === false) {
  710. util.scrollLeft(container, containerScroll.left + diffBottom.left);
  711. } else {
  712. // 自动调整
  713. if (diffTop.left < 0) {
  714. util.scrollLeft(container, containerScroll.left + diffTop.left);
  715. } else {
  716. util.scrollLeft(container, containerScroll.left + diffBottom.left);
  717. }
  718. }
  719. } else {
  720. if (!onlyScrollIfNeeded) {
  721. alignWithLeft = alignWithLeft === undefined ? true : !!alignWithLeft;
  722. if (alignWithLeft) {
  723. util.scrollLeft(container, containerScroll.left + diffTop.left);
  724. } else {
  725. util.scrollLeft(container, containerScroll.left + diffBottom.left);
  726. }
  727. }
  728. }
  729. }
  730. }
  731. module.exports = scrollIntoView;
  732. /***/ }),
  733. /***/ 5425:
  734. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  735. "use strict";
  736. module.exports = __webpack_require__(1345);
  737. /***/ }),
  738. /***/ 5022:
  739. /***/ (function(module) {
  740. "use strict";
  741. 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; };
  742. 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; };
  743. var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source;
  744. function getClientPosition(elem) {
  745. var box = undefined;
  746. var x = undefined;
  747. var y = undefined;
  748. var doc = elem.ownerDocument;
  749. var body = doc.body;
  750. var docElem = doc && doc.documentElement;
  751. // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式
  752. box = elem.getBoundingClientRect();
  753. // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop
  754. // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确
  755. // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin
  756. x = box.left;
  757. y = box.top;
  758. // In IE, most of the time, 2 extra pixels are added to the top and left
  759. // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and
  760. // IE6 standards mode, this border can be overridden by setting the
  761. // document element's border to zero -- thus, we cannot rely on the
  762. // offset always being 2 pixels.
  763. // In quirks mode, the offset can be determined by querying the body's
  764. // clientLeft/clientTop, but in standards mode, it is found by querying
  765. // the document element's clientLeft/clientTop. Since we already called
  766. // getClientBoundingRect we have already forced a reflow, so it is not
  767. // too expensive just to query them all.
  768. // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的
  769. // 窗口边框标准是设 documentElement ,quirks 时设置 body
  770. // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去
  771. // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置
  772. // 标准 ie 下 docElem.clientTop 就是 border-top
  773. // ie7 html 即窗口边框改变不了。永远为 2
  774. // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0
  775. x -= docElem.clientLeft || body.clientLeft || 0;
  776. y -= docElem.clientTop || body.clientTop || 0;
  777. return {
  778. left: x,
  779. top: y
  780. };
  781. }
  782. function getScroll(w, top) {
  783. var ret = w['page' + (top ? 'Y' : 'X') + 'Offset'];
  784. var method = 'scroll' + (top ? 'Top' : 'Left');
  785. if (typeof ret !== 'number') {
  786. var d = w.document;
  787. // ie6,7,8 standard mode
  788. ret = d.documentElement[method];
  789. if (typeof ret !== 'number') {
  790. // quirks mode
  791. ret = d.body[method];
  792. }
  793. }
  794. return ret;
  795. }
  796. function getScrollLeft(w) {
  797. return getScroll(w);
  798. }
  799. function getScrollTop(w) {
  800. return getScroll(w, true);
  801. }
  802. function getOffset(el) {
  803. var pos = getClientPosition(el);
  804. var doc = el.ownerDocument;
  805. var w = doc.defaultView || doc.parentWindow;
  806. pos.left += getScrollLeft(w);
  807. pos.top += getScrollTop(w);
  808. return pos;
  809. }
  810. function _getComputedStyle(elem, name, computedStyle_) {
  811. var val = '';
  812. var d = elem.ownerDocument;
  813. var computedStyle = computedStyle_ || d.defaultView.getComputedStyle(elem, null);
  814. // https://github.com/kissyteam/kissy/issues/61
  815. if (computedStyle) {
  816. val = computedStyle.getPropertyValue(name) || computedStyle[name];
  817. }
  818. return val;
  819. }
  820. var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i');
  821. var RE_POS = /^(top|right|bottom|left)$/;
  822. var CURRENT_STYLE = 'currentStyle';
  823. var RUNTIME_STYLE = 'runtimeStyle';
  824. var LEFT = 'left';
  825. var PX = 'px';
  826. function _getComputedStyleIE(elem, name) {
  827. // currentStyle maybe null
  828. // http://msdn.microsoft.com/en-us/library/ms535231.aspx
  829. var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name];
  830. // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值
  831. // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19
  832. // 在 ie 下不对,需要直接用 offset 方式
  833. // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了
  834. // From the awesome hack by Dean Edwards
  835. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  836. // If we're not dealing with a regular pixel number
  837. // but a number that has a weird ending, we need to convert it to pixels
  838. // exclude left right for relativity
  839. if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {
  840. // Remember the original values
  841. var style = elem.style;
  842. var left = style[LEFT];
  843. var rsLeft = elem[RUNTIME_STYLE][LEFT];
  844. // prevent flashing of content
  845. elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT];
  846. // Put in the new values to get a computed value out
  847. style[LEFT] = name === 'fontSize' ? '1em' : ret || 0;
  848. ret = style.pixelLeft + PX;
  849. // Revert the changed values
  850. style[LEFT] = left;
  851. elem[RUNTIME_STYLE][LEFT] = rsLeft;
  852. }
  853. return ret === '' ? 'auto' : ret;
  854. }
  855. var getComputedStyleX = undefined;
  856. if (typeof window !== 'undefined') {
  857. getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;
  858. }
  859. function each(arr, fn) {
  860. for (var i = 0; i < arr.length; i++) {
  861. fn(arr[i]);
  862. }
  863. }
  864. function isBorderBoxFn(elem) {
  865. return getComputedStyleX(elem, 'boxSizing') === 'border-box';
  866. }
  867. var BOX_MODELS = ['margin', 'border', 'padding'];
  868. var CONTENT_INDEX = -1;
  869. var PADDING_INDEX = 2;
  870. var BORDER_INDEX = 1;
  871. var MARGIN_INDEX = 0;
  872. function swap(elem, options, callback) {
  873. var old = {};
  874. var style = elem.style;
  875. var name = undefined;
  876. // Remember the old values, and insert the new ones
  877. for (name in options) {
  878. if (options.hasOwnProperty(name)) {
  879. old[name] = style[name];
  880. style[name] = options[name];
  881. }
  882. }
  883. callback.call(elem);
  884. // Revert the old values
  885. for (name in options) {
  886. if (options.hasOwnProperty(name)) {
  887. style[name] = old[name];
  888. }
  889. }
  890. }
  891. function getPBMWidth(elem, props, which) {
  892. var value = 0;
  893. var prop = undefined;
  894. var j = undefined;
  895. var i = undefined;
  896. for (j = 0; j < props.length; j++) {
  897. prop = props[j];
  898. if (prop) {
  899. for (i = 0; i < which.length; i++) {
  900. var cssProp = undefined;
  901. if (prop === 'border') {
  902. cssProp = prop + which[i] + 'Width';
  903. } else {
  904. cssProp = prop + which[i];
  905. }
  906. value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;
  907. }
  908. }
  909. }
  910. return value;
  911. }
  912. /**
  913. * A crude way of determining if an object is a window
  914. * @member util
  915. */
  916. function isWindow(obj) {
  917. // must use == for ie8
  918. /* eslint eqeqeq:0 */
  919. return obj != null && obj == obj.window;
  920. }
  921. var domUtils = {};
  922. each(['Width', 'Height'], function (name) {
  923. domUtils['doc' + name] = function (refWin) {
  924. var d = refWin.document;
  925. return Math.max(
  926. // firefox chrome documentElement.scrollHeight< body.scrollHeight
  927. // ie standard mode : documentElement.scrollHeight> body.scrollHeight
  928. d.documentElement['scroll' + name],
  929. // quirks : documentElement.scrollHeight 最大等于可视窗口多一点?
  930. d.body['scroll' + name], domUtils['viewport' + name](d));
  931. };
  932. domUtils['viewport' + name] = function (win) {
  933. // pc browser includes scrollbar in window.innerWidth
  934. var prop = 'client' + name;
  935. var doc = win.document;
  936. var body = doc.body;
  937. var documentElement = doc.documentElement;
  938. var documentElementProp = documentElement[prop];
  939. // 标准模式取 documentElement
  940. // backcompat 取 body
  941. return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp;
  942. };
  943. });
  944. /*
  945. 得到元素的大小信息
  946. @param elem
  947. @param name
  948. @param {String} [extra] 'padding' : (css width) + padding
  949. 'border' : (css width) + padding + border
  950. 'margin' : (css width) + padding + border + margin
  951. */
  952. function getWH(elem, name, extra) {
  953. if (isWindow(elem)) {
  954. return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);
  955. } else if (elem.nodeType === 9) {
  956. return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);
  957. }
  958. var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
  959. var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight;
  960. var computedStyle = getComputedStyleX(elem);
  961. var isBorderBox = isBorderBoxFn(elem, computedStyle);
  962. var cssBoxValue = 0;
  963. if (borderBoxValue == null || borderBoxValue <= 0) {
  964. borderBoxValue = undefined;
  965. // Fall back to computed then un computed css if necessary
  966. cssBoxValue = getComputedStyleX(elem, name);
  967. if (cssBoxValue == null || Number(cssBoxValue) < 0) {
  968. cssBoxValue = elem.style[name] || 0;
  969. }
  970. // Normalize '', auto, and prepare for extra
  971. cssBoxValue = parseFloat(cssBoxValue) || 0;
  972. }
  973. if (extra === undefined) {
  974. extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;
  975. }
  976. var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;
  977. var val = borderBoxValue || cssBoxValue;
  978. if (extra === CONTENT_INDEX) {
  979. if (borderBoxValueOrIsBorderBox) {
  980. return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle);
  981. }
  982. return cssBoxValue;
  983. }
  984. if (borderBoxValueOrIsBorderBox) {
  985. var padding = extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle);
  986. return val + (extra === BORDER_INDEX ? 0 : padding);
  987. }
  988. return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle);
  989. }
  990. var cssShow = {
  991. position: 'absolute',
  992. visibility: 'hidden',
  993. display: 'block'
  994. };
  995. // fix #119 : https://github.com/kissyteam/kissy/issues/119
  996. function getWHIgnoreDisplay(elem) {
  997. var val = undefined;
  998. var args = arguments;
  999. // in case elem is window
  1000. // elem.offsetWidth === undefined
  1001. if (elem.offsetWidth !== 0) {
  1002. val = getWH.apply(undefined, args);
  1003. } else {
  1004. swap(elem, cssShow, function () {
  1005. val = getWH.apply(undefined, args);
  1006. });
  1007. }
  1008. return val;
  1009. }
  1010. function css(el, name, v) {
  1011. var value = v;
  1012. if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
  1013. for (var i in name) {
  1014. if (name.hasOwnProperty(i)) {
  1015. css(el, i, name[i]);
  1016. }
  1017. }
  1018. return undefined;
  1019. }
  1020. if (typeof value !== 'undefined') {
  1021. if (typeof value === 'number') {
  1022. value += 'px';
  1023. }
  1024. el.style[name] = value;
  1025. return undefined;
  1026. }
  1027. return getComputedStyleX(el, name);
  1028. }
  1029. each(['width', 'height'], function (name) {
  1030. var first = name.charAt(0).toUpperCase() + name.slice(1);
  1031. domUtils['outer' + first] = function (el, includeMargin) {
  1032. return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);
  1033. };
  1034. var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
  1035. domUtils[name] = function (elem, val) {
  1036. if (val !== undefined) {
  1037. if (elem) {
  1038. var computedStyle = getComputedStyleX(elem);
  1039. var isBorderBox = isBorderBoxFn(elem);
  1040. if (isBorderBox) {
  1041. val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle);
  1042. }
  1043. return css(elem, name, val);
  1044. }
  1045. return undefined;
  1046. }
  1047. return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);
  1048. };
  1049. });
  1050. // 设置 elem 相对 elem.ownerDocument 的坐标
  1051. function setOffset(elem, offset) {
  1052. // set position first, in-case top/left are set even on static elem
  1053. if (css(elem, 'position') === 'static') {
  1054. elem.style.position = 'relative';
  1055. }
  1056. var old = getOffset(elem);
  1057. var ret = {};
  1058. var current = undefined;
  1059. var key = undefined;
  1060. for (key in offset) {
  1061. if (offset.hasOwnProperty(key)) {
  1062. current = parseFloat(css(elem, key)) || 0;
  1063. ret[key] = current + offset[key] - old[key];
  1064. }
  1065. }
  1066. css(elem, ret);
  1067. }
  1068. module.exports = _extends({
  1069. getWindow: function getWindow(node) {
  1070. var doc = node.ownerDocument || node;
  1071. return doc.defaultView || doc.parentWindow;
  1072. },
  1073. offset: function offset(el, value) {
  1074. if (typeof value !== 'undefined') {
  1075. setOffset(el, value);
  1076. } else {
  1077. return getOffset(el);
  1078. }
  1079. },
  1080. isWindow: isWindow,
  1081. each: each,
  1082. css: css,
  1083. clone: function clone(obj) {
  1084. var ret = {};
  1085. for (var i in obj) {
  1086. if (obj.hasOwnProperty(i)) {
  1087. ret[i] = obj[i];
  1088. }
  1089. }
  1090. var overflow = obj.overflow;
  1091. if (overflow) {
  1092. for (var i in obj) {
  1093. if (obj.hasOwnProperty(i)) {
  1094. ret.overflow[i] = obj.overflow[i];
  1095. }
  1096. }
  1097. }
  1098. return ret;
  1099. },
  1100. scrollLeft: function scrollLeft(w, v) {
  1101. if (isWindow(w)) {
  1102. if (v === undefined) {
  1103. return getScrollLeft(w);
  1104. }
  1105. window.scrollTo(v, getScrollTop(w));
  1106. } else {
  1107. if (v === undefined) {
  1108. return w.scrollLeft;
  1109. }
  1110. w.scrollLeft = v;
  1111. }
  1112. },
  1113. scrollTop: function scrollTop(w, v) {
  1114. if (isWindow(w)) {
  1115. if (v === undefined) {
  1116. return getScrollTop(w);
  1117. }
  1118. window.scrollTo(getScrollLeft(w), v);
  1119. } else {
  1120. if (v === undefined) {
  1121. return w.scrollTop;
  1122. }
  1123. w.scrollTop = v;
  1124. }
  1125. },
  1126. viewportWidth: 0,
  1127. viewportHeight: 0
  1128. }, domUtils);
  1129. /***/ }),
  1130. /***/ 8575:
  1131. /***/ (function(module) {
  1132. if (typeof Object.create === 'function') {
  1133. // implementation from standard node.js 'util' module
  1134. module.exports = function inherits(ctor, superCtor) {
  1135. if (superCtor) {
  1136. ctor.super_ = superCtor
  1137. ctor.prototype = Object.create(superCtor.prototype, {
  1138. constructor: {
  1139. value: ctor,
  1140. enumerable: false,
  1141. writable: true,
  1142. configurable: true
  1143. }
  1144. })
  1145. }
  1146. };
  1147. } else {
  1148. // old school shim for old browsers
  1149. module.exports = function inherits(ctor, superCtor) {
  1150. if (superCtor) {
  1151. ctor.super_ = superCtor
  1152. var TempCtor = function () {}
  1153. TempCtor.prototype = superCtor.prototype
  1154. ctor.prototype = new TempCtor()
  1155. ctor.prototype.constructor = ctor
  1156. }
  1157. }
  1158. }
  1159. /***/ }),
  1160. /***/ 9894:
  1161. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1162. // Load in dependencies
  1163. var computedStyle = __webpack_require__(4827);
  1164. /**
  1165. * Calculate the `line-height` of a given node
  1166. * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.
  1167. * @returns {Number} `line-height` of the element in pixels
  1168. */
  1169. function lineHeight(node) {
  1170. // Grab the line-height via style
  1171. var lnHeightStr = computedStyle(node, 'line-height');
  1172. var lnHeight = parseFloat(lnHeightStr, 10);
  1173. // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')
  1174. if (lnHeightStr === lnHeight + '') {
  1175. // Save the old lineHeight style and update the em unit to the element
  1176. var _lnHeightStyle = node.style.lineHeight;
  1177. node.style.lineHeight = lnHeightStr + 'em';
  1178. // Calculate the em based height
  1179. lnHeightStr = computedStyle(node, 'line-height');
  1180. lnHeight = parseFloat(lnHeightStr, 10);
  1181. // Revert the lineHeight style
  1182. if (_lnHeightStyle) {
  1183. node.style.lineHeight = _lnHeightStyle;
  1184. } else {
  1185. delete node.style.lineHeight;
  1186. }
  1187. }
  1188. // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt)
  1189. // DEV: `em` units are converted to `pt` in IE6
  1190. // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length
  1191. if (lnHeightStr.indexOf('pt') !== -1) {
  1192. lnHeight *= 4;
  1193. lnHeight /= 3;
  1194. // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
  1195. } else if (lnHeightStr.indexOf('mm') !== -1) {
  1196. lnHeight *= 96;
  1197. lnHeight /= 25.4;
  1198. // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
  1199. } else if (lnHeightStr.indexOf('cm') !== -1) {
  1200. lnHeight *= 96;
  1201. lnHeight /= 2.54;
  1202. // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
  1203. } else if (lnHeightStr.indexOf('in') !== -1) {
  1204. lnHeight *= 96;
  1205. // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
  1206. } else if (lnHeightStr.indexOf('pc') !== -1) {
  1207. lnHeight *= 16;
  1208. }
  1209. // Continue our computation
  1210. lnHeight = Math.round(lnHeight);
  1211. // If the line-height is "normal", calculate by font-size
  1212. if (lnHeightStr === 'normal') {
  1213. // Create a temporary node
  1214. var nodeName = node.nodeName;
  1215. var _node = document.createElement(nodeName);
  1216. _node.innerHTML = '&nbsp;';
  1217. // If we have a text area, reset it to only 1 row
  1218. // https://github.com/twolfson/line-height/issues/4
  1219. if (nodeName.toUpperCase() === 'TEXTAREA') {
  1220. _node.setAttribute('rows', '1');
  1221. }
  1222. // Set the font-size of the element
  1223. var fontSizeStr = computedStyle(node, 'font-size');
  1224. _node.style.fontSize = fontSizeStr;
  1225. // Remove default padding/border which can affect offset height
  1226. // https://github.com/twolfson/line-height/issues/4
  1227. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
  1228. _node.style.padding = '0px';
  1229. _node.style.border = '0px';
  1230. // Append it to the body
  1231. var body = document.body;
  1232. body.appendChild(_node);
  1233. // Assume the line height of the element is the height
  1234. var height = _node.offsetHeight;
  1235. lnHeight = height;
  1236. // Remove our child from the DOM
  1237. body.removeChild(_node);
  1238. }
  1239. // Return the calculated height
  1240. return lnHeight;
  1241. }
  1242. // Export lineHeight
  1243. module.exports = lineHeight;
  1244. /***/ }),
  1245. /***/ 7970:
  1246. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1247. module.exports = __webpack_require__(195);
  1248. /***/ }),
  1249. /***/ 3110:
  1250. /***/ (function(module) {
  1251. "use strict";
  1252. /**
  1253. * Copyright (c) 2015, Facebook, Inc.
  1254. * All rights reserved.
  1255. *
  1256. * This source code is licensed under the BSD-style license found in the
  1257. * LICENSE file in the root directory of this source tree. An additional grant
  1258. * of patent rights can be found in the PATENTS file in the same directory.
  1259. *
  1260. * @providesModule ExecutionEnvironment
  1261. */
  1262. /*jslint evil: true */
  1263. var canUseDOM = !!(
  1264. typeof window !== 'undefined' &&
  1265. window.document &&
  1266. window.document.createElement
  1267. );
  1268. /**
  1269. * Simple, lightweight module assisting with the detection and context of
  1270. * Worker. Helps avoid circular dependencies and allows code to reason about
  1271. * whether or not they are in a Worker, even if they never include the main
  1272. * `ReactWorker` dependency.
  1273. */
  1274. var ExecutionEnvironment = {
  1275. canUseDOM: canUseDOM,
  1276. canUseWorkers: typeof Worker !== 'undefined',
  1277. canUseEventListeners:
  1278. canUseDOM && !!(window.addEventListener || window.attachEvent),
  1279. canUseViewport: canUseDOM && !!window.screen,
  1280. isInWorker: !canUseDOM // For now, this is true - might change in the future.
  1281. };
  1282. module.exports = ExecutionEnvironment;
  1283. /***/ }),
  1284. /***/ 3812:
  1285. /***/ (function(module) {
  1286. /**
  1287. * Copyright 2004-present Facebook. All Rights Reserved.
  1288. *
  1289. * @providesModule UserAgent_DEPRECATED
  1290. */
  1291. /**
  1292. * Provides entirely client-side User Agent and OS detection. You should prefer
  1293. * the non-deprecated UserAgent module when possible, which exposes our
  1294. * authoritative server-side PHP-based detection to the client.
  1295. *
  1296. * Usage is straightforward:
  1297. *
  1298. * if (UserAgent_DEPRECATED.ie()) {
  1299. * // IE
  1300. * }
  1301. *
  1302. * You can also do version checks:
  1303. *
  1304. * if (UserAgent_DEPRECATED.ie() >= 7) {
  1305. * // IE7 or better
  1306. * }
  1307. *
  1308. * The browser functions will return NaN if the browser does not match, so
  1309. * you can also do version compares the other way:
  1310. *
  1311. * if (UserAgent_DEPRECATED.ie() < 7) {
  1312. * // IE6 or worse
  1313. * }
  1314. *
  1315. * Note that the version is a float and may include a minor version number,
  1316. * so you should always use range operators to perform comparisons, not
  1317. * strict equality.
  1318. *
  1319. * **Note:** You should **strongly** prefer capability detection to browser
  1320. * version detection where it's reasonable:
  1321. *
  1322. * http://www.quirksmode.org/js/support.html
  1323. *
  1324. * Further, we have a large number of mature wrapper functions and classes
  1325. * which abstract away many browser irregularities. Check the documentation,
  1326. * grep for things, or ask on javascript@lists.facebook.com before writing yet
  1327. * another copy of "event || window.event".
  1328. *
  1329. */
  1330. var _populated = false;
  1331. // Browsers
  1332. var _ie, _firefox, _opera, _webkit, _chrome;
  1333. // Actual IE browser for compatibility mode
  1334. var _ie_real_version;
  1335. // Platforms
  1336. var _osx, _windows, _linux, _android;
  1337. // Architectures
  1338. var _win64;
  1339. // Devices
  1340. var _iphone, _ipad, _native;
  1341. var _mobile;
  1342. function _populate() {
  1343. if (_populated) {
  1344. return;
  1345. }
  1346. _populated = true;
  1347. // To work around buggy JS libraries that can't handle multi-digit
  1348. // version numbers, Opera 10's user agent string claims it's Opera
  1349. // 9, then later includes a Version/X.Y field:
  1350. //
  1351. // Opera/9.80 (foo) Presto/2.2.15 Version/10.10
  1352. var uas = navigator.userAgent;
  1353. 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);
  1354. var os = /(Mac OS X)|(Windows)|(Linux)/.exec(uas);
  1355. _iphone = /\b(iPhone|iP[ao]d)/.exec(uas);
  1356. _ipad = /\b(iP[ao]d)/.exec(uas);
  1357. _android = /Android/i.exec(uas);
  1358. _native = /FBAN\/\w+;/i.exec(uas);
  1359. _mobile = /Mobile/i.exec(uas);
  1360. // Note that the IE team blog would have you believe you should be checking
  1361. // for 'Win64; x64'. But MSDN then reveals that you can actually be coming
  1362. // from either x64 or ia64; so ultimately, you should just check for Win64
  1363. // as in indicator of whether you're in 64-bit IE. 32-bit IE on 64-bit
  1364. // Windows will send 'WOW64' instead.
  1365. _win64 = !!(/Win64/.exec(uas));
  1366. if (agent) {
  1367. _ie = agent[1] ? parseFloat(agent[1]) : (
  1368. agent[5] ? parseFloat(agent[5]) : NaN);
  1369. // IE compatibility mode
  1370. if (_ie && document && document.documentMode) {
  1371. _ie = document.documentMode;
  1372. }
  1373. // grab the "true" ie version from the trident token if available
  1374. var trident = /(?:Trident\/(\d+.\d+))/.exec(uas);
  1375. _ie_real_version = trident ? parseFloat(trident[1]) + 4 : _ie;
  1376. _firefox = agent[2] ? parseFloat(agent[2]) : NaN;
  1377. _opera = agent[3] ? parseFloat(agent[3]) : NaN;
  1378. _webkit = agent[4] ? parseFloat(agent[4]) : NaN;
  1379. if (_webkit) {
  1380. // We do not add the regexp to the above test, because it will always
  1381. // match 'safari' only since 'AppleWebKit' appears before 'Chrome' in
  1382. // the userAgent string.
  1383. agent = /(?:Chrome\/(\d+\.\d+))/.exec(uas);
  1384. _chrome = agent && agent[1] ? parseFloat(agent[1]) : NaN;
  1385. } else {
  1386. _chrome = NaN;
  1387. }
  1388. } else {
  1389. _ie = _firefox = _opera = _chrome = _webkit = NaN;
  1390. }
  1391. if (os) {
  1392. if (os[1]) {
  1393. // Detect OS X version. If no version number matches, set _osx to true.
  1394. // Version examples: 10, 10_6_1, 10.7
  1395. // Parses version number as a float, taking only first two sets of
  1396. // digits. If only one set of digits is found, returns just the major
  1397. // version number.
  1398. var ver = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(uas);
  1399. _osx = ver ? parseFloat(ver[1].replace('_', '.')) : true;
  1400. } else {
  1401. _osx = false;
  1402. }
  1403. _windows = !!os[2];
  1404. _linux = !!os[3];
  1405. } else {
  1406. _osx = _windows = _linux = false;
  1407. }
  1408. }
  1409. var UserAgent_DEPRECATED = {
  1410. /**
  1411. * Check if the UA is Internet Explorer.
  1412. *
  1413. *
  1414. * @return float|NaN Version number (if match) or NaN.
  1415. */
  1416. ie: function() {
  1417. return _populate() || _ie;
  1418. },
  1419. /**
  1420. * Check if we're in Internet Explorer compatibility mode.
  1421. *
  1422. * @return bool true if in compatibility mode, false if
  1423. * not compatibility mode or not ie
  1424. */
  1425. ieCompatibilityMode: function() {
  1426. return _populate() || (_ie_real_version > _ie);
  1427. },
  1428. /**
  1429. * Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we
  1430. * only need this because Skype can't handle 64-bit IE yet. We need to remove
  1431. * this when we don't need it -- tracked by #601957.
  1432. */
  1433. ie64: function() {
  1434. return UserAgent_DEPRECATED.ie() && _win64;
  1435. },
  1436. /**
  1437. * Check if the UA is Firefox.
  1438. *
  1439. *
  1440. * @return float|NaN Version number (if match) or NaN.
  1441. */
  1442. firefox: function() {
  1443. return _populate() || _firefox;
  1444. },
  1445. /**
  1446. * Check if the UA is Opera.
  1447. *
  1448. *
  1449. * @return float|NaN Version number (if match) or NaN.
  1450. */
  1451. opera: function() {
  1452. return _populate() || _opera;
  1453. },
  1454. /**
  1455. * Check if the UA is WebKit.
  1456. *
  1457. *
  1458. * @return float|NaN Version number (if match) or NaN.
  1459. */
  1460. webkit: function() {
  1461. return _populate() || _webkit;
  1462. },
  1463. /**
  1464. * For Push
  1465. * WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit
  1466. */
  1467. safari: function() {
  1468. return UserAgent_DEPRECATED.webkit();
  1469. },
  1470. /**
  1471. * Check if the UA is a Chrome browser.
  1472. *
  1473. *
  1474. * @return float|NaN Version number (if match) or NaN.
  1475. */
  1476. chrome : function() {
  1477. return _populate() || _chrome;
  1478. },
  1479. /**
  1480. * Check if the user is running Windows.
  1481. *
  1482. * @return bool `true' if the user's OS is Windows.
  1483. */
  1484. windows: function() {
  1485. return _populate() || _windows;
  1486. },
  1487. /**
  1488. * Check if the user is running Mac OS X.
  1489. *
  1490. * @return float|bool Returns a float if a version number is detected,
  1491. * otherwise true/false.
  1492. */
  1493. osx: function() {
  1494. return _populate() || _osx;
  1495. },
  1496. /**
  1497. * Check if the user is running Linux.
  1498. *
  1499. * @return bool `true' if the user's OS is some flavor of Linux.
  1500. */
  1501. linux: function() {
  1502. return _populate() || _linux;
  1503. },
  1504. /**
  1505. * Check if the user is running on an iPhone or iPod platform.
  1506. *
  1507. * @return bool `true' if the user is running some flavor of the
  1508. * iPhone OS.
  1509. */
  1510. iphone: function() {
  1511. return _populate() || _iphone;
  1512. },
  1513. mobile: function() {
  1514. return _populate() || (_iphone || _ipad || _android || _mobile);
  1515. },
  1516. nativeApp: function() {
  1517. // webviews inside of the native apps
  1518. return _populate() || _native;
  1519. },
  1520. android: function() {
  1521. return _populate() || _android;
  1522. },
  1523. ipad: function() {
  1524. return _populate() || _ipad;
  1525. }
  1526. };
  1527. module.exports = UserAgent_DEPRECATED;
  1528. /***/ }),
  1529. /***/ 7939:
  1530. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1531. "use strict";
  1532. /**
  1533. * Copyright 2013-2015, Facebook, Inc.
  1534. * All rights reserved.
  1535. *
  1536. * This source code is licensed under the BSD-style license found in the
  1537. * LICENSE file in the root directory of this source tree. An additional grant
  1538. * of patent rights can be found in the PATENTS file in the same directory.
  1539. *
  1540. * @providesModule isEventSupported
  1541. */
  1542. var ExecutionEnvironment = __webpack_require__(3110);
  1543. var useHasFeature;
  1544. if (ExecutionEnvironment.canUseDOM) {
  1545. useHasFeature =
  1546. document.implementation &&
  1547. document.implementation.hasFeature &&
  1548. // always returns true in newer browsers as per the standard.
  1549. // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
  1550. document.implementation.hasFeature('', '') !== true;
  1551. }
  1552. /**
  1553. * Checks if an event is supported in the current execution environment.
  1554. *
  1555. * NOTE: This will not work correctly for non-generic events such as `change`,
  1556. * `reset`, `load`, `error`, and `select`.
  1557. *
  1558. * Borrows from Modernizr.
  1559. *
  1560. * @param {string} eventNameSuffix Event name, e.g. "click".
  1561. * @param {?boolean} capture Check if the capture phase is supported.
  1562. * @return {boolean} True if the event is supported.
  1563. * @internal
  1564. * @license Modernizr 3.0.0pre (Custom Build) | MIT
  1565. */
  1566. function isEventSupported(eventNameSuffix, capture) {
  1567. if (!ExecutionEnvironment.canUseDOM ||
  1568. capture && !('addEventListener' in document)) {
  1569. return false;
  1570. }
  1571. var eventName = 'on' + eventNameSuffix;
  1572. var isSupported = eventName in document;
  1573. if (!isSupported) {
  1574. var element = document.createElement('div');
  1575. element.setAttribute(eventName, 'return;');
  1576. isSupported = typeof element[eventName] === 'function';
  1577. }
  1578. if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
  1579. // This is the only way to test support for the `wheel` event in IE9+.
  1580. isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
  1581. }
  1582. return isSupported;
  1583. }
  1584. module.exports = isEventSupported;
  1585. /***/ }),
  1586. /***/ 195:
  1587. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1588. "use strict";
  1589. /**
  1590. * Copyright (c) 2015, Facebook, Inc.
  1591. * All rights reserved.
  1592. *
  1593. * This source code is licensed under the BSD-style license found in the
  1594. * LICENSE file in the root directory of this source tree. An additional grant
  1595. * of patent rights can be found in the PATENTS file in the same directory.
  1596. *
  1597. * @providesModule normalizeWheel
  1598. * @typechecks
  1599. */
  1600. var UserAgent_DEPRECATED = __webpack_require__(3812);
  1601. var isEventSupported = __webpack_require__(7939);
  1602. // Reasonable defaults
  1603. var PIXEL_STEP = 10;
  1604. var LINE_HEIGHT = 40;
  1605. var PAGE_HEIGHT = 800;
  1606. /**
  1607. * Mouse wheel (and 2-finger trackpad) support on the web sucks. It is
  1608. * complicated, thus this doc is long and (hopefully) detailed enough to answer
  1609. * your questions.
  1610. *
  1611. * If you need to react to the mouse wheel in a predictable way, this code is
  1612. * like your bestest friend. * hugs *
  1613. *
  1614. * As of today, there are 4 DOM event types you can listen to:
  1615. *
  1616. * 'wheel' -- Chrome(31+), FF(17+), IE(9+)
  1617. * 'mousewheel' -- Chrome, IE(6+), Opera, Safari
  1618. * 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother!
  1619. * 'DOMMouseScroll' -- FF(0.9.7+) since 2003
  1620. *
  1621. * So what to do? The is the best:
  1622. *
  1623. * normalizeWheel.getEventType();
  1624. *
  1625. * In your event callback, use this code to get sane interpretation of the
  1626. * deltas. This code will return an object with properties:
  1627. *
  1628. * spinX -- normalized spin speed (use for zoom) - x plane
  1629. * spinY -- " - y plane
  1630. * pixelX -- normalized distance (to pixels) - x plane
  1631. * pixelY -- " - y plane
  1632. *
  1633. * Wheel values are provided by the browser assuming you are using the wheel to
  1634. * scroll a web page by a number of lines or pixels (or pages). Values can vary
  1635. * significantly on different platforms and browsers, forgetting that you can
  1636. * scroll at different speeds. Some devices (like trackpads) emit more events
  1637. * at smaller increments with fine granularity, and some emit massive jumps with
  1638. * linear speed or acceleration.
  1639. *
  1640. * This code does its best to normalize the deltas for you:
  1641. *
  1642. * - spin is trying to normalize how far the wheel was spun (or trackpad
  1643. * dragged). This is super useful for zoom support where you want to
  1644. * throw away the chunky scroll steps on the PC and make those equal to
  1645. * the slow and smooth tiny steps on the Mac. Key data: This code tries to
  1646. * resolve a single slow step on a wheel to 1.
  1647. *
  1648. * - pixel is normalizing the desired scroll delta in pixel units. You'll
  1649. * get the crazy differences between browsers, but at least it'll be in
  1650. * pixels!
  1651. *
  1652. * - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This
  1653. * should translate to positive value zooming IN, negative zooming OUT.
  1654. * This matches the newer 'wheel' event.
  1655. *
  1656. * Why are there spinX, spinY (or pixels)?
  1657. *
  1658. * - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn
  1659. * with a mouse. It results in side-scrolling in the browser by default.
  1660. *
  1661. * - spinY is what you expect -- it's the classic axis of a mouse wheel.
  1662. *
  1663. * - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and
  1664. * probably is by browsers in conjunction with fancy 3D controllers .. but
  1665. * you know.
  1666. *
  1667. * Implementation info:
  1668. *
  1669. * Examples of 'wheel' event if you scroll slowly (down) by one step with an
  1670. * average mouse:
  1671. *
  1672. * OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120)
  1673. * OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12)
  1674. * OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A)
  1675. * Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120)
  1676. * Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120)
  1677. *
  1678. * On the trackpad:
  1679. *
  1680. * OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6)
  1681. * OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A)
  1682. *
  1683. * On other/older browsers.. it's more complicated as there can be multiple and
  1684. * also missing delta values.
  1685. *
  1686. * The 'wheel' event is more standard:
  1687. *
  1688. * http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
  1689. *
  1690. * The basics is that it includes a unit, deltaMode (pixels, lines, pages), and
  1691. * deltaX, deltaY and deltaZ. Some browsers provide other values to maintain
  1692. * backward compatibility with older events. Those other values help us
  1693. * better normalize spin speed. Example of what the browsers provide:
  1694. *
  1695. * | event.wheelDelta | event.detail
  1696. * ------------------+------------------+--------------
  1697. * Safari v5/OS X | -120 | 0
  1698. * Safari v5/Win7 | -120 | 0
  1699. * Chrome v17/OS X | -120 | 0
  1700. * Chrome v17/Win7 | -120 | 0
  1701. * IE9/Win7 | -120 | undefined
  1702. * Firefox v4/OS X | undefined | 1
  1703. * Firefox v4/Win7 | undefined | 3
  1704. *
  1705. */
  1706. function normalizeWheel(/*object*/ event) /*object*/ {
  1707. var sX = 0, sY = 0, // spinX, spinY
  1708. pX = 0, pY = 0; // pixelX, pixelY
  1709. // Legacy
  1710. if ('detail' in event) { sY = event.detail; }
  1711. if ('wheelDelta' in event) { sY = -event.wheelDelta / 120; }
  1712. if ('wheelDeltaY' in event) { sY = -event.wheelDeltaY / 120; }
  1713. if ('wheelDeltaX' in event) { sX = -event.wheelDeltaX / 120; }
  1714. // side scrolling on FF with DOMMouseScroll
  1715. if ( 'axis' in event && event.axis === event.HORIZONTAL_AXIS ) {
  1716. sX = sY;
  1717. sY = 0;
  1718. }
  1719. pX = sX * PIXEL_STEP;
  1720. pY = sY * PIXEL_STEP;
  1721. if ('deltaY' in event) { pY = event.deltaY; }
  1722. if ('deltaX' in event) { pX = event.deltaX; }
  1723. if ((pX || pY) && event.deltaMode) {
  1724. if (event.deltaMode == 1) { // delta in LINE units
  1725. pX *= LINE_HEIGHT;
  1726. pY *= LINE_HEIGHT;
  1727. } else { // delta in PAGE units
  1728. pX *= PAGE_HEIGHT;
  1729. pY *= PAGE_HEIGHT;
  1730. }
  1731. }
  1732. // Fall-back if spin cannot be determined
  1733. if (pX && !sX) { sX = (pX < 1) ? -1 : 1; }
  1734. if (pY && !sY) { sY = (pY < 1) ? -1 : 1; }
  1735. return { spinX : sX,
  1736. spinY : sY,
  1737. pixelX : pX,
  1738. pixelY : pY };
  1739. }
  1740. /**
  1741. * The best combination if you prefer spinX + spinY normalization. It favors
  1742. * the older DOMMouseScroll for Firefox, as FF does not include wheelDelta with
  1743. * 'wheel' event, making spin speed determination impossible.
  1744. */
  1745. normalizeWheel.getEventType = function() /*string*/ {
  1746. return (UserAgent_DEPRECATED.firefox())
  1747. ? 'DOMMouseScroll'
  1748. : (isEventSupported('wheel'))
  1749. ? 'wheel'
  1750. : 'mousewheel';
  1751. };
  1752. module.exports = normalizeWheel;
  1753. /***/ }),
  1754. /***/ 5372:
  1755. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1756. "use strict";
  1757. /**
  1758. * Copyright (c) 2013-present, Facebook, Inc.
  1759. *
  1760. * This source code is licensed under the MIT license found in the
  1761. * LICENSE file in the root directory of this source tree.
  1762. */
  1763. var ReactPropTypesSecret = __webpack_require__(9567);
  1764. function emptyFunction() {}
  1765. function emptyFunctionWithReset() {}
  1766. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  1767. module.exports = function() {
  1768. function shim(props, propName, componentName, location, propFullName, secret) {
  1769. if (secret === ReactPropTypesSecret) {
  1770. // It is still safe when called from React.
  1771. return;
  1772. }
  1773. var err = new Error(
  1774. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  1775. 'Use PropTypes.checkPropTypes() to call them. ' +
  1776. 'Read more at http://fb.me/use-check-prop-types'
  1777. );
  1778. err.name = 'Invariant Violation';
  1779. throw err;
  1780. };
  1781. shim.isRequired = shim;
  1782. function getShim() {
  1783. return shim;
  1784. };
  1785. // Important!
  1786. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  1787. var ReactPropTypes = {
  1788. array: shim,
  1789. bigint: shim,
  1790. bool: shim,
  1791. func: shim,
  1792. number: shim,
  1793. object: shim,
  1794. string: shim,
  1795. symbol: shim,
  1796. any: shim,
  1797. arrayOf: getShim,
  1798. element: shim,
  1799. elementType: shim,
  1800. instanceOf: getShim,
  1801. node: shim,
  1802. objectOf: getShim,
  1803. oneOf: getShim,
  1804. oneOfType: getShim,
  1805. shape: getShim,
  1806. exact: getShim,
  1807. checkPropTypes: emptyFunctionWithReset,
  1808. resetWarningCache: emptyFunction
  1809. };
  1810. ReactPropTypes.PropTypes = ReactPropTypes;
  1811. return ReactPropTypes;
  1812. };
  1813. /***/ }),
  1814. /***/ 2652:
  1815. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  1816. /**
  1817. * Copyright (c) 2013-present, Facebook, Inc.
  1818. *
  1819. * This source code is licensed under the MIT license found in the
  1820. * LICENSE file in the root directory of this source tree.
  1821. */
  1822. if (false) { var throwOnDirectAccess, ReactIs; } else {
  1823. // By explicitly using `prop-types` you are opting into new production behavior.
  1824. // http://fb.me/prop-types-in-prod
  1825. module.exports = __webpack_require__(5372)();
  1826. }
  1827. /***/ }),
  1828. /***/ 9567:
  1829. /***/ (function(module) {
  1830. "use strict";
  1831. /**
  1832. * Copyright (c) 2013-present, Facebook, Inc.
  1833. *
  1834. * This source code is licensed under the MIT license found in the
  1835. * LICENSE file in the root directory of this source tree.
  1836. */
  1837. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  1838. module.exports = ReactPropTypesSecret;
  1839. /***/ }),
  1840. /***/ 5438:
  1841. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1842. "use strict";
  1843. var __extends = (this && this.__extends) || (function () {
  1844. var extendStatics = Object.setPrototypeOf ||
  1845. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1846. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1847. return function (d, b) {
  1848. extendStatics(d, b);
  1849. function __() { this.constructor = d; }
  1850. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1851. };
  1852. })();
  1853. var __assign = (this && this.__assign) || Object.assign || function(t) {
  1854. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1855. s = arguments[i];
  1856. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  1857. t[p] = s[p];
  1858. }
  1859. return t;
  1860. };
  1861. var __rest = (this && this.__rest) || function (s, e) {
  1862. var t = {};
  1863. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  1864. t[p] = s[p];
  1865. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  1866. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  1867. t[p[i]] = s[p[i]];
  1868. return t;
  1869. };
  1870. exports.__esModule = true;
  1871. var React = __webpack_require__(9196);
  1872. var PropTypes = __webpack_require__(2652);
  1873. var autosize = __webpack_require__(6411);
  1874. var _getLineHeight = __webpack_require__(9894);
  1875. var getLineHeight = _getLineHeight;
  1876. var RESIZED = "autosize:resized";
  1877. /**
  1878. * A light replacement for built-in textarea component
  1879. * which automaticaly adjusts its height to match the content
  1880. */
  1881. var TextareaAutosizeClass = /** @class */ (function (_super) {
  1882. __extends(TextareaAutosizeClass, _super);
  1883. function TextareaAutosizeClass() {
  1884. var _this = _super !== null && _super.apply(this, arguments) || this;
  1885. _this.state = {
  1886. lineHeight: null
  1887. };
  1888. _this.textarea = null;
  1889. _this.onResize = function (e) {
  1890. if (_this.props.onResize) {
  1891. _this.props.onResize(e);
  1892. }
  1893. };
  1894. _this.updateLineHeight = function () {
  1895. if (_this.textarea) {
  1896. _this.setState({
  1897. lineHeight: getLineHeight(_this.textarea)
  1898. });
  1899. }
  1900. };
  1901. _this.onChange = function (e) {
  1902. var onChange = _this.props.onChange;
  1903. _this.currentValue = e.currentTarget.value;
  1904. onChange && onChange(e);
  1905. };
  1906. return _this;
  1907. }
  1908. TextareaAutosizeClass.prototype.componentDidMount = function () {
  1909. var _this = this;
  1910. var _a = this.props, maxRows = _a.maxRows, async = _a.async;
  1911. if (typeof maxRows === "number") {
  1912. this.updateLineHeight();
  1913. }
  1914. if (typeof maxRows === "number" || async) {
  1915. /*
  1916. the defer is needed to:
  1917. - force "autosize" to activate the scrollbar when this.props.maxRows is passed
  1918. - support StyledComponents (see #71)
  1919. */
  1920. setTimeout(function () { return _this.textarea && autosize(_this.textarea); });
  1921. }
  1922. else {
  1923. this.textarea && autosize(this.textarea);
  1924. }
  1925. if (this.textarea) {
  1926. this.textarea.addEventListener(RESIZED, this.onResize);
  1927. }
  1928. };
  1929. TextareaAutosizeClass.prototype.componentWillUnmount = function () {
  1930. if (this.textarea) {
  1931. this.textarea.removeEventListener(RESIZED, this.onResize);
  1932. autosize.destroy(this.textarea);
  1933. }
  1934. };
  1935. TextareaAutosizeClass.prototype.render = function () {
  1936. var _this = this;
  1937. 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;
  1938. var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
  1939. return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) {
  1940. _this.textarea = element;
  1941. if (typeof _this.props.innerRef === 'function') {
  1942. _this.props.innerRef(element);
  1943. }
  1944. else if (_this.props.innerRef) {
  1945. _this.props.innerRef.current = element;
  1946. }
  1947. } }), children));
  1948. };
  1949. TextareaAutosizeClass.prototype.componentDidUpdate = function () {
  1950. this.textarea && autosize.update(this.textarea);
  1951. };
  1952. TextareaAutosizeClass.defaultProps = {
  1953. rows: 1,
  1954. async: false
  1955. };
  1956. TextareaAutosizeClass.propTypes = {
  1957. rows: PropTypes.number,
  1958. maxRows: PropTypes.number,
  1959. onResize: PropTypes.func,
  1960. innerRef: PropTypes.any,
  1961. async: PropTypes.bool
  1962. };
  1963. return TextareaAutosizeClass;
  1964. }(React.Component));
  1965. exports.TextareaAutosize = React.forwardRef(function (props, ref) {
  1966. return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref }));
  1967. });
  1968. /***/ }),
  1969. /***/ 773:
  1970. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1971. "use strict";
  1972. var __webpack_unused_export__;
  1973. __webpack_unused_export__ = true;
  1974. var TextareaAutosize_1 = __webpack_require__(5438);
  1975. exports.Z = TextareaAutosize_1.TextareaAutosize;
  1976. /***/ }),
  1977. /***/ 3124:
  1978. /***/ (function(module) {
  1979. var traverse = module.exports = function (obj) {
  1980. return new Traverse(obj);
  1981. };
  1982. function Traverse (obj) {
  1983. this.value = obj;
  1984. }
  1985. Traverse.prototype.get = function (ps) {
  1986. var node = this.value;
  1987. for (var i = 0; i < ps.length; i ++) {
  1988. var key = ps[i];
  1989. if (!node || !hasOwnProperty.call(node, key)) {
  1990. node = undefined;
  1991. break;
  1992. }
  1993. node = node[key];
  1994. }
  1995. return node;
  1996. };
  1997. Traverse.prototype.has = function (ps) {
  1998. var node = this.value;
  1999. for (var i = 0; i < ps.length; i ++) {
  2000. var key = ps[i];
  2001. if (!node || !hasOwnProperty.call(node, key)) {
  2002. return false;
  2003. }
  2004. node = node[key];
  2005. }
  2006. return true;
  2007. };
  2008. Traverse.prototype.set = function (ps, value) {
  2009. var node = this.value;
  2010. for (var i = 0; i < ps.length - 1; i ++) {
  2011. var key = ps[i];
  2012. if (!hasOwnProperty.call(node, key)) node[key] = {};
  2013. node = node[key];
  2014. }
  2015. node[ps[i]] = value;
  2016. return value;
  2017. };
  2018. Traverse.prototype.map = function (cb) {
  2019. return walk(this.value, cb, true);
  2020. };
  2021. Traverse.prototype.forEach = function (cb) {
  2022. this.value = walk(this.value, cb, false);
  2023. return this.value;
  2024. };
  2025. Traverse.prototype.reduce = function (cb, init) {
  2026. var skip = arguments.length === 1;
  2027. var acc = skip ? this.value : init;
  2028. this.forEach(function (x) {
  2029. if (!this.isRoot || !skip) {
  2030. acc = cb.call(this, acc, x);
  2031. }
  2032. });
  2033. return acc;
  2034. };
  2035. Traverse.prototype.paths = function () {
  2036. var acc = [];
  2037. this.forEach(function (x) {
  2038. acc.push(this.path);
  2039. });
  2040. return acc;
  2041. };
  2042. Traverse.prototype.nodes = function () {
  2043. var acc = [];
  2044. this.forEach(function (x) {
  2045. acc.push(this.node);
  2046. });
  2047. return acc;
  2048. };
  2049. Traverse.prototype.clone = function () {
  2050. var parents = [], nodes = [];
  2051. return (function clone (src) {
  2052. for (var i = 0; i < parents.length; i++) {
  2053. if (parents[i] === src) {
  2054. return nodes[i];
  2055. }
  2056. }
  2057. if (typeof src === 'object' && src !== null) {
  2058. var dst = copy(src);
  2059. parents.push(src);
  2060. nodes.push(dst);
  2061. forEach(objectKeys(src), function (key) {
  2062. dst[key] = clone(src[key]);
  2063. });
  2064. parents.pop();
  2065. nodes.pop();
  2066. return dst;
  2067. }
  2068. else {
  2069. return src;
  2070. }
  2071. })(this.value);
  2072. };
  2073. function walk (root, cb, immutable) {
  2074. var path = [];
  2075. var parents = [];
  2076. var alive = true;
  2077. return (function walker (node_) {
  2078. var node = immutable ? copy(node_) : node_;
  2079. var modifiers = {};
  2080. var keepGoing = true;
  2081. var state = {
  2082. node : node,
  2083. node_ : node_,
  2084. path : [].concat(path),
  2085. parent : parents[parents.length - 1],
  2086. parents : parents,
  2087. key : path.slice(-1)[0],
  2088. isRoot : path.length === 0,
  2089. level : path.length,
  2090. circular : null,
  2091. update : function (x, stopHere) {
  2092. if (!state.isRoot) {
  2093. state.parent.node[state.key] = x;
  2094. }
  2095. state.node = x;
  2096. if (stopHere) keepGoing = false;
  2097. },
  2098. 'delete' : function (stopHere) {
  2099. delete state.parent.node[state.key];
  2100. if (stopHere) keepGoing = false;
  2101. },
  2102. remove : function (stopHere) {
  2103. if (isArray(state.parent.node)) {
  2104. state.parent.node.splice(state.key, 1);
  2105. }
  2106. else {
  2107. delete state.parent.node[state.key];
  2108. }
  2109. if (stopHere) keepGoing = false;
  2110. },
  2111. keys : null,
  2112. before : function (f) { modifiers.before = f },
  2113. after : function (f) { modifiers.after = f },
  2114. pre : function (f) { modifiers.pre = f },
  2115. post : function (f) { modifiers.post = f },
  2116. stop : function () { alive = false },
  2117. block : function () { keepGoing = false }
  2118. };
  2119. if (!alive) return state;
  2120. function updateState() {
  2121. if (typeof state.node === 'object' && state.node !== null) {
  2122. if (!state.keys || state.node_ !== state.node) {
  2123. state.keys = objectKeys(state.node)
  2124. }
  2125. state.isLeaf = state.keys.length == 0;
  2126. for (var i = 0; i < parents.length; i++) {
  2127. if (parents[i].node_ === node_) {
  2128. state.circular = parents[i];
  2129. break;
  2130. }
  2131. }
  2132. }
  2133. else {
  2134. state.isLeaf = true;
  2135. state.keys = null;
  2136. }
  2137. state.notLeaf = !state.isLeaf;
  2138. state.notRoot = !state.isRoot;
  2139. }
  2140. updateState();
  2141. // use return values to update if defined
  2142. var ret = cb.call(state, state.node);
  2143. if (ret !== undefined && state.update) state.update(ret);
  2144. if (modifiers.before) modifiers.before.call(state, state.node);
  2145. if (!keepGoing) return state;
  2146. if (typeof state.node == 'object'
  2147. && state.node !== null && !state.circular) {
  2148. parents.push(state);
  2149. updateState();
  2150. forEach(state.keys, function (key, i) {
  2151. path.push(key);
  2152. if (modifiers.pre) modifiers.pre.call(state, state.node[key], key);
  2153. var child = walker(state.node[key]);
  2154. if (immutable && hasOwnProperty.call(state.node, key)) {
  2155. state.node[key] = child.node;
  2156. }
  2157. child.isLast = i == state.keys.length - 1;
  2158. child.isFirst = i == 0;
  2159. if (modifiers.post) modifiers.post.call(state, child);
  2160. path.pop();
  2161. });
  2162. parents.pop();
  2163. }
  2164. if (modifiers.after) modifiers.after.call(state, state.node);
  2165. return state;
  2166. })(root).node;
  2167. }
  2168. function copy (src) {
  2169. if (typeof src === 'object' && src !== null) {
  2170. var dst;
  2171. if (isArray(src)) {
  2172. dst = [];
  2173. }
  2174. else if (isDate(src)) {
  2175. dst = new Date(src.getTime ? src.getTime() : src);
  2176. }
  2177. else if (isRegExp(src)) {
  2178. dst = new RegExp(src);
  2179. }
  2180. else if (isError(src)) {
  2181. dst = { message: src.message };
  2182. }
  2183. else if (isBoolean(src)) {
  2184. dst = new Boolean(src);
  2185. }
  2186. else if (isNumber(src)) {
  2187. dst = new Number(src);
  2188. }
  2189. else if (isString(src)) {
  2190. dst = new String(src);
  2191. }
  2192. else if (Object.create && Object.getPrototypeOf) {
  2193. dst = Object.create(Object.getPrototypeOf(src));
  2194. }
  2195. else if (src.constructor === Object) {
  2196. dst = {};
  2197. }
  2198. else {
  2199. var proto =
  2200. (src.constructor && src.constructor.prototype)
  2201. || src.__proto__
  2202. || {}
  2203. ;
  2204. var T = function () {};
  2205. T.prototype = proto;
  2206. dst = new T;
  2207. }
  2208. forEach(objectKeys(src), function (key) {
  2209. dst[key] = src[key];
  2210. });
  2211. return dst;
  2212. }
  2213. else return src;
  2214. }
  2215. var objectKeys = Object.keys || function keys (obj) {
  2216. var res = [];
  2217. for (var key in obj) res.push(key)
  2218. return res;
  2219. };
  2220. function toS (obj) { return Object.prototype.toString.call(obj) }
  2221. function isDate (obj) { return toS(obj) === '[object Date]' }
  2222. function isRegExp (obj) { return toS(obj) === '[object RegExp]' }
  2223. function isError (obj) { return toS(obj) === '[object Error]' }
  2224. function isBoolean (obj) { return toS(obj) === '[object Boolean]' }
  2225. function isNumber (obj) { return toS(obj) === '[object Number]' }
  2226. function isString (obj) { return toS(obj) === '[object String]' }
  2227. var isArray = Array.isArray || function isArray (xs) {
  2228. return Object.prototype.toString.call(xs) === '[object Array]';
  2229. };
  2230. var forEach = function (xs, fn) {
  2231. if (xs.forEach) return xs.forEach(fn)
  2232. else for (var i = 0; i < xs.length; i++) {
  2233. fn(xs[i], i, xs);
  2234. }
  2235. };
  2236. forEach(objectKeys(Traverse.prototype), function (key) {
  2237. traverse[key] = function (obj) {
  2238. var args = [].slice.call(arguments, 1);
  2239. var t = new Traverse(obj);
  2240. return t[key].apply(t, args);
  2241. };
  2242. });
  2243. var hasOwnProperty = Object.hasOwnProperty || function (obj, key) {
  2244. return key in obj;
  2245. };
  2246. /***/ }),
  2247. /***/ 9196:
  2248. /***/ (function(module) {
  2249. "use strict";
  2250. module.exports = window["React"];
  2251. /***/ })
  2252. /******/ });
  2253. /************************************************************************/
  2254. /******/ // The module cache
  2255. /******/ var __webpack_module_cache__ = {};
  2256. /******/
  2257. /******/ // The require function
  2258. /******/ function __webpack_require__(moduleId) {
  2259. /******/ // Check if module is in cache
  2260. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  2261. /******/ if (cachedModule !== undefined) {
  2262. /******/ return cachedModule.exports;
  2263. /******/ }
  2264. /******/ // Create a new module (and put it into the cache)
  2265. /******/ var module = __webpack_module_cache__[moduleId] = {
  2266. /******/ // no module.id needed
  2267. /******/ // no module.loaded needed
  2268. /******/ exports: {}
  2269. /******/ };
  2270. /******/
  2271. /******/ // Execute the module function
  2272. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  2273. /******/
  2274. /******/ // Return the exports of the module
  2275. /******/ return module.exports;
  2276. /******/ }
  2277. /******/
  2278. /************************************************************************/
  2279. /******/ /* webpack/runtime/compat get default export */
  2280. /******/ !function() {
  2281. /******/ // getDefaultExport function for compatibility with non-harmony modules
  2282. /******/ __webpack_require__.n = function(module) {
  2283. /******/ var getter = module && module.__esModule ?
  2284. /******/ function() { return module['default']; } :
  2285. /******/ function() { return module; };
  2286. /******/ __webpack_require__.d(getter, { a: getter });
  2287. /******/ return getter;
  2288. /******/ };
  2289. /******/ }();
  2290. /******/
  2291. /******/ /* webpack/runtime/define property getters */
  2292. /******/ !function() {
  2293. /******/ // define getter functions for harmony exports
  2294. /******/ __webpack_require__.d = function(exports, definition) {
  2295. /******/ for(var key in definition) {
  2296. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  2297. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  2298. /******/ }
  2299. /******/ }
  2300. /******/ };
  2301. /******/ }();
  2302. /******/
  2303. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  2304. /******/ !function() {
  2305. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  2306. /******/ }();
  2307. /******/
  2308. /******/ /* webpack/runtime/make namespace object */
  2309. /******/ !function() {
  2310. /******/ // define __esModule on exports
  2311. /******/ __webpack_require__.r = function(exports) {
  2312. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  2313. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  2314. /******/ }
  2315. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  2316. /******/ };
  2317. /******/ }();
  2318. /******/
  2319. /************************************************************************/
  2320. var __webpack_exports__ = {};
  2321. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  2322. !function() {
  2323. "use strict";
  2324. // ESM COMPAT FLAG
  2325. __webpack_require__.r(__webpack_exports__);
  2326. // EXPORTS
  2327. __webpack_require__.d(__webpack_exports__, {
  2328. "AlignmentControl": function() { return /* reexport */ AlignmentControl; },
  2329. "AlignmentToolbar": function() { return /* reexport */ AlignmentToolbar; },
  2330. "Autocomplete": function() { return /* reexport */ autocomplete; },
  2331. "BlockAlignmentControl": function() { return /* reexport */ BlockAlignmentControl; },
  2332. "BlockAlignmentToolbar": function() { return /* reexport */ BlockAlignmentToolbar; },
  2333. "BlockBreadcrumb": function() { return /* reexport */ block_breadcrumb; },
  2334. "BlockColorsStyleSelector": function() { return /* reexport */ color_style_selector; },
  2335. "BlockContextProvider": function() { return /* reexport */ BlockContextProvider; },
  2336. "BlockControls": function() { return /* reexport */ block_controls; },
  2337. "BlockEdit": function() { return /* reexport */ BlockEdit; },
  2338. "BlockEditorKeyboardShortcuts": function() { return /* reexport */ keyboard_shortcuts; },
  2339. "BlockEditorProvider": function() { return /* reexport */ provider; },
  2340. "BlockFormatControls": function() { return /* reexport */ BlockFormatControls; },
  2341. "BlockIcon": function() { return /* reexport */ block_icon; },
  2342. "BlockInspector": function() { return /* reexport */ block_inspector; },
  2343. "BlockList": function() { return /* reexport */ BlockList; },
  2344. "BlockMover": function() { return /* reexport */ block_mover; },
  2345. "BlockNavigationDropdown": function() { return /* reexport */ dropdown; },
  2346. "BlockPreview": function() { return /* reexport */ block_preview; },
  2347. "BlockSelectionClearer": function() { return /* reexport */ BlockSelectionClearer; },
  2348. "BlockSettingsMenu": function() { return /* reexport */ block_settings_menu; },
  2349. "BlockSettingsMenuControls": function() { return /* reexport */ block_settings_menu_controls; },
  2350. "BlockStyles": function() { return /* reexport */ block_styles; },
  2351. "BlockTitle": function() { return /* reexport */ BlockTitle; },
  2352. "BlockToolbar": function() { return /* reexport */ block_toolbar; },
  2353. "BlockTools": function() { return /* reexport */ BlockTools; },
  2354. "BlockVerticalAlignmentControl": function() { return /* reexport */ BlockVerticalAlignmentControl; },
  2355. "BlockVerticalAlignmentToolbar": function() { return /* reexport */ BlockVerticalAlignmentToolbar; },
  2356. "ButtonBlockAppender": function() { return /* reexport */ button_block_appender; },
  2357. "ButtonBlockerAppender": function() { return /* reexport */ ButtonBlockerAppender; },
  2358. "ColorPalette": function() { return /* reexport */ color_palette; },
  2359. "ColorPaletteControl": function() { return /* reexport */ ColorPaletteControl; },
  2360. "ContrastChecker": function() { return /* reexport */ contrast_checker; },
  2361. "CopyHandler": function() { return /* reexport */ copy_handler; },
  2362. "DefaultBlockAppender": function() { return /* reexport */ default_block_appender; },
  2363. "FontSizePicker": function() { return /* reexport */ font_size_picker; },
  2364. "InnerBlocks": function() { return /* reexport */ inner_blocks; },
  2365. "Inserter": function() { return /* reexport */ inserter; },
  2366. "InspectorAdvancedControls": function() { return /* reexport */ InspectorAdvancedControls; },
  2367. "InspectorControls": function() { return /* reexport */ inspector_controls; },
  2368. "JustifyContentControl": function() { return /* reexport */ JustifyContentControl; },
  2369. "JustifyToolbar": function() { return /* reexport */ JustifyToolbar; },
  2370. "LineHeightControl": function() { return /* reexport */ line_height_control; },
  2371. "MediaPlaceholder": function() { return /* reexport */ media_placeholder; },
  2372. "MediaReplaceFlow": function() { return /* reexport */ media_replace_flow; },
  2373. "MediaUpload": function() { return /* reexport */ media_upload; },
  2374. "MediaUploadCheck": function() { return /* reexport */ media_upload_check; },
  2375. "MultiSelectScrollIntoView": function() { return /* reexport */ MultiSelectScrollIntoView; },
  2376. "NavigableToolbar": function() { return /* reexport */ navigable_toolbar; },
  2377. "ObserveTyping": function() { return /* reexport */ observe_typing; },
  2378. "PanelColorSettings": function() { return /* reexport */ panel_color_settings; },
  2379. "PlainText": function() { return /* reexport */ plain_text; },
  2380. "RichText": function() { return /* reexport */ rich_text; },
  2381. "RichTextShortcut": function() { return /* reexport */ RichTextShortcut; },
  2382. "RichTextToolbarButton": function() { return /* reexport */ RichTextToolbarButton; },
  2383. "SETTINGS_DEFAULTS": function() { return /* reexport */ SETTINGS_DEFAULTS; },
  2384. "SkipToSelectedBlock": function() { return /* reexport */ skip_to_selected_block; },
  2385. "ToolSelector": function() { return /* reexport */ tool_selector; },
  2386. "Typewriter": function() { return /* reexport */ typewriter; },
  2387. "URLInput": function() { return /* reexport */ url_input; },
  2388. "URLInputButton": function() { return /* reexport */ url_input_button; },
  2389. "URLPopover": function() { return /* reexport */ url_popover; },
  2390. "Warning": function() { return /* reexport */ warning; },
  2391. "WritingFlow": function() { return /* reexport */ writing_flow; },
  2392. "__experimentalBlockAlignmentMatrixControl": function() { return /* reexport */ block_alignment_matrix_control; },
  2393. "__experimentalBlockContentOverlay": function() { return /* reexport */ BlockContentOverlay; },
  2394. "__experimentalBlockFullHeightAligmentControl": function() { return /* reexport */ block_full_height_alignment_control; },
  2395. "__experimentalBlockPatternSetup": function() { return /* reexport */ block_pattern_setup; },
  2396. "__experimentalBlockPatternsList": function() { return /* reexport */ block_patterns_list; },
  2397. "__experimentalBlockVariationPicker": function() { return /* reexport */ block_variation_picker; },
  2398. "__experimentalBlockVariationTransforms": function() { return /* reexport */ block_variation_transforms; },
  2399. "__experimentalBorderRadiusControl": function() { return /* reexport */ BorderRadiusControl; },
  2400. "__experimentalBorderStyleControl": function() { return /* reexport */ BorderStyleControl; },
  2401. "__experimentalColorGradientControl": function() { return /* reexport */ control; },
  2402. "__experimentalColorGradientSettingsDropdown": function() { return /* reexport */ ColorGradientSettingsDropdown; },
  2403. "__experimentalDateFormatPicker": function() { return /* reexport */ DateFormatPicker; },
  2404. "__experimentalDuotoneControl": function() { return /* reexport */ duotone_control; },
  2405. "__experimentalFontAppearanceControl": function() { return /* reexport */ FontAppearanceControl; },
  2406. "__experimentalFontFamilyControl": function() { return /* reexport */ FontFamilyControl; },
  2407. "__experimentalGetBorderClassesAndStyles": function() { return /* reexport */ getBorderClassesAndStyles; },
  2408. "__experimentalGetColorClassesAndStyles": function() { return /* reexport */ getColorClassesAndStyles; },
  2409. "__experimentalGetGradientClass": function() { return /* reexport */ __experimentalGetGradientClass; },
  2410. "__experimentalGetGradientObjectByGradientValue": function() { return /* reexport */ __experimentalGetGradientObjectByGradientValue; },
  2411. "__experimentalGetMatchingVariation": function() { return /* reexport */ __experimentalGetMatchingVariation; },
  2412. "__experimentalGetSpacingClassesAndStyles": function() { return /* reexport */ getSpacingClassesAndStyles; },
  2413. "__experimentalImageEditingProvider": function() { return /* reexport */ ImageEditingProvider; },
  2414. "__experimentalImageEditor": function() { return /* reexport */ ImageEditor; },
  2415. "__experimentalImageSizeControl": function() { return /* reexport */ ImageSizeControl; },
  2416. "__experimentalImageURLInputUI": function() { return /* reexport */ ImageURLInputUI; },
  2417. "__experimentalLayoutStyle": function() { return /* reexport */ LayoutStyle; },
  2418. "__experimentalLetterSpacingControl": function() { return /* reexport */ LetterSpacingControl; },
  2419. "__experimentalLibrary": function() { return /* reexport */ library; },
  2420. "__experimentalLinkControl": function() { return /* reexport */ link_control; },
  2421. "__experimentalLinkControlSearchInput": function() { return /* reexport */ search_input; },
  2422. "__experimentalLinkControlSearchItem": function() { return /* reexport */ search_item; },
  2423. "__experimentalLinkControlSearchResults": function() { return /* reexport */ LinkControlSearchResults; },
  2424. "__experimentalListView": function() { return /* reexport */ components_list_view; },
  2425. "__experimentalPanelColorGradientSettings": function() { return /* reexport */ panel_color_gradient_settings; },
  2426. "__experimentalPreviewOptions": function() { return /* reexport */ PreviewOptions; },
  2427. "__experimentalResponsiveBlockControl": function() { return /* reexport */ responsive_block_control; },
  2428. "__experimentalTextDecorationControl": function() { return /* reexport */ TextDecorationControl; },
  2429. "__experimentalTextTransformControl": function() { return /* reexport */ TextTransformControl; },
  2430. "__experimentalToolsPanelColorDropdown": function() { return /* reexport */ ToolsPanelColorDropdown; },
  2431. "__experimentalUnitControl": function() { return /* reexport */ UnitControl; },
  2432. "__experimentalUseBlockPreview": function() { return /* reexport */ useBlockPreview; },
  2433. "__experimentalUseBorderProps": function() { return /* reexport */ useBorderProps; },
  2434. "__experimentalUseColorProps": function() { return /* reexport */ useColorProps; },
  2435. "__experimentalUseCustomSides": function() { return /* reexport */ useCustomSides; },
  2436. "__experimentalUseGradient": function() { return /* reexport */ __experimentalUseGradient; },
  2437. "__experimentalUseNoRecursiveRenders": function() { return /* reexport */ useNoRecursiveRenders; },
  2438. "__experimentalUseResizeCanvas": function() { return /* reexport */ useResizeCanvas; },
  2439. "__unstableBlockNameContext": function() { return /* reexport */ block_name_context; },
  2440. "__unstableBlockSettingsMenuFirstItem": function() { return /* reexport */ block_settings_menu_first_item; },
  2441. "__unstableBlockToolbarLastItem": function() { return /* reexport */ block_toolbar_last_item; },
  2442. "__unstableEditorStyles": function() { return /* reexport */ EditorStyles; },
  2443. "__unstableIframe": function() { return /* reexport */ iframe; },
  2444. "__unstableInserterMenuExtension": function() { return /* reexport */ inserter_menu_extension; },
  2445. "__unstablePresetDuotoneFilter": function() { return /* reexport */ PresetDuotoneFilter; },
  2446. "__unstableRichTextInputEvent": function() { return /* reexport */ __unstableRichTextInputEvent; },
  2447. "__unstableUseBlockSelectionClearer": function() { return /* reexport */ useBlockSelectionClearer; },
  2448. "__unstableUseClipboardHandler": function() { return /* reexport */ useClipboardHandler; },
  2449. "__unstableUseMouseMoveTypingReset": function() { return /* reexport */ useMouseMoveTypingReset; },
  2450. "__unstableUseTypewriter": function() { return /* reexport */ useTypewriter; },
  2451. "__unstableUseTypingObserver": function() { return /* reexport */ useTypingObserver; },
  2452. "createCustomColorsHOC": function() { return /* reexport */ createCustomColorsHOC; },
  2453. "getColorClassName": function() { return /* reexport */ getColorClassName; },
  2454. "getColorObjectByAttributeValues": function() { return /* reexport */ getColorObjectByAttributeValues; },
  2455. "getColorObjectByColorValue": function() { return /* reexport */ getColorObjectByColorValue; },
  2456. "getFontSize": function() { return /* reexport */ getFontSize; },
  2457. "getFontSizeClass": function() { return /* reexport */ getFontSizeClass; },
  2458. "getFontSizeObjectByValue": function() { return /* reexport */ getFontSizeObjectByValue; },
  2459. "getGradientSlugByValue": function() { return /* reexport */ getGradientSlugByValue; },
  2460. "getGradientValueBySlug": function() { return /* reexport */ getGradientValueBySlug; },
  2461. "getPxFromCssUnit": function() { return /* reexport */ parse_css_unit_to_px; },
  2462. "store": function() { return /* reexport */ store; },
  2463. "storeConfig": function() { return /* reexport */ storeConfig; },
  2464. "transformStyles": function() { return /* reexport */ transform_styles; },
  2465. "useBlockDisplayInformation": function() { return /* reexport */ useBlockDisplayInformation; },
  2466. "useBlockEditContext": function() { return /* reexport */ useBlockEditContext; },
  2467. "useBlockProps": function() { return /* reexport */ useBlockProps; },
  2468. "useCachedTruthy": function() { return /* reexport */ useCachedTruthy; },
  2469. "useInnerBlocksProps": function() { return /* reexport */ useInnerBlocksProps; },
  2470. "useSetting": function() { return /* reexport */ useSetting; },
  2471. "withColorContext": function() { return /* reexport */ with_color_context; },
  2472. "withColors": function() { return /* reexport */ withColors; },
  2473. "withFontSizes": function() { return /* reexport */ with_font_sizes; }
  2474. });
  2475. // NAMESPACE OBJECT: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js
  2476. var selectors_namespaceObject = {};
  2477. __webpack_require__.r(selectors_namespaceObject);
  2478. __webpack_require__.d(selectors_namespaceObject, {
  2479. "__experimentalGetActiveBlockIdByBlockNames": function() { return __experimentalGetActiveBlockIdByBlockNames; },
  2480. "__experimentalGetAllowedBlocks": function() { return __experimentalGetAllowedBlocks; },
  2481. "__experimentalGetAllowedPatterns": function() { return __experimentalGetAllowedPatterns; },
  2482. "__experimentalGetBlockListSettingsForBlocks": function() { return __experimentalGetBlockListSettingsForBlocks; },
  2483. "__experimentalGetDirectInsertBlock": function() { return __experimentalGetDirectInsertBlock; },
  2484. "__experimentalGetGlobalBlocksByName": function() { return __experimentalGetGlobalBlocksByName; },
  2485. "__experimentalGetLastBlockAttributeChanges": function() { return __experimentalGetLastBlockAttributeChanges; },
  2486. "__experimentalGetParsedPattern": function() { return __experimentalGetParsedPattern; },
  2487. "__experimentalGetPatternTransformItems": function() { return __experimentalGetPatternTransformItems; },
  2488. "__experimentalGetPatternsByBlockTypes": function() { return __experimentalGetPatternsByBlockTypes; },
  2489. "__experimentalGetReusableBlockTitle": function() { return __experimentalGetReusableBlockTitle; },
  2490. "__unstableGetBlockWithoutInnerBlocks": function() { return __unstableGetBlockWithoutInnerBlocks; },
  2491. "__unstableGetClientIdWithClientIdsTree": function() { return __unstableGetClientIdWithClientIdsTree; },
  2492. "__unstableGetClientIdsTree": function() { return __unstableGetClientIdsTree; },
  2493. "__unstableGetSelectedBlocksWithPartialSelection": function() { return __unstableGetSelectedBlocksWithPartialSelection; },
  2494. "__unstableIsFullySelected": function() { return __unstableIsFullySelected; },
  2495. "__unstableIsLastBlockChangeIgnored": function() { return __unstableIsLastBlockChangeIgnored; },
  2496. "__unstableIsSelectionCollapsed": function() { return __unstableIsSelectionCollapsed; },
  2497. "__unstableIsSelectionMergeable": function() { return __unstableIsSelectionMergeable; },
  2498. "areInnerBlocksControlled": function() { return areInnerBlocksControlled; },
  2499. "canInsertBlockType": function() { return canInsertBlockType; },
  2500. "canInsertBlocks": function() { return canInsertBlocks; },
  2501. "canLockBlockType": function() { return canLockBlockType; },
  2502. "canMoveBlock": function() { return canMoveBlock; },
  2503. "canMoveBlocks": function() { return canMoveBlocks; },
  2504. "canRemoveBlock": function() { return canRemoveBlock; },
  2505. "canRemoveBlocks": function() { return canRemoveBlocks; },
  2506. "didAutomaticChange": function() { return didAutomaticChange; },
  2507. "getAdjacentBlockClientId": function() { return getAdjacentBlockClientId; },
  2508. "getBlock": function() { return getBlock; },
  2509. "getBlockAttributes": function() { return getBlockAttributes; },
  2510. "getBlockCount": function() { return getBlockCount; },
  2511. "getBlockHierarchyRootClientId": function() { return getBlockHierarchyRootClientId; },
  2512. "getBlockIndex": function() { return getBlockIndex; },
  2513. "getBlockInsertionPoint": function() { return getBlockInsertionPoint; },
  2514. "getBlockListSettings": function() { return getBlockListSettings; },
  2515. "getBlockMode": function() { return getBlockMode; },
  2516. "getBlockName": function() { return getBlockName; },
  2517. "getBlockOrder": function() { return getBlockOrder; },
  2518. "getBlockParents": function() { return getBlockParents; },
  2519. "getBlockParentsByBlockName": function() { return getBlockParentsByBlockName; },
  2520. "getBlockRootClientId": function() { return getBlockRootClientId; },
  2521. "getBlockSelectionEnd": function() { return getBlockSelectionEnd; },
  2522. "getBlockSelectionStart": function() { return getBlockSelectionStart; },
  2523. "getBlockTransformItems": function() { return getBlockTransformItems; },
  2524. "getBlocks": function() { return getBlocks; },
  2525. "getBlocksByClientId": function() { return getBlocksByClientId; },
  2526. "getClientIdsOfDescendants": function() { return getClientIdsOfDescendants; },
  2527. "getClientIdsWithDescendants": function() { return getClientIdsWithDescendants; },
  2528. "getDraggedBlockClientIds": function() { return getDraggedBlockClientIds; },
  2529. "getFirstMultiSelectedBlockClientId": function() { return getFirstMultiSelectedBlockClientId; },
  2530. "getGlobalBlockCount": function() { return getGlobalBlockCount; },
  2531. "getInserterItems": function() { return getInserterItems; },
  2532. "getLastMultiSelectedBlockClientId": function() { return getLastMultiSelectedBlockClientId; },
  2533. "getLowestCommonAncestorWithSelectedBlock": function() { return getLowestCommonAncestorWithSelectedBlock; },
  2534. "getMultiSelectedBlockClientIds": function() { return getMultiSelectedBlockClientIds; },
  2535. "getMultiSelectedBlocks": function() { return getMultiSelectedBlocks; },
  2536. "getMultiSelectedBlocksEndClientId": function() { return getMultiSelectedBlocksEndClientId; },
  2537. "getMultiSelectedBlocksStartClientId": function() { return getMultiSelectedBlocksStartClientId; },
  2538. "getNextBlockClientId": function() { return getNextBlockClientId; },
  2539. "getPreviousBlockClientId": function() { return getPreviousBlockClientId; },
  2540. "getSelectedBlock": function() { return getSelectedBlock; },
  2541. "getSelectedBlockClientId": function() { return getSelectedBlockClientId; },
  2542. "getSelectedBlockClientIds": function() { return getSelectedBlockClientIds; },
  2543. "getSelectedBlockCount": function() { return getSelectedBlockCount; },
  2544. "getSelectedBlocksInitialCaretPosition": function() { return getSelectedBlocksInitialCaretPosition; },
  2545. "getSelectionEnd": function() { return getSelectionEnd; },
  2546. "getSelectionStart": function() { return getSelectionStart; },
  2547. "getSettings": function() { return getSettings; },
  2548. "getTemplate": function() { return getTemplate; },
  2549. "getTemplateLock": function() { return getTemplateLock; },
  2550. "hasBlockMovingClientId": function() { return selectors_hasBlockMovingClientId; },
  2551. "hasInserterItems": function() { return hasInserterItems; },
  2552. "hasMultiSelection": function() { return hasMultiSelection; },
  2553. "hasSelectedBlock": function() { return hasSelectedBlock; },
  2554. "hasSelectedInnerBlock": function() { return hasSelectedInnerBlock; },
  2555. "isAncestorBeingDragged": function() { return isAncestorBeingDragged; },
  2556. "isAncestorMultiSelected": function() { return isAncestorMultiSelected; },
  2557. "isBlockBeingDragged": function() { return isBlockBeingDragged; },
  2558. "isBlockHighlighted": function() { return isBlockHighlighted; },
  2559. "isBlockInsertionPointVisible": function() { return isBlockInsertionPointVisible; },
  2560. "isBlockMultiSelected": function() { return isBlockMultiSelected; },
  2561. "isBlockSelected": function() { return isBlockSelected; },
  2562. "isBlockValid": function() { return isBlockValid; },
  2563. "isBlockWithinSelection": function() { return isBlockWithinSelection; },
  2564. "isCaretWithinFormattedText": function() { return selectors_isCaretWithinFormattedText; },
  2565. "isDraggingBlocks": function() { return isDraggingBlocks; },
  2566. "isFirstMultiSelectedBlock": function() { return isFirstMultiSelectedBlock; },
  2567. "isLastBlockChangePersistent": function() { return isLastBlockChangePersistent; },
  2568. "isMultiSelecting": function() { return selectors_isMultiSelecting; },
  2569. "isNavigationMode": function() { return selectors_isNavigationMode; },
  2570. "isSelectionEnabled": function() { return selectors_isSelectionEnabled; },
  2571. "isTyping": function() { return selectors_isTyping; },
  2572. "isValidTemplate": function() { return isValidTemplate; },
  2573. "wasBlockJustInserted": function() { return wasBlockJustInserted; }
  2574. });
  2575. // NAMESPACE OBJECT: ./node_modules/@wordpress/block-editor/build-module/store/actions.js
  2576. var actions_namespaceObject = {};
  2577. __webpack_require__.r(actions_namespaceObject);
  2578. __webpack_require__.d(actions_namespaceObject, {
  2579. "__unstableDeleteSelection": function() { return __unstableDeleteSelection; },
  2580. "__unstableExpandSelection": function() { return __unstableExpandSelection; },
  2581. "__unstableMarkAutomaticChange": function() { return __unstableMarkAutomaticChange; },
  2582. "__unstableMarkLastChangeAsPersistent": function() { return __unstableMarkLastChangeAsPersistent; },
  2583. "__unstableMarkNextChangeAsNotPersistent": function() { return __unstableMarkNextChangeAsNotPersistent; },
  2584. "__unstableSaveReusableBlock": function() { return __unstableSaveReusableBlock; },
  2585. "__unstableSplitSelection": function() { return __unstableSplitSelection; },
  2586. "clearSelectedBlock": function() { return clearSelectedBlock; },
  2587. "duplicateBlocks": function() { return duplicateBlocks; },
  2588. "enterFormattedText": function() { return enterFormattedText; },
  2589. "exitFormattedText": function() { return exitFormattedText; },
  2590. "flashBlock": function() { return flashBlock; },
  2591. "hideInsertionPoint": function() { return hideInsertionPoint; },
  2592. "insertAfterBlock": function() { return insertAfterBlock; },
  2593. "insertBeforeBlock": function() { return insertBeforeBlock; },
  2594. "insertBlock": function() { return insertBlock; },
  2595. "insertBlocks": function() { return insertBlocks; },
  2596. "insertDefaultBlock": function() { return insertDefaultBlock; },
  2597. "mergeBlocks": function() { return mergeBlocks; },
  2598. "moveBlockToPosition": function() { return moveBlockToPosition; },
  2599. "moveBlocksDown": function() { return moveBlocksDown; },
  2600. "moveBlocksToPosition": function() { return moveBlocksToPosition; },
  2601. "moveBlocksUp": function() { return moveBlocksUp; },
  2602. "multiSelect": function() { return multiSelect; },
  2603. "receiveBlocks": function() { return receiveBlocks; },
  2604. "removeBlock": function() { return removeBlock; },
  2605. "removeBlocks": function() { return removeBlocks; },
  2606. "replaceBlock": function() { return replaceBlock; },
  2607. "replaceBlocks": function() { return replaceBlocks; },
  2608. "replaceInnerBlocks": function() { return replaceInnerBlocks; },
  2609. "resetBlocks": function() { return resetBlocks; },
  2610. "resetSelection": function() { return resetSelection; },
  2611. "selectBlock": function() { return selectBlock; },
  2612. "selectNextBlock": function() { return selectNextBlock; },
  2613. "selectPreviousBlock": function() { return selectPreviousBlock; },
  2614. "selectionChange": function() { return selectionChange; },
  2615. "setBlockMovingClientId": function() { return setBlockMovingClientId; },
  2616. "setHasControlledInnerBlocks": function() { return setHasControlledInnerBlocks; },
  2617. "setNavigationMode": function() { return setNavigationMode; },
  2618. "setTemplateValidity": function() { return setTemplateValidity; },
  2619. "showInsertionPoint": function() { return showInsertionPoint; },
  2620. "startDraggingBlocks": function() { return startDraggingBlocks; },
  2621. "startMultiSelect": function() { return startMultiSelect; },
  2622. "startTyping": function() { return startTyping; },
  2623. "stopDraggingBlocks": function() { return stopDraggingBlocks; },
  2624. "stopMultiSelect": function() { return stopMultiSelect; },
  2625. "stopTyping": function() { return stopTyping; },
  2626. "synchronizeTemplate": function() { return synchronizeTemplate; },
  2627. "toggleBlockHighlight": function() { return toggleBlockHighlight; },
  2628. "toggleBlockMode": function() { return toggleBlockMode; },
  2629. "toggleSelection": function() { return toggleSelection; },
  2630. "updateBlock": function() { return updateBlock; },
  2631. "updateBlockAttributes": function() { return updateBlockAttributes; },
  2632. "updateBlockListSettings": function() { return updateBlockListSettings; },
  2633. "updateSettings": function() { return updateSettings; },
  2634. "validateBlocksToTemplate": function() { return validateBlocksToTemplate; }
  2635. });
  2636. ;// CONCATENATED MODULE: external ["wp","blocks"]
  2637. var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
  2638. ;// CONCATENATED MODULE: external ["wp","hooks"]
  2639. var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
  2640. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/compat.js
  2641. /**
  2642. * WordPress dependencies
  2643. */
  2644. function migrateLightBlockWrapper(settings) {
  2645. const {
  2646. apiVersion = 1
  2647. } = settings;
  2648. if (apiVersion < 2 && (0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'lightBlockWrapper', false)) {
  2649. settings.apiVersion = 2;
  2650. }
  2651. return settings;
  2652. }
  2653. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/compat/migrateLightBlockWrapper', migrateLightBlockWrapper);
  2654. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  2655. function _extends() {
  2656. _extends = Object.assign ? Object.assign.bind() : function (target) {
  2657. for (var i = 1; i < arguments.length; i++) {
  2658. var source = arguments[i];
  2659. for (var key in source) {
  2660. if (Object.prototype.hasOwnProperty.call(source, key)) {
  2661. target[key] = source[key];
  2662. }
  2663. }
  2664. }
  2665. return target;
  2666. };
  2667. return _extends.apply(this, arguments);
  2668. }
  2669. ;// CONCATENATED MODULE: external ["wp","element"]
  2670. var external_wp_element_namespaceObject = window["wp"]["element"];
  2671. // EXTERNAL MODULE: ./node_modules/classnames/index.js
  2672. var classnames = __webpack_require__(4403);
  2673. var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
  2674. ;// CONCATENATED MODULE: external "lodash"
  2675. var external_lodash_namespaceObject = window["lodash"];
  2676. ;// CONCATENATED MODULE: external ["wp","compose"]
  2677. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  2678. ;// CONCATENATED MODULE: external ["wp","components"]
  2679. var external_wp_components_namespaceObject = window["wp"]["components"];
  2680. ;// CONCATENATED MODULE: external ["wp","data"]
  2681. var external_wp_data_namespaceObject = window["wp"]["data"];
  2682. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/groups.js
  2683. /**
  2684. * WordPress dependencies
  2685. */
  2686. const BlockControlsDefault = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControls');
  2687. const BlockControlsBlock = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsBlock');
  2688. const BlockControlsInline = (0,external_wp_components_namespaceObject.createSlotFill)('BlockFormatControls');
  2689. const BlockControlsOther = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsOther');
  2690. const BlockControlsParent = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsParent');
  2691. const groups = {
  2692. default: BlockControlsDefault,
  2693. block: BlockControlsBlock,
  2694. inline: BlockControlsInline,
  2695. other: BlockControlsOther,
  2696. parent: BlockControlsParent
  2697. };
  2698. /* harmony default export */ var block_controls_groups = (groups);
  2699. ;// CONCATENATED MODULE: external ["wp","i18n"]
  2700. var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  2701. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/defaults.js
  2702. /**
  2703. * WordPress dependencies
  2704. */
  2705. const PREFERENCES_DEFAULTS = {
  2706. insertUsage: {}
  2707. };
  2708. /**
  2709. * The default editor settings
  2710. *
  2711. * @typedef {Object} SETTINGS_DEFAULT
  2712. * @property {boolean} alignWide Enable/Disable Wide/Full Alignments
  2713. * @property {boolean} supportsLayout Enable/disable layouts support in container blocks.
  2714. * @property {boolean} imageEditing Image Editing settings set to false to disable.
  2715. * @property {Array} imageSizes Available image sizes
  2716. * @property {number} maxWidth Max width to constraint resizing
  2717. * @property {boolean|Array} allowedBlockTypes Allowed block types
  2718. * @property {boolean} hasFixedToolbar Whether or not the editor toolbar is fixed
  2719. * @property {boolean} focusMode Whether the focus mode is enabled or not
  2720. * @property {Array} styles Editor Styles
  2721. * @property {boolean} keepCaretInsideBlock Whether caret should move between blocks in edit mode
  2722. * @property {string} bodyPlaceholder Empty post placeholder
  2723. * @property {string} titlePlaceholder Empty title placeholder
  2724. * @property {boolean} canLockBlocks Whether the user can manage Block Lock state
  2725. * @property {boolean} codeEditingEnabled Whether or not the user can switch to the code editor
  2726. * @property {boolean} generateAnchors Enable/Disable auto anchor generation for Heading blocks
  2727. * @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.
  2728. * @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
  2729. * @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
  2730. * @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
  2731. * @property {boolean} __unstableGalleryWithImageBlocks Whether the user has enabled the refactored gallery block which uses InnerBlocks
  2732. */
  2733. const SETTINGS_DEFAULTS = {
  2734. alignWide: false,
  2735. supportsLayout: true,
  2736. // colors setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
  2737. // The setting is only kept for backward compatibility purposes.
  2738. colors: [{
  2739. name: (0,external_wp_i18n_namespaceObject.__)('Black'),
  2740. slug: 'black',
  2741. color: '#000000'
  2742. }, {
  2743. name: (0,external_wp_i18n_namespaceObject.__)('Cyan bluish gray'),
  2744. slug: 'cyan-bluish-gray',
  2745. color: '#abb8c3'
  2746. }, {
  2747. name: (0,external_wp_i18n_namespaceObject.__)('White'),
  2748. slug: 'white',
  2749. color: '#ffffff'
  2750. }, {
  2751. name: (0,external_wp_i18n_namespaceObject.__)('Pale pink'),
  2752. slug: 'pale-pink',
  2753. color: '#f78da7'
  2754. }, {
  2755. name: (0,external_wp_i18n_namespaceObject.__)('Vivid red'),
  2756. slug: 'vivid-red',
  2757. color: '#cf2e2e'
  2758. }, {
  2759. name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid orange'),
  2760. slug: 'luminous-vivid-orange',
  2761. color: '#ff6900'
  2762. }, {
  2763. name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid amber'),
  2764. slug: 'luminous-vivid-amber',
  2765. color: '#fcb900'
  2766. }, {
  2767. name: (0,external_wp_i18n_namespaceObject.__)('Light green cyan'),
  2768. slug: 'light-green-cyan',
  2769. color: '#7bdcb5'
  2770. }, {
  2771. name: (0,external_wp_i18n_namespaceObject.__)('Vivid green cyan'),
  2772. slug: 'vivid-green-cyan',
  2773. color: '#00d084'
  2774. }, {
  2775. name: (0,external_wp_i18n_namespaceObject.__)('Pale cyan blue'),
  2776. slug: 'pale-cyan-blue',
  2777. color: '#8ed1fc'
  2778. }, {
  2779. name: (0,external_wp_i18n_namespaceObject.__)('Vivid cyan blue'),
  2780. slug: 'vivid-cyan-blue',
  2781. color: '#0693e3'
  2782. }, {
  2783. name: (0,external_wp_i18n_namespaceObject.__)('Vivid purple'),
  2784. slug: 'vivid-purple',
  2785. color: '#9b51e0'
  2786. }],
  2787. // fontSizes setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
  2788. // The setting is only kept for backward compatibility purposes.
  2789. fontSizes: [{
  2790. name: (0,external_wp_i18n_namespaceObject._x)('Small', 'font size name'),
  2791. size: 13,
  2792. slug: 'small'
  2793. }, {
  2794. name: (0,external_wp_i18n_namespaceObject._x)('Normal', 'font size name'),
  2795. size: 16,
  2796. slug: 'normal'
  2797. }, {
  2798. name: (0,external_wp_i18n_namespaceObject._x)('Medium', 'font size name'),
  2799. size: 20,
  2800. slug: 'medium'
  2801. }, {
  2802. name: (0,external_wp_i18n_namespaceObject._x)('Large', 'font size name'),
  2803. size: 36,
  2804. slug: 'large'
  2805. }, {
  2806. name: (0,external_wp_i18n_namespaceObject._x)('Huge', 'font size name'),
  2807. size: 42,
  2808. slug: 'huge'
  2809. }],
  2810. // Image default size slug.
  2811. imageDefaultSize: 'large',
  2812. imageSizes: [{
  2813. slug: 'thumbnail',
  2814. name: (0,external_wp_i18n_namespaceObject.__)('Thumbnail')
  2815. }, {
  2816. slug: 'medium',
  2817. name: (0,external_wp_i18n_namespaceObject.__)('Medium')
  2818. }, {
  2819. slug: 'large',
  2820. name: (0,external_wp_i18n_namespaceObject.__)('Large')
  2821. }, {
  2822. slug: 'full',
  2823. name: (0,external_wp_i18n_namespaceObject.__)('Full Size')
  2824. }],
  2825. // Allow plugin to disable Image Editor if need be.
  2826. imageEditing: true,
  2827. // This is current max width of the block inner area
  2828. // It's used to constraint image resizing and this value could be overridden later by themes
  2829. maxWidth: 580,
  2830. // Allowed block types for the editor, defaulting to true (all supported).
  2831. allowedBlockTypes: true,
  2832. // Maximum upload size in bytes allowed for the site.
  2833. maxUploadFileSize: 0,
  2834. // List of allowed mime types and file extensions.
  2835. allowedMimeTypes: null,
  2836. // Allows to disable block locking interface.
  2837. canLockBlocks: true,
  2838. __experimentalCanUserUseUnfilteredHTML: false,
  2839. __experimentalBlockDirectory: false,
  2840. __mobileEnablePageTemplates: false,
  2841. __experimentalBlockPatterns: [],
  2842. __experimentalBlockPatternCategories: [],
  2843. __experimentalSpotlightEntityBlocks: [],
  2844. __unstableGalleryWithImageBlocks: false,
  2845. generateAnchors: false,
  2846. // gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
  2847. // The setting is only kept for backward compatibility purposes.
  2848. gradients: [{
  2849. name: (0,external_wp_i18n_namespaceObject.__)('Vivid cyan blue to vivid purple'),
  2850. gradient: 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
  2851. slug: 'vivid-cyan-blue-to-vivid-purple'
  2852. }, {
  2853. name: (0,external_wp_i18n_namespaceObject.__)('Light green cyan to vivid green cyan'),
  2854. gradient: 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
  2855. slug: 'light-green-cyan-to-vivid-green-cyan'
  2856. }, {
  2857. name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid amber to luminous vivid orange'),
  2858. gradient: 'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)',
  2859. slug: 'luminous-vivid-amber-to-luminous-vivid-orange'
  2860. }, {
  2861. name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid orange to vivid red'),
  2862. gradient: 'linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)',
  2863. slug: 'luminous-vivid-orange-to-vivid-red'
  2864. }, {
  2865. name: (0,external_wp_i18n_namespaceObject.__)('Very light gray to cyan bluish gray'),
  2866. gradient: 'linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%)',
  2867. slug: 'very-light-gray-to-cyan-bluish-gray'
  2868. }, {
  2869. name: (0,external_wp_i18n_namespaceObject.__)('Cool to warm spectrum'),
  2870. 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%)',
  2871. slug: 'cool-to-warm-spectrum'
  2872. }, {
  2873. name: (0,external_wp_i18n_namespaceObject.__)('Blush light purple'),
  2874. gradient: 'linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)',
  2875. slug: 'blush-light-purple'
  2876. }, {
  2877. name: (0,external_wp_i18n_namespaceObject.__)('Blush bordeaux'),
  2878. gradient: 'linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)',
  2879. slug: 'blush-bordeaux'
  2880. }, {
  2881. name: (0,external_wp_i18n_namespaceObject.__)('Luminous dusk'),
  2882. gradient: 'linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%)',
  2883. slug: 'luminous-dusk'
  2884. }, {
  2885. name: (0,external_wp_i18n_namespaceObject.__)('Pale ocean'),
  2886. gradient: 'linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%)',
  2887. slug: 'pale-ocean'
  2888. }, {
  2889. name: (0,external_wp_i18n_namespaceObject.__)('Electric grass'),
  2890. gradient: 'linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%)',
  2891. slug: 'electric-grass'
  2892. }, {
  2893. name: (0,external_wp_i18n_namespaceObject.__)('Midnight'),
  2894. gradient: 'linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%)',
  2895. slug: 'midnight'
  2896. }],
  2897. __unstableResolvedAssets: {
  2898. styles: [],
  2899. scripts: []
  2900. }
  2901. };
  2902. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/array.js
  2903. /**
  2904. * External dependencies
  2905. */
  2906. /**
  2907. * Insert one or multiple elements into a given position of an array.
  2908. *
  2909. * @param {Array} array Source array.
  2910. * @param {*} elements Elements to insert.
  2911. * @param {number} index Insert Position.
  2912. *
  2913. * @return {Array} Result.
  2914. */
  2915. function insertAt(array, elements, index) {
  2916. return [...array.slice(0, index), ...(0,external_lodash_namespaceObject.castArray)(elements), ...array.slice(index)];
  2917. }
  2918. /**
  2919. * Moves an element in an array.
  2920. *
  2921. * @param {Array} array Source array.
  2922. * @param {number} from Source index.
  2923. * @param {number} to Destination index.
  2924. * @param {number} count Number of elements to move.
  2925. *
  2926. * @return {Array} Result.
  2927. */
  2928. function moveTo(array, from, to) {
  2929. let count = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
  2930. const withoutMovedElements = [...array];
  2931. withoutMovedElements.splice(from, count);
  2932. return insertAt(withoutMovedElements, array.slice(from, from + count), to);
  2933. }
  2934. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/reducer.js
  2935. /**
  2936. * External dependencies
  2937. */
  2938. /**
  2939. * WordPress dependencies
  2940. */
  2941. /**
  2942. * Internal dependencies
  2943. */
  2944. /**
  2945. * Given an array of blocks, returns an object where each key is a nesting
  2946. * context, the value of which is an array of block client IDs existing within
  2947. * that nesting context.
  2948. *
  2949. * @param {Array} blocks Blocks to map.
  2950. * @param {?string} rootClientId Assumed root client ID.
  2951. *
  2952. * @return {Object} Block order map object.
  2953. */
  2954. function mapBlockOrder(blocks) {
  2955. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  2956. const result = {
  2957. [rootClientId]: []
  2958. };
  2959. blocks.forEach(block => {
  2960. const {
  2961. clientId,
  2962. innerBlocks
  2963. } = block;
  2964. result[rootClientId].push(clientId);
  2965. Object.assign(result, mapBlockOrder(innerBlocks, clientId));
  2966. });
  2967. return result;
  2968. }
  2969. /**
  2970. * Given an array of blocks, returns an object where each key contains
  2971. * the clientId of the block and the value is the parent of the block.
  2972. *
  2973. * @param {Array} blocks Blocks to map.
  2974. * @param {?string} rootClientId Assumed root client ID.
  2975. *
  2976. * @return {Object} Block order map object.
  2977. */
  2978. function mapBlockParents(blocks) {
  2979. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  2980. return blocks.reduce((result, block) => Object.assign(result, {
  2981. [block.clientId]: rootClientId
  2982. }, mapBlockParents(block.innerBlocks, block.clientId)), {});
  2983. }
  2984. /**
  2985. * Helper method to iterate through all blocks, recursing into inner blocks,
  2986. * applying a transformation function to each one.
  2987. * Returns a flattened object with the transformed blocks.
  2988. *
  2989. * @param {Array} blocks Blocks to flatten.
  2990. * @param {Function} transform Transforming function to be applied to each block.
  2991. *
  2992. * @return {Object} Flattened object.
  2993. */
  2994. function flattenBlocks(blocks) {
  2995. let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : external_lodash_namespaceObject.identity;
  2996. const result = {};
  2997. const stack = [...blocks];
  2998. while (stack.length) {
  2999. const {
  3000. innerBlocks,
  3001. ...block
  3002. } = stack.shift();
  3003. stack.push(...innerBlocks);
  3004. result[block.clientId] = transform(block);
  3005. }
  3006. return result;
  3007. }
  3008. /**
  3009. * Given an array of blocks, returns an object containing all blocks, without
  3010. * attributes, recursing into inner blocks. Keys correspond to the block client
  3011. * ID, the value of which is the attributes object.
  3012. *
  3013. * @param {Array} blocks Blocks to flatten.
  3014. *
  3015. * @return {Object} Flattened block attributes object.
  3016. */
  3017. function getFlattenedBlocksWithoutAttributes(blocks) {
  3018. return flattenBlocks(blocks, block => (0,external_lodash_namespaceObject.omit)(block, 'attributes'));
  3019. }
  3020. /**
  3021. * Given an array of blocks, returns an object containing all block attributes,
  3022. * recursing into inner blocks. Keys correspond to the block client ID, the
  3023. * value of which is the attributes object.
  3024. *
  3025. * @param {Array} blocks Blocks to flatten.
  3026. *
  3027. * @return {Object} Flattened block attributes object.
  3028. */
  3029. function getFlattenedBlockAttributes(blocks) {
  3030. return flattenBlocks(blocks, block => block.attributes);
  3031. }
  3032. /**
  3033. * Returns an object against which it is safe to perform mutating operations,
  3034. * given the original object and its current working copy.
  3035. *
  3036. * @param {Object} original Original object.
  3037. * @param {Object} working Working object.
  3038. *
  3039. * @return {Object} Mutation-safe object.
  3040. */
  3041. function getMutateSafeObject(original, working) {
  3042. if (original === working) {
  3043. return { ...original
  3044. };
  3045. }
  3046. return working;
  3047. }
  3048. /**
  3049. * Returns true if the two object arguments have the same keys, or false
  3050. * otherwise.
  3051. *
  3052. * @param {Object} a First object.
  3053. * @param {Object} b Second object.
  3054. *
  3055. * @return {boolean} Whether the two objects have the same keys.
  3056. */
  3057. function hasSameKeys(a, b) {
  3058. return (0,external_lodash_namespaceObject.isEqual)((0,external_lodash_namespaceObject.keys)(a), (0,external_lodash_namespaceObject.keys)(b));
  3059. }
  3060. /**
  3061. * Returns true if, given the currently dispatching action and the previously
  3062. * dispatched action, the two actions are updating the same block attribute, or
  3063. * false otherwise.
  3064. *
  3065. * @param {Object} action Currently dispatching action.
  3066. * @param {Object} lastAction Previously dispatched action.
  3067. *
  3068. * @return {boolean} Whether actions are updating the same block attribute.
  3069. */
  3070. function isUpdatingSameBlockAttribute(action, lastAction) {
  3071. 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);
  3072. }
  3073. function buildBlockTree(state, blocks) {
  3074. const result = {};
  3075. const stack = [...blocks];
  3076. const flattenedBlocks = [...blocks];
  3077. while (stack.length) {
  3078. const block = stack.shift();
  3079. stack.push(...block.innerBlocks);
  3080. flattenedBlocks.push(...block.innerBlocks);
  3081. } // Create objects before mutating them, that way it's always defined.
  3082. for (const block of flattenedBlocks) {
  3083. result[block.clientId] = {};
  3084. }
  3085. for (const block of flattenedBlocks) {
  3086. result[block.clientId] = Object.assign(result[block.clientId], { ...state.byClientId[block.clientId],
  3087. attributes: state.attributes[block.clientId],
  3088. innerBlocks: block.innerBlocks.map(subBlock => result[subBlock.clientId])
  3089. });
  3090. }
  3091. return result;
  3092. }
  3093. function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
  3094. let updateChildrenOfUpdatedClientIds = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3095. const uncontrolledParents = new Set([]);
  3096. const controlledParents = new Set();
  3097. for (const clientId of updatedClientIds) {
  3098. let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents[clientId];
  3099. do {
  3100. if (state.controlledInnerBlocks[current]) {
  3101. // Should stop on controlled blocks.
  3102. // If we reach a controlled parent, break out of the loop.
  3103. controlledParents.add(current);
  3104. break;
  3105. } else {
  3106. // Else continue traversing up through parents.
  3107. uncontrolledParents.add(current);
  3108. current = state.parents[current];
  3109. }
  3110. } while (current !== undefined);
  3111. } // To make sure the order of assignments doesn't matter,
  3112. // we first create empty objects and mutates the inner blocks later.
  3113. for (const clientId of uncontrolledParents) {
  3114. tree[clientId] = { ...tree[clientId]
  3115. };
  3116. }
  3117. for (const clientId of uncontrolledParents) {
  3118. tree[clientId].innerBlocks = (state.order[clientId] || []).map(subClientId => tree[subClientId]);
  3119. } // Controlled parent blocks, need a dedicated key for their inner blocks
  3120. // to be used when doing getBlocks( controlledBlockClientId ).
  3121. for (const clientId of controlledParents) {
  3122. tree['controlled||' + clientId] = {
  3123. innerBlocks: (state.order[clientId] || []).map(subClientId => tree[subClientId])
  3124. };
  3125. }
  3126. return tree;
  3127. }
  3128. /**
  3129. * Higher-order reducer intended to compute full block objects key for each block in the post.
  3130. * This is a denormalization to optimize the performance of the getBlock selectors and avoid
  3131. * recomputing the block objects and avoid heavy memoization.
  3132. *
  3133. * @param {Function} reducer Original reducer function.
  3134. *
  3135. * @return {Function} Enhanced reducer function.
  3136. */
  3137. const withBlockTree = reducer => function () {
  3138. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3139. let action = arguments.length > 1 ? arguments[1] : undefined;
  3140. const newState = reducer(state, action);
  3141. if (newState === state) {
  3142. return state;
  3143. }
  3144. newState.tree = state.tree ? state.tree : {};
  3145. switch (action.type) {
  3146. case 'RECEIVE_BLOCKS':
  3147. case 'INSERT_BLOCKS':
  3148. {
  3149. const subTree = buildBlockTree(newState, action.blocks);
  3150. newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
  3151. ...subTree
  3152. }, action.rootClientId ? [action.rootClientId] : [''], true);
  3153. break;
  3154. }
  3155. case 'UPDATE_BLOCK':
  3156. newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
  3157. [action.clientId]: { ...newState.tree[action.clientId],
  3158. ...newState.byClientId[action.clientId],
  3159. attributes: newState.attributes[action.clientId]
  3160. }
  3161. }, [action.clientId], false);
  3162. break;
  3163. case 'UPDATE_BLOCK_ATTRIBUTES':
  3164. {
  3165. const newSubTree = action.clientIds.reduce((result, clientId) => {
  3166. result[clientId] = { ...newState.tree[clientId],
  3167. attributes: newState.attributes[clientId]
  3168. };
  3169. return result;
  3170. }, {});
  3171. newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
  3172. ...newSubTree
  3173. }, action.clientIds, false);
  3174. break;
  3175. }
  3176. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3177. {
  3178. const subTree = buildBlockTree(newState, action.blocks);
  3179. newState.tree = updateParentInnerBlocksInTree(newState, { ...(0,external_lodash_namespaceObject.omit)(newState.tree, action.replacedClientIds.concat( // Controlled inner blocks are only removed
  3180. // if the block doesn't move to another position
  3181. // otherwise their content will be lost.
  3182. action.replacedClientIds.filter(clientId => !subTree[clientId]).map(clientId => 'controlled||' + clientId))),
  3183. ...subTree
  3184. }, 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.
  3185. const parentsOfRemovedBlocks = [];
  3186. for (const clientId of action.clientIds) {
  3187. if (state.parents[clientId] !== undefined && (state.parents[clientId] === '' || newState.byClientId[state.parents[clientId]])) {
  3188. parentsOfRemovedBlocks.push(state.parents[clientId]);
  3189. }
  3190. }
  3191. newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, parentsOfRemovedBlocks, true);
  3192. break;
  3193. }
  3194. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3195. const parentsOfRemovedBlocks = [];
  3196. for (const clientId of action.clientIds) {
  3197. if (state.parents[clientId] !== undefined && (state.parents[clientId] === '' || newState.byClientId[state.parents[clientId]])) {
  3198. parentsOfRemovedBlocks.push(state.parents[clientId]);
  3199. }
  3200. }
  3201. newState.tree = updateParentInnerBlocksInTree(newState, (0,external_lodash_namespaceObject.omit)(newState.tree, action.removedClientIds.concat(action.removedClientIds.map(clientId => 'controlled||' + clientId))), parentsOfRemovedBlocks, true);
  3202. break;
  3203. case 'MOVE_BLOCKS_TO_POSITION':
  3204. {
  3205. const updatedBlockUids = [];
  3206. if (action.fromRootClientId) {
  3207. updatedBlockUids.push(action.fromRootClientId);
  3208. }
  3209. if (action.toRootClientId) {
  3210. updatedBlockUids.push(action.toRootClientId);
  3211. }
  3212. if (!action.fromRootClientId || !action.fromRootClientId) {
  3213. updatedBlockUids.push('');
  3214. }
  3215. newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, updatedBlockUids, true);
  3216. break;
  3217. }
  3218. case 'MOVE_BLOCKS_UP':
  3219. case 'MOVE_BLOCKS_DOWN':
  3220. {
  3221. const updatedBlockUids = [action.rootClientId ? action.rootClientId : ''];
  3222. newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, updatedBlockUids, true);
  3223. break;
  3224. }
  3225. case 'SAVE_REUSABLE_BLOCK_SUCCESS':
  3226. {
  3227. const updatedBlockUids = (0,external_lodash_namespaceObject.keys)((0,external_lodash_namespaceObject.omitBy)(newState.attributes, (attributes, clientId) => {
  3228. return newState.byClientId[clientId].name !== 'core/block' || attributes.ref !== action.updatedId;
  3229. }));
  3230. newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
  3231. ...updatedBlockUids.reduce((result, clientId) => {
  3232. result[clientId] = { ...newState.byClientId[clientId],
  3233. attributes: newState.attributes[clientId],
  3234. innerBlocks: newState.tree[clientId].innerBlocks
  3235. };
  3236. return result;
  3237. }, {})
  3238. }, updatedBlockUids, false);
  3239. }
  3240. }
  3241. return newState;
  3242. };
  3243. /**
  3244. * Higher-order reducer intended to augment the blocks reducer, assigning an
  3245. * `isPersistentChange` property value corresponding to whether a change in
  3246. * state can be considered as persistent. All changes are considered persistent
  3247. * except when updating the same block attribute as in the previous action.
  3248. *
  3249. * @param {Function} reducer Original reducer function.
  3250. *
  3251. * @return {Function} Enhanced reducer function.
  3252. */
  3253. function withPersistentBlockChange(reducer) {
  3254. let lastAction;
  3255. let markNextChangeAsNotPersistent = false;
  3256. return (state, action) => {
  3257. let nextState = reducer(state, action);
  3258. const isExplicitPersistentChange = action.type === 'MARK_LAST_CHANGE_AS_PERSISTENT' || markNextChangeAsNotPersistent; // Defer to previous state value (or default) unless changing or
  3259. // explicitly marking as persistent.
  3260. if (state === nextState && !isExplicitPersistentChange) {
  3261. var _state$isPersistentCh;
  3262. markNextChangeAsNotPersistent = action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
  3263. const nextIsPersistentChange = (_state$isPersistentCh = state === null || state === void 0 ? void 0 : state.isPersistentChange) !== null && _state$isPersistentCh !== void 0 ? _state$isPersistentCh : true;
  3264. if (state.isPersistentChange === nextIsPersistentChange) {
  3265. return state;
  3266. }
  3267. return { ...nextState,
  3268. isPersistentChange: nextIsPersistentChange
  3269. };
  3270. }
  3271. nextState = { ...nextState,
  3272. isPersistentChange: isExplicitPersistentChange ? !markNextChangeAsNotPersistent : !isUpdatingSameBlockAttribute(action, lastAction)
  3273. }; // In comparing against the previous action, consider only those which
  3274. // would have qualified as one which would have been ignored or not
  3275. // have resulted in a changed state.
  3276. lastAction = action;
  3277. markNextChangeAsNotPersistent = action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
  3278. return nextState;
  3279. };
  3280. }
  3281. /**
  3282. * Higher-order reducer intended to augment the blocks reducer, assigning an
  3283. * `isIgnoredChange` property value corresponding to whether a change in state
  3284. * can be considered as ignored. A change is considered ignored when the result
  3285. * of an action not incurred by direct user interaction.
  3286. *
  3287. * @param {Function} reducer Original reducer function.
  3288. *
  3289. * @return {Function} Enhanced reducer function.
  3290. */
  3291. function withIgnoredBlockChange(reducer) {
  3292. /**
  3293. * Set of action types for which a blocks state change should be ignored.
  3294. *
  3295. * @type {Set}
  3296. */
  3297. const IGNORED_ACTION_TYPES = new Set(['RECEIVE_BLOCKS']);
  3298. return (state, action) => {
  3299. const nextState = reducer(state, action);
  3300. if (nextState !== state) {
  3301. nextState.isIgnoredChange = IGNORED_ACTION_TYPES.has(action.type);
  3302. }
  3303. return nextState;
  3304. };
  3305. }
  3306. /**
  3307. * Higher-order reducer targeting the combined blocks reducer, augmenting
  3308. * block client IDs in remove action to include cascade of inner blocks.
  3309. *
  3310. * @param {Function} reducer Original reducer function.
  3311. *
  3312. * @return {Function} Enhanced reducer function.
  3313. */
  3314. const withInnerBlocksRemoveCascade = reducer => (state, action) => {
  3315. // Gets all children which need to be removed.
  3316. const getAllChildren = clientIds => {
  3317. let result = clientIds;
  3318. for (let i = 0; i < result.length; i++) {
  3319. if (!state.order[result[i]] || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i]]) {
  3320. continue;
  3321. }
  3322. if (result === clientIds) {
  3323. result = [...result];
  3324. }
  3325. result.push(...state.order[result[i]]);
  3326. }
  3327. return result;
  3328. };
  3329. if (state) {
  3330. switch (action.type) {
  3331. case 'REMOVE_BLOCKS':
  3332. action = { ...action,
  3333. type: 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN',
  3334. removedClientIds: getAllChildren(action.clientIds)
  3335. };
  3336. break;
  3337. case 'REPLACE_BLOCKS':
  3338. action = { ...action,
  3339. type: 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN',
  3340. replacedClientIds: getAllChildren(action.clientIds)
  3341. };
  3342. break;
  3343. }
  3344. }
  3345. return reducer(state, action);
  3346. };
  3347. /**
  3348. * Higher-order reducer which targets the combined blocks reducer and handles
  3349. * the `RESET_BLOCKS` action. When dispatched, this action will replace all
  3350. * blocks that exist in the post, leaving blocks that exist only in state (e.g.
  3351. * reusable blocks and blocks controlled by inner blocks controllers) alone.
  3352. *
  3353. * @param {Function} reducer Original reducer function.
  3354. *
  3355. * @return {Function} Enhanced reducer function.
  3356. */
  3357. const withBlockReset = reducer => (state, action) => {
  3358. if (action.type === 'RESET_BLOCKS') {
  3359. const newState = { ...state,
  3360. byClientId: getFlattenedBlocksWithoutAttributes(action.blocks),
  3361. attributes: getFlattenedBlockAttributes(action.blocks),
  3362. order: mapBlockOrder(action.blocks),
  3363. parents: mapBlockParents(action.blocks),
  3364. controlledInnerBlocks: {}
  3365. };
  3366. const subTree = buildBlockTree(newState, action.blocks);
  3367. newState.tree = { ...subTree,
  3368. // Root.
  3369. '': {
  3370. innerBlocks: action.blocks.map(subBlock => subTree[subBlock.clientId])
  3371. }
  3372. };
  3373. return newState;
  3374. }
  3375. return reducer(state, action);
  3376. };
  3377. /**
  3378. * Higher-order reducer which targets the combined blocks reducer and handles
  3379. * the `REPLACE_INNER_BLOCKS` action. When dispatched, this action the state
  3380. * should become equivalent to the execution of a `REMOVE_BLOCKS` action
  3381. * containing all the child's of the root block followed by the execution of
  3382. * `INSERT_BLOCKS` with the new blocks.
  3383. *
  3384. * @param {Function} reducer Original reducer function.
  3385. *
  3386. * @return {Function} Enhanced reducer function.
  3387. */
  3388. const withReplaceInnerBlocks = reducer => (state, action) => {
  3389. if (action.type !== 'REPLACE_INNER_BLOCKS') {
  3390. return reducer(state, action);
  3391. } // Finds every nested inner block controller. We must check the action blocks
  3392. // and not just the block parent state because some inner block controllers
  3393. // should be deleted if specified, whereas others should not be deleted. If
  3394. // a controlled should not be deleted, then we need to avoid deleting its
  3395. // inner blocks from the block state because its inner blocks will not be
  3396. // attached to the block in the action.
  3397. const nestedControllers = {};
  3398. if (Object.keys(state.controlledInnerBlocks).length) {
  3399. const stack = [...action.blocks];
  3400. while (stack.length) {
  3401. const {
  3402. innerBlocks,
  3403. ...block
  3404. } = stack.shift();
  3405. stack.push(...innerBlocks);
  3406. if (!!state.controlledInnerBlocks[block.clientId]) {
  3407. nestedControllers[block.clientId] = true;
  3408. }
  3409. }
  3410. } // The `keepControlledInnerBlocks` prop will keep the inner blocks of the
  3411. // marked block in the block state so that they can be reattached to the
  3412. // marked block when we re-insert everything a few lines below.
  3413. let stateAfterBlocksRemoval = state;
  3414. if (state.order[action.rootClientId]) {
  3415. stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, {
  3416. type: 'REMOVE_BLOCKS',
  3417. keepControlledInnerBlocks: nestedControllers,
  3418. clientIds: state.order[action.rootClientId]
  3419. });
  3420. }
  3421. let stateAfterInsert = stateAfterBlocksRemoval;
  3422. if (action.blocks.length) {
  3423. stateAfterInsert = reducer(stateAfterInsert, { ...action,
  3424. type: 'INSERT_BLOCKS',
  3425. index: 0
  3426. }); // We need to re-attach the block order of the controlled inner blocks.
  3427. // Otherwise, an inner block controller's blocks will be deleted entirely
  3428. // from its entity..
  3429. stateAfterInsert.order = { ...stateAfterInsert.order,
  3430. ...(0,external_lodash_namespaceObject.reduce)(nestedControllers, (result, value, key) => {
  3431. if (state.order[key]) {
  3432. result[key] = state.order[key];
  3433. }
  3434. return result;
  3435. }, {})
  3436. };
  3437. }
  3438. return stateAfterInsert;
  3439. };
  3440. /**
  3441. * Higher-order reducer which targets the combined blocks reducer and handles
  3442. * the `SAVE_REUSABLE_BLOCK_SUCCESS` action. This action can't be handled by
  3443. * regular reducers and needs a higher-order reducer since it needs access to
  3444. * both `byClientId` and `attributes` simultaneously.
  3445. *
  3446. * @param {Function} reducer Original reducer function.
  3447. *
  3448. * @return {Function} Enhanced reducer function.
  3449. */
  3450. const withSaveReusableBlock = reducer => (state, action) => {
  3451. if (state && action.type === 'SAVE_REUSABLE_BLOCK_SUCCESS') {
  3452. const {
  3453. id,
  3454. updatedId
  3455. } = action; // If a temporary reusable block is saved, we swap the temporary id with the final one.
  3456. if (id === updatedId) {
  3457. return state;
  3458. }
  3459. state = { ...state
  3460. };
  3461. state.attributes = (0,external_lodash_namespaceObject.mapValues)(state.attributes, (attributes, clientId) => {
  3462. const {
  3463. name
  3464. } = state.byClientId[clientId];
  3465. if (name === 'core/block' && attributes.ref === id) {
  3466. return { ...attributes,
  3467. ref: updatedId
  3468. };
  3469. }
  3470. return attributes;
  3471. });
  3472. }
  3473. return reducer(state, action);
  3474. };
  3475. /**
  3476. * Higher-order reducer which removes blocks from state when switching parent block controlled state.
  3477. *
  3478. * @param {Function} reducer Original reducer function.
  3479. *
  3480. * @return {Function} Enhanced reducer function.
  3481. */
  3482. const withResetControlledBlocks = reducer => (state, action) => {
  3483. if (action.type === 'SET_HAS_CONTROLLED_INNER_BLOCKS') {
  3484. // when switching a block from controlled to uncontrolled or inverse,
  3485. // we need to remove its content first.
  3486. const tempState = reducer(state, {
  3487. type: 'REPLACE_INNER_BLOCKS',
  3488. rootClientId: action.clientId,
  3489. blocks: []
  3490. });
  3491. return reducer(tempState, action);
  3492. }
  3493. return reducer(state, action);
  3494. };
  3495. /**
  3496. * Reducer returning the blocks state.
  3497. *
  3498. * @param {Object} state Current state.
  3499. * @param {Object} action Dispatched action.
  3500. *
  3501. * @return {Object} Updated state.
  3502. */
  3503. const blocks = (0,external_lodash_namespaceObject.flow)(external_wp_data_namespaceObject.combineReducers, withSaveReusableBlock, // Needs to be before withBlockCache.
  3504. withBlockTree, // Needs to be before withInnerBlocksRemoveCascade.
  3505. withInnerBlocksRemoveCascade, withReplaceInnerBlocks, // Needs to be after withInnerBlocksRemoveCascade.
  3506. withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetControlledBlocks)({
  3507. byClientId() {
  3508. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3509. let action = arguments.length > 1 ? arguments[1] : undefined;
  3510. switch (action.type) {
  3511. case 'RECEIVE_BLOCKS':
  3512. case 'INSERT_BLOCKS':
  3513. return { ...state,
  3514. ...getFlattenedBlocksWithoutAttributes(action.blocks)
  3515. };
  3516. case 'UPDATE_BLOCK':
  3517. // Ignore updates if block isn't known.
  3518. if (!state[action.clientId]) {
  3519. return state;
  3520. } // Do nothing if only attributes change.
  3521. const changes = (0,external_lodash_namespaceObject.omit)(action.updates, 'attributes');
  3522. if ((0,external_lodash_namespaceObject.isEmpty)(changes)) {
  3523. return state;
  3524. }
  3525. return { ...state,
  3526. [action.clientId]: { ...state[action.clientId],
  3527. ...changes
  3528. }
  3529. };
  3530. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3531. if (!action.blocks) {
  3532. return state;
  3533. }
  3534. return { ...(0,external_lodash_namespaceObject.omit)(state, action.replacedClientIds),
  3535. ...getFlattenedBlocksWithoutAttributes(action.blocks)
  3536. };
  3537. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3538. return (0,external_lodash_namespaceObject.omit)(state, action.removedClientIds);
  3539. }
  3540. return state;
  3541. },
  3542. attributes() {
  3543. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3544. let action = arguments.length > 1 ? arguments[1] : undefined;
  3545. switch (action.type) {
  3546. case 'RECEIVE_BLOCKS':
  3547. case 'INSERT_BLOCKS':
  3548. return { ...state,
  3549. ...getFlattenedBlockAttributes(action.blocks)
  3550. };
  3551. case 'UPDATE_BLOCK':
  3552. // Ignore updates if block isn't known or there are no attribute changes.
  3553. if (!state[action.clientId] || !action.updates.attributes) {
  3554. return state;
  3555. }
  3556. return { ...state,
  3557. [action.clientId]: { ...state[action.clientId],
  3558. ...action.updates.attributes
  3559. }
  3560. };
  3561. case 'UPDATE_BLOCK_ATTRIBUTES':
  3562. {
  3563. // Avoid a state change if none of the block IDs are known.
  3564. if (action.clientIds.every(id => !state[id])) {
  3565. return state;
  3566. }
  3567. const next = action.clientIds.reduce((accumulator, id) => ({ ...accumulator,
  3568. [id]: (0,external_lodash_namespaceObject.reduce)(action.uniqueByBlock ? action.attributes[id] : action.attributes, (result, value, key) => {
  3569. // Consider as updates only changed values.
  3570. if (value !== result[key]) {
  3571. result = getMutateSafeObject(state[id], result);
  3572. result[key] = value;
  3573. }
  3574. return result;
  3575. }, state[id])
  3576. }), {});
  3577. if (action.clientIds.every(id => next[id] === state[id])) {
  3578. return state;
  3579. }
  3580. return { ...state,
  3581. ...next
  3582. };
  3583. }
  3584. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3585. if (!action.blocks) {
  3586. return state;
  3587. }
  3588. return { ...(0,external_lodash_namespaceObject.omit)(state, action.replacedClientIds),
  3589. ...getFlattenedBlockAttributes(action.blocks)
  3590. };
  3591. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3592. return (0,external_lodash_namespaceObject.omit)(state, action.removedClientIds);
  3593. }
  3594. return state;
  3595. },
  3596. order() {
  3597. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3598. let action = arguments.length > 1 ? arguments[1] : undefined;
  3599. switch (action.type) {
  3600. case 'RECEIVE_BLOCKS':
  3601. {
  3602. const blockOrder = mapBlockOrder(action.blocks);
  3603. return { ...state,
  3604. ...(0,external_lodash_namespaceObject.omit)(blockOrder, ''),
  3605. '': ((state === null || state === void 0 ? void 0 : state['']) || []).concat(blockOrder[''])
  3606. };
  3607. }
  3608. case 'INSERT_BLOCKS':
  3609. {
  3610. const {
  3611. rootClientId = ''
  3612. } = action;
  3613. const subState = state[rootClientId] || [];
  3614. const mappedBlocks = mapBlockOrder(action.blocks, rootClientId);
  3615. const {
  3616. index = subState.length
  3617. } = action;
  3618. return { ...state,
  3619. ...mappedBlocks,
  3620. [rootClientId]: insertAt(subState, mappedBlocks[rootClientId], index)
  3621. };
  3622. }
  3623. case 'MOVE_BLOCKS_TO_POSITION':
  3624. {
  3625. const {
  3626. fromRootClientId = '',
  3627. toRootClientId = '',
  3628. clientIds
  3629. } = action;
  3630. const {
  3631. index = state[toRootClientId].length
  3632. } = action; // Moving inside the same parent block.
  3633. if (fromRootClientId === toRootClientId) {
  3634. const subState = state[toRootClientId];
  3635. const fromIndex = subState.indexOf(clientIds[0]);
  3636. return { ...state,
  3637. [toRootClientId]: moveTo(state[toRootClientId], fromIndex, index, clientIds.length)
  3638. };
  3639. } // Moving from a parent block to another.
  3640. return { ...state,
  3641. [fromRootClientId]: (0,external_lodash_namespaceObject.without)(state[fromRootClientId], ...clientIds),
  3642. [toRootClientId]: insertAt(state[toRootClientId], clientIds, index)
  3643. };
  3644. }
  3645. case 'MOVE_BLOCKS_UP':
  3646. {
  3647. const {
  3648. clientIds,
  3649. rootClientId = ''
  3650. } = action;
  3651. const firstClientId = (0,external_lodash_namespaceObject.first)(clientIds);
  3652. const subState = state[rootClientId];
  3653. if (!subState.length || firstClientId === (0,external_lodash_namespaceObject.first)(subState)) {
  3654. return state;
  3655. }
  3656. const firstIndex = subState.indexOf(firstClientId);
  3657. return { ...state,
  3658. [rootClientId]: moveTo(subState, firstIndex, firstIndex - 1, clientIds.length)
  3659. };
  3660. }
  3661. case 'MOVE_BLOCKS_DOWN':
  3662. {
  3663. const {
  3664. clientIds,
  3665. rootClientId = ''
  3666. } = action;
  3667. const firstClientId = (0,external_lodash_namespaceObject.first)(clientIds);
  3668. const lastClientId = (0,external_lodash_namespaceObject.last)(clientIds);
  3669. const subState = state[rootClientId];
  3670. if (!subState.length || lastClientId === (0,external_lodash_namespaceObject.last)(subState)) {
  3671. return state;
  3672. }
  3673. const firstIndex = subState.indexOf(firstClientId);
  3674. return { ...state,
  3675. [rootClientId]: moveTo(subState, firstIndex, firstIndex + 1, clientIds.length)
  3676. };
  3677. }
  3678. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3679. {
  3680. const {
  3681. clientIds
  3682. } = action;
  3683. if (!action.blocks) {
  3684. return state;
  3685. }
  3686. const mappedBlocks = mapBlockOrder(action.blocks);
  3687. return (0,external_lodash_namespaceObject.flow)([nextState => (0,external_lodash_namespaceObject.omit)(nextState, action.replacedClientIds), nextState => ({ ...nextState,
  3688. ...(0,external_lodash_namespaceObject.omit)(mappedBlocks, '')
  3689. }), nextState => (0,external_lodash_namespaceObject.mapValues)(nextState, subState => (0,external_lodash_namespaceObject.reduce)(subState, (result, clientId) => {
  3690. if (clientId === clientIds[0]) {
  3691. return [...result, ...mappedBlocks['']];
  3692. }
  3693. if (clientIds.indexOf(clientId) === -1) {
  3694. result.push(clientId);
  3695. }
  3696. return result;
  3697. }, []))])(state);
  3698. }
  3699. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3700. return (0,external_lodash_namespaceObject.flow)([// Remove inner block ordering for removed blocks.
  3701. nextState => (0,external_lodash_namespaceObject.omit)(nextState, action.removedClientIds), // Remove deleted blocks from other blocks' orderings.
  3702. nextState => (0,external_lodash_namespaceObject.mapValues)(nextState, subState => (0,external_lodash_namespaceObject.without)(subState, ...action.removedClientIds))])(state);
  3703. }
  3704. return state;
  3705. },
  3706. // While technically redundant data as the inverse of `order`, it serves as
  3707. // an optimization for the selectors which derive the ancestry of a block.
  3708. parents() {
  3709. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3710. let action = arguments.length > 1 ? arguments[1] : undefined;
  3711. switch (action.type) {
  3712. case 'RECEIVE_BLOCKS':
  3713. return { ...state,
  3714. ...mapBlockParents(action.blocks)
  3715. };
  3716. case 'INSERT_BLOCKS':
  3717. return { ...state,
  3718. ...mapBlockParents(action.blocks, action.rootClientId || '')
  3719. };
  3720. case 'MOVE_BLOCKS_TO_POSITION':
  3721. {
  3722. return { ...state,
  3723. ...action.clientIds.reduce((accumulator, id) => {
  3724. accumulator[id] = action.toRootClientId || '';
  3725. return accumulator;
  3726. }, {})
  3727. };
  3728. }
  3729. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3730. return { ...(0,external_lodash_namespaceObject.omit)(state, action.replacedClientIds),
  3731. ...mapBlockParents(action.blocks, state[action.clientIds[0]])
  3732. };
  3733. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  3734. return (0,external_lodash_namespaceObject.omit)(state, action.removedClientIds);
  3735. }
  3736. return state;
  3737. },
  3738. controlledInnerBlocks() {
  3739. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3740. let {
  3741. type,
  3742. clientId,
  3743. hasControlledInnerBlocks
  3744. } = arguments.length > 1 ? arguments[1] : undefined;
  3745. if (type === 'SET_HAS_CONTROLLED_INNER_BLOCKS') {
  3746. return { ...state,
  3747. [clientId]: hasControlledInnerBlocks
  3748. };
  3749. }
  3750. return state;
  3751. }
  3752. });
  3753. /**
  3754. * Reducer returning typing state.
  3755. *
  3756. * @param {boolean} state Current state.
  3757. * @param {Object} action Dispatched action.
  3758. *
  3759. * @return {boolean} Updated state.
  3760. */
  3761. function isTyping() {
  3762. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3763. let action = arguments.length > 1 ? arguments[1] : undefined;
  3764. switch (action.type) {
  3765. case 'START_TYPING':
  3766. return true;
  3767. case 'STOP_TYPING':
  3768. return false;
  3769. }
  3770. return state;
  3771. }
  3772. /**
  3773. * Reducer returning dragged block client id.
  3774. *
  3775. * @param {string[]} state Current state.
  3776. * @param {Object} action Dispatched action.
  3777. *
  3778. * @return {string[]} Updated state.
  3779. */
  3780. function draggedBlocks() {
  3781. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  3782. let action = arguments.length > 1 ? arguments[1] : undefined;
  3783. switch (action.type) {
  3784. case 'START_DRAGGING_BLOCKS':
  3785. return action.clientIds;
  3786. case 'STOP_DRAGGING_BLOCKS':
  3787. return [];
  3788. }
  3789. return state;
  3790. }
  3791. /**
  3792. * Reducer returning whether the caret is within formatted text.
  3793. *
  3794. * @param {boolean} state Current state.
  3795. * @param {Object} action Dispatched action.
  3796. *
  3797. * @return {boolean} Updated state.
  3798. */
  3799. function isCaretWithinFormattedText() {
  3800. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3801. let action = arguments.length > 1 ? arguments[1] : undefined;
  3802. switch (action.type) {
  3803. case 'ENTER_FORMATTED_TEXT':
  3804. return true;
  3805. case 'EXIT_FORMATTED_TEXT':
  3806. return false;
  3807. }
  3808. return state;
  3809. }
  3810. /**
  3811. * Internal helper reducer for selectionStart and selectionEnd. Can hold a block
  3812. * selection, represented by an object with property clientId.
  3813. *
  3814. * @param {Object} state Current state.
  3815. * @param {Object} action Dispatched action.
  3816. *
  3817. * @return {Object} Updated state.
  3818. */
  3819. function selectionHelper() {
  3820. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3821. let action = arguments.length > 1 ? arguments[1] : undefined;
  3822. switch (action.type) {
  3823. case 'CLEAR_SELECTED_BLOCK':
  3824. {
  3825. if (state.clientId) {
  3826. return {};
  3827. }
  3828. return state;
  3829. }
  3830. case 'SELECT_BLOCK':
  3831. if (action.clientId === state.clientId) {
  3832. return state;
  3833. }
  3834. return {
  3835. clientId: action.clientId
  3836. };
  3837. case 'REPLACE_INNER_BLOCKS':
  3838. case 'INSERT_BLOCKS':
  3839. {
  3840. if (!action.updateSelection || !action.blocks.length) {
  3841. return state;
  3842. }
  3843. return {
  3844. clientId: action.blocks[0].clientId
  3845. };
  3846. }
  3847. case 'REMOVE_BLOCKS':
  3848. if (!action.clientIds || !action.clientIds.length || action.clientIds.indexOf(state.clientId) === -1) {
  3849. return state;
  3850. }
  3851. return {};
  3852. case 'REPLACE_BLOCKS':
  3853. {
  3854. if (action.clientIds.indexOf(state.clientId) === -1) {
  3855. return state;
  3856. }
  3857. const blockToSelect = action.blocks[action.indexToSelect] || action.blocks[action.blocks.length - 1];
  3858. if (!blockToSelect) {
  3859. return {};
  3860. }
  3861. if (blockToSelect.clientId === state.clientId) {
  3862. return state;
  3863. }
  3864. return {
  3865. clientId: blockToSelect.clientId
  3866. };
  3867. }
  3868. }
  3869. return state;
  3870. }
  3871. /**
  3872. * Reducer returning the selection state.
  3873. *
  3874. * @param {boolean} state Current state.
  3875. * @param {Object} action Dispatched action.
  3876. *
  3877. * @return {boolean} Updated state.
  3878. */
  3879. function selection() {
  3880. var _state$selectionStart, _state$selectionEnd, _state$selectionStart2, _state$selectionEnd2;
  3881. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3882. let action = arguments.length > 1 ? arguments[1] : undefined;
  3883. switch (action.type) {
  3884. case 'SELECTION_CHANGE':
  3885. if (action.clientId) {
  3886. return {
  3887. selectionStart: {
  3888. clientId: action.clientId,
  3889. attributeKey: action.attributeKey,
  3890. offset: action.startOffset
  3891. },
  3892. selectionEnd: {
  3893. clientId: action.clientId,
  3894. attributeKey: action.attributeKey,
  3895. offset: action.endOffset
  3896. }
  3897. };
  3898. }
  3899. return {
  3900. selectionStart: action.start || state.selectionStart,
  3901. selectionEnd: action.end || state.selectionEnd
  3902. };
  3903. case 'RESET_SELECTION':
  3904. const {
  3905. selectionStart,
  3906. selectionEnd
  3907. } = action;
  3908. return {
  3909. selectionStart,
  3910. selectionEnd
  3911. };
  3912. case 'MULTI_SELECT':
  3913. const {
  3914. start,
  3915. end
  3916. } = action;
  3917. 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)) {
  3918. return state;
  3919. }
  3920. return {
  3921. selectionStart: {
  3922. clientId: start
  3923. },
  3924. selectionEnd: {
  3925. clientId: end
  3926. }
  3927. };
  3928. case 'RESET_BLOCKS':
  3929. const startClientId = state === null || state === void 0 ? void 0 : (_state$selectionStart2 = state.selectionStart) === null || _state$selectionStart2 === void 0 ? void 0 : _state$selectionStart2.clientId;
  3930. 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.
  3931. if (!startClientId && !endClientId) {
  3932. return state;
  3933. } // If the start of the selection won't exist after reset, remove selection.
  3934. if (!action.blocks.some(block => block.clientId === startClientId)) {
  3935. return {
  3936. selectionStart: {},
  3937. selectionEnd: {}
  3938. };
  3939. } // If the end of the selection won't exist after reset, collapse selection.
  3940. if (!action.blocks.some(block => block.clientId === endClientId)) {
  3941. return { ...state,
  3942. selectionEnd: state.selectionStart
  3943. };
  3944. }
  3945. }
  3946. return {
  3947. selectionStart: selectionHelper(state.selectionStart, action),
  3948. selectionEnd: selectionHelper(state.selectionEnd, action)
  3949. };
  3950. }
  3951. /**
  3952. * Reducer returning whether the user is multi-selecting.
  3953. *
  3954. * @param {boolean} state Current state.
  3955. * @param {Object} action Dispatched action.
  3956. *
  3957. * @return {boolean} Updated state.
  3958. */
  3959. function isMultiSelecting() {
  3960. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3961. let action = arguments.length > 1 ? arguments[1] : undefined;
  3962. switch (action.type) {
  3963. case 'START_MULTI_SELECT':
  3964. return true;
  3965. case 'STOP_MULTI_SELECT':
  3966. return false;
  3967. }
  3968. return state;
  3969. }
  3970. /**
  3971. * Reducer returning whether selection is enabled.
  3972. *
  3973. * @param {boolean} state Current state.
  3974. * @param {Object} action Dispatched action.
  3975. *
  3976. * @return {boolean} Updated state.
  3977. */
  3978. function isSelectionEnabled() {
  3979. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  3980. let action = arguments.length > 1 ? arguments[1] : undefined;
  3981. switch (action.type) {
  3982. case 'TOGGLE_SELECTION':
  3983. return action.isSelectionEnabled;
  3984. }
  3985. return state;
  3986. }
  3987. /**
  3988. * Reducer returning the initial block selection.
  3989. *
  3990. * Currently this in only used to restore the selection after block deletion and
  3991. * pasting new content.This reducer should eventually be removed in favour of setting
  3992. * selection directly.
  3993. *
  3994. * @param {boolean} state Current state.
  3995. * @param {Object} action Dispatched action.
  3996. *
  3997. * @return {number|null} Initial position: 0, -1 or null.
  3998. */
  3999. function initialPosition() {
  4000. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4001. let action = arguments.length > 1 ? arguments[1] : undefined;
  4002. if (action.type === 'REPLACE_BLOCKS' && action.initialPosition !== undefined) {
  4003. return action.initialPosition;
  4004. } else if (['MULTI_SELECT', 'SELECT_BLOCK', 'RESET_SELECTION', 'INSERT_BLOCKS', 'REPLACE_INNER_BLOCKS'].includes(action.type)) {
  4005. return action.initialPosition;
  4006. }
  4007. return state;
  4008. }
  4009. function blocksMode() {
  4010. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4011. let action = arguments.length > 1 ? arguments[1] : undefined;
  4012. if (action.type === 'TOGGLE_BLOCK_MODE') {
  4013. const {
  4014. clientId
  4015. } = action;
  4016. return { ...state,
  4017. [clientId]: state[clientId] && state[clientId] === 'html' ? 'visual' : 'html'
  4018. };
  4019. }
  4020. return state;
  4021. }
  4022. /**
  4023. * Reducer returning the block insertion point visibility, either null if there
  4024. * is not an explicit insertion point assigned, or an object of its `index` and
  4025. * `rootClientId`.
  4026. *
  4027. * @param {Object} state Current state.
  4028. * @param {Object} action Dispatched action.
  4029. *
  4030. * @return {Object} Updated state.
  4031. */
  4032. function insertionPoint() {
  4033. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4034. let action = arguments.length > 1 ? arguments[1] : undefined;
  4035. switch (action.type) {
  4036. case 'SHOW_INSERTION_POINT':
  4037. const {
  4038. rootClientId,
  4039. index,
  4040. __unstableWithInserter
  4041. } = action;
  4042. return {
  4043. rootClientId,
  4044. index,
  4045. __unstableWithInserter
  4046. };
  4047. case 'HIDE_INSERTION_POINT':
  4048. return null;
  4049. }
  4050. return state;
  4051. }
  4052. /**
  4053. * Reducer returning whether the post blocks match the defined template or not.
  4054. *
  4055. * @param {Object} state Current state.
  4056. * @param {Object} action Dispatched action.
  4057. *
  4058. * @return {boolean} Updated state.
  4059. */
  4060. function template() {
  4061. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  4062. isValid: true
  4063. };
  4064. let action = arguments.length > 1 ? arguments[1] : undefined;
  4065. switch (action.type) {
  4066. case 'SET_TEMPLATE_VALIDITY':
  4067. return { ...state,
  4068. isValid: action.isValid
  4069. };
  4070. }
  4071. return state;
  4072. }
  4073. /**
  4074. * Reducer returning the editor setting.
  4075. *
  4076. * @param {Object} state Current state.
  4077. * @param {Object} action Dispatched action.
  4078. *
  4079. * @return {Object} Updated state.
  4080. */
  4081. function settings() {
  4082. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SETTINGS_DEFAULTS;
  4083. let action = arguments.length > 1 ? arguments[1] : undefined;
  4084. switch (action.type) {
  4085. case 'UPDATE_SETTINGS':
  4086. return { ...state,
  4087. ...action.settings
  4088. };
  4089. }
  4090. return state;
  4091. }
  4092. /**
  4093. * Reducer returning the user preferences.
  4094. *
  4095. * @param {Object} state Current state.
  4096. * @param {Object} action Dispatched action.
  4097. *
  4098. * @return {string} Updated state.
  4099. */
  4100. function preferences() {
  4101. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PREFERENCES_DEFAULTS;
  4102. let action = arguments.length > 1 ? arguments[1] : undefined;
  4103. switch (action.type) {
  4104. case 'INSERT_BLOCKS':
  4105. case 'REPLACE_BLOCKS':
  4106. return action.blocks.reduce((prevState, block) => {
  4107. const {
  4108. attributes,
  4109. name: blockName
  4110. } = block;
  4111. 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
  4112. // one that is used for block variations in the Inserter (`getItemFromVariation`).
  4113. let id = match !== null && match !== void 0 && match.name ? `${blockName}/${match.name}` : blockName;
  4114. const insert = {
  4115. name: id
  4116. };
  4117. if (blockName === 'core/block') {
  4118. insert.ref = attributes.ref;
  4119. id += '/' + attributes.ref;
  4120. }
  4121. return { ...prevState,
  4122. insertUsage: { ...prevState.insertUsage,
  4123. [id]: {
  4124. time: action.time,
  4125. count: prevState.insertUsage[id] ? prevState.insertUsage[id].count + 1 : 1,
  4126. insert
  4127. }
  4128. }
  4129. };
  4130. }, state);
  4131. }
  4132. return state;
  4133. }
  4134. /**
  4135. * Reducer returning an object where each key is a block client ID, its value
  4136. * representing the settings for its nested blocks.
  4137. *
  4138. * @param {Object} state Current state.
  4139. * @param {Object} action Dispatched action.
  4140. *
  4141. * @return {Object} Updated state.
  4142. */
  4143. const blockListSettings = function () {
  4144. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4145. let action = arguments.length > 1 ? arguments[1] : undefined;
  4146. switch (action.type) {
  4147. // Even if the replaced blocks have the same client ID, our logic
  4148. // should correct the state.
  4149. case 'REPLACE_BLOCKS':
  4150. case 'REMOVE_BLOCKS':
  4151. {
  4152. return (0,external_lodash_namespaceObject.omit)(state, action.clientIds);
  4153. }
  4154. case 'UPDATE_BLOCK_LIST_SETTINGS':
  4155. {
  4156. const {
  4157. clientId
  4158. } = action;
  4159. if (!action.settings) {
  4160. if (state.hasOwnProperty(clientId)) {
  4161. return (0,external_lodash_namespaceObject.omit)(state, clientId);
  4162. }
  4163. return state;
  4164. }
  4165. if ((0,external_lodash_namespaceObject.isEqual)(state[clientId], action.settings)) {
  4166. return state;
  4167. }
  4168. return { ...state,
  4169. [clientId]: action.settings
  4170. };
  4171. }
  4172. }
  4173. return state;
  4174. };
  4175. /**
  4176. * Reducer returning whether the navigation mode is enabled or not.
  4177. *
  4178. * @param {string} state Current state.
  4179. * @param {Object} action Dispatched action.
  4180. *
  4181. * @return {string} Updated state.
  4182. */
  4183. function isNavigationMode() {
  4184. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4185. let action = arguments.length > 1 ? arguments[1] : undefined;
  4186. // Let inserting block always trigger Edit mode.
  4187. if (action.type === 'INSERT_BLOCKS') {
  4188. return false;
  4189. }
  4190. if (action.type === 'SET_NAVIGATION_MODE') {
  4191. return action.isNavigationMode;
  4192. }
  4193. return state;
  4194. }
  4195. /**
  4196. * Reducer returning whether the block moving mode is enabled or not.
  4197. *
  4198. * @param {string|null} state Current state.
  4199. * @param {Object} action Dispatched action.
  4200. *
  4201. * @return {string|null} Updated state.
  4202. */
  4203. function hasBlockMovingClientId() {
  4204. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4205. let action = arguments.length > 1 ? arguments[1] : undefined;
  4206. // Let inserting block always trigger Edit mode.
  4207. if (action.type === 'SET_BLOCK_MOVING_MODE') {
  4208. return action.hasBlockMovingClientId;
  4209. }
  4210. if (action.type === 'SET_NAVIGATION_MODE') {
  4211. return null;
  4212. }
  4213. return state;
  4214. }
  4215. /**
  4216. * Reducer return an updated state representing the most recent block attribute
  4217. * update. The state is structured as an object where the keys represent the
  4218. * client IDs of blocks, the values a subset of attributes from the most recent
  4219. * block update. The state is always reset to null if the last action is
  4220. * anything other than an attributes update.
  4221. *
  4222. * @param {Object<string,Object>} state Current state.
  4223. * @param {Object} action Action object.
  4224. *
  4225. * @return {[string,Object]} Updated state.
  4226. */
  4227. function lastBlockAttributesChange(state, action) {
  4228. switch (action.type) {
  4229. case 'UPDATE_BLOCK':
  4230. if (!action.updates.attributes) {
  4231. break;
  4232. }
  4233. return {
  4234. [action.clientId]: action.updates.attributes
  4235. };
  4236. case 'UPDATE_BLOCK_ATTRIBUTES':
  4237. return action.clientIds.reduce((accumulator, id) => ({ ...accumulator,
  4238. [id]: action.uniqueByBlock ? action.attributes[id] : action.attributes
  4239. }), {});
  4240. }
  4241. return null;
  4242. }
  4243. /**
  4244. * Reducer returning automatic change state.
  4245. *
  4246. * @param {boolean} state Current state.
  4247. * @param {Object} action Dispatched action.
  4248. *
  4249. * @return {string} Updated state.
  4250. */
  4251. function automaticChangeStatus(state, action) {
  4252. switch (action.type) {
  4253. case 'MARK_AUTOMATIC_CHANGE':
  4254. return 'pending';
  4255. case 'MARK_AUTOMATIC_CHANGE_FINAL':
  4256. if (state === 'pending') {
  4257. return 'final';
  4258. }
  4259. return;
  4260. case 'SELECTION_CHANGE':
  4261. // As long as the state is not final, ignore any selection changes.
  4262. if (state !== 'final') {
  4263. return state;
  4264. }
  4265. return;
  4266. // Undoing an automatic change should still be possible after mouse
  4267. // move.
  4268. case 'START_TYPING':
  4269. case 'STOP_TYPING':
  4270. return state;
  4271. } // Reset the state by default (for any action not handled).
  4272. }
  4273. /**
  4274. * Reducer returning current highlighted block.
  4275. *
  4276. * @param {boolean} state Current highlighted block.
  4277. * @param {Object} action Dispatched action.
  4278. *
  4279. * @return {string} Updated state.
  4280. */
  4281. function highlightedBlock(state, action) {
  4282. switch (action.type) {
  4283. case 'TOGGLE_BLOCK_HIGHLIGHT':
  4284. const {
  4285. clientId,
  4286. isHighlighted
  4287. } = action;
  4288. if (isHighlighted) {
  4289. return clientId;
  4290. } else if (state === clientId) {
  4291. return null;
  4292. }
  4293. return state;
  4294. case 'SELECT_BLOCK':
  4295. if (action.clientId !== state) {
  4296. return null;
  4297. }
  4298. }
  4299. return state;
  4300. }
  4301. /**
  4302. * Reducer returning the block insertion event list state.
  4303. *
  4304. * @param {Object} state Current state.
  4305. * @param {Object} action Dispatched action.
  4306. *
  4307. * @return {Object} Updated state.
  4308. */
  4309. function lastBlockInserted() {
  4310. var _action$meta;
  4311. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4312. let action = arguments.length > 1 ? arguments[1] : undefined;
  4313. switch (action.type) {
  4314. case 'INSERT_BLOCKS':
  4315. if (!action.blocks.length) {
  4316. return state;
  4317. }
  4318. const clientId = action.blocks[0].clientId;
  4319. const source = (_action$meta = action.meta) === null || _action$meta === void 0 ? void 0 : _action$meta.source;
  4320. return {
  4321. clientId,
  4322. source
  4323. };
  4324. case 'RESET_BLOCKS':
  4325. return {};
  4326. }
  4327. return state;
  4328. }
  4329. /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  4330. blocks,
  4331. isTyping,
  4332. draggedBlocks,
  4333. isCaretWithinFormattedText,
  4334. selection,
  4335. isMultiSelecting,
  4336. isSelectionEnabled,
  4337. initialPosition,
  4338. blocksMode,
  4339. blockListSettings,
  4340. insertionPoint,
  4341. template,
  4342. settings,
  4343. preferences,
  4344. lastBlockAttributesChange,
  4345. isNavigationMode,
  4346. hasBlockMovingClientId,
  4347. automaticChangeStatus,
  4348. highlightedBlock,
  4349. lastBlockInserted
  4350. }));
  4351. ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
  4352. var LEAF_KEY, hasWeakMap;
  4353. /**
  4354. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  4355. *
  4356. * @type {Object}
  4357. */
  4358. LEAF_KEY = {};
  4359. /**
  4360. * Whether environment supports WeakMap.
  4361. *
  4362. * @type {boolean}
  4363. */
  4364. hasWeakMap = typeof WeakMap !== 'undefined';
  4365. /**
  4366. * Returns the first argument as the sole entry in an array.
  4367. *
  4368. * @param {*} value Value to return.
  4369. *
  4370. * @return {Array} Value returned as entry in array.
  4371. */
  4372. function arrayOf( value ) {
  4373. return [ value ];
  4374. }
  4375. /**
  4376. * Returns true if the value passed is object-like, or false otherwise. A value
  4377. * is object-like if it can support property assignment, e.g. object or array.
  4378. *
  4379. * @param {*} value Value to test.
  4380. *
  4381. * @return {boolean} Whether value is object-like.
  4382. */
  4383. function isObjectLike( value ) {
  4384. return !! value && 'object' === typeof value;
  4385. }
  4386. /**
  4387. * Creates and returns a new cache object.
  4388. *
  4389. * @return {Object} Cache object.
  4390. */
  4391. function createCache() {
  4392. var cache = {
  4393. clear: function() {
  4394. cache.head = null;
  4395. },
  4396. };
  4397. return cache;
  4398. }
  4399. /**
  4400. * Returns true if entries within the two arrays are strictly equal by
  4401. * reference from a starting index.
  4402. *
  4403. * @param {Array} a First array.
  4404. * @param {Array} b Second array.
  4405. * @param {number} fromIndex Index from which to start comparison.
  4406. *
  4407. * @return {boolean} Whether arrays are shallowly equal.
  4408. */
  4409. function isShallowEqual( a, b, fromIndex ) {
  4410. var i;
  4411. if ( a.length !== b.length ) {
  4412. return false;
  4413. }
  4414. for ( i = fromIndex; i < a.length; i++ ) {
  4415. if ( a[ i ] !== b[ i ] ) {
  4416. return false;
  4417. }
  4418. }
  4419. return true;
  4420. }
  4421. /**
  4422. * Returns a memoized selector function. The getDependants function argument is
  4423. * called before the memoized selector and is expected to return an immutable
  4424. * reference or array of references on which the selector depends for computing
  4425. * its own return value. The memoize cache is preserved only as long as those
  4426. * dependant references remain the same. If getDependants returns a different
  4427. * reference(s), the cache is cleared and the selector value regenerated.
  4428. *
  4429. * @param {Function} selector Selector function.
  4430. * @param {Function} getDependants Dependant getter returning an immutable
  4431. * reference or array of reference used in
  4432. * cache bust consideration.
  4433. *
  4434. * @return {Function} Memoized selector.
  4435. */
  4436. /* harmony default export */ function rememo(selector, getDependants ) {
  4437. var rootCache, getCache;
  4438. // Use object source as dependant if getter not provided
  4439. if ( ! getDependants ) {
  4440. getDependants = arrayOf;
  4441. }
  4442. /**
  4443. * Returns the root cache. If WeakMap is supported, this is assigned to the
  4444. * root WeakMap cache set, otherwise it is a shared instance of the default
  4445. * cache object.
  4446. *
  4447. * @return {(WeakMap|Object)} Root cache object.
  4448. */
  4449. function getRootCache() {
  4450. return rootCache;
  4451. }
  4452. /**
  4453. * Returns the cache for a given dependants array. When possible, a WeakMap
  4454. * will be used to create a unique cache for each set of dependants. This
  4455. * is feasible due to the nature of WeakMap in allowing garbage collection
  4456. * to occur on entries where the key object is no longer referenced. Since
  4457. * WeakMap requires the key to be an object, this is only possible when the
  4458. * dependant is object-like. The root cache is created as a hierarchy where
  4459. * each top-level key is the first entry in a dependants set, the value a
  4460. * WeakMap where each key is the next dependant, and so on. This continues
  4461. * so long as the dependants are object-like. If no dependants are object-
  4462. * like, then the cache is shared across all invocations.
  4463. *
  4464. * @see isObjectLike
  4465. *
  4466. * @param {Array} dependants Selector dependants.
  4467. *
  4468. * @return {Object} Cache object.
  4469. */
  4470. function getWeakMapCache( dependants ) {
  4471. var caches = rootCache,
  4472. isUniqueByDependants = true,
  4473. i, dependant, map, cache;
  4474. for ( i = 0; i < dependants.length; i++ ) {
  4475. dependant = dependants[ i ];
  4476. // Can only compose WeakMap from object-like key.
  4477. if ( ! isObjectLike( dependant ) ) {
  4478. isUniqueByDependants = false;
  4479. break;
  4480. }
  4481. // Does current segment of cache already have a WeakMap?
  4482. if ( caches.has( dependant ) ) {
  4483. // Traverse into nested WeakMap.
  4484. caches = caches.get( dependant );
  4485. } else {
  4486. // Create, set, and traverse into a new one.
  4487. map = new WeakMap();
  4488. caches.set( dependant, map );
  4489. caches = map;
  4490. }
  4491. }
  4492. // We use an arbitrary (but consistent) object as key for the last item
  4493. // in the WeakMap to serve as our running cache.
  4494. if ( ! caches.has( LEAF_KEY ) ) {
  4495. cache = createCache();
  4496. cache.isUniqueByDependants = isUniqueByDependants;
  4497. caches.set( LEAF_KEY, cache );
  4498. }
  4499. return caches.get( LEAF_KEY );
  4500. }
  4501. // Assign cache handler by availability of WeakMap
  4502. getCache = hasWeakMap ? getWeakMapCache : getRootCache;
  4503. /**
  4504. * Resets root memoization cache.
  4505. */
  4506. function clear() {
  4507. rootCache = hasWeakMap ? new WeakMap() : createCache();
  4508. }
  4509. // eslint-disable-next-line jsdoc/check-param-names
  4510. /**
  4511. * The augmented selector call, considering first whether dependants have
  4512. * changed before passing it to underlying memoize function.
  4513. *
  4514. * @param {Object} source Source object for derivation.
  4515. * @param {...*} extraArgs Additional arguments to pass to selector.
  4516. *
  4517. * @return {*} Selector result.
  4518. */
  4519. function callSelector( /* source, ...extraArgs */ ) {
  4520. var len = arguments.length,
  4521. cache, node, i, args, dependants;
  4522. // Create copy of arguments (avoid leaking deoptimization).
  4523. args = new Array( len );
  4524. for ( i = 0; i < len; i++ ) {
  4525. args[ i ] = arguments[ i ];
  4526. }
  4527. dependants = getDependants.apply( null, args );
  4528. cache = getCache( dependants );
  4529. // If not guaranteed uniqueness by dependants (primitive type or lack
  4530. // of WeakMap support), shallow compare against last dependants and, if
  4531. // references have changed, destroy cache to recalculate result.
  4532. if ( ! cache.isUniqueByDependants ) {
  4533. if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
  4534. cache.clear();
  4535. }
  4536. cache.lastDependants = dependants;
  4537. }
  4538. node = cache.head;
  4539. while ( node ) {
  4540. // Check whether node arguments match arguments
  4541. if ( ! isShallowEqual( node.args, args, 1 ) ) {
  4542. node = node.next;
  4543. continue;
  4544. }
  4545. // At this point we can assume we've found a match
  4546. // Surface matched node to head if not already
  4547. if ( node !== cache.head ) {
  4548. // Adjust siblings to point to each other.
  4549. node.prev.next = node.next;
  4550. if ( node.next ) {
  4551. node.next.prev = node.prev;
  4552. }
  4553. node.next = cache.head;
  4554. node.prev = null;
  4555. cache.head.prev = node;
  4556. cache.head = node;
  4557. }
  4558. // Return immediately
  4559. return node.val;
  4560. }
  4561. // No cached value found. Continue to insertion phase:
  4562. node = {
  4563. // Generate the result from original function
  4564. val: selector.apply( null, args ),
  4565. };
  4566. // Avoid including the source object in the cache.
  4567. args[ 0 ] = null;
  4568. node.args = args;
  4569. // Don't need to check whether node is already head, since it would
  4570. // have been returned above already if it was
  4571. // Shift existing head down list
  4572. if ( cache.head ) {
  4573. cache.head.prev = node;
  4574. node.next = cache.head;
  4575. }
  4576. cache.head = node;
  4577. return node.val;
  4578. }
  4579. callSelector.getDependants = getDependants;
  4580. callSelector.clear = clear;
  4581. clear();
  4582. return callSelector;
  4583. }
  4584. ;// CONCATENATED MODULE: external ["wp","primitives"]
  4585. var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
  4586. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js
  4587. /**
  4588. * WordPress dependencies
  4589. */
  4590. const symbol = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  4591. xmlns: "http://www.w3.org/2000/svg",
  4592. viewBox: "0 0 24 24"
  4593. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  4594. 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"
  4595. }));
  4596. /* harmony default export */ var library_symbol = (symbol);
  4597. ;// CONCATENATED MODULE: external ["wp","richText"]
  4598. var external_wp_richText_namespaceObject = window["wp"]["richText"];
  4599. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/utils.js
  4600. /**
  4601. * Helper function that maps attribute definition properties to the
  4602. * ones used by RichText utils like `create, toHTMLString, etc..`.
  4603. *
  4604. * @param {Object} attributeDefinition A block's attribute definition object.
  4605. * @return {Object} The mapped object.
  4606. */
  4607. function mapRichTextSettings(attributeDefinition) {
  4608. const {
  4609. multiline: multilineTag,
  4610. __unstableMultilineWrapperTags: multilineWrapperTags,
  4611. __unstablePreserveWhiteSpace: preserveWhiteSpace
  4612. } = attributeDefinition;
  4613. return {
  4614. multilineTag,
  4615. multilineWrapperTags,
  4616. preserveWhiteSpace
  4617. };
  4618. }
  4619. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js
  4620. /**
  4621. * External dependencies
  4622. */
  4623. /**
  4624. * WordPress dependencies
  4625. */
  4626. /**
  4627. * Internal dependencies
  4628. */
  4629. /**
  4630. * A block selection object.
  4631. *
  4632. * @typedef {Object} WPBlockSelection
  4633. *
  4634. * @property {string} clientId A block client ID.
  4635. * @property {string} attributeKey A block attribute key.
  4636. * @property {number} offset An attribute value offset, based on the rich
  4637. * text value. See `wp.richText.create`.
  4638. */
  4639. // Module constants.
  4640. const MILLISECONDS_PER_HOUR = 3600 * 1000;
  4641. const MILLISECONDS_PER_DAY = 24 * 3600 * 1000;
  4642. const MILLISECONDS_PER_WEEK = 7 * 24 * 3600 * 1000;
  4643. /**
  4644. * Shared reference to an empty array for cases where it is important to avoid
  4645. * returning a new array reference on every invocation, as in a connected or
  4646. * other pure component which performs `shouldComponentUpdate` check on props.
  4647. * This should be used as a last resort, since the normalized data should be
  4648. * maintained by the reducer result in state.
  4649. *
  4650. * @type {Array}
  4651. */
  4652. const EMPTY_ARRAY = [];
  4653. /**
  4654. * Returns a block's name given its client ID, or null if no block exists with
  4655. * the client ID.
  4656. *
  4657. * @param {Object} state Editor state.
  4658. * @param {string} clientId Block client ID.
  4659. *
  4660. * @return {string} Block name.
  4661. */
  4662. function getBlockName(state, clientId) {
  4663. const block = state.blocks.byClientId[clientId];
  4664. const socialLinkName = 'core/social-link';
  4665. if (external_wp_element_namespaceObject.Platform.OS !== 'web' && (block === null || block === void 0 ? void 0 : block.name) === socialLinkName) {
  4666. const attributes = state.blocks.attributes[clientId];
  4667. const {
  4668. service
  4669. } = attributes;
  4670. return service ? `${socialLinkName}-${service}` : socialLinkName;
  4671. }
  4672. return block ? block.name : null;
  4673. }
  4674. /**
  4675. * Returns whether a block is valid or not.
  4676. *
  4677. * @param {Object} state Editor state.
  4678. * @param {string} clientId Block client ID.
  4679. *
  4680. * @return {boolean} Is Valid.
  4681. */
  4682. function isBlockValid(state, clientId) {
  4683. const block = state.blocks.byClientId[clientId];
  4684. return !!block && block.isValid;
  4685. }
  4686. /**
  4687. * Returns a block's attributes given its client ID, or null if no block exists with
  4688. * the client ID.
  4689. *
  4690. * @param {Object} state Editor state.
  4691. * @param {string} clientId Block client ID.
  4692. *
  4693. * @return {Object?} Block attributes.
  4694. */
  4695. function getBlockAttributes(state, clientId) {
  4696. const block = state.blocks.byClientId[clientId];
  4697. if (!block) {
  4698. return null;
  4699. }
  4700. return state.blocks.attributes[clientId];
  4701. }
  4702. /**
  4703. * Returns a block given its client ID. This is a parsed copy of the block,
  4704. * containing its `blockName`, `clientId`, and current `attributes` state. This
  4705. * is not the block's registration settings, which must be retrieved from the
  4706. * blocks module registration store.
  4707. *
  4708. * getBlock recurses through its inner blocks until all its children blocks have
  4709. * been retrieved. Note that getBlock will not return the child inner blocks of
  4710. * an inner block controller. This is because an inner block controller syncs
  4711. * itself with its own entity, and should therefore not be included with the
  4712. * blocks of a different entity. For example, say you call `getBlocks( TP )` to
  4713. * get the blocks of a template part. If another template part is a child of TP,
  4714. * then the nested template part's child blocks will not be returned. This way,
  4715. * the template block itself is considered part of the parent, but the children
  4716. * are not.
  4717. *
  4718. * @param {Object} state Editor state.
  4719. * @param {string} clientId Block client ID.
  4720. *
  4721. * @return {Object} Parsed block object.
  4722. */
  4723. function getBlock(state, clientId) {
  4724. const block = state.blocks.byClientId[clientId];
  4725. if (!block) {
  4726. return null;
  4727. }
  4728. return state.blocks.tree[clientId];
  4729. }
  4730. const __unstableGetBlockWithoutInnerBlocks = rememo((state, clientId) => {
  4731. const block = state.blocks.byClientId[clientId];
  4732. if (!block) {
  4733. return null;
  4734. }
  4735. return { ...block,
  4736. attributes: getBlockAttributes(state, clientId)
  4737. };
  4738. }, (state, clientId) => [state.blocks.byClientId[clientId], state.blocks.attributes[clientId]]);
  4739. /**
  4740. * Returns all block objects for the current post being edited as an array in
  4741. * the order they appear in the post. Note that this will exclude child blocks
  4742. * of nested inner block controllers.
  4743. *
  4744. * @param {Object} state Editor state.
  4745. * @param {?string} rootClientId Optional root client ID of block list.
  4746. *
  4747. * @return {Object[]} Post blocks.
  4748. */
  4749. function getBlocks(state, rootClientId) {
  4750. var _state$blocks$tree$tr;
  4751. const treeKey = !rootClientId || !areInnerBlocksControlled(state, rootClientId) ? rootClientId || '' : 'controlled||' + rootClientId;
  4752. 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;
  4753. }
  4754. /**
  4755. * Returns a stripped down block object containing only its client ID,
  4756. * and its inner blocks' client IDs.
  4757. *
  4758. * @param {Object} state Editor state.
  4759. * @param {string} clientId Client ID of the block to get.
  4760. *
  4761. * @return {Object} Client IDs of the post blocks.
  4762. */
  4763. const __unstableGetClientIdWithClientIdsTree = rememo((state, clientId) => ({
  4764. clientId,
  4765. innerBlocks: __unstableGetClientIdsTree(state, clientId)
  4766. }), state => [state.blocks.order]);
  4767. /**
  4768. * Returns the block tree represented in the block-editor store from the
  4769. * given root, consisting of stripped down block objects containing only
  4770. * their client IDs, and their inner blocks' client IDs.
  4771. *
  4772. * @param {Object} state Editor state.
  4773. * @param {?string} rootClientId Optional root client ID of block list.
  4774. *
  4775. * @return {Object[]} Client IDs of the post blocks.
  4776. */
  4777. const __unstableGetClientIdsTree = rememo(function (state) {
  4778. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  4779. return (0,external_lodash_namespaceObject.map)(getBlockOrder(state, rootClientId), clientId => __unstableGetClientIdWithClientIdsTree(state, clientId));
  4780. }, state => [state.blocks.order]);
  4781. /**
  4782. * Returns an array containing the clientIds of all descendants of the blocks
  4783. * given. Returned ids are ordered first by the order of the ids given, then
  4784. * by the order that they appear in the editor.
  4785. *
  4786. * @param {Object} state Global application state.
  4787. * @param {Array} clientIds Array of blocks to inspect.
  4788. *
  4789. * @return {Array} ids of descendants.
  4790. */
  4791. const getClientIdsOfDescendants = rememo((state, clientIds) => {
  4792. const collectedIds = [];
  4793. for (const givenId of clientIds) {
  4794. for (const descendantId of getBlockOrder(state, givenId)) {
  4795. collectedIds.push(descendantId, ...getClientIdsOfDescendants(state, [descendantId]));
  4796. }
  4797. }
  4798. return collectedIds;
  4799. }, state => [state.blocks.order]);
  4800. /**
  4801. * Returns an array containing the clientIds of the top-level blocks and
  4802. * their descendants of any depth (for nested blocks). Ids are returned
  4803. * in the same order that they appear in the editor.
  4804. *
  4805. * @param {Object} state Global application state.
  4806. *
  4807. * @return {Array} ids of top-level and descendant blocks.
  4808. */
  4809. const getClientIdsWithDescendants = rememo(state => {
  4810. const collectedIds = [];
  4811. for (const topLevelId of getBlockOrder(state)) {
  4812. collectedIds.push(topLevelId, ...getClientIdsOfDescendants(state, [topLevelId]));
  4813. }
  4814. return collectedIds;
  4815. }, state => [state.blocks.order]);
  4816. /**
  4817. * Returns the total number of blocks, or the total number of blocks with a specific name in a post.
  4818. * The number returned includes nested blocks.
  4819. *
  4820. * @param {Object} state Global application state.
  4821. * @param {?string} blockName Optional block name, if specified only blocks of that type will be counted.
  4822. *
  4823. * @return {number} Number of blocks in the post, or number of blocks with name equal to blockName.
  4824. */
  4825. const getGlobalBlockCount = rememo((state, blockName) => {
  4826. const clientIds = getClientIdsWithDescendants(state);
  4827. if (!blockName) {
  4828. return clientIds.length;
  4829. }
  4830. return (0,external_lodash_namespaceObject.reduce)(clientIds, (accumulator, clientId) => {
  4831. const block = state.blocks.byClientId[clientId];
  4832. return block.name === blockName ? accumulator + 1 : accumulator;
  4833. }, 0);
  4834. }, state => [state.blocks.order, state.blocks.byClientId]);
  4835. /**
  4836. * Returns all global blocks that match a blockName. Results include nested blocks.
  4837. *
  4838. * @param {Object} state Global application state.
  4839. * @param {?string} blockName Optional block name, if not specified, returns an empty array.
  4840. *
  4841. * @return {Array} Array of clientIds of blocks with name equal to blockName.
  4842. */
  4843. const __experimentalGetGlobalBlocksByName = rememo((state, blockName) => {
  4844. if (!blockName) {
  4845. return EMPTY_ARRAY;
  4846. }
  4847. const clientIds = getClientIdsWithDescendants(state);
  4848. const foundBlocks = clientIds.filter(clientId => {
  4849. const block = state.blocks.byClientId[clientId];
  4850. return block.name === blockName;
  4851. });
  4852. return foundBlocks.length > 0 ? foundBlocks : EMPTY_ARRAY;
  4853. }, state => [state.blocks.order, state.blocks.byClientId]);
  4854. /**
  4855. * Given an array of block client IDs, returns the corresponding array of block
  4856. * objects.
  4857. *
  4858. * @param {Object} state Editor state.
  4859. * @param {string[]} clientIds Client IDs for which blocks are to be returned.
  4860. *
  4861. * @return {WPBlock[]} Block objects.
  4862. */
  4863. 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]));
  4864. /**
  4865. * Returns the number of blocks currently present in the post.
  4866. *
  4867. * @param {Object} state Editor state.
  4868. * @param {?string} rootClientId Optional root client ID of block list.
  4869. *
  4870. * @return {number} Number of blocks in the post.
  4871. */
  4872. function getBlockCount(state, rootClientId) {
  4873. return getBlockOrder(state, rootClientId).length;
  4874. }
  4875. /**
  4876. * Returns the current selection start block client ID, attribute key and text
  4877. * offset.
  4878. *
  4879. * @param {Object} state Block editor state.
  4880. *
  4881. * @return {WPBlockSelection} Selection start information.
  4882. */
  4883. function getSelectionStart(state) {
  4884. return state.selection.selectionStart;
  4885. }
  4886. /**
  4887. * Returns the current selection end block client ID, attribute key and text
  4888. * offset.
  4889. *
  4890. * @param {Object} state Block editor state.
  4891. *
  4892. * @return {WPBlockSelection} Selection end information.
  4893. */
  4894. function getSelectionEnd(state) {
  4895. return state.selection.selectionEnd;
  4896. }
  4897. /**
  4898. * Returns the current block selection start. This value may be null, and it
  4899. * may represent either a singular block selection or multi-selection start.
  4900. * A selection is singular if its start and end match.
  4901. *
  4902. * @param {Object} state Global application state.
  4903. *
  4904. * @return {?string} Client ID of block selection start.
  4905. */
  4906. function getBlockSelectionStart(state) {
  4907. return state.selection.selectionStart.clientId;
  4908. }
  4909. /**
  4910. * Returns the current block selection end. This value may be null, and it
  4911. * may represent either a singular block selection or multi-selection end.
  4912. * A selection is singular if its start and end match.
  4913. *
  4914. * @param {Object} state Global application state.
  4915. *
  4916. * @return {?string} Client ID of block selection end.
  4917. */
  4918. function getBlockSelectionEnd(state) {
  4919. return state.selection.selectionEnd.clientId;
  4920. }
  4921. /**
  4922. * Returns the number of blocks currently selected in the post.
  4923. *
  4924. * @param {Object} state Global application state.
  4925. *
  4926. * @return {number} Number of blocks selected in the post.
  4927. */
  4928. function getSelectedBlockCount(state) {
  4929. const multiSelectedBlockCount = getMultiSelectedBlockClientIds(state).length;
  4930. if (multiSelectedBlockCount) {
  4931. return multiSelectedBlockCount;
  4932. }
  4933. return state.selection.selectionStart.clientId ? 1 : 0;
  4934. }
  4935. /**
  4936. * Returns true if there is a single selected block, or false otherwise.
  4937. *
  4938. * @param {Object} state Editor state.
  4939. *
  4940. * @return {boolean} Whether a single block is selected.
  4941. */
  4942. function hasSelectedBlock(state) {
  4943. const {
  4944. selectionStart,
  4945. selectionEnd
  4946. } = state.selection;
  4947. return !!selectionStart.clientId && selectionStart.clientId === selectionEnd.clientId;
  4948. }
  4949. /**
  4950. * Returns the currently selected block client ID, or null if there is no
  4951. * selected block.
  4952. *
  4953. * @param {Object} state Editor state.
  4954. *
  4955. * @return {?string} Selected block client ID.
  4956. */
  4957. function getSelectedBlockClientId(state) {
  4958. const {
  4959. selectionStart,
  4960. selectionEnd
  4961. } = state.selection;
  4962. const {
  4963. clientId
  4964. } = selectionStart;
  4965. if (!clientId || clientId !== selectionEnd.clientId) {
  4966. return null;
  4967. }
  4968. return clientId;
  4969. }
  4970. /**
  4971. * Returns the currently selected block, or null if there is no selected block.
  4972. *
  4973. * @param {Object} state Global application state.
  4974. *
  4975. * @return {?Object} Selected block.
  4976. */
  4977. function getSelectedBlock(state) {
  4978. const clientId = getSelectedBlockClientId(state);
  4979. return clientId ? getBlock(state, clientId) : null;
  4980. }
  4981. /**
  4982. * Given a block client ID, returns the root block from which the block is
  4983. * nested, an empty string for top-level blocks, or null if the block does not
  4984. * exist.
  4985. *
  4986. * @param {Object} state Editor state.
  4987. * @param {string} clientId Block from which to find root client ID.
  4988. *
  4989. * @return {?string} Root client ID, if exists
  4990. */
  4991. function getBlockRootClientId(state, clientId) {
  4992. return state.blocks.parents[clientId] !== undefined ? state.blocks.parents[clientId] : null;
  4993. }
  4994. /**
  4995. * Given a block client ID, returns the list of all its parents from top to bottom.
  4996. *
  4997. * @param {Object} state Editor state.
  4998. * @param {string} clientId Block from which to find root client ID.
  4999. * @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false).
  5000. *
  5001. * @return {Array} ClientIDs of the parent blocks.
  5002. */
  5003. const getBlockParents = rememo(function (state, clientId) {
  5004. let ascending = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5005. const parents = [];
  5006. let current = clientId;
  5007. while (!!state.blocks.parents[current]) {
  5008. current = state.blocks.parents[current];
  5009. parents.push(current);
  5010. }
  5011. return ascending ? parents : parents.reverse();
  5012. }, state => [state.blocks.parents]);
  5013. /**
  5014. * Given a block client ID and a block name, returns the list of all its parents
  5015. * from top to bottom, filtered by the given name(s). For example, if passed
  5016. * 'core/group' as the blockName, it will only return parents which are group
  5017. * blocks. If passed `[ 'core/group', 'core/cover']`, as the blockName, it will
  5018. * return parents which are group blocks and parents which are cover blocks.
  5019. *
  5020. * @param {Object} state Editor state.
  5021. * @param {string} clientId Block from which to find root client ID.
  5022. * @param {string|string[]} blockName Block name(s) to filter.
  5023. * @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false).
  5024. *
  5025. * @return {Array} ClientIDs of the parent blocks.
  5026. */
  5027. const getBlockParentsByBlockName = rememo(function (state, clientId, blockName) {
  5028. let ascending = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5029. const parents = getBlockParents(state, clientId, ascending);
  5030. return (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.map)(parents, id => ({
  5031. id,
  5032. name: getBlockName(state, id)
  5033. })), _ref => {
  5034. let {
  5035. name
  5036. } = _ref;
  5037. if (Array.isArray(blockName)) {
  5038. return blockName.includes(name);
  5039. }
  5040. return name === blockName;
  5041. }), _ref2 => {
  5042. let {
  5043. id
  5044. } = _ref2;
  5045. return id;
  5046. });
  5047. }, state => [state.blocks.parents]);
  5048. /**
  5049. * 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.
  5050. *
  5051. * @param {Object} state Editor state.
  5052. * @param {string} clientId Block from which to find root client ID.
  5053. *
  5054. * @return {string} Root client ID
  5055. */
  5056. function getBlockHierarchyRootClientId(state, clientId) {
  5057. let current = clientId;
  5058. let parent;
  5059. do {
  5060. parent = current;
  5061. current = state.blocks.parents[current];
  5062. } while (current);
  5063. return parent;
  5064. }
  5065. /**
  5066. * Given a block client ID, returns the lowest common ancestor with selected client ID.
  5067. *
  5068. * @param {Object} state Editor state.
  5069. * @param {string} clientId Block from which to find common ancestor client ID.
  5070. *
  5071. * @return {string} Common ancestor client ID or undefined
  5072. */
  5073. function getLowestCommonAncestorWithSelectedBlock(state, clientId) {
  5074. const selectedId = getSelectedBlockClientId(state);
  5075. const clientParents = [...getBlockParents(state, clientId), clientId];
  5076. const selectedParents = [...getBlockParents(state, selectedId), selectedId];
  5077. let lowestCommonAncestor;
  5078. const maxDepth = Math.min(clientParents.length, selectedParents.length);
  5079. for (let index = 0; index < maxDepth; index++) {
  5080. if (clientParents[index] === selectedParents[index]) {
  5081. lowestCommonAncestor = clientParents[index];
  5082. } else {
  5083. break;
  5084. }
  5085. }
  5086. return lowestCommonAncestor;
  5087. }
  5088. /**
  5089. * Returns the client ID of the block adjacent one at the given reference
  5090. * startClientId and modifier directionality. Defaults start startClientId to
  5091. * the selected block, and direction as next block. Returns null if there is no
  5092. * adjacent block.
  5093. *
  5094. * @param {Object} state Editor state.
  5095. * @param {?string} startClientId Optional client ID of block from which to
  5096. * search.
  5097. * @param {?number} modifier Directionality multiplier (1 next, -1
  5098. * previous).
  5099. *
  5100. * @return {?string} Return the client ID of the block, or null if none exists.
  5101. */
  5102. function getAdjacentBlockClientId(state, startClientId) {
  5103. let modifier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
  5104. // Default to selected block.
  5105. if (startClientId === undefined) {
  5106. startClientId = getSelectedBlockClientId(state);
  5107. } // Try multi-selection starting at extent based on modifier.
  5108. if (startClientId === undefined) {
  5109. if (modifier < 0) {
  5110. startClientId = getFirstMultiSelectedBlockClientId(state);
  5111. } else {
  5112. startClientId = getLastMultiSelectedBlockClientId(state);
  5113. }
  5114. } // Validate working start client ID.
  5115. if (!startClientId) {
  5116. return null;
  5117. } // Retrieve start block root client ID, being careful to allow the falsey
  5118. // empty string top-level root by explicitly testing against null.
  5119. const rootClientId = getBlockRootClientId(state, startClientId);
  5120. if (rootClientId === null) {
  5121. return null;
  5122. }
  5123. const {
  5124. order
  5125. } = state.blocks;
  5126. const orderSet = order[rootClientId];
  5127. const index = orderSet.indexOf(startClientId);
  5128. const nextIndex = index + 1 * modifier; // Block was first in set and we're attempting to get previous.
  5129. if (nextIndex < 0) {
  5130. return null;
  5131. } // Block was last in set and we're attempting to get next.
  5132. if (nextIndex === orderSet.length) {
  5133. return null;
  5134. } // Assume incremented index is within the set.
  5135. return orderSet[nextIndex];
  5136. }
  5137. /**
  5138. * Returns the previous block's client ID from the given reference start ID.
  5139. * Defaults start to the selected block. Returns null if there is no previous
  5140. * block.
  5141. *
  5142. * @param {Object} state Editor state.
  5143. * @param {?string} startClientId Optional client ID of block from which to
  5144. * search.
  5145. *
  5146. * @return {?string} Adjacent block's client ID, or null if none exists.
  5147. */
  5148. function getPreviousBlockClientId(state, startClientId) {
  5149. return getAdjacentBlockClientId(state, startClientId, -1);
  5150. }
  5151. /**
  5152. * Returns the next block's client ID from the given reference start ID.
  5153. * Defaults start to the selected block. Returns null if there is no next
  5154. * block.
  5155. *
  5156. * @param {Object} state Editor state.
  5157. * @param {?string} startClientId Optional client ID of block from which to
  5158. * search.
  5159. *
  5160. * @return {?string} Adjacent block's client ID, or null if none exists.
  5161. */
  5162. function getNextBlockClientId(state, startClientId) {
  5163. return getAdjacentBlockClientId(state, startClientId, 1);
  5164. }
  5165. /* eslint-disable jsdoc/valid-types */
  5166. /**
  5167. * Returns the initial caret position for the selected block.
  5168. * This position is to used to position the caret properly when the selected block changes.
  5169. * If the current block is not a RichText, having initial position set to 0 means "focus block"
  5170. *
  5171. * @param {Object} state Global application state.
  5172. *
  5173. * @return {0|-1|null} Initial position.
  5174. */
  5175. function getSelectedBlocksInitialCaretPosition(state) {
  5176. /* eslint-enable jsdoc/valid-types */
  5177. return state.initialPosition;
  5178. }
  5179. /**
  5180. * Returns the current selection set of block client IDs (multiselection or single selection).
  5181. *
  5182. * @param {Object} state Editor state.
  5183. *
  5184. * @return {Array} Multi-selected block client IDs.
  5185. */
  5186. const getSelectedBlockClientIds = rememo(state => {
  5187. const {
  5188. selectionStart,
  5189. selectionEnd
  5190. } = state.selection;
  5191. if (selectionStart.clientId === undefined || selectionEnd.clientId === undefined) {
  5192. return EMPTY_ARRAY;
  5193. }
  5194. if (selectionStart.clientId === selectionEnd.clientId) {
  5195. return [selectionStart.clientId];
  5196. } // Retrieve root client ID to aid in retrieving relevant nested block
  5197. // order, being careful to allow the falsey empty string top-level root
  5198. // by explicitly testing against null.
  5199. const rootClientId = getBlockRootClientId(state, selectionStart.clientId);
  5200. if (rootClientId === null) {
  5201. return EMPTY_ARRAY;
  5202. }
  5203. const blockOrder = getBlockOrder(state, rootClientId);
  5204. const startIndex = blockOrder.indexOf(selectionStart.clientId);
  5205. const endIndex = blockOrder.indexOf(selectionEnd.clientId);
  5206. if (startIndex > endIndex) {
  5207. return blockOrder.slice(endIndex, startIndex + 1);
  5208. }
  5209. return blockOrder.slice(startIndex, endIndex + 1);
  5210. }, state => [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId]);
  5211. /**
  5212. * Returns the current multi-selection set of block client IDs, or an empty
  5213. * array if there is no multi-selection.
  5214. *
  5215. * @param {Object} state Editor state.
  5216. *
  5217. * @return {Array} Multi-selected block client IDs.
  5218. */
  5219. function getMultiSelectedBlockClientIds(state) {
  5220. const {
  5221. selectionStart,
  5222. selectionEnd
  5223. } = state.selection;
  5224. if (selectionStart.clientId === selectionEnd.clientId) {
  5225. return EMPTY_ARRAY;
  5226. }
  5227. return getSelectedBlockClientIds(state);
  5228. }
  5229. /**
  5230. * Returns the current multi-selection set of blocks, or an empty array if
  5231. * there is no multi-selection.
  5232. *
  5233. * @param {Object} state Editor state.
  5234. *
  5235. * @return {Array} Multi-selected block objects.
  5236. */
  5237. const getMultiSelectedBlocks = rememo(state => {
  5238. const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(state);
  5239. if (!multiSelectedBlockClientIds.length) {
  5240. return EMPTY_ARRAY;
  5241. }
  5242. return multiSelectedBlockClientIds.map(clientId => getBlock(state, clientId));
  5243. }, state => [...getSelectedBlockClientIds.getDependants(state), state.blocks.byClientId, state.blocks.order, state.blocks.attributes]);
  5244. /**
  5245. * Returns the client ID of the first block in the multi-selection set, or null
  5246. * if there is no multi-selection.
  5247. *
  5248. * @param {Object} state Editor state.
  5249. *
  5250. * @return {?string} First block client ID in the multi-selection set.
  5251. */
  5252. function getFirstMultiSelectedBlockClientId(state) {
  5253. return (0,external_lodash_namespaceObject.first)(getMultiSelectedBlockClientIds(state)) || null;
  5254. }
  5255. /**
  5256. * Returns the client ID of the last block in the multi-selection set, or null
  5257. * if there is no multi-selection.
  5258. *
  5259. * @param {Object} state Editor state.
  5260. *
  5261. * @return {?string} Last block client ID in the multi-selection set.
  5262. */
  5263. function getLastMultiSelectedBlockClientId(state) {
  5264. return (0,external_lodash_namespaceObject.last)(getMultiSelectedBlockClientIds(state)) || null;
  5265. }
  5266. /**
  5267. * Returns true if a multi-selection exists, and the block corresponding to the
  5268. * specified client ID is the first block of the multi-selection set, or false
  5269. * otherwise.
  5270. *
  5271. * @param {Object} state Editor state.
  5272. * @param {string} clientId Block client ID.
  5273. *
  5274. * @return {boolean} Whether block is first in multi-selection.
  5275. */
  5276. function isFirstMultiSelectedBlock(state, clientId) {
  5277. return getFirstMultiSelectedBlockClientId(state) === clientId;
  5278. }
  5279. /**
  5280. * Returns true if the client ID occurs within the block multi-selection, or
  5281. * false otherwise.
  5282. *
  5283. * @param {Object} state Editor state.
  5284. * @param {string} clientId Block client ID.
  5285. *
  5286. * @return {boolean} Whether block is in multi-selection set.
  5287. */
  5288. function isBlockMultiSelected(state, clientId) {
  5289. return getMultiSelectedBlockClientIds(state).indexOf(clientId) !== -1;
  5290. }
  5291. /**
  5292. * Returns true if an ancestor of the block is multi-selected, or false
  5293. * otherwise.
  5294. *
  5295. * @param {Object} state Editor state.
  5296. * @param {string} clientId Block client ID.
  5297. *
  5298. * @return {boolean} Whether an ancestor of the block is in multi-selection
  5299. * set.
  5300. */
  5301. const isAncestorMultiSelected = rememo((state, clientId) => {
  5302. let ancestorClientId = clientId;
  5303. let isMultiSelected = false;
  5304. while (ancestorClientId && !isMultiSelected) {
  5305. ancestorClientId = getBlockRootClientId(state, ancestorClientId);
  5306. isMultiSelected = isBlockMultiSelected(state, ancestorClientId);
  5307. }
  5308. return isMultiSelected;
  5309. }, state => [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId]);
  5310. /**
  5311. * Returns the client ID of the block which begins the multi-selection set, or
  5312. * null if there is no multi-selection.
  5313. *
  5314. * This is not necessarily the first client ID in the selection.
  5315. *
  5316. * @see getFirstMultiSelectedBlockClientId
  5317. *
  5318. * @param {Object} state Editor state.
  5319. *
  5320. * @return {?string} Client ID of block beginning multi-selection.
  5321. */
  5322. function getMultiSelectedBlocksStartClientId(state) {
  5323. const {
  5324. selectionStart,
  5325. selectionEnd
  5326. } = state.selection;
  5327. if (selectionStart.clientId === selectionEnd.clientId) {
  5328. return null;
  5329. }
  5330. return selectionStart.clientId || null;
  5331. }
  5332. /**
  5333. * Returns the client ID of the block which ends the multi-selection set, or
  5334. * null if there is no multi-selection.
  5335. *
  5336. * This is not necessarily the last client ID in the selection.
  5337. *
  5338. * @see getLastMultiSelectedBlockClientId
  5339. *
  5340. * @param {Object} state Editor state.
  5341. *
  5342. * @return {?string} Client ID of block ending multi-selection.
  5343. */
  5344. function getMultiSelectedBlocksEndClientId(state) {
  5345. const {
  5346. selectionStart,
  5347. selectionEnd
  5348. } = state.selection;
  5349. if (selectionStart.clientId === selectionEnd.clientId) {
  5350. return null;
  5351. }
  5352. return selectionEnd.clientId || null;
  5353. }
  5354. /**
  5355. * Returns true if the selection is not partial.
  5356. *
  5357. * @param {Object} state Editor state.
  5358. *
  5359. * @return {boolean} Whether the selection is mergeable.
  5360. */
  5361. function __unstableIsFullySelected(state) {
  5362. const selectionAnchor = getSelectionStart(state);
  5363. const selectionFocus = getSelectionEnd(state);
  5364. return !selectionAnchor.attributeKey && !selectionFocus.attributeKey && typeof selectionAnchor.offset === 'undefined' && typeof selectionFocus.offset === 'undefined';
  5365. }
  5366. /**
  5367. * Returns true if the selection is collapsed.
  5368. *
  5369. * @param {Object} state Editor state.
  5370. *
  5371. * @return {boolean} Whether the selection is collapsed.
  5372. */
  5373. function __unstableIsSelectionCollapsed(state) {
  5374. const selectionAnchor = getSelectionStart(state);
  5375. const selectionFocus = getSelectionEnd(state);
  5376. return !!selectionAnchor && !!selectionFocus && selectionAnchor.clientId === selectionFocus.clientId && selectionAnchor.attributeKey === selectionFocus.attributeKey && selectionAnchor.offset === selectionFocus.offset;
  5377. }
  5378. /**
  5379. * Check whether the selection is mergeable.
  5380. *
  5381. * @param {Object} state Editor state.
  5382. * @param {boolean} isForward Whether to merge forwards.
  5383. *
  5384. * @return {boolean} Whether the selection is mergeable.
  5385. */
  5386. function __unstableIsSelectionMergeable(state, isForward) {
  5387. const selectionAnchor = getSelectionStart(state);
  5388. const selectionFocus = getSelectionEnd(state); // It's not mergeable if the start and end are within the same block.
  5389. if (selectionAnchor.clientId === selectionFocus.clientId) return false; // It's not mergeable if there's no rich text selection.
  5390. if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') return false;
  5391. const anchorRootClientId = getBlockRootClientId(state, selectionAnchor.clientId);
  5392. const focusRootClientId = getBlockRootClientId(state, selectionFocus.clientId); // It's not mergeable if the selection doesn't start and end in the same
  5393. // block list. Maybe in the future it should be allowed.
  5394. if (anchorRootClientId !== focusRootClientId) {
  5395. return false;
  5396. }
  5397. const blockOrder = getBlockOrder(state, anchorRootClientId);
  5398. const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
  5399. const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order.
  5400. let selectionStart, selectionEnd;
  5401. if (anchorIndex > focusIndex) {
  5402. selectionStart = selectionFocus;
  5403. selectionEnd = selectionAnchor;
  5404. } else {
  5405. selectionStart = selectionAnchor;
  5406. selectionEnd = selectionFocus;
  5407. }
  5408. const targetBlockClientId = isForward ? selectionEnd.clientId : selectionStart.clientId;
  5409. const blockToMergeClientId = isForward ? selectionStart.clientId : selectionEnd.clientId;
  5410. const targetBlock = getBlock(state, targetBlockClientId);
  5411. const targetBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(targetBlock.name);
  5412. if (!targetBlockType.merge) return false;
  5413. const blockToMerge = getBlock(state, blockToMergeClientId); // It's mergeable if the blocks are of the same type.
  5414. if (blockToMerge.name === targetBlock.name) return true; // If the blocks are of a different type, try to transform the block being
  5415. // merged into the same type of block.
  5416. const blocksToMerge = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blockToMerge, targetBlock.name);
  5417. return blocksToMerge && blocksToMerge.length;
  5418. }
  5419. /**
  5420. * Get partial selected blocks with their content updated
  5421. * based on the selection.
  5422. *
  5423. * @param {Object} state Editor state.
  5424. *
  5425. * @return {Object[]} Updated partial selected blocks.
  5426. */
  5427. const __unstableGetSelectedBlocksWithPartialSelection = state => {
  5428. const selectionAnchor = getSelectionStart(state);
  5429. const selectionFocus = getSelectionEnd(state);
  5430. if (selectionAnchor.clientId === selectionFocus.clientId) {
  5431. return EMPTY_ARRAY;
  5432. } // Can't split if the selection is not set.
  5433. if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') {
  5434. return EMPTY_ARRAY;
  5435. }
  5436. const anchorRootClientId = getBlockRootClientId(state, selectionAnchor.clientId);
  5437. const focusRootClientId = getBlockRootClientId(state, selectionFocus.clientId); // It's not splittable if the selection doesn't start and end in the same
  5438. // block list. Maybe in the future it should be allowed.
  5439. if (anchorRootClientId !== focusRootClientId) {
  5440. return EMPTY_ARRAY;
  5441. }
  5442. const blockOrder = getBlockOrder(state, anchorRootClientId);
  5443. const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
  5444. const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order.
  5445. const [selectionStart, selectionEnd] = anchorIndex > focusIndex ? [selectionFocus, selectionAnchor] : [selectionAnchor, selectionFocus];
  5446. const blockA = getBlock(state, selectionStart.clientId);
  5447. const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name);
  5448. const blockB = getBlock(state, selectionEnd.clientId);
  5449. const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name);
  5450. const htmlA = blockA.attributes[selectionStart.attributeKey];
  5451. const htmlB = blockB.attributes[selectionEnd.attributeKey];
  5452. const attributeDefinitionA = blockAType.attributes[selectionStart.attributeKey];
  5453. const attributeDefinitionB = blockBType.attributes[selectionEnd.attributeKey];
  5454. let valueA = (0,external_wp_richText_namespaceObject.create)({
  5455. html: htmlA,
  5456. ...mapRichTextSettings(attributeDefinitionA)
  5457. });
  5458. let valueB = (0,external_wp_richText_namespaceObject.create)({
  5459. html: htmlB,
  5460. ...mapRichTextSettings(attributeDefinitionB)
  5461. });
  5462. valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, 0, selectionStart.offset);
  5463. valueB = (0,external_wp_richText_namespaceObject.remove)(valueB, selectionEnd.offset, valueB.text.length);
  5464. return [{ ...blockA,
  5465. attributes: { ...blockA.attributes,
  5466. [selectionStart.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  5467. value: valueA,
  5468. ...mapRichTextSettings(attributeDefinitionA)
  5469. })
  5470. }
  5471. }, { ...blockB,
  5472. attributes: { ...blockB.attributes,
  5473. [selectionEnd.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  5474. value: valueB,
  5475. ...mapRichTextSettings(attributeDefinitionB)
  5476. })
  5477. }
  5478. }];
  5479. };
  5480. /**
  5481. * Returns an array containing all block client IDs in the editor in the order
  5482. * they appear. Optionally accepts a root client ID of the block list for which
  5483. * the order should be returned, defaulting to the top-level block order.
  5484. *
  5485. * @param {Object} state Editor state.
  5486. * @param {?string} rootClientId Optional root client ID of block list.
  5487. *
  5488. * @return {Array} Ordered client IDs of editor blocks.
  5489. */
  5490. function getBlockOrder(state, rootClientId) {
  5491. return state.blocks.order[rootClientId || ''] || EMPTY_ARRAY;
  5492. }
  5493. /**
  5494. * Returns the index at which the block corresponding to the specified client
  5495. * ID occurs within the block order, or `-1` if the block does not exist.
  5496. *
  5497. * @param {Object} state Editor state.
  5498. * @param {string} clientId Block client ID.
  5499. *
  5500. * @return {number} Index at which block exists in order.
  5501. */
  5502. function getBlockIndex(state, clientId) {
  5503. const rootClientId = getBlockRootClientId(state, clientId);
  5504. return getBlockOrder(state, rootClientId).indexOf(clientId);
  5505. }
  5506. /**
  5507. * Returns true if the block corresponding to the specified client ID is
  5508. * currently selected and no multi-selection exists, or false otherwise.
  5509. *
  5510. * @param {Object} state Editor state.
  5511. * @param {string} clientId Block client ID.
  5512. *
  5513. * @return {boolean} Whether block is selected and multi-selection exists.
  5514. */
  5515. function isBlockSelected(state, clientId) {
  5516. const {
  5517. selectionStart,
  5518. selectionEnd
  5519. } = state.selection;
  5520. if (selectionStart.clientId !== selectionEnd.clientId) {
  5521. return false;
  5522. }
  5523. return selectionStart.clientId === clientId;
  5524. }
  5525. /**
  5526. * Returns true if one of the block's inner blocks is selected.
  5527. *
  5528. * @param {Object} state Editor state.
  5529. * @param {string} clientId Block client ID.
  5530. * @param {boolean} deep Perform a deep check.
  5531. *
  5532. * @return {boolean} Whether the block as an inner block selected
  5533. */
  5534. function hasSelectedInnerBlock(state, clientId) {
  5535. let deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5536. return (0,external_lodash_namespaceObject.some)(getBlockOrder(state, clientId), innerClientId => isBlockSelected(state, innerClientId) || isBlockMultiSelected(state, innerClientId) || deep && hasSelectedInnerBlock(state, innerClientId, deep));
  5537. }
  5538. /**
  5539. * Returns true if the block corresponding to the specified client ID is
  5540. * currently selected but isn't the last of the selected blocks. Here "last"
  5541. * refers to the block sequence in the document, _not_ the sequence of
  5542. * multi-selection, which is why `state.selectionEnd` isn't used.
  5543. *
  5544. * @param {Object} state Editor state.
  5545. * @param {string} clientId Block client ID.
  5546. *
  5547. * @return {boolean} Whether block is selected and not the last in the
  5548. * selection.
  5549. */
  5550. function isBlockWithinSelection(state, clientId) {
  5551. if (!clientId) {
  5552. return false;
  5553. }
  5554. const clientIds = getMultiSelectedBlockClientIds(state);
  5555. const index = clientIds.indexOf(clientId);
  5556. return index > -1 && index < clientIds.length - 1;
  5557. }
  5558. /**
  5559. * Returns true if a multi-selection has been made, or false otherwise.
  5560. *
  5561. * @param {Object} state Editor state.
  5562. *
  5563. * @return {boolean} Whether multi-selection has been made.
  5564. */
  5565. function hasMultiSelection(state) {
  5566. const {
  5567. selectionStart,
  5568. selectionEnd
  5569. } = state.selection;
  5570. return selectionStart.clientId !== selectionEnd.clientId;
  5571. }
  5572. /**
  5573. * Whether in the process of multi-selecting or not. This flag is only true
  5574. * while the multi-selection is being selected (by mouse move), and is false
  5575. * once the multi-selection has been settled.
  5576. *
  5577. * @see hasMultiSelection
  5578. *
  5579. * @param {Object} state Global application state.
  5580. *
  5581. * @return {boolean} True if multi-selecting, false if not.
  5582. */
  5583. function selectors_isMultiSelecting(state) {
  5584. return state.isMultiSelecting;
  5585. }
  5586. /**
  5587. * Selector that returns if multi-selection is enabled or not.
  5588. *
  5589. * @param {Object} state Global application state.
  5590. *
  5591. * @return {boolean} True if it should be possible to multi-select blocks, false if multi-selection is disabled.
  5592. */
  5593. function selectors_isSelectionEnabled(state) {
  5594. return state.isSelectionEnabled;
  5595. }
  5596. /**
  5597. * Returns the block's editing mode, defaulting to "visual" if not explicitly
  5598. * assigned.
  5599. *
  5600. * @param {Object} state Editor state.
  5601. * @param {string} clientId Block client ID.
  5602. *
  5603. * @return {Object} Block editing mode.
  5604. */
  5605. function getBlockMode(state, clientId) {
  5606. return state.blocksMode[clientId] || 'visual';
  5607. }
  5608. /**
  5609. * Returns true if the user is typing, or false otherwise.
  5610. *
  5611. * @param {Object} state Global application state.
  5612. *
  5613. * @return {boolean} Whether user is typing.
  5614. */
  5615. function selectors_isTyping(state) {
  5616. return state.isTyping;
  5617. }
  5618. /**
  5619. * Returns true if the user is dragging blocks, or false otherwise.
  5620. *
  5621. * @param {Object} state Global application state.
  5622. *
  5623. * @return {boolean} Whether user is dragging blocks.
  5624. */
  5625. function isDraggingBlocks(state) {
  5626. return !!state.draggedBlocks.length;
  5627. }
  5628. /**
  5629. * Returns the client ids of any blocks being directly dragged.
  5630. *
  5631. * This does not include children of a parent being dragged.
  5632. *
  5633. * @param {Object} state Global application state.
  5634. *
  5635. * @return {string[]} Array of dragged block client ids.
  5636. */
  5637. function getDraggedBlockClientIds(state) {
  5638. return state.draggedBlocks;
  5639. }
  5640. /**
  5641. * Returns whether the block is being dragged.
  5642. *
  5643. * Only returns true if the block is being directly dragged,
  5644. * not if the block is a child of a parent being dragged.
  5645. * See `isAncestorBeingDragged` for child blocks.
  5646. *
  5647. * @param {Object} state Global application state.
  5648. * @param {string} clientId Client id for block to check.
  5649. *
  5650. * @return {boolean} Whether the block is being dragged.
  5651. */
  5652. function isBlockBeingDragged(state, clientId) {
  5653. return state.draggedBlocks.includes(clientId);
  5654. }
  5655. /**
  5656. * Returns whether a parent/ancestor of the block is being dragged.
  5657. *
  5658. * @param {Object} state Global application state.
  5659. * @param {string} clientId Client id for block to check.
  5660. *
  5661. * @return {boolean} Whether the block's ancestor is being dragged.
  5662. */
  5663. function isAncestorBeingDragged(state, clientId) {
  5664. // Return early if no blocks are being dragged rather than
  5665. // the more expensive check for parents.
  5666. if (!isDraggingBlocks(state)) {
  5667. return false;
  5668. }
  5669. const parents = getBlockParents(state, clientId);
  5670. return (0,external_lodash_namespaceObject.some)(parents, parentClientId => isBlockBeingDragged(state, parentClientId));
  5671. }
  5672. /**
  5673. * Returns true if the caret is within formatted text, or false otherwise.
  5674. *
  5675. * @param {Object} state Global application state.
  5676. *
  5677. * @return {boolean} Whether the caret is within formatted text.
  5678. */
  5679. function selectors_isCaretWithinFormattedText(state) {
  5680. return state.isCaretWithinFormattedText;
  5681. }
  5682. /**
  5683. * Returns the insertion point, the index at which the new inserted block would
  5684. * be placed. Defaults to the last index.
  5685. *
  5686. * @param {Object} state Editor state.
  5687. *
  5688. * @return {Object} Insertion point object with `rootClientId`, `index`.
  5689. */
  5690. function getBlockInsertionPoint(state) {
  5691. let rootClientId, index;
  5692. const {
  5693. insertionPoint,
  5694. selection: {
  5695. selectionEnd
  5696. }
  5697. } = state;
  5698. if (insertionPoint !== null) {
  5699. return insertionPoint;
  5700. }
  5701. const {
  5702. clientId
  5703. } = selectionEnd;
  5704. if (clientId) {
  5705. rootClientId = getBlockRootClientId(state, clientId) || undefined;
  5706. index = getBlockIndex(state, selectionEnd.clientId, rootClientId) + 1;
  5707. } else {
  5708. index = getBlockOrder(state).length;
  5709. }
  5710. return {
  5711. rootClientId,
  5712. index
  5713. };
  5714. }
  5715. /**
  5716. * Returns true if we should show the block insertion point.
  5717. *
  5718. * @param {Object} state Global application state.
  5719. *
  5720. * @return {?boolean} Whether the insertion point is visible or not.
  5721. */
  5722. function isBlockInsertionPointVisible(state) {
  5723. return state.insertionPoint !== null;
  5724. }
  5725. /**
  5726. * Returns whether the blocks matches the template or not.
  5727. *
  5728. * @param {boolean} state
  5729. * @return {?boolean} Whether the template is valid or not.
  5730. */
  5731. function isValidTemplate(state) {
  5732. return state.template.isValid;
  5733. }
  5734. /**
  5735. * Returns the defined block template
  5736. *
  5737. * @param {boolean} state
  5738. *
  5739. * @return {?Array} Block Template.
  5740. */
  5741. function getTemplate(state) {
  5742. return state.settings.template;
  5743. }
  5744. /**
  5745. * Returns the defined block template lock. Optionally accepts a root block
  5746. * client ID as context, otherwise defaulting to the global context.
  5747. *
  5748. * @param {Object} state Editor state.
  5749. * @param {?string} rootClientId Optional block root client ID.
  5750. *
  5751. * @return {?string} Block Template Lock
  5752. */
  5753. function getTemplateLock(state, rootClientId) {
  5754. if (!rootClientId) {
  5755. return state.settings.templateLock;
  5756. }
  5757. const blockListSettings = getBlockListSettings(state, rootClientId);
  5758. if (!blockListSettings) {
  5759. return null;
  5760. }
  5761. return blockListSettings.templateLock;
  5762. }
  5763. const checkAllowList = function (list, item) {
  5764. let defaultResult = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5765. if ((0,external_lodash_namespaceObject.isBoolean)(list)) {
  5766. return list;
  5767. }
  5768. if ((0,external_lodash_namespaceObject.isArray)(list)) {
  5769. // TODO: when there is a canonical way to detect that we are editing a post
  5770. // the following check should be changed to something like:
  5771. // if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )
  5772. if (list.includes('core/post-content') && item === null) {
  5773. return true;
  5774. }
  5775. return list.includes(item);
  5776. }
  5777. return defaultResult;
  5778. };
  5779. /**
  5780. * Determines if the given block type is allowed to be inserted into the block list.
  5781. * This function is not exported and not memoized because using a memoized selector
  5782. * inside another memoized selector is just a waste of time.
  5783. *
  5784. * @param {Object} state Editor state.
  5785. * @param {string|Object} blockName The block type object, e.g., the response
  5786. * from the block directory; or a string name of
  5787. * an installed block type, e.g.' core/paragraph'.
  5788. * @param {?string} rootClientId Optional root client ID of block list.
  5789. *
  5790. * @return {boolean} Whether the given block type is allowed to be inserted.
  5791. */
  5792. const canInsertBlockTypeUnmemoized = function (state, blockName) {
  5793. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5794. let blockType;
  5795. if (blockName && 'object' === typeof blockName) {
  5796. blockType = blockName;
  5797. blockName = blockType.name;
  5798. } else {
  5799. blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName);
  5800. }
  5801. if (!blockType) {
  5802. return false;
  5803. }
  5804. const {
  5805. allowedBlockTypes
  5806. } = getSettings(state);
  5807. const isBlockAllowedInEditor = checkAllowList(allowedBlockTypes, blockName, true);
  5808. if (!isBlockAllowedInEditor) {
  5809. return false;
  5810. }
  5811. const isLocked = !!getTemplateLock(state, rootClientId);
  5812. if (isLocked) {
  5813. return false;
  5814. }
  5815. const parentBlockListSettings = getBlockListSettings(state, rootClientId); // The parent block doesn't have settings indicating it doesn't support
  5816. // inner blocks, return false.
  5817. if (rootClientId && parentBlockListSettings === undefined) {
  5818. return false;
  5819. }
  5820. const parentAllowedBlocks = parentBlockListSettings === null || parentBlockListSettings === void 0 ? void 0 : parentBlockListSettings.allowedBlocks;
  5821. const hasParentAllowedBlock = checkAllowList(parentAllowedBlocks, blockName);
  5822. const blockAllowedParentBlocks = blockType.parent;
  5823. const parentName = getBlockName(state, rootClientId);
  5824. const hasBlockAllowedParent = checkAllowList(blockAllowedParentBlocks, parentName);
  5825. let hasBlockAllowedAncestor = true;
  5826. const blockAllowedAncestorBlocks = blockType.ancestor;
  5827. if (blockAllowedAncestorBlocks) {
  5828. const ancestors = [rootClientId, ...getBlockParents(state, rootClientId)];
  5829. hasBlockAllowedAncestor = (0,external_lodash_namespaceObject.some)(ancestors, ancestorClientId => checkAllowList(blockAllowedAncestorBlocks, getBlockName(state, ancestorClientId)));
  5830. }
  5831. const canInsert = hasBlockAllowedAncestor && (hasParentAllowedBlock === null && hasBlockAllowedParent === null || hasParentAllowedBlock === true || hasBlockAllowedParent === true);
  5832. if (!canInsert) {
  5833. return canInsert;
  5834. }
  5835. /**
  5836. * This filter is an ad-hoc solution to prevent adding template parts inside post content.
  5837. * Conceptually, having a filter inside a selector is bad pattern so this code will be
  5838. * replaced by a declarative API that doesn't the following drawbacks:
  5839. *
  5840. * Filters are not reactive: Upon switching between "template mode" and non "template mode",
  5841. * the filter and selector won't necessarily be executed again. For now, it doesn't matter much
  5842. * because you can't switch between the two modes while the inserter stays open.
  5843. *
  5844. * Filters are global: Once they're defined, they will affect all editor instances and all registries.
  5845. * An ideal API would only affect specific editor instances.
  5846. */
  5847. return (0,external_wp_hooks_namespaceObject.applyFilters)('blockEditor.__unstableCanInsertBlockType', canInsert, blockType, rootClientId, {
  5848. // Pass bound selectors of the current registry. If we're in a nested
  5849. // context, the data will differ from the one selected from the root
  5850. // registry.
  5851. getBlock: getBlock.bind(null, state),
  5852. getBlockParentsByBlockName: getBlockParentsByBlockName.bind(null, state)
  5853. });
  5854. };
  5855. /**
  5856. * Determines if the given block type is allowed to be inserted into the block list.
  5857. *
  5858. * @param {Object} state Editor state.
  5859. * @param {string} blockName The name of the block type, e.g.' core/paragraph'.
  5860. * @param {?string} rootClientId Optional root client ID of block list.
  5861. *
  5862. * @return {boolean} Whether the given block type is allowed to be inserted.
  5863. */
  5864. const canInsertBlockType = rememo(canInsertBlockTypeUnmemoized, (state, blockName, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId[rootClientId], state.settings.allowedBlockTypes, state.settings.templateLock]);
  5865. /**
  5866. * Determines if the given blocks are allowed to be inserted into the block
  5867. * list.
  5868. *
  5869. * @param {Object} state Editor state.
  5870. * @param {string} clientIds The block client IDs to be inserted.
  5871. * @param {?string} rootClientId Optional root client ID of block list.
  5872. *
  5873. * @return {boolean} Whether the given blocks are allowed to be inserted.
  5874. */
  5875. function canInsertBlocks(state, clientIds) {
  5876. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5877. return clientIds.every(id => canInsertBlockType(state, getBlockName(state, id), rootClientId));
  5878. }
  5879. /**
  5880. * Determines if the given block is allowed to be deleted.
  5881. *
  5882. * @param {Object} state Editor state.
  5883. * @param {string} clientId The block client Id.
  5884. * @param {?string} rootClientId Optional root client ID of block list.
  5885. *
  5886. * @return {boolean} Whether the given block is allowed to be removed.
  5887. */
  5888. function canRemoveBlock(state, clientId) {
  5889. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5890. const attributes = getBlockAttributes(state, clientId); // attributes can be null if the block is already deleted.
  5891. if (attributes === null) {
  5892. return true;
  5893. }
  5894. const {
  5895. lock
  5896. } = attributes;
  5897. const parentIsLocked = !!getTemplateLock(state, rootClientId); // If we don't have a lock on the blockType level, we defer to the parent templateLock.
  5898. if (lock === undefined || (lock === null || lock === void 0 ? void 0 : lock.remove) === undefined) {
  5899. return !parentIsLocked;
  5900. } // When remove is true, it means we cannot remove it.
  5901. return !(lock !== null && lock !== void 0 && lock.remove);
  5902. }
  5903. /**
  5904. * Determines if the given blocks are allowed to be removed.
  5905. *
  5906. * @param {Object} state Editor state.
  5907. * @param {string} clientIds The block client IDs to be removed.
  5908. * @param {?string} rootClientId Optional root client ID of block list.
  5909. *
  5910. * @return {boolean} Whether the given blocks are allowed to be removed.
  5911. */
  5912. function canRemoveBlocks(state, clientIds) {
  5913. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5914. return clientIds.every(clientId => canRemoveBlock(state, clientId, rootClientId));
  5915. }
  5916. /**
  5917. * Determines if the given block is allowed to be moved.
  5918. *
  5919. * @param {Object} state Editor state.
  5920. * @param {string} clientId The block client Id.
  5921. * @param {?string} rootClientId Optional root client ID of block list.
  5922. *
  5923. * @return {boolean} Whether the given block is allowed to be moved.
  5924. */
  5925. function canMoveBlock(state, clientId) {
  5926. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5927. const attributes = getBlockAttributes(state, clientId);
  5928. if (attributes === null) {
  5929. return;
  5930. }
  5931. const {
  5932. lock
  5933. } = attributes;
  5934. const parentIsLocked = getTemplateLock(state, rootClientId) === 'all'; // If we don't have a lock on the blockType level, we defer to the parent templateLock.
  5935. if (lock === undefined || (lock === null || lock === void 0 ? void 0 : lock.move) === undefined) {
  5936. return !parentIsLocked;
  5937. } // When move is true, it means we cannot move it.
  5938. return !(lock !== null && lock !== void 0 && lock.move);
  5939. }
  5940. /**
  5941. * Determines if the given blocks are allowed to be moved.
  5942. *
  5943. * @param {Object} state Editor state.
  5944. * @param {string} clientIds The block client IDs to be moved.
  5945. * @param {?string} rootClientId Optional root client ID of block list.
  5946. *
  5947. * @return {boolean} Whether the given blocks are allowed to be moved.
  5948. */
  5949. function canMoveBlocks(state, clientIds) {
  5950. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5951. return clientIds.every(clientId => canMoveBlock(state, clientId, rootClientId));
  5952. }
  5953. /**
  5954. * Determines if the given block type can be locked/unlocked by a user.
  5955. *
  5956. * @param {Object} state Editor state.
  5957. * @param {(string|Object)} nameOrType Block name or type object.
  5958. *
  5959. * @return {boolean} Whether a given block type can be locked/unlocked.
  5960. */
  5961. function canLockBlockType(state, nameOrType) {
  5962. var _state$settings;
  5963. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(nameOrType, 'lock', true)) {
  5964. return false;
  5965. } // Use block editor settings as the default value.
  5966. return !!((_state$settings = state.settings) !== null && _state$settings !== void 0 && _state$settings.canLockBlocks);
  5967. }
  5968. /**
  5969. * Returns information about how recently and frequently a block has been inserted.
  5970. *
  5971. * @param {Object} state Global application state.
  5972. * @param {string} id A string which identifies the insert, e.g. 'core/block/12'
  5973. *
  5974. * @return {?{ time: number, count: number }} An object containing `time` which is when the last
  5975. * insert occurred as a UNIX epoch, and `count` which is
  5976. * the number of inserts that have occurred.
  5977. */
  5978. function getInsertUsage(state, id) {
  5979. var _state$preferences$in, _state$preferences$in2;
  5980. 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;
  5981. }
  5982. /**
  5983. * Returns whether we can show a block type in the inserter
  5984. *
  5985. * @param {Object} state Global State
  5986. * @param {Object} blockType BlockType
  5987. * @param {?string} rootClientId Optional root client ID of block list.
  5988. *
  5989. * @return {boolean} Whether the given block type is allowed to be shown in the inserter.
  5990. */
  5991. const canIncludeBlockTypeInInserter = (state, blockType, rootClientId) => {
  5992. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'inserter', true)) {
  5993. return false;
  5994. }
  5995. return canInsertBlockTypeUnmemoized(state, blockType.name, rootClientId);
  5996. };
  5997. /**
  5998. * Return a function to be used to tranform a block variation to an inserter item
  5999. *
  6000. * @param {Object} state Global State
  6001. * @param {Object} item Denormalized inserter item
  6002. * @return {Function} Function to transform a block variation to inserter item
  6003. */
  6004. const getItemFromVariation = (state, item) => variation => {
  6005. const variationId = `${item.id}/${variation.name}`;
  6006. const {
  6007. time,
  6008. count = 0
  6009. } = getInsertUsage(state, variationId) || {};
  6010. return { ...item,
  6011. id: variationId,
  6012. icon: variation.icon || item.icon,
  6013. title: variation.title || item.title,
  6014. description: variation.description || item.description,
  6015. category: variation.category || item.category,
  6016. // If `example` is explicitly undefined for the variation, the preview will not be shown.
  6017. example: variation.hasOwnProperty('example') ? variation.example : item.example,
  6018. initialAttributes: { ...item.initialAttributes,
  6019. ...variation.attributes
  6020. },
  6021. innerBlocks: variation.innerBlocks,
  6022. keywords: variation.keywords || item.keywords,
  6023. frecency: calculateFrecency(time, count)
  6024. };
  6025. };
  6026. /**
  6027. * Returns the calculated frecency.
  6028. *
  6029. * 'frecency' is a heuristic (https://en.wikipedia.org/wiki/Frecency)
  6030. * that combines block usage frequenty and recency.
  6031. *
  6032. * @param {number} time When the last insert occurred as a UNIX epoch
  6033. * @param {number} count The number of inserts that have occurred.
  6034. *
  6035. * @return {number} The calculated frecency.
  6036. */
  6037. const calculateFrecency = (time, count) => {
  6038. if (!time) {
  6039. return count;
  6040. } // The selector is cached, which means Date.now() is the last time that the
  6041. // relevant state changed. This suits our needs.
  6042. const duration = Date.now() - time;
  6043. switch (true) {
  6044. case duration < MILLISECONDS_PER_HOUR:
  6045. return count * 4;
  6046. case duration < MILLISECONDS_PER_DAY:
  6047. return count * 2;
  6048. case duration < MILLISECONDS_PER_WEEK:
  6049. return count / 2;
  6050. default:
  6051. return count / 4;
  6052. }
  6053. };
  6054. /**
  6055. * Returns a function that accepts a block type and builds an item to be shown
  6056. * in a specific context. It's used for building items for Inserter and available
  6057. * block Transfroms list.
  6058. *
  6059. * @param {Object} state Editor state.
  6060. * @param {Object} options Options object for handling the building of a block type.
  6061. * @param {string} options.buildScope The scope for which the item is going to be used.
  6062. * @return {Function} Function returns an item to be shown in a specific context (Inserter|Transforms list).
  6063. */
  6064. const buildBlockTypeItem = (state, _ref3) => {
  6065. let {
  6066. buildScope = 'inserter'
  6067. } = _ref3;
  6068. return blockType => {
  6069. const id = blockType.name;
  6070. let isDisabled = false;
  6071. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType.name, 'multiple', true)) {
  6072. isDisabled = (0,external_lodash_namespaceObject.some)(getBlocksByClientId(state, getClientIdsWithDescendants(state)), {
  6073. name: blockType.name
  6074. });
  6075. }
  6076. const {
  6077. time,
  6078. count = 0
  6079. } = getInsertUsage(state, id) || {};
  6080. const blockItemBase = {
  6081. id,
  6082. name: blockType.name,
  6083. title: blockType.title,
  6084. icon: blockType.icon,
  6085. isDisabled,
  6086. frecency: calculateFrecency(time, count)
  6087. };
  6088. if (buildScope === 'transform') return blockItemBase;
  6089. const inserterVariations = (0,external_wp_blocks_namespaceObject.getBlockVariations)(blockType.name, 'inserter');
  6090. return { ...blockItemBase,
  6091. initialAttributes: {},
  6092. description: blockType.description,
  6093. category: blockType.category,
  6094. keywords: blockType.keywords,
  6095. variations: inserterVariations,
  6096. example: blockType.example,
  6097. utility: 1 // Deprecated.
  6098. };
  6099. };
  6100. };
  6101. /**
  6102. * Determines the items that appear in the inserter. Includes both static
  6103. * items (e.g. a regular block type) and dynamic items (e.g. a reusable block).
  6104. *
  6105. * Each item object contains what's necessary to display a button in the
  6106. * inserter and handle its selection.
  6107. *
  6108. * The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency)
  6109. * that combines block usage frequenty and recency.
  6110. *
  6111. * Items are returned ordered descendingly by their 'utility' and 'frecency'.
  6112. *
  6113. * @param {Object} state Editor state.
  6114. * @param {?string} rootClientId Optional root client ID of block list.
  6115. *
  6116. * @return {WPEditorInserterItem[]} Items that appear in inserter.
  6117. *
  6118. * @typedef {Object} WPEditorInserterItem
  6119. * @property {string} id Unique identifier for the item.
  6120. * @property {string} name The type of block to create.
  6121. * @property {Object} initialAttributes Attributes to pass to the newly created block.
  6122. * @property {string} title Title of the item, as it appears in the inserter.
  6123. * @property {string} icon Dashicon for the item, as it appears in the inserter.
  6124. * @property {string} category Block category that the item is associated with.
  6125. * @property {string[]} keywords Keywords that can be searched to find this item.
  6126. * @property {boolean} isDisabled Whether or not the user should be prevented from inserting
  6127. * this item.
  6128. * @property {number} frecency Heuristic that combines frequency and recency.
  6129. */
  6130. const getInserterItems = rememo(function (state) {
  6131. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6132. const buildBlockTypeInserterItem = buildBlockTypeItem(state, {
  6133. buildScope: 'inserter'
  6134. });
  6135. /*
  6136. * Matches block comment delimiters amid serialized content.
  6137. *
  6138. * @see `tokenizer` in `@wordpress/block-serialization-default-parser`
  6139. * package
  6140. *
  6141. * blockParserTokenizer differs from the original tokenizer in the
  6142. * following ways:
  6143. *
  6144. * - removed global flag (/g)
  6145. * - prepended ^\s*
  6146. *
  6147. */
  6148. const blockParserTokenizer = /^\s*<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/;
  6149. const buildReusableBlockInserterItem = reusableBlock => {
  6150. let icon = library_symbol;
  6151. /*
  6152. * Instead of always displaying a generic "symbol" icon for every
  6153. * reusable block, try to use an icon that represents the first
  6154. * outermost block contained in the reusable block. This requires
  6155. * scanning the serialized form of the reusable block to find its
  6156. * first block delimiter, then looking up the corresponding block
  6157. * type, if available.
  6158. */
  6159. if (external_wp_element_namespaceObject.Platform.OS === 'web') {
  6160. const content = typeof reusableBlock.content.raw === 'string' ? reusableBlock.content.raw : reusableBlock.content;
  6161. const rawBlockMatch = content.match(blockParserTokenizer);
  6162. if (rawBlockMatch) {
  6163. const [,, namespace = 'core/', blockName] = rawBlockMatch;
  6164. const referencedBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(namespace + blockName);
  6165. if (referencedBlockType) {
  6166. icon = referencedBlockType.icon;
  6167. }
  6168. }
  6169. }
  6170. const id = `core/block/${reusableBlock.id}`;
  6171. const {
  6172. time,
  6173. count = 0
  6174. } = getInsertUsage(state, id) || {};
  6175. const frecency = calculateFrecency(time, count);
  6176. return {
  6177. id,
  6178. name: 'core/block',
  6179. initialAttributes: {
  6180. ref: reusableBlock.id
  6181. },
  6182. title: reusableBlock.title.raw,
  6183. icon,
  6184. category: 'reusable',
  6185. keywords: [],
  6186. isDisabled: false,
  6187. utility: 1,
  6188. // Deprecated.
  6189. frecency
  6190. };
  6191. };
  6192. const blockTypeInserterItems = (0,external_wp_blocks_namespaceObject.getBlockTypes)().filter(blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)).map(buildBlockTypeInserterItem);
  6193. const reusableBlockInserterItems = canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) ? getReusableBlocks(state).map(buildReusableBlockInserterItem) : [];
  6194. const items = blockTypeInserterItems.reduce((accumulator, item) => {
  6195. const {
  6196. variations = []
  6197. } = item; // Exclude any block type item that is to be replaced by a default variation.
  6198. if (!variations.some(_ref4 => {
  6199. let {
  6200. isDefault
  6201. } = _ref4;
  6202. return isDefault;
  6203. })) {
  6204. accumulator.push(item);
  6205. }
  6206. if (variations.length) {
  6207. const variationMapper = getItemFromVariation(state, item);
  6208. accumulator.push(...variations.map(variationMapper));
  6209. }
  6210. return accumulator;
  6211. }, []); // Ensure core blocks are prioritized in the returned results,
  6212. // because third party blocks can be registered earlier than
  6213. // the core blocks (usually by using the `init` action),
  6214. // thus affecting the display order.
  6215. // We don't sort reusable blocks as they are handled differently.
  6216. const groupByType = (blocks, block) => {
  6217. const {
  6218. core,
  6219. noncore
  6220. } = blocks;
  6221. const type = block.name.startsWith('core/') ? core : noncore;
  6222. type.push(block);
  6223. return blocks;
  6224. };
  6225. const {
  6226. core: coreItems,
  6227. noncore: nonCoreItems
  6228. } = items.reduce(groupByType, {
  6229. core: [],
  6230. noncore: []
  6231. });
  6232. const sortedBlockTypes = [...coreItems, ...nonCoreItems];
  6233. return [...sortedBlockTypes, ...reusableBlockInserterItems];
  6234. }, (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)()]);
  6235. /**
  6236. * Determines the items that appear in the available block transforms list.
  6237. *
  6238. * Each item object contains what's necessary to display a menu item in the
  6239. * transform list and handle its selection.
  6240. *
  6241. * The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency)
  6242. * that combines block usage frequenty and recency.
  6243. *
  6244. * Items are returned ordered descendingly by their 'frecency'.
  6245. *
  6246. * @param {Object} state Editor state.
  6247. * @param {?string} rootClientId Optional root client ID of block list.
  6248. *
  6249. * @return {WPEditorTransformItem[]} Items that appear in inserter.
  6250. *
  6251. * @typedef {Object} WPEditorTransformItem
  6252. * @property {string} id Unique identifier for the item.
  6253. * @property {string} name The type of block to create.
  6254. * @property {string} title Title of the item, as it appears in the inserter.
  6255. * @property {string} icon Dashicon for the item, as it appears in the inserter.
  6256. * @property {boolean} isDisabled Whether or not the user should be prevented from inserting
  6257. * this item.
  6258. * @property {number} frecency Heuristic that combines frequency and recency.
  6259. */
  6260. const getBlockTransformItems = rememo(function (state, blocks) {
  6261. var _itemsByName$sourceBl;
  6262. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6263. const [sourceBlock] = blocks;
  6264. const buildBlockTypeTransformItem = buildBlockTypeItem(state, {
  6265. buildScope: 'transform'
  6266. });
  6267. const blockTypeTransformItems = (0,external_wp_blocks_namespaceObject.getBlockTypes)().filter(blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)).map(buildBlockTypeTransformItem);
  6268. const itemsByName = (0,external_lodash_namespaceObject.mapKeys)(blockTypeTransformItems, _ref5 => {
  6269. let {
  6270. name
  6271. } = _ref5;
  6272. return name;
  6273. }); // Consider unwraping the highest priority.
  6274. itemsByName['*'] = {
  6275. frecency: +Infinity,
  6276. id: '*',
  6277. isDisabled: false,
  6278. name: '*',
  6279. title: (0,external_wp_i18n_namespaceObject.__)('Unwrap'),
  6280. icon: (_itemsByName$sourceBl = itemsByName[sourceBlock.name]) === null || _itemsByName$sourceBl === void 0 ? void 0 : _itemsByName$sourceBl.icon
  6281. };
  6282. const possibleTransforms = (0,external_wp_blocks_namespaceObject.getPossibleBlockTransformations)(blocks).reduce((accumulator, block) => {
  6283. if (block === '*') {
  6284. accumulator.push(itemsByName['*']);
  6285. } else if (itemsByName[block === null || block === void 0 ? void 0 : block.name]) {
  6286. accumulator.push(itemsByName[block.name]);
  6287. }
  6288. return accumulator;
  6289. }, []);
  6290. return (0,external_lodash_namespaceObject.orderBy)(possibleTransforms, block => itemsByName[block.name].frecency, 'desc');
  6291. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, (0,external_wp_blocks_namespaceObject.getBlockTypes)()]);
  6292. /**
  6293. * Determines whether there are items to show in the inserter.
  6294. *
  6295. * @param {Object} state Editor state.
  6296. * @param {?string} rootClientId Optional root client ID of block list.
  6297. *
  6298. * @return {boolean} Items that appear in inserter.
  6299. */
  6300. const hasInserterItems = rememo(function (state) {
  6301. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6302. const hasBlockType = (0,external_lodash_namespaceObject.some)((0,external_wp_blocks_namespaceObject.getBlockTypes)(), blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId));
  6303. if (hasBlockType) {
  6304. return true;
  6305. }
  6306. const hasReusableBlock = canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) && getReusableBlocks(state).length > 0;
  6307. return hasReusableBlock;
  6308. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), (0,external_wp_blocks_namespaceObject.getBlockTypes)()]);
  6309. /**
  6310. * Returns the list of allowed inserter blocks for inner blocks children
  6311. *
  6312. * @param {Object} state Editor state.
  6313. * @param {?string} rootClientId Optional root client ID of block list.
  6314. *
  6315. * @return {Array?} The list of allowed block types.
  6316. */
  6317. const __experimentalGetAllowedBlocks = rememo(function (state) {
  6318. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6319. if (!rootClientId) {
  6320. return;
  6321. }
  6322. return (0,external_lodash_namespaceObject.filter)((0,external_wp_blocks_namespaceObject.getBlockTypes)(), blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId));
  6323. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, (0,external_wp_blocks_namespaceObject.getBlockTypes)()]);
  6324. /**
  6325. * Returns the block to be directly inserted by the block appender.
  6326. *
  6327. * @param {Object} state Editor state.
  6328. * @param {?string} rootClientId Optional root client ID of block list.
  6329. *
  6330. * @return {?WPDirectInsertBlock} The block type to be directly inserted.
  6331. *
  6332. * @typedef {Object} WPDirectInsertBlock
  6333. * @property {string} name The type of block.
  6334. * @property {?Object} attributes Attributes to pass to the newly created block.
  6335. * @property {?Array<string>} attributesToCopy Attributes to be copied from adjecent blocks when inserted.
  6336. */
  6337. const __experimentalGetDirectInsertBlock = rememo(function (state) {
  6338. var _state$blockListSetti, _state$blockListSetti2;
  6339. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6340. if (!rootClientId) {
  6341. return;
  6342. }
  6343. const defaultBlock = (_state$blockListSetti = state.blockListSettings[rootClientId]) === null || _state$blockListSetti === void 0 ? void 0 : _state$blockListSetti.__experimentalDefaultBlock;
  6344. const directInsert = (_state$blockListSetti2 = state.blockListSettings[rootClientId]) === null || _state$blockListSetti2 === void 0 ? void 0 : _state$blockListSetti2.__experimentalDirectInsert;
  6345. if (!defaultBlock || !directInsert) {
  6346. return;
  6347. }
  6348. if (typeof directInsert === 'function') {
  6349. return directInsert(getBlock(state, rootClientId)) ? defaultBlock : null;
  6350. }
  6351. return defaultBlock;
  6352. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.tree[rootClientId]]);
  6353. const checkAllowListRecursive = (blocks, allowedBlockTypes) => {
  6354. if ((0,external_lodash_namespaceObject.isBoolean)(allowedBlockTypes)) {
  6355. return allowedBlockTypes;
  6356. }
  6357. const blocksQueue = [...blocks];
  6358. while (blocksQueue.length > 0) {
  6359. var _block$innerBlocks;
  6360. const block = blocksQueue.shift();
  6361. const isAllowed = checkAllowList(allowedBlockTypes, block.name || block.blockName, true);
  6362. if (!isAllowed) {
  6363. return false;
  6364. }
  6365. (_block$innerBlocks = block.innerBlocks) === null || _block$innerBlocks === void 0 ? void 0 : _block$innerBlocks.forEach(innerBlock => {
  6366. blocksQueue.push(innerBlock);
  6367. });
  6368. }
  6369. return true;
  6370. };
  6371. const __experimentalGetParsedPattern = rememo((state, patternName) => {
  6372. const patterns = state.settings.__experimentalBlockPatterns;
  6373. const pattern = patterns.find(_ref6 => {
  6374. let {
  6375. name
  6376. } = _ref6;
  6377. return name === patternName;
  6378. });
  6379. if (!pattern) {
  6380. return null;
  6381. }
  6382. return { ...pattern,
  6383. blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content, {
  6384. __unstableSkipMigrationLogs: true
  6385. })
  6386. };
  6387. }, state => [state.settings.__experimentalBlockPatterns]);
  6388. const getAllAllowedPatterns = rememo(state => {
  6389. const patterns = state.settings.__experimentalBlockPatterns;
  6390. const {
  6391. allowedBlockTypes
  6392. } = getSettings(state);
  6393. const parsedPatterns = patterns.filter(_ref7 => {
  6394. let {
  6395. inserter = true
  6396. } = _ref7;
  6397. return !!inserter;
  6398. }).map(_ref8 => {
  6399. let {
  6400. name
  6401. } = _ref8;
  6402. return __experimentalGetParsedPattern(state, name);
  6403. });
  6404. const allowedPatterns = parsedPatterns.filter(_ref9 => {
  6405. let {
  6406. blocks
  6407. } = _ref9;
  6408. return checkAllowListRecursive(blocks, allowedBlockTypes);
  6409. });
  6410. return allowedPatterns;
  6411. }, state => [state.settings.__experimentalBlockPatterns, state.settings.allowedBlockTypes]);
  6412. /**
  6413. * Returns the list of allowed patterns for inner blocks children.
  6414. *
  6415. * @param {Object} state Editor state.
  6416. * @param {?string} rootClientId Optional target root client ID.
  6417. *
  6418. * @return {Array?} The list of allowed patterns.
  6419. */
  6420. const __experimentalGetAllowedPatterns = rememo(function (state) {
  6421. let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6422. const availableParsedPatterns = getAllAllowedPatterns(state);
  6423. const patternsAllowed = (0,external_lodash_namespaceObject.filter)(availableParsedPatterns, _ref10 => {
  6424. let {
  6425. blocks
  6426. } = _ref10;
  6427. return blocks.every(_ref11 => {
  6428. let {
  6429. name
  6430. } = _ref11;
  6431. return canInsertBlockType(state, name, rootClientId);
  6432. });
  6433. });
  6434. return patternsAllowed;
  6435. }, (state, rootClientId) => [state.settings.__experimentalBlockPatterns, state.settings.allowedBlockTypes, state.settings.templateLock, state.blockListSettings[rootClientId], state.blocks.byClientId[rootClientId]]);
  6436. /**
  6437. * Returns the list of patterns based on their declared `blockTypes`
  6438. * and a block's name.
  6439. * Patterns can use `blockTypes` to integrate in work flows like
  6440. * suggesting appropriate patterns in a Placeholder state(during insertion)
  6441. * or blocks transformations.
  6442. *
  6443. * @param {Object} state Editor state.
  6444. * @param {string|string[]} blockNames Block's name or array of block names to find matching pattens.
  6445. * @param {?string} rootClientId Optional target root client ID.
  6446. *
  6447. * @return {Array} The list of matched block patterns based on declared `blockTypes` and block name.
  6448. */
  6449. const __experimentalGetPatternsByBlockTypes = rememo(function (state, blockNames) {
  6450. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6451. if (!blockNames) return EMPTY_ARRAY;
  6452. const patterns = __experimentalGetAllowedPatterns(state, rootClientId);
  6453. const normalizedBlockNames = Array.isArray(blockNames) ? blockNames : [blockNames];
  6454. return patterns.filter(pattern => {
  6455. var _pattern$blockTypes, _pattern$blockTypes$s;
  6456. 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));
  6457. });
  6458. }, (state, rootClientId) => [...__experimentalGetAllowedPatterns.getDependants(state, rootClientId)]);
  6459. /**
  6460. * Determines the items that appear in the available pattern transforms list.
  6461. *
  6462. * For now we only handle blocks without InnerBlocks and take into account
  6463. * the `__experimentalRole` property of blocks' attributes for the transformation.
  6464. *
  6465. * We return the first set of possible eligible block patterns,
  6466. * by checking the `blockTypes` property. We still have to recurse through
  6467. * block pattern's blocks and try to find matches from the selected blocks.
  6468. * Now this happens in the consumer to avoid heavy operations in the selector.
  6469. *
  6470. * @param {Object} state Editor state.
  6471. * @param {Object[]} blocks The selected blocks.
  6472. * @param {?string} rootClientId Optional root client ID of block list.
  6473. *
  6474. * @return {WPBlockPattern[]} Items that are eligible for a pattern transformation.
  6475. */
  6476. const __experimentalGetPatternTransformItems = rememo(function (state, blocks) {
  6477. let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6478. if (!blocks) return EMPTY_ARRAY;
  6479. /**
  6480. * For now we only handle blocks without InnerBlocks and take into account
  6481. * the `__experimentalRole` property of blocks' attributes for the transformation.
  6482. * Note that the blocks have been retrieved through `getBlock`, which doesn't
  6483. * return the inner blocks of an inner block controller, so we still need
  6484. * to check for this case too.
  6485. */
  6486. if (blocks.some(_ref12 => {
  6487. let {
  6488. clientId,
  6489. innerBlocks
  6490. } = _ref12;
  6491. return innerBlocks.length || areInnerBlocksControlled(state, clientId);
  6492. })) {
  6493. return EMPTY_ARRAY;
  6494. } // Create a Set of the selected block names that is used in patterns filtering.
  6495. const selectedBlockNames = Array.from(new Set(blocks.map(_ref13 => {
  6496. let {
  6497. name
  6498. } = _ref13;
  6499. return name;
  6500. })));
  6501. /**
  6502. * Here we will return first set of possible eligible block patterns,
  6503. * by checking the `blockTypes` property. We still have to recurse through
  6504. * block pattern's blocks and try to find matches from the selected blocks.
  6505. * Now this happens in the consumer to avoid heavy operations in the selector.
  6506. */
  6507. return __experimentalGetPatternsByBlockTypes(state, selectedBlockNames, rootClientId);
  6508. }, (state, rootClientId) => [...__experimentalGetPatternsByBlockTypes.getDependants(state, rootClientId)]);
  6509. /**
  6510. * Returns the Block List settings of a block, if any exist.
  6511. *
  6512. * @param {Object} state Editor state.
  6513. * @param {?string} clientId Block client ID.
  6514. *
  6515. * @return {?Object} Block settings of the block if set.
  6516. */
  6517. function getBlockListSettings(state, clientId) {
  6518. return state.blockListSettings[clientId];
  6519. }
  6520. /**
  6521. * Returns the editor settings.
  6522. *
  6523. * @param {Object} state Editor state.
  6524. *
  6525. * @return {Object} The editor settings object.
  6526. */
  6527. function getSettings(state) {
  6528. return state.settings;
  6529. }
  6530. /**
  6531. * Returns true if the most recent block change is be considered persistent, or
  6532. * false otherwise. A persistent change is one committed by BlockEditorProvider
  6533. * via its `onChange` callback, in addition to `onInput`.
  6534. *
  6535. * @param {Object} state Block editor state.
  6536. *
  6537. * @return {boolean} Whether the most recent block change was persistent.
  6538. */
  6539. function isLastBlockChangePersistent(state) {
  6540. return state.blocks.isPersistentChange;
  6541. }
  6542. /**
  6543. * Returns the block list settings for an array of blocks, if any exist.
  6544. *
  6545. * @param {Object} state Editor state.
  6546. * @param {Array} clientIds Block client IDs.
  6547. *
  6548. * @return {Object} An object where the keys are client ids and the values are
  6549. * a block list setting object.
  6550. */
  6551. const __experimentalGetBlockListSettingsForBlocks = rememo(function (state) {
  6552. let clientIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  6553. return clientIds.reduce((blockListSettingsForBlocks, clientId) => {
  6554. if (!state.blockListSettings[clientId]) {
  6555. return blockListSettingsForBlocks;
  6556. }
  6557. return { ...blockListSettingsForBlocks,
  6558. [clientId]: state.blockListSettings[clientId]
  6559. };
  6560. }, {});
  6561. }, state => [state.blockListSettings]);
  6562. /**
  6563. * Returns the title of a given reusable block
  6564. *
  6565. * @param {Object} state Global application state.
  6566. * @param {number|string} ref The shared block's ID.
  6567. *
  6568. * @return {string} The reusable block saved title.
  6569. */
  6570. const __experimentalGetReusableBlockTitle = rememo((state, ref) => {
  6571. var _reusableBlock$title;
  6572. const reusableBlock = (0,external_lodash_namespaceObject.find)(getReusableBlocks(state), block => block.id === ref);
  6573. if (!reusableBlock) {
  6574. return null;
  6575. }
  6576. return (_reusableBlock$title = reusableBlock.title) === null || _reusableBlock$title === void 0 ? void 0 : _reusableBlock$title.raw;
  6577. }, state => [getReusableBlocks(state)]);
  6578. /**
  6579. * Returns true if the most recent block change is be considered ignored, or
  6580. * false otherwise. An ignored change is one not to be committed by
  6581. * BlockEditorProvider, neither via `onChange` nor `onInput`.
  6582. *
  6583. * @param {Object} state Block editor state.
  6584. *
  6585. * @return {boolean} Whether the most recent block change was ignored.
  6586. */
  6587. function __unstableIsLastBlockChangeIgnored(state) {
  6588. // TODO: Removal Plan: Changes incurred by RECEIVE_BLOCKS should not be
  6589. // ignored if in-fact they result in a change in blocks state. The current
  6590. // need to ignore changes not a result of user interaction should be
  6591. // accounted for in the refactoring of reusable blocks as occurring within
  6592. // their own separate block editor / state (#7119).
  6593. return state.blocks.isIgnoredChange;
  6594. }
  6595. /**
  6596. * Returns the block attributes changed as a result of the last dispatched
  6597. * action.
  6598. *
  6599. * @param {Object} state Block editor state.
  6600. *
  6601. * @return {Object<string,Object>} Subsets of block attributes changed, keyed
  6602. * by block client ID.
  6603. */
  6604. function __experimentalGetLastBlockAttributeChanges(state) {
  6605. return state.lastBlockAttributesChange;
  6606. }
  6607. /**
  6608. * Returns the available reusable blocks
  6609. *
  6610. * @param {Object} state Global application state.
  6611. *
  6612. * @return {Array} Reusable blocks
  6613. */
  6614. function getReusableBlocks(state) {
  6615. var _state$settings$__exp, _state$settings2;
  6616. 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;
  6617. }
  6618. /**
  6619. * Returns whether the navigation mode is enabled.
  6620. *
  6621. * @param {Object} state Editor state.
  6622. *
  6623. * @return {boolean} Is navigation mode enabled.
  6624. */
  6625. function selectors_isNavigationMode(state) {
  6626. return state.isNavigationMode;
  6627. }
  6628. /**
  6629. * Returns whether block moving mode is enabled.
  6630. *
  6631. * @param {Object} state Editor state.
  6632. *
  6633. * @return {string} Client Id of moving block.
  6634. */
  6635. function selectors_hasBlockMovingClientId(state) {
  6636. return state.hasBlockMovingClientId;
  6637. }
  6638. /**
  6639. * Returns true if the last change was an automatic change, false otherwise.
  6640. *
  6641. * @param {Object} state Global application state.
  6642. *
  6643. * @return {boolean} Whether the last change was automatic.
  6644. */
  6645. function didAutomaticChange(state) {
  6646. return !!state.automaticChangeStatus;
  6647. }
  6648. /**
  6649. * Returns true if the current highlighted block matches the block clientId.
  6650. *
  6651. * @param {Object} state Global application state.
  6652. * @param {string} clientId The block to check.
  6653. *
  6654. * @return {boolean} Whether the block is currently highlighted.
  6655. */
  6656. function isBlockHighlighted(state, clientId) {
  6657. return state.highlightedBlock === clientId;
  6658. }
  6659. /**
  6660. * Checks if a given block has controlled inner blocks.
  6661. *
  6662. * @param {Object} state Global application state.
  6663. * @param {string} clientId The block to check.
  6664. *
  6665. * @return {boolean} True if the block has controlled inner blocks.
  6666. */
  6667. function areInnerBlocksControlled(state, clientId) {
  6668. return !!state.blocks.controlledInnerBlocks[clientId];
  6669. }
  6670. /**
  6671. * Returns the clientId for the first 'active' block of a given array of block names.
  6672. * A block is 'active' if it (or a child) is the selected block.
  6673. * Returns the first match moving up the DOM from the selected block.
  6674. *
  6675. * @param {Object} state Global application state.
  6676. * @param {string[]} validBlocksNames The names of block types to check for.
  6677. *
  6678. * @return {string} The matching block's clientId.
  6679. */
  6680. const __experimentalGetActiveBlockIdByBlockNames = rememo((state, validBlockNames) => {
  6681. if (!validBlockNames.length) {
  6682. return null;
  6683. } // Check if selected block is a valid entity area.
  6684. const selectedBlockClientId = getSelectedBlockClientId(state);
  6685. if (validBlockNames.includes(getBlockName(state, selectedBlockClientId))) {
  6686. return selectedBlockClientId;
  6687. } // Check if first selected block is a child of a valid entity area.
  6688. const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(state);
  6689. const entityAreaParents = getBlockParentsByBlockName(state, selectedBlockClientId || multiSelectedBlockClientIds[0], validBlockNames);
  6690. if (entityAreaParents) {
  6691. // Last parent closest/most interior.
  6692. return (0,external_lodash_namespaceObject.last)(entityAreaParents);
  6693. }
  6694. return null;
  6695. }, (state, validBlockNames) => [state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId, validBlockNames]);
  6696. /**
  6697. * Tells if the block with the passed clientId was just inserted.
  6698. *
  6699. * @param {Object} state Global application state.
  6700. * @param {Object} clientId Client Id of the block.
  6701. * @param {?string} source Optional insertion source of the block.
  6702. * @return {boolean} True if the block matches the last block inserted from the specified source.
  6703. */
  6704. function wasBlockJustInserted(state, clientId, source) {
  6705. const {
  6706. lastBlockInserted
  6707. } = state;
  6708. return lastBlockInserted.clientId === clientId && lastBlockInserted.source === source;
  6709. }
  6710. ;// CONCATENATED MODULE: external ["wp","a11y"]
  6711. var external_wp_a11y_namespaceObject = window["wp"]["a11y"];
  6712. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  6713. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  6714. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  6715. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/actions.js
  6716. /**
  6717. * External dependencies
  6718. */
  6719. /**
  6720. * WordPress dependencies
  6721. */
  6722. /**
  6723. * Internal dependencies
  6724. */
  6725. /**
  6726. * Action which will insert a default block insert action if there
  6727. * are no other blocks at the root of the editor. This action should be used
  6728. * in actions which may result in no blocks remaining in the editor (removal,
  6729. * replacement, etc).
  6730. */
  6731. const ensureDefaultBlock = () => _ref => {
  6732. let {
  6733. select,
  6734. dispatch
  6735. } = _ref;
  6736. // To avoid a focus loss when removing the last block, assure there is
  6737. // always a default block if the last of the blocks have been removed.
  6738. const count = select.getBlockCount();
  6739. if (count > 0) {
  6740. return;
  6741. } // If there's an custom appender, don't insert default block.
  6742. // We have to remember to manually move the focus elsewhere to
  6743. // prevent it from being lost though.
  6744. const {
  6745. __unstableHasCustomAppender
  6746. } = select.getSettings();
  6747. if (__unstableHasCustomAppender) {
  6748. return;
  6749. }
  6750. dispatch.insertDefaultBlock();
  6751. };
  6752. /**
  6753. * Action that resets blocks state to the specified array of blocks, taking precedence
  6754. * over any other content reflected as an edit in state.
  6755. *
  6756. * @param {Array} blocks Array of blocks.
  6757. */
  6758. const resetBlocks = blocks => _ref2 => {
  6759. let {
  6760. dispatch
  6761. } = _ref2;
  6762. dispatch({
  6763. type: 'RESET_BLOCKS',
  6764. blocks
  6765. });
  6766. dispatch(validateBlocksToTemplate(blocks));
  6767. };
  6768. /**
  6769. * Block validity is a function of blocks state (at the point of a
  6770. * reset) and the template setting. As a compromise to its placement
  6771. * across distinct parts of state, it is implemented here as a side-
  6772. * effect of the block reset action.
  6773. *
  6774. * @param {Array} blocks Array of blocks.
  6775. */
  6776. const validateBlocksToTemplate = blocks => _ref3 => {
  6777. let {
  6778. select,
  6779. dispatch
  6780. } = _ref3;
  6781. const template = select.getTemplate();
  6782. const templateLock = select.getTemplateLock(); // Unlocked templates are considered always valid because they act
  6783. // as default values only.
  6784. const isBlocksValidToTemplate = !template || templateLock !== 'all' || (0,external_wp_blocks_namespaceObject.doBlocksMatchTemplate)(blocks, template); // Update if validity has changed.
  6785. const isValidTemplate = select.isValidTemplate();
  6786. if (isBlocksValidToTemplate !== isValidTemplate) {
  6787. dispatch.setTemplateValidity(isBlocksValidToTemplate);
  6788. return isBlocksValidToTemplate;
  6789. }
  6790. };
  6791. /**
  6792. * A block selection object.
  6793. *
  6794. * @typedef {Object} WPBlockSelection
  6795. *
  6796. * @property {string} clientId A block client ID.
  6797. * @property {string} attributeKey A block attribute key.
  6798. * @property {number} offset An attribute value offset, based on the rich
  6799. * text value. See `wp.richText.create`.
  6800. */
  6801. /**
  6802. * A selection object.
  6803. *
  6804. * @typedef {Object} WPSelection
  6805. *
  6806. * @property {WPBlockSelection} start The selection start.
  6807. * @property {WPBlockSelection} end The selection end.
  6808. */
  6809. /* eslint-disable jsdoc/valid-types */
  6810. /**
  6811. * Returns an action object used in signalling that selection state should be
  6812. * reset to the specified selection.
  6813. *
  6814. * @param {WPBlockSelection} selectionStart The selection start.
  6815. * @param {WPBlockSelection} selectionEnd The selection end.
  6816. * @param {0|-1|null} initialPosition Initial block position.
  6817. *
  6818. * @return {Object} Action object.
  6819. */
  6820. function resetSelection(selectionStart, selectionEnd, initialPosition) {
  6821. /* eslint-enable jsdoc/valid-types */
  6822. return {
  6823. type: 'RESET_SELECTION',
  6824. selectionStart,
  6825. selectionEnd,
  6826. initialPosition
  6827. };
  6828. }
  6829. /**
  6830. * Returns an action object used in signalling that blocks have been received.
  6831. * Unlike resetBlocks, these should be appended to the existing known set, not
  6832. * replacing.
  6833. *
  6834. * @deprecated
  6835. *
  6836. * @param {Object[]} blocks Array of block objects.
  6837. *
  6838. * @return {Object} Action object.
  6839. */
  6840. function receiveBlocks(blocks) {
  6841. external_wp_deprecated_default()('wp.data.dispatch( "core/block-editor" ).receiveBlocks', {
  6842. since: '5.9',
  6843. alternative: 'resetBlocks or insertBlocks'
  6844. });
  6845. return {
  6846. type: 'RECEIVE_BLOCKS',
  6847. blocks
  6848. };
  6849. }
  6850. /**
  6851. * Action that updates attributes of multiple blocks with the specified client IDs.
  6852. *
  6853. * @param {string|string[]} clientIds Block client IDs.
  6854. * @param {Object} attributes Block attributes to be merged. Should be keyed by clientIds if
  6855. * uniqueByBlock is true.
  6856. * @param {boolean} uniqueByBlock true if each block in clientIds array has a unique set of attributes
  6857. * @return {Object} Action object.
  6858. */
  6859. function updateBlockAttributes(clientIds, attributes) {
  6860. let uniqueByBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6861. return {
  6862. type: 'UPDATE_BLOCK_ATTRIBUTES',
  6863. clientIds: (0,external_lodash_namespaceObject.castArray)(clientIds),
  6864. attributes,
  6865. uniqueByBlock
  6866. };
  6867. }
  6868. /**
  6869. * Action that updates the block with the specified client ID.
  6870. *
  6871. * @param {string} clientId Block client ID.
  6872. * @param {Object} updates Block attributes to be merged.
  6873. *
  6874. * @return {Object} Action object.
  6875. */
  6876. function updateBlock(clientId, updates) {
  6877. return {
  6878. type: 'UPDATE_BLOCK',
  6879. clientId,
  6880. updates
  6881. };
  6882. }
  6883. /* eslint-disable jsdoc/valid-types */
  6884. /**
  6885. * Returns an action object used in signalling that the block with the
  6886. * specified client ID has been selected, optionally accepting a position
  6887. * value reflecting its selection directionality. An initialPosition of -1
  6888. * reflects a reverse selection.
  6889. *
  6890. * @param {string} clientId Block client ID.
  6891. * @param {0|-1|null} initialPosition Optional initial position. Pass as -1 to
  6892. * reflect reverse selection.
  6893. *
  6894. * @return {Object} Action object.
  6895. */
  6896. function selectBlock(clientId) {
  6897. let initialPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  6898. /* eslint-enable jsdoc/valid-types */
  6899. return {
  6900. type: 'SELECT_BLOCK',
  6901. initialPosition,
  6902. clientId
  6903. };
  6904. }
  6905. /**
  6906. * Yields action objects used in signalling that the block preceding the given
  6907. * clientId should be selected.
  6908. *
  6909. * @param {string} clientId Block client ID.
  6910. */
  6911. const selectPreviousBlock = clientId => _ref4 => {
  6912. let {
  6913. select,
  6914. dispatch
  6915. } = _ref4;
  6916. const previousBlockClientId = select.getPreviousBlockClientId(clientId);
  6917. if (previousBlockClientId) {
  6918. dispatch.selectBlock(previousBlockClientId, -1);
  6919. }
  6920. };
  6921. /**
  6922. * Yields action objects used in signalling that the block following the given
  6923. * clientId should be selected.
  6924. *
  6925. * @param {string} clientId Block client ID.
  6926. */
  6927. const selectNextBlock = clientId => _ref5 => {
  6928. let {
  6929. select,
  6930. dispatch
  6931. } = _ref5;
  6932. const nextBlockClientId = select.getNextBlockClientId(clientId);
  6933. if (nextBlockClientId) {
  6934. dispatch.selectBlock(nextBlockClientId);
  6935. }
  6936. };
  6937. /**
  6938. * Action that starts block multi-selection.
  6939. *
  6940. * @return {Object} Action object.
  6941. */
  6942. function startMultiSelect() {
  6943. return {
  6944. type: 'START_MULTI_SELECT'
  6945. };
  6946. }
  6947. /**
  6948. * Action that stops block multi-selection.
  6949. *
  6950. * @return {Object} Action object.
  6951. */
  6952. function stopMultiSelect() {
  6953. return {
  6954. type: 'STOP_MULTI_SELECT'
  6955. };
  6956. }
  6957. /**
  6958. * Action that changes block multi-selection.
  6959. *
  6960. * @param {string} start First block of the multi selection.
  6961. * @param {string} end Last block of the multiselection.
  6962. * @param {number|null} __experimentalInitialPosition Optional initial position. Pass as null to skip focus within editor canvas.
  6963. */
  6964. const multiSelect = function (start, end) {
  6965. let __experimentalInitialPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  6966. return _ref6 => {
  6967. let {
  6968. select,
  6969. dispatch
  6970. } = _ref6;
  6971. const startBlockRootClientId = select.getBlockRootClientId(start);
  6972. const endBlockRootClientId = select.getBlockRootClientId(end); // Only allow block multi-selections at the same level.
  6973. if (startBlockRootClientId !== endBlockRootClientId) {
  6974. return;
  6975. }
  6976. dispatch({
  6977. type: 'MULTI_SELECT',
  6978. start,
  6979. end,
  6980. initialPosition: __experimentalInitialPosition
  6981. });
  6982. const blockCount = select.getSelectedBlockCount();
  6983. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)(
  6984. /* translators: %s: number of selected blocks */
  6985. (0,external_wp_i18n_namespaceObject._n)('%s block selected.', '%s blocks selected.', blockCount), blockCount), 'assertive');
  6986. };
  6987. };
  6988. /**
  6989. * Action that clears the block selection.
  6990. *
  6991. * @return {Object} Action object.
  6992. */
  6993. function clearSelectedBlock() {
  6994. return {
  6995. type: 'CLEAR_SELECTED_BLOCK'
  6996. };
  6997. }
  6998. /**
  6999. * Action that enables or disables block selection.
  7000. *
  7001. * @param {boolean} [isSelectionEnabled=true] Whether block selection should
  7002. * be enabled.
  7003. *
  7004. * @return {Object} Action object.
  7005. */
  7006. function toggleSelection() {
  7007. let isSelectionEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  7008. return {
  7009. type: 'TOGGLE_SELECTION',
  7010. isSelectionEnabled
  7011. };
  7012. }
  7013. function getBlocksWithDefaultStylesApplied(blocks, blockEditorSettings) {
  7014. var _blockEditorSettings$, _blockEditorSettings$2;
  7015. 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$ : {};
  7016. return blocks.map(block => {
  7017. var _block$attributes;
  7018. const blockName = block.name;
  7019. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'defaultStylePicker', true)) {
  7020. return block;
  7021. }
  7022. if (!preferredStyleVariations[blockName]) {
  7023. return block;
  7024. }
  7025. const className = (_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.className;
  7026. if (className !== null && className !== void 0 && className.includes('is-style-')) {
  7027. return block;
  7028. }
  7029. const {
  7030. attributes = {}
  7031. } = block;
  7032. const blockStyle = preferredStyleVariations[blockName];
  7033. return { ...block,
  7034. attributes: { ...attributes,
  7035. className: `${className || ''} is-style-${blockStyle}`.trim()
  7036. }
  7037. };
  7038. });
  7039. }
  7040. /* eslint-disable jsdoc/valid-types */
  7041. /**
  7042. * Action that replaces given blocks with one or more replacement blocks.
  7043. *
  7044. * @param {(string|string[])} clientIds Block client ID(s) to replace.
  7045. * @param {(Object|Object[])} blocks Replacement block(s).
  7046. * @param {number} indexToSelect Index of replacement block to select.
  7047. * @param {0|-1|null} initialPosition Index of caret after in the selected block after the operation.
  7048. * @param {?Object} meta Optional Meta values to be passed to the action object.
  7049. *
  7050. * @return {Object} Action object.
  7051. */
  7052. const replaceBlocks = function (clientIds, blocks, indexToSelect) {
  7053. let initialPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  7054. let meta = arguments.length > 4 ? arguments[4] : undefined;
  7055. return _ref7 => {
  7056. let {
  7057. select,
  7058. dispatch
  7059. } = _ref7;
  7060. /* eslint-enable jsdoc/valid-types */
  7061. clientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
  7062. blocks = getBlocksWithDefaultStylesApplied((0,external_lodash_namespaceObject.castArray)(blocks), select.getSettings());
  7063. const rootClientId = select.getBlockRootClientId((0,external_lodash_namespaceObject.first)(clientIds)); // Replace is valid if the new blocks can be inserted in the root block.
  7064. for (let index = 0; index < blocks.length; index++) {
  7065. const block = blocks[index];
  7066. const canInsertBlock = select.canInsertBlockType(block.name, rootClientId);
  7067. if (!canInsertBlock) {
  7068. return;
  7069. }
  7070. }
  7071. dispatch({
  7072. type: 'REPLACE_BLOCKS',
  7073. clientIds,
  7074. blocks,
  7075. time: Date.now(),
  7076. indexToSelect,
  7077. initialPosition,
  7078. meta
  7079. });
  7080. dispatch(ensureDefaultBlock());
  7081. };
  7082. };
  7083. /**
  7084. * Action that replaces a single block with one or more replacement blocks.
  7085. *
  7086. * @param {(string|string[])} clientId Block client ID to replace.
  7087. * @param {(Object|Object[])} block Replacement block(s).
  7088. *
  7089. * @return {Object} Action object.
  7090. */
  7091. function replaceBlock(clientId, block) {
  7092. return replaceBlocks(clientId, block);
  7093. }
  7094. /**
  7095. * Higher-order action creator which, given the action type to dispatch creates
  7096. * an action creator for managing block movement.
  7097. *
  7098. * @param {string} type Action type to dispatch.
  7099. *
  7100. * @return {Function} Action creator.
  7101. */
  7102. const createOnMove = type => (clientIds, rootClientId) => _ref8 => {
  7103. let {
  7104. select,
  7105. dispatch
  7106. } = _ref8;
  7107. // If one of the blocks is locked or the parent is locked, we cannot move any block.
  7108. const canMoveBlocks = select.canMoveBlocks(clientIds, rootClientId);
  7109. if (!canMoveBlocks) {
  7110. return;
  7111. }
  7112. dispatch({
  7113. type,
  7114. clientIds: (0,external_lodash_namespaceObject.castArray)(clientIds),
  7115. rootClientId
  7116. });
  7117. };
  7118. const moveBlocksDown = createOnMove('MOVE_BLOCKS_DOWN');
  7119. const moveBlocksUp = createOnMove('MOVE_BLOCKS_UP');
  7120. /**
  7121. * Action that moves given blocks to a new position.
  7122. *
  7123. * @param {?string} clientIds The client IDs of the blocks.
  7124. * @param {?string} fromRootClientId Root client ID source.
  7125. * @param {?string} toRootClientId Root client ID destination.
  7126. * @param {number} index The index to move the blocks to.
  7127. */
  7128. const moveBlocksToPosition = function (clientIds) {
  7129. let fromRootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  7130. let toRootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  7131. let index = arguments.length > 3 ? arguments[3] : undefined;
  7132. return _ref9 => {
  7133. let {
  7134. select,
  7135. dispatch
  7136. } = _ref9;
  7137. const canMoveBlocks = select.canMoveBlocks(clientIds, fromRootClientId); // If one of the blocks is locked or the parent is locked, we cannot move any block.
  7138. if (!canMoveBlocks) {
  7139. return;
  7140. } // If moving inside the same root block the move is always possible.
  7141. if (fromRootClientId !== toRootClientId) {
  7142. const canRemoveBlocks = select.canRemoveBlocks(clientIds, fromRootClientId); // If we're moving to another block, it means we're deleting blocks from
  7143. // the original block, so we need to check if removing is possible.
  7144. if (!canRemoveBlocks) {
  7145. return;
  7146. }
  7147. 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.
  7148. if (!canInsertBlocks) {
  7149. return;
  7150. }
  7151. }
  7152. dispatch({
  7153. type: 'MOVE_BLOCKS_TO_POSITION',
  7154. fromRootClientId,
  7155. toRootClientId,
  7156. clientIds,
  7157. index
  7158. });
  7159. };
  7160. };
  7161. /**
  7162. * Action that moves given block to a new position.
  7163. *
  7164. * @param {?string} clientId The client ID of the block.
  7165. * @param {?string} fromRootClientId Root client ID source.
  7166. * @param {?string} toRootClientId Root client ID destination.
  7167. * @param {number} index The index to move the block to.
  7168. */
  7169. function moveBlockToPosition(clientId) {
  7170. let fromRootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  7171. let toRootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  7172. let index = arguments.length > 3 ? arguments[3] : undefined;
  7173. return moveBlocksToPosition([clientId], fromRootClientId, toRootClientId, index);
  7174. }
  7175. /**
  7176. * Action that inserts a single block, optionally at a specific index respective a root block list.
  7177. *
  7178. * @param {Object} block Block object to insert.
  7179. * @param {?number} index Index at which block should be inserted.
  7180. * @param {?string} rootClientId Optional root client ID of block list on which to insert.
  7181. * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
  7182. * @param {?Object} meta Optional Meta values to be passed to the action object.
  7183. *
  7184. * @return {Object} Action object.
  7185. */
  7186. function insertBlock(block, index, rootClientId, updateSelection, meta) {
  7187. return insertBlocks([block], index, rootClientId, updateSelection, 0, meta);
  7188. }
  7189. /* eslint-disable jsdoc/valid-types */
  7190. /**
  7191. * Action that inserts an array of blocks, optionally at a specific index respective a root block list.
  7192. *
  7193. * @param {Object[]} blocks Block objects to insert.
  7194. * @param {?number} index Index at which block should be inserted.
  7195. * @param {?string} rootClientId Optional root client ID of block list on which to insert.
  7196. * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
  7197. * @param {0|-1|null} initialPosition Initial focus position. Setting it to null prevent focusing the inserted block.
  7198. * @param {?Object} meta Optional Meta values to be passed to the action object.
  7199. * @return {Object} Action object.
  7200. */
  7201. const insertBlocks = function (blocks, index, rootClientId) {
  7202. let updateSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  7203. let initialPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
  7204. let meta = arguments.length > 5 ? arguments[5] : undefined;
  7205. return _ref10 => {
  7206. let {
  7207. select,
  7208. dispatch
  7209. } = _ref10;
  7210. /* eslint-enable jsdoc/valid-types */
  7211. if ((0,external_lodash_namespaceObject.isObject)(initialPosition)) {
  7212. meta = initialPosition;
  7213. initialPosition = 0;
  7214. external_wp_deprecated_default()("meta argument in wp.data.dispatch('core/block-editor')", {
  7215. since: '5.8',
  7216. hint: 'The meta argument is now the 6th argument of the function'
  7217. });
  7218. }
  7219. blocks = getBlocksWithDefaultStylesApplied((0,external_lodash_namespaceObject.castArray)(blocks), select.getSettings());
  7220. const allowedBlocks = [];
  7221. for (const block of blocks) {
  7222. const isValid = select.canInsertBlockType(block.name, rootClientId);
  7223. if (isValid) {
  7224. allowedBlocks.push(block);
  7225. }
  7226. }
  7227. if (allowedBlocks.length) {
  7228. dispatch({
  7229. type: 'INSERT_BLOCKS',
  7230. blocks: allowedBlocks,
  7231. index,
  7232. rootClientId,
  7233. time: Date.now(),
  7234. updateSelection,
  7235. initialPosition: updateSelection ? initialPosition : null,
  7236. meta
  7237. });
  7238. }
  7239. };
  7240. };
  7241. /**
  7242. * Action that shows the insertion point.
  7243. *
  7244. * @param {?string} rootClientId Optional root client ID of block list on
  7245. * which to insert.
  7246. * @param {?number} index Index at which block should be inserted.
  7247. * @param {Object} __unstableOptions Whether or not to show an inserter button.
  7248. *
  7249. * @return {Object} Action object.
  7250. */
  7251. function showInsertionPoint(rootClientId, index) {
  7252. let __unstableOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  7253. const {
  7254. __unstableWithInserter
  7255. } = __unstableOptions;
  7256. return {
  7257. type: 'SHOW_INSERTION_POINT',
  7258. rootClientId,
  7259. index,
  7260. __unstableWithInserter
  7261. };
  7262. }
  7263. /**
  7264. * Action that hides the insertion point.
  7265. *
  7266. * @return {Object} Action object.
  7267. */
  7268. function hideInsertionPoint() {
  7269. return {
  7270. type: 'HIDE_INSERTION_POINT'
  7271. };
  7272. }
  7273. /**
  7274. * Action that resets the template validity.
  7275. *
  7276. * @param {boolean} isValid template validity flag.
  7277. *
  7278. * @return {Object} Action object.
  7279. */
  7280. function setTemplateValidity(isValid) {
  7281. return {
  7282. type: 'SET_TEMPLATE_VALIDITY',
  7283. isValid
  7284. };
  7285. }
  7286. /**
  7287. * Action that synchronizes the template with the list of blocks.
  7288. *
  7289. * @return {Object} Action object.
  7290. */
  7291. const synchronizeTemplate = () => _ref11 => {
  7292. let {
  7293. select,
  7294. dispatch
  7295. } = _ref11;
  7296. dispatch({
  7297. type: 'SYNCHRONIZE_TEMPLATE'
  7298. });
  7299. const blocks = select.getBlocks();
  7300. const template = select.getTemplate();
  7301. const updatedBlockList = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template);
  7302. dispatch.resetBlocks(updatedBlockList);
  7303. };
  7304. /**
  7305. * Delete the current selection.
  7306. *
  7307. * @param {boolean} isForward
  7308. */
  7309. const __unstableDeleteSelection = isForward => _ref12 => {
  7310. let {
  7311. registry,
  7312. select,
  7313. dispatch
  7314. } = _ref12;
  7315. const selectionAnchor = select.getSelectionStart();
  7316. const selectionFocus = select.getSelectionEnd();
  7317. if (selectionAnchor.clientId === selectionFocus.clientId) return; // It's not mergeable if there's no rich text selection.
  7318. if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') return false;
  7319. const anchorRootClientId = select.getBlockRootClientId(selectionAnchor.clientId);
  7320. const focusRootClientId = select.getBlockRootClientId(selectionFocus.clientId); // It's not mergeable if the selection doesn't start and end in the same
  7321. // block list. Maybe in the future it should be allowed.
  7322. if (anchorRootClientId !== focusRootClientId) {
  7323. return;
  7324. }
  7325. const blockOrder = select.getBlockOrder(anchorRootClientId);
  7326. const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
  7327. const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order.
  7328. let selectionStart, selectionEnd;
  7329. if (anchorIndex > focusIndex) {
  7330. selectionStart = selectionFocus;
  7331. selectionEnd = selectionAnchor;
  7332. } else {
  7333. selectionStart = selectionAnchor;
  7334. selectionEnd = selectionFocus;
  7335. }
  7336. const targetSelection = isForward ? selectionEnd : selectionStart;
  7337. const targetBlock = select.getBlock(targetSelection.clientId);
  7338. const targetBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(targetBlock.name);
  7339. if (!targetBlockType.merge) {
  7340. return;
  7341. }
  7342. const selectionA = selectionStart;
  7343. const selectionB = selectionEnd;
  7344. const blockA = select.getBlock(selectionA.clientId);
  7345. const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name);
  7346. const blockB = select.getBlock(selectionB.clientId);
  7347. const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name);
  7348. const htmlA = blockA.attributes[selectionA.attributeKey];
  7349. const htmlB = blockB.attributes[selectionB.attributeKey];
  7350. const attributeDefinitionA = blockAType.attributes[selectionA.attributeKey];
  7351. const attributeDefinitionB = blockBType.attributes[selectionB.attributeKey];
  7352. let valueA = (0,external_wp_richText_namespaceObject.create)({
  7353. html: htmlA,
  7354. ...mapRichTextSettings(attributeDefinitionA)
  7355. });
  7356. let valueB = (0,external_wp_richText_namespaceObject.create)({
  7357. html: htmlB,
  7358. ...mapRichTextSettings(attributeDefinitionB)
  7359. }); // A robust way to retain selection position through various transforms
  7360. // is to insert a special character at the position and then recover it.
  7361. const START_OF_SELECTED_AREA = '\u0086';
  7362. valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, selectionA.offset, valueA.text.length);
  7363. 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.
  7364. const cloneA = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockA, {
  7365. [selectionA.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  7366. value: valueA,
  7367. ...mapRichTextSettings(attributeDefinitionA)
  7368. })
  7369. });
  7370. const cloneB = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockB, {
  7371. [selectionB.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  7372. value: valueB,
  7373. ...mapRichTextSettings(attributeDefinitionB)
  7374. })
  7375. });
  7376. const followingBlock = isForward ? cloneA : cloneB; // We can only merge blocks with similar types
  7377. // thus, we transform the block to merge first
  7378. 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
  7379. if (!blocksWithTheSameType || !blocksWithTheSameType.length) {
  7380. return;
  7381. }
  7382. let updatedAttributes;
  7383. if (isForward) {
  7384. const blockToMerge = blocksWithTheSameType.pop();
  7385. updatedAttributes = targetBlockType.merge(blockToMerge.attributes, cloneB.attributes);
  7386. } else {
  7387. const blockToMerge = blocksWithTheSameType.shift();
  7388. updatedAttributes = targetBlockType.merge(cloneA.attributes, blockToMerge.attributes);
  7389. }
  7390. const newAttributeKey = (0,external_lodash_namespaceObject.findKey)(updatedAttributes, v => typeof v === 'string' && v.indexOf(START_OF_SELECTED_AREA) !== -1);
  7391. const convertedHtml = updatedAttributes[newAttributeKey];
  7392. const convertedValue = (0,external_wp_richText_namespaceObject.create)({
  7393. html: convertedHtml,
  7394. ...mapRichTextSettings(targetBlockType.attributes[newAttributeKey])
  7395. });
  7396. const newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA);
  7397. const newValue = (0,external_wp_richText_namespaceObject.remove)(convertedValue, newOffset, newOffset + 1);
  7398. const newHtml = (0,external_wp_richText_namespaceObject.toHTMLString)({
  7399. value: newValue,
  7400. ...mapRichTextSettings(targetBlockType.attributes[newAttributeKey])
  7401. });
  7402. updatedAttributes[newAttributeKey] = newHtml;
  7403. const selectedBlockClientIds = select.getSelectedBlockClientIds();
  7404. const replacement = [...(isForward ? blocksWithTheSameType : []), { // Preserve the original client ID.
  7405. ...targetBlock,
  7406. attributes: { ...targetBlock.attributes,
  7407. ...updatedAttributes
  7408. }
  7409. }, ...(isForward ? [] : blocksWithTheSameType)];
  7410. registry.batch(() => {
  7411. dispatch.selectionChange(targetBlock.clientId, newAttributeKey, newOffset, newOffset);
  7412. dispatch.replaceBlocks(selectedBlockClientIds, replacement, 0, // If we don't pass the `indexToSelect` it will default to the last block.
  7413. select.getSelectedBlocksInitialCaretPosition());
  7414. });
  7415. };
  7416. /**
  7417. * Split the current selection.
  7418. */
  7419. const __unstableSplitSelection = () => _ref13 => {
  7420. let {
  7421. select,
  7422. dispatch
  7423. } = _ref13;
  7424. const selectionAnchor = select.getSelectionStart();
  7425. const selectionFocus = select.getSelectionEnd();
  7426. if (selectionAnchor.clientId === selectionFocus.clientId) return; // Can't split if the selection is not set.
  7427. if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') return;
  7428. const anchorRootClientId = select.getBlockRootClientId(selectionAnchor.clientId);
  7429. const focusRootClientId = select.getBlockRootClientId(selectionFocus.clientId); // It's not splittable if the selection doesn't start and end in the same
  7430. // block list. Maybe in the future it should be allowed.
  7431. if (anchorRootClientId !== focusRootClientId) {
  7432. return;
  7433. }
  7434. const blockOrder = select.getBlockOrder(anchorRootClientId);
  7435. const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
  7436. const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order.
  7437. let selectionStart, selectionEnd;
  7438. if (anchorIndex > focusIndex) {
  7439. selectionStart = selectionFocus;
  7440. selectionEnd = selectionAnchor;
  7441. } else {
  7442. selectionStart = selectionAnchor;
  7443. selectionEnd = selectionFocus;
  7444. }
  7445. const selectionA = selectionStart;
  7446. const selectionB = selectionEnd;
  7447. const blockA = select.getBlock(selectionA.clientId);
  7448. const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name);
  7449. const blockB = select.getBlock(selectionB.clientId);
  7450. const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name);
  7451. const htmlA = blockA.attributes[selectionA.attributeKey];
  7452. const htmlB = blockB.attributes[selectionB.attributeKey];
  7453. const attributeDefinitionA = blockAType.attributes[selectionA.attributeKey];
  7454. const attributeDefinitionB = blockBType.attributes[selectionB.attributeKey];
  7455. let valueA = (0,external_wp_richText_namespaceObject.create)({
  7456. html: htmlA,
  7457. ...mapRichTextSettings(attributeDefinitionA)
  7458. });
  7459. let valueB = (0,external_wp_richText_namespaceObject.create)({
  7460. html: htmlB,
  7461. ...mapRichTextSettings(attributeDefinitionB)
  7462. });
  7463. valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, selectionA.offset, valueA.text.length);
  7464. valueB = (0,external_wp_richText_namespaceObject.remove)(valueB, 0, selectionB.offset);
  7465. dispatch.replaceBlocks(select.getSelectedBlockClientIds(), [{ // Preserve the original client ID.
  7466. ...blockA,
  7467. attributes: { ...blockA.attributes,
  7468. [selectionA.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  7469. value: valueA,
  7470. ...mapRichTextSettings(attributeDefinitionA)
  7471. })
  7472. }
  7473. }, (0,external_wp_blocks_namespaceObject.createBlock)((0,external_wp_blocks_namespaceObject.getDefaultBlockName)()), { // Preserve the original client ID.
  7474. ...blockB,
  7475. attributes: { ...blockB.attributes,
  7476. [selectionB.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
  7477. value: valueB,
  7478. ...mapRichTextSettings(attributeDefinitionB)
  7479. })
  7480. }
  7481. }], 1, // If we don't pass the `indexToSelect` it will default to the last block.
  7482. select.getSelectedBlocksInitialCaretPosition());
  7483. };
  7484. /**
  7485. * Expand the selection to cover the entire blocks, removing partial selection.
  7486. */
  7487. const __unstableExpandSelection = () => _ref14 => {
  7488. let {
  7489. select,
  7490. dispatch
  7491. } = _ref14;
  7492. const selectionAnchor = select.getSelectionStart();
  7493. const selectionFocus = select.getSelectionEnd();
  7494. dispatch.selectionChange({
  7495. start: {
  7496. clientId: selectionAnchor.clientId
  7497. },
  7498. end: {
  7499. clientId: selectionFocus.clientId
  7500. }
  7501. });
  7502. };
  7503. /**
  7504. * Action that merges two blocks.
  7505. *
  7506. * @param {string} firstBlockClientId Client ID of the first block to merge.
  7507. * @param {string} secondBlockClientId Client ID of the second block to merge.
  7508. */
  7509. const mergeBlocks = (firstBlockClientId, secondBlockClientId) => _ref15 => {
  7510. let {
  7511. select,
  7512. dispatch
  7513. } = _ref15;
  7514. const blocks = [firstBlockClientId, secondBlockClientId];
  7515. dispatch({
  7516. type: 'MERGE_BLOCKS',
  7517. blocks
  7518. });
  7519. const [clientIdA, clientIdB] = blocks;
  7520. const blockA = select.getBlock(clientIdA);
  7521. const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name); // Only focus the previous block if it's not mergeable.
  7522. if (blockAType && !blockAType.merge) {
  7523. dispatch.selectBlock(blockA.clientId);
  7524. return;
  7525. }
  7526. const blockB = select.getBlock(clientIdB);
  7527. const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name);
  7528. const {
  7529. clientId,
  7530. attributeKey,
  7531. offset
  7532. } = select.getSelectionStart();
  7533. const selectedBlockType = clientId === clientIdA ? blockAType : blockBType;
  7534. const attributeDefinition = selectedBlockType.attributes[attributeKey];
  7535. const canRestoreTextSelection = (clientId === clientIdA || clientId === clientIdB) && attributeKey !== undefined && offset !== undefined && // We cannot restore text selection if the RichText identifier
  7536. // is not a defined block attribute key. This can be the case if the
  7537. // fallback intance ID is used to store selection (and no RichText
  7538. // identifier is set), or when the identifier is wrong.
  7539. !!attributeDefinition;
  7540. if (!attributeDefinition) {
  7541. if (typeof attributeKey === 'number') {
  7542. 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}`);
  7543. } else {
  7544. window.console.error('The RichText identifier prop does not match any attributes defined by the block.');
  7545. }
  7546. } // A robust way to retain selection position through various transforms
  7547. // is to insert a special character at the position and then recover it.
  7548. const START_OF_SELECTED_AREA = '\u0086'; // Clone the blocks so we don't insert the character in a "live" block.
  7549. const cloneA = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockA);
  7550. const cloneB = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockB);
  7551. if (canRestoreTextSelection) {
  7552. const selectedBlock = clientId === clientIdA ? cloneA : cloneB;
  7553. const html = selectedBlock.attributes[attributeKey];
  7554. const value = (0,external_wp_richText_namespaceObject.insert)((0,external_wp_richText_namespaceObject.create)({
  7555. html,
  7556. ...mapRichTextSettings(attributeDefinition)
  7557. }), START_OF_SELECTED_AREA, offset, offset);
  7558. selectedBlock.attributes[attributeKey] = (0,external_wp_richText_namespaceObject.toHTMLString)({
  7559. value,
  7560. ...mapRichTextSettings(attributeDefinition)
  7561. });
  7562. } // We can only merge blocks with similar types
  7563. // thus, we transform the block to merge first.
  7564. 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.
  7565. if (!blocksWithTheSameType || !blocksWithTheSameType.length) {
  7566. return;
  7567. } // Calling the merge to update the attributes and remove the block to be merged.
  7568. const updatedAttributes = blockAType.merge(cloneA.attributes, blocksWithTheSameType[0].attributes);
  7569. if (canRestoreTextSelection) {
  7570. const newAttributeKey = (0,external_lodash_namespaceObject.findKey)(updatedAttributes, v => typeof v === 'string' && v.indexOf(START_OF_SELECTED_AREA) !== -1);
  7571. const convertedHtml = updatedAttributes[newAttributeKey];
  7572. const convertedValue = (0,external_wp_richText_namespaceObject.create)({
  7573. html: convertedHtml,
  7574. ...mapRichTextSettings(blockAType.attributes[newAttributeKey])
  7575. });
  7576. const newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA);
  7577. const newValue = (0,external_wp_richText_namespaceObject.remove)(convertedValue, newOffset, newOffset + 1);
  7578. const newHtml = (0,external_wp_richText_namespaceObject.toHTMLString)({
  7579. value: newValue,
  7580. ...mapRichTextSettings(blockAType.attributes[newAttributeKey])
  7581. });
  7582. updatedAttributes[newAttributeKey] = newHtml;
  7583. dispatch.selectionChange(blockA.clientId, newAttributeKey, newOffset, newOffset);
  7584. }
  7585. dispatch.replaceBlocks([blockA.clientId, blockB.clientId], [{ ...blockA,
  7586. attributes: { ...blockA.attributes,
  7587. ...updatedAttributes
  7588. }
  7589. }, ...blocksWithTheSameType.slice(1)], 0 // If we don't pass the `indexToSelect` it will default to the last block.
  7590. );
  7591. };
  7592. /**
  7593. * Yields action objects used in signalling that the blocks corresponding to
  7594. * the set of specified client IDs are to be removed.
  7595. *
  7596. * @param {string|string[]} clientIds Client IDs of blocks to remove.
  7597. * @param {boolean} selectPrevious True if the previous block should be
  7598. * selected when a block is removed.
  7599. */
  7600. const removeBlocks = function (clientIds) {
  7601. let selectPrevious = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  7602. return _ref16 => {
  7603. let {
  7604. select,
  7605. dispatch
  7606. } = _ref16;
  7607. if (!clientIds || !clientIds.length) {
  7608. return;
  7609. }
  7610. clientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
  7611. const rootClientId = select.getBlockRootClientId(clientIds[0]);
  7612. const canRemoveBlocks = select.canRemoveBlocks(clientIds, rootClientId);
  7613. if (!canRemoveBlocks) {
  7614. return;
  7615. }
  7616. if (selectPrevious) {
  7617. dispatch.selectPreviousBlock(clientIds[0]);
  7618. }
  7619. dispatch({
  7620. type: 'REMOVE_BLOCKS',
  7621. clientIds
  7622. }); // To avoid a focus loss when removing the last block, assure there is
  7623. // always a default block if the last of the blocks have been removed.
  7624. dispatch(ensureDefaultBlock());
  7625. };
  7626. };
  7627. /**
  7628. * Returns an action object used in signalling that the block with the
  7629. * specified client ID is to be removed.
  7630. *
  7631. * @param {string} clientId Client ID of block to remove.
  7632. * @param {boolean} selectPrevious True if the previous block should be
  7633. * selected when a block is removed.
  7634. *
  7635. * @return {Object} Action object.
  7636. */
  7637. function removeBlock(clientId, selectPrevious) {
  7638. return removeBlocks([clientId], selectPrevious);
  7639. }
  7640. /* eslint-disable jsdoc/valid-types */
  7641. /**
  7642. * Returns an action object used in signalling that the inner blocks with the
  7643. * specified client ID should be replaced.
  7644. *
  7645. * @param {string} rootClientId Client ID of the block whose InnerBlocks will re replaced.
  7646. * @param {Object[]} blocks Block objects to insert as new InnerBlocks
  7647. * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to false.
  7648. * @param {0|-1|null} initialPosition Initial block position.
  7649. * @return {Object} Action object.
  7650. */
  7651. function replaceInnerBlocks(rootClientId, blocks) {
  7652. let updateSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7653. let initialPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  7654. /* eslint-enable jsdoc/valid-types */
  7655. return {
  7656. type: 'REPLACE_INNER_BLOCKS',
  7657. rootClientId,
  7658. blocks,
  7659. updateSelection,
  7660. initialPosition: updateSelection ? initialPosition : null,
  7661. time: Date.now()
  7662. };
  7663. }
  7664. /**
  7665. * Returns an action object used to toggle the block editing mode between
  7666. * visual and HTML modes.
  7667. *
  7668. * @param {string} clientId Block client ID.
  7669. *
  7670. * @return {Object} Action object.
  7671. */
  7672. function toggleBlockMode(clientId) {
  7673. return {
  7674. type: 'TOGGLE_BLOCK_MODE',
  7675. clientId
  7676. };
  7677. }
  7678. /**
  7679. * Returns an action object used in signalling that the user has begun to type.
  7680. *
  7681. * @return {Object} Action object.
  7682. */
  7683. function startTyping() {
  7684. return {
  7685. type: 'START_TYPING'
  7686. };
  7687. }
  7688. /**
  7689. * Returns an action object used in signalling that the user has stopped typing.
  7690. *
  7691. * @return {Object} Action object.
  7692. */
  7693. function stopTyping() {
  7694. return {
  7695. type: 'STOP_TYPING'
  7696. };
  7697. }
  7698. /**
  7699. * Returns an action object used in signalling that the user has begun to drag blocks.
  7700. *
  7701. * @param {string[]} clientIds An array of client ids being dragged
  7702. *
  7703. * @return {Object} Action object.
  7704. */
  7705. function startDraggingBlocks() {
  7706. let clientIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  7707. return {
  7708. type: 'START_DRAGGING_BLOCKS',
  7709. clientIds
  7710. };
  7711. }
  7712. /**
  7713. * Returns an action object used in signalling that the user has stopped dragging blocks.
  7714. *
  7715. * @return {Object} Action object.
  7716. */
  7717. function stopDraggingBlocks() {
  7718. return {
  7719. type: 'STOP_DRAGGING_BLOCKS'
  7720. };
  7721. }
  7722. /**
  7723. * Returns an action object used in signalling that the caret has entered formatted text.
  7724. *
  7725. * @return {Object} Action object.
  7726. */
  7727. function enterFormattedText() {
  7728. return {
  7729. type: 'ENTER_FORMATTED_TEXT'
  7730. };
  7731. }
  7732. /**
  7733. * Returns an action object used in signalling that the user caret has exited formatted text.
  7734. *
  7735. * @return {Object} Action object.
  7736. */
  7737. function exitFormattedText() {
  7738. return {
  7739. type: 'EXIT_FORMATTED_TEXT'
  7740. };
  7741. }
  7742. /**
  7743. * Action that changes the position of the user caret.
  7744. *
  7745. * @param {string|WPSelection} clientId The selected block client ID.
  7746. * @param {string} attributeKey The selected block attribute key.
  7747. * @param {number} startOffset The start offset.
  7748. * @param {number} endOffset The end offset.
  7749. *
  7750. * @return {Object} Action object.
  7751. */
  7752. function selectionChange(clientId, attributeKey, startOffset, endOffset) {
  7753. if (typeof clientId === 'string') {
  7754. return {
  7755. type: 'SELECTION_CHANGE',
  7756. clientId,
  7757. attributeKey,
  7758. startOffset,
  7759. endOffset
  7760. };
  7761. }
  7762. return {
  7763. type: 'SELECTION_CHANGE',
  7764. ...clientId
  7765. };
  7766. }
  7767. /**
  7768. * Action that adds a new block of the default type to the block list.
  7769. *
  7770. * @param {?Object} attributes Optional attributes of the block to assign.
  7771. * @param {?string} rootClientId Optional root client ID of block list on which
  7772. * to append.
  7773. * @param {?number} index Optional index where to insert the default block.
  7774. */
  7775. const insertDefaultBlock = (attributes, rootClientId, index) => _ref17 => {
  7776. let {
  7777. dispatch
  7778. } = _ref17;
  7779. // Abort if there is no default block type (if it has been unregistered).
  7780. const defaultBlockName = (0,external_wp_blocks_namespaceObject.getDefaultBlockName)();
  7781. if (!defaultBlockName) {
  7782. return;
  7783. }
  7784. const block = (0,external_wp_blocks_namespaceObject.createBlock)(defaultBlockName, attributes);
  7785. return dispatch.insertBlock(block, index, rootClientId);
  7786. };
  7787. /**
  7788. * Action that changes the nested settings of a given block.
  7789. *
  7790. * @param {string} clientId Client ID of the block whose nested setting are
  7791. * being received.
  7792. * @param {Object} settings Object with the new settings for the nested block.
  7793. *
  7794. * @return {Object} Action object
  7795. */
  7796. function updateBlockListSettings(clientId, settings) {
  7797. return {
  7798. type: 'UPDATE_BLOCK_LIST_SETTINGS',
  7799. clientId,
  7800. settings
  7801. };
  7802. }
  7803. /**
  7804. * Action that updates the block editor settings.
  7805. *
  7806. * @param {Object} settings Updated settings
  7807. *
  7808. * @return {Object} Action object
  7809. */
  7810. function updateSettings(settings) {
  7811. return {
  7812. type: 'UPDATE_SETTINGS',
  7813. settings
  7814. };
  7815. }
  7816. /**
  7817. * Action that signals that a temporary reusable block has been saved
  7818. * in order to switch its temporary id with the real id.
  7819. *
  7820. * @param {string} id Reusable block's id.
  7821. * @param {string} updatedId Updated block's id.
  7822. *
  7823. * @return {Object} Action object.
  7824. */
  7825. function __unstableSaveReusableBlock(id, updatedId) {
  7826. return {
  7827. type: 'SAVE_REUSABLE_BLOCK_SUCCESS',
  7828. id,
  7829. updatedId
  7830. };
  7831. }
  7832. /**
  7833. * Action that marks the last block change explicitly as persistent.
  7834. *
  7835. * @return {Object} Action object.
  7836. */
  7837. function __unstableMarkLastChangeAsPersistent() {
  7838. return {
  7839. type: 'MARK_LAST_CHANGE_AS_PERSISTENT'
  7840. };
  7841. }
  7842. /**
  7843. * Action that signals that the next block change should be marked explicitly as not persistent.
  7844. *
  7845. * @return {Object} Action object.
  7846. */
  7847. function __unstableMarkNextChangeAsNotPersistent() {
  7848. return {
  7849. type: 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT'
  7850. };
  7851. }
  7852. /**
  7853. * Action that marks the last block change as an automatic change, meaning it was not
  7854. * performed by the user, and can be undone using the `Escape` and `Backspace` keys.
  7855. * This action must be called after the change was made, and any actions that are a
  7856. * consequence of it, so it is recommended to be called at the next idle period to ensure all
  7857. * selection changes have been recorded.
  7858. */
  7859. const __unstableMarkAutomaticChange = () => _ref18 => {
  7860. let {
  7861. dispatch
  7862. } = _ref18;
  7863. dispatch({
  7864. type: 'MARK_AUTOMATIC_CHANGE'
  7865. });
  7866. const {
  7867. requestIdleCallback = cb => setTimeout(cb, 100)
  7868. } = window;
  7869. requestIdleCallback(() => {
  7870. dispatch({
  7871. type: 'MARK_AUTOMATIC_CHANGE_FINAL'
  7872. });
  7873. });
  7874. };
  7875. /**
  7876. * Action that enables or disables the navigation mode.
  7877. *
  7878. * @param {string} isNavigationMode Enable/Disable navigation mode.
  7879. */
  7880. const setNavigationMode = function () {
  7881. let isNavigationMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  7882. return _ref19 => {
  7883. let {
  7884. dispatch
  7885. } = _ref19;
  7886. dispatch({
  7887. type: 'SET_NAVIGATION_MODE',
  7888. isNavigationMode
  7889. });
  7890. if (isNavigationMode) {
  7891. (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.'));
  7892. } else {
  7893. (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.'));
  7894. }
  7895. };
  7896. };
  7897. /**
  7898. * Action that enables or disables the block moving mode.
  7899. *
  7900. * @param {string|null} hasBlockMovingClientId Enable/Disable block moving mode.
  7901. */
  7902. const setBlockMovingClientId = function () {
  7903. let hasBlockMovingClientId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  7904. return _ref20 => {
  7905. let {
  7906. dispatch
  7907. } = _ref20;
  7908. dispatch({
  7909. type: 'SET_BLOCK_MOVING_MODE',
  7910. hasBlockMovingClientId
  7911. });
  7912. if (hasBlockMovingClientId) {
  7913. (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.'));
  7914. }
  7915. };
  7916. };
  7917. /**
  7918. * Action that duplicates a list of blocks.
  7919. *
  7920. * @param {string[]} clientIds
  7921. * @param {boolean} updateSelection
  7922. */
  7923. const duplicateBlocks = function (clientIds) {
  7924. let updateSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  7925. return _ref21 => {
  7926. let {
  7927. select,
  7928. dispatch
  7929. } = _ref21;
  7930. if (!clientIds || !clientIds.length) {
  7931. return;
  7932. } // Return early if blocks don't exist.
  7933. const blocks = select.getBlocksByClientId(clientIds);
  7934. if ((0,external_lodash_namespaceObject.some)(blocks, block => !block)) {
  7935. return;
  7936. } // Return early if blocks don't support multiple usage.
  7937. const blockNames = blocks.map(block => block.name);
  7938. if (blockNames.some(blockName => !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'multiple', true))) {
  7939. return;
  7940. }
  7941. const rootClientId = select.getBlockRootClientId(clientIds[0]);
  7942. const lastSelectedIndex = select.getBlockIndex((0,external_lodash_namespaceObject.last)((0,external_lodash_namespaceObject.castArray)(clientIds)));
  7943. const clonedBlocks = blocks.map(block => (0,external_wp_blocks_namespaceObject.__experimentalCloneSanitizedBlock)(block));
  7944. dispatch.insertBlocks(clonedBlocks, lastSelectedIndex + 1, rootClientId, updateSelection);
  7945. if (clonedBlocks.length > 1 && updateSelection) {
  7946. dispatch.multiSelect((0,external_lodash_namespaceObject.first)(clonedBlocks).clientId, (0,external_lodash_namespaceObject.last)(clonedBlocks).clientId);
  7947. }
  7948. return clonedBlocks.map(block => block.clientId);
  7949. };
  7950. };
  7951. /**
  7952. * Action that inserts an empty block before a given block.
  7953. *
  7954. * @param {string} clientId
  7955. */
  7956. const insertBeforeBlock = clientId => _ref22 => {
  7957. let {
  7958. select,
  7959. dispatch
  7960. } = _ref22;
  7961. if (!clientId) {
  7962. return;
  7963. }
  7964. const rootClientId = select.getBlockRootClientId(clientId);
  7965. const isLocked = select.getTemplateLock(rootClientId);
  7966. if (isLocked) {
  7967. return;
  7968. }
  7969. const firstSelectedIndex = select.getBlockIndex(clientId);
  7970. return dispatch.insertDefaultBlock({}, rootClientId, firstSelectedIndex);
  7971. };
  7972. /**
  7973. * Action that inserts an empty block after a given block.
  7974. *
  7975. * @param {string} clientId
  7976. */
  7977. const insertAfterBlock = clientId => _ref23 => {
  7978. let {
  7979. select,
  7980. dispatch
  7981. } = _ref23;
  7982. if (!clientId) {
  7983. return;
  7984. }
  7985. const rootClientId = select.getBlockRootClientId(clientId);
  7986. const isLocked = select.getTemplateLock(rootClientId);
  7987. if (isLocked) {
  7988. return;
  7989. }
  7990. const firstSelectedIndex = select.getBlockIndex(clientId);
  7991. return dispatch.insertDefaultBlock({}, rootClientId, firstSelectedIndex + 1);
  7992. };
  7993. /**
  7994. * Action that toggles the highlighted block state.
  7995. *
  7996. * @param {string} clientId The block's clientId.
  7997. * @param {boolean} isHighlighted The highlight state.
  7998. */
  7999. function toggleBlockHighlight(clientId, isHighlighted) {
  8000. return {
  8001. type: 'TOGGLE_BLOCK_HIGHLIGHT',
  8002. clientId,
  8003. isHighlighted
  8004. };
  8005. }
  8006. /**
  8007. * Action that "flashes" the block with a given `clientId` by rhythmically highlighting it.
  8008. *
  8009. * @param {string} clientId Target block client ID.
  8010. */
  8011. const flashBlock = clientId => async _ref24 => {
  8012. let {
  8013. dispatch
  8014. } = _ref24;
  8015. dispatch(toggleBlockHighlight(clientId, true));
  8016. await new Promise(resolve => setTimeout(resolve, 150));
  8017. dispatch(toggleBlockHighlight(clientId, false));
  8018. };
  8019. /**
  8020. * Action that sets whether a block has controlled inner blocks.
  8021. *
  8022. * @param {string} clientId The block's clientId.
  8023. * @param {boolean} hasControlledInnerBlocks True if the block's inner blocks are controlled.
  8024. */
  8025. function setHasControlledInnerBlocks(clientId, hasControlledInnerBlocks) {
  8026. return {
  8027. type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
  8028. hasControlledInnerBlocks,
  8029. clientId
  8030. };
  8031. }
  8032. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/constants.js
  8033. const STORE_NAME = 'core/block-editor';
  8034. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/index.js
  8035. /**
  8036. * WordPress dependencies
  8037. */
  8038. /**
  8039. * Internal dependencies
  8040. */
  8041. /**
  8042. * Block editor data store configuration.
  8043. *
  8044. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
  8045. *
  8046. * @type {Object}
  8047. */
  8048. const storeConfig = {
  8049. reducer: reducer,
  8050. selectors: selectors_namespaceObject,
  8051. actions: actions_namespaceObject
  8052. };
  8053. /**
  8054. * Store definition for the block editor namespace.
  8055. *
  8056. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  8057. *
  8058. * @type {Object}
  8059. */
  8060. const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { ...storeConfig,
  8061. persist: ['preferences']
  8062. }); // Ideally we'd use register instead of register stores.
  8063. (0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, { ...storeConfig,
  8064. persist: ['preferences']
  8065. });
  8066. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/context.js
  8067. /**
  8068. * WordPress dependencies
  8069. */
  8070. const DEFAULT_BLOCK_EDIT_CONTEXT = {
  8071. name: '',
  8072. isSelected: false
  8073. };
  8074. const Context = (0,external_wp_element_namespaceObject.createContext)(DEFAULT_BLOCK_EDIT_CONTEXT);
  8075. const {
  8076. Provider
  8077. } = Context;
  8078. /**
  8079. * A hook that returns the block edit context.
  8080. *
  8081. * @return {Object} Block edit context
  8082. */
  8083. function useBlockEditContext() {
  8084. return (0,external_wp_element_namespaceObject.useContext)(Context);
  8085. }
  8086. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-display-block-controls/index.js
  8087. /**
  8088. * WordPress dependencies
  8089. */
  8090. /**
  8091. * Internal dependencies
  8092. */
  8093. function useDisplayBlockControls() {
  8094. const {
  8095. isSelected,
  8096. clientId,
  8097. name
  8098. } = useBlockEditContext();
  8099. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  8100. if (isSelected) {
  8101. return true;
  8102. }
  8103. const {
  8104. getBlockName,
  8105. isFirstMultiSelectedBlock,
  8106. getMultiSelectedBlockClientIds
  8107. } = select(store);
  8108. if (isFirstMultiSelectedBlock(clientId)) {
  8109. return getMultiSelectedBlockClientIds().every(id => getBlockName(id) === name);
  8110. }
  8111. return false;
  8112. }, [clientId, isSelected, name]);
  8113. }
  8114. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/hook.js
  8115. /**
  8116. * WordPress dependencies
  8117. */
  8118. /**
  8119. * Internal dependencies
  8120. */
  8121. function useBlockControlsFill(group, shareWithChildBlocks) {
  8122. const isDisplayed = useDisplayBlockControls();
  8123. const {
  8124. clientId
  8125. } = useBlockEditContext();
  8126. const isParentDisplayed = (0,external_wp_data_namespaceObject.useSelect)(select => {
  8127. const {
  8128. getBlockName,
  8129. hasSelectedInnerBlock
  8130. } = select(store);
  8131. const {
  8132. hasBlockSupport
  8133. } = select(external_wp_blocks_namespaceObject.store);
  8134. return shareWithChildBlocks && hasBlockSupport(getBlockName(clientId), '__experimentalExposeControlsToChildren', false) && hasSelectedInnerBlock(clientId);
  8135. }, [shareWithChildBlocks, clientId]);
  8136. if (isDisplayed) {
  8137. var _groups$group;
  8138. return (_groups$group = block_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill;
  8139. }
  8140. if (isParentDisplayed) {
  8141. return block_controls_groups.parent.Fill;
  8142. }
  8143. return null;
  8144. }
  8145. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/fill.js
  8146. /**
  8147. * External dependencies
  8148. */
  8149. /**
  8150. * WordPress dependencies
  8151. */
  8152. /**
  8153. * Internal dependencies
  8154. */
  8155. function BlockControlsFill(_ref) {
  8156. let {
  8157. group = 'default',
  8158. controls,
  8159. children,
  8160. __experimentalShareWithChildBlocks = false
  8161. } = _ref;
  8162. const Fill = useBlockControlsFill(group, __experimentalShareWithChildBlocks);
  8163. if (!Fill) {
  8164. return null;
  8165. }
  8166. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
  8167. document: document
  8168. }, (0,external_wp_element_namespaceObject.createElement)(Fill, null, fillProps => {
  8169. // Children passed to BlockControlsFill will not have access to any
  8170. // React Context whose Provider is part of the BlockControlsSlot tree.
  8171. // So we re-create the Provider in this subtree.
  8172. const value = !(0,external_lodash_namespaceObject.isEmpty)(fillProps) ? fillProps : null;
  8173. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolbarContext.Provider, {
  8174. value: value
  8175. }, group === 'default' && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
  8176. controls: controls
  8177. }), children);
  8178. }));
  8179. }
  8180. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/slot.js
  8181. /**
  8182. * WordPress dependencies
  8183. */
  8184. /**
  8185. * Internal dependencies
  8186. */
  8187. function BlockControlsSlot(_ref) {
  8188. let {
  8189. group = 'default',
  8190. ...props
  8191. } = _ref;
  8192. const accessibleToolbarState = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.__experimentalToolbarContext);
  8193. const Slot = block_controls_groups[group].Slot;
  8194. const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(Slot.__unstableName);
  8195. const hasFills = Boolean(slot.fills && slot.fills.length);
  8196. if (!hasFills) {
  8197. return null;
  8198. }
  8199. if (group === 'default') {
  8200. return (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, {
  8201. bubblesVirtually: true,
  8202. fillProps: accessibleToolbarState
  8203. }));
  8204. }
  8205. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, {
  8206. bubblesVirtually: true,
  8207. fillProps: accessibleToolbarState
  8208. })));
  8209. }
  8210. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/index.js
  8211. /**
  8212. * Internal dependencies
  8213. */
  8214. const BlockControls = BlockControlsFill;
  8215. BlockControls.Slot = BlockControlsSlot; // This is just here for backward compatibility.
  8216. const BlockFormatControls = props => {
  8217. return (0,external_wp_element_namespaceObject.createElement)(BlockControlsFill, _extends({
  8218. group: "inline"
  8219. }, props));
  8220. };
  8221. BlockFormatControls.Slot = props => {
  8222. return (0,external_wp_element_namespaceObject.createElement)(BlockControlsSlot, _extends({
  8223. group: "inline"
  8224. }, props));
  8225. };
  8226. /* harmony default export */ var block_controls = (BlockControls);
  8227. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-none.js
  8228. /**
  8229. * WordPress dependencies
  8230. */
  8231. const alignNone = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8232. xmlns: "http://www.w3.org/2000/svg",
  8233. viewBox: "0 0 24 24"
  8234. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8235. d: "M5 15h14V9H5v6zm0 4.8h14v-1.5H5v1.5zM5 4.2v1.5h14V4.2H5z"
  8236. }));
  8237. /* harmony default export */ var align_none = (alignNone);
  8238. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-left.js
  8239. /**
  8240. * WordPress dependencies
  8241. */
  8242. const positionLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8243. xmlns: "http://www.w3.org/2000/svg",
  8244. viewBox: "0 0 24 24"
  8245. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8246. d: "M4 9v6h14V9H4zm8-4.8H4v1.5h8V4.2zM4 19.8h8v-1.5H4v1.5z"
  8247. }));
  8248. /* harmony default export */ var position_left = (positionLeft);
  8249. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-center.js
  8250. /**
  8251. * WordPress dependencies
  8252. */
  8253. const positionCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8254. xmlns: "http://www.w3.org/2000/svg",
  8255. viewBox: "0 0 24 24"
  8256. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8257. d: "M7 9v6h10V9H7zM5 19.8h14v-1.5H5v1.5zM5 4.3v1.5h14V4.3H5z"
  8258. }));
  8259. /* harmony default export */ var position_center = (positionCenter);
  8260. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-right.js
  8261. /**
  8262. * WordPress dependencies
  8263. */
  8264. const positionRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8265. xmlns: "http://www.w3.org/2000/svg",
  8266. viewBox: "0 0 24 24"
  8267. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8268. d: "M6 15h14V9H6v6zm6-10.8v1.5h8V4.2h-8zm0 15.6h8v-1.5h-8v1.5z"
  8269. }));
  8270. /* harmony default export */ var position_right = (positionRight);
  8271. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stretch-wide.js
  8272. /**
  8273. * WordPress dependencies
  8274. */
  8275. const stretchWide = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8276. xmlns: "http://www.w3.org/2000/svg",
  8277. viewBox: "0 0 24 24"
  8278. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8279. d: "M5 9v6h14V9H5zm11-4.8H8v1.5h8V4.2zM8 19.8h8v-1.5H8v1.5z"
  8280. }));
  8281. /* harmony default export */ var stretch_wide = (stretchWide);
  8282. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stretch-full-width.js
  8283. /**
  8284. * WordPress dependencies
  8285. */
  8286. const stretchFullWidth = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8287. xmlns: "http://www.w3.org/2000/svg",
  8288. viewBox: "0 0 24 24"
  8289. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8290. d: "M5 4v11h14V4H5zm3 15.8h8v-1.5H8v1.5z"
  8291. }));
  8292. /* harmony default export */ var stretch_full_width = (stretchFullWidth);
  8293. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-left.js
  8294. /**
  8295. * WordPress dependencies
  8296. */
  8297. const justifyLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8298. xmlns: "http://www.w3.org/2000/svg",
  8299. viewBox: "0 0 24 24"
  8300. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8301. d: "M9 9v6h11V9H9zM4 20h1.5V4H4v16z"
  8302. }));
  8303. /* harmony default export */ var justify_left = (justifyLeft);
  8304. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-center.js
  8305. /**
  8306. * WordPress dependencies
  8307. */
  8308. const justifyCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8309. xmlns: "http://www.w3.org/2000/svg",
  8310. viewBox: "0 0 24 24"
  8311. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8312. d: "M20 9h-7.2V4h-1.6v5H4v6h7.2v5h1.6v-5H20z"
  8313. }));
  8314. /* harmony default export */ var justify_center = (justifyCenter);
  8315. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-right.js
  8316. /**
  8317. * WordPress dependencies
  8318. */
  8319. const justifyRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8320. xmlns: "http://www.w3.org/2000/svg",
  8321. viewBox: "0 0 24 24"
  8322. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8323. d: "M4 15h11V9H4v6zM18.5 4v16H20V4h-1.5z"
  8324. }));
  8325. /* harmony default export */ var justify_right = (justifyRight);
  8326. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-space-between.js
  8327. /**
  8328. * WordPress dependencies
  8329. */
  8330. const justifySpaceBetween = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8331. xmlns: "http://www.w3.org/2000/svg",
  8332. viewBox: "0 0 24 24"
  8333. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8334. d: "M9 15h6V9H9v6zm-5 5h1.5V4H4v16zM18.5 4v16H20V4h-1.5z"
  8335. }));
  8336. /* harmony default export */ var justify_space_between = (justifySpaceBetween);
  8337. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-right.js
  8338. /**
  8339. * WordPress dependencies
  8340. */
  8341. const arrowRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8342. xmlns: "http://www.w3.org/2000/svg",
  8343. viewBox: "0 0 24 24"
  8344. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8345. 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"
  8346. }));
  8347. /* harmony default export */ var arrow_right = (arrowRight);
  8348. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-down.js
  8349. /**
  8350. * WordPress dependencies
  8351. */
  8352. const arrowDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8353. xmlns: "http://www.w3.org/2000/svg",
  8354. viewBox: "0 0 24 24"
  8355. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8356. 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"
  8357. }));
  8358. /* harmony default export */ var arrow_down = (arrowDown);
  8359. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/utils.js
  8360. /**
  8361. * Utility to generate the proper CSS selector for layout styles.
  8362. *
  8363. * @param {string|string[]} selectors - CSS selectors
  8364. * @param {boolean} append - string to append.
  8365. *
  8366. * @return {string} - CSS selector.
  8367. */
  8368. function appendSelectors(selectors) {
  8369. let append = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  8370. // Ideally we shouldn't need the `.editor-styles-wrapper` increased specificity here
  8371. // The problem though is that we have a `.editor-styles-wrapper p { margin: reset; }` style
  8372. // it's used to reset the default margin added by wp-admin to paragraphs
  8373. // so we need this to be higher speficity otherwise, it won't be applied to paragraphs inside containers
  8374. // When the post editor is fully iframed, this extra classname could be removed.
  8375. return selectors.split(',').map(subselector => `.editor-styles-wrapper ${subselector} ${append}`).join(',');
  8376. }
  8377. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/block-refs-provider.js
  8378. /**
  8379. * WordPress dependencies
  8380. */
  8381. const BlockRefs = (0,external_wp_element_namespaceObject.createContext)({
  8382. refs: new Map(),
  8383. callbacks: new Map()
  8384. });
  8385. function BlockRefsProvider(_ref) {
  8386. let {
  8387. children
  8388. } = _ref;
  8389. const value = (0,external_wp_element_namespaceObject.useMemo)(() => ({
  8390. refs: new Map(),
  8391. callbacks: new Map()
  8392. }), []);
  8393. return (0,external_wp_element_namespaceObject.createElement)(BlockRefs.Provider, {
  8394. value: value
  8395. }, children);
  8396. }
  8397. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-refs.js
  8398. /**
  8399. * WordPress dependencies
  8400. */
  8401. /**
  8402. * Internal dependencies
  8403. */
  8404. /** @typedef {import('@wordpress/element').RefCallback} RefCallback */
  8405. /** @typedef {import('@wordpress/element').RefObject} RefObject */
  8406. /**
  8407. * Provides a ref to the BlockRefs context.
  8408. *
  8409. * @param {string} clientId The client ID of the element ref.
  8410. *
  8411. * @return {RefCallback} Ref callback.
  8412. */
  8413. function useBlockRefProvider(clientId) {
  8414. const {
  8415. refs,
  8416. callbacks
  8417. } = (0,external_wp_element_namespaceObject.useContext)(BlockRefs);
  8418. const ref = (0,external_wp_element_namespaceObject.useRef)();
  8419. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  8420. refs.set(ref, clientId);
  8421. return () => {
  8422. refs.delete(ref);
  8423. };
  8424. }, [clientId]);
  8425. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  8426. // Update the ref in the provider.
  8427. ref.current = element; // Call any update functions.
  8428. callbacks.forEach((id, setElement) => {
  8429. if (clientId === id) {
  8430. setElement(element);
  8431. }
  8432. });
  8433. }, [clientId]);
  8434. }
  8435. /**
  8436. * Gets a ref pointing to the current block element. Continues to return a
  8437. * stable ref even if the block client ID changes.
  8438. *
  8439. * @param {string} clientId The client ID to get a ref for.
  8440. *
  8441. * @return {RefObject} A ref containing the element.
  8442. */
  8443. function useBlockRef(clientId) {
  8444. const {
  8445. refs
  8446. } = (0,external_wp_element_namespaceObject.useContext)(BlockRefs);
  8447. const freshClientId = (0,external_wp_element_namespaceObject.useRef)();
  8448. freshClientId.current = clientId; // Always return an object, even if no ref exists for a given client ID, so
  8449. // that `current` works at a later point.
  8450. return (0,external_wp_element_namespaceObject.useMemo)(() => ({
  8451. get current() {
  8452. let element = null; // Multiple refs may be created for a single block. Find the
  8453. // first that has an element set.
  8454. for (const [ref, id] of refs.entries()) {
  8455. if (id === freshClientId.current && ref.current) {
  8456. element = ref.current;
  8457. }
  8458. }
  8459. return element;
  8460. }
  8461. }), []);
  8462. }
  8463. /**
  8464. * Return the element for a given client ID. Updates whenever the element
  8465. * changes, becomes available, or disappears.
  8466. *
  8467. * @param {string} clientId The client ID to an element for.
  8468. *
  8469. * @return {Element|null} The block's wrapper element.
  8470. */
  8471. function useBlockElement(clientId) {
  8472. const {
  8473. callbacks
  8474. } = (0,external_wp_element_namespaceObject.useContext)(BlockRefs);
  8475. const ref = useBlockRef(clientId);
  8476. const [element, setElement] = (0,external_wp_element_namespaceObject.useState)(null);
  8477. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  8478. if (!clientId) {
  8479. return;
  8480. }
  8481. callbacks.set(setElement, clientId);
  8482. return () => {
  8483. callbacks.delete(setElement);
  8484. };
  8485. }, [clientId]);
  8486. return ref.current || element;
  8487. }
  8488. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-setting/index.js
  8489. /**
  8490. * External dependencies
  8491. */
  8492. /**
  8493. * WordPress dependencies
  8494. */
  8495. /**
  8496. * Internal dependencies
  8497. */
  8498. const blockedPaths = ['color', 'border', 'typography', 'spacing'];
  8499. const deprecatedFlags = {
  8500. 'color.palette': settings => settings.colors === undefined ? undefined : settings.colors,
  8501. 'color.gradients': settings => settings.gradients === undefined ? undefined : settings.gradients,
  8502. 'color.custom': settings => settings.disableCustomColors === undefined ? undefined : !settings.disableCustomColors,
  8503. 'color.customGradient': settings => settings.disableCustomGradients === undefined ? undefined : !settings.disableCustomGradients,
  8504. 'typography.fontSizes': settings => settings.fontSizes === undefined ? undefined : settings.fontSizes,
  8505. 'typography.customFontSize': settings => settings.disableCustomFontSizes === undefined ? undefined : !settings.disableCustomFontSizes,
  8506. 'typography.lineHeight': settings => settings.enableCustomLineHeight,
  8507. 'spacing.units': settings => {
  8508. if (settings.enableCustomUnits === undefined) {
  8509. return;
  8510. }
  8511. if (settings.enableCustomUnits === true) {
  8512. return ['px', 'em', 'rem', 'vh', 'vw', '%'];
  8513. }
  8514. return settings.enableCustomUnits;
  8515. },
  8516. 'spacing.padding': settings => settings.enableCustomSpacing
  8517. };
  8518. const prefixedFlags = {
  8519. /*
  8520. * These were only available in the plugin
  8521. * and can be removed when the minimum WordPress version
  8522. * for the plugin is 5.9.
  8523. */
  8524. 'border.customColor': 'border.color',
  8525. 'border.customStyle': 'border.style',
  8526. 'border.customWidth': 'border.width',
  8527. 'typography.customFontStyle': 'typography.fontStyle',
  8528. 'typography.customFontWeight': 'typography.fontWeight',
  8529. 'typography.customLetterSpacing': 'typography.letterSpacing',
  8530. 'typography.customTextDecorations': 'typography.textDecoration',
  8531. 'typography.customTextTransforms': 'typography.textTransform',
  8532. /*
  8533. * These were part of WordPress 5.8 and we need to keep them.
  8534. */
  8535. 'border.customRadius': 'border.radius',
  8536. 'spacing.customMargin': 'spacing.margin',
  8537. 'spacing.customPadding': 'spacing.padding',
  8538. 'typography.customLineHeight': 'typography.lineHeight'
  8539. };
  8540. /**
  8541. * Remove `custom` prefixes for flags that did not land in 5.8.
  8542. *
  8543. * This provides continued support for `custom` prefixed properties. It will
  8544. * be removed once third party devs have had sufficient time to update themes,
  8545. * plugins, etc.
  8546. *
  8547. * @see https://github.com/WordPress/gutenberg/pull/34485
  8548. *
  8549. * @param {string} path Path to desired value in settings.
  8550. * @return {string} The value for defined setting.
  8551. */
  8552. const removeCustomPrefixes = path => {
  8553. return prefixedFlags[path] || path;
  8554. };
  8555. /**
  8556. * Hook that retrieves the editor setting.
  8557. * It works with nested objects using by finding the value at path.
  8558. *
  8559. * @param {string} path The path to the setting.
  8560. * @return {any} Returns the value defined for the setting.
  8561. * @example
  8562. * ```js
  8563. * const isEnabled = useSetting( 'typography.dropCap' );
  8564. * ```
  8565. */
  8566. function useSetting(path) {
  8567. const {
  8568. name: blockName
  8569. } = useBlockEditContext();
  8570. const setting = (0,external_wp_data_namespaceObject.useSelect)(select => {
  8571. var _get;
  8572. if (blockedPaths.includes(path)) {
  8573. // eslint-disable-next-line no-console
  8574. console.warn('Top level useSetting paths are disabled. Please use a subpath to query the information needed.');
  8575. return undefined;
  8576. }
  8577. const settings = select(store).getSettings(); // 1 - Use __experimental features, if available.
  8578. // We cascade to the all value if the block one is not available.
  8579. const normalizedPath = removeCustomPrefixes(path);
  8580. const defaultsPath = `__experimentalFeatures.${normalizedPath}`;
  8581. const blockPath = `__experimentalFeatures.blocks.${blockName}.${normalizedPath}`;
  8582. const experimentalFeaturesResult = (_get = (0,external_lodash_namespaceObject.get)(settings, blockPath)) !== null && _get !== void 0 ? _get : (0,external_lodash_namespaceObject.get)(settings, defaultsPath);
  8583. if (experimentalFeaturesResult !== undefined) {
  8584. if (external_wp_blocks_namespaceObject.__EXPERIMENTAL_PATHS_WITH_MERGE[normalizedPath]) {
  8585. var _ref, _experimentalFeatures;
  8586. return (_ref = (_experimentalFeatures = experimentalFeaturesResult.custom) !== null && _experimentalFeatures !== void 0 ? _experimentalFeatures : experimentalFeaturesResult.theme) !== null && _ref !== void 0 ? _ref : experimentalFeaturesResult.default;
  8587. }
  8588. return experimentalFeaturesResult;
  8589. } // 2 - Use deprecated settings, otherwise.
  8590. const deprecatedSettingsValue = deprecatedFlags[normalizedPath] ? deprecatedFlags[normalizedPath](settings) : undefined;
  8591. if (deprecatedSettingsValue !== undefined) {
  8592. return deprecatedSettingsValue;
  8593. } // 3 - Fall back for typography.dropCap:
  8594. // This is only necessary to support typography.dropCap.
  8595. // when __experimentalFeatures are not present (core without plugin).
  8596. // To remove when __experimentalFeatures are ported to core.
  8597. return normalizedPath === 'typography.dropCap' ? true : undefined;
  8598. }, [blockName, path]);
  8599. return setting;
  8600. }
  8601. ;// CONCATENATED MODULE: external ["wp","warning"]
  8602. var external_wp_warning_namespaceObject = window["wp"]["warning"];
  8603. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/groups.js
  8604. /**
  8605. * WordPress dependencies
  8606. */
  8607. const InspectorControlsDefault = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControls');
  8608. const InspectorControlsAdvanced = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorAdvancedControls');
  8609. const InspectorControlsBorder = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsBorder');
  8610. const InspectorControlsColor = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsColor');
  8611. const InspectorControlsDimensions = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsDimensions');
  8612. const InspectorControlsTypography = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsTypography');
  8613. const groups_groups = {
  8614. default: InspectorControlsDefault,
  8615. advanced: InspectorControlsAdvanced,
  8616. border: InspectorControlsBorder,
  8617. color: InspectorControlsColor,
  8618. dimensions: InspectorControlsDimensions,
  8619. typography: InspectorControlsTypography
  8620. };
  8621. /* harmony default export */ var inspector_controls_groups = (groups_groups);
  8622. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/fill.js
  8623. /**
  8624. * External dependencies
  8625. */
  8626. /**
  8627. * WordPress dependencies
  8628. */
  8629. /**
  8630. * Internal dependencies
  8631. */
  8632. function InspectorControlsFill(_ref) {
  8633. var _groups$group;
  8634. let {
  8635. __experimentalGroup: group = 'default',
  8636. children
  8637. } = _ref;
  8638. const isDisplayed = useDisplayBlockControls();
  8639. const Fill = (_groups$group = inspector_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill;
  8640. if (!Fill) {
  8641. typeof process !== "undefined" && process.env && "production" !== "production" ? 0 : void 0;
  8642. return null;
  8643. }
  8644. if (!isDisplayed) {
  8645. return null;
  8646. }
  8647. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
  8648. document: document
  8649. }, (0,external_wp_element_namespaceObject.createElement)(Fill, null, fillProps => {
  8650. // Children passed to InspectorControlsFill will not have
  8651. // access to any React Context whose Provider is part of
  8652. // the InspectorControlsSlot tree. So we re-create the
  8653. // Provider in this subtree.
  8654. const value = !(0,external_lodash_namespaceObject.isEmpty)(fillProps) ? fillProps : null;
  8655. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelContext.Provider, {
  8656. value: value
  8657. }, children);
  8658. }));
  8659. }
  8660. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/utils.js
  8661. /**
  8662. * External dependencies
  8663. */
  8664. /**
  8665. * WordPress dependencies
  8666. */
  8667. /**
  8668. * Removed falsy values from nested object.
  8669. *
  8670. * @param {*} object
  8671. * @return {*} Object cleaned from falsy values
  8672. */
  8673. const cleanEmptyObject = object => {
  8674. if (!(0,external_lodash_namespaceObject.isObject)(object) || Array.isArray(object)) {
  8675. return object;
  8676. }
  8677. const cleanedNestedObjects = (0,external_lodash_namespaceObject.pickBy)((0,external_lodash_namespaceObject.mapValues)(object, cleanEmptyObject), external_lodash_namespaceObject.identity);
  8678. return (0,external_lodash_namespaceObject.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
  8679. };
  8680. function immutableSet(object, path, value) {
  8681. return (0,external_lodash_namespaceObject.setWith)(object ? (0,external_lodash_namespaceObject.clone)(object) : {}, path, value, external_lodash_namespaceObject.clone);
  8682. }
  8683. function transformStyles(activeSupports, migrationPaths, result, source, index, results) {
  8684. var _source$;
  8685. // If there are no active supports return early.
  8686. if ((0,external_lodash_namespaceObject.every)(activeSupports, isActive => !isActive)) {
  8687. return result;
  8688. } // If the condition verifies we are probably in the presence of a wrapping transform
  8689. // e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.
  8690. if (results.length === 1 && result.innerBlocks.length === source.length) {
  8691. return result;
  8692. } // For cases where we have a transform from one block to multiple blocks
  8693. // or multiple blocks to one block we apply the styles of the first source block
  8694. // to the result(s).
  8695. 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
  8696. // that has more than one block in the result
  8697. // we apply the styles on source N to the result N,
  8698. // if source N does not exists we do nothing.
  8699. if (results.length > 1 && source.length > 1) {
  8700. if (source[index]) {
  8701. var _source$index;
  8702. referenceBlockAttributes = (_source$index = source[index]) === null || _source$index === void 0 ? void 0 : _source$index.attributes;
  8703. } else {
  8704. return result;
  8705. }
  8706. }
  8707. let returnBlock = result;
  8708. (0,external_lodash_namespaceObject.forEach)(activeSupports, (isActive, support) => {
  8709. if (isActive) {
  8710. migrationPaths[support].forEach(path => {
  8711. const styleValue = (0,external_lodash_namespaceObject.get)(referenceBlockAttributes, path);
  8712. if (styleValue) {
  8713. returnBlock = { ...returnBlock,
  8714. attributes: immutableSet(returnBlock.attributes, path, styleValue)
  8715. };
  8716. }
  8717. });
  8718. }
  8719. });
  8720. return returnBlock;
  8721. }
  8722. /**
  8723. * Check whether serialization of specific block support feature or set should
  8724. * be skipped.
  8725. *
  8726. * @param {string|Object} blockType Block name or block type object.
  8727. * @param {string} featureSet Name of block support feature set.
  8728. * @param {string} feature Name of the individual feature to check.
  8729. *
  8730. * @return {boolean} Whether serialization should occur.
  8731. */
  8732. function shouldSkipSerialization(blockType, featureSet, feature) {
  8733. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, featureSet);
  8734. const skipSerialization = support === null || support === void 0 ? void 0 : support.__experimentalSkipSerialization;
  8735. if (Array.isArray(skipSerialization)) {
  8736. return skipSerialization.includes(feature);
  8737. }
  8738. return skipSerialization;
  8739. }
  8740. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/block-support-tools-panel.js
  8741. /**
  8742. * WordPress dependencies
  8743. */
  8744. /**
  8745. * Internal dependencies
  8746. */
  8747. function BlockSupportToolsPanel(_ref) {
  8748. let {
  8749. children,
  8750. group,
  8751. label
  8752. } = _ref;
  8753. const {
  8754. updateBlockAttributes
  8755. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  8756. const {
  8757. getBlockAttributes,
  8758. getMultiSelectedBlockClientIds,
  8759. getSelectedBlockClientId,
  8760. hasMultiSelection
  8761. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  8762. const panelId = getSelectedBlockClientId();
  8763. const resetAll = (0,external_wp_element_namespaceObject.useCallback)(function () {
  8764. let resetFilters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  8765. const newAttributes = {};
  8766. const clientIds = hasMultiSelection() ? getMultiSelectedBlockClientIds() : [panelId];
  8767. clientIds.forEach(clientId => {
  8768. const {
  8769. style
  8770. } = getBlockAttributes(clientId);
  8771. let newBlockAttributes = {
  8772. style
  8773. };
  8774. resetFilters.forEach(resetFilter => {
  8775. newBlockAttributes = { ...newBlockAttributes,
  8776. ...resetFilter(newBlockAttributes)
  8777. };
  8778. }); // Enforce a cleaned style object.
  8779. newBlockAttributes = { ...newBlockAttributes,
  8780. style: cleanEmptyObject(newBlockAttributes.style)
  8781. };
  8782. newAttributes[clientId] = newBlockAttributes;
  8783. });
  8784. updateBlockAttributes(clientIds, newAttributes, true);
  8785. }, [cleanEmptyObject, getBlockAttributes, getMultiSelectedBlockClientIds, hasMultiSelection, panelId, updateBlockAttributes]);
  8786. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, {
  8787. className: `${group}-block-support-panel`,
  8788. label: label,
  8789. resetAll: resetAll,
  8790. key: panelId,
  8791. panelId: panelId,
  8792. hasInnerWrapper: true,
  8793. shouldRenderPlaceholderItems: true // Required to maintain fills ordering.
  8794. ,
  8795. __experimentalFirstVisibleItemClass: "first",
  8796. __experimentalLastVisibleItemClass: "last"
  8797. }, children);
  8798. }
  8799. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/block-support-slot-container.js
  8800. /**
  8801. * WordPress dependencies
  8802. */
  8803. function BlockSupportSlotContainer(_ref) {
  8804. let {
  8805. Slot,
  8806. ...props
  8807. } = _ref;
  8808. const toolsPanelContext = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.__experimentalToolsPanelContext);
  8809. return (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, {
  8810. fillProps: toolsPanelContext,
  8811. bubblesVirtually: true
  8812. }));
  8813. }
  8814. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/slot.js
  8815. /**
  8816. * WordPress dependencies
  8817. */
  8818. /**
  8819. * Internal dependencies
  8820. */
  8821. function InspectorControlsSlot(_ref) {
  8822. var _groups$group;
  8823. let {
  8824. __experimentalGroup: group = 'default',
  8825. label,
  8826. ...props
  8827. } = _ref;
  8828. const Slot = (_groups$group = inspector_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Slot;
  8829. const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(Slot === null || Slot === void 0 ? void 0 : Slot.__unstableName);
  8830. if (!Slot || !slot) {
  8831. typeof process !== "undefined" && process.env && "production" !== "production" ? 0 : void 0;
  8832. return null;
  8833. }
  8834. const hasFills = Boolean(slot.fills && slot.fills.length);
  8835. if (!hasFills) {
  8836. return null;
  8837. }
  8838. if (label) {
  8839. return (0,external_wp_element_namespaceObject.createElement)(BlockSupportToolsPanel, {
  8840. group: group,
  8841. label: label
  8842. }, (0,external_wp_element_namespaceObject.createElement)(BlockSupportSlotContainer, _extends({}, props, {
  8843. Slot: Slot
  8844. })));
  8845. }
  8846. return (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, {
  8847. bubblesVirtually: true
  8848. }));
  8849. }
  8850. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/index.js
  8851. /**
  8852. * Internal dependencies
  8853. */
  8854. const InspectorControls = InspectorControlsFill;
  8855. InspectorControls.Slot = InspectorControlsSlot; // This is just here for backward compatibility.
  8856. const InspectorAdvancedControls = props => {
  8857. return (0,external_wp_element_namespaceObject.createElement)(InspectorControlsFill, _extends({}, props, {
  8858. __experimentalGroup: "advanced"
  8859. }));
  8860. };
  8861. InspectorAdvancedControls.Slot = props => {
  8862. return (0,external_wp_element_namespaceObject.createElement)(InspectorControlsSlot, _extends({}, props, {
  8863. __experimentalGroup: "advanced"
  8864. }));
  8865. };
  8866. InspectorAdvancedControls.slotName = 'InspectorAdvancedControls';
  8867. /**
  8868. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-controls/README.md
  8869. */
  8870. /* harmony default export */ var inspector_controls = (InspectorControls);
  8871. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/margin.js
  8872. /**
  8873. * WordPress dependencies
  8874. */
  8875. /**
  8876. * Internal dependencies
  8877. */
  8878. /**
  8879. * Determines if there is margin support.
  8880. *
  8881. * @param {string|Object} blockType Block name or Block Type object.
  8882. *
  8883. * @return {boolean} Whether there is support.
  8884. */
  8885. function hasMarginSupport(blockType) {
  8886. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, SPACING_SUPPORT_KEY);
  8887. return !!(true === support || support !== null && support !== void 0 && support.margin);
  8888. }
  8889. /**
  8890. * Checks if there is a current value in the margin block support attributes.
  8891. *
  8892. * @param {Object} props Block props.
  8893. * @return {boolean} Whether or not the block has a margin value set.
  8894. */
  8895. function hasMarginValue(props) {
  8896. var _props$attributes$sty, _props$attributes$sty2;
  8897. 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;
  8898. }
  8899. /**
  8900. * Resets the margin block support attributes. This can be used when disabling
  8901. * the margin support controls for a block via a `ToolsPanel`.
  8902. *
  8903. * @param {Object} props Block props.
  8904. * @param {Object} props.attributes Block's attributes.
  8905. * @param {Object} props.setAttributes Function to set block's attributes.
  8906. */
  8907. function resetMargin(_ref) {
  8908. let {
  8909. attributes = {},
  8910. setAttributes
  8911. } = _ref;
  8912. const {
  8913. style
  8914. } = attributes;
  8915. setAttributes({
  8916. style: cleanEmptyObject({ ...style,
  8917. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  8918. margin: undefined
  8919. }
  8920. })
  8921. });
  8922. }
  8923. /**
  8924. * Custom hook that checks if margin settings have been disabled.
  8925. *
  8926. * @param {string} name The name of the block.
  8927. *
  8928. * @return {boolean} Whether margin setting is disabled.
  8929. */
  8930. function useIsMarginDisabled() {
  8931. let {
  8932. name: blockName
  8933. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  8934. const isDisabled = !useSetting('spacing.margin');
  8935. const isInvalid = !useIsDimensionsSupportValid(blockName, 'margin');
  8936. return !hasMarginSupport(blockName) || isDisabled || isInvalid;
  8937. }
  8938. /**
  8939. * Inspector control panel containing the margin related configuration
  8940. *
  8941. * @param {Object} props Block props.
  8942. *
  8943. * @return {WPElement} Margin edit element.
  8944. */
  8945. function MarginEdit(props) {
  8946. var _style$spacing;
  8947. const {
  8948. name: blockName,
  8949. attributes: {
  8950. style
  8951. },
  8952. setAttributes
  8953. } = props;
  8954. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  8955. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  8956. });
  8957. const sides = useCustomSides(blockName, 'margin');
  8958. const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
  8959. if (useIsMarginDisabled(props)) {
  8960. return null;
  8961. }
  8962. const onChange = next => {
  8963. const newStyle = { ...style,
  8964. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  8965. margin: next
  8966. }
  8967. };
  8968. setAttributes({
  8969. style: cleanEmptyObject(newStyle)
  8970. });
  8971. };
  8972. const onChangeShowVisualizer = next => {
  8973. const newStyle = { ...style,
  8974. visualizers: {
  8975. margin: next
  8976. }
  8977. };
  8978. setAttributes({
  8979. style: cleanEmptyObject(newStyle)
  8980. });
  8981. };
  8982. return external_wp_element_namespaceObject.Platform.select({
  8983. web: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
  8984. values: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.margin,
  8985. onChange: onChange,
  8986. onChangeShowVisualizer: onChangeShowVisualizer,
  8987. label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
  8988. sides: sides,
  8989. units: units,
  8990. allowReset: false,
  8991. splitOnAxis: splitOnAxis
  8992. })),
  8993. native: null
  8994. });
  8995. }
  8996. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/padding.js
  8997. /**
  8998. * WordPress dependencies
  8999. */
  9000. /**
  9001. * Internal dependencies
  9002. */
  9003. /**
  9004. * Determines if there is padding support.
  9005. *
  9006. * @param {string|Object} blockType Block name or Block Type object.
  9007. *
  9008. * @return {boolean} Whether there is support.
  9009. */
  9010. function hasPaddingSupport(blockType) {
  9011. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, SPACING_SUPPORT_KEY);
  9012. return !!(true === support || support !== null && support !== void 0 && support.padding);
  9013. }
  9014. /**
  9015. * Checks if there is a current value in the padding block support attributes.
  9016. *
  9017. * @param {Object} props Block props.
  9018. * @return {boolean} Whether or not the block has a padding value set.
  9019. */
  9020. function hasPaddingValue(props) {
  9021. var _props$attributes$sty, _props$attributes$sty2;
  9022. 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;
  9023. }
  9024. /**
  9025. * Resets the padding block support attributes. This can be used when disabling
  9026. * the padding support controls for a block via a `ToolsPanel`.
  9027. *
  9028. * @param {Object} props Block props.
  9029. * @param {Object} props.attributes Block's attributes.
  9030. * @param {Object} props.setAttributes Function to set block's attributes.
  9031. */
  9032. function resetPadding(_ref) {
  9033. let {
  9034. attributes = {},
  9035. setAttributes
  9036. } = _ref;
  9037. const {
  9038. style
  9039. } = attributes;
  9040. setAttributes({
  9041. style: cleanEmptyObject({ ...style,
  9042. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  9043. padding: undefined
  9044. }
  9045. })
  9046. });
  9047. }
  9048. /**
  9049. * Custom hook that checks if padding settings have been disabled.
  9050. *
  9051. * @param {string} name The name of the block.
  9052. *
  9053. * @return {boolean} Whether padding setting is disabled.
  9054. */
  9055. function useIsPaddingDisabled() {
  9056. let {
  9057. name: blockName
  9058. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9059. const isDisabled = !useSetting('spacing.padding');
  9060. const isInvalid = !useIsDimensionsSupportValid(blockName, 'padding');
  9061. return !hasPaddingSupport(blockName) || isDisabled || isInvalid;
  9062. }
  9063. /**
  9064. * Inspector control panel containing the padding related configuration
  9065. *
  9066. * @param {Object} props
  9067. *
  9068. * @return {WPElement} Padding edit element.
  9069. */
  9070. function PaddingEdit(props) {
  9071. var _style$spacing;
  9072. const {
  9073. name: blockName,
  9074. attributes: {
  9075. style
  9076. },
  9077. setAttributes
  9078. } = props;
  9079. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  9080. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  9081. });
  9082. const sides = useCustomSides(blockName, 'padding');
  9083. const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
  9084. if (useIsPaddingDisabled(props)) {
  9085. return null;
  9086. }
  9087. const onChange = next => {
  9088. const newStyle = { ...style,
  9089. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  9090. padding: next
  9091. }
  9092. };
  9093. setAttributes({
  9094. style: cleanEmptyObject(newStyle)
  9095. });
  9096. };
  9097. const onChangeShowVisualizer = next => {
  9098. const newStyle = { ...style,
  9099. visualizers: {
  9100. padding: next
  9101. }
  9102. };
  9103. setAttributes({
  9104. style: cleanEmptyObject(newStyle)
  9105. });
  9106. };
  9107. return external_wp_element_namespaceObject.Platform.select({
  9108. web: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
  9109. values: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.padding,
  9110. onChange: onChange,
  9111. onChangeShowVisualizer: onChangeShowVisualizer,
  9112. label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
  9113. sides: sides,
  9114. units: units,
  9115. allowReset: false,
  9116. splitOnAxis: splitOnAxis
  9117. })),
  9118. native: null
  9119. });
  9120. }
  9121. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/dimensions.js
  9122. /**
  9123. * WordPress dependencies
  9124. */
  9125. /**
  9126. * Internal dependencies
  9127. */
  9128. const SPACING_SUPPORT_KEY = 'spacing';
  9129. const ALL_SIDES = ['top', 'right', 'bottom', 'left'];
  9130. const AXIAL_SIDES = ['vertical', 'horizontal'];
  9131. /**
  9132. * Inspector controls for dimensions support.
  9133. *
  9134. * @param {Object} props Block props.
  9135. *
  9136. * @return {WPElement} Inspector controls for spacing support features.
  9137. */
  9138. function DimensionsPanel(props) {
  9139. const isGapDisabled = useIsGapDisabled(props);
  9140. const isPaddingDisabled = useIsPaddingDisabled(props);
  9141. const isMarginDisabled = useIsMarginDisabled(props);
  9142. const isDisabled = useIsDimensionsDisabled(props);
  9143. const isSupported = hasDimensionsSupport(props.name);
  9144. if (isDisabled || !isSupported) {
  9145. return null;
  9146. }
  9147. const defaultSpacingControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [SPACING_SUPPORT_KEY, '__experimentalDefaultControls']);
  9148. const createResetAllFilter = attribute => newAttributes => {
  9149. var _newAttributes$style;
  9150. return { ...newAttributes,
  9151. style: { ...newAttributes.style,
  9152. spacing: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style.spacing),
  9153. [attribute]: undefined
  9154. }
  9155. }
  9156. };
  9157. };
  9158. return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
  9159. __experimentalGroup: "dimensions"
  9160. }, !isPaddingDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  9161. hasValue: () => hasPaddingValue(props),
  9162. label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
  9163. onDeselect: () => resetPadding(props),
  9164. resetAllFilter: createResetAllFilter('padding'),
  9165. isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.padding,
  9166. panelId: props.clientId
  9167. }, (0,external_wp_element_namespaceObject.createElement)(PaddingEdit, props)), !isMarginDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  9168. hasValue: () => hasMarginValue(props),
  9169. label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
  9170. onDeselect: () => resetMargin(props),
  9171. resetAllFilter: createResetAllFilter('margin'),
  9172. isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.margin,
  9173. panelId: props.clientId
  9174. }, (0,external_wp_element_namespaceObject.createElement)(MarginEdit, props)), !isGapDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  9175. hasValue: () => hasGapValue(props),
  9176. label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
  9177. onDeselect: () => resetGap(props),
  9178. resetAllFilter: createResetAllFilter('blockGap'),
  9179. isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.blockGap,
  9180. panelId: props.clientId
  9181. }, (0,external_wp_element_namespaceObject.createElement)(GapEdit, props)));
  9182. }
  9183. /**
  9184. * Determine whether there is dimensions related block support.
  9185. *
  9186. * @param {string} blockName Block name.
  9187. *
  9188. * @return {boolean} Whether there is support.
  9189. */
  9190. function hasDimensionsSupport(blockName) {
  9191. if (external_wp_element_namespaceObject.Platform.OS !== 'web') {
  9192. return false;
  9193. }
  9194. return hasGapSupport(blockName) || hasPaddingSupport(blockName) || hasMarginSupport(blockName);
  9195. }
  9196. /**
  9197. * Determines whether dimensions support has been disabled.
  9198. *
  9199. * @param {Object} props Block properties.
  9200. *
  9201. * @return {boolean} If spacing support is completely disabled.
  9202. */
  9203. const useIsDimensionsDisabled = function () {
  9204. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9205. const gapDisabled = useIsGapDisabled(props);
  9206. const paddingDisabled = useIsPaddingDisabled(props);
  9207. const marginDisabled = useIsMarginDisabled(props);
  9208. return gapDisabled && paddingDisabled && marginDisabled;
  9209. };
  9210. /**
  9211. * Custom hook to retrieve which padding/margin/blockGap is supported
  9212. * e.g. top, right, bottom or left.
  9213. *
  9214. * Sides are opted into by default. It is only if a specific side is set to
  9215. * false that it is omitted.
  9216. *
  9217. * @param {string} blockName Block name.
  9218. * @param {string} feature The feature custom sides relate to e.g. padding or margins.
  9219. *
  9220. * @return {?string[]} Strings representing the custom sides available.
  9221. */
  9222. function useCustomSides(blockName, feature) {
  9223. var _support$feature;
  9224. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, SPACING_SUPPORT_KEY); // Skip when setting is boolean as theme isn't setting arbitrary sides.
  9225. if (!support || typeof support[feature] === 'boolean') {
  9226. return;
  9227. } // Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).
  9228. if (Array.isArray(support[feature])) {
  9229. return support[feature];
  9230. } // Finally, attempt to return `.sides` if the setting is an object.
  9231. if ((_support$feature = support[feature]) !== null && _support$feature !== void 0 && _support$feature.sides) {
  9232. return support[feature].sides;
  9233. }
  9234. }
  9235. /**
  9236. * Custom hook to determine whether the sides configured in the
  9237. * block support are valid. A dimension property cannot declare
  9238. * support for a mix of axial and individual sides.
  9239. *
  9240. * @param {string} blockName Block name.
  9241. * @param {string} feature The feature custom sides relate to e.g. padding or margins.
  9242. *
  9243. * @return {boolean} If the feature has a valid configuration of sides.
  9244. */
  9245. function useIsDimensionsSupportValid(blockName, feature) {
  9246. const sides = useCustomSides(blockName, feature);
  9247. if (sides && sides.some(side => ALL_SIDES.includes(side)) && sides.some(side => AXIAL_SIDES.includes(side))) {
  9248. // eslint-disable-next-line no-console
  9249. console.warn(`The ${feature} support for the "${blockName}" block can not be configured to support both axial and arbitrary sides.`);
  9250. return false;
  9251. }
  9252. return true;
  9253. }
  9254. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/gap.js
  9255. /**
  9256. * WordPress dependencies
  9257. */
  9258. /**
  9259. * Internal dependencies
  9260. */
  9261. /**
  9262. * Determines if there is gap support.
  9263. *
  9264. * @param {string|Object} blockType Block name or Block Type object.
  9265. * @return {boolean} Whether there is support.
  9266. */
  9267. function hasGapSupport(blockType) {
  9268. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, SPACING_SUPPORT_KEY);
  9269. return !!(true === support || support !== null && support !== void 0 && support.blockGap);
  9270. }
  9271. /**
  9272. * Checks if there is a current value in the gap block support attributes.
  9273. *
  9274. * @param {Object} props Block props.
  9275. * @return {boolean} Whether or not the block has a gap value set.
  9276. */
  9277. function hasGapValue(props) {
  9278. var _props$attributes$sty, _props$attributes$sty2;
  9279. 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;
  9280. }
  9281. /**
  9282. * Returns a BoxControl object value from a given blockGap style value.
  9283. * The string check is for backwards compatibility before Gutenberg supported
  9284. * split gap values (row and column) and the value was a string n + unit.
  9285. *
  9286. * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
  9287. * @return {Object|null} A value to pass to the BoxControl component.
  9288. */
  9289. function getGapBoxControlValueFromStyle(blockGapValue) {
  9290. if (!blockGapValue) {
  9291. return null;
  9292. }
  9293. const isValueString = typeof blockGapValue === 'string';
  9294. return {
  9295. top: isValueString ? blockGapValue : blockGapValue === null || blockGapValue === void 0 ? void 0 : blockGapValue.top,
  9296. left: isValueString ? blockGapValue : blockGapValue === null || blockGapValue === void 0 ? void 0 : blockGapValue.left
  9297. };
  9298. }
  9299. /**
  9300. * Returns a CSS value for the `gap` property from a given blockGap style.
  9301. *
  9302. * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
  9303. * @param {string?} defaultValue A default gap value.
  9304. * @return {string|null} The concatenated gap value (row and column).
  9305. */
  9306. function getGapCSSValue(blockGapValue) {
  9307. let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
  9308. const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue);
  9309. if (!blockGapBoxControlValue) {
  9310. return null;
  9311. }
  9312. const row = (blockGapBoxControlValue === null || blockGapBoxControlValue === void 0 ? void 0 : blockGapBoxControlValue.top) || defaultValue;
  9313. const column = (blockGapBoxControlValue === null || blockGapBoxControlValue === void 0 ? void 0 : blockGapBoxControlValue.left) || defaultValue;
  9314. return row === column ? row : `${row} ${column}`;
  9315. }
  9316. /**
  9317. * Resets the gap block support attribute. This can be used when disabling
  9318. * the gap support controls for a block via a progressive discovery panel.
  9319. *
  9320. * @param {Object} props Block props.
  9321. * @param {Object} props.attributes Block's attributes.
  9322. * @param {Object} props.setAttributes Function to set block's attributes.
  9323. */
  9324. function resetGap(_ref) {
  9325. let {
  9326. attributes = {},
  9327. setAttributes
  9328. } = _ref;
  9329. const {
  9330. style
  9331. } = attributes;
  9332. setAttributes({
  9333. style: { ...style,
  9334. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  9335. blockGap: undefined
  9336. }
  9337. }
  9338. });
  9339. }
  9340. /**
  9341. * Custom hook that checks if gap settings have been disabled.
  9342. *
  9343. * @param {string} name The name of the block.
  9344. * @return {boolean} Whether the gap setting is disabled.
  9345. */
  9346. function useIsGapDisabled() {
  9347. let {
  9348. name: blockName
  9349. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9350. const isDisabled = !useSetting('spacing.blockGap');
  9351. return !hasGapSupport(blockName) || isDisabled;
  9352. }
  9353. /**
  9354. * Inspector control panel containing the gap related configuration
  9355. *
  9356. * @param {Object} props
  9357. *
  9358. * @return {WPElement} Gap edit element.
  9359. */
  9360. function GapEdit(props) {
  9361. var _style$spacing;
  9362. const {
  9363. clientId,
  9364. attributes: {
  9365. style
  9366. },
  9367. name: blockName,
  9368. setAttributes
  9369. } = props;
  9370. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  9371. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  9372. });
  9373. const sides = useCustomSides(blockName, 'blockGap');
  9374. const ref = useBlockRef(clientId);
  9375. if (useIsGapDisabled(props)) {
  9376. return null;
  9377. }
  9378. const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
  9379. const onChange = next => {
  9380. var _window;
  9381. let blockGap = next; // If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.
  9382. if (!!next && splitOnAxis) {
  9383. blockGap = { ...getGapBoxControlValueFromStyle(next)
  9384. };
  9385. }
  9386. const newStyle = { ...style,
  9387. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  9388. blockGap
  9389. }
  9390. };
  9391. setAttributes({
  9392. style: cleanEmptyObject(newStyle)
  9393. }); // In Safari, changing the `gap` CSS value on its own will not trigger the layout
  9394. // to be recalculated / re-rendered. To force the updated gap to re-render, here
  9395. // we replace the block's node with itself.
  9396. 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 ');
  9397. if (ref.current && isSafari) {
  9398. var _ref$current$parentNo;
  9399. (_ref$current$parentNo = ref.current.parentNode) === null || _ref$current$parentNo === void 0 ? void 0 : _ref$current$parentNo.replaceChild(ref.current, ref.current);
  9400. }
  9401. };
  9402. 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.
  9403. // Gap row and column values translate to top/bottom and left/right respectively.
  9404. const boxControlGapValue = splitOnAxis ? { ...gapValue,
  9405. right: gapValue === null || gapValue === void 0 ? void 0 : gapValue.left,
  9406. bottom: gapValue === null || gapValue === void 0 ? void 0 : gapValue.top
  9407. } : gapValue === null || gapValue === void 0 ? void 0 : gapValue.top;
  9408. return external_wp_element_namespaceObject.Platform.select({
  9409. web: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, splitOnAxis ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
  9410. label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
  9411. min: 0,
  9412. onChange: onChange,
  9413. units: units,
  9414. sides: sides,
  9415. values: boxControlGapValue,
  9416. allowReset: false,
  9417. splitOnAxis: splitOnAxis
  9418. }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
  9419. label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
  9420. __unstableInputWidth: "80px",
  9421. min: 0,
  9422. onChange: onChange,
  9423. units: units // Default to `row` for combined values.
  9424. ,
  9425. value: boxControlGapValue
  9426. })),
  9427. native: null
  9428. });
  9429. }
  9430. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/icons.js
  9431. /**
  9432. * WordPress dependencies
  9433. */
  9434. const alignBottom = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  9435. xmlns: "http://www.w3.org/2000/svg",
  9436. viewBox: "0 0 24 24"
  9437. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  9438. d: "M15 4H9v11h6V4zM4 18.5V20h16v-1.5H4z"
  9439. }));
  9440. const alignCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  9441. xmlns: "http://www.w3.org/2000/svg",
  9442. viewBox: "0 0 24 24"
  9443. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  9444. d: "M20 11h-5V4H9v7H4v1.5h5V20h6v-7.5h5z"
  9445. }));
  9446. const alignTop = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  9447. xmlns: "http://www.w3.org/2000/svg",
  9448. viewBox: "0 0 24 24"
  9449. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  9450. d: "M9 20h6V9H9v11zM4 4v1.5h16V4H4z"
  9451. }));
  9452. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/ui.js
  9453. /**
  9454. * WordPress dependencies
  9455. */
  9456. /**
  9457. * Internal dependencies
  9458. */
  9459. const BLOCK_ALIGNMENTS_CONTROLS = {
  9460. top: {
  9461. icon: alignTop,
  9462. title: (0,external_wp_i18n_namespaceObject._x)('Align top', 'Block vertical alignment setting')
  9463. },
  9464. center: {
  9465. icon: alignCenter,
  9466. title: (0,external_wp_i18n_namespaceObject._x)('Align middle', 'Block vertical alignment setting')
  9467. },
  9468. bottom: {
  9469. icon: alignBottom,
  9470. title: (0,external_wp_i18n_namespaceObject._x)('Align bottom', 'Block vertical alignment setting')
  9471. }
  9472. };
  9473. const DEFAULT_CONTROLS = ['top', 'center', 'bottom'];
  9474. const DEFAULT_CONTROL = 'top';
  9475. const POPOVER_PROPS = {
  9476. isAlternate: true
  9477. };
  9478. function BlockVerticalAlignmentUI(_ref) {
  9479. let {
  9480. value,
  9481. onChange,
  9482. controls = DEFAULT_CONTROLS,
  9483. isCollapsed = true,
  9484. isToolbar
  9485. } = _ref;
  9486. function applyOrUnset(align) {
  9487. return () => onChange(value === align ? undefined : align);
  9488. }
  9489. const activeAlignment = BLOCK_ALIGNMENTS_CONTROLS[value];
  9490. const defaultAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[DEFAULT_CONTROL];
  9491. const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
  9492. const extraProps = isToolbar ? {
  9493. isCollapsed
  9494. } : {};
  9495. return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({
  9496. popoverProps: POPOVER_PROPS,
  9497. icon: activeAlignment ? activeAlignment.icon : defaultAlignmentControl.icon,
  9498. label: (0,external_wp_i18n_namespaceObject._x)('Change vertical alignment', 'Block vertical alignment setting label'),
  9499. controls: controls.map(control => {
  9500. return { ...BLOCK_ALIGNMENTS_CONTROLS[control],
  9501. isActive: value === control,
  9502. role: isCollapsed ? 'menuitemradio' : undefined,
  9503. onClick: applyOrUnset(control)
  9504. };
  9505. })
  9506. }, extraProps));
  9507. }
  9508. /**
  9509. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-toolbar/README.md
  9510. */
  9511. /* harmony default export */ var ui = (BlockVerticalAlignmentUI);
  9512. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/index.js
  9513. /**
  9514. * Internal dependencies
  9515. */
  9516. const BlockVerticalAlignmentControl = props => {
  9517. return (0,external_wp_element_namespaceObject.createElement)(ui, _extends({}, props, {
  9518. isToolbar: false
  9519. }));
  9520. };
  9521. const BlockVerticalAlignmentToolbar = props => {
  9522. return (0,external_wp_element_namespaceObject.createElement)(ui, _extends({}, props, {
  9523. isToolbar: true
  9524. }));
  9525. };
  9526. /**
  9527. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-control/README.md
  9528. */
  9529. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/justify-content-control/ui.js
  9530. /**
  9531. * WordPress dependencies
  9532. */
  9533. const icons = {
  9534. left: justify_left,
  9535. center: justify_center,
  9536. right: justify_right,
  9537. 'space-between': justify_space_between
  9538. };
  9539. function JustifyContentUI(_ref) {
  9540. let {
  9541. allowedControls = ['left', 'center', 'right', 'space-between'],
  9542. isCollapsed = true,
  9543. onChange,
  9544. value,
  9545. popoverProps,
  9546. isToolbar
  9547. } = _ref;
  9548. // If the control is already selected we want a click
  9549. // again on the control to deselect the item, so we
  9550. // call onChange( undefined )
  9551. const handleClick = next => {
  9552. if (next === value) {
  9553. onChange(undefined);
  9554. } else {
  9555. onChange(next);
  9556. }
  9557. };
  9558. const icon = value ? icons[value] : icons.left;
  9559. const allControls = [{
  9560. name: 'left',
  9561. icon: justify_left,
  9562. title: (0,external_wp_i18n_namespaceObject.__)('Justify items left'),
  9563. isActive: 'left' === value,
  9564. onClick: () => handleClick('left')
  9565. }, {
  9566. name: 'center',
  9567. icon: justify_center,
  9568. title: (0,external_wp_i18n_namespaceObject.__)('Justify items center'),
  9569. isActive: 'center' === value,
  9570. onClick: () => handleClick('center')
  9571. }, {
  9572. name: 'right',
  9573. icon: justify_right,
  9574. title: (0,external_wp_i18n_namespaceObject.__)('Justify items right'),
  9575. isActive: 'right' === value,
  9576. onClick: () => handleClick('right')
  9577. }, {
  9578. name: 'space-between',
  9579. icon: justify_space_between,
  9580. title: (0,external_wp_i18n_namespaceObject.__)('Space between items'),
  9581. isActive: 'space-between' === value,
  9582. onClick: () => handleClick('space-between')
  9583. }];
  9584. const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
  9585. const extraProps = isToolbar ? {
  9586. isCollapsed
  9587. } : {};
  9588. return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({
  9589. icon: icon,
  9590. popoverProps: popoverProps,
  9591. label: (0,external_wp_i18n_namespaceObject.__)('Change items justification'),
  9592. controls: allControls.filter(elem => allowedControls.includes(elem.name))
  9593. }, extraProps));
  9594. }
  9595. /* harmony default export */ var justify_content_control_ui = (JustifyContentUI);
  9596. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/justify-content-control/index.js
  9597. /**
  9598. * Internal dependencies
  9599. */
  9600. const JustifyContentControl = props => {
  9601. return (0,external_wp_element_namespaceObject.createElement)(justify_content_control_ui, _extends({}, props, {
  9602. isToolbar: false
  9603. }));
  9604. };
  9605. const JustifyToolbar = props => {
  9606. return (0,external_wp_element_namespaceObject.createElement)(justify_content_control_ui, _extends({}, props, {
  9607. isToolbar: true
  9608. }));
  9609. };
  9610. /**
  9611. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/justify-content-control/README.md
  9612. */
  9613. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/flex.js
  9614. /**
  9615. * WordPress dependencies
  9616. */
  9617. /**
  9618. * Internal dependencies
  9619. */
  9620. // Used with the default, horizontal flex orientation.
  9621. const justifyContentMap = {
  9622. left: 'flex-start',
  9623. right: 'flex-end',
  9624. center: 'center',
  9625. 'space-between': 'space-between'
  9626. }; // Used with the vertical (column) flex orientation.
  9627. const alignItemsMap = {
  9628. left: 'flex-start',
  9629. right: 'flex-end',
  9630. center: 'center'
  9631. };
  9632. const verticalAlignmentMap = {
  9633. top: 'flex-start',
  9634. center: 'center',
  9635. bottom: 'flex-end'
  9636. };
  9637. const flexWrapOptions = ['wrap', 'nowrap'];
  9638. /* harmony default export */ var flex = ({
  9639. name: 'flex',
  9640. label: (0,external_wp_i18n_namespaceObject.__)('Flex'),
  9641. inspectorControls: function FlexLayoutInspectorControls(_ref) {
  9642. let {
  9643. layout = {},
  9644. onChange,
  9645. layoutBlockSupport = {}
  9646. } = _ref;
  9647. const {
  9648. allowOrientation = true
  9649. } = layoutBlockSupport;
  9650. 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, {
  9651. layout: layout,
  9652. onChange: onChange
  9653. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, allowOrientation && (0,external_wp_element_namespaceObject.createElement)(OrientationControl, {
  9654. layout: layout,
  9655. onChange: onChange
  9656. }))), (0,external_wp_element_namespaceObject.createElement)(FlexWrapControl, {
  9657. layout: layout,
  9658. onChange: onChange
  9659. }));
  9660. },
  9661. toolBarControls: function FlexLayoutToolbarControls(_ref2) {
  9662. let {
  9663. layout = {},
  9664. onChange,
  9665. layoutBlockSupport
  9666. } = _ref2;
  9667. if (layoutBlockSupport !== null && layoutBlockSupport !== void 0 && layoutBlockSupport.allowSwitching) {
  9668. return null;
  9669. }
  9670. const {
  9671. allowVerticalAlignment = true
  9672. } = layoutBlockSupport;
  9673. return (0,external_wp_element_namespaceObject.createElement)(block_controls, {
  9674. group: "block",
  9675. __experimentalShareWithChildBlocks: true
  9676. }, (0,external_wp_element_namespaceObject.createElement)(FlexLayoutJustifyContentControl, {
  9677. layout: layout,
  9678. onChange: onChange,
  9679. isToolbar: true
  9680. }), allowVerticalAlignment && (layout === null || layout === void 0 ? void 0 : layout.orientation) !== 'vertical' && (0,external_wp_element_namespaceObject.createElement)(FlexLayoutVerticalAlignmentControl, {
  9681. layout: layout,
  9682. onChange: onChange,
  9683. isToolbar: true
  9684. }));
  9685. },
  9686. save: function FlexLayoutStyle(_ref3) {
  9687. var _style$spacing, _style$spacing2;
  9688. let {
  9689. selector,
  9690. layout,
  9691. style,
  9692. blockName
  9693. } = _ref3;
  9694. const {
  9695. orientation = 'horizontal'
  9696. } = layout;
  9697. const blockGapSupport = useSetting('spacing.blockGap');
  9698. const fallbackValue = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, ['spacing', 'blockGap', '__experimentalDefault']) || '0.5em';
  9699. const hasBlockGapStylesSupport = blockGapSupport !== null; // If a block's block.json skips serialization for spacing or spacing.blockGap,
  9700. // don't apply the user-defined value to the styles.
  9701. 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, fallbackValue) : `var( --wp--style--block-gap, ${fallbackValue} )`;
  9702. const justifyContent = justifyContentMap[layout.justifyContent] || justifyContentMap.left;
  9703. const flexWrap = flexWrapOptions.includes(layout.flexWrap) ? layout.flexWrap : 'wrap';
  9704. const verticalAlignment = verticalAlignmentMap[layout.verticalAlignment] || verticalAlignmentMap.center;
  9705. const rowOrientation = `
  9706. flex-direction: row;
  9707. align-items: ${verticalAlignment};
  9708. justify-content: ${justifyContent};
  9709. `;
  9710. const alignItems = alignItemsMap[layout.justifyContent] || alignItemsMap.left;
  9711. const columnOrientation = `
  9712. flex-direction: column;
  9713. align-items: ${alignItems};
  9714. `;
  9715. return (0,external_wp_element_namespaceObject.createElement)("style", null, `
  9716. ${appendSelectors(selector)} {
  9717. display: flex;
  9718. flex-wrap: ${flexWrap};
  9719. gap: ${hasBlockGapStylesSupport ? blockGapValue : fallbackValue};
  9720. ${orientation === 'horizontal' ? rowOrientation : columnOrientation}
  9721. }
  9722. ${appendSelectors(selector, '> *')} {
  9723. margin: 0;
  9724. }
  9725. `);
  9726. },
  9727. getOrientation(layout) {
  9728. const {
  9729. orientation = 'horizontal'
  9730. } = layout;
  9731. return orientation;
  9732. },
  9733. getAlignments() {
  9734. return [];
  9735. }
  9736. });
  9737. function FlexLayoutVerticalAlignmentControl(_ref4) {
  9738. let {
  9739. layout,
  9740. onChange,
  9741. isToolbar = false
  9742. } = _ref4;
  9743. const {
  9744. verticalAlignment = verticalAlignmentMap.center
  9745. } = layout;
  9746. const onVerticalAlignmentChange = value => {
  9747. onChange({ ...layout,
  9748. verticalAlignment: value
  9749. });
  9750. };
  9751. if (isToolbar) {
  9752. return (0,external_wp_element_namespaceObject.createElement)(BlockVerticalAlignmentControl, {
  9753. onChange: onVerticalAlignmentChange,
  9754. value: verticalAlignment
  9755. });
  9756. }
  9757. const verticalAlignmentOptions = [{
  9758. value: 'flex-start',
  9759. label: (0,external_wp_i18n_namespaceObject.__)('Align items top')
  9760. }, {
  9761. value: 'center',
  9762. label: (0,external_wp_i18n_namespaceObject.__)('Align items center')
  9763. }, {
  9764. value: 'flex-end',
  9765. label: (0,external_wp_i18n_namespaceObject.__)('Align items bottom')
  9766. }];
  9767. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  9768. className: "block-editor-hooks__flex-layout-vertical-alignment-control"
  9769. }, (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) => {
  9770. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  9771. key: value,
  9772. label: label,
  9773. icon: icon,
  9774. isPressed: verticalAlignment === value,
  9775. onClick: () => onVerticalAlignmentChange(value)
  9776. });
  9777. })));
  9778. }
  9779. function FlexLayoutJustifyContentControl(_ref5) {
  9780. let {
  9781. layout,
  9782. onChange,
  9783. isToolbar = false
  9784. } = _ref5;
  9785. const {
  9786. justifyContent = 'left',
  9787. orientation = 'horizontal'
  9788. } = layout;
  9789. const onJustificationChange = value => {
  9790. onChange({ ...layout,
  9791. justifyContent: value
  9792. });
  9793. };
  9794. const allowedControls = ['left', 'center', 'right'];
  9795. if (orientation === 'horizontal') {
  9796. allowedControls.push('space-between');
  9797. }
  9798. if (isToolbar) {
  9799. return (0,external_wp_element_namespaceObject.createElement)(JustifyContentControl, {
  9800. allowedControls: allowedControls,
  9801. value: justifyContent,
  9802. onChange: onJustificationChange,
  9803. popoverProps: {
  9804. position: 'bottom right',
  9805. isAlternate: true
  9806. }
  9807. });
  9808. }
  9809. const justificationOptions = [{
  9810. value: 'left',
  9811. icon: justify_left,
  9812. label: (0,external_wp_i18n_namespaceObject.__)('Justify items left')
  9813. }, {
  9814. value: 'center',
  9815. icon: justify_center,
  9816. label: (0,external_wp_i18n_namespaceObject.__)('Justify items center')
  9817. }, {
  9818. value: 'right',
  9819. icon: justify_right,
  9820. label: (0,external_wp_i18n_namespaceObject.__)('Justify items right')
  9821. }];
  9822. if (orientation === 'horizontal') {
  9823. justificationOptions.push({
  9824. value: 'space-between',
  9825. icon: justify_space_between,
  9826. label: (0,external_wp_i18n_namespaceObject.__)('Space between items')
  9827. });
  9828. }
  9829. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  9830. className: "block-editor-hooks__flex-layout-justification-controls"
  9831. }, (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 => {
  9832. let {
  9833. value,
  9834. icon,
  9835. label
  9836. } = _ref6;
  9837. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  9838. key: value,
  9839. label: label,
  9840. icon: icon,
  9841. isPressed: justifyContent === value,
  9842. onClick: () => onJustificationChange(value)
  9843. });
  9844. })));
  9845. }
  9846. function FlexWrapControl(_ref7) {
  9847. let {
  9848. layout,
  9849. onChange
  9850. } = _ref7;
  9851. const {
  9852. flexWrap = 'wrap'
  9853. } = layout;
  9854. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  9855. label: (0,external_wp_i18n_namespaceObject.__)('Allow to wrap to multiple lines'),
  9856. onChange: value => {
  9857. onChange({ ...layout,
  9858. flexWrap: value ? 'wrap' : 'nowrap'
  9859. });
  9860. },
  9861. checked: flexWrap === 'wrap'
  9862. });
  9863. }
  9864. function OrientationControl(_ref8) {
  9865. let {
  9866. layout,
  9867. onChange
  9868. } = _ref8;
  9869. const {
  9870. orientation = 'horizontal'
  9871. } = layout;
  9872. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  9873. className: "block-editor-hooks__flex-layout-orientation-controls"
  9874. }, (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, {
  9875. label: 'horizontal',
  9876. icon: arrow_right,
  9877. isPressed: orientation === 'horizontal',
  9878. onClick: () => onChange({ ...layout,
  9879. orientation: 'horizontal'
  9880. })
  9881. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  9882. label: 'vertical',
  9883. icon: arrow_down,
  9884. isPressed: orientation === 'vertical',
  9885. onClick: () => onChange({ ...layout,
  9886. orientation: 'vertical'
  9887. })
  9888. }));
  9889. }
  9890. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js
  9891. /**
  9892. * WordPress dependencies
  9893. */
  9894. /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
  9895. /**
  9896. * Return an SVG icon.
  9897. *
  9898. * @param {IconProps} props icon is the SVG component to render
  9899. * size is a number specifiying the icon size in pixels
  9900. * Other props will be passed to wrapped SVG component
  9901. *
  9902. * @return {JSX.Element} Icon component
  9903. */
  9904. function Icon(_ref) {
  9905. let {
  9906. icon,
  9907. size = 24,
  9908. ...props
  9909. } = _ref;
  9910. return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
  9911. width: size,
  9912. height: size,
  9913. ...props
  9914. });
  9915. }
  9916. /* harmony default export */ var build_module_icon = (Icon);
  9917. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/flow.js
  9918. /**
  9919. * WordPress dependencies
  9920. */
  9921. /**
  9922. * Internal dependencies
  9923. */
  9924. /* harmony default export */ var flow = ({
  9925. name: 'default',
  9926. label: (0,external_wp_i18n_namespaceObject.__)('Flow'),
  9927. inspectorControls: function DefaultLayoutInspectorControls(_ref) {
  9928. let {
  9929. layout,
  9930. onChange
  9931. } = _ref;
  9932. const {
  9933. wideSize,
  9934. contentSize
  9935. } = layout;
  9936. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  9937. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  9938. });
  9939. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  9940. className: "block-editor-hooks__layout-controls"
  9941. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  9942. className: "block-editor-hooks__layout-controls-unit"
  9943. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
  9944. label: (0,external_wp_i18n_namespaceObject.__)('Content'),
  9945. labelPosition: "top",
  9946. __unstableInputWidth: "80px",
  9947. value: contentSize || wideSize || '',
  9948. onChange: nextWidth => {
  9949. nextWidth = 0 > parseFloat(nextWidth) ? '0' : nextWidth;
  9950. onChange({ ...layout,
  9951. contentSize: nextWidth
  9952. });
  9953. },
  9954. units: units
  9955. }), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  9956. icon: position_center
  9957. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  9958. className: "block-editor-hooks__layout-controls-unit"
  9959. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
  9960. label: (0,external_wp_i18n_namespaceObject.__)('Wide'),
  9961. labelPosition: "top",
  9962. __unstableInputWidth: "80px",
  9963. value: wideSize || contentSize || '',
  9964. onChange: nextWidth => {
  9965. nextWidth = 0 > parseFloat(nextWidth) ? '0' : nextWidth;
  9966. onChange({ ...layout,
  9967. wideSize: nextWidth
  9968. });
  9969. },
  9970. units: units
  9971. }), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  9972. icon: stretch_wide
  9973. }))), (0,external_wp_element_namespaceObject.createElement)("div", {
  9974. className: "block-editor-hooks__layout-controls-reset"
  9975. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  9976. variant: "secondary",
  9977. isSmall: true,
  9978. disabled: !contentSize && !wideSize,
  9979. onClick: () => onChange({
  9980. contentSize: undefined,
  9981. wideSize: undefined,
  9982. inherit: false
  9983. })
  9984. }, (0,external_wp_i18n_namespaceObject.__)('Reset'))), (0,external_wp_element_namespaceObject.createElement)("p", {
  9985. className: "block-editor-hooks__layout-controls-helptext"
  9986. }, (0,external_wp_i18n_namespaceObject.__)('Customize the width for all elements that are assigned to the center or wide columns.')));
  9987. },
  9988. toolBarControls: function DefaultLayoutToolbarControls() {
  9989. return null;
  9990. },
  9991. save: function DefaultLayoutStyle(_ref2) {
  9992. var _style$spacing;
  9993. let {
  9994. selector,
  9995. layout = {},
  9996. style,
  9997. blockName
  9998. } = _ref2;
  9999. const {
  10000. contentSize,
  10001. wideSize
  10002. } = layout;
  10003. const blockGapSupport = useSetting('spacing.blockGap');
  10004. const hasBlockGapStylesSupport = blockGapSupport !== null;
  10005. const blockGapStyleValue = getGapBoxControlValueFromStyle(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
  10006. // spacing.blockGap, don't apply the user-defined value to the styles.
  10007. const blockGapValue = blockGapStyleValue !== null && blockGapStyleValue !== void 0 && blockGapStyleValue.top && !shouldSkipSerialization(blockName, 'spacing', 'blockGap') ? blockGapStyleValue === null || blockGapStyleValue === void 0 ? void 0 : blockGapStyleValue.top : 'var( --wp--style--block-gap )';
  10008. let output = !!contentSize || !!wideSize ? `
  10009. ${appendSelectors(selector, '> :where(:not(.alignleft):not(.alignright))')} {
  10010. max-width: ${contentSize !== null && contentSize !== void 0 ? contentSize : wideSize};
  10011. margin-left: auto !important;
  10012. margin-right: auto !important;
  10013. }
  10014. ${appendSelectors(selector, '> .alignwide')} {
  10015. max-width: ${wideSize !== null && wideSize !== void 0 ? wideSize : contentSize};
  10016. }
  10017. ${appendSelectors(selector, '> .alignfull')} {
  10018. max-width: none;
  10019. }
  10020. ` : '';
  10021. output += `
  10022. ${appendSelectors(selector, '> .alignleft')} {
  10023. float: left;
  10024. margin-inline-start: 0;
  10025. margin-inline-end: 2em;
  10026. }
  10027. ${appendSelectors(selector, '> .alignright')} {
  10028. float: right;
  10029. margin-inline-start: 2em;
  10030. margin-inline-end: 0;
  10031. }
  10032. ${appendSelectors(selector, '> .aligncenter')} {
  10033. margin-left: auto !important;
  10034. margin-right: auto !important;
  10035. }
  10036. `;
  10037. if (hasBlockGapStylesSupport) {
  10038. output += `
  10039. ${appendSelectors(selector, '> *')} {
  10040. margin-block-start: 0;
  10041. margin-block-end: 0;
  10042. }
  10043. ${appendSelectors(selector, '> * + *')} {
  10044. margin-block-start: ${blockGapValue};
  10045. }
  10046. `;
  10047. }
  10048. return (0,external_wp_element_namespaceObject.createElement)("style", null, output);
  10049. },
  10050. getOrientation() {
  10051. return 'vertical';
  10052. },
  10053. getAlignments(layout) {
  10054. const alignmentInfo = getAlignmentsInfo(layout);
  10055. if (layout.alignments !== undefined) {
  10056. if (!layout.alignments.includes('none')) {
  10057. layout.alignments.unshift('none');
  10058. }
  10059. return layout.alignments.map(alignment => ({
  10060. name: alignment,
  10061. info: alignmentInfo[alignment]
  10062. }));
  10063. }
  10064. const {
  10065. contentSize,
  10066. wideSize
  10067. } = layout;
  10068. const alignments = [{
  10069. name: 'left'
  10070. }, {
  10071. name: 'center'
  10072. }, {
  10073. name: 'right'
  10074. }];
  10075. if (contentSize) {
  10076. alignments.unshift({
  10077. name: 'full'
  10078. });
  10079. }
  10080. if (wideSize) {
  10081. alignments.unshift({
  10082. name: 'wide',
  10083. info: alignmentInfo.wide
  10084. });
  10085. }
  10086. alignments.unshift({
  10087. name: 'none',
  10088. info: alignmentInfo.none
  10089. });
  10090. return alignments;
  10091. }
  10092. });
  10093. /**
  10094. * Helper method to assign contextual info to clarify
  10095. * alignment settings.
  10096. *
  10097. * Besides checking if `contentSize` and `wideSize` have a
  10098. * value, we now show this information only if their values
  10099. * are not a `css var`. This needs to change when parsing
  10100. * css variables land.
  10101. *
  10102. * @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752
  10103. *
  10104. * @param {Object} layout The layout object.
  10105. * @return {Object} An object with contextual info per alignment.
  10106. */
  10107. function getAlignmentsInfo(layout) {
  10108. const {
  10109. contentSize,
  10110. wideSize
  10111. } = layout;
  10112. const alignmentInfo = {};
  10113. const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%)?$/i;
  10114. if (sizeRegex.test(contentSize)) {
  10115. // translators: %s: container size (i.e. 600px etc)
  10116. alignmentInfo.none = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Max %s wide'), contentSize);
  10117. }
  10118. if (sizeRegex.test(wideSize)) {
  10119. // translators: %s: container size (i.e. 600px etc)
  10120. alignmentInfo.wide = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Max %s wide'), wideSize);
  10121. }
  10122. return alignmentInfo;
  10123. }
  10124. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/index.js
  10125. /**
  10126. * Internal dependencies
  10127. */
  10128. const layoutTypes = [flow, flex];
  10129. /**
  10130. * Retrieves a layout type by name.
  10131. *
  10132. * @param {string} name - The name of the layout type.
  10133. * @return {Object} Layout type.
  10134. */
  10135. function getLayoutType() {
  10136. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
  10137. return layoutTypes.find(layoutType => layoutType.name === name);
  10138. }
  10139. /**
  10140. * Retrieves the available layout types.
  10141. *
  10142. * @return {Array} Layout types.
  10143. */
  10144. function getLayoutTypes() {
  10145. return layoutTypes;
  10146. }
  10147. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/layout.js
  10148. /**
  10149. * WordPress dependencies
  10150. */
  10151. /**
  10152. * Internal dependencies
  10153. */
  10154. const defaultLayout = {
  10155. type: 'default'
  10156. };
  10157. const Layout = (0,external_wp_element_namespaceObject.createContext)(defaultLayout);
  10158. /**
  10159. * Allows to define the layout.
  10160. */
  10161. const LayoutProvider = Layout.Provider;
  10162. /**
  10163. * React hook used to retrieve the layout config.
  10164. */
  10165. function useLayout() {
  10166. return (0,external_wp_element_namespaceObject.useContext)(Layout);
  10167. }
  10168. function LayoutStyle(_ref) {
  10169. let {
  10170. layout = {},
  10171. ...props
  10172. } = _ref;
  10173. const layoutType = getLayoutType(layout.type);
  10174. if (layoutType) {
  10175. return (0,external_wp_element_namespaceObject.createElement)(layoutType.save, _extends({
  10176. layout: layout
  10177. }, props));
  10178. }
  10179. return null;
  10180. }
  10181. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/use-available-alignments.js
  10182. /**
  10183. * WordPress dependencies
  10184. */
  10185. /**
  10186. * Internal dependencies
  10187. */
  10188. const use_available_alignments_DEFAULT_CONTROLS = ['none', 'left', 'center', 'right', 'wide', 'full'];
  10189. const WIDE_CONTROLS = ['wide', 'full'];
  10190. function useAvailableAlignments() {
  10191. let controls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : use_available_alignments_DEFAULT_CONTROLS;
  10192. // Always add the `none` option if not exists.
  10193. if (!controls.includes('none')) {
  10194. controls = ['none', ...controls];
  10195. }
  10196. const {
  10197. wideControlsEnabled = false,
  10198. themeSupportsLayout
  10199. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  10200. const {
  10201. getSettings
  10202. } = select(store);
  10203. const settings = getSettings();
  10204. return {
  10205. wideControlsEnabled: settings.alignWide,
  10206. themeSupportsLayout: settings.supportsLayout
  10207. };
  10208. }, []);
  10209. const layout = useLayout();
  10210. const layoutType = getLayoutType(layout === null || layout === void 0 ? void 0 : layout.type);
  10211. const layoutAlignments = layoutType.getAlignments(layout);
  10212. if (themeSupportsLayout) {
  10213. const alignments = layoutAlignments.filter(_ref => {
  10214. let {
  10215. name: alignmentName
  10216. } = _ref;
  10217. return controls.includes(alignmentName);
  10218. }); // While we treat `none` as an alignment, we shouldn't return it if no
  10219. // other alignments exist.
  10220. if (alignments.length === 1 && alignments[0].name === 'none') {
  10221. return [];
  10222. }
  10223. return alignments;
  10224. } // Starting here, it's the fallback for themes not supporting the layout config.
  10225. if (layoutType.name !== 'default') {
  10226. return [];
  10227. }
  10228. const {
  10229. alignments: availableAlignments = use_available_alignments_DEFAULT_CONTROLS
  10230. } = layout;
  10231. const enabledControls = controls.filter(control => (layout.alignments || // Ignore the global wideAlignment check if the layout explicitely defines alignments.
  10232. wideControlsEnabled || !WIDE_CONTROLS.includes(control)) && availableAlignments.includes(control)).map(enabledControl => ({
  10233. name: enabledControl
  10234. })); // While we treat `none` as an alignment, we shouldn't return it if no
  10235. // other alignments exist.
  10236. if (enabledControls.length === 1 && enabledControls[0].name === 'none') {
  10237. return [];
  10238. }
  10239. return enabledControls;
  10240. }
  10241. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/ui.js
  10242. /**
  10243. * External dependencies
  10244. */
  10245. /**
  10246. * WordPress dependencies
  10247. */
  10248. /**
  10249. * Internal dependencies
  10250. */
  10251. const ui_BLOCK_ALIGNMENTS_CONTROLS = {
  10252. none: {
  10253. icon: align_none,
  10254. title: (0,external_wp_i18n_namespaceObject._x)('None', 'Alignment option')
  10255. },
  10256. left: {
  10257. icon: position_left,
  10258. title: (0,external_wp_i18n_namespaceObject.__)('Align left')
  10259. },
  10260. center: {
  10261. icon: position_center,
  10262. title: (0,external_wp_i18n_namespaceObject.__)('Align center')
  10263. },
  10264. right: {
  10265. icon: position_right,
  10266. title: (0,external_wp_i18n_namespaceObject.__)('Align right')
  10267. },
  10268. wide: {
  10269. icon: stretch_wide,
  10270. title: (0,external_wp_i18n_namespaceObject.__)('Wide width')
  10271. },
  10272. full: {
  10273. icon: stretch_full_width,
  10274. title: (0,external_wp_i18n_namespaceObject.__)('Full width')
  10275. }
  10276. };
  10277. const ui_DEFAULT_CONTROL = 'none';
  10278. const ui_POPOVER_PROPS = {
  10279. isAlternate: true
  10280. };
  10281. function BlockAlignmentUI(_ref) {
  10282. let {
  10283. value,
  10284. onChange,
  10285. controls,
  10286. isToolbar,
  10287. isCollapsed = true
  10288. } = _ref;
  10289. const enabledControls = useAvailableAlignments(controls);
  10290. const hasEnabledControls = !!enabledControls.length;
  10291. if (!hasEnabledControls) {
  10292. return null;
  10293. }
  10294. function onChangeAlignment(align) {
  10295. onChange([value, 'none'].includes(align) ? undefined : align);
  10296. }
  10297. const activeAlignmentControl = ui_BLOCK_ALIGNMENTS_CONTROLS[value];
  10298. const defaultAlignmentControl = ui_BLOCK_ALIGNMENTS_CONTROLS[ui_DEFAULT_CONTROL];
  10299. const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
  10300. const commonProps = {
  10301. popoverProps: ui_POPOVER_PROPS,
  10302. icon: activeAlignmentControl ? activeAlignmentControl.icon : defaultAlignmentControl.icon,
  10303. label: (0,external_wp_i18n_namespaceObject.__)('Align'),
  10304. toggleProps: {
  10305. describedBy: (0,external_wp_i18n_namespaceObject.__)('Change alignment')
  10306. }
  10307. };
  10308. const extraProps = isToolbar || external_wp_element_namespaceObject.Platform.isNative ? {
  10309. isCollapsed: isToolbar ? isCollapsed : undefined,
  10310. controls: enabledControls.map(_ref2 => {
  10311. let {
  10312. name: controlName
  10313. } = _ref2;
  10314. return { ...ui_BLOCK_ALIGNMENTS_CONTROLS[controlName],
  10315. isActive: value === controlName || !value && controlName === 'none',
  10316. role: isCollapsed ? 'menuitemradio' : undefined,
  10317. onClick: () => onChangeAlignment(controlName)
  10318. };
  10319. })
  10320. } : {
  10321. children: _ref3 => {
  10322. let {
  10323. onClose
  10324. } = _ref3;
  10325. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  10326. className: "block-editor-block-alignment-control__menu-group"
  10327. }, enabledControls.map(_ref4 => {
  10328. let {
  10329. name: controlName,
  10330. info
  10331. } = _ref4;
  10332. const {
  10333. icon,
  10334. title
  10335. } = ui_BLOCK_ALIGNMENTS_CONTROLS[controlName]; // If no value is provided, mark as selected the `none` option.
  10336. const isSelected = controlName === value || !value && controlName === 'none';
  10337. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  10338. key: controlName,
  10339. icon: icon,
  10340. iconPosition: "left",
  10341. className: classnames_default()('components-dropdown-menu__menu-item', {
  10342. 'is-active': isSelected
  10343. }),
  10344. isSelected: isSelected,
  10345. onClick: () => {
  10346. onChangeAlignment(controlName);
  10347. onClose();
  10348. },
  10349. role: "menuitemradio",
  10350. info: info
  10351. }, title);
  10352. })));
  10353. }
  10354. };
  10355. return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({}, commonProps, extraProps));
  10356. }
  10357. /* harmony default export */ var block_alignment_control_ui = (BlockAlignmentUI);
  10358. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/index.js
  10359. /**
  10360. * Internal dependencies
  10361. */
  10362. const BlockAlignmentControl = props => {
  10363. return (0,external_wp_element_namespaceObject.createElement)(block_alignment_control_ui, _extends({}, props, {
  10364. isToolbar: false
  10365. }));
  10366. };
  10367. const BlockAlignmentToolbar = props => {
  10368. return (0,external_wp_element_namespaceObject.createElement)(block_alignment_control_ui, _extends({}, props, {
  10369. isToolbar: true
  10370. }));
  10371. };
  10372. /**
  10373. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-alignment-control/README.md
  10374. */
  10375. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/align.js
  10376. /**
  10377. * External dependencies
  10378. */
  10379. /**
  10380. * WordPress dependencies
  10381. */
  10382. /**
  10383. * Internal dependencies
  10384. */
  10385. /**
  10386. * An array which includes all possible valid alignments,
  10387. * used to validate if an alignment is valid or not.
  10388. *
  10389. * @constant
  10390. * @type {string[]}
  10391. */
  10392. const ALL_ALIGNMENTS = ['left', 'center', 'right', 'wide', 'full'];
  10393. /**
  10394. * An array which includes all wide alignments.
  10395. * In order for this alignments to be valid they need to be supported by the block,
  10396. * and by the theme.
  10397. *
  10398. * @constant
  10399. * @type {string[]}
  10400. */
  10401. const WIDE_ALIGNMENTS = ['wide', 'full'];
  10402. /**
  10403. * Returns the valid alignments.
  10404. * 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.
  10405. * Exported just for testing purposes, not exported outside the module.
  10406. *
  10407. * @param {?boolean|string[]} blockAlign Aligns supported by the block.
  10408. * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise.
  10409. * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise.
  10410. *
  10411. * @return {string[]} Valid alignments.
  10412. */
  10413. function getValidAlignments(blockAlign) {
  10414. let hasWideBlockSupport = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  10415. let hasWideEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  10416. let validAlignments;
  10417. if (Array.isArray(blockAlign)) {
  10418. validAlignments = ALL_ALIGNMENTS.filter(value => blockAlign.includes(value));
  10419. } else if (blockAlign === true) {
  10420. // `true` includes all alignments...
  10421. validAlignments = [...ALL_ALIGNMENTS];
  10422. } else {
  10423. validAlignments = [];
  10424. }
  10425. if (!hasWideEnabled || blockAlign === true && !hasWideBlockSupport) {
  10426. return (0,external_lodash_namespaceObject.without)(validAlignments, ...WIDE_ALIGNMENTS);
  10427. }
  10428. return validAlignments;
  10429. }
  10430. /**
  10431. * Filters registered block settings, extending attributes to include `align`.
  10432. *
  10433. * @param {Object} settings Original block settings.
  10434. *
  10435. * @return {Object} Filtered block settings.
  10436. */
  10437. function addAttribute(settings) {
  10438. // Allow blocks to specify their own attribute definition with default values if needed.
  10439. if ((0,external_lodash_namespaceObject.has)(settings.attributes, ['align', 'type'])) {
  10440. return settings;
  10441. }
  10442. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'align')) {
  10443. // Gracefully handle if settings.attributes is undefined.
  10444. settings.attributes = { ...settings.attributes,
  10445. align: {
  10446. type: 'string',
  10447. // Allow for '' since it is used by updateAlignment function
  10448. // in withToolbarControls for special cases with defined default values.
  10449. enum: [...ALL_ALIGNMENTS, '']
  10450. }
  10451. };
  10452. }
  10453. return settings;
  10454. }
  10455. /**
  10456. * Override the default edit UI to include new toolbar controls for block
  10457. * alignment, if block defines support.
  10458. *
  10459. * @param {Function} BlockEdit Original component.
  10460. *
  10461. * @return {Function} Wrapped component.
  10462. */
  10463. const withToolbarControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  10464. const {
  10465. name: blockName
  10466. } = props; // Compute the block valid alignments by taking into account,
  10467. // if the theme supports wide alignments or not and the layout's
  10468. // availble alignments. We do that for conditionally rendering
  10469. // Slot.
  10470. const blockAllowedAlignments = getValidAlignments((0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, 'align'), (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'alignWide', true));
  10471. const validAlignments = useAvailableAlignments(blockAllowedAlignments).map(_ref => {
  10472. let {
  10473. name
  10474. } = _ref;
  10475. return name;
  10476. });
  10477. const updateAlignment = nextAlign => {
  10478. if (!nextAlign) {
  10479. var _blockType$attributes, _blockType$attributes2;
  10480. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(props.name);
  10481. 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;
  10482. if (blockDefaultAlign) {
  10483. nextAlign = '';
  10484. }
  10485. }
  10486. props.setAttributes({
  10487. align: nextAlign
  10488. });
  10489. };
  10490. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !!validAlignments.length && (0,external_wp_element_namespaceObject.createElement)(block_controls, {
  10491. group: "block",
  10492. __experimentalShareWithChildBlocks: true
  10493. }, (0,external_wp_element_namespaceObject.createElement)(BlockAlignmentControl, {
  10494. value: props.attributes.align,
  10495. onChange: updateAlignment,
  10496. controls: validAlignments
  10497. })), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props));
  10498. }, 'withToolbarControls');
  10499. /**
  10500. * Override the default block element to add alignment wrapper props.
  10501. *
  10502. * @param {Function} BlockListBlock Original component.
  10503. *
  10504. * @return {Function} Wrapped component.
  10505. */
  10506. const withDataAlign = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  10507. const {
  10508. name,
  10509. attributes
  10510. } = props;
  10511. const {
  10512. align
  10513. } = attributes;
  10514. const blockAllowedAlignments = getValidAlignments((0,external_wp_blocks_namespaceObject.getBlockSupport)(name, 'align'), (0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, 'alignWide', true));
  10515. const validAlignments = useAvailableAlignments(blockAllowedAlignments); // If an alignment is not assigned, there's no need to go through the
  10516. // effort to validate or assign its value.
  10517. if (align === undefined) {
  10518. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
  10519. }
  10520. let wrapperProps = props.wrapperProps;
  10521. if (validAlignments.some(alignment => alignment.name === align)) {
  10522. wrapperProps = { ...wrapperProps,
  10523. 'data-align': align
  10524. };
  10525. }
  10526. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  10527. wrapperProps: wrapperProps
  10528. }));
  10529. });
  10530. /**
  10531. * Override props assigned to save component to inject alignment class name if
  10532. * block supports it.
  10533. *
  10534. * @param {Object} props Additional props applied to save element.
  10535. * @param {Object} blockType Block type.
  10536. * @param {Object} attributes Block attributes.
  10537. *
  10538. * @return {Object} Filtered props applied to save element.
  10539. */
  10540. function addAssignedAlign(props, blockType, attributes) {
  10541. const {
  10542. align
  10543. } = attributes;
  10544. const blockAlign = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, 'align');
  10545. const hasWideBlockSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'alignWide', true); // Compute valid alignments without taking into account if
  10546. // the theme supports wide alignments or not.
  10547. // This way changing themes does not impact the block save.
  10548. const isAlignValid = getValidAlignments(blockAlign, hasWideBlockSupport).includes(align);
  10549. if (isAlignValid) {
  10550. props.className = classnames_default()(`align${align}`, props.className);
  10551. }
  10552. return props;
  10553. }
  10554. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/align/addAttribute', addAttribute);
  10555. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/align/with-data-align', withDataAlign);
  10556. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/align/with-toolbar-controls', withToolbarControls);
  10557. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/align/addAssignedAlign', addAssignedAlign);
  10558. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/lock.js
  10559. /**
  10560. * External dependencies
  10561. */
  10562. /**
  10563. * WordPress dependencies
  10564. */
  10565. /**
  10566. * Filters registered block settings, extending attributes to include `lock`.
  10567. *
  10568. * @param {Object} settings Original block settings.
  10569. *
  10570. * @return {Object} Filtered block settings.
  10571. */
  10572. function lock_addAttribute(settings) {
  10573. // Allow blocks to specify their own attribute definition with default values if needed.
  10574. if ((0,external_lodash_namespaceObject.has)(settings.attributes, ['lock', 'type'])) {
  10575. return settings;
  10576. } // Gracefully handle if settings.attributes is undefined.
  10577. settings.attributes = { ...settings.attributes,
  10578. lock: {
  10579. type: 'object'
  10580. }
  10581. };
  10582. return settings;
  10583. }
  10584. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/lock/addAttribute', lock_addAttribute);
  10585. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/anchor.js
  10586. /**
  10587. * External dependencies
  10588. */
  10589. /**
  10590. * WordPress dependencies
  10591. */
  10592. /**
  10593. * Internal dependencies
  10594. */
  10595. /**
  10596. * Regular expression matching invalid anchor characters for replacement.
  10597. *
  10598. * @type {RegExp}
  10599. */
  10600. const ANCHOR_REGEX = /[\s#]/g;
  10601. const ANCHOR_SCHEMA = {
  10602. type: 'string',
  10603. source: 'attribute',
  10604. attribute: 'id',
  10605. selector: '*'
  10606. };
  10607. /**
  10608. * Filters registered block settings, extending attributes with anchor using ID
  10609. * of the first node.
  10610. *
  10611. * @param {Object} settings Original block settings.
  10612. *
  10613. * @return {Object} Filtered block settings.
  10614. */
  10615. function anchor_addAttribute(settings) {
  10616. // Allow blocks to specify their own attribute definition with default values if needed.
  10617. if ((0,external_lodash_namespaceObject.has)(settings.attributes, ['anchor', 'type'])) {
  10618. return settings;
  10619. }
  10620. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'anchor')) {
  10621. // Gracefully handle if settings.attributes is undefined.
  10622. settings.attributes = { ...settings.attributes,
  10623. anchor: ANCHOR_SCHEMA
  10624. };
  10625. }
  10626. return settings;
  10627. }
  10628. /**
  10629. * Override the default edit UI to include a new block inspector control for
  10630. * assigning the anchor ID, if block supports anchor.
  10631. *
  10632. * @param {WPComponent} BlockEdit Original component.
  10633. *
  10634. * @return {WPComponent} Wrapped component.
  10635. */
  10636. const withInspectorControl = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => {
  10637. return props => {
  10638. const hasAnchor = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'anchor');
  10639. if (hasAnchor && props.isSelected) {
  10640. const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web';
  10641. const textControl = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  10642. className: "html-anchor-control",
  10643. label: (0,external_wp_i18n_namespaceObject.__)('HTML anchor'),
  10644. 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, {
  10645. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/page-jumps/')
  10646. }, (0,external_wp_i18n_namespaceObject.__)('Learn more about anchors'))),
  10647. value: props.attributes.anchor || '',
  10648. placeholder: !isWeb ? (0,external_wp_i18n_namespaceObject.__)('Add an anchor') : null,
  10649. onChange: nextValue => {
  10650. nextValue = nextValue.replace(ANCHOR_REGEX, '-');
  10651. props.setAttributes({
  10652. anchor: nextValue
  10653. });
  10654. },
  10655. autoCapitalize: "none",
  10656. autoComplete: "off"
  10657. });
  10658. 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, {
  10659. __experimentalGroup: "advanced"
  10660. }, 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, {
  10661. title: (0,external_wp_i18n_namespaceObject.__)('Heading settings')
  10662. }, textControl)));
  10663. }
  10664. return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
  10665. };
  10666. }, 'withInspectorControl');
  10667. /**
  10668. * Override props assigned to save component to inject anchor ID, if block
  10669. * supports anchor. This is only applied if the block's save result is an
  10670. * element and not a markup string.
  10671. *
  10672. * @param {Object} extraProps Additional props applied to save element.
  10673. * @param {Object} blockType Block type.
  10674. * @param {Object} attributes Current block attributes.
  10675. *
  10676. * @return {Object} Filtered props applied to save element.
  10677. */
  10678. function addSaveProps(extraProps, blockType, attributes) {
  10679. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'anchor')) {
  10680. extraProps.id = attributes.anchor === '' ? null : attributes.anchor;
  10681. }
  10682. return extraProps;
  10683. }
  10684. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/anchor/attribute', anchor_addAttribute);
  10685. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/anchor/with-inspector-control', withInspectorControl);
  10686. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/anchor/save-props', addSaveProps);
  10687. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/custom-class-name.js
  10688. /**
  10689. * External dependencies
  10690. */
  10691. /**
  10692. * WordPress dependencies
  10693. */
  10694. /**
  10695. * Internal dependencies
  10696. */
  10697. /**
  10698. * Filters registered block settings, extending attributes with anchor using ID
  10699. * of the first node.
  10700. *
  10701. * @param {Object} settings Original block settings.
  10702. *
  10703. * @return {Object} Filtered block settings.
  10704. */
  10705. function custom_class_name_addAttribute(settings) {
  10706. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'customClassName', true)) {
  10707. // Gracefully handle if settings.attributes is undefined.
  10708. settings.attributes = { ...settings.attributes,
  10709. className: {
  10710. type: 'string'
  10711. }
  10712. };
  10713. }
  10714. return settings;
  10715. }
  10716. /**
  10717. * Override the default edit UI to include a new block inspector control for
  10718. * assigning the custom class name, if block supports custom class name.
  10719. *
  10720. * @param {WPComponent} BlockEdit Original component.
  10721. *
  10722. * @return {WPComponent} Wrapped component.
  10723. */
  10724. const custom_class_name_withInspectorControl = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => {
  10725. return props => {
  10726. const hasCustomClassName = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'customClassName', true);
  10727. if (hasCustomClassName && props.isSelected) {
  10728. 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, {
  10729. __experimentalGroup: "advanced"
  10730. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  10731. autoComplete: "off",
  10732. label: (0,external_wp_i18n_namespaceObject.__)('Additional CSS class(es)'),
  10733. value: props.attributes.className || '',
  10734. onChange: nextValue => {
  10735. props.setAttributes({
  10736. className: nextValue !== '' ? nextValue : undefined
  10737. });
  10738. },
  10739. help: (0,external_wp_i18n_namespaceObject.__)('Separate multiple classes with spaces.')
  10740. })));
  10741. }
  10742. return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
  10743. };
  10744. }, 'withInspectorControl');
  10745. /**
  10746. * Override props assigned to save component to inject anchor ID, if block
  10747. * supports anchor. This is only applied if the block's save result is an
  10748. * element and not a markup string.
  10749. *
  10750. * @param {Object} extraProps Additional props applied to save element.
  10751. * @param {Object} blockType Block type.
  10752. * @param {Object} attributes Current block attributes.
  10753. *
  10754. * @return {Object} Filtered props applied to save element.
  10755. */
  10756. function custom_class_name_addSaveProps(extraProps, blockType, attributes) {
  10757. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'customClassName', true) && attributes.className) {
  10758. extraProps.className = classnames_default()(extraProps.className, attributes.className);
  10759. }
  10760. return extraProps;
  10761. }
  10762. function addTransforms(result, source, index, results) {
  10763. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(result.name, 'customClassName', true)) {
  10764. return result;
  10765. } // If the condition verifies we are probably in the presence of a wrapping transform
  10766. // e.g: nesting paragraphs in a group or columns and in that case the class should not be kept.
  10767. if (results.length === 1 && result.innerBlocks.length === source.length) {
  10768. return result;
  10769. } // If we are transforming one block to multiple blocks or multiple blocks to one block,
  10770. // we ignore the class during the transform.
  10771. if (results.length === 1 && source.length > 1 || results.length > 1 && source.length === 1) {
  10772. return result;
  10773. } // If we are in presence of transform between one or more block in the source
  10774. // that have one or more blocks in the result
  10775. // we apply the class on source N to the result N,
  10776. // if source N does not exists we do nothing.
  10777. if (source[index]) {
  10778. var _source$index;
  10779. const originClassName = (_source$index = source[index]) === null || _source$index === void 0 ? void 0 : _source$index.attributes.className;
  10780. if (originClassName) {
  10781. return { ...result,
  10782. attributes: { ...result.attributes,
  10783. className: originClassName
  10784. }
  10785. };
  10786. }
  10787. }
  10788. return result;
  10789. }
  10790. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/custom-class-name/attribute', custom_class_name_addAttribute);
  10791. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/custom-class-name/with-inspector-control', custom_class_name_withInspectorControl);
  10792. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/custom-class-name/save-props', custom_class_name_addSaveProps);
  10793. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.switchToBlockType.transformedBlock', 'core/color/addTransforms', addTransforms);
  10794. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/generated-class-name.js
  10795. /**
  10796. * External dependencies
  10797. */
  10798. /**
  10799. * WordPress dependencies
  10800. */
  10801. /**
  10802. * Override props assigned to save component to inject generated className if
  10803. * block supports it. This is only applied if the block's save result is an
  10804. * element and not a markup string.
  10805. *
  10806. * @param {Object} extraProps Additional props applied to save element.
  10807. * @param {Object} blockType Block type.
  10808. *
  10809. * @return {Object} Filtered props applied to save element.
  10810. */
  10811. function addGeneratedClassName(extraProps, blockType) {
  10812. // Adding the generated className.
  10813. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'className', true)) {
  10814. if (typeof extraProps.className === 'string') {
  10815. // We have some extra classes and want to add the default classname
  10816. // We use uniq to prevent duplicate classnames.
  10817. extraProps.className = (0,external_lodash_namespaceObject.uniq)([(0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(blockType.name), ...extraProps.className.split(' ')]).join(' ').trim();
  10818. } else {
  10819. // There is no string in the className variable,
  10820. // so we just dump the default name in there.
  10821. extraProps.className = (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(blockType.name);
  10822. }
  10823. }
  10824. return extraProps;
  10825. }
  10826. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/generated-class-name/save-props', addGeneratedClassName);
  10827. ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/utils.js
  10828. /**
  10829. * External dependencies
  10830. */
  10831. /**
  10832. * Internal dependencies
  10833. */
  10834. function generateBoxRules(style, options, path, ruleKey) {
  10835. const boxStyle = (0,external_lodash_namespaceObject.get)(style, path);
  10836. if (!boxStyle) {
  10837. return [];
  10838. }
  10839. const rules = [];
  10840. if (typeof boxStyle === 'string') {
  10841. rules.push({
  10842. selector: options.selector,
  10843. key: ruleKey,
  10844. value: boxStyle
  10845. });
  10846. } else {
  10847. const sideRules = ['top', 'right', 'bottom', 'left'].reduce((acc, side) => {
  10848. const value = (0,external_lodash_namespaceObject.get)(boxStyle, [side]);
  10849. if (value) {
  10850. acc.push({
  10851. selector: options.selector,
  10852. key: `${ruleKey}${(0,external_lodash_namespaceObject.upperFirst)(side)}`,
  10853. value
  10854. });
  10855. }
  10856. return acc;
  10857. }, []);
  10858. rules.push(...sideRules);
  10859. }
  10860. return rules;
  10861. }
  10862. ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/padding.js
  10863. /**
  10864. * Internal dependencies
  10865. */
  10866. const padding = {
  10867. name: 'padding',
  10868. generate: (style, options) => {
  10869. return generateBoxRules(style, options, ['spacing', 'padding'], 'padding');
  10870. }
  10871. };
  10872. /* harmony default export */ var styles_padding = (padding);
  10873. ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/margin.js
  10874. /**
  10875. * Internal dependencies
  10876. */
  10877. const margin = {
  10878. name: 'margin',
  10879. generate: (style, options) => {
  10880. return generateBoxRules(style, options, ['spacing', 'margin'], 'margin');
  10881. }
  10882. };
  10883. /* harmony default export */ var styles_margin = (margin);
  10884. ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/index.js
  10885. /**
  10886. * Internal dependencies
  10887. */
  10888. const styleDefinitions = [styles_margin, styles_padding];
  10889. ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/index.js
  10890. /**
  10891. * External dependencies
  10892. */
  10893. /**
  10894. * Internal dependencies
  10895. */
  10896. /**
  10897. * Generates a stylesheet for a given style object and selector.
  10898. *
  10899. * @param style Style object.
  10900. * @param options Options object with settings to adjust how the styles are generated.
  10901. *
  10902. * @return generated stylesheet.
  10903. */
  10904. function generate(style, options) {
  10905. const rules = getCSSRules(style, options);
  10906. const groupedRules = groupBy(rules, 'selector');
  10907. const selectorRules = Object.keys(groupedRules).reduce((acc, subSelector) => {
  10908. acc.push(`${subSelector} { ${groupedRules[subSelector].map(rule => `${kebabCase(rule.key)}: ${rule.value};`).join(' ')} }`);
  10909. return acc;
  10910. }, []);
  10911. return selectorRules.join('\n');
  10912. }
  10913. /**
  10914. * Returns a JSON representation of the generated CSS rules.
  10915. *
  10916. * @param style Style object.
  10917. * @param options Options object with settings to adjust how the styles are generated.
  10918. *
  10919. * @return generated styles.
  10920. */
  10921. function getCSSRules(style, options) {
  10922. const rules = [];
  10923. styleDefinitions.forEach(definition => {
  10924. rules.push(...definition.generate(style, options));
  10925. });
  10926. return rules;
  10927. }
  10928. ;// CONCATENATED MODULE: external ["wp","dom"]
  10929. var external_wp_dom_namespaceObject = window["wp"]["dom"];
  10930. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-context/index.js
  10931. /**
  10932. * WordPress dependencies
  10933. */
  10934. /** @typedef {import('react').ReactNode} ReactNode */
  10935. /**
  10936. * @typedef BlockContextProviderProps
  10937. *
  10938. * @property {Record<string,*>} value Context value to merge with current
  10939. * value.
  10940. * @property {ReactNode} children Component children.
  10941. */
  10942. /** @type {import('react').Context<Record<string,*>>} */
  10943. const block_context_Context = (0,external_wp_element_namespaceObject.createContext)({});
  10944. /**
  10945. * Component which merges passed value with current consumed block context.
  10946. *
  10947. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md
  10948. *
  10949. * @param {BlockContextProviderProps} props
  10950. */
  10951. function BlockContextProvider(_ref) {
  10952. let {
  10953. value,
  10954. children
  10955. } = _ref;
  10956. const context = (0,external_wp_element_namespaceObject.useContext)(block_context_Context);
  10957. const nextValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...context,
  10958. ...value
  10959. }), [context, value]);
  10960. return (0,external_wp_element_namespaceObject.createElement)(block_context_Context.Provider, {
  10961. value: nextValue,
  10962. children: children
  10963. });
  10964. }
  10965. /* harmony default export */ var block_context = (block_context_Context);
  10966. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/edit.js
  10967. /**
  10968. * External dependencies
  10969. */
  10970. /**
  10971. * WordPress dependencies
  10972. */
  10973. /**
  10974. * Internal dependencies
  10975. */
  10976. /**
  10977. * Default value used for blocks which do not define their own context needs,
  10978. * used to guarantee that a block's `context` prop will always be an object. It
  10979. * is assigned as a constant since it is always expected to be an empty object,
  10980. * and in order to avoid unnecessary React reconciliations of a changing object.
  10981. *
  10982. * @type {{}}
  10983. */
  10984. const DEFAULT_BLOCK_CONTEXT = {};
  10985. const Edit = props => {
  10986. const {
  10987. attributes = {},
  10988. name
  10989. } = props;
  10990. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
  10991. const blockContext = (0,external_wp_element_namespaceObject.useContext)(block_context); // Assign context values using the block type's declared context needs.
  10992. const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
  10993. return blockType && blockType.usesContext ? (0,external_lodash_namespaceObject.pick)(blockContext, blockType.usesContext) : DEFAULT_BLOCK_CONTEXT;
  10994. }, [blockType, blockContext]);
  10995. if (!blockType) {
  10996. return null;
  10997. } // `edit` and `save` are functions or components describing the markup
  10998. // with which a block is displayed. If `blockType` is valid, assign
  10999. // them preferentially as the render value for the block.
  11000. const Component = blockType.edit || blockType.save;
  11001. if (blockType.apiVersion > 1) {
  11002. return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({}, props, {
  11003. context: context
  11004. }));
  11005. } // Generate a class name for the block's editable form.
  11006. const generatedClassName = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'className', true) ? (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name) : null;
  11007. const className = classnames_default()(generatedClassName, attributes.className);
  11008. return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({}, props, {
  11009. context: context,
  11010. className: className
  11011. }));
  11012. };
  11013. /* harmony default export */ var edit = ((0,external_wp_components_namespaceObject.withFilters)('editor.BlockEdit')(Edit));
  11014. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/index.js
  11015. /**
  11016. * WordPress dependencies
  11017. */
  11018. /**
  11019. * Internal dependencies
  11020. */
  11021. /**
  11022. * The `useBlockEditContext` hook provides information about the block this hook is being used in.
  11023. * It returns an object with the `name`, `isSelected` state, and the `clientId` of the block.
  11024. * It is useful if you want to create custom hooks that need access to the current blocks clientId
  11025. * but don't want to rely on the data getting passed in as a parameter.
  11026. *
  11027. * @return {Object} Block edit context
  11028. */
  11029. function BlockEdit(props) {
  11030. const {
  11031. name,
  11032. isSelected,
  11033. clientId
  11034. } = props;
  11035. const context = {
  11036. name,
  11037. isSelected,
  11038. clientId
  11039. };
  11040. return (0,external_wp_element_namespaceObject.createElement)(Provider // It is important to return the same object if props haven't
  11041. // changed to avoid unnecessary rerenders.
  11042. // See https://reactjs.org/docs/context.html#caveats.
  11043. , {
  11044. value: (0,external_wp_element_namespaceObject.useMemo)(() => context, Object.values(context))
  11045. }, (0,external_wp_element_namespaceObject.createElement)(edit, props));
  11046. }
  11047. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-horizontal.js
  11048. /**
  11049. * WordPress dependencies
  11050. */
  11051. const moreHorizontal = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  11052. xmlns: "http://www.w3.org/2000/svg",
  11053. viewBox: "0 0 24 24"
  11054. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  11055. d: "M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"
  11056. }));
  11057. /* harmony default export */ var more_horizontal = (moreHorizontal);
  11058. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/warning/index.js
  11059. /**
  11060. * External dependencies
  11061. */
  11062. /**
  11063. * WordPress dependencies
  11064. */
  11065. function Warning(_ref) {
  11066. let {
  11067. className,
  11068. actions,
  11069. children,
  11070. secondaryActions
  11071. } = _ref;
  11072. return (0,external_wp_element_namespaceObject.createElement)("div", {
  11073. style: {
  11074. display: 'contents',
  11075. all: 'initial'
  11076. }
  11077. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  11078. className: classnames_default()(className, 'block-editor-warning')
  11079. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  11080. className: "block-editor-warning__contents"
  11081. }, (0,external_wp_element_namespaceObject.createElement)("p", {
  11082. className: "block-editor-warning__message"
  11083. }, children), (external_wp_element_namespaceObject.Children.count(actions) > 0 || secondaryActions) && (0,external_wp_element_namespaceObject.createElement)("div", {
  11084. className: "block-editor-warning__actions"
  11085. }, external_wp_element_namespaceObject.Children.count(actions) > 0 && external_wp_element_namespaceObject.Children.map(actions, (action, i) => (0,external_wp_element_namespaceObject.createElement)("span", {
  11086. key: i,
  11087. className: "block-editor-warning__action"
  11088. }, action)), secondaryActions && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
  11089. className: "block-editor-warning__secondary",
  11090. icon: more_horizontal,
  11091. label: (0,external_wp_i18n_namespaceObject.__)('More options'),
  11092. popoverProps: {
  11093. position: 'bottom left',
  11094. className: 'block-editor-warning__dropdown'
  11095. },
  11096. noIcons: true
  11097. }, () => (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, {
  11098. onClick: item.onClick,
  11099. key: pos
  11100. }, item.title))))))));
  11101. }
  11102. /**
  11103. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
  11104. */
  11105. /* harmony default export */ var warning = (Warning);
  11106. // EXTERNAL MODULE: ./node_modules/diff/lib/diff/character.js
  11107. var character = __webpack_require__(1973);
  11108. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/block-view.js
  11109. /**
  11110. * WordPress dependencies
  11111. */
  11112. function BlockView(_ref) {
  11113. let {
  11114. title,
  11115. rawContent,
  11116. renderedContent,
  11117. action,
  11118. actionText,
  11119. className
  11120. } = _ref;
  11121. return (0,external_wp_element_namespaceObject.createElement)("div", {
  11122. className: className
  11123. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  11124. className: "block-editor-block-compare__content"
  11125. }, (0,external_wp_element_namespaceObject.createElement)("h2", {
  11126. className: "block-editor-block-compare__heading"
  11127. }, title), (0,external_wp_element_namespaceObject.createElement)("div", {
  11128. className: "block-editor-block-compare__html"
  11129. }, rawContent), (0,external_wp_element_namespaceObject.createElement)("div", {
  11130. className: "block-editor-block-compare__preview edit-post-visual-editor"
  11131. }, (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", {
  11132. className: "block-editor-block-compare__action"
  11133. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  11134. variant: "secondary",
  11135. tabIndex: "0",
  11136. onClick: action
  11137. }, actionText)));
  11138. }
  11139. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/index.js
  11140. /**
  11141. * External dependencies
  11142. */
  11143. // diff doesn't tree-shake correctly, so we import from the individual
  11144. // module here, to avoid including too much of the library
  11145. /**
  11146. * WordPress dependencies
  11147. */
  11148. /**
  11149. * Internal dependencies
  11150. */
  11151. function BlockCompare(_ref) {
  11152. let {
  11153. block,
  11154. onKeep,
  11155. onConvert,
  11156. convertor,
  11157. convertButtonText
  11158. } = _ref;
  11159. function getDifference(originalContent, newContent) {
  11160. const difference = (0,character/* diffChars */.Kx)(originalContent, newContent);
  11161. return difference.map((item, pos) => {
  11162. const classes = classnames_default()({
  11163. 'block-editor-block-compare__added': item.added,
  11164. 'block-editor-block-compare__removed': item.removed
  11165. });
  11166. return (0,external_wp_element_namespaceObject.createElement)("span", {
  11167. key: pos,
  11168. className: classes
  11169. }, item.value);
  11170. });
  11171. }
  11172. function getConvertedContent(convertedBlock) {
  11173. // The convertor may return an array of items or a single item.
  11174. const newBlocks = (0,external_lodash_namespaceObject.castArray)(convertedBlock); // Get converted block details.
  11175. const newContent = newBlocks.map(item => (0,external_wp_blocks_namespaceObject.getSaveContent)(item.name, item.attributes, item.innerBlocks));
  11176. return newContent.join('');
  11177. }
  11178. const converted = getConvertedContent(convertor(block));
  11179. const difference = getDifference(block.originalContent, converted);
  11180. return (0,external_wp_element_namespaceObject.createElement)("div", {
  11181. className: "block-editor-block-compare__wrapper"
  11182. }, (0,external_wp_element_namespaceObject.createElement)(BlockView, {
  11183. title: (0,external_wp_i18n_namespaceObject.__)('Current'),
  11184. className: "block-editor-block-compare__current",
  11185. action: onKeep,
  11186. actionText: (0,external_wp_i18n_namespaceObject.__)('Convert to HTML'),
  11187. rawContent: block.originalContent,
  11188. renderedContent: block.originalContent
  11189. }), (0,external_wp_element_namespaceObject.createElement)(BlockView, {
  11190. title: (0,external_wp_i18n_namespaceObject.__)('After Conversion'),
  11191. className: "block-editor-block-compare__converted",
  11192. action: onConvert,
  11193. actionText: convertButtonText,
  11194. rawContent: difference,
  11195. renderedContent: converted
  11196. }));
  11197. }
  11198. /* harmony default export */ var block_compare = (BlockCompare);
  11199. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-invalid-warning.js
  11200. /**
  11201. * WordPress dependencies
  11202. */
  11203. /**
  11204. * Internal dependencies
  11205. */
  11206. function BlockInvalidWarning(_ref) {
  11207. let {
  11208. convertToHTML,
  11209. convertToBlocks,
  11210. convertToClassic,
  11211. attemptBlockRecovery,
  11212. block
  11213. } = _ref;
  11214. const hasHTMLBlock = !!(0,external_wp_blocks_namespaceObject.getBlockType)('core/html');
  11215. const [compare, setCompare] = (0,external_wp_element_namespaceObject.useState)(false);
  11216. const onCompare = (0,external_wp_element_namespaceObject.useCallback)(() => setCompare(true), []);
  11217. const onCompareClose = (0,external_wp_element_namespaceObject.useCallback)(() => setCompare(false), []); // We memo the array here to prevent the children components from being updated unexpectedly.
  11218. const hiddenActions = (0,external_wp_element_namespaceObject.useMemo)(() => [{
  11219. // translators: Button to fix block content
  11220. title: (0,external_wp_i18n_namespaceObject._x)('Resolve', 'imperative verb'),
  11221. onClick: onCompare
  11222. }, hasHTMLBlock && {
  11223. title: (0,external_wp_i18n_namespaceObject.__)('Convert to HTML'),
  11224. onClick: convertToHTML
  11225. }, {
  11226. title: (0,external_wp_i18n_namespaceObject.__)('Convert to Classic Block'),
  11227. onClick: convertToClassic
  11228. }].filter(Boolean), [onCompare, convertToHTML, convertToClassic]);
  11229. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(warning, {
  11230. actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  11231. key: "recover",
  11232. onClick: attemptBlockRecovery,
  11233. variant: "primary"
  11234. }, (0,external_wp_i18n_namespaceObject.__)('Attempt Block Recovery'))],
  11235. secondaryActions: hiddenActions
  11236. }, (0,external_wp_i18n_namespaceObject.__)('This block contains unexpected or invalid content.')), compare && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
  11237. title: // translators: Dialog title to fix block content
  11238. (0,external_wp_i18n_namespaceObject.__)('Resolve Block'),
  11239. onRequestClose: onCompareClose,
  11240. className: "block-editor-block-compare"
  11241. }, (0,external_wp_element_namespaceObject.createElement)(block_compare, {
  11242. block: block,
  11243. onKeep: convertToHTML,
  11244. onConvert: convertToBlocks,
  11245. convertor: blockToBlocks,
  11246. convertButtonText: (0,external_wp_i18n_namespaceObject.__)('Convert to Blocks')
  11247. })));
  11248. }
  11249. const blockToClassic = block => (0,external_wp_blocks_namespaceObject.createBlock)('core/freeform', {
  11250. content: block.originalContent
  11251. });
  11252. const blockToHTML = block => (0,external_wp_blocks_namespaceObject.createBlock)('core/html', {
  11253. content: block.originalContent
  11254. });
  11255. const blockToBlocks = block => (0,external_wp_blocks_namespaceObject.rawHandler)({
  11256. HTML: block.originalContent
  11257. });
  11258. const recoverBlock = _ref2 => {
  11259. let {
  11260. name,
  11261. attributes,
  11262. innerBlocks
  11263. } = _ref2;
  11264. return (0,external_wp_blocks_namespaceObject.createBlock)(name, attributes, innerBlocks);
  11265. };
  11266. /* harmony default export */ var block_invalid_warning = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref3) => {
  11267. let {
  11268. clientId
  11269. } = _ref3;
  11270. return {
  11271. block: select(store).getBlock(clientId)
  11272. };
  11273. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref4) => {
  11274. let {
  11275. block
  11276. } = _ref4;
  11277. const {
  11278. replaceBlock
  11279. } = dispatch(store);
  11280. return {
  11281. convertToClassic() {
  11282. replaceBlock(block.clientId, blockToClassic(block));
  11283. },
  11284. convertToHTML() {
  11285. replaceBlock(block.clientId, blockToHTML(block));
  11286. },
  11287. convertToBlocks() {
  11288. replaceBlock(block.clientId, blockToBlocks(block));
  11289. },
  11290. attemptBlockRecovery() {
  11291. replaceBlock(block.clientId, recoverBlock(block));
  11292. }
  11293. };
  11294. })])(BlockInvalidWarning));
  11295. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-warning.js
  11296. /**
  11297. * WordPress dependencies
  11298. */
  11299. /**
  11300. * Internal dependencies
  11301. */
  11302. const block_crash_warning_warning = (0,external_wp_element_namespaceObject.createElement)(warning, {
  11303. className: "block-editor-block-list__block-crash-warning"
  11304. }, (0,external_wp_i18n_namespaceObject.__)('This block has encountered an error and cannot be previewed.'));
  11305. /* harmony default export */ var block_crash_warning = (() => block_crash_warning_warning);
  11306. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-boundary.js
  11307. /**
  11308. * WordPress dependencies
  11309. */
  11310. class BlockCrashBoundary extends external_wp_element_namespaceObject.Component {
  11311. constructor() {
  11312. super(...arguments);
  11313. this.state = {
  11314. hasError: false
  11315. };
  11316. }
  11317. componentDidCatch() {
  11318. this.setState({
  11319. hasError: true
  11320. });
  11321. }
  11322. render() {
  11323. if (this.state.hasError) {
  11324. return this.props.fallback;
  11325. }
  11326. return this.props.children;
  11327. }
  11328. }
  11329. /* harmony default export */ var block_crash_boundary = (BlockCrashBoundary);
  11330. // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
  11331. var lib = __webpack_require__(773);
  11332. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-html.js
  11333. /**
  11334. * External dependencies
  11335. */
  11336. /**
  11337. * WordPress dependencies
  11338. */
  11339. /**
  11340. * Internal dependencies
  11341. */
  11342. function BlockHTML(_ref) {
  11343. let {
  11344. clientId
  11345. } = _ref;
  11346. const [html, setHtml] = (0,external_wp_element_namespaceObject.useState)('');
  11347. const block = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlock(clientId), [clientId]);
  11348. const {
  11349. updateBlock
  11350. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  11351. const onChange = () => {
  11352. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
  11353. if (!blockType) {
  11354. return;
  11355. }
  11356. 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
  11357. const content = html ? html : (0,external_wp_blocks_namespaceObject.getSaveContent)(blockType, attributes);
  11358. const [isValid] = html ? (0,external_wp_blocks_namespaceObject.validateBlock)({ ...block,
  11359. attributes,
  11360. originalContent: content
  11361. }) : [true];
  11362. updateBlock(clientId, {
  11363. attributes,
  11364. originalContent: content,
  11365. isValid
  11366. }); // Ensure the state is updated if we reset so it displays the default content.
  11367. if (!html) {
  11368. setHtml({
  11369. content
  11370. });
  11371. }
  11372. };
  11373. (0,external_wp_element_namespaceObject.useEffect)(() => {
  11374. setHtml((0,external_wp_blocks_namespaceObject.getBlockContent)(block));
  11375. }, [block]);
  11376. return (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, {
  11377. className: "block-editor-block-list__block-html-textarea",
  11378. value: html,
  11379. onBlur: onChange,
  11380. onChange: event => setHtml(event.target.value)
  11381. });
  11382. }
  11383. /* harmony default export */ var block_html = (BlockHTML);
  11384. ;// CONCATENATED MODULE: ./node_modules/@react-spring/rafz/dist/react-spring-rafz.esm.js
  11385. let updateQueue = makeQueue();
  11386. const raf = fn => schedule(fn, updateQueue);
  11387. let writeQueue = makeQueue();
  11388. raf.write = fn => schedule(fn, writeQueue);
  11389. let onStartQueue = makeQueue();
  11390. raf.onStart = fn => schedule(fn, onStartQueue);
  11391. let onFrameQueue = makeQueue();
  11392. raf.onFrame = fn => schedule(fn, onFrameQueue);
  11393. let onFinishQueue = makeQueue();
  11394. raf.onFinish = fn => schedule(fn, onFinishQueue);
  11395. let timeouts = [];
  11396. raf.setTimeout = (handler, ms) => {
  11397. let time = raf.now() + ms;
  11398. let cancel = () => {
  11399. let i = timeouts.findIndex(t => t.cancel == cancel);
  11400. if (~i) timeouts.splice(i, 1);
  11401. pendingCount -= ~i ? 1 : 0;
  11402. };
  11403. let timeout = {
  11404. time,
  11405. handler,
  11406. cancel
  11407. };
  11408. timeouts.splice(findTimeout(time), 0, timeout);
  11409. pendingCount += 1;
  11410. start();
  11411. return timeout;
  11412. };
  11413. let findTimeout = time => ~(~timeouts.findIndex(t => t.time > time) || ~timeouts.length);
  11414. raf.cancel = fn => {
  11415. onStartQueue.delete(fn);
  11416. onFrameQueue.delete(fn);
  11417. onFinishQueue.delete(fn);
  11418. updateQueue.delete(fn);
  11419. writeQueue.delete(fn);
  11420. };
  11421. raf.sync = fn => {
  11422. sync = true;
  11423. raf.batchedUpdates(fn);
  11424. sync = false;
  11425. };
  11426. raf.throttle = fn => {
  11427. let lastArgs;
  11428. function queuedFn() {
  11429. try {
  11430. fn(...lastArgs);
  11431. } finally {
  11432. lastArgs = null;
  11433. }
  11434. }
  11435. function throttled(...args) {
  11436. lastArgs = args;
  11437. raf.onStart(queuedFn);
  11438. }
  11439. throttled.handler = fn;
  11440. throttled.cancel = () => {
  11441. onStartQueue.delete(queuedFn);
  11442. lastArgs = null;
  11443. };
  11444. return throttled;
  11445. };
  11446. let nativeRaf = typeof window != 'undefined' ? window.requestAnimationFrame : () => {};
  11447. raf.use = impl => nativeRaf = impl;
  11448. raf.now = typeof performance != 'undefined' ? () => performance.now() : Date.now;
  11449. raf.batchedUpdates = fn => fn();
  11450. raf.catch = console.error;
  11451. raf.frameLoop = 'always';
  11452. raf.advance = () => {
  11453. if (raf.frameLoop !== 'demand') {
  11454. console.warn('Cannot call the manual advancement of rafz whilst frameLoop is not set as demand');
  11455. } else {
  11456. update();
  11457. }
  11458. };
  11459. let ts = -1;
  11460. let pendingCount = 0;
  11461. let sync = false;
  11462. function schedule(fn, queue) {
  11463. if (sync) {
  11464. queue.delete(fn);
  11465. fn(0);
  11466. } else {
  11467. queue.add(fn);
  11468. start();
  11469. }
  11470. }
  11471. function start() {
  11472. if (ts < 0) {
  11473. ts = 0;
  11474. if (raf.frameLoop !== 'demand') {
  11475. nativeRaf(loop);
  11476. }
  11477. }
  11478. }
  11479. function stop() {
  11480. ts = -1;
  11481. }
  11482. function loop() {
  11483. if (~ts) {
  11484. nativeRaf(loop);
  11485. raf.batchedUpdates(update);
  11486. }
  11487. }
  11488. function update() {
  11489. let prevTs = ts;
  11490. ts = raf.now();
  11491. let count = findTimeout(ts);
  11492. if (count) {
  11493. eachSafely(timeouts.splice(0, count), t => t.handler());
  11494. pendingCount -= count;
  11495. }
  11496. if (!pendingCount) {
  11497. stop();
  11498. return;
  11499. }
  11500. onStartQueue.flush();
  11501. updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
  11502. onFrameQueue.flush();
  11503. writeQueue.flush();
  11504. onFinishQueue.flush();
  11505. }
  11506. function makeQueue() {
  11507. let next = new Set();
  11508. let current = next;
  11509. return {
  11510. add(fn) {
  11511. pendingCount += current == next && !next.has(fn) ? 1 : 0;
  11512. next.add(fn);
  11513. },
  11514. delete(fn) {
  11515. pendingCount -= current == next && next.has(fn) ? 1 : 0;
  11516. return next.delete(fn);
  11517. },
  11518. flush(arg) {
  11519. if (current.size) {
  11520. next = new Set();
  11521. pendingCount -= current.size;
  11522. eachSafely(current, fn => fn(arg) && next.add(fn));
  11523. pendingCount += next.size;
  11524. current = next;
  11525. }
  11526. }
  11527. };
  11528. }
  11529. function eachSafely(values, each) {
  11530. values.forEach(value => {
  11531. try {
  11532. each(value);
  11533. } catch (e) {
  11534. raf.catch(e);
  11535. }
  11536. });
  11537. }
  11538. const __raf = {
  11539. count() {
  11540. return pendingCount;
  11541. },
  11542. isRunning() {
  11543. return ts >= 0;
  11544. },
  11545. clear() {
  11546. ts = -1;
  11547. timeouts = [];
  11548. onStartQueue = makeQueue();
  11549. updateQueue = makeQueue();
  11550. onFrameQueue = makeQueue();
  11551. writeQueue = makeQueue();
  11552. onFinishQueue = makeQueue();
  11553. pendingCount = 0;
  11554. }
  11555. };
  11556. // EXTERNAL MODULE: external "React"
  11557. var external_React_ = __webpack_require__(9196);
  11558. var external_React_default = /*#__PURE__*/__webpack_require__.n(external_React_);
  11559. ;// CONCATENATED MODULE: ./node_modules/@react-spring/shared/dist/react-spring-shared.esm.js
  11560. function noop() {}
  11561. const defineHidden = (obj, key, value) => Object.defineProperty(obj, key, {
  11562. value,
  11563. writable: true,
  11564. configurable: true
  11565. });
  11566. const react_spring_shared_esm_is = {
  11567. arr: Array.isArray,
  11568. obj: a => !!a && a.constructor.name === 'Object',
  11569. fun: a => typeof a === 'function',
  11570. str: a => typeof a === 'string',
  11571. num: a => typeof a === 'number',
  11572. und: a => a === undefined
  11573. };
  11574. function isEqual(a, b) {
  11575. if (react_spring_shared_esm_is.arr(a)) {
  11576. if (!react_spring_shared_esm_is.arr(b) || a.length !== b.length) return false;
  11577. for (let i = 0; i < a.length; i++) {
  11578. if (a[i] !== b[i]) return false;
  11579. }
  11580. return true;
  11581. }
  11582. return a === b;
  11583. }
  11584. const react_spring_shared_esm_each = (obj, fn) => obj.forEach(fn);
  11585. function eachProp(obj, fn, ctx) {
  11586. if (react_spring_shared_esm_is.arr(obj)) {
  11587. for (let i = 0; i < obj.length; i++) {
  11588. fn.call(ctx, obj[i], `${i}`);
  11589. }
  11590. return;
  11591. }
  11592. for (const key in obj) {
  11593. if (obj.hasOwnProperty(key)) {
  11594. fn.call(ctx, obj[key], key);
  11595. }
  11596. }
  11597. }
  11598. const react_spring_shared_esm_toArray = a => react_spring_shared_esm_is.und(a) ? [] : react_spring_shared_esm_is.arr(a) ? a : [a];
  11599. function flush(queue, iterator) {
  11600. if (queue.size) {
  11601. const items = Array.from(queue);
  11602. queue.clear();
  11603. react_spring_shared_esm_each(items, iterator);
  11604. }
  11605. }
  11606. const flushCalls = (queue, ...args) => flush(queue, fn => fn(...args));
  11607. const isSSR = () => typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
  11608. let createStringInterpolator$1;
  11609. let to;
  11610. let colors$1 = null;
  11611. let skipAnimation = false;
  11612. let willAdvance = noop;
  11613. const react_spring_shared_esm_assign = globals => {
  11614. if (globals.to) to = globals.to;
  11615. if (globals.now) raf.now = globals.now;
  11616. if (globals.colors !== undefined) colors$1 = globals.colors;
  11617. if (globals.skipAnimation != null) skipAnimation = globals.skipAnimation;
  11618. if (globals.createStringInterpolator) createStringInterpolator$1 = globals.createStringInterpolator;
  11619. if (globals.requestAnimationFrame) raf.use(globals.requestAnimationFrame);
  11620. if (globals.batchedUpdates) raf.batchedUpdates = globals.batchedUpdates;
  11621. if (globals.willAdvance) willAdvance = globals.willAdvance;
  11622. if (globals.frameLoop) raf.frameLoop = globals.frameLoop;
  11623. };
  11624. var globals = /*#__PURE__*/Object.freeze({
  11625. __proto__: null,
  11626. get createStringInterpolator () { return createStringInterpolator$1; },
  11627. get to () { return to; },
  11628. get colors () { return colors$1; },
  11629. get skipAnimation () { return skipAnimation; },
  11630. get willAdvance () { return willAdvance; },
  11631. assign: react_spring_shared_esm_assign
  11632. });
  11633. const startQueue = new Set();
  11634. let currentFrame = [];
  11635. let prevFrame = [];
  11636. let priority = 0;
  11637. const frameLoop = {
  11638. get idle() {
  11639. return !startQueue.size && !currentFrame.length;
  11640. },
  11641. start(animation) {
  11642. if (priority > animation.priority) {
  11643. startQueue.add(animation);
  11644. raf.onStart(flushStartQueue);
  11645. } else {
  11646. startSafely(animation);
  11647. raf(advance);
  11648. }
  11649. },
  11650. advance,
  11651. sort(animation) {
  11652. if (priority) {
  11653. raf.onFrame(() => frameLoop.sort(animation));
  11654. } else {
  11655. const prevIndex = currentFrame.indexOf(animation);
  11656. if (~prevIndex) {
  11657. currentFrame.splice(prevIndex, 1);
  11658. startUnsafely(animation);
  11659. }
  11660. }
  11661. },
  11662. clear() {
  11663. currentFrame = [];
  11664. startQueue.clear();
  11665. }
  11666. };
  11667. function flushStartQueue() {
  11668. startQueue.forEach(startSafely);
  11669. startQueue.clear();
  11670. raf(advance);
  11671. }
  11672. function startSafely(animation) {
  11673. if (!currentFrame.includes(animation)) startUnsafely(animation);
  11674. }
  11675. function startUnsafely(animation) {
  11676. currentFrame.splice(findIndex(currentFrame, other => other.priority > animation.priority), 0, animation);
  11677. }
  11678. function advance(dt) {
  11679. const nextFrame = prevFrame;
  11680. for (let i = 0; i < currentFrame.length; i++) {
  11681. const animation = currentFrame[i];
  11682. priority = animation.priority;
  11683. if (!animation.idle) {
  11684. willAdvance(animation);
  11685. animation.advance(dt);
  11686. if (!animation.idle) {
  11687. nextFrame.push(animation);
  11688. }
  11689. }
  11690. }
  11691. priority = 0;
  11692. prevFrame = currentFrame;
  11693. prevFrame.length = 0;
  11694. currentFrame = nextFrame;
  11695. return currentFrame.length > 0;
  11696. }
  11697. function findIndex(arr, test) {
  11698. const index = arr.findIndex(test);
  11699. return index < 0 ? arr.length : index;
  11700. }
  11701. const colors = {
  11702. transparent: 0x00000000,
  11703. aliceblue: 0xf0f8ffff,
  11704. antiquewhite: 0xfaebd7ff,
  11705. aqua: 0x00ffffff,
  11706. aquamarine: 0x7fffd4ff,
  11707. azure: 0xf0ffffff,
  11708. beige: 0xf5f5dcff,
  11709. bisque: 0xffe4c4ff,
  11710. black: 0x000000ff,
  11711. blanchedalmond: 0xffebcdff,
  11712. blue: 0x0000ffff,
  11713. blueviolet: 0x8a2be2ff,
  11714. brown: 0xa52a2aff,
  11715. burlywood: 0xdeb887ff,
  11716. burntsienna: 0xea7e5dff,
  11717. cadetblue: 0x5f9ea0ff,
  11718. chartreuse: 0x7fff00ff,
  11719. chocolate: 0xd2691eff,
  11720. coral: 0xff7f50ff,
  11721. cornflowerblue: 0x6495edff,
  11722. cornsilk: 0xfff8dcff,
  11723. crimson: 0xdc143cff,
  11724. cyan: 0x00ffffff,
  11725. darkblue: 0x00008bff,
  11726. darkcyan: 0x008b8bff,
  11727. darkgoldenrod: 0xb8860bff,
  11728. darkgray: 0xa9a9a9ff,
  11729. darkgreen: 0x006400ff,
  11730. darkgrey: 0xa9a9a9ff,
  11731. darkkhaki: 0xbdb76bff,
  11732. darkmagenta: 0x8b008bff,
  11733. darkolivegreen: 0x556b2fff,
  11734. darkorange: 0xff8c00ff,
  11735. darkorchid: 0x9932ccff,
  11736. darkred: 0x8b0000ff,
  11737. darksalmon: 0xe9967aff,
  11738. darkseagreen: 0x8fbc8fff,
  11739. darkslateblue: 0x483d8bff,
  11740. darkslategray: 0x2f4f4fff,
  11741. darkslategrey: 0x2f4f4fff,
  11742. darkturquoise: 0x00ced1ff,
  11743. darkviolet: 0x9400d3ff,
  11744. deeppink: 0xff1493ff,
  11745. deepskyblue: 0x00bfffff,
  11746. dimgray: 0x696969ff,
  11747. dimgrey: 0x696969ff,
  11748. dodgerblue: 0x1e90ffff,
  11749. firebrick: 0xb22222ff,
  11750. floralwhite: 0xfffaf0ff,
  11751. forestgreen: 0x228b22ff,
  11752. fuchsia: 0xff00ffff,
  11753. gainsboro: 0xdcdcdcff,
  11754. ghostwhite: 0xf8f8ffff,
  11755. gold: 0xffd700ff,
  11756. goldenrod: 0xdaa520ff,
  11757. gray: 0x808080ff,
  11758. green: 0x008000ff,
  11759. greenyellow: 0xadff2fff,
  11760. grey: 0x808080ff,
  11761. honeydew: 0xf0fff0ff,
  11762. hotpink: 0xff69b4ff,
  11763. indianred: 0xcd5c5cff,
  11764. indigo: 0x4b0082ff,
  11765. ivory: 0xfffff0ff,
  11766. khaki: 0xf0e68cff,
  11767. lavender: 0xe6e6faff,
  11768. lavenderblush: 0xfff0f5ff,
  11769. lawngreen: 0x7cfc00ff,
  11770. lemonchiffon: 0xfffacdff,
  11771. lightblue: 0xadd8e6ff,
  11772. lightcoral: 0xf08080ff,
  11773. lightcyan: 0xe0ffffff,
  11774. lightgoldenrodyellow: 0xfafad2ff,
  11775. lightgray: 0xd3d3d3ff,
  11776. lightgreen: 0x90ee90ff,
  11777. lightgrey: 0xd3d3d3ff,
  11778. lightpink: 0xffb6c1ff,
  11779. lightsalmon: 0xffa07aff,
  11780. lightseagreen: 0x20b2aaff,
  11781. lightskyblue: 0x87cefaff,
  11782. lightslategray: 0x778899ff,
  11783. lightslategrey: 0x778899ff,
  11784. lightsteelblue: 0xb0c4deff,
  11785. lightyellow: 0xffffe0ff,
  11786. lime: 0x00ff00ff,
  11787. limegreen: 0x32cd32ff,
  11788. linen: 0xfaf0e6ff,
  11789. magenta: 0xff00ffff,
  11790. maroon: 0x800000ff,
  11791. mediumaquamarine: 0x66cdaaff,
  11792. mediumblue: 0x0000cdff,
  11793. mediumorchid: 0xba55d3ff,
  11794. mediumpurple: 0x9370dbff,
  11795. mediumseagreen: 0x3cb371ff,
  11796. mediumslateblue: 0x7b68eeff,
  11797. mediumspringgreen: 0x00fa9aff,
  11798. mediumturquoise: 0x48d1ccff,
  11799. mediumvioletred: 0xc71585ff,
  11800. midnightblue: 0x191970ff,
  11801. mintcream: 0xf5fffaff,
  11802. mistyrose: 0xffe4e1ff,
  11803. moccasin: 0xffe4b5ff,
  11804. navajowhite: 0xffdeadff,
  11805. navy: 0x000080ff,
  11806. oldlace: 0xfdf5e6ff,
  11807. olive: 0x808000ff,
  11808. olivedrab: 0x6b8e23ff,
  11809. orange: 0xffa500ff,
  11810. orangered: 0xff4500ff,
  11811. orchid: 0xda70d6ff,
  11812. palegoldenrod: 0xeee8aaff,
  11813. palegreen: 0x98fb98ff,
  11814. paleturquoise: 0xafeeeeff,
  11815. palevioletred: 0xdb7093ff,
  11816. papayawhip: 0xffefd5ff,
  11817. peachpuff: 0xffdab9ff,
  11818. peru: 0xcd853fff,
  11819. pink: 0xffc0cbff,
  11820. plum: 0xdda0ddff,
  11821. powderblue: 0xb0e0e6ff,
  11822. purple: 0x800080ff,
  11823. rebeccapurple: 0x663399ff,
  11824. red: 0xff0000ff,
  11825. rosybrown: 0xbc8f8fff,
  11826. royalblue: 0x4169e1ff,
  11827. saddlebrown: 0x8b4513ff,
  11828. salmon: 0xfa8072ff,
  11829. sandybrown: 0xf4a460ff,
  11830. seagreen: 0x2e8b57ff,
  11831. seashell: 0xfff5eeff,
  11832. sienna: 0xa0522dff,
  11833. silver: 0xc0c0c0ff,
  11834. skyblue: 0x87ceebff,
  11835. slateblue: 0x6a5acdff,
  11836. slategray: 0x708090ff,
  11837. slategrey: 0x708090ff,
  11838. snow: 0xfffafaff,
  11839. springgreen: 0x00ff7fff,
  11840. steelblue: 0x4682b4ff,
  11841. tan: 0xd2b48cff,
  11842. teal: 0x008080ff,
  11843. thistle: 0xd8bfd8ff,
  11844. tomato: 0xff6347ff,
  11845. turquoise: 0x40e0d0ff,
  11846. violet: 0xee82eeff,
  11847. wheat: 0xf5deb3ff,
  11848. white: 0xffffffff,
  11849. whitesmoke: 0xf5f5f5ff,
  11850. yellow: 0xffff00ff,
  11851. yellowgreen: 0x9acd32ff
  11852. };
  11853. const NUMBER = '[-+]?\\d*\\.?\\d+';
  11854. const PERCENTAGE = NUMBER + '%';
  11855. function call(...parts) {
  11856. return '\\(\\s*(' + parts.join(')\\s*,\\s*(') + ')\\s*\\)';
  11857. }
  11858. const rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER));
  11859. const rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER));
  11860. const hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
  11861. const hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
  11862. const hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
  11863. const hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
  11864. const hex6 = /^#([0-9a-fA-F]{6})$/;
  11865. const hex8 = /^#([0-9a-fA-F]{8})$/;
  11866. function normalizeColor(color) {
  11867. let match;
  11868. if (typeof color === 'number') {
  11869. return color >>> 0 === color && color >= 0 && color <= 0xffffffff ? color : null;
  11870. }
  11871. if (match = hex6.exec(color)) return parseInt(match[1] + 'ff', 16) >>> 0;
  11872. if (colors$1 && colors$1[color] !== undefined) {
  11873. return colors$1[color];
  11874. }
  11875. if (match = rgb.exec(color)) {
  11876. return (parse255(match[1]) << 24 | parse255(match[2]) << 16 | parse255(match[3]) << 8 | 0x000000ff) >>> 0;
  11877. }
  11878. if (match = rgba.exec(color)) {
  11879. return (parse255(match[1]) << 24 | parse255(match[2]) << 16 | parse255(match[3]) << 8 | parse1(match[4])) >>> 0;
  11880. }
  11881. if (match = hex3.exec(color)) {
  11882. return parseInt(match[1] + match[1] + match[2] + match[2] + match[3] + match[3] + 'ff', 16) >>> 0;
  11883. }
  11884. if (match = hex8.exec(color)) return parseInt(match[1], 16) >>> 0;
  11885. if (match = hex4.exec(color)) {
  11886. return parseInt(match[1] + match[1] + match[2] + match[2] + match[3] + match[3] + match[4] + match[4], 16) >>> 0;
  11887. }
  11888. if (match = hsl.exec(color)) {
  11889. return (hslToRgb(parse360(match[1]), parsePercentage(match[2]), parsePercentage(match[3])) | 0x000000ff) >>> 0;
  11890. }
  11891. if (match = hsla.exec(color)) {
  11892. return (hslToRgb(parse360(match[1]), parsePercentage(match[2]), parsePercentage(match[3])) | parse1(match[4])) >>> 0;
  11893. }
  11894. return null;
  11895. }
  11896. function hue2rgb(p, q, t) {
  11897. if (t < 0) t += 1;
  11898. if (t > 1) t -= 1;
  11899. if (t < 1 / 6) return p + (q - p) * 6 * t;
  11900. if (t < 1 / 2) return q;
  11901. if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
  11902. return p;
  11903. }
  11904. function hslToRgb(h, s, l) {
  11905. const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  11906. const p = 2 * l - q;
  11907. const r = hue2rgb(p, q, h + 1 / 3);
  11908. const g = hue2rgb(p, q, h);
  11909. const b = hue2rgb(p, q, h - 1 / 3);
  11910. return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
  11911. }
  11912. function parse255(str) {
  11913. const int = parseInt(str, 10);
  11914. if (int < 0) return 0;
  11915. if (int > 255) return 255;
  11916. return int;
  11917. }
  11918. function parse360(str) {
  11919. const int = parseFloat(str);
  11920. return (int % 360 + 360) % 360 / 360;
  11921. }
  11922. function parse1(str) {
  11923. const num = parseFloat(str);
  11924. if (num < 0) return 0;
  11925. if (num > 1) return 255;
  11926. return Math.round(num * 255);
  11927. }
  11928. function parsePercentage(str) {
  11929. const int = parseFloat(str);
  11930. if (int < 0) return 0;
  11931. if (int > 100) return 1;
  11932. return int / 100;
  11933. }
  11934. function colorToRgba(input) {
  11935. let int32Color = normalizeColor(input);
  11936. if (int32Color === null) return input;
  11937. int32Color = int32Color || 0;
  11938. let r = (int32Color & 0xff000000) >>> 24;
  11939. let g = (int32Color & 0x00ff0000) >>> 16;
  11940. let b = (int32Color & 0x0000ff00) >>> 8;
  11941. let a = (int32Color & 0x000000ff) / 255;
  11942. return `rgba(${r}, ${g}, ${b}, ${a})`;
  11943. }
  11944. const createInterpolator = (range, output, extrapolate) => {
  11945. if (react_spring_shared_esm_is.fun(range)) {
  11946. return range;
  11947. }
  11948. if (react_spring_shared_esm_is.arr(range)) {
  11949. return createInterpolator({
  11950. range,
  11951. output: output,
  11952. extrapolate
  11953. });
  11954. }
  11955. if (react_spring_shared_esm_is.str(range.output[0])) {
  11956. return createStringInterpolator$1(range);
  11957. }
  11958. const config = range;
  11959. const outputRange = config.output;
  11960. const inputRange = config.range || [0, 1];
  11961. const extrapolateLeft = config.extrapolateLeft || config.extrapolate || 'extend';
  11962. const extrapolateRight = config.extrapolateRight || config.extrapolate || 'extend';
  11963. const easing = config.easing || (t => t);
  11964. return input => {
  11965. const range = findRange(input, inputRange);
  11966. return interpolate(input, inputRange[range], inputRange[range + 1], outputRange[range], outputRange[range + 1], easing, extrapolateLeft, extrapolateRight, config.map);
  11967. };
  11968. };
  11969. function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
  11970. let result = map ? map(input) : input;
  11971. if (result < inputMin) {
  11972. if (extrapolateLeft === 'identity') return result;else if (extrapolateLeft === 'clamp') result = inputMin;
  11973. }
  11974. if (result > inputMax) {
  11975. if (extrapolateRight === 'identity') return result;else if (extrapolateRight === 'clamp') result = inputMax;
  11976. }
  11977. if (outputMin === outputMax) return outputMin;
  11978. if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax;
  11979. if (inputMin === -Infinity) result = -result;else if (inputMax === Infinity) result = result - inputMin;else result = (result - inputMin) / (inputMax - inputMin);
  11980. result = easing(result);
  11981. if (outputMin === -Infinity) result = -result;else if (outputMax === Infinity) result = result + outputMin;else result = result * (outputMax - outputMin) + outputMin;
  11982. return result;
  11983. }
  11984. function findRange(input, inputRange) {
  11985. for (var i = 1; i < inputRange.length - 1; ++i) if (inputRange[i] >= input) break;
  11986. return i - 1;
  11987. }
  11988. function react_spring_shared_esm_extends() {
  11989. react_spring_shared_esm_extends = Object.assign || function (target) {
  11990. for (var i = 1; i < arguments.length; i++) {
  11991. var source = arguments[i];
  11992. for (var key in source) {
  11993. if (Object.prototype.hasOwnProperty.call(source, key)) {
  11994. target[key] = source[key];
  11995. }
  11996. }
  11997. }
  11998. return target;
  11999. };
  12000. return react_spring_shared_esm_extends.apply(this, arguments);
  12001. }
  12002. const $get = Symbol.for('FluidValue.get');
  12003. const $observers = Symbol.for('FluidValue.observers');
  12004. const hasFluidValue = arg => Boolean(arg && arg[$get]);
  12005. const getFluidValue = arg => arg && arg[$get] ? arg[$get]() : arg;
  12006. const getFluidObservers = target => target[$observers] || null;
  12007. function callFluidObserver(observer, event) {
  12008. if (observer.eventObserved) {
  12009. observer.eventObserved(event);
  12010. } else {
  12011. observer(event);
  12012. }
  12013. }
  12014. function callFluidObservers(target, event) {
  12015. let observers = target[$observers];
  12016. if (observers) {
  12017. observers.forEach(observer => {
  12018. callFluidObserver(observer, event);
  12019. });
  12020. }
  12021. }
  12022. class FluidValue {
  12023. constructor(get) {
  12024. this[$get] = void 0;
  12025. this[$observers] = void 0;
  12026. if (!get && !(get = this.get)) {
  12027. throw Error('Unknown getter');
  12028. }
  12029. setFluidGetter(this, get);
  12030. }
  12031. }
  12032. const setFluidGetter = (target, get) => setHidden(target, $get, get);
  12033. function addFluidObserver(target, observer) {
  12034. if (target[$get]) {
  12035. let observers = target[$observers];
  12036. if (!observers) {
  12037. setHidden(target, $observers, observers = new Set());
  12038. }
  12039. if (!observers.has(observer)) {
  12040. observers.add(observer);
  12041. if (target.observerAdded) {
  12042. target.observerAdded(observers.size, observer);
  12043. }
  12044. }
  12045. }
  12046. return observer;
  12047. }
  12048. function removeFluidObserver(target, observer) {
  12049. let observers = target[$observers];
  12050. if (observers && observers.has(observer)) {
  12051. const count = observers.size - 1;
  12052. if (count) {
  12053. observers.delete(observer);
  12054. } else {
  12055. target[$observers] = null;
  12056. }
  12057. if (target.observerRemoved) {
  12058. target.observerRemoved(count, observer);
  12059. }
  12060. }
  12061. }
  12062. const setHidden = (target, key, value) => Object.defineProperty(target, key, {
  12063. value,
  12064. writable: true,
  12065. configurable: true
  12066. });
  12067. const numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
  12068. const colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
  12069. const unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, 'i');
  12070. const rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
  12071. const cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
  12072. const variableToRgba = input => {
  12073. const [token, fallback] = parseCSSVariable(input);
  12074. if (!token || isSSR()) {
  12075. return input;
  12076. }
  12077. const value = window.getComputedStyle(document.documentElement).getPropertyValue(token);
  12078. if (value) {
  12079. return value.trim();
  12080. } else if (fallback && fallback.startsWith('--')) {
  12081. const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback);
  12082. if (_value) {
  12083. return _value;
  12084. } else {
  12085. return input;
  12086. }
  12087. } else if (fallback && cssVariableRegex.test(fallback)) {
  12088. return variableToRgba(fallback);
  12089. } else if (fallback) {
  12090. return fallback;
  12091. }
  12092. return input;
  12093. };
  12094. const parseCSSVariable = current => {
  12095. const match = cssVariableRegex.exec(current);
  12096. if (!match) return [,];
  12097. const [, token, fallback] = match;
  12098. return [token, fallback];
  12099. };
  12100. let namedColorRegex;
  12101. const rgbaRound = (_, p1, p2, p3, p4) => `rgba(${Math.round(p1)}, ${Math.round(p2)}, ${Math.round(p3)}, ${p4})`;
  12102. const createStringInterpolator = config => {
  12103. if (!namedColorRegex) namedColorRegex = colors$1 ? new RegExp(`(${Object.keys(colors$1).join('|')})(?!\\w)`, 'g') : /^\b$/;
  12104. const output = config.output.map(value => {
  12105. return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba);
  12106. });
  12107. const keyframes = output.map(value => value.match(numberRegex).map(Number));
  12108. const outputRanges = keyframes[0].map((_, i) => keyframes.map(values => {
  12109. if (!(i in values)) {
  12110. throw Error('The arity of each "output" value must be equal');
  12111. }
  12112. return values[i];
  12113. }));
  12114. const interpolators = outputRanges.map(output => createInterpolator(react_spring_shared_esm_extends({}, config, {
  12115. output
  12116. })));
  12117. return input => {
  12118. var _output$find;
  12119. const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find(value => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, ''));
  12120. let i = 0;
  12121. return output[0].replace(numberRegex, () => `${interpolators[i++](input)}${missingUnit || ''}`).replace(rgbaRegex, rgbaRound);
  12122. };
  12123. };
  12124. const prefix = 'react-spring: ';
  12125. const once = fn => {
  12126. const func = fn;
  12127. let called = false;
  12128. if (typeof func != 'function') {
  12129. throw new TypeError(`${prefix}once requires a function parameter`);
  12130. }
  12131. return (...args) => {
  12132. if (!called) {
  12133. func(...args);
  12134. called = true;
  12135. }
  12136. };
  12137. };
  12138. const warnInterpolate = once(console.warn);
  12139. function react_spring_shared_esm_deprecateInterpolate() {
  12140. warnInterpolate(`${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`);
  12141. }
  12142. const warnDirectCall = once(console.warn);
  12143. function deprecateDirectCall() {
  12144. 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`);
  12145. }
  12146. function isAnimatedString(value) {
  12147. return react_spring_shared_esm_is.str(value) && (value[0] == '#' || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {}));
  12148. }
  12149. const react_spring_shared_esm_useIsomorphicLayoutEffect = isSSR() ? external_React_.useEffect : external_React_.useLayoutEffect;
  12150. const useIsMounted = () => {
  12151. const isMounted = (0,external_React_.useRef)(false);
  12152. react_spring_shared_esm_useIsomorphicLayoutEffect(() => {
  12153. isMounted.current = true;
  12154. return () => {
  12155. isMounted.current = false;
  12156. };
  12157. }, []);
  12158. return isMounted;
  12159. };
  12160. function react_spring_shared_esm_useForceUpdate() {
  12161. const update = (0,external_React_.useState)()[1];
  12162. const isMounted = useIsMounted();
  12163. return () => {
  12164. if (isMounted.current) {
  12165. update(Math.random());
  12166. }
  12167. };
  12168. }
  12169. function useMemoOne(getResult, inputs) {
  12170. const [initial] = (0,external_React_.useState)(() => ({
  12171. inputs,
  12172. result: getResult()
  12173. }));
  12174. const committed = (0,external_React_.useRef)();
  12175. const prevCache = committed.current;
  12176. let cache = prevCache;
  12177. if (cache) {
  12178. const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs));
  12179. if (!useCache) {
  12180. cache = {
  12181. inputs,
  12182. result: getResult()
  12183. };
  12184. }
  12185. } else {
  12186. cache = initial;
  12187. }
  12188. (0,external_React_.useEffect)(() => {
  12189. committed.current = cache;
  12190. if (prevCache == initial) {
  12191. initial.inputs = initial.result = undefined;
  12192. }
  12193. }, [cache]);
  12194. return cache.result;
  12195. }
  12196. function areInputsEqual(next, prev) {
  12197. if (next.length !== prev.length) {
  12198. return false;
  12199. }
  12200. for (let i = 0; i < next.length; i++) {
  12201. if (next[i] !== prev[i]) {
  12202. return false;
  12203. }
  12204. }
  12205. return true;
  12206. }
  12207. const react_spring_shared_esm_useOnce = effect => (0,external_React_.useEffect)(effect, emptyDeps);
  12208. const emptyDeps = [];
  12209. function react_spring_shared_esm_usePrev(value) {
  12210. const prevRef = (0,external_React_.useRef)();
  12211. (0,external_React_.useEffect)(() => {
  12212. prevRef.current = value;
  12213. });
  12214. return prevRef.current;
  12215. }
  12216. const useReducedMotion = () => {
  12217. const [reducedMotion, setReducedMotion] = useState(null);
  12218. react_spring_shared_esm_useIsomorphicLayoutEffect(() => {
  12219. const mql = window.matchMedia('(prefers-reduced-motion)');
  12220. const handleMediaChange = e => {
  12221. setReducedMotion(e.matches);
  12222. react_spring_shared_esm_assign({
  12223. skipAnimation: e.matches
  12224. });
  12225. };
  12226. handleMediaChange(mql);
  12227. mql.addEventListener('change', handleMediaChange);
  12228. return () => {
  12229. mql.removeEventListener('change', handleMediaChange);
  12230. };
  12231. }, []);
  12232. return reducedMotion;
  12233. };
  12234. ;// CONCATENATED MODULE: ./node_modules/@react-spring/animated/dist/react-spring-animated.esm.js
  12235. const $node = Symbol.for('Animated:node');
  12236. const isAnimated = value => !!value && value[$node] === value;
  12237. const getAnimated = owner => owner && owner[$node];
  12238. const setAnimated = (owner, node) => defineHidden(owner, $node, node);
  12239. const getPayload = owner => owner && owner[$node] && owner[$node].getPayload();
  12240. class Animated {
  12241. constructor() {
  12242. this.payload = void 0;
  12243. setAnimated(this, this);
  12244. }
  12245. getPayload() {
  12246. return this.payload || [];
  12247. }
  12248. }
  12249. class AnimatedValue extends Animated {
  12250. constructor(_value) {
  12251. super();
  12252. this.done = true;
  12253. this.elapsedTime = void 0;
  12254. this.lastPosition = void 0;
  12255. this.lastVelocity = void 0;
  12256. this.v0 = void 0;
  12257. this.durationProgress = 0;
  12258. this._value = _value;
  12259. if (react_spring_shared_esm_is.num(this._value)) {
  12260. this.lastPosition = this._value;
  12261. }
  12262. }
  12263. static create(value) {
  12264. return new AnimatedValue(value);
  12265. }
  12266. getPayload() {
  12267. return [this];
  12268. }
  12269. getValue() {
  12270. return this._value;
  12271. }
  12272. setValue(value, step) {
  12273. if (react_spring_shared_esm_is.num(value)) {
  12274. this.lastPosition = value;
  12275. if (step) {
  12276. value = Math.round(value / step) * step;
  12277. if (this.done) {
  12278. this.lastPosition = value;
  12279. }
  12280. }
  12281. }
  12282. if (this._value === value) {
  12283. return false;
  12284. }
  12285. this._value = value;
  12286. return true;
  12287. }
  12288. reset() {
  12289. const {
  12290. done
  12291. } = this;
  12292. this.done = false;
  12293. if (react_spring_shared_esm_is.num(this._value)) {
  12294. this.elapsedTime = 0;
  12295. this.durationProgress = 0;
  12296. this.lastPosition = this._value;
  12297. if (done) this.lastVelocity = null;
  12298. this.v0 = null;
  12299. }
  12300. }
  12301. }
  12302. class AnimatedString extends AnimatedValue {
  12303. constructor(value) {
  12304. super(0);
  12305. this._string = null;
  12306. this._toString = void 0;
  12307. this._toString = createInterpolator({
  12308. output: [value, value]
  12309. });
  12310. }
  12311. static create(value) {
  12312. return new AnimatedString(value);
  12313. }
  12314. getValue() {
  12315. let value = this._string;
  12316. return value == null ? this._string = this._toString(this._value) : value;
  12317. }
  12318. setValue(value) {
  12319. if (react_spring_shared_esm_is.str(value)) {
  12320. if (value == this._string) {
  12321. return false;
  12322. }
  12323. this._string = value;
  12324. this._value = 1;
  12325. } else if (super.setValue(value)) {
  12326. this._string = null;
  12327. } else {
  12328. return false;
  12329. }
  12330. return true;
  12331. }
  12332. reset(goal) {
  12333. if (goal) {
  12334. this._toString = createInterpolator({
  12335. output: [this.getValue(), goal]
  12336. });
  12337. }
  12338. this._value = 0;
  12339. super.reset();
  12340. }
  12341. }
  12342. const TreeContext = {
  12343. dependencies: null
  12344. };
  12345. class AnimatedObject extends Animated {
  12346. constructor(source) {
  12347. super();
  12348. this.source = source;
  12349. this.setValue(source);
  12350. }
  12351. getValue(animated) {
  12352. const values = {};
  12353. eachProp(this.source, (source, key) => {
  12354. if (isAnimated(source)) {
  12355. values[key] = source.getValue(animated);
  12356. } else if (hasFluidValue(source)) {
  12357. values[key] = getFluidValue(source);
  12358. } else if (!animated) {
  12359. values[key] = source;
  12360. }
  12361. });
  12362. return values;
  12363. }
  12364. setValue(source) {
  12365. this.source = source;
  12366. this.payload = this._makePayload(source);
  12367. }
  12368. reset() {
  12369. if (this.payload) {
  12370. react_spring_shared_esm_each(this.payload, node => node.reset());
  12371. }
  12372. }
  12373. _makePayload(source) {
  12374. if (source) {
  12375. const payload = new Set();
  12376. eachProp(source, this._addToPayload, payload);
  12377. return Array.from(payload);
  12378. }
  12379. }
  12380. _addToPayload(source) {
  12381. if (TreeContext.dependencies && hasFluidValue(source)) {
  12382. TreeContext.dependencies.add(source);
  12383. }
  12384. const payload = getPayload(source);
  12385. if (payload) {
  12386. react_spring_shared_esm_each(payload, node => this.add(node));
  12387. }
  12388. }
  12389. }
  12390. class AnimatedArray extends AnimatedObject {
  12391. constructor(source) {
  12392. super(source);
  12393. }
  12394. static create(source) {
  12395. return new AnimatedArray(source);
  12396. }
  12397. getValue() {
  12398. return this.source.map(node => node.getValue());
  12399. }
  12400. setValue(source) {
  12401. const payload = this.getPayload();
  12402. if (source.length == payload.length) {
  12403. return payload.map((node, i) => node.setValue(source[i])).some(Boolean);
  12404. }
  12405. super.setValue(source.map(makeAnimated));
  12406. return true;
  12407. }
  12408. }
  12409. function makeAnimated(value) {
  12410. const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
  12411. return nodeType.create(value);
  12412. }
  12413. function getAnimatedType(value) {
  12414. const parentNode = getAnimated(value);
  12415. return parentNode ? parentNode.constructor : react_spring_shared_esm_is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
  12416. }
  12417. function react_spring_animated_esm_extends() {
  12418. react_spring_animated_esm_extends = Object.assign || function (target) {
  12419. for (var i = 1; i < arguments.length; i++) {
  12420. var source = arguments[i];
  12421. for (var key in source) {
  12422. if (Object.prototype.hasOwnProperty.call(source, key)) {
  12423. target[key] = source[key];
  12424. }
  12425. }
  12426. }
  12427. return target;
  12428. };
  12429. return react_spring_animated_esm_extends.apply(this, arguments);
  12430. }
  12431. const withAnimated = (Component, host) => {
  12432. const hasInstance = !react_spring_shared_esm_is.fun(Component) || Component.prototype && Component.prototype.isReactComponent;
  12433. return (0,external_React_.forwardRef)((givenProps, givenRef) => {
  12434. const instanceRef = (0,external_React_.useRef)(null);
  12435. const ref = hasInstance && (0,external_React_.useCallback)(value => {
  12436. instanceRef.current = updateRef(givenRef, value);
  12437. }, [givenRef]);
  12438. const [props, deps] = getAnimatedState(givenProps, host);
  12439. const forceUpdate = react_spring_shared_esm_useForceUpdate();
  12440. const callback = () => {
  12441. const instance = instanceRef.current;
  12442. if (hasInstance && !instance) {
  12443. return;
  12444. }
  12445. const didUpdate = instance ? host.applyAnimatedValues(instance, props.getValue(true)) : false;
  12446. if (didUpdate === false) {
  12447. forceUpdate();
  12448. }
  12449. };
  12450. const observer = new PropsObserver(callback, deps);
  12451. const observerRef = (0,external_React_.useRef)();
  12452. react_spring_shared_esm_useIsomorphicLayoutEffect(() => {
  12453. observerRef.current = observer;
  12454. react_spring_shared_esm_each(deps, dep => addFluidObserver(dep, observer));
  12455. return () => {
  12456. if (observerRef.current) {
  12457. react_spring_shared_esm_each(observerRef.current.deps, dep => removeFluidObserver(dep, observerRef.current));
  12458. raf.cancel(observerRef.current.update);
  12459. }
  12460. };
  12461. });
  12462. (0,external_React_.useEffect)(callback, []);
  12463. react_spring_shared_esm_useOnce(() => () => {
  12464. const observer = observerRef.current;
  12465. react_spring_shared_esm_each(observer.deps, dep => removeFluidObserver(dep, observer));
  12466. });
  12467. const usedProps = host.getComponentProps(props.getValue());
  12468. return external_React_.createElement(Component, react_spring_animated_esm_extends({}, usedProps, {
  12469. ref: ref
  12470. }));
  12471. });
  12472. };
  12473. class PropsObserver {
  12474. constructor(update, deps) {
  12475. this.update = update;
  12476. this.deps = deps;
  12477. }
  12478. eventObserved(event) {
  12479. if (event.type == 'change') {
  12480. raf.write(this.update);
  12481. }
  12482. }
  12483. }
  12484. function getAnimatedState(props, host) {
  12485. const dependencies = new Set();
  12486. TreeContext.dependencies = dependencies;
  12487. if (props.style) props = react_spring_animated_esm_extends({}, props, {
  12488. style: host.createAnimatedStyle(props.style)
  12489. });
  12490. props = new AnimatedObject(props);
  12491. TreeContext.dependencies = null;
  12492. return [props, dependencies];
  12493. }
  12494. function updateRef(ref, value) {
  12495. if (ref) {
  12496. if (react_spring_shared_esm_is.fun(ref)) ref(value);else ref.current = value;
  12497. }
  12498. return value;
  12499. }
  12500. const cacheKey = Symbol.for('AnimatedComponent');
  12501. const createHost = (components, {
  12502. applyAnimatedValues: _applyAnimatedValues = () => false,
  12503. createAnimatedStyle: _createAnimatedStyle = style => new AnimatedObject(style),
  12504. getComponentProps: _getComponentProps = props => props
  12505. } = {}) => {
  12506. const hostConfig = {
  12507. applyAnimatedValues: _applyAnimatedValues,
  12508. createAnimatedStyle: _createAnimatedStyle,
  12509. getComponentProps: _getComponentProps
  12510. };
  12511. const animated = Component => {
  12512. const displayName = getDisplayName(Component) || 'Anonymous';
  12513. if (react_spring_shared_esm_is.str(Component)) {
  12514. Component = animated[Component] || (animated[Component] = withAnimated(Component, hostConfig));
  12515. } else {
  12516. Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig));
  12517. }
  12518. Component.displayName = `Animated(${displayName})`;
  12519. return Component;
  12520. };
  12521. eachProp(components, (Component, key) => {
  12522. if (react_spring_shared_esm_is.arr(components)) {
  12523. key = getDisplayName(Component);
  12524. }
  12525. animated[key] = animated(Component);
  12526. });
  12527. return {
  12528. animated
  12529. };
  12530. };
  12531. 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;
  12532. ;// CONCATENATED MODULE: ./node_modules/@react-spring/core/dist/react-spring-core.esm.js
  12533. function react_spring_core_esm_extends() {
  12534. react_spring_core_esm_extends = Object.assign || function (target) {
  12535. for (var i = 1; i < arguments.length; i++) {
  12536. var source = arguments[i];
  12537. for (var key in source) {
  12538. if (Object.prototype.hasOwnProperty.call(source, key)) {
  12539. target[key] = source[key];
  12540. }
  12541. }
  12542. }
  12543. return target;
  12544. };
  12545. return react_spring_core_esm_extends.apply(this, arguments);
  12546. }
  12547. function callProp(value, ...args) {
  12548. return react_spring_shared_esm_is.fun(value) ? value(...args) : value;
  12549. }
  12550. 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)));
  12551. const resolveProp = (prop, key) => react_spring_shared_esm_is.obj(prop) ? key && prop[key] : prop;
  12552. const getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : undefined;
  12553. const noopTransform = value => value;
  12554. const getDefaultProps = (props, transform = noopTransform) => {
  12555. let keys = DEFAULT_PROPS;
  12556. if (props.default && props.default !== true) {
  12557. props = props.default;
  12558. keys = Object.keys(props);
  12559. }
  12560. const defaults = {};
  12561. for (const key of keys) {
  12562. const value = transform(props[key], key);
  12563. if (!react_spring_shared_esm_is.und(value)) {
  12564. defaults[key] = value;
  12565. }
  12566. }
  12567. return defaults;
  12568. };
  12569. const DEFAULT_PROPS = ['config', 'onProps', 'onStart', 'onChange', 'onPause', 'onResume', 'onRest'];
  12570. const RESERVED_PROPS = {
  12571. config: 1,
  12572. from: 1,
  12573. to: 1,
  12574. ref: 1,
  12575. loop: 1,
  12576. reset: 1,
  12577. pause: 1,
  12578. cancel: 1,
  12579. reverse: 1,
  12580. immediate: 1,
  12581. default: 1,
  12582. delay: 1,
  12583. onProps: 1,
  12584. onStart: 1,
  12585. onChange: 1,
  12586. onPause: 1,
  12587. onResume: 1,
  12588. onRest: 1,
  12589. onResolve: 1,
  12590. items: 1,
  12591. trail: 1,
  12592. sort: 1,
  12593. expires: 1,
  12594. initial: 1,
  12595. enter: 1,
  12596. update: 1,
  12597. leave: 1,
  12598. children: 1,
  12599. onDestroyed: 1,
  12600. keys: 1,
  12601. callId: 1,
  12602. parentId: 1
  12603. };
  12604. function getForwardProps(props) {
  12605. const forward = {};
  12606. let count = 0;
  12607. eachProp(props, (value, prop) => {
  12608. if (!RESERVED_PROPS[prop]) {
  12609. forward[prop] = value;
  12610. count++;
  12611. }
  12612. });
  12613. if (count) {
  12614. return forward;
  12615. }
  12616. }
  12617. function inferTo(props) {
  12618. const to = getForwardProps(props);
  12619. if (to) {
  12620. const out = {
  12621. to
  12622. };
  12623. eachProp(props, (val, key) => key in to || (out[key] = val));
  12624. return out;
  12625. }
  12626. return react_spring_core_esm_extends({}, props);
  12627. }
  12628. function computeGoal(value) {
  12629. value = getFluidValue(value);
  12630. return react_spring_shared_esm_is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({
  12631. range: [0, 1],
  12632. output: [value, value]
  12633. })(1) : value;
  12634. }
  12635. function hasProps(props) {
  12636. for (const _ in props) return true;
  12637. return false;
  12638. }
  12639. function isAsyncTo(to) {
  12640. return react_spring_shared_esm_is.fun(to) || react_spring_shared_esm_is.arr(to) && react_spring_shared_esm_is.obj(to[0]);
  12641. }
  12642. function detachRefs(ctrl, ref) {
  12643. var _ctrl$ref;
  12644. (_ctrl$ref = ctrl.ref) == null ? void 0 : _ctrl$ref.delete(ctrl);
  12645. ref == null ? void 0 : ref.delete(ctrl);
  12646. }
  12647. function replaceRef(ctrl, ref) {
  12648. if (ref && ctrl.ref !== ref) {
  12649. var _ctrl$ref2;
  12650. (_ctrl$ref2 = ctrl.ref) == null ? void 0 : _ctrl$ref2.delete(ctrl);
  12651. ref.add(ctrl);
  12652. ctrl.ref = ref;
  12653. }
  12654. }
  12655. function useChain(refs, timeSteps, timeFrame = 1000) {
  12656. useIsomorphicLayoutEffect(() => {
  12657. if (timeSteps) {
  12658. let prevDelay = 0;
  12659. each(refs, (ref, i) => {
  12660. const controllers = ref.current;
  12661. if (controllers.length) {
  12662. let delay = timeFrame * timeSteps[i];
  12663. if (isNaN(delay)) delay = prevDelay;else prevDelay = delay;
  12664. each(controllers, ctrl => {
  12665. each(ctrl.queue, props => {
  12666. const memoizedDelayProp = props.delay;
  12667. props.delay = key => delay + callProp(memoizedDelayProp || 0, key);
  12668. });
  12669. });
  12670. ref.start();
  12671. }
  12672. });
  12673. } else {
  12674. let p = Promise.resolve();
  12675. each(refs, ref => {
  12676. const controllers = ref.current;
  12677. if (controllers.length) {
  12678. const queues = controllers.map(ctrl => {
  12679. const q = ctrl.queue;
  12680. ctrl.queue = [];
  12681. return q;
  12682. });
  12683. p = p.then(() => {
  12684. each(controllers, (ctrl, i) => each(queues[i] || [], update => ctrl.queue.push(update)));
  12685. return Promise.all(ref.start());
  12686. });
  12687. }
  12688. });
  12689. }
  12690. });
  12691. }
  12692. const config = {
  12693. default: {
  12694. tension: 170,
  12695. friction: 26
  12696. },
  12697. gentle: {
  12698. tension: 120,
  12699. friction: 14
  12700. },
  12701. wobbly: {
  12702. tension: 180,
  12703. friction: 12
  12704. },
  12705. stiff: {
  12706. tension: 210,
  12707. friction: 20
  12708. },
  12709. slow: {
  12710. tension: 280,
  12711. friction: 60
  12712. },
  12713. molasses: {
  12714. tension: 280,
  12715. friction: 120
  12716. }
  12717. };
  12718. const c1 = 1.70158;
  12719. const c2 = c1 * 1.525;
  12720. const c3 = c1 + 1;
  12721. const c4 = 2 * Math.PI / 3;
  12722. const c5 = 2 * Math.PI / 4.5;
  12723. const bounceOut = x => {
  12724. const n1 = 7.5625;
  12725. const d1 = 2.75;
  12726. if (x < 1 / d1) {
  12727. return n1 * x * x;
  12728. } else if (x < 2 / d1) {
  12729. return n1 * (x -= 1.5 / d1) * x + 0.75;
  12730. } else if (x < 2.5 / d1) {
  12731. return n1 * (x -= 2.25 / d1) * x + 0.9375;
  12732. } else {
  12733. return n1 * (x -= 2.625 / d1) * x + 0.984375;
  12734. }
  12735. };
  12736. const easings = {
  12737. linear: x => x,
  12738. easeInQuad: x => x * x,
  12739. easeOutQuad: x => 1 - (1 - x) * (1 - x),
  12740. easeInOutQuad: x => x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2,
  12741. easeInCubic: x => x * x * x,
  12742. easeOutCubic: x => 1 - Math.pow(1 - x, 3),
  12743. easeInOutCubic: x => x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2,
  12744. easeInQuart: x => x * x * x * x,
  12745. easeOutQuart: x => 1 - Math.pow(1 - x, 4),
  12746. easeInOutQuart: x => x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2,
  12747. easeInQuint: x => x * x * x * x * x,
  12748. easeOutQuint: x => 1 - Math.pow(1 - x, 5),
  12749. easeInOutQuint: x => x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2,
  12750. easeInSine: x => 1 - Math.cos(x * Math.PI / 2),
  12751. easeOutSine: x => Math.sin(x * Math.PI / 2),
  12752. easeInOutSine: x => -(Math.cos(Math.PI * x) - 1) / 2,
  12753. easeInExpo: x => x === 0 ? 0 : Math.pow(2, 10 * x - 10),
  12754. easeOutExpo: x => x === 1 ? 1 : 1 - Math.pow(2, -10 * x),
  12755. 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,
  12756. easeInCirc: x => 1 - Math.sqrt(1 - Math.pow(x, 2)),
  12757. easeOutCirc: x => Math.sqrt(1 - Math.pow(x - 1, 2)),
  12758. 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,
  12759. easeInBack: x => c3 * x * x * x - c1 * x * x,
  12760. easeOutBack: x => 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2),
  12761. 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,
  12762. easeInElastic: x => x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4),
  12763. easeOutElastic: x => x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1,
  12764. 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,
  12765. easeInBounce: x => 1 - bounceOut(1 - x),
  12766. easeOutBounce: bounceOut,
  12767. easeInOutBounce: x => x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2
  12768. };
  12769. const defaults = react_spring_core_esm_extends({}, config.default, {
  12770. mass: 1,
  12771. damping: 1,
  12772. easing: easings.linear,
  12773. clamp: false
  12774. });
  12775. class AnimationConfig {
  12776. constructor() {
  12777. this.tension = void 0;
  12778. this.friction = void 0;
  12779. this.frequency = void 0;
  12780. this.damping = void 0;
  12781. this.mass = void 0;
  12782. this.velocity = 0;
  12783. this.restVelocity = void 0;
  12784. this.precision = void 0;
  12785. this.progress = void 0;
  12786. this.duration = void 0;
  12787. this.easing = void 0;
  12788. this.clamp = void 0;
  12789. this.bounce = void 0;
  12790. this.decay = void 0;
  12791. this.round = void 0;
  12792. Object.assign(this, defaults);
  12793. }
  12794. }
  12795. function mergeConfig(config, newConfig, defaultConfig) {
  12796. if (defaultConfig) {
  12797. defaultConfig = react_spring_core_esm_extends({}, defaultConfig);
  12798. sanitizeConfig(defaultConfig, newConfig);
  12799. newConfig = react_spring_core_esm_extends({}, defaultConfig, newConfig);
  12800. }
  12801. sanitizeConfig(config, newConfig);
  12802. Object.assign(config, newConfig);
  12803. for (const key in defaults) {
  12804. if (config[key] == null) {
  12805. config[key] = defaults[key];
  12806. }
  12807. }
  12808. let {
  12809. mass,
  12810. frequency,
  12811. damping
  12812. } = config;
  12813. if (!react_spring_shared_esm_is.und(frequency)) {
  12814. if (frequency < 0.01) frequency = 0.01;
  12815. if (damping < 0) damping = 0;
  12816. config.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
  12817. config.friction = 4 * Math.PI * damping * mass / frequency;
  12818. }
  12819. return config;
  12820. }
  12821. function sanitizeConfig(config, props) {
  12822. if (!react_spring_shared_esm_is.und(props.decay)) {
  12823. config.duration = undefined;
  12824. } else {
  12825. const isTensionConfig = !react_spring_shared_esm_is.und(props.tension) || !react_spring_shared_esm_is.und(props.friction);
  12826. 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)) {
  12827. config.duration = undefined;
  12828. config.decay = undefined;
  12829. }
  12830. if (isTensionConfig) {
  12831. config.frequency = undefined;
  12832. }
  12833. }
  12834. }
  12835. const emptyArray = [];
  12836. class Animation {
  12837. constructor() {
  12838. this.changed = false;
  12839. this.values = emptyArray;
  12840. this.toValues = null;
  12841. this.fromValues = emptyArray;
  12842. this.to = void 0;
  12843. this.from = void 0;
  12844. this.config = new AnimationConfig();
  12845. this.immediate = false;
  12846. }
  12847. }
  12848. function scheduleProps(callId, {
  12849. key,
  12850. props,
  12851. defaultProps,
  12852. state,
  12853. actions
  12854. }) {
  12855. return new Promise((resolve, reject) => {
  12856. var _props$cancel;
  12857. let delay;
  12858. let timeout;
  12859. let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps == null ? void 0 : defaultProps.cancel, key);
  12860. if (cancel) {
  12861. onStart();
  12862. } else {
  12863. if (!react_spring_shared_esm_is.und(props.pause)) {
  12864. state.paused = matchProp(props.pause, key);
  12865. }
  12866. let pause = defaultProps == null ? void 0 : defaultProps.pause;
  12867. if (pause !== true) {
  12868. pause = state.paused || matchProp(pause, key);
  12869. }
  12870. delay = callProp(props.delay || 0, key);
  12871. if (pause) {
  12872. state.resumeQueue.add(onResume);
  12873. actions.pause();
  12874. } else {
  12875. actions.resume();
  12876. onResume();
  12877. }
  12878. }
  12879. function onPause() {
  12880. state.resumeQueue.add(onResume);
  12881. state.timeouts.delete(timeout);
  12882. timeout.cancel();
  12883. delay = timeout.time - raf.now();
  12884. }
  12885. function onResume() {
  12886. if (delay > 0 && !globals.skipAnimation) {
  12887. state.delayed = true;
  12888. timeout = raf.setTimeout(onStart, delay);
  12889. state.pauseQueue.add(onPause);
  12890. state.timeouts.add(timeout);
  12891. } else {
  12892. onStart();
  12893. }
  12894. }
  12895. function onStart() {
  12896. if (state.delayed) {
  12897. state.delayed = false;
  12898. }
  12899. state.pauseQueue.delete(onPause);
  12900. state.timeouts.delete(timeout);
  12901. if (callId <= (state.cancelId || 0)) {
  12902. cancel = true;
  12903. }
  12904. try {
  12905. actions.start(react_spring_core_esm_extends({}, props, {
  12906. callId,
  12907. cancel
  12908. }), resolve);
  12909. } catch (err) {
  12910. reject(err);
  12911. }
  12912. }
  12913. });
  12914. }
  12915. 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));
  12916. const getNoopResult = value => ({
  12917. value,
  12918. noop: true,
  12919. finished: true,
  12920. cancelled: false
  12921. });
  12922. const getFinishedResult = (value, finished, cancelled = false) => ({
  12923. value,
  12924. finished,
  12925. cancelled
  12926. });
  12927. const getCancelledResult = value => ({
  12928. value,
  12929. cancelled: true,
  12930. finished: false
  12931. });
  12932. function runAsync(to, props, state, target) {
  12933. const {
  12934. callId,
  12935. parentId,
  12936. onRest
  12937. } = props;
  12938. const {
  12939. asyncTo: prevTo,
  12940. promise: prevPromise
  12941. } = state;
  12942. if (!parentId && to === prevTo && !props.reset) {
  12943. return prevPromise;
  12944. }
  12945. return state.promise = (async () => {
  12946. state.asyncId = callId;
  12947. state.asyncTo = to;
  12948. const defaultProps = getDefaultProps(props, (value, key) => key === 'onRest' ? undefined : value);
  12949. let preventBail;
  12950. let bail;
  12951. const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject));
  12952. const bailIfEnded = bailSignal => {
  12953. const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false);
  12954. if (bailResult) {
  12955. bailSignal.result = bailResult;
  12956. bail(bailSignal);
  12957. throw bailSignal;
  12958. }
  12959. };
  12960. const animate = (arg1, arg2) => {
  12961. const bailSignal = new BailSignal();
  12962. const skipAnimationSignal = new SkipAniamtionSignal();
  12963. return (async () => {
  12964. if (globals.skipAnimation) {
  12965. stopAsync(state);
  12966. skipAnimationSignal.result = getFinishedResult(target, false);
  12967. bail(skipAnimationSignal);
  12968. throw skipAnimationSignal;
  12969. }
  12970. bailIfEnded(bailSignal);
  12971. const props = react_spring_shared_esm_is.obj(arg1) ? react_spring_core_esm_extends({}, arg1) : react_spring_core_esm_extends({}, arg2, {
  12972. to: arg1
  12973. });
  12974. props.parentId = callId;
  12975. eachProp(defaultProps, (value, key) => {
  12976. if (react_spring_shared_esm_is.und(props[key])) {
  12977. props[key] = value;
  12978. }
  12979. });
  12980. const result = await target.start(props);
  12981. bailIfEnded(bailSignal);
  12982. if (state.paused) {
  12983. await new Promise(resume => {
  12984. state.resumeQueue.add(resume);
  12985. });
  12986. }
  12987. return result;
  12988. })();
  12989. };
  12990. let result;
  12991. if (globals.skipAnimation) {
  12992. stopAsync(state);
  12993. return getFinishedResult(target, false);
  12994. }
  12995. try {
  12996. let animating;
  12997. if (react_spring_shared_esm_is.arr(to)) {
  12998. animating = (async queue => {
  12999. for (const props of queue) {
  13000. await animate(props);
  13001. }
  13002. })(to);
  13003. } else {
  13004. animating = Promise.resolve(to(animate, target.stop.bind(target)));
  13005. }
  13006. await Promise.all([animating.then(preventBail), bailPromise]);
  13007. result = getFinishedResult(target.get(), true, false);
  13008. } catch (err) {
  13009. if (err instanceof BailSignal) {
  13010. result = err.result;
  13011. } else if (err instanceof SkipAniamtionSignal) {
  13012. result = err.result;
  13013. } else {
  13014. throw err;
  13015. }
  13016. } finally {
  13017. if (callId == state.asyncId) {
  13018. state.asyncId = parentId;
  13019. state.asyncTo = parentId ? prevTo : undefined;
  13020. state.promise = parentId ? prevPromise : undefined;
  13021. }
  13022. }
  13023. if (react_spring_shared_esm_is.fun(onRest)) {
  13024. raf.batchedUpdates(() => {
  13025. onRest(result, target, target.item);
  13026. });
  13027. }
  13028. return result;
  13029. })();
  13030. }
  13031. function stopAsync(state, cancelId) {
  13032. flush(state.timeouts, t => t.cancel());
  13033. state.pauseQueue.clear();
  13034. state.resumeQueue.clear();
  13035. state.asyncId = state.asyncTo = state.promise = undefined;
  13036. if (cancelId) state.cancelId = cancelId;
  13037. }
  13038. class BailSignal extends Error {
  13039. constructor() {
  13040. super('An async animation has been interrupted. You see this error because you ' + 'forgot to use `await` or `.catch(...)` on its returned promise.');
  13041. this.result = void 0;
  13042. }
  13043. }
  13044. class SkipAniamtionSignal extends Error {
  13045. constructor() {
  13046. super('SkipAnimationSignal');
  13047. this.result = void 0;
  13048. }
  13049. }
  13050. const isFrameValue = value => value instanceof FrameValue;
  13051. let nextId$1 = 1;
  13052. class FrameValue extends FluidValue {
  13053. constructor(...args) {
  13054. super(...args);
  13055. this.id = nextId$1++;
  13056. this.key = void 0;
  13057. this._priority = 0;
  13058. }
  13059. get priority() {
  13060. return this._priority;
  13061. }
  13062. set priority(priority) {
  13063. if (this._priority != priority) {
  13064. this._priority = priority;
  13065. this._onPriorityChange(priority);
  13066. }
  13067. }
  13068. get() {
  13069. const node = getAnimated(this);
  13070. return node && node.getValue();
  13071. }
  13072. to(...args) {
  13073. return globals.to(this, args);
  13074. }
  13075. interpolate(...args) {
  13076. react_spring_shared_esm_deprecateInterpolate();
  13077. return globals.to(this, args);
  13078. }
  13079. toJSON() {
  13080. return this.get();
  13081. }
  13082. observerAdded(count) {
  13083. if (count == 1) this._attach();
  13084. }
  13085. observerRemoved(count) {
  13086. if (count == 0) this._detach();
  13087. }
  13088. _attach() {}
  13089. _detach() {}
  13090. _onChange(value, idle = false) {
  13091. callFluidObservers(this, {
  13092. type: 'change',
  13093. parent: this,
  13094. value,
  13095. idle
  13096. });
  13097. }
  13098. _onPriorityChange(priority) {
  13099. if (!this.idle) {
  13100. frameLoop.sort(this);
  13101. }
  13102. callFluidObservers(this, {
  13103. type: 'priority',
  13104. parent: this,
  13105. priority
  13106. });
  13107. }
  13108. }
  13109. const $P = Symbol.for('SpringPhase');
  13110. const HAS_ANIMATED = 1;
  13111. const IS_ANIMATING = 2;
  13112. const IS_PAUSED = 4;
  13113. const hasAnimated = target => (target[$P] & HAS_ANIMATED) > 0;
  13114. const isAnimating = target => (target[$P] & IS_ANIMATING) > 0;
  13115. const isPaused = target => (target[$P] & IS_PAUSED) > 0;
  13116. const setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING;
  13117. const setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED;
  13118. class SpringValue extends FrameValue {
  13119. constructor(arg1, arg2) {
  13120. super();
  13121. this.key = void 0;
  13122. this.animation = new Animation();
  13123. this.queue = void 0;
  13124. this.defaultProps = {};
  13125. this._state = {
  13126. paused: false,
  13127. delayed: false,
  13128. pauseQueue: new Set(),
  13129. resumeQueue: new Set(),
  13130. timeouts: new Set()
  13131. };
  13132. this._pendingCalls = new Set();
  13133. this._lastCallId = 0;
  13134. this._lastToId = 0;
  13135. this._memoizedDuration = 0;
  13136. if (!react_spring_shared_esm_is.und(arg1) || !react_spring_shared_esm_is.und(arg2)) {
  13137. const props = react_spring_shared_esm_is.obj(arg1) ? react_spring_core_esm_extends({}, arg1) : react_spring_core_esm_extends({}, arg2, {
  13138. from: arg1
  13139. });
  13140. if (react_spring_shared_esm_is.und(props.default)) {
  13141. props.default = true;
  13142. }
  13143. this.start(props);
  13144. }
  13145. }
  13146. get idle() {
  13147. return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
  13148. }
  13149. get goal() {
  13150. return getFluidValue(this.animation.to);
  13151. }
  13152. get velocity() {
  13153. const node = getAnimated(this);
  13154. return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map(node => node.lastVelocity || 0);
  13155. }
  13156. get hasAnimated() {
  13157. return hasAnimated(this);
  13158. }
  13159. get isAnimating() {
  13160. return isAnimating(this);
  13161. }
  13162. get isPaused() {
  13163. return isPaused(this);
  13164. }
  13165. get isDelayed() {
  13166. return this._state.delayed;
  13167. }
  13168. advance(dt) {
  13169. let idle = true;
  13170. let changed = false;
  13171. const anim = this.animation;
  13172. let {
  13173. config,
  13174. toValues
  13175. } = anim;
  13176. const payload = getPayload(anim.to);
  13177. if (!payload && hasFluidValue(anim.to)) {
  13178. toValues = react_spring_shared_esm_toArray(getFluidValue(anim.to));
  13179. }
  13180. anim.values.forEach((node, i) => {
  13181. if (node.done) return;
  13182. const to = node.constructor == AnimatedString ? 1 : payload ? payload[i].lastPosition : toValues[i];
  13183. let finished = anim.immediate;
  13184. let position = to;
  13185. if (!finished) {
  13186. position = node.lastPosition;
  13187. if (config.tension <= 0) {
  13188. node.done = true;
  13189. return;
  13190. }
  13191. let elapsed = node.elapsedTime += dt;
  13192. const from = anim.fromValues[i];
  13193. const v0 = node.v0 != null ? node.v0 : node.v0 = react_spring_shared_esm_is.arr(config.velocity) ? config.velocity[i] : config.velocity;
  13194. let velocity;
  13195. if (!react_spring_shared_esm_is.und(config.duration)) {
  13196. let p = 1;
  13197. if (config.duration > 0) {
  13198. if (this._memoizedDuration !== config.duration) {
  13199. this._memoizedDuration = config.duration;
  13200. if (node.durationProgress > 0) {
  13201. node.elapsedTime = config.duration * node.durationProgress;
  13202. elapsed = node.elapsedTime += dt;
  13203. }
  13204. }
  13205. p = (config.progress || 0) + elapsed / this._memoizedDuration;
  13206. p = p > 1 ? 1 : p < 0 ? 0 : p;
  13207. node.durationProgress = p;
  13208. }
  13209. position = from + config.easing(p) * (to - from);
  13210. velocity = (position - node.lastPosition) / dt;
  13211. finished = p == 1;
  13212. } else if (config.decay) {
  13213. const decay = config.decay === true ? 0.998 : config.decay;
  13214. const e = Math.exp(-(1 - decay) * elapsed);
  13215. position = from + v0 / (1 - decay) * (1 - e);
  13216. finished = Math.abs(node.lastPosition - position) < 0.1;
  13217. velocity = v0 * e;
  13218. } else {
  13219. velocity = node.lastVelocity == null ? v0 : node.lastVelocity;
  13220. const precision = config.precision || (from == to ? 0.005 : Math.min(1, Math.abs(to - from) * 0.001));
  13221. const restVelocity = config.restVelocity || precision / 10;
  13222. const bounceFactor = config.clamp ? 0 : config.bounce;
  13223. const canBounce = !react_spring_shared_esm_is.und(bounceFactor);
  13224. const isGrowing = from == to ? node.v0 > 0 : from < to;
  13225. let isMoving;
  13226. let isBouncing = false;
  13227. const step = 1;
  13228. const numSteps = Math.ceil(dt / step);
  13229. for (let n = 0; n < numSteps; ++n) {
  13230. isMoving = Math.abs(velocity) > restVelocity;
  13231. if (!isMoving) {
  13232. finished = Math.abs(to - position) <= precision;
  13233. if (finished) {
  13234. break;
  13235. }
  13236. }
  13237. if (canBounce) {
  13238. isBouncing = position == to || position > to == isGrowing;
  13239. if (isBouncing) {
  13240. velocity = -velocity * bounceFactor;
  13241. position = to;
  13242. }
  13243. }
  13244. const springForce = -config.tension * 0.000001 * (position - to);
  13245. const dampingForce = -config.friction * 0.001 * velocity;
  13246. const acceleration = (springForce + dampingForce) / config.mass;
  13247. velocity = velocity + acceleration * step;
  13248. position = position + velocity * step;
  13249. }
  13250. }
  13251. node.lastVelocity = velocity;
  13252. if (Number.isNaN(position)) {
  13253. console.warn(`Got NaN while animating:`, this);
  13254. finished = true;
  13255. }
  13256. }
  13257. if (payload && !payload[i].done) {
  13258. finished = false;
  13259. }
  13260. if (finished) {
  13261. node.done = true;
  13262. } else {
  13263. idle = false;
  13264. }
  13265. if (node.setValue(position, config.round)) {
  13266. changed = true;
  13267. }
  13268. });
  13269. const node = getAnimated(this);
  13270. const currVal = node.getValue();
  13271. if (idle) {
  13272. const finalVal = getFluidValue(anim.to);
  13273. if ((currVal !== finalVal || changed) && !config.decay) {
  13274. node.setValue(finalVal);
  13275. this._onChange(finalVal);
  13276. } else if (changed && config.decay) {
  13277. this._onChange(currVal);
  13278. }
  13279. this._stop();
  13280. } else if (changed) {
  13281. this._onChange(currVal);
  13282. }
  13283. }
  13284. set(value) {
  13285. raf.batchedUpdates(() => {
  13286. this._stop();
  13287. this._focus(value);
  13288. this._set(value);
  13289. });
  13290. return this;
  13291. }
  13292. pause() {
  13293. this._update({
  13294. pause: true
  13295. });
  13296. }
  13297. resume() {
  13298. this._update({
  13299. pause: false
  13300. });
  13301. }
  13302. finish() {
  13303. if (isAnimating(this)) {
  13304. const {
  13305. to,
  13306. config
  13307. } = this.animation;
  13308. raf.batchedUpdates(() => {
  13309. this._onStart();
  13310. if (!config.decay) {
  13311. this._set(to, false);
  13312. }
  13313. this._stop();
  13314. });
  13315. }
  13316. return this;
  13317. }
  13318. update(props) {
  13319. const queue = this.queue || (this.queue = []);
  13320. queue.push(props);
  13321. return this;
  13322. }
  13323. start(to, arg2) {
  13324. let queue;
  13325. if (!react_spring_shared_esm_is.und(to)) {
  13326. queue = [react_spring_shared_esm_is.obj(to) ? to : react_spring_core_esm_extends({}, arg2, {
  13327. to
  13328. })];
  13329. } else {
  13330. queue = this.queue || [];
  13331. this.queue = [];
  13332. }
  13333. return Promise.all(queue.map(props => {
  13334. const up = this._update(props);
  13335. return up;
  13336. })).then(results => getCombinedResult(this, results));
  13337. }
  13338. stop(cancel) {
  13339. const {
  13340. to
  13341. } = this.animation;
  13342. this._focus(this.get());
  13343. stopAsync(this._state, cancel && this._lastCallId);
  13344. raf.batchedUpdates(() => this._stop(to, cancel));
  13345. return this;
  13346. }
  13347. reset() {
  13348. this._update({
  13349. reset: true
  13350. });
  13351. }
  13352. eventObserved(event) {
  13353. if (event.type == 'change') {
  13354. this._start();
  13355. } else if (event.type == 'priority') {
  13356. this.priority = event.priority + 1;
  13357. }
  13358. }
  13359. _prepareNode(props) {
  13360. const key = this.key || '';
  13361. let {
  13362. to,
  13363. from
  13364. } = props;
  13365. to = react_spring_shared_esm_is.obj(to) ? to[key] : to;
  13366. if (to == null || isAsyncTo(to)) {
  13367. to = undefined;
  13368. }
  13369. from = react_spring_shared_esm_is.obj(from) ? from[key] : from;
  13370. if (from == null) {
  13371. from = undefined;
  13372. }
  13373. const range = {
  13374. to,
  13375. from
  13376. };
  13377. if (!hasAnimated(this)) {
  13378. if (props.reverse) [to, from] = [from, to];
  13379. from = getFluidValue(from);
  13380. if (!react_spring_shared_esm_is.und(from)) {
  13381. this._set(from);
  13382. } else if (!getAnimated(this)) {
  13383. this._set(to);
  13384. }
  13385. }
  13386. return range;
  13387. }
  13388. _update(_ref, isLoop) {
  13389. let props = react_spring_core_esm_extends({}, _ref);
  13390. const {
  13391. key,
  13392. defaultProps
  13393. } = this;
  13394. if (props.default) Object.assign(defaultProps, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value));
  13395. mergeActiveFn(this, props, 'onProps');
  13396. sendEvent(this, 'onProps', props, this);
  13397. const range = this._prepareNode(props);
  13398. if (Object.isFrozen(this)) {
  13399. throw Error('Cannot animate a `SpringValue` object that is frozen. ' + 'Did you forget to pass your component to `animated(...)` before animating its props?');
  13400. }
  13401. const state = this._state;
  13402. return scheduleProps(++this._lastCallId, {
  13403. key,
  13404. props,
  13405. defaultProps,
  13406. state,
  13407. actions: {
  13408. pause: () => {
  13409. if (!isPaused(this)) {
  13410. setPausedBit(this, true);
  13411. flushCalls(state.pauseQueue);
  13412. sendEvent(this, 'onPause', getFinishedResult(this, checkFinished(this, this.animation.to)), this);
  13413. }
  13414. },
  13415. resume: () => {
  13416. if (isPaused(this)) {
  13417. setPausedBit(this, false);
  13418. if (isAnimating(this)) {
  13419. this._resume();
  13420. }
  13421. flushCalls(state.resumeQueue);
  13422. sendEvent(this, 'onResume', getFinishedResult(this, checkFinished(this, this.animation.to)), this);
  13423. }
  13424. },
  13425. start: this._merge.bind(this, range)
  13426. }
  13427. }).then(result => {
  13428. if (props.loop && result.finished && !(isLoop && result.noop)) {
  13429. const nextProps = createLoopUpdate(props);
  13430. if (nextProps) {
  13431. return this._update(nextProps, true);
  13432. }
  13433. }
  13434. return result;
  13435. });
  13436. }
  13437. _merge(range, props, resolve) {
  13438. if (props.cancel) {
  13439. this.stop(true);
  13440. return resolve(getCancelledResult(this));
  13441. }
  13442. const hasToProp = !react_spring_shared_esm_is.und(range.to);
  13443. const hasFromProp = !react_spring_shared_esm_is.und(range.from);
  13444. if (hasToProp || hasFromProp) {
  13445. if (props.callId > this._lastToId) {
  13446. this._lastToId = props.callId;
  13447. } else {
  13448. return resolve(getCancelledResult(this));
  13449. }
  13450. }
  13451. const {
  13452. key,
  13453. defaultProps,
  13454. animation: anim
  13455. } = this;
  13456. const {
  13457. to: prevTo,
  13458. from: prevFrom
  13459. } = anim;
  13460. let {
  13461. to = prevTo,
  13462. from = prevFrom
  13463. } = range;
  13464. if (hasFromProp && !hasToProp && (!props.default || react_spring_shared_esm_is.und(to))) {
  13465. to = from;
  13466. }
  13467. if (props.reverse) [to, from] = [from, to];
  13468. const hasFromChanged = !isEqual(from, prevFrom);
  13469. if (hasFromChanged) {
  13470. anim.from = from;
  13471. }
  13472. from = getFluidValue(from);
  13473. const hasToChanged = !isEqual(to, prevTo);
  13474. if (hasToChanged) {
  13475. this._focus(to);
  13476. }
  13477. const hasAsyncTo = isAsyncTo(props.to);
  13478. const {
  13479. config
  13480. } = anim;
  13481. const {
  13482. decay,
  13483. velocity
  13484. } = config;
  13485. if (hasToProp || hasFromProp) {
  13486. config.velocity = 0;
  13487. }
  13488. if (props.config && !hasAsyncTo) {
  13489. mergeConfig(config, callProp(props.config, key), props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0);
  13490. }
  13491. let node = getAnimated(this);
  13492. if (!node || react_spring_shared_esm_is.und(to)) {
  13493. return resolve(getFinishedResult(this, true));
  13494. }
  13495. const reset = react_spring_shared_esm_is.und(props.reset) ? hasFromProp && !props.default : !react_spring_shared_esm_is.und(from) && matchProp(props.reset, key);
  13496. const value = reset ? from : this.get();
  13497. const goal = computeGoal(to);
  13498. const isAnimatable = react_spring_shared_esm_is.num(goal) || react_spring_shared_esm_is.arr(goal) || isAnimatedString(goal);
  13499. const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key));
  13500. if (hasToChanged) {
  13501. const nodeType = getAnimatedType(to);
  13502. if (nodeType !== node.constructor) {
  13503. if (immediate) {
  13504. node = this._set(goal);
  13505. } else throw Error(`Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`);
  13506. }
  13507. }
  13508. const goalType = node.constructor;
  13509. let started = hasFluidValue(to);
  13510. let finished = false;
  13511. if (!started) {
  13512. const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
  13513. if (hasToChanged || hasValueChanged) {
  13514. finished = isEqual(computeGoal(value), goal);
  13515. started = !finished;
  13516. }
  13517. if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config.decay, decay) || !isEqual(config.velocity, velocity)) {
  13518. started = true;
  13519. }
  13520. }
  13521. if (finished && isAnimating(this)) {
  13522. if (anim.changed && !reset) {
  13523. started = true;
  13524. } else if (!started) {
  13525. this._stop(prevTo);
  13526. }
  13527. }
  13528. if (!hasAsyncTo) {
  13529. if (started || hasFluidValue(prevTo)) {
  13530. anim.values = node.getPayload();
  13531. anim.toValues = hasFluidValue(to) ? null : goalType == AnimatedString ? [1] : react_spring_shared_esm_toArray(goal);
  13532. }
  13533. if (anim.immediate != immediate) {
  13534. anim.immediate = immediate;
  13535. if (!immediate && !reset) {
  13536. this._set(prevTo);
  13537. }
  13538. }
  13539. if (started) {
  13540. const {
  13541. onRest
  13542. } = anim;
  13543. react_spring_shared_esm_each(ACTIVE_EVENTS, type => mergeActiveFn(this, props, type));
  13544. const result = getFinishedResult(this, checkFinished(this, prevTo));
  13545. flushCalls(this._pendingCalls, result);
  13546. this._pendingCalls.add(resolve);
  13547. if (anim.changed) raf.batchedUpdates(() => {
  13548. anim.changed = !reset;
  13549. onRest == null ? void 0 : onRest(result, this);
  13550. if (reset) {
  13551. callProp(defaultProps.onRest, result);
  13552. } else {
  13553. anim.onStart == null ? void 0 : anim.onStart(result, this);
  13554. }
  13555. });
  13556. }
  13557. }
  13558. if (reset) {
  13559. this._set(value);
  13560. }
  13561. if (hasAsyncTo) {
  13562. resolve(runAsync(props.to, props, this._state, this));
  13563. } else if (started) {
  13564. this._start();
  13565. } else if (isAnimating(this) && !hasToChanged) {
  13566. this._pendingCalls.add(resolve);
  13567. } else {
  13568. resolve(getNoopResult(value));
  13569. }
  13570. }
  13571. _focus(value) {
  13572. const anim = this.animation;
  13573. if (value !== anim.to) {
  13574. if (getFluidObservers(this)) {
  13575. this._detach();
  13576. }
  13577. anim.to = value;
  13578. if (getFluidObservers(this)) {
  13579. this._attach();
  13580. }
  13581. }
  13582. }
  13583. _attach() {
  13584. let priority = 0;
  13585. const {
  13586. to
  13587. } = this.animation;
  13588. if (hasFluidValue(to)) {
  13589. addFluidObserver(to, this);
  13590. if (isFrameValue(to)) {
  13591. priority = to.priority + 1;
  13592. }
  13593. }
  13594. this.priority = priority;
  13595. }
  13596. _detach() {
  13597. const {
  13598. to
  13599. } = this.animation;
  13600. if (hasFluidValue(to)) {
  13601. removeFluidObserver(to, this);
  13602. }
  13603. }
  13604. _set(arg, idle = true) {
  13605. const value = getFluidValue(arg);
  13606. if (!react_spring_shared_esm_is.und(value)) {
  13607. const oldNode = getAnimated(this);
  13608. if (!oldNode || !isEqual(value, oldNode.getValue())) {
  13609. const nodeType = getAnimatedType(value);
  13610. if (!oldNode || oldNode.constructor != nodeType) {
  13611. setAnimated(this, nodeType.create(value));
  13612. } else {
  13613. oldNode.setValue(value);
  13614. }
  13615. if (oldNode) {
  13616. raf.batchedUpdates(() => {
  13617. this._onChange(value, idle);
  13618. });
  13619. }
  13620. }
  13621. }
  13622. return getAnimated(this);
  13623. }
  13624. _onStart() {
  13625. const anim = this.animation;
  13626. if (!anim.changed) {
  13627. anim.changed = true;
  13628. sendEvent(this, 'onStart', getFinishedResult(this, checkFinished(this, anim.to)), this);
  13629. }
  13630. }
  13631. _onChange(value, idle) {
  13632. if (!idle) {
  13633. this._onStart();
  13634. callProp(this.animation.onChange, value, this);
  13635. }
  13636. callProp(this.defaultProps.onChange, value, this);
  13637. super._onChange(value, idle);
  13638. }
  13639. _start() {
  13640. const anim = this.animation;
  13641. getAnimated(this).reset(getFluidValue(anim.to));
  13642. if (!anim.immediate) {
  13643. anim.fromValues = anim.values.map(node => node.lastPosition);
  13644. }
  13645. if (!isAnimating(this)) {
  13646. setActiveBit(this, true);
  13647. if (!isPaused(this)) {
  13648. this._resume();
  13649. }
  13650. }
  13651. }
  13652. _resume() {
  13653. if (globals.skipAnimation) {
  13654. this.finish();
  13655. } else {
  13656. frameLoop.start(this);
  13657. }
  13658. }
  13659. _stop(goal, cancel) {
  13660. if (isAnimating(this)) {
  13661. setActiveBit(this, false);
  13662. const anim = this.animation;
  13663. react_spring_shared_esm_each(anim.values, node => {
  13664. node.done = true;
  13665. });
  13666. if (anim.toValues) {
  13667. anim.onChange = anim.onPause = anim.onResume = undefined;
  13668. }
  13669. callFluidObservers(this, {
  13670. type: 'idle',
  13671. parent: this
  13672. });
  13673. const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to));
  13674. flushCalls(this._pendingCalls, result);
  13675. if (anim.changed) {
  13676. anim.changed = false;
  13677. sendEvent(this, 'onRest', result, this);
  13678. }
  13679. }
  13680. }
  13681. }
  13682. function checkFinished(target, to) {
  13683. const goal = computeGoal(to);
  13684. const value = computeGoal(target.get());
  13685. return isEqual(value, goal);
  13686. }
  13687. function createLoopUpdate(props, loop = props.loop, to = props.to) {
  13688. let loopRet = callProp(loop);
  13689. if (loopRet) {
  13690. const overrides = loopRet !== true && inferTo(loopRet);
  13691. const reverse = (overrides || props).reverse;
  13692. const reset = !overrides || overrides.reset;
  13693. return createUpdate(react_spring_core_esm_extends({}, props, {
  13694. loop,
  13695. default: false,
  13696. pause: undefined,
  13697. to: !reverse || isAsyncTo(to) ? to : undefined,
  13698. from: reset ? props.from : undefined,
  13699. reset
  13700. }, overrides));
  13701. }
  13702. }
  13703. function createUpdate(props) {
  13704. const {
  13705. to,
  13706. from
  13707. } = props = inferTo(props);
  13708. const keys = new Set();
  13709. if (react_spring_shared_esm_is.obj(to)) findDefined(to, keys);
  13710. if (react_spring_shared_esm_is.obj(from)) findDefined(from, keys);
  13711. props.keys = keys.size ? Array.from(keys) : null;
  13712. return props;
  13713. }
  13714. function declareUpdate(props) {
  13715. const update = createUpdate(props);
  13716. if (react_spring_shared_esm_is.und(update.default)) {
  13717. update.default = getDefaultProps(update);
  13718. }
  13719. return update;
  13720. }
  13721. function findDefined(values, keys) {
  13722. eachProp(values, (value, key) => value != null && keys.add(key));
  13723. }
  13724. const ACTIVE_EVENTS = ['onStart', 'onRest', 'onChange', 'onPause', 'onResume'];
  13725. function mergeActiveFn(target, props, type) {
  13726. target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : undefined;
  13727. }
  13728. function sendEvent(target, type, ...args) {
  13729. var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps;
  13730. (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args);
  13731. (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args);
  13732. }
  13733. const BATCHED_EVENTS = ['onStart', 'onChange', 'onRest'];
  13734. let nextId = 1;
  13735. class Controller {
  13736. constructor(props, flush) {
  13737. this.id = nextId++;
  13738. this.springs = {};
  13739. this.queue = [];
  13740. this.ref = void 0;
  13741. this._flush = void 0;
  13742. this._initialProps = void 0;
  13743. this._lastAsyncId = 0;
  13744. this._active = new Set();
  13745. this._changed = new Set();
  13746. this._started = false;
  13747. this._item = void 0;
  13748. this._state = {
  13749. paused: false,
  13750. pauseQueue: new Set(),
  13751. resumeQueue: new Set(),
  13752. timeouts: new Set()
  13753. };
  13754. this._events = {
  13755. onStart: new Map(),
  13756. onChange: new Map(),
  13757. onRest: new Map()
  13758. };
  13759. this._onFrame = this._onFrame.bind(this);
  13760. if (flush) {
  13761. this._flush = flush;
  13762. }
  13763. if (props) {
  13764. this.start(react_spring_core_esm_extends({
  13765. default: true
  13766. }, props));
  13767. }
  13768. }
  13769. get idle() {
  13770. return !this._state.asyncTo && Object.values(this.springs).every(spring => {
  13771. return spring.idle && !spring.isDelayed && !spring.isPaused;
  13772. });
  13773. }
  13774. get item() {
  13775. return this._item;
  13776. }
  13777. set item(item) {
  13778. this._item = item;
  13779. }
  13780. get() {
  13781. const values = {};
  13782. this.each((spring, key) => values[key] = spring.get());
  13783. return values;
  13784. }
  13785. set(values) {
  13786. for (const key in values) {
  13787. const value = values[key];
  13788. if (!react_spring_shared_esm_is.und(value)) {
  13789. this.springs[key].set(value);
  13790. }
  13791. }
  13792. }
  13793. update(props) {
  13794. if (props) {
  13795. this.queue.push(createUpdate(props));
  13796. }
  13797. return this;
  13798. }
  13799. start(props) {
  13800. let {
  13801. queue
  13802. } = this;
  13803. if (props) {
  13804. queue = react_spring_shared_esm_toArray(props).map(createUpdate);
  13805. } else {
  13806. this.queue = [];
  13807. }
  13808. if (this._flush) {
  13809. return this._flush(this, queue);
  13810. }
  13811. prepareKeys(this, queue);
  13812. return flushUpdateQueue(this, queue);
  13813. }
  13814. stop(arg, keys) {
  13815. if (arg !== !!arg) {
  13816. keys = arg;
  13817. }
  13818. if (keys) {
  13819. const springs = this.springs;
  13820. react_spring_shared_esm_each(react_spring_shared_esm_toArray(keys), key => springs[key].stop(!!arg));
  13821. } else {
  13822. stopAsync(this._state, this._lastAsyncId);
  13823. this.each(spring => spring.stop(!!arg));
  13824. }
  13825. return this;
  13826. }
  13827. pause(keys) {
  13828. if (react_spring_shared_esm_is.und(keys)) {
  13829. this.start({
  13830. pause: true
  13831. });
  13832. } else {
  13833. const springs = this.springs;
  13834. react_spring_shared_esm_each(react_spring_shared_esm_toArray(keys), key => springs[key].pause());
  13835. }
  13836. return this;
  13837. }
  13838. resume(keys) {
  13839. if (react_spring_shared_esm_is.und(keys)) {
  13840. this.start({
  13841. pause: false
  13842. });
  13843. } else {
  13844. const springs = this.springs;
  13845. react_spring_shared_esm_each(react_spring_shared_esm_toArray(keys), key => springs[key].resume());
  13846. }
  13847. return this;
  13848. }
  13849. each(iterator) {
  13850. eachProp(this.springs, iterator);
  13851. }
  13852. _onFrame() {
  13853. const {
  13854. onStart,
  13855. onChange,
  13856. onRest
  13857. } = this._events;
  13858. const active = this._active.size > 0;
  13859. const changed = this._changed.size > 0;
  13860. if (active && !this._started || changed && !this._started) {
  13861. this._started = true;
  13862. flush(onStart, ([onStart, result]) => {
  13863. result.value = this.get();
  13864. onStart(result, this, this._item);
  13865. });
  13866. }
  13867. const idle = !active && this._started;
  13868. const values = changed || idle && onRest.size ? this.get() : null;
  13869. if (changed && onChange.size) {
  13870. flush(onChange, ([onChange, result]) => {
  13871. result.value = values;
  13872. onChange(result, this, this._item);
  13873. });
  13874. }
  13875. if (idle) {
  13876. this._started = false;
  13877. flush(onRest, ([onRest, result]) => {
  13878. result.value = values;
  13879. onRest(result, this, this._item);
  13880. });
  13881. }
  13882. }
  13883. eventObserved(event) {
  13884. if (event.type == 'change') {
  13885. this._changed.add(event.parent);
  13886. if (!event.idle) {
  13887. this._active.add(event.parent);
  13888. }
  13889. } else if (event.type == 'idle') {
  13890. this._active.delete(event.parent);
  13891. } else return;
  13892. raf.onFrame(this._onFrame);
  13893. }
  13894. }
  13895. function flushUpdateQueue(ctrl, queue) {
  13896. return Promise.all(queue.map(props => flushUpdate(ctrl, props))).then(results => getCombinedResult(ctrl, results));
  13897. }
  13898. async function flushUpdate(ctrl, props, isLoop) {
  13899. const {
  13900. keys,
  13901. to,
  13902. from,
  13903. loop,
  13904. onRest,
  13905. onResolve
  13906. } = props;
  13907. const defaults = react_spring_shared_esm_is.obj(props.default) && props.default;
  13908. if (loop) {
  13909. props.loop = false;
  13910. }
  13911. if (to === false) props.to = null;
  13912. if (from === false) props.from = null;
  13913. const asyncTo = react_spring_shared_esm_is.arr(to) || react_spring_shared_esm_is.fun(to) ? to : undefined;
  13914. if (asyncTo) {
  13915. props.to = undefined;
  13916. props.onRest = undefined;
  13917. if (defaults) {
  13918. defaults.onRest = undefined;
  13919. }
  13920. } else {
  13921. react_spring_shared_esm_each(BATCHED_EVENTS, key => {
  13922. const handler = props[key];
  13923. if (react_spring_shared_esm_is.fun(handler)) {
  13924. const queue = ctrl['_events'][key];
  13925. props[key] = ({
  13926. finished,
  13927. cancelled
  13928. }) => {
  13929. const result = queue.get(handler);
  13930. if (result) {
  13931. if (!finished) result.finished = false;
  13932. if (cancelled) result.cancelled = true;
  13933. } else {
  13934. queue.set(handler, {
  13935. value: null,
  13936. finished: finished || false,
  13937. cancelled: cancelled || false
  13938. });
  13939. }
  13940. };
  13941. if (defaults) {
  13942. defaults[key] = props[key];
  13943. }
  13944. }
  13945. });
  13946. }
  13947. const state = ctrl['_state'];
  13948. if (props.pause === !state.paused) {
  13949. state.paused = props.pause;
  13950. flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
  13951. } else if (state.paused) {
  13952. props.pause = true;
  13953. }
  13954. const promises = (keys || Object.keys(ctrl.springs)).map(key => ctrl.springs[key].start(props));
  13955. const cancel = props.cancel === true || getDefaultProp(props, 'cancel') === true;
  13956. if (asyncTo || cancel && state.asyncId) {
  13957. promises.push(scheduleProps(++ctrl['_lastAsyncId'], {
  13958. props,
  13959. state,
  13960. actions: {
  13961. pause: noop,
  13962. resume: noop,
  13963. start(props, resolve) {
  13964. if (cancel) {
  13965. stopAsync(state, ctrl['_lastAsyncId']);
  13966. resolve(getCancelledResult(ctrl));
  13967. } else {
  13968. props.onRest = onRest;
  13969. resolve(runAsync(asyncTo, props, state, ctrl));
  13970. }
  13971. }
  13972. }
  13973. }));
  13974. }
  13975. if (state.paused) {
  13976. await new Promise(resume => {
  13977. state.resumeQueue.add(resume);
  13978. });
  13979. }
  13980. const result = getCombinedResult(ctrl, await Promise.all(promises));
  13981. if (loop && result.finished && !(isLoop && result.noop)) {
  13982. const nextProps = createLoopUpdate(props, loop, to);
  13983. if (nextProps) {
  13984. prepareKeys(ctrl, [nextProps]);
  13985. return flushUpdate(ctrl, nextProps, true);
  13986. }
  13987. }
  13988. if (onResolve) {
  13989. raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
  13990. }
  13991. return result;
  13992. }
  13993. function getSprings(ctrl, props) {
  13994. const springs = react_spring_core_esm_extends({}, ctrl.springs);
  13995. if (props) {
  13996. react_spring_shared_esm_each(react_spring_shared_esm_toArray(props), props => {
  13997. if (react_spring_shared_esm_is.und(props.keys)) {
  13998. props = createUpdate(props);
  13999. }
  14000. if (!react_spring_shared_esm_is.obj(props.to)) {
  14001. props = react_spring_core_esm_extends({}, props, {
  14002. to: undefined
  14003. });
  14004. }
  14005. prepareSprings(springs, props, key => {
  14006. return createSpring(key);
  14007. });
  14008. });
  14009. }
  14010. setSprings(ctrl, springs);
  14011. return springs;
  14012. }
  14013. function setSprings(ctrl, springs) {
  14014. eachProp(springs, (spring, key) => {
  14015. if (!ctrl.springs[key]) {
  14016. ctrl.springs[key] = spring;
  14017. addFluidObserver(spring, ctrl);
  14018. }
  14019. });
  14020. }
  14021. function createSpring(key, observer) {
  14022. const spring = new SpringValue();
  14023. spring.key = key;
  14024. if (observer) {
  14025. addFluidObserver(spring, observer);
  14026. }
  14027. return spring;
  14028. }
  14029. function prepareSprings(springs, props, create) {
  14030. if (props.keys) {
  14031. react_spring_shared_esm_each(props.keys, key => {
  14032. const spring = springs[key] || (springs[key] = create(key));
  14033. spring['_prepareNode'](props);
  14034. });
  14035. }
  14036. }
  14037. function prepareKeys(ctrl, queue) {
  14038. react_spring_shared_esm_each(queue, props => {
  14039. prepareSprings(ctrl.springs, props, key => {
  14040. return createSpring(key, ctrl);
  14041. });
  14042. });
  14043. }
  14044. function _objectWithoutPropertiesLoose(source, excluded) {
  14045. if (source == null) return {};
  14046. var target = {};
  14047. var sourceKeys = Object.keys(source);
  14048. var key, i;
  14049. for (i = 0; i < sourceKeys.length; i++) {
  14050. key = sourceKeys[i];
  14051. if (excluded.indexOf(key) >= 0) continue;
  14052. target[key] = source[key];
  14053. }
  14054. return target;
  14055. }
  14056. const _excluded$3 = ["children"];
  14057. const SpringContext = _ref => {
  14058. let {
  14059. children
  14060. } = _ref,
  14061. props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
  14062. const inherited = (0,external_React_.useContext)(ctx);
  14063. const pause = props.pause || !!inherited.pause,
  14064. immediate = props.immediate || !!inherited.immediate;
  14065. props = useMemoOne(() => ({
  14066. pause,
  14067. immediate
  14068. }), [pause, immediate]);
  14069. const {
  14070. Provider
  14071. } = ctx;
  14072. return external_React_.createElement(Provider, {
  14073. value: props
  14074. }, children);
  14075. };
  14076. const ctx = makeContext(SpringContext, {});
  14077. SpringContext.Provider = ctx.Provider;
  14078. SpringContext.Consumer = ctx.Consumer;
  14079. function makeContext(target, init) {
  14080. Object.assign(target, external_React_.createContext(init));
  14081. target.Provider._context = target;
  14082. target.Consumer._context = target;
  14083. return target;
  14084. }
  14085. const SpringRef = () => {
  14086. const current = [];
  14087. const SpringRef = function SpringRef(props) {
  14088. deprecateDirectCall();
  14089. const results = [];
  14090. react_spring_shared_esm_each(current, (ctrl, i) => {
  14091. if (react_spring_shared_esm_is.und(props)) {
  14092. results.push(ctrl.start());
  14093. } else {
  14094. const update = _getProps(props, ctrl, i);
  14095. if (update) {
  14096. results.push(ctrl.start(update));
  14097. }
  14098. }
  14099. });
  14100. return results;
  14101. };
  14102. SpringRef.current = current;
  14103. SpringRef.add = function (ctrl) {
  14104. if (!current.includes(ctrl)) {
  14105. current.push(ctrl);
  14106. }
  14107. };
  14108. SpringRef.delete = function (ctrl) {
  14109. const i = current.indexOf(ctrl);
  14110. if (~i) current.splice(i, 1);
  14111. };
  14112. SpringRef.pause = function () {
  14113. react_spring_shared_esm_each(current, ctrl => ctrl.pause(...arguments));
  14114. return this;
  14115. };
  14116. SpringRef.resume = function () {
  14117. react_spring_shared_esm_each(current, ctrl => ctrl.resume(...arguments));
  14118. return this;
  14119. };
  14120. SpringRef.set = function (values) {
  14121. react_spring_shared_esm_each(current, ctrl => ctrl.set(values));
  14122. };
  14123. SpringRef.start = function (props) {
  14124. const results = [];
  14125. react_spring_shared_esm_each(current, (ctrl, i) => {
  14126. if (react_spring_shared_esm_is.und(props)) {
  14127. results.push(ctrl.start());
  14128. } else {
  14129. const update = this._getProps(props, ctrl, i);
  14130. if (update) {
  14131. results.push(ctrl.start(update));
  14132. }
  14133. }
  14134. });
  14135. return results;
  14136. };
  14137. SpringRef.stop = function () {
  14138. react_spring_shared_esm_each(current, ctrl => ctrl.stop(...arguments));
  14139. return this;
  14140. };
  14141. SpringRef.update = function (props) {
  14142. react_spring_shared_esm_each(current, (ctrl, i) => ctrl.update(this._getProps(props, ctrl, i)));
  14143. return this;
  14144. };
  14145. const _getProps = function _getProps(arg, ctrl, index) {
  14146. return react_spring_shared_esm_is.fun(arg) ? arg(index, ctrl) : arg;
  14147. };
  14148. SpringRef._getProps = _getProps;
  14149. return SpringRef;
  14150. };
  14151. function useSprings(length, props, deps) {
  14152. const propsFn = react_spring_shared_esm_is.fun(props) && props;
  14153. if (propsFn && !deps) deps = [];
  14154. const ref = (0,external_React_.useMemo)(() => propsFn || arguments.length == 3 ? SpringRef() : void 0, []);
  14155. const layoutId = (0,external_React_.useRef)(0);
  14156. const forceUpdate = react_spring_shared_esm_useForceUpdate();
  14157. const state = (0,external_React_.useMemo)(() => ({
  14158. ctrls: [],
  14159. queue: [],
  14160. flush(ctrl, updates) {
  14161. const springs = getSprings(ctrl, updates);
  14162. const canFlushSync = layoutId.current > 0 && !state.queue.length && !Object.keys(springs).some(key => !ctrl.springs[key]);
  14163. return canFlushSync ? flushUpdateQueue(ctrl, updates) : new Promise(resolve => {
  14164. setSprings(ctrl, springs);
  14165. state.queue.push(() => {
  14166. resolve(flushUpdateQueue(ctrl, updates));
  14167. });
  14168. forceUpdate();
  14169. });
  14170. }
  14171. }), []);
  14172. const ctrls = (0,external_React_.useRef)([...state.ctrls]);
  14173. const updates = [];
  14174. const prevLength = react_spring_shared_esm_usePrev(length) || 0;
  14175. (0,external_React_.useMemo)(() => {
  14176. react_spring_shared_esm_each(ctrls.current.slice(length, prevLength), ctrl => {
  14177. detachRefs(ctrl, ref);
  14178. ctrl.stop(true);
  14179. });
  14180. ctrls.current.length = length;
  14181. declareUpdates(prevLength, length);
  14182. }, [length]);
  14183. (0,external_React_.useMemo)(() => {
  14184. declareUpdates(0, Math.min(prevLength, length));
  14185. }, deps);
  14186. function declareUpdates(startIndex, endIndex) {
  14187. for (let i = startIndex; i < endIndex; i++) {
  14188. const ctrl = ctrls.current[i] || (ctrls.current[i] = new Controller(null, state.flush));
  14189. const update = propsFn ? propsFn(i, ctrl) : props[i];
  14190. if (update) {
  14191. updates[i] = declareUpdate(update);
  14192. }
  14193. }
  14194. }
  14195. const springs = ctrls.current.map((ctrl, i) => getSprings(ctrl, updates[i]));
  14196. const context = (0,external_React_.useContext)(SpringContext);
  14197. const prevContext = react_spring_shared_esm_usePrev(context);
  14198. const hasContext = context !== prevContext && hasProps(context);
  14199. react_spring_shared_esm_useIsomorphicLayoutEffect(() => {
  14200. layoutId.current++;
  14201. state.ctrls = ctrls.current;
  14202. const {
  14203. queue
  14204. } = state;
  14205. if (queue.length) {
  14206. state.queue = [];
  14207. react_spring_shared_esm_each(queue, cb => cb());
  14208. }
  14209. react_spring_shared_esm_each(ctrls.current, (ctrl, i) => {
  14210. ref == null ? void 0 : ref.add(ctrl);
  14211. if (hasContext) {
  14212. ctrl.start({
  14213. default: context
  14214. });
  14215. }
  14216. const update = updates[i];
  14217. if (update) {
  14218. replaceRef(ctrl, update.ref);
  14219. if (ctrl.ref) {
  14220. ctrl.queue.push(update);
  14221. } else {
  14222. ctrl.start(update);
  14223. }
  14224. }
  14225. });
  14226. });
  14227. react_spring_shared_esm_useOnce(() => () => {
  14228. react_spring_shared_esm_each(state.ctrls, ctrl => ctrl.stop(true));
  14229. });
  14230. const values = springs.map(x => react_spring_core_esm_extends({}, x));
  14231. return ref ? [values, ref] : values;
  14232. }
  14233. function useSpring(props, deps) {
  14234. const isFn = react_spring_shared_esm_is.fun(props);
  14235. const [[values], ref] = useSprings(1, isFn ? props : [props], isFn ? deps || [] : deps);
  14236. return isFn || arguments.length == 2 ? [values, ref] : values;
  14237. }
  14238. const initSpringRef = () => SpringRef();
  14239. const useSpringRef = () => useState(initSpringRef)[0];
  14240. function useTrail(length, propsArg, deps) {
  14241. var _passedRef;
  14242. const propsFn = is.fun(propsArg) && propsArg;
  14243. if (propsFn && !deps) deps = [];
  14244. let reverse = true;
  14245. let passedRef = undefined;
  14246. const result = useSprings(length, (i, ctrl) => {
  14247. const props = propsFn ? propsFn(i, ctrl) : propsArg;
  14248. passedRef = props.ref;
  14249. reverse = reverse && props.reverse;
  14250. return props;
  14251. }, deps || [{}]);
  14252. const ref = (_passedRef = passedRef) != null ? _passedRef : result[1];
  14253. useIsomorphicLayoutEffect(() => {
  14254. each(ref.current, (ctrl, i) => {
  14255. const parent = ref.current[i + (reverse ? 1 : -1)];
  14256. if (parent) {
  14257. ctrl.start({
  14258. to: parent.springs
  14259. });
  14260. } else {
  14261. ctrl.start();
  14262. }
  14263. });
  14264. }, deps);
  14265. if (propsFn || arguments.length == 3) {
  14266. ref['_getProps'] = (propsArg, ctrl, i) => {
  14267. const props = is.fun(propsArg) ? propsArg(i, ctrl) : propsArg;
  14268. if (props) {
  14269. const parent = ref.current[i + (props.reverse ? 1 : -1)];
  14270. if (parent) props.to = parent.springs;
  14271. return props;
  14272. }
  14273. };
  14274. return result;
  14275. }
  14276. ref['start'] = propsArg => {
  14277. const results = [];
  14278. each(ref.current, (ctrl, i) => {
  14279. const props = is.fun(propsArg) ? propsArg(i, ctrl) : propsArg;
  14280. const parent = ref.current[i + (reverse ? 1 : -1)];
  14281. if (parent) {
  14282. results.push(ctrl.start(react_spring_core_esm_extends({}, props, {
  14283. to: parent.springs
  14284. })));
  14285. } else {
  14286. results.push(ctrl.start(react_spring_core_esm_extends({}, props)));
  14287. }
  14288. });
  14289. return results;
  14290. };
  14291. return result[0];
  14292. }
  14293. let TransitionPhase;
  14294. (function (TransitionPhase) {
  14295. TransitionPhase["MOUNT"] = "mount";
  14296. TransitionPhase["ENTER"] = "enter";
  14297. TransitionPhase["UPDATE"] = "update";
  14298. TransitionPhase["LEAVE"] = "leave";
  14299. })(TransitionPhase || (TransitionPhase = {}));
  14300. function useTransition(data, props, deps) {
  14301. const propsFn = is.fun(props) && props;
  14302. const {
  14303. reset,
  14304. sort,
  14305. trail = 0,
  14306. expires = true,
  14307. exitBeforeEnter = false,
  14308. onDestroyed,
  14309. ref: propsRef,
  14310. config: propsConfig
  14311. } = propsFn ? propsFn() : props;
  14312. const ref = useMemo(() => propsFn || arguments.length == 3 ? SpringRef() : void 0, []);
  14313. const items = toArray(data);
  14314. const transitions = [];
  14315. const usedTransitions = useRef(null);
  14316. const prevTransitions = reset ? null : usedTransitions.current;
  14317. useIsomorphicLayoutEffect(() => {
  14318. usedTransitions.current = transitions;
  14319. });
  14320. useOnce(() => {
  14321. each(transitions, t => {
  14322. ref == null ? void 0 : ref.add(t.ctrl);
  14323. t.ctrl.ref = ref;
  14324. });
  14325. return () => {
  14326. each(usedTransitions.current, t => {
  14327. if (t.expired) {
  14328. clearTimeout(t.expirationId);
  14329. }
  14330. detachRefs(t.ctrl, ref);
  14331. t.ctrl.stop(true);
  14332. });
  14333. };
  14334. });
  14335. const keys = getKeys(items, propsFn ? propsFn() : props, prevTransitions);
  14336. const expired = reset && usedTransitions.current || [];
  14337. useIsomorphicLayoutEffect(() => each(expired, ({
  14338. ctrl,
  14339. item,
  14340. key
  14341. }) => {
  14342. detachRefs(ctrl, ref);
  14343. callProp(onDestroyed, item, key);
  14344. }));
  14345. const reused = [];
  14346. if (prevTransitions) each(prevTransitions, (t, i) => {
  14347. if (t.expired) {
  14348. clearTimeout(t.expirationId);
  14349. expired.push(t);
  14350. } else {
  14351. i = reused[i] = keys.indexOf(t.key);
  14352. if (~i) transitions[i] = t;
  14353. }
  14354. });
  14355. each(items, (item, i) => {
  14356. if (!transitions[i]) {
  14357. transitions[i] = {
  14358. key: keys[i],
  14359. item,
  14360. phase: TransitionPhase.MOUNT,
  14361. ctrl: new Controller()
  14362. };
  14363. transitions[i].ctrl.item = item;
  14364. }
  14365. });
  14366. if (reused.length) {
  14367. let i = -1;
  14368. const {
  14369. leave
  14370. } = propsFn ? propsFn() : props;
  14371. each(reused, (keyIndex, prevIndex) => {
  14372. const t = prevTransitions[prevIndex];
  14373. if (~keyIndex) {
  14374. i = transitions.indexOf(t);
  14375. transitions[i] = react_spring_core_esm_extends({}, t, {
  14376. item: items[keyIndex]
  14377. });
  14378. } else if (leave) {
  14379. transitions.splice(++i, 0, t);
  14380. }
  14381. });
  14382. }
  14383. if (is.fun(sort)) {
  14384. transitions.sort((a, b) => sort(a.item, b.item));
  14385. }
  14386. let delay = -trail;
  14387. const forceUpdate = useForceUpdate();
  14388. const defaultProps = getDefaultProps(props);
  14389. const changes = new Map();
  14390. const exitingTransitions = useRef(new Map());
  14391. const forceChange = useRef(false);
  14392. each(transitions, (t, i) => {
  14393. const key = t.key;
  14394. const prevPhase = t.phase;
  14395. const p = propsFn ? propsFn() : props;
  14396. let to;
  14397. let phase;
  14398. let propsDelay = callProp(p.delay || 0, key);
  14399. if (prevPhase == TransitionPhase.MOUNT) {
  14400. to = p.enter;
  14401. phase = TransitionPhase.ENTER;
  14402. } else {
  14403. const isLeave = keys.indexOf(key) < 0;
  14404. if (prevPhase != TransitionPhase.LEAVE) {
  14405. if (isLeave) {
  14406. to = p.leave;
  14407. phase = TransitionPhase.LEAVE;
  14408. } else if (to = p.update) {
  14409. phase = TransitionPhase.UPDATE;
  14410. } else return;
  14411. } else if (!isLeave) {
  14412. to = p.enter;
  14413. phase = TransitionPhase.ENTER;
  14414. } else return;
  14415. }
  14416. to = callProp(to, t.item, i);
  14417. to = is.obj(to) ? inferTo(to) : {
  14418. to
  14419. };
  14420. if (!to.config) {
  14421. const config = propsConfig || defaultProps.config;
  14422. to.config = callProp(config, t.item, i, phase);
  14423. }
  14424. delay += trail;
  14425. const payload = react_spring_core_esm_extends({}, defaultProps, {
  14426. delay: propsDelay + delay,
  14427. ref: propsRef,
  14428. immediate: p.immediate,
  14429. reset: false
  14430. }, to);
  14431. if (phase == TransitionPhase.ENTER && is.und(payload.from)) {
  14432. const _p = propsFn ? propsFn() : props;
  14433. const from = is.und(_p.initial) || prevTransitions ? _p.from : _p.initial;
  14434. payload.from = callProp(from, t.item, i);
  14435. }
  14436. const {
  14437. onResolve
  14438. } = payload;
  14439. payload.onResolve = result => {
  14440. callProp(onResolve, result);
  14441. const transitions = usedTransitions.current;
  14442. const t = transitions.find(t => t.key === key);
  14443. if (!t) return;
  14444. if (result.cancelled && t.phase != TransitionPhase.UPDATE) {
  14445. return;
  14446. }
  14447. if (t.ctrl.idle) {
  14448. const idle = transitions.every(t => t.ctrl.idle);
  14449. if (t.phase == TransitionPhase.LEAVE) {
  14450. const expiry = callProp(expires, t.item);
  14451. if (expiry !== false) {
  14452. const expiryMs = expiry === true ? 0 : expiry;
  14453. t.expired = true;
  14454. if (!idle && expiryMs > 0) {
  14455. if (expiryMs <= 0x7fffffff) t.expirationId = setTimeout(forceUpdate, expiryMs);
  14456. return;
  14457. }
  14458. }
  14459. }
  14460. if (idle && transitions.some(t => t.expired)) {
  14461. exitingTransitions.current.delete(t);
  14462. if (exitBeforeEnter) {
  14463. forceChange.current = true;
  14464. }
  14465. forceUpdate();
  14466. }
  14467. }
  14468. };
  14469. const springs = getSprings(t.ctrl, payload);
  14470. if (phase === TransitionPhase.LEAVE && exitBeforeEnter) {
  14471. exitingTransitions.current.set(t, {
  14472. phase,
  14473. springs,
  14474. payload
  14475. });
  14476. } else {
  14477. changes.set(t, {
  14478. phase,
  14479. springs,
  14480. payload
  14481. });
  14482. }
  14483. });
  14484. const context = useContext(SpringContext);
  14485. const prevContext = usePrev(context);
  14486. const hasContext = context !== prevContext && hasProps(context);
  14487. useIsomorphicLayoutEffect(() => {
  14488. if (hasContext) {
  14489. each(transitions, t => {
  14490. t.ctrl.start({
  14491. default: context
  14492. });
  14493. });
  14494. }
  14495. }, [context]);
  14496. each(changes, (_, t) => {
  14497. if (exitingTransitions.current.size) {
  14498. const ind = transitions.findIndex(state => state.key === t.key);
  14499. transitions.splice(ind, 1);
  14500. }
  14501. });
  14502. useIsomorphicLayoutEffect(() => {
  14503. each(exitingTransitions.current.size ? exitingTransitions.current : changes, ({
  14504. phase,
  14505. payload
  14506. }, t) => {
  14507. const {
  14508. ctrl
  14509. } = t;
  14510. t.phase = phase;
  14511. ref == null ? void 0 : ref.add(ctrl);
  14512. if (hasContext && phase == TransitionPhase.ENTER) {
  14513. ctrl.start({
  14514. default: context
  14515. });
  14516. }
  14517. if (payload) {
  14518. replaceRef(ctrl, payload.ref);
  14519. if ((ctrl.ref || ref) && !forceChange.current) {
  14520. ctrl.update(payload);
  14521. } else {
  14522. ctrl.start(payload);
  14523. if (forceChange.current) {
  14524. forceChange.current = false;
  14525. }
  14526. }
  14527. }
  14528. });
  14529. }, reset ? void 0 : deps);
  14530. const renderTransitions = render => React.createElement(React.Fragment, null, transitions.map((t, i) => {
  14531. const {
  14532. springs
  14533. } = changes.get(t) || t.ctrl;
  14534. const elem = render(react_spring_core_esm_extends({}, springs), t.item, t, i);
  14535. return elem && elem.type ? React.createElement(elem.type, react_spring_core_esm_extends({}, elem.props, {
  14536. key: is.str(t.key) || is.num(t.key) ? t.key : t.ctrl.id,
  14537. ref: elem.ref
  14538. })) : elem;
  14539. }));
  14540. return ref ? [renderTransitions, ref] : renderTransitions;
  14541. }
  14542. let nextKey = 1;
  14543. function getKeys(items, {
  14544. key,
  14545. keys = key
  14546. }, prevTransitions) {
  14547. if (keys === null) {
  14548. const reused = new Set();
  14549. return items.map(item => {
  14550. const t = prevTransitions && prevTransitions.find(t => t.item === item && t.phase !== TransitionPhase.LEAVE && !reused.has(t));
  14551. if (t) {
  14552. reused.add(t);
  14553. return t.key;
  14554. }
  14555. return nextKey++;
  14556. });
  14557. }
  14558. return is.und(keys) ? items : is.fun(keys) ? items.map(keys) : toArray(keys);
  14559. }
  14560. const _excluded$2 = (/* unused pure expression or super */ null && (["children"]));
  14561. function Spring(_ref) {
  14562. let {
  14563. children
  14564. } = _ref,
  14565. props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
  14566. return children(useSpring(props));
  14567. }
  14568. const _excluded$1 = (/* unused pure expression or super */ null && (["items", "children"]));
  14569. function Trail(_ref) {
  14570. let {
  14571. items,
  14572. children
  14573. } = _ref,
  14574. props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
  14575. const trails = useTrail(items.length, props);
  14576. return items.map((item, index) => {
  14577. const result = children(item, index);
  14578. return is.fun(result) ? result(trails[index]) : result;
  14579. });
  14580. }
  14581. const _excluded = (/* unused pure expression or super */ null && (["items", "children"]));
  14582. function Transition(_ref) {
  14583. let {
  14584. items,
  14585. children
  14586. } = _ref,
  14587. props = _objectWithoutPropertiesLoose(_ref, _excluded);
  14588. return useTransition(items, props)(children);
  14589. }
  14590. class Interpolation extends FrameValue {
  14591. constructor(source, args) {
  14592. super();
  14593. this.key = void 0;
  14594. this.idle = true;
  14595. this.calc = void 0;
  14596. this._active = new Set();
  14597. this.source = source;
  14598. this.calc = createInterpolator(...args);
  14599. const value = this._get();
  14600. const nodeType = getAnimatedType(value);
  14601. setAnimated(this, nodeType.create(value));
  14602. }
  14603. advance(_dt) {
  14604. const value = this._get();
  14605. const oldValue = this.get();
  14606. if (!isEqual(value, oldValue)) {
  14607. getAnimated(this).setValue(value);
  14608. this._onChange(value, this.idle);
  14609. }
  14610. if (!this.idle && checkIdle(this._active)) {
  14611. becomeIdle(this);
  14612. }
  14613. }
  14614. _get() {
  14615. const inputs = react_spring_shared_esm_is.arr(this.source) ? this.source.map(getFluidValue) : react_spring_shared_esm_toArray(getFluidValue(this.source));
  14616. return this.calc(...inputs);
  14617. }
  14618. _start() {
  14619. if (this.idle && !checkIdle(this._active)) {
  14620. this.idle = false;
  14621. react_spring_shared_esm_each(getPayload(this), node => {
  14622. node.done = false;
  14623. });
  14624. if (globals.skipAnimation) {
  14625. raf.batchedUpdates(() => this.advance());
  14626. becomeIdle(this);
  14627. } else {
  14628. frameLoop.start(this);
  14629. }
  14630. }
  14631. }
  14632. _attach() {
  14633. let priority = 1;
  14634. react_spring_shared_esm_each(react_spring_shared_esm_toArray(this.source), source => {
  14635. if (hasFluidValue(source)) {
  14636. addFluidObserver(source, this);
  14637. }
  14638. if (isFrameValue(source)) {
  14639. if (!source.idle) {
  14640. this._active.add(source);
  14641. }
  14642. priority = Math.max(priority, source.priority + 1);
  14643. }
  14644. });
  14645. this.priority = priority;
  14646. this._start();
  14647. }
  14648. _detach() {
  14649. react_spring_shared_esm_each(react_spring_shared_esm_toArray(this.source), source => {
  14650. if (hasFluidValue(source)) {
  14651. removeFluidObserver(source, this);
  14652. }
  14653. });
  14654. this._active.clear();
  14655. becomeIdle(this);
  14656. }
  14657. eventObserved(event) {
  14658. if (event.type == 'change') {
  14659. if (event.idle) {
  14660. this.advance();
  14661. } else {
  14662. this._active.add(event.parent);
  14663. this._start();
  14664. }
  14665. } else if (event.type == 'idle') {
  14666. this._active.delete(event.parent);
  14667. } else if (event.type == 'priority') {
  14668. this.priority = react_spring_shared_esm_toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0);
  14669. }
  14670. }
  14671. }
  14672. function isIdle(source) {
  14673. return source.idle !== false;
  14674. }
  14675. function checkIdle(active) {
  14676. return !active.size || Array.from(active).every(isIdle);
  14677. }
  14678. function becomeIdle(self) {
  14679. if (!self.idle) {
  14680. self.idle = true;
  14681. react_spring_shared_esm_each(getPayload(self), node => {
  14682. node.done = true;
  14683. });
  14684. callFluidObservers(self, {
  14685. type: 'idle',
  14686. parent: self
  14687. });
  14688. }
  14689. }
  14690. const react_spring_core_esm_to = (source, ...args) => new Interpolation(source, args);
  14691. const react_spring_core_esm_interpolate = (source, ...args) => (deprecateInterpolate(), new Interpolation(source, args));
  14692. globals.assign({
  14693. createStringInterpolator: createStringInterpolator,
  14694. to: (source, args) => new Interpolation(source, args)
  14695. });
  14696. const react_spring_core_esm_update = frameLoop.advance;
  14697. ;// CONCATENATED MODULE: external "ReactDOM"
  14698. var external_ReactDOM_namespaceObject = window["ReactDOM"];
  14699. ;// CONCATENATED MODULE: ./node_modules/@react-spring/web/dist/react-spring-web.esm.js
  14700. function react_spring_web_esm_objectWithoutPropertiesLoose(source, excluded) {
  14701. if (source == null) return {};
  14702. var target = {};
  14703. var sourceKeys = Object.keys(source);
  14704. var key, i;
  14705. for (i = 0; i < sourceKeys.length; i++) {
  14706. key = sourceKeys[i];
  14707. if (excluded.indexOf(key) >= 0) continue;
  14708. target[key] = source[key];
  14709. }
  14710. return target;
  14711. }
  14712. const react_spring_web_esm_excluded$2 = ["style", "children", "scrollTop", "scrollLeft"];
  14713. const isCustomPropRE = /^--/;
  14714. function dangerousStyleValue(name, value) {
  14715. if (value == null || typeof value === 'boolean' || value === '') return '';
  14716. if (typeof value === 'number' && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px';
  14717. return ('' + value).trim();
  14718. }
  14719. const attributeCache = {};
  14720. function applyAnimatedValues(instance, props) {
  14721. if (!instance.nodeType || !instance.setAttribute) {
  14722. return false;
  14723. }
  14724. const isFilterElement = instance.nodeName === 'filter' || instance.parentNode && instance.parentNode.nodeName === 'filter';
  14725. const _ref = props,
  14726. {
  14727. style,
  14728. children,
  14729. scrollTop,
  14730. scrollLeft
  14731. } = _ref,
  14732. attributes = react_spring_web_esm_objectWithoutPropertiesLoose(_ref, react_spring_web_esm_excluded$2);
  14733. const values = Object.values(attributes);
  14734. const names = Object.keys(attributes).map(name => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, n => '-' + n.toLowerCase())));
  14735. if (children !== void 0) {
  14736. instance.textContent = children;
  14737. }
  14738. for (let name in style) {
  14739. if (style.hasOwnProperty(name)) {
  14740. const value = dangerousStyleValue(name, style[name]);
  14741. if (isCustomPropRE.test(name)) {
  14742. instance.style.setProperty(name, value);
  14743. } else {
  14744. instance.style[name] = value;
  14745. }
  14746. }
  14747. }
  14748. names.forEach((name, i) => {
  14749. instance.setAttribute(name, values[i]);
  14750. });
  14751. if (scrollTop !== void 0) {
  14752. instance.scrollTop = scrollTop;
  14753. }
  14754. if (scrollLeft !== void 0) {
  14755. instance.scrollLeft = scrollLeft;
  14756. }
  14757. }
  14758. let isUnitlessNumber = {
  14759. animationIterationCount: true,
  14760. borderImageOutset: true,
  14761. borderImageSlice: true,
  14762. borderImageWidth: true,
  14763. boxFlex: true,
  14764. boxFlexGroup: true,
  14765. boxOrdinalGroup: true,
  14766. columnCount: true,
  14767. columns: true,
  14768. flex: true,
  14769. flexGrow: true,
  14770. flexPositive: true,
  14771. flexShrink: true,
  14772. flexNegative: true,
  14773. flexOrder: true,
  14774. gridRow: true,
  14775. gridRowEnd: true,
  14776. gridRowSpan: true,
  14777. gridRowStart: true,
  14778. gridColumn: true,
  14779. gridColumnEnd: true,
  14780. gridColumnSpan: true,
  14781. gridColumnStart: true,
  14782. fontWeight: true,
  14783. lineClamp: true,
  14784. lineHeight: true,
  14785. opacity: true,
  14786. order: true,
  14787. orphans: true,
  14788. tabSize: true,
  14789. widows: true,
  14790. zIndex: true,
  14791. zoom: true,
  14792. fillOpacity: true,
  14793. floodOpacity: true,
  14794. stopOpacity: true,
  14795. strokeDasharray: true,
  14796. strokeDashoffset: true,
  14797. strokeMiterlimit: true,
  14798. strokeOpacity: true,
  14799. strokeWidth: true
  14800. };
  14801. const prefixKey = (prefix, key) => prefix + key.charAt(0).toUpperCase() + key.substring(1);
  14802. const prefixes = ['Webkit', 'Ms', 'Moz', 'O'];
  14803. isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
  14804. prefixes.forEach(prefix => acc[prefixKey(prefix, prop)] = acc[prop]);
  14805. return acc;
  14806. }, isUnitlessNumber);
  14807. const react_spring_web_esm_excluded$1 = ["x", "y", "z"];
  14808. const domTransforms = /^(matrix|translate|scale|rotate|skew)/;
  14809. const pxTransforms = /^(translate)/;
  14810. const degTransforms = /^(rotate|skew)/;
  14811. const addUnit = (value, unit) => react_spring_shared_esm_is.num(value) && value !== 0 ? value + unit : value;
  14812. 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;
  14813. class AnimatedStyle extends AnimatedObject {
  14814. constructor(_ref) {
  14815. let {
  14816. x,
  14817. y,
  14818. z
  14819. } = _ref,
  14820. style = react_spring_web_esm_objectWithoutPropertiesLoose(_ref, react_spring_web_esm_excluded$1);
  14821. const inputs = [];
  14822. const transforms = [];
  14823. if (x || y || z) {
  14824. inputs.push([x || 0, y || 0, z || 0]);
  14825. transforms.push(xyz => [`translate3d(${xyz.map(v => addUnit(v, 'px')).join(',')})`, isValueIdentity(xyz, 0)]);
  14826. }
  14827. eachProp(style, (value, key) => {
  14828. if (key === 'transform') {
  14829. inputs.push([value || '']);
  14830. transforms.push(transform => [transform, transform === '']);
  14831. } else if (domTransforms.test(key)) {
  14832. delete style[key];
  14833. if (react_spring_shared_esm_is.und(value)) return;
  14834. const unit = pxTransforms.test(key) ? 'px' : degTransforms.test(key) ? 'deg' : '';
  14835. inputs.push(react_spring_shared_esm_toArray(value));
  14836. 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)]);
  14837. }
  14838. });
  14839. if (inputs.length) {
  14840. style.transform = new FluidTransform(inputs, transforms);
  14841. }
  14842. super(style);
  14843. }
  14844. }
  14845. class FluidTransform extends FluidValue {
  14846. constructor(inputs, transforms) {
  14847. super();
  14848. this._value = null;
  14849. this.inputs = inputs;
  14850. this.transforms = transforms;
  14851. }
  14852. get() {
  14853. return this._value || (this._value = this._get());
  14854. }
  14855. _get() {
  14856. let transform = '';
  14857. let identity = true;
  14858. react_spring_shared_esm_each(this.inputs, (input, i) => {
  14859. const arg1 = getFluidValue(input[0]);
  14860. const [t, id] = this.transforms[i](react_spring_shared_esm_is.arr(arg1) ? arg1 : input.map(getFluidValue));
  14861. transform += ' ' + t;
  14862. identity = identity && id;
  14863. });
  14864. return identity ? 'none' : transform;
  14865. }
  14866. observerAdded(count) {
  14867. if (count == 1) react_spring_shared_esm_each(this.inputs, input => react_spring_shared_esm_each(input, value => hasFluidValue(value) && addFluidObserver(value, this)));
  14868. }
  14869. observerRemoved(count) {
  14870. if (count == 0) react_spring_shared_esm_each(this.inputs, input => react_spring_shared_esm_each(input, value => hasFluidValue(value) && removeFluidObserver(value, this)));
  14871. }
  14872. eventObserved(event) {
  14873. if (event.type == 'change') {
  14874. this._value = null;
  14875. }
  14876. callFluidObservers(this, event);
  14877. }
  14878. }
  14879. 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'];
  14880. const react_spring_web_esm_excluded = ["scrollTop", "scrollLeft"];
  14881. globals.assign({
  14882. batchedUpdates: external_ReactDOM_namespaceObject.unstable_batchedUpdates,
  14883. createStringInterpolator: createStringInterpolator,
  14884. colors: colors
  14885. });
  14886. const host = createHost(primitives, {
  14887. applyAnimatedValues,
  14888. createAnimatedStyle: style => new AnimatedStyle(style),
  14889. getComponentProps: _ref => {
  14890. let props = react_spring_web_esm_objectWithoutPropertiesLoose(_ref, react_spring_web_esm_excluded);
  14891. return props;
  14892. }
  14893. });
  14894. const animated = host.animated;
  14895. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-moving-animation/index.js
  14896. /**
  14897. * External dependencies
  14898. */
  14899. /**
  14900. * WordPress dependencies
  14901. */
  14902. /**
  14903. * Simple reducer used to increment a counter.
  14904. *
  14905. * @param {number} state Previous counter value.
  14906. * @return {number} New state value.
  14907. */
  14908. const counterReducer = state => state + 1;
  14909. const getAbsolutePosition = element => {
  14910. return {
  14911. top: element.offsetTop,
  14912. left: element.offsetLeft
  14913. };
  14914. };
  14915. /**
  14916. * Hook used to compute the styles required to move a div into a new position.
  14917. *
  14918. * The way this animation works is the following:
  14919. * - It first renders the element as if there was no animation.
  14920. * - It takes a snapshot of the position of the block to use it
  14921. * as a destination point for the animation.
  14922. * - It restores the element to the previous position using a CSS transform
  14923. * - It uses the "resetAnimation" flag to reset the animation
  14924. * from the beginning in order to animate to the new destination point.
  14925. *
  14926. * @param {Object} $1 Options
  14927. * @param {boolean} $1.isSelected Whether it's the current block or not.
  14928. * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.
  14929. * @param {boolean} $1.enableAnimation Enable/Disable animation.
  14930. * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.
  14931. */
  14932. function useMovingAnimation(_ref) {
  14933. let {
  14934. isSelected,
  14935. adjustScrolling,
  14936. enableAnimation,
  14937. triggerAnimationOnChange
  14938. } = _ref;
  14939. const ref = (0,external_wp_element_namespaceObject.useRef)();
  14940. const prefersReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)() || !enableAnimation;
  14941. const [triggeredAnimation, triggerAnimation] = (0,external_wp_element_namespaceObject.useReducer)(counterReducer, 0);
  14942. const [finishedAnimation, endAnimation] = (0,external_wp_element_namespaceObject.useReducer)(counterReducer, 0);
  14943. const [transform, setTransform] = (0,external_wp_element_namespaceObject.useState)({
  14944. x: 0,
  14945. y: 0
  14946. });
  14947. 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
  14948. // return a function to maintain that position by scrolling.
  14949. const preserveScrollPosition = (0,external_wp_element_namespaceObject.useMemo)(() => {
  14950. if (!adjustScrolling || !ref.current) {
  14951. return () => {};
  14952. }
  14953. const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(ref.current);
  14954. if (!scrollContainer) {
  14955. return () => {};
  14956. }
  14957. const prevRect = ref.current.getBoundingClientRect();
  14958. return () => {
  14959. const blockRect = ref.current.getBoundingClientRect();
  14960. const diff = blockRect.top - prevRect.top;
  14961. if (diff) {
  14962. scrollContainer.scrollTop += diff;
  14963. }
  14964. };
  14965. }, [triggerAnimationOnChange, adjustScrolling]);
  14966. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  14967. if (triggeredAnimation) {
  14968. endAnimation();
  14969. }
  14970. }, [triggeredAnimation]);
  14971. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  14972. if (!previous) {
  14973. return;
  14974. }
  14975. if (prefersReducedMotion) {
  14976. // If the animation is disabled and the scroll needs to be adjusted,
  14977. // just move directly to the final scroll position.
  14978. preserveScrollPosition();
  14979. return;
  14980. }
  14981. ref.current.style.transform = '';
  14982. const destination = getAbsolutePosition(ref.current);
  14983. triggerAnimation();
  14984. setTransform({
  14985. x: Math.round(previous.left - destination.left),
  14986. y: Math.round(previous.top - destination.top)
  14987. });
  14988. }, [triggerAnimationOnChange]); // Only called when either the x or y value changes.
  14989. function onFrameChange(_ref2) {
  14990. let {
  14991. x,
  14992. y
  14993. } = _ref2;
  14994. if (!ref.current) {
  14995. return;
  14996. }
  14997. const isMoving = x === 0 && y === 0;
  14998. ref.current.style.transformOrigin = isMoving ? '' : 'center';
  14999. ref.current.style.transform = isMoving ? '' : `translate3d(${x}px,${y}px,0)`;
  15000. ref.current.style.zIndex = !isSelected || isMoving ? '' : '1';
  15001. preserveScrollPosition();
  15002. } // Called for every frame computed by useSpring.
  15003. function onChange(_ref3) {
  15004. let {
  15005. value
  15006. } = _ref3;
  15007. let {
  15008. x,
  15009. y
  15010. } = value;
  15011. x = Math.round(x);
  15012. y = Math.round(y);
  15013. if (x !== onChange.x || y !== onChange.y) {
  15014. onFrameChange({
  15015. x,
  15016. y
  15017. });
  15018. onChange.x = x;
  15019. onChange.y = y;
  15020. }
  15021. }
  15022. onChange.x = 0;
  15023. onChange.y = 0;
  15024. useSpring({
  15025. from: {
  15026. x: transform.x,
  15027. y: transform.y
  15028. },
  15029. to: {
  15030. x: 0,
  15031. y: 0
  15032. },
  15033. reset: triggeredAnimation !== finishedAnimation,
  15034. config: {
  15035. mass: 5,
  15036. tension: 2000,
  15037. friction: 200
  15038. },
  15039. immediate: prefersReducedMotion,
  15040. onChange
  15041. });
  15042. return ref;
  15043. }
  15044. /* harmony default export */ var use_moving_animation = (useMovingAnimation);
  15045. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/dom.js
  15046. const BLOCK_SELECTOR = '.block-editor-block-list__block';
  15047. const APPENDER_SELECTOR = '.block-list-appender';
  15048. const BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender';
  15049. /**
  15050. * Returns true if two elements are contained within the same block.
  15051. *
  15052. * @param {Element} a First element.
  15053. * @param {Element} b Second element.
  15054. *
  15055. * @return {boolean} Whether elements are in the same block.
  15056. */
  15057. function isInSameBlock(a, b) {
  15058. return a.closest(BLOCK_SELECTOR) === b.closest(BLOCK_SELECTOR);
  15059. }
  15060. /**
  15061. * Returns true if an element is considered part of the block and not its inner
  15062. * blocks or appender.
  15063. *
  15064. * @param {Element} blockElement Block container element.
  15065. * @param {Element} element Element.
  15066. *
  15067. * @return {boolean} Whether an element is considered part of the block and not
  15068. * its inner blocks or appender.
  15069. */
  15070. function isInsideRootBlock(blockElement, element) {
  15071. const parentBlock = element.closest([BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS].join(','));
  15072. return parentBlock === blockElement;
  15073. }
  15074. /**
  15075. * Finds the block client ID given any DOM node inside the block.
  15076. *
  15077. * @param {Node?} node DOM node.
  15078. *
  15079. * @return {string|undefined} Client ID or undefined if the node is not part of
  15080. * a block.
  15081. */
  15082. function getBlockClientId(node) {
  15083. while (node && node.nodeType !== node.ELEMENT_NODE) {
  15084. node = node.parentNode;
  15085. }
  15086. if (!node) {
  15087. return;
  15088. }
  15089. const elementNode =
  15090. /** @type {Element} */
  15091. node;
  15092. const blockNode = elementNode.closest(BLOCK_SELECTOR);
  15093. if (!blockNode) {
  15094. return;
  15095. }
  15096. return blockNode.id.slice('block-'.length);
  15097. }
  15098. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-focus-first-element.js
  15099. /**
  15100. * External dependencies
  15101. */
  15102. /**
  15103. * WordPress dependencies
  15104. */
  15105. /**
  15106. * Internal dependencies
  15107. */
  15108. /** @typedef {import('@wordpress/element').RefObject} RefObject */
  15109. /**
  15110. * Returns the initial position if the block needs to be focussed, `undefined`
  15111. * otherwise. The initial position is either 0 (start) or -1 (end).
  15112. *
  15113. * @param {string} clientId Block client ID.
  15114. *
  15115. * @return {number} The initial position, either 0 (start) or -1 (end).
  15116. */
  15117. function useInitialPosition(clientId) {
  15118. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  15119. const {
  15120. getSelectedBlocksInitialCaretPosition,
  15121. isNavigationMode,
  15122. isBlockSelected
  15123. } = select(store);
  15124. if (!isBlockSelected(clientId)) {
  15125. return;
  15126. }
  15127. if (isNavigationMode()) {
  15128. return;
  15129. } // If there's no initial position, return 0 to focus the start.
  15130. return getSelectedBlocksInitialCaretPosition();
  15131. }, [clientId]);
  15132. }
  15133. /**
  15134. * Transitions focus to the block or inner tabbable when the block becomes
  15135. * selected and an initial position is set.
  15136. *
  15137. * @param {string} clientId Block client ID.
  15138. *
  15139. * @return {RefObject} React ref with the block element.
  15140. */
  15141. function useFocusFirstElement(clientId) {
  15142. const ref = (0,external_wp_element_namespaceObject.useRef)();
  15143. const initialPosition = useInitialPosition(clientId);
  15144. const {
  15145. isBlockSelected,
  15146. isMultiSelecting
  15147. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  15148. (0,external_wp_element_namespaceObject.useEffect)(() => {
  15149. // Check if the block is still selected at the time this effect runs.
  15150. if (!isBlockSelected(clientId) || isMultiSelecting()) {
  15151. return;
  15152. }
  15153. if (initialPosition === undefined || initialPosition === null) {
  15154. return;
  15155. }
  15156. if (!ref.current) {
  15157. return;
  15158. }
  15159. const {
  15160. ownerDocument
  15161. } = ref.current; // Do not focus the block if it already contains the active element.
  15162. if (ref.current.contains(ownerDocument.activeElement)) {
  15163. return;
  15164. } // Find all tabbables within node.
  15165. 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
  15166. // tabbables.
  15167. const isReverse = -1 === initialPosition;
  15168. const target = (isReverse ? external_lodash_namespaceObject.last : external_lodash_namespaceObject.first)(textInputs) || ref.current;
  15169. if (!isInsideRootBlock(ref.current, target)) {
  15170. ref.current.focus();
  15171. return;
  15172. } // Check to see if element is focussable before a generic caret insert.
  15173. if (!ref.current.getAttribute('contenteditable')) {
  15174. 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.
  15175. if (focusElement && isInsideRootBlock(ref.current, focusElement) && (0,external_wp_dom_namespaceObject.isFormElement)(focusElement)) {
  15176. focusElement.focus();
  15177. return;
  15178. }
  15179. }
  15180. (0,external_wp_dom_namespaceObject.placeCaretAtHorizontalEdge)(target, isReverse);
  15181. }, [initialPosition, clientId]);
  15182. return ref;
  15183. }
  15184. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-is-hovered.js
  15185. /**
  15186. * WordPress dependencies
  15187. */
  15188. /**
  15189. * Internal dependencies
  15190. */
  15191. function listener(event) {
  15192. if (event.defaultPrevented) {
  15193. return;
  15194. }
  15195. const action = event.type === 'mouseover' ? 'add' : 'remove';
  15196. event.preventDefault();
  15197. event.currentTarget.classList[action]('is-hovered');
  15198. }
  15199. /**
  15200. * Adds `is-hovered` class when the block is hovered and in navigation or
  15201. * outline mode.
  15202. */
  15203. function useIsHovered() {
  15204. const isEnabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
  15205. const {
  15206. isNavigationMode,
  15207. getSettings
  15208. } = select(store);
  15209. return isNavigationMode() || getSettings().outlineMode;
  15210. }, []);
  15211. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  15212. if (isEnabled) {
  15213. node.addEventListener('mouseout', listener);
  15214. node.addEventListener('mouseover', listener);
  15215. return () => {
  15216. node.removeEventListener('mouseout', listener);
  15217. node.removeEventListener('mouseover', listener); // Remove class in case it lingers.
  15218. node.classList.remove('is-hovered');
  15219. };
  15220. }
  15221. }, [isEnabled]);
  15222. }
  15223. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-class-names.js
  15224. /**
  15225. * External dependencies
  15226. */
  15227. /**
  15228. * WordPress dependencies
  15229. */
  15230. /**
  15231. * Internal dependencies
  15232. */
  15233. /**
  15234. * Returns the class names used for the different states of the block.
  15235. *
  15236. * @param {string} clientId The block client ID.
  15237. *
  15238. * @return {string} The class names.
  15239. */
  15240. function useBlockClassNames(clientId) {
  15241. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  15242. const {
  15243. isBlockBeingDragged,
  15244. isBlockHighlighted,
  15245. isBlockSelected,
  15246. isBlockMultiSelected,
  15247. getBlockName,
  15248. getSettings,
  15249. hasSelectedInnerBlock,
  15250. isTyping,
  15251. __experimentalGetActiveBlockIdByBlockNames: getActiveBlockIdByBlockNames
  15252. } = select(store);
  15253. const {
  15254. __experimentalSpotlightEntityBlocks: spotlightEntityBlocks,
  15255. outlineMode
  15256. } = getSettings();
  15257. const isDragging = isBlockBeingDragged(clientId);
  15258. const isSelected = isBlockSelected(clientId);
  15259. const name = getBlockName(clientId);
  15260. const checkDeep = true; // "ancestor" is the more appropriate label due to "deep" check.
  15261. const isAncestorOfSelectedBlock = hasSelectedInnerBlock(clientId, checkDeep);
  15262. const activeEntityBlockId = getActiveBlockIdByBlockNames(spotlightEntityBlocks);
  15263. return classnames_default()({
  15264. 'is-selected': isSelected,
  15265. 'is-highlighted': isBlockHighlighted(clientId),
  15266. 'is-multi-selected': isBlockMultiSelected(clientId),
  15267. 'is-reusable': (0,external_wp_blocks_namespaceObject.isReusableBlock)((0,external_wp_blocks_namespaceObject.getBlockType)(name)),
  15268. 'is-dragging': isDragging,
  15269. 'has-child-selected': isAncestorOfSelectedBlock,
  15270. 'has-active-entity': activeEntityBlockId,
  15271. // Determine if there is an active entity area to spotlight.
  15272. 'is-active-entity': activeEntityBlockId === clientId,
  15273. 'remove-outline': isSelected && outlineMode && isTyping()
  15274. });
  15275. }, [clientId]);
  15276. }
  15277. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-default-class-name.js
  15278. /**
  15279. * WordPress dependencies
  15280. */
  15281. /**
  15282. * Internal dependencies
  15283. */
  15284. /**
  15285. * Returns the default class name if the block is a light block and it supports
  15286. * `className`.
  15287. *
  15288. * @param {string} clientId The block client ID.
  15289. *
  15290. * @return {string} The class name, e.g. `wp-block-paragraph`.
  15291. */
  15292. function useBlockDefaultClassName(clientId) {
  15293. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  15294. const name = select(store).getBlockName(clientId);
  15295. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
  15296. const hasLightBlockWrapper = (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1;
  15297. if (!hasLightBlockWrapper) {
  15298. return;
  15299. }
  15300. return (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name);
  15301. }, [clientId]);
  15302. }
  15303. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-custom-class-name.js
  15304. /**
  15305. * WordPress dependencies
  15306. */
  15307. /**
  15308. * Internal dependencies
  15309. */
  15310. /**
  15311. * Returns the custom class name if the block is a light block.
  15312. *
  15313. * @param {string} clientId The block client ID.
  15314. *
  15315. * @return {string} The custom class name.
  15316. */
  15317. function useBlockCustomClassName(clientId) {
  15318. // It's good for this to be a separate selector because it will be executed
  15319. // on every attribute change, while the other selectors are not re-evaluated
  15320. // as much.
  15321. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  15322. const {
  15323. getBlockName,
  15324. getBlockAttributes
  15325. } = select(store);
  15326. const attributes = getBlockAttributes(clientId);
  15327. if (!(attributes !== null && attributes !== void 0 && attributes.className)) {
  15328. return;
  15329. }
  15330. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(getBlockName(clientId));
  15331. const hasLightBlockWrapper = (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1;
  15332. if (!hasLightBlockWrapper) {
  15333. return;
  15334. }
  15335. return attributes.className;
  15336. }, [clientId]);
  15337. }
  15338. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js
  15339. /**
  15340. * External dependencies
  15341. */
  15342. /**
  15343. * WordPress dependencies
  15344. */
  15345. /**
  15346. * Internal dependencies
  15347. */
  15348. /**
  15349. * Returns the class names used for block moving mode.
  15350. *
  15351. * @param {string} clientId The block client ID to insert above.
  15352. *
  15353. * @return {string} The class names.
  15354. */
  15355. function useBlockMovingModeClassNames(clientId) {
  15356. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  15357. const {
  15358. hasBlockMovingClientId,
  15359. canInsertBlockType,
  15360. getBlockName,
  15361. getBlockRootClientId,
  15362. isBlockSelected
  15363. } = select(store); // The classes are only relevant for the selected block. Avoid
  15364. // re-rendering all blocks!
  15365. if (!isBlockSelected(clientId)) {
  15366. return;
  15367. }
  15368. const movingClientId = hasBlockMovingClientId();
  15369. if (!movingClientId) {
  15370. return;
  15371. }
  15372. return classnames_default()('is-block-moving-mode', {
  15373. 'can-insert-moving-block': canInsertBlockType(getBlockName(movingClientId), getBlockRootClientId(clientId))
  15374. });
  15375. }, [clientId]);
  15376. }
  15377. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-focus-handler.js
  15378. /**
  15379. * WordPress dependencies
  15380. */
  15381. /**
  15382. * Internal dependencies
  15383. */
  15384. /**
  15385. * Selects the block if it receives focus.
  15386. *
  15387. * @param {string} clientId Block client ID.
  15388. */
  15389. function useFocusHandler(clientId) {
  15390. const {
  15391. isBlockSelected
  15392. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  15393. const {
  15394. selectBlock,
  15395. selectionChange
  15396. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  15397. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  15398. /**
  15399. * Marks the block as selected when focused and not already
  15400. * selected. This specifically handles the case where block does not
  15401. * set focus on its own (via `setFocus`), typically if there is no
  15402. * focusable input in the block.
  15403. *
  15404. * @param {FocusEvent} event Focus event.
  15405. */
  15406. function onFocus(event) {
  15407. // When the whole editor is editable, let writing flow handle
  15408. // selection.
  15409. if (node.parentElement.closest('[contenteditable="true"]')) {
  15410. return;
  15411. } // Check synchronously because a non-selected block might be
  15412. // getting data through `useSelect` asynchronously.
  15413. if (isBlockSelected(clientId)) {
  15414. // Potentially change selection away from rich text.
  15415. if (!event.target.isContentEditable) {
  15416. selectionChange(clientId);
  15417. }
  15418. return;
  15419. } // If an inner block is focussed, that block is resposible for
  15420. // setting the selected block.
  15421. if (!isInsideRootBlock(node, event.target)) {
  15422. return;
  15423. }
  15424. selectBlock(clientId);
  15425. }
  15426. node.addEventListener('focusin', onFocus);
  15427. return () => {
  15428. node.removeEventListener('focusin', onFocus);
  15429. };
  15430. }, [isBlockSelected, selectBlock]);
  15431. }
  15432. ;// CONCATENATED MODULE: external ["wp","keycodes"]
  15433. var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
  15434. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js
  15435. /**
  15436. * WordPress dependencies
  15437. */
  15438. /**
  15439. * Internal dependencies
  15440. */
  15441. /**
  15442. * Adds block behaviour:
  15443. * - Removes the block on BACKSPACE.
  15444. * - Inserts a default block on ENTER.
  15445. * - Disables dragging of block contents.
  15446. *
  15447. * @param {string} clientId Block client ID.
  15448. */
  15449. function useEventHandlers(clientId) {
  15450. const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isBlockSelected(clientId), [clientId]);
  15451. const {
  15452. getBlockRootClientId,
  15453. getBlockIndex
  15454. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  15455. const {
  15456. insertDefaultBlock,
  15457. removeBlock
  15458. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  15459. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  15460. if (!isSelected) {
  15461. return;
  15462. }
  15463. /**
  15464. * Interprets keydown event intent to remove or insert after block if
  15465. * key event occurs on wrapper node. This can occur when the block has
  15466. * no text fields of its own, particularly after initial insertion, to
  15467. * allow for easy deletion and continuous writing flow to add additional
  15468. * content.
  15469. *
  15470. * @param {KeyboardEvent} event Keydown event.
  15471. */
  15472. function onKeyDown(event) {
  15473. const {
  15474. keyCode,
  15475. target
  15476. } = event;
  15477. if (keyCode !== external_wp_keycodes_namespaceObject.ENTER && keyCode !== external_wp_keycodes_namespaceObject.BACKSPACE && keyCode !== external_wp_keycodes_namespaceObject.DELETE) {
  15478. return;
  15479. }
  15480. if (target !== node || (0,external_wp_dom_namespaceObject.isTextField)(target)) {
  15481. return;
  15482. }
  15483. event.preventDefault();
  15484. if (keyCode === external_wp_keycodes_namespaceObject.ENTER) {
  15485. insertDefaultBlock({}, getBlockRootClientId(clientId), getBlockIndex(clientId) + 1);
  15486. } else {
  15487. removeBlock(clientId);
  15488. }
  15489. }
  15490. /**
  15491. * Prevents default dragging behavior within a block. To do: we must
  15492. * handle this in the future and clean up the drag target.
  15493. *
  15494. * @param {DragEvent} event Drag event.
  15495. */
  15496. function onDragStart(event) {
  15497. event.preventDefault();
  15498. }
  15499. node.addEventListener('keydown', onKeyDown);
  15500. node.addEventListener('dragstart', onDragStart);
  15501. return () => {
  15502. node.removeEventListener('keydown', onKeyDown);
  15503. node.removeEventListener('dragstart', onDragStart);
  15504. };
  15505. }, [clientId, isSelected, getBlockRootClientId, getBlockIndex, insertDefaultBlock, removeBlock]);
  15506. }
  15507. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-nav-mode-exit.js
  15508. /**
  15509. * WordPress dependencies
  15510. */
  15511. /**
  15512. * Internal dependencies
  15513. */
  15514. /**
  15515. * Allows navigation mode to be exited by clicking in the selected block.
  15516. *
  15517. * @param {string} clientId Block client ID.
  15518. */
  15519. function useNavModeExit(clientId) {
  15520. const {
  15521. isNavigationMode,
  15522. isBlockSelected
  15523. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  15524. const {
  15525. setNavigationMode,
  15526. selectBlock
  15527. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  15528. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  15529. function onMouseDown(event) {
  15530. // Don't select a block if it's already handled by a child
  15531. // block.
  15532. if (isNavigationMode() && !event.defaultPrevented) {
  15533. // Prevent focus from moving to the block.
  15534. event.preventDefault(); // When clicking on a selected block, exit navigation mode.
  15535. if (isBlockSelected(clientId)) {
  15536. setNavigationMode(false);
  15537. } else {
  15538. selectBlock(clientId);
  15539. }
  15540. }
  15541. }
  15542. node.addEventListener('mousedown', onMouseDown);
  15543. return () => {
  15544. node.addEventListener('mousedown', onMouseDown);
  15545. };
  15546. }, [clientId, isNavigationMode, isBlockSelected, setNavigationMode]);
  15547. }
  15548. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-intersection-observer.js
  15549. /**
  15550. * WordPress dependencies
  15551. */
  15552. /**
  15553. * Internal dependencies
  15554. */
  15555. function useIntersectionObserver() {
  15556. const observer = (0,external_wp_element_namespaceObject.useContext)(IntersectionObserver);
  15557. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  15558. if (observer) {
  15559. observer.observe(node);
  15560. return () => {
  15561. observer.unobserve(node);
  15562. };
  15563. }
  15564. }, [observer]);
  15565. }
  15566. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/index.js
  15567. /**
  15568. * External dependencies
  15569. */
  15570. /**
  15571. * WordPress dependencies
  15572. */
  15573. /**
  15574. * Internal dependencies
  15575. */
  15576. /**
  15577. * If the block count exceeds the threshold, we disable the reordering animation
  15578. * to avoid laginess.
  15579. */
  15580. const BLOCK_ANIMATION_THRESHOLD = 200;
  15581. /**
  15582. * This hook is used to lightly mark an element as a block element. The element
  15583. * should be the outermost element of a block. Call this hook and pass the
  15584. * returned props to the element to mark as a block. If you define a ref for the
  15585. * element, it is important to pass the ref to this hook, which the hook in turn
  15586. * will pass to the component through the props it returns. Optionally, you can
  15587. * also pass any other props through this hook, and they will be merged and
  15588. * returned.
  15589. *
  15590. * @param {Object} props Optional. Props to pass to the element. Must contain
  15591. * the ref if one is defined.
  15592. * @param {Object} options Options for internal use only.
  15593. * @param {boolean} options.__unstableIsHtml
  15594. *
  15595. * @return {Object} Props to pass to the element to mark as a block.
  15596. */
  15597. function useBlockProps() {
  15598. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  15599. let {
  15600. __unstableIsHtml
  15601. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  15602. const {
  15603. clientId,
  15604. className,
  15605. wrapperProps = {},
  15606. isAligned
  15607. } = (0,external_wp_element_namespaceObject.useContext)(BlockListBlockContext);
  15608. const {
  15609. index,
  15610. mode,
  15611. name,
  15612. blockApiVersion,
  15613. blockTitle,
  15614. isPartOfSelection,
  15615. adjustScrolling,
  15616. enableAnimation
  15617. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  15618. const {
  15619. getBlockIndex,
  15620. getBlockMode,
  15621. getBlockName,
  15622. isTyping,
  15623. getGlobalBlockCount,
  15624. isBlockSelected,
  15625. isBlockMultiSelected,
  15626. isAncestorMultiSelected,
  15627. isFirstMultiSelectedBlock
  15628. } = select(store);
  15629. const isSelected = isBlockSelected(clientId);
  15630. const isPartOfMultiSelection = isBlockMultiSelected(clientId) || isAncestorMultiSelected(clientId);
  15631. const blockName = getBlockName(clientId);
  15632. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName);
  15633. return {
  15634. index: getBlockIndex(clientId),
  15635. mode: getBlockMode(clientId),
  15636. name: blockName,
  15637. blockApiVersion: (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) || 1,
  15638. blockTitle: blockType === null || blockType === void 0 ? void 0 : blockType.title,
  15639. isPartOfSelection: isSelected || isPartOfMultiSelection,
  15640. adjustScrolling: isSelected || isFirstMultiSelectedBlock(clientId),
  15641. enableAnimation: !isTyping() && getGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD
  15642. };
  15643. }, [clientId]); // translators: %s: Type of block (i.e. Text, Image etc)
  15644. const blockLabel = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Block: %s'), blockTitle);
  15645. const htmlSuffix = mode === 'html' && !__unstableIsHtml ? '-visual' : '';
  15646. 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({
  15647. isSelected: isPartOfSelection,
  15648. adjustScrolling,
  15649. enableAnimation,
  15650. triggerAnimationOnChange: index
  15651. })]);
  15652. const blockEditContext = useBlockEditContext(); // Ensures it warns only inside the `edit` implementation for the block.
  15653. if (blockApiVersion < 2 && clientId === blockEditContext.clientId) {
  15654. typeof process !== "undefined" && process.env && "production" !== "production" ? 0 : void 0;
  15655. }
  15656. return { ...wrapperProps,
  15657. ...props,
  15658. ref: mergedRefs,
  15659. id: `block-${clientId}${htmlSuffix}`,
  15660. tabIndex: 0,
  15661. role: 'document',
  15662. 'aria-label': blockLabel,
  15663. 'data-block': clientId,
  15664. 'data-type': name,
  15665. 'data-title': blockTitle,
  15666. className: classnames_default()( // The wp-block className is important for editor styles.
  15667. classnames_default()('block-editor-block-list__block', {
  15668. 'wp-block': !isAligned
  15669. }), className, props.className, wrapperProps.className, useBlockClassNames(clientId), useBlockDefaultClassName(clientId), useBlockCustomClassName(clientId), useBlockMovingModeClassNames(clientId)),
  15670. style: { ...wrapperProps.style,
  15671. ...props.style
  15672. }
  15673. };
  15674. }
  15675. /**
  15676. * Call within a save function to get the props for the block wrapper.
  15677. *
  15678. * @param {Object} props Optional. Props to pass to the element.
  15679. */
  15680. useBlockProps.save = external_wp_blocks_namespaceObject.__unstableGetBlockProps;
  15681. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block.js
  15682. /**
  15683. * External dependencies
  15684. */
  15685. /**
  15686. * WordPress dependencies
  15687. */
  15688. /**
  15689. * Internal dependencies
  15690. */
  15691. const BlockListBlockContext = (0,external_wp_element_namespaceObject.createContext)();
  15692. /**
  15693. * Merges wrapper props with special handling for classNames and styles.
  15694. *
  15695. * @param {Object} propsA
  15696. * @param {Object} propsB
  15697. *
  15698. * @return {Object} Merged props.
  15699. */
  15700. function mergeWrapperProps(propsA, propsB) {
  15701. const newProps = { ...propsA,
  15702. ...propsB
  15703. };
  15704. if (propsA && propsB && propsA.className && propsB.className) {
  15705. newProps.className = classnames_default()(propsA.className, propsB.className);
  15706. }
  15707. if (propsA && propsB && propsA.style && propsB.style) {
  15708. newProps.style = { ...propsA.style,
  15709. ...propsB.style
  15710. };
  15711. }
  15712. return newProps;
  15713. }
  15714. function Block(_ref) {
  15715. let {
  15716. children,
  15717. isHtml,
  15718. ...props
  15719. } = _ref;
  15720. return (0,external_wp_element_namespaceObject.createElement)("div", useBlockProps(props, {
  15721. __unstableIsHtml: isHtml
  15722. }), children);
  15723. }
  15724. function BlockListBlock(_ref2) {
  15725. var _wrapperProps;
  15726. let {
  15727. block: {
  15728. __unstableBlockSource
  15729. },
  15730. mode,
  15731. isLocked,
  15732. canRemove,
  15733. clientId,
  15734. isSelected,
  15735. isSelectionEnabled,
  15736. className,
  15737. name,
  15738. isValid,
  15739. attributes,
  15740. wrapperProps,
  15741. setAttributes,
  15742. onReplace,
  15743. onInsertBlocksAfter,
  15744. onMerge,
  15745. toggleSelection
  15746. } = _ref2;
  15747. const themeSupportsLayout = (0,external_wp_data_namespaceObject.useSelect)(select => {
  15748. const {
  15749. getSettings
  15750. } = select(store);
  15751. return getSettings().supportsLayout;
  15752. }, []);
  15753. const {
  15754. removeBlock
  15755. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  15756. 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
  15757. // HTML mode. This allows us to render all of the ancillary pieces
  15758. // (InspectorControls, etc.) which are inside `BlockEdit` but not
  15759. // `BlockHTML`, even in HTML mode.
  15760. let blockEdit = (0,external_wp_element_namespaceObject.createElement)(BlockEdit, {
  15761. name: name,
  15762. isSelected: isSelected,
  15763. attributes: attributes,
  15764. setAttributes: setAttributes,
  15765. insertBlocksAfter: isLocked ? undefined : onInsertBlocksAfter,
  15766. onReplace: canRemove ? onReplace : undefined,
  15767. onRemove: canRemove ? onRemove : undefined,
  15768. mergeBlocks: canRemove ? onMerge : undefined,
  15769. clientId: clientId,
  15770. isSelectionEnabled: isSelectionEnabled,
  15771. toggleSelection: toggleSelection
  15772. });
  15773. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name); // Determine whether the block has props to apply to the wrapper.
  15774. if (blockType !== null && blockType !== void 0 && blockType.getEditWrapperProps) {
  15775. wrapperProps = mergeWrapperProps(wrapperProps, blockType.getEditWrapperProps(attributes));
  15776. }
  15777. const isAligned = wrapperProps && !!wrapperProps['data-align'] && !themeSupportsLayout; // For aligned blocks, provide a wrapper element so the block can be
  15778. // positioned relative to the block column.
  15779. // This is only kept for classic themes that don't support layout
  15780. // Historically we used to rely on extra divs and data-align to
  15781. // provide the alignments styles in the editor.
  15782. // Due to the differences between frontend and backend, we migrated
  15783. // to the layout feature, and we're now aligning the markup of frontend
  15784. // and backend.
  15785. if (isAligned) {
  15786. blockEdit = (0,external_wp_element_namespaceObject.createElement)("div", {
  15787. className: "wp-block",
  15788. "data-align": wrapperProps['data-align']
  15789. }, blockEdit);
  15790. }
  15791. let block;
  15792. if (!isValid) {
  15793. const saveContent = __unstableBlockSource ? (0,external_wp_blocks_namespaceObject.serializeRawBlock)(__unstableBlockSource) : (0,external_wp_blocks_namespaceObject.getSaveContent)(blockType, attributes);
  15794. block = (0,external_wp_element_namespaceObject.createElement)(Block, {
  15795. className: "has-warning"
  15796. }, (0,external_wp_element_namespaceObject.createElement)(block_invalid_warning, {
  15797. clientId: clientId
  15798. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, (0,external_wp_dom_namespaceObject.safeHTML)(saveContent)));
  15799. } else if (mode === 'html') {
  15800. // Render blockEdit so the inspector controls don't disappear.
  15801. // See #8969.
  15802. block = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  15803. style: {
  15804. display: 'none'
  15805. }
  15806. }, blockEdit), (0,external_wp_element_namespaceObject.createElement)(Block, {
  15807. isHtml: true
  15808. }, (0,external_wp_element_namespaceObject.createElement)(block_html, {
  15809. clientId: clientId
  15810. })));
  15811. } else if ((blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1) {
  15812. block = blockEdit;
  15813. } else {
  15814. block = (0,external_wp_element_namespaceObject.createElement)(Block, wrapperProps, blockEdit);
  15815. }
  15816. const value = {
  15817. clientId,
  15818. className: (_wrapperProps = wrapperProps) !== null && _wrapperProps !== void 0 && _wrapperProps['data-align'] && themeSupportsLayout ? classnames_default()(className, `align${wrapperProps['data-align']}`) : className,
  15819. wrapperProps: (0,external_lodash_namespaceObject.omit)(wrapperProps, ['data-align']),
  15820. isAligned
  15821. };
  15822. const memoizedValue = (0,external_wp_element_namespaceObject.useMemo)(() => value, Object.values(value));
  15823. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlockContext.Provider, {
  15824. value: memoizedValue
  15825. }, (0,external_wp_element_namespaceObject.createElement)(block_crash_boundary, {
  15826. fallback: (0,external_wp_element_namespaceObject.createElement)(Block, {
  15827. className: "has-warning"
  15828. }, (0,external_wp_element_namespaceObject.createElement)(block_crash_warning, null))
  15829. }, block));
  15830. }
  15831. const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)((select, _ref3) => {
  15832. let {
  15833. clientId,
  15834. rootClientId
  15835. } = _ref3;
  15836. const {
  15837. isBlockSelected,
  15838. getBlockMode,
  15839. isSelectionEnabled,
  15840. getTemplateLock,
  15841. __unstableGetBlockWithoutInnerBlocks,
  15842. canRemoveBlock,
  15843. canMoveBlock
  15844. } = select(store);
  15845. const block = __unstableGetBlockWithoutInnerBlocks(clientId);
  15846. const isSelected = isBlockSelected(clientId);
  15847. const templateLock = getTemplateLock(rootClientId);
  15848. const canRemove = canRemoveBlock(clientId, rootClientId);
  15849. const canMove = canMoveBlock(clientId, rootClientId); // The fallback to `{}` is a temporary fix.
  15850. // This function should never be called when a block is not present in
  15851. // the state. It happens now because the order in withSelect rendering
  15852. // is not correct.
  15853. const {
  15854. name,
  15855. attributes,
  15856. isValid
  15857. } = block || {}; // Do not add new properties here, use `useSelect` instead to avoid
  15858. // leaking new props to the public API (editor.BlockListBlock filter).
  15859. return {
  15860. mode: getBlockMode(clientId),
  15861. isSelectionEnabled: isSelectionEnabled(),
  15862. isLocked: !!templateLock,
  15863. canRemove,
  15864. canMove,
  15865. // Users of the editor.BlockListBlock filter used to be able to
  15866. // access the block prop.
  15867. // Ideally these blocks would rely on the clientId prop only.
  15868. // This is kept for backward compatibility reasons.
  15869. block,
  15870. name,
  15871. attributes,
  15872. isValid,
  15873. isSelected
  15874. };
  15875. });
  15876. const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps, _ref4) => {
  15877. let {
  15878. select
  15879. } = _ref4;
  15880. const {
  15881. updateBlockAttributes,
  15882. insertBlocks,
  15883. mergeBlocks,
  15884. replaceBlocks,
  15885. toggleSelection,
  15886. __unstableMarkLastChangeAsPersistent
  15887. } = dispatch(store); // Do not add new properties here, use `useDispatch` instead to avoid
  15888. // leaking new props to the public API (editor.BlockListBlock filter).
  15889. return {
  15890. setAttributes(newAttributes) {
  15891. const {
  15892. getMultiSelectedBlockClientIds
  15893. } = select(store);
  15894. const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds();
  15895. const {
  15896. clientId
  15897. } = ownProps;
  15898. const clientIds = multiSelectedBlockClientIds.length ? multiSelectedBlockClientIds : [clientId];
  15899. updateBlockAttributes(clientIds, newAttributes);
  15900. },
  15901. onInsertBlocks(blocks, index) {
  15902. const {
  15903. rootClientId
  15904. } = ownProps;
  15905. insertBlocks(blocks, index, rootClientId);
  15906. },
  15907. onInsertBlocksAfter(blocks) {
  15908. const {
  15909. clientId,
  15910. rootClientId
  15911. } = ownProps;
  15912. const {
  15913. getBlockIndex
  15914. } = select(store);
  15915. const index = getBlockIndex(clientId);
  15916. insertBlocks(blocks, index + 1, rootClientId);
  15917. },
  15918. onMerge(forward) {
  15919. const {
  15920. clientId
  15921. } = ownProps;
  15922. const {
  15923. getPreviousBlockClientId,
  15924. getNextBlockClientId
  15925. } = select(store);
  15926. if (forward) {
  15927. const nextBlockClientId = getNextBlockClientId(clientId);
  15928. if (nextBlockClientId) {
  15929. mergeBlocks(clientId, nextBlockClientId);
  15930. }
  15931. } else {
  15932. const previousBlockClientId = getPreviousBlockClientId(clientId);
  15933. if (previousBlockClientId) {
  15934. mergeBlocks(previousBlockClientId, clientId);
  15935. }
  15936. }
  15937. },
  15938. onReplace(blocks, indexToSelect, initialPosition) {
  15939. if (blocks.length && !(0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(blocks[blocks.length - 1])) {
  15940. __unstableMarkLastChangeAsPersistent();
  15941. }
  15942. replaceBlocks([ownProps.clientId], blocks, indexToSelect, initialPosition);
  15943. },
  15944. toggleSelection(selectionEnabled) {
  15945. toggleSelection(selectionEnabled);
  15946. }
  15947. };
  15948. });
  15949. /* 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
  15950. // see issue for more info
  15951. // https://github.com/WordPress/gutenberg/issues/17013
  15952. (0,external_wp_compose_namespaceObject.ifCondition)(_ref5 => {
  15953. let {
  15954. block
  15955. } = _ref5;
  15956. return !!block;
  15957. }), (0,external_wp_components_namespaceObject.withFilters)('editor.BlockListBlock'))(BlockListBlock));
  15958. ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
  15959. var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  15960. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js
  15961. /**
  15962. * WordPress dependencies
  15963. */
  15964. const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  15965. xmlns: "http://www.w3.org/2000/svg",
  15966. viewBox: "0 0 24 24"
  15967. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  15968. d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
  15969. }));
  15970. /* harmony default export */ var library_plus = (plus);
  15971. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/tips.js
  15972. /**
  15973. * WordPress dependencies
  15974. */
  15975. 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.'), {
  15976. kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
  15977. }), (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.'), {
  15978. kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
  15979. }), (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.'), {
  15980. kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
  15981. }), (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.")];
  15982. function Tips() {
  15983. const [randomIndex] = (0,external_wp_element_namespaceObject.useState)( // Disable Reason: I'm not generating an HTML id.
  15984. // eslint-disable-next-line no-restricted-syntax
  15985. Math.floor(Math.random() * globalTips.length));
  15986. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tip, null, globalTips[randomIndex]);
  15987. }
  15988. /* harmony default export */ var tips = (Tips);
  15989. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js
  15990. /**
  15991. * WordPress dependencies
  15992. */
  15993. const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  15994. xmlns: "http://www.w3.org/2000/svg",
  15995. viewBox: "0 0 24 24"
  15996. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  15997. 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"
  15998. }));
  15999. /* harmony default export */ var block_default = (blockDefault);
  16000. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-icon/index.js
  16001. /**
  16002. * External dependencies
  16003. */
  16004. /**
  16005. * WordPress dependencies
  16006. */
  16007. function BlockIcon(_ref) {
  16008. var _icon;
  16009. let {
  16010. icon,
  16011. showColors = false,
  16012. className
  16013. } = _ref;
  16014. if (((_icon = icon) === null || _icon === void 0 ? void 0 : _icon.src) === 'block-default') {
  16015. icon = {
  16016. src: block_default
  16017. };
  16018. }
  16019. const renderedIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
  16020. icon: icon && icon.src ? icon.src : icon
  16021. });
  16022. const style = showColors ? {
  16023. backgroundColor: icon && icon.background,
  16024. color: icon && icon.foreground
  16025. } : {};
  16026. return (0,external_wp_element_namespaceObject.createElement)("span", {
  16027. style: style,
  16028. className: classnames_default()('block-editor-block-icon', className, {
  16029. 'has-colors': showColors
  16030. })
  16031. }, renderedIcon);
  16032. }
  16033. /**
  16034. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-icon/README.md
  16035. */
  16036. /* harmony default export */ var block_icon = ((0,external_wp_element_namespaceObject.memo)(BlockIcon));
  16037. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-card/index.js
  16038. /**
  16039. * WordPress dependencies
  16040. */
  16041. /**
  16042. * Internal dependencies
  16043. */
  16044. function BlockCard(_ref) {
  16045. let {
  16046. title,
  16047. icon,
  16048. description,
  16049. blockType
  16050. } = _ref;
  16051. if (blockType) {
  16052. external_wp_deprecated_default()('`blockType` property in `BlockCard component`', {
  16053. since: '5.7',
  16054. alternative: '`title, icon and description` properties'
  16055. });
  16056. ({
  16057. title,
  16058. icon,
  16059. description
  16060. } = blockType);
  16061. }
  16062. return (0,external_wp_element_namespaceObject.createElement)("div", {
  16063. className: "block-editor-block-card"
  16064. }, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  16065. icon: icon,
  16066. showColors: true
  16067. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  16068. className: "block-editor-block-card__content"
  16069. }, (0,external_wp_element_namespaceObject.createElement)("h2", {
  16070. className: "block-editor-block-card__title"
  16071. }, title), (0,external_wp_element_namespaceObject.createElement)("span", {
  16072. className: "block-editor-block-card__description"
  16073. }, description)));
  16074. }
  16075. /* harmony default export */ var block_card = (BlockCard);
  16076. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/with-registry-provider.js
  16077. /**
  16078. * WordPress dependencies
  16079. */
  16080. /**
  16081. * Internal dependencies
  16082. */
  16083. const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => {
  16084. return (0,external_wp_data_namespaceObject.withRegistry)(_ref => {
  16085. let {
  16086. useSubRegistry = true,
  16087. registry,
  16088. ...props
  16089. } = _ref;
  16090. if (!useSubRegistry) {
  16091. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({
  16092. registry: registry
  16093. }, props));
  16094. }
  16095. const [subRegistry, setSubRegistry] = (0,external_wp_element_namespaceObject.useState)(null);
  16096. (0,external_wp_element_namespaceObject.useEffect)(() => {
  16097. const newRegistry = (0,external_wp_data_namespaceObject.createRegistry)({}, registry);
  16098. newRegistry.registerStore(STORE_NAME, storeConfig);
  16099. setSubRegistry(newRegistry);
  16100. }, [registry]);
  16101. if (!subRegistry) {
  16102. return null;
  16103. }
  16104. return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.RegistryProvider, {
  16105. value: subRegistry
  16106. }, (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({
  16107. registry: subRegistry
  16108. }, props)));
  16109. });
  16110. }, 'withRegistryProvider');
  16111. /* harmony default export */ var with_registry_provider = (withRegistryProvider);
  16112. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/use-block-sync.js
  16113. /**
  16114. * External dependencies
  16115. */
  16116. /**
  16117. * WordPress dependencies
  16118. */
  16119. /**
  16120. * Internal dependencies
  16121. */
  16122. /**
  16123. * A function to call when the block value has been updated in the block-editor
  16124. * store.
  16125. *
  16126. * @callback onBlockUpdate
  16127. * @param {Object[]} blocks The updated blocks.
  16128. * @param {Object} options The updated block options, such as selectionStart
  16129. * and selectionEnd.
  16130. */
  16131. /**
  16132. * useBlockSync is a side effect which handles bidirectional sync between the
  16133. * block-editor store and a controlling data source which provides blocks. This
  16134. * is most commonly used by the BlockEditorProvider to synchronize the contents
  16135. * of the block-editor store with the root entity, like a post.
  16136. *
  16137. * Another example would be the template part block, which provides blocks from
  16138. * a separate entity data source than a root entity. This hook syncs edits to
  16139. * the template part in the block editor back to the entity and vice-versa.
  16140. *
  16141. * Here are some of its basic functions:
  16142. * - Initalizes the block-editor store for the given clientID to the blocks
  16143. * given via props.
  16144. * - Adds incoming changes (like undo) to the block-editor store.
  16145. * - Adds outgoing changes (like editing content) to the controlling entity,
  16146. * determining if a change should be considered persistent or not.
  16147. * - Handles edge cases and race conditions which occur in those operations.
  16148. * - Ignores changes which happen to other entities (like nested inner block
  16149. * controllers.
  16150. * - Passes selection state from the block-editor store to the controlling entity.
  16151. *
  16152. * @param {Object} props Props for the block sync hook
  16153. * @param {string} props.clientId The client ID of the inner block controller.
  16154. * If none is passed, then it is assumed to be a
  16155. * root controller rather than an inner block
  16156. * controller.
  16157. * @param {Object[]} props.value The control value for the blocks. This value
  16158. * is used to initalize the block-editor store
  16159. * and for resetting the blocks to incoming
  16160. * changes like undo.
  16161. * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.
  16162. * @param {onBlockUpdate} props.onChange Function to call when a persistent
  16163. * change has been made in the block-editor blocks
  16164. * for the given clientId. For example, after
  16165. * this function is called, an entity is marked
  16166. * dirty because it has changes to save.
  16167. * @param {onBlockUpdate} props.onInput Function to call when a non-persistent
  16168. * change has been made in the block-editor blocks
  16169. * for the given clientId. When this is called,
  16170. * controlling sources do not become dirty.
  16171. */
  16172. function useBlockSync(_ref) {
  16173. let {
  16174. clientId = null,
  16175. value: controlledBlocks,
  16176. selection: controlledSelection,
  16177. onChange = external_lodash_namespaceObject.noop,
  16178. onInput = external_lodash_namespaceObject.noop
  16179. } = _ref;
  16180. const registry = (0,external_wp_data_namespaceObject.useRegistry)();
  16181. const {
  16182. resetBlocks,
  16183. resetSelection,
  16184. replaceInnerBlocks,
  16185. setHasControlledInnerBlocks,
  16186. __unstableMarkNextChangeAsNotPersistent
  16187. } = registry.dispatch(store);
  16188. const {
  16189. getBlockName,
  16190. getBlocks
  16191. } = registry.select(store);
  16192. const isControlled = (0,external_wp_data_namespaceObject.useSelect)(select => {
  16193. return !clientId || select(store).areInnerBlocksControlled(clientId);
  16194. }, [clientId]);
  16195. const pendingChanges = (0,external_wp_element_namespaceObject.useRef)({
  16196. incoming: null,
  16197. outgoing: []
  16198. });
  16199. const subscribed = (0,external_wp_element_namespaceObject.useRef)(false);
  16200. const setControlledBlocks = () => {
  16201. if (!controlledBlocks) {
  16202. return;
  16203. } // We don't need to persist this change because we only replace
  16204. // controlled inner blocks when the change was caused by an entity,
  16205. // and so it would already be persisted.
  16206. __unstableMarkNextChangeAsNotPersistent();
  16207. if (clientId) {
  16208. // It is important to batch here because otherwise,
  16209. // as soon as `setHasControlledInnerBlocks` is called
  16210. // the effect to restore might be triggered
  16211. // before the actual blocks get set properly in state.
  16212. registry.batch(() => {
  16213. setHasControlledInnerBlocks(clientId, true);
  16214. const storeBlocks = controlledBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
  16215. if (subscribed.current) {
  16216. pendingChanges.current.incoming = storeBlocks;
  16217. }
  16218. __unstableMarkNextChangeAsNotPersistent();
  16219. replaceInnerBlocks(clientId, storeBlocks);
  16220. });
  16221. } else {
  16222. if (subscribed.current) {
  16223. pendingChanges.current.incoming = controlledBlocks;
  16224. }
  16225. resetBlocks(controlledBlocks);
  16226. }
  16227. }; // Add a subscription to the block-editor registry to detect when changes
  16228. // have been made. This lets us inform the data source of changes. This
  16229. // is an effect so that the subscriber can run synchronously without
  16230. // waiting for React renders for changes.
  16231. const onInputRef = (0,external_wp_element_namespaceObject.useRef)(onInput);
  16232. const onChangeRef = (0,external_wp_element_namespaceObject.useRef)(onChange);
  16233. (0,external_wp_element_namespaceObject.useEffect)(() => {
  16234. onInputRef.current = onInput;
  16235. onChangeRef.current = onChange;
  16236. }, [onInput, onChange]); // Determine if blocks need to be reset when they change.
  16237. (0,external_wp_element_namespaceObject.useEffect)(() => {
  16238. if (pendingChanges.current.outgoing.includes(controlledBlocks)) {
  16239. // Skip block reset if the value matches expected outbound sync
  16240. // triggered by this component by a preceding change detection.
  16241. // Only skip if the value matches expectation, since a reset should
  16242. // still occur if the value is modified (not equal by reference),
  16243. // to allow that the consumer may apply modifications to reflect
  16244. // back on the editor.
  16245. if ((0,external_lodash_namespaceObject.last)(pendingChanges.current.outgoing) === controlledBlocks) {
  16246. pendingChanges.current.outgoing = [];
  16247. }
  16248. } else if (getBlocks(clientId) !== controlledBlocks) {
  16249. // Reset changing value in all other cases than the sync described
  16250. // above. Since this can be reached in an update following an out-
  16251. // bound sync, unset the outbound value to avoid considering it in
  16252. // subsequent renders.
  16253. pendingChanges.current.outgoing = [];
  16254. setControlledBlocks();
  16255. if (controlledSelection) {
  16256. resetSelection(controlledSelection.selectionStart, controlledSelection.selectionEnd, controlledSelection.initialPosition);
  16257. }
  16258. }
  16259. }, [controlledBlocks, clientId]);
  16260. (0,external_wp_element_namespaceObject.useEffect)(() => {
  16261. // When the block becomes uncontrolled, it means its inner state has been reset
  16262. // we need to take the blocks again from the external value property.
  16263. if (!isControlled) {
  16264. pendingChanges.current.outgoing = [];
  16265. setControlledBlocks();
  16266. }
  16267. }, [isControlled]);
  16268. (0,external_wp_element_namespaceObject.useEffect)(() => {
  16269. const {
  16270. getSelectionStart,
  16271. getSelectionEnd,
  16272. getSelectedBlocksInitialCaretPosition,
  16273. isLastBlockChangePersistent,
  16274. __unstableIsLastBlockChangeIgnored,
  16275. areInnerBlocksControlled
  16276. } = registry.select(store);
  16277. let blocks = getBlocks(clientId);
  16278. let isPersistent = isLastBlockChangePersistent();
  16279. let previousAreBlocksDifferent = false;
  16280. subscribed.current = true;
  16281. const unsubscribe = registry.subscribe(() => {
  16282. // Sometimes, when changing block lists, lingering subscriptions
  16283. // might trigger before they are cleaned up. If the block for which
  16284. // the subscription runs is no longer in the store, this would clear
  16285. // its parent entity's block list. To avoid this, we bail out if
  16286. // the subscription is triggering for a block (`clientId !== null`)
  16287. // and its block name can't be found because it's not on the list.
  16288. // (`getBlockName( clientId ) === null`).
  16289. if (clientId !== null && getBlockName(clientId) === null) return; // When RESET_BLOCKS on parent blocks get called, the controlled blocks
  16290. // can reset to uncontrolled, in these situations, it means we need to populate
  16291. // the blocks again from the external blocks (the value property here)
  16292. // and we should stop triggering onChange
  16293. const isStillControlled = !clientId || areInnerBlocksControlled(clientId);
  16294. if (!isStillControlled) {
  16295. return;
  16296. }
  16297. const newIsPersistent = isLastBlockChangePersistent();
  16298. const newBlocks = getBlocks(clientId);
  16299. const areBlocksDifferent = newBlocks !== blocks;
  16300. blocks = newBlocks;
  16301. if (areBlocksDifferent && (pendingChanges.current.incoming || __unstableIsLastBlockChangeIgnored())) {
  16302. pendingChanges.current.incoming = null;
  16303. isPersistent = newIsPersistent;
  16304. return;
  16305. } // Since we often dispatch an action to mark the previous action as
  16306. // persistent, we need to make sure that the blocks changed on the
  16307. // previous action before committing the change.
  16308. const didPersistenceChange = previousAreBlocksDifferent && !areBlocksDifferent && newIsPersistent && !isPersistent;
  16309. if (areBlocksDifferent || didPersistenceChange) {
  16310. isPersistent = newIsPersistent; // We know that onChange/onInput will update controlledBlocks.
  16311. // We need to be aware that it was caused by an outgoing change
  16312. // so that we do not treat it as an incoming change later on,
  16313. // which would cause a block reset.
  16314. pendingChanges.current.outgoing.push(blocks); // Inform the controlling entity that changes have been made to
  16315. // the block-editor store they should be aware about.
  16316. const updateParent = isPersistent ? onChangeRef.current : onInputRef.current;
  16317. updateParent(blocks, {
  16318. selection: {
  16319. selectionStart: getSelectionStart(),
  16320. selectionEnd: getSelectionEnd(),
  16321. initialPosition: getSelectedBlocksInitialCaretPosition()
  16322. }
  16323. });
  16324. }
  16325. previousAreBlocksDifferent = areBlocksDifferent;
  16326. });
  16327. return () => unsubscribe();
  16328. }, [registry, clientId]);
  16329. }
  16330. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/index.js
  16331. /**
  16332. * WordPress dependencies
  16333. */
  16334. /**
  16335. * Internal dependencies
  16336. */
  16337. /** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
  16338. function BlockEditorProvider(props) {
  16339. const {
  16340. children,
  16341. settings
  16342. } = props;
  16343. const {
  16344. updateSettings
  16345. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  16346. (0,external_wp_element_namespaceObject.useEffect)(() => {
  16347. updateSettings(settings);
  16348. }, [settings]); // Syncs the entity provider with changes in the block-editor store.
  16349. useBlockSync(props);
  16350. return (0,external_wp_element_namespaceObject.createElement)(BlockRefsProvider, null, children);
  16351. }
  16352. /* harmony default export */ var provider = (with_registry_provider(BlockEditorProvider));
  16353. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/live.js
  16354. /**
  16355. * WordPress dependencies
  16356. */
  16357. /**
  16358. * Internal dependencies
  16359. */
  16360. function LiveBlockPreview(_ref) {
  16361. let {
  16362. onClick
  16363. } = _ref;
  16364. return (0,external_wp_element_namespaceObject.createElement)("div", {
  16365. tabIndex: 0,
  16366. role: "button",
  16367. onClick: onClick,
  16368. onKeyPress: onClick
  16369. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, null, (0,external_wp_element_namespaceObject.createElement)(BlockList, null)));
  16370. }
  16371. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-selection-clearer/index.js
  16372. /**
  16373. * WordPress dependencies
  16374. */
  16375. /**
  16376. * Internal dependencies
  16377. */
  16378. /**
  16379. * Pass the returned ref callback to an element that should clear block
  16380. * selection. Selection will only be cleared if the element is clicked directly,
  16381. * not if a child element is clicked.
  16382. *
  16383. * @return {import('react').RefCallback} Ref callback.
  16384. */
  16385. function useBlockSelectionClearer() {
  16386. const {
  16387. hasSelectedBlock,
  16388. hasMultiSelection
  16389. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  16390. const {
  16391. clearSelectedBlock
  16392. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  16393. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  16394. function onMouseDown(event) {
  16395. if (!hasSelectedBlock() && !hasMultiSelection()) {
  16396. return;
  16397. } // Only handle clicks on the element, not the children.
  16398. if (event.target !== node) {
  16399. return;
  16400. }
  16401. clearSelectedBlock();
  16402. }
  16403. node.addEventListener('mousedown', onMouseDown);
  16404. return () => {
  16405. node.removeEventListener('mousedown', onMouseDown);
  16406. };
  16407. }, [hasSelectedBlock, hasMultiSelection, clearSelectedBlock]);
  16408. }
  16409. function BlockSelectionClearer(props) {
  16410. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  16411. ref: useBlockSelectionClearer()
  16412. }, props));
  16413. }
  16414. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-multi-selection.js
  16415. /**
  16416. * External dependencies
  16417. */
  16418. /**
  16419. * WordPress dependencies
  16420. */
  16421. /**
  16422. * Internal dependencies
  16423. */
  16424. function selector(select) {
  16425. const {
  16426. isMultiSelecting,
  16427. getMultiSelectedBlockClientIds,
  16428. hasMultiSelection,
  16429. getSelectedBlockClientId,
  16430. getSelectedBlocksInitialCaretPosition,
  16431. __unstableIsFullySelected
  16432. } = select(store);
  16433. return {
  16434. isMultiSelecting: isMultiSelecting(),
  16435. multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),
  16436. hasMultiSelection: hasMultiSelection(),
  16437. selectedBlockClientId: getSelectedBlockClientId(),
  16438. initialPosition: getSelectedBlocksInitialCaretPosition(),
  16439. isFullSelection: __unstableIsFullySelected()
  16440. };
  16441. }
  16442. function useMultiSelection() {
  16443. const {
  16444. initialPosition,
  16445. isMultiSelecting,
  16446. multiSelectedBlockClientIds,
  16447. hasMultiSelection,
  16448. selectedBlockClientId,
  16449. isFullSelection
  16450. } = (0,external_wp_data_namespaceObject.useSelect)(selector, []);
  16451. const selectedRef = useBlockRef(selectedBlockClientId); // These must be in the right DOM order.
  16452. const startRef = useBlockRef((0,external_lodash_namespaceObject.first)(multiSelectedBlockClientIds));
  16453. const endRef = useBlockRef((0,external_lodash_namespaceObject.last)(multiSelectedBlockClientIds));
  16454. /**
  16455. * When the component updates, and there is multi selection, we need to
  16456. * select the entire block contents.
  16457. */
  16458. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  16459. const {
  16460. ownerDocument
  16461. } = node;
  16462. const {
  16463. defaultView
  16464. } = ownerDocument; // Allow initialPosition to bypass focus behavior. This is useful
  16465. // for the list view or other areas where we don't want to transfer
  16466. // focus to the editor canvas.
  16467. if (initialPosition === undefined || initialPosition === null) {
  16468. return;
  16469. }
  16470. if (!hasMultiSelection || isMultiSelecting) {
  16471. if (!selectedBlockClientId || isMultiSelecting) {
  16472. return;
  16473. }
  16474. const selection = defaultView.getSelection();
  16475. if (selection.rangeCount && !selection.isCollapsed) {
  16476. const blockNode = selectedRef.current;
  16477. const {
  16478. startContainer,
  16479. endContainer
  16480. } = selection.getRangeAt(0);
  16481. if (!!blockNode && (!blockNode.contains(startContainer) || !blockNode.contains(endContainer))) {
  16482. selection.removeAllRanges();
  16483. }
  16484. }
  16485. return;
  16486. }
  16487. const {
  16488. length
  16489. } = multiSelectedBlockClientIds;
  16490. if (length < 2) {
  16491. return;
  16492. }
  16493. if (!isFullSelection) {
  16494. return;
  16495. } // Allow cross contentEditable selection by temporarily making
  16496. // all content editable. We can't rely on using the store and
  16497. // React because re-rending happens too slowly. We need to be
  16498. // able to select across instances immediately.
  16499. node.contentEditable = true; // For some browsers, like Safari, it is important that focus happens
  16500. // BEFORE selection.
  16501. node.focus(); // The block refs might not be immediately available
  16502. // when dragging blocks into another block.
  16503. if (!startRef.current || !endRef.current) {
  16504. return;
  16505. }
  16506. const selection = defaultView.getSelection();
  16507. const range = ownerDocument.createRange(); // These must be in the right DOM order.
  16508. range.setStartBefore(startRef.current);
  16509. range.setEndAfter(endRef.current);
  16510. selection.removeAllRanges();
  16511. selection.addRange(range);
  16512. }, [hasMultiSelection, isMultiSelecting, multiSelectedBlockClientIds, selectedBlockClientId, initialPosition, isFullSelection]);
  16513. }
  16514. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-tab-nav.js
  16515. /**
  16516. * WordPress dependencies
  16517. */
  16518. /**
  16519. * Internal dependencies
  16520. */
  16521. function useTabNav() {
  16522. const container = (0,external_wp_element_namespaceObject.useRef)();
  16523. const focusCaptureBeforeRef = (0,external_wp_element_namespaceObject.useRef)();
  16524. const focusCaptureAfterRef = (0,external_wp_element_namespaceObject.useRef)();
  16525. const lastFocus = (0,external_wp_element_namespaceObject.useRef)();
  16526. const {
  16527. hasMultiSelection,
  16528. getSelectedBlockClientId,
  16529. getBlockCount
  16530. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  16531. const {
  16532. setNavigationMode
  16533. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  16534. const isNavigationMode = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isNavigationMode(), []); // Don't allow tabbing to this element in Navigation mode.
  16535. const focusCaptureTabIndex = !isNavigationMode ? '0' : undefined; // Reference that holds the a flag for enabling or disabling
  16536. // capturing on the focus capture elements.
  16537. const noCapture = (0,external_wp_element_namespaceObject.useRef)();
  16538. function onFocusCapture(event) {
  16539. // Do not capture incoming focus if set by us in WritingFlow.
  16540. if (noCapture.current) {
  16541. noCapture.current = null;
  16542. } else if (hasMultiSelection()) {
  16543. container.current.focus();
  16544. } else if (getSelectedBlockClientId()) {
  16545. lastFocus.current.focus();
  16546. } else {
  16547. setNavigationMode(true);
  16548. const isBefore = // eslint-disable-next-line no-bitwise
  16549. event.target.compareDocumentPosition(container.current) & event.target.DOCUMENT_POSITION_FOLLOWING;
  16550. const action = isBefore ? 'findNext' : 'findPrevious';
  16551. external_wp_dom_namespaceObject.focus.tabbable[action](event.target).focus();
  16552. }
  16553. }
  16554. const before = (0,external_wp_element_namespaceObject.createElement)("div", {
  16555. ref: focusCaptureBeforeRef,
  16556. tabIndex: focusCaptureTabIndex,
  16557. onFocus: onFocusCapture
  16558. });
  16559. const after = (0,external_wp_element_namespaceObject.createElement)("div", {
  16560. ref: focusCaptureAfterRef,
  16561. tabIndex: focusCaptureTabIndex,
  16562. onFocus: onFocusCapture
  16563. });
  16564. const ref = (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  16565. function onKeyDown(event) {
  16566. if (event.defaultPrevented) {
  16567. return;
  16568. }
  16569. if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !hasMultiSelection()) {
  16570. event.preventDefault();
  16571. setNavigationMode(true);
  16572. return;
  16573. } // In Edit mode, Tab should focus the first tabbable element after
  16574. // the content, which is normally the sidebar (with block controls)
  16575. // and Shift+Tab should focus the first tabbable element before the
  16576. // content, which is normally the block toolbar.
  16577. // Arrow keys can be used, and Tab and arrow keys can be used in
  16578. // Navigation mode (press Esc), to navigate through blocks.
  16579. if (event.keyCode !== external_wp_keycodes_namespaceObject.TAB) {
  16580. return;
  16581. }
  16582. const isShift = event.shiftKey;
  16583. const direction = isShift ? 'findPrevious' : 'findNext';
  16584. if (!hasMultiSelection() && !getSelectedBlockClientId()) {
  16585. // Preserve the behaviour of entering navigation mode when
  16586. // tabbing into the content without a block selection.
  16587. // `onFocusCapture` already did this previously, but we need to
  16588. // do it again here because after clearing block selection,
  16589. // focus land on the writing flow container and pressing Tab
  16590. // will no longer send focus through the focus capture element.
  16591. if (event.target === node) setNavigationMode(true);
  16592. return;
  16593. } // Allow tabbing from the block wrapper to a form element,
  16594. // and between form elements rendered in a block,
  16595. // such as inside a placeholder. Form elements are generally
  16596. // meant to be UI rather than part of the content. Ideally
  16597. // these are not rendered in the content and perhaps in the
  16598. // future they can be rendered in an iframe or shadow DOM.
  16599. 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))) {
  16600. return;
  16601. }
  16602. const next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef; // Disable focus capturing on the focus capture element, so it
  16603. // doesn't refocus this block and so it allows default behaviour
  16604. // (moving focus to the next tabbable element).
  16605. noCapture.current = true; // Focusing the focus capture element, which is located above and
  16606. // below the editor, should not scroll the page all the way up or
  16607. // down.
  16608. next.current.focus({
  16609. preventScroll: true
  16610. });
  16611. }
  16612. function onFocusOut(event) {
  16613. lastFocus.current = event.target;
  16614. const {
  16615. ownerDocument
  16616. } = node; // If focus disappears due to there being no blocks, move focus to
  16617. // the writing flow wrapper.
  16618. if (!event.relatedTarget && ownerDocument.activeElement === ownerDocument.body && getBlockCount() === 0) {
  16619. node.focus();
  16620. }
  16621. } // When tabbing back to an element in block list, this event handler prevents scrolling if the
  16622. // focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph
  16623. // when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the
  16624. // top or bottom of the document.
  16625. //
  16626. // Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this
  16627. // earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.
  16628. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters
  16629. function preventScrollOnTab(event) {
  16630. var _event$target;
  16631. if (event.keyCode !== external_wp_keycodes_namespaceObject.TAB) {
  16632. return;
  16633. }
  16634. if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getAttribute('role')) === 'region') {
  16635. return;
  16636. }
  16637. if (container.current === event.target) {
  16638. return;
  16639. }
  16640. const isShift = event.shiftKey;
  16641. const direction = isShift ? 'findPrevious' : 'findNext';
  16642. 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)
  16643. if (target === focusCaptureBeforeRef.current || target === focusCaptureAfterRef.current) {
  16644. event.preventDefault();
  16645. target.focus({
  16646. preventScroll: true
  16647. });
  16648. }
  16649. }
  16650. const {
  16651. ownerDocument
  16652. } = node;
  16653. const {
  16654. defaultView
  16655. } = ownerDocument;
  16656. defaultView.addEventListener('keydown', preventScrollOnTab);
  16657. node.addEventListener('keydown', onKeyDown);
  16658. node.addEventListener('focusout', onFocusOut);
  16659. return () => {
  16660. defaultView.removeEventListener('keydown', preventScrollOnTab);
  16661. node.removeEventListener('keydown', onKeyDown);
  16662. node.removeEventListener('focusout', onFocusOut);
  16663. };
  16664. }, []);
  16665. const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([container, ref]);
  16666. return [before, mergedRefs, after];
  16667. }
  16668. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-arrow-nav.js
  16669. /**
  16670. * External dependencies
  16671. */
  16672. /**
  16673. * WordPress dependencies
  16674. */
  16675. /**
  16676. * Internal dependencies
  16677. */
  16678. /**
  16679. * Returns true if the element should consider edge navigation upon a keyboard
  16680. * event of the given directional key code, or false otherwise.
  16681. *
  16682. * @param {Element} element HTML element to test.
  16683. * @param {number} keyCode KeyboardEvent keyCode to test.
  16684. * @param {boolean} hasModifier Whether a modifier is pressed.
  16685. *
  16686. * @return {boolean} Whether element should consider edge navigation.
  16687. */
  16688. function isNavigationCandidate(element, keyCode, hasModifier) {
  16689. const isVertical = keyCode === external_wp_keycodes_namespaceObject.UP || keyCode === external_wp_keycodes_namespaceObject.DOWN; // Currently, all elements support unmodified vertical navigation.
  16690. if (isVertical && !hasModifier) {
  16691. return true;
  16692. } // Native inputs should not navigate horizontally.
  16693. const {
  16694. tagName
  16695. } = element;
  16696. return tagName !== 'INPUT' && tagName !== 'TEXTAREA';
  16697. }
  16698. /**
  16699. * Returns the optimal tab target from the given focused element in the desired
  16700. * direction. A preference is made toward text fields, falling back to the block
  16701. * focus stop if no other candidates exist for the block.
  16702. *
  16703. * @param {Element} target Currently focused text field.
  16704. * @param {boolean} isReverse True if considering as the first field.
  16705. * @param {Element} containerElement Element containing all blocks.
  16706. * @param {boolean} onlyVertical Whether to only consider tabbable elements
  16707. * that are visually above or under the
  16708. * target.
  16709. *
  16710. * @return {?Element} Optimal tab target, if one exists.
  16711. */
  16712. function getClosestTabbable(target, isReverse, containerElement, onlyVertical) {
  16713. // Since the current focus target is not guaranteed to be a text field, find
  16714. // all focusables. Tabbability is considered later.
  16715. let focusableNodes = external_wp_dom_namespaceObject.focus.focusable.find(containerElement);
  16716. if (isReverse) {
  16717. focusableNodes = (0,external_lodash_namespaceObject.reverse)(focusableNodes);
  16718. } // Consider as candidates those focusables after the current target. It's
  16719. // assumed this can only be reached if the target is focusable (on its
  16720. // keydown event), so no need to verify it exists in the set.
  16721. focusableNodes = focusableNodes.slice(focusableNodes.indexOf(target) + 1);
  16722. let targetRect;
  16723. if (onlyVertical) {
  16724. targetRect = target.getBoundingClientRect();
  16725. }
  16726. function isTabCandidate(node) {
  16727. // Not a candidate if the node is not tabbable.
  16728. if (!external_wp_dom_namespaceObject.focus.tabbable.isTabbableIndex(node)) {
  16729. return false;
  16730. } // Skip focusable elements such as links within content editable nodes.
  16731. if (node.isContentEditable && node.contentEditable !== 'true') {
  16732. return false;
  16733. }
  16734. if (onlyVertical) {
  16735. const nodeRect = node.getBoundingClientRect();
  16736. if (nodeRect.left >= targetRect.right || nodeRect.right <= targetRect.left) {
  16737. return false;
  16738. }
  16739. }
  16740. return true;
  16741. }
  16742. return (0,external_lodash_namespaceObject.find)(focusableNodes, isTabCandidate);
  16743. }
  16744. function useArrowNav() {
  16745. const {
  16746. getSelectedBlockClientId,
  16747. getMultiSelectedBlocksEndClientId,
  16748. getPreviousBlockClientId,
  16749. getNextBlockClientId,
  16750. getSettings,
  16751. hasMultiSelection
  16752. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  16753. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  16754. // Here a DOMRect is stored while moving the caret vertically so
  16755. // vertical position of the start position can be restored. This is to
  16756. // recreate browser behaviour across blocks.
  16757. let verticalRect;
  16758. function onMouseDown() {
  16759. verticalRect = null;
  16760. }
  16761. /**
  16762. * Returns true if the given target field is the last in its block which
  16763. * can be considered for tab transition. For example, in a block with
  16764. * two text fields, this would return true when reversing from the first
  16765. * of the two fields, but false when reversing from the second.
  16766. *
  16767. * @param {Element} target Currently focused text field.
  16768. * @param {boolean} isReverse True if considering as the first field.
  16769. *
  16770. * @return {boolean} Whether field is at edge for tab transition.
  16771. */
  16772. function isTabbableEdge(target, isReverse) {
  16773. const closestTabbable = getClosestTabbable(target, isReverse, node);
  16774. return !closestTabbable || !isInSameBlock(target, closestTabbable);
  16775. }
  16776. function onKeyDown(event) {
  16777. const {
  16778. keyCode,
  16779. target
  16780. } = event;
  16781. const isUp = keyCode === external_wp_keycodes_namespaceObject.UP;
  16782. const isDown = keyCode === external_wp_keycodes_namespaceObject.DOWN;
  16783. const isLeft = keyCode === external_wp_keycodes_namespaceObject.LEFT;
  16784. const isRight = keyCode === external_wp_keycodes_namespaceObject.RIGHT;
  16785. const isReverse = isUp || isLeft;
  16786. const isHorizontal = isLeft || isRight;
  16787. const isVertical = isUp || isDown;
  16788. const isNav = isHorizontal || isVertical;
  16789. const isShift = event.shiftKey;
  16790. const hasModifier = isShift || event.ctrlKey || event.altKey || event.metaKey;
  16791. const isNavEdge = isVertical ? external_wp_dom_namespaceObject.isVerticalEdge : external_wp_dom_namespaceObject.isHorizontalEdge;
  16792. const {
  16793. ownerDocument
  16794. } = node;
  16795. const {
  16796. defaultView
  16797. } = ownerDocument;
  16798. if (hasMultiSelection()) {
  16799. return;
  16800. } // When presing any key other than up or down, the initial vertical
  16801. // position must ALWAYS be reset. The vertical position is saved so
  16802. // it can be restored as well as possible on sebsequent vertical
  16803. // arrow key presses. It may not always be possible to restore the
  16804. // exact same position (such as at an empty line), so it wouldn't be
  16805. // good to compute the position right before any vertical arrow key
  16806. // press.
  16807. if (!isVertical) {
  16808. verticalRect = null;
  16809. } else if (!verticalRect) {
  16810. verticalRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView);
  16811. } // Abort if navigation has already been handled (e.g. RichText
  16812. // inline boundaries).
  16813. if (event.defaultPrevented) {
  16814. return;
  16815. }
  16816. if (!isNav) {
  16817. return;
  16818. } // Abort if our current target is not a candidate for navigation
  16819. // (e.g. preserve native input behaviors).
  16820. if (!isNavigationCandidate(target, keyCode, hasModifier)) {
  16821. return;
  16822. } // In the case of RTL scripts, right means previous and left means
  16823. // next, which is the exact reverse of LTR.
  16824. const isReverseDir = (0,external_wp_dom_namespaceObject.isRTL)(target) ? !isReverse : isReverse;
  16825. const {
  16826. keepCaretInsideBlock
  16827. } = getSettings();
  16828. const selectedBlockClientId = getSelectedBlockClientId();
  16829. if (isShift) {
  16830. const selectionEndClientId = getMultiSelectedBlocksEndClientId();
  16831. const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
  16832. const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
  16833. if ( // Ensure that there is a target block.
  16834. (isReverse && selectionBeforeEndClientId || !isReverse && selectionAfterEndClientId) && isTabbableEdge(target, isReverse) && isNavEdge(target, isReverse)) {
  16835. node.contentEditable = true; // Firefox doesn't automatically move focus.
  16836. node.focus();
  16837. }
  16838. } else if (isVertical && (0,external_wp_dom_namespaceObject.isVerticalEdge)(target, isReverse) && !keepCaretInsideBlock) {
  16839. const closestTabbable = getClosestTabbable(target, isReverse, node, true);
  16840. if (closestTabbable) {
  16841. (0,external_wp_dom_namespaceObject.placeCaretAtVerticalEdge)(closestTabbable, isReverse, verticalRect);
  16842. event.preventDefault();
  16843. }
  16844. } else if (isHorizontal && defaultView.getSelection().isCollapsed && (0,external_wp_dom_namespaceObject.isHorizontalEdge)(target, isReverseDir) && !keepCaretInsideBlock) {
  16845. const closestTabbable = getClosestTabbable(target, isReverseDir, node);
  16846. (0,external_wp_dom_namespaceObject.placeCaretAtHorizontalEdge)(closestTabbable, isReverse);
  16847. event.preventDefault();
  16848. }
  16849. }
  16850. node.addEventListener('mousedown', onMouseDown);
  16851. node.addEventListener('keydown', onKeyDown);
  16852. return () => {
  16853. node.removeEventListener('mousedown', onMouseDown);
  16854. node.removeEventListener('keydown', onKeyDown);
  16855. };
  16856. }, []);
  16857. }
  16858. ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
  16859. var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
  16860. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-select-all.js
  16861. /**
  16862. * External dependencies
  16863. */
  16864. /**
  16865. * WordPress dependencies
  16866. */
  16867. /**
  16868. * Internal dependencies
  16869. */
  16870. function useSelectAll() {
  16871. const {
  16872. getBlockOrder,
  16873. getSelectedBlockClientIds,
  16874. getBlockRootClientId
  16875. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  16876. const {
  16877. multiSelect
  16878. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  16879. const isMatch = (0,external_wp_keyboardShortcuts_namespaceObject.__unstableUseShortcutEventMatch)();
  16880. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  16881. function onKeyDown(event) {
  16882. if (!isMatch('core/block-editor/select-all', event)) {
  16883. return;
  16884. }
  16885. const selectedClientIds = getSelectedBlockClientIds();
  16886. if (selectedClientIds.length < 2 && !(0,external_wp_dom_namespaceObject.isEntirelySelected)(event.target)) {
  16887. return;
  16888. }
  16889. const [firstSelectedClientId] = selectedClientIds;
  16890. const rootClientId = getBlockRootClientId(firstSelectedClientId);
  16891. let blockClientIds = getBlockOrder(rootClientId); // If we have selected all sibling nested blocks, try selecting up a
  16892. // level. See: https://github.com/WordPress/gutenberg/pull/31859/
  16893. if (selectedClientIds.length === blockClientIds.length) {
  16894. blockClientIds = getBlockOrder(getBlockRootClientId(rootClientId));
  16895. }
  16896. const firstClientId = (0,external_lodash_namespaceObject.first)(blockClientIds);
  16897. const lastClientId = (0,external_lodash_namespaceObject.last)(blockClientIds);
  16898. if (firstClientId === lastClientId) {
  16899. return;
  16900. }
  16901. multiSelect(firstClientId, lastClientId);
  16902. event.preventDefault();
  16903. }
  16904. node.addEventListener('keydown', onKeyDown);
  16905. return () => {
  16906. node.removeEventListener('keydown', onKeyDown);
  16907. };
  16908. }, []);
  16909. }
  16910. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-drag-selection.js
  16911. /**
  16912. * WordPress dependencies
  16913. */
  16914. /**
  16915. * Internal dependencies
  16916. */
  16917. /**
  16918. * Sets the `contenteditable` wrapper element to `value`.
  16919. *
  16920. * @param {HTMLElement} node Block element.
  16921. * @param {boolean} value `contentEditable` value (true or false)
  16922. */
  16923. function setContentEditableWrapper(node, value) {
  16924. node.contentEditable = value; // Firefox doesn't automatically move focus.
  16925. if (value) node.focus();
  16926. }
  16927. /**
  16928. * Sets a multi-selection based on the native selection across blocks.
  16929. */
  16930. function useDragSelection() {
  16931. const {
  16932. startMultiSelect,
  16933. stopMultiSelect
  16934. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  16935. const {
  16936. isSelectionEnabled,
  16937. hasMultiSelection
  16938. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  16939. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  16940. const {
  16941. ownerDocument
  16942. } = node;
  16943. const {
  16944. defaultView
  16945. } = ownerDocument;
  16946. let anchorElement;
  16947. let rafId;
  16948. function onMouseUp() {
  16949. stopMultiSelect(); // Equivalent to attaching the listener once.
  16950. defaultView.removeEventListener('mouseup', onMouseUp); // The browser selection won't have updated yet at this point,
  16951. // so wait until the next animation frame to get the browser
  16952. // selection.
  16953. rafId = defaultView.requestAnimationFrame(() => {
  16954. if (hasMultiSelection()) {
  16955. return;
  16956. } // If the selection is complete (on mouse up), and no
  16957. // multiple blocks have been selected, set focus back to the
  16958. // anchor element. if the anchor element contains the
  16959. // selection. Additionally, the contentEditable wrapper can
  16960. // now be disabled again.
  16961. setContentEditableWrapper(node, false);
  16962. const selection = defaultView.getSelection();
  16963. if (selection.rangeCount) {
  16964. const {
  16965. commonAncestorContainer
  16966. } = selection.getRangeAt(0);
  16967. if (anchorElement.contains(commonAncestorContainer)) {
  16968. anchorElement.focus();
  16969. }
  16970. }
  16971. });
  16972. }
  16973. function onMouseLeave(_ref) {
  16974. let {
  16975. buttons,
  16976. target
  16977. } = _ref;
  16978. // The primary button must be pressed to initiate selection.
  16979. // See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  16980. if (buttons !== 1) {
  16981. return;
  16982. } // Check the attribute, not the contentEditable attribute. All
  16983. // child elements of the content editable wrapper are editable
  16984. // and return true for this property. We only want to start
  16985. // multi selecting when the mouse leaves the wrapper.
  16986. if (!target.getAttribute('contenteditable')) {
  16987. return;
  16988. }
  16989. if (!isSelectionEnabled()) {
  16990. return;
  16991. }
  16992. anchorElement = ownerDocument.activeElement;
  16993. startMultiSelect(); // `onSelectionStart` is called after `mousedown` and
  16994. // `mouseleave` (from a block). The selection ends when
  16995. // `mouseup` happens anywhere in the window.
  16996. defaultView.addEventListener('mouseup', onMouseUp); // Allow cross contentEditable selection by temporarily making
  16997. // all content editable. We can't rely on using the store and
  16998. // React because re-rending happens too slowly. We need to be
  16999. // able to select across instances immediately.
  17000. setContentEditableWrapper(node, true);
  17001. }
  17002. node.addEventListener('mouseout', onMouseLeave);
  17003. return () => {
  17004. node.removeEventListener('mouseout', onMouseLeave);
  17005. defaultView.removeEventListener('mouseup', onMouseUp);
  17006. defaultView.cancelAnimationFrame(rafId);
  17007. };
  17008. }, [startMultiSelect, stopMultiSelect, isSelectionEnabled, hasMultiSelection]);
  17009. }
  17010. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-selection-observer.js
  17011. /**
  17012. * WordPress dependencies
  17013. */
  17014. /**
  17015. * Internal dependencies
  17016. */
  17017. /**
  17018. * Extract the selection start node from the selection. When the anchor node is
  17019. * not a text node, the selection offset is the index of a child node.
  17020. *
  17021. * @param {Selection} selection The selection.
  17022. *
  17023. * @return {Element} The selection start node.
  17024. */
  17025. function extractSelectionStartNode(selection) {
  17026. const {
  17027. anchorNode,
  17028. anchorOffset
  17029. } = selection;
  17030. if (anchorNode.nodeType === anchorNode.TEXT_NODE) {
  17031. return anchorNode;
  17032. }
  17033. return anchorNode.childNodes[anchorOffset];
  17034. }
  17035. /**
  17036. * Extract the selection end node from the selection. When the focus node is not
  17037. * a text node, the selection offset is the index of a child node. The selection
  17038. * reaches up to but excluding that child node.
  17039. *
  17040. * @param {Selection} selection The selection.
  17041. *
  17042. * @return {Element} The selection start node.
  17043. */
  17044. function extractSelectionEndNode(selection) {
  17045. const {
  17046. focusNode,
  17047. focusOffset
  17048. } = selection;
  17049. if (focusNode.nodeType === focusNode.TEXT_NODE) {
  17050. return focusNode;
  17051. }
  17052. return focusNode.childNodes[focusOffset - 1];
  17053. }
  17054. function findDepth(a, b) {
  17055. let depth = 0;
  17056. while (a[depth] === b[depth]) {
  17057. depth++;
  17058. }
  17059. return depth;
  17060. }
  17061. /**
  17062. * Sets the `contenteditable` wrapper element to `value`.
  17063. *
  17064. * @param {HTMLElement} node Block element.
  17065. * @param {boolean} value `contentEditable` value (true or false)
  17066. */
  17067. function use_selection_observer_setContentEditableWrapper(node, value) {
  17068. node.contentEditable = value; // Firefox doesn't automatically move focus.
  17069. if (value) node.focus();
  17070. }
  17071. /**
  17072. * Sets a multi-selection based on the native selection across blocks.
  17073. */
  17074. function useSelectionObserver() {
  17075. const {
  17076. multiSelect,
  17077. selectBlock,
  17078. selectionChange
  17079. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  17080. const {
  17081. getBlockParents,
  17082. getBlockSelectionStart
  17083. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  17084. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  17085. const {
  17086. ownerDocument
  17087. } = node;
  17088. const {
  17089. defaultView
  17090. } = ownerDocument;
  17091. function onSelectionChange(event) {
  17092. const selection = defaultView.getSelection(); // If no selection is found, end multi selection and disable the
  17093. // contentEditable wrapper.
  17094. if (!selection.rangeCount) {
  17095. use_selection_observer_setContentEditableWrapper(node, false);
  17096. return;
  17097. } // If selection is collapsed and we haven't used `shift+click`,
  17098. // end multi selection and disable the contentEditable wrapper.
  17099. // We have to check about `shift+click` case because elements
  17100. // that don't support text selection might be involved, and we might
  17101. // update the clientIds to multi-select blocks.
  17102. // For now we check if the event is a `mouse` event.
  17103. const isClickShift = event.shiftKey && event.type === 'mouseup';
  17104. if (selection.isCollapsed && !isClickShift) {
  17105. use_selection_observer_setContentEditableWrapper(node, false);
  17106. return;
  17107. }
  17108. let startClientId = getBlockClientId(extractSelectionStartNode(selection));
  17109. let endClientId = getBlockClientId(extractSelectionEndNode(selection)); // If the selection has changed and we had pressed `shift+click`,
  17110. // we need to check if in an element that doesn't support
  17111. // text selection has been clicked.
  17112. if (isClickShift) {
  17113. const selectedClientId = getBlockSelectionStart();
  17114. const clickedClientId = getBlockClientId(event.target); // `endClientId` is not defined if we end the selection by clicking a non-selectable block.
  17115. // We need to check if there was already a selection with a non-selectable focusNode.
  17116. const focusNodeIsNonSelectable = clickedClientId !== endClientId;
  17117. if (startClientId === endClientId && selection.isCollapsed || !endClientId || focusNodeIsNonSelectable) {
  17118. endClientId = clickedClientId;
  17119. } // Handle the case when we have a non-selectable block
  17120. // selected and click another one.
  17121. if (startClientId !== selectedClientId) {
  17122. startClientId = selectedClientId;
  17123. }
  17124. } // If the selection did not involve a block, return.
  17125. if (startClientId === undefined && endClientId === undefined) {
  17126. use_selection_observer_setContentEditableWrapper(node, false);
  17127. return;
  17128. }
  17129. const isSingularSelection = startClientId === endClientId;
  17130. if (isSingularSelection) {
  17131. selectBlock(startClientId);
  17132. } else {
  17133. const startPath = [...getBlockParents(startClientId), startClientId];
  17134. const endPath = [...getBlockParents(endClientId), endClientId];
  17135. const depth = findDepth(startPath, endPath);
  17136. multiSelect(startPath[depth], endPath[depth]);
  17137. }
  17138. }
  17139. function addListeners() {
  17140. ownerDocument.addEventListener('selectionchange', onSelectionChange);
  17141. defaultView.addEventListener('mouseup', onSelectionChange);
  17142. }
  17143. function removeListeners() {
  17144. ownerDocument.removeEventListener('selectionchange', onSelectionChange);
  17145. defaultView.removeEventListener('mouseup', onSelectionChange);
  17146. }
  17147. function resetListeners() {
  17148. removeListeners();
  17149. addListeners();
  17150. }
  17151. addListeners(); // We must allow rich text to set selection first. This ensures that
  17152. // our `selectionchange` listener is always reset to be called after
  17153. // the rich text one.
  17154. node.addEventListener('focusin', resetListeners);
  17155. return () => {
  17156. removeListeners();
  17157. node.removeEventListener('focusin', resetListeners);
  17158. };
  17159. }, [multiSelect, selectBlock, selectionChange, getBlockParents]);
  17160. }
  17161. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-click-selection.js
  17162. /**
  17163. * WordPress dependencies
  17164. */
  17165. /**
  17166. * Internal dependencies
  17167. */
  17168. function useClickSelection() {
  17169. const {
  17170. selectBlock
  17171. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  17172. const {
  17173. isSelectionEnabled,
  17174. getBlockSelectionStart,
  17175. hasMultiSelection
  17176. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  17177. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  17178. function onMouseDown(event) {
  17179. // The main button.
  17180. // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
  17181. if (!isSelectionEnabled() || event.button !== 0) {
  17182. return;
  17183. }
  17184. const startClientId = getBlockSelectionStart();
  17185. const clickedClientId = getBlockClientId(event.target);
  17186. if (event.shiftKey) {
  17187. if (startClientId !== clickedClientId) {
  17188. node.contentEditable = true; // Firefox doesn't automatically move focus.
  17189. node.focus();
  17190. }
  17191. } else if (hasMultiSelection()) {
  17192. // Allow user to escape out of a multi-selection to a
  17193. // singular selection of a block via click. This is handled
  17194. // here since focus handling excludes blocks when there is
  17195. // multiselection, as focus can be incurred by starting a
  17196. // multiselection (focus moved to first block's multi-
  17197. // controls).
  17198. selectBlock(clickedClientId);
  17199. }
  17200. }
  17201. node.addEventListener('mousedown', onMouseDown);
  17202. return () => {
  17203. node.removeEventListener('mousedown', onMouseDown);
  17204. };
  17205. }, [selectBlock, isSelectionEnabled, getBlockSelectionStart, hasMultiSelection]);
  17206. }
  17207. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-input.js
  17208. /**
  17209. * WordPress dependencies
  17210. */
  17211. /**
  17212. * Internal dependencies
  17213. */
  17214. /**
  17215. * Handles input for selections across blocks.
  17216. */
  17217. function useInput() {
  17218. const {
  17219. __unstableIsFullySelected,
  17220. getSelectedBlockClientIds,
  17221. __unstableIsSelectionMergeable,
  17222. hasMultiSelection
  17223. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  17224. const {
  17225. replaceBlocks,
  17226. __unstableSplitSelection,
  17227. removeBlocks,
  17228. __unstableDeleteSelection,
  17229. __unstableExpandSelection
  17230. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  17231. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  17232. function onKeyDown(event) {
  17233. if (event.defaultPrevented) {
  17234. return;
  17235. }
  17236. if (!hasMultiSelection()) {
  17237. return;
  17238. }
  17239. if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
  17240. node.contentEditable = false;
  17241. event.preventDefault();
  17242. if (__unstableIsFullySelected()) {
  17243. replaceBlocks(getSelectedBlockClientIds(), (0,external_wp_blocks_namespaceObject.createBlock)((0,external_wp_blocks_namespaceObject.getDefaultBlockName)()));
  17244. } else {
  17245. __unstableSplitSelection();
  17246. }
  17247. } else if (event.keyCode === external_wp_keycodes_namespaceObject.BACKSPACE || event.keyCode === external_wp_keycodes_namespaceObject.DELETE) {
  17248. node.contentEditable = false;
  17249. event.preventDefault();
  17250. if (__unstableIsFullySelected()) {
  17251. removeBlocks(getSelectedBlockClientIds());
  17252. } else if (__unstableIsSelectionMergeable()) {
  17253. __unstableDeleteSelection(event.keyCode === external_wp_keycodes_namespaceObject.DELETE);
  17254. } else {
  17255. __unstableExpandSelection();
  17256. }
  17257. } else if ( // If key.length is longer than 1, it's a control key that doesn't
  17258. // input anything.
  17259. event.key.length === 1 && !(event.metaKey || event.ctrlKey)) {
  17260. node.contentEditable = false;
  17261. if (__unstableIsSelectionMergeable()) {
  17262. __unstableDeleteSelection(event.keyCode === external_wp_keycodes_namespaceObject.DELETE);
  17263. } else {
  17264. event.preventDefault(); // Safari does not stop default behaviour with either
  17265. // event.preventDefault() or node.contentEditable = false, so
  17266. // remove the selection to stop browser manipulation.
  17267. node.ownerDocument.defaultView.getSelection().removeAllRanges();
  17268. }
  17269. }
  17270. }
  17271. function onCompositionStart(event) {
  17272. if (!hasMultiSelection()) {
  17273. return;
  17274. }
  17275. node.contentEditable = false;
  17276. if (__unstableIsSelectionMergeable()) {
  17277. __unstableDeleteSelection();
  17278. } else {
  17279. event.preventDefault(); // Safari does not stop default behaviour with either
  17280. // event.preventDefault() or node.contentEditable = false, so
  17281. // remove the selection to stop browser manipulation.
  17282. node.ownerDocument.defaultView.getSelection().removeAllRanges();
  17283. }
  17284. }
  17285. node.addEventListener('keydown', onKeyDown);
  17286. node.addEventListener('compositionstart', onCompositionStart);
  17287. return () => {
  17288. node.removeEventListener('keydown', onKeyDown);
  17289. node.removeEventListener('compositionstart', onCompositionStart);
  17290. };
  17291. }, []);
  17292. }
  17293. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/index.js
  17294. /**
  17295. * External dependencies
  17296. */
  17297. /**
  17298. * WordPress dependencies
  17299. */
  17300. /**
  17301. * Internal dependencies
  17302. */
  17303. function useWritingFlow() {
  17304. const [before, ref, after] = useTabNav();
  17305. const hasMultiSelection = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).hasMultiSelection(), []);
  17306. return [before, (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, useInput(), useDragSelection(), useSelectionObserver(), useClickSelection(), useMultiSelection(), useSelectAll(), useArrowNav(), (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  17307. node.tabIndex = -1;
  17308. node.contentEditable = hasMultiSelection;
  17309. if (!hasMultiSelection) {
  17310. return;
  17311. }
  17312. node.setAttribute('aria-label', (0,external_wp_i18n_namespaceObject.__)('Multiple selected blocks'));
  17313. return () => {
  17314. node.removeAttribute('aria-label');
  17315. };
  17316. }, [hasMultiSelection])]), after];
  17317. }
  17318. function WritingFlow(_ref, forwardedRef) {
  17319. let {
  17320. children,
  17321. ...props
  17322. } = _ref;
  17323. const [before, ref, after] = useWritingFlow();
  17324. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, before, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, props, {
  17325. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, forwardedRef]),
  17326. className: classnames_default()(props.className, 'block-editor-writing-flow')
  17327. }), children), after);
  17328. }
  17329. /**
  17330. * Handles selection and navigation across blocks. This component should be
  17331. * wrapped around BlockList.
  17332. *
  17333. * @param {Object} props Component properties.
  17334. * @param {WPElement} props.children Children to be rendered.
  17335. */
  17336. /* harmony default export */ var writing_flow = ((0,external_wp_element_namespaceObject.forwardRef)(WritingFlow));
  17337. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/iframe/index.js
  17338. /**
  17339. * External dependencies
  17340. */
  17341. /**
  17342. * WordPress dependencies
  17343. */
  17344. /**
  17345. * Internal dependencies
  17346. */
  17347. const BODY_CLASS_NAME = 'editor-styles-wrapper';
  17348. const BLOCK_PREFIX = 'wp-block';
  17349. /**
  17350. * Clones stylesheets targetting the editor canvas to the given document. A
  17351. * stylesheet is considered targetting the editor a canvas if it contains the
  17352. * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.
  17353. *
  17354. * Ideally, this hook should be removed in the future and styles should be added
  17355. * explicitly as editor styles.
  17356. */
  17357. function useStylesCompatibility() {
  17358. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  17359. // Search the document for stylesheets targetting the editor canvas.
  17360. Array.from(document.styleSheets).forEach(styleSheet => {
  17361. try {
  17362. // May fail for external styles.
  17363. // eslint-disable-next-line no-unused-expressions
  17364. styleSheet.cssRules;
  17365. } catch (e) {
  17366. return;
  17367. }
  17368. const {
  17369. ownerNode,
  17370. cssRules
  17371. } = styleSheet;
  17372. if (!cssRules) {
  17373. return;
  17374. } // Generally, ignore inline styles. We add inline styles belonging to a
  17375. // stylesheet later, which may or may not match the selectors.
  17376. if (ownerNode.tagName !== 'LINK') {
  17377. return;
  17378. } // Don't try to add the reset styles, which were removed as a dependency
  17379. // from `edit-blocks` for the iframe since we don't need to reset admin
  17380. // styles.
  17381. if (ownerNode.id === 'wp-reset-editor-styles-css') {
  17382. return;
  17383. }
  17384. const isMatch = Array.from(cssRules).find(_ref => {
  17385. let {
  17386. selectorText
  17387. } = _ref;
  17388. return selectorText && (selectorText.includes(`.${BODY_CLASS_NAME}`) || selectorText.includes(`.${BLOCK_PREFIX}`));
  17389. });
  17390. if (isMatch && !node.ownerDocument.getElementById(ownerNode.id)) {
  17391. // Display warning once we have a way to add style dependencies to the editor.
  17392. // See: https://github.com/WordPress/gutenberg/pull/37466.
  17393. node.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
  17394. const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
  17395. const inlineCssElement = document.getElementById(inlineCssId);
  17396. if (inlineCssElement) {
  17397. node.appendChild(inlineCssElement.cloneNode(true));
  17398. }
  17399. }
  17400. });
  17401. }, []);
  17402. }
  17403. /**
  17404. * Bubbles some event types (keydown, keypress, and dragover) to parent document
  17405. * document to ensure that the keyboard shortcuts and drag and drop work.
  17406. *
  17407. * Ideally, we should remove event bubbling in the future. Keyboard shortcuts
  17408. * should be context dependent, e.g. actions on blocks like Cmd+A should not
  17409. * work globally outside the block editor.
  17410. *
  17411. * @param {Document} doc Document to attach listeners to.
  17412. */
  17413. function bubbleEvents(doc) {
  17414. const {
  17415. defaultView
  17416. } = doc;
  17417. const {
  17418. frameElement
  17419. } = defaultView;
  17420. function bubbleEvent(event) {
  17421. const prototype = Object.getPrototypeOf(event);
  17422. const constructorName = prototype.constructor.name;
  17423. const Constructor = window[constructorName];
  17424. const init = {};
  17425. for (const key in event) {
  17426. init[key] = event[key];
  17427. }
  17428. if (event instanceof defaultView.MouseEvent) {
  17429. const rect = frameElement.getBoundingClientRect();
  17430. init.clientX += rect.left;
  17431. init.clientY += rect.top;
  17432. }
  17433. const newEvent = new Constructor(event.type, init);
  17434. const cancelled = !frameElement.dispatchEvent(newEvent);
  17435. if (cancelled) {
  17436. event.preventDefault();
  17437. }
  17438. }
  17439. const eventTypes = ['dragover'];
  17440. for (const name of eventTypes) {
  17441. doc.addEventListener(name, bubbleEvent);
  17442. }
  17443. }
  17444. function useParsedAssets(html) {
  17445. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  17446. const doc = document.implementation.createHTMLDocument('');
  17447. doc.body.innerHTML = html;
  17448. return Array.from(doc.body.children);
  17449. }, [html]);
  17450. }
  17451. async function loadScript(head, _ref2) {
  17452. let {
  17453. id,
  17454. src
  17455. } = _ref2;
  17456. return new Promise((resolve, reject) => {
  17457. const script = head.ownerDocument.createElement('script');
  17458. script.id = id;
  17459. if (src) {
  17460. script.src = src;
  17461. script.onload = () => resolve();
  17462. script.onerror = () => reject();
  17463. } else {
  17464. resolve();
  17465. }
  17466. head.appendChild(script);
  17467. });
  17468. }
  17469. function Iframe(_ref3, ref) {
  17470. let {
  17471. contentRef,
  17472. children,
  17473. head,
  17474. tabIndex = 0,
  17475. assets,
  17476. ...props
  17477. } = _ref3;
  17478. const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(() => ({}));
  17479. const [iframeDocument, setIframeDocument] = (0,external_wp_element_namespaceObject.useState)();
  17480. const [bodyClasses, setBodyClasses] = (0,external_wp_element_namespaceObject.useState)([]);
  17481. const styles = useParsedAssets(assets === null || assets === void 0 ? void 0 : assets.styles);
  17482. const scripts = useParsedAssets(assets === null || assets === void 0 ? void 0 : assets.scripts);
  17483. const clearerRef = useBlockSelectionClearer();
  17484. const [before, writingFlowRef, after] = useWritingFlow();
  17485. const setRef = (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  17486. function setDocumentIfReady() {
  17487. const {
  17488. contentDocument,
  17489. ownerDocument
  17490. } = node;
  17491. const {
  17492. readyState,
  17493. documentElement
  17494. } = contentDocument;
  17495. if (readyState !== 'interactive' && readyState !== 'complete') {
  17496. return false;
  17497. }
  17498. bubbleEvents(contentDocument);
  17499. setIframeDocument(contentDocument);
  17500. clearerRef(documentElement); // Ideally ALL classes that are added through get_body_class should
  17501. // be added in the editor too, which we'll somehow have to get from
  17502. // the server in the future (which will run the PHP filters).
  17503. setBodyClasses(Array.from(ownerDocument.body.classList).filter(name => name.startsWith('admin-color-') || name.startsWith('post-type-') || name === 'wp-embed-responsive'));
  17504. contentDocument.dir = ownerDocument.dir;
  17505. documentElement.removeChild(contentDocument.head);
  17506. documentElement.removeChild(contentDocument.body);
  17507. return true;
  17508. } // Document set with srcDoc is not immediately ready.
  17509. node.addEventListener('load', setDocumentIfReady);
  17510. return () => node.removeEventListener('load', setDocumentIfReady);
  17511. }, []);
  17512. const headRef = (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  17513. scripts.reduce((promise, script) => promise.then(() => loadScript(element, script)), Promise.resolve()).finally(() => {
  17514. // When script are loaded, re-render blocks to allow them
  17515. // to initialise.
  17516. forceRender();
  17517. });
  17518. }, []);
  17519. const bodyRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([contentRef, clearerRef, writingFlowRef]);
  17520. const styleCompatibilityRef = useStylesCompatibility();
  17521. head = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("style", null, 'body{margin:0}'), styles.map(_ref4 => {
  17522. let {
  17523. tagName,
  17524. href,
  17525. id,
  17526. rel,
  17527. media,
  17528. textContent
  17529. } = _ref4;
  17530. const TagName = tagName.toLowerCase();
  17531. if (TagName === 'style') {
  17532. return (0,external_wp_element_namespaceObject.createElement)(TagName, {
  17533. id,
  17534. key: id
  17535. }, textContent);
  17536. }
  17537. return (0,external_wp_element_namespaceObject.createElement)(TagName, {
  17538. href,
  17539. id,
  17540. rel,
  17541. media,
  17542. key: id
  17543. });
  17544. }), head);
  17545. 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, {
  17546. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, setRef]),
  17547. tabIndex: tabIndex // Correct doctype is required to enable rendering in standards mode
  17548. ,
  17549. srcDoc: "<!doctype html>",
  17550. title: (0,external_wp_i18n_namespaceObject.__)('Editor canvas')
  17551. }), 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", {
  17552. ref: headRef
  17553. }, head), (0,external_wp_element_namespaceObject.createElement)("body", {
  17554. ref: bodyRef,
  17555. className: classnames_default()(BODY_CLASS_NAME, ...bodyClasses)
  17556. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  17557. style: {
  17558. display: 'none'
  17559. },
  17560. ref: styleCompatibilityRef
  17561. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
  17562. document: iframeDocument
  17563. }, children))), iframeDocument.documentElement)), tabIndex >= 0 && after);
  17564. }
  17565. /* harmony default export */ var iframe = ((0,external_wp_element_namespaceObject.forwardRef)(Iframe));
  17566. ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs
  17567. 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()})};
  17568. ;// CONCATENATED MODULE: ./node_modules/colord/plugins/names.mjs
  17569. /* 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"])}
  17570. ;// CONCATENATED MODULE: ./node_modules/colord/plugins/a11y.mjs
  17571. 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}}
  17572. // EXTERNAL MODULE: ./node_modules/traverse/index.js
  17573. var traverse = __webpack_require__(3124);
  17574. var traverse_default = /*#__PURE__*/__webpack_require__.n(traverse);
  17575. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/parse.js
  17576. /* eslint-disable @wordpress/no-unused-vars-before-return */
  17577. // Adapted from https://github.com/reworkcss/css
  17578. // because we needed to remove source map support.
  17579. // http://www.w3.org/TR/CSS21/grammar.htm
  17580. // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
  17581. const commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
  17582. /* harmony default export */ function parse(css, options) {
  17583. options = options || {};
  17584. /**
  17585. * Positional.
  17586. */
  17587. let lineno = 1;
  17588. let column = 1;
  17589. /**
  17590. * Update lineno and column based on `str`.
  17591. */
  17592. function updatePosition(str) {
  17593. const lines = str.match(/\n/g);
  17594. if (lines) {
  17595. lineno += lines.length;
  17596. }
  17597. const i = str.lastIndexOf('\n'); // eslint-disable-next-line no-bitwise
  17598. column = ~i ? str.length - i : column + str.length;
  17599. }
  17600. /**
  17601. * Mark position and patch `node.position`.
  17602. */
  17603. function position() {
  17604. const start = {
  17605. line: lineno,
  17606. column
  17607. };
  17608. return function (node) {
  17609. node.position = new Position(start);
  17610. whitespace();
  17611. return node;
  17612. };
  17613. }
  17614. /**
  17615. * Store position information for a node
  17616. */
  17617. function Position(start) {
  17618. this.start = start;
  17619. this.end = {
  17620. line: lineno,
  17621. column
  17622. };
  17623. this.source = options.source;
  17624. }
  17625. /**
  17626. * Non-enumerable source string
  17627. */
  17628. Position.prototype.content = css;
  17629. /**
  17630. * Error `msg`.
  17631. */
  17632. const errorsList = [];
  17633. function error(msg) {
  17634. const err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
  17635. err.reason = msg;
  17636. err.filename = options.source;
  17637. err.line = lineno;
  17638. err.column = column;
  17639. err.source = css;
  17640. if (options.silent) {
  17641. errorsList.push(err);
  17642. } else {
  17643. throw err;
  17644. }
  17645. }
  17646. /**
  17647. * Parse stylesheet.
  17648. */
  17649. function stylesheet() {
  17650. const rulesList = rules();
  17651. return {
  17652. type: 'stylesheet',
  17653. stylesheet: {
  17654. source: options.source,
  17655. rules: rulesList,
  17656. parsingErrors: errorsList
  17657. }
  17658. };
  17659. }
  17660. /**
  17661. * Opening brace.
  17662. */
  17663. function open() {
  17664. return match(/^{\s*/);
  17665. }
  17666. /**
  17667. * Closing brace.
  17668. */
  17669. function close() {
  17670. return match(/^}/);
  17671. }
  17672. /**
  17673. * Parse ruleset.
  17674. */
  17675. function rules() {
  17676. let node;
  17677. const accumulator = [];
  17678. whitespace();
  17679. comments(accumulator);
  17680. while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
  17681. if (node !== false) {
  17682. accumulator.push(node);
  17683. comments(accumulator);
  17684. }
  17685. }
  17686. return accumulator;
  17687. }
  17688. /**
  17689. * Match `re` and return captures.
  17690. */
  17691. function match(re) {
  17692. const m = re.exec(css);
  17693. if (!m) {
  17694. return;
  17695. }
  17696. const str = m[0];
  17697. updatePosition(str);
  17698. css = css.slice(str.length);
  17699. return m;
  17700. }
  17701. /**
  17702. * Parse whitespace.
  17703. */
  17704. function whitespace() {
  17705. match(/^\s*/);
  17706. }
  17707. /**
  17708. * Parse comments;
  17709. */
  17710. function comments(accumulator) {
  17711. let c;
  17712. accumulator = accumulator || []; // eslint-disable-next-line no-cond-assign
  17713. while (c = comment()) {
  17714. if (c !== false) {
  17715. accumulator.push(c);
  17716. }
  17717. }
  17718. return accumulator;
  17719. }
  17720. /**
  17721. * Parse comment.
  17722. */
  17723. function comment() {
  17724. const pos = position();
  17725. if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
  17726. return;
  17727. }
  17728. let i = 2;
  17729. while ('' !== css.charAt(i) && ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
  17730. ++i;
  17731. }
  17732. i += 2;
  17733. if ('' === css.charAt(i - 1)) {
  17734. return error('End of comment missing');
  17735. }
  17736. const str = css.slice(2, i - 2);
  17737. column += 2;
  17738. updatePosition(str);
  17739. css = css.slice(i);
  17740. column += 2;
  17741. return pos({
  17742. type: 'comment',
  17743. comment: str
  17744. });
  17745. }
  17746. /**
  17747. * Parse selector.
  17748. */
  17749. function selector() {
  17750. const m = match(/^([^{]+)/);
  17751. if (!m) {
  17752. return;
  17753. } // FIXME: Remove all comments from selectors http://ostermiller.org/findcomment.html
  17754. return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '').replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (matched) {
  17755. return matched.replace(/,/g, '\u200C');
  17756. }).split(/\s*(?![^(]*\)),\s*/).map(function (s) {
  17757. return s.replace(/\u200C/g, ',');
  17758. });
  17759. }
  17760. /**
  17761. * Parse declaration.
  17762. */
  17763. function declaration() {
  17764. const pos = position(); // prop.
  17765. let prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
  17766. if (!prop) {
  17767. return;
  17768. }
  17769. prop = trim(prop[0]); // :
  17770. if (!match(/^:\s*/)) {
  17771. return error("property missing ':'");
  17772. } // val.
  17773. const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
  17774. const ret = pos({
  17775. type: 'declaration',
  17776. property: prop.replace(commentre, ''),
  17777. value: val ? trim(val[0]).replace(commentre, '') : ''
  17778. }); // ;
  17779. match(/^[;\s]*/);
  17780. return ret;
  17781. }
  17782. /**
  17783. * Parse declarations.
  17784. */
  17785. function declarations() {
  17786. const decls = [];
  17787. if (!open()) {
  17788. return error("missing '{'");
  17789. }
  17790. comments(decls); // declarations.
  17791. let decl; // eslint-disable-next-line no-cond-assign
  17792. while (decl = declaration()) {
  17793. if (decl !== false) {
  17794. decls.push(decl);
  17795. comments(decls);
  17796. }
  17797. }
  17798. if (!close()) {
  17799. return error("missing '}'");
  17800. }
  17801. return decls;
  17802. }
  17803. /**
  17804. * Parse keyframe.
  17805. */
  17806. function keyframe() {
  17807. let m;
  17808. const vals = [];
  17809. const pos = position(); // eslint-disable-next-line no-cond-assign
  17810. while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
  17811. vals.push(m[1]);
  17812. match(/^,\s*/);
  17813. }
  17814. if (!vals.length) {
  17815. return;
  17816. }
  17817. return pos({
  17818. type: 'keyframe',
  17819. values: vals,
  17820. declarations: declarations()
  17821. });
  17822. }
  17823. /**
  17824. * Parse keyframes.
  17825. */
  17826. function atkeyframes() {
  17827. const pos = position();
  17828. let m = match(/^@([-\w]+)?keyframes\s*/);
  17829. if (!m) {
  17830. return;
  17831. }
  17832. const vendor = m[1]; // identifier
  17833. m = match(/^([-\w]+)\s*/);
  17834. if (!m) {
  17835. return error('@keyframes missing name');
  17836. }
  17837. const name = m[1];
  17838. if (!open()) {
  17839. return error("@keyframes missing '{'");
  17840. }
  17841. let frame;
  17842. let frames = comments(); // eslint-disable-next-line no-cond-assign
  17843. while (frame = keyframe()) {
  17844. frames.push(frame);
  17845. frames = frames.concat(comments());
  17846. }
  17847. if (!close()) {
  17848. return error("@keyframes missing '}'");
  17849. }
  17850. return pos({
  17851. type: 'keyframes',
  17852. name,
  17853. vendor,
  17854. keyframes: frames
  17855. });
  17856. }
  17857. /**
  17858. * Parse supports.
  17859. */
  17860. function atsupports() {
  17861. const pos = position();
  17862. const m = match(/^@supports *([^{]+)/);
  17863. if (!m) {
  17864. return;
  17865. }
  17866. const supports = trim(m[1]);
  17867. if (!open()) {
  17868. return error("@supports missing '{'");
  17869. }
  17870. const style = comments().concat(rules());
  17871. if (!close()) {
  17872. return error("@supports missing '}'");
  17873. }
  17874. return pos({
  17875. type: 'supports',
  17876. supports,
  17877. rules: style
  17878. });
  17879. }
  17880. /**
  17881. * Parse host.
  17882. */
  17883. function athost() {
  17884. const pos = position();
  17885. const m = match(/^@host\s*/);
  17886. if (!m) {
  17887. return;
  17888. }
  17889. if (!open()) {
  17890. return error("@host missing '{'");
  17891. }
  17892. const style = comments().concat(rules());
  17893. if (!close()) {
  17894. return error("@host missing '}'");
  17895. }
  17896. return pos({
  17897. type: 'host',
  17898. rules: style
  17899. });
  17900. }
  17901. /**
  17902. * Parse media.
  17903. */
  17904. function atmedia() {
  17905. const pos = position();
  17906. const m = match(/^@media *([^{]+)/);
  17907. if (!m) {
  17908. return;
  17909. }
  17910. const media = trim(m[1]);
  17911. if (!open()) {
  17912. return error("@media missing '{'");
  17913. }
  17914. const style = comments().concat(rules());
  17915. if (!close()) {
  17916. return error("@media missing '}'");
  17917. }
  17918. return pos({
  17919. type: 'media',
  17920. media,
  17921. rules: style
  17922. });
  17923. }
  17924. /**
  17925. * Parse custom-media.
  17926. */
  17927. function atcustommedia() {
  17928. const pos = position();
  17929. const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
  17930. if (!m) {
  17931. return;
  17932. }
  17933. return pos({
  17934. type: 'custom-media',
  17935. name: trim(m[1]),
  17936. media: trim(m[2])
  17937. });
  17938. }
  17939. /**
  17940. * Parse paged media.
  17941. */
  17942. function atpage() {
  17943. const pos = position();
  17944. const m = match(/^@page */);
  17945. if (!m) {
  17946. return;
  17947. }
  17948. const sel = selector() || [];
  17949. if (!open()) {
  17950. return error("@page missing '{'");
  17951. }
  17952. let decls = comments(); // declarations.
  17953. let decl; // eslint-disable-next-line no-cond-assign
  17954. while (decl = declaration()) {
  17955. decls.push(decl);
  17956. decls = decls.concat(comments());
  17957. }
  17958. if (!close()) {
  17959. return error("@page missing '}'");
  17960. }
  17961. return pos({
  17962. type: 'page',
  17963. selectors: sel,
  17964. declarations: decls
  17965. });
  17966. }
  17967. /**
  17968. * Parse document.
  17969. */
  17970. function atdocument() {
  17971. const pos = position();
  17972. const m = match(/^@([-\w]+)?document *([^{]+)/);
  17973. if (!m) {
  17974. return;
  17975. }
  17976. const vendor = trim(m[1]);
  17977. const doc = trim(m[2]);
  17978. if (!open()) {
  17979. return error("@document missing '{'");
  17980. }
  17981. const style = comments().concat(rules());
  17982. if (!close()) {
  17983. return error("@document missing '}'");
  17984. }
  17985. return pos({
  17986. type: 'document',
  17987. document: doc,
  17988. vendor,
  17989. rules: style
  17990. });
  17991. }
  17992. /**
  17993. * Parse font-face.
  17994. */
  17995. function atfontface() {
  17996. const pos = position();
  17997. const m = match(/^@font-face\s*/);
  17998. if (!m) {
  17999. return;
  18000. }
  18001. if (!open()) {
  18002. return error("@font-face missing '{'");
  18003. }
  18004. let decls = comments(); // declarations.
  18005. let decl; // eslint-disable-next-line no-cond-assign
  18006. while (decl = declaration()) {
  18007. decls.push(decl);
  18008. decls = decls.concat(comments());
  18009. }
  18010. if (!close()) {
  18011. return error("@font-face missing '}'");
  18012. }
  18013. return pos({
  18014. type: 'font-face',
  18015. declarations: decls
  18016. });
  18017. }
  18018. /**
  18019. * Parse import
  18020. */
  18021. const atimport = _compileAtrule('import');
  18022. /**
  18023. * Parse charset
  18024. */
  18025. const atcharset = _compileAtrule('charset');
  18026. /**
  18027. * Parse namespace
  18028. */
  18029. const atnamespace = _compileAtrule('namespace');
  18030. /**
  18031. * Parse non-block at-rules
  18032. */
  18033. function _compileAtrule(name) {
  18034. const re = new RegExp('^@' + name + '\\s*([^;]+);');
  18035. return function () {
  18036. const pos = position();
  18037. const m = match(re);
  18038. if (!m) {
  18039. return;
  18040. }
  18041. const ret = {
  18042. type: name
  18043. };
  18044. ret[name] = m[1].trim();
  18045. return pos(ret);
  18046. };
  18047. }
  18048. /**
  18049. * Parse at rule.
  18050. */
  18051. function atrule() {
  18052. if (css[0] !== '@') {
  18053. return;
  18054. }
  18055. return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface();
  18056. }
  18057. /**
  18058. * Parse rule.
  18059. */
  18060. function rule() {
  18061. const pos = position();
  18062. const sel = selector();
  18063. if (!sel) {
  18064. return error('selector missing');
  18065. }
  18066. comments();
  18067. return pos({
  18068. type: 'rule',
  18069. selectors: sel,
  18070. declarations: declarations()
  18071. });
  18072. }
  18073. return addParent(stylesheet());
  18074. }
  18075. /**
  18076. * Trim `str`.
  18077. */
  18078. function trim(str) {
  18079. return str ? str.replace(/^\s+|\s+$/g, '') : '';
  18080. }
  18081. /**
  18082. * Adds non-enumerable parent node reference to each node.
  18083. */
  18084. function addParent(obj, parent) {
  18085. const isNode = obj && typeof obj.type === 'string';
  18086. const childParent = isNode ? obj : parent;
  18087. for (const k in obj) {
  18088. const value = obj[k];
  18089. if (Array.isArray(value)) {
  18090. value.forEach(function (v) {
  18091. addParent(v, childParent);
  18092. });
  18093. } else if (value && typeof value === 'object') {
  18094. addParent(value, childParent);
  18095. }
  18096. }
  18097. if (isNode) {
  18098. Object.defineProperty(obj, 'parent', {
  18099. configurable: true,
  18100. writable: true,
  18101. enumerable: false,
  18102. value: parent || null
  18103. });
  18104. }
  18105. return obj;
  18106. }
  18107. /* eslint-enable @wordpress/no-unused-vars-before-return */
  18108. // EXTERNAL MODULE: ./node_modules/inherits/inherits_browser.js
  18109. var inherits_browser = __webpack_require__(8575);
  18110. var inherits_browser_default = /*#__PURE__*/__webpack_require__.n(inherits_browser);
  18111. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/compiler.js
  18112. // Adapted from https://github.com/reworkcss/css
  18113. // because we needed to remove source map support.
  18114. /**
  18115. * Expose `Compiler`.
  18116. */
  18117. /* harmony default export */ var compiler = (Compiler);
  18118. /**
  18119. * Initialize a compiler.
  18120. */
  18121. function Compiler(opts) {
  18122. this.options = opts || {};
  18123. }
  18124. /**
  18125. * Emit `str`
  18126. */
  18127. Compiler.prototype.emit = function (str) {
  18128. return str;
  18129. };
  18130. /**
  18131. * Visit `node`.
  18132. */
  18133. Compiler.prototype.visit = function (node) {
  18134. return this[node.type](node);
  18135. };
  18136. /**
  18137. * Map visit over array of `nodes`, optionally using a `delim`
  18138. */
  18139. Compiler.prototype.mapVisit = function (nodes, delim) {
  18140. let buf = '';
  18141. delim = delim || '';
  18142. for (let i = 0, length = nodes.length; i < length; i++) {
  18143. buf += this.visit(nodes[i]);
  18144. if (delim && i < length - 1) {
  18145. buf += this.emit(delim);
  18146. }
  18147. }
  18148. return buf;
  18149. };
  18150. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/compress.js
  18151. // Adapted from https://github.com/reworkcss/css
  18152. // because we needed to remove source map support.
  18153. /**
  18154. * External dependencies
  18155. */
  18156. /**
  18157. * Internal dependencies
  18158. */
  18159. /**
  18160. * Expose compiler.
  18161. */
  18162. /* harmony default export */ var compress = (compress_Compiler);
  18163. /**
  18164. * Initialize a new `Compiler`.
  18165. */
  18166. function compress_Compiler(options) {
  18167. compiler.call(this, options);
  18168. }
  18169. /**
  18170. * Inherit from `Base.prototype`.
  18171. */
  18172. inherits_browser_default()(compress_Compiler, compiler);
  18173. /**
  18174. * Compile `node`.
  18175. */
  18176. compress_Compiler.prototype.compile = function (node) {
  18177. return node.stylesheet.rules.map(this.visit, this).join('');
  18178. };
  18179. /**
  18180. * Visit comment node.
  18181. */
  18182. compress_Compiler.prototype.comment = function (node) {
  18183. return this.emit('', node.position);
  18184. };
  18185. /**
  18186. * Visit import node.
  18187. */
  18188. compress_Compiler.prototype.import = function (node) {
  18189. return this.emit('@import ' + node.import + ';', node.position);
  18190. };
  18191. /**
  18192. * Visit media node.
  18193. */
  18194. compress_Compiler.prototype.media = function (node) {
  18195. return this.emit('@media ' + node.media, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  18196. };
  18197. /**
  18198. * Visit document node.
  18199. */
  18200. compress_Compiler.prototype.document = function (node) {
  18201. const doc = '@' + (node.vendor || '') + 'document ' + node.document;
  18202. return this.emit(doc, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  18203. };
  18204. /**
  18205. * Visit charset node.
  18206. */
  18207. compress_Compiler.prototype.charset = function (node) {
  18208. return this.emit('@charset ' + node.charset + ';', node.position);
  18209. };
  18210. /**
  18211. * Visit namespace node.
  18212. */
  18213. compress_Compiler.prototype.namespace = function (node) {
  18214. return this.emit('@namespace ' + node.namespace + ';', node.position);
  18215. };
  18216. /**
  18217. * Visit supports node.
  18218. */
  18219. compress_Compiler.prototype.supports = function (node) {
  18220. return this.emit('@supports ' + node.supports, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  18221. };
  18222. /**
  18223. * Visit keyframes node.
  18224. */
  18225. compress_Compiler.prototype.keyframes = function (node) {
  18226. return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit('{') + this.mapVisit(node.keyframes) + this.emit('}');
  18227. };
  18228. /**
  18229. * Visit keyframe node.
  18230. */
  18231. compress_Compiler.prototype.keyframe = function (node) {
  18232. const decls = node.declarations;
  18233. return this.emit(node.values.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
  18234. };
  18235. /**
  18236. * Visit page node.
  18237. */
  18238. compress_Compiler.prototype.page = function (node) {
  18239. const sel = node.selectors.length ? node.selectors.join(', ') : '';
  18240. return this.emit('@page ' + sel, node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
  18241. };
  18242. /**
  18243. * Visit font-face node.
  18244. */
  18245. compress_Compiler.prototype['font-face'] = function (node) {
  18246. return this.emit('@font-face', node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
  18247. };
  18248. /**
  18249. * Visit host node.
  18250. */
  18251. compress_Compiler.prototype.host = function (node) {
  18252. return this.emit('@host', node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  18253. };
  18254. /**
  18255. * Visit custom-media node.
  18256. */
  18257. compress_Compiler.prototype['custom-media'] = function (node) {
  18258. return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
  18259. };
  18260. /**
  18261. * Visit rule node.
  18262. */
  18263. compress_Compiler.prototype.rule = function (node) {
  18264. const decls = node.declarations;
  18265. if (!decls.length) {
  18266. return '';
  18267. }
  18268. return this.emit(node.selectors.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
  18269. };
  18270. /**
  18271. * Visit declaration node.
  18272. */
  18273. compress_Compiler.prototype.declaration = function (node) {
  18274. return this.emit(node.property + ':' + node.value, node.position) + this.emit(';');
  18275. };
  18276. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/identity.js
  18277. /* eslint-disable @wordpress/no-unused-vars-before-return */
  18278. // Adapted from https://github.com/reworkcss/css
  18279. // because we needed to remove source map support.
  18280. /**
  18281. * External dependencies
  18282. */
  18283. /**
  18284. * Internal dependencies
  18285. */
  18286. /**
  18287. * Expose compiler.
  18288. */
  18289. /* harmony default export */ var identity = (identity_Compiler);
  18290. /**
  18291. * Initialize a new `Compiler`.
  18292. */
  18293. function identity_Compiler(options) {
  18294. options = options || {};
  18295. compiler.call(this, options);
  18296. this.indentation = options.indent;
  18297. }
  18298. /**
  18299. * Inherit from `Base.prototype`.
  18300. */
  18301. inherits_browser_default()(identity_Compiler, compiler);
  18302. /**
  18303. * Compile `node`.
  18304. */
  18305. identity_Compiler.prototype.compile = function (node) {
  18306. return this.stylesheet(node);
  18307. };
  18308. /**
  18309. * Visit stylesheet node.
  18310. */
  18311. identity_Compiler.prototype.stylesheet = function (node) {
  18312. return this.mapVisit(node.stylesheet.rules, '\n\n');
  18313. };
  18314. /**
  18315. * Visit comment node.
  18316. */
  18317. identity_Compiler.prototype.comment = function (node) {
  18318. return this.emit(this.indent() + '/*' + node.comment + '*/', node.position);
  18319. };
  18320. /**
  18321. * Visit import node.
  18322. */
  18323. identity_Compiler.prototype.import = function (node) {
  18324. return this.emit('@import ' + node.import + ';', node.position);
  18325. };
  18326. /**
  18327. * Visit media node.
  18328. */
  18329. identity_Compiler.prototype.media = function (node) {
  18330. 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}');
  18331. };
  18332. /**
  18333. * Visit document node.
  18334. */
  18335. identity_Compiler.prototype.document = function (node) {
  18336. const doc = '@' + (node.vendor || '') + 'document ' + node.document;
  18337. return this.emit(doc, node.position) + this.emit(' ' + ' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  18338. };
  18339. /**
  18340. * Visit charset node.
  18341. */
  18342. identity_Compiler.prototype.charset = function (node) {
  18343. return this.emit('@charset ' + node.charset + ';', node.position);
  18344. };
  18345. /**
  18346. * Visit namespace node.
  18347. */
  18348. identity_Compiler.prototype.namespace = function (node) {
  18349. return this.emit('@namespace ' + node.namespace + ';', node.position);
  18350. };
  18351. /**
  18352. * Visit supports node.
  18353. */
  18354. identity_Compiler.prototype.supports = function (node) {
  18355. 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}');
  18356. };
  18357. /**
  18358. * Visit keyframes node.
  18359. */
  18360. identity_Compiler.prototype.keyframes = function (node) {
  18361. 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) + '}');
  18362. };
  18363. /**
  18364. * Visit keyframe node.
  18365. */
  18366. identity_Compiler.prototype.keyframe = function (node) {
  18367. const decls = node.declarations;
  18368. 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');
  18369. };
  18370. /**
  18371. * Visit page node.
  18372. */
  18373. identity_Compiler.prototype.page = function (node) {
  18374. const sel = node.selectors.length ? node.selectors.join(', ') + ' ' : '';
  18375. 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}');
  18376. };
  18377. /**
  18378. * Visit font-face node.
  18379. */
  18380. identity_Compiler.prototype['font-face'] = function (node) {
  18381. 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}');
  18382. };
  18383. /**
  18384. * Visit host node.
  18385. */
  18386. identity_Compiler.prototype.host = function (node) {
  18387. return this.emit('@host', node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  18388. };
  18389. /**
  18390. * Visit custom-media node.
  18391. */
  18392. identity_Compiler.prototype['custom-media'] = function (node) {
  18393. return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
  18394. };
  18395. /**
  18396. * Visit rule node.
  18397. */
  18398. identity_Compiler.prototype.rule = function (node) {
  18399. const indent = this.indent();
  18400. const decls = node.declarations;
  18401. if (!decls.length) {
  18402. return '';
  18403. }
  18404. return this.emit(node.selectors.map(function (s) {
  18405. return indent + s;
  18406. }).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() + '}');
  18407. };
  18408. /**
  18409. * Visit declaration node.
  18410. */
  18411. identity_Compiler.prototype.declaration = function (node) {
  18412. return this.emit(this.indent()) + this.emit(node.property + ': ' + node.value, node.position) + this.emit(';');
  18413. };
  18414. /**
  18415. * Increase, decrease or return current indentation.
  18416. */
  18417. identity_Compiler.prototype.indent = function (level) {
  18418. this.level = this.level || 1;
  18419. if (null !== level) {
  18420. this.level += level;
  18421. return '';
  18422. }
  18423. return Array(this.level).join(this.indentation || ' ');
  18424. };
  18425. /* eslint-enable @wordpress/no-unused-vars-before-return */
  18426. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/index.js
  18427. // Adapted from https://github.com/reworkcss/css
  18428. // because we needed to remove source map support.
  18429. /**
  18430. * Internal dependencies
  18431. */
  18432. /**
  18433. * Stringfy the given AST `node`.
  18434. *
  18435. * Options:
  18436. *
  18437. * - `compress` space-optimized output
  18438. * - `sourcemap` return an object with `.code` and `.map`
  18439. *
  18440. * @param {Object} node
  18441. * @param {Object} [options]
  18442. * @return {string}
  18443. */
  18444. /* harmony default export */ function stringify(node, options) {
  18445. options = options || {};
  18446. const compiler = options.compress ? new compress(options) : new identity(options);
  18447. const code = compiler.compile(node);
  18448. return code;
  18449. }
  18450. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/traverse.js
  18451. /**
  18452. * External dependencies
  18453. */
  18454. /**
  18455. * Internal dependencies
  18456. */
  18457. function traverseCSS(css, callback) {
  18458. try {
  18459. const parsed = parse(css);
  18460. const updated = traverse_default().map(parsed, function (node) {
  18461. if (!node) {
  18462. return node;
  18463. }
  18464. const updatedNode = callback(node);
  18465. return this.update(updatedNode);
  18466. });
  18467. return stringify(updated);
  18468. } catch (err) {
  18469. // eslint-disable-next-line no-console
  18470. console.warn('Error while traversing the CSS: ' + err);
  18471. return null;
  18472. }
  18473. }
  18474. /* harmony default export */ var transform_styles_traverse = (traverseCSS);
  18475. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/transforms/url-rewrite.js
  18476. /**
  18477. * Return `true` if the given path is http/https.
  18478. *
  18479. * @param {string} filePath path
  18480. *
  18481. * @return {boolean} is remote path.
  18482. */
  18483. function isRemotePath(filePath) {
  18484. return /^(?:https?:)?\/\//.test(filePath);
  18485. }
  18486. /**
  18487. * Return `true` if the given filePath is an absolute url.
  18488. *
  18489. * @param {string} filePath path
  18490. *
  18491. * @return {boolean} is absolute path.
  18492. */
  18493. function isAbsolutePath(filePath) {
  18494. return /^\/(?!\/)/.test(filePath);
  18495. }
  18496. /**
  18497. * Whether or not the url should be inluded.
  18498. *
  18499. * @param {Object} meta url meta info
  18500. *
  18501. * @return {boolean} is valid.
  18502. */
  18503. function isValidURL(meta) {
  18504. // Ignore hashes or data uris.
  18505. if (meta.value.indexOf('data:') === 0 || meta.value.indexOf('#') === 0) {
  18506. return false;
  18507. }
  18508. if (isAbsolutePath(meta.value)) {
  18509. return false;
  18510. } // Do not handle the http/https urls if `includeRemote` is false.
  18511. if (isRemotePath(meta.value)) {
  18512. return false;
  18513. }
  18514. return true;
  18515. }
  18516. /**
  18517. * Get the absolute path of the url, relative to the basePath
  18518. *
  18519. * @param {string} str the url
  18520. * @param {string} baseURL base URL
  18521. *
  18522. * @return {string} the full path to the file
  18523. */
  18524. function getResourcePath(str, baseURL) {
  18525. return new URL(str, baseURL).toString();
  18526. }
  18527. /**
  18528. * Process the single `url()` pattern
  18529. *
  18530. * @param {string} baseURL the base URL for relative URLs.
  18531. *
  18532. * @return {Promise} the Promise.
  18533. */
  18534. function processURL(baseURL) {
  18535. return meta => ({ ...meta,
  18536. newUrl: 'url(' + meta.before + meta.quote + getResourcePath(meta.value, baseURL) + meta.quote + meta.after + ')'
  18537. });
  18538. }
  18539. /**
  18540. * Get all `url()`s, and return the meta info
  18541. *
  18542. * @param {string} value decl.value.
  18543. *
  18544. * @return {Array} the urls.
  18545. */
  18546. function getURLs(value) {
  18547. const reg = /url\((\s*)(['"]?)(.+?)\2(\s*)\)/g;
  18548. let match;
  18549. const URLs = [];
  18550. while ((match = reg.exec(value)) !== null) {
  18551. const meta = {
  18552. source: match[0],
  18553. before: match[1],
  18554. quote: match[2],
  18555. value: match[3],
  18556. after: match[4]
  18557. };
  18558. if (isValidURL(meta)) {
  18559. URLs.push(meta);
  18560. }
  18561. }
  18562. return URLs;
  18563. }
  18564. /**
  18565. * Replace the raw value's `url()` segment to the new value
  18566. *
  18567. * @param {string} raw the raw value.
  18568. * @param {Array} URLs the URLs to replace.
  18569. *
  18570. * @return {string} the new value.
  18571. */
  18572. function replaceURLs(raw, URLs) {
  18573. URLs.forEach(item => {
  18574. raw = raw.replace(item.source, item.newUrl);
  18575. });
  18576. return raw;
  18577. }
  18578. const rewrite = rootURL => node => {
  18579. if (node.type === 'declaration') {
  18580. const updatedURLs = getURLs(node.value).map(processURL(rootURL));
  18581. return { ...node,
  18582. value: replaceURLs(node.value, updatedURLs)
  18583. };
  18584. }
  18585. return node;
  18586. };
  18587. /* harmony default export */ var url_rewrite = (rewrite);
  18588. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/transforms/wrap.js
  18589. /**
  18590. * @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector.
  18591. */
  18592. const IS_ROOT_TAG = /^(body|html|:root).*$/;
  18593. /**
  18594. * Creates a callback to modify selectors so they only apply within a certain
  18595. * namespace.
  18596. *
  18597. * @param {string} namespace Namespace to prefix selectors with.
  18598. * @param {string[]} ignore Selectors to not prefix.
  18599. *
  18600. * @return {(node: Object) => Object} Callback to wrap selectors.
  18601. */
  18602. const wrap = function (namespace) {
  18603. let ignore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  18604. return node => {
  18605. /**
  18606. * Updates selector if necessary.
  18607. *
  18608. * @param {string} selector Selector to modify.
  18609. *
  18610. * @return {string} Updated selector.
  18611. */
  18612. const updateSelector = selector => {
  18613. if (ignore.includes(selector.trim())) {
  18614. return selector;
  18615. } // Anything other than a root tag is always prefixed.
  18616. {
  18617. if (!selector.match(IS_ROOT_TAG)) {
  18618. return namespace + ' ' + selector;
  18619. }
  18620. } // HTML and Body elements cannot be contained within our container so lets extract their styles.
  18621. return selector.replace(/^(body|html|:root)/, namespace);
  18622. };
  18623. if (node.type === 'rule') {
  18624. return { ...node,
  18625. selectors: node.selectors.map(updateSelector)
  18626. };
  18627. }
  18628. return node;
  18629. };
  18630. };
  18631. /* harmony default export */ var transforms_wrap = (wrap);
  18632. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/index.js
  18633. /**
  18634. * External dependencies
  18635. */
  18636. /**
  18637. * WordPress dependencies
  18638. */
  18639. /**
  18640. * Internal dependencies
  18641. */
  18642. /**
  18643. * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
  18644. *
  18645. * @param {Array} styles CSS rules.
  18646. * @param {string} wrapperClassName Wrapper Class Name.
  18647. * @return {Array} converted rules.
  18648. */
  18649. const transform_styles_transformStyles = function (styles) {
  18650. let wrapperClassName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  18651. return (0,external_lodash_namespaceObject.map)(styles, _ref => {
  18652. let {
  18653. css,
  18654. baseURL
  18655. } = _ref;
  18656. const transforms = [];
  18657. if (wrapperClassName) {
  18658. transforms.push(transforms_wrap(wrapperClassName));
  18659. }
  18660. if (baseURL) {
  18661. transforms.push(url_rewrite(baseURL));
  18662. }
  18663. if (transforms.length) {
  18664. return transform_styles_traverse(css, (0,external_wp_compose_namespaceObject.compose)(transforms));
  18665. }
  18666. return css;
  18667. });
  18668. };
  18669. /* harmony default export */ var transform_styles = (transform_styles_transformStyles);
  18670. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/editor-styles/index.js
  18671. /**
  18672. * External dependencies
  18673. */
  18674. /**
  18675. * WordPress dependencies
  18676. */
  18677. /**
  18678. * Internal dependencies
  18679. */
  18680. const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';
  18681. k([names, a11y]);
  18682. function useDarkThemeBodyClassName(styles) {
  18683. return (0,external_wp_element_namespaceObject.useCallback)(node => {
  18684. if (!node) {
  18685. return;
  18686. }
  18687. const {
  18688. ownerDocument
  18689. } = node;
  18690. const {
  18691. defaultView,
  18692. body
  18693. } = ownerDocument;
  18694. const canvas = ownerDocument.querySelector(EDITOR_STYLES_SELECTOR);
  18695. let backgroundColor;
  18696. if (!canvas) {
  18697. // The real .editor-styles-wrapper element might not exist in the
  18698. // DOM, so calculate the background color by creating a fake
  18699. // wrapper.
  18700. const tempCanvas = ownerDocument.createElement('div');
  18701. tempCanvas.classList.add('editor-styles-wrapper');
  18702. body.appendChild(tempCanvas);
  18703. backgroundColor = defaultView.getComputedStyle(tempCanvas, null).getPropertyValue('background-color');
  18704. body.removeChild(tempCanvas);
  18705. } else {
  18706. backgroundColor = defaultView.getComputedStyle(canvas, null).getPropertyValue('background-color');
  18707. }
  18708. const colordBackgroundColor = w(backgroundColor); // If background is transparent, it should be treated as light color.
  18709. if (colordBackgroundColor.luminance() > 0.5 || colordBackgroundColor.alpha() === 0) {
  18710. body.classList.remove('is-dark-theme');
  18711. } else {
  18712. body.classList.add('is-dark-theme');
  18713. }
  18714. }, [styles]);
  18715. }
  18716. function EditorStyles(_ref) {
  18717. let {
  18718. styles
  18719. } = _ref;
  18720. const transformedStyles = (0,external_wp_element_namespaceObject.useMemo)(() => transform_styles(styles, EDITOR_STYLES_SELECTOR), [styles]);
  18721. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("style", {
  18722. ref: useDarkThemeBodyClassName(styles)
  18723. }), transformedStyles.map((css, index) => (0,external_wp_element_namespaceObject.createElement)("style", {
  18724. key: index
  18725. }, css)));
  18726. }
  18727. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/auto.js
  18728. /**
  18729. * WordPress dependencies
  18730. */
  18731. /**
  18732. * Internal dependencies
  18733. */
  18734. // This is used to avoid rendering the block list if the sizes change.
  18735. let MemoizedBlockList;
  18736. const MAX_HEIGHT = 2000;
  18737. function AutoBlockPreview(_ref) {
  18738. let {
  18739. viewportWidth,
  18740. __experimentalPadding,
  18741. __experimentalMinHeight
  18742. } = _ref;
  18743. const [containerResizeListener, {
  18744. width: containerWidth
  18745. }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
  18746. const [contentResizeListener, {
  18747. height: contentHeight
  18748. }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
  18749. const {
  18750. styles,
  18751. assets
  18752. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  18753. const settings = select(store).getSettings();
  18754. return {
  18755. styles: settings.styles,
  18756. assets: settings.__unstableResolvedAssets
  18757. };
  18758. }, []); // Avoid scrollbars for pattern previews.
  18759. const editorStyles = (0,external_wp_element_namespaceObject.useMemo)(() => {
  18760. if (styles) {
  18761. return [...styles, {
  18762. css: 'body{height:auto;overflow:hidden;}',
  18763. __unstableType: 'presets'
  18764. }];
  18765. }
  18766. return styles;
  18767. }, [styles]); // Initialize on render instead of module top level, to avoid circular dependency issues.
  18768. MemoizedBlockList = MemoizedBlockList || (0,external_wp_compose_namespaceObject.pure)(BlockList);
  18769. const scale = containerWidth / viewportWidth;
  18770. return (0,external_wp_element_namespaceObject.createElement)("div", {
  18771. className: "block-editor-block-preview__container"
  18772. }, containerResizeListener, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, {
  18773. className: "block-editor-block-preview__content",
  18774. style: {
  18775. transform: `scale(${scale})`,
  18776. height: contentHeight * scale,
  18777. maxHeight: contentHeight > MAX_HEIGHT ? MAX_HEIGHT * scale : undefined,
  18778. minHeight: __experimentalMinHeight
  18779. }
  18780. }, (0,external_wp_element_namespaceObject.createElement)(iframe, {
  18781. head: (0,external_wp_element_namespaceObject.createElement)(EditorStyles, {
  18782. styles: editorStyles
  18783. }),
  18784. assets: assets,
  18785. contentRef: (0,external_wp_compose_namespaceObject.useRefEffect)(bodyElement => {
  18786. const {
  18787. ownerDocument: {
  18788. documentElement
  18789. }
  18790. } = bodyElement;
  18791. documentElement.classList.add('block-editor-block-preview__content-iframe');
  18792. documentElement.style.position = 'absolute';
  18793. documentElement.style.width = '100%';
  18794. bodyElement.style.padding = __experimentalPadding + 'px'; // necessary for contentResizeListener to work.
  18795. bodyElement.style.position = 'relative';
  18796. }, []),
  18797. "aria-hidden": true,
  18798. tabIndex: -1,
  18799. style: {
  18800. position: 'absolute',
  18801. width: viewportWidth,
  18802. height: contentHeight,
  18803. pointerEvents: 'none',
  18804. // This is a catch-all max-height for patterns.
  18805. // See: https://github.com/WordPress/gutenberg/pull/38175.
  18806. maxHeight: MAX_HEIGHT,
  18807. minHeight: scale < 1 && __experimentalMinHeight ? __experimentalMinHeight / scale : __experimentalMinHeight
  18808. }
  18809. }, contentResizeListener, (0,external_wp_element_namespaceObject.createElement)(MemoizedBlockList, {
  18810. renderAppender: false
  18811. }))));
  18812. }
  18813. /* harmony default export */ var auto = (AutoBlockPreview);
  18814. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/index.js
  18815. /**
  18816. * External dependencies
  18817. */
  18818. /**
  18819. * WordPress dependencies
  18820. */
  18821. /**
  18822. * Internal dependencies
  18823. */
  18824. function BlockPreview(_ref) {
  18825. let {
  18826. blocks,
  18827. __experimentalPadding = 0,
  18828. viewportWidth = 1200,
  18829. __experimentalLive = false,
  18830. __experimentalOnClick,
  18831. __experimentalMinHeight
  18832. } = _ref;
  18833. const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings(), []);
  18834. const settings = (0,external_wp_element_namespaceObject.useMemo)(() => {
  18835. const _settings = { ...originalSettings
  18836. };
  18837. _settings.__experimentalBlockPatterns = [];
  18838. return _settings;
  18839. }, [originalSettings]);
  18840. const renderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.castArray)(blocks), [blocks]);
  18841. if (!blocks || blocks.length === 0) {
  18842. return null;
  18843. }
  18844. return (0,external_wp_element_namespaceObject.createElement)(provider, {
  18845. value: renderedBlocks,
  18846. settings: settings
  18847. }, __experimentalLive ? (0,external_wp_element_namespaceObject.createElement)(LiveBlockPreview, {
  18848. onClick: __experimentalOnClick
  18849. }) : (0,external_wp_element_namespaceObject.createElement)(auto, {
  18850. viewportWidth: viewportWidth,
  18851. __experimentalPadding: __experimentalPadding,
  18852. __experimentalMinHeight: __experimentalMinHeight
  18853. }));
  18854. }
  18855. /**
  18856. * BlockPreview renders a preview of a block or array of blocks.
  18857. *
  18858. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md
  18859. *
  18860. * @param {Object} preview options for how the preview should be shown
  18861. * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.
  18862. * @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.
  18863. *
  18864. * @return {WPComponent} The component to be rendered.
  18865. */
  18866. /* harmony default export */ var block_preview = ((0,external_wp_element_namespaceObject.memo)(BlockPreview));
  18867. /**
  18868. * This hook is used to lightly mark an element as a block preview wrapper
  18869. * element. Call this hook and pass the returned props to the element to mark as
  18870. * a block preview wrapper, automatically rendering inner blocks as children. If
  18871. * you define a ref for the element, it is important to pass the ref to this
  18872. * hook, which the hook in turn will pass to the component through the props it
  18873. * returns. Optionally, you can also pass any other props through this hook, and
  18874. * they will be merged and returned.
  18875. *
  18876. * @param {Object} options Preview options.
  18877. * @param {WPBlock[]} options.blocks Block objects.
  18878. * @param {Object} options.props Optional. Props to pass to the element. Must contain
  18879. * the ref if one is defined.
  18880. * @param {Object} options.__experimentalLayout Layout settings to be used in the preview.
  18881. *
  18882. */
  18883. function useBlockPreview(_ref2) {
  18884. let {
  18885. blocks,
  18886. props = {},
  18887. __experimentalLayout
  18888. } = _ref2;
  18889. const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings(), []);
  18890. const disabledRef = (0,external_wp_compose_namespaceObject.__experimentalUseDisabled)();
  18891. const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, disabledRef]);
  18892. const settings = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...originalSettings,
  18893. __experimentalBlockPatterns: []
  18894. }), [originalSettings]);
  18895. const renderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.castArray)(blocks), [blocks]);
  18896. const children = (0,external_wp_element_namespaceObject.createElement)(provider, {
  18897. value: renderedBlocks,
  18898. settings: settings
  18899. }, (0,external_wp_element_namespaceObject.createElement)(BlockListItems, {
  18900. renderAppender: false,
  18901. __experimentalLayout: __experimentalLayout
  18902. }));
  18903. return { ...props,
  18904. ref,
  18905. className: classnames_default()(props.className, 'block-editor-block-preview__live-content', 'components-disabled'),
  18906. children: blocks !== null && blocks !== void 0 && blocks.length ? children : null
  18907. };
  18908. }
  18909. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/preview-panel.js
  18910. /**
  18911. * WordPress dependencies
  18912. */
  18913. /**
  18914. * Internal dependencies
  18915. */
  18916. function InserterPreviewPanel(_ref) {
  18917. var _hoveredItemBlockType, _hoveredItemBlockType2;
  18918. let {
  18919. item
  18920. } = _ref;
  18921. const {
  18922. name,
  18923. title,
  18924. icon,
  18925. description,
  18926. initialAttributes
  18927. } = item;
  18928. const hoveredItemBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
  18929. const isReusable = (0,external_wp_blocks_namespaceObject.isReusableBlock)(item);
  18930. return (0,external_wp_element_namespaceObject.createElement)("div", {
  18931. className: "block-editor-inserter__preview-container"
  18932. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  18933. className: "block-editor-inserter__preview"
  18934. }, isReusable || hoveredItemBlockType !== null && hoveredItemBlockType !== void 0 && hoveredItemBlockType.example ? (0,external_wp_element_namespaceObject.createElement)("div", {
  18935. className: "block-editor-inserter__preview-content"
  18936. }, (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  18937. __experimentalPadding: 16,
  18938. viewportWidth: (_hoveredItemBlockType = (_hoveredItemBlockType2 = hoveredItemBlockType.example) === null || _hoveredItemBlockType2 === void 0 ? void 0 : _hoveredItemBlockType2.viewportWidth) !== null && _hoveredItemBlockType !== void 0 ? _hoveredItemBlockType : 500,
  18939. blocks: hoveredItemBlockType.example ? (0,external_wp_blocks_namespaceObject.getBlockFromExample)(item.name, {
  18940. attributes: { ...hoveredItemBlockType.example.attributes,
  18941. ...initialAttributes
  18942. },
  18943. innerBlocks: hoveredItemBlockType.example.innerBlocks
  18944. }) : (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes)
  18945. })) : (0,external_wp_element_namespaceObject.createElement)("div", {
  18946. className: "block-editor-inserter__preview-content-missing"
  18947. }, (0,external_wp_i18n_namespaceObject.__)('No Preview Available.'))), !isReusable && (0,external_wp_element_namespaceObject.createElement)(block_card, {
  18948. title: title,
  18949. icon: icon,
  18950. description: description
  18951. }));
  18952. }
  18953. /* harmony default export */ var preview_panel = (InserterPreviewPanel);
  18954. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/context.js
  18955. /**
  18956. * WordPress dependencies
  18957. */
  18958. const InserterListboxContext = (0,external_wp_element_namespaceObject.createContext)();
  18959. /* harmony default export */ var context = (InserterListboxContext);
  18960. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/item.js
  18961. /**
  18962. * WordPress dependencies
  18963. */
  18964. /**
  18965. * Internal dependencies
  18966. */
  18967. function InserterListboxItem(_ref, ref) {
  18968. let {
  18969. isFirst,
  18970. as: Component,
  18971. children,
  18972. ...props
  18973. } = _ref;
  18974. const state = (0,external_wp_element_namespaceObject.useContext)(context);
  18975. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
  18976. ref: ref,
  18977. state: state,
  18978. role: "option" // Use the CompositeItem `focusable` prop over Button's
  18979. // isFocusable. The latter was shown to cause an issue
  18980. // with tab order in the inserter list.
  18981. ,
  18982. focusable: true
  18983. }, props), htmlProps => {
  18984. const propsWithTabIndex = { ...htmlProps,
  18985. tabIndex: isFirst ? 0 : htmlProps.tabIndex
  18986. };
  18987. if (Component) {
  18988. return (0,external_wp_element_namespaceObject.createElement)(Component, propsWithTabIndex, children);
  18989. }
  18990. if (typeof children === 'function') {
  18991. return children(propsWithTabIndex);
  18992. }
  18993. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, propsWithTabIndex, children);
  18994. });
  18995. }
  18996. /* harmony default export */ var inserter_listbox_item = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxItem));
  18997. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drag-handle.js
  18998. /**
  18999. * WordPress dependencies
  19000. */
  19001. const dragHandle = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  19002. width: "24",
  19003. height: "24",
  19004. xmlns: "http://www.w3.org/2000/svg",
  19005. viewBox: "0 0 24 24"
  19006. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  19007. d: "M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z"
  19008. }));
  19009. /* harmony default export */ var drag_handle = (dragHandle);
  19010. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/draggable-chip.js
  19011. /**
  19012. * WordPress dependencies
  19013. */
  19014. /**
  19015. * Internal dependencies
  19016. */
  19017. function BlockDraggableChip(_ref) {
  19018. let {
  19019. count,
  19020. icon
  19021. } = _ref;
  19022. return (0,external_wp_element_namespaceObject.createElement)("div", {
  19023. className: "block-editor-block-draggable-chip-wrapper"
  19024. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  19025. className: "block-editor-block-draggable-chip"
  19026. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
  19027. justify: "center",
  19028. className: "block-editor-block-draggable-chip__content"
  19029. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, icon ? (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  19030. icon: icon
  19031. }) : (0,external_wp_i18n_namespaceObject.sprintf)(
  19032. /* translators: %d: Number of blocks. */
  19033. (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, {
  19034. icon: drag_handle
  19035. })))));
  19036. }
  19037. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-draggable-blocks/index.js
  19038. /**
  19039. * WordPress dependencies
  19040. */
  19041. /**
  19042. * Internal dependencies
  19043. */
  19044. const InserterDraggableBlocks = _ref => {
  19045. let {
  19046. isEnabled,
  19047. blocks,
  19048. icon,
  19049. children
  19050. } = _ref;
  19051. const transferData = {
  19052. type: 'inserter',
  19053. blocks
  19054. };
  19055. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Draggable, {
  19056. __experimentalTransferDataType: "wp-blocks",
  19057. transferData: transferData,
  19058. __experimentalDragComponent: (0,external_wp_element_namespaceObject.createElement)(BlockDraggableChip, {
  19059. count: blocks.length,
  19060. icon: icon
  19061. })
  19062. }, _ref2 => {
  19063. let {
  19064. onDraggableStart,
  19065. onDraggableEnd
  19066. } = _ref2;
  19067. return children({
  19068. draggable: isEnabled,
  19069. onDragStart: isEnabled ? onDraggableStart : undefined,
  19070. onDragEnd: isEnabled ? onDraggableEnd : undefined
  19071. });
  19072. });
  19073. };
  19074. /* harmony default export */ var inserter_draggable_blocks = (InserterDraggableBlocks);
  19075. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-list-item/index.js
  19076. /**
  19077. * External dependencies
  19078. */
  19079. /**
  19080. * WordPress dependencies
  19081. */
  19082. /**
  19083. * Internal dependencies
  19084. */
  19085. /**
  19086. * Return true if platform is MacOS.
  19087. *
  19088. * @param {Object} _window window object by default; used for DI testing.
  19089. *
  19090. * @return {boolean} True if MacOS; false otherwise.
  19091. */
  19092. function isAppleOS() {
  19093. let _window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
  19094. const {
  19095. platform
  19096. } = _window.navigator;
  19097. return platform.indexOf('Mac') !== -1 || ['iPad', 'iPhone'].includes(platform);
  19098. }
  19099. function InserterListItem(_ref) {
  19100. let {
  19101. className,
  19102. isFirst,
  19103. item,
  19104. onSelect,
  19105. onHover,
  19106. isDraggable,
  19107. ...props
  19108. } = _ref;
  19109. const isDragging = (0,external_wp_element_namespaceObject.useRef)(false);
  19110. const itemIconStyle = item.icon ? {
  19111. backgroundColor: item.icon.background,
  19112. color: item.icon.foreground
  19113. } : {};
  19114. const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
  19115. return [(0,external_wp_blocks_namespaceObject.createBlock)(item.name, item.initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(item.innerBlocks))];
  19116. }, [item.name, item.initialAttributes, item.initialAttributes]);
  19117. return (0,external_wp_element_namespaceObject.createElement)(inserter_draggable_blocks, {
  19118. isEnabled: isDraggable && !item.disabled,
  19119. blocks: blocks,
  19120. icon: item.icon
  19121. }, _ref2 => {
  19122. let {
  19123. draggable,
  19124. onDragStart,
  19125. onDragEnd
  19126. } = _ref2;
  19127. return (0,external_wp_element_namespaceObject.createElement)("div", {
  19128. className: "block-editor-block-types-list__list-item",
  19129. draggable: draggable,
  19130. onDragStart: event => {
  19131. isDragging.current = true;
  19132. if (onDragStart) {
  19133. onHover(null);
  19134. onDragStart(event);
  19135. }
  19136. },
  19137. onDragEnd: event => {
  19138. isDragging.current = false;
  19139. if (onDragEnd) {
  19140. onDragEnd(event);
  19141. }
  19142. }
  19143. }, (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_item, _extends({
  19144. isFirst: isFirst,
  19145. className: classnames_default()('block-editor-block-types-list__item', className),
  19146. disabled: item.isDisabled,
  19147. onClick: event => {
  19148. event.preventDefault();
  19149. onSelect(item, isAppleOS() ? event.metaKey : event.ctrlKey);
  19150. onHover(null);
  19151. },
  19152. onKeyDown: event => {
  19153. const {
  19154. keyCode
  19155. } = event;
  19156. if (keyCode === external_wp_keycodes_namespaceObject.ENTER) {
  19157. event.preventDefault();
  19158. onSelect(item, isAppleOS() ? event.metaKey : event.ctrlKey);
  19159. onHover(null);
  19160. }
  19161. },
  19162. onFocus: () => {
  19163. if (isDragging.current) {
  19164. return;
  19165. }
  19166. onHover(item);
  19167. },
  19168. onMouseEnter: () => {
  19169. if (isDragging.current) {
  19170. return;
  19171. }
  19172. onHover(item);
  19173. },
  19174. onMouseLeave: () => onHover(null),
  19175. onBlur: () => onHover(null)
  19176. }, props), (0,external_wp_element_namespaceObject.createElement)("span", {
  19177. className: "block-editor-block-types-list__item-icon",
  19178. style: itemIconStyle
  19179. }, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  19180. icon: item.icon,
  19181. showColors: true
  19182. })), (0,external_wp_element_namespaceObject.createElement)("span", {
  19183. className: "block-editor-block-types-list__item-title"
  19184. }, item.title)));
  19185. });
  19186. }
  19187. /* harmony default export */ var inserter_list_item = ((0,external_wp_element_namespaceObject.memo)(InserterListItem));
  19188. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/group.js
  19189. /**
  19190. * WordPress dependencies
  19191. */
  19192. function InserterListboxGroup(props, ref) {
  19193. const [shouldSpeak, setShouldSpeak] = (0,external_wp_element_namespaceObject.useState)(false);
  19194. (0,external_wp_element_namespaceObject.useEffect)(() => {
  19195. if (shouldSpeak) {
  19196. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to move through blocks'));
  19197. }
  19198. }, [shouldSpeak]);
  19199. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  19200. ref: ref,
  19201. role: "listbox",
  19202. "aria-orientation": "horizontal",
  19203. onFocus: () => {
  19204. setShouldSpeak(true);
  19205. },
  19206. onBlur: event => {
  19207. const focusingOutsideGroup = !event.currentTarget.contains(event.relatedTarget);
  19208. if (focusingOutsideGroup) {
  19209. setShouldSpeak(false);
  19210. }
  19211. }
  19212. }, props));
  19213. }
  19214. /* harmony default export */ var group = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxGroup));
  19215. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/row.js
  19216. /**
  19217. * WordPress dependencies
  19218. */
  19219. /**
  19220. * Internal dependencies
  19221. */
  19222. function InserterListboxRow(props, ref) {
  19223. const state = (0,external_wp_element_namespaceObject.useContext)(context);
  19224. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeGroup, _extends({
  19225. state: state,
  19226. role: "presentation",
  19227. ref: ref
  19228. }, props));
  19229. }
  19230. /* harmony default export */ var inserter_listbox_row = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxRow));
  19231. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-types-list/index.js
  19232. /**
  19233. * WordPress dependencies
  19234. */
  19235. /**
  19236. * Internal dependencies
  19237. */
  19238. function chunk(array, size) {
  19239. const chunks = [];
  19240. for (let i = 0, j = array.length; i < j; i += size) {
  19241. chunks.push(array.slice(i, i + size));
  19242. }
  19243. return chunks;
  19244. }
  19245. function BlockTypesList(_ref) {
  19246. let {
  19247. items = [],
  19248. onSelect,
  19249. onHover = () => {},
  19250. children,
  19251. label,
  19252. isDraggable = true
  19253. } = _ref;
  19254. return (0,external_wp_element_namespaceObject.createElement)(group, {
  19255. className: "block-editor-block-types-list",
  19256. "aria-label": label
  19257. }, chunk(items, 3).map((row, i) => (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_row, {
  19258. key: i
  19259. }, row.map((item, j) => (0,external_wp_element_namespaceObject.createElement)(inserter_list_item, {
  19260. key: item.id,
  19261. item: item,
  19262. className: (0,external_wp_blocks_namespaceObject.getBlockMenuDefaultClassName)(item.id),
  19263. onSelect: onSelect,
  19264. onHover: onHover,
  19265. isDraggable: isDraggable,
  19266. isFirst: i === 0 && j === 0
  19267. })))), children);
  19268. }
  19269. /* harmony default export */ var block_types_list = (BlockTypesList);
  19270. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/panel.js
  19271. /**
  19272. * WordPress dependencies
  19273. */
  19274. function InserterPanel(_ref) {
  19275. let {
  19276. title,
  19277. icon,
  19278. children
  19279. } = _ref;
  19280. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  19281. className: "block-editor-inserter__panel-header"
  19282. }, (0,external_wp_element_namespaceObject.createElement)("h2", {
  19283. className: "block-editor-inserter__panel-title"
  19284. }, title), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
  19285. icon: icon
  19286. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  19287. className: "block-editor-inserter__panel-content"
  19288. }, children));
  19289. }
  19290. /* harmony default export */ var panel = (InserterPanel);
  19291. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-block-types-state.js
  19292. /**
  19293. * WordPress dependencies
  19294. */
  19295. /**
  19296. * Internal dependencies
  19297. */
  19298. /**
  19299. * Retrieves the block types inserter state.
  19300. *
  19301. * @param {string=} rootClientId Insertion's root client ID.
  19302. * @param {Function} onInsert function called when inserter a list of blocks.
  19303. * @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)
  19304. */
  19305. const useBlockTypesState = (rootClientId, onInsert) => {
  19306. const {
  19307. categories,
  19308. collections,
  19309. items
  19310. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  19311. const {
  19312. getInserterItems
  19313. } = select(store);
  19314. const {
  19315. getCategories,
  19316. getCollections
  19317. } = select(external_wp_blocks_namespaceObject.store);
  19318. return {
  19319. categories: getCategories(),
  19320. collections: getCollections(),
  19321. items: getInserterItems(rootClientId)
  19322. };
  19323. }, [rootClientId]);
  19324. const onSelectItem = (0,external_wp_element_namespaceObject.useCallback)((_ref, shouldFocusBlock) => {
  19325. let {
  19326. name,
  19327. initialAttributes,
  19328. innerBlocks
  19329. } = _ref;
  19330. const insertedBlock = (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(innerBlocks));
  19331. onInsert(insertedBlock, undefined, shouldFocusBlock);
  19332. }, [onInsert]);
  19333. return [items, categories, collections, onSelectItem];
  19334. };
  19335. /* harmony default export */ var use_block_types_state = (useBlockTypesState);
  19336. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/index.js
  19337. /**
  19338. * WordPress dependencies
  19339. */
  19340. /**
  19341. * Internal dependencies
  19342. */
  19343. function InserterListbox(_ref) {
  19344. let {
  19345. children
  19346. } = _ref;
  19347. const compositeState = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({
  19348. shift: true,
  19349. wrap: 'horizontal'
  19350. });
  19351. return (0,external_wp_element_namespaceObject.createElement)(context.Provider, {
  19352. value: compositeState
  19353. }, children);
  19354. }
  19355. /* harmony default export */ var inserter_listbox = (InserterListbox);
  19356. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-types-tab.js
  19357. /**
  19358. * External dependencies
  19359. */
  19360. /**
  19361. * WordPress dependencies
  19362. */
  19363. /**
  19364. * Internal dependencies
  19365. */
  19366. const getBlockNamespace = item => item.name.split('/')[0];
  19367. const MAX_SUGGESTED_ITEMS = 6;
  19368. /**
  19369. * Shared reference to an empty array for cases where it is important to avoid
  19370. * returning a new array reference on every invocation and rerendering the component.
  19371. *
  19372. * @type {Array}
  19373. */
  19374. const block_types_tab_EMPTY_ARRAY = [];
  19375. function BlockTypesTab(_ref) {
  19376. let {
  19377. rootClientId,
  19378. onInsert,
  19379. onHover,
  19380. showMostUsedBlocks
  19381. } = _ref;
  19382. const [items, categories, collections, onSelectItem] = use_block_types_state(rootClientId, onInsert);
  19383. const suggestedItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
  19384. return (0,external_lodash_namespaceObject.orderBy)(items, ['frecency'], ['desc']).slice(0, MAX_SUGGESTED_ITEMS);
  19385. }, [items]);
  19386. const uncategorizedItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
  19387. return items.filter(item => !item.category);
  19388. }, [items]);
  19389. const itemsPerCategory = (0,external_wp_element_namespaceObject.useMemo)(() => {
  19390. return (0,external_lodash_namespaceObject.flow)(itemList => itemList.filter(item => item.category && item.category !== 'reusable'), itemList => (0,external_lodash_namespaceObject.groupBy)(itemList, 'category'))(items);
  19391. }, [items]);
  19392. const itemsPerCollection = (0,external_wp_element_namespaceObject.useMemo)(() => {
  19393. // Create a new Object to avoid mutating collection.
  19394. const result = { ...collections
  19395. };
  19396. Object.keys(collections).forEach(namespace => {
  19397. result[namespace] = items.filter(item => getBlockNamespace(item) === namespace);
  19398. if (result[namespace].length === 0) {
  19399. delete result[namespace];
  19400. }
  19401. });
  19402. return result;
  19403. }, [items, collections]); // Hide block preview on unmount.
  19404. (0,external_wp_element_namespaceObject.useEffect)(() => () => onHover(null), []);
  19405. /**
  19406. * The inserter contains a big number of blocks and opening it is a costful operation.
  19407. * The rendering is the most costful part of it, in order to improve the responsiveness
  19408. * of the "opening" action, these lazy lists allow us to render the inserter category per category,
  19409. * once all the categories are rendered, we start rendering the collections and the uncategorized block types.
  19410. */
  19411. const currentlyRenderedCategories = (0,external_wp_compose_namespaceObject.useAsyncList)(categories);
  19412. const didRenderAllCategories = categories.length === currentlyRenderedCategories.length; // Async List requires an array.
  19413. const collectionEntries = (0,external_wp_element_namespaceObject.useMemo)(() => {
  19414. return Object.entries(collections);
  19415. }, [collections]);
  19416. const currentlyRenderedCollections = (0,external_wp_compose_namespaceObject.useAsyncList)(didRenderAllCategories ? collectionEntries : block_types_tab_EMPTY_ARRAY);
  19417. 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, {
  19418. title: (0,external_wp_i18n_namespaceObject._x)('Most used', 'blocks')
  19419. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  19420. items: suggestedItems,
  19421. onSelect: onSelectItem,
  19422. onHover: onHover,
  19423. label: (0,external_wp_i18n_namespaceObject._x)('Most used', 'blocks')
  19424. })), (0,external_lodash_namespaceObject.map)(currentlyRenderedCategories, category => {
  19425. const categoryItems = itemsPerCategory[category.slug];
  19426. if (!categoryItems || !categoryItems.length) {
  19427. return null;
  19428. }
  19429. return (0,external_wp_element_namespaceObject.createElement)(panel, {
  19430. key: category.slug,
  19431. title: category.title,
  19432. icon: category.icon
  19433. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  19434. items: categoryItems,
  19435. onSelect: onSelectItem,
  19436. onHover: onHover,
  19437. label: category.title
  19438. }));
  19439. }), didRenderAllCategories && uncategorizedItems.length > 0 && (0,external_wp_element_namespaceObject.createElement)(panel, {
  19440. className: "block-editor-inserter__uncategorized-blocks-panel",
  19441. title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized')
  19442. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  19443. items: uncategorizedItems,
  19444. onSelect: onSelectItem,
  19445. onHover: onHover,
  19446. label: (0,external_wp_i18n_namespaceObject.__)('Uncategorized')
  19447. })), (0,external_lodash_namespaceObject.map)(currentlyRenderedCollections, _ref2 => {
  19448. let [namespace, collection] = _ref2;
  19449. const collectionItems = itemsPerCollection[namespace];
  19450. if (!collectionItems || !collectionItems.length) {
  19451. return null;
  19452. }
  19453. return (0,external_wp_element_namespaceObject.createElement)(panel, {
  19454. key: namespace,
  19455. title: collection.title,
  19456. icon: collection.icon
  19457. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  19458. items: collectionItems,
  19459. onSelect: onSelectItem,
  19460. onHover: onHover,
  19461. label: collection.title
  19462. }));
  19463. })));
  19464. }
  19465. /* harmony default export */ var block_types_tab = (BlockTypesTab);
  19466. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/pattern-panel.js
  19467. /**
  19468. * External dependencies
  19469. */
  19470. /**
  19471. * WordPress dependencies
  19472. */
  19473. function PatternInserterPanel(_ref) {
  19474. let {
  19475. selectedCategory,
  19476. patternCategories,
  19477. onClickCategory,
  19478. openPatternExplorer
  19479. } = _ref;
  19480. const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
  19481. const categoryOptions = () => {
  19482. const options = [];
  19483. patternCategories.map(patternCategory => {
  19484. return options.push({
  19485. value: patternCategory.name,
  19486. label: patternCategory.label
  19487. });
  19488. });
  19489. return options;
  19490. };
  19491. const onChangeSelect = selected => {
  19492. onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name));
  19493. };
  19494. 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
  19495. // from a Select element. To prevent closing the useDialog on iOS devices, we
  19496. // stop propagating the onBlur event if there is no relatedTarget, which means
  19497. // that the user most likely did not click on an element within the editor canvas.
  19498. const onBlur = event => {
  19499. if (!(event !== null && event !== void 0 && event.relatedTarget)) {
  19500. event.stopPropagation();
  19501. }
  19502. };
  19503. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
  19504. justify: "space-between",
  19505. align: "start",
  19506. gap: "4",
  19507. className: className
  19508. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
  19509. isBlock: true
  19510. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
  19511. className: "block-editor-inserter__panel-dropdown",
  19512. label: (0,external_wp_i18n_namespaceObject.__)('Filter patterns'),
  19513. hideLabelFromVision: true,
  19514. value: selectedCategory.name,
  19515. onChange: onChangeSelect,
  19516. onBlur: onBlur,
  19517. options: categoryOptions()
  19518. })), !isMobile && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  19519. variant: "secondary",
  19520. className: "block-editor-inserter__patterns-explorer-expand",
  19521. label: (0,external_wp_i18n_namespaceObject.__)('Explore all patterns'),
  19522. onClick: () => openPatternExplorer()
  19523. }, (0,external_wp_i18n_namespaceObject._x)('Explore', 'Label for showing all block patterns'))));
  19524. }
  19525. /* harmony default export */ var pattern_panel = (PatternInserterPanel);
  19526. ;// CONCATENATED MODULE: external ["wp","notices"]
  19527. var external_wp_notices_namespaceObject = window["wp"]["notices"];
  19528. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-patterns-state.js
  19529. /**
  19530. * External dependencies
  19531. */
  19532. /**
  19533. * WordPress dependencies
  19534. */
  19535. /**
  19536. * Internal dependencies
  19537. */
  19538. /**
  19539. * Retrieves the block patterns inserter state.
  19540. *
  19541. * @param {Function} onInsert function called when inserter a list of blocks.
  19542. * @param {string=} rootClientId Insertion's root client ID.
  19543. *
  19544. * @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)
  19545. */
  19546. const usePatternsState = (onInsert, rootClientId) => {
  19547. const {
  19548. patternCategories,
  19549. patterns
  19550. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  19551. const {
  19552. __experimentalGetAllowedPatterns,
  19553. getSettings
  19554. } = select(store);
  19555. return {
  19556. patterns: __experimentalGetAllowedPatterns(rootClientId),
  19557. patternCategories: getSettings().__experimentalBlockPatternCategories
  19558. };
  19559. }, [rootClientId]);
  19560. const {
  19561. createSuccessNotice
  19562. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
  19563. const onClickPattern = (0,external_wp_element_namespaceObject.useCallback)((pattern, blocks) => {
  19564. onInsert((0,external_lodash_namespaceObject.map)(blocks, block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block)), pattern.name);
  19565. createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
  19566. /* translators: %s: block pattern title. */
  19567. (0,external_wp_i18n_namespaceObject.__)('Block pattern "%s" inserted.'), pattern.title), {
  19568. type: 'snackbar'
  19569. });
  19570. }, []);
  19571. return [patterns, patternCategories, onClickPattern];
  19572. };
  19573. /* harmony default export */ var use_patterns_state = (usePatternsState);
  19574. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-patterns-list/index.js
  19575. /**
  19576. * WordPress dependencies
  19577. */
  19578. /**
  19579. * Internal dependencies
  19580. */
  19581. function BlockPattern(_ref) {
  19582. let {
  19583. isDraggable,
  19584. pattern,
  19585. onClick,
  19586. composite
  19587. } = _ref;
  19588. const {
  19589. blocks,
  19590. viewportWidth
  19591. } = pattern;
  19592. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockPattern);
  19593. const descriptionId = `block-editor-block-patterns-list__item-description-${instanceId}`;
  19594. return (0,external_wp_element_namespaceObject.createElement)(inserter_draggable_blocks, {
  19595. isEnabled: isDraggable,
  19596. blocks: blocks
  19597. }, _ref2 => {
  19598. let {
  19599. draggable,
  19600. onDragStart,
  19601. onDragEnd
  19602. } = _ref2;
  19603. return (0,external_wp_element_namespaceObject.createElement)("div", {
  19604. className: "block-editor-block-patterns-list__list-item",
  19605. "aria-label": pattern.title,
  19606. "aria-describedby": pattern.description ? descriptionId : undefined,
  19607. draggable: draggable,
  19608. onDragStart: onDragStart,
  19609. onDragEnd: onDragEnd
  19610. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
  19611. role: "option",
  19612. as: "div"
  19613. }, composite, {
  19614. className: "block-editor-block-patterns-list__item",
  19615. onClick: () => onClick(pattern, blocks)
  19616. }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  19617. blocks: blocks,
  19618. viewportWidth: viewportWidth
  19619. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  19620. className: "block-editor-block-patterns-list__item-title"
  19621. }, pattern.title), !!pattern.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  19622. id: descriptionId
  19623. }, pattern.description)));
  19624. });
  19625. }
  19626. function BlockPatternPlaceholder() {
  19627. return (0,external_wp_element_namespaceObject.createElement)("div", {
  19628. className: "block-editor-block-patterns-list__item is-placeholder"
  19629. });
  19630. }
  19631. function BlockPatternList(_ref3) {
  19632. let {
  19633. isDraggable,
  19634. blockPatterns,
  19635. shownPatterns,
  19636. onClickPattern,
  19637. orientation,
  19638. label = (0,external_wp_i18n_namespaceObject.__)('Block Patterns')
  19639. } = _ref3;
  19640. const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({
  19641. orientation
  19642. });
  19643. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
  19644. role: "listbox",
  19645. className: "block-editor-block-patterns-list",
  19646. "aria-label": label
  19647. }), blockPatterns.map(pattern => {
  19648. const isShown = shownPatterns.includes(pattern);
  19649. return isShown ? (0,external_wp_element_namespaceObject.createElement)(BlockPattern, {
  19650. key: pattern.name,
  19651. pattern: pattern,
  19652. onClick: onClickPattern,
  19653. isDraggable: isDraggable,
  19654. composite: composite
  19655. }) : (0,external_wp_element_namespaceObject.createElement)(BlockPatternPlaceholder, {
  19656. key: pattern.name
  19657. });
  19658. }));
  19659. }
  19660. /* harmony default export */ var block_patterns_list = (BlockPatternList);
  19661. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-explorer/sidebar.js
  19662. /**
  19663. * WordPress dependencies
  19664. */
  19665. function PatternCategoriesList(_ref) {
  19666. let {
  19667. selectedCategory,
  19668. patternCategories,
  19669. onClickCategory
  19670. } = _ref;
  19671. const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
  19672. return (0,external_wp_element_namespaceObject.createElement)("div", {
  19673. className: `${baseClassName}__categories-list`
  19674. }, patternCategories.map(_ref2 => {
  19675. let {
  19676. name,
  19677. label
  19678. } = _ref2;
  19679. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  19680. key: name,
  19681. label: label,
  19682. className: `${baseClassName}__categories-list__item`,
  19683. isPressed: selectedCategory === name,
  19684. onClick: () => {
  19685. onClickCategory(name);
  19686. }
  19687. }, label);
  19688. }));
  19689. }
  19690. function PatternsExplorerSearch(_ref3) {
  19691. let {
  19692. filterValue,
  19693. setFilterValue
  19694. } = _ref3;
  19695. const baseClassName = 'block-editor-block-patterns-explorer__search';
  19696. return (0,external_wp_element_namespaceObject.createElement)("div", {
  19697. className: baseClassName
  19698. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
  19699. onChange: setFilterValue,
  19700. value: filterValue,
  19701. label: (0,external_wp_i18n_namespaceObject.__)('Search for patterns'),
  19702. placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
  19703. }));
  19704. }
  19705. function PatternExplorerSidebar(_ref4) {
  19706. let {
  19707. selectedCategory,
  19708. patternCategories,
  19709. onClickCategory,
  19710. filterValue,
  19711. setFilterValue
  19712. } = _ref4;
  19713. const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
  19714. return (0,external_wp_element_namespaceObject.createElement)("div", {
  19715. className: baseClassName
  19716. }, (0,external_wp_element_namespaceObject.createElement)(PatternsExplorerSearch, {
  19717. filterValue: filterValue,
  19718. setFilterValue: setFilterValue
  19719. }), !filterValue && (0,external_wp_element_namespaceObject.createElement)(PatternCategoriesList, {
  19720. selectedCategory: selectedCategory,
  19721. patternCategories: patternCategories,
  19722. onClickCategory: onClickCategory
  19723. }));
  19724. }
  19725. /* harmony default export */ var sidebar = (PatternExplorerSidebar);
  19726. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/no-results.js
  19727. /**
  19728. * WordPress dependencies
  19729. */
  19730. function InserterNoResults() {
  19731. return (0,external_wp_element_namespaceObject.createElement)("div", {
  19732. className: "block-editor-inserter__no-results"
  19733. }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  19734. className: "block-editor-inserter__no-results-icon",
  19735. icon: block_default
  19736. }), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('No results found.')));
  19737. }
  19738. /* harmony default export */ var no_results = (InserterNoResults);
  19739. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-insertion-point.js
  19740. /**
  19741. * External dependencies
  19742. */
  19743. /**
  19744. * WordPress dependencies
  19745. */
  19746. /**
  19747. * Internal dependencies
  19748. */
  19749. /**
  19750. * @typedef WPInserterConfig
  19751. *
  19752. * @property {string=} rootClientId If set, insertion will be into the
  19753. * block with this ID.
  19754. * @property {number=} insertionIndex If set, insertion will be into this
  19755. * explicit position.
  19756. * @property {string=} clientId If set, insertion will be after the
  19757. * block with this ID.
  19758. * @property {boolean=} isAppender Whether the inserter is an appender
  19759. * or not.
  19760. * @property {Function=} onSelect Called after insertion.
  19761. */
  19762. /**
  19763. * Returns the insertion point state given the inserter config.
  19764. *
  19765. * @param {WPInserterConfig} config Inserter Config.
  19766. * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).
  19767. */
  19768. function useInsertionPoint(_ref) {
  19769. let {
  19770. rootClientId = '',
  19771. insertionIndex,
  19772. clientId,
  19773. isAppender,
  19774. onSelect,
  19775. shouldFocusBlock = true
  19776. } = _ref;
  19777. const {
  19778. getSelectedBlock
  19779. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  19780. const {
  19781. destinationRootClientId,
  19782. destinationIndex
  19783. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  19784. const {
  19785. getSelectedBlockClientId,
  19786. getBlockRootClientId,
  19787. getBlockIndex,
  19788. getBlockOrder
  19789. } = select(store);
  19790. const selectedBlockClientId = getSelectedBlockClientId();
  19791. let _destinationRootClientId = rootClientId;
  19792. let _destinationIndex;
  19793. if (insertionIndex !== undefined) {
  19794. // Insert into a specific index.
  19795. _destinationIndex = insertionIndex;
  19796. } else if (clientId) {
  19797. // Insert after a specific client ID.
  19798. _destinationIndex = getBlockIndex(clientId);
  19799. } else if (!isAppender && selectedBlockClientId) {
  19800. _destinationRootClientId = getBlockRootClientId(selectedBlockClientId);
  19801. _destinationIndex = getBlockIndex(selectedBlockClientId) + 1;
  19802. } else {
  19803. // Insert at the end of the list.
  19804. _destinationIndex = getBlockOrder(_destinationRootClientId).length;
  19805. }
  19806. return {
  19807. destinationRootClientId: _destinationRootClientId,
  19808. destinationIndex: _destinationIndex
  19809. };
  19810. }, [rootClientId, insertionIndex, clientId, isAppender]);
  19811. const {
  19812. replaceBlocks,
  19813. insertBlocks,
  19814. showInsertionPoint,
  19815. hideInsertionPoint
  19816. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  19817. const onInsertBlocks = (0,external_wp_element_namespaceObject.useCallback)(function (blocks, meta) {
  19818. let shouldForceFocusBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  19819. const selectedBlock = getSelectedBlock();
  19820. if (!isAppender && selectedBlock && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(selectedBlock)) {
  19821. replaceBlocks(selectedBlock.clientId, blocks, null, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
  19822. } else {
  19823. insertBlocks(blocks, destinationIndex, destinationRootClientId, true, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
  19824. }
  19825. const message = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %d: the name of the block that has been added
  19826. (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);
  19827. (0,external_wp_a11y_namespaceObject.speak)(message);
  19828. if (onSelect) {
  19829. onSelect();
  19830. }
  19831. }, [isAppender, getSelectedBlock, replaceBlocks, insertBlocks, destinationRootClientId, destinationIndex, onSelect, shouldFocusBlock]);
  19832. const onToggleInsertionPoint = (0,external_wp_element_namespaceObject.useCallback)(show => {
  19833. if (show) {
  19834. showInsertionPoint(destinationRootClientId, destinationIndex);
  19835. } else {
  19836. hideInsertionPoint();
  19837. }
  19838. }, [showInsertionPoint, hideInsertionPoint, destinationRootClientId, destinationIndex]);
  19839. return [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint];
  19840. }
  19841. /* harmony default export */ var use_insertion_point = (useInsertionPoint);
  19842. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-items.js
  19843. /**
  19844. * External dependencies
  19845. */
  19846. // Default search helpers.
  19847. const defaultGetName = item => item.name || '';
  19848. const defaultGetTitle = item => item.title;
  19849. const defaultGetDescription = item => item.description || '';
  19850. const defaultGetKeywords = item => item.keywords || [];
  19851. const defaultGetCategory = item => item.category;
  19852. const defaultGetCollection = () => null;
  19853. /**
  19854. * Sanitizes the search input string.
  19855. *
  19856. * @param {string} input The search input to normalize.
  19857. *
  19858. * @return {string} The normalized search input.
  19859. */
  19860. function normalizeSearchInput() {
  19861. let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  19862. // Disregard diacritics.
  19863. // Input: "média"
  19864. input = (0,external_lodash_namespaceObject.deburr)(input); // Accommodate leading slash, matching autocomplete expectations.
  19865. // Input: "/media"
  19866. input = input.replace(/^\//, ''); // Lowercase.
  19867. // Input: "MEDIA"
  19868. input = input.toLowerCase();
  19869. return input;
  19870. }
  19871. /**
  19872. * Converts the search term into a list of normalized terms.
  19873. *
  19874. * @param {string} input The search term to normalize.
  19875. *
  19876. * @return {string[]} The normalized list of search terms.
  19877. */
  19878. const getNormalizedSearchTerms = function () {
  19879. let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  19880. // Extract words.
  19881. return (0,external_lodash_namespaceObject.words)(normalizeSearchInput(input));
  19882. };
  19883. const removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
  19884. return (0,external_lodash_namespaceObject.differenceWith)(unmatchedTerms, getNormalizedSearchTerms(unprocessedTerms), (unmatchedTerm, unprocessedTerm) => unprocessedTerm.includes(unmatchedTerm));
  19885. };
  19886. const searchBlockItems = (items, categories, collections, searchInput) => {
  19887. const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
  19888. if (normalizedSearchTerms.length === 0) {
  19889. return items;
  19890. }
  19891. const config = {
  19892. getCategory: item => {
  19893. var _find;
  19894. return (_find = (0,external_lodash_namespaceObject.find)(categories, {
  19895. slug: item.category
  19896. })) === null || _find === void 0 ? void 0 : _find.title;
  19897. },
  19898. getCollection: item => {
  19899. var _collections$item$nam;
  19900. return (_collections$item$nam = collections[item.name.split('/')[0]]) === null || _collections$item$nam === void 0 ? void 0 : _collections$item$nam.title;
  19901. }
  19902. };
  19903. return searchItems(items, searchInput, config);
  19904. };
  19905. /**
  19906. * Filters an item list given a search term.
  19907. *
  19908. * @param {Array} items Item list
  19909. * @param {string} searchInput Search input.
  19910. * @param {Object} config Search Config.
  19911. *
  19912. * @return {Array} Filtered item list.
  19913. */
  19914. const searchItems = function () {
  19915. let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  19916. let searchInput = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  19917. let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  19918. const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
  19919. if (normalizedSearchTerms.length === 0) {
  19920. return items;
  19921. }
  19922. const rankedItems = items.map(item => {
  19923. return [item, getItemSearchRank(item, searchInput, config)];
  19924. }).filter(_ref => {
  19925. let [, rank] = _ref;
  19926. return rank > 0;
  19927. });
  19928. rankedItems.sort((_ref2, _ref3) => {
  19929. let [, rank1] = _ref2;
  19930. let [, rank2] = _ref3;
  19931. return rank2 - rank1;
  19932. });
  19933. return rankedItems.map(_ref4 => {
  19934. let [item] = _ref4;
  19935. return item;
  19936. });
  19937. };
  19938. /**
  19939. * Get the search rank for a given item and a specific search term.
  19940. * The better the match, the higher the rank.
  19941. * If the rank equals 0, it should be excluded from the results.
  19942. *
  19943. * @param {Object} item Item to filter.
  19944. * @param {string} searchTerm Search term.
  19945. * @param {Object} config Search Config.
  19946. *
  19947. * @return {number} Search Rank.
  19948. */
  19949. function getItemSearchRank(item, searchTerm) {
  19950. let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  19951. const {
  19952. getName = defaultGetName,
  19953. getTitle = defaultGetTitle,
  19954. getDescription = defaultGetDescription,
  19955. getKeywords = defaultGetKeywords,
  19956. getCategory = defaultGetCategory,
  19957. getCollection = defaultGetCollection
  19958. } = config;
  19959. const name = getName(item);
  19960. const title = getTitle(item);
  19961. const description = getDescription(item);
  19962. const keywords = getKeywords(item);
  19963. const category = getCategory(item);
  19964. const collection = getCollection(item);
  19965. const normalizedSearchInput = normalizeSearchInput(searchTerm);
  19966. const normalizedTitle = normalizeSearchInput(title);
  19967. let rank = 0; // Prefers exact matches
  19968. // Then prefers if the beginning of the title matches the search term
  19969. // name, keywords, categories, collection, variations match come later.
  19970. if (normalizedSearchInput === normalizedTitle) {
  19971. rank += 30;
  19972. } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
  19973. rank += 20;
  19974. } else {
  19975. const terms = [name, title, description, ...keywords, category, collection].join(' ');
  19976. const normalizedSearchTerms = (0,external_lodash_namespaceObject.words)(normalizedSearchInput);
  19977. const unmatchedTerms = removeMatchingTerms(normalizedSearchTerms, terms);
  19978. if (unmatchedTerms.length === 0) {
  19979. rank += 10;
  19980. }
  19981. } // Give a better rank to "core" namespaced items.
  19982. if (rank !== 0 && name.startsWith('core/')) {
  19983. const isCoreBlockVariation = name !== item.id; // Give a bit better rank to "core" blocks over "core" block variations.
  19984. rank += isCoreBlockVariation ? 1 : 2;
  19985. }
  19986. return rank;
  19987. }
  19988. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-explorer/patterns-list.js
  19989. /**
  19990. * WordPress dependencies
  19991. */
  19992. /**
  19993. * Internal dependencies
  19994. */
  19995. const INITIAL_INSERTER_RESULTS = 2;
  19996. function PatternsListHeader(_ref) {
  19997. let {
  19998. filterValue,
  19999. filteredBlockPatternsLength
  20000. } = _ref;
  20001. if (!filterValue) {
  20002. return null;
  20003. }
  20004. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
  20005. level: 2,
  20006. lineHeight: '48px',
  20007. className: "block-editor-block-patterns-explorer__search-results-count"
  20008. }, (0,external_wp_i18n_namespaceObject.sprintf)(
  20009. /* translators: %d: number of patterns. %s: block pattern search query */
  20010. (0,external_wp_i18n_namespaceObject._n)('%1$d pattern found for "%2$s"', '%1$d patterns found for "%2$s"', filteredBlockPatternsLength), filteredBlockPatternsLength, filterValue));
  20011. }
  20012. function PatternList(_ref2) {
  20013. let {
  20014. filterValue,
  20015. selectedCategory,
  20016. patternCategories
  20017. } = _ref2;
  20018. const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
  20019. const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
  20020. shouldFocusBlock: true
  20021. });
  20022. const [allPatterns,, onSelectBlockPattern] = use_patterns_state(onInsertBlocks, destinationRootClientId);
  20023. const registeredPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => patternCategories.map(patternCategory => patternCategory.name), [patternCategories]);
  20024. const filteredBlockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => {
  20025. if (!filterValue) {
  20026. return allPatterns.filter(pattern => {
  20027. var _pattern$categories, _pattern$categories2;
  20028. 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);
  20029. });
  20030. }
  20031. return searchItems(allPatterns, filterValue);
  20032. }, [filterValue, selectedCategory, allPatterns]); // Announce search results on change.
  20033. (0,external_wp_element_namespaceObject.useEffect)(() => {
  20034. if (!filterValue) {
  20035. return;
  20036. }
  20037. const count = filteredBlockPatterns.length;
  20038. const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
  20039. /* translators: %d: number of results. */
  20040. (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
  20041. debouncedSpeak(resultsFoundMessage);
  20042. }, [filterValue, debouncedSpeak]);
  20043. const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(filteredBlockPatterns, {
  20044. step: INITIAL_INSERTER_RESULTS
  20045. });
  20046. const hasItems = !!(filteredBlockPatterns !== null && filteredBlockPatterns !== void 0 && filteredBlockPatterns.length);
  20047. return (0,external_wp_element_namespaceObject.createElement)("div", {
  20048. className: "block-editor-block-patterns-explorer__list"
  20049. }, hasItems && (0,external_wp_element_namespaceObject.createElement)(PatternsListHeader, {
  20050. filterValue: filterValue,
  20051. filteredBlockPatternsLength: filteredBlockPatterns.length
  20052. }), (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, {
  20053. shownPatterns: currentShownPatterns,
  20054. blockPatterns: filteredBlockPatterns,
  20055. onClickPattern: onSelectBlockPattern,
  20056. isDraggable: false
  20057. })));
  20058. }
  20059. /* harmony default export */ var patterns_list = (PatternList);
  20060. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-explorer/explorer.js
  20061. /**
  20062. * WordPress dependencies
  20063. */
  20064. /**
  20065. * Internal dependencies
  20066. */
  20067. function PatternsExplorer(_ref) {
  20068. let {
  20069. initialCategory,
  20070. patternCategories
  20071. } = _ref;
  20072. const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
  20073. const [selectedCategory, setSelectedCategory] = (0,external_wp_element_namespaceObject.useState)(initialCategory === null || initialCategory === void 0 ? void 0 : initialCategory.name);
  20074. return (0,external_wp_element_namespaceObject.createElement)("div", {
  20075. className: "block-editor-block-patterns-explorer"
  20076. }, (0,external_wp_element_namespaceObject.createElement)(sidebar, {
  20077. selectedCategory: selectedCategory,
  20078. patternCategories: patternCategories,
  20079. onClickCategory: setSelectedCategory,
  20080. filterValue: filterValue,
  20081. setFilterValue: setFilterValue
  20082. }), (0,external_wp_element_namespaceObject.createElement)(patterns_list, {
  20083. filterValue: filterValue,
  20084. selectedCategory: selectedCategory,
  20085. patternCategories: patternCategories
  20086. }));
  20087. }
  20088. function PatternsExplorerModal(_ref2) {
  20089. let {
  20090. onModalClose,
  20091. ...restProps
  20092. } = _ref2;
  20093. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
  20094. title: (0,external_wp_i18n_namespaceObject.__)('Patterns'),
  20095. closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
  20096. onRequestClose: onModalClose,
  20097. isFullScreen: true
  20098. }, (0,external_wp_element_namespaceObject.createElement)(PatternsExplorer, restProps));
  20099. }
  20100. /* harmony default export */ var explorer = (PatternsExplorerModal);
  20101. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-tab.js
  20102. /**
  20103. * WordPress dependencies
  20104. */
  20105. /**
  20106. * Internal dependencies
  20107. */
  20108. function BlockPatternsCategory(_ref) {
  20109. let {
  20110. rootClientId,
  20111. onInsert,
  20112. selectedCategory,
  20113. populatedCategories
  20114. } = _ref;
  20115. const [allPatterns,, onClick] = use_patterns_state(onInsert, rootClientId);
  20116. const getPatternIndex = (0,external_wp_element_namespaceObject.useCallback)(pattern => {
  20117. var _pattern$categories;
  20118. if (!((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length)) {
  20119. return Infinity;
  20120. }
  20121. const indexedCategories = populatedCategories.reduce((accumulator, _ref2, index) => {
  20122. let {
  20123. name
  20124. } = _ref2;
  20125. accumulator[name] = index;
  20126. return accumulator;
  20127. }, {});
  20128. return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity));
  20129. }, [populatedCategories]);
  20130. const currentCategoryPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => allPatterns.filter(pattern => {
  20131. var _pattern$categories2;
  20132. return selectedCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory.name);
  20133. }), [allPatterns, selectedCategory]); // Ordering the patterns is important for the async rendering.
  20134. const orderedPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => {
  20135. return currentCategoryPatterns.sort((a, b) => {
  20136. return getPatternIndex(a) - getPatternIndex(b);
  20137. });
  20138. }, [currentCategoryPatterns, getPatternIndex]);
  20139. const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(orderedPatterns);
  20140. if (!currentCategoryPatterns.length) {
  20141. return null;
  20142. }
  20143. return (0,external_wp_element_namespaceObject.createElement)("div", {
  20144. className: "block-editor-inserter__panel-content"
  20145. }, (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, {
  20146. shownPatterns: currentShownPatterns,
  20147. blockPatterns: currentCategoryPatterns,
  20148. onClickPattern: onClick,
  20149. label: selectedCategory.label,
  20150. orientation: "vertical",
  20151. isDraggable: true
  20152. }));
  20153. }
  20154. function BlockPatternsTabs(_ref3) {
  20155. let {
  20156. rootClientId,
  20157. onInsert,
  20158. onClickCategory,
  20159. selectedCategory
  20160. } = _ref3;
  20161. const [showPatternsExplorer, setShowPatternsExplorer] = (0,external_wp_element_namespaceObject.useState)(false);
  20162. const [allPatterns, allCategories] = use_patterns_state();
  20163. const hasRegisteredCategory = (0,external_wp_element_namespaceObject.useCallback)(pattern => {
  20164. if (!pattern.categories || !pattern.categories.length) {
  20165. return false;
  20166. }
  20167. return pattern.categories.some(cat => allCategories.some(category => category.name === cat));
  20168. }, [allCategories]); // Remove any empty categories.
  20169. const populatedCategories = (0,external_wp_element_namespaceObject.useMemo)(() => {
  20170. const categories = allCategories.filter(category => allPatterns.some(pattern => {
  20171. var _pattern$categories3;
  20172. return (_pattern$categories3 = pattern.categories) === null || _pattern$categories3 === void 0 ? void 0 : _pattern$categories3.includes(category.name);
  20173. })).sort((_ref4, _ref5) => {
  20174. let {
  20175. name: currentName
  20176. } = _ref4;
  20177. let {
  20178. name: nextName
  20179. } = _ref5;
  20180. if (![currentName, nextName].includes('featured')) {
  20181. return 0;
  20182. }
  20183. return currentName === 'featured' ? -1 : 1;
  20184. });
  20185. if (allPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
  20186. categories.push({
  20187. name: 'uncategorized',
  20188. label: (0,external_wp_i18n_namespaceObject._x)('Uncategorized')
  20189. });
  20190. }
  20191. return categories;
  20192. }, [allPatterns, allCategories]);
  20193. const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
  20194. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(pattern_panel, {
  20195. selectedCategory: patternCategory,
  20196. patternCategories: populatedCategories,
  20197. onClickCategory: onClickCategory,
  20198. openPatternExplorer: () => setShowPatternsExplorer(true)
  20199. }), !showPatternsExplorer && (0,external_wp_element_namespaceObject.createElement)(BlockPatternsCategory, {
  20200. rootClientId: rootClientId,
  20201. onInsert: onInsert,
  20202. selectedCategory: patternCategory,
  20203. populatedCategories: populatedCategories
  20204. }), showPatternsExplorer && (0,external_wp_element_namespaceObject.createElement)(explorer, {
  20205. initialCategory: patternCategory,
  20206. patternCategories: populatedCategories,
  20207. onModalClose: () => setShowPatternsExplorer(false)
  20208. }));
  20209. }
  20210. /* harmony default export */ var block_patterns_tab = (BlockPatternsTabs);
  20211. ;// CONCATENATED MODULE: external ["wp","url"]
  20212. var external_wp_url_namespaceObject = window["wp"]["url"];
  20213. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/reusable-blocks-tab.js
  20214. /**
  20215. * WordPress dependencies
  20216. */
  20217. /**
  20218. * Internal dependencies
  20219. */
  20220. function ReusableBlocksList(_ref) {
  20221. let {
  20222. onHover,
  20223. onInsert,
  20224. rootClientId
  20225. } = _ref;
  20226. const [items,,, onSelectItem] = use_block_types_state(rootClientId, onInsert);
  20227. const filteredItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
  20228. return items.filter(_ref2 => {
  20229. let {
  20230. category
  20231. } = _ref2;
  20232. return category === 'reusable';
  20233. });
  20234. }, [items]);
  20235. if (filteredItems.length === 0) {
  20236. return (0,external_wp_element_namespaceObject.createElement)(no_results, null);
  20237. }
  20238. return (0,external_wp_element_namespaceObject.createElement)(panel, {
  20239. title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
  20240. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  20241. items: filteredItems,
  20242. onSelect: onSelectItem,
  20243. onHover: onHover,
  20244. label: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
  20245. }));
  20246. } // The unwrapped component is only exported for use by unit tests.
  20247. /**
  20248. * List of reusable blocks shown in the "Reusable" tab of the inserter.
  20249. *
  20250. * @param {Object} props Component props.
  20251. * @param {?string} props.rootClientId Client id of block to insert into.
  20252. * @param {Function} props.onInsert Callback to run when item is inserted.
  20253. * @param {Function} props.onHover Callback to run when item is hovered.
  20254. *
  20255. * @return {WPComponent} The component.
  20256. */
  20257. function ReusableBlocksTab(_ref3) {
  20258. let {
  20259. rootClientId,
  20260. onInsert,
  20261. onHover
  20262. } = _ref3;
  20263. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ReusableBlocksList, {
  20264. onHover: onHover,
  20265. onInsert: onInsert,
  20266. rootClientId: rootClientId
  20267. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  20268. className: "block-editor-inserter__manage-reusable-blocks-container"
  20269. }, (0,external_wp_element_namespaceObject.createElement)("a", {
  20270. className: "block-editor-inserter__manage-reusable-blocks",
  20271. href: (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
  20272. post_type: 'wp_block'
  20273. })
  20274. }, (0,external_wp_i18n_namespaceObject.__)('Manage Reusable blocks'))));
  20275. }
  20276. /* harmony default export */ var reusable_blocks_tab = (ReusableBlocksTab);
  20277. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-menu-extension/index.js
  20278. /**
  20279. * WordPress dependencies
  20280. */
  20281. const {
  20282. Fill: __unstableInserterMenuExtension,
  20283. Slot
  20284. } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableInserterMenuExtension');
  20285. __unstableInserterMenuExtension.Slot = Slot;
  20286. /* harmony default export */ var inserter_menu_extension = (__unstableInserterMenuExtension);
  20287. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-results.js
  20288. /**
  20289. * External dependencies
  20290. */
  20291. /**
  20292. * WordPress dependencies
  20293. */
  20294. /**
  20295. * Internal dependencies
  20296. */
  20297. const search_results_INITIAL_INSERTER_RESULTS = 9;
  20298. /**
  20299. * Shared reference to an empty array for cases where it is important to avoid
  20300. * returning a new array reference on every invocation and rerendering the component.
  20301. *
  20302. * @type {Array}
  20303. */
  20304. const search_results_EMPTY_ARRAY = [];
  20305. function InserterSearchResults(_ref) {
  20306. let {
  20307. filterValue,
  20308. onSelect,
  20309. onHover,
  20310. rootClientId,
  20311. clientId,
  20312. isAppender,
  20313. __experimentalInsertionIndex,
  20314. maxBlockPatterns,
  20315. maxBlockTypes,
  20316. showBlockDirectory = false,
  20317. isDraggable = true,
  20318. shouldFocusBlock = true,
  20319. prioritizePatterns
  20320. } = _ref;
  20321. const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
  20322. const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
  20323. onSelect,
  20324. rootClientId,
  20325. clientId,
  20326. isAppender,
  20327. insertionIndex: __experimentalInsertionIndex,
  20328. shouldFocusBlock
  20329. });
  20330. const [blockTypes, blockTypeCategories, blockTypeCollections, onSelectBlockType] = use_block_types_state(destinationRootClientId, onInsertBlocks);
  20331. const [patterns,, onSelectBlockPattern] = use_patterns_state(onInsertBlocks, destinationRootClientId);
  20332. const filteredBlockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => {
  20333. if (maxBlockPatterns === 0) {
  20334. return [];
  20335. }
  20336. const results = searchItems(patterns, filterValue);
  20337. return maxBlockPatterns !== undefined ? results.slice(0, maxBlockPatterns) : results;
  20338. }, [filterValue, patterns, maxBlockPatterns]);
  20339. let maxBlockTypesToShow = maxBlockTypes;
  20340. if (prioritizePatterns && filteredBlockPatterns.length > 2) {
  20341. maxBlockTypesToShow = 0;
  20342. }
  20343. const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
  20344. if (maxBlockTypesToShow === 0) {
  20345. return [];
  20346. }
  20347. const results = searchBlockItems((0,external_lodash_namespaceObject.orderBy)(blockTypes, ['frecency'], ['desc']), blockTypeCategories, blockTypeCollections, filterValue);
  20348. return maxBlockTypesToShow !== undefined ? results.slice(0, maxBlockTypesToShow) : results;
  20349. }, [filterValue, blockTypes, blockTypeCategories, blockTypeCollections, maxBlockTypes]); // Announce search results on change.
  20350. (0,external_wp_element_namespaceObject.useEffect)(() => {
  20351. if (!filterValue) {
  20352. return;
  20353. }
  20354. const count = filteredBlockTypes.length + filteredBlockPatterns.length;
  20355. const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
  20356. /* translators: %d: number of results. */
  20357. (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
  20358. debouncedSpeak(resultsFoundMessage);
  20359. }, [filterValue, debouncedSpeak]);
  20360. const currentShownBlockTypes = (0,external_wp_compose_namespaceObject.useAsyncList)(filteredBlockTypes, {
  20361. step: search_results_INITIAL_INSERTER_RESULTS
  20362. });
  20363. const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(currentShownBlockTypes.length === filteredBlockTypes.length ? filteredBlockPatterns : search_results_EMPTY_ARRAY);
  20364. const hasItems = !(0,external_lodash_namespaceObject.isEmpty)(filteredBlockTypes) || !(0,external_lodash_namespaceObject.isEmpty)(filteredBlockPatterns);
  20365. const blocksUI = !!filteredBlockTypes.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
  20366. title: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Blocks'))
  20367. }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
  20368. items: currentShownBlockTypes,
  20369. onSelect: onSelectBlockType,
  20370. onHover: onHover,
  20371. label: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
  20372. isDraggable: isDraggable
  20373. }));
  20374. const patternsUI = !!filteredBlockPatterns.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
  20375. title: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Block Patterns'))
  20376. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  20377. className: "block-editor-inserter__quick-inserter-patterns"
  20378. }, (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, {
  20379. shownPatterns: currentShownPatterns,
  20380. blockPatterns: filteredBlockPatterns,
  20381. onClickPattern: onSelectBlockPattern,
  20382. isDraggable: isDraggable
  20383. })));
  20384. 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", {
  20385. className: "block-editor-inserter__quick-inserter-separator"
  20386. }), prioritizePatterns ? blocksUI : patternsUI, showBlockDirectory && (0,external_wp_element_namespaceObject.createElement)(inserter_menu_extension.Slot, {
  20387. fillProps: {
  20388. onSelect: onSelectBlockType,
  20389. onHover,
  20390. filterValue,
  20391. hasItems,
  20392. rootClientId: destinationRootClientId
  20393. }
  20394. }, fills => {
  20395. if (fills.length) {
  20396. return fills;
  20397. }
  20398. if (!hasItems) {
  20399. return (0,external_wp_element_namespaceObject.createElement)(no_results, null);
  20400. }
  20401. return null;
  20402. }));
  20403. }
  20404. /* harmony default export */ var search_results = (InserterSearchResults);
  20405. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/tabs.js
  20406. /**
  20407. * WordPress dependencies
  20408. */
  20409. const blocksTab = {
  20410. name: 'blocks',
  20411. /* translators: Blocks tab title in the block inserter. */
  20412. title: (0,external_wp_i18n_namespaceObject.__)('Blocks')
  20413. };
  20414. const patternsTab = {
  20415. name: 'patterns',
  20416. /* translators: Patterns tab title in the block inserter. */
  20417. title: (0,external_wp_i18n_namespaceObject.__)('Patterns')
  20418. };
  20419. const reusableBlocksTab = {
  20420. name: 'reusable',
  20421. /* translators: Reusable blocks tab title in the block inserter. */
  20422. title: (0,external_wp_i18n_namespaceObject.__)('Reusable')
  20423. };
  20424. function InserterTabs(_ref) {
  20425. let {
  20426. children,
  20427. showPatterns = false,
  20428. showReusableBlocks = false,
  20429. onSelect
  20430. } = _ref;
  20431. const tabs = (0,external_wp_element_namespaceObject.useMemo)(() => {
  20432. const tempTabs = [blocksTab];
  20433. if (showPatterns) {
  20434. tempTabs.push(patternsTab);
  20435. }
  20436. if (showReusableBlocks) {
  20437. tempTabs.push(reusableBlocksTab);
  20438. }
  20439. return tempTabs;
  20440. }, [blocksTab, showPatterns, patternsTab, showReusableBlocks, reusableBlocksTab]);
  20441. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
  20442. className: "block-editor-inserter__tabs",
  20443. tabs: tabs,
  20444. onSelect: onSelect
  20445. }, children);
  20446. }
  20447. /* harmony default export */ var tabs = (InserterTabs);
  20448. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/menu.js
  20449. /**
  20450. * WordPress dependencies
  20451. */
  20452. /**
  20453. * Internal dependencies
  20454. */
  20455. function InserterMenu(_ref, ref) {
  20456. let {
  20457. rootClientId,
  20458. clientId,
  20459. isAppender,
  20460. __experimentalInsertionIndex,
  20461. onSelect,
  20462. showInserterHelpPanel,
  20463. showMostUsedBlocks,
  20464. __experimentalFilterValue = '',
  20465. shouldFocusBlock = true
  20466. } = _ref;
  20467. const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(__experimentalFilterValue);
  20468. const [hoveredItem, setHoveredItem] = (0,external_wp_element_namespaceObject.useState)(null);
  20469. const [selectedPatternCategory, setSelectedPatternCategory] = (0,external_wp_element_namespaceObject.useState)(null);
  20470. const [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint] = use_insertion_point({
  20471. rootClientId,
  20472. clientId,
  20473. isAppender,
  20474. insertionIndex: __experimentalInsertionIndex,
  20475. shouldFocusBlock
  20476. });
  20477. const {
  20478. showPatterns,
  20479. hasReusableBlocks
  20480. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  20481. var _getSettings$__experi;
  20482. const {
  20483. __experimentalGetAllowedPatterns,
  20484. getSettings
  20485. } = select(store);
  20486. return {
  20487. showPatterns: !!__experimentalGetAllowedPatterns(destinationRootClientId).length,
  20488. hasReusableBlocks: !!((_getSettings$__experi = getSettings().__experimentalReusableBlocks) !== null && _getSettings$__experi !== void 0 && _getSettings$__experi.length)
  20489. };
  20490. }, [destinationRootClientId]);
  20491. const onInsert = (0,external_wp_element_namespaceObject.useCallback)((blocks, meta, shouldForceFocusBlock) => {
  20492. onInsertBlocks(blocks, meta, shouldForceFocusBlock);
  20493. onSelect();
  20494. }, [onInsertBlocks, onSelect]);
  20495. const onInsertPattern = (0,external_wp_element_namespaceObject.useCallback)((blocks, patternName) => {
  20496. onInsertBlocks(blocks, {
  20497. patternName
  20498. });
  20499. onSelect();
  20500. }, [onInsertBlocks, onSelect]);
  20501. const onHover = (0,external_wp_element_namespaceObject.useCallback)(item => {
  20502. onToggleInsertionPoint(!!item);
  20503. setHoveredItem(item);
  20504. }, [onToggleInsertionPoint, setHoveredItem]);
  20505. const onClickPatternCategory = (0,external_wp_element_namespaceObject.useCallback)(patternCategory => {
  20506. setSelectedPatternCategory(patternCategory);
  20507. }, [setSelectedPatternCategory]);
  20508. 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", {
  20509. className: "block-editor-inserter__block-list"
  20510. }, (0,external_wp_element_namespaceObject.createElement)(block_types_tab, {
  20511. rootClientId: destinationRootClientId,
  20512. onInsert: onInsert,
  20513. onHover: onHover,
  20514. showMostUsedBlocks: showMostUsedBlocks
  20515. })), showInserterHelpPanel && (0,external_wp_element_namespaceObject.createElement)("div", {
  20516. className: "block-editor-inserter__tips"
  20517. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  20518. as: "h2"
  20519. }, (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]);
  20520. const patternsTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(block_patterns_tab, {
  20521. rootClientId: destinationRootClientId,
  20522. onInsert: onInsertPattern,
  20523. onClickCategory: onClickPatternCategory,
  20524. selectedCategory: selectedPatternCategory
  20525. }), [destinationRootClientId, onInsertPattern, onClickPatternCategory, selectedPatternCategory]);
  20526. const reusableBlocksTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(reusable_blocks_tab, {
  20527. rootClientId: destinationRootClientId,
  20528. onInsert: onInsert,
  20529. onHover: onHover
  20530. }), [destinationRootClientId, onInsert, onHover]);
  20531. const getCurrentTab = (0,external_wp_element_namespaceObject.useCallback)(tab => {
  20532. if (tab.name === 'blocks') {
  20533. return blocksTab;
  20534. } else if (tab.name === 'patterns') {
  20535. return patternsTab;
  20536. }
  20537. return reusableBlocksTab;
  20538. }, [blocksTab, patternsTab, reusableBlocksTab]);
  20539. const searchRef = (0,external_wp_element_namespaceObject.useRef)();
  20540. (0,external_wp_element_namespaceObject.useImperativeHandle)(ref, () => ({
  20541. focusSearch: () => {
  20542. searchRef.current.focus();
  20543. }
  20544. }));
  20545. return (0,external_wp_element_namespaceObject.createElement)("div", {
  20546. className: "block-editor-inserter__menu"
  20547. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  20548. className: "block-editor-inserter__main-area"
  20549. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  20550. className: "block-editor-inserter__content"
  20551. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
  20552. className: "block-editor-inserter__search",
  20553. onChange: value => {
  20554. if (hoveredItem) setHoveredItem(null);
  20555. setFilterValue(value);
  20556. },
  20557. value: filterValue,
  20558. label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks and patterns'),
  20559. placeholder: (0,external_wp_i18n_namespaceObject.__)('Search'),
  20560. ref: searchRef
  20561. }), !!filterValue && (0,external_wp_element_namespaceObject.createElement)(search_results, {
  20562. filterValue: filterValue,
  20563. onSelect: onSelect,
  20564. onHover: onHover,
  20565. rootClientId: rootClientId,
  20566. clientId: clientId,
  20567. isAppender: isAppender,
  20568. __experimentalInsertionIndex: __experimentalInsertionIndex,
  20569. showBlockDirectory: true,
  20570. shouldFocusBlock: shouldFocusBlock
  20571. }), !filterValue && (showPatterns || hasReusableBlocks) && (0,external_wp_element_namespaceObject.createElement)(tabs, {
  20572. showPatterns: showPatterns,
  20573. showReusableBlocks: hasReusableBlocks
  20574. }, getCurrentTab), !filterValue && !showPatterns && !hasReusableBlocks && blocksTab)), showInserterHelpPanel && hoveredItem && (0,external_wp_element_namespaceObject.createElement)(preview_panel, {
  20575. item: hoveredItem
  20576. }));
  20577. }
  20578. /* harmony default export */ var menu = ((0,external_wp_element_namespaceObject.forwardRef)(InserterMenu));
  20579. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/quick-inserter.js
  20580. /**
  20581. * External dependencies
  20582. */
  20583. /**
  20584. * WordPress dependencies
  20585. */
  20586. /**
  20587. * Internal dependencies
  20588. */
  20589. const SEARCH_THRESHOLD = 6;
  20590. const SHOWN_BLOCK_TYPES = 6;
  20591. const SHOWN_BLOCK_PATTERNS = 2;
  20592. const SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION = 4;
  20593. function QuickInserter(_ref) {
  20594. let {
  20595. onSelect,
  20596. rootClientId,
  20597. clientId,
  20598. isAppender,
  20599. prioritizePatterns
  20600. } = _ref;
  20601. const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
  20602. const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
  20603. onSelect,
  20604. rootClientId,
  20605. clientId,
  20606. isAppender
  20607. });
  20608. const [blockTypes] = use_block_types_state(destinationRootClientId, onInsertBlocks);
  20609. const [patterns] = use_patterns_state(onInsertBlocks, destinationRootClientId);
  20610. const {
  20611. setInserterIsOpened,
  20612. insertionIndex
  20613. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  20614. const {
  20615. getSettings,
  20616. getBlockIndex,
  20617. getBlockCount
  20618. } = select(store);
  20619. const settings = getSettings();
  20620. const index = getBlockIndex(clientId);
  20621. const blockCount = getBlockCount();
  20622. return {
  20623. setInserterIsOpened: settings.__experimentalSetIsInserterOpened,
  20624. insertionIndex: index === -1 ? blockCount : index
  20625. };
  20626. }, [clientId]);
  20627. const showPatterns = patterns.length && (!!filterValue || prioritizePatterns);
  20628. const showSearch = showPatterns && patterns.length > SEARCH_THRESHOLD || blockTypes.length > SEARCH_THRESHOLD;
  20629. (0,external_wp_element_namespaceObject.useEffect)(() => {
  20630. if (setInserterIsOpened) {
  20631. setInserterIsOpened(false);
  20632. }
  20633. }, [setInserterIsOpened]); // When clicking Browse All select the appropriate block so as
  20634. // the insertion point can work as expected.
  20635. const onBrowseAll = () => {
  20636. setInserterIsOpened({
  20637. rootClientId,
  20638. insertionIndex,
  20639. filterValue
  20640. });
  20641. };
  20642. let maxBlockPatterns = 0;
  20643. if (showPatterns) {
  20644. maxBlockPatterns = prioritizePatterns ? SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION : SHOWN_BLOCK_PATTERNS;
  20645. }
  20646. return (0,external_wp_element_namespaceObject.createElement)("div", {
  20647. className: classnames_default()('block-editor-inserter__quick-inserter', {
  20648. 'has-search': showSearch,
  20649. 'has-expand': setInserterIsOpened
  20650. })
  20651. }, showSearch && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
  20652. className: "block-editor-inserter__search",
  20653. value: filterValue,
  20654. onChange: value => {
  20655. setFilterValue(value);
  20656. },
  20657. label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks and patterns'),
  20658. placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
  20659. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  20660. className: "block-editor-inserter__quick-inserter-results"
  20661. }, (0,external_wp_element_namespaceObject.createElement)(search_results, {
  20662. filterValue: filterValue,
  20663. onSelect: onSelect,
  20664. rootClientId: rootClientId,
  20665. clientId: clientId,
  20666. isAppender: isAppender,
  20667. maxBlockPatterns: maxBlockPatterns,
  20668. maxBlockTypes: SHOWN_BLOCK_TYPES,
  20669. isDraggable: false,
  20670. prioritizePatterns: prioritizePatterns
  20671. })), setInserterIsOpened && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  20672. className: "block-editor-inserter__quick-inserter-expand",
  20673. onClick: onBrowseAll,
  20674. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Browse all. This will open the main inserter panel in the editor toolbar.')
  20675. }, (0,external_wp_i18n_namespaceObject.__)('Browse all')));
  20676. }
  20677. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/index.js
  20678. /**
  20679. * External dependencies
  20680. */
  20681. /**
  20682. * WordPress dependencies
  20683. */
  20684. /**
  20685. * Internal dependencies
  20686. */
  20687. const defaultRenderToggle = _ref => {
  20688. let {
  20689. onToggle,
  20690. disabled,
  20691. isOpen,
  20692. blockTitle,
  20693. hasSingleBlockType,
  20694. toggleProps = {},
  20695. prioritizePatterns
  20696. } = _ref;
  20697. let label;
  20698. if (hasSingleBlockType) {
  20699. label = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block when there is only one
  20700. (0,external_wp_i18n_namespaceObject._x)('Add %s', 'directly add the only allowed block'), blockTitle);
  20701. } else if (prioritizePatterns) {
  20702. label = (0,external_wp_i18n_namespaceObject.__)('Add pattern');
  20703. } else {
  20704. label = (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button');
  20705. }
  20706. const {
  20707. onClick,
  20708. ...rest
  20709. } = toggleProps; // Handle both onClick functions from the toggle and the parent component.
  20710. function handleClick(event) {
  20711. if (onToggle) {
  20712. onToggle(event);
  20713. }
  20714. if (onClick) {
  20715. onClick(event);
  20716. }
  20717. }
  20718. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
  20719. icon: library_plus,
  20720. label: label,
  20721. tooltipPosition: "bottom",
  20722. onClick: handleClick,
  20723. className: "block-editor-inserter__toggle",
  20724. "aria-haspopup": !hasSingleBlockType ? 'true' : false,
  20725. "aria-expanded": !hasSingleBlockType ? isOpen : false,
  20726. disabled: disabled
  20727. }, rest));
  20728. };
  20729. class Inserter extends external_wp_element_namespaceObject.Component {
  20730. constructor() {
  20731. super(...arguments);
  20732. this.onToggle = this.onToggle.bind(this);
  20733. this.renderToggle = this.renderToggle.bind(this);
  20734. this.renderContent = this.renderContent.bind(this);
  20735. }
  20736. onToggle(isOpen) {
  20737. const {
  20738. onToggle
  20739. } = this.props; // Surface toggle callback to parent component.
  20740. if (onToggle) {
  20741. onToggle(isOpen);
  20742. }
  20743. }
  20744. /**
  20745. * Render callback to display Dropdown toggle element.
  20746. *
  20747. * @param {Object} options
  20748. * @param {Function} options.onToggle Callback to invoke when toggle is
  20749. * pressed.
  20750. * @param {boolean} options.isOpen Whether dropdown is currently open.
  20751. *
  20752. * @return {WPElement} Dropdown toggle element.
  20753. */
  20754. renderToggle(_ref2) {
  20755. let {
  20756. onToggle,
  20757. isOpen
  20758. } = _ref2;
  20759. const {
  20760. disabled,
  20761. blockTitle,
  20762. hasSingleBlockType,
  20763. directInsertBlock,
  20764. toggleProps,
  20765. hasItems,
  20766. renderToggle = defaultRenderToggle,
  20767. prioritizePatterns
  20768. } = this.props;
  20769. return renderToggle({
  20770. onToggle,
  20771. isOpen,
  20772. disabled: disabled || !hasItems,
  20773. blockTitle,
  20774. hasSingleBlockType,
  20775. directInsertBlock,
  20776. toggleProps,
  20777. prioritizePatterns
  20778. });
  20779. }
  20780. /**
  20781. * Render callback to display Dropdown content element.
  20782. *
  20783. * @param {Object} options
  20784. * @param {Function} options.onClose Callback to invoke when dropdown is
  20785. * closed.
  20786. *
  20787. * @return {WPElement} Dropdown content element.
  20788. */
  20789. renderContent(_ref3) {
  20790. let {
  20791. onClose
  20792. } = _ref3;
  20793. const {
  20794. rootClientId,
  20795. clientId,
  20796. isAppender,
  20797. showInserterHelpPanel,
  20798. // This prop is experimental to give some time for the quick inserter to mature
  20799. // Feel free to make them stable after a few releases.
  20800. __experimentalIsQuick: isQuick,
  20801. prioritizePatterns
  20802. } = this.props;
  20803. if (isQuick) {
  20804. return (0,external_wp_element_namespaceObject.createElement)(QuickInserter, {
  20805. onSelect: () => {
  20806. onClose();
  20807. },
  20808. rootClientId: rootClientId,
  20809. clientId: clientId,
  20810. isAppender: isAppender,
  20811. prioritizePatterns: prioritizePatterns
  20812. });
  20813. }
  20814. return (0,external_wp_element_namespaceObject.createElement)(menu, {
  20815. onSelect: () => {
  20816. onClose();
  20817. },
  20818. rootClientId: rootClientId,
  20819. clientId: clientId,
  20820. isAppender: isAppender,
  20821. showInserterHelpPanel: showInserterHelpPanel
  20822. });
  20823. }
  20824. render() {
  20825. const {
  20826. position,
  20827. hasSingleBlockType,
  20828. directInsertBlock,
  20829. insertOnlyAllowedBlock,
  20830. __experimentalIsQuick: isQuick,
  20831. onSelectOrClose
  20832. } = this.props;
  20833. if (hasSingleBlockType || directInsertBlock) {
  20834. return this.renderToggle({
  20835. onToggle: insertOnlyAllowedBlock
  20836. });
  20837. }
  20838. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  20839. className: "block-editor-inserter",
  20840. contentClassName: classnames_default()('block-editor-inserter__popover', {
  20841. 'is-quick': isQuick
  20842. }),
  20843. position: position,
  20844. onToggle: this.onToggle,
  20845. expandOnMobile: true,
  20846. headerTitle: (0,external_wp_i18n_namespaceObject.__)('Add a block'),
  20847. renderToggle: this.renderToggle,
  20848. renderContent: this.renderContent,
  20849. onClose: onSelectOrClose
  20850. });
  20851. }
  20852. }
  20853. /* harmony default export */ var inserter = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref4) => {
  20854. let {
  20855. clientId,
  20856. rootClientId
  20857. } = _ref4;
  20858. const {
  20859. getBlockRootClientId,
  20860. hasInserterItems,
  20861. __experimentalGetAllowedBlocks,
  20862. __experimentalGetDirectInsertBlock,
  20863. getBlockIndex,
  20864. getBlockCount,
  20865. getSettings
  20866. } = select(store);
  20867. const {
  20868. getBlockVariations
  20869. } = select(external_wp_blocks_namespaceObject.store);
  20870. rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
  20871. const allowedBlocks = __experimentalGetAllowedBlocks(rootClientId);
  20872. const directInsertBlock = __experimentalGetDirectInsertBlock(rootClientId);
  20873. const index = getBlockIndex(clientId);
  20874. const blockCount = getBlockCount();
  20875. const settings = getSettings();
  20876. const hasSingleBlockType = (0,external_lodash_namespaceObject.size)(allowedBlocks) === 1 && (0,external_lodash_namespaceObject.size)(getBlockVariations(allowedBlocks[0].name, 'inserter')) === 0;
  20877. let allowedBlockType = false;
  20878. if (hasSingleBlockType) {
  20879. allowedBlockType = allowedBlocks[0];
  20880. }
  20881. return {
  20882. hasItems: hasInserterItems(rootClientId),
  20883. hasSingleBlockType,
  20884. blockTitle: allowedBlockType ? allowedBlockType.title : '',
  20885. allowedBlockType,
  20886. directInsertBlock,
  20887. rootClientId,
  20888. prioritizePatterns: settings.__experimentalPreferPatternsOnRoot && !rootClientId && index > 0 && (index < blockCount || blockCount === 0)
  20889. };
  20890. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps, _ref5) => {
  20891. let {
  20892. select
  20893. } = _ref5;
  20894. return {
  20895. insertOnlyAllowedBlock() {
  20896. const {
  20897. rootClientId,
  20898. clientId,
  20899. isAppender,
  20900. hasSingleBlockType,
  20901. allowedBlockType,
  20902. directInsertBlock,
  20903. onSelectOrClose
  20904. } = ownProps;
  20905. if (!hasSingleBlockType && !directInsertBlock) {
  20906. return;
  20907. }
  20908. function getAdjacentBlockAttributes(attributesToCopy) {
  20909. const {
  20910. getBlock,
  20911. getPreviousBlockClientId
  20912. } = select(store);
  20913. if (!attributesToCopy || !clientId && !rootClientId) {
  20914. return {};
  20915. }
  20916. const result = {};
  20917. let adjacentAttributes = {}; // If there is no clientId, then attempt to get attributes
  20918. // from the last block within innerBlocks of the root block.
  20919. if (!clientId) {
  20920. var _parentBlock$innerBlo;
  20921. const parentBlock = getBlock(rootClientId);
  20922. if (parentBlock !== null && parentBlock !== void 0 && (_parentBlock$innerBlo = parentBlock.innerBlocks) !== null && _parentBlock$innerBlo !== void 0 && _parentBlock$innerBlo.length) {
  20923. const lastInnerBlock = parentBlock.innerBlocks[parentBlock.innerBlocks.length - 1];
  20924. if (directInsertBlock && (directInsertBlock === null || directInsertBlock === void 0 ? void 0 : directInsertBlock.name) === lastInnerBlock.name) {
  20925. adjacentAttributes = lastInnerBlock.attributes;
  20926. }
  20927. }
  20928. } else {
  20929. // Otherwise, attempt to get attributes from the
  20930. // previous block relative to the current clientId.
  20931. const currentBlock = getBlock(clientId);
  20932. const previousBlock = getBlock(getPreviousBlockClientId(clientId));
  20933. if ((currentBlock === null || currentBlock === void 0 ? void 0 : currentBlock.name) === (previousBlock === null || previousBlock === void 0 ? void 0 : previousBlock.name)) {
  20934. adjacentAttributes = (previousBlock === null || previousBlock === void 0 ? void 0 : previousBlock.attributes) || {};
  20935. }
  20936. } // Copy over only those attributes flagged to be copied.
  20937. attributesToCopy.forEach(attribute => {
  20938. if (adjacentAttributes.hasOwnProperty(attribute)) {
  20939. result[attribute] = adjacentAttributes[attribute];
  20940. }
  20941. });
  20942. return result;
  20943. }
  20944. function getInsertionIndex() {
  20945. const {
  20946. getBlockIndex,
  20947. getBlockSelectionEnd,
  20948. getBlockOrder,
  20949. getBlockRootClientId
  20950. } = select(store); // If the clientId is defined, we insert at the position of the block.
  20951. if (clientId) {
  20952. return getBlockIndex(clientId);
  20953. } // If there a selected block, we insert after the selected block.
  20954. const end = getBlockSelectionEnd();
  20955. if (!isAppender && end && getBlockRootClientId(end) === rootClientId) {
  20956. return getBlockIndex(end) + 1;
  20957. } // Otherwise, we insert at the end of the current rootClientId.
  20958. return getBlockOrder(rootClientId).length;
  20959. }
  20960. const {
  20961. insertBlock
  20962. } = dispatch(store);
  20963. let blockToInsert; // Attempt to augment the directInsertBlock with attributes from an adjacent block.
  20964. // This ensures styling from nearby blocks is preserved in the newly inserted block.
  20965. // See: https://github.com/WordPress/gutenberg/issues/37904
  20966. if (directInsertBlock) {
  20967. const newAttributes = getAdjacentBlockAttributes(directInsertBlock.attributesToCopy);
  20968. blockToInsert = (0,external_wp_blocks_namespaceObject.createBlock)(directInsertBlock.name, { ...(directInsertBlock.attributes || {}),
  20969. ...newAttributes
  20970. });
  20971. } else {
  20972. blockToInsert = (0,external_wp_blocks_namespaceObject.createBlock)(allowedBlockType.name);
  20973. }
  20974. insertBlock(blockToInsert, getInsertionIndex(), rootClientId);
  20975. if (onSelectOrClose) {
  20976. onSelectOrClose();
  20977. }
  20978. const message = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block that has been added
  20979. (0,external_wp_i18n_namespaceObject.__)('%s block added'), allowedBlockType.title);
  20980. (0,external_wp_a11y_namespaceObject.speak)(message);
  20981. }
  20982. };
  20983. }), // The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as
  20984. // a way to detect the global Inserter.
  20985. (0,external_wp_compose_namespaceObject.ifCondition)(_ref6 => {
  20986. let {
  20987. hasItems,
  20988. isAppender,
  20989. rootClientId,
  20990. clientId
  20991. } = _ref6;
  20992. return hasItems || !isAppender && !rootClientId && !clientId;
  20993. })])(Inserter));
  20994. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-block-appender/index.js
  20995. /**
  20996. * External dependencies
  20997. */
  20998. /**
  20999. * WordPress dependencies
  21000. */
  21001. /**
  21002. * Internal dependencies
  21003. */
  21004. /**
  21005. * Zero width non-breaking space, used as padding for the paragraph when it is
  21006. * empty.
  21007. */
  21008. const ZWNBSP = '\ufeff';
  21009. function DefaultBlockAppender(_ref) {
  21010. let {
  21011. isLocked,
  21012. onAppend,
  21013. showPrompt,
  21014. placeholder,
  21015. rootClientId
  21016. } = _ref;
  21017. if (isLocked) {
  21018. return null;
  21019. }
  21020. const value = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Type / to choose a block');
  21021. return (0,external_wp_element_namespaceObject.createElement)("div", {
  21022. "data-root-client-id": rootClientId || '',
  21023. className: classnames_default()('block-editor-default-block-appender', {
  21024. 'has-visible-prompt': showPrompt
  21025. })
  21026. }, (0,external_wp_element_namespaceObject.createElement)("p", {
  21027. tabIndex: "0" // We want this element to be styled as a paragraph by themes.
  21028. // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
  21029. ,
  21030. role: "button",
  21031. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Add default block') // A wrapping container for this one already has the wp-block className.
  21032. ,
  21033. className: "block-editor-default-block-appender__content",
  21034. onKeyDown: event => {
  21035. if (external_wp_keycodes_namespaceObject.ENTER === event.keyCode || external_wp_keycodes_namespaceObject.SPACE === event.keyCode) {
  21036. onAppend();
  21037. }
  21038. },
  21039. onClick: () => onAppend(),
  21040. onFocus: () => {
  21041. if (showPrompt) {
  21042. onAppend();
  21043. }
  21044. }
  21045. }, showPrompt ? value : ZWNBSP), (0,external_wp_element_namespaceObject.createElement)(inserter, {
  21046. rootClientId: rootClientId,
  21047. position: "bottom right",
  21048. isAppender: true,
  21049. __experimentalIsQuick: true
  21050. }));
  21051. }
  21052. /* harmony default export */ var default_block_appender = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
  21053. const {
  21054. getBlockCount,
  21055. getSettings,
  21056. getTemplateLock
  21057. } = select(store);
  21058. const isEmpty = !getBlockCount(ownProps.rootClientId);
  21059. const {
  21060. bodyPlaceholder
  21061. } = getSettings();
  21062. return {
  21063. showPrompt: isEmpty,
  21064. isLocked: !!getTemplateLock(ownProps.rootClientId),
  21065. placeholder: bodyPlaceholder
  21066. };
  21067. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => {
  21068. const {
  21069. insertDefaultBlock,
  21070. startTyping
  21071. } = dispatch(store);
  21072. return {
  21073. onAppend() {
  21074. const {
  21075. rootClientId
  21076. } = ownProps;
  21077. insertDefaultBlock(undefined, rootClientId);
  21078. startTyping();
  21079. }
  21080. };
  21081. }))(DefaultBlockAppender));
  21082. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/button-block-appender/index.js
  21083. /**
  21084. * External dependencies
  21085. */
  21086. /**
  21087. * WordPress dependencies
  21088. */
  21089. /**
  21090. * Internal dependencies
  21091. */
  21092. function ButtonBlockAppender(_ref, ref) {
  21093. let {
  21094. rootClientId,
  21095. className,
  21096. onFocus,
  21097. tabIndex
  21098. } = _ref;
  21099. return (0,external_wp_element_namespaceObject.createElement)(inserter, {
  21100. position: "bottom center",
  21101. rootClientId: rootClientId,
  21102. __experimentalIsQuick: true,
  21103. renderToggle: _ref2 => {
  21104. let {
  21105. onToggle,
  21106. disabled,
  21107. isOpen,
  21108. blockTitle,
  21109. hasSingleBlockType
  21110. } = _ref2;
  21111. let label;
  21112. if (hasSingleBlockType) {
  21113. label = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block when there is only one
  21114. (0,external_wp_i18n_namespaceObject._x)('Add %s', 'directly add the only allowed block'), blockTitle);
  21115. } else {
  21116. label = (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button');
  21117. }
  21118. const isToggleButton = !hasSingleBlockType;
  21119. let inserterButton = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  21120. ref: ref,
  21121. onFocus: onFocus,
  21122. tabIndex: tabIndex,
  21123. className: classnames_default()(className, 'block-editor-button-block-appender'),
  21124. onClick: onToggle,
  21125. "aria-haspopup": isToggleButton ? 'true' : undefined,
  21126. "aria-expanded": isToggleButton ? isOpen : undefined,
  21127. disabled: disabled,
  21128. label: label
  21129. }, !hasSingleBlockType && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  21130. as: "span"
  21131. }, label), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  21132. icon: library_plus
  21133. }));
  21134. if (isToggleButton || hasSingleBlockType) {
  21135. inserterButton = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
  21136. text: label
  21137. }, inserterButton);
  21138. }
  21139. return inserterButton;
  21140. },
  21141. isAppender: true
  21142. });
  21143. }
  21144. /**
  21145. * Use `ButtonBlockAppender` instead.
  21146. *
  21147. * @deprecated
  21148. */
  21149. const ButtonBlockerAppender = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  21150. external_wp_deprecated_default()(`wp.blockEditor.ButtonBlockerAppender`, {
  21151. alternative: 'wp.blockEditor.ButtonBlockAppender',
  21152. since: '5.9'
  21153. });
  21154. return ButtonBlockAppender(props, ref);
  21155. });
  21156. /**
  21157. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/button-block-appender/README.md
  21158. */
  21159. /* harmony default export */ var button_block_appender = ((0,external_wp_element_namespaceObject.forwardRef)(ButtonBlockAppender));
  21160. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list-appender/index.js
  21161. /**
  21162. * External dependencies
  21163. */
  21164. /**
  21165. * WordPress dependencies
  21166. */
  21167. /**
  21168. * Internal dependencies
  21169. */
  21170. function BlockListAppender(_ref) {
  21171. let {
  21172. rootClientId,
  21173. canInsertDefaultBlock,
  21174. isLocked,
  21175. renderAppender: CustomAppender,
  21176. className,
  21177. selectedBlockClientId,
  21178. tagName: TagName = 'div'
  21179. } = _ref;
  21180. if (isLocked || CustomAppender === false) {
  21181. return null;
  21182. }
  21183. let appender;
  21184. if (CustomAppender) {
  21185. // Prefer custom render prop if provided.
  21186. appender = (0,external_wp_element_namespaceObject.createElement)(CustomAppender, null);
  21187. } else {
  21188. const isParentSelected = selectedBlockClientId === rootClientId || !rootClientId && !selectedBlockClientId;
  21189. if (!isParentSelected) {
  21190. return null;
  21191. }
  21192. if (canInsertDefaultBlock) {
  21193. // Render the default block appender when renderAppender has not been
  21194. // provided and the context supports use of the default appender.
  21195. appender = (0,external_wp_element_namespaceObject.createElement)(default_block_appender, {
  21196. rootClientId: rootClientId
  21197. });
  21198. } else {
  21199. // Fallback in the case no renderAppender has been provided and the
  21200. // default block can't be inserted.
  21201. appender = (0,external_wp_element_namespaceObject.createElement)(button_block_appender, {
  21202. rootClientId: rootClientId,
  21203. className: "block-list-appender__toggle"
  21204. });
  21205. }
  21206. }
  21207. return (0,external_wp_element_namespaceObject.createElement)(TagName // A `tabIndex` is used on the wrapping `div` element in order to
  21208. // force a focus event to occur when an appender `button` element
  21209. // is clicked. In some browsers (Firefox, Safari), button clicks do
  21210. // not emit a focus event, which could cause this event to propagate
  21211. // unexpectedly. The `tabIndex` ensures that the interaction is
  21212. // captured as a focus, without also adding an extra tab stop.
  21213. //
  21214. // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  21215. , {
  21216. tabIndex: -1,
  21217. className: classnames_default()('block-list-appender wp-block', className) // Needed in case the whole editor is content editable (for multi
  21218. // selection). It fixes an edge case where ArrowDown and ArrowRight
  21219. // should collapse the selection to the end of that selection and
  21220. // not into the appender.
  21221. ,
  21222. contentEditable: false // The appender exists to let you add the first Paragraph before
  21223. // any is inserted. To that end, this appender should visually be
  21224. // presented as a block. That means theme CSS should style it as if
  21225. // it were an empty paragraph block. That means a `wp-block` class to
  21226. // ensure the width is correct, and a [data-block] attribute to ensure
  21227. // the correct margin is applied, especially for classic themes which
  21228. // have commonly targeted that attribute for margins.
  21229. ,
  21230. "data-block": true
  21231. }, appender);
  21232. }
  21233. /* harmony default export */ var block_list_appender = ((0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => {
  21234. let {
  21235. rootClientId
  21236. } = _ref2;
  21237. const {
  21238. canInsertBlockType,
  21239. getTemplateLock,
  21240. getSelectedBlockClientId
  21241. } = select(store);
  21242. return {
  21243. isLocked: !!getTemplateLock(rootClientId),
  21244. canInsertDefaultBlock: canInsertBlockType((0,external_wp_blocks_namespaceObject.getDefaultBlockName)(), rootClientId),
  21245. selectedBlockClientId: getSelectedBlockClientId()
  21246. };
  21247. })(BlockListAppender));
  21248. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/use-popover-scroll.js
  21249. /**
  21250. * WordPress dependencies
  21251. */
  21252. /**
  21253. * Allow scrolling "through" popovers over the canvas. This is only called for
  21254. * as long as the pointer is over a popover. Do not use React events because it
  21255. * will bubble through portals.
  21256. *
  21257. * @param {Object} scrollableRef
  21258. */
  21259. function usePopoverScroll(scrollableRef) {
  21260. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  21261. if (!scrollableRef) {
  21262. return;
  21263. }
  21264. function onWheel(event) {
  21265. const {
  21266. deltaX,
  21267. deltaY
  21268. } = event;
  21269. scrollableRef.current.scrollBy(deltaX, deltaY);
  21270. } // Tell the browser that we do not call event.preventDefault
  21271. // See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners
  21272. const options = {
  21273. passive: true
  21274. };
  21275. node.addEventListener('wheel', onWheel, options);
  21276. return () => {
  21277. node.removeEventListener('wheel', onWheel, options);
  21278. };
  21279. }, [scrollableRef]);
  21280. }
  21281. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/insertion-point.js
  21282. /**
  21283. * External dependencies
  21284. */
  21285. /**
  21286. * WordPress dependencies
  21287. */
  21288. /**
  21289. * Internal dependencies
  21290. */
  21291. const InsertionPointOpenRef = (0,external_wp_element_namespaceObject.createContext)();
  21292. function InsertionPointPopover(_ref) {
  21293. let {
  21294. __unstablePopoverSlot,
  21295. __unstableContentRef
  21296. } = _ref;
  21297. const {
  21298. selectBlock,
  21299. hideInsertionPoint
  21300. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  21301. const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef);
  21302. const ref = (0,external_wp_element_namespaceObject.useRef)();
  21303. const {
  21304. orientation,
  21305. previousClientId,
  21306. nextClientId,
  21307. rootClientId,
  21308. isInserterShown
  21309. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  21310. var _getBlockListSettings;
  21311. const {
  21312. getBlockOrder,
  21313. getBlockListSettings,
  21314. getBlockInsertionPoint,
  21315. isBlockBeingDragged,
  21316. getPreviousBlockClientId,
  21317. getNextBlockClientId
  21318. } = select(store);
  21319. const insertionPoint = getBlockInsertionPoint();
  21320. const order = getBlockOrder(insertionPoint.rootClientId);
  21321. if (!order.length) {
  21322. return {};
  21323. }
  21324. let _previousClientId = order[insertionPoint.index - 1];
  21325. let _nextClientId = order[insertionPoint.index];
  21326. while (isBlockBeingDragged(_previousClientId)) {
  21327. _previousClientId = getPreviousBlockClientId(_previousClientId);
  21328. }
  21329. while (isBlockBeingDragged(_nextClientId)) {
  21330. _nextClientId = getNextBlockClientId(_nextClientId);
  21331. }
  21332. return {
  21333. previousClientId: _previousClientId,
  21334. nextClientId: _nextClientId,
  21335. orientation: ((_getBlockListSettings = getBlockListSettings(insertionPoint.rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical',
  21336. rootClientId: insertionPoint.rootClientId,
  21337. isInserterShown: insertionPoint === null || insertionPoint === void 0 ? void 0 : insertionPoint.__unstableWithInserter
  21338. };
  21339. }, []);
  21340. const previousElement = useBlockElement(previousClientId);
  21341. const nextElement = useBlockElement(nextClientId);
  21342. const isVertical = orientation === 'vertical';
  21343. const style = (0,external_wp_element_namespaceObject.useMemo)(() => {
  21344. if (!previousElement && !nextElement) {
  21345. return {};
  21346. }
  21347. const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
  21348. const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
  21349. if (isVertical) {
  21350. return {
  21351. width: previousElement ? previousElement.offsetWidth : nextElement.offsetWidth,
  21352. height: nextRect && previousRect ? nextRect.top - previousRect.bottom : 0
  21353. };
  21354. }
  21355. let width = 0;
  21356. if (previousRect && nextRect) {
  21357. width = (0,external_wp_i18n_namespaceObject.isRTL)() ? previousRect.left - nextRect.right : nextRect.left - previousRect.right;
  21358. }
  21359. return {
  21360. width,
  21361. height: previousElement ? previousElement.offsetHeight : nextElement.offsetHeight
  21362. };
  21363. }, [previousElement, nextElement]);
  21364. const getAnchorRect = (0,external_wp_element_namespaceObject.useCallback)(() => {
  21365. if (!previousElement && !nextElement) {
  21366. return {};
  21367. }
  21368. const {
  21369. ownerDocument
  21370. } = previousElement || nextElement;
  21371. const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
  21372. const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
  21373. if (isVertical) {
  21374. if ((0,external_wp_i18n_namespaceObject.isRTL)()) {
  21375. return {
  21376. top: previousRect ? previousRect.bottom : nextRect.top,
  21377. left: previousRect ? previousRect.right : nextRect.right,
  21378. right: previousRect ? previousRect.left : nextRect.left,
  21379. bottom: nextRect ? nextRect.top : previousRect.bottom,
  21380. ownerDocument
  21381. };
  21382. }
  21383. return {
  21384. top: previousRect ? previousRect.bottom : nextRect.top,
  21385. left: previousRect ? previousRect.left : nextRect.left,
  21386. right: previousRect ? previousRect.right : nextRect.right,
  21387. bottom: nextRect ? nextRect.top : previousRect.bottom,
  21388. ownerDocument
  21389. };
  21390. }
  21391. if ((0,external_wp_i18n_namespaceObject.isRTL)()) {
  21392. return {
  21393. top: previousRect ? previousRect.top : nextRect.top,
  21394. left: previousRect ? previousRect.left : nextRect.right,
  21395. right: nextRect ? nextRect.right : previousRect.left,
  21396. bottom: previousRect ? previousRect.bottom : nextRect.bottom,
  21397. ownerDocument
  21398. };
  21399. }
  21400. return {
  21401. top: previousRect ? previousRect.top : nextRect.top,
  21402. left: previousRect ? previousRect.right : nextRect.left,
  21403. right: nextRect ? nextRect.left : previousRect.right,
  21404. bottom: previousRect ? previousRect.bottom : nextRect.bottom,
  21405. ownerDocument
  21406. };
  21407. }, [previousElement, nextElement]);
  21408. const popoverScrollRef = usePopoverScroll(__unstableContentRef);
  21409. const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
  21410. const className = classnames_default()('block-editor-block-list__insertion-point', 'is-' + orientation);
  21411. function onClick(event) {
  21412. if (event.target === ref.current && nextClientId) {
  21413. selectBlock(nextClientId, -1);
  21414. }
  21415. }
  21416. function onFocus(event) {
  21417. // Only handle click on the wrapper specifically, and not an event
  21418. // bubbled from the inserter itself.
  21419. if (event.target !== ref.current) {
  21420. openRef.current = true;
  21421. }
  21422. }
  21423. function maybeHideInserterPoint(event) {
  21424. // Only hide the inserter if it's triggered on the wrapper,
  21425. // and the inserter is not open.
  21426. if (event.target === ref.current && !openRef.current) {
  21427. hideInsertionPoint();
  21428. }
  21429. } // Only show the in-between inserter between blocks, so when there's a
  21430. // previous and a next element.
  21431. const showInsertionPointInserter = previousElement && nextElement && isInserterShown; // Define animation variants for the line element.
  21432. const horizontalLine = {
  21433. start: {
  21434. width: 0,
  21435. top: '50%',
  21436. bottom: '50%',
  21437. x: 0
  21438. },
  21439. rest: {
  21440. width: 4,
  21441. top: 0,
  21442. bottom: 0,
  21443. x: -2
  21444. },
  21445. hover: {
  21446. width: 4,
  21447. top: 0,
  21448. bottom: 0,
  21449. x: -2
  21450. }
  21451. };
  21452. const verticalLine = {
  21453. start: {
  21454. height: 0,
  21455. left: '50%',
  21456. right: '50%',
  21457. y: 0
  21458. },
  21459. rest: {
  21460. height: 4,
  21461. left: 0,
  21462. right: 0,
  21463. y: -2
  21464. },
  21465. hover: {
  21466. height: 4,
  21467. left: 0,
  21468. right: 0,
  21469. y: -2
  21470. }
  21471. };
  21472. const lineVariants = {
  21473. // Initial position starts from the center and invisible.
  21474. start: { ...(!isVertical ? horizontalLine.start : verticalLine.start),
  21475. opacity: 0
  21476. },
  21477. // The line expands to fill the container. If the inserter is visible it
  21478. // is delayed so it appears orchestrated.
  21479. rest: { ...(!isVertical ? horizontalLine.rest : verticalLine.rest),
  21480. opacity: 1,
  21481. borderRadius: '2px',
  21482. transition: {
  21483. delay: showInsertionPointInserter ? 0.4 : 0
  21484. }
  21485. },
  21486. hover: { ...(!isVertical ? horizontalLine.hover : verticalLine.hover),
  21487. opacity: 1,
  21488. borderRadius: '2px',
  21489. transition: {
  21490. delay: 0.4
  21491. }
  21492. }
  21493. };
  21494. const inserterVariants = {
  21495. start: {
  21496. scale: disableMotion ? 1 : 0
  21497. },
  21498. rest: {
  21499. scale: 1,
  21500. transition: {
  21501. delay: 0.2
  21502. }
  21503. }
  21504. };
  21505. /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
  21506. // While ideally it would be enough to capture the
  21507. // bubbling focus event from the Inserter, due to the
  21508. // characteristics of click focusing of `button`s in
  21509. // Firefox and Safari, it is not reliable.
  21510. //
  21511. // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  21512. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  21513. ref: popoverScrollRef,
  21514. noArrow: true,
  21515. animate: false,
  21516. getAnchorRect: getAnchorRect,
  21517. focusOnMount: false,
  21518. className: "block-editor-block-list__insertion-point-popover" // Render in the old slot if needed for backward compatibility,
  21519. // otherwise render in place (not in the the default popover slot).
  21520. ,
  21521. __unstableSlotName: __unstablePopoverSlot || null // Forces a remount of the popover when its position changes
  21522. // This makes sure the popover doesn't animate from its previous position.
  21523. ,
  21524. key: nextClientId + '--' + rootClientId
  21525. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
  21526. layout: !disableMotion,
  21527. initial: disableMotion ? 'rest' : 'start',
  21528. animate: "rest",
  21529. whileHover: "hover",
  21530. whileTap: "pressed",
  21531. exit: "start",
  21532. ref: ref,
  21533. tabIndex: -1,
  21534. onClick: onClick,
  21535. onFocus: onFocus,
  21536. className: classnames_default()(className, {
  21537. 'is-with-inserter': showInsertionPointInserter
  21538. }),
  21539. onHoverEnd: maybeHideInserterPoint,
  21540. style: style
  21541. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
  21542. variants: lineVariants,
  21543. className: "block-editor-block-list__insertion-point-indicator"
  21544. }), showInsertionPointInserter && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
  21545. variants: inserterVariants,
  21546. className: classnames_default()('block-editor-block-list__insertion-point-inserter')
  21547. }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
  21548. position: "bottom center",
  21549. clientId: nextClientId,
  21550. rootClientId: rootClientId,
  21551. __experimentalIsQuick: true,
  21552. onToggle: isOpen => {
  21553. openRef.current = isOpen;
  21554. },
  21555. onSelectOrClose: () => {
  21556. openRef.current = false;
  21557. }
  21558. }))));
  21559. /* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
  21560. }
  21561. function InsertionPoint(_ref2) {
  21562. let {
  21563. children,
  21564. __unstablePopoverSlot,
  21565. __unstableContentRef
  21566. } = _ref2;
  21567. const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
  21568. return select(store).isBlockInsertionPointVisible();
  21569. }, []);
  21570. return (0,external_wp_element_namespaceObject.createElement)(InsertionPointOpenRef.Provider, {
  21571. value: (0,external_wp_element_namespaceObject.useRef)(false)
  21572. }, isVisible && (0,external_wp_element_namespaceObject.createElement)(InsertionPointPopover, {
  21573. __unstablePopoverSlot: __unstablePopoverSlot,
  21574. __unstableContentRef: __unstableContentRef
  21575. }), children);
  21576. }
  21577. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-in-between-inserter.js
  21578. /**
  21579. * WordPress dependencies
  21580. */
  21581. /**
  21582. * Internal dependencies
  21583. */
  21584. function useInBetweenInserter() {
  21585. const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef);
  21586. const hasReducedUI = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().hasReducedUI, []);
  21587. const {
  21588. getBlockListSettings,
  21589. getBlockRootClientId,
  21590. getBlockIndex,
  21591. isBlockInsertionPointVisible,
  21592. isMultiSelecting,
  21593. getSelectedBlockClientIds,
  21594. getTemplateLock
  21595. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  21596. const {
  21597. showInsertionPoint,
  21598. hideInsertionPoint
  21599. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  21600. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  21601. if (hasReducedUI) {
  21602. return;
  21603. }
  21604. function onMouseMove(event) {
  21605. var _getBlockListSettings, _element$parentElemen;
  21606. if (openRef.current) {
  21607. return;
  21608. }
  21609. if (isMultiSelecting()) {
  21610. return;
  21611. }
  21612. if (!event.target.classList.contains('block-editor-block-list__layout')) {
  21613. if (isBlockInsertionPointVisible()) {
  21614. hideInsertionPoint();
  21615. }
  21616. return;
  21617. }
  21618. let rootClientId;
  21619. if (!event.target.classList.contains('is-root-container')) {
  21620. const blockElement = !!event.target.getAttribute('data-block') ? event.target : event.target.closest('[data-block]');
  21621. rootClientId = blockElement.getAttribute('data-block');
  21622. } // Don't set the insertion point if the template is locked.
  21623. if (getTemplateLock(rootClientId)) {
  21624. return;
  21625. }
  21626. const orientation = ((_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical';
  21627. const rect = event.target.getBoundingClientRect();
  21628. const offsetTop = event.clientY - rect.top;
  21629. const offsetLeft = event.clientX - rect.left;
  21630. const children = Array.from(event.target.children);
  21631. let element = children.find(blockEl => {
  21632. return blockEl.classList.contains('wp-block') && orientation === 'vertical' && blockEl.offsetTop > offsetTop || blockEl.classList.contains('wp-block') && orientation === 'horizontal' && blockEl.offsetLeft > offsetLeft;
  21633. });
  21634. if (!element) {
  21635. return;
  21636. } // The block may be in an alignment wrapper, so check the first direct
  21637. // child if the element has no ID.
  21638. if (!element.id) {
  21639. element = element.firstElementChild;
  21640. if (!element) {
  21641. return;
  21642. }
  21643. } // Don't show the insertion point if a parent block has an "overlay"
  21644. // See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337
  21645. const parentOverlay = (_element$parentElemen = element.parentElement) === null || _element$parentElemen === void 0 ? void 0 : _element$parentElemen.closest('.block-editor-block-content-overlay.overlay-active');
  21646. if (parentOverlay) {
  21647. return;
  21648. }
  21649. const clientId = element.id.slice('block-'.length);
  21650. if (!clientId) {
  21651. return;
  21652. } // Don't show the inserter when hovering above (conflicts with
  21653. // block toolbar) or inside selected block(s).
  21654. if (getSelectedBlockClientIds().includes(clientId)) {
  21655. return;
  21656. }
  21657. const elementRect = element.getBoundingClientRect();
  21658. if (orientation === 'horizontal' && (event.clientY > elementRect.bottom || event.clientY < elementRect.top) || orientation === 'vertical' && (event.clientX > elementRect.right || event.clientX < elementRect.left)) {
  21659. if (isBlockInsertionPointVisible()) {
  21660. hideInsertionPoint();
  21661. }
  21662. return;
  21663. }
  21664. const index = getBlockIndex(clientId); // Don't show the in-between inserter before the first block in
  21665. // the list (preserves the original behaviour).
  21666. if (index === 0) {
  21667. if (isBlockInsertionPointVisible()) {
  21668. hideInsertionPoint();
  21669. }
  21670. return;
  21671. }
  21672. showInsertionPoint(rootClientId, index, {
  21673. __unstableWithInserter: true
  21674. });
  21675. }
  21676. node.addEventListener('mousemove', onMouseMove);
  21677. return () => {
  21678. node.removeEventListener('mousemove', onMouseMove);
  21679. };
  21680. }, [openRef, getBlockListSettings, getBlockRootClientId, getBlockIndex, isBlockInsertionPointVisible, isMultiSelecting, showInsertionPoint, hideInsertionPoint, getSelectedBlockClientIds]);
  21681. }
  21682. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/pre-parse-patterns.js
  21683. /**
  21684. * WordPress dependencies
  21685. */
  21686. /**
  21687. * Internal dependencies
  21688. */
  21689. const requestIdleCallback = (() => {
  21690. if (typeof window === 'undefined') {
  21691. return callback => {
  21692. setTimeout(() => callback(Date.now()), 0);
  21693. };
  21694. }
  21695. return window.requestIdleCallback || window.requestAnimationFrame;
  21696. })();
  21697. const cancelIdleCallback = (() => {
  21698. if (typeof window === 'undefined') {
  21699. return clearTimeout;
  21700. }
  21701. return window.cancelIdleCallback || window.cancelAnimationFrame;
  21702. })();
  21703. function usePreParsePatterns() {
  21704. const patterns = (0,external_wp_data_namespaceObject.useSelect)(_select => _select(store).getSettings().__experimentalBlockPatterns, []);
  21705. (0,external_wp_element_namespaceObject.useEffect)(() => {
  21706. if (!(patterns !== null && patterns !== void 0 && patterns.length)) {
  21707. return;
  21708. }
  21709. let handle;
  21710. let index = -1;
  21711. const callback = () => {
  21712. index++;
  21713. if (index >= patterns.length) {
  21714. return;
  21715. }
  21716. (0,external_wp_data_namespaceObject.select)(store).__experimentalGetParsedPattern(patterns[index].name);
  21717. handle = requestIdleCallback(callback);
  21718. };
  21719. handle = requestIdleCallback(callback);
  21720. return () => cancelIdleCallback(handle);
  21721. }, [patterns]);
  21722. return null;
  21723. }
  21724. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-display-information/index.js
  21725. /**
  21726. * WordPress dependencies
  21727. */
  21728. /**
  21729. * Internal dependencies
  21730. */
  21731. /** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */
  21732. /**
  21733. * Contains basic block's information for display reasons.
  21734. *
  21735. * @typedef {Object} WPBlockDisplayInformation
  21736. *
  21737. * @property {string} title Human-readable block type label.
  21738. * @property {WPIcon} icon Block type icon.
  21739. * @property {string} description A detailed block type description.
  21740. */
  21741. /**
  21742. * Hook used to try to find a matching block variation and return
  21743. * the appropriate information for display reasons. In order to
  21744. * to try to find a match we need to things:
  21745. * 1. Block's client id to extract it's current attributes.
  21746. * 2. A block variation should have set `isActive` prop to a proper function.
  21747. *
  21748. * If for any reason a block variaton match cannot be found,
  21749. * the returned information come from the Block Type.
  21750. * If no blockType is found with the provided clientId, returns null.
  21751. *
  21752. * @param {string} clientId Block's client id.
  21753. * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.
  21754. */
  21755. function useBlockDisplayInformation(clientId) {
  21756. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  21757. if (!clientId) return null;
  21758. const {
  21759. getBlockName,
  21760. getBlockAttributes
  21761. } = select(store);
  21762. const {
  21763. getBlockType,
  21764. getActiveBlockVariation
  21765. } = select(external_wp_blocks_namespaceObject.store);
  21766. const blockName = getBlockName(clientId);
  21767. const blockType = getBlockType(blockName);
  21768. if (!blockType) return null;
  21769. const attributes = getBlockAttributes(clientId);
  21770. const match = getActiveBlockVariation(blockName, attributes);
  21771. const blockTypeInfo = {
  21772. title: blockType.title,
  21773. icon: blockType.icon,
  21774. description: blockType.description,
  21775. anchor: attributes === null || attributes === void 0 ? void 0 : attributes.anchor
  21776. };
  21777. if (!match) return blockTypeInfo;
  21778. return {
  21779. title: match.title || blockType.title,
  21780. icon: match.icon || blockType.icon,
  21781. description: match.description || blockType.description
  21782. };
  21783. }, [clientId]);
  21784. }
  21785. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-title/use-block-display-title.js
  21786. /**
  21787. * External dependencies
  21788. */
  21789. /**
  21790. * WordPress dependencies
  21791. */
  21792. /**
  21793. * Internal dependencies
  21794. */
  21795. /**
  21796. * Returns the block's configured title as a string, or empty if the title
  21797. * cannot be determined.
  21798. *
  21799. * @example
  21800. *
  21801. * ```js
  21802. * useBlockDisplayTitle( 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1', 17 );
  21803. * ```
  21804. *
  21805. * @param {string} clientId Client ID of block.
  21806. * @param {number|undefined} maximumLength The maximum length that the block title string may be before truncated.
  21807. * @return {?string} Block title.
  21808. */
  21809. function useBlockDisplayTitle(clientId, maximumLength) {
  21810. const {
  21811. attributes,
  21812. name,
  21813. reusableBlockTitle
  21814. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  21815. if (!clientId) {
  21816. return {};
  21817. }
  21818. const {
  21819. getBlockName,
  21820. getBlockAttributes,
  21821. __experimentalGetReusableBlockTitle
  21822. } = select(store);
  21823. const blockName = getBlockName(clientId);
  21824. if (!blockName) {
  21825. return {};
  21826. }
  21827. const isReusable = (0,external_wp_blocks_namespaceObject.isReusableBlock)((0,external_wp_blocks_namespaceObject.getBlockType)(blockName));
  21828. return {
  21829. attributes: getBlockAttributes(clientId),
  21830. name: blockName,
  21831. reusableBlockTitle: isReusable && __experimentalGetReusableBlockTitle(getBlockAttributes(clientId).ref)
  21832. };
  21833. }, [clientId]);
  21834. const blockInformation = useBlockDisplayInformation(clientId);
  21835. if (!name || !blockInformation) {
  21836. return null;
  21837. }
  21838. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
  21839. const blockLabel = blockType ? (0,external_wp_blocks_namespaceObject.__experimentalGetBlockLabel)(blockType, attributes) : null;
  21840. const label = reusableBlockTitle || blockLabel; // Label will fallback to the title if no label is defined for the current
  21841. // label context. If the label is defined we prioritize it over a
  21842. // possible block variation title match.
  21843. const blockTitle = label && label !== blockType.title ? label : blockInformation.title;
  21844. if (maximumLength && maximumLength > 0) {
  21845. return (0,external_lodash_namespaceObject.truncate)(blockTitle, {
  21846. length: maximumLength
  21847. });
  21848. }
  21849. return blockTitle;
  21850. }
  21851. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-title/index.js
  21852. /**
  21853. * Internal dependencies
  21854. */
  21855. /**
  21856. * Renders the block's configured title as a string, or empty if the title
  21857. * cannot be determined.
  21858. *
  21859. * @example
  21860. *
  21861. * ```jsx
  21862. * <BlockTitle clientId="afd1cb17-2c08-4e7a-91be-007ba7ddc3a1" maximumLength={ 17 }/>
  21863. * ```
  21864. *
  21865. * @param {Object} props
  21866. * @param {string} props.clientId Client ID of block.
  21867. * @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated.
  21868. *
  21869. * @return {JSX.Element} Block title.
  21870. */
  21871. function BlockTitle(_ref) {
  21872. let {
  21873. clientId,
  21874. maximumLength
  21875. } = _ref;
  21876. return useBlockDisplayTitle(clientId, maximumLength);
  21877. }
  21878. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/use-scroll-when-dragging.js
  21879. /**
  21880. * WordPress dependencies
  21881. */
  21882. const SCROLL_INACTIVE_DISTANCE_PX = 50;
  21883. const SCROLL_INTERVAL_MS = 25;
  21884. const PIXELS_PER_SECOND_PER_PERCENTAGE = 1000;
  21885. const VELOCITY_MULTIPLIER = PIXELS_PER_SECOND_PER_PERCENTAGE * (SCROLL_INTERVAL_MS / 1000);
  21886. /**
  21887. * React hook that scrolls the scroll container when a block is being dragged.
  21888. *
  21889. * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`
  21890. * functions to be called in `onDragStart`, `onDragOver`
  21891. * and `onDragEnd` events respectively.
  21892. */
  21893. function useScrollWhenDragging() {
  21894. const dragStartY = (0,external_wp_element_namespaceObject.useRef)(null);
  21895. const velocityY = (0,external_wp_element_namespaceObject.useRef)(null);
  21896. const scrollParentY = (0,external_wp_element_namespaceObject.useRef)(null);
  21897. const scrollEditorInterval = (0,external_wp_element_namespaceObject.useRef)(null); // Clear interval when unmounting.
  21898. (0,external_wp_element_namespaceObject.useEffect)(() => () => {
  21899. if (scrollEditorInterval.current) {
  21900. clearInterval(scrollEditorInterval.current);
  21901. scrollEditorInterval.current = null;
  21902. }
  21903. }, []);
  21904. const startScrolling = (0,external_wp_element_namespaceObject.useCallback)(event => {
  21905. dragStartY.current = event.clientY; // Find nearest parent(s) to scroll.
  21906. scrollParentY.current = (0,external_wp_dom_namespaceObject.getScrollContainer)(event.target);
  21907. scrollEditorInterval.current = setInterval(() => {
  21908. if (scrollParentY.current && velocityY.current) {
  21909. const newTop = scrollParentY.current.scrollTop + velocityY.current; // Setting `behavior: 'smooth'` as a scroll property seems to hurt performance.
  21910. // Better to use a small scroll interval.
  21911. scrollParentY.current.scroll({
  21912. top: newTop
  21913. });
  21914. }
  21915. }, SCROLL_INTERVAL_MS);
  21916. }, []);
  21917. const scrollOnDragOver = (0,external_wp_element_namespaceObject.useCallback)(event => {
  21918. if (!scrollParentY.current) {
  21919. return;
  21920. }
  21921. const scrollParentHeight = scrollParentY.current.offsetHeight;
  21922. const offsetDragStartPosition = dragStartY.current - scrollParentY.current.offsetTop;
  21923. const offsetDragPosition = event.clientY - scrollParentY.current.offsetTop;
  21924. if (event.clientY > offsetDragStartPosition) {
  21925. // User is dragging downwards.
  21926. const moveableDistance = Math.max(scrollParentHeight - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  21927. const dragDistance = Math.max(offsetDragPosition - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  21928. const distancePercentage = dragDistance / moveableDistance;
  21929. velocityY.current = VELOCITY_MULTIPLIER * distancePercentage;
  21930. } else if (event.clientY < offsetDragStartPosition) {
  21931. // User is dragging upwards.
  21932. const moveableDistance = Math.max(offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  21933. const dragDistance = Math.max(offsetDragStartPosition - offsetDragPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  21934. const distancePercentage = dragDistance / moveableDistance;
  21935. velocityY.current = -VELOCITY_MULTIPLIER * distancePercentage;
  21936. } else {
  21937. velocityY.current = 0;
  21938. }
  21939. }, []);
  21940. const stopScrolling = () => {
  21941. dragStartY.current = null;
  21942. scrollParentY.current = null;
  21943. if (scrollEditorInterval.current) {
  21944. clearInterval(scrollEditorInterval.current);
  21945. scrollEditorInterval.current = null;
  21946. }
  21947. };
  21948. return [startScrolling, scrollOnDragOver, stopScrolling];
  21949. }
  21950. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/index.js
  21951. /**
  21952. * WordPress dependencies
  21953. */
  21954. /**
  21955. * Internal dependencies
  21956. */
  21957. const BlockDraggable = _ref => {
  21958. let {
  21959. children,
  21960. clientIds,
  21961. cloneClassname,
  21962. onDragStart,
  21963. onDragEnd
  21964. } = _ref;
  21965. const {
  21966. srcRootClientId,
  21967. isDraggable,
  21968. icon
  21969. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  21970. var _getBlockType;
  21971. const {
  21972. canMoveBlocks,
  21973. getBlockRootClientId,
  21974. getBlockName
  21975. } = select(store);
  21976. const rootClientId = getBlockRootClientId(clientIds[0]);
  21977. const blockName = getBlockName(clientIds[0]);
  21978. return {
  21979. srcRootClientId: rootClientId,
  21980. isDraggable: canMoveBlocks(clientIds, rootClientId),
  21981. icon: (_getBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon
  21982. };
  21983. }, [clientIds]);
  21984. const isDragging = (0,external_wp_element_namespaceObject.useRef)(false);
  21985. const [startScrolling, scrollOnDragOver, stopScrolling] = useScrollWhenDragging();
  21986. const {
  21987. startDraggingBlocks,
  21988. stopDraggingBlocks
  21989. } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Stop dragging blocks if the block draggable is unmounted.
  21990. (0,external_wp_element_namespaceObject.useEffect)(() => {
  21991. return () => {
  21992. if (isDragging.current) {
  21993. stopDraggingBlocks();
  21994. }
  21995. };
  21996. }, []);
  21997. if (!isDraggable) {
  21998. return children({
  21999. isDraggable: false
  22000. });
  22001. }
  22002. const transferData = {
  22003. type: 'block',
  22004. srcClientIds: clientIds,
  22005. srcRootClientId
  22006. };
  22007. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Draggable, {
  22008. cloneClassname: cloneClassname,
  22009. __experimentalTransferDataType: "wp-blocks",
  22010. transferData: transferData,
  22011. onDragStart: event => {
  22012. startDraggingBlocks(clientIds);
  22013. isDragging.current = true;
  22014. startScrolling(event);
  22015. if (onDragStart) {
  22016. onDragStart();
  22017. }
  22018. },
  22019. onDragOver: scrollOnDragOver,
  22020. onDragEnd: () => {
  22021. stopDraggingBlocks();
  22022. isDragging.current = false;
  22023. stopScrolling();
  22024. if (onDragEnd) {
  22025. onDragEnd();
  22026. }
  22027. },
  22028. __experimentalDragComponent: (0,external_wp_element_namespaceObject.createElement)(BlockDraggableChip, {
  22029. count: clientIds.length,
  22030. icon: icon
  22031. })
  22032. }, _ref2 => {
  22033. let {
  22034. onDraggableStart,
  22035. onDraggableEnd
  22036. } = _ref2;
  22037. return children({
  22038. draggable: true,
  22039. onDragStart: onDraggableStart,
  22040. onDragEnd: onDraggableEnd
  22041. });
  22042. });
  22043. };
  22044. /* harmony default export */ var block_draggable = (BlockDraggable);
  22045. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-selection-button.js
  22046. /**
  22047. * External dependencies
  22048. */
  22049. /**
  22050. * WordPress dependencies
  22051. */
  22052. /**
  22053. * Internal dependencies
  22054. */
  22055. /**
  22056. * Block selection button component, displaying the label of the block. If the block
  22057. * descends from a root block, a button is displayed enabling the user to select
  22058. * the root block.
  22059. *
  22060. * @param {string} props Component props.
  22061. * @param {string} props.clientId Client ID of block.
  22062. *
  22063. * @return {WPComponent} The component to be rendered.
  22064. */
  22065. function BlockSelectionButton(_ref) {
  22066. let {
  22067. clientId,
  22068. rootClientId,
  22069. blockElement
  22070. } = _ref;
  22071. const blockInformation = useBlockDisplayInformation(clientId);
  22072. const selected = (0,external_wp_data_namespaceObject.useSelect)(select => {
  22073. var _getBlockListSettings;
  22074. const {
  22075. getBlock,
  22076. getBlockIndex,
  22077. hasBlockMovingClientId,
  22078. getBlockListSettings
  22079. } = select(store);
  22080. const index = getBlockIndex(clientId);
  22081. const {
  22082. name,
  22083. attributes
  22084. } = getBlock(clientId);
  22085. const blockMovingMode = hasBlockMovingClientId();
  22086. return {
  22087. index,
  22088. name,
  22089. attributes,
  22090. blockMovingMode,
  22091. orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
  22092. };
  22093. }, [clientId, rootClientId]);
  22094. const {
  22095. index,
  22096. name,
  22097. attributes,
  22098. blockMovingMode,
  22099. orientation
  22100. } = selected;
  22101. const {
  22102. setNavigationMode,
  22103. removeBlock
  22104. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  22105. const ref = (0,external_wp_element_namespaceObject.useRef)();
  22106. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
  22107. const label = (0,external_wp_blocks_namespaceObject.__experimentalGetAccessibleBlockLabel)(blockType, attributes, index + 1, orientation); // Focus the breadcrumb in navigation mode.
  22108. (0,external_wp_element_namespaceObject.useEffect)(() => {
  22109. ref.current.focus();
  22110. (0,external_wp_a11y_namespaceObject.speak)(label);
  22111. }, [label]);
  22112. const {
  22113. hasBlockMovingClientId,
  22114. getBlockIndex,
  22115. getBlockRootClientId,
  22116. getClientIdsOfDescendants,
  22117. getSelectedBlockClientId,
  22118. getMultiSelectedBlocksEndClientId,
  22119. getPreviousBlockClientId,
  22120. getNextBlockClientId,
  22121. isNavigationMode
  22122. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  22123. const {
  22124. selectBlock,
  22125. clearSelectedBlock,
  22126. setBlockMovingClientId,
  22127. moveBlockToPosition
  22128. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  22129. function onKeyDown(event) {
  22130. const {
  22131. keyCode
  22132. } = event;
  22133. const isUp = keyCode === external_wp_keycodes_namespaceObject.UP;
  22134. const isDown = keyCode === external_wp_keycodes_namespaceObject.DOWN;
  22135. const isLeft = keyCode === external_wp_keycodes_namespaceObject.LEFT;
  22136. const isRight = keyCode === external_wp_keycodes_namespaceObject.RIGHT;
  22137. const isTab = keyCode === external_wp_keycodes_namespaceObject.TAB;
  22138. const isEscape = keyCode === external_wp_keycodes_namespaceObject.ESCAPE;
  22139. const isEnter = keyCode === external_wp_keycodes_namespaceObject.ENTER;
  22140. const isSpace = keyCode === external_wp_keycodes_namespaceObject.SPACE;
  22141. const isShift = event.shiftKey;
  22142. if (keyCode === external_wp_keycodes_namespaceObject.BACKSPACE || keyCode === external_wp_keycodes_namespaceObject.DELETE) {
  22143. removeBlock(clientId);
  22144. event.preventDefault();
  22145. return;
  22146. }
  22147. const selectedBlockClientId = getSelectedBlockClientId();
  22148. const selectionEndClientId = getMultiSelectedBlocksEndClientId();
  22149. const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
  22150. const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
  22151. const navigateUp = isTab && isShift || isUp;
  22152. const navigateDown = isTab && !isShift || isDown; // Move out of current nesting level (no effect if at root level).
  22153. const navigateOut = isLeft; // Move into next nesting level (no effect if the current block has no innerBlocks).
  22154. const navigateIn = isRight;
  22155. let focusedBlockUid;
  22156. if (navigateUp) {
  22157. focusedBlockUid = selectionBeforeEndClientId;
  22158. } else if (navigateDown) {
  22159. focusedBlockUid = selectionAfterEndClientId;
  22160. } else if (navigateOut) {
  22161. var _getBlockRootClientId;
  22162. focusedBlockUid = (_getBlockRootClientId = getBlockRootClientId(selectedBlockClientId)) !== null && _getBlockRootClientId !== void 0 ? _getBlockRootClientId : selectedBlockClientId;
  22163. } else if (navigateIn) {
  22164. var _getClientIdsOfDescen;
  22165. focusedBlockUid = (_getClientIdsOfDescen = getClientIdsOfDescendants([selectedBlockClientId])[0]) !== null && _getClientIdsOfDescen !== void 0 ? _getClientIdsOfDescen : selectedBlockClientId;
  22166. }
  22167. const startingBlockClientId = hasBlockMovingClientId();
  22168. if (isEscape && isNavigationMode()) {
  22169. clearSelectedBlock();
  22170. event.preventDefault();
  22171. }
  22172. if (isEscape && startingBlockClientId && !event.defaultPrevented) {
  22173. setBlockMovingClientId(null);
  22174. event.preventDefault();
  22175. }
  22176. if ((isEnter || isSpace) && startingBlockClientId) {
  22177. const sourceRoot = getBlockRootClientId(startingBlockClientId);
  22178. const destRoot = getBlockRootClientId(selectedBlockClientId);
  22179. const sourceBlockIndex = getBlockIndex(startingBlockClientId);
  22180. let destinationBlockIndex = getBlockIndex(selectedBlockClientId);
  22181. if (sourceBlockIndex < destinationBlockIndex && sourceRoot === destRoot) {
  22182. destinationBlockIndex -= 1;
  22183. }
  22184. moveBlockToPosition(startingBlockClientId, sourceRoot, destRoot, destinationBlockIndex);
  22185. selectBlock(startingBlockClientId);
  22186. setBlockMovingClientId(null);
  22187. }
  22188. if (navigateDown || navigateUp || navigateOut || navigateIn) {
  22189. if (focusedBlockUid) {
  22190. event.preventDefault();
  22191. selectBlock(focusedBlockUid);
  22192. } else if (isTab && selectedBlockClientId) {
  22193. let nextTabbable;
  22194. if (navigateDown) {
  22195. nextTabbable = blockElement;
  22196. do {
  22197. nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findNext(nextTabbable);
  22198. } while (nextTabbable && blockElement.contains(nextTabbable));
  22199. if (!nextTabbable) {
  22200. nextTabbable = blockElement.ownerDocument.defaultView.frameElement;
  22201. nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findNext(nextTabbable);
  22202. }
  22203. } else {
  22204. nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findPrevious(blockElement);
  22205. }
  22206. if (nextTabbable) {
  22207. event.preventDefault();
  22208. nextTabbable.focus();
  22209. clearSelectedBlock();
  22210. }
  22211. }
  22212. }
  22213. }
  22214. const classNames = classnames_default()('block-editor-block-list__block-selection-button', {
  22215. 'is-block-moving-mode': !!blockMovingMode
  22216. });
  22217. const dragHandleLabel = (0,external_wp_i18n_namespaceObject.__)('Drag');
  22218. return (0,external_wp_element_namespaceObject.createElement)("div", {
  22219. className: classNames
  22220. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
  22221. justify: "center",
  22222. className: "block-editor-block-list__block-selection-button__content"
  22223. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  22224. icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
  22225. showColors: true
  22226. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
  22227. clientIds: [clientId]
  22228. }, draggableProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
  22229. icon: drag_handle,
  22230. className: "block-selection-button_drag-handle",
  22231. "aria-hidden": "true",
  22232. label: dragHandleLabel // Should not be able to tab to drag handle as this
  22233. // button can only be used with a pointer device.
  22234. ,
  22235. tabIndex: "-1"
  22236. }, draggableProps)))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  22237. ref: ref,
  22238. onClick: () => setNavigationMode(false),
  22239. onKeyDown: onKeyDown,
  22240. label: label,
  22241. className: "block-selection-button_select-button"
  22242. }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
  22243. clientId: clientId,
  22244. maximumLength: 35
  22245. })))));
  22246. }
  22247. /* harmony default export */ var block_selection_button = (BlockSelectionButton);
  22248. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/navigable-toolbar/index.js
  22249. /**
  22250. * WordPress dependencies
  22251. */
  22252. function hasOnlyToolbarItem(elements) {
  22253. const dataProp = 'toolbarItem';
  22254. return !elements.some(element => !(dataProp in element.dataset));
  22255. }
  22256. function getAllToolbarItemsIn(container) {
  22257. return Array.from(container.querySelectorAll('[data-toolbar-item]'));
  22258. }
  22259. function hasFocusWithin(container) {
  22260. return container.contains(container.ownerDocument.activeElement);
  22261. }
  22262. function focusFirstTabbableIn(container) {
  22263. const [firstTabbable] = external_wp_dom_namespaceObject.focus.tabbable.find(container);
  22264. if (firstTabbable) {
  22265. firstTabbable.focus();
  22266. }
  22267. }
  22268. function useIsAccessibleToolbar(ref) {
  22269. /*
  22270. * By default, we'll assume the starting accessible state of the Toolbar
  22271. * is true, as it seems to be the most common case.
  22272. *
  22273. * Transitioning from an (initial) false to true state causes the
  22274. * <Toolbar /> component to mount twice, which is causing undesired
  22275. * side-effects. These side-effects appear to only affect certain
  22276. * E2E tests.
  22277. *
  22278. * This was initial discovered in this pull-request:
  22279. * https://github.com/WordPress/gutenberg/pull/23425
  22280. */
  22281. const initialAccessibleToolbarState = true; // By default, it's gonna render NavigableMenu. If all the tabbable elements
  22282. // inside the toolbar are ToolbarItem components (or derived components like
  22283. // ToolbarButton), then we can wrap them with the accessible Toolbar
  22284. // component.
  22285. const [isAccessibleToolbar, setIsAccessibleToolbar] = (0,external_wp_element_namespaceObject.useState)(initialAccessibleToolbarState);
  22286. const determineIsAccessibleToolbar = (0,external_wp_element_namespaceObject.useCallback)(() => {
  22287. const tabbables = external_wp_dom_namespaceObject.focus.tabbable.find(ref.current);
  22288. const onlyToolbarItem = hasOnlyToolbarItem(tabbables);
  22289. if (!onlyToolbarItem) {
  22290. external_wp_deprecated_default()('Using custom components as toolbar controls', {
  22291. since: '5.6',
  22292. alternative: 'ToolbarItem, ToolbarButton or ToolbarDropdownMenu components',
  22293. link: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols'
  22294. });
  22295. }
  22296. setIsAccessibleToolbar(onlyToolbarItem);
  22297. }, []);
  22298. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  22299. // Toolbar buttons may be rendered asynchronously, so we use
  22300. // MutationObserver to check if the toolbar subtree has been modified.
  22301. const observer = new window.MutationObserver(determineIsAccessibleToolbar);
  22302. observer.observe(ref.current, {
  22303. childList: true,
  22304. subtree: true
  22305. });
  22306. return () => observer.disconnect();
  22307. }, [isAccessibleToolbar]);
  22308. return isAccessibleToolbar;
  22309. }
  22310. function useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, defaultIndex, onIndexChange) {
  22311. // Make sure we don't use modified versions of this prop.
  22312. const [initialFocusOnMount] = (0,external_wp_element_namespaceObject.useState)(focusOnMount);
  22313. const [initialIndex] = (0,external_wp_element_namespaceObject.useState)(defaultIndex);
  22314. const focusToolbar = (0,external_wp_element_namespaceObject.useCallback)(() => {
  22315. focusFirstTabbableIn(ref.current);
  22316. }, []); // Focus on toolbar when pressing alt+F10 when the toolbar is visible.
  22317. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/block-editor/focus-toolbar', focusToolbar);
  22318. (0,external_wp_element_namespaceObject.useEffect)(() => {
  22319. if (initialFocusOnMount) {
  22320. focusToolbar();
  22321. }
  22322. }, [isAccessibleToolbar, initialFocusOnMount, focusToolbar]);
  22323. (0,external_wp_element_namespaceObject.useEffect)(() => {
  22324. // If initialIndex is passed, we focus on that toolbar item when the
  22325. // toolbar gets mounted and initial focus is not forced.
  22326. // We have to wait for the next browser paint because block controls aren't
  22327. // rendered right away when the toolbar gets mounted.
  22328. let raf = 0;
  22329. if (initialIndex && !initialFocusOnMount) {
  22330. raf = window.requestAnimationFrame(() => {
  22331. const items = getAllToolbarItemsIn(ref.current);
  22332. const index = initialIndex || 0;
  22333. if (items[index] && hasFocusWithin(ref.current)) {
  22334. items[index].focus();
  22335. }
  22336. });
  22337. }
  22338. return () => {
  22339. window.cancelAnimationFrame(raf);
  22340. if (!onIndexChange || !ref.current) return; // When the toolbar element is unmounted and onIndexChange is passed, we
  22341. // pass the focused toolbar item index so it can be hydrated later.
  22342. const items = getAllToolbarItemsIn(ref.current);
  22343. const index = items.findIndex(item => item.tabIndex === 0);
  22344. onIndexChange(index);
  22345. };
  22346. }, [initialIndex, initialFocusOnMount]);
  22347. }
  22348. function NavigableToolbar(_ref) {
  22349. let {
  22350. children,
  22351. focusOnMount,
  22352. __experimentalInitialIndex: initialIndex,
  22353. __experimentalOnIndexChange: onIndexChange,
  22354. ...props
  22355. } = _ref;
  22356. const ref = (0,external_wp_element_namespaceObject.useRef)();
  22357. const isAccessibleToolbar = useIsAccessibleToolbar(ref);
  22358. useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, initialIndex, onIndexChange);
  22359. if (isAccessibleToolbar) {
  22360. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Toolbar, _extends({
  22361. label: props['aria-label'],
  22362. ref: ref
  22363. }, props), children);
  22364. }
  22365. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, _extends({
  22366. orientation: "horizontal",
  22367. role: "toolbar",
  22368. ref: ref
  22369. }, props), children);
  22370. }
  22371. /* harmony default export */ var navigable_toolbar = (NavigableToolbar);
  22372. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right.js
  22373. /**
  22374. * WordPress dependencies
  22375. */
  22376. const chevronRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  22377. xmlns: "http://www.w3.org/2000/svg",
  22378. viewBox: "0 0 24 24"
  22379. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  22380. d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
  22381. }));
  22382. /* harmony default export */ var chevron_right = (chevronRight);
  22383. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left.js
  22384. /**
  22385. * WordPress dependencies
  22386. */
  22387. const chevronLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  22388. xmlns: "http://www.w3.org/2000/svg",
  22389. viewBox: "0 0 24 24"
  22390. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  22391. d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
  22392. }));
  22393. /* harmony default export */ var chevron_left = (chevronLeft);
  22394. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-up.js
  22395. /**
  22396. * WordPress dependencies
  22397. */
  22398. const chevronUp = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  22399. viewBox: "0 0 24 24",
  22400. xmlns: "http://www.w3.org/2000/svg"
  22401. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  22402. d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"
  22403. }));
  22404. /* harmony default export */ var chevron_up = (chevronUp);
  22405. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-down.js
  22406. /**
  22407. * WordPress dependencies
  22408. */
  22409. const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  22410. viewBox: "0 0 24 24",
  22411. xmlns: "http://www.w3.org/2000/svg"
  22412. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  22413. d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
  22414. }));
  22415. /* harmony default export */ var chevron_down = (chevronDown);
  22416. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/mover-description.js
  22417. /**
  22418. * WordPress dependencies
  22419. */
  22420. /**
  22421. * Return a label for the block movement controls depending on block position.
  22422. *
  22423. * @param {number} selectedCount Number of blocks selected.
  22424. * @param {string} type Block type - in the case of a single block, should
  22425. * define its 'type'. I.e. 'Text', 'Heading', 'Image' etc.
  22426. * @param {number} firstIndex The index (position - 1) of the first block selected.
  22427. * @param {boolean} isFirst This is the first block.
  22428. * @param {boolean} isLast This is the last block.
  22429. * @param {number} dir Direction of movement (> 0 is considered to be going
  22430. * down, < 0 is up).
  22431. * @param {string} orientation The orientation of the block movers, vertical or
  22432. * horizontal.
  22433. *
  22434. * @return {string} Label for the block movement controls.
  22435. */
  22436. function getBlockMoverDescription(selectedCount, type, firstIndex, isFirst, isLast, dir, orientation) {
  22437. const position = firstIndex + 1;
  22438. const getMovementDirection = moveDirection => {
  22439. if (moveDirection === 'up') {
  22440. if (orientation === 'horizontal') {
  22441. return (0,external_wp_i18n_namespaceObject.isRTL)() ? 'right' : 'left';
  22442. }
  22443. return 'up';
  22444. } else if (moveDirection === 'down') {
  22445. if (orientation === 'horizontal') {
  22446. return (0,external_wp_i18n_namespaceObject.isRTL)() ? 'left' : 'right';
  22447. }
  22448. return 'down';
  22449. }
  22450. return null;
  22451. };
  22452. if (selectedCount > 1) {
  22453. return getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir);
  22454. }
  22455. if (isFirst && isLast) {
  22456. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Type of block (i.e. Text, Image etc)
  22457. (0,external_wp_i18n_namespaceObject.__)('Block %s is the only block, and cannot be moved'), type);
  22458. }
  22459. if (dir > 0 && !isLast) {
  22460. // Moving down.
  22461. const movementDirection = getMovementDirection('down');
  22462. if (movementDirection === 'down') {
  22463. 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
  22464. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d down to position %3$d'), type, position, position + 1);
  22465. }
  22466. if (movementDirection === 'left') {
  22467. 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
  22468. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d left to position %3$d'), type, position, position + 1);
  22469. }
  22470. if (movementDirection === 'right') {
  22471. 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
  22472. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d right to position %3$d'), type, position, position + 1);
  22473. }
  22474. }
  22475. if (dir > 0 && isLast) {
  22476. // Moving down, and is the last item.
  22477. const movementDirection = getMovementDirection('down');
  22478. if (movementDirection === 'down') {
  22479. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  22480. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved down'), type);
  22481. }
  22482. if (movementDirection === 'left') {
  22483. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  22484. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved left'), type);
  22485. }
  22486. if (movementDirection === 'right') {
  22487. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  22488. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved right'), type);
  22489. }
  22490. }
  22491. if (dir < 0 && !isFirst) {
  22492. // Moving up.
  22493. const movementDirection = getMovementDirection('up');
  22494. if (movementDirection === 'up') {
  22495. 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
  22496. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d up to position %3$d'), type, position, position - 1);
  22497. }
  22498. if (movementDirection === 'left') {
  22499. 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
  22500. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d left to position %3$d'), type, position, position - 1);
  22501. }
  22502. if (movementDirection === 'right') {
  22503. 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
  22504. (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d right to position %3$d'), type, position, position - 1);
  22505. }
  22506. }
  22507. if (dir < 0 && isFirst) {
  22508. // Moving up, and is the first item.
  22509. const movementDirection = getMovementDirection('up');
  22510. if (movementDirection === 'up') {
  22511. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  22512. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved up'), type);
  22513. }
  22514. if (movementDirection === 'left') {
  22515. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  22516. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved left'), type);
  22517. }
  22518. if (movementDirection === 'right') {
  22519. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
  22520. (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved right'), type);
  22521. }
  22522. }
  22523. }
  22524. /**
  22525. * Return a label for the block movement controls depending on block position.
  22526. *
  22527. * @param {number} selectedCount Number of blocks selected.
  22528. * @param {number} firstIndex The index (position - 1) of the first block selected.
  22529. * @param {boolean} isFirst This is the first block.
  22530. * @param {boolean} isLast This is the last block.
  22531. * @param {number} dir Direction of movement (> 0 is considered to be going
  22532. * down, < 0 is up).
  22533. *
  22534. * @return {string} Label for the block movement controls.
  22535. */
  22536. function getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir) {
  22537. const position = firstIndex + 1;
  22538. if (dir < 0 && isFirst) {
  22539. return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved up as they are already at the top');
  22540. }
  22541. if (dir > 0 && isLast) {
  22542. return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved down as they are already at the bottom');
  22543. }
  22544. if (dir < 0 && !isFirst) {
  22545. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
  22546. (0,external_wp_i18n_namespaceObject._n)('Move %1$d block from position %2$d up by one place', 'Move %1$d blocks from position %2$d up by one place', selectedCount), selectedCount, position);
  22547. }
  22548. if (dir > 0 && !isLast) {
  22549. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
  22550. (0,external_wp_i18n_namespaceObject._n)('Move %1$d block from position %2$d down by one place', 'Move %1$d blocks from position %2$d down by one place', selectedCount), selectedCount, position);
  22551. }
  22552. }
  22553. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/button.js
  22554. /**
  22555. * External dependencies
  22556. */
  22557. /**
  22558. * WordPress dependencies
  22559. */
  22560. /**
  22561. * Internal dependencies
  22562. */
  22563. const getArrowIcon = (direction, orientation) => {
  22564. if (direction === 'up') {
  22565. if (orientation === 'horizontal') {
  22566. return (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left;
  22567. }
  22568. return chevron_up;
  22569. } else if (direction === 'down') {
  22570. if (orientation === 'horizontal') {
  22571. return (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right;
  22572. }
  22573. return chevron_down;
  22574. }
  22575. return null;
  22576. };
  22577. const getMovementDirectionLabel = (moveDirection, orientation) => {
  22578. if (moveDirection === 'up') {
  22579. if (orientation === 'horizontal') {
  22580. return (0,external_wp_i18n_namespaceObject.isRTL)() ? (0,external_wp_i18n_namespaceObject.__)('Move right') : (0,external_wp_i18n_namespaceObject.__)('Move left');
  22581. }
  22582. return (0,external_wp_i18n_namespaceObject.__)('Move up');
  22583. } else if (moveDirection === 'down') {
  22584. if (orientation === 'horizontal') {
  22585. return (0,external_wp_i18n_namespaceObject.isRTL)() ? (0,external_wp_i18n_namespaceObject.__)('Move left') : (0,external_wp_i18n_namespaceObject.__)('Move right');
  22586. }
  22587. return (0,external_wp_i18n_namespaceObject.__)('Move down');
  22588. }
  22589. return null;
  22590. };
  22591. const BlockMoverButton = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => {
  22592. let {
  22593. clientIds,
  22594. direction,
  22595. orientation: moverOrientation,
  22596. ...props
  22597. } = _ref;
  22598. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockMoverButton);
  22599. const blocksCount = (0,external_lodash_namespaceObject.castArray)(clientIds).length;
  22600. const {
  22601. blockType,
  22602. isDisabled,
  22603. rootClientId,
  22604. isFirst,
  22605. isLast,
  22606. firstIndex,
  22607. orientation = 'vertical'
  22608. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  22609. const {
  22610. getBlockIndex,
  22611. getBlockRootClientId,
  22612. getBlockOrder,
  22613. getBlock,
  22614. getBlockListSettings
  22615. } = select(store);
  22616. const normalizedClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
  22617. const firstClientId = (0,external_lodash_namespaceObject.first)(normalizedClientIds);
  22618. const blockRootClientId = getBlockRootClientId(firstClientId);
  22619. const firstBlockIndex = getBlockIndex(firstClientId);
  22620. const lastBlockIndex = getBlockIndex((0,external_lodash_namespaceObject.last)(normalizedClientIds));
  22621. const blockOrder = getBlockOrder(blockRootClientId);
  22622. const block = getBlock(firstClientId);
  22623. const isFirstBlock = firstBlockIndex === 0;
  22624. const isLastBlock = lastBlockIndex === blockOrder.length - 1;
  22625. const {
  22626. orientation: blockListOrientation
  22627. } = getBlockListSettings(blockRootClientId) || {};
  22628. return {
  22629. blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
  22630. isDisabled: direction === 'up' ? isFirstBlock : isLastBlock,
  22631. rootClientId: blockRootClientId,
  22632. firstIndex: firstBlockIndex,
  22633. isFirst: isFirstBlock,
  22634. isLast: isLastBlock,
  22635. orientation: moverOrientation || blockListOrientation
  22636. };
  22637. }, [clientIds, direction]);
  22638. const {
  22639. moveBlocksDown,
  22640. moveBlocksUp
  22641. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  22642. const moverFunction = direction === 'up' ? moveBlocksUp : moveBlocksDown;
  22643. const onClick = event => {
  22644. moverFunction(clientIds, rootClientId);
  22645. if (props.onClick) {
  22646. props.onClick(event);
  22647. }
  22648. };
  22649. const descriptionId = `block-editor-block-mover-button__description-${instanceId}`;
  22650. 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({
  22651. ref: ref,
  22652. className: classnames_default()('block-editor-block-mover-button', `is-${direction}-button`),
  22653. icon: getArrowIcon(direction, orientation),
  22654. label: getMovementDirectionLabel(direction, orientation),
  22655. "aria-describedby": descriptionId
  22656. }, props, {
  22657. onClick: isDisabled ? null : onClick,
  22658. "aria-disabled": isDisabled
  22659. })), (0,external_wp_element_namespaceObject.createElement)("span", {
  22660. id: descriptionId,
  22661. className: "block-editor-block-mover-button__description"
  22662. }, getBlockMoverDescription(blocksCount, blockType && blockType.title, firstIndex, isFirst, isLast, direction === 'up' ? -1 : 1, orientation)));
  22663. });
  22664. const BlockMoverUpButton = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  22665. return (0,external_wp_element_namespaceObject.createElement)(BlockMoverButton, _extends({
  22666. direction: "up",
  22667. ref: ref
  22668. }, props));
  22669. });
  22670. const BlockMoverDownButton = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  22671. return (0,external_wp_element_namespaceObject.createElement)(BlockMoverButton, _extends({
  22672. direction: "down",
  22673. ref: ref
  22674. }, props));
  22675. });
  22676. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/index.js
  22677. /**
  22678. * External dependencies
  22679. */
  22680. /**
  22681. * WordPress dependencies
  22682. */
  22683. /**
  22684. * Internal dependencies
  22685. */
  22686. function BlockMover(_ref) {
  22687. let {
  22688. isFirst,
  22689. isLast,
  22690. clientIds,
  22691. canMove,
  22692. isHidden,
  22693. rootClientId,
  22694. orientation,
  22695. hideDragHandle
  22696. } = _ref;
  22697. const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false);
  22698. const onFocus = () => setIsFocused(true);
  22699. const onBlur = () => setIsFocused(false);
  22700. if (!canMove || isFirst && isLast && !rootClientId) {
  22701. return null;
  22702. }
  22703. const dragHandleLabel = (0,external_wp_i18n_namespaceObject.__)('Drag'); // We emulate a disabled state because forcefully applying the `disabled`
  22704. // attribute on the buttons while it has focus causes the screen to change
  22705. // to an unfocused state (body as active element) without firing blur on,
  22706. // the rendering parent, leaving it unable to react to focus out.
  22707. return (0,external_wp_element_namespaceObject.createElement)("div", {
  22708. className: classnames_default()('block-editor-block-mover', {
  22709. 'is-visible': isFocused || !isHidden,
  22710. 'is-horizontal': orientation === 'horizontal'
  22711. })
  22712. }, !hideDragHandle && (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
  22713. clientIds: clientIds,
  22714. cloneClassname: "block-editor-block-mover__drag-clone"
  22715. }, draggableProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
  22716. icon: drag_handle,
  22717. className: "block-editor-block-mover__drag-handle",
  22718. "aria-hidden": "true",
  22719. label: dragHandleLabel // Should not be able to tab to drag handle as this
  22720. // button can only be used with a pointer device.
  22721. ,
  22722. tabIndex: "-1"
  22723. }, draggableProps))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
  22724. className: "block-editor-block-mover__move-button-container"
  22725. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
  22726. onFocus: onFocus,
  22727. onBlur: onBlur
  22728. }, itemProps => (0,external_wp_element_namespaceObject.createElement)(BlockMoverUpButton, _extends({
  22729. clientIds: clientIds
  22730. }, itemProps))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
  22731. onFocus: onFocus,
  22732. onBlur: onBlur
  22733. }, itemProps => (0,external_wp_element_namespaceObject.createElement)(BlockMoverDownButton, _extends({
  22734. clientIds: clientIds
  22735. }, itemProps)))));
  22736. }
  22737. /**
  22738. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-mover/README.md
  22739. */
  22740. /* harmony default export */ var block_mover = ((0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => {
  22741. var _getBlockListSettings;
  22742. let {
  22743. clientIds
  22744. } = _ref2;
  22745. const {
  22746. getBlock,
  22747. getBlockIndex,
  22748. getBlockListSettings,
  22749. canMoveBlocks,
  22750. getBlockOrder,
  22751. getBlockRootClientId
  22752. } = select(store);
  22753. const normalizedClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
  22754. const firstClientId = (0,external_lodash_namespaceObject.first)(normalizedClientIds);
  22755. const block = getBlock(firstClientId);
  22756. const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.first)(normalizedClientIds));
  22757. const firstIndex = getBlockIndex(firstClientId);
  22758. const lastIndex = getBlockIndex((0,external_lodash_namespaceObject.last)(normalizedClientIds));
  22759. const blockOrder = getBlockOrder(rootClientId);
  22760. const isFirst = firstIndex === 0;
  22761. const isLast = lastIndex === blockOrder.length - 1;
  22762. return {
  22763. blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
  22764. canMove: canMoveBlocks(clientIds, rootClientId),
  22765. rootClientId,
  22766. firstIndex,
  22767. isFirst,
  22768. isLast,
  22769. orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
  22770. };
  22771. })(BlockMover));
  22772. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/utils.js
  22773. /**
  22774. * External dependencies
  22775. */
  22776. /**
  22777. * WordPress dependencies
  22778. */
  22779. const {
  22780. clearTimeout: utils_clearTimeout,
  22781. setTimeout: utils_setTimeout
  22782. } = window;
  22783. const DEBOUNCE_TIMEOUT = 200;
  22784. /**
  22785. * Hook that creates a showMover state, as well as debounced show/hide callbacks.
  22786. *
  22787. * @param {Object} props Component props.
  22788. * @param {Object} props.ref Element reference.
  22789. * @param {boolean} props.isFocused Whether the component has current focus.
  22790. * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
  22791. * @param {Function} [props.onChange=noop] Callback function.
  22792. */
  22793. function useDebouncedShowMovers(_ref) {
  22794. let {
  22795. ref,
  22796. isFocused,
  22797. debounceTimeout = DEBOUNCE_TIMEOUT,
  22798. onChange = external_lodash_namespaceObject.noop
  22799. } = _ref;
  22800. const [showMovers, setShowMovers] = (0,external_wp_element_namespaceObject.useState)(false);
  22801. const timeoutRef = (0,external_wp_element_namespaceObject.useRef)();
  22802. const handleOnChange = nextIsFocused => {
  22803. if (ref !== null && ref !== void 0 && ref.current) {
  22804. setShowMovers(nextIsFocused);
  22805. }
  22806. onChange(nextIsFocused);
  22807. };
  22808. const getIsHovered = () => {
  22809. return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.matches(':hover');
  22810. };
  22811. const shouldHideMovers = () => {
  22812. const isHovered = getIsHovered();
  22813. return !isFocused && !isHovered;
  22814. };
  22815. const clearTimeoutRef = () => {
  22816. const timeout = timeoutRef.current;
  22817. if (timeout && utils_clearTimeout) {
  22818. utils_clearTimeout(timeout);
  22819. }
  22820. };
  22821. const debouncedShowMovers = event => {
  22822. if (event) {
  22823. event.stopPropagation();
  22824. }
  22825. clearTimeoutRef();
  22826. if (!showMovers) {
  22827. handleOnChange(true);
  22828. }
  22829. };
  22830. const debouncedHideMovers = event => {
  22831. if (event) {
  22832. event.stopPropagation();
  22833. }
  22834. clearTimeoutRef();
  22835. timeoutRef.current = utils_setTimeout(() => {
  22836. if (shouldHideMovers()) {
  22837. handleOnChange(false);
  22838. }
  22839. }, debounceTimeout);
  22840. };
  22841. (0,external_wp_element_namespaceObject.useEffect)(() => () => {
  22842. /**
  22843. * We need to call the change handler with `isFocused`
  22844. * set to false on unmount because we also clear the
  22845. * timeout that would handle that.
  22846. */
  22847. handleOnChange(false);
  22848. clearTimeoutRef();
  22849. }, []);
  22850. return {
  22851. showMovers,
  22852. debouncedShowMovers,
  22853. debouncedHideMovers
  22854. };
  22855. }
  22856. /**
  22857. * Hook that provides a showMovers state and gesture events for DOM elements
  22858. * that interact with the showMovers state.
  22859. *
  22860. * @param {Object} props Component props.
  22861. * @param {Object} props.ref Element reference.
  22862. * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
  22863. * @param {Function} [props.onChange=noop] Callback function.
  22864. */
  22865. function useShowMoversGestures(_ref2) {
  22866. let {
  22867. ref,
  22868. debounceTimeout = DEBOUNCE_TIMEOUT,
  22869. onChange = external_lodash_namespaceObject.noop
  22870. } = _ref2;
  22871. const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false);
  22872. const {
  22873. showMovers,
  22874. debouncedShowMovers,
  22875. debouncedHideMovers
  22876. } = useDebouncedShowMovers({
  22877. ref,
  22878. debounceTimeout,
  22879. isFocused,
  22880. onChange
  22881. });
  22882. const registerRef = (0,external_wp_element_namespaceObject.useRef)(false);
  22883. const isFocusedWithin = () => {
  22884. return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.contains(ref.current.ownerDocument.activeElement);
  22885. };
  22886. (0,external_wp_element_namespaceObject.useEffect)(() => {
  22887. const node = ref.current;
  22888. const handleOnFocus = () => {
  22889. if (isFocusedWithin()) {
  22890. setIsFocused(true);
  22891. debouncedShowMovers();
  22892. }
  22893. };
  22894. const handleOnBlur = () => {
  22895. if (!isFocusedWithin()) {
  22896. setIsFocused(false);
  22897. debouncedHideMovers();
  22898. }
  22899. };
  22900. /**
  22901. * Events are added via DOM events (vs. React synthetic events),
  22902. * as the child React components swallow mouse events.
  22903. */
  22904. if (node && !registerRef.current) {
  22905. node.addEventListener('focus', handleOnFocus, true);
  22906. node.addEventListener('blur', handleOnBlur, true);
  22907. registerRef.current = true;
  22908. }
  22909. return () => {
  22910. if (node) {
  22911. node.removeEventListener('focus', handleOnFocus);
  22912. node.removeEventListener('blur', handleOnBlur);
  22913. }
  22914. };
  22915. }, [ref, registerRef, setIsFocused, debouncedShowMovers, debouncedHideMovers]);
  22916. return {
  22917. showMovers,
  22918. gestures: {
  22919. onMouseMove: debouncedShowMovers,
  22920. onMouseLeave: debouncedHideMovers
  22921. }
  22922. };
  22923. }
  22924. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-parent-selector/index.js
  22925. /**
  22926. * WordPress dependencies
  22927. */
  22928. /**
  22929. * Internal dependencies
  22930. */
  22931. /**
  22932. * Block parent selector component, displaying the hierarchy of the
  22933. * current block selection as a single icon to "go up" a level.
  22934. *
  22935. * @return {WPComponent} Parent block selector.
  22936. */
  22937. function BlockParentSelector() {
  22938. const {
  22939. selectBlock,
  22940. toggleBlockHighlight
  22941. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  22942. const {
  22943. firstParentClientId,
  22944. shouldHide,
  22945. hasReducedUI
  22946. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  22947. const {
  22948. getBlockName,
  22949. getBlockParents,
  22950. getSelectedBlockClientId,
  22951. getSettings
  22952. } = select(store);
  22953. const {
  22954. hasBlockSupport
  22955. } = select(external_wp_blocks_namespaceObject.store);
  22956. const selectedBlockClientId = getSelectedBlockClientId();
  22957. const parents = getBlockParents(selectedBlockClientId);
  22958. const _firstParentClientId = parents[parents.length - 1];
  22959. const parentBlockName = getBlockName(_firstParentClientId);
  22960. const _parentBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(parentBlockName);
  22961. const settings = getSettings();
  22962. return {
  22963. firstParentClientId: _firstParentClientId,
  22964. shouldHide: !hasBlockSupport(_parentBlockType, '__experimentalParentSelector', true),
  22965. hasReducedUI: settings.hasReducedUI
  22966. };
  22967. }, []);
  22968. const blockInformation = useBlockDisplayInformation(firstParentClientId); // Allows highlighting the parent block outline when focusing or hovering
  22969. // the parent block selector within the child.
  22970. const nodeRef = (0,external_wp_element_namespaceObject.useRef)();
  22971. const {
  22972. gestures: showMoversGestures
  22973. } = useShowMoversGestures({
  22974. ref: nodeRef,
  22975. onChange(isFocused) {
  22976. if (isFocused && hasReducedUI) {
  22977. return;
  22978. }
  22979. toggleBlockHighlight(firstParentClientId, isFocused);
  22980. }
  22981. });
  22982. if (shouldHide || firstParentClientId === undefined) {
  22983. return null;
  22984. }
  22985. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  22986. className: "block-editor-block-parent-selector",
  22987. key: firstParentClientId,
  22988. ref: nodeRef
  22989. }, showMoversGestures), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  22990. className: "block-editor-block-parent-selector__button",
  22991. onClick: () => selectBlock(firstParentClientId),
  22992. label: (0,external_wp_i18n_namespaceObject.sprintf)(
  22993. /* translators: %s: Name of the block's parent. */
  22994. (0,external_wp_i18n_namespaceObject.__)('Select %s'), blockInformation.title),
  22995. showTooltip: true,
  22996. icon: (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  22997. icon: blockInformation.icon
  22998. })
  22999. }));
  23000. }
  23001. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/copy.js
  23002. /**
  23003. * WordPress dependencies
  23004. */
  23005. const copy = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  23006. xmlns: "http://www.w3.org/2000/svg",
  23007. viewBox: "0 0 24 24"
  23008. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  23009. 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"
  23010. }));
  23011. /* harmony default export */ var library_copy = (copy);
  23012. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/preview-block-popover.js
  23013. /**
  23014. * WordPress dependencies
  23015. */
  23016. /**
  23017. * Internal dependencies
  23018. */
  23019. function PreviewBlockPopover(_ref) {
  23020. let {
  23021. blocks
  23022. } = _ref;
  23023. return (0,external_wp_element_namespaceObject.createElement)("div", {
  23024. className: "block-editor-block-switcher__popover__preview__parent"
  23025. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  23026. className: "block-editor-block-switcher__popover__preview__container"
  23027. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  23028. className: "block-editor-block-switcher__preview__popover",
  23029. position: "bottom right",
  23030. focusOnMount: false
  23031. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  23032. className: "block-editor-block-switcher__preview"
  23033. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  23034. className: "block-editor-block-switcher__preview-title"
  23035. }, (0,external_wp_i18n_namespaceObject.__)('Preview')), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  23036. viewportWidth: 500,
  23037. blocks: blocks
  23038. })))));
  23039. }
  23040. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-transformations-menu.js
  23041. /**
  23042. * WordPress dependencies
  23043. */
  23044. /**
  23045. * Internal dependencies
  23046. */
  23047. const BlockTransformationsMenu = _ref => {
  23048. let {
  23049. className,
  23050. possibleBlockTransformations,
  23051. onSelect,
  23052. blocks
  23053. } = _ref;
  23054. const [hoveredTransformItemName, setHoveredTransformItemName] = (0,external_wp_element_namespaceObject.useState)();
  23055. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  23056. label: (0,external_wp_i18n_namespaceObject.__)('Transform to'),
  23057. className: className
  23058. }, hoveredTransformItemName && (0,external_wp_element_namespaceObject.createElement)(PreviewBlockPopover, {
  23059. blocks: (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, hoveredTransformItemName)
  23060. }), possibleBlockTransformations.map(item => {
  23061. const {
  23062. name,
  23063. icon,
  23064. title,
  23065. isDisabled
  23066. } = item;
  23067. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  23068. key: name,
  23069. className: (0,external_wp_blocks_namespaceObject.getBlockMenuDefaultClassName)(name),
  23070. onClick: event => {
  23071. event.preventDefault();
  23072. onSelect(name);
  23073. },
  23074. disabled: isDisabled,
  23075. onMouseLeave: () => setHoveredTransformItemName(null),
  23076. onMouseEnter: () => setHoveredTransformItemName(name)
  23077. }, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  23078. icon: icon,
  23079. showColors: true
  23080. }), title);
  23081. }));
  23082. };
  23083. /* harmony default export */ var block_transformations_menu = (BlockTransformationsMenu);
  23084. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js
  23085. /**
  23086. * WordPress dependencies
  23087. */
  23088. const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  23089. xmlns: "http://www.w3.org/2000/svg",
  23090. viewBox: "0 0 24 24"
  23091. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  23092. d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
  23093. }));
  23094. /* harmony default export */ var library_check = (check);
  23095. ;// CONCATENATED MODULE: external ["wp","tokenList"]
  23096. var external_wp_tokenList_namespaceObject = window["wp"]["tokenList"];
  23097. var external_wp_tokenList_default = /*#__PURE__*/__webpack_require__.n(external_wp_tokenList_namespaceObject);
  23098. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/utils.js
  23099. /**
  23100. * External dependencies
  23101. */
  23102. /**
  23103. * WordPress dependencies
  23104. */
  23105. /**
  23106. * Returns the active style from the given className.
  23107. *
  23108. * @param {Array} styles Block style variations.
  23109. * @param {string} className Class name
  23110. *
  23111. * @return {Object?} The active style.
  23112. */
  23113. function getActiveStyle(styles, className) {
  23114. for (const style of new (external_wp_tokenList_default())(className).values()) {
  23115. if (style.indexOf('is-style-') === -1) {
  23116. continue;
  23117. }
  23118. const potentialStyleName = style.substring(9);
  23119. const activeStyle = (0,external_lodash_namespaceObject.find)(styles, {
  23120. name: potentialStyleName
  23121. });
  23122. if (activeStyle) {
  23123. return activeStyle;
  23124. }
  23125. }
  23126. return (0,external_lodash_namespaceObject.find)(styles, 'isDefault');
  23127. }
  23128. /**
  23129. * Replaces the active style in the block's className.
  23130. *
  23131. * @param {string} className Class name.
  23132. * @param {Object?} activeStyle The replaced style.
  23133. * @param {Object} newStyle The replacing style.
  23134. *
  23135. * @return {string} The updated className.
  23136. */
  23137. function replaceActiveStyle(className, activeStyle, newStyle) {
  23138. const list = new (external_wp_tokenList_default())(className);
  23139. if (activeStyle) {
  23140. list.remove('is-style-' + activeStyle.name);
  23141. }
  23142. list.add('is-style-' + newStyle.name);
  23143. return list.value;
  23144. }
  23145. /**
  23146. * Returns a collection of styles that can be represented on the frontend.
  23147. * The function checks a style collection for a default style. If none is found, it adds one to
  23148. * act as a fallback for when there is no active style applied to a block. The default item also serves
  23149. * as a switch on the frontend to deactivate non-default styles.
  23150. *
  23151. * @param {Array} styles Block style variations.
  23152. *
  23153. * @return {Array<Object?>} The style collection.
  23154. */
  23155. function getRenderedStyles(styles) {
  23156. if (!styles || styles.length === 0) {
  23157. return [];
  23158. }
  23159. return getDefaultStyle(styles) ? styles : [{
  23160. name: 'default',
  23161. label: (0,external_wp_i18n_namespaceObject._x)('Default', 'block style'),
  23162. isDefault: true
  23163. }, ...styles];
  23164. }
  23165. /**
  23166. * Returns a style object from a collection of styles where that style object is the default block style.
  23167. *
  23168. * @param {Array} styles Block style variations.
  23169. *
  23170. * @return {Object?} The default style object, if found.
  23171. */
  23172. function getDefaultStyle(styles) {
  23173. return (0,external_lodash_namespaceObject.find)(styles, 'isDefault');
  23174. }
  23175. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/use-styles-for-block.js
  23176. /**
  23177. * WordPress dependencies
  23178. */
  23179. /**
  23180. * Internal dependencies
  23181. */
  23182. /**
  23183. *
  23184. * @param {WPBlock} block Block object.
  23185. * @param {WPBlockType} type Block type settings.
  23186. * @return {WPBlock} A generic block ready for styles preview.
  23187. */
  23188. function useGenericPreviewBlock(block, type) {
  23189. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  23190. const example = type === null || type === void 0 ? void 0 : type.example;
  23191. const blockName = type === null || type === void 0 ? void 0 : type.name;
  23192. if (example && blockName) {
  23193. return (0,external_wp_blocks_namespaceObject.getBlockFromExample)(blockName, {
  23194. attributes: example.attributes,
  23195. innerBlocks: example.innerBlocks
  23196. });
  23197. }
  23198. if (block) {
  23199. return (0,external_wp_blocks_namespaceObject.cloneBlock)(block);
  23200. }
  23201. }, [type !== null && type !== void 0 && type.example ? block === null || block === void 0 ? void 0 : block.name : block, type]);
  23202. }
  23203. /**
  23204. * @typedef useStylesForBlocksArguments
  23205. * @property {string} clientId Block client ID.
  23206. * @property {() => void} onSwitch Block style switch callback function.
  23207. */
  23208. /**
  23209. *
  23210. * @param {useStylesForBlocksArguments} useStylesForBlocks arguments.
  23211. * @return {Object} Results of the select methods.
  23212. */
  23213. function useStylesForBlocks(_ref) {
  23214. let {
  23215. clientId,
  23216. onSwitch
  23217. } = _ref;
  23218. const selector = select => {
  23219. const {
  23220. getBlock
  23221. } = select(store);
  23222. const block = getBlock(clientId);
  23223. if (!block) {
  23224. return {};
  23225. }
  23226. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
  23227. const {
  23228. getBlockStyles
  23229. } = select(external_wp_blocks_namespaceObject.store);
  23230. return {
  23231. block,
  23232. blockType,
  23233. styles: getBlockStyles(block.name),
  23234. className: block.attributes.className || ''
  23235. };
  23236. };
  23237. const {
  23238. styles,
  23239. block,
  23240. blockType,
  23241. className
  23242. } = (0,external_wp_data_namespaceObject.useSelect)(selector, [clientId]);
  23243. const {
  23244. updateBlockAttributes
  23245. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  23246. const stylesToRender = getRenderedStyles(styles);
  23247. const activeStyle = getActiveStyle(stylesToRender, className);
  23248. const genericPreviewBlock = useGenericPreviewBlock(block, blockType);
  23249. const onSelect = style => {
  23250. const styleClassName = replaceActiveStyle(className, activeStyle, style);
  23251. updateBlockAttributes(clientId, {
  23252. className: styleClassName
  23253. });
  23254. onSwitch();
  23255. };
  23256. return {
  23257. onSelect,
  23258. stylesToRender,
  23259. activeStyle,
  23260. genericPreviewBlock,
  23261. className
  23262. };
  23263. }
  23264. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/menu-items.js
  23265. /**
  23266. * External dependencies
  23267. */
  23268. /**
  23269. * WordPress dependencies
  23270. */
  23271. /**
  23272. * Internal dependencies
  23273. */
  23274. function BlockStylesMenuItems(_ref) {
  23275. let {
  23276. clientId,
  23277. onSwitch = external_lodash_namespaceObject.noop
  23278. } = _ref;
  23279. const {
  23280. onSelect,
  23281. stylesToRender,
  23282. activeStyle
  23283. } = useStylesForBlocks({
  23284. clientId,
  23285. onSwitch
  23286. });
  23287. if (!stylesToRender || stylesToRender.length === 0) {
  23288. return null;
  23289. }
  23290. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, stylesToRender.map(style => {
  23291. const menuItemText = style.label || style.name;
  23292. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  23293. key: style.name,
  23294. icon: activeStyle.name === style.name ? library_check : null,
  23295. onClick: () => onSelect(style)
  23296. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
  23297. as: "span",
  23298. limit: 18,
  23299. ellipsizeMode: "tail",
  23300. truncate: true
  23301. }, menuItemText));
  23302. }));
  23303. }
  23304. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-styles-menu.js
  23305. /**
  23306. * WordPress dependencies
  23307. */
  23308. /**
  23309. * Internal dependencies
  23310. */
  23311. function BlockStylesMenu(_ref) {
  23312. let {
  23313. hoveredBlock,
  23314. onSwitch
  23315. } = _ref;
  23316. const {
  23317. clientId
  23318. } = hoveredBlock;
  23319. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  23320. label: (0,external_wp_i18n_namespaceObject.__)('Styles'),
  23321. className: "block-editor-block-switcher__styles__menugroup"
  23322. }, (0,external_wp_element_namespaceObject.createElement)(BlockStylesMenuItems, {
  23323. clientId: clientId,
  23324. onSwitch: onSwitch
  23325. }));
  23326. }
  23327. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/utils.js
  23328. /**
  23329. * WordPress dependencies
  23330. */
  23331. /**
  23332. * Try to find a matching block by a block's name in a provided
  23333. * block. We recurse through InnerBlocks and return the reference
  23334. * of the matched block (it could be an InnerBlock).
  23335. * If no match is found return nothing.
  23336. *
  23337. * @param {WPBlock} block The block to try to find a match.
  23338. * @param {string} selectedBlockName The block's name to use for matching condition.
  23339. * @param {Set} consumedBlocks A set holding the previously matched/consumed blocks.
  23340. *
  23341. * @return {WPBlock?} The matched block if found or nothing(`undefined`).
  23342. */
  23343. const getMatchingBlockByName = function (block, selectedBlockName) {
  23344. let consumedBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
  23345. const {
  23346. clientId,
  23347. name,
  23348. innerBlocks = []
  23349. } = block; // Check if block has been consumed already.
  23350. if (consumedBlocks.has(clientId)) return;
  23351. if (name === selectedBlockName) return block; // Try to find a matching block from InnerBlocks recursively.
  23352. for (const innerBlock of innerBlocks) {
  23353. const match = getMatchingBlockByName(innerBlock, selectedBlockName, consumedBlocks);
  23354. if (match) return match;
  23355. }
  23356. };
  23357. /**
  23358. * Find and return the block attributes to retain through
  23359. * the transformation, based on Block Type's `role:content`
  23360. * attributes. If no `role:content` attributes exist,
  23361. * return selected block's attributes.
  23362. *
  23363. * @param {string} name Block type's namespaced name.
  23364. * @param {Object} attributes Selected block's attributes.
  23365. * @return {Object} The block's attributes to retain.
  23366. */
  23367. const getRetainedBlockAttributes = (name, attributes) => {
  23368. const contentAttributes = (0,external_wp_blocks_namespaceObject.__experimentalGetBlockAttributesNamesByRole)(name, 'content');
  23369. if (!(contentAttributes !== null && contentAttributes !== void 0 && contentAttributes.length)) return attributes;
  23370. return contentAttributes.reduce((_accumulator, attribute) => {
  23371. if (attributes[attribute]) _accumulator[attribute] = attributes[attribute];
  23372. return _accumulator;
  23373. }, {});
  23374. };
  23375. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/use-transformed-patterns.js
  23376. /**
  23377. * WordPress dependencies
  23378. */
  23379. /**
  23380. * Internal dependencies
  23381. */
  23382. /**
  23383. * Mutate the matched block's attributes by getting
  23384. * which block type's attributes to retain and prioritize
  23385. * them in the merging of the attributes.
  23386. *
  23387. * @param {WPBlock} match The matched block.
  23388. * @param {WPBlock} selectedBlock The selected block.
  23389. * @return {void}
  23390. */
  23391. const transformMatchingBlock = (match, selectedBlock) => {
  23392. // Get the block attributes to retain through the transformation.
  23393. const retainedBlockAttributes = getRetainedBlockAttributes(selectedBlock.name, selectedBlock.attributes);
  23394. match.attributes = { ...match.attributes,
  23395. ...retainedBlockAttributes
  23396. };
  23397. };
  23398. /**
  23399. * By providing the selected blocks and pattern's blocks
  23400. * find the matching blocks, transform them and return them.
  23401. * If not all selected blocks are matched, return nothing.
  23402. *
  23403. * @param {WPBlock[]} selectedBlocks The selected blocks.
  23404. * @param {WPBlock[]} patternBlocks The pattern's blocks.
  23405. * @return {WPBlock[]|void} The transformed pattern's blocks or undefined if not all selected blocks have been matched.
  23406. */
  23407. const getPatternTransformedBlocks = (selectedBlocks, patternBlocks) => {
  23408. // Clone Pattern's blocks to produce new clientIds and be able to mutate the matches.
  23409. const _patternBlocks = patternBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
  23410. /**
  23411. * Keep track of the consumed pattern blocks.
  23412. * This is needed because we loop the selected blocks
  23413. * and for example we may have selected two paragraphs and
  23414. * the pattern's blocks could have more `paragraphs`.
  23415. */
  23416. const consumedBlocks = new Set();
  23417. for (const selectedBlock of selectedBlocks) {
  23418. let isMatch = false;
  23419. for (const patternBlock of _patternBlocks) {
  23420. const match = getMatchingBlockByName(patternBlock, selectedBlock.name, consumedBlocks);
  23421. if (!match) continue;
  23422. isMatch = true;
  23423. consumedBlocks.add(match.clientId); // We update (mutate) the matching pattern block.
  23424. transformMatchingBlock(match, selectedBlock); // No need to loop through other pattern's blocks.
  23425. break;
  23426. } // Bail eary if a selected block has not been matched.
  23427. if (!isMatch) return;
  23428. }
  23429. return _patternBlocks;
  23430. };
  23431. /**
  23432. * @typedef {WPBlockPattern & {transformedBlocks: WPBlock[]}} TransformedBlockPattern
  23433. */
  23434. /**
  23435. * Custom hook that accepts patterns from state and the selected
  23436. * blocks and tries to match these with the pattern's blocks.
  23437. * If all selected blocks are matched with a Pattern's block,
  23438. * we transform them by retaining block's attributes with `role:content`.
  23439. * The transformed pattern's blocks are set to a new pattern
  23440. * property `transformedBlocks`.
  23441. *
  23442. * @param {WPBlockPattern[]} patterns Patterns from state.
  23443. * @param {WPBlock[]} selectedBlocks The currently selected blocks.
  23444. * @return {TransformedBlockPattern[]} Returns the eligible matched patterns with all the selected blocks.
  23445. */
  23446. const useTransformedPatterns = (patterns, selectedBlocks) => {
  23447. return (0,external_wp_element_namespaceObject.useMemo)(() => patterns.reduce((accumulator, _pattern) => {
  23448. const transformedBlocks = getPatternTransformedBlocks(selectedBlocks, _pattern.blocks);
  23449. if (transformedBlocks) {
  23450. accumulator.push({ ..._pattern,
  23451. transformedBlocks
  23452. });
  23453. }
  23454. return accumulator;
  23455. }, []), [patterns, selectedBlocks]);
  23456. };
  23457. /* harmony default export */ var use_transformed_patterns = (useTransformedPatterns);
  23458. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/pattern-transformations-menu.js
  23459. /**
  23460. * WordPress dependencies
  23461. */
  23462. /**
  23463. * Internal dependencies
  23464. */
  23465. function PatternTransformationsMenu(_ref) {
  23466. let {
  23467. blocks,
  23468. patterns: statePatterns,
  23469. onSelect
  23470. } = _ref;
  23471. const [showTransforms, setShowTransforms] = (0,external_wp_element_namespaceObject.useState)(false);
  23472. const patterns = use_transformed_patterns(statePatterns, blocks);
  23473. if (!patterns.length) return null;
  23474. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  23475. className: "block-editor-block-switcher__pattern__transforms__menugroup"
  23476. }, showTransforms && (0,external_wp_element_namespaceObject.createElement)(PreviewPatternsPopover, {
  23477. patterns: patterns,
  23478. onSelect: onSelect
  23479. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  23480. onClick: event => {
  23481. event.preventDefault();
  23482. setShowTransforms(!showTransforms);
  23483. },
  23484. icon: chevron_right
  23485. }, (0,external_wp_i18n_namespaceObject.__)('Patterns')));
  23486. }
  23487. function PreviewPatternsPopover(_ref2) {
  23488. let {
  23489. patterns,
  23490. onSelect
  23491. } = _ref2;
  23492. return (0,external_wp_element_namespaceObject.createElement)("div", {
  23493. className: "block-editor-block-switcher__popover__preview__parent"
  23494. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  23495. className: "block-editor-block-switcher__popover__preview__container"
  23496. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  23497. className: "block-editor-block-switcher__preview__popover",
  23498. position: "bottom right"
  23499. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  23500. className: "block-editor-block-switcher__preview"
  23501. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  23502. className: "block-editor-block-switcher__preview-title"
  23503. }, (0,external_wp_i18n_namespaceObject.__)('Preview')), (0,external_wp_element_namespaceObject.createElement)(BlockPatternsList, {
  23504. patterns: patterns,
  23505. onSelect: onSelect
  23506. })))));
  23507. }
  23508. function BlockPatternsList(_ref3) {
  23509. let {
  23510. patterns,
  23511. onSelect
  23512. } = _ref3;
  23513. const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)();
  23514. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
  23515. role: "listbox",
  23516. className: "block-editor-block-switcher__preview-patterns-container",
  23517. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Patterns list')
  23518. }), patterns.map(pattern => (0,external_wp_element_namespaceObject.createElement)(pattern_transformations_menu_BlockPattern, {
  23519. key: pattern.name,
  23520. pattern: pattern,
  23521. onSelect: onSelect,
  23522. composite: composite
  23523. })));
  23524. }
  23525. function pattern_transformations_menu_BlockPattern(_ref4) {
  23526. let {
  23527. pattern,
  23528. onSelect,
  23529. composite
  23530. } = _ref4;
  23531. // TODO check pattern/preview width...
  23532. const baseClassName = 'block-editor-block-switcher__preview-patterns-container';
  23533. const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(pattern_transformations_menu_BlockPattern, `${baseClassName}-list__item-description`);
  23534. return (0,external_wp_element_namespaceObject.createElement)("div", {
  23535. className: `${baseClassName}-list__list-item`,
  23536. "aria-label": pattern.title,
  23537. "aria-describedby": pattern.description ? descriptionId : undefined
  23538. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
  23539. role: "option",
  23540. as: "div"
  23541. }, composite, {
  23542. className: `${baseClassName}-list__item`,
  23543. onClick: () => onSelect(pattern.transformedBlocks)
  23544. }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  23545. blocks: pattern.transformedBlocks,
  23546. viewportWidth: pattern.viewportWidth || 500
  23547. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  23548. className: `${baseClassName}-list__item-title`
  23549. }, pattern.title)), !!pattern.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  23550. id: descriptionId
  23551. }, pattern.description));
  23552. }
  23553. /* harmony default export */ var pattern_transformations_menu = (PatternTransformationsMenu);
  23554. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/index.js
  23555. /**
  23556. * External dependencies
  23557. */
  23558. /**
  23559. * WordPress dependencies
  23560. */
  23561. /**
  23562. * Internal dependencies
  23563. */
  23564. const BlockSwitcherDropdownMenu = _ref => {
  23565. let {
  23566. clientIds,
  23567. blocks
  23568. } = _ref;
  23569. const {
  23570. replaceBlocks
  23571. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  23572. const blockInformation = useBlockDisplayInformation(blocks[0].clientId);
  23573. const {
  23574. possibleBlockTransformations,
  23575. canRemove,
  23576. hasBlockStyles,
  23577. icon,
  23578. blockTitle,
  23579. patterns
  23580. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  23581. var _getBlockType2;
  23582. const {
  23583. getBlockRootClientId,
  23584. getBlockTransformItems,
  23585. __experimentalGetPatternTransformItems
  23586. } = select(store);
  23587. const {
  23588. getBlockStyles,
  23589. getBlockType
  23590. } = select(external_wp_blocks_namespaceObject.store);
  23591. const {
  23592. canRemoveBlocks
  23593. } = select(store);
  23594. const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.castArray)(clientIds)[0]);
  23595. const [{
  23596. name: firstBlockName
  23597. }] = blocks;
  23598. const _isSingleBlockSelected = blocks.length === 1;
  23599. const styles = _isSingleBlockSelected && getBlockStyles(firstBlockName);
  23600. let _icon;
  23601. if (_isSingleBlockSelected) {
  23602. _icon = blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon; // Take into account active block variations.
  23603. } else {
  23604. var _getBlockType;
  23605. const isSelectionOfSameType = (0,external_lodash_namespaceObject.uniq)(blocks.map(_ref2 => {
  23606. let {
  23607. name
  23608. } = _ref2;
  23609. return name;
  23610. })).length === 1; // When selection consists of blocks of multiple types, display an
  23611. // appropriate icon to communicate the non-uniformity.
  23612. _icon = isSelectionOfSameType ? (_getBlockType = getBlockType(firstBlockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon : library_copy;
  23613. }
  23614. return {
  23615. possibleBlockTransformations: getBlockTransformItems(blocks, rootClientId),
  23616. canRemove: canRemoveBlocks(clientIds, rootClientId),
  23617. hasBlockStyles: !!(styles !== null && styles !== void 0 && styles.length),
  23618. icon: _icon,
  23619. blockTitle: (_getBlockType2 = getBlockType(firstBlockName)) === null || _getBlockType2 === void 0 ? void 0 : _getBlockType2.title,
  23620. patterns: __experimentalGetPatternTransformItems(blocks, rootClientId)
  23621. };
  23622. }, [clientIds, blocks, blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon]);
  23623. const isReusable = blocks.length === 1 && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]);
  23624. const isTemplate = blocks.length === 1 && (0,external_wp_blocks_namespaceObject.isTemplatePart)(blocks[0]); // Simple block tranformation based on the `Block Transforms` API.
  23625. const onBlockTransform = name => replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, name)); // Pattern transformation through the `Patterns` API.
  23626. const onPatternTransform = transformedBlocks => replaceBlocks(clientIds, transformedBlocks);
  23627. const hasPossibleBlockTransformations = !!possibleBlockTransformations.length && canRemove;
  23628. const hasPatternTransformation = !!(patterns !== null && patterns !== void 0 && patterns.length) && canRemove;
  23629. if (!hasBlockStyles && !hasPossibleBlockTransformations) {
  23630. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  23631. disabled: true,
  23632. className: "block-editor-block-switcher__no-switcher-icon",
  23633. title: blockTitle,
  23634. icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  23635. icon: icon,
  23636. showColors: true
  23637. }), (isReusable || isTemplate) && (0,external_wp_element_namespaceObject.createElement)("span", {
  23638. className: "block-editor-block-switcher__toggle-text"
  23639. }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
  23640. clientId: clientIds,
  23641. maximumLength: 35
  23642. })))
  23643. }));
  23644. }
  23645. const blockSwitcherLabel = blockTitle;
  23646. const blockSwitcherDescription = 1 === blocks.length ? (0,external_wp_i18n_namespaceObject.sprintf)(
  23647. /* translators: %s: block title. */
  23648. (0,external_wp_i18n_namespaceObject.__)('%s: Change block type or style'), blockTitle) : (0,external_wp_i18n_namespaceObject.sprintf)(
  23649. /* translators: %d: number of blocks. */
  23650. (0,external_wp_i18n_namespaceObject._n)('Change type of %d block', 'Change type of %d blocks', blocks.length), blocks.length);
  23651. const showDropDown = hasBlockStyles || hasPossibleBlockTransformations || hasPatternTransformation;
  23652. 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, {
  23653. className: "block-editor-block-switcher",
  23654. label: blockSwitcherLabel,
  23655. popoverProps: {
  23656. position: 'bottom right',
  23657. isAlternate: true,
  23658. className: 'block-editor-block-switcher__popover'
  23659. },
  23660. icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  23661. icon: icon,
  23662. className: "block-editor-block-switcher__toggle",
  23663. showColors: true
  23664. }), (isReusable || isTemplate) && (0,external_wp_element_namespaceObject.createElement)("span", {
  23665. className: "block-editor-block-switcher__toggle-text"
  23666. }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
  23667. clientId: clientIds,
  23668. maximumLength: 35
  23669. }))),
  23670. toggleProps: {
  23671. describedBy: blockSwitcherDescription,
  23672. ...toggleProps
  23673. },
  23674. menuProps: {
  23675. orientation: 'both'
  23676. }
  23677. }, _ref3 => {
  23678. let {
  23679. onClose
  23680. } = _ref3;
  23681. return showDropDown && (0,external_wp_element_namespaceObject.createElement)("div", {
  23682. className: "block-editor-block-switcher__container"
  23683. }, hasPatternTransformation && (0,external_wp_element_namespaceObject.createElement)(pattern_transformations_menu, {
  23684. blocks: blocks,
  23685. patterns: patterns,
  23686. onSelect: transformedBlocks => {
  23687. onPatternTransform(transformedBlocks);
  23688. onClose();
  23689. }
  23690. }), hasPossibleBlockTransformations && (0,external_wp_element_namespaceObject.createElement)(block_transformations_menu, {
  23691. className: "block-editor-block-switcher__transforms__menugroup",
  23692. possibleBlockTransformations: possibleBlockTransformations,
  23693. blocks: blocks,
  23694. onSelect: name => {
  23695. onBlockTransform(name);
  23696. onClose();
  23697. }
  23698. }), hasBlockStyles && (0,external_wp_element_namespaceObject.createElement)(BlockStylesMenu, {
  23699. hoveredBlock: blocks[0],
  23700. onSwitch: onClose
  23701. }));
  23702. })));
  23703. };
  23704. const BlockSwitcher = _ref4 => {
  23705. let {
  23706. clientIds
  23707. } = _ref4;
  23708. const blocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlocksByClientId(clientIds), [clientIds]);
  23709. if (!blocks.length || blocks.some(block => !block)) {
  23710. return null;
  23711. }
  23712. return (0,external_wp_element_namespaceObject.createElement)(BlockSwitcherDropdownMenu, {
  23713. clientIds: clientIds,
  23714. blocks: blocks
  23715. });
  23716. };
  23717. /* harmony default export */ var block_switcher = (BlockSwitcher);
  23718. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/block-toolbar-last-item.js
  23719. /**
  23720. * WordPress dependencies
  23721. */
  23722. const {
  23723. Fill: __unstableBlockToolbarLastItem,
  23724. Slot: block_toolbar_last_item_Slot
  23725. } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableBlockToolbarLastItem');
  23726. __unstableBlockToolbarLastItem.Slot = block_toolbar_last_item_Slot;
  23727. /* harmony default export */ var block_toolbar_last_item = (__unstableBlockToolbarLastItem);
  23728. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-vertical.js
  23729. /**
  23730. * WordPress dependencies
  23731. */
  23732. const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  23733. xmlns: "http://www.w3.org/2000/svg",
  23734. viewBox: "0 0 24 24"
  23735. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  23736. d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
  23737. }));
  23738. /* harmony default export */ var more_vertical = (moreVertical);
  23739. ;// CONCATENATED MODULE: external ["wp","blob"]
  23740. var external_wp_blob_namespaceObject = window["wp"]["blob"];
  23741. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/pasting.js
  23742. /**
  23743. * WordPress dependencies
  23744. */
  23745. function getPasteEventData(_ref) {
  23746. let {
  23747. clipboardData
  23748. } = _ref;
  23749. let plainText = '';
  23750. let html = ''; // IE11 only supports `Text` as an argument for `getData` and will
  23751. // otherwise throw an invalid argument error, so we try the standard
  23752. // arguments first, then fallback to `Text` if they fail.
  23753. try {
  23754. plainText = clipboardData.getData('text/plain');
  23755. html = clipboardData.getData('text/html');
  23756. } catch (error1) {
  23757. try {
  23758. html = clipboardData.getData('Text');
  23759. } catch (error2) {
  23760. // Some browsers like UC Browser paste plain text by default and
  23761. // don't support clipboardData at all, so allow default
  23762. // behaviour.
  23763. return;
  23764. }
  23765. }
  23766. const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(clipboardData).filter(_ref2 => {
  23767. let {
  23768. type
  23769. } = _ref2;
  23770. return /^image\/(?:jpe?g|png|gif|webp)$/.test(type);
  23771. });
  23772. if (files.length && !shouldDismissPastedFiles(files, html, plainText)) {
  23773. html = files.map(file => `<img src="${(0,external_wp_blob_namespaceObject.createBlobURL)(file)}">`).join('');
  23774. plainText = '';
  23775. }
  23776. return {
  23777. html,
  23778. plainText
  23779. };
  23780. }
  23781. /**
  23782. * Given a collection of DataTransfer files and HTML and plain text strings,
  23783. * determine whether the files are to be dismissed in favor of the HTML.
  23784. *
  23785. * Certain office-type programs, like Microsoft Word or Apple Numbers,
  23786. * will, upon copy, generate a screenshot of the content being copied and
  23787. * attach it to the clipboard alongside the actual rich text that the user
  23788. * sought to copy. In those cases, we should let Gutenberg handle the rich text
  23789. * content and not the screenshot, since this allows Gutenberg to insert
  23790. * meaningful blocks, like paragraphs, lists or even tables.
  23791. *
  23792. * @param {File[]} files File objects obtained from a paste event
  23793. * @param {string} html HTML content obtained from a paste event
  23794. * @return {boolean} True if the files should be dismissed
  23795. */
  23796. function shouldDismissPastedFiles(files, html
  23797. /*, plainText */
  23798. ) {
  23799. // The question is only relevant when there is actual HTML content and when
  23800. // there is exactly one image file.
  23801. if (html && (files === null || files === void 0 ? void 0 : files.length) === 1 && files[0].type.indexOf('image/') === 0) {
  23802. var _html$match;
  23803. // A single <img> tag found in the HTML source suggests that the
  23804. // content being pasted revolves around an image. Sometimes there are
  23805. // other elements found, like <figure>, but we assume that the user's
  23806. // intention is to paste the actual image file.
  23807. const IMAGE_TAG = /<\s*img\b/gi;
  23808. return ((_html$match = html.match(IMAGE_TAG)) === null || _html$match === void 0 ? void 0 : _html$match.length) !== 1;
  23809. }
  23810. return false;
  23811. }
  23812. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/copy-handler/index.js
  23813. /**
  23814. * WordPress dependencies
  23815. */
  23816. /**
  23817. * Internal dependencies
  23818. */
  23819. function useNotifyCopy() {
  23820. const {
  23821. getBlockName
  23822. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  23823. const {
  23824. getBlockType
  23825. } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
  23826. const {
  23827. createSuccessNotice
  23828. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
  23829. return (0,external_wp_element_namespaceObject.useCallback)((eventType, selectedBlockClientIds) => {
  23830. let notice = '';
  23831. if (selectedBlockClientIds.length === 1) {
  23832. var _getBlockType;
  23833. const clientId = selectedBlockClientIds[0];
  23834. const title = (_getBlockType = getBlockType(getBlockName(clientId))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
  23835. notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: Name of the block being copied, e.g. "Paragraph".
  23836. (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".
  23837. (0,external_wp_i18n_namespaceObject.__)('Moved "%s" to clipboard.'), title);
  23838. } else {
  23839. notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of blocks being copied.
  23840. (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.
  23841. (0,external_wp_i18n_namespaceObject._n)('Moved %d block to clipboard.', 'Moved %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length);
  23842. }
  23843. createSuccessNotice(notice, {
  23844. type: 'snackbar'
  23845. });
  23846. }, []);
  23847. }
  23848. function useClipboardHandler() {
  23849. const {
  23850. getBlocksByClientId,
  23851. getSelectedBlockClientIds,
  23852. hasMultiSelection,
  23853. getSettings,
  23854. __unstableIsFullySelected,
  23855. __unstableIsSelectionCollapsed,
  23856. __unstableIsSelectionMergeable,
  23857. __unstableGetSelectedBlocksWithPartialSelection
  23858. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  23859. const {
  23860. flashBlock,
  23861. removeBlocks,
  23862. replaceBlocks,
  23863. __unstableDeleteSelection,
  23864. __unstableExpandSelection
  23865. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  23866. const notifyCopy = useNotifyCopy();
  23867. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  23868. function handler(event) {
  23869. const selectedBlockClientIds = getSelectedBlockClientIds();
  23870. if (selectedBlockClientIds.length === 0) {
  23871. return;
  23872. } // Always handle multiple selected blocks.
  23873. if (!hasMultiSelection()) {
  23874. const {
  23875. target
  23876. } = event;
  23877. const {
  23878. ownerDocument
  23879. } = target; // If copying, only consider actual text selection as selection.
  23880. // Otherwise, any focus on an input field is considered.
  23881. 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.
  23882. if (hasSelection) {
  23883. return;
  23884. }
  23885. }
  23886. if (!node.contains(event.target.ownerDocument.activeElement)) {
  23887. return;
  23888. }
  23889. const eventDefaultPrevented = event.defaultPrevented;
  23890. event.preventDefault();
  23891. const isSelectionMergeable = __unstableIsSelectionMergeable();
  23892. const shouldHandleWholeBlocks = __unstableIsSelectionCollapsed() || __unstableIsFullySelected();
  23893. const expandSelectionIsNeeded = !shouldHandleWholeBlocks && !isSelectionMergeable;
  23894. if (event.type === 'copy' || event.type === 'cut') {
  23895. if (selectedBlockClientIds.length === 1) {
  23896. flashBlock(selectedBlockClientIds[0]);
  23897. } // If we have a partial selection that is not mergeable, just
  23898. // expand the selection to the whole blocks.
  23899. if (expandSelectionIsNeeded) {
  23900. __unstableExpandSelection();
  23901. } else {
  23902. notifyCopy(event.type, selectedBlockClientIds);
  23903. let blocks; // Check if we have partial selection.
  23904. if (shouldHandleWholeBlocks) {
  23905. blocks = getBlocksByClientId(selectedBlockClientIds);
  23906. } else {
  23907. const [head, tail] = __unstableGetSelectedBlocksWithPartialSelection();
  23908. const inBetweenBlocks = getBlocksByClientId(selectedBlockClientIds.slice(1, selectedBlockClientIds.length - 1));
  23909. blocks = [head, ...inBetweenBlocks, tail];
  23910. }
  23911. const serialized = (0,external_wp_blocks_namespaceObject.serialize)(blocks);
  23912. event.clipboardData.setData('text/plain', serialized);
  23913. event.clipboardData.setData('text/html', serialized);
  23914. }
  23915. }
  23916. if (event.type === 'cut') {
  23917. // We need to also check if at the start we needed to
  23918. // expand the selection, as in this point we might have
  23919. // programmatically fully selected the blocks above.
  23920. if (shouldHandleWholeBlocks && !expandSelectionIsNeeded) {
  23921. removeBlocks(selectedBlockClientIds);
  23922. } else {
  23923. __unstableDeleteSelection();
  23924. }
  23925. } else if (event.type === 'paste') {
  23926. if (eventDefaultPrevented) {
  23927. // This was likely already handled in rich-text/use-paste-handler.js.
  23928. return;
  23929. }
  23930. const {
  23931. __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML
  23932. } = getSettings();
  23933. const {
  23934. plainText,
  23935. html
  23936. } = getPasteEventData(event);
  23937. const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({
  23938. HTML: html,
  23939. plainText,
  23940. mode: 'BLOCKS',
  23941. canUserUseUnfilteredHTML
  23942. });
  23943. replaceBlocks(selectedBlockClientIds, blocks, blocks.length - 1, -1);
  23944. }
  23945. }
  23946. node.ownerDocument.addEventListener('copy', handler);
  23947. node.ownerDocument.addEventListener('cut', handler);
  23948. node.ownerDocument.addEventListener('paste', handler);
  23949. return () => {
  23950. node.ownerDocument.removeEventListener('copy', handler);
  23951. node.ownerDocument.removeEventListener('cut', handler);
  23952. node.ownerDocument.removeEventListener('paste', handler);
  23953. };
  23954. }, []);
  23955. }
  23956. function CopyHandler(_ref) {
  23957. let {
  23958. children
  23959. } = _ref;
  23960. return (0,external_wp_element_namespaceObject.createElement)("div", {
  23961. ref: useClipboardHandler()
  23962. }, children);
  23963. }
  23964. /**
  23965. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/copy-handler/README.md
  23966. */
  23967. /* harmony default export */ var copy_handler = (CopyHandler);
  23968. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-actions/index.js
  23969. /**
  23970. * External dependencies
  23971. */
  23972. /**
  23973. * WordPress dependencies
  23974. */
  23975. /**
  23976. * Internal dependencies
  23977. */
  23978. function BlockActions(_ref) {
  23979. let {
  23980. clientIds,
  23981. children,
  23982. __experimentalUpdateSelection: updateSelection
  23983. } = _ref;
  23984. const {
  23985. canInsertBlockType,
  23986. getBlockRootClientId,
  23987. getBlocksByClientId,
  23988. canMoveBlocks,
  23989. canRemoveBlocks
  23990. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  23991. const {
  23992. getDefaultBlockName,
  23993. getGroupingBlockName
  23994. } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
  23995. const blocks = getBlocksByClientId(clientIds);
  23996. const rootClientId = getBlockRootClientId(clientIds[0]);
  23997. const canDuplicate = (0,external_lodash_namespaceObject.every)(blocks, block => {
  23998. return !!block && (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'multiple', true) && canInsertBlockType(block.name, rootClientId);
  23999. });
  24000. const canInsertDefaultBlock = canInsertBlockType(getDefaultBlockName(), rootClientId);
  24001. const canMove = canMoveBlocks(clientIds, rootClientId);
  24002. const canRemove = canRemoveBlocks(clientIds, rootClientId);
  24003. const {
  24004. removeBlocks,
  24005. replaceBlocks,
  24006. duplicateBlocks,
  24007. insertAfterBlock,
  24008. insertBeforeBlock,
  24009. flashBlock,
  24010. setBlockMovingClientId,
  24011. setNavigationMode,
  24012. selectBlock
  24013. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  24014. const notifyCopy = useNotifyCopy();
  24015. return children({
  24016. canDuplicate,
  24017. canInsertDefaultBlock,
  24018. canMove,
  24019. canRemove,
  24020. rootClientId,
  24021. blocks,
  24022. onDuplicate() {
  24023. return duplicateBlocks(clientIds, updateSelection);
  24024. },
  24025. onRemove() {
  24026. return removeBlocks(clientIds, updateSelection);
  24027. },
  24028. onInsertBefore() {
  24029. insertBeforeBlock((0,external_lodash_namespaceObject.first)((0,external_lodash_namespaceObject.castArray)(clientIds)));
  24030. },
  24031. onInsertAfter() {
  24032. insertAfterBlock((0,external_lodash_namespaceObject.last)((0,external_lodash_namespaceObject.castArray)(clientIds)));
  24033. },
  24034. onMoveTo() {
  24035. setNavigationMode(true);
  24036. selectBlock(clientIds[0]);
  24037. setBlockMovingClientId(clientIds[0]);
  24038. },
  24039. onGroup() {
  24040. if (!blocks.length) {
  24041. return;
  24042. }
  24043. const groupingBlockName = getGroupingBlockName(); // Activate the `transform` on `core/group` which does the conversion.
  24044. const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, groupingBlockName);
  24045. if (!newBlocks) {
  24046. return;
  24047. }
  24048. replaceBlocks(clientIds, newBlocks);
  24049. },
  24050. onUngroup() {
  24051. if (!blocks.length) {
  24052. return;
  24053. }
  24054. const innerBlocks = blocks[0].innerBlocks;
  24055. if (!innerBlocks.length) {
  24056. return;
  24057. }
  24058. replaceBlocks(clientIds, innerBlocks);
  24059. },
  24060. onCopy() {
  24061. const selectedBlockClientIds = blocks.map(_ref2 => {
  24062. let {
  24063. clientId
  24064. } = _ref2;
  24065. return clientId;
  24066. });
  24067. if (blocks.length === 1) {
  24068. flashBlock(selectedBlockClientIds[0]);
  24069. }
  24070. notifyCopy('copy', selectedBlockClientIds);
  24071. }
  24072. });
  24073. }
  24074. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-mode-toggle.js
  24075. /**
  24076. * External dependencies
  24077. */
  24078. /**
  24079. * WordPress dependencies
  24080. */
  24081. /**
  24082. * Internal dependencies
  24083. */
  24084. function BlockModeToggle(_ref) {
  24085. let {
  24086. blockType,
  24087. mode,
  24088. onToggleMode,
  24089. small = false,
  24090. isCodeEditingEnabled = true
  24091. } = _ref;
  24092. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'html', true) || !isCodeEditingEnabled) {
  24093. return null;
  24094. }
  24095. const label = mode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Edit as HTML') : (0,external_wp_i18n_namespaceObject.__)('Edit visually');
  24096. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  24097. onClick: onToggleMode
  24098. }, !small && label);
  24099. }
  24100. /* harmony default export */ var block_mode_toggle = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => {
  24101. let {
  24102. clientId
  24103. } = _ref2;
  24104. const {
  24105. getBlock,
  24106. getBlockMode,
  24107. getSettings
  24108. } = select(store);
  24109. const block = getBlock(clientId);
  24110. const isCodeEditingEnabled = getSettings().codeEditingEnabled;
  24111. return {
  24112. mode: getBlockMode(clientId),
  24113. blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
  24114. isCodeEditingEnabled
  24115. };
  24116. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref3) => {
  24117. let {
  24118. onToggle = external_lodash_namespaceObject.noop,
  24119. clientId
  24120. } = _ref3;
  24121. return {
  24122. onToggleMode() {
  24123. dispatch(store).toggleBlockMode(clientId);
  24124. onToggle();
  24125. }
  24126. };
  24127. })])(BlockModeToggle));
  24128. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-convert-button.js
  24129. /**
  24130. * WordPress dependencies
  24131. */
  24132. function BlockConvertButton(_ref) {
  24133. let {
  24134. shouldRender,
  24135. onClick,
  24136. small
  24137. } = _ref;
  24138. if (!shouldRender) {
  24139. return null;
  24140. }
  24141. const label = (0,external_wp_i18n_namespaceObject.__)('Convert to Blocks');
  24142. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  24143. onClick: onClick
  24144. }, !small && label);
  24145. }
  24146. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-html-convert-button.js
  24147. /**
  24148. * WordPress dependencies
  24149. */
  24150. /**
  24151. * Internal dependencies
  24152. */
  24153. /* harmony default export */ var block_html_convert_button = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, _ref) => {
  24154. let {
  24155. clientId
  24156. } = _ref;
  24157. const block = select(store).getBlock(clientId);
  24158. return {
  24159. block,
  24160. shouldRender: block && block.name === 'core/html'
  24161. };
  24162. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref2) => {
  24163. let {
  24164. block
  24165. } = _ref2;
  24166. return {
  24167. onClick: () => dispatch(store).replaceBlocks(block.clientId, (0,external_wp_blocks_namespaceObject.rawHandler)({
  24168. HTML: (0,external_wp_blocks_namespaceObject.getBlockContent)(block)
  24169. }))
  24170. };
  24171. }))(BlockConvertButton));
  24172. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-menu-first-item.js
  24173. /**
  24174. * WordPress dependencies
  24175. */
  24176. const {
  24177. Fill: __unstableBlockSettingsMenuFirstItem,
  24178. Slot: block_settings_menu_first_item_Slot
  24179. } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableBlockSettingsMenuFirstItem');
  24180. __unstableBlockSettingsMenuFirstItem.Slot = block_settings_menu_first_item_Slot;
  24181. /* harmony default export */ var block_settings_menu_first_item = (__unstableBlockSettingsMenuFirstItem);
  24182. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/index.js
  24183. /**
  24184. * WordPress dependencies
  24185. */
  24186. /**
  24187. * Internal dependencies
  24188. */
  24189. function ConvertToGroupButton(_ref) {
  24190. let {
  24191. clientIds,
  24192. isGroupable,
  24193. isUngroupable,
  24194. blocksSelection,
  24195. groupingBlockName,
  24196. onClose = () => {}
  24197. } = _ref;
  24198. const {
  24199. replaceBlocks
  24200. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  24201. const onConvertToGroup = () => {
  24202. // Activate the `transform` on the Grouping Block which does the conversion.
  24203. const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocksSelection, groupingBlockName);
  24204. if (newBlocks) {
  24205. replaceBlocks(clientIds, newBlocks);
  24206. }
  24207. };
  24208. const onConvertFromGroup = () => {
  24209. const innerBlocks = blocksSelection[0].innerBlocks;
  24210. if (!innerBlocks.length) {
  24211. return;
  24212. }
  24213. replaceBlocks(clientIds, innerBlocks);
  24214. };
  24215. if (!isGroupable && !isUngroupable) {
  24216. return null;
  24217. }
  24218. 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, {
  24219. onClick: () => {
  24220. onConvertToGroup();
  24221. onClose();
  24222. }
  24223. }, (0,external_wp_i18n_namespaceObject._x)('Group', 'verb')), isUngroupable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  24224. onClick: () => {
  24225. onConvertFromGroup();
  24226. onClose();
  24227. }
  24228. }, (0,external_wp_i18n_namespaceObject._x)('Ungroup', 'Ungrouping blocks from within a Group block back into individual blocks within the Editor ')));
  24229. }
  24230. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js
  24231. /**
  24232. * WordPress dependencies
  24233. */
  24234. /**
  24235. * Internal dependencies
  24236. */
  24237. /**
  24238. * Contains the properties `ConvertToGroupButton` component needs.
  24239. *
  24240. * @typedef {Object} ConvertToGroupButtonProps
  24241. * @property {string[]} clientIds An array of the selected client ids.
  24242. * @property {boolean} isGroupable Indicates if the selected blocks can be grouped.
  24243. * @property {boolean} isUngroupable Indicates if the selected blocks can be ungrouped.
  24244. * @property {WPBlock[]} blocksSelection An array of the selected blocks.
  24245. * @property {string} groupingBlockName The name of block used for handling grouping interactions.
  24246. */
  24247. /**
  24248. * Returns the properties `ConvertToGroupButton` component needs to work properly.
  24249. * It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton`
  24250. * should be rendered, to avoid ending up with an empty MenuGroup.
  24251. *
  24252. * @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.
  24253. */
  24254. function useConvertToGroupButtonProps() {
  24255. const {
  24256. clientIds,
  24257. isGroupable,
  24258. isUngroupable,
  24259. blocksSelection,
  24260. groupingBlockName
  24261. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  24262. var _blocksSelection$;
  24263. const {
  24264. getBlockRootClientId,
  24265. getBlocksByClientId,
  24266. canInsertBlockType,
  24267. getSelectedBlockClientIds
  24268. } = select(store);
  24269. const {
  24270. getGroupingBlockName
  24271. } = select(external_wp_blocks_namespaceObject.store);
  24272. const _clientIds = getSelectedBlockClientIds();
  24273. const _groupingBlockName = getGroupingBlockName();
  24274. const rootClientId = !!(_clientIds !== null && _clientIds !== void 0 && _clientIds.length) ? getBlockRootClientId(_clientIds[0]) : undefined;
  24275. const groupingBlockAvailable = canInsertBlockType(_groupingBlockName, rootClientId);
  24276. const _blocksSelection = getBlocksByClientId(_clientIds);
  24277. const isSingleGroupingBlock = _blocksSelection.length === 1 && ((_blocksSelection$ = _blocksSelection[0]) === null || _blocksSelection$ === void 0 ? void 0 : _blocksSelection$.name) === _groupingBlockName; // Do we have
  24278. // 1. Grouping block available to be inserted?
  24279. // 2. One or more blocks selected
  24280. const _isGroupable = groupingBlockAvailable && _blocksSelection.length; // Do we have a single Group Block selected and does that group have inner blocks?
  24281. const _isUngroupable = isSingleGroupingBlock && !!_blocksSelection[0].innerBlocks.length;
  24282. return {
  24283. clientIds: _clientIds,
  24284. isGroupable: _isGroupable,
  24285. isUngroupable: _isUngroupable,
  24286. blocksSelection: _blocksSelection,
  24287. groupingBlockName: _groupingBlockName
  24288. };
  24289. }, []);
  24290. return {
  24291. clientIds,
  24292. isGroupable,
  24293. isUngroupable,
  24294. blocksSelection,
  24295. groupingBlockName
  24296. };
  24297. }
  24298. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/unlock.js
  24299. /**
  24300. * WordPress dependencies
  24301. */
  24302. const unlock = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  24303. viewBox: "0 0 24 24",
  24304. xmlns: "http://www.w3.org/2000/svg"
  24305. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  24306. 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"
  24307. }));
  24308. /* harmony default export */ var library_unlock = (unlock);
  24309. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/lock.js
  24310. /**
  24311. * WordPress dependencies
  24312. */
  24313. const lock = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  24314. viewBox: "0 0 24 24",
  24315. xmlns: "http://www.w3.org/2000/svg"
  24316. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  24317. 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"
  24318. }));
  24319. /* harmony default export */ var library_lock = (lock);
  24320. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/use-block-lock.js
  24321. /**
  24322. * WordPress dependencies
  24323. */
  24324. /**
  24325. * Internal dependencies
  24326. */
  24327. /**
  24328. * Return details about the block lock status.
  24329. *
  24330. * @param {string} clientId The block client Id.
  24331. *
  24332. * @return {Object} Block lock status
  24333. */
  24334. function useBlockLock(clientId) {
  24335. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  24336. const {
  24337. canMoveBlock,
  24338. canRemoveBlock,
  24339. canLockBlockType,
  24340. getBlockName,
  24341. getBlockRootClientId
  24342. } = select(store);
  24343. const rootClientId = getBlockRootClientId(clientId);
  24344. const canMove = canMoveBlock(clientId, rootClientId);
  24345. const canRemove = canRemoveBlock(clientId, rootClientId);
  24346. return {
  24347. canMove,
  24348. canRemove,
  24349. canLock: canLockBlockType(getBlockName(clientId)),
  24350. isLocked: !canMove || !canRemove
  24351. };
  24352. }, [clientId]);
  24353. }
  24354. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/modal.js
  24355. /**
  24356. * WordPress dependencies
  24357. */
  24358. /**
  24359. * Internal dependencies
  24360. */
  24361. function BlockLockModal(_ref) {
  24362. let {
  24363. clientId,
  24364. onClose
  24365. } = _ref;
  24366. const [lock, setLock] = (0,external_wp_element_namespaceObject.useState)({
  24367. move: false,
  24368. remove: false
  24369. });
  24370. const {
  24371. canMove,
  24372. canRemove
  24373. } = useBlockLock(clientId);
  24374. const {
  24375. updateBlockAttributes
  24376. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  24377. const blockInformation = useBlockDisplayInformation(clientId);
  24378. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockLockModal, 'block-editor-block-lock-modal__options-title');
  24379. (0,external_wp_element_namespaceObject.useEffect)(() => {
  24380. setLock({
  24381. move: !canMove,
  24382. remove: !canRemove
  24383. });
  24384. }, [canMove, canRemove]);
  24385. const isAllChecked = Object.values(lock).every(Boolean);
  24386. const isMixed = Object.values(lock).some(Boolean) && !isAllChecked;
  24387. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
  24388. title: (0,external_wp_i18n_namespaceObject.sprintf)(
  24389. /* translators: %s: Name of the block. */
  24390. (0,external_wp_i18n_namespaceObject.__)('Lock %s'), blockInformation.title),
  24391. overlayClassName: "block-editor-block-lock-modal",
  24392. closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
  24393. onRequestClose: onClose
  24394. }, (0,external_wp_element_namespaceObject.createElement)("form", {
  24395. onSubmit: event => {
  24396. event.preventDefault();
  24397. updateBlockAttributes([clientId], {
  24398. lock
  24399. });
  24400. onClose();
  24401. }
  24402. }, (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)("div", {
  24403. role: "group",
  24404. "aria-labelledby": instanceId,
  24405. className: "block-editor-block-lock-modal__options"
  24406. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  24407. className: "block-editor-block-lock-modal__options-title",
  24408. label: (0,external_wp_element_namespaceObject.createElement)("span", {
  24409. id: instanceId
  24410. }, (0,external_wp_i18n_namespaceObject.__)('Lock all')),
  24411. checked: isAllChecked,
  24412. indeterminate: isMixed,
  24413. onChange: newValue => setLock({
  24414. move: newValue,
  24415. remove: newValue
  24416. })
  24417. }), (0,external_wp_element_namespaceObject.createElement)("ul", {
  24418. className: "block-editor-block-lock-modal__checklist"
  24419. }, (0,external_wp_element_namespaceObject.createElement)("li", {
  24420. className: "block-editor-block-lock-modal__checklist-item"
  24421. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  24422. 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, {
  24423. icon: lock.move ? library_lock : library_unlock
  24424. })),
  24425. checked: lock.move,
  24426. onChange: move => setLock(prevLock => ({ ...prevLock,
  24427. move
  24428. }))
  24429. })), (0,external_wp_element_namespaceObject.createElement)("li", {
  24430. className: "block-editor-block-lock-modal__checklist-item"
  24431. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  24432. 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, {
  24433. icon: lock.remove ? library_lock : library_unlock
  24434. })),
  24435. checked: lock.remove,
  24436. onChange: remove => setLock(prevLock => ({ ...prevLock,
  24437. remove
  24438. }))
  24439. })))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
  24440. className: "block-editor-block-lock-modal__actions",
  24441. justify: "flex-end",
  24442. expanded: false
  24443. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  24444. variant: "tertiary",
  24445. onClick: onClose
  24446. }, (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, {
  24447. variant: "primary",
  24448. type: "submit"
  24449. }, (0,external_wp_i18n_namespaceObject.__)('Apply'))))));
  24450. }
  24451. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/menu-item.js
  24452. /**
  24453. * WordPress dependencies
  24454. */
  24455. /**
  24456. * Internal dependencies
  24457. */
  24458. function BlockLockMenuItem(_ref) {
  24459. let {
  24460. clientId
  24461. } = _ref;
  24462. const {
  24463. canLock,
  24464. isLocked
  24465. } = useBlockLock(clientId);
  24466. const [isModalOpen, toggleModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false);
  24467. if (!canLock) {
  24468. return null;
  24469. }
  24470. const label = isLocked ? (0,external_wp_i18n_namespaceObject.__)('Unlock') : (0,external_wp_i18n_namespaceObject.__)('Lock');
  24471. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  24472. icon: isLocked ? library_unlock : library_lock,
  24473. onClick: toggleModal
  24474. }, label), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(BlockLockModal, {
  24475. clientId: clientId,
  24476. onClose: toggleModal
  24477. }));
  24478. }
  24479. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu-controls/index.js
  24480. /**
  24481. * External dependencies
  24482. */
  24483. /**
  24484. * WordPress dependencies
  24485. */
  24486. /**
  24487. * Internal dependencies
  24488. */
  24489. const {
  24490. Fill,
  24491. Slot: block_settings_menu_controls_Slot
  24492. } = (0,external_wp_components_namespaceObject.createSlotFill)('BlockSettingsMenuControls');
  24493. const BlockSettingsMenuControlsSlot = _ref => {
  24494. let {
  24495. fillProps,
  24496. clientIds = null
  24497. } = _ref;
  24498. const {
  24499. selectedBlocks,
  24500. selectedClientIds,
  24501. canRemove
  24502. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  24503. const {
  24504. getBlocksByClientId,
  24505. getSelectedBlockClientIds,
  24506. canRemoveBlocks
  24507. } = select(store);
  24508. const ids = clientIds !== null ? clientIds : getSelectedBlockClientIds();
  24509. return {
  24510. selectedBlocks: (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.compact)(getBlocksByClientId(ids)), block => block.name),
  24511. selectedClientIds: ids,
  24512. canRemove: canRemoveBlocks(ids)
  24513. };
  24514. }, [clientIds]);
  24515. const showLockButton = selectedClientIds.length === 1; // Check if current selection of blocks is Groupable or Ungroupable
  24516. // and pass this props down to ConvertToGroupButton.
  24517. const convertToGroupButtonProps = useConvertToGroupButtonProps();
  24518. const {
  24519. isGroupable,
  24520. isUngroupable
  24521. } = convertToGroupButtonProps;
  24522. const showConvertToGroupButton = (isGroupable || isUngroupable) && canRemove;
  24523. return (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls_Slot, {
  24524. fillProps: { ...fillProps,
  24525. selectedBlocks,
  24526. selectedClientIds
  24527. }
  24528. }, fills => {
  24529. if (!(fills !== null && fills !== void 0 && fills.length) > 0 && !showConvertToGroupButton && !showLockButton) {
  24530. return null;
  24531. }
  24532. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, showLockButton && (0,external_wp_element_namespaceObject.createElement)(BlockLockMenuItem, {
  24533. clientId: selectedClientIds[0]
  24534. }), fills, showConvertToGroupButton && (0,external_wp_element_namespaceObject.createElement)(ConvertToGroupButton, _extends({}, convertToGroupButtonProps, {
  24535. onClose: fillProps === null || fillProps === void 0 ? void 0 : fillProps.onClose
  24536. })));
  24537. });
  24538. };
  24539. /**
  24540. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-settings-menu-controls/README.md
  24541. *
  24542. * @param {Object} props Fill props.
  24543. * @return {WPElement} Element.
  24544. */
  24545. function BlockSettingsMenuControls(_ref2) {
  24546. let { ...props
  24547. } = _ref2;
  24548. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
  24549. document: document
  24550. }, (0,external_wp_element_namespaceObject.createElement)(Fill, props));
  24551. }
  24552. BlockSettingsMenuControls.Slot = BlockSettingsMenuControlsSlot;
  24553. /* harmony default export */ var block_settings_menu_controls = (BlockSettingsMenuControls);
  24554. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-dropdown.js
  24555. /**
  24556. * External dependencies
  24557. */
  24558. /**
  24559. * WordPress dependencies
  24560. */
  24561. /**
  24562. * Internal dependencies
  24563. */
  24564. const block_settings_dropdown_POPOVER_PROPS = {
  24565. className: 'block-editor-block-settings-menu__popover',
  24566. position: 'bottom right',
  24567. isAlternate: true
  24568. };
  24569. function CopyMenuItem(_ref) {
  24570. let {
  24571. blocks,
  24572. onCopy
  24573. } = _ref;
  24574. const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(() => (0,external_wp_blocks_namespaceObject.serialize)(blocks), onCopy);
  24575. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  24576. ref: ref
  24577. }, (0,external_wp_i18n_namespaceObject.__)('Copy'));
  24578. }
  24579. function BlockSettingsDropdown(_ref2) {
  24580. let {
  24581. clientIds,
  24582. __experimentalSelectBlock,
  24583. children,
  24584. ...props
  24585. } = _ref2;
  24586. const blockClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
  24587. const count = blockClientIds.length;
  24588. const firstBlockClientId = blockClientIds[0];
  24589. const {
  24590. firstParentClientId,
  24591. hasReducedUI,
  24592. onlyBlock,
  24593. parentBlockType,
  24594. previousBlockClientId,
  24595. nextBlockClientId,
  24596. selectedBlockClientIds
  24597. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  24598. const {
  24599. getBlockCount,
  24600. getBlockName,
  24601. getBlockParents,
  24602. getPreviousBlockClientId,
  24603. getNextBlockClientId,
  24604. getSelectedBlockClientIds,
  24605. getSettings
  24606. } = select(store);
  24607. const parents = getBlockParents(firstBlockClientId);
  24608. const _firstParentClientId = parents[parents.length - 1];
  24609. const parentBlockName = getBlockName(_firstParentClientId);
  24610. return {
  24611. firstParentClientId: _firstParentClientId,
  24612. hasReducedUI: getSettings().hasReducedUI,
  24613. onlyBlock: 1 === getBlockCount(),
  24614. parentBlockType: (0,external_wp_blocks_namespaceObject.getBlockType)(parentBlockName),
  24615. previousBlockClientId: getPreviousBlockClientId(firstBlockClientId),
  24616. nextBlockClientId: getNextBlockClientId(firstBlockClientId),
  24617. selectedBlockClientIds: getSelectedBlockClientIds()
  24618. };
  24619. }, [firstBlockClientId]);
  24620. const shortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
  24621. const {
  24622. getShortcutRepresentation
  24623. } = select(external_wp_keyboardShortcuts_namespaceObject.store);
  24624. return {
  24625. duplicate: getShortcutRepresentation('core/block-editor/duplicate'),
  24626. remove: getShortcutRepresentation('core/block-editor/remove'),
  24627. insertAfter: getShortcutRepresentation('core/block-editor/insert-after'),
  24628. insertBefore: getShortcutRepresentation('core/block-editor/insert-before')
  24629. };
  24630. }, []);
  24631. const {
  24632. selectBlock,
  24633. toggleBlockHighlight
  24634. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  24635. const updateSelectionAfterDuplicate = (0,external_wp_element_namespaceObject.useCallback)(__experimentalSelectBlock ? async clientIdsPromise => {
  24636. const ids = await clientIdsPromise;
  24637. if (ids && ids[0]) {
  24638. __experimentalSelectBlock(ids[0]);
  24639. }
  24640. } : external_lodash_namespaceObject.noop, [__experimentalSelectBlock]);
  24641. const blockTitle = useBlockDisplayTitle(firstBlockClientId, 25);
  24642. const updateSelectionAfterRemove = (0,external_wp_element_namespaceObject.useCallback)(__experimentalSelectBlock ? () => {
  24643. const blockToSelect = previousBlockClientId || nextBlockClientId;
  24644. if (blockToSelect && // From the block options dropdown, it's possible to remove a block that is not selected,
  24645. // in this case, it's not necessary to update the selection since the selected block wasn't removed.
  24646. selectedBlockClientIds.includes(firstBlockClientId) && // Don't update selection when next/prev block also is in the selection ( and gets removed ),
  24647. // In case someone selects all blocks and removes them at once.
  24648. !selectedBlockClientIds.includes(blockToSelect)) {
  24649. __experimentalSelectBlock(blockToSelect);
  24650. }
  24651. } : external_lodash_namespaceObject.noop, [__experimentalSelectBlock, previousBlockClientId, nextBlockClientId, selectedBlockClientIds]);
  24652. const label = (0,external_wp_i18n_namespaceObject.sprintf)(
  24653. /* translators: %s: block name */
  24654. (0,external_wp_i18n_namespaceObject.__)('Remove %s'), blockTitle);
  24655. const removeBlockLabel = count === 1 ? label : (0,external_wp_i18n_namespaceObject.__)('Remove blocks'); // Allows highlighting the parent block outline when focusing or hovering
  24656. // the parent block selector within the child.
  24657. const selectParentButtonRef = (0,external_wp_element_namespaceObject.useRef)();
  24658. const {
  24659. gestures: showParentOutlineGestures
  24660. } = useShowMoversGestures({
  24661. ref: selectParentButtonRef,
  24662. onChange(isFocused) {
  24663. if (isFocused && hasReducedUI) {
  24664. return;
  24665. }
  24666. toggleBlockHighlight(firstParentClientId, isFocused);
  24667. }
  24668. });
  24669. return (0,external_wp_element_namespaceObject.createElement)(BlockActions, {
  24670. clientIds: clientIds,
  24671. __experimentalUpdateSelection: !__experimentalSelectBlock
  24672. }, _ref3 => {
  24673. let {
  24674. canDuplicate,
  24675. canInsertDefaultBlock,
  24676. canMove,
  24677. canRemove,
  24678. onDuplicate,
  24679. onInsertAfter,
  24680. onInsertBefore,
  24681. onRemove,
  24682. onCopy,
  24683. onMoveTo,
  24684. blocks
  24685. } = _ref3;
  24686. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, _extends({
  24687. icon: more_vertical,
  24688. label: (0,external_wp_i18n_namespaceObject.__)('Options'),
  24689. className: "block-editor-block-settings-menu",
  24690. popoverProps: block_settings_dropdown_POPOVER_PROPS,
  24691. noIcons: true
  24692. }, props), _ref4 => {
  24693. let {
  24694. onClose
  24695. } = _ref4;
  24696. 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, {
  24697. fillProps: {
  24698. onClose
  24699. }
  24700. }), firstParentClientId !== undefined && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, _extends({}, showParentOutlineGestures, {
  24701. ref: selectParentButtonRef,
  24702. icon: (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  24703. icon: parentBlockType.icon
  24704. }),
  24705. onClick: () => selectBlock(firstParentClientId)
  24706. }), (0,external_wp_i18n_namespaceObject.sprintf)(
  24707. /* translators: %s: Name of the block's parent. */
  24708. (0,external_wp_i18n_namespaceObject.__)('Select parent block (%s)'), parentBlockType.title)), count === 1 && (0,external_wp_element_namespaceObject.createElement)(block_html_convert_button, {
  24709. clientId: firstBlockClientId
  24710. }), (0,external_wp_element_namespaceObject.createElement)(CopyMenuItem, {
  24711. blocks: blocks,
  24712. onCopy: onCopy
  24713. }), canDuplicate && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  24714. onClick: (0,external_lodash_namespaceObject.flow)(onClose, onDuplicate, updateSelectionAfterDuplicate),
  24715. shortcut: shortcuts.duplicate
  24716. }, (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, {
  24717. onClick: (0,external_lodash_namespaceObject.flow)(onClose, onInsertBefore),
  24718. shortcut: shortcuts.insertBefore
  24719. }, (0,external_wp_i18n_namespaceObject.__)('Insert before')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  24720. onClick: (0,external_lodash_namespaceObject.flow)(onClose, onInsertAfter),
  24721. shortcut: shortcuts.insertAfter
  24722. }, (0,external_wp_i18n_namespaceObject.__)('Insert after'))), canMove && !onlyBlock && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  24723. onClick: (0,external_lodash_namespaceObject.flow)(onClose, onMoveTo)
  24724. }, (0,external_wp_i18n_namespaceObject.__)('Move to')), count === 1 && (0,external_wp_element_namespaceObject.createElement)(block_mode_toggle, {
  24725. clientId: firstBlockClientId,
  24726. onToggle: onClose
  24727. })), (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls.Slot, {
  24728. fillProps: {
  24729. onClose
  24730. },
  24731. clientIds: clientIds
  24732. }), typeof children === 'function' ? children({
  24733. onClose
  24734. }) : external_wp_element_namespaceObject.Children.map(child => (0,external_wp_element_namespaceObject.cloneElement)(child, {
  24735. onClose
  24736. })), canRemove && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  24737. onClick: (0,external_lodash_namespaceObject.flow)(onClose, onRemove, updateSelectionAfterRemove),
  24738. shortcut: shortcuts.remove
  24739. }, removeBlockLabel)));
  24740. });
  24741. });
  24742. }
  24743. /* harmony default export */ var block_settings_dropdown = (BlockSettingsDropdown);
  24744. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/index.js
  24745. /**
  24746. * WordPress dependencies
  24747. */
  24748. /**
  24749. * Internal dependencies
  24750. */
  24751. function BlockSettingsMenu(_ref) {
  24752. let {
  24753. clientIds,
  24754. ...props
  24755. } = _ref;
  24756. 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({
  24757. clientIds: clientIds,
  24758. toggleProps: toggleProps
  24759. }, props))));
  24760. }
  24761. /* harmony default export */ var block_settings_menu = (BlockSettingsMenu);
  24762. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/toolbar.js
  24763. /**
  24764. * WordPress dependencies
  24765. */
  24766. /**
  24767. * Internal dependencies
  24768. */
  24769. function BlockLockToolbar(_ref) {
  24770. let {
  24771. clientId
  24772. } = _ref;
  24773. const blockInformation = useBlockDisplayInformation(clientId);
  24774. const {
  24775. canMove,
  24776. canRemove,
  24777. canLock
  24778. } = useBlockLock(clientId);
  24779. const [isModalOpen, toggleModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false);
  24780. if (!canLock) {
  24781. return null;
  24782. }
  24783. if (canMove && canRemove) {
  24784. return null;
  24785. }
  24786. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
  24787. className: "block-editor-block-lock-toolbar"
  24788. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  24789. icon: library_lock,
  24790. label: (0,external_wp_i18n_namespaceObject.sprintf)(
  24791. /* translators: %s: block name */
  24792. (0,external_wp_i18n_namespaceObject.__)('Unlock %s'), blockInformation.title),
  24793. onClick: toggleModal
  24794. })), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(BlockLockModal, {
  24795. clientId: clientId,
  24796. onClose: toggleModal
  24797. }));
  24798. }
  24799. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/group.js
  24800. /**
  24801. * WordPress dependencies
  24802. */
  24803. const group_group = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  24804. viewBox: "0 0 24 24",
  24805. xmlns: "http://www.w3.org/2000/svg"
  24806. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  24807. 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"
  24808. }));
  24809. /* harmony default export */ var library_group = (group_group);
  24810. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/row.js
  24811. /**
  24812. * WordPress dependencies
  24813. */
  24814. const row = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  24815. xmlns: "http://www.w3.org/2000/svg",
  24816. viewBox: "0 0 24 24"
  24817. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  24818. 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"
  24819. }));
  24820. /* harmony default export */ var library_row = (row);
  24821. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stack.js
  24822. /**
  24823. * WordPress dependencies
  24824. */
  24825. const stack = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  24826. xmlns: "http://www.w3.org/2000/svg",
  24827. viewBox: "0 0 24 24"
  24828. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  24829. 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"
  24830. }));
  24831. /* harmony default export */ var library_stack = (stack);
  24832. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/toolbar.js
  24833. /**
  24834. * WordPress dependencies
  24835. */
  24836. /**
  24837. * Internal dependencies
  24838. */
  24839. const layouts = {
  24840. group: undefined,
  24841. row: {
  24842. type: 'flex',
  24843. flexWrap: 'nowrap'
  24844. },
  24845. stack: {
  24846. type: 'flex',
  24847. orientation: 'vertical'
  24848. }
  24849. };
  24850. function BlockGroupToolbar() {
  24851. const {
  24852. blocksSelection,
  24853. clientIds,
  24854. groupingBlockName,
  24855. isGroupable
  24856. } = useConvertToGroupButtonProps();
  24857. const {
  24858. replaceBlocks
  24859. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  24860. const {
  24861. canRemove
  24862. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  24863. const {
  24864. canRemoveBlocks
  24865. } = select(store);
  24866. return {
  24867. canRemove: canRemoveBlocks(clientIds)
  24868. };
  24869. }, [clientIds]);
  24870. const onConvertToGroup = function () {
  24871. let layout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'group';
  24872. const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocksSelection, groupingBlockName);
  24873. if (newBlocks && newBlocks.length > 0) {
  24874. // Because the block is not in the store yet we can't use
  24875. // updateBlockAttributes so need to manually update attributes.
  24876. newBlocks[0].attributes.layout = layouts[layout];
  24877. replaceBlocks(clientIds, newBlocks);
  24878. }
  24879. };
  24880. const onConvertToRow = () => onConvertToGroup('row');
  24881. const onConvertToStack = () => onConvertToGroup('stack'); // Don't render the button if the current selection cannot be grouped.
  24882. // A good example is selecting multiple button blocks within a Buttons block:
  24883. // The group block is not a valid child of Buttons, so we should not show the button.
  24884. // Any blocks that are locked against removal also cannot be grouped.
  24885. if (!isGroupable || !canRemove) {
  24886. return null;
  24887. }
  24888. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  24889. icon: library_group,
  24890. label: (0,external_wp_i18n_namespaceObject._x)('Group', 'verb'),
  24891. onClick: onConvertToGroup
  24892. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  24893. icon: library_row,
  24894. label: (0,external_wp_i18n_namespaceObject._x)('Row', 'single horizontal line'),
  24895. onClick: onConvertToRow
  24896. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  24897. icon: library_stack,
  24898. label: (0,external_wp_i18n_namespaceObject._x)('Stack', 'verb'),
  24899. onClick: onConvertToStack
  24900. }));
  24901. }
  24902. /* harmony default export */ var toolbar = (BlockGroupToolbar);
  24903. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/block-name-context.js
  24904. /**
  24905. * WordPress dependencies
  24906. */
  24907. const __unstableBlockNameContext = (0,external_wp_element_namespaceObject.createContext)('');
  24908. /* harmony default export */ var block_name_context = (__unstableBlockNameContext);
  24909. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/index.js
  24910. /**
  24911. * External dependencies
  24912. */
  24913. /**
  24914. * WordPress dependencies
  24915. */
  24916. /**
  24917. * Internal dependencies
  24918. */
  24919. const BlockToolbar = _ref => {
  24920. let {
  24921. hideDragHandle
  24922. } = _ref;
  24923. const {
  24924. blockClientIds,
  24925. blockClientId,
  24926. blockType,
  24927. hasFixedToolbar,
  24928. hasReducedUI,
  24929. isValid,
  24930. isVisual
  24931. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  24932. const {
  24933. getBlockName,
  24934. getBlockMode,
  24935. getSelectedBlockClientIds,
  24936. isBlockValid,
  24937. getBlockRootClientId,
  24938. getSettings
  24939. } = select(store);
  24940. const selectedBlockClientIds = getSelectedBlockClientIds();
  24941. const selectedBlockClientId = selectedBlockClientIds[0];
  24942. const blockRootClientId = getBlockRootClientId(selectedBlockClientId);
  24943. const settings = getSettings();
  24944. return {
  24945. blockClientIds: selectedBlockClientIds,
  24946. blockClientId: selectedBlockClientId,
  24947. blockType: selectedBlockClientId && (0,external_wp_blocks_namespaceObject.getBlockType)(getBlockName(selectedBlockClientId)),
  24948. hasFixedToolbar: settings.hasFixedToolbar,
  24949. hasReducedUI: settings.hasReducedUI,
  24950. rootClientId: blockRootClientId,
  24951. isValid: selectedBlockClientIds.every(id => isBlockValid(id)),
  24952. isVisual: selectedBlockClientIds.every(id => getBlockMode(id) === 'visual')
  24953. };
  24954. }, []); // Handles highlighting the current block outline on hover or focus of the
  24955. // block type toolbar area.
  24956. const {
  24957. toggleBlockHighlight
  24958. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  24959. const nodeRef = (0,external_wp_element_namespaceObject.useRef)();
  24960. const {
  24961. showMovers,
  24962. gestures: showMoversGestures
  24963. } = useShowMoversGestures({
  24964. ref: nodeRef,
  24965. onChange(isFocused) {
  24966. if (isFocused && hasReducedUI) {
  24967. return;
  24968. }
  24969. toggleBlockHighlight(blockClientId, isFocused);
  24970. }
  24971. }); // Account for the cases where the block toolbar is rendered within the
  24972. // header area and not contextually to the block.
  24973. const displayHeaderToolbar = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<') || hasFixedToolbar;
  24974. if (blockType) {
  24975. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalToolbar', true)) {
  24976. return null;
  24977. }
  24978. }
  24979. const shouldShowMovers = displayHeaderToolbar || showMovers;
  24980. if (blockClientIds.length === 0) {
  24981. return null;
  24982. }
  24983. const shouldShowVisualToolbar = isValid && isVisual;
  24984. const isMultiToolbar = blockClientIds.length > 1;
  24985. const classes = classnames_default()('block-editor-block-toolbar', shouldShowMovers && 'is-showing-movers');
  24986. return (0,external_wp_element_namespaceObject.createElement)("div", {
  24987. className: classes
  24988. }, !isMultiToolbar && !displayHeaderToolbar && (0,external_wp_element_namespaceObject.createElement)(BlockParentSelector, {
  24989. clientIds: blockClientIds
  24990. }), (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  24991. ref: nodeRef
  24992. }, showMoversGestures), (shouldShowVisualToolbar || isMultiToolbar) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
  24993. className: "block-editor-block-toolbar__block-controls"
  24994. }, (0,external_wp_element_namespaceObject.createElement)(block_switcher, {
  24995. clientIds: blockClientIds
  24996. }), !isMultiToolbar && (0,external_wp_element_namespaceObject.createElement)(BlockLockToolbar, {
  24997. clientId: blockClientIds[0]
  24998. }), (0,external_wp_element_namespaceObject.createElement)(block_mover, {
  24999. clientIds: blockClientIds,
  25000. hideDragHandle: hideDragHandle || hasReducedUI
  25001. }))), 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, {
  25002. group: "parent",
  25003. className: "block-editor-block-toolbar__slot"
  25004. }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
  25005. group: "block",
  25006. className: "block-editor-block-toolbar__slot"
  25007. }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
  25008. className: "block-editor-block-toolbar__slot"
  25009. }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
  25010. group: "inline",
  25011. className: "block-editor-block-toolbar__slot"
  25012. }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
  25013. group: "other",
  25014. className: "block-editor-block-toolbar__slot"
  25015. }), (0,external_wp_element_namespaceObject.createElement)(block_name_context.Provider, {
  25016. value: blockType === null || blockType === void 0 ? void 0 : blockType.name
  25017. }, (0,external_wp_element_namespaceObject.createElement)(block_toolbar_last_item.Slot, null))), (0,external_wp_element_namespaceObject.createElement)(block_settings_menu, {
  25018. clientIds: blockClientIds
  25019. }));
  25020. };
  25021. /**
  25022. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md
  25023. */
  25024. /* harmony default export */ var block_toolbar = (BlockToolbar);
  25025. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-contextual-toolbar.js
  25026. /**
  25027. * External dependencies
  25028. */
  25029. /**
  25030. * WordPress dependencies
  25031. */
  25032. /**
  25033. * Internal dependencies
  25034. */
  25035. function BlockContextualToolbar(_ref) {
  25036. let {
  25037. focusOnMount,
  25038. isFixed,
  25039. ...props
  25040. } = _ref;
  25041. const {
  25042. blockType,
  25043. hasParents,
  25044. showParentSelector
  25045. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  25046. const {
  25047. getBlockName,
  25048. getBlockParents,
  25049. getSelectedBlockClientIds
  25050. } = select(store);
  25051. const {
  25052. getBlockType
  25053. } = select(external_wp_blocks_namespaceObject.store);
  25054. const selectedBlockClientIds = getSelectedBlockClientIds();
  25055. const selectedBlockClientId = selectedBlockClientIds[0];
  25056. const parents = getBlockParents(selectedBlockClientId);
  25057. const firstParentClientId = parents[parents.length - 1];
  25058. const parentBlockName = getBlockName(firstParentClientId);
  25059. const parentBlockType = getBlockType(parentBlockName);
  25060. return {
  25061. blockType: selectedBlockClientId && getBlockType(getBlockName(selectedBlockClientId)),
  25062. hasParents: parents.length,
  25063. showParentSelector: (0,external_wp_blocks_namespaceObject.hasBlockSupport)(parentBlockType, '__experimentalParentSelector', true) && selectedBlockClientIds.length <= 1
  25064. };
  25065. }, []);
  25066. if (blockType) {
  25067. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalToolbar', true)) {
  25068. return null;
  25069. }
  25070. } // Shifts the toolbar to make room for the parent block selector.
  25071. const classes = classnames_default()('block-editor-block-contextual-toolbar', {
  25072. 'has-parent': hasParents && showParentSelector,
  25073. 'is-fixed': isFixed
  25074. });
  25075. return (0,external_wp_element_namespaceObject.createElement)(navigable_toolbar, _extends({
  25076. focusOnMount: focusOnMount,
  25077. className: classes
  25078. /* translators: accessibility text for the block toolbar */
  25079. ,
  25080. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block tools')
  25081. }, props), (0,external_wp_element_namespaceObject.createElement)(block_toolbar, {
  25082. hideDragHandle: isFixed
  25083. }));
  25084. }
  25085. /* harmony default export */ var block_contextual_toolbar = (BlockContextualToolbar);
  25086. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-popover.js
  25087. /**
  25088. * External dependencies
  25089. */
  25090. /**
  25091. * WordPress dependencies
  25092. */
  25093. /**
  25094. * Internal dependencies
  25095. */
  25096. function block_popover_selector(select) {
  25097. const {
  25098. isNavigationMode,
  25099. isMultiSelecting,
  25100. hasMultiSelection,
  25101. isTyping,
  25102. isCaretWithinFormattedText,
  25103. getSettings,
  25104. getLastMultiSelectedBlockClientId
  25105. } = select(store);
  25106. return {
  25107. isNavigationMode: isNavigationMode(),
  25108. isMultiSelecting: isMultiSelecting(),
  25109. isTyping: isTyping(),
  25110. isCaretWithinFormattedText: isCaretWithinFormattedText(),
  25111. hasMultiSelection: hasMultiSelection(),
  25112. hasFixedToolbar: getSettings().hasFixedToolbar,
  25113. lastClientId: getLastMultiSelectedBlockClientId()
  25114. };
  25115. }
  25116. function BlockPopover(_ref) {
  25117. let {
  25118. clientId,
  25119. rootClientId,
  25120. isValid,
  25121. isEmptyDefaultBlock,
  25122. capturingClientId,
  25123. __unstablePopoverSlot,
  25124. __unstableContentRef
  25125. } = _ref;
  25126. const {
  25127. isNavigationMode,
  25128. isMultiSelecting,
  25129. isTyping,
  25130. isCaretWithinFormattedText,
  25131. hasMultiSelection,
  25132. hasFixedToolbar,
  25133. lastClientId
  25134. } = (0,external_wp_data_namespaceObject.useSelect)(block_popover_selector, []);
  25135. const isInsertionPointVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
  25136. const {
  25137. isBlockInsertionPointVisible,
  25138. getBlockInsertionPoint,
  25139. getBlockOrder
  25140. } = select(store);
  25141. if (!isBlockInsertionPointVisible()) {
  25142. return false;
  25143. }
  25144. const insertionPoint = getBlockInsertionPoint();
  25145. const order = getBlockOrder(insertionPoint.rootClientId);
  25146. return order[insertionPoint.index] === clientId;
  25147. }, [clientId]);
  25148. const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
  25149. const [isToolbarForced, setIsToolbarForced] = (0,external_wp_element_namespaceObject.useState)(false);
  25150. const [isInserterShown, setIsInserterShown] = (0,external_wp_element_namespaceObject.useState)(false);
  25151. const {
  25152. stopTyping
  25153. } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Controls when the side inserter on empty lines should
  25154. // be shown, including writing and selection modes.
  25155. const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock && isValid;
  25156. const shouldShowBreadcrumb = isNavigationMode;
  25157. const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !showEmptyBlockSideInserter && !isMultiSelecting && (!isTyping || isCaretWithinFormattedText);
  25158. const canFocusHiddenToolbar = !isNavigationMode && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock;
  25159. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/block-editor/focus-toolbar', () => {
  25160. setIsToolbarForced(true);
  25161. stopTyping(true);
  25162. }, {
  25163. isDisabled: !canFocusHiddenToolbar
  25164. });
  25165. (0,external_wp_element_namespaceObject.useEffect)(() => {
  25166. if (!shouldShowContextualToolbar) {
  25167. setIsToolbarForced(false);
  25168. }
  25169. }, [shouldShowContextualToolbar]); // Stores the active toolbar item index so the block toolbar can return focus
  25170. // to it when re-mounting.
  25171. const initialToolbarItemIndexRef = (0,external_wp_element_namespaceObject.useRef)();
  25172. const selectedElement = useBlockElement(clientId);
  25173. const lastSelectedElement = useBlockElement(lastClientId);
  25174. const capturingElement = useBlockElement(capturingClientId);
  25175. const popoverScrollRef = usePopoverScroll(__unstableContentRef);
  25176. if (!shouldShowBreadcrumb && !shouldShowContextualToolbar && !isToolbarForced && !showEmptyBlockSideInserter) {
  25177. return null;
  25178. }
  25179. let node = selectedElement;
  25180. if (!node) {
  25181. return null;
  25182. }
  25183. if (capturingClientId) {
  25184. node = capturingElement;
  25185. }
  25186. let anchorRef = node;
  25187. if (hasMultiSelection) {
  25188. // Wait to render the popover until the bottom reference is available
  25189. // as well.
  25190. if (!lastSelectedElement) {
  25191. return null;
  25192. }
  25193. anchorRef = {
  25194. top: node,
  25195. bottom: lastSelectedElement
  25196. };
  25197. }
  25198. function onFocus() {
  25199. setIsInserterShown(true);
  25200. }
  25201. function onBlur() {
  25202. setIsInserterShown(false);
  25203. } // Position above the anchor, pop out towards the right, and position in the
  25204. // left corner. For the side inserter, pop out towards the left, and
  25205. // position in the right corner.
  25206. // To do: refactor `Popover` to make this prop clearer.
  25207. const popoverPosition = showEmptyBlockSideInserter ? 'top left right' : 'top right left';
  25208. const {
  25209. ownerDocument
  25210. } = node;
  25211. const stickyBoundaryElement = showEmptyBlockSideInserter ? undefined : // The sticky boundary element should be the boundary at which the
  25212. // the block toolbar becomes sticky when the block scolls out of view.
  25213. // In case of an iframe, this should be the iframe boundary, otherwise
  25214. // the scroll container.
  25215. ownerDocument.defaultView.frameElement || (0,external_wp_dom_namespaceObject.getScrollContainer)(node) || ownerDocument.body;
  25216. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  25217. ref: popoverScrollRef,
  25218. noArrow: true,
  25219. animate: false,
  25220. position: popoverPosition,
  25221. focusOnMount: false,
  25222. anchorRef: anchorRef,
  25223. className: classnames_default()('block-editor-block-list__block-popover', {
  25224. 'is-insertion-point-visible': isInsertionPointVisible
  25225. }),
  25226. __unstableStickyBoundaryElement: stickyBoundaryElement // Render in the old slot if needed for backward compatibility,
  25227. // otherwise render in place (not in the the default popover slot).
  25228. ,
  25229. __unstableSlotName: __unstablePopoverSlot || null,
  25230. __unstableBoundaryParent: true // Observe movement for block animations (especially horizontal).
  25231. ,
  25232. __unstableObserveElement: node,
  25233. shouldAnchorIncludePadding: true // Used to safeguard sticky position behavior against cases where it would permanently
  25234. // obscure specific sections of a block.
  25235. ,
  25236. __unstableEditorCanvasWrapper: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current
  25237. }, (shouldShowContextualToolbar || isToolbarForced) && (0,external_wp_element_namespaceObject.createElement)("div", {
  25238. onFocus: onFocus,
  25239. onBlur: onBlur // While ideally it would be enough to capture the
  25240. // bubbling focus event from the Inserter, due to the
  25241. // characteristics of click focusing of `button`s in
  25242. // Firefox and Safari, it is not reliable.
  25243. //
  25244. // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  25245. ,
  25246. tabIndex: -1,
  25247. className: classnames_default()('block-editor-block-list__block-popover-inserter', {
  25248. 'is-visible': isInserterShown
  25249. })
  25250. }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
  25251. clientId: clientId,
  25252. rootClientId: rootClientId,
  25253. __experimentalIsQuick: true
  25254. })), (shouldShowContextualToolbar || isToolbarForced) && (0,external_wp_element_namespaceObject.createElement)(block_contextual_toolbar // If the toolbar is being shown because of being forced
  25255. // it should focus the toolbar right after the mount.
  25256. , {
  25257. focusOnMount: isToolbarForced,
  25258. __experimentalInitialIndex: initialToolbarItemIndexRef.current,
  25259. __experimentalOnIndexChange: index => {
  25260. initialToolbarItemIndexRef.current = index;
  25261. } // Resets the index whenever the active block changes so
  25262. // this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
  25263. ,
  25264. key: clientId
  25265. }), shouldShowBreadcrumb && (0,external_wp_element_namespaceObject.createElement)(block_selection_button, {
  25266. clientId: clientId,
  25267. rootClientId: rootClientId,
  25268. blockElement: node
  25269. }), showEmptyBlockSideInserter && (0,external_wp_element_namespaceObject.createElement)("div", {
  25270. className: "block-editor-block-list__empty-block-inserter"
  25271. }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
  25272. position: "bottom right",
  25273. rootClientId: rootClientId,
  25274. clientId: clientId,
  25275. __experimentalIsQuick: true
  25276. })));
  25277. }
  25278. function wrapperSelector(select) {
  25279. const {
  25280. getSelectedBlockClientId,
  25281. getFirstMultiSelectedBlockClientId,
  25282. getBlockRootClientId,
  25283. getBlock,
  25284. getBlockParents,
  25285. __experimentalGetBlockListSettingsForBlocks
  25286. } = select(store);
  25287. const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
  25288. if (!clientId) {
  25289. return;
  25290. }
  25291. const {
  25292. name,
  25293. attributes = {},
  25294. isValid
  25295. } = getBlock(clientId) || {};
  25296. const blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId.
  25297. const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(blockParentsClientIds); // Get the clientId of the topmost parent with the capture toolbars setting.
  25298. const capturingClientId = (0,external_lodash_namespaceObject.find)(blockParentsClientIds, parentClientId => {
  25299. var _parentBlockListSetti;
  25300. return (_parentBlockListSetti = parentBlockListSettings[parentClientId]) === null || _parentBlockListSetti === void 0 ? void 0 : _parentBlockListSetti.__experimentalCaptureToolbars;
  25301. });
  25302. return {
  25303. clientId,
  25304. rootClientId: getBlockRootClientId(clientId),
  25305. name,
  25306. isValid,
  25307. isEmptyDefaultBlock: name && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)({
  25308. name,
  25309. attributes
  25310. }),
  25311. capturingClientId
  25312. };
  25313. }
  25314. function WrappedBlockPopover(_ref2) {
  25315. let {
  25316. __unstablePopoverSlot,
  25317. __unstableContentRef
  25318. } = _ref2;
  25319. const selected = (0,external_wp_data_namespaceObject.useSelect)(wrapperSelector, []);
  25320. if (!selected) {
  25321. return null;
  25322. }
  25323. const {
  25324. clientId,
  25325. rootClientId,
  25326. name,
  25327. isValid,
  25328. isEmptyDefaultBlock,
  25329. capturingClientId
  25330. } = selected;
  25331. if (!name) {
  25332. return null;
  25333. }
  25334. return (0,external_wp_element_namespaceObject.createElement)(BlockPopover, {
  25335. clientId: clientId,
  25336. rootClientId: rootClientId,
  25337. isValid: isValid,
  25338. isEmptyDefaultBlock: isEmptyDefaultBlock,
  25339. capturingClientId: capturingClientId,
  25340. __unstablePopoverSlot: __unstablePopoverSlot,
  25341. __unstableContentRef: __unstableContentRef
  25342. });
  25343. }
  25344. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/back-compat.js
  25345. /**
  25346. * WordPress dependencies
  25347. */
  25348. /**
  25349. * Internal dependencies
  25350. */
  25351. function BlockToolsBackCompat(_ref) {
  25352. let {
  25353. children
  25354. } = _ref;
  25355. const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef);
  25356. const isDisabled = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.Disabled.Context); // If context is set, `BlockTools` is a parent component.
  25357. if (openRef || isDisabled) {
  25358. return children;
  25359. }
  25360. external_wp_deprecated_default()('wp.components.Popover.Slot name="block-toolbar"', {
  25361. alternative: 'wp.blockEditor.BlockTools',
  25362. since: '5.8'
  25363. });
  25364. return (0,external_wp_element_namespaceObject.createElement)(InsertionPoint, {
  25365. __unstablePopoverSlot: "block-toolbar"
  25366. }, (0,external_wp_element_namespaceObject.createElement)(WrappedBlockPopover, {
  25367. __unstablePopoverSlot: "block-toolbar"
  25368. }), children);
  25369. }
  25370. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/with-client-id.js
  25371. /**
  25372. * WordPress dependencies
  25373. */
  25374. /**
  25375. * Internal dependencies
  25376. */
  25377. const withClientId = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
  25378. const {
  25379. clientId
  25380. } = useBlockEditContext();
  25381. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  25382. clientId: clientId
  25383. }));
  25384. }, 'withClientId');
  25385. /* harmony default export */ var with_client_id = (withClientId);
  25386. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/button-block-appender.js
  25387. /**
  25388. * External dependencies
  25389. */
  25390. /**
  25391. * Internal dependencies
  25392. */
  25393. const button_block_appender_ButtonBlockAppender = _ref => {
  25394. let {
  25395. clientId,
  25396. showSeparator,
  25397. isFloating,
  25398. onAddBlock,
  25399. isToggle
  25400. } = _ref;
  25401. return (0,external_wp_element_namespaceObject.createElement)(button_block_appender, {
  25402. className: classnames_default()({
  25403. 'block-list-appender__toggle': isToggle
  25404. }),
  25405. rootClientId: clientId,
  25406. showSeparator: showSeparator,
  25407. isFloating: isFloating,
  25408. onAddBlock: onAddBlock
  25409. });
  25410. };
  25411. /* harmony default export */ var inner_blocks_button_block_appender = (with_client_id(button_block_appender_ButtonBlockAppender));
  25412. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/default-block-appender.js
  25413. /**
  25414. * External dependencies
  25415. */
  25416. /**
  25417. * WordPress dependencies
  25418. */
  25419. /**
  25420. * Internal dependencies
  25421. */
  25422. const default_block_appender_DefaultBlockAppender = _ref => {
  25423. let {
  25424. clientId
  25425. } = _ref;
  25426. return (0,external_wp_element_namespaceObject.createElement)(default_block_appender, {
  25427. rootClientId: clientId
  25428. });
  25429. };
  25430. /* 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) => {
  25431. let {
  25432. clientId
  25433. } = _ref2;
  25434. const {
  25435. getBlockOrder
  25436. } = select(store);
  25437. const blockClientIds = getBlockOrder(clientId);
  25438. return {
  25439. lastBlockClientId: (0,external_lodash_namespaceObject.last)(blockClientIds)
  25440. };
  25441. })])(default_block_appender_DefaultBlockAppender));
  25442. ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
  25443. var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
  25444. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
  25445. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-nested-settings-update.js
  25446. /**
  25447. * WordPress dependencies
  25448. */
  25449. /**
  25450. * Internal dependencies
  25451. */
  25452. /** @typedef {import('../../selectors').WPDirectInsertBlock } WPDirectInsertBlock */
  25453. /**
  25454. * This hook is a side effect which updates the block-editor store when changes
  25455. * happen to inner block settings. The given props are transformed into a
  25456. * settings object, and if that is different from the current settings object in
  25457. * the block-editor store, then the store is updated with the new settings which
  25458. * came from props.
  25459. *
  25460. * @param {string} clientId The client ID of the block to update.
  25461. * @param {string[]} allowedBlocks An array of block names which are permitted
  25462. * in inner blocks.
  25463. * @param {?WPDirectInsertBlock} __experimentalDefaultBlock The default block to insert: [ blockName, { blockAttributes } ].
  25464. * @param {?Function|boolean} __experimentalDirectInsert If a default block should be inserted directly by the
  25465. * appender.
  25466. * @param {string} [templateLock] The template lock specified for the inner
  25467. * blocks component. (e.g. "all")
  25468. * @param {boolean} captureToolbars Whether or children toolbars should be shown
  25469. * in the inner blocks component rather than on
  25470. * the child block.
  25471. * @param {string} orientation The direction in which the block
  25472. * should face.
  25473. * @param {Object} layout The layout object for the block container.
  25474. */
  25475. function useNestedSettingsUpdate(clientId, allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout) {
  25476. const {
  25477. updateBlockListSettings
  25478. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  25479. const {
  25480. blockListSettings,
  25481. parentLock
  25482. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  25483. const rootClientId = select(store).getBlockRootClientId(clientId);
  25484. return {
  25485. blockListSettings: select(store).getBlockListSettings(clientId),
  25486. parentLock: select(store).getTemplateLock(rootClientId)
  25487. };
  25488. }, [clientId]); // Memoize as inner blocks implementors often pass a new array on every
  25489. // render.
  25490. const _allowedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => allowedBlocks, allowedBlocks);
  25491. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  25492. const newSettings = {
  25493. allowedBlocks: _allowedBlocks,
  25494. templateLock: templateLock === undefined ? parentLock : templateLock
  25495. }; // These values are not defined for RN, so only include them if they
  25496. // are defined.
  25497. if (captureToolbars !== undefined) {
  25498. newSettings.__experimentalCaptureToolbars = captureToolbars;
  25499. } // Orientation depends on layout,
  25500. // ideally the separate orientation prop should be deprecated.
  25501. if (orientation !== undefined) {
  25502. newSettings.orientation = orientation;
  25503. } else {
  25504. const layoutType = getLayoutType(layout === null || layout === void 0 ? void 0 : layout.type);
  25505. newSettings.orientation = layoutType.getOrientation(layout);
  25506. }
  25507. if (__experimentalDefaultBlock !== undefined) {
  25508. newSettings.__experimentalDefaultBlock = __experimentalDefaultBlock;
  25509. }
  25510. if (__experimentalDirectInsert !== undefined) {
  25511. newSettings.__experimentalDirectInsert = __experimentalDirectInsert;
  25512. }
  25513. if (!external_wp_isShallowEqual_default()(blockListSettings, newSettings)) {
  25514. updateBlockListSettings(clientId, newSettings);
  25515. }
  25516. }, [clientId, blockListSettings, _allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings, layout]);
  25517. }
  25518. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-inner-block-template-sync.js
  25519. /**
  25520. * External dependencies
  25521. */
  25522. /**
  25523. * WordPress dependencies
  25524. */
  25525. /**
  25526. * Internal dependencies
  25527. */
  25528. /**
  25529. * This hook makes sure that a block's inner blocks stay in sync with the given
  25530. * block "template". The template is a block hierarchy to which inner blocks must
  25531. * conform. If the blocks get "out of sync" with the template and the template
  25532. * is meant to be locked (e.g. templateLock = "all"), then we replace the inner
  25533. * blocks with the correct value after synchronizing it with the template.
  25534. *
  25535. * @param {string} clientId The block client ID.
  25536. * @param {Object} template The template to match.
  25537. * @param {string} templateLock The template lock state for the inner blocks. For
  25538. * example, if the template lock is set to "all",
  25539. * then the inner blocks will stay in sync with the
  25540. * template. If not defined or set to false, then
  25541. * the inner blocks will not be synchronized with
  25542. * the given template.
  25543. * @param {boolean} templateInsertUpdatesSelection Whether or not to update the
  25544. * block-editor selection state when inner blocks
  25545. * are replaced after template synchronization.
  25546. */
  25547. function useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection) {
  25548. const {
  25549. getSelectedBlocksInitialCaretPosition
  25550. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  25551. const {
  25552. replaceInnerBlocks
  25553. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  25554. const innerBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlocks(clientId), [clientId]); // Maintain a reference to the previous value so we can do a deep equality check.
  25555. const existingTemplate = (0,external_wp_element_namespaceObject.useRef)(null);
  25556. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  25557. // Only synchronize innerBlocks with template if innerBlocks are empty or
  25558. // a locking all exists directly on the block.
  25559. if (innerBlocks.length === 0 || templateLock === 'all') {
  25560. const hasTemplateChanged = !(0,external_lodash_namespaceObject.isEqual)(template, existingTemplate.current);
  25561. if (hasTemplateChanged) {
  25562. existingTemplate.current = template;
  25563. const nextBlocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(innerBlocks, template);
  25564. if (!(0,external_lodash_namespaceObject.isEqual)(nextBlocks, innerBlocks)) {
  25565. replaceInnerBlocks(clientId, nextBlocks, innerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0, // This ensures the "initialPosition" doesn't change when applying the template
  25566. // If we're supposed to focus the block, we'll focus the first inner block
  25567. // otherwise, we won't apply any auto-focus.
  25568. // This ensures for instance that the focus stays in the inserter when inserting the "buttons" block.
  25569. getSelectedBlocksInitialCaretPosition());
  25570. }
  25571. }
  25572. }
  25573. }, [innerBlocks, template, templateLock, clientId]);
  25574. }
  25575. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/get-block-context.js
  25576. /**
  25577. * External dependencies
  25578. */
  25579. /**
  25580. * Block context cache, implemented as a WeakMap mapping block types to a
  25581. * WeakMap mapping attributes object to context value.
  25582. *
  25583. * @type {WeakMap<string,WeakMap<string,*>>}
  25584. */
  25585. const BLOCK_CONTEXT_CACHE = new WeakMap();
  25586. /**
  25587. * Returns a cached context object value for a given set of attributes for the
  25588. * block type.
  25589. *
  25590. * @param {Record<string,*>} attributes Block attributes object.
  25591. * @param {WPBlockType} blockType Block type settings.
  25592. *
  25593. * @return {Record<string,*>} Context value.
  25594. */
  25595. function getBlockContext(attributes, blockType) {
  25596. if (!BLOCK_CONTEXT_CACHE.has(blockType)) {
  25597. BLOCK_CONTEXT_CACHE.set(blockType, new WeakMap());
  25598. }
  25599. const blockTypeCache = BLOCK_CONTEXT_CACHE.get(blockType);
  25600. if (!blockTypeCache.has(attributes)) {
  25601. const context = (0,external_lodash_namespaceObject.mapValues)(blockType.providesContext, attributeName => attributes[attributeName]);
  25602. blockTypeCache.set(attributes, context);
  25603. }
  25604. return blockTypeCache.get(attributes);
  25605. }
  25606. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-on-block-drop/index.js
  25607. /**
  25608. * WordPress dependencies
  25609. */
  25610. /**
  25611. * Internal dependencies
  25612. */
  25613. /** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */
  25614. /**
  25615. * Retrieve the data for a block drop event.
  25616. *
  25617. * @param {WPSyntheticEvent} event The drop event.
  25618. *
  25619. * @return {Object} An object with block drag and drop data.
  25620. */
  25621. function parseDropEvent(event) {
  25622. let result = {
  25623. srcRootClientId: null,
  25624. srcClientIds: null,
  25625. srcIndex: null,
  25626. type: null,
  25627. blocks: null
  25628. };
  25629. if (!event.dataTransfer) {
  25630. return result;
  25631. }
  25632. try {
  25633. result = Object.assign(result, JSON.parse(event.dataTransfer.getData('wp-blocks')));
  25634. } catch (err) {
  25635. return result;
  25636. }
  25637. return result;
  25638. }
  25639. /**
  25640. * A function that returns an event handler function for block drop events.
  25641. *
  25642. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  25643. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  25644. * @param {Function} getBlockIndex A function that gets the index of a block.
  25645. * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
  25646. * @param {Function} moveBlocksToPosition A function that moves blocks.
  25647. * @param {Function} insertBlocks A function that inserts blocks.
  25648. * @param {Function} clearSelectedBlock A function that clears block selection.
  25649. * @return {Function} The event handler for a block drop event.
  25650. */
  25651. function onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock) {
  25652. return event => {
  25653. const {
  25654. srcRootClientId: sourceRootClientId,
  25655. srcClientIds: sourceClientIds,
  25656. type: dropType,
  25657. blocks
  25658. } = parseDropEvent(event); // If the user is inserting a block.
  25659. if (dropType === 'inserter') {
  25660. clearSelectedBlock();
  25661. const blocksToInsert = blocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
  25662. insertBlocks(blocksToInsert, targetBlockIndex, targetRootClientId, true, null);
  25663. } // If the user is moving a block.
  25664. if (dropType === 'block') {
  25665. const sourceBlockIndex = getBlockIndex(sourceClientIds[0]); // If the user is dropping to the same position, return early.
  25666. if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) {
  25667. return;
  25668. } // If the user is attempting to drop a block within its own
  25669. // nested blocks, return early as this would create infinite
  25670. // recursion.
  25671. if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants(sourceClientIds).some(id => id === targetRootClientId)) {
  25672. return;
  25673. }
  25674. const isAtSameLevel = sourceRootClientId === targetRootClientId;
  25675. const draggedBlockCount = sourceClientIds.length; // If the block is kept at the same level and moved downwards,
  25676. // subtract to take into account that the blocks being dragged
  25677. // were removed from the block list above the insertion point.
  25678. const insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex;
  25679. moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex);
  25680. }
  25681. };
  25682. }
  25683. /**
  25684. * A function that returns an event handler function for block-related file drop events.
  25685. *
  25686. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  25687. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  25688. * @param {boolean} hasUploadPermissions Whether the user has upload permissions.
  25689. * @param {Function} updateBlockAttributes A function that updates a block's attributes.
  25690. * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.
  25691. * @param {Function} insertBlocks A function that inserts blocks.
  25692. *
  25693. * @return {Function} The event handler for a block-related file drop event.
  25694. */
  25695. function onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks) {
  25696. return files => {
  25697. if (!hasUploadPermissions) {
  25698. return;
  25699. }
  25700. 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));
  25701. if (transformation) {
  25702. const blocks = transformation.transform(files, updateBlockAttributes);
  25703. insertBlocks(blocks, targetBlockIndex, targetRootClientId);
  25704. }
  25705. };
  25706. }
  25707. /**
  25708. * A function that returns an event handler function for block-related HTML drop events.
  25709. *
  25710. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  25711. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  25712. * @param {Function} insertBlocks A function that inserts blocks.
  25713. *
  25714. * @return {Function} The event handler for a block-related HTML drop event.
  25715. */
  25716. function onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks) {
  25717. return HTML => {
  25718. const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({
  25719. HTML,
  25720. mode: 'BLOCKS'
  25721. });
  25722. if (blocks.length) {
  25723. insertBlocks(blocks, targetBlockIndex, targetRootClientId);
  25724. }
  25725. };
  25726. }
  25727. /**
  25728. * A React hook for handling block drop events.
  25729. *
  25730. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  25731. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  25732. *
  25733. * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.
  25734. */
  25735. function useOnBlockDrop(targetRootClientId, targetBlockIndex) {
  25736. const hasUploadPermissions = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().mediaUpload, []);
  25737. const {
  25738. canInsertBlockType,
  25739. getBlockIndex,
  25740. getClientIdsOfDescendants
  25741. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  25742. const {
  25743. insertBlocks,
  25744. moveBlocksToPosition,
  25745. updateBlockAttributes,
  25746. clearSelectedBlock
  25747. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  25748. const _onDrop = onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock);
  25749. const _onFilesDrop = onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks);
  25750. const _onHTMLDrop = onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks);
  25751. return event => {
  25752. const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(event.dataTransfer);
  25753. const html = event.dataTransfer.getData('text/html');
  25754. /**
  25755. * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
  25756. * The order of the checks is important to recognise the HTML drop.
  25757. */
  25758. if (html) {
  25759. _onHTMLDrop(html);
  25760. } else if (files.length) {
  25761. _onFilesDrop(files);
  25762. } else {
  25763. _onDrop(event);
  25764. }
  25765. };
  25766. }
  25767. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/math.js
  25768. /**
  25769. * A string representing the name of an edge.
  25770. *
  25771. * @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName
  25772. */
  25773. /**
  25774. * @typedef {Object} WPPoint
  25775. * @property {number} x The horizontal position.
  25776. * @property {number} y The vertical position.
  25777. */
  25778. /**
  25779. * Given a point, a DOMRect and the name of an edge, returns the distance to
  25780. * that edge of the rect.
  25781. *
  25782. * This function works for edges that are horizontal or vertical (e.g. not
  25783. * rotated), the following terms are used so that the function works in both
  25784. * orientations:
  25785. *
  25786. * - Forward, meaning the axis running horizontally when an edge is vertical
  25787. * and vertically when an edge is horizontal.
  25788. * - Lateral, meaning the axis running vertically when an edge is vertical
  25789. * and horizontally when an edge is horizontal.
  25790. *
  25791. * @param {WPPoint} point The point to measure distance from.
  25792. * @param {DOMRect} rect A DOM Rect containing edge positions.
  25793. * @param {WPEdgeName} edge The edge to measure to.
  25794. */
  25795. function getDistanceFromPointToEdge(point, rect, edge) {
  25796. const isHorizontal = edge === 'top' || edge === 'bottom';
  25797. const {
  25798. x,
  25799. y
  25800. } = point;
  25801. const pointLateralPosition = isHorizontal ? x : y;
  25802. const pointForwardPosition = isHorizontal ? y : x;
  25803. const edgeStart = isHorizontal ? rect.left : rect.top;
  25804. const edgeEnd = isHorizontal ? rect.right : rect.bottom;
  25805. const edgeForwardPosition = rect[edge]; // Measure the straight line distance to the edge of the rect, when the
  25806. // point is adjacent to the edge.
  25807. // Else, if the point is positioned diagonally to the edge of the rect,
  25808. // measure diagonally to the nearest corner that the edge meets.
  25809. let edgeLateralPosition;
  25810. if (pointLateralPosition >= edgeStart && pointLateralPosition <= edgeEnd) {
  25811. edgeLateralPosition = pointLateralPosition;
  25812. } else if (pointLateralPosition < edgeEnd) {
  25813. edgeLateralPosition = edgeStart;
  25814. } else {
  25815. edgeLateralPosition = edgeEnd;
  25816. }
  25817. return Math.sqrt((pointLateralPosition - edgeLateralPosition) ** 2 + (pointForwardPosition - edgeForwardPosition) ** 2);
  25818. }
  25819. /**
  25820. * Given a point, a DOMRect and a list of allowed edges returns the name of and
  25821. * distance to the nearest edge.
  25822. *
  25823. * @param {WPPoint} point The point to measure distance from.
  25824. * @param {DOMRect} rect A DOM Rect containing edge positions.
  25825. * @param {WPEdgeName[]} allowedEdges A list of the edges included in the
  25826. * calculation. Defaults to all edges.
  25827. *
  25828. * @return {[number, string]} An array where the first value is the distance
  25829. * and a second is the edge name.
  25830. */
  25831. function getDistanceToNearestEdge(point, rect) {
  25832. let allowedEdges = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ['top', 'bottom', 'left', 'right'];
  25833. let candidateDistance;
  25834. let candidateEdge;
  25835. allowedEdges.forEach(edge => {
  25836. const distance = getDistanceFromPointToEdge(point, rect, edge);
  25837. if (candidateDistance === undefined || distance < candidateDistance) {
  25838. candidateDistance = distance;
  25839. candidateEdge = edge;
  25840. }
  25841. });
  25842. return [candidateDistance, candidateEdge];
  25843. }
  25844. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-drop-zone/index.js
  25845. /**
  25846. * WordPress dependencies
  25847. */
  25848. /**
  25849. * Internal dependencies
  25850. */
  25851. /** @typedef {import('../../utils/math').WPPoint} WPPoint */
  25852. /**
  25853. * The orientation of a block list.
  25854. *
  25855. * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
  25856. */
  25857. /**
  25858. * Given a list of block DOM elements finds the index that a block should be dropped
  25859. * at.
  25860. *
  25861. * @param {Element[]} elements Array of DOM elements that represent each block in a block list.
  25862. * @param {WPPoint} position The position of the item being dragged.
  25863. * @param {WPBlockListOrientation} orientation The orientation of a block list.
  25864. *
  25865. * @return {number|undefined} The block index that's closest to the drag position.
  25866. */
  25867. function getNearestBlockIndex(elements, position, orientation) {
  25868. const allowedEdges = orientation === 'horizontal' ? ['left', 'right'] : ['top', 'bottom'];
  25869. const isRightToLeft = (0,external_wp_i18n_namespaceObject.isRTL)();
  25870. let candidateIndex;
  25871. let candidateDistance;
  25872. elements.forEach((element, index) => {
  25873. const rect = element.getBoundingClientRect();
  25874. const [distance, edge] = getDistanceToNearestEdge(position, rect, allowedEdges);
  25875. if (candidateDistance === undefined || distance < candidateDistance) {
  25876. // If the user is dropping to the trailing edge of the block
  25877. // add 1 to the index to represent dragging after.
  25878. // Take RTL languages into account where the left edge is
  25879. // the trailing edge.
  25880. const isTrailingEdge = edge === 'bottom' || !isRightToLeft && edge === 'right' || isRightToLeft && edge === 'left';
  25881. const offset = isTrailingEdge ? 1 : 0; // Update the currently known best candidate.
  25882. candidateDistance = distance;
  25883. candidateIndex = index + offset;
  25884. }
  25885. });
  25886. return candidateIndex;
  25887. }
  25888. /**
  25889. * @typedef {Object} WPBlockDropZoneConfig
  25890. * @property {string} rootClientId The root client id for the block list.
  25891. */
  25892. /**
  25893. * A React hook that can be used to make a block list handle drag and drop.
  25894. *
  25895. * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
  25896. */
  25897. function useBlockDropZone() {
  25898. let {
  25899. // An undefined value represents a top-level block. Default to an empty
  25900. // string for this so that `targetRootClientId` can be easily compared to
  25901. // values returned by the `getRootBlockClientId` selector, which also uses
  25902. // an empty string to represent top-level blocks.
  25903. rootClientId: targetRootClientId = ''
  25904. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  25905. const [targetBlockIndex, setTargetBlockIndex] = (0,external_wp_element_namespaceObject.useState)(null);
  25906. const isLockedAll = (0,external_wp_data_namespaceObject.useSelect)(select => {
  25907. const {
  25908. getTemplateLock
  25909. } = select(store);
  25910. return getTemplateLock(targetRootClientId) === 'all';
  25911. }, [targetRootClientId]);
  25912. const {
  25913. getBlockListSettings
  25914. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  25915. const {
  25916. showInsertionPoint,
  25917. hideInsertionPoint
  25918. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  25919. const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex);
  25920. const throttled = (0,external_wp_compose_namespaceObject.useThrottle)((0,external_wp_element_namespaceObject.useCallback)((event, currentTarget) => {
  25921. var _getBlockListSettings;
  25922. const blockElements = Array.from(currentTarget.children).filter( // Ensure the element is a block. It should have the `wp-block` class.
  25923. element => element.classList.contains('wp-block'));
  25924. const targetIndex = getNearestBlockIndex(blockElements, {
  25925. x: event.clientX,
  25926. y: event.clientY
  25927. }, (_getBlockListSettings = getBlockListSettings(targetRootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation);
  25928. setTargetBlockIndex(targetIndex === undefined ? 0 : targetIndex);
  25929. if (targetIndex !== null) {
  25930. showInsertionPoint(targetRootClientId, targetIndex);
  25931. }
  25932. }, []), 200);
  25933. return (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({
  25934. isDisabled: isLockedAll,
  25935. onDrop: onBlockDrop,
  25936. onDragOver(event) {
  25937. // `currentTarget` is only available while the event is being
  25938. // handled, so get it now and pass it to the thottled function.
  25939. // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
  25940. throttled(event, event.currentTarget);
  25941. },
  25942. onDragLeave() {
  25943. throttled.cancel();
  25944. hideInsertionPoint();
  25945. setTargetBlockIndex(null);
  25946. },
  25947. onDragEnd() {
  25948. throttled.cancel();
  25949. hideInsertionPoint();
  25950. setTargetBlockIndex(null);
  25951. }
  25952. });
  25953. }
  25954. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/index.js
  25955. /**
  25956. * External dependencies
  25957. */
  25958. /**
  25959. * WordPress dependencies
  25960. */
  25961. /**
  25962. * Internal dependencies
  25963. */
  25964. /**
  25965. * InnerBlocks is a component which allows a single block to have multiple blocks
  25966. * as children. The UncontrolledInnerBlocks component is used whenever the inner
  25967. * blocks are not controlled by another entity. In other words, it is normally
  25968. * used for inner blocks in the post editor
  25969. *
  25970. * @param {Object} props The component props.
  25971. */
  25972. function UncontrolledInnerBlocks(props) {
  25973. const {
  25974. clientId,
  25975. allowedBlocks,
  25976. __experimentalDefaultBlock,
  25977. __experimentalDirectInsert,
  25978. template,
  25979. templateLock,
  25980. wrapperRef,
  25981. templateInsertUpdatesSelection,
  25982. __experimentalCaptureToolbars: captureToolbars,
  25983. __experimentalAppenderTagName,
  25984. renderAppender,
  25985. orientation,
  25986. placeholder,
  25987. __experimentalLayout
  25988. } = props;
  25989. useNestedSettingsUpdate(clientId, allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, __experimentalLayout);
  25990. useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection);
  25991. const context = (0,external_wp_data_namespaceObject.useSelect)(select => {
  25992. const block = select(store).getBlock(clientId);
  25993. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
  25994. if (!blockType || !blockType.providesContext) {
  25995. return;
  25996. }
  25997. return getBlockContext(block.attributes, blockType);
  25998. }, [clientId]); // This component needs to always be synchronous as it's the one changing
  25999. // the async mode depending on the block selection.
  26000. return (0,external_wp_element_namespaceObject.createElement)(BlockContextProvider, {
  26001. value: context
  26002. }, (0,external_wp_element_namespaceObject.createElement)(BlockListItems, {
  26003. rootClientId: clientId,
  26004. renderAppender: renderAppender,
  26005. __experimentalAppenderTagName: __experimentalAppenderTagName,
  26006. __experimentalLayout: __experimentalLayout,
  26007. wrapperRef: wrapperRef,
  26008. placeholder: placeholder
  26009. }));
  26010. }
  26011. /**
  26012. * The controlled inner blocks component wraps the uncontrolled inner blocks
  26013. * component with the blockSync hook. This keeps the innerBlocks of the block in
  26014. * the block-editor store in sync with the blocks of the controlling entity. An
  26015. * example of an inner block controller is a template part block, which provides
  26016. * its own blocks from the template part entity data source.
  26017. *
  26018. * @param {Object} props The component props.
  26019. */
  26020. function ControlledInnerBlocks(props) {
  26021. useBlockSync(props);
  26022. return (0,external_wp_element_namespaceObject.createElement)(UncontrolledInnerBlocks, props);
  26023. }
  26024. const ForwardedInnerBlocks = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  26025. const innerBlocksProps = useInnerBlocksProps({
  26026. ref
  26027. }, props);
  26028. return (0,external_wp_element_namespaceObject.createElement)("div", {
  26029. className: "block-editor-inner-blocks"
  26030. }, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps));
  26031. });
  26032. /**
  26033. * This hook is used to lightly mark an element as an inner blocks wrapper
  26034. * element. Call this hook and pass the returned props to the element to mark as
  26035. * an inner blocks wrapper, automatically rendering inner blocks as children. If
  26036. * you define a ref for the element, it is important to pass the ref to this
  26037. * hook, which the hook in turn will pass to the component through the props it
  26038. * returns. Optionally, you can also pass any other props through this hook, and
  26039. * they will be merged and returned.
  26040. *
  26041. * @param {Object} props Optional. Props to pass to the element. Must contain
  26042. * the ref if one is defined.
  26043. * @param {Object} options Optional. Inner blocks options.
  26044. *
  26045. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
  26046. */
  26047. function useInnerBlocksProps() {
  26048. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  26049. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  26050. const {
  26051. clientId
  26052. } = useBlockEditContext();
  26053. const isSmallScreen = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
  26054. const {
  26055. __experimentalCaptureToolbars,
  26056. hasOverlay
  26057. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  26058. if (!clientId) {
  26059. return {};
  26060. }
  26061. const {
  26062. getBlockName,
  26063. isBlockSelected,
  26064. hasSelectedInnerBlock,
  26065. isNavigationMode
  26066. } = select(store);
  26067. const blockName = getBlockName(clientId);
  26068. const enableClickThrough = isNavigationMode() || isSmallScreen;
  26069. return {
  26070. __experimentalCaptureToolbars: select(external_wp_blocks_namespaceObject.store).hasBlockSupport(blockName, '__experimentalExposeControlsToChildren', false),
  26071. hasOverlay: blockName !== 'core/template' && !isBlockSelected(clientId) && !hasSelectedInnerBlock(clientId, true) && enableClickThrough
  26072. };
  26073. }, [clientId, isSmallScreen]);
  26074. const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, useBlockDropZone({
  26075. rootClientId: clientId
  26076. })]);
  26077. const innerBlocksProps = {
  26078. __experimentalCaptureToolbars,
  26079. ...options
  26080. };
  26081. const InnerBlocks = innerBlocksProps.value && innerBlocksProps.onChange ? ControlledInnerBlocks : UncontrolledInnerBlocks;
  26082. return { ...props,
  26083. ref,
  26084. className: classnames_default()(props.className, 'block-editor-block-list__layout', {
  26085. 'has-overlay': hasOverlay
  26086. }),
  26087. children: clientId ? (0,external_wp_element_namespaceObject.createElement)(InnerBlocks, _extends({}, innerBlocksProps, {
  26088. clientId: clientId
  26089. })) : (0,external_wp_element_namespaceObject.createElement)(BlockListItems, options)
  26090. };
  26091. }
  26092. useInnerBlocksProps.save = external_wp_blocks_namespaceObject.__unstableGetInnerBlocksProps; // Expose default appender placeholders as components.
  26093. ForwardedInnerBlocks.DefaultBlockAppender = inner_blocks_default_block_appender;
  26094. ForwardedInnerBlocks.ButtonBlockAppender = inner_blocks_button_block_appender;
  26095. ForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;
  26096. /**
  26097. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
  26098. */
  26099. /* harmony default export */ var inner_blocks = (ForwardedInnerBlocks);
  26100. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/index.js
  26101. /**
  26102. * External dependencies
  26103. */
  26104. /**
  26105. * WordPress dependencies
  26106. */
  26107. /**
  26108. * Internal dependencies
  26109. */
  26110. const elementContext = (0,external_wp_element_namespaceObject.createContext)();
  26111. const IntersectionObserver = (0,external_wp_element_namespaceObject.createContext)();
  26112. function Root(_ref) {
  26113. let {
  26114. className,
  26115. ...settings
  26116. } = _ref;
  26117. const [element, setElement] = (0,external_wp_element_namespaceObject.useState)();
  26118. const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
  26119. const {
  26120. isOutlineMode,
  26121. isFocusMode,
  26122. isNavigationMode
  26123. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  26124. const {
  26125. getSettings,
  26126. isNavigationMode: _isNavigationMode
  26127. } = select(store);
  26128. const {
  26129. outlineMode,
  26130. focusMode
  26131. } = getSettings();
  26132. return {
  26133. isOutlineMode: outlineMode,
  26134. isFocusMode: focusMode,
  26135. isNavigationMode: _isNavigationMode()
  26136. };
  26137. }, []);
  26138. const innerBlocksProps = useInnerBlocksProps({
  26139. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([useBlockSelectionClearer(), useInBetweenInserter(), setElement]),
  26140. className: classnames_default()('is-root-container', className, {
  26141. 'is-outline-mode': isOutlineMode,
  26142. 'is-focus-mode': isFocusMode && isLargeViewport,
  26143. 'is-navigate-mode': isNavigationMode
  26144. })
  26145. }, settings);
  26146. return (0,external_wp_element_namespaceObject.createElement)(elementContext.Provider, {
  26147. value: element
  26148. }, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps));
  26149. }
  26150. function BlockList(settings) {
  26151. usePreParsePatterns();
  26152. return (0,external_wp_element_namespaceObject.createElement)(BlockToolsBackCompat, null, (0,external_wp_element_namespaceObject.createElement)(Provider, {
  26153. value: DEFAULT_BLOCK_EDIT_CONTEXT
  26154. }, (0,external_wp_element_namespaceObject.createElement)(Root, settings)));
  26155. }
  26156. BlockList.__unstableElementContext = elementContext;
  26157. function Items(_ref2) {
  26158. let {
  26159. placeholder,
  26160. rootClientId,
  26161. renderAppender,
  26162. __experimentalAppenderTagName,
  26163. __experimentalLayout: layout = defaultLayout
  26164. } = _ref2;
  26165. const [intersectingBlocks, setIntersectingBlocks] = (0,external_wp_element_namespaceObject.useState)(new Set());
  26166. const intersectionObserver = (0,external_wp_element_namespaceObject.useMemo)(() => {
  26167. const {
  26168. IntersectionObserver: Observer
  26169. } = window;
  26170. if (!Observer) {
  26171. return;
  26172. }
  26173. return new Observer(entries => {
  26174. setIntersectingBlocks(oldIntersectingBlocks => {
  26175. const newIntersectingBlocks = new Set(oldIntersectingBlocks);
  26176. for (const entry of entries) {
  26177. const clientId = entry.target.getAttribute('data-block');
  26178. const action = entry.isIntersecting ? 'add' : 'delete';
  26179. newIntersectingBlocks[action](clientId);
  26180. }
  26181. return newIntersectingBlocks;
  26182. });
  26183. });
  26184. }, [setIntersectingBlocks]);
  26185. const {
  26186. order,
  26187. selectedBlocks
  26188. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  26189. const {
  26190. getBlockOrder,
  26191. getSelectedBlockClientIds
  26192. } = select(store);
  26193. return {
  26194. order: getBlockOrder(rootClientId),
  26195. selectedBlocks: getSelectedBlockClientIds()
  26196. };
  26197. }, [rootClientId]);
  26198. return (0,external_wp_element_namespaceObject.createElement)(LayoutProvider, {
  26199. value: layout
  26200. }, (0,external_wp_element_namespaceObject.createElement)(IntersectionObserver.Provider, {
  26201. value: intersectionObserver
  26202. }, order.map(clientId => (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
  26203. key: clientId,
  26204. value: // Only provide data asynchronously if the block is
  26205. // not visible and not selected.
  26206. !intersectingBlocks.has(clientId) && !selectedBlocks.includes(clientId)
  26207. }, (0,external_wp_element_namespaceObject.createElement)(block, {
  26208. rootClientId: rootClientId,
  26209. clientId: clientId
  26210. })))), order.length < 1 && placeholder, (0,external_wp_element_namespaceObject.createElement)(block_list_appender, {
  26211. tagName: __experimentalAppenderTagName,
  26212. rootClientId: rootClientId,
  26213. renderAppender: renderAppender
  26214. }));
  26215. }
  26216. function BlockListItems(props) {
  26217. // This component needs to always be synchronous as it's the one changing
  26218. // the async mode depending on the block selection.
  26219. return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
  26220. value: false
  26221. }, (0,external_wp_element_namespaceObject.createElement)(Items, props));
  26222. }
  26223. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/control.js
  26224. /**
  26225. * External dependencies
  26226. */
  26227. /**
  26228. * WordPress dependencies
  26229. */
  26230. /**
  26231. * Internal dependencies
  26232. */
  26233. const colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients'];
  26234. function ColorGradientControlInner(_ref) {
  26235. let {
  26236. colors,
  26237. gradients,
  26238. disableCustomColors,
  26239. disableCustomGradients,
  26240. __experimentalHasMultipleOrigins,
  26241. __experimentalIsRenderedInSidebar,
  26242. className,
  26243. label,
  26244. onColorChange,
  26245. onGradientChange,
  26246. colorValue,
  26247. gradientValue,
  26248. clearable,
  26249. showTitle = true,
  26250. enableAlpha
  26251. } = _ref;
  26252. const canChooseAColor = onColorChange && (!(0,external_lodash_namespaceObject.isEmpty)(colors) || !disableCustomColors);
  26253. const canChooseAGradient = onGradientChange && (!(0,external_lodash_namespaceObject.isEmpty)(gradients) || !disableCustomGradients);
  26254. const [currentTab, setCurrentTab] = (0,external_wp_element_namespaceObject.useState)(gradientValue ? 'gradient' : !!canChooseAColor && 'color');
  26255. if (!canChooseAColor && !canChooseAGradient) {
  26256. return null;
  26257. }
  26258. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, {
  26259. className: classnames_default()('block-editor-color-gradient-control', className)
  26260. }, (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  26261. className: "block-editor-color-gradient-control__fieldset"
  26262. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
  26263. spacing: 1
  26264. }, showTitle && (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_element_namespaceObject.createElement)("div", {
  26265. className: "block-editor-color-gradient-control__color-indicator"
  26266. }, (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.__experimentalToggleGroupControl, {
  26267. value: currentTab,
  26268. onChange: setCurrentTab,
  26269. label: (0,external_wp_i18n_namespaceObject.__)('Select color type'),
  26270. hideLabelFromVision: true,
  26271. isBlock: true
  26272. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
  26273. value: "color",
  26274. label: (0,external_wp_i18n_namespaceObject.__)('Solid')
  26275. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
  26276. value: "gradient",
  26277. label: (0,external_wp_i18n_namespaceObject.__)('Gradient')
  26278. })), (currentTab === 'color' || !canChooseAGradient) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorPalette, {
  26279. value: colorValue,
  26280. onChange: canChooseAGradient ? newColor => {
  26281. onColorChange(newColor);
  26282. onGradientChange();
  26283. } : onColorChange,
  26284. colors,
  26285. disableCustomColors,
  26286. __experimentalHasMultipleOrigins: __experimentalHasMultipleOrigins,
  26287. __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,
  26288. clearable: clearable,
  26289. enableAlpha: enableAlpha
  26290. }), (currentTab === 'gradient' || !canChooseAColor) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.GradientPicker, {
  26291. value: gradientValue,
  26292. onChange: canChooseAColor ? newGradient => {
  26293. onGradientChange(newGradient);
  26294. onColorChange();
  26295. } : onGradientChange,
  26296. gradients,
  26297. disableCustomGradients,
  26298. __experimentalHasMultipleOrigins: __experimentalHasMultipleOrigins,
  26299. __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,
  26300. clearable: clearable
  26301. }))));
  26302. }
  26303. function ColorGradientControlSelect(props) {
  26304. const colorGradientSettings = {};
  26305. colorGradientSettings.colors = useSetting('color.palette');
  26306. colorGradientSettings.gradients = useSetting('color.gradients');
  26307. colorGradientSettings.disableCustomColors = !useSetting('color.custom');
  26308. colorGradientSettings.disableCustomGradients = !useSetting('color.customGradient');
  26309. return (0,external_wp_element_namespaceObject.createElement)(ColorGradientControlInner, _extends({}, colorGradientSettings, props));
  26310. }
  26311. function ColorGradientControl(props) {
  26312. if ((0,external_lodash_namespaceObject.every)(colorsAndGradientKeys, key => props.hasOwnProperty(key))) {
  26313. return (0,external_wp_element_namespaceObject.createElement)(ColorGradientControlInner, props);
  26314. }
  26315. return (0,external_wp_element_namespaceObject.createElement)(ColorGradientControlSelect, props);
  26316. }
  26317. /* harmony default export */ var control = (ColorGradientControl);
  26318. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/dropdown.js
  26319. /**
  26320. * External dependencies
  26321. */
  26322. /**
  26323. * WordPress dependencies
  26324. */
  26325. /**
  26326. * Internal dependencies
  26327. */
  26328. function ColorGradientSettingsDropdown(_ref) {
  26329. let {
  26330. colors,
  26331. gradients,
  26332. disableCustomColors,
  26333. disableCustomGradients,
  26334. __experimentalHasMultipleOrigins,
  26335. __experimentalIsRenderedInSidebar,
  26336. enableAlpha,
  26337. settings
  26338. } = _ref;
  26339. let dropdownPosition;
  26340. if (__experimentalIsRenderedInSidebar) {
  26341. dropdownPosition = 'bottom left';
  26342. }
  26343. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, {
  26344. isBordered: true,
  26345. isSeparated: true,
  26346. className: "block-editor-panel-color-gradient-settings__item-group"
  26347. }, settings.map((setting, index) => setting && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  26348. key: index,
  26349. position: dropdownPosition,
  26350. className: "block-editor-panel-color-gradient-settings__dropdown",
  26351. contentClassName: "block-editor-panel-color-gradient-settings__dropdown-content",
  26352. renderToggle: _ref2 => {
  26353. var _setting$gradientValu;
  26354. let {
  26355. isOpen,
  26356. onToggle
  26357. } = _ref2;
  26358. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItem, {
  26359. onClick: onToggle,
  26360. className: classnames_default()('block-editor-panel-color-gradient-settings__item', {
  26361. 'is-open': isOpen
  26362. })
  26363. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
  26364. justify: "flex-start"
  26365. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
  26366. className: "block-editor-panel-color-gradient-settings__color-indicator",
  26367. colorValue: (_setting$gradientValu = setting.gradientValue) !== null && _setting$gradientValu !== void 0 ? _setting$gradientValu : setting.colorValue
  26368. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, setting.label)));
  26369. },
  26370. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(control, _extends({
  26371. showTitle: false,
  26372. colors,
  26373. gradients,
  26374. disableCustomColors,
  26375. disableCustomGradients,
  26376. __experimentalHasMultipleOrigins,
  26377. __experimentalIsRenderedInSidebar,
  26378. enableAlpha
  26379. }, setting))
  26380. })));
  26381. }
  26382. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/use-common-single-multiple-selects.js
  26383. /**
  26384. * Internal dependencies
  26385. */
  26386. function useCommonSingleMultipleSelects() {
  26387. return {
  26388. disableCustomColors: !useSetting('color.custom'),
  26389. disableCustomGradients: !useSetting('color.customGradient')
  26390. };
  26391. }
  26392. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js
  26393. /**
  26394. * WordPress dependencies
  26395. */
  26396. /**
  26397. * Internal dependencies
  26398. */
  26399. /**
  26400. * Retrieves color and gradient related settings.
  26401. *
  26402. * The arrays for colors and gradients are made up of color palettes from each
  26403. * origin i.e. "Core", "Theme", and "User".
  26404. *
  26405. * @return {Object} Color and gradient related settings.
  26406. */
  26407. function useMultipleOriginColorsAndGradients() {
  26408. const colorGradientSettings = useCommonSingleMultipleSelects();
  26409. const customColors = useSetting('color.palette.custom');
  26410. const themeColors = useSetting('color.palette.theme');
  26411. const defaultColors = useSetting('color.palette.default');
  26412. const shouldDisplayDefaultColors = useSetting('color.defaultPalette');
  26413. colorGradientSettings.colors = (0,external_wp_element_namespaceObject.useMemo)(() => {
  26414. const result = [];
  26415. if (themeColors && themeColors.length) {
  26416. result.push({
  26417. name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'),
  26418. colors: themeColors
  26419. });
  26420. }
  26421. if (shouldDisplayDefaultColors && defaultColors && defaultColors.length) {
  26422. result.push({
  26423. name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'),
  26424. colors: defaultColors
  26425. });
  26426. }
  26427. if (customColors && customColors.length) {
  26428. result.push({
  26429. name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette comes from the theme.'),
  26430. colors: customColors
  26431. });
  26432. }
  26433. return result;
  26434. }, [defaultColors, themeColors, customColors]);
  26435. const customGradients = useSetting('color.gradients.custom');
  26436. const themeGradients = useSetting('color.gradients.theme');
  26437. const defaultGradients = useSetting('color.gradients.default');
  26438. const shouldDisplayDefaultGradients = useSetting('color.defaultGradients');
  26439. colorGradientSettings.gradients = (0,external_wp_element_namespaceObject.useMemo)(() => {
  26440. const result = [];
  26441. if (themeGradients && themeGradients.length) {
  26442. result.push({
  26443. name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'),
  26444. gradients: themeGradients
  26445. });
  26446. }
  26447. if (shouldDisplayDefaultGradients && defaultGradients && defaultGradients.length) {
  26448. result.push({
  26449. name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'),
  26450. gradients: defaultGradients
  26451. });
  26452. }
  26453. if (customGradients && customGradients.length) {
  26454. result.push({
  26455. name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette is created by the user.'),
  26456. gradients: customGradients
  26457. });
  26458. }
  26459. return result;
  26460. }, [customGradients, themeGradients, defaultGradients]);
  26461. return colorGradientSettings;
  26462. }
  26463. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/utils.js
  26464. /**
  26465. * External dependencies
  26466. */
  26467. k([names, a11y]);
  26468. /**
  26469. * Provided an array of color objects as set by the theme or by the editor defaults,
  26470. * and the values of the defined color or custom color returns a color object describing the color.
  26471. *
  26472. * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
  26473. * @param {?string} definedColor A string containing the color slug.
  26474. * @param {?string} customColor A string containing the customColor value.
  26475. *
  26476. * @return {?Object} If definedColor is passed and the name is found in colors,
  26477. * the color object exactly as set by the theme or editor defaults is returned.
  26478. * Otherwise, an object that just sets the color is defined.
  26479. */
  26480. const getColorObjectByAttributeValues = (colors, definedColor, customColor) => {
  26481. if (definedColor) {
  26482. const colorObj = (0,external_lodash_namespaceObject.find)(colors, {
  26483. slug: definedColor
  26484. });
  26485. if (colorObj) {
  26486. return colorObj;
  26487. }
  26488. }
  26489. return {
  26490. color: customColor
  26491. };
  26492. };
  26493. /**
  26494. * 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.
  26495. *
  26496. * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
  26497. * @param {?string} colorValue A string containing the color value.
  26498. *
  26499. * @return {?Object} Color object included in the colors array whose color property equals colorValue.
  26500. * Returns undefined if no color object matches this requirement.
  26501. */
  26502. const getColorObjectByColorValue = (colors, colorValue) => {
  26503. return (0,external_lodash_namespaceObject.find)(colors, {
  26504. color: colorValue
  26505. });
  26506. };
  26507. /**
  26508. * Returns a class based on the context a color is being used and its slug.
  26509. *
  26510. * @param {string} colorContextName Context/place where color is being used e.g: background, text etc...
  26511. * @param {string} colorSlug Slug of the color.
  26512. *
  26513. * @return {?string} String with the class corresponding to the color in the provided context.
  26514. * Returns undefined if either colorContextName or colorSlug are not provided.
  26515. */
  26516. function getColorClassName(colorContextName, colorSlug) {
  26517. if (!colorContextName || !colorSlug) {
  26518. return undefined;
  26519. }
  26520. return `has-${(0,external_lodash_namespaceObject.kebabCase)(colorSlug)}-${colorContextName}`;
  26521. }
  26522. /**
  26523. * Given an array of color objects and a color value returns the color value of the most readable color in the array.
  26524. *
  26525. * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
  26526. * @param {?string} colorValue A string containing the color value.
  26527. *
  26528. * @return {string} String with the color value of the most readable color.
  26529. */
  26530. function getMostReadableColor(colors, colorValue) {
  26531. const colordColor = w(colorValue);
  26532. return (0,external_lodash_namespaceObject.maxBy)(colors, _ref => {
  26533. let {
  26534. color
  26535. } = _ref;
  26536. return colordColor.contrast(color);
  26537. }).color;
  26538. }
  26539. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-color.js
  26540. /**
  26541. * External dependencies
  26542. */
  26543. /**
  26544. * WordPress dependencies
  26545. */
  26546. /**
  26547. * Internal dependencies
  26548. */
  26549. // Defining empty array here instead of inline avoids unnecessary re-renders of
  26550. // color control.
  26551. const border_color_EMPTY_ARRAY = [];
  26552. /**
  26553. * Inspector control panel containing the border color related configuration.
  26554. *
  26555. * There is deliberate overlap between the colors and borders block supports
  26556. * relating to border color. It can be argued the border color controls could
  26557. * be included within either, or both, the colors and borders panels in the
  26558. * inspector controls. If they share the same block attributes it should not
  26559. * matter.
  26560. *
  26561. * @param {Object} props Block properties.
  26562. *
  26563. * @return {WPElement} Border color edit element.
  26564. */
  26565. function BorderColorEdit(props) {
  26566. const {
  26567. attributes: {
  26568. borderColor,
  26569. style
  26570. },
  26571. setAttributes
  26572. } = props;
  26573. const colorGradientSettings = useMultipleOriginColorsAndGradients();
  26574. const availableColors = colorGradientSettings.colors.reduce((colors, origin) => colors.concat(origin.colors), []);
  26575. const {
  26576. color: customBorderColor
  26577. } = (style === null || style === void 0 ? void 0 : style.border) || {};
  26578. const [colorValue, setColorValue] = (0,external_wp_element_namespaceObject.useState)(() => {
  26579. var _getColorObjectByAttr;
  26580. return (_getColorObjectByAttr = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
  26581. }); // Detect changes in the color attributes and update the colorValue to keep the
  26582. // UI in sync. This is necessary for situations when border controls interact with
  26583. // each other: eg, setting the border width to zero causes the color and style
  26584. // selections to be cleared.
  26585. (0,external_wp_element_namespaceObject.useEffect)(() => {
  26586. var _getColorObjectByAttr2;
  26587. setColorValue((_getColorObjectByAttr2 = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color);
  26588. }, [borderColor, customBorderColor, availableColors]);
  26589. const onChangeColor = value => {
  26590. setColorValue(value);
  26591. const colorObject = getColorObjectByColorValue(availableColors, value);
  26592. const newStyle = { ...style,
  26593. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  26594. color: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
  26595. }
  26596. }; // If empty slug, ensure undefined to remove attribute.
  26597. const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
  26598. setAttributes({
  26599. style: cleanEmptyObject(newStyle),
  26600. borderColor: newNamedColor
  26601. });
  26602. };
  26603. const settings = [{
  26604. label: (0,external_wp_i18n_namespaceObject.__)('Color'),
  26605. onColorChange: onChangeColor,
  26606. colorValue,
  26607. clearable: false
  26608. }];
  26609. return (0,external_wp_element_namespaceObject.createElement)(ColorGradientSettingsDropdown, _extends({
  26610. settings: settings,
  26611. disableCustomColors: true,
  26612. disableCustomGradients: true,
  26613. __experimentalHasMultipleOrigins: true,
  26614. __experimentalIsRenderedInSidebar: true,
  26615. enableAlpha: true
  26616. }, colorGradientSettings));
  26617. }
  26618. /**
  26619. * Checks if there is a current value in the border color block support
  26620. * attributes.
  26621. *
  26622. * @param {Object} props Block props.
  26623. * @return {boolean} Whether or not the block has a border color value set.
  26624. */
  26625. function hasBorderColorValue(props) {
  26626. var _style$border;
  26627. const {
  26628. attributes: {
  26629. borderColor,
  26630. style
  26631. }
  26632. } = props;
  26633. return !!borderColor || !!(style !== null && style !== void 0 && (_style$border = style.border) !== null && _style$border !== void 0 && _style$border.color);
  26634. }
  26635. /**
  26636. * Resets the border color block support attributes. This can be used when
  26637. * disabling the border color support controls for a block via a progressive
  26638. * discovery panel.
  26639. *
  26640. * @param {Object} props Block props.
  26641. * @param {Object} props.attributes Block's attributes.
  26642. * @param {Object} props.setAttributes Function to set block's attributes.
  26643. */
  26644. function resetBorderColor(_ref) {
  26645. let {
  26646. attributes = {},
  26647. setAttributes
  26648. } = _ref;
  26649. const {
  26650. style
  26651. } = attributes;
  26652. setAttributes({
  26653. borderColor: undefined,
  26654. style: removeBorderAttribute(style, 'color')
  26655. });
  26656. }
  26657. /**
  26658. * Filters registered block settings, extending attributes to include
  26659. * `borderColor` if needed.
  26660. *
  26661. * @param {Object} settings Original block settings.
  26662. *
  26663. * @return {Object} Updated block settings.
  26664. */
  26665. function addAttributes(settings) {
  26666. if (!hasBorderSupport(settings, 'color')) {
  26667. return settings;
  26668. } // Allow blocks to specify default value if needed.
  26669. if (settings.attributes.borderColor) {
  26670. return settings;
  26671. } // Add new borderColor attribute to block settings.
  26672. return { ...settings,
  26673. attributes: { ...settings.attributes,
  26674. borderColor: {
  26675. type: 'string'
  26676. }
  26677. }
  26678. };
  26679. }
  26680. /**
  26681. * Override props assigned to save component to inject border color.
  26682. *
  26683. * @param {Object} props Additional props applied to save element.
  26684. * @param {Object} blockType Block type definition.
  26685. * @param {Object} attributes Block's attributes.
  26686. *
  26687. * @return {Object} Filtered props to apply to save element.
  26688. */
  26689. function border_color_addSaveProps(props, blockType, attributes) {
  26690. var _style$border2;
  26691. if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType, BORDER_SUPPORT_KEY, 'color')) {
  26692. return props;
  26693. }
  26694. const {
  26695. borderColor,
  26696. style
  26697. } = attributes;
  26698. const borderColorClass = getColorClassName('border-color', borderColor);
  26699. const newClassName = classnames_default()(props.className, {
  26700. 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.color),
  26701. [borderColorClass]: !!borderColorClass
  26702. }); // If we are clearing the last of the previous classes in `className`
  26703. // set it to `undefined` to avoid rendering empty DOM attributes.
  26704. props.className = newClassName ? newClassName : undefined;
  26705. return props;
  26706. }
  26707. /**
  26708. * Filters the registered block settings to apply border color styles and
  26709. * classnames to the block edit wrapper.
  26710. *
  26711. * @param {Object} settings Original block settings.
  26712. *
  26713. * @return {Object} Filtered block settings.
  26714. */
  26715. function addEditProps(settings) {
  26716. if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings, BORDER_SUPPORT_KEY, 'color')) {
  26717. return settings;
  26718. }
  26719. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  26720. settings.getEditWrapperProps = attributes => {
  26721. let props = {};
  26722. if (existingGetEditWrapperProps) {
  26723. props = existingGetEditWrapperProps(attributes);
  26724. }
  26725. return border_color_addSaveProps(props, settings, attributes);
  26726. };
  26727. return settings;
  26728. }
  26729. /**
  26730. * This adds inline styles for color palette colors.
  26731. * Ideally, this is not needed and themes should load their palettes on the editor.
  26732. *
  26733. * @param {Function} BlockListBlock Original component.
  26734. *
  26735. * @return {Function} Wrapped component.
  26736. */
  26737. const withBorderColorPaletteStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  26738. var _getColorObjectByAttr3, _props$wrapperProps;
  26739. const {
  26740. name,
  26741. attributes
  26742. } = props;
  26743. const {
  26744. borderColor
  26745. } = attributes;
  26746. const colors = useSetting('color.palette') || border_color_EMPTY_ARRAY;
  26747. if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name, BORDER_SUPPORT_KEY, 'color')) {
  26748. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
  26749. }
  26750. const extraStyles = {
  26751. borderColor: borderColor ? (_getColorObjectByAttr3 = getColorObjectByAttributeValues(colors, borderColor)) === null || _getColorObjectByAttr3 === void 0 ? void 0 : _getColorObjectByAttr3.color : undefined
  26752. };
  26753. let wrapperProps = props.wrapperProps;
  26754. wrapperProps = { ...props.wrapperProps,
  26755. style: { ...extraStyles,
  26756. ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style)
  26757. }
  26758. };
  26759. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  26760. wrapperProps: wrapperProps
  26761. }));
  26762. });
  26763. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
  26764. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', border_color_addSaveProps);
  26765. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
  26766. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
  26767. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/utils.js
  26768. /**
  26769. * WordPress dependencies
  26770. */
  26771. /**
  26772. * Gets the (non-undefined) item with the highest occurrence within an array
  26773. * Based in part on: https://stackoverflow.com/a/20762713
  26774. *
  26775. * Undefined values are always sorted to the end by `sort`, so this function
  26776. * returns the first element, to always prioritize real values over undefined
  26777. * values.
  26778. *
  26779. * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description
  26780. *
  26781. * @param {Array<any>} inputArray Array of items to check.
  26782. * @return {any} The item with the most occurrences.
  26783. */
  26784. function mode(inputArray) {
  26785. const arr = [...inputArray];
  26786. return arr.sort((a, b) => inputArray.filter(v => v === b).length - inputArray.filter(v => v === a).length).shift();
  26787. }
  26788. /**
  26789. * Returns the most common CSS unit in the radius values.
  26790. * Falls back to `px` as a default unit.
  26791. *
  26792. * @param {Object|string} values Radius values.
  26793. * @return {string} Most common CSS unit in values. Default: `px`.
  26794. */
  26795. function getAllUnit() {
  26796. let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  26797. if (typeof values === 'string') {
  26798. const [, unit] = (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(values);
  26799. return unit || 'px';
  26800. }
  26801. const allUnits = Object.values(values).map(value => {
  26802. const [, unit] = (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(value);
  26803. return unit;
  26804. });
  26805. return mode(allUnits) || 'px';
  26806. }
  26807. /**
  26808. * Gets the 'all' input value and unit from values data.
  26809. *
  26810. * @param {Object|string} values Radius values.
  26811. * @return {string} A value + unit for the 'all' input.
  26812. */
  26813. function getAllValue() {
  26814. let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  26815. /**
  26816. * Border radius support was originally a single pixel value.
  26817. *
  26818. * To maintain backwards compatibility treat this case as the all value.
  26819. */
  26820. if (typeof values === 'string') {
  26821. return values;
  26822. }
  26823. const parsedQuantitiesAndUnits = Object.values(values).map(value => (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(value));
  26824. const allValues = parsedQuantitiesAndUnits.map(value => {
  26825. var _value$;
  26826. return (_value$ = value[0]) !== null && _value$ !== void 0 ? _value$ : '';
  26827. });
  26828. const allUnits = parsedQuantitiesAndUnits.map(value => value[1]);
  26829. const value = allValues.every(v => v === allValues[0]) ? allValues[0] : '';
  26830. const unit = mode(allUnits);
  26831. const allValue = value === 0 || value ? `${value}${unit}` : undefined;
  26832. return allValue;
  26833. }
  26834. /**
  26835. * Checks to determine if values are mixed.
  26836. *
  26837. * @param {Object} values Radius values.
  26838. * @return {boolean} Whether values are mixed.
  26839. */
  26840. function hasMixedValues() {
  26841. let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  26842. const allValue = getAllValue(values);
  26843. const isMixed = typeof values === 'string' ? false : isNaN(parseFloat(allValue));
  26844. return isMixed;
  26845. }
  26846. /**
  26847. * Checks to determine if values are defined.
  26848. *
  26849. * @param {Object} values Radius values.
  26850. * @return {boolean} Whether values are mixed.
  26851. */
  26852. function hasDefinedValues(values) {
  26853. if (!values) {
  26854. return false;
  26855. } // A string value represents a shorthand value.
  26856. if (typeof values === 'string') {
  26857. return true;
  26858. } // An object represents longhand border radius values, if any are set
  26859. // flag values as being defined.
  26860. const filteredValues = Object.values(values).filter(value => {
  26861. return !!value || value === 0;
  26862. });
  26863. return !!filteredValues.length;
  26864. }
  26865. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/all-input-control.js
  26866. /**
  26867. * WordPress dependencies
  26868. */
  26869. /**
  26870. * Internal dependencies
  26871. */
  26872. function AllInputControl(_ref) {
  26873. let {
  26874. onChange,
  26875. values,
  26876. ...props
  26877. } = _ref;
  26878. const allValue = getAllValue(values);
  26879. const hasValues = hasDefinedValues(values);
  26880. const isMixed = hasValues && hasMixedValues(values);
  26881. const allPlaceholder = isMixed ? (0,external_wp_i18n_namespaceObject.__)('Mixed') : null;
  26882. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, _extends({}, props, {
  26883. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Border radius'),
  26884. disableUnits: isMixed,
  26885. isOnly: true,
  26886. value: allValue,
  26887. onChange: onChange,
  26888. placeholder: allPlaceholder
  26889. }));
  26890. }
  26891. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/input-controls.js
  26892. /**
  26893. * WordPress dependencies
  26894. */
  26895. const CORNERS = {
  26896. topLeft: (0,external_wp_i18n_namespaceObject.__)('Top left'),
  26897. topRight: (0,external_wp_i18n_namespaceObject.__)('Top right'),
  26898. bottomLeft: (0,external_wp_i18n_namespaceObject.__)('Bottom left'),
  26899. bottomRight: (0,external_wp_i18n_namespaceObject.__)('Bottom right')
  26900. };
  26901. function BoxInputControls(_ref) {
  26902. let {
  26903. onChange,
  26904. values: valuesProp,
  26905. ...props
  26906. } = _ref;
  26907. const createHandleOnChange = corner => next => {
  26908. if (!onChange) {
  26909. return;
  26910. }
  26911. onChange({ ...values,
  26912. [corner]: next ? next : undefined
  26913. });
  26914. }; // For shorthand style & backwards compatibility, handle flat string value.
  26915. const values = typeof valuesProp !== 'string' ? valuesProp : {
  26916. topLeft: valuesProp,
  26917. topRight: valuesProp,
  26918. bottomLeft: valuesProp,
  26919. bottomRight: valuesProp
  26920. }; // Controls are wrapped in tooltips as visible labels aren't desired here.
  26921. return (0,external_wp_element_namespaceObject.createElement)("div", {
  26922. className: "components-border-radius-control__input-controls-wrapper"
  26923. }, Object.entries(CORNERS).map(_ref2 => {
  26924. let [key, label] = _ref2;
  26925. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, _extends({}, props, {
  26926. key: key,
  26927. "aria-label": label,
  26928. value: values[key],
  26929. onChange: createHandleOnChange(key)
  26930. }));
  26931. }));
  26932. }
  26933. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link.js
  26934. /**
  26935. * WordPress dependencies
  26936. */
  26937. const link_link = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  26938. xmlns: "http://www.w3.org/2000/svg",
  26939. viewBox: "0 0 24 24"
  26940. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  26941. 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"
  26942. }));
  26943. /* harmony default export */ var library_link = (link_link);
  26944. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link-off.js
  26945. /**
  26946. * WordPress dependencies
  26947. */
  26948. const linkOff = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  26949. xmlns: "http://www.w3.org/2000/svg",
  26950. viewBox: "0 0 24 24"
  26951. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  26952. 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"
  26953. }));
  26954. /* harmony default export */ var link_off = (linkOff);
  26955. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/linked-button.js
  26956. /**
  26957. * WordPress dependencies
  26958. */
  26959. function LinkedButton(_ref) {
  26960. let {
  26961. isLinked,
  26962. ...props
  26963. } = _ref;
  26964. const label = isLinked ? (0,external_wp_i18n_namespaceObject.__)('Unlink Radii') : (0,external_wp_i18n_namespaceObject.__)('Link Radii');
  26965. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
  26966. text: label
  26967. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
  26968. className: "component-border-radius-control__linked-button",
  26969. isPrimary: isLinked,
  26970. isSecondary: !isLinked,
  26971. isSmall: true,
  26972. icon: isLinked ? library_link : link_off,
  26973. iconSize: 16,
  26974. "aria-label": label
  26975. })));
  26976. }
  26977. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/index.js
  26978. /**
  26979. * WordPress dependencies
  26980. */
  26981. /**
  26982. * Internal dependencies
  26983. */
  26984. const DEFAULT_VALUES = {
  26985. topLeft: null,
  26986. topRight: null,
  26987. bottomLeft: null,
  26988. bottomRight: null
  26989. };
  26990. const MIN_BORDER_RADIUS_VALUE = 0;
  26991. const MAX_BORDER_RADIUS_VALUES = {
  26992. px: 100,
  26993. em: 20,
  26994. rem: 20
  26995. };
  26996. /**
  26997. * Control to display border radius options.
  26998. *
  26999. * @param {Object} props Component props.
  27000. * @param {Function} props.onChange Callback to handle onChange.
  27001. * @param {Object} props.values Border radius values.
  27002. *
  27003. * @return {WPElement} Custom border radius control.
  27004. */
  27005. function BorderRadiusControl(_ref) {
  27006. let {
  27007. onChange,
  27008. values
  27009. } = _ref;
  27010. const [isLinked, setIsLinked] = (0,external_wp_element_namespaceObject.useState)(!hasDefinedValues(values) || !hasMixedValues(values));
  27011. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  27012. availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem']
  27013. });
  27014. const unit = getAllUnit(values);
  27015. const unitConfig = units && units.find(item => item.value === unit);
  27016. const step = (unitConfig === null || unitConfig === void 0 ? void 0 : unitConfig.step) || 1;
  27017. const [allValue] = (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(getAllValue(values));
  27018. const toggleLinked = () => setIsLinked(!isLinked);
  27019. const handleSliderChange = next => {
  27020. onChange(next !== undefined ? `${next}${unit}` : undefined);
  27021. };
  27022. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  27023. className: "components-border-radius-control"
  27024. }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Radius')), (0,external_wp_element_namespaceObject.createElement)("div", {
  27025. className: "components-border-radius-control__wrapper"
  27026. }, isLinked ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(AllInputControl, {
  27027. className: "components-border-radius-control__unit-control",
  27028. values: values,
  27029. min: MIN_BORDER_RADIUS_VALUE,
  27030. onChange: onChange,
  27031. units: units
  27032. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.RangeControl, {
  27033. className: "components-border-radius-control__range-control",
  27034. value: allValue !== null && allValue !== void 0 ? allValue : '',
  27035. min: MIN_BORDER_RADIUS_VALUE,
  27036. max: MAX_BORDER_RADIUS_VALUES[unit],
  27037. initialPosition: 0,
  27038. withInputField: false,
  27039. onChange: handleSliderChange,
  27040. step: step
  27041. })) : (0,external_wp_element_namespaceObject.createElement)(BoxInputControls, {
  27042. min: MIN_BORDER_RADIUS_VALUE,
  27043. onChange: onChange,
  27044. values: values || DEFAULT_VALUES,
  27045. units: units
  27046. }), (0,external_wp_element_namespaceObject.createElement)(LinkedButton, {
  27047. onClick: toggleLinked,
  27048. isLinked: isLinked
  27049. })));
  27050. }
  27051. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-radius.js
  27052. /**
  27053. * Internal dependencies
  27054. */
  27055. /**
  27056. * Inspector control panel containing the border radius related configuration.
  27057. *
  27058. * @param {Object} props Block properties.
  27059. *
  27060. * @return {WPElement} Border radius edit element.
  27061. */
  27062. function BorderRadiusEdit(props) {
  27063. var _style$border;
  27064. const {
  27065. attributes: {
  27066. style
  27067. },
  27068. setAttributes
  27069. } = props;
  27070. const onChange = newRadius => {
  27071. let newStyle = { ...style,
  27072. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  27073. radius: newRadius
  27074. }
  27075. };
  27076. if (newRadius === undefined || newRadius === '') {
  27077. newStyle = cleanEmptyObject(newStyle);
  27078. }
  27079. setAttributes({
  27080. style: newStyle
  27081. });
  27082. };
  27083. return (0,external_wp_element_namespaceObject.createElement)(BorderRadiusControl, {
  27084. values: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius,
  27085. onChange: onChange
  27086. });
  27087. }
  27088. /**
  27089. * Checks if there is a current value in the border radius block support
  27090. * attributes.
  27091. *
  27092. * @param {Object} props Block props.
  27093. * @return {boolean} Whether or not the block has a border radius value set.
  27094. */
  27095. function hasBorderRadiusValue(props) {
  27096. var _props$attributes$sty, _props$attributes$sty2;
  27097. 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;
  27098. if (typeof borderRadius === 'object') {
  27099. return Object.entries(borderRadius).some(Boolean);
  27100. }
  27101. return !!borderRadius;
  27102. }
  27103. /**
  27104. * Resets the border radius block support attributes. This can be used when
  27105. * disabling the border radius support controls for a block via a progressive
  27106. * discovery panel.
  27107. *
  27108. * @param {Object} props Block props.
  27109. * @param {Object} props.attributes Block's attributes.
  27110. * @param {Object} props.setAttributes Function to set block's attributes.
  27111. */
  27112. function resetBorderRadius(_ref) {
  27113. let {
  27114. attributes = {},
  27115. setAttributes
  27116. } = _ref;
  27117. const {
  27118. style
  27119. } = attributes;
  27120. setAttributes({
  27121. style: removeBorderAttribute(style, 'radius')
  27122. });
  27123. }
  27124. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/line-solid.js
  27125. /**
  27126. * WordPress dependencies
  27127. */
  27128. const lineSolid = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  27129. xmlns: "http://www.w3.org/2000/svg",
  27130. width: "24",
  27131. height: "24",
  27132. fill: "none"
  27133. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  27134. d: "M5 11.25h14v1.5H5z"
  27135. }));
  27136. /* harmony default export */ var line_solid = (lineSolid);
  27137. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/line-dashed.js
  27138. /**
  27139. * WordPress dependencies
  27140. */
  27141. const lineDashed = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  27142. xmlns: "http://www.w3.org/2000/svg",
  27143. width: "24",
  27144. height: "24",
  27145. fill: "none"
  27146. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  27147. fillRule: "evenodd",
  27148. d: "M5 11.25h3v1.5H5v-1.5zm5.5 0h3v1.5h-3v-1.5zm8.5 0h-3v1.5h3v-1.5z",
  27149. clipRule: "evenodd"
  27150. }));
  27151. /* harmony default export */ var line_dashed = (lineDashed);
  27152. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/line-dotted.js
  27153. /**
  27154. * WordPress dependencies
  27155. */
  27156. const lineDotted = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  27157. xmlns: "http://www.w3.org/2000/svg",
  27158. width: "24",
  27159. height: "24",
  27160. fill: "none"
  27161. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  27162. fillRule: "evenodd",
  27163. d: "M5.25 11.25h1.5v1.5h-1.5v-1.5zm3 0h1.5v1.5h-1.5v-1.5zm4.5 0h-1.5v1.5h1.5v-1.5zm1.5 0h1.5v1.5h-1.5v-1.5zm4.5 0h-1.5v1.5h1.5v-1.5z",
  27164. clipRule: "evenodd"
  27165. }));
  27166. /* harmony default export */ var line_dotted = (lineDotted);
  27167. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-style-control/index.js
  27168. /**
  27169. * WordPress dependencies
  27170. */
  27171. const BORDER_STYLES = [{
  27172. label: (0,external_wp_i18n_namespaceObject.__)('Solid'),
  27173. icon: line_solid,
  27174. value: 'solid'
  27175. }, {
  27176. label: (0,external_wp_i18n_namespaceObject.__)('Dashed'),
  27177. icon: line_dashed,
  27178. value: 'dashed'
  27179. }, {
  27180. label: (0,external_wp_i18n_namespaceObject.__)('Dotted'),
  27181. icon: line_dotted,
  27182. value: 'dotted'
  27183. }];
  27184. /**
  27185. * Control to display border style options.
  27186. *
  27187. * @param {Object} props Component props.
  27188. * @param {Function} props.onChange Handler for changing border style selection.
  27189. * @param {string} props.value Currently selected border style value.
  27190. *
  27191. * @return {WPElement} Custom border style segmented control.
  27192. */
  27193. function BorderStyleControl(_ref) {
  27194. let {
  27195. onChange,
  27196. value
  27197. } = _ref;
  27198. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  27199. className: "components-border-style-control"
  27200. }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Style')), (0,external_wp_element_namespaceObject.createElement)("div", {
  27201. className: "components-border-style-control__buttons"
  27202. }, BORDER_STYLES.map(borderStyle => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  27203. key: borderStyle.value,
  27204. icon: borderStyle.icon,
  27205. isSmall: true,
  27206. isPressed: borderStyle.value === value,
  27207. onClick: () => onChange(borderStyle.value === value ? undefined : borderStyle.value),
  27208. "aria-label": borderStyle.label
  27209. }))));
  27210. }
  27211. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-style.js
  27212. /**
  27213. * Internal dependencies
  27214. */
  27215. /**
  27216. * Inspector control for configuring border style property.
  27217. *
  27218. * @param {Object} props Block properties.
  27219. *
  27220. * @return {WPElement} Border style edit element.
  27221. */
  27222. const BorderStyleEdit = props => {
  27223. var _style$border;
  27224. const {
  27225. attributes: {
  27226. style
  27227. },
  27228. setAttributes
  27229. } = props;
  27230. const onChange = newBorderStyle => {
  27231. const newStyleAttributes = { ...style,
  27232. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  27233. style: newBorderStyle
  27234. }
  27235. };
  27236. setAttributes({
  27237. style: cleanEmptyObject(newStyleAttributes)
  27238. });
  27239. };
  27240. return (0,external_wp_element_namespaceObject.createElement)(BorderStyleControl, {
  27241. value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.style,
  27242. onChange: onChange
  27243. });
  27244. };
  27245. /**
  27246. * Checks if there is a current value in the border style block support
  27247. * attributes.
  27248. *
  27249. * @param {Object} props Block props.
  27250. * @return {boolean} Whether or not the block has a border style value set.
  27251. */
  27252. function hasBorderStyleValue(props) {
  27253. var _props$attributes$sty, _props$attributes$sty2;
  27254. return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.border) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.style);
  27255. }
  27256. /**
  27257. * Resets the border style block support attribute. This can be used when
  27258. * disabling the border style support control for a block via a progressive
  27259. * discovery panel.
  27260. *
  27261. * @param {Object} props Block props.
  27262. * @param {Object} props.attributes Block's attributes.
  27263. * @param {Object} props.setAttributes Function to set block's attributes.
  27264. */
  27265. function resetBorderStyle(_ref) {
  27266. let {
  27267. attributes = {},
  27268. setAttributes
  27269. } = _ref;
  27270. const {
  27271. style
  27272. } = attributes;
  27273. setAttributes({
  27274. style: removeBorderAttribute(style, 'style')
  27275. });
  27276. }
  27277. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-width.js
  27278. /**
  27279. * WordPress dependencies
  27280. */
  27281. /**
  27282. * Internal dependencies
  27283. */
  27284. const MIN_BORDER_WIDTH = 0;
  27285. /**
  27286. * Inspector control for configuring border width property.
  27287. *
  27288. * @param {Object} props Block properties.
  27289. *
  27290. * @return {WPElement} Border width edit element.
  27291. */
  27292. const BorderWidthEdit = props => {
  27293. const {
  27294. attributes: {
  27295. borderColor,
  27296. style
  27297. },
  27298. setAttributes
  27299. } = props;
  27300. const {
  27301. width,
  27302. color: customBorderColor,
  27303. style: borderStyle
  27304. } = (style === null || style === void 0 ? void 0 : style.border) || {}; // Used to temporarily track previous border color & style selections to be
  27305. // able to restore them when border width changes from zero value.
  27306. const [styleSelection, setStyleSelection] = (0,external_wp_element_namespaceObject.useState)();
  27307. const [colorSelection, setColorSelection] = (0,external_wp_element_namespaceObject.useState)();
  27308. const [customColorSelection, setCustomColorSelection] = (0,external_wp_element_namespaceObject.useState)();
  27309. const onChange = newWidth => {
  27310. let newStyle = { ...style,
  27311. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  27312. width: newWidth
  27313. }
  27314. }; // Used to clear named border color attribute.
  27315. let borderPaletteColor = borderColor;
  27316. const hasZeroWidth = parseFloat(newWidth) === 0;
  27317. const hadPreviousZeroWidth = parseFloat(width) === 0; // Setting the border width explicitly to zero will also set the
  27318. // border style to `none` and clear border color attributes.
  27319. if (hasZeroWidth && !hadPreviousZeroWidth) {
  27320. // Before clearing color and style selections, keep track of
  27321. // the current selections so they can be restored when the width
  27322. // changes to a non-zero value.
  27323. setColorSelection(borderColor);
  27324. setCustomColorSelection(customBorderColor);
  27325. setStyleSelection(borderStyle); // Clear style and color attributes.
  27326. borderPaletteColor = undefined;
  27327. newStyle.border.color = undefined;
  27328. newStyle.border.style = 'none';
  27329. }
  27330. if (!hasZeroWidth && hadPreviousZeroWidth) {
  27331. // Restore previous border style selection if width is now not zero and
  27332. // border style was 'none'. This is to support changes to the UI which
  27333. // change the border style UI to a segmented control without a "none"
  27334. // option.
  27335. if (borderStyle === 'none') {
  27336. newStyle.border.style = styleSelection;
  27337. } // Restore previous border color selection if width is no longer zero
  27338. // and current border color is undefined.
  27339. if (borderColor === undefined) {
  27340. borderPaletteColor = colorSelection;
  27341. newStyle.border.color = customColorSelection;
  27342. }
  27343. } // If width was reset, clean out undefined styles.
  27344. if (newWidth === undefined || newWidth === '') {
  27345. newStyle = cleanEmptyObject(newStyle);
  27346. }
  27347. setAttributes({
  27348. borderColor: borderPaletteColor,
  27349. style: newStyle
  27350. });
  27351. };
  27352. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  27353. availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem']
  27354. });
  27355. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
  27356. value: width,
  27357. label: (0,external_wp_i18n_namespaceObject.__)('Width'),
  27358. min: MIN_BORDER_WIDTH,
  27359. onChange: onChange,
  27360. units: units
  27361. });
  27362. };
  27363. /**
  27364. * Checks if there is a current value in the border width block support
  27365. * attributes.
  27366. *
  27367. * @param {Object} props Block props.
  27368. * @return {boolean} Whether or not the block has a border width value set.
  27369. */
  27370. function hasBorderWidthValue(props) {
  27371. var _props$attributes$sty, _props$attributes$sty2;
  27372. return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.border) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.width);
  27373. }
  27374. /**
  27375. * Resets the border width block support attribute. This can be used when
  27376. * disabling the border width support control for a block via a progressive
  27377. * discovery panel.
  27378. *
  27379. * @param {Object} props Block props.
  27380. * @param {Object} props.attributes Block's attributes.
  27381. * @param {Object} props.setAttributes Function to set block's attributes.
  27382. */
  27383. function resetBorderWidth(_ref) {
  27384. let {
  27385. attributes = {},
  27386. setAttributes
  27387. } = _ref;
  27388. const {
  27389. style
  27390. } = attributes;
  27391. setAttributes({
  27392. style: removeBorderAttribute(style, 'width')
  27393. });
  27394. }
  27395. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border.js
  27396. /**
  27397. * WordPress dependencies
  27398. */
  27399. /**
  27400. * Internal dependencies
  27401. */
  27402. const BORDER_SUPPORT_KEY = '__experimentalBorder';
  27403. function BorderPanel(props) {
  27404. const {
  27405. clientId
  27406. } = props;
  27407. const isColorSupported = useSetting('border.color') && hasBorderSupport(props.name, 'color');
  27408. const isRadiusSupported = useSetting('border.radius') && hasBorderSupport(props.name, 'radius');
  27409. const isStyleSupported = useSetting('border.style') && hasBorderSupport(props.name, 'style');
  27410. const isWidthSupported = useSetting('border.width') && hasBorderSupport(props.name, 'width');
  27411. const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
  27412. if (isDisabled) {
  27413. return null;
  27414. }
  27415. const defaultBorderControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
  27416. const createResetAllFilter = function (borderAttribute) {
  27417. let topLevelAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  27418. return newAttributes => {
  27419. var _newAttributes$style;
  27420. return { ...newAttributes,
  27421. ...topLevelAttributes,
  27422. style: { ...newAttributes.style,
  27423. border: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style.border),
  27424. [borderAttribute]: undefined
  27425. }
  27426. }
  27427. };
  27428. };
  27429. };
  27430. return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
  27431. __experimentalGroup: "border"
  27432. }, isWidthSupported && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  27433. className: "single-column",
  27434. hasValue: () => hasBorderWidthValue(props),
  27435. label: (0,external_wp_i18n_namespaceObject.__)('Width'),
  27436. onDeselect: () => resetBorderWidth(props),
  27437. isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.width,
  27438. resetAllFilter: createResetAllFilter('width'),
  27439. panelId: clientId
  27440. }, (0,external_wp_element_namespaceObject.createElement)(BorderWidthEdit, props)), isStyleSupported && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  27441. className: "single-column",
  27442. hasValue: () => hasBorderStyleValue(props),
  27443. label: (0,external_wp_i18n_namespaceObject.__)('Style'),
  27444. onDeselect: () => resetBorderStyle(props),
  27445. isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.style,
  27446. resetAllFilter: createResetAllFilter('style'),
  27447. panelId: clientId
  27448. }, (0,external_wp_element_namespaceObject.createElement)(BorderStyleEdit, props)), isColorSupported && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  27449. hasValue: () => hasBorderColorValue(props),
  27450. label: (0,external_wp_i18n_namespaceObject.__)('Color'),
  27451. onDeselect: () => resetBorderColor(props),
  27452. isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color,
  27453. resetAllFilter: createResetAllFilter('color', {
  27454. borderColor: undefined
  27455. }),
  27456. panelId: clientId
  27457. }, (0,external_wp_element_namespaceObject.createElement)(BorderColorEdit, props)), isRadiusSupported && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  27458. hasValue: () => hasBorderRadiusValue(props),
  27459. label: (0,external_wp_i18n_namespaceObject.__)('Radius'),
  27460. onDeselect: () => resetBorderRadius(props),
  27461. isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.radius,
  27462. resetAllFilter: createResetAllFilter('radius'),
  27463. panelId: clientId
  27464. }, (0,external_wp_element_namespaceObject.createElement)(BorderRadiusEdit, props)));
  27465. }
  27466. /**
  27467. * Determine whether there is block support for border properties.
  27468. *
  27469. * @param {string} blockName Block name.
  27470. * @param {string} feature Border feature to check support for.
  27471. *
  27472. * @return {boolean} Whether there is support.
  27473. */
  27474. function hasBorderSupport(blockName) {
  27475. let feature = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'any';
  27476. if (external_wp_element_namespaceObject.Platform.OS !== 'web') {
  27477. return false;
  27478. }
  27479. const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, BORDER_SUPPORT_KEY);
  27480. if (support === true) {
  27481. return true;
  27482. }
  27483. if (feature === 'any') {
  27484. 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);
  27485. }
  27486. return !!(support !== null && support !== void 0 && support[feature]);
  27487. }
  27488. /**
  27489. * Returns a new style object where the specified border attribute has been
  27490. * removed.
  27491. *
  27492. * @param {Object} style Styles from block attributes.
  27493. * @param {string} attribute The border style attribute to clear.
  27494. *
  27495. * @return {Object} Style object with the specified attribute removed.
  27496. */
  27497. function removeBorderAttribute(style, attribute) {
  27498. return cleanEmptyObject({ ...style,
  27499. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  27500. [attribute]: undefined
  27501. }
  27502. });
  27503. }
  27504. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradients/use-gradient.js
  27505. /**
  27506. * External dependencies
  27507. */
  27508. /**
  27509. * WordPress dependencies
  27510. */
  27511. /**
  27512. * Internal dependencies
  27513. */
  27514. function __experimentalGetGradientClass(gradientSlug) {
  27515. if (!gradientSlug) {
  27516. return undefined;
  27517. }
  27518. return `has-${gradientSlug}-gradient-background`;
  27519. }
  27520. /**
  27521. * Retrieves the gradient value per slug.
  27522. *
  27523. * @param {Array} gradients Gradient Palette
  27524. * @param {string} slug Gradient slug
  27525. *
  27526. * @return {string} Gradient value.
  27527. */
  27528. function getGradientValueBySlug(gradients, slug) {
  27529. const gradient = (0,external_lodash_namespaceObject.find)(gradients, ['slug', slug]);
  27530. return gradient && gradient.gradient;
  27531. }
  27532. function __experimentalGetGradientObjectByGradientValue(gradients, value) {
  27533. const gradient = (0,external_lodash_namespaceObject.find)(gradients, ['gradient', value]);
  27534. return gradient;
  27535. }
  27536. /**
  27537. * Retrieves the gradient slug per slug.
  27538. *
  27539. * @param {Array} gradients Gradient Palette
  27540. * @param {string} value Gradient value
  27541. * @return {string} Gradient slug.
  27542. */
  27543. function getGradientSlugByValue(gradients, value) {
  27544. const gradient = __experimentalGetGradientObjectByGradientValue(gradients, value);
  27545. return gradient && gradient.slug;
  27546. }
  27547. function __experimentalUseGradient() {
  27548. let {
  27549. gradientAttribute = 'gradient',
  27550. customGradientAttribute = 'customGradient'
  27551. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  27552. const {
  27553. clientId
  27554. } = useBlockEditContext();
  27555. const userGradientPalette = useSetting('color.gradients.custom');
  27556. const themeGradientPalette = useSetting('color.gradients.theme');
  27557. const defaultGradientPalette = useSetting('color.gradients.default');
  27558. const allGradients = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userGradientPalette || []), ...(themeGradientPalette || []), ...(defaultGradientPalette || [])], [userGradientPalette, themeGradientPalette, defaultGradientPalette]);
  27559. const {
  27560. gradient,
  27561. customGradient
  27562. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  27563. const {
  27564. getBlockAttributes
  27565. } = select(store);
  27566. const attributes = getBlockAttributes(clientId) || {};
  27567. return {
  27568. customGradient: attributes[customGradientAttribute],
  27569. gradient: attributes[gradientAttribute]
  27570. };
  27571. }, [clientId, gradientAttribute, customGradientAttribute]);
  27572. const {
  27573. updateBlockAttributes
  27574. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  27575. const setGradient = (0,external_wp_element_namespaceObject.useCallback)(newGradientValue => {
  27576. const slug = getGradientSlugByValue(allGradients, newGradientValue);
  27577. if (slug) {
  27578. updateBlockAttributes(clientId, {
  27579. [gradientAttribute]: slug,
  27580. [customGradientAttribute]: undefined
  27581. });
  27582. return;
  27583. }
  27584. updateBlockAttributes(clientId, {
  27585. [gradientAttribute]: undefined,
  27586. [customGradientAttribute]: newGradientValue
  27587. });
  27588. }, [allGradients, clientId, updateBlockAttributes]);
  27589. const gradientClass = __experimentalGetGradientClass(gradient);
  27590. let gradientValue;
  27591. if (gradient) {
  27592. gradientValue = getGradientValueBySlug(allGradients, gradient);
  27593. } else {
  27594. gradientValue = customGradient;
  27595. }
  27596. return {
  27597. gradientClass,
  27598. gradientValue,
  27599. setGradient
  27600. };
  27601. }
  27602. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/contrast-checker/index.js
  27603. /**
  27604. * External dependencies
  27605. */
  27606. /**
  27607. * WordPress dependencies
  27608. */
  27609. k([names, a11y]);
  27610. function ContrastChecker(_ref) {
  27611. let {
  27612. backgroundColor,
  27613. fallbackBackgroundColor,
  27614. fallbackTextColor,
  27615. fallbackLinkColor,
  27616. fontSize,
  27617. // Font size value in pixels.
  27618. isLargeText,
  27619. textColor,
  27620. linkColor,
  27621. enableAlphaChecker = false
  27622. } = _ref;
  27623. const currentBackgroundColor = backgroundColor || fallbackBackgroundColor; // Must have a background color.
  27624. if (!currentBackgroundColor) {
  27625. return null;
  27626. }
  27627. const currentTextColor = textColor || fallbackTextColor;
  27628. const currentLinkColor = linkColor || fallbackLinkColor; // Must have at least one text color.
  27629. if (!currentTextColor && !currentLinkColor) {
  27630. return null;
  27631. }
  27632. const textColors = [{
  27633. color: currentTextColor,
  27634. description: (0,external_wp_i18n_namespaceObject.__)('text color')
  27635. }, {
  27636. color: currentLinkColor,
  27637. description: (0,external_wp_i18n_namespaceObject.__)('link color')
  27638. }];
  27639. const colordBackgroundColor = w(currentBackgroundColor);
  27640. const backgroundColorHasTransparency = colordBackgroundColor.alpha() < 1;
  27641. const backgroundColorBrightness = colordBackgroundColor.brightness();
  27642. const isReadableOptions = {
  27643. level: 'AA',
  27644. size: isLargeText || isLargeText !== false && fontSize >= 24 ? 'large' : 'small'
  27645. };
  27646. let message = '';
  27647. let speakMessage = '';
  27648. for (const item of textColors) {
  27649. // If there is no color, go no further.
  27650. if (!item.color) {
  27651. continue;
  27652. }
  27653. const colordTextColor = w(item.color);
  27654. const isColordTextReadable = colordTextColor.isReadable(colordBackgroundColor, isReadableOptions);
  27655. const textHasTransparency = colordTextColor.alpha() < 1; // If the contrast is not readable.
  27656. if (!isColordTextReadable) {
  27657. // Don't show the message if the background or text is transparent.
  27658. if (backgroundColorHasTransparency || textHasTransparency) {
  27659. continue;
  27660. }
  27661. 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".
  27662. (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".
  27663. (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);
  27664. 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.
  27665. // These messages take priority over the transparency warning.
  27666. break;
  27667. } // If there is no contrast warning and the text is transparent,
  27668. // show the transparent warning if alpha check is enabled.
  27669. if (textHasTransparency && enableAlphaChecker) {
  27670. message = (0,external_wp_i18n_namespaceObject.__)('Transparent text may be hard for people to read.');
  27671. speakMessage = (0,external_wp_i18n_namespaceObject.__)('Transparent text may be hard for people to read.');
  27672. }
  27673. }
  27674. if (!message) {
  27675. return null;
  27676. } // Note: The `Notice` component can speak messages via its `spokenMessage`
  27677. // prop, but the contrast checker requires granular control over when the
  27678. // announcements are made. Notably, the message will be re-announced if a
  27679. // new color combination is selected and the contrast is still insufficient.
  27680. (0,external_wp_a11y_namespaceObject.speak)(speakMessage);
  27681. return (0,external_wp_element_namespaceObject.createElement)("div", {
  27682. className: "block-editor-contrast-checker"
  27683. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
  27684. spokenMessage: null,
  27685. status: "warning",
  27686. isDismissible: false
  27687. }, message));
  27688. }
  27689. /**
  27690. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/contrast-checker/README.md
  27691. */
  27692. /* harmony default export */ var contrast_checker = (ContrastChecker);
  27693. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/tools-panel-color-dropdown.js
  27694. /**
  27695. * External dependencies
  27696. */
  27697. /**
  27698. * WordPress dependencies
  27699. */
  27700. /**
  27701. * Internal dependencies
  27702. */
  27703. function ToolsPanelColorDropdown(_ref) {
  27704. var _settings$gradientVal;
  27705. let {
  27706. settings,
  27707. enableAlpha,
  27708. ...otherProps
  27709. } = _ref;
  27710. const colorGradientSettings = useMultipleOriginColorsAndGradients();
  27711. const controlSettings = { ...colorGradientSettings,
  27712. clearable: false,
  27713. enableAlpha,
  27714. label: settings.label,
  27715. onColorChange: settings.onColorChange,
  27716. onGradientChange: settings.onGradientChange,
  27717. colorValue: settings.colorValue,
  27718. gradientValue: settings.gradientValue
  27719. };
  27720. const selectedColor = (_settings$gradientVal = settings.gradientValue) !== null && _settings$gradientVal !== void 0 ? _settings$gradientVal : settings.colorValue;
  27721. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, _extends({
  27722. hasValue: settings.hasValue,
  27723. label: settings.label,
  27724. onDeselect: settings.onDeselect,
  27725. isShownByDefault: settings.isShownByDefault,
  27726. resetAllFilter: settings.resetAllFilter
  27727. }, otherProps, {
  27728. className: "block-editor-tools-panel-color-gradient-settings__item"
  27729. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  27730. className: "block-editor-tools-panel-color-dropdown",
  27731. contentClassName: "block-editor-panel-color-gradient-settings__dropdown-content",
  27732. renderToggle: _ref2 => {
  27733. let {
  27734. isOpen,
  27735. onToggle
  27736. } = _ref2;
  27737. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  27738. onClick: onToggle,
  27739. "aria-expanded": isOpen,
  27740. className: classnames_default()('block-editor-panel-color-gradient-settings__dropdown', {
  27741. 'is-open': isOpen
  27742. })
  27743. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
  27744. justify: "flex-start"
  27745. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
  27746. className: "block-editor-panel-color-gradient-settings__color-indicator",
  27747. colorValue: selectedColor
  27748. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, settings.label)));
  27749. },
  27750. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(control, _extends({
  27751. showTitle: false,
  27752. __experimentalHasMultipleOrigins: true,
  27753. __experimentalIsRenderedInSidebar: true,
  27754. enableAlpha: true
  27755. }, controlSettings))
  27756. }));
  27757. }
  27758. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/color-panel.js
  27759. /**
  27760. * WordPress dependencies
  27761. */
  27762. /**
  27763. * Internal dependencies
  27764. */
  27765. function getComputedStyle(node) {
  27766. return node.ownerDocument.defaultView.getComputedStyle(node);
  27767. }
  27768. function ColorPanel(_ref) {
  27769. let {
  27770. enableAlpha = false,
  27771. settings,
  27772. clientId,
  27773. enableContrastChecking = true
  27774. } = _ref;
  27775. const [detectedBackgroundColor, setDetectedBackgroundColor] = (0,external_wp_element_namespaceObject.useState)();
  27776. const [detectedColor, setDetectedColor] = (0,external_wp_element_namespaceObject.useState)();
  27777. const [detectedLinkColor, setDetectedLinkColor] = (0,external_wp_element_namespaceObject.useState)();
  27778. const ref = useBlockRef(clientId);
  27779. (0,external_wp_element_namespaceObject.useEffect)(() => {
  27780. var _ref$current;
  27781. if (!enableContrastChecking) {
  27782. return;
  27783. }
  27784. if (!ref.current) {
  27785. return;
  27786. }
  27787. setDetectedColor(getComputedStyle(ref.current).color);
  27788. const firstLinkElement = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector('a');
  27789. if (firstLinkElement && !!firstLinkElement.innerText) {
  27790. setDetectedLinkColor(getComputedStyle(firstLinkElement).color);
  27791. }
  27792. let backgroundColorNode = ref.current;
  27793. let backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor;
  27794. while (backgroundColor === 'rgba(0, 0, 0, 0)' && backgroundColorNode.parentNode && backgroundColorNode.parentNode.nodeType === backgroundColorNode.parentNode.ELEMENT_NODE) {
  27795. backgroundColorNode = backgroundColorNode.parentNode;
  27796. backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor;
  27797. }
  27798. setDetectedBackgroundColor(backgroundColor);
  27799. });
  27800. return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
  27801. __experimentalGroup: "color"
  27802. }, settings.map((setting, index) => (0,external_wp_element_namespaceObject.createElement)(ToolsPanelColorDropdown, {
  27803. key: index,
  27804. settings: setting,
  27805. panelId: clientId,
  27806. enableAlpha: enableAlpha
  27807. })), enableContrastChecking && (0,external_wp_element_namespaceObject.createElement)(contrast_checker, {
  27808. backgroundColor: detectedBackgroundColor,
  27809. textColor: detectedColor,
  27810. enableAlphaChecker: enableAlpha,
  27811. linkColor: detectedLinkColor
  27812. }));
  27813. }
  27814. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/color.js
  27815. /**
  27816. * External dependencies
  27817. */
  27818. /**
  27819. * WordPress dependencies
  27820. */
  27821. /**
  27822. * Internal dependencies
  27823. */
  27824. const COLOR_SUPPORT_KEY = 'color';
  27825. const hasColorSupport = blockType => {
  27826. const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
  27827. return colorSupport && (colorSupport.link === true || colorSupport.gradient === true || colorSupport.background !== false || colorSupport.text !== false);
  27828. };
  27829. const hasLinkColorSupport = blockType => {
  27830. if (external_wp_element_namespaceObject.Platform.OS !== 'web') {
  27831. return false;
  27832. }
  27833. const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
  27834. return (0,external_lodash_namespaceObject.isObject)(colorSupport) && !!colorSupport.link;
  27835. };
  27836. const hasGradientSupport = blockType => {
  27837. const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
  27838. return (0,external_lodash_namespaceObject.isObject)(colorSupport) && !!colorSupport.gradients;
  27839. };
  27840. const hasBackgroundColorSupport = blockType => {
  27841. const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
  27842. return colorSupport && colorSupport.background !== false;
  27843. };
  27844. const hasTextColorSupport = blockType => {
  27845. const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
  27846. return colorSupport && colorSupport.text !== false;
  27847. };
  27848. /**
  27849. * Checks whether a color has been set either with a named preset color in
  27850. * a top level block attribute or as a custom value within the style attribute
  27851. * object.
  27852. *
  27853. * @param {string} name Name of the color to check.
  27854. * @return {boolean} Whether or not a color has a value.
  27855. */
  27856. const hasColor = name => props => {
  27857. var _props$attributes$sty9, _props$attributes$sty10;
  27858. if (name === 'background') {
  27859. var _props$attributes$sty, _props$attributes$sty2, _props$attributes$sty3, _props$attributes$sty4;
  27860. return !!props.attributes.backgroundColor || !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.color) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.background) || !!props.attributes.gradient || !!((_props$attributes$sty3 = props.attributes.style) !== null && _props$attributes$sty3 !== void 0 && (_props$attributes$sty4 = _props$attributes$sty3.color) !== null && _props$attributes$sty4 !== void 0 && _props$attributes$sty4.gradient);
  27861. }
  27862. if (name === 'link') {
  27863. var _props$attributes$sty5, _props$attributes$sty6, _props$attributes$sty7, _props$attributes$sty8;
  27864. return !!((_props$attributes$sty5 = props.attributes.style) !== null && _props$attributes$sty5 !== void 0 && (_props$attributes$sty6 = _props$attributes$sty5.elements) !== null && _props$attributes$sty6 !== void 0 && (_props$attributes$sty7 = _props$attributes$sty6.link) !== null && _props$attributes$sty7 !== void 0 && (_props$attributes$sty8 = _props$attributes$sty7.color) !== null && _props$attributes$sty8 !== void 0 && _props$attributes$sty8.text);
  27865. }
  27866. return !!props.attributes[`${name}Color`] || !!((_props$attributes$sty9 = props.attributes.style) !== null && _props$attributes$sty9 !== void 0 && (_props$attributes$sty10 = _props$attributes$sty9.color) !== null && _props$attributes$sty10 !== void 0 && _props$attributes$sty10[name]);
  27867. };
  27868. /**
  27869. * Clears a single color property from a style object.
  27870. *
  27871. * @param {Array} path Path to color property to clear within styles object.
  27872. * @param {Object} style Block attributes style object.
  27873. * @return {Object} Styles with the color property omitted.
  27874. */
  27875. const clearColorFromStyles = (path, style) => cleanEmptyObject(immutableSet(style, path, undefined));
  27876. /**
  27877. * Resets the block attributes for text color.
  27878. *
  27879. * @param {Object} props Current block props.
  27880. * @param {Object} props.attributes Block attributes.
  27881. * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.
  27882. */
  27883. const resetTextColor = _ref => {
  27884. let {
  27885. attributes,
  27886. setAttributes
  27887. } = _ref;
  27888. setAttributes({
  27889. textColor: undefined,
  27890. style: clearColorFromStyles(['color', 'text'], attributes.style)
  27891. });
  27892. };
  27893. /**
  27894. * Clears text color related properties from supplied attributes.
  27895. *
  27896. * @param {Object} attributes Block attributes.
  27897. * @return {Object} Update block attributes with text color properties omitted.
  27898. */
  27899. const resetAllTextFilter = attributes => ({
  27900. textColor: undefined,
  27901. style: clearColorFromStyles(['color', 'text'], attributes.style)
  27902. });
  27903. /**
  27904. * Resets the block attributes for link color.
  27905. *
  27906. * @param {Object} props Current block props.
  27907. * @param {Object} props.attributes Block attributes.
  27908. * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.
  27909. */
  27910. const resetLinkColor = _ref2 => {
  27911. let {
  27912. attributes,
  27913. setAttributes
  27914. } = _ref2;
  27915. const path = ['elements', 'link', 'color', 'text'];
  27916. setAttributes({
  27917. style: clearColorFromStyles(path, attributes.style)
  27918. });
  27919. };
  27920. /**
  27921. * Clears link color related properties from supplied attributes.
  27922. *
  27923. * @param {Object} attributes Block attributes.
  27924. * @return {Object} Update block attributes with link color properties omitted.
  27925. */
  27926. const resetAllLinkFilter = attributes => ({
  27927. style: clearColorFromStyles(['elements', 'link', 'color', 'text'], attributes.style)
  27928. });
  27929. /**
  27930. * Clears all background color related properties including gradients from
  27931. * supplied block attributes.
  27932. *
  27933. * @param {Object} attributes Block attributes.
  27934. * @return {Object} Block attributes with background and gradient omitted.
  27935. */
  27936. const clearBackgroundAndGradient = attributes => {
  27937. var _attributes$style;
  27938. return {
  27939. backgroundColor: undefined,
  27940. gradient: undefined,
  27941. style: { ...attributes.style,
  27942. color: { ...((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.color),
  27943. background: undefined,
  27944. gradient: undefined
  27945. }
  27946. }
  27947. };
  27948. };
  27949. /**
  27950. * Resets the block attributes for both background color and gradient.
  27951. *
  27952. * @param {Object} props Current block props.
  27953. * @param {Object} props.attributes Block attributes.
  27954. * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.
  27955. */
  27956. const resetBackgroundAndGradient = _ref3 => {
  27957. let {
  27958. attributes,
  27959. setAttributes
  27960. } = _ref3;
  27961. setAttributes(clearBackgroundAndGradient(attributes));
  27962. };
  27963. /**
  27964. * Filters registered block settings, extending attributes to include
  27965. * `backgroundColor` and `textColor` attribute.
  27966. *
  27967. * @param {Object} settings Original block settings.
  27968. *
  27969. * @return {Object} Filtered block settings.
  27970. */
  27971. function color_addAttributes(settings) {
  27972. if (!hasColorSupport(settings)) {
  27973. return settings;
  27974. } // Allow blocks to specify their own attribute definition with default values if needed.
  27975. if (!settings.attributes.backgroundColor) {
  27976. Object.assign(settings.attributes, {
  27977. backgroundColor: {
  27978. type: 'string'
  27979. }
  27980. });
  27981. }
  27982. if (!settings.attributes.textColor) {
  27983. Object.assign(settings.attributes, {
  27984. textColor: {
  27985. type: 'string'
  27986. }
  27987. });
  27988. }
  27989. if (hasGradientSupport(settings) && !settings.attributes.gradient) {
  27990. Object.assign(settings.attributes, {
  27991. gradient: {
  27992. type: 'string'
  27993. }
  27994. });
  27995. }
  27996. return settings;
  27997. }
  27998. /**
  27999. * Override props assigned to save component to inject colors classnames.
  28000. *
  28001. * @param {Object} props Additional props applied to save element.
  28002. * @param {Object} blockType Block type.
  28003. * @param {Object} attributes Block attributes.
  28004. *
  28005. * @return {Object} Filtered props applied to save element.
  28006. */
  28007. function color_addSaveProps(props, blockType, attributes) {
  28008. var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link;
  28009. if (!hasColorSupport(blockType) || shouldSkipSerialization(blockType, COLOR_SUPPORT_KEY)) {
  28010. return props;
  28011. }
  28012. const hasGradient = hasGradientSupport(blockType); // I'd have preferred to avoid the "style" attribute usage here
  28013. const {
  28014. backgroundColor,
  28015. textColor,
  28016. gradient,
  28017. style
  28018. } = attributes;
  28019. const shouldSerialize = feature => !shouldSkipSerialization(blockType, COLOR_SUPPORT_KEY, feature); // Primary color classes must come before the `has-text-color`,
  28020. // `has-background` and `has-link-color` classes to maintain backwards
  28021. // compatibility and avoid block invalidations.
  28022. const textClass = shouldSerialize('text') ? getColorClassName('color', textColor) : undefined;
  28023. const gradientClass = shouldSerialize('gradients') ? __experimentalGetGradientClass(gradient) : undefined;
  28024. const backgroundClass = shouldSerialize('background') ? getColorClassName('background-color', backgroundColor) : undefined;
  28025. const serializeHasBackground = shouldSerialize('background') || shouldSerialize('gradients');
  28026. 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));
  28027. const newClassName = classnames_default()(props.className, textClass, gradientClass, {
  28028. // Don't apply the background class if there's a custom gradient.
  28029. [backgroundClass]: (!hasGradient || !(style !== null && style !== void 0 && (_style$color3 = style.color) !== null && _style$color3 !== void 0 && _style$color3.gradient)) && !!backgroundClass,
  28030. '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)),
  28031. 'has-background': serializeHasBackground && hasBackground,
  28032. '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)
  28033. });
  28034. props.className = newClassName ? newClassName : undefined;
  28035. return props;
  28036. }
  28037. /**
  28038. * Filters registered block settings to extend the block edit wrapper
  28039. * to apply the desired styles and classnames properly.
  28040. *
  28041. * @param {Object} settings Original block settings.
  28042. *
  28043. * @return {Object} Filtered block settings.
  28044. */
  28045. function color_addEditProps(settings) {
  28046. if (!hasColorSupport(settings) || shouldSkipSerialization(settings, COLOR_SUPPORT_KEY)) {
  28047. return settings;
  28048. }
  28049. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  28050. settings.getEditWrapperProps = attributes => {
  28051. let props = {};
  28052. if (existingGetEditWrapperProps) {
  28053. props = existingGetEditWrapperProps(attributes);
  28054. }
  28055. return color_addSaveProps(props, settings, attributes);
  28056. };
  28057. return settings;
  28058. }
  28059. const getLinkColorFromAttributeValue = (colors, value) => {
  28060. const attributeParsed = /var:preset\|color\|(.+)/.exec(value);
  28061. if (attributeParsed && attributeParsed[1]) {
  28062. return getColorObjectByAttributeValues(colors, attributeParsed[1]).color;
  28063. }
  28064. return value;
  28065. };
  28066. /**
  28067. * Inspector control panel containing the color related configuration
  28068. *
  28069. * @param {Object} props
  28070. *
  28071. * @return {WPElement} Color edit element.
  28072. */
  28073. function ColorEdit(props) {
  28074. var _style$color6, _style$color7, _style$color8, _style$elements2, _style$elements2$link, _style$elements2$link2, _style$elements3, _style$elements3$link, _style$elements3$link2;
  28075. const {
  28076. name: blockName,
  28077. attributes
  28078. } = props; // Some color settings have a special handling for deprecated flags in `useSetting`,
  28079. // so we can't unwrap them by doing const { ... } = useSetting('color')
  28080. // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
  28081. const userPalette = useSetting('color.palette.custom');
  28082. const themePalette = useSetting('color.palette.theme');
  28083. const defaultPalette = useSetting('color.palette.default');
  28084. const allSolids = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
  28085. const userGradientPalette = useSetting('color.gradients.custom');
  28086. const themeGradientPalette = useSetting('color.gradients.theme');
  28087. const defaultGradientPalette = useSetting('color.gradients.default');
  28088. const allGradients = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userGradientPalette || []), ...(themeGradientPalette || []), ...(defaultGradientPalette || [])], [userGradientPalette, themeGradientPalette, defaultGradientPalette]);
  28089. const areCustomSolidsEnabled = useSetting('color.custom');
  28090. const areCustomGradientsEnabled = useSetting('color.customGradient');
  28091. const isBackgroundEnabled = useSetting('color.background');
  28092. const isLinkEnabled = useSetting('color.link');
  28093. const isTextEnabled = useSetting('color.text');
  28094. const solidsEnabled = areCustomSolidsEnabled || !themePalette || (themePalette === null || themePalette === void 0 ? void 0 : themePalette.length) > 0;
  28095. const gradientsEnabled = areCustomGradientsEnabled || !themeGradientPalette || (themeGradientPalette === null || themeGradientPalette === void 0 ? void 0 : themeGradientPalette.length) > 0; // Shouldn't be needed but right now the ColorGradientsPanel
  28096. // can trigger both onChangeColor and onChangeBackground
  28097. // synchronously causing our two callbacks to override changes
  28098. // from each other.
  28099. const localAttributes = (0,external_wp_element_namespaceObject.useRef)(attributes);
  28100. (0,external_wp_element_namespaceObject.useEffect)(() => {
  28101. localAttributes.current = attributes;
  28102. }, [attributes]);
  28103. if (!hasColorSupport(blockName)) {
  28104. return null;
  28105. }
  28106. const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && solidsEnabled;
  28107. const hasTextColor = hasTextColorSupport(blockName) && isTextEnabled && solidsEnabled;
  28108. const hasBackgroundColor = hasBackgroundColorSupport(blockName) && isBackgroundEnabled && solidsEnabled;
  28109. const hasGradientColor = hasGradientSupport(blockName) && gradientsEnabled;
  28110. if (!hasLinkColor && !hasTextColor && !hasBackgroundColor && !hasGradientColor) {
  28111. return null;
  28112. }
  28113. const {
  28114. style,
  28115. textColor,
  28116. backgroundColor,
  28117. gradient
  28118. } = attributes;
  28119. let gradientValue;
  28120. if (hasGradientColor && gradient) {
  28121. gradientValue = getGradientValueBySlug(allGradients, gradient);
  28122. } else if (hasGradientColor) {
  28123. var _style$color5;
  28124. gradientValue = style === null || style === void 0 ? void 0 : (_style$color5 = style.color) === null || _style$color5 === void 0 ? void 0 : _style$color5.gradient;
  28125. }
  28126. const onChangeColor = name => value => {
  28127. var _localAttributes$curr, _localAttributes$curr2;
  28128. const colorObject = getColorObjectByColorValue(allSolids, value);
  28129. const attributeName = name + 'Color';
  28130. const newStyle = { ...localAttributes.current.style,
  28131. 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),
  28132. [name]: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
  28133. }
  28134. };
  28135. const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
  28136. const newAttributes = {
  28137. style: cleanEmptyObject(newStyle),
  28138. [attributeName]: newNamedColor
  28139. };
  28140. props.setAttributes(newAttributes);
  28141. localAttributes.current = { ...localAttributes.current,
  28142. ...newAttributes
  28143. };
  28144. };
  28145. const onChangeGradient = value => {
  28146. const slug = getGradientSlugByValue(allGradients, value);
  28147. let newAttributes;
  28148. if (slug) {
  28149. var _localAttributes$curr3, _localAttributes$curr4, _localAttributes$curr5;
  28150. const newStyle = { ...((_localAttributes$curr3 = localAttributes.current) === null || _localAttributes$curr3 === void 0 ? void 0 : _localAttributes$curr3.style),
  28151. 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),
  28152. gradient: undefined
  28153. }
  28154. };
  28155. newAttributes = {
  28156. style: cleanEmptyObject(newStyle),
  28157. gradient: slug
  28158. };
  28159. } else {
  28160. var _localAttributes$curr6, _localAttributes$curr7, _localAttributes$curr8;
  28161. const newStyle = { ...((_localAttributes$curr6 = localAttributes.current) === null || _localAttributes$curr6 === void 0 ? void 0 : _localAttributes$curr6.style),
  28162. 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),
  28163. gradient: value
  28164. }
  28165. };
  28166. newAttributes = {
  28167. style: cleanEmptyObject(newStyle),
  28168. gradient: undefined
  28169. };
  28170. }
  28171. props.setAttributes(newAttributes);
  28172. localAttributes.current = { ...localAttributes.current,
  28173. ...newAttributes
  28174. };
  28175. };
  28176. const onChangeLinkColor = value => {
  28177. const colorObject = getColorObjectByColorValue(allSolids, value);
  28178. const newLinkColorValue = colorObject !== null && colorObject !== void 0 && colorObject.slug ? `var:preset|color|${colorObject.slug}` : value;
  28179. const newStyle = cleanEmptyObject(immutableSet(style, ['elements', 'link', 'color', 'text'], newLinkColorValue));
  28180. props.setAttributes({
  28181. style: newStyle
  28182. });
  28183. };
  28184. 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);
  28185. const defaultColorControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [COLOR_SUPPORT_KEY, '__experimentalDefaultControls']);
  28186. return (0,external_wp_element_namespaceObject.createElement)(ColorPanel, {
  28187. enableContrastChecking: enableContrastChecking,
  28188. clientId: props.clientId,
  28189. enableAlpha: true,
  28190. settings: [...(hasTextColor ? [{
  28191. label: (0,external_wp_i18n_namespaceObject.__)('Text'),
  28192. onColorChange: onChangeColor('text'),
  28193. 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,
  28194. isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.text,
  28195. hasValue: () => hasColor('text')(props),
  28196. onDeselect: () => resetTextColor(props),
  28197. resetAllFilter: resetAllTextFilter
  28198. }] : []), ...(hasBackgroundColor || hasGradientColor ? [{
  28199. label: (0,external_wp_i18n_namespaceObject.__)('Background'),
  28200. onColorChange: hasBackgroundColor ? onChangeColor('background') : undefined,
  28201. 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,
  28202. gradientValue,
  28203. onGradientChange: hasGradientColor ? onChangeGradient : undefined,
  28204. isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.background,
  28205. hasValue: () => hasColor('background')(props),
  28206. onDeselect: () => resetBackgroundAndGradient(props),
  28207. resetAllFilter: clearBackgroundAndGradient
  28208. }] : []), ...(hasLinkColor ? [{
  28209. label: (0,external_wp_i18n_namespaceObject.__)('Link'),
  28210. onColorChange: onChangeLinkColor,
  28211. 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),
  28212. 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),
  28213. isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.link,
  28214. hasValue: () => hasColor('link')(props),
  28215. onDeselect: () => resetLinkColor(props),
  28216. resetAllFilter: resetAllLinkFilter
  28217. }] : [])]
  28218. });
  28219. }
  28220. /**
  28221. * This adds inline styles for color palette colors.
  28222. * Ideally, this is not needed and themes should load their palettes on the editor.
  28223. *
  28224. * @param {Function} BlockListBlock Original component.
  28225. *
  28226. * @return {Function} Wrapped component.
  28227. */
  28228. const withColorPaletteStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  28229. var _props$wrapperProps;
  28230. const {
  28231. name,
  28232. attributes
  28233. } = props;
  28234. const {
  28235. backgroundColor,
  28236. textColor
  28237. } = attributes;
  28238. const userPalette = useSetting('color.palette.custom') || [];
  28239. const themePalette = useSetting('color.palette.theme') || [];
  28240. const defaultPalette = useSetting('color.palette.default') || [];
  28241. const colors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
  28242. if (!hasColorSupport(name) || shouldSkipSerialization(name, COLOR_SUPPORT_KEY)) {
  28243. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
  28244. }
  28245. const extraStyles = {};
  28246. if (textColor && !shouldSkipSerialization(name, COLOR_SUPPORT_KEY, 'text')) {
  28247. var _getColorObjectByAttr;
  28248. extraStyles.color = (_getColorObjectByAttr = getColorObjectByAttributeValues(colors, textColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
  28249. }
  28250. if (backgroundColor && !shouldSkipSerialization(name, COLOR_SUPPORT_KEY, 'background')) {
  28251. var _getColorObjectByAttr2;
  28252. extraStyles.backgroundColor = (_getColorObjectByAttr2 = getColorObjectByAttributeValues(colors, backgroundColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color;
  28253. }
  28254. let wrapperProps = props.wrapperProps;
  28255. wrapperProps = { ...props.wrapperProps,
  28256. style: { ...extraStyles,
  28257. ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style)
  28258. }
  28259. };
  28260. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  28261. wrapperProps: wrapperProps
  28262. }));
  28263. });
  28264. const MIGRATION_PATHS = {
  28265. linkColor: [['style', 'elements', 'link', 'color', 'text']],
  28266. textColor: [['textColor'], ['style', 'color', 'text']],
  28267. backgroundColor: [['backgroundColor'], ['style', 'color', 'background']],
  28268. gradient: [['gradient'], ['style', 'color', 'gradient']]
  28269. };
  28270. function color_addTransforms(result, source, index, results) {
  28271. const destinationBlockType = result.name;
  28272. const activeSupports = {
  28273. linkColor: hasLinkColorSupport(destinationBlockType),
  28274. textColor: hasTextColorSupport(destinationBlockType),
  28275. backgroundColor: hasBackgroundColorSupport(destinationBlockType),
  28276. gradient: hasGradientSupport(destinationBlockType)
  28277. };
  28278. return transformStyles(activeSupports, MIGRATION_PATHS, result, source, index, results);
  28279. }
  28280. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/color/addAttribute', color_addAttributes);
  28281. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/color/addSaveProps', color_addSaveProps);
  28282. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/color/addEditProps', color_addEditProps);
  28283. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/color/with-color-palette-styles', withColorPaletteStyles);
  28284. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.switchToBlockType.transformedBlock', 'core/color/addTransforms', color_addTransforms);
  28285. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-appearance-control/index.js
  28286. /**
  28287. * WordPress dependencies
  28288. */
  28289. const FONT_STYLES = [{
  28290. name: (0,external_wp_i18n_namespaceObject._x)('Regular', 'font style'),
  28291. value: 'normal'
  28292. }, {
  28293. name: (0,external_wp_i18n_namespaceObject._x)('Italic', 'font style'),
  28294. value: 'italic'
  28295. }];
  28296. const FONT_WEIGHTS = [{
  28297. name: (0,external_wp_i18n_namespaceObject._x)('Thin', 'font weight'),
  28298. value: '100'
  28299. }, {
  28300. name: (0,external_wp_i18n_namespaceObject._x)('Extra Light', 'font weight'),
  28301. value: '200'
  28302. }, {
  28303. name: (0,external_wp_i18n_namespaceObject._x)('Light', 'font weight'),
  28304. value: '300'
  28305. }, {
  28306. name: (0,external_wp_i18n_namespaceObject._x)('Regular', 'font weight'),
  28307. value: '400'
  28308. }, {
  28309. name: (0,external_wp_i18n_namespaceObject._x)('Medium', 'font weight'),
  28310. value: '500'
  28311. }, {
  28312. name: (0,external_wp_i18n_namespaceObject._x)('Semi Bold', 'font weight'),
  28313. value: '600'
  28314. }, {
  28315. name: (0,external_wp_i18n_namespaceObject._x)('Bold', 'font weight'),
  28316. value: '700'
  28317. }, {
  28318. name: (0,external_wp_i18n_namespaceObject._x)('Extra Bold', 'font weight'),
  28319. value: '800'
  28320. }, {
  28321. name: (0,external_wp_i18n_namespaceObject._x)('Black', 'font weight'),
  28322. value: '900'
  28323. }];
  28324. /**
  28325. * Adjusts font appearance field label in case either font styles or weights
  28326. * are disabled.
  28327. *
  28328. * @param {boolean} hasFontStyles Whether font styles are enabled and present.
  28329. * @param {boolean} hasFontWeights Whether font weights are enabled and present.
  28330. * @return {string} A label representing what font appearance is being edited.
  28331. */
  28332. const getFontAppearanceLabel = (hasFontStyles, hasFontWeights) => {
  28333. if (!hasFontStyles) {
  28334. return (0,external_wp_i18n_namespaceObject.__)('Font weight');
  28335. }
  28336. if (!hasFontWeights) {
  28337. return (0,external_wp_i18n_namespaceObject.__)('Font style');
  28338. }
  28339. return (0,external_wp_i18n_namespaceObject.__)('Appearance');
  28340. };
  28341. /**
  28342. * Control to display unified font style and weight options.
  28343. *
  28344. * @param {Object} props Component props.
  28345. *
  28346. * @return {WPElement} Font appearance control.
  28347. */
  28348. function FontAppearanceControl(props) {
  28349. const {
  28350. onChange,
  28351. hasFontStyles = true,
  28352. hasFontWeights = true,
  28353. value: {
  28354. fontStyle,
  28355. fontWeight
  28356. }
  28357. } = props;
  28358. const hasStylesOrWeights = hasFontStyles || hasFontWeights;
  28359. const label = getFontAppearanceLabel(hasFontStyles, hasFontWeights);
  28360. const defaultOption = {
  28361. key: 'default',
  28362. name: (0,external_wp_i18n_namespaceObject.__)('Default'),
  28363. style: {
  28364. fontStyle: undefined,
  28365. fontWeight: undefined
  28366. }
  28367. }; // Combines both font style and weight options into a single dropdown.
  28368. const combineOptions = () => {
  28369. const combinedOptions = [defaultOption];
  28370. FONT_STYLES.forEach(_ref => {
  28371. let {
  28372. name: styleName,
  28373. value: styleValue
  28374. } = _ref;
  28375. FONT_WEIGHTS.forEach(_ref2 => {
  28376. let {
  28377. name: weightName,
  28378. value: weightValue
  28379. } = _ref2;
  28380. const optionName = styleValue === 'normal' ? weightName : (0,external_wp_i18n_namespaceObject.sprintf)(
  28381. /* translators: 1: Font weight name. 2: Font style name. */
  28382. (0,external_wp_i18n_namespaceObject.__)('%1$s %2$s'), weightName, styleName);
  28383. combinedOptions.push({
  28384. key: `${styleValue}-${weightValue}`,
  28385. name: optionName,
  28386. style: {
  28387. fontStyle: styleValue,
  28388. fontWeight: weightValue
  28389. }
  28390. });
  28391. });
  28392. });
  28393. return combinedOptions;
  28394. }; // Generates select options for font styles only.
  28395. const styleOptions = () => {
  28396. const combinedOptions = [defaultOption];
  28397. FONT_STYLES.forEach(_ref3 => {
  28398. let {
  28399. name,
  28400. value
  28401. } = _ref3;
  28402. combinedOptions.push({
  28403. key: value,
  28404. name,
  28405. style: {
  28406. fontStyle: value,
  28407. fontWeight: undefined
  28408. }
  28409. });
  28410. });
  28411. return combinedOptions;
  28412. }; // Generates select options for font weights only.
  28413. const weightOptions = () => {
  28414. const combinedOptions = [defaultOption];
  28415. FONT_WEIGHTS.forEach(_ref4 => {
  28416. let {
  28417. name,
  28418. value
  28419. } = _ref4;
  28420. combinedOptions.push({
  28421. key: value,
  28422. name,
  28423. style: {
  28424. fontStyle: undefined,
  28425. fontWeight: value
  28426. }
  28427. });
  28428. });
  28429. return combinedOptions;
  28430. }; // Map font styles and weights to select options.
  28431. const selectOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
  28432. if (hasFontStyles && hasFontWeights) {
  28433. return combineOptions();
  28434. }
  28435. return hasFontStyles ? styleOptions() : weightOptions();
  28436. }, [props.options]); // Find current selection by comparing font style & weight against options,
  28437. // and fall back to the Default option if there is no matching option.
  28438. const currentSelection = selectOptions.find(option => option.style.fontStyle === fontStyle && option.style.fontWeight === fontWeight) || selectOptions[0]; // Adjusts screen reader description based on styles or weights.
  28439. const getDescribedBy = () => {
  28440. if (!currentSelection) {
  28441. return (0,external_wp_i18n_namespaceObject.__)('No selected font appearance');
  28442. }
  28443. if (!hasFontStyles) {
  28444. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Currently selected font weight.
  28445. (0,external_wp_i18n_namespaceObject.__)('Currently selected font weight: %s'), currentSelection.name);
  28446. }
  28447. if (!hasFontWeights) {
  28448. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Currently selected font style.
  28449. (0,external_wp_i18n_namespaceObject.__)('Currently selected font style: %s'), currentSelection.name);
  28450. }
  28451. return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Currently selected font appearance.
  28452. (0,external_wp_i18n_namespaceObject.__)('Currently selected font appearance: %s'), currentSelection.name);
  28453. };
  28454. return hasStylesOrWeights && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CustomSelectControl, {
  28455. className: "components-font-appearance-control",
  28456. label: label,
  28457. describedBy: getDescribedBy(),
  28458. options: selectOptions,
  28459. value: currentSelection,
  28460. onChange: _ref5 => {
  28461. let {
  28462. selectedItem
  28463. } = _ref5;
  28464. return onChange(selectedItem.style);
  28465. }
  28466. });
  28467. }
  28468. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/line-height-control/utils.js
  28469. const BASE_DEFAULT_VALUE = 1.5;
  28470. const STEP = 0.1;
  28471. /**
  28472. * There are varying value types within LineHeightControl:
  28473. *
  28474. * {undefined} Initial value. No changes from the user.
  28475. * {string} Input value. Value consumed/outputted by the input. Empty would be ''.
  28476. * {number} Block attribute type. Input value needs to be converted for attribute setting.
  28477. *
  28478. * Note: If the value is undefined, the input requires it to be an empty string ('')
  28479. * in order to be considered "controlled" by props (rather than internal state).
  28480. */
  28481. const RESET_VALUE = '';
  28482. /**
  28483. * Determines if the lineHeight attribute has been properly defined.
  28484. *
  28485. * @param {any} lineHeight The value to check.
  28486. *
  28487. * @return {boolean} Whether the lineHeight attribute is valid.
  28488. */
  28489. function isLineHeightDefined(lineHeight) {
  28490. return lineHeight !== undefined && lineHeight !== RESET_VALUE;
  28491. }
  28492. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/line-height-control/index.js
  28493. /**
  28494. * WordPress dependencies
  28495. */
  28496. /**
  28497. * Internal dependencies
  28498. */
  28499. const LineHeightControl = _ref => {
  28500. let {
  28501. value: lineHeight,
  28502. onChange,
  28503. /** Start opting into the new margin-free styles that will become the default in a future version. */
  28504. __nextHasNoMarginBottom = false,
  28505. __unstableInputWidth = '60px'
  28506. } = _ref;
  28507. const isDefined = isLineHeightDefined(lineHeight);
  28508. const adjustNextValue = (nextValue, wasTypedOrPasted) => {
  28509. // Set the next value without modification if lineHeight has been defined.
  28510. if (isDefined) return nextValue;
  28511. /**
  28512. * The following logic handles the initial step up/down action
  28513. * (from an undefined value state) so that the next values are better suited for
  28514. * line-height rendering. For example, the first step up should immediately
  28515. * go to 1.6, rather than the normally expected 0.1.
  28516. *
  28517. * Step up/down actions can be triggered by keydowns of the up/down arrow keys,
  28518. * or by clicking the spin buttons.
  28519. */
  28520. switch (`${nextValue}`) {
  28521. case `${STEP}`:
  28522. // Increment by step value.
  28523. return BASE_DEFAULT_VALUE + STEP;
  28524. case '0':
  28525. {
  28526. // This means the user explicitly input '0', rather than stepped down
  28527. // from an undefined value state.
  28528. if (wasTypedOrPasted) return nextValue; // Decrement by step value.
  28529. return BASE_DEFAULT_VALUE - STEP;
  28530. }
  28531. case '':
  28532. return BASE_DEFAULT_VALUE;
  28533. default:
  28534. return nextValue;
  28535. }
  28536. };
  28537. const stateReducer = (state, action) => {
  28538. var _action$payload$event;
  28539. // Be careful when changing this — cross-browser behavior of the
  28540. // `inputType` field in `input` events are inconsistent.
  28541. // For example, Firefox emits an input event with inputType="insertReplacementText"
  28542. // on spin button clicks, while other browsers do not even emit an input event.
  28543. const wasTypedOrPasted = ['insertText', 'insertFromPaste'].includes((_action$payload$event = action.payload.event.nativeEvent) === null || _action$payload$event === void 0 ? void 0 : _action$payload$event.inputType);
  28544. const value = adjustNextValue(state.value, wasTypedOrPasted);
  28545. return { ...state,
  28546. value
  28547. };
  28548. };
  28549. const value = isDefined ? lineHeight : RESET_VALUE;
  28550. if (!__nextHasNoMarginBottom) {
  28551. external_wp_deprecated_default()('Bottom margin styles for wp.blockEditor.LineHeightControl', {
  28552. since: '6.0',
  28553. version: '6.4',
  28554. hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version'
  28555. });
  28556. }
  28557. const deprecatedStyles = __nextHasNoMarginBottom ? undefined : {
  28558. marginBottom: 24
  28559. };
  28560. return (0,external_wp_element_namespaceObject.createElement)("div", {
  28561. className: "block-editor-line-height-control",
  28562. style: deprecatedStyles
  28563. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNumberControl, {
  28564. __unstableInputWidth: __unstableInputWidth,
  28565. __unstableStateReducer: stateReducer,
  28566. onChange: onChange,
  28567. label: (0,external_wp_i18n_namespaceObject.__)('Line height'),
  28568. placeholder: BASE_DEFAULT_VALUE,
  28569. step: STEP,
  28570. value: value,
  28571. min: 0
  28572. }));
  28573. };
  28574. /**
  28575. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/line-height-control/README.md
  28576. */
  28577. /* harmony default export */ var line_height_control = (LineHeightControl);
  28578. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/line-height.js
  28579. /**
  28580. * WordPress dependencies
  28581. */
  28582. /**
  28583. * Internal dependencies
  28584. */
  28585. const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';
  28586. /**
  28587. * Inspector control panel containing the line height related configuration
  28588. *
  28589. * @param {Object} props
  28590. *
  28591. * @return {WPElement} Line height edit element.
  28592. */
  28593. function LineHeightEdit(props) {
  28594. var _style$typography;
  28595. const {
  28596. attributes: {
  28597. style
  28598. },
  28599. setAttributes
  28600. } = props;
  28601. const onChange = newLineHeightValue => {
  28602. const newStyle = { ...style,
  28603. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  28604. lineHeight: newLineHeightValue
  28605. }
  28606. };
  28607. setAttributes({
  28608. style: cleanEmptyObject(newStyle)
  28609. });
  28610. };
  28611. return (0,external_wp_element_namespaceObject.createElement)(line_height_control, {
  28612. __unstableInputWidth: "100%",
  28613. __nextHasNoMarginBottom: true,
  28614. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.lineHeight,
  28615. onChange: onChange
  28616. });
  28617. }
  28618. /**
  28619. * Custom hook that checks if line-height settings have been disabled.
  28620. *
  28621. * @param {string} name The name of the block.
  28622. * @return {boolean} Whether setting is disabled.
  28623. */
  28624. function useIsLineHeightDisabled() {
  28625. let {
  28626. name: blockName
  28627. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  28628. const isDisabled = !useSetting('typography.lineHeight');
  28629. return !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, LINE_HEIGHT_SUPPORT_KEY) || isDisabled;
  28630. }
  28631. /**
  28632. * Checks if there is a current value set for the line height block support.
  28633. *
  28634. * @param {Object} props Block props.
  28635. * @return {boolean} Whether or not the block has a line height value set.
  28636. */
  28637. function hasLineHeightValue(props) {
  28638. var _props$attributes$sty, _props$attributes$sty2;
  28639. 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);
  28640. }
  28641. /**
  28642. * Resets the line height block support attribute. This can be used when
  28643. * disabling the line height support controls for a block via a progressive
  28644. * discovery panel.
  28645. *
  28646. * @param {Object} props Block props.
  28647. * @param {Object} props.attributes Block's attributes.
  28648. * @param {Object} props.setAttributes Function to set block's attributes.
  28649. */
  28650. function resetLineHeight(_ref) {
  28651. let {
  28652. attributes = {},
  28653. setAttributes
  28654. } = _ref;
  28655. const {
  28656. style
  28657. } = attributes;
  28658. setAttributes({
  28659. style: cleanEmptyObject({ ...style,
  28660. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  28661. lineHeight: undefined
  28662. }
  28663. })
  28664. });
  28665. }
  28666. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-appearance.js
  28667. /**
  28668. * WordPress dependencies
  28669. */
  28670. /**
  28671. * Internal dependencies
  28672. */
  28673. /**
  28674. * Key within block settings' support array indicating support for font style.
  28675. */
  28676. const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
  28677. /**
  28678. * Key within block settings' support array indicating support for font weight.
  28679. */
  28680. const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
  28681. /**
  28682. * Inspector control panel containing the font appearance options.
  28683. *
  28684. * @param {Object} props Block properties.
  28685. *
  28686. * @return {WPElement} Font appearance edit element.
  28687. */
  28688. function FontAppearanceEdit(props) {
  28689. var _style$typography, _style$typography2;
  28690. const {
  28691. attributes: {
  28692. style
  28693. },
  28694. setAttributes
  28695. } = props;
  28696. const hasFontStyles = !useIsFontStyleDisabled(props);
  28697. const hasFontWeights = !useIsFontWeightDisabled(props);
  28698. const onChange = newStyles => {
  28699. setAttributes({
  28700. style: cleanEmptyObject({ ...style,
  28701. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  28702. fontStyle: newStyles.fontStyle,
  28703. fontWeight: newStyles.fontWeight
  28704. }
  28705. })
  28706. });
  28707. };
  28708. const fontStyle = style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontStyle;
  28709. const fontWeight = style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontWeight;
  28710. return (0,external_wp_element_namespaceObject.createElement)(FontAppearanceControl, {
  28711. onChange: onChange,
  28712. hasFontStyles: hasFontStyles,
  28713. hasFontWeights: hasFontWeights,
  28714. value: {
  28715. fontStyle,
  28716. fontWeight
  28717. }
  28718. });
  28719. }
  28720. /**
  28721. * Checks if font style support has been disabled either by not opting in for
  28722. * support or by failing to provide preset styles.
  28723. *
  28724. * @param {Object} props Block properties.
  28725. * @param {string} props.name Name for the block type.
  28726. *
  28727. * @return {boolean} Whether font style support has been disabled.
  28728. */
  28729. function useIsFontStyleDisabled() {
  28730. let {
  28731. name: blockName
  28732. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  28733. const styleSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_STYLE_SUPPORT_KEY);
  28734. const hasFontStyles = useSetting('typography.fontStyle');
  28735. return !styleSupport || !hasFontStyles;
  28736. }
  28737. /**
  28738. * Checks if font weight support has been disabled either by not opting in for
  28739. * support or by failing to provide preset weights.
  28740. *
  28741. * @param {Object} props Block properties.
  28742. * @param {string} props.name Name for the block type.
  28743. *
  28744. * @return {boolean} Whether font weight support has been disabled.
  28745. */
  28746. function useIsFontWeightDisabled() {
  28747. let {
  28748. name: blockName
  28749. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  28750. const weightSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_WEIGHT_SUPPORT_KEY);
  28751. const hasFontWeights = useSetting('typography.fontWeight');
  28752. return !weightSupport || !hasFontWeights;
  28753. }
  28754. /**
  28755. * Checks if font appearance support has been disabled.
  28756. *
  28757. * @param {Object} props Block properties.
  28758. *
  28759. * @return {boolean} Whether font appearance support has been disabled.
  28760. */
  28761. function useIsFontAppearanceDisabled(props) {
  28762. const stylesDisabled = useIsFontStyleDisabled(props);
  28763. const weightsDisabled = useIsFontWeightDisabled(props);
  28764. return stylesDisabled && weightsDisabled;
  28765. }
  28766. /**
  28767. * Checks if there is either a font style or weight value set within the
  28768. * typography styles.
  28769. *
  28770. * @param {Object} props Block props.
  28771. * @return {boolean} Whether or not the block has a font style or weight.
  28772. */
  28773. function hasFontAppearanceValue(props) {
  28774. var _props$attributes$sty;
  28775. const {
  28776. fontStyle,
  28777. fontWeight
  28778. } = ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.typography) || {};
  28779. return !!fontStyle || !!fontWeight;
  28780. }
  28781. /**
  28782. * Resets the font style and weight block support attributes. This can be used
  28783. * when disabling the font appearance support controls for a block via a
  28784. * progressive discovery panel.
  28785. *
  28786. * @param {Object} props Block props.
  28787. * @param {Object} props.attributes Block's attributes.
  28788. * @param {Object} props.setAttributes Function to set block's attributes.
  28789. */
  28790. function resetFontAppearance(_ref) {
  28791. let {
  28792. attributes = {},
  28793. setAttributes
  28794. } = _ref;
  28795. const {
  28796. style
  28797. } = attributes;
  28798. setAttributes({
  28799. style: cleanEmptyObject({ ...style,
  28800. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  28801. fontStyle: undefined,
  28802. fontWeight: undefined
  28803. }
  28804. })
  28805. });
  28806. }
  28807. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-family/index.js
  28808. /**
  28809. * External dependencies
  28810. */
  28811. /**
  28812. * WordPress dependencies
  28813. */
  28814. /**
  28815. * Internal dependencies
  28816. */
  28817. function FontFamilyControl(_ref) {
  28818. let {
  28819. value = '',
  28820. onChange,
  28821. fontFamilies,
  28822. ...props
  28823. } = _ref;
  28824. const blockLevelFontFamilies = useSetting('typography.fontFamilies');
  28825. if (!fontFamilies) {
  28826. fontFamilies = blockLevelFontFamilies;
  28827. }
  28828. if ((0,external_lodash_namespaceObject.isEmpty)(fontFamilies)) {
  28829. return null;
  28830. }
  28831. const options = [{
  28832. value: '',
  28833. label: (0,external_wp_i18n_namespaceObject.__)('Default')
  28834. }, ...fontFamilies.map(_ref2 => {
  28835. let {
  28836. fontFamily,
  28837. name
  28838. } = _ref2;
  28839. return {
  28840. value: fontFamily,
  28841. label: name || fontFamily
  28842. };
  28843. })];
  28844. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, _extends({
  28845. label: (0,external_wp_i18n_namespaceObject.__)('Font family'),
  28846. options: options,
  28847. value: value,
  28848. onChange: onChange,
  28849. labelPosition: "top"
  28850. }, props));
  28851. }
  28852. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-family.js
  28853. /**
  28854. * External dependencies
  28855. */
  28856. /**
  28857. * WordPress dependencies
  28858. */
  28859. /**
  28860. * Internal dependencies
  28861. */
  28862. const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';
  28863. /**
  28864. * Filters registered block settings, extending attributes to include
  28865. * the `fontFamily` attribute.
  28866. *
  28867. * @param {Object} settings Original block settings
  28868. * @return {Object} Filtered block settings
  28869. */
  28870. function font_family_addAttributes(settings) {
  28871. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_FAMILY_SUPPORT_KEY)) {
  28872. return settings;
  28873. } // Allow blocks to specify a default value if needed.
  28874. if (!settings.attributes.fontFamily) {
  28875. Object.assign(settings.attributes, {
  28876. fontFamily: {
  28877. type: 'string'
  28878. }
  28879. });
  28880. }
  28881. return settings;
  28882. }
  28883. /**
  28884. * Override props assigned to save component to inject font family.
  28885. *
  28886. * @param {Object} props Additional props applied to save element
  28887. * @param {Object} blockType Block type
  28888. * @param {Object} attributes Block attributes
  28889. * @return {Object} Filtered props applied to save element
  28890. */
  28891. function font_family_addSaveProps(props, blockType, attributes) {
  28892. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, FONT_FAMILY_SUPPORT_KEY)) {
  28893. return props;
  28894. }
  28895. if (shouldSkipSerialization(blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontFamily')) {
  28896. return props;
  28897. }
  28898. if (!(attributes !== null && attributes !== void 0 && attributes.fontFamily)) {
  28899. return props;
  28900. } // Use TokenList to dedupe classes.
  28901. const classes = new (external_wp_tokenList_default())(props.className);
  28902. classes.add(`has-${(0,external_lodash_namespaceObject.kebabCase)(attributes === null || attributes === void 0 ? void 0 : attributes.fontFamily)}-font-family`);
  28903. const newClassName = classes.value;
  28904. props.className = newClassName ? newClassName : undefined;
  28905. return props;
  28906. }
  28907. /**
  28908. * Filters registered block settings to expand the block edit wrapper
  28909. * by applying the desired styles and classnames.
  28910. *
  28911. * @param {Object} settings Original block settings.
  28912. *
  28913. * @return {Object} Filtered block settings.
  28914. */
  28915. function font_family_addEditProps(settings) {
  28916. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_FAMILY_SUPPORT_KEY)) {
  28917. return settings;
  28918. }
  28919. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  28920. settings.getEditWrapperProps = attributes => {
  28921. let props = {};
  28922. if (existingGetEditWrapperProps) {
  28923. props = existingGetEditWrapperProps(attributes);
  28924. }
  28925. return font_family_addSaveProps(props, settings, attributes);
  28926. };
  28927. return settings;
  28928. }
  28929. function FontFamilyEdit(_ref) {
  28930. var _find;
  28931. let {
  28932. setAttributes,
  28933. attributes: {
  28934. fontFamily
  28935. }
  28936. } = _ref;
  28937. const fontFamilies = useSetting('typography.fontFamilies');
  28938. const value = (_find = (0,external_lodash_namespaceObject.find)(fontFamilies, _ref2 => {
  28939. let {
  28940. slug
  28941. } = _ref2;
  28942. return fontFamily === slug;
  28943. })) === null || _find === void 0 ? void 0 : _find.fontFamily;
  28944. function onChange(newValue) {
  28945. const predefinedFontFamily = (0,external_lodash_namespaceObject.find)(fontFamilies, _ref3 => {
  28946. let {
  28947. fontFamily: f
  28948. } = _ref3;
  28949. return f === newValue;
  28950. });
  28951. setAttributes({
  28952. fontFamily: predefinedFontFamily === null || predefinedFontFamily === void 0 ? void 0 : predefinedFontFamily.slug
  28953. });
  28954. }
  28955. return (0,external_wp_element_namespaceObject.createElement)(FontFamilyControl, {
  28956. className: "block-editor-hooks-font-family-control",
  28957. fontFamilies: fontFamilies,
  28958. value: value,
  28959. onChange: onChange
  28960. });
  28961. }
  28962. /**
  28963. * Custom hook that checks if font-family functionality is disabled.
  28964. *
  28965. * @param {string} name The name of the block.
  28966. * @return {boolean} Whether setting is disabled.
  28967. */
  28968. function useIsFontFamilyDisabled(_ref4) {
  28969. let {
  28970. name
  28971. } = _ref4;
  28972. const fontFamilies = useSetting('typography.fontFamilies');
  28973. return !fontFamilies || fontFamilies.length === 0 || !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, FONT_FAMILY_SUPPORT_KEY);
  28974. }
  28975. /**
  28976. * Checks if there is a current value set for the font family block support.
  28977. *
  28978. * @param {Object} props Block props.
  28979. * @return {boolean} Whether or not the block has a font family value set.
  28980. */
  28981. function hasFontFamilyValue(props) {
  28982. return !!props.attributes.fontFamily;
  28983. }
  28984. /**
  28985. * Resets the font family block support attribute. This can be used when
  28986. * disabling the font family support controls for a block via a progressive
  28987. * discovery panel.
  28988. *
  28989. * @param {Object} props Block props.
  28990. * @param {Object} props.setAttributes Function to set block's attributes.
  28991. */
  28992. function resetFontFamily(_ref5) {
  28993. let {
  28994. setAttributes
  28995. } = _ref5;
  28996. setAttributes({
  28997. fontFamily: undefined
  28998. });
  28999. }
  29000. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/fontFamily/addAttribute', font_family_addAttributes);
  29001. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/fontFamily/addSaveProps', font_family_addSaveProps);
  29002. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/fontFamily/addEditProps', font_family_addEditProps);
  29003. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/utils.js
  29004. /**
  29005. * External dependencies
  29006. */
  29007. /**
  29008. * Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values.
  29009. * If namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned.
  29010. *
  29011. * @param {Array} fontSizes Array of font size objects containing at least the "name" and "size" values as properties.
  29012. * @param {?string} fontSizeAttribute Content of the font size attribute (slug).
  29013. * @param {?number} customFontSizeAttribute Contents of the custom font size attribute (value).
  29014. *
  29015. * @return {?Object} If fontSizeAttribute is set and an equal slug is found in fontSizes it returns the font size object for that slug.
  29016. * Otherwise, an object with just the size value based on customFontSize is returned.
  29017. */
  29018. const getFontSize = (fontSizes, fontSizeAttribute, customFontSizeAttribute) => {
  29019. if (fontSizeAttribute) {
  29020. const fontSizeObject = (0,external_lodash_namespaceObject.find)(fontSizes, {
  29021. slug: fontSizeAttribute
  29022. });
  29023. if (fontSizeObject) {
  29024. return fontSizeObject;
  29025. }
  29026. }
  29027. return {
  29028. size: customFontSizeAttribute
  29029. };
  29030. };
  29031. /**
  29032. * Returns the corresponding font size object for a given value.
  29033. *
  29034. * @param {Array} fontSizes Array of font size objects.
  29035. * @param {number} value Font size value.
  29036. *
  29037. * @return {Object} Font size object.
  29038. */
  29039. function getFontSizeObjectByValue(fontSizes, value) {
  29040. const fontSizeObject = (0,external_lodash_namespaceObject.find)(fontSizes, {
  29041. size: value
  29042. });
  29043. if (fontSizeObject) {
  29044. return fontSizeObject;
  29045. }
  29046. return {
  29047. size: value
  29048. };
  29049. }
  29050. /**
  29051. * Returns a class based on fontSizeName.
  29052. *
  29053. * @param {string} fontSizeSlug Slug of the fontSize.
  29054. *
  29055. * @return {string} String with the class corresponding to the fontSize passed.
  29056. * The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'.
  29057. */
  29058. function getFontSizeClass(fontSizeSlug) {
  29059. if (!fontSizeSlug) {
  29060. return;
  29061. }
  29062. return `has-${(0,external_lodash_namespaceObject.kebabCase)(fontSizeSlug)}-font-size`;
  29063. }
  29064. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/font-size-picker.js
  29065. /**
  29066. * WordPress dependencies
  29067. */
  29068. /**
  29069. * Internal dependencies
  29070. */
  29071. function FontSizePicker(props) {
  29072. const fontSizes = useSetting('typography.fontSizes');
  29073. const disableCustomFontSizes = !useSetting('typography.customFontSize');
  29074. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FontSizePicker, _extends({}, props, {
  29075. fontSizes: fontSizes,
  29076. disableCustomFontSizes: disableCustomFontSizes
  29077. }));
  29078. }
  29079. /**
  29080. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/font-sizes/README.md
  29081. */
  29082. /* harmony default export */ var font_size_picker = (FontSizePicker);
  29083. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-size.js
  29084. /**
  29085. * WordPress dependencies
  29086. */
  29087. /**
  29088. * Internal dependencies
  29089. */
  29090. const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
  29091. /**
  29092. * Filters registered block settings, extending attributes to include
  29093. * `fontSize` and `fontWeight` attributes.
  29094. *
  29095. * @param {Object} settings Original block settings.
  29096. *
  29097. * @return {Object} Filtered block settings.
  29098. */
  29099. function font_size_addAttributes(settings) {
  29100. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_SIZE_SUPPORT_KEY)) {
  29101. return settings;
  29102. } // Allow blocks to specify a default value if needed.
  29103. if (!settings.attributes.fontSize) {
  29104. Object.assign(settings.attributes, {
  29105. fontSize: {
  29106. type: 'string'
  29107. }
  29108. });
  29109. }
  29110. return settings;
  29111. }
  29112. /**
  29113. * Override props assigned to save component to inject font size.
  29114. *
  29115. * @param {Object} props Additional props applied to save element.
  29116. * @param {Object} blockType Block type.
  29117. * @param {Object} attributes Block attributes.
  29118. *
  29119. * @return {Object} Filtered props applied to save element.
  29120. */
  29121. function font_size_addSaveProps(props, blockType, attributes) {
  29122. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, FONT_SIZE_SUPPORT_KEY)) {
  29123. return props;
  29124. }
  29125. if (shouldSkipSerialization(blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontSize')) {
  29126. return props;
  29127. } // Use TokenList to dedupe classes.
  29128. const classes = new (external_wp_tokenList_default())(props.className);
  29129. classes.add(getFontSizeClass(attributes.fontSize));
  29130. const newClassName = classes.value;
  29131. props.className = newClassName ? newClassName : undefined;
  29132. return props;
  29133. }
  29134. /**
  29135. * Filters registered block settings to expand the block edit wrapper
  29136. * by applying the desired styles and classnames.
  29137. *
  29138. * @param {Object} settings Original block settings.
  29139. *
  29140. * @return {Object} Filtered block settings.
  29141. */
  29142. function font_size_addEditProps(settings) {
  29143. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_SIZE_SUPPORT_KEY)) {
  29144. return settings;
  29145. }
  29146. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  29147. settings.getEditWrapperProps = attributes => {
  29148. let props = {};
  29149. if (existingGetEditWrapperProps) {
  29150. props = existingGetEditWrapperProps(attributes);
  29151. }
  29152. return font_size_addSaveProps(props, settings, attributes);
  29153. };
  29154. return settings;
  29155. }
  29156. /**
  29157. * Inspector control panel containing the font size related configuration
  29158. *
  29159. * @param {Object} props
  29160. *
  29161. * @return {WPElement} Font size edit element.
  29162. */
  29163. function FontSizeEdit(props) {
  29164. var _style$typography, _style$typography2;
  29165. const {
  29166. attributes: {
  29167. fontSize,
  29168. style
  29169. },
  29170. setAttributes
  29171. } = props;
  29172. const fontSizes = useSetting('typography.fontSizes');
  29173. const onChange = value => {
  29174. const fontSizeSlug = getFontSizeObjectByValue(fontSizes, value).slug;
  29175. setAttributes({
  29176. style: cleanEmptyObject({ ...style,
  29177. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  29178. fontSize: fontSizeSlug ? undefined : value
  29179. }
  29180. }),
  29181. fontSize: fontSizeSlug
  29182. });
  29183. };
  29184. 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);
  29185. 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;
  29186. return (0,external_wp_element_namespaceObject.createElement)(font_size_picker, {
  29187. onChange: onChange,
  29188. value: fontSizeValue,
  29189. withReset: false
  29190. });
  29191. }
  29192. /**
  29193. * Checks if there is a current value set for the font size block support.
  29194. *
  29195. * @param {Object} props Block props.
  29196. * @return {boolean} Whether or not the block has a font size value set.
  29197. */
  29198. function hasFontSizeValue(props) {
  29199. var _style$typography3;
  29200. const {
  29201. fontSize,
  29202. style
  29203. } = props.attributes;
  29204. return !!fontSize || !!(style !== null && style !== void 0 && (_style$typography3 = style.typography) !== null && _style$typography3 !== void 0 && _style$typography3.fontSize);
  29205. }
  29206. /**
  29207. * Resets the font size block support attribute. This can be used when
  29208. * disabling the font size support controls for a block via a progressive
  29209. * discovery panel.
  29210. *
  29211. * @param {Object} props Block props.
  29212. * @param {Object} props.attributes Block's attributes.
  29213. * @param {Object} props.setAttributes Function to set block's attributes.
  29214. */
  29215. function resetFontSize(_ref) {
  29216. let {
  29217. attributes = {},
  29218. setAttributes
  29219. } = _ref;
  29220. const {
  29221. style
  29222. } = attributes;
  29223. setAttributes({
  29224. fontSize: undefined,
  29225. style: cleanEmptyObject({ ...style,
  29226. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  29227. fontSize: undefined
  29228. }
  29229. })
  29230. });
  29231. }
  29232. /**
  29233. * Custom hook that checks if font-size settings have been disabled.
  29234. *
  29235. * @param {string} name The name of the block.
  29236. * @return {boolean} Whether setting is disabled.
  29237. */
  29238. function useIsFontSizeDisabled() {
  29239. let {
  29240. name: blockName
  29241. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  29242. const fontSizes = useSetting('typography.fontSizes');
  29243. const hasFontSizes = !!(fontSizes !== null && fontSizes !== void 0 && fontSizes.length);
  29244. return !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_SIZE_SUPPORT_KEY) || !hasFontSizes;
  29245. }
  29246. /**
  29247. * Add inline styles for font sizes.
  29248. * Ideally, this is not needed and themes load the font-size classes on the
  29249. * editor.
  29250. *
  29251. * @param {Function} BlockListBlock Original component.
  29252. *
  29253. * @return {Function} Wrapped component.
  29254. */
  29255. const withFontSizeInlineStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  29256. var _style$typography4, _style$typography5;
  29257. const fontSizes = useSetting('typography.fontSizes');
  29258. const {
  29259. name: blockName,
  29260. attributes: {
  29261. fontSize,
  29262. style
  29263. },
  29264. wrapperProps
  29265. } = props; // Only add inline styles if the block supports font sizes,
  29266. // doesn't skip serialization of font sizes,
  29267. // doesn't already have an inline font size,
  29268. // and does have a class to extract the font size from.
  29269. 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) {
  29270. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
  29271. }
  29272. 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;
  29273. const newProps = { ...props,
  29274. wrapperProps: { ...wrapperProps,
  29275. style: {
  29276. fontSize: fontSizeValue,
  29277. ...(wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.style)
  29278. }
  29279. }
  29280. };
  29281. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, newProps);
  29282. }, 'withFontSizeInlineStyles');
  29283. const font_size_MIGRATION_PATHS = {
  29284. fontSize: [['fontSize'], ['style', 'typography', 'fontSize']]
  29285. };
  29286. function font_size_addTransforms(result, source, index, results) {
  29287. const destinationBlockType = result.name;
  29288. const activeSupports = {
  29289. fontSize: (0,external_wp_blocks_namespaceObject.hasBlockSupport)(destinationBlockType, FONT_SIZE_SUPPORT_KEY)
  29290. };
  29291. return transformStyles(activeSupports, font_size_MIGRATION_PATHS, result, source, index, results);
  29292. }
  29293. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/font/addAttribute', font_size_addAttributes);
  29294. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/font/addSaveProps', font_size_addSaveProps);
  29295. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/font/addEditProps', font_size_addEditProps);
  29296. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/font-size/with-font-size-inline-styles', withFontSizeInlineStyles);
  29297. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.switchToBlockType.transformedBlock', 'core/font-size/addTransforms', font_size_addTransforms);
  29298. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-underline.js
  29299. /**
  29300. * WordPress dependencies
  29301. */
  29302. const formatUnderline = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  29303. xmlns: "http://www.w3.org/2000/svg",
  29304. viewBox: "0 0 24 24"
  29305. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  29306. 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"
  29307. }));
  29308. /* harmony default export */ var format_underline = (formatUnderline);
  29309. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-strikethrough.js
  29310. /**
  29311. * WordPress dependencies
  29312. */
  29313. const formatStrikethrough = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  29314. xmlns: "http://www.w3.org/2000/svg",
  29315. viewBox: "0 0 24 24"
  29316. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  29317. 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"
  29318. }));
  29319. /* harmony default export */ var format_strikethrough = (formatStrikethrough);
  29320. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-decoration-control/index.js
  29321. /**
  29322. * WordPress dependencies
  29323. */
  29324. const TEXT_DECORATIONS = [{
  29325. name: (0,external_wp_i18n_namespaceObject.__)('Underline'),
  29326. value: 'underline',
  29327. icon: format_underline
  29328. }, {
  29329. name: (0,external_wp_i18n_namespaceObject.__)('Strikethrough'),
  29330. value: 'line-through',
  29331. icon: format_strikethrough
  29332. }];
  29333. /**
  29334. * Control to facilitate text decoration selections.
  29335. *
  29336. * @param {Object} props Component props.
  29337. * @param {string} props.value Currently selected text decoration.
  29338. * @param {Function} props.onChange Handles change in text decoration selection.
  29339. *
  29340. * @return {WPElement} Text decoration control.
  29341. */
  29342. function TextDecorationControl(_ref) {
  29343. let {
  29344. value,
  29345. onChange
  29346. } = _ref;
  29347. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  29348. className: "block-editor-text-decoration-control"
  29349. }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Decoration')), (0,external_wp_element_namespaceObject.createElement)("div", {
  29350. className: "block-editor-text-decoration-control__buttons"
  29351. }, TEXT_DECORATIONS.map(textDecoration => {
  29352. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  29353. key: textDecoration.value,
  29354. icon: textDecoration.icon,
  29355. isSmall: true,
  29356. isPressed: textDecoration.value === value,
  29357. onClick: () => onChange(textDecoration.value === value ? undefined : textDecoration.value),
  29358. "aria-label": textDecoration.name
  29359. });
  29360. })));
  29361. }
  29362. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/text-decoration.js
  29363. /**
  29364. * WordPress dependencies
  29365. */
  29366. /**
  29367. * Internal dependencies
  29368. */
  29369. /**
  29370. * Key within block settings' supports array indicating support for text
  29371. * decorations e.g. settings found in `block.json`.
  29372. */
  29373. const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
  29374. /**
  29375. * Inspector control panel containing the text decoration options.
  29376. *
  29377. * @param {Object} props Block properties.
  29378. *
  29379. * @return {WPElement} Text decoration edit element.
  29380. */
  29381. function TextDecorationEdit(props) {
  29382. var _style$typography;
  29383. const {
  29384. attributes: {
  29385. style
  29386. },
  29387. setAttributes
  29388. } = props;
  29389. function onChange(newDecoration) {
  29390. setAttributes({
  29391. style: cleanEmptyObject({ ...style,
  29392. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  29393. textDecoration: newDecoration
  29394. }
  29395. })
  29396. });
  29397. }
  29398. return (0,external_wp_element_namespaceObject.createElement)(TextDecorationControl, {
  29399. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textDecoration,
  29400. onChange: onChange
  29401. });
  29402. }
  29403. /**
  29404. * Checks if text-decoration settings have been disabled.
  29405. *
  29406. * @param {string} name Name of the block.
  29407. *
  29408. * @return {boolean} Whether or not the setting is disabled.
  29409. */
  29410. function useIsTextDecorationDisabled() {
  29411. let {
  29412. name: blockName
  29413. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  29414. const notSupported = !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, TEXT_DECORATION_SUPPORT_KEY);
  29415. const hasTextDecoration = useSetting('typography.textDecoration');
  29416. return notSupported || !hasTextDecoration;
  29417. }
  29418. /**
  29419. * Checks if there is a current value set for the text decoration block support.
  29420. *
  29421. * @param {Object} props Block props.
  29422. * @return {boolean} Whether or not the block has a text decoration set.
  29423. */
  29424. function hasTextDecorationValue(props) {
  29425. var _props$attributes$sty, _props$attributes$sty2;
  29426. 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);
  29427. }
  29428. /**
  29429. * Resets the text decoration block support attribute. This can be used when
  29430. * disabling the text decoration support controls for a block via a progressive
  29431. * discovery panel.
  29432. *
  29433. * @param {Object} props Block props.
  29434. * @param {Object} props.attributes Block's attributes.
  29435. * @param {Object} props.setAttributes Function to set block's attributes.
  29436. */
  29437. function resetTextDecoration(_ref) {
  29438. let {
  29439. attributes = {},
  29440. setAttributes
  29441. } = _ref;
  29442. const {
  29443. style
  29444. } = attributes;
  29445. setAttributes({
  29446. style: cleanEmptyObject({ ...style,
  29447. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  29448. textDecoration: undefined
  29449. }
  29450. })
  29451. });
  29452. }
  29453. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-uppercase.js
  29454. /**
  29455. * WordPress dependencies
  29456. */
  29457. const formatUppercase = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  29458. xmlns: "http://www.w3.org/2000/svg",
  29459. viewBox: "0 0 24 24"
  29460. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  29461. 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"
  29462. }));
  29463. /* harmony default export */ var format_uppercase = (formatUppercase);
  29464. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-lowercase.js
  29465. /**
  29466. * WordPress dependencies
  29467. */
  29468. const formatLowercase = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  29469. xmlns: "http://www.w3.org/2000/svg",
  29470. viewBox: "0 0 24 24"
  29471. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  29472. 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"
  29473. }));
  29474. /* harmony default export */ var format_lowercase = (formatLowercase);
  29475. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-capitalize.js
  29476. /**
  29477. * WordPress dependencies
  29478. */
  29479. const formatCapitalize = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  29480. xmlns: "http://www.w3.org/2000/svg",
  29481. viewBox: "0 0 24 24"
  29482. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  29483. 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"
  29484. }));
  29485. /* harmony default export */ var format_capitalize = (formatCapitalize);
  29486. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-transform-control/index.js
  29487. /**
  29488. * WordPress dependencies
  29489. */
  29490. const TEXT_TRANSFORMS = [{
  29491. name: (0,external_wp_i18n_namespaceObject.__)('Uppercase'),
  29492. value: 'uppercase',
  29493. icon: format_uppercase
  29494. }, {
  29495. name: (0,external_wp_i18n_namespaceObject.__)('Lowercase'),
  29496. value: 'lowercase',
  29497. icon: format_lowercase
  29498. }, {
  29499. name: (0,external_wp_i18n_namespaceObject.__)('Capitalize'),
  29500. value: 'capitalize',
  29501. icon: format_capitalize
  29502. }];
  29503. /**
  29504. * Control to facilitate text transform selections.
  29505. *
  29506. * @param {Object} props Component props.
  29507. * @param {string} props.value Currently selected text transform.
  29508. * @param {Function} props.onChange Handles change in text transform selection.
  29509. *
  29510. * @return {WPElement} Text transform control.
  29511. */
  29512. function TextTransformControl(_ref) {
  29513. let {
  29514. value,
  29515. onChange
  29516. } = _ref;
  29517. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  29518. className: "block-editor-text-transform-control"
  29519. }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Letter case')), (0,external_wp_element_namespaceObject.createElement)("div", {
  29520. className: "block-editor-text-transform-control__buttons"
  29521. }, TEXT_TRANSFORMS.map(textTransform => {
  29522. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  29523. key: textTransform.value,
  29524. icon: textTransform.icon,
  29525. isSmall: true,
  29526. isPressed: value === textTransform.value,
  29527. "aria-label": textTransform.name,
  29528. onClick: () => onChange(value === textTransform.value ? undefined : textTransform.value)
  29529. });
  29530. })));
  29531. }
  29532. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/text-transform.js
  29533. /**
  29534. * WordPress dependencies
  29535. */
  29536. /**
  29537. * Internal dependencies
  29538. */
  29539. /**
  29540. * Key within block settings' supports array indicating support for text
  29541. * transforms e.g. settings found in `block.json`.
  29542. */
  29543. const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
  29544. /**
  29545. * Inspector control panel containing the text transform options.
  29546. *
  29547. * @param {Object} props Block properties.
  29548. *
  29549. * @return {WPElement} Text transform edit element.
  29550. */
  29551. function TextTransformEdit(props) {
  29552. var _style$typography;
  29553. const {
  29554. attributes: {
  29555. style
  29556. },
  29557. setAttributes
  29558. } = props;
  29559. function onChange(newTransform) {
  29560. setAttributes({
  29561. style: cleanEmptyObject({ ...style,
  29562. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  29563. textTransform: newTransform
  29564. }
  29565. })
  29566. });
  29567. }
  29568. return (0,external_wp_element_namespaceObject.createElement)(TextTransformControl, {
  29569. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textTransform,
  29570. onChange: onChange
  29571. });
  29572. }
  29573. /**
  29574. * Checks if text-transform settings have been disabled.
  29575. *
  29576. * @param {string} name Name of the block.
  29577. *
  29578. * @return {boolean} Whether or not the setting is disabled.
  29579. */
  29580. function useIsTextTransformDisabled() {
  29581. let {
  29582. name: blockName
  29583. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  29584. const notSupported = !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, TEXT_TRANSFORM_SUPPORT_KEY);
  29585. const hasTextTransforms = useSetting('typography.textTransform');
  29586. return notSupported || !hasTextTransforms;
  29587. }
  29588. /**
  29589. * Checks if there is a current value set for the text transform block support.
  29590. *
  29591. * @param {Object} props Block props.
  29592. * @return {boolean} Whether or not the block has a text transform set.
  29593. */
  29594. function hasTextTransformValue(props) {
  29595. var _props$attributes$sty, _props$attributes$sty2;
  29596. 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);
  29597. }
  29598. /**
  29599. * Resets the text transform block support attribute. This can be used when
  29600. * disabling the text transform support controls for a block via a progressive
  29601. * discovery panel.
  29602. *
  29603. * @param {Object} props Block props.
  29604. * @param {Object} props.attributes Block's attributes.
  29605. * @param {Object} props.setAttributes Function to set block's attributes.
  29606. */
  29607. function resetTextTransform(_ref) {
  29608. let {
  29609. attributes = {},
  29610. setAttributes
  29611. } = _ref;
  29612. const {
  29613. style
  29614. } = attributes;
  29615. setAttributes({
  29616. style: cleanEmptyObject({ ...style,
  29617. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  29618. textTransform: undefined
  29619. }
  29620. })
  29621. });
  29622. }
  29623. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/letter-spacing-control/index.js
  29624. /**
  29625. * WordPress dependencies
  29626. */
  29627. /**
  29628. * Internal dependencies
  29629. */
  29630. /**
  29631. * Control for letter-spacing.
  29632. *
  29633. * @param {Object} props Component props.
  29634. * @param {string} props.value Currently selected letter-spacing.
  29635. * @param {Function} props.onChange Handles change in letter-spacing selection.
  29636. * @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS value.
  29637. *
  29638. * @return {WPElement} Letter-spacing control.
  29639. */
  29640. function LetterSpacingControl(_ref) {
  29641. let {
  29642. value,
  29643. onChange,
  29644. __unstableInputWidth = '60px'
  29645. } = _ref;
  29646. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  29647. availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem'],
  29648. defaultValues: {
  29649. px: 2,
  29650. em: 0.2,
  29651. rem: 0.2
  29652. }
  29653. });
  29654. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
  29655. label: (0,external_wp_i18n_namespaceObject.__)('Letter spacing'),
  29656. value: value,
  29657. __unstableInputWidth: __unstableInputWidth,
  29658. units: units,
  29659. onChange: onChange
  29660. });
  29661. }
  29662. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/letter-spacing.js
  29663. /**
  29664. * WordPress dependencies
  29665. */
  29666. /**
  29667. * Internal dependencies
  29668. */
  29669. /**
  29670. * Key within block settings' supports array indicating support for letter-spacing
  29671. * e.g. settings found in `block.json`.
  29672. */
  29673. const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
  29674. /**
  29675. * Inspector control panel containing the letter-spacing options.
  29676. *
  29677. * @param {Object} props Block properties.
  29678. * @return {WPElement} Letter-spacing edit element.
  29679. */
  29680. function LetterSpacingEdit(props) {
  29681. var _style$typography;
  29682. const {
  29683. attributes: {
  29684. style
  29685. },
  29686. setAttributes
  29687. } = props;
  29688. function onChange(newSpacing) {
  29689. setAttributes({
  29690. style: cleanEmptyObject({ ...style,
  29691. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  29692. letterSpacing: newSpacing
  29693. }
  29694. })
  29695. });
  29696. }
  29697. return (0,external_wp_element_namespaceObject.createElement)(LetterSpacingControl, {
  29698. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.letterSpacing,
  29699. onChange: onChange,
  29700. __unstableInputWidth: '100%'
  29701. });
  29702. }
  29703. /**
  29704. * Checks if letter-spacing settings have been disabled.
  29705. *
  29706. * @param {string} name Name of the block.
  29707. * @return {boolean} Whether or not the setting is disabled.
  29708. */
  29709. function useIsLetterSpacingDisabled() {
  29710. let {
  29711. name: blockName
  29712. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  29713. const notSupported = !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, LETTER_SPACING_SUPPORT_KEY);
  29714. const hasLetterSpacing = useSetting('typography.letterSpacing');
  29715. return notSupported || !hasLetterSpacing;
  29716. }
  29717. /**
  29718. * Checks if there is a current value set for the letter spacing block support.
  29719. *
  29720. * @param {Object} props Block props.
  29721. * @return {boolean} Whether or not the block has a letter spacing set.
  29722. */
  29723. function hasLetterSpacingValue(props) {
  29724. var _props$attributes$sty, _props$attributes$sty2;
  29725. 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);
  29726. }
  29727. /**
  29728. * Resets the letter spacing block support attribute. This can be used when
  29729. * disabling the letter spacing support controls for a block via a progressive
  29730. * discovery panel.
  29731. *
  29732. * @param {Object} props Block props.
  29733. * @param {Object} props.attributes Block's attributes.
  29734. * @param {Object} props.setAttributes Function to set block's attributes.
  29735. */
  29736. function resetLetterSpacing(_ref) {
  29737. let {
  29738. attributes = {},
  29739. setAttributes
  29740. } = _ref;
  29741. const {
  29742. style
  29743. } = attributes;
  29744. setAttributes({
  29745. style: cleanEmptyObject({ ...style,
  29746. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  29747. letterSpacing: undefined
  29748. }
  29749. })
  29750. });
  29751. }
  29752. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/typography.js
  29753. /**
  29754. * WordPress dependencies
  29755. */
  29756. /**
  29757. * Internal dependencies
  29758. */
  29759. const TYPOGRAPHY_SUPPORT_KEY = 'typography';
  29760. 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];
  29761. function TypographyPanel(props) {
  29762. const {
  29763. clientId
  29764. } = props;
  29765. const isFontFamilyDisabled = useIsFontFamilyDisabled(props);
  29766. const isFontSizeDisabled = useIsFontSizeDisabled(props);
  29767. const isFontAppearanceDisabled = useIsFontAppearanceDisabled(props);
  29768. const isLineHeightDisabled = useIsLineHeightDisabled(props);
  29769. const isTextDecorationDisabled = useIsTextDecorationDisabled(props);
  29770. const isTextTransformDisabled = useIsTextTransformDisabled(props);
  29771. const isLetterSpacingDisabled = useIsLetterSpacingDisabled(props);
  29772. const hasFontStyles = !useIsFontStyleDisabled(props);
  29773. const hasFontWeights = !useIsFontWeightDisabled(props);
  29774. const isDisabled = useIsTypographyDisabled(props);
  29775. const isSupported = hasTypographySupport(props.name);
  29776. if (isDisabled || !isSupported) return null;
  29777. const defaultControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [TYPOGRAPHY_SUPPORT_KEY, '__experimentalDefaultControls']);
  29778. const createResetAllFilter = attribute => newAttributes => {
  29779. var _newAttributes$style;
  29780. return { ...newAttributes,
  29781. style: { ...newAttributes.style,
  29782. typography: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style.typography),
  29783. [attribute]: undefined
  29784. }
  29785. }
  29786. };
  29787. };
  29788. return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
  29789. __experimentalGroup: "typography"
  29790. }, !isFontFamilyDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  29791. hasValue: () => hasFontFamilyValue(props),
  29792. label: (0,external_wp_i18n_namespaceObject.__)('Font family'),
  29793. onDeselect: () => resetFontFamily(props),
  29794. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.fontFamily,
  29795. resetAllFilter: newAttributes => ({ ...newAttributes,
  29796. fontFamily: undefined
  29797. }),
  29798. panelId: clientId
  29799. }, (0,external_wp_element_namespaceObject.createElement)(FontFamilyEdit, props)), !isFontSizeDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  29800. hasValue: () => hasFontSizeValue(props),
  29801. label: (0,external_wp_i18n_namespaceObject.__)('Font size'),
  29802. onDeselect: () => resetFontSize(props),
  29803. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.fontSize,
  29804. resetAllFilter: newAttributes => {
  29805. var _newAttributes$style2;
  29806. return { ...newAttributes,
  29807. fontSize: undefined,
  29808. style: { ...newAttributes.style,
  29809. typography: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.typography),
  29810. fontSize: undefined
  29811. }
  29812. }
  29813. };
  29814. },
  29815. panelId: clientId
  29816. }, (0,external_wp_element_namespaceObject.createElement)(FontSizeEdit, props)), !isFontAppearanceDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  29817. className: "single-column",
  29818. hasValue: () => hasFontAppearanceValue(props),
  29819. label: getFontAppearanceLabel(hasFontStyles, hasFontWeights),
  29820. onDeselect: () => resetFontAppearance(props),
  29821. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.fontAppearance,
  29822. resetAllFilter: newAttributes => {
  29823. var _newAttributes$style3;
  29824. return { ...newAttributes,
  29825. style: { ...newAttributes.style,
  29826. typography: { ...((_newAttributes$style3 = newAttributes.style) === null || _newAttributes$style3 === void 0 ? void 0 : _newAttributes$style3.typography),
  29827. fontStyle: undefined,
  29828. fontWeight: undefined
  29829. }
  29830. }
  29831. };
  29832. },
  29833. panelId: clientId
  29834. }, (0,external_wp_element_namespaceObject.createElement)(FontAppearanceEdit, props)), !isLineHeightDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  29835. className: "single-column",
  29836. hasValue: () => hasLineHeightValue(props),
  29837. label: (0,external_wp_i18n_namespaceObject.__)('Line height'),
  29838. onDeselect: () => resetLineHeight(props),
  29839. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.lineHeight,
  29840. resetAllFilter: createResetAllFilter('lineHeight'),
  29841. panelId: clientId
  29842. }, (0,external_wp_element_namespaceObject.createElement)(LineHeightEdit, props)), !isTextDecorationDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  29843. className: "single-column",
  29844. hasValue: () => hasTextDecorationValue(props),
  29845. label: (0,external_wp_i18n_namespaceObject.__)('Decoration'),
  29846. onDeselect: () => resetTextDecoration(props),
  29847. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.textDecoration,
  29848. resetAllFilter: createResetAllFilter('textDecoration'),
  29849. panelId: clientId
  29850. }, (0,external_wp_element_namespaceObject.createElement)(TextDecorationEdit, props)), !isTextTransformDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  29851. className: "single-column",
  29852. hasValue: () => hasTextTransformValue(props),
  29853. label: (0,external_wp_i18n_namespaceObject.__)('Letter case'),
  29854. onDeselect: () => resetTextTransform(props),
  29855. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.textTransform,
  29856. resetAllFilter: createResetAllFilter('textTransform'),
  29857. panelId: clientId
  29858. }, (0,external_wp_element_namespaceObject.createElement)(TextTransformEdit, props)), !isLetterSpacingDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
  29859. className: "single-column",
  29860. hasValue: () => hasLetterSpacingValue(props),
  29861. label: (0,external_wp_i18n_namespaceObject.__)('Letter spacing'),
  29862. onDeselect: () => resetLetterSpacing(props),
  29863. isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.letterSpacing,
  29864. resetAllFilter: createResetAllFilter('letterSpacing'),
  29865. panelId: clientId
  29866. }, (0,external_wp_element_namespaceObject.createElement)(LetterSpacingEdit, props)));
  29867. }
  29868. const hasTypographySupport = blockName => {
  29869. return TYPOGRAPHY_SUPPORT_KEYS.some(key => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, key));
  29870. };
  29871. function useIsTypographyDisabled() {
  29872. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  29873. const configs = [useIsFontAppearanceDisabled(props), useIsFontSizeDisabled(props), useIsLineHeightDisabled(props), useIsFontFamilyDisabled(props), useIsTextDecorationDisabled(props), useIsTextTransformDisabled(props), useIsLetterSpacingDisabled(props)];
  29874. return configs.filter(Boolean).length === configs.length;
  29875. }
  29876. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/style.js
  29877. /**
  29878. * External dependencies
  29879. */
  29880. /**
  29881. * WordPress dependencies
  29882. */
  29883. /**
  29884. * Internal dependencies
  29885. */
  29886. const styleSupportKeys = [...TYPOGRAPHY_SUPPORT_KEYS, BORDER_SUPPORT_KEY, COLOR_SUPPORT_KEY, SPACING_SUPPORT_KEY];
  29887. const hasStyleSupport = blockType => styleSupportKeys.some(key => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, key));
  29888. const VARIABLE_REFERENCE_PREFIX = 'var:';
  29889. const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
  29890. const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
  29891. function compileStyleValue(uncompiledValue) {
  29892. if ((0,external_lodash_namespaceObject.startsWith)(uncompiledValue, VARIABLE_REFERENCE_PREFIX)) {
  29893. const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
  29894. return `var(--wp--${variable})`;
  29895. }
  29896. return uncompiledValue;
  29897. }
  29898. /**
  29899. * Returns the inline styles to add depending on the style object
  29900. *
  29901. * @param {Object} styles Styles configuration.
  29902. *
  29903. * @return {Object} Flattened CSS variables declaration.
  29904. */
  29905. function getInlineStyles() {
  29906. let styles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  29907. const ignoredStyles = ['spacing.blockGap'];
  29908. const output = {};
  29909. Object.keys(external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY).forEach(propKey => {
  29910. const path = external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[propKey].value;
  29911. const subPaths = external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[propKey].properties; // Ignore styles on elements because they are handled on the server.
  29912. if ((0,external_lodash_namespaceObject.has)(styles, path) && 'elements' !== (0,external_lodash_namespaceObject.first)(path)) {
  29913. // Checking if style value is a string allows for shorthand css
  29914. // option and backwards compatibility for border radius support.
  29915. const styleValue = (0,external_lodash_namespaceObject.get)(styles, path);
  29916. if (!external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[propKey].useEngine) {
  29917. if (!!subPaths && !(0,external_lodash_namespaceObject.isString)(styleValue)) {
  29918. Object.entries(subPaths).forEach(entry => {
  29919. const [name, subPath] = entry;
  29920. const value = (0,external_lodash_namespaceObject.get)(styleValue, [subPath]);
  29921. if (value) {
  29922. output[name] = compileStyleValue(value);
  29923. }
  29924. });
  29925. } else if (!ignoredStyles.includes(path.join('.'))) {
  29926. output[propKey] = compileStyleValue((0,external_lodash_namespaceObject.get)(styles, path));
  29927. }
  29928. }
  29929. }
  29930. }); // The goal is to move everything to server side generated engine styles
  29931. // This is temporary as we absorb more and more styles into the engine.
  29932. const extraRules = getCSSRules(styles, {
  29933. selector: 'self'
  29934. });
  29935. extraRules.forEach(rule => {
  29936. if (rule.selector !== 'self') {
  29937. throw "This style can't be added as inline style";
  29938. }
  29939. output[rule.key] = rule.value;
  29940. });
  29941. return output;
  29942. }
  29943. function compileElementsStyles(selector) {
  29944. let elements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  29945. return (0,external_lodash_namespaceObject.map)(elements, (styles, element) => {
  29946. const elementStyles = getInlineStyles(styles);
  29947. if (!(0,external_lodash_namespaceObject.isEmpty)(elementStyles)) {
  29948. // The .editor-styles-wrapper selector is required on elements styles. As it is
  29949. // added to all other editor styles, not providing it causes reset and global
  29950. // styles to override element styles because of higher specificity.
  29951. return [`.editor-styles-wrapper .${selector} ${external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[element]}{`, ...(0,external_lodash_namespaceObject.map)(elementStyles, (value, property) => `\t${(0,external_lodash_namespaceObject.kebabCase)(property)}: ${value};`), '}'].join('\n');
  29952. }
  29953. return '';
  29954. }).join('\n');
  29955. }
  29956. /**
  29957. * Filters registered block settings, extending attributes to include `style` attribute.
  29958. *
  29959. * @param {Object} settings Original block settings.
  29960. *
  29961. * @return {Object} Filtered block settings.
  29962. */
  29963. function style_addAttribute(settings) {
  29964. if (!hasStyleSupport(settings)) {
  29965. return settings;
  29966. } // Allow blocks to specify their own attribute definition with default values if needed.
  29967. if (!settings.attributes.style) {
  29968. Object.assign(settings.attributes, {
  29969. style: {
  29970. type: 'object'
  29971. }
  29972. });
  29973. }
  29974. return settings;
  29975. }
  29976. /**
  29977. * A dictionary of paths to flag skipping block support serialization as the key,
  29978. * with values providing the style paths to be omitted from serialization.
  29979. *
  29980. * @constant
  29981. * @type {Record<string, string[]>}
  29982. */
  29983. const skipSerializationPathsEdit = {
  29984. [`${BORDER_SUPPORT_KEY}.__experimentalSkipSerialization`]: ['border'],
  29985. [`${COLOR_SUPPORT_KEY}.__experimentalSkipSerialization`]: [COLOR_SUPPORT_KEY],
  29986. [`${TYPOGRAPHY_SUPPORT_KEY}.__experimentalSkipSerialization`]: [TYPOGRAPHY_SUPPORT_KEY],
  29987. [`${SPACING_SUPPORT_KEY}.__experimentalSkipSerialization`]: ['spacing']
  29988. };
  29989. /**
  29990. * A dictionary of paths to flag skipping block support serialization as the key,
  29991. * with values providing the style paths to be omitted from serialization.
  29992. *
  29993. * Extends the Edit skip paths to enable skipping additional paths in just
  29994. * the Save component. This allows a block support to be serialized within the
  29995. * editor, while using an alternate approach, such as server-side rendering, when
  29996. * the support is saved.
  29997. *
  29998. * @constant
  29999. * @type {Record<string, string[]>}
  30000. */
  30001. const skipSerializationPathsSave = { ...skipSerializationPathsEdit,
  30002. [`${SPACING_SUPPORT_KEY}`]: ['spacing.blockGap']
  30003. };
  30004. /**
  30005. * A dictionary used to normalize feature names between support flags, style
  30006. * object properties and __experimentSkipSerialization configuration arrays.
  30007. *
  30008. * This allows not having to provide a migration for a support flag and possible
  30009. * backwards compatibility bridges, while still achieving consistency between
  30010. * the support flag and the skip serialization array.
  30011. *
  30012. * @constant
  30013. * @type {Record<string, string>}
  30014. */
  30015. const renamedFeatures = {
  30016. gradients: 'gradient'
  30017. };
  30018. /**
  30019. * Override props assigned to save component to inject the CSS variables definition.
  30020. *
  30021. * @param {Object} props Additional props applied to save element.
  30022. * @param {Object} blockType Block type.
  30023. * @param {Object} attributes Block attributes.
  30024. * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization.
  30025. *
  30026. * @return {Object} Filtered props applied to save element.
  30027. */
  30028. function style_addSaveProps(props, blockType, attributes) {
  30029. let skipPaths = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : skipSerializationPathsSave;
  30030. if (!hasStyleSupport(blockType)) {
  30031. return props;
  30032. }
  30033. let {
  30034. style
  30035. } = attributes;
  30036. (0,external_lodash_namespaceObject.forEach)(skipPaths, (path, indicator) => {
  30037. const skipSerialization = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, indicator);
  30038. if (skipSerialization === true) {
  30039. style = (0,external_lodash_namespaceObject.omit)(style, path);
  30040. }
  30041. if (Array.isArray(skipSerialization)) {
  30042. skipSerialization.forEach(featureName => {
  30043. const feature = renamedFeatures[featureName] || featureName;
  30044. style = (0,external_lodash_namespaceObject.omit)(style, [[...path, feature]]);
  30045. });
  30046. }
  30047. });
  30048. props.style = { ...getInlineStyles(style),
  30049. ...props.style
  30050. };
  30051. return props;
  30052. }
  30053. /**
  30054. * Filters registered block settings to extend the block edit wrapper
  30055. * to apply the desired styles and classnames properly.
  30056. *
  30057. * @param {Object} settings Original block settings.
  30058. *
  30059. * @return {Object}.Filtered block settings.
  30060. */
  30061. function style_addEditProps(settings) {
  30062. if (!hasStyleSupport(settings)) {
  30063. return settings;
  30064. }
  30065. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  30066. settings.getEditWrapperProps = attributes => {
  30067. let props = {};
  30068. if (existingGetEditWrapperProps) {
  30069. props = existingGetEditWrapperProps(attributes);
  30070. }
  30071. return style_addSaveProps(props, settings, attributes, skipSerializationPathsEdit);
  30072. };
  30073. return settings;
  30074. }
  30075. /**
  30076. * Override the default edit UI to include new inspector controls for
  30077. * all the custom styles configs.
  30078. *
  30079. * @param {Function} BlockEdit Original component.
  30080. *
  30081. * @return {Function} Wrapped component.
  30082. */
  30083. const withBlockControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  30084. const shouldDisplayControls = useDisplayBlockControls();
  30085. 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));
  30086. }, 'withToolbarControls');
  30087. /**
  30088. * Override the default block element to include duotone styles.
  30089. *
  30090. * @param {Function} BlockListBlock Original component
  30091. * @return {Function} Wrapped component
  30092. */
  30093. const withElementsStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  30094. var _props$attributes$sty, _props$attributes$sty2;
  30095. const blockElementsContainerIdentifier = `wp-elements-${(0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock)}`;
  30096. const skipLinkColorSerialization = shouldSkipSerialization(props.name, COLOR_SUPPORT_KEY, 'link'); // The Elements API only supports link colors for now,
  30097. // hence the specific omission of `link` in the elements styles.
  30098. // This might need to be refactored or removed if the Elements API
  30099. // changes or `link` supports styles beyond `color`.
  30100. const elements = skipLinkColorSerialization ? (0,external_lodash_namespaceObject.omit)((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.elements, ['link']) : (_props$attributes$sty2 = props.attributes.style) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.elements;
  30101. const styles = compileElementsStyles(blockElementsContainerIdentifier, elements);
  30102. const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext);
  30103. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, elements && element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)("style", {
  30104. dangerouslySetInnerHTML: {
  30105. __html: styles
  30106. }
  30107. }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  30108. className: elements ? classnames_default()(props.className, blockElementsContainerIdentifier) : props.className
  30109. })));
  30110. });
  30111. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/style/addAttribute', style_addAttribute);
  30112. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/style/addSaveProps', style_addSaveProps);
  30113. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/style/addEditProps', style_addEditProps);
  30114. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/style/with-block-controls', withBlockControls);
  30115. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/with-elements-styles', withElementsStyles);
  30116. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/duotone-control/index.js
  30117. /**
  30118. * WordPress dependencies
  30119. */
  30120. function DuotoneControl(_ref) {
  30121. let {
  30122. colorPalette,
  30123. duotonePalette,
  30124. disableCustomColors,
  30125. disableCustomDuotone,
  30126. value,
  30127. onChange
  30128. } = _ref;
  30129. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  30130. popoverProps: {
  30131. className: 'block-editor-duotone-control__popover',
  30132. headerTitle: (0,external_wp_i18n_namespaceObject.__)('Duotone'),
  30133. isAlternate: true
  30134. },
  30135. renderToggle: _ref2 => {
  30136. let {
  30137. isOpen,
  30138. onToggle
  30139. } = _ref2;
  30140. const openOnArrowDown = event => {
  30141. if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
  30142. event.preventDefault();
  30143. onToggle();
  30144. }
  30145. };
  30146. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  30147. showTooltip: true,
  30148. onClick: onToggle,
  30149. "aria-haspopup": "true",
  30150. "aria-expanded": isOpen,
  30151. onKeyDown: openOnArrowDown,
  30152. label: (0,external_wp_i18n_namespaceObject.__)('Apply duotone filter'),
  30153. icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DuotoneSwatch, {
  30154. values: value
  30155. })
  30156. });
  30157. },
  30158. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  30159. label: (0,external_wp_i18n_namespaceObject.__)('Duotone')
  30160. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  30161. className: "block-editor-duotone-control__description"
  30162. }, (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, {
  30163. colorPalette: colorPalette,
  30164. duotonePalette: duotonePalette,
  30165. disableCustomColors: disableCustomColors,
  30166. disableCustomDuotone: disableCustomDuotone,
  30167. value: value,
  30168. onChange: onChange
  30169. }))
  30170. });
  30171. }
  30172. /* harmony default export */ var duotone_control = (DuotoneControl);
  30173. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/duotone.js
  30174. /**
  30175. * External dependencies
  30176. */
  30177. /**
  30178. * WordPress dependencies
  30179. */
  30180. /**
  30181. * Internal dependencies
  30182. */
  30183. const duotone_EMPTY_ARRAY = [];
  30184. k([names]);
  30185. /**
  30186. * Convert a list of colors to an object of R, G, and B values.
  30187. *
  30188. * @param {string[]} colors Array of RBG color strings.
  30189. *
  30190. * @return {Object} R, G, and B values.
  30191. */
  30192. function getValuesFromColors() {
  30193. let colors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  30194. const values = {
  30195. r: [],
  30196. g: [],
  30197. b: [],
  30198. a: []
  30199. };
  30200. colors.forEach(color => {
  30201. const rgbColor = w(color).toRgb();
  30202. values.r.push(rgbColor.r / 255);
  30203. values.g.push(rgbColor.g / 255);
  30204. values.b.push(rgbColor.b / 255);
  30205. values.a.push(rgbColor.a);
  30206. });
  30207. return values;
  30208. }
  30209. /**
  30210. * Values for the SVG `feComponentTransfer`.
  30211. *
  30212. * @typedef Values {Object}
  30213. * @property {number[]} r Red values.
  30214. * @property {number[]} g Green values.
  30215. * @property {number[]} b Blue values.
  30216. * @property {number[]} a Alpha values.
  30217. */
  30218. /**
  30219. * Stylesheet for rendering the duotone filter.
  30220. *
  30221. * @param {Object} props Duotone props.
  30222. * @param {string} props.selector Selector to apply the filter to.
  30223. * @param {string} props.id Unique id for this duotone filter.
  30224. *
  30225. * @return {WPElement} Duotone element.
  30226. */
  30227. function DuotoneStylesheet(_ref) {
  30228. let {
  30229. selector,
  30230. id
  30231. } = _ref;
  30232. const css = `
  30233. ${selector} {
  30234. filter: url( #${id} );
  30235. }
  30236. `;
  30237. return (0,external_wp_element_namespaceObject.createElement)("style", null, css);
  30238. }
  30239. /**
  30240. * SVG for rendering the duotone filter.
  30241. *
  30242. * @param {Object} props Duotone props.
  30243. * @param {string} props.id Unique id for this duotone filter.
  30244. * @param {Values} props.values R, G, B, and A values to filter with.
  30245. *
  30246. * @return {WPElement} Duotone element.
  30247. */
  30248. function DuotoneFilter(_ref2) {
  30249. let {
  30250. id,
  30251. values
  30252. } = _ref2;
  30253. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  30254. xmlnsXlink: "http://www.w3.org/1999/xlink",
  30255. viewBox: "0 0 0 0",
  30256. width: "0",
  30257. height: "0",
  30258. focusable: "false",
  30259. role: "none",
  30260. style: {
  30261. visibility: 'hidden',
  30262. position: 'absolute',
  30263. left: '-9999px',
  30264. overflow: 'hidden'
  30265. }
  30266. }, (0,external_wp_element_namespaceObject.createElement)("defs", null, (0,external_wp_element_namespaceObject.createElement)("filter", {
  30267. id: id
  30268. }, (0,external_wp_element_namespaceObject.createElement)("feColorMatrix", {
  30269. // Use sRGB instead of linearRGB so transparency looks correct.
  30270. colorInterpolationFilters: "sRGB",
  30271. type: "matrix" // Use perceptual brightness to convert to grayscale.
  30272. ,
  30273. values: " .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "
  30274. }), (0,external_wp_element_namespaceObject.createElement)("feComponentTransfer", {
  30275. // Use sRGB instead of linearRGB to be consistent with how CSS gradients work.
  30276. colorInterpolationFilters: "sRGB"
  30277. }, (0,external_wp_element_namespaceObject.createElement)("feFuncR", {
  30278. type: "table",
  30279. tableValues: values.r.join(' ')
  30280. }), (0,external_wp_element_namespaceObject.createElement)("feFuncG", {
  30281. type: "table",
  30282. tableValues: values.g.join(' ')
  30283. }), (0,external_wp_element_namespaceObject.createElement)("feFuncB", {
  30284. type: "table",
  30285. tableValues: values.b.join(' ')
  30286. }), (0,external_wp_element_namespaceObject.createElement)("feFuncA", {
  30287. type: "table",
  30288. tableValues: values.a.join(' ')
  30289. })), (0,external_wp_element_namespaceObject.createElement)("feComposite", {
  30290. // Re-mask the image with the original transparency since the feColorMatrix above loses that information.
  30291. in2: "SourceGraphic",
  30292. operator: "in"
  30293. }))));
  30294. }
  30295. /**
  30296. * SVG and stylesheet needed for rendering the duotone filter.
  30297. *
  30298. * @param {Object} props Duotone props.
  30299. * @param {string} props.selector Selector to apply the filter to.
  30300. * @param {string} props.id Unique id for this duotone filter.
  30301. * @param {Values} props.values R, G, B, and A values to filter with.
  30302. *
  30303. * @return {WPElement} Duotone element.
  30304. */
  30305. function InlineDuotone(_ref3) {
  30306. let {
  30307. selector,
  30308. id,
  30309. values
  30310. } = _ref3;
  30311. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(DuotoneFilter, {
  30312. id: id,
  30313. values: values
  30314. }), (0,external_wp_element_namespaceObject.createElement)(DuotoneStylesheet, {
  30315. id: id,
  30316. selector: selector
  30317. }));
  30318. }
  30319. function useMultiOriginPresets(_ref4) {
  30320. let {
  30321. presetSetting,
  30322. defaultSetting
  30323. } = _ref4;
  30324. const disableDefault = !useSetting(defaultSetting);
  30325. const userPresets = useSetting(`${presetSetting}.custom`) || duotone_EMPTY_ARRAY;
  30326. const themePresets = useSetting(`${presetSetting}.theme`) || duotone_EMPTY_ARRAY;
  30327. const defaultPresets = useSetting(`${presetSetting}.default`) || duotone_EMPTY_ARRAY;
  30328. return (0,external_wp_element_namespaceObject.useMemo)(() => [...userPresets, ...themePresets, ...(disableDefault ? duotone_EMPTY_ARRAY : defaultPresets)], [disableDefault, userPresets, themePresets, defaultPresets]);
  30329. }
  30330. function DuotonePanel(_ref5) {
  30331. var _style$color;
  30332. let {
  30333. attributes,
  30334. setAttributes
  30335. } = _ref5;
  30336. const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
  30337. const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
  30338. const duotonePalette = useMultiOriginPresets({
  30339. presetSetting: 'color.duotone',
  30340. defaultSetting: 'color.defaultDuotone'
  30341. });
  30342. const colorPalette = useMultiOriginPresets({
  30343. presetSetting: 'color.palette',
  30344. defaultSetting: 'color.defaultPalette'
  30345. });
  30346. const disableCustomColors = !useSetting('color.custom');
  30347. const disableCustomDuotone = !useSetting('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors;
  30348. if ((duotonePalette === null || duotonePalette === void 0 ? void 0 : duotonePalette.length) === 0 && disableCustomDuotone) {
  30349. return null;
  30350. }
  30351. return (0,external_wp_element_namespaceObject.createElement)(block_controls, {
  30352. group: "block",
  30353. __experimentalShareWithChildBlocks: true
  30354. }, (0,external_wp_element_namespaceObject.createElement)(duotone_control, {
  30355. duotonePalette: duotonePalette,
  30356. colorPalette: colorPalette,
  30357. disableCustomDuotone: disableCustomDuotone,
  30358. disableCustomColors: disableCustomColors,
  30359. value: duotone,
  30360. onChange: newDuotone => {
  30361. const newStyle = { ...style,
  30362. color: { ...(style === null || style === void 0 ? void 0 : style.color),
  30363. duotone: newDuotone
  30364. }
  30365. };
  30366. setAttributes({
  30367. style: newStyle
  30368. });
  30369. }
  30370. }));
  30371. }
  30372. /**
  30373. * Filters registered block settings, extending attributes to include
  30374. * the `duotone` attribute.
  30375. *
  30376. * @param {Object} settings Original block settings.
  30377. *
  30378. * @return {Object} Filtered block settings.
  30379. */
  30380. function addDuotoneAttributes(settings) {
  30381. if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'color.__experimentalDuotone')) {
  30382. return settings;
  30383. } // Allow blocks to specify their own attribute definition with default
  30384. // values if needed.
  30385. if (!settings.attributes.style) {
  30386. Object.assign(settings.attributes, {
  30387. style: {
  30388. type: 'object'
  30389. }
  30390. });
  30391. }
  30392. return settings;
  30393. }
  30394. /**
  30395. * Override the default edit UI to include toolbar controls for duotone if the
  30396. * block supports duotone.
  30397. *
  30398. * @param {Function} BlockEdit Original component.
  30399. *
  30400. * @return {Function} Wrapped component.
  30401. */
  30402. const withDuotoneControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  30403. const hasDuotoneSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'color.__experimentalDuotone');
  30404. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), hasDuotoneSupport && (0,external_wp_element_namespaceObject.createElement)(DuotonePanel, props));
  30405. }, 'withDuotoneControls');
  30406. /**
  30407. * Function that scopes a selector with another one. This works a bit like
  30408. * SCSS nesting except the `&` operator isn't supported.
  30409. *
  30410. * @example
  30411. * ```js
  30412. * const scope = '.a, .b .c';
  30413. * const selector = '> .x, .y';
  30414. * const merged = scopeSelector( scope, selector );
  30415. * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'
  30416. * ```
  30417. *
  30418. * @param {string} scope Selector to scope to.
  30419. * @param {string} selector Original selector.
  30420. *
  30421. * @return {string} Scoped selector.
  30422. */
  30423. function scopeSelector(scope, selector) {
  30424. const scopes = scope.split(',');
  30425. const selectors = selector.split(',');
  30426. const selectorsScoped = [];
  30427. scopes.forEach(outer => {
  30428. selectors.forEach(inner => {
  30429. selectorsScoped.push(`${outer.trim()} ${inner.trim()}`);
  30430. });
  30431. });
  30432. return selectorsScoped.join(', ');
  30433. }
  30434. /**
  30435. * Override the default block element to include duotone styles.
  30436. *
  30437. * @param {Function} BlockListBlock Original component.
  30438. *
  30439. * @return {Function} Wrapped component.
  30440. */
  30441. const withDuotoneStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  30442. var _props$attributes, _props$attributes$sty, _props$attributes$sty2;
  30443. const duotoneSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, 'color.__experimentalDuotone');
  30444. const values = 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;
  30445. if (!duotoneSupport || !values) {
  30446. return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
  30447. }
  30448. const id = `wp-duotone-${(0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock)}`; // Extra .editor-styles-wrapper specificity is needed in the editor
  30449. // since we're not using inline styles to apply the filter. We need to
  30450. // override duotone applied by global styles and theme.json.
  30451. const selectorsGroup = scopeSelector(`.editor-styles-wrapper .${id}`, duotoneSupport);
  30452. const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, id);
  30453. const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext);
  30454. 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, {
  30455. selector: selectorsGroup,
  30456. id: id,
  30457. values: getValuesFromColors(values)
  30458. }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  30459. className: className
  30460. })));
  30461. }, 'withDuotoneStyles');
  30462. function PresetDuotoneFilter(_ref6) {
  30463. let {
  30464. preset
  30465. } = _ref6;
  30466. return (0,external_wp_element_namespaceObject.createElement)(DuotoneFilter, {
  30467. id: `wp-duotone-${preset.slug}`,
  30468. values: getValuesFromColors(preset.colors)
  30469. });
  30470. }
  30471. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/duotone/add-attributes', addDuotoneAttributes);
  30472. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/duotone/with-editor-controls', withDuotoneControls);
  30473. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/duotone/with-styles', withDuotoneStyles);
  30474. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/layout.js
  30475. /**
  30476. * External dependencies
  30477. */
  30478. /**
  30479. * WordPress dependencies
  30480. */
  30481. /**
  30482. * Internal dependencies
  30483. */
  30484. const layoutBlockSupportKey = '__experimentalLayout';
  30485. /**
  30486. * Generates the utility classnames for the given blocks layout attributes.
  30487. * This method was primarily added to reintroduce classnames that were removed
  30488. * in the 5.9 release (https://github.com/WordPress/gutenberg/issues/38719), rather
  30489. * than providing an extensive list of all possible layout classes. The plan is to
  30490. * have the style engine generate a more extensive list of utility classnames which
  30491. * will then replace this method.
  30492. *
  30493. * @param { Array } attributes Array of block attributes.
  30494. *
  30495. * @return { Array } Array of CSS classname strings.
  30496. */
  30497. function getLayoutClasses(attributes) {
  30498. var _attributes$layout, _attributes$layout2, _attributes$layout3;
  30499. const layoutClassnames = [];
  30500. if (!attributes.layout) {
  30501. return layoutClassnames;
  30502. }
  30503. if (attributes !== null && attributes !== void 0 && (_attributes$layout = attributes.layout) !== null && _attributes$layout !== void 0 && _attributes$layout.orientation) {
  30504. layoutClassnames.push(`is-${(0,external_lodash_namespaceObject.kebabCase)(attributes.layout.orientation)}`);
  30505. }
  30506. if (attributes !== null && attributes !== void 0 && (_attributes$layout2 = attributes.layout) !== null && _attributes$layout2 !== void 0 && _attributes$layout2.justifyContent) {
  30507. layoutClassnames.push(`is-content-justification-${(0,external_lodash_namespaceObject.kebabCase)(attributes.layout.justifyContent)}`);
  30508. }
  30509. if (attributes !== null && attributes !== void 0 && (_attributes$layout3 = attributes.layout) !== null && _attributes$layout3 !== void 0 && _attributes$layout3.flexWrap && attributes.layout.flexWrap === 'nowrap') {
  30510. layoutClassnames.push('is-nowrap');
  30511. }
  30512. return layoutClassnames;
  30513. }
  30514. function LayoutPanel(_ref) {
  30515. let {
  30516. setAttributes,
  30517. attributes,
  30518. name: blockName
  30519. } = _ref;
  30520. const {
  30521. layout
  30522. } = attributes;
  30523. const defaultThemeLayout = useSetting('layout');
  30524. const themeSupportsLayout = (0,external_wp_data_namespaceObject.useSelect)(select => {
  30525. const {
  30526. getSettings
  30527. } = select(store);
  30528. return getSettings().supportsLayout;
  30529. }, []);
  30530. const layoutBlockSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, layoutBlockSupportKey, {});
  30531. const {
  30532. allowSwitching,
  30533. allowEditing = true,
  30534. allowInheriting = true,
  30535. default: defaultBlockLayout
  30536. } = layoutBlockSupport;
  30537. if (!allowEditing) {
  30538. return null;
  30539. } // Only show the inherit toggle if it's supported,
  30540. // a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),
  30541. // and that the default / flow layout type is in use, as this is the only one that supports inheritance.
  30542. 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 && layout.inherit));
  30543. const usedLayout = layout || defaultBlockLayout || {};
  30544. const {
  30545. inherit = false,
  30546. type = 'default'
  30547. } = usedLayout;
  30548. /**
  30549. * `themeSupportsLayout` is only relevant to the `default/flow`
  30550. * layout and it should not be taken into account when other
  30551. * `layout` types are used.
  30552. */
  30553. if (type === 'default' && !themeSupportsLayout) {
  30554. return null;
  30555. }
  30556. const layoutType = getLayoutType(type);
  30557. const onChangeType = newType => setAttributes({
  30558. layout: {
  30559. type: newType
  30560. }
  30561. });
  30562. const onChangeLayout = newLayout => setAttributes({
  30563. layout: newLayout
  30564. });
  30565. 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, {
  30566. title: (0,external_wp_i18n_namespaceObject.__)('Layout')
  30567. }, showInheritToggle && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  30568. label: (0,external_wp_i18n_namespaceObject.__)('Inherit default layout'),
  30569. checked: !!inherit,
  30570. onChange: () => setAttributes({
  30571. layout: {
  30572. inherit: !inherit
  30573. }
  30574. })
  30575. }), !inherit && allowSwitching && (0,external_wp_element_namespaceObject.createElement)(LayoutTypeSwitcher, {
  30576. type: type,
  30577. onChange: onChangeType
  30578. }), !inherit && layoutType && (0,external_wp_element_namespaceObject.createElement)(layoutType.inspectorControls, {
  30579. layout: usedLayout,
  30580. onChange: onChangeLayout,
  30581. layoutBlockSupport: layoutBlockSupport
  30582. }))), !inherit && layoutType && (0,external_wp_element_namespaceObject.createElement)(layoutType.toolBarControls, {
  30583. layout: usedLayout,
  30584. onChange: onChangeLayout,
  30585. layoutBlockSupport: layoutBlockSupport
  30586. }));
  30587. }
  30588. function LayoutTypeSwitcher(_ref2) {
  30589. let {
  30590. type,
  30591. onChange
  30592. } = _ref2;
  30593. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ButtonGroup, null, getLayoutTypes().map(_ref3 => {
  30594. let {
  30595. name,
  30596. label
  30597. } = _ref3;
  30598. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  30599. key: name,
  30600. isPressed: type === name,
  30601. onClick: () => onChange(name)
  30602. }, label);
  30603. }));
  30604. }
  30605. /**
  30606. * Filters registered block settings, extending attributes to include `layout`.
  30607. *
  30608. * @param {Object} settings Original block settings.
  30609. *
  30610. * @return {Object} Filtered block settings.
  30611. */
  30612. function layout_addAttribute(settings) {
  30613. if ((0,external_lodash_namespaceObject.has)(settings.attributes, ['layout', 'type'])) {
  30614. return settings;
  30615. }
  30616. if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, layoutBlockSupportKey)) {
  30617. settings.attributes = { ...settings.attributes,
  30618. layout: {
  30619. type: 'object'
  30620. }
  30621. };
  30622. }
  30623. return settings;
  30624. }
  30625. /**
  30626. * Override the default edit UI to include layout controls
  30627. *
  30628. * @param {Function} BlockEdit Original component.
  30629. *
  30630. * @return {Function} Wrapped component.
  30631. */
  30632. const withInspectorControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  30633. const {
  30634. name: blockName
  30635. } = props;
  30636. const supportLayout = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, layoutBlockSupportKey);
  30637. return [supportLayout && (0,external_wp_element_namespaceObject.createElement)(LayoutPanel, _extends({
  30638. key: "layout"
  30639. }, props)), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({
  30640. key: "edit"
  30641. }, props))];
  30642. }, 'withInspectorControls');
  30643. /**
  30644. * Override the default block element to add the layout styles.
  30645. *
  30646. * @param {Function} BlockListBlock Original component.
  30647. *
  30648. * @return {Function} Wrapped component.
  30649. */
  30650. const withLayoutStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
  30651. const {
  30652. name,
  30653. attributes
  30654. } = props;
  30655. const shouldRenderLayoutStyles = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, layoutBlockSupportKey);
  30656. const id = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock);
  30657. const defaultThemeLayout = useSetting('layout') || {};
  30658. const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext);
  30659. const {
  30660. layout
  30661. } = attributes;
  30662. const {
  30663. default: defaultBlockLayout
  30664. } = (0,external_wp_blocks_namespaceObject.getBlockSupport)(name, layoutBlockSupportKey) || {};
  30665. const usedLayout = layout !== null && layout !== void 0 && layout.inherit ? defaultThemeLayout : layout || defaultBlockLayout || {};
  30666. const layoutClasses = shouldRenderLayoutStyles ? getLayoutClasses(attributes) : null;
  30667. const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, {
  30668. [`wp-container-${id}`]: shouldRenderLayoutStyles
  30669. }, layoutClasses);
  30670. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, shouldRenderLayoutStyles && element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(LayoutStyle, {
  30671. blockName: name,
  30672. selector: `.wp-container-${id}`,
  30673. layout: usedLayout,
  30674. style: attributes === null || attributes === void 0 ? void 0 : attributes.style
  30675. }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
  30676. className: className
  30677. })));
  30678. });
  30679. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/layout/addAttribute', layout_addAttribute);
  30680. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/layout/with-layout-styles', withLayoutStyles);
  30681. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/layout/with-inspector-controls', withInspectorControls);
  30682. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-border-props.js
  30683. /**
  30684. * External dependencies
  30685. */
  30686. /**
  30687. * Internal dependencies
  30688. */
  30689. // This utility is intended to assist where the serialization of the border
  30690. // block support is being skipped for a block but the border related CSS classes
  30691. // & styles still need to be generated so they can be applied to inner elements.
  30692. const use_border_props_EMPTY_ARRAY = [];
  30693. /**
  30694. * Provides the CSS class names and inline styles for a block's border support
  30695. * attributes.
  30696. *
  30697. * @param {Object} attributes Block attributes.
  30698. * @param {string} attributes.borderColor Selected named border color.
  30699. * @param {Object} attributes.style Block's styles attribute.
  30700. *
  30701. * @return {Object} Border block support derived CSS classes & styles.
  30702. */
  30703. function getBorderClassesAndStyles(_ref) {
  30704. var _style$border;
  30705. let {
  30706. borderColor,
  30707. style
  30708. } = _ref;
  30709. const borderStyles = (style === null || style === void 0 ? void 0 : style.border) || {};
  30710. const borderClass = getColorClassName('border-color', borderColor);
  30711. const className = classnames_default()({
  30712. [borderClass]: !!borderClass,
  30713. 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color)
  30714. });
  30715. return {
  30716. className: className || undefined,
  30717. style: getInlineStyles({
  30718. border: borderStyles
  30719. })
  30720. };
  30721. }
  30722. /**
  30723. * Derives the border related props for a block from its border block support
  30724. * attributes.
  30725. *
  30726. * Inline styles are forced for named colors to ensure these selections are
  30727. * reflected when themes do not load their color stylesheets in the editor.
  30728. *
  30729. * @param {Object} attributes Block attributes.
  30730. *
  30731. * @return {Object} ClassName & style props from border block support.
  30732. */
  30733. function useBorderProps(attributes) {
  30734. const colors = useSetting('color.palette') || use_border_props_EMPTY_ARRAY;
  30735. const borderProps = getBorderClassesAndStyles(attributes); // Force inline style to apply border color when themes do not load their
  30736. // color stylesheets in the editor.
  30737. if (attributes.borderColor) {
  30738. const borderColorObject = getColorObjectByAttributeValues(colors, attributes.borderColor);
  30739. borderProps.style.borderColor = borderColorObject.color;
  30740. }
  30741. return borderProps;
  30742. }
  30743. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-color-props.js
  30744. /**
  30745. * External dependencies
  30746. */
  30747. /**
  30748. * WordPress dependencies
  30749. */
  30750. /**
  30751. * Internal dependencies
  30752. */
  30753. // The code in this file has largely been lifted from the color block support
  30754. // hook.
  30755. //
  30756. // This utility is intended to assist where the serialization of the colors
  30757. // block support is being skipped for a block but the color related CSS classes
  30758. // & styles still need to be generated so they can be applied to inner elements.
  30759. /**
  30760. * Provides the CSS class names and inline styles for a block's color support
  30761. * attributes.
  30762. *
  30763. * @param {Object} attributes Block attributes.
  30764. *
  30765. * @return {Object} Color block support derived CSS classes & styles.
  30766. */
  30767. function getColorClassesAndStyles(attributes) {
  30768. var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link;
  30769. const {
  30770. backgroundColor,
  30771. textColor,
  30772. gradient,
  30773. style
  30774. } = attributes; // Collect color CSS classes.
  30775. const backgroundClass = getColorClassName('background-color', backgroundColor);
  30776. const textClass = getColorClassName('color', textColor);
  30777. const gradientClass = __experimentalGetGradientClass(gradient);
  30778. 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.
  30779. const className = classnames_default()(textClass, gradientClass, {
  30780. // Don't apply the background class if there's a gradient.
  30781. [backgroundClass]: !hasGradient && !!backgroundClass,
  30782. '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),
  30783. '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),
  30784. '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
  30785. }); // Collect inline styles for colors.
  30786. const colorStyles = (style === null || style === void 0 ? void 0 : style.color) || {};
  30787. const styleProp = getInlineStyles({
  30788. color: colorStyles
  30789. });
  30790. return {
  30791. className: className || undefined,
  30792. style: styleProp
  30793. };
  30794. }
  30795. const EMPTY_OBJECT = {};
  30796. /**
  30797. * Determines the color related props for a block derived from its color block
  30798. * support attributes.
  30799. *
  30800. * Inline styles are forced for named colors to ensure these selections are
  30801. * reflected when themes do not load their color stylesheets in the editor.
  30802. *
  30803. * @param {Object} attributes Block attributes.
  30804. *
  30805. * @return {Object} ClassName & style props from colors block support.
  30806. */
  30807. function useColorProps(attributes) {
  30808. const {
  30809. backgroundColor,
  30810. textColor,
  30811. gradient
  30812. } = attributes; // Some color settings have a special handling for deprecated flags in `useSetting`,
  30813. // so we can't unwrap them by doing const { ... } = useSetting('color')
  30814. // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
  30815. const userPalette = useSetting('color.palette.custom') || [];
  30816. const themePalette = useSetting('color.palette.theme') || [];
  30817. const defaultPalette = useSetting('color.palette.default') || [];
  30818. const gradientsPerOrigin = useSetting('color.gradients') || EMPTY_OBJECT;
  30819. const colors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
  30820. 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]);
  30821. const colorProps = getColorClassesAndStyles(attributes); // Force inline styles to apply colors when themes do not load their color
  30822. // stylesheets in the editor.
  30823. if (backgroundColor) {
  30824. const backgroundColorObject = getColorObjectByAttributeValues(colors, backgroundColor);
  30825. colorProps.style.backgroundColor = backgroundColorObject.color;
  30826. }
  30827. if (gradient) {
  30828. colorProps.style.background = getGradientValueBySlug(gradients, gradient);
  30829. }
  30830. if (textColor) {
  30831. const textColorObject = getColorObjectByAttributeValues(colors, textColor);
  30832. colorProps.style.color = textColorObject.color;
  30833. }
  30834. return colorProps;
  30835. }
  30836. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-spacing-props.js
  30837. /**
  30838. * Internal dependencies
  30839. */
  30840. // This utility is intended to assist where the serialization of the spacing
  30841. // block support is being skipped for a block but the spacing related CSS
  30842. // styles still need to be generated so they can be applied to inner elements.
  30843. /**
  30844. * Provides the CSS class names and inline styles for a block's spacing support
  30845. * attributes.
  30846. *
  30847. * @param {Object} attributes Block attributes.
  30848. *
  30849. * @return {Object} Spacing block support derived CSS classes & styles.
  30850. */
  30851. function getSpacingClassesAndStyles(attributes) {
  30852. const {
  30853. style
  30854. } = attributes; // Collect inline styles for spacing.
  30855. const spacingStyles = (style === null || style === void 0 ? void 0 : style.spacing) || {};
  30856. const styleProp = getInlineStyles({
  30857. spacing: spacingStyles
  30858. });
  30859. return {
  30860. style: styleProp
  30861. };
  30862. }
  30863. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-cached-truthy.js
  30864. /**
  30865. * WordPress dependencies
  30866. */
  30867. /**
  30868. * Keeps an up-to-date copy of the passed value and returns it. If value becomes falsy, it will return the last truthy copy.
  30869. *
  30870. * @param {any} value
  30871. * @return {any} value
  30872. */
  30873. function useCachedTruthy(value) {
  30874. const [cachedValue, setCachedValue] = (0,external_wp_element_namespaceObject.useState)(value);
  30875. (0,external_wp_element_namespaceObject.useEffect)(() => {
  30876. if (value) {
  30877. setCachedValue(value);
  30878. }
  30879. }, [value]);
  30880. return cachedValue;
  30881. }
  30882. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/index.js
  30883. /**
  30884. * Internal dependencies
  30885. */
  30886. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/with-colors.js
  30887. /**
  30888. * External dependencies
  30889. */
  30890. /**
  30891. * WordPress dependencies
  30892. */
  30893. /**
  30894. * Internal dependencies
  30895. */
  30896. /**
  30897. * Higher order component factory for injecting the `colorsArray` argument as
  30898. * the colors prop in the `withCustomColors` HOC.
  30899. *
  30900. * @param {Array} colorsArray An array of color objects.
  30901. *
  30902. * @return {Function} The higher order component.
  30903. */
  30904. const withCustomColorPalette = colorsArray => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  30905. colors: colorsArray
  30906. })), 'withCustomColorPalette');
  30907. /**
  30908. * Higher order component factory for injecting the editor colors as the
  30909. * `colors` prop in the `withColors` HOC.
  30910. *
  30911. * @return {Function} The higher order component.
  30912. */
  30913. const withEditorColorPalette = () => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
  30914. // Some color settings have a special handling for deprecated flags in `useSetting`,
  30915. // so we can't unwrap them by doing const { ... } = useSetting('color')
  30916. // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
  30917. const userPalette = useSetting('color.palette.custom');
  30918. const themePalette = useSetting('color.palette.theme');
  30919. const defaultPalette = useSetting('color.palette.default');
  30920. const allColors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
  30921. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  30922. colors: allColors
  30923. }));
  30924. }, 'withEditorColorPalette');
  30925. /**
  30926. * Helper function used with `createHigherOrderComponent` to create
  30927. * higher order components for managing color logic.
  30928. *
  30929. * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).
  30930. * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.
  30931. *
  30932. * @return {WPComponent} The component that can be used as a HOC.
  30933. */
  30934. function createColorHOC(colorTypes, withColorPalette) {
  30935. const colorMap = (0,external_lodash_namespaceObject.reduce)(colorTypes, (colorObject, colorType) => {
  30936. return { ...colorObject,
  30937. ...((0,external_lodash_namespaceObject.isString)(colorType) ? {
  30938. [colorType]: (0,external_lodash_namespaceObject.kebabCase)(colorType)
  30939. } : colorType)
  30940. };
  30941. }, {});
  30942. return (0,external_wp_compose_namespaceObject.compose)([withColorPalette, WrappedComponent => {
  30943. return class extends external_wp_element_namespaceObject.Component {
  30944. constructor(props) {
  30945. super(props);
  30946. this.setters = this.createSetters();
  30947. this.colorUtils = {
  30948. getMostReadableColor: this.getMostReadableColor.bind(this)
  30949. };
  30950. this.state = {};
  30951. }
  30952. getMostReadableColor(colorValue) {
  30953. const {
  30954. colors
  30955. } = this.props;
  30956. return getMostReadableColor(colors, colorValue);
  30957. }
  30958. createSetters() {
  30959. return (0,external_lodash_namespaceObject.reduce)(colorMap, (settersAccumulator, colorContext, colorAttributeName) => {
  30960. const upperFirstColorAttributeName = (0,external_lodash_namespaceObject.upperFirst)(colorAttributeName);
  30961. const customColorAttributeName = `custom${upperFirstColorAttributeName}`;
  30962. settersAccumulator[`set${upperFirstColorAttributeName}`] = this.createSetColor(colorAttributeName, customColorAttributeName);
  30963. return settersAccumulator;
  30964. }, {});
  30965. }
  30966. createSetColor(colorAttributeName, customColorAttributeName) {
  30967. return colorValue => {
  30968. const colorObject = getColorObjectByColorValue(this.props.colors, colorValue);
  30969. this.props.setAttributes({
  30970. [colorAttributeName]: colorObject && colorObject.slug ? colorObject.slug : undefined,
  30971. [customColorAttributeName]: colorObject && colorObject.slug ? undefined : colorValue
  30972. });
  30973. };
  30974. }
  30975. static getDerivedStateFromProps(_ref, previousState) {
  30976. let {
  30977. attributes,
  30978. colors
  30979. } = _ref;
  30980. return (0,external_lodash_namespaceObject.reduce)(colorMap, (newState, colorContext, colorAttributeName) => {
  30981. const colorObject = getColorObjectByAttributeValues(colors, attributes[colorAttributeName], attributes[`custom${(0,external_lodash_namespaceObject.upperFirst)(colorAttributeName)}`]);
  30982. const previousColorObject = previousState[colorAttributeName];
  30983. const previousColor = previousColorObject === null || previousColorObject === void 0 ? void 0 : previousColorObject.color;
  30984. /**
  30985. * The "and previousColorObject" condition checks that a previous color object was already computed.
  30986. * At the start previousColorObject and colorValue are both equal to undefined
  30987. * bus as previousColorObject does not exist we should compute the object.
  30988. */
  30989. if (previousColor === colorObject.color && previousColorObject) {
  30990. newState[colorAttributeName] = previousColorObject;
  30991. } else {
  30992. newState[colorAttributeName] = { ...colorObject,
  30993. class: getColorClassName(colorContext, colorObject.slug)
  30994. };
  30995. }
  30996. return newState;
  30997. }, {});
  30998. }
  30999. render() {
  31000. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props, {
  31001. colors: undefined
  31002. }, this.state, this.setters, {
  31003. colorUtils: this.colorUtils
  31004. }));
  31005. }
  31006. };
  31007. }]);
  31008. }
  31009. /**
  31010. * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic
  31011. * for class generation color value, retrieval and color attribute setting.
  31012. *
  31013. * Use this higher-order component to work with a custom set of colors.
  31014. *
  31015. * @example
  31016. *
  31017. * ```jsx
  31018. * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];
  31019. * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );
  31020. * // ...
  31021. * export default compose(
  31022. * withCustomColors( 'backgroundColor', 'borderColor' ),
  31023. * MyColorfulComponent,
  31024. * );
  31025. * ```
  31026. *
  31027. * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).
  31028. *
  31029. * @return {Function} Higher-order component.
  31030. */
  31031. function createCustomColorsHOC(colorsArray) {
  31032. return function () {
  31033. const withColorPalette = withCustomColorPalette(colorsArray);
  31034. for (var _len = arguments.length, colorTypes = new Array(_len), _key = 0; _key < _len; _key++) {
  31035. colorTypes[_key] = arguments[_key];
  31036. }
  31037. return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(createColorHOC(colorTypes, withColorPalette), 'withCustomColors');
  31038. };
  31039. }
  31040. /**
  31041. * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.
  31042. *
  31043. * For use with the default editor/theme color palette.
  31044. *
  31045. * @example
  31046. *
  31047. * ```jsx
  31048. * export default compose(
  31049. * withColors( 'backgroundColor', { textColor: 'color' } ),
  31050. * MyColorfulComponent,
  31051. * );
  31052. * ```
  31053. *
  31054. * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,
  31055. * it should contain the color attribute name as key and the color context as value.
  31056. * If the argument is a string the value should be the color attribute name,
  31057. * the color context is computed by applying a kebab case transform to the value.
  31058. * Color context represents the context/place where the color is going to be used.
  31059. * The class name of the color is generated using 'has' followed by the color name
  31060. * and ending with the color context all in kebab case e.g: has-green-background-color.
  31061. *
  31062. * @return {Function} Higher-order component.
  31063. */
  31064. function withColors() {
  31065. const withColorPalette = withEditorColorPalette();
  31066. for (var _len2 = arguments.length, colorTypes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  31067. colorTypes[_key2] = arguments[_key2];
  31068. }
  31069. return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(createColorHOC(colorTypes, withColorPalette), 'withColors');
  31070. }
  31071. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/index.js
  31072. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradients/index.js
  31073. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/with-font-sizes.js
  31074. /**
  31075. * External dependencies
  31076. */
  31077. /**
  31078. * WordPress dependencies
  31079. */
  31080. /**
  31081. * Internal dependencies
  31082. */
  31083. const DEFAULT_FONT_SIZES = [];
  31084. /**
  31085. * Higher-order component, which handles font size logic for class generation,
  31086. * font size value retrieval, and font size change handling.
  31087. *
  31088. * @param {...(Object|string)} fontSizeNames The arguments should all be strings.
  31089. * Each string contains the font size
  31090. * attribute name e.g: 'fontSize'.
  31091. *
  31092. * @return {Function} Higher-order component.
  31093. */
  31094. /* harmony default export */ var with_font_sizes = (function () {
  31095. for (var _len = arguments.length, fontSizeNames = new Array(_len), _key = 0; _key < _len; _key++) {
  31096. fontSizeNames[_key] = arguments[_key];
  31097. }
  31098. /*
  31099. * Computes an object whose key is the font size attribute name as passed in the array,
  31100. * and the value is the custom font size attribute name.
  31101. * Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized.
  31102. */
  31103. const fontSizeAttributeNames = (0,external_lodash_namespaceObject.reduce)(fontSizeNames, (fontSizeAttributeNamesAccumulator, fontSizeAttributeName) => {
  31104. fontSizeAttributeNamesAccumulator[fontSizeAttributeName] = `custom${(0,external_lodash_namespaceObject.upperFirst)(fontSizeAttributeName)}`;
  31105. return fontSizeAttributeNamesAccumulator;
  31106. }, {});
  31107. return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
  31108. const fontSizes = useSetting('typography.fontSizes') || DEFAULT_FONT_SIZES;
  31109. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  31110. fontSizes: fontSizes
  31111. }));
  31112. }, 'withFontSizes'), WrappedComponent => {
  31113. return class extends external_wp_element_namespaceObject.Component {
  31114. constructor(props) {
  31115. super(props);
  31116. this.setters = this.createSetters();
  31117. this.state = {};
  31118. }
  31119. createSetters() {
  31120. return (0,external_lodash_namespaceObject.reduce)(fontSizeAttributeNames, (settersAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => {
  31121. const upperFirstFontSizeAttributeName = (0,external_lodash_namespaceObject.upperFirst)(fontSizeAttributeName);
  31122. settersAccumulator[`set${upperFirstFontSizeAttributeName}`] = this.createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName);
  31123. return settersAccumulator;
  31124. }, {});
  31125. }
  31126. createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName) {
  31127. return fontSizeValue => {
  31128. const fontSizeObject = (0,external_lodash_namespaceObject.find)(this.props.fontSizes, {
  31129. size: Number(fontSizeValue)
  31130. });
  31131. this.props.setAttributes({
  31132. [fontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? fontSizeObject.slug : undefined,
  31133. [customFontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? undefined : fontSizeValue
  31134. });
  31135. };
  31136. }
  31137. static getDerivedStateFromProps(_ref, previousState) {
  31138. let {
  31139. attributes,
  31140. fontSizes
  31141. } = _ref;
  31142. const didAttributesChange = (customFontSizeAttributeName, fontSizeAttributeName) => {
  31143. if (previousState[fontSizeAttributeName]) {
  31144. // If new font size is name compare with the previous slug.
  31145. if (attributes[fontSizeAttributeName]) {
  31146. return attributes[fontSizeAttributeName] !== previousState[fontSizeAttributeName].slug;
  31147. } // If font size is not named, update when the font size value changes.
  31148. return previousState[fontSizeAttributeName].size !== attributes[customFontSizeAttributeName];
  31149. } // In this case we need to build the font size object.
  31150. return true;
  31151. };
  31152. if (!(0,external_lodash_namespaceObject.some)(fontSizeAttributeNames, didAttributesChange)) {
  31153. return null;
  31154. }
  31155. const newState = (0,external_lodash_namespaceObject.reduce)((0,external_lodash_namespaceObject.pickBy)(fontSizeAttributeNames, didAttributesChange), (newStateAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => {
  31156. const fontSizeAttributeValue = attributes[fontSizeAttributeName];
  31157. const fontSizeObject = getFontSize(fontSizes, fontSizeAttributeValue, attributes[customFontSizeAttributeName]);
  31158. newStateAccumulator[fontSizeAttributeName] = { ...fontSizeObject,
  31159. class: getFontSizeClass(fontSizeAttributeValue)
  31160. };
  31161. return newStateAccumulator;
  31162. }, {});
  31163. return { ...previousState,
  31164. ...newState
  31165. };
  31166. }
  31167. render() {
  31168. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props, {
  31169. fontSizes: undefined
  31170. }, this.state, this.setters));
  31171. }
  31172. };
  31173. }]), 'withFontSizes');
  31174. });
  31175. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/index.js
  31176. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-left.js
  31177. /**
  31178. * WordPress dependencies
  31179. */
  31180. const alignLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31181. xmlns: "http://www.w3.org/2000/svg",
  31182. viewBox: "0 0 24 24"
  31183. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31184. d: "M4 19.8h8.9v-1.5H4v1.5zm8.9-15.6H4v1.5h8.9V4.2zm-8.9 7v1.5h16v-1.5H4z"
  31185. }));
  31186. /* harmony default export */ var align_left = (alignLeft);
  31187. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-center.js
  31188. /**
  31189. * WordPress dependencies
  31190. */
  31191. const align_center_alignCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31192. xmlns: "http://www.w3.org/2000/svg",
  31193. viewBox: "0 0 24 24"
  31194. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31195. d: "M16.4 4.2H7.6v1.5h8.9V4.2zM4 11.2v1.5h16v-1.5H4zm3.6 8.6h8.9v-1.5H7.6v1.5z"
  31196. }));
  31197. /* harmony default export */ var align_center = (align_center_alignCenter);
  31198. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-right.js
  31199. /**
  31200. * WordPress dependencies
  31201. */
  31202. const alignRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31203. xmlns: "http://www.w3.org/2000/svg",
  31204. viewBox: "0 0 24 24"
  31205. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31206. d: "M11.1 19.8H20v-1.5h-8.9v1.5zm0-15.6v1.5H20V4.2h-8.9zM4 12.8h16v-1.5H4v1.5z"
  31207. }));
  31208. /* harmony default export */ var align_right = (alignRight);
  31209. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/alignment-control/ui.js
  31210. /**
  31211. * External dependencies
  31212. */
  31213. /**
  31214. * WordPress dependencies
  31215. */
  31216. const DEFAULT_ALIGNMENT_CONTROLS = [{
  31217. icon: align_left,
  31218. title: (0,external_wp_i18n_namespaceObject.__)('Align text left'),
  31219. align: 'left'
  31220. }, {
  31221. icon: align_center,
  31222. title: (0,external_wp_i18n_namespaceObject.__)('Align text center'),
  31223. align: 'center'
  31224. }, {
  31225. icon: align_right,
  31226. title: (0,external_wp_i18n_namespaceObject.__)('Align text right'),
  31227. align: 'right'
  31228. }];
  31229. const alignment_control_ui_POPOVER_PROPS = {
  31230. position: 'bottom right',
  31231. isAlternate: true
  31232. };
  31233. function AlignmentUI(_ref) {
  31234. let {
  31235. value,
  31236. onChange,
  31237. alignmentControls = DEFAULT_ALIGNMENT_CONTROLS,
  31238. label = (0,external_wp_i18n_namespaceObject.__)('Align'),
  31239. describedBy = (0,external_wp_i18n_namespaceObject.__)('Change text alignment'),
  31240. isCollapsed = true,
  31241. isToolbar
  31242. } = _ref;
  31243. function applyOrUnset(align) {
  31244. return () => onChange(value === align ? undefined : align);
  31245. }
  31246. const activeAlignment = (0,external_lodash_namespaceObject.find)(alignmentControls, control => control.align === value);
  31247. function setIcon() {
  31248. if (activeAlignment) return activeAlignment.icon;
  31249. return (0,external_wp_i18n_namespaceObject.isRTL)() ? align_right : align_left;
  31250. }
  31251. const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
  31252. const extraProps = isToolbar ? {
  31253. isCollapsed
  31254. } : {};
  31255. return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({
  31256. icon: setIcon(),
  31257. label: label,
  31258. toggleProps: {
  31259. describedBy
  31260. },
  31261. popoverProps: alignment_control_ui_POPOVER_PROPS,
  31262. controls: alignmentControls.map(control => {
  31263. const {
  31264. align
  31265. } = control;
  31266. const isActive = value === align;
  31267. return { ...control,
  31268. isActive,
  31269. role: isCollapsed ? 'menuitemradio' : undefined,
  31270. onClick: applyOrUnset(align)
  31271. };
  31272. })
  31273. }, extraProps));
  31274. }
  31275. /* harmony default export */ var alignment_control_ui = (AlignmentUI);
  31276. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/alignment-control/index.js
  31277. /**
  31278. * Internal dependencies
  31279. */
  31280. const AlignmentControl = props => {
  31281. return (0,external_wp_element_namespaceObject.createElement)(alignment_control_ui, _extends({}, props, {
  31282. isToolbar: false
  31283. }));
  31284. };
  31285. const AlignmentToolbar = props => {
  31286. return (0,external_wp_element_namespaceObject.createElement)(alignment_control_ui, _extends({}, props, {
  31287. isToolbar: true
  31288. }));
  31289. };
  31290. /**
  31291. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/alignment-control/README.md
  31292. */
  31293. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/autocompleters/block.js
  31294. /**
  31295. * External dependencies
  31296. */
  31297. /**
  31298. * WordPress dependencies
  31299. */
  31300. /**
  31301. * Internal dependencies
  31302. */
  31303. const block_SHOWN_BLOCK_TYPES = 9;
  31304. /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
  31305. /**
  31306. * Creates a blocks repeater for replacing the current block with a selected block type.
  31307. *
  31308. * @return {WPCompleter} A blocks completer.
  31309. */
  31310. function createBlockCompleter() {
  31311. return {
  31312. name: 'blocks',
  31313. className: 'block-editor-autocompleters__block',
  31314. triggerPrefix: '/',
  31315. useItems(filterValue) {
  31316. const {
  31317. rootClientId,
  31318. selectedBlockName
  31319. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  31320. const {
  31321. getSelectedBlockClientId,
  31322. getBlockName,
  31323. getBlockInsertionPoint
  31324. } = select(store);
  31325. const selectedBlockClientId = getSelectedBlockClientId();
  31326. return {
  31327. selectedBlockName: selectedBlockClientId ? getBlockName(selectedBlockClientId) : null,
  31328. rootClientId: getBlockInsertionPoint().rootClientId
  31329. };
  31330. }, []);
  31331. const [items, categories, collections] = use_block_types_state(rootClientId, external_lodash_namespaceObject.noop);
  31332. const filteredItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
  31333. const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : (0,external_lodash_namespaceObject.orderBy)(items, ['frecency'], ['desc']);
  31334. return initialFilteredItems.filter(item => item.name !== selectedBlockName).slice(0, block_SHOWN_BLOCK_TYPES);
  31335. }, [filterValue, selectedBlockName, items, categories, collections]);
  31336. const options = (0,external_wp_element_namespaceObject.useMemo)(() => filteredItems.map(blockItem => {
  31337. const {
  31338. title,
  31339. icon,
  31340. isDisabled
  31341. } = blockItem;
  31342. return {
  31343. key: `block-${blockItem.id}`,
  31344. value: blockItem,
  31345. label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  31346. key: "icon",
  31347. icon: icon,
  31348. showColors: true
  31349. }), title),
  31350. isDisabled
  31351. };
  31352. }), [filteredItems]);
  31353. return [options];
  31354. },
  31355. allowContext(before, after) {
  31356. return !(/\S/.test(before) || /\S/.test(after));
  31357. },
  31358. getOptionCompletion(inserterItem) {
  31359. const {
  31360. name,
  31361. initialAttributes,
  31362. innerBlocks
  31363. } = inserterItem;
  31364. return {
  31365. action: 'replace',
  31366. value: (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(innerBlocks))
  31367. };
  31368. }
  31369. };
  31370. }
  31371. /**
  31372. * Creates a blocks repeater for replacing the current block with a selected block type.
  31373. *
  31374. * @return {WPCompleter} A blocks completer.
  31375. */
  31376. /* harmony default export */ var autocompleters_block = (createBlockCompleter());
  31377. ;// CONCATENATED MODULE: external ["wp","apiFetch"]
  31378. var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
  31379. var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
  31380. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js
  31381. /**
  31382. * WordPress dependencies
  31383. */
  31384. const page = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31385. xmlns: "http://www.w3.org/2000/svg",
  31386. viewBox: "0 0 24 24"
  31387. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31388. 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"
  31389. }));
  31390. /* harmony default export */ var library_page = (page);
  31391. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post.js
  31392. /**
  31393. * WordPress dependencies
  31394. */
  31395. const post = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31396. xmlns: "http://www.w3.org/2000/svg",
  31397. viewBox: "0 0 24 24"
  31398. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31399. 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"
  31400. }));
  31401. /* harmony default export */ var library_post = (post);
  31402. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/autocompleters/link.js
  31403. /**
  31404. * WordPress dependencies
  31405. */
  31406. const SHOWN_SUGGESTIONS = 10;
  31407. /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
  31408. /**
  31409. * Creates a suggestion list for links to posts or pages.
  31410. *
  31411. * @return {WPCompleter} A links completer.
  31412. */
  31413. function createLinkCompleter() {
  31414. return {
  31415. name: 'links',
  31416. className: 'block-editor-autocompleters__link',
  31417. triggerPrefix: '[[',
  31418. options: async letters => {
  31419. let options = await external_wp_apiFetch_default()({
  31420. path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
  31421. per_page: SHOWN_SUGGESTIONS,
  31422. search: letters,
  31423. type: 'post',
  31424. order_by: 'menu_order'
  31425. })
  31426. });
  31427. options = options.filter(option => option.title !== '');
  31428. return options;
  31429. },
  31430. getOptionKeywords(item) {
  31431. const expansionWords = item.title.split(/\s+/);
  31432. return [...expansionWords];
  31433. },
  31434. getOptionLabel(item) {
  31435. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  31436. key: "icon",
  31437. icon: item.subtype === 'page' ? library_page : library_post
  31438. }), item.title);
  31439. },
  31440. getOptionCompletion(item) {
  31441. return (0,external_wp_element_namespaceObject.createElement)("a", {
  31442. href: item.url
  31443. }, item.title);
  31444. }
  31445. };
  31446. }
  31447. /**
  31448. * Creates a suggestion list for links to posts or pages..
  31449. *
  31450. * @return {WPCompleter} A link completer.
  31451. */
  31452. /* harmony default export */ var autocompleters_link = (createLinkCompleter());
  31453. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/autocomplete/index.js
  31454. /**
  31455. * External dependencies
  31456. */
  31457. /**
  31458. * WordPress dependencies
  31459. */
  31460. /**
  31461. * Internal dependencies
  31462. */
  31463. /**
  31464. * Shared reference to an empty array for cases where it is important to avoid
  31465. * returning a new array reference on every invocation.
  31466. *
  31467. * @type {Array}
  31468. */
  31469. const autocomplete_EMPTY_ARRAY = [];
  31470. function useCompleters(_ref) {
  31471. let {
  31472. completers = autocomplete_EMPTY_ARRAY
  31473. } = _ref;
  31474. const {
  31475. name
  31476. } = useBlockEditContext();
  31477. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  31478. let filteredCompleters = completers;
  31479. if (name === (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() || (0,external_wp_blocks_namespaceObject.getBlockSupport)(name, '__experimentalSlashInserter', false)) {
  31480. filteredCompleters = filteredCompleters.concat([autocompleters_block, autocompleters_link]);
  31481. }
  31482. if ((0,external_wp_hooks_namespaceObject.hasFilter)('editor.Autocomplete.completers')) {
  31483. // Provide copies so filters may directly modify them.
  31484. if (filteredCompleters === completers) {
  31485. filteredCompleters = filteredCompleters.map(external_lodash_namespaceObject.clone);
  31486. }
  31487. filteredCompleters = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.Autocomplete.completers', filteredCompleters, name);
  31488. }
  31489. return filteredCompleters;
  31490. }, [completers, name]);
  31491. }
  31492. function useBlockEditorAutocompleteProps(props) {
  31493. return (0,external_wp_components_namespaceObject.__unstableUseAutocompleteProps)({ ...props,
  31494. completers: useCompleters(props)
  31495. });
  31496. }
  31497. /**
  31498. * Wrap the default Autocomplete component with one that supports a filter hook
  31499. * for customizing its list of autocompleters.
  31500. *
  31501. * @type {import('react').FC}
  31502. */
  31503. function BlockEditorAutocomplete(props) {
  31504. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Autocomplete, _extends({}, props, {
  31505. completers: useCompleters(props)
  31506. }));
  31507. }
  31508. /**
  31509. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/autocomplete/README.md
  31510. */
  31511. /* harmony default export */ var autocomplete = (BlockEditorAutocomplete);
  31512. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/fullscreen.js
  31513. /**
  31514. * WordPress dependencies
  31515. */
  31516. const fullscreen = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31517. xmlns: "http://www.w3.org/2000/svg",
  31518. viewBox: "0 0 24 24"
  31519. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31520. 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"
  31521. }));
  31522. /* harmony default export */ var library_fullscreen = (fullscreen);
  31523. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-full-height-alignment-control/index.js
  31524. /**
  31525. * WordPress dependencies
  31526. */
  31527. function BlockFullHeightAlignmentControl(_ref) {
  31528. let {
  31529. isActive,
  31530. label = (0,external_wp_i18n_namespaceObject.__)('Toggle full height'),
  31531. onToggle,
  31532. isDisabled
  31533. } = _ref;
  31534. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  31535. isActive: isActive,
  31536. icon: library_fullscreen,
  31537. label: label,
  31538. onClick: () => onToggle(!isActive),
  31539. disabled: isDisabled
  31540. });
  31541. }
  31542. /* harmony default export */ var block_full_height_alignment_control = (BlockFullHeightAlignmentControl);
  31543. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-matrix-control/index.js
  31544. /**
  31545. * External dependencies
  31546. */
  31547. /**
  31548. * WordPress dependencies
  31549. */
  31550. function BlockAlignmentMatrixControl(props) {
  31551. const {
  31552. label = (0,external_wp_i18n_namespaceObject.__)('Change matrix alignment'),
  31553. onChange = external_lodash_namespaceObject.noop,
  31554. value = 'center',
  31555. isDisabled
  31556. } = props;
  31557. const icon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalAlignmentMatrixControl.Icon, {
  31558. value: value
  31559. });
  31560. const className = 'block-editor-block-alignment-matrix-control';
  31561. const popoverClassName = `${className}__popover`;
  31562. const isAlternate = true;
  31563. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  31564. position: "bottom right",
  31565. className: className,
  31566. popoverProps: {
  31567. className: popoverClassName,
  31568. isAlternate
  31569. },
  31570. renderToggle: _ref => {
  31571. let {
  31572. onToggle,
  31573. isOpen
  31574. } = _ref;
  31575. const openOnArrowDown = event => {
  31576. if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
  31577. event.preventDefault();
  31578. onToggle();
  31579. }
  31580. };
  31581. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  31582. onClick: onToggle,
  31583. "aria-haspopup": "true",
  31584. "aria-expanded": isOpen,
  31585. onKeyDown: openOnArrowDown,
  31586. label: label,
  31587. icon: icon,
  31588. showTooltip: true,
  31589. disabled: isDisabled
  31590. });
  31591. },
  31592. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalAlignmentMatrixControl, {
  31593. hasFocusBorder: false,
  31594. onChange: onChange,
  31595. value: value
  31596. })
  31597. });
  31598. }
  31599. /* harmony default export */ var block_alignment_matrix_control = (BlockAlignmentMatrixControl);
  31600. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right-small.js
  31601. /**
  31602. * WordPress dependencies
  31603. */
  31604. const chevronRightSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31605. xmlns: "http://www.w3.org/2000/svg",
  31606. viewBox: "0 0 24 24"
  31607. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31608. d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"
  31609. }));
  31610. /* harmony default export */ var chevron_right_small = (chevronRightSmall);
  31611. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-breadcrumb/index.js
  31612. /**
  31613. * WordPress dependencies
  31614. */
  31615. /**
  31616. * Internal dependencies
  31617. */
  31618. /**
  31619. * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.
  31620. *
  31621. * @param {Object} props Component props.
  31622. * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.
  31623. * @return {WPElement} Block Breadcrumb.
  31624. */
  31625. function BlockBreadcrumb(_ref) {
  31626. let {
  31627. rootLabelText
  31628. } = _ref;
  31629. const {
  31630. selectBlock,
  31631. clearSelectedBlock
  31632. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  31633. const {
  31634. clientId,
  31635. parents,
  31636. hasSelection
  31637. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  31638. const {
  31639. getSelectionStart,
  31640. getSelectedBlockClientId,
  31641. getBlockParents
  31642. } = select(store);
  31643. const selectedBlockClientId = getSelectedBlockClientId();
  31644. return {
  31645. parents: getBlockParents(selectedBlockClientId),
  31646. clientId: selectedBlockClientId,
  31647. hasSelection: !!getSelectionStart().clientId
  31648. };
  31649. }, []);
  31650. const rootLabel = rootLabelText || (0,external_wp_i18n_namespaceObject.__)('Document');
  31651. /*
  31652. * Disable reason: The `list` ARIA role is redundant but
  31653. * Safari+VoiceOver won't announce the list otherwise.
  31654. */
  31655. /* eslint-disable jsx-a11y/no-redundant-roles */
  31656. return (0,external_wp_element_namespaceObject.createElement)("ul", {
  31657. className: "block-editor-block-breadcrumb",
  31658. role: "list",
  31659. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block breadcrumb')
  31660. }, (0,external_wp_element_namespaceObject.createElement)("li", {
  31661. className: !hasSelection ? 'block-editor-block-breadcrumb__current' : undefined,
  31662. "aria-current": !hasSelection ? 'true' : undefined
  31663. }, hasSelection && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  31664. className: "block-editor-block-breadcrumb__button",
  31665. variant: "tertiary",
  31666. onClick: clearSelectedBlock
  31667. }, rootLabel), !hasSelection && rootLabel, !!clientId && (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  31668. icon: chevron_right_small,
  31669. className: "block-editor-block-breadcrumb__separator"
  31670. })), parents.map(parentClientId => (0,external_wp_element_namespaceObject.createElement)("li", {
  31671. key: parentClientId
  31672. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  31673. className: "block-editor-block-breadcrumb__button",
  31674. variant: "tertiary",
  31675. onClick: () => selectBlock(parentClientId)
  31676. }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
  31677. clientId: parentClientId,
  31678. maximumLength: 35
  31679. })), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  31680. icon: chevron_right_small,
  31681. className: "block-editor-block-breadcrumb__separator"
  31682. }))), !!clientId && (0,external_wp_element_namespaceObject.createElement)("li", {
  31683. className: "block-editor-block-breadcrumb__current",
  31684. "aria-current": "true"
  31685. }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
  31686. clientId: clientId,
  31687. maximumLength: 35
  31688. })))
  31689. /* eslint-enable jsx-a11y/no-redundant-roles */
  31690. ;
  31691. }
  31692. /* harmony default export */ var block_breadcrumb = (BlockBreadcrumb);
  31693. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-content-overlay/index.js
  31694. /**
  31695. * WordPress dependencies
  31696. */
  31697. /**
  31698. * Internal dependencies
  31699. */
  31700. /**
  31701. * External dependencies
  31702. */
  31703. function BlockContentOverlay(_ref) {
  31704. let {
  31705. clientId,
  31706. tagName: TagName = 'div',
  31707. wrapperProps,
  31708. className
  31709. } = _ref;
  31710. const baseClassName = 'block-editor-block-content-overlay';
  31711. const [isOverlayActive, setIsOverlayActive] = (0,external_wp_element_namespaceObject.useState)(true);
  31712. const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false);
  31713. const {
  31714. isParentSelected,
  31715. hasChildSelected,
  31716. isDraggingBlocks,
  31717. isParentHighlighted
  31718. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  31719. const {
  31720. isBlockSelected,
  31721. hasSelectedInnerBlock,
  31722. isDraggingBlocks: _isDraggingBlocks,
  31723. isBlockHighlighted
  31724. } = select(store);
  31725. return {
  31726. isParentSelected: isBlockSelected(clientId),
  31727. hasChildSelected: hasSelectedInnerBlock(clientId, true),
  31728. isDraggingBlocks: _isDraggingBlocks(),
  31729. isParentHighlighted: isBlockHighlighted(clientId)
  31730. };
  31731. }, [clientId]);
  31732. const classes = classnames_default()(baseClassName, wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.className, className, {
  31733. 'overlay-active': isOverlayActive,
  31734. 'parent-highlighted': isParentHighlighted,
  31735. 'is-dragging-blocks': isDraggingBlocks
  31736. });
  31737. (0,external_wp_element_namespaceObject.useEffect)(() => {
  31738. // Reenable when blocks are not in use.
  31739. if (!isParentSelected && !hasChildSelected && !isOverlayActive) {
  31740. setIsOverlayActive(true);
  31741. } // Disable if parent selected by another means (such as list view).
  31742. // We check hover to ensure the overlay click interaction is not taking place.
  31743. // Trying to click the overlay will select the parent block via its 'focusin'
  31744. // listener on the wrapper, so if the block is selected while hovered we will
  31745. // let the mouseup disable the overlay instead.
  31746. if (isParentSelected && !isHovered && isOverlayActive) {
  31747. setIsOverlayActive(false);
  31748. } // Ensure overlay is disabled if a child block is selected.
  31749. if (hasChildSelected && isOverlayActive) {
  31750. setIsOverlayActive(false);
  31751. }
  31752. }, [isParentSelected, hasChildSelected, isOverlayActive, isHovered]); // Disabled because the overlay div doesn't actually have a role or functionality
  31753. // as far as the a11y is concerned. We're just catching the first click so that
  31754. // the block can be selected without interacting with its contents.
  31755. /* eslint-disable jsx-a11y/no-static-element-interactions */
  31756. return (0,external_wp_element_namespaceObject.createElement)(TagName, _extends({}, wrapperProps, {
  31757. className: classes,
  31758. onMouseEnter: () => setIsHovered(true),
  31759. onMouseLeave: () => setIsHovered(false),
  31760. onMouseUp: isOverlayActive ? () => setIsOverlayActive(false) : undefined
  31761. }), wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.children);
  31762. }
  31763. /* eslint-enable jsx-a11y/no-static-element-interactions */
  31764. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-style-selector/index.js
  31765. /**
  31766. * WordPress dependencies
  31767. */
  31768. const ColorSelectorSVGIcon = () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  31769. xmlns: "https://www.w3.org/2000/svg",
  31770. viewBox: "0 0 20 20"
  31771. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  31772. 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"
  31773. }));
  31774. /**
  31775. * Color Selector Icon component.
  31776. *
  31777. * @param {Object} props Component properties.
  31778. * @param {Object} props.style Style object.
  31779. * @param {string} props.className Class name for component.
  31780. *
  31781. * @return {*} React Icon component.
  31782. */
  31783. const ColorSelectorIcon = _ref => {
  31784. let {
  31785. style,
  31786. className
  31787. } = _ref;
  31788. return (0,external_wp_element_namespaceObject.createElement)("div", {
  31789. className: "block-library-colors-selector__icon-container"
  31790. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  31791. className: `${className} block-library-colors-selector__state-selection`,
  31792. style: style
  31793. }, (0,external_wp_element_namespaceObject.createElement)(ColorSelectorSVGIcon, null)));
  31794. };
  31795. /**
  31796. * Renders the Colors Selector Toolbar with the icon button.
  31797. *
  31798. * @param {Object} props Component properties.
  31799. * @param {Object} props.TextColor Text color component that wraps icon.
  31800. * @param {Object} props.BackgroundColor Background color component that wraps icon.
  31801. *
  31802. * @return {*} React toggle button component.
  31803. */
  31804. const renderToggleComponent = _ref2 => {
  31805. let {
  31806. TextColor,
  31807. BackgroundColor
  31808. } = _ref2;
  31809. return _ref3 => {
  31810. let {
  31811. onToggle,
  31812. isOpen
  31813. } = _ref3;
  31814. const openOnArrowDown = event => {
  31815. if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
  31816. event.preventDefault();
  31817. onToggle();
  31818. }
  31819. };
  31820. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  31821. className: "components-toolbar__control block-library-colors-selector__toggle",
  31822. label: (0,external_wp_i18n_namespaceObject.__)('Open Colors Selector'),
  31823. onClick: onToggle,
  31824. onKeyDown: openOnArrowDown,
  31825. 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)))
  31826. }));
  31827. };
  31828. };
  31829. const BlockColorsStyleSelector = _ref4 => {
  31830. let {
  31831. children,
  31832. ...other
  31833. } = _ref4;
  31834. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  31835. position: "bottom right",
  31836. className: "block-library-colors-selector",
  31837. contentClassName: "block-library-colors-selector__popover",
  31838. renderToggle: renderToggleComponent(other),
  31839. renderContent: () => children
  31840. });
  31841. };
  31842. /* harmony default export */ var color_style_selector = (BlockColorsStyleSelector);
  31843. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/list-view.js
  31844. /**
  31845. * WordPress dependencies
  31846. */
  31847. const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  31848. viewBox: "0 0 24 24",
  31849. xmlns: "http://www.w3.org/2000/svg"
  31850. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  31851. d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
  31852. }));
  31853. /* harmony default export */ var list_view = (listView);
  31854. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/leaf.js
  31855. /**
  31856. * External dependencies
  31857. */
  31858. /**
  31859. * WordPress dependencies
  31860. */
  31861. /**
  31862. * Internal dependencies
  31863. */
  31864. const AnimatedTreeGridRow = animated(external_wp_components_namespaceObject.__experimentalTreeGridRow);
  31865. function ListViewLeaf(_ref) {
  31866. let {
  31867. isSelected,
  31868. position,
  31869. level,
  31870. rowCount,
  31871. children,
  31872. className,
  31873. path,
  31874. ...props
  31875. } = _ref;
  31876. const ref = use_moving_animation({
  31877. isSelected,
  31878. adjustScrolling: false,
  31879. enableAnimation: true,
  31880. triggerAnimationOnChange: path
  31881. });
  31882. return (0,external_wp_element_namespaceObject.createElement)(AnimatedTreeGridRow, _extends({
  31883. ref: ref,
  31884. className: classnames_default()('block-editor-list-view-leaf', className),
  31885. level: level,
  31886. positionInSet: position,
  31887. setSize: rowCount
  31888. }, props), children);
  31889. }
  31890. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/expander.js
  31891. /**
  31892. * WordPress dependencies
  31893. */
  31894. function ListViewExpander(_ref) {
  31895. let {
  31896. onClick
  31897. } = _ref;
  31898. return (// Keyboard events are handled by TreeGrid see: components/src/tree-grid/index.js
  31899. //
  31900. // The expander component is implemented as a pseudo element in the w3 example
  31901. // https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html
  31902. //
  31903. // We've mimicked this by adding an icon with aria-hidden set to true to hide this from the accessibility tree.
  31904. // For the current tree grid implementation, please do not try to make this a button.
  31905. //
  31906. // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
  31907. (0,external_wp_element_namespaceObject.createElement)("span", {
  31908. className: "block-editor-list-view__expander",
  31909. onClick: event => onClick(event, {
  31910. forceToggle: true
  31911. }),
  31912. "aria-hidden": "true"
  31913. }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  31914. icon: chevron_right_small
  31915. }))
  31916. );
  31917. }
  31918. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/block-select-button.js
  31919. /**
  31920. * External dependencies
  31921. */
  31922. /**
  31923. * WordPress dependencies
  31924. */
  31925. /**
  31926. * Internal dependencies
  31927. */
  31928. function ListViewBlockSelectButton(_ref, ref) {
  31929. let {
  31930. className,
  31931. block: {
  31932. clientId
  31933. },
  31934. onClick,
  31935. onToggleExpanded,
  31936. tabIndex,
  31937. onFocus,
  31938. onDragStart,
  31939. onDragEnd,
  31940. draggable
  31941. } = _ref;
  31942. const blockInformation = useBlockDisplayInformation(clientId);
  31943. const {
  31944. isLocked
  31945. } = useBlockLock(clientId); // The `href` attribute triggers the browser's native HTML drag operations.
  31946. // When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
  31947. // We need to clear any HTML drag data to prevent `pasteHandler` from firing
  31948. // inside the `useOnBlockDrop` hook.
  31949. const onDragStartHandler = event => {
  31950. event.dataTransfer.clearData();
  31951. onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(event);
  31952. };
  31953. function onKeyDownHandler(event) {
  31954. if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER || event.keyCode === external_wp_keycodes_namespaceObject.SPACE) {
  31955. onClick(event);
  31956. }
  31957. }
  31958. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  31959. className: classnames_default()('block-editor-list-view-block-select-button', className),
  31960. onClick: onClick,
  31961. onKeyDown: onKeyDownHandler,
  31962. ref: ref,
  31963. tabIndex: tabIndex,
  31964. onFocus: onFocus,
  31965. onDragStart: onDragStartHandler,
  31966. onDragEnd: onDragEnd,
  31967. draggable: draggable,
  31968. href: `#block-${clientId}`,
  31969. "aria-hidden": true
  31970. }, (0,external_wp_element_namespaceObject.createElement)(ListViewExpander, {
  31971. onClick: onToggleExpanded
  31972. }), (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  31973. icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
  31974. showColors: true
  31975. }), (0,external_wp_element_namespaceObject.createElement)("span", {
  31976. className: "block-editor-list-view-block-select-button__title"
  31977. }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
  31978. clientId: clientId,
  31979. maximumLength: 35
  31980. })), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && (0,external_wp_element_namespaceObject.createElement)("span", {
  31981. className: "block-editor-list-view-block-select-button__anchor"
  31982. }, blockInformation.anchor), isLocked && (0,external_wp_element_namespaceObject.createElement)("span", {
  31983. className: "block-editor-list-view-block-select-button__lock"
  31984. }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  31985. icon: library_lock
  31986. }))));
  31987. }
  31988. /* harmony default export */ var block_select_button = ((0,external_wp_element_namespaceObject.forwardRef)(ListViewBlockSelectButton));
  31989. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/block-contents.js
  31990. /**
  31991. * External dependencies
  31992. */
  31993. /**
  31994. * WordPress dependencies
  31995. */
  31996. /**
  31997. * Internal dependencies
  31998. */
  31999. const ListViewBlockContents = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => {
  32000. let {
  32001. onClick,
  32002. onToggleExpanded,
  32003. block,
  32004. isSelected,
  32005. position,
  32006. siblingBlockCount,
  32007. level,
  32008. isExpanded,
  32009. selectedClientIds,
  32010. ...props
  32011. } = _ref;
  32012. const {
  32013. clientId
  32014. } = block;
  32015. const {
  32016. blockMovingClientId,
  32017. selectedBlockInBlockEditor
  32018. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  32019. const {
  32020. hasBlockMovingClientId,
  32021. getSelectedBlockClientId
  32022. } = select(store);
  32023. return {
  32024. blockMovingClientId: hasBlockMovingClientId(),
  32025. selectedBlockInBlockEditor: getSelectedBlockClientId()
  32026. };
  32027. }, [clientId]);
  32028. const isBlockMoveTarget = blockMovingClientId && selectedBlockInBlockEditor === clientId;
  32029. const className = classnames_default()('block-editor-list-view-block-contents', {
  32030. 'is-dropping-before': isBlockMoveTarget
  32031. }); // Only include all selected blocks if the currently clicked on block
  32032. // is one of the selected blocks. This ensures that if a user attempts
  32033. // to drag a block that isn't part of the selection, they're still able
  32034. // to drag it and rearrange its position.
  32035. const draggableClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
  32036. return (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
  32037. clientIds: draggableClientIds
  32038. }, _ref2 => {
  32039. let {
  32040. draggable,
  32041. onDragStart,
  32042. onDragEnd
  32043. } = _ref2;
  32044. return (0,external_wp_element_namespaceObject.createElement)(block_select_button, _extends({
  32045. ref: ref,
  32046. className: className,
  32047. block: block,
  32048. onClick: onClick,
  32049. onToggleExpanded: onToggleExpanded,
  32050. isSelected: isSelected,
  32051. position: position,
  32052. siblingBlockCount: siblingBlockCount,
  32053. level: level,
  32054. draggable: draggable,
  32055. onDragStart: onDragStart,
  32056. onDragEnd: onDragEnd,
  32057. isExpanded: isExpanded
  32058. }, props));
  32059. });
  32060. });
  32061. /* harmony default export */ var block_contents = (ListViewBlockContents);
  32062. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/context.js
  32063. /**
  32064. * WordPress dependencies
  32065. */
  32066. const ListViewContext = (0,external_wp_element_namespaceObject.createContext)({
  32067. __experimentalFeatures: false,
  32068. __experimentalPersistentListViewFeatures: false
  32069. });
  32070. const useListViewContext = () => (0,external_wp_element_namespaceObject.useContext)(ListViewContext);
  32071. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/utils.js
  32072. /**
  32073. * External dependencies
  32074. */
  32075. /**
  32076. * WordPress dependencies
  32077. */
  32078. const getBlockPositionDescription = (position, siblingCount, level) => (0,external_wp_i18n_namespaceObject.sprintf)(
  32079. /* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */
  32080. (0,external_wp_i18n_namespaceObject.__)('Block %1$d of %2$d, Level %3$d'), position, siblingCount, level);
  32081. /**
  32082. * Returns true if the client ID occurs within the block selection or multi-selection,
  32083. * or false otherwise.
  32084. *
  32085. * @param {string} clientId Block client ID.
  32086. * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.
  32087. *
  32088. * @return {boolean} Whether the block is in multi-selection set.
  32089. */
  32090. const isClientIdSelected = (clientId, selectedBlockClientIds) => (0,external_lodash_namespaceObject.isArray)(selectedBlockClientIds) && selectedBlockClientIds.length ? selectedBlockClientIds.indexOf(clientId) !== -1 : selectedBlockClientIds === clientId;
  32091. /**
  32092. * From a start and end clientId of potentially different nesting levels,
  32093. * return the nearest-depth ids that have a common level of depth in the
  32094. * nesting hierarchy. For multiple block selection, this ensure that the
  32095. * selection is always at the same nesting level, and not split across
  32096. * separate levels.
  32097. *
  32098. * @param {string} startId The first id of a selection.
  32099. * @param {string} endId The end id of a selection, usually one that has been clicked on.
  32100. * @param {string[]} startParents An array of ancestor ids for the start id, in descending order.
  32101. * @param {string[]} endParents An array of ancestor ids for the end id, in descending order.
  32102. * @return {Object} An object containing the start and end ids.
  32103. */
  32104. function getCommonDepthClientIds(startId, endId, startParents, endParents) {
  32105. const startPath = [...startParents, startId];
  32106. const endPath = [...endParents, endId];
  32107. const depth = Math.min(startPath.length, endPath.length) - 1;
  32108. const start = startPath[depth];
  32109. const end = endPath[depth];
  32110. return {
  32111. start,
  32112. end
  32113. };
  32114. }
  32115. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/block.js
  32116. /**
  32117. * External dependencies
  32118. */
  32119. /**
  32120. * WordPress dependencies
  32121. */
  32122. /**
  32123. * Internal dependencies
  32124. */
  32125. function ListViewBlock(_ref) {
  32126. let {
  32127. block,
  32128. isDragged,
  32129. isSelected,
  32130. isBranchSelected,
  32131. selectBlock,
  32132. position,
  32133. level,
  32134. rowCount,
  32135. siblingBlockCount,
  32136. showBlockMovers,
  32137. path,
  32138. isExpanded,
  32139. selectedClientIds,
  32140. preventAnnouncement
  32141. } = _ref;
  32142. const cellRef = (0,external_wp_element_namespaceObject.useRef)(null);
  32143. const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false);
  32144. const {
  32145. clientId
  32146. } = block;
  32147. const isFirstSelectedBlock = isSelected && selectedClientIds[0] === clientId;
  32148. const isLastSelectedBlock = isSelected && selectedClientIds[selectedClientIds.length - 1] === clientId;
  32149. const {
  32150. toggleBlockHighlight
  32151. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  32152. const blockInformation = useBlockDisplayInformation(clientId);
  32153. const {
  32154. isLocked
  32155. } = useBlockLock(clientId);
  32156. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewBlock);
  32157. const descriptionId = `list-view-block-select-button__${instanceId}`;
  32158. const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
  32159. let blockAriaLabel = (0,external_wp_i18n_namespaceObject.__)('Link');
  32160. if (blockInformation) {
  32161. 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.
  32162. (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.
  32163. (0,external_wp_i18n_namespaceObject.__)('%s link'), blockInformation.title);
  32164. }
  32165. const settingsAriaLabel = blockInformation ? (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: The title of the block.
  32166. (0,external_wp_i18n_namespaceObject.__)('Options for %s block'), blockInformation.title) : (0,external_wp_i18n_namespaceObject.__)('Options');
  32167. const {
  32168. __experimentalFeatures: withExperimentalFeatures,
  32169. __experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,
  32170. __experimentalHideContainerBlockActions: hideContainerBlockActions,
  32171. isTreeGridMounted,
  32172. expand,
  32173. collapse
  32174. } = useListViewContext();
  32175. const hasSiblings = siblingBlockCount > 0;
  32176. const hasRenderedMovers = showBlockMovers && hasSiblings;
  32177. const moverCellClassName = classnames_default()('block-editor-list-view-block__mover-cell', {
  32178. 'is-visible': isHovered || isSelected
  32179. });
  32180. const listViewBlockSettingsClassName = classnames_default()('block-editor-list-view-block__menu-cell', {
  32181. 'is-visible': isHovered || isFirstSelectedBlock
  32182. }); // If ListView has experimental features related to the Persistent List View,
  32183. // only focus the selected list item on mount; otherwise the list would always
  32184. // try to steal the focus from the editor canvas.
  32185. (0,external_wp_element_namespaceObject.useEffect)(() => {
  32186. if (withExperimentalPersistentListViewFeatures && !isTreeGridMounted && isSelected) {
  32187. cellRef.current.focus();
  32188. }
  32189. }, []);
  32190. const highlightBlock = withExperimentalPersistentListViewFeatures ? toggleBlockHighlight : () => {};
  32191. const onMouseEnter = (0,external_wp_element_namespaceObject.useCallback)(() => {
  32192. setIsHovered(true);
  32193. highlightBlock(clientId, true);
  32194. }, [clientId, setIsHovered, highlightBlock]);
  32195. const onMouseLeave = (0,external_wp_element_namespaceObject.useCallback)(() => {
  32196. setIsHovered(false);
  32197. highlightBlock(clientId, false);
  32198. }, [clientId, setIsHovered, highlightBlock]);
  32199. const selectEditorBlock = (0,external_wp_element_namespaceObject.useCallback)(event => {
  32200. selectBlock(event, clientId);
  32201. event.preventDefault();
  32202. }, [clientId, selectBlock]);
  32203. const updateSelection = (0,external_wp_element_namespaceObject.useCallback)(newClientId => {
  32204. selectBlock(undefined, newClientId);
  32205. }, [selectBlock]);
  32206. const toggleExpanded = (0,external_wp_element_namespaceObject.useCallback)(event => {
  32207. // Prevent shift+click from opening link in a new window when toggling.
  32208. event.preventDefault();
  32209. event.stopPropagation();
  32210. if (isExpanded === true) {
  32211. collapse(clientId);
  32212. } else if (isExpanded === false) {
  32213. expand(clientId);
  32214. }
  32215. }, [clientId, expand, collapse, isExpanded]);
  32216. const showBlockActions = withExperimentalFeatures && ( // hide actions for blocks like core/widget-areas
  32217. !hideContainerBlockActions || hideContainerBlockActions && level > 1);
  32218. const hideBlockActions = withExperimentalFeatures && !showBlockActions;
  32219. let colSpan;
  32220. if (hasRenderedMovers) {
  32221. colSpan = 2;
  32222. } else if (hideBlockActions) {
  32223. colSpan = 3;
  32224. }
  32225. const classes = classnames_default()({
  32226. 'is-selected': isSelected,
  32227. 'is-first-selected': isFirstSelectedBlock,
  32228. 'is-last-selected': isLastSelectedBlock,
  32229. 'is-branch-selected': withExperimentalPersistentListViewFeatures && isBranchSelected,
  32230. 'is-dragging': isDragged,
  32231. 'has-single-cell': hideBlockActions
  32232. }); // Only include all selected blocks if the currently clicked on block
  32233. // is one of the selected blocks. This ensures that if a user attempts
  32234. // to alter a block that isn't part of the selection, they're still able
  32235. // to do so.
  32236. const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
  32237. return (0,external_wp_element_namespaceObject.createElement)(ListViewLeaf, {
  32238. className: classes,
  32239. onMouseEnter: onMouseEnter,
  32240. onMouseLeave: onMouseLeave,
  32241. onFocus: onMouseEnter,
  32242. onBlur: onMouseLeave,
  32243. level: level,
  32244. position: position,
  32245. rowCount: rowCount,
  32246. path: path,
  32247. id: `list-view-block-${clientId}`,
  32248. "data-block": clientId,
  32249. isExpanded: isExpanded,
  32250. "aria-selected": !!isSelected
  32251. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
  32252. className: "block-editor-list-view-block__contents-cell",
  32253. colSpan: colSpan,
  32254. ref: cellRef,
  32255. "aria-label": blockAriaLabel,
  32256. "aria-selected": !!isSelected,
  32257. "aria-expanded": isExpanded,
  32258. "aria-describedby": descriptionId
  32259. }, _ref2 => {
  32260. let {
  32261. ref,
  32262. tabIndex,
  32263. onFocus
  32264. } = _ref2;
  32265. return (0,external_wp_element_namespaceObject.createElement)("div", {
  32266. className: "block-editor-list-view-block__contents-container"
  32267. }, (0,external_wp_element_namespaceObject.createElement)(block_contents, {
  32268. block: block,
  32269. onClick: selectEditorBlock,
  32270. onToggleExpanded: toggleExpanded,
  32271. isSelected: isSelected,
  32272. position: position,
  32273. siblingBlockCount: siblingBlockCount,
  32274. level: level,
  32275. ref: ref,
  32276. tabIndex: tabIndex,
  32277. onFocus: onFocus,
  32278. isExpanded: isExpanded,
  32279. selectedClientIds: selectedClientIds,
  32280. preventAnnouncement: preventAnnouncement
  32281. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  32282. className: "block-editor-list-view-block-select-button__description",
  32283. id: descriptionId
  32284. }, blockPositionDescription));
  32285. }), hasRenderedMovers && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
  32286. className: moverCellClassName,
  32287. withoutGridItem: true
  32288. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridItem, null, _ref3 => {
  32289. let {
  32290. ref,
  32291. tabIndex,
  32292. onFocus
  32293. } = _ref3;
  32294. return (0,external_wp_element_namespaceObject.createElement)(BlockMoverUpButton, {
  32295. orientation: "vertical",
  32296. clientIds: [clientId],
  32297. ref: ref,
  32298. tabIndex: tabIndex,
  32299. onFocus: onFocus
  32300. });
  32301. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridItem, null, _ref4 => {
  32302. let {
  32303. ref,
  32304. tabIndex,
  32305. onFocus
  32306. } = _ref4;
  32307. return (0,external_wp_element_namespaceObject.createElement)(BlockMoverDownButton, {
  32308. orientation: "vertical",
  32309. clientIds: [clientId],
  32310. ref: ref,
  32311. tabIndex: tabIndex,
  32312. onFocus: onFocus
  32313. });
  32314. }))), showBlockActions && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
  32315. className: listViewBlockSettingsClassName,
  32316. "aria-selected": !!isSelected
  32317. }, _ref5 => {
  32318. let {
  32319. ref,
  32320. tabIndex,
  32321. onFocus
  32322. } = _ref5;
  32323. return (0,external_wp_element_namespaceObject.createElement)(block_settings_dropdown, {
  32324. clientIds: dropdownClientIds,
  32325. icon: more_vertical,
  32326. label: settingsAriaLabel,
  32327. toggleProps: {
  32328. ref,
  32329. className: 'block-editor-list-view-block__menu',
  32330. tabIndex,
  32331. onFocus
  32332. },
  32333. disableOpenOnArrowDown: true,
  32334. __experimentalSelectBlock: updateSelection
  32335. });
  32336. }));
  32337. }
  32338. /* harmony default export */ var list_view_block = ((0,external_wp_element_namespaceObject.memo)(ListViewBlock));
  32339. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/branch.js
  32340. /**
  32341. * External dependencies
  32342. */
  32343. /**
  32344. * WordPress dependencies
  32345. */
  32346. /**
  32347. * Internal dependencies
  32348. */
  32349. /**
  32350. * Given a block, returns the total number of blocks in that subtree. This is used to help determine
  32351. * the list position of a block.
  32352. *
  32353. * When a block is collapsed, we do not count their children as part of that total. In the current drag
  32354. * implementation dragged blocks and their children are not counted.
  32355. *
  32356. * @param {Object} block block tree
  32357. * @param {Object} expandedState state that notes which branches are collapsed
  32358. * @param {Array} draggedClientIds a list of dragged client ids
  32359. * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.
  32360. * @return {number} block count
  32361. */
  32362. function countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault) {
  32363. var _expandedState$block$;
  32364. const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
  32365. if (isDragged) {
  32366. return 0;
  32367. }
  32368. const isExpanded = (_expandedState$block$ = expandedState[block.clientId]) !== null && _expandedState$block$ !== void 0 ? _expandedState$block$ : isExpandedByDefault;
  32369. if (isExpanded) {
  32370. return 1 + block.innerBlocks.reduce(countReducer(expandedState, draggedClientIds, isExpandedByDefault), 0);
  32371. }
  32372. return 1;
  32373. }
  32374. const countReducer = (expandedState, draggedClientIds, isExpandedByDefault) => (count, block) => {
  32375. var _expandedState$block$2;
  32376. const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
  32377. if (isDragged) {
  32378. return count;
  32379. }
  32380. const isExpanded = (_expandedState$block$2 = expandedState[block.clientId]) !== null && _expandedState$block$2 !== void 0 ? _expandedState$block$2 : isExpandedByDefault;
  32381. if (isExpanded && block.innerBlocks.length > 0) {
  32382. return count + countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault);
  32383. }
  32384. return count + 1;
  32385. };
  32386. function ListViewBranch(props) {
  32387. const {
  32388. blocks,
  32389. selectBlock,
  32390. showBlockMovers,
  32391. showNestedBlocks,
  32392. selectedClientIds,
  32393. level = 1,
  32394. path = '',
  32395. isBranchSelected = false,
  32396. listPosition = 0,
  32397. fixedListWindow,
  32398. expandNested
  32399. } = props;
  32400. const {
  32401. expandedState,
  32402. draggedClientIds,
  32403. __experimentalPersistentListViewFeatures
  32404. } = useListViewContext();
  32405. const filteredBlocks = (0,external_lodash_namespaceObject.compact)(blocks);
  32406. const blockCount = filteredBlocks.length;
  32407. let nextPosition = listPosition;
  32408. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, filteredBlocks.map((block, index) => {
  32409. var _expandedState$client;
  32410. const {
  32411. clientId,
  32412. innerBlocks
  32413. } = block;
  32414. if (index > 0) {
  32415. nextPosition += countBlocks(filteredBlocks[index - 1], expandedState, draggedClientIds, expandNested);
  32416. }
  32417. const usesWindowing = __experimentalPersistentListViewFeatures;
  32418. const {
  32419. itemInView
  32420. } = fixedListWindow;
  32421. const blockInView = !usesWindowing || itemInView(nextPosition);
  32422. const position = index + 1;
  32423. const updatedPath = path.length > 0 ? `${path}_${position}` : `${position}`;
  32424. const hasNestedBlocks = showNestedBlocks && !!innerBlocks && !!innerBlocks.length;
  32425. const isExpanded = hasNestedBlocks ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : expandNested : undefined;
  32426. const isDragged = !!(draggedClientIds !== null && draggedClientIds !== void 0 && draggedClientIds.includes(clientId));
  32427. const showBlock = isDragged || blockInView; // Make updates to the selected or dragged blocks synchronous,
  32428. // but asynchronous for any other block.
  32429. const isSelected = isClientIdSelected(clientId, selectedClientIds);
  32430. const isSelectedBranch = isBranchSelected || isSelected && hasNestedBlocks;
  32431. return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
  32432. key: clientId,
  32433. value: !isSelected
  32434. }, showBlock && (0,external_wp_element_namespaceObject.createElement)(list_view_block, {
  32435. block: block,
  32436. selectBlock: selectBlock,
  32437. isSelected: isSelected,
  32438. isBranchSelected: isSelectedBranch,
  32439. isDragged: isDragged,
  32440. level: level,
  32441. position: position,
  32442. rowCount: blockCount,
  32443. siblingBlockCount: blockCount,
  32444. showBlockMovers: showBlockMovers,
  32445. path: updatedPath,
  32446. isExpanded: isExpanded,
  32447. listPosition: nextPosition,
  32448. selectedClientIds: selectedClientIds
  32449. }), !showBlock && (0,external_wp_element_namespaceObject.createElement)("tr", null, (0,external_wp_element_namespaceObject.createElement)("td", {
  32450. className: "block-editor-list-view-placeholder"
  32451. })), hasNestedBlocks && isExpanded && !isDragged && (0,external_wp_element_namespaceObject.createElement)(ListViewBranch, {
  32452. blocks: innerBlocks,
  32453. selectBlock: selectBlock,
  32454. showBlockMovers: showBlockMovers,
  32455. showNestedBlocks: showNestedBlocks,
  32456. level: level + 1,
  32457. path: updatedPath,
  32458. listPosition: nextPosition + 1,
  32459. fixedListWindow: fixedListWindow,
  32460. isBranchSelected: isSelectedBranch,
  32461. selectedClientIds: selectedClientIds,
  32462. expandNested: expandNested
  32463. }));
  32464. }));
  32465. }
  32466. ListViewBranch.defaultProps = {
  32467. selectBlock: () => {}
  32468. };
  32469. /* harmony default export */ var branch = ((0,external_wp_element_namespaceObject.memo)(ListViewBranch));
  32470. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/drop-indicator.js
  32471. /**
  32472. * WordPress dependencies
  32473. */
  32474. function ListViewDropIndicator(_ref) {
  32475. let {
  32476. listViewRef,
  32477. blockDropTarget
  32478. } = _ref;
  32479. const {
  32480. rootClientId,
  32481. clientId,
  32482. dropPosition
  32483. } = blockDropTarget || {};
  32484. const [rootBlockElement, blockElement] = (0,external_wp_element_namespaceObject.useMemo)(() => {
  32485. if (!listViewRef.current) {
  32486. return [];
  32487. } // The rootClientId will be defined whenever dropping into inner
  32488. // block lists, but is undefined when dropping at the root level.
  32489. const _rootBlockElement = rootClientId ? listViewRef.current.querySelector(`[data-block="${rootClientId}"]`) : undefined; // The clientId represents the sibling block, the dragged block will
  32490. // usually be inserted adjacent to it. It will be undefined when
  32491. // dropping a block into an empty block list.
  32492. const _blockElement = clientId ? listViewRef.current.querySelector(`[data-block="${clientId}"]`) : undefined;
  32493. return [_rootBlockElement, _blockElement];
  32494. }, [rootClientId, clientId]); // The targetElement is the element that the drop indicator will appear
  32495. // before or after. When dropping into an empty block list, blockElement
  32496. // is undefined, so the indicator will appear after the rootBlockElement.
  32497. const targetElement = blockElement || rootBlockElement;
  32498. const getDropIndicatorIndent = (0,external_wp_element_namespaceObject.useCallback)(() => {
  32499. if (!rootBlockElement) {
  32500. return 0;
  32501. } // Calculate the indent using the block icon of the root block.
  32502. // Using a classname selector here might be flaky and could be
  32503. // improved.
  32504. const targetElementRect = targetElement.getBoundingClientRect();
  32505. const rootBlockIconElement = rootBlockElement.querySelector('.block-editor-block-icon');
  32506. const rootBlockIconRect = rootBlockIconElement.getBoundingClientRect();
  32507. return rootBlockIconRect.right - targetElementRect.left;
  32508. }, [rootBlockElement, targetElement]);
  32509. const style = (0,external_wp_element_namespaceObject.useMemo)(() => {
  32510. if (!targetElement) {
  32511. return {};
  32512. }
  32513. const indent = getDropIndicatorIndent();
  32514. return {
  32515. width: targetElement.offsetWidth - indent
  32516. };
  32517. }, [getDropIndicatorIndent, targetElement]);
  32518. const getAnchorRect = (0,external_wp_element_namespaceObject.useCallback)(() => {
  32519. if (!targetElement) {
  32520. return {};
  32521. }
  32522. const ownerDocument = targetElement.ownerDocument;
  32523. const rect = targetElement.getBoundingClientRect();
  32524. const indent = getDropIndicatorIndent();
  32525. const anchorRect = {
  32526. left: rect.left + indent,
  32527. right: rect.right,
  32528. width: 0,
  32529. height: rect.height,
  32530. ownerDocument
  32531. };
  32532. if (dropPosition === 'top') {
  32533. return { ...anchorRect,
  32534. top: rect.top,
  32535. bottom: rect.top
  32536. };
  32537. }
  32538. if (dropPosition === 'bottom' || dropPosition === 'inside') {
  32539. return { ...anchorRect,
  32540. top: rect.bottom,
  32541. bottom: rect.bottom
  32542. };
  32543. }
  32544. return {};
  32545. }, [targetElement, dropPosition, getDropIndicatorIndent]);
  32546. if (!targetElement) {
  32547. return null;
  32548. }
  32549. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  32550. noArrow: true,
  32551. animate: false,
  32552. getAnchorRect: getAnchorRect,
  32553. focusOnMount: false,
  32554. className: "block-editor-list-view-drop-indicator"
  32555. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  32556. style: style,
  32557. className: "block-editor-list-view-drop-indicator__line"
  32558. }));
  32559. }
  32560. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-block-selection.js
  32561. /**
  32562. * External dependencies
  32563. */
  32564. /**
  32565. * WordPress dependencies
  32566. */
  32567. /**
  32568. * Internal dependencies
  32569. */
  32570. function useBlockSelection() {
  32571. const {
  32572. clearSelectedBlock,
  32573. multiSelect,
  32574. selectBlock
  32575. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  32576. const {
  32577. getBlockName,
  32578. getBlockParents,
  32579. getBlockSelectionStart,
  32580. getBlockSelectionEnd,
  32581. getSelectedBlockClientIds,
  32582. hasMultiSelection,
  32583. hasSelectedBlock
  32584. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  32585. const {
  32586. getBlockType
  32587. } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
  32588. const updateBlockSelection = (0,external_wp_element_namespaceObject.useCallback)(async (event, clientId, destinationClientId) => {
  32589. if (!(event !== null && event !== void 0 && event.shiftKey)) {
  32590. await clearSelectedBlock();
  32591. selectBlock(clientId);
  32592. return;
  32593. } // To handle multiple block selection via the `SHIFT` key, prevent
  32594. // the browser default behavior of opening the link in a new window.
  32595. event.preventDefault();
  32596. 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.
  32597. if (!isKeyPress && !hasSelectedBlock() && !hasMultiSelection()) {
  32598. selectBlock(clientId, null);
  32599. return;
  32600. }
  32601. const selectedBlocks = getSelectedBlockClientIds();
  32602. const clientIdWithParents = [...getBlockParents(clientId), clientId];
  32603. if (isKeyPress && !selectedBlocks.some(blockId => clientIdWithParents.includes(blockId))) {
  32604. // Ensure that shift-selecting blocks via the keyboard only
  32605. // expands the current selection if focusing over already
  32606. // selected blocks. Otherwise, clear the selection so that
  32607. // a user can create a new selection entirely by keyboard.
  32608. await clearSelectedBlock();
  32609. }
  32610. let startTarget = getBlockSelectionStart();
  32611. let endTarget = clientId; // Handle keyboard behavior for selecting multiple blocks.
  32612. if (isKeyPress) {
  32613. if (!hasSelectedBlock() && !hasMultiSelection()) {
  32614. // Set the starting point of the selection to the currently
  32615. // focused block, if there are no blocks currently selected.
  32616. // This ensures that as the selection is expanded or contracted,
  32617. // the starting point of the selection is anchored to that block.
  32618. startTarget = clientId;
  32619. }
  32620. if (destinationClientId) {
  32621. // If the user presses UP or DOWN, we want to ensure that the block they're
  32622. // moving to is the target for selection, and not the currently focused one.
  32623. endTarget = destinationClientId;
  32624. }
  32625. }
  32626. const startParents = getBlockParents(startTarget);
  32627. const endParents = getBlockParents(endTarget);
  32628. const {
  32629. start,
  32630. end
  32631. } = getCommonDepthClientIds(startTarget, endTarget, startParents, endParents);
  32632. await multiSelect(start, end, null); // Announce deselected block, or number of deselected blocks if
  32633. // the total number of blocks deselected is greater than one.
  32634. const updatedSelectedBlocks = getSelectedBlockClientIds(); // If the selection is greater than 1 and the Home or End keys
  32635. // were used to generate the selection, then skip announcing the
  32636. // deselected blocks.
  32637. if ((event.keyCode === external_wp_keycodes_namespaceObject.HOME || event.keyCode === external_wp_keycodes_namespaceObject.END) && updatedSelectedBlocks.length > 1) {
  32638. return;
  32639. }
  32640. const selectionDiff = (0,external_lodash_namespaceObject.difference)(selectedBlocks, updatedSelectedBlocks);
  32641. let label;
  32642. if (selectionDiff.length === 1) {
  32643. var _getBlockType;
  32644. const title = (_getBlockType = getBlockType(getBlockName(selectionDiff[0]))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
  32645. if (title) {
  32646. label = (0,external_wp_i18n_namespaceObject.sprintf)(
  32647. /* translators: %s: block name */
  32648. (0,external_wp_i18n_namespaceObject.__)('%s deselected.'), title);
  32649. }
  32650. } else if (selectionDiff.length > 1) {
  32651. label = (0,external_wp_i18n_namespaceObject.sprintf)(
  32652. /* translators: %s: number of deselected blocks */
  32653. (0,external_wp_i18n_namespaceObject.__)('%s blocks deselected.'), selectionDiff.length);
  32654. }
  32655. if (label) {
  32656. (0,external_wp_a11y_namespaceObject.speak)(label);
  32657. }
  32658. }, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart, getBlockSelectionEnd, getSelectedBlockClientIds, hasMultiSelection, hasSelectedBlock, multiSelect, selectBlock]);
  32659. return {
  32660. updateBlockSelection
  32661. };
  32662. }
  32663. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-client-ids.js
  32664. /**
  32665. * WordPress dependencies
  32666. */
  32667. /**
  32668. * Internal dependencies
  32669. */
  32670. function useListViewClientIds(blocks) {
  32671. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  32672. const {
  32673. getDraggedBlockClientIds,
  32674. getSelectedBlockClientIds,
  32675. __unstableGetClientIdsTree
  32676. } = select(store);
  32677. return {
  32678. selectedClientIds: getSelectedBlockClientIds(),
  32679. draggedClientIds: getDraggedBlockClientIds(),
  32680. clientIdsTree: blocks ? blocks : __unstableGetClientIdsTree()
  32681. };
  32682. }, [blocks]);
  32683. }
  32684. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-drop-zone.js
  32685. /**
  32686. * WordPress dependencies
  32687. */
  32688. /**
  32689. * Internal dependencies
  32690. */
  32691. /** @typedef {import('../../utils/math').WPPoint} WPPoint */
  32692. /**
  32693. * The type of a drag event.
  32694. *
  32695. * @typedef {'default'|'file'|'html'} WPDragEventType
  32696. */
  32697. /**
  32698. * An array representing data for blocks in the DOM used by drag and drop.
  32699. *
  32700. * @typedef {Object} WPListViewDropZoneBlocks
  32701. * @property {string} clientId The client id for the block.
  32702. * @property {string} rootClientId The root client id for the block.
  32703. * @property {number} blockIndex The block's index.
  32704. * @property {Element} element The DOM element representing the block.
  32705. * @property {number} innerBlockCount The number of inner blocks the block has.
  32706. * @property {boolean} isDraggedBlock Whether the block is currently being dragged.
  32707. * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.
  32708. * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.
  32709. */
  32710. /**
  32711. * An object containing details of a drop target.
  32712. *
  32713. * @typedef {Object} WPListViewDropZoneTarget
  32714. * @property {string} blockIndex The insertion index.
  32715. * @property {string} rootClientId The root client id for the block.
  32716. * @property {string|undefined} clientId The client id for the block.
  32717. * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.
  32718. * 'inside' refers to nesting as an inner block.
  32719. */
  32720. /**
  32721. * Is the point contained by the rectangle.
  32722. *
  32723. * @param {WPPoint} point The point.
  32724. * @param {DOMRect} rect The rectangle.
  32725. *
  32726. * @return {boolean} True if the point is contained by the rectangle, false otherwise.
  32727. */
  32728. function isPointContainedByRect(point, rect) {
  32729. return rect.left <= point.x && rect.right >= point.x && rect.top <= point.y && rect.bottom >= point.y;
  32730. }
  32731. /**
  32732. * Determines whether the user positioning the dragged block to nest as an
  32733. * inner block.
  32734. *
  32735. * Presently this is determined by whether the cursor is on the right hand side
  32736. * of the block.
  32737. *
  32738. * @param {WPPoint} point The point representing the cursor position when dragging.
  32739. * @param {DOMRect} rect The rectangle.
  32740. */
  32741. function isNestingGesture(point, rect) {
  32742. const blockCenterX = rect.left + rect.width / 2;
  32743. return point.x > blockCenterX;
  32744. } // Block navigation is always a vertical list, so only allow dropping
  32745. // to the above or below a block.
  32746. const ALLOWED_DROP_EDGES = ['top', 'bottom'];
  32747. /**
  32748. * Given blocks data and the cursor position, compute the drop target.
  32749. *
  32750. * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.
  32751. * @param {WPPoint} position The point representing the cursor position when dragging.
  32752. *
  32753. * @return {WPListViewDropZoneTarget} An object containing data about the drop target.
  32754. */
  32755. function getListViewDropTarget(blocksData, position) {
  32756. let candidateEdge;
  32757. let candidateBlockData;
  32758. let candidateDistance;
  32759. let candidateRect;
  32760. for (const blockData of blocksData) {
  32761. if (blockData.isDraggedBlock) {
  32762. continue;
  32763. }
  32764. const rect = blockData.element.getBoundingClientRect();
  32765. const [distance, edge] = getDistanceToNearestEdge(position, rect, ALLOWED_DROP_EDGES);
  32766. const isCursorWithinBlock = isPointContainedByRect(position, rect);
  32767. if (candidateDistance === undefined || distance < candidateDistance || isCursorWithinBlock) {
  32768. candidateDistance = distance;
  32769. const index = blocksData.indexOf(blockData);
  32770. const previousBlockData = blocksData[index - 1]; // If dragging near the top of a block and the preceding block
  32771. // is at the same level, use the preceding block as the candidate
  32772. // instead, as later it makes determining a nesting drop easier.
  32773. if (edge === 'top' && previousBlockData && previousBlockData.rootClientId === blockData.rootClientId && !previousBlockData.isDraggedBlock) {
  32774. candidateBlockData = previousBlockData;
  32775. candidateEdge = 'bottom';
  32776. candidateRect = previousBlockData.element.getBoundingClientRect();
  32777. } else {
  32778. candidateBlockData = blockData;
  32779. candidateEdge = edge;
  32780. candidateRect = rect;
  32781. } // If the mouse position is within the block, break early
  32782. // as the user would intend to drop either before or after
  32783. // this block.
  32784. //
  32785. // This solves an issue where some rows in the list view
  32786. // tree overlap slightly due to sub-pixel rendering.
  32787. if (isCursorWithinBlock) {
  32788. break;
  32789. }
  32790. }
  32791. }
  32792. if (!candidateBlockData) {
  32793. return;
  32794. }
  32795. const isDraggingBelow = candidateEdge === 'bottom'; // If the user is dragging towards the bottom of the block check whether
  32796. // they might be trying to nest the block as a child.
  32797. // If the block already has inner blocks, this should always be treated
  32798. // as nesting since the next block in the tree will be the first child.
  32799. if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 || isNestingGesture(position, candidateRect))) {
  32800. return {
  32801. rootClientId: candidateBlockData.clientId,
  32802. blockIndex: 0,
  32803. dropPosition: 'inside'
  32804. };
  32805. } // If dropping as a sibling, but block cannot be inserted in
  32806. // this context, return early.
  32807. if (!candidateBlockData.canInsertDraggedBlocksAsSibling) {
  32808. return;
  32809. }
  32810. const offset = isDraggingBelow ? 1 : 0;
  32811. return {
  32812. rootClientId: candidateBlockData.rootClientId,
  32813. clientId: candidateBlockData.clientId,
  32814. blockIndex: candidateBlockData.blockIndex + offset,
  32815. dropPosition: candidateEdge
  32816. };
  32817. }
  32818. /**
  32819. * A react hook for implementing a drop zone in list view.
  32820. *
  32821. * @return {WPListViewDropZoneTarget} The drop target.
  32822. */
  32823. function useListViewDropZone() {
  32824. const {
  32825. getBlockRootClientId,
  32826. getBlockIndex,
  32827. getBlockCount,
  32828. getDraggedBlockClientIds,
  32829. canInsertBlocks
  32830. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  32831. const [target, setTarget] = (0,external_wp_element_namespaceObject.useState)();
  32832. const {
  32833. rootClientId: targetRootClientId,
  32834. blockIndex: targetBlockIndex
  32835. } = target || {};
  32836. const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex);
  32837. const draggedBlockClientIds = getDraggedBlockClientIds();
  32838. const throttled = (0,external_wp_compose_namespaceObject.useThrottle)((0,external_wp_element_namespaceObject.useCallback)((event, currentTarget) => {
  32839. const position = {
  32840. x: event.clientX,
  32841. y: event.clientY
  32842. };
  32843. const isBlockDrag = !!(draggedBlockClientIds !== null && draggedBlockClientIds !== void 0 && draggedBlockClientIds.length);
  32844. const blockElements = Array.from(currentTarget.querySelectorAll('[data-block]'));
  32845. const blocksData = blockElements.map(blockElement => {
  32846. const clientId = blockElement.dataset.block;
  32847. const rootClientId = getBlockRootClientId(clientId);
  32848. return {
  32849. clientId,
  32850. rootClientId,
  32851. blockIndex: getBlockIndex(clientId),
  32852. element: blockElement,
  32853. isDraggedBlock: isBlockDrag ? draggedBlockClientIds.includes(clientId) : false,
  32854. innerBlockCount: getBlockCount(clientId),
  32855. canInsertDraggedBlocksAsSibling: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, rootClientId) : true,
  32856. canInsertDraggedBlocksAsChild: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, clientId) : true
  32857. };
  32858. });
  32859. const newTarget = getListViewDropTarget(blocksData, position);
  32860. if (newTarget) {
  32861. setTarget(newTarget);
  32862. }
  32863. }, [draggedBlockClientIds]), 200);
  32864. const ref = (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({
  32865. onDrop: onBlockDrop,
  32866. onDragOver(event) {
  32867. // `currentTarget` is only available while the event is being
  32868. // handled, so get it now and pass it to the thottled function.
  32869. // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
  32870. throttled(event, event.currentTarget);
  32871. },
  32872. onDragEnd() {
  32873. throttled.cancel();
  32874. setTarget(null);
  32875. }
  32876. });
  32877. return {
  32878. ref,
  32879. target
  32880. };
  32881. }
  32882. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-expand-selected-item.js
  32883. /**
  32884. * WordPress dependencies
  32885. */
  32886. /**
  32887. * Internal dependencies
  32888. */
  32889. function useListViewExpandSelectedItem(_ref) {
  32890. let {
  32891. firstSelectedBlockClientId,
  32892. setExpandedState
  32893. } = _ref;
  32894. const [selectedTreeId, setSelectedTreeId] = (0,external_wp_element_namespaceObject.useState)(null);
  32895. const {
  32896. selectedBlockParentClientIds
  32897. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  32898. const {
  32899. getBlockParents
  32900. } = select(store);
  32901. return {
  32902. selectedBlockParentClientIds: getBlockParents(firstSelectedBlockClientId, false)
  32903. };
  32904. }, [firstSelectedBlockClientId]);
  32905. const parentClientIds = Array.isArray(selectedBlockParentClientIds) && selectedBlockParentClientIds.length ? selectedBlockParentClientIds : null; // Expand tree when a block is selected.
  32906. (0,external_wp_element_namespaceObject.useEffect)(() => {
  32907. // If the selectedTreeId is the same as the selected block,
  32908. // it means that the block was selected using the block list tree.
  32909. if (selectedTreeId === firstSelectedBlockClientId) {
  32910. return;
  32911. } // If the selected block has parents, get the top-level parent.
  32912. if (parentClientIds) {
  32913. // If the selected block has parents,
  32914. // expand the tree branch.
  32915. setExpandedState({
  32916. type: 'expand',
  32917. clientIds: selectedBlockParentClientIds
  32918. });
  32919. }
  32920. }, [firstSelectedBlockClientId]);
  32921. return {
  32922. setSelectedTreeId
  32923. };
  32924. }
  32925. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/index.js
  32926. /**
  32927. * WordPress dependencies
  32928. */
  32929. /**
  32930. * Internal dependencies
  32931. */
  32932. const expanded = (state, action) => {
  32933. if (Array.isArray(action.clientIds)) {
  32934. return { ...state,
  32935. ...action.clientIds.reduce((newState, id) => ({ ...newState,
  32936. [id]: action.type === 'expand'
  32937. }), {})
  32938. };
  32939. }
  32940. return state;
  32941. };
  32942. const BLOCK_LIST_ITEM_HEIGHT = 36;
  32943. /**
  32944. * Wrap `ListViewRows` with `TreeGrid`. ListViewRows is a
  32945. * recursive component (it renders itself), so this ensures TreeGrid is only
  32946. * present at the very top of the navigation grid.
  32947. *
  32948. * @param {Object} props Components props.
  32949. * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
  32950. * @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.
  32951. * @param {boolean} props.showBlockMovers Flag to enable block movers
  32952. * @param {boolean} props.__experimentalFeatures Flag to enable experimental features.
  32953. * @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.
  32954. * @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)
  32955. * @param {string} props.id Unique identifier for the root list element (primarily for a11y purposes).
  32956. * @param {boolean} props.expandNested Flag to determine whether nested levels are expanded by default.
  32957. * @param {Object} ref Forwarded ref
  32958. */
  32959. function ListView(_ref, ref) {
  32960. let {
  32961. blocks,
  32962. __experimentalFeatures,
  32963. __experimentalPersistentListViewFeatures,
  32964. __experimentalHideContainerBlockActions,
  32965. showNestedBlocks,
  32966. showBlockMovers,
  32967. id,
  32968. expandNested = false,
  32969. ...props
  32970. } = _ref;
  32971. const {
  32972. clientIdsTree,
  32973. draggedClientIds,
  32974. selectedClientIds
  32975. } = useListViewClientIds(blocks);
  32976. const {
  32977. visibleBlockCount
  32978. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  32979. const {
  32980. getGlobalBlockCount,
  32981. getClientIdsOfDescendants
  32982. } = select(store);
  32983. const draggedBlockCount = (draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.length) > 0 ? getClientIdsOfDescendants(draggedClientIds).length + 1 : 0;
  32984. return {
  32985. visibleBlockCount: getGlobalBlockCount() - draggedBlockCount
  32986. };
  32987. }, [draggedClientIds]);
  32988. const {
  32989. updateBlockSelection
  32990. } = useBlockSelection();
  32991. const [expandedState, setExpandedState] = (0,external_wp_element_namespaceObject.useReducer)(expanded, {});
  32992. const {
  32993. ref: dropZoneRef,
  32994. target: blockDropTarget
  32995. } = useListViewDropZone();
  32996. const elementRef = (0,external_wp_element_namespaceObject.useRef)();
  32997. const treeGridRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([elementRef, dropZoneRef, ref]);
  32998. const isMounted = (0,external_wp_element_namespaceObject.useRef)(false);
  32999. const {
  33000. setSelectedTreeId
  33001. } = useListViewExpandSelectedItem({
  33002. firstSelectedBlockClientId: selectedClientIds[0],
  33003. setExpandedState
  33004. });
  33005. const selectEditorBlock = (0,external_wp_element_namespaceObject.useCallback)((event, clientId) => {
  33006. updateBlockSelection(event, clientId);
  33007. setSelectedTreeId(clientId);
  33008. }, [setSelectedTreeId, updateBlockSelection]);
  33009. (0,external_wp_element_namespaceObject.useEffect)(() => {
  33010. isMounted.current = true;
  33011. }, []); // List View renders a fixed number of items and relies on each having a fixed item height of 36px.
  33012. // If this value changes, we should also change the itemHeight value set in useFixedWindowList.
  33013. // See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
  33014. const [fixedListWindow] = (0,external_wp_compose_namespaceObject.__experimentalUseFixedWindowList)(elementRef, BLOCK_LIST_ITEM_HEIGHT, visibleBlockCount, {
  33015. useWindowing: __experimentalPersistentListViewFeatures,
  33016. windowOverscan: 40
  33017. });
  33018. const expand = (0,external_wp_element_namespaceObject.useCallback)(clientId => {
  33019. if (!clientId) {
  33020. return;
  33021. }
  33022. setExpandedState({
  33023. type: 'expand',
  33024. clientIds: [clientId]
  33025. });
  33026. }, [setExpandedState]);
  33027. const collapse = (0,external_wp_element_namespaceObject.useCallback)(clientId => {
  33028. if (!clientId) {
  33029. return;
  33030. }
  33031. setExpandedState({
  33032. type: 'collapse',
  33033. clientIds: [clientId]
  33034. });
  33035. }, [setExpandedState]);
  33036. const expandRow = (0,external_wp_element_namespaceObject.useCallback)(row => {
  33037. var _row$dataset;
  33038. expand(row === null || row === void 0 ? void 0 : (_row$dataset = row.dataset) === null || _row$dataset === void 0 ? void 0 : _row$dataset.block);
  33039. }, [expand]);
  33040. const collapseRow = (0,external_wp_element_namespaceObject.useCallback)(row => {
  33041. var _row$dataset2;
  33042. collapse(row === null || row === void 0 ? void 0 : (_row$dataset2 = row.dataset) === null || _row$dataset2 === void 0 ? void 0 : _row$dataset2.block);
  33043. }, [collapse]);
  33044. const focusRow = (0,external_wp_element_namespaceObject.useCallback)((event, startRow, endRow) => {
  33045. if (event.shiftKey) {
  33046. var _startRow$dataset, _endRow$dataset;
  33047. 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);
  33048. }
  33049. }, [updateBlockSelection]);
  33050. const contextValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({
  33051. __experimentalFeatures,
  33052. __experimentalPersistentListViewFeatures,
  33053. __experimentalHideContainerBlockActions,
  33054. isTreeGridMounted: isMounted.current,
  33055. draggedClientIds,
  33056. expandedState,
  33057. expand,
  33058. collapse
  33059. }), [__experimentalFeatures, __experimentalPersistentListViewFeatures, __experimentalHideContainerBlockActions, isMounted.current, draggedClientIds, expandedState, expand, collapse]);
  33060. return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
  33061. value: true
  33062. }, (0,external_wp_element_namespaceObject.createElement)(ListViewDropIndicator, {
  33063. listViewRef: elementRef,
  33064. blockDropTarget: blockDropTarget
  33065. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGrid, {
  33066. id: id,
  33067. className: "block-editor-list-view-tree",
  33068. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block navigation structure'),
  33069. ref: treeGridRef,
  33070. onCollapseRow: collapseRow,
  33071. onExpandRow: expandRow,
  33072. onFocusRow: focusRow
  33073. }, (0,external_wp_element_namespaceObject.createElement)(ListViewContext.Provider, {
  33074. value: contextValue
  33075. }, (0,external_wp_element_namespaceObject.createElement)(branch, _extends({
  33076. blocks: clientIdsTree,
  33077. selectBlock: selectEditorBlock,
  33078. showNestedBlocks: showNestedBlocks,
  33079. showBlockMovers: showBlockMovers,
  33080. fixedListWindow: fixedListWindow,
  33081. selectedClientIds: selectedClientIds,
  33082. expandNested: expandNested
  33083. }, props)))));
  33084. }
  33085. /* harmony default export */ var components_list_view = ((0,external_wp_element_namespaceObject.forwardRef)(ListView));
  33086. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/dropdown.js
  33087. /**
  33088. * WordPress dependencies
  33089. */
  33090. /**
  33091. * Internal dependencies
  33092. */
  33093. function BlockNavigationDropdownToggle(_ref) {
  33094. let {
  33095. isEnabled,
  33096. onToggle,
  33097. isOpen,
  33098. innerRef,
  33099. ...props
  33100. } = _ref;
  33101. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
  33102. ref: innerRef,
  33103. icon: list_view,
  33104. "aria-expanded": isOpen,
  33105. "aria-haspopup": "true",
  33106. onClick: isEnabled ? onToggle : undefined
  33107. /* translators: button label text should, if possible, be under 16 characters. */
  33108. ,
  33109. label: (0,external_wp_i18n_namespaceObject.__)('List view'),
  33110. className: "block-editor-block-navigation",
  33111. "aria-disabled": !isEnabled
  33112. }));
  33113. }
  33114. function BlockNavigationDropdown(_ref2, ref) {
  33115. let {
  33116. isDisabled,
  33117. __experimentalFeatures,
  33118. ...props
  33119. } = _ref2;
  33120. const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).getBlockCount(), []);
  33121. const isEnabled = hasBlocks && !isDisabled;
  33122. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  33123. contentClassName: "block-editor-block-navigation__popover",
  33124. position: "bottom right",
  33125. renderToggle: _ref3 => {
  33126. let {
  33127. isOpen,
  33128. onToggle
  33129. } = _ref3;
  33130. return (0,external_wp_element_namespaceObject.createElement)(BlockNavigationDropdownToggle, _extends({}, props, {
  33131. innerRef: ref,
  33132. isOpen: isOpen,
  33133. onToggle: onToggle,
  33134. isEnabled: isEnabled
  33135. }));
  33136. },
  33137. renderContent: () => (0,external_wp_element_namespaceObject.createElement)("div", {
  33138. className: "block-editor-block-navigation__container"
  33139. }, (0,external_wp_element_namespaceObject.createElement)("p", {
  33140. className: "block-editor-block-navigation__label"
  33141. }, (0,external_wp_i18n_namespaceObject.__)('List view')), (0,external_wp_element_namespaceObject.createElement)(components_list_view, {
  33142. showNestedBlocks: true,
  33143. __experimentalFeatures: __experimentalFeatures
  33144. }))
  33145. });
  33146. }
  33147. /* harmony default export */ var dropdown = ((0,external_wp_element_namespaceObject.forwardRef)(BlockNavigationDropdown));
  33148. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/preview-panel.js
  33149. /**
  33150. * WordPress dependencies
  33151. */
  33152. /**
  33153. * Internal dependencies
  33154. */
  33155. function BlockStylesPreviewPanel(_ref) {
  33156. let {
  33157. genericPreviewBlock,
  33158. style,
  33159. className,
  33160. activeStyle
  33161. } = _ref;
  33162. const styleClassName = replaceActiveStyle(className, activeStyle, style);
  33163. const previewBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
  33164. return { ...genericPreviewBlock,
  33165. title: style.label || style.name,
  33166. description: style.description,
  33167. initialAttributes: { ...genericPreviewBlock.attributes,
  33168. className: styleClassName + ' block-editor-block-styles__block-preview-container'
  33169. }
  33170. };
  33171. }, [genericPreviewBlock, styleClassName]);
  33172. return (0,external_wp_element_namespaceObject.createElement)(preview_panel, {
  33173. item: previewBlocks,
  33174. isStylePreview: true
  33175. });
  33176. }
  33177. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/index.js
  33178. /**
  33179. * External dependencies
  33180. */
  33181. /**
  33182. * WordPress dependencies
  33183. */
  33184. /**
  33185. * Internal dependencies
  33186. */
  33187. function BlockStylesPreviewPanelSlot(_ref) {
  33188. let {
  33189. scope
  33190. } = _ref;
  33191. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
  33192. name: `BlockStylesPreviewPanel/${scope}`
  33193. });
  33194. }
  33195. function BlockStylesPreviewPanelFill(_ref2) {
  33196. let {
  33197. children,
  33198. scope,
  33199. ...props
  33200. } = _ref2;
  33201. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
  33202. name: `BlockStylesPreviewPanel/${scope}`
  33203. }, (0,external_wp_element_namespaceObject.createElement)("div", props, children));
  33204. } // Top position (in px) of the Block Styles container
  33205. // relative to the editor pane.
  33206. // The value is the equivalent of the container's right position.
  33207. const DEFAULT_POSITION_TOP = 16; // Block Styles component for the Settings Sidebar.
  33208. function BlockStyles(_ref3) {
  33209. let {
  33210. clientId,
  33211. onSwitch = external_lodash_namespaceObject.noop,
  33212. onHoverClassName = external_lodash_namespaceObject.noop,
  33213. scope
  33214. } = _ref3;
  33215. const {
  33216. onSelect,
  33217. stylesToRender,
  33218. activeStyle,
  33219. genericPreviewBlock,
  33220. className: previewClassName
  33221. } = useStylesForBlocks({
  33222. clientId,
  33223. onSwitch
  33224. });
  33225. const [hoveredStyle, setHoveredStyle] = (0,external_wp_element_namespaceObject.useState)(null);
  33226. const [containerScrollTop, setContainerScrollTop] = (0,external_wp_element_namespaceObject.useState)(0);
  33227. const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
  33228. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  33229. const scrollContainer = document.querySelector('.interface-interface-skeleton__content');
  33230. const scrollTop = (scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTop) || 0;
  33231. setContainerScrollTop(scrollTop + DEFAULT_POSITION_TOP);
  33232. }, [hoveredStyle]);
  33233. if (!stylesToRender || stylesToRender.length === 0) {
  33234. return null;
  33235. }
  33236. const debouncedSetHoveredStyle = (0,external_lodash_namespaceObject.debounce)(setHoveredStyle, 250);
  33237. const onSelectStylePreview = style => {
  33238. onSelect(style);
  33239. onHoverClassName(null);
  33240. setHoveredStyle(null);
  33241. debouncedSetHoveredStyle.cancel();
  33242. };
  33243. const styleItemHandler = item => {
  33244. var _item$name;
  33245. if (hoveredStyle === item) {
  33246. debouncedSetHoveredStyle.cancel();
  33247. return;
  33248. }
  33249. debouncedSetHoveredStyle(item);
  33250. onHoverClassName((_item$name = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name !== void 0 ? _item$name : null);
  33251. };
  33252. return (0,external_wp_element_namespaceObject.createElement)("div", {
  33253. className: "block-editor-block-styles"
  33254. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  33255. className: "block-editor-block-styles__variants"
  33256. }, stylesToRender.map(style => {
  33257. const buttonText = style.label || style.name;
  33258. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33259. className: classnames_default()('block-editor-block-styles__item', {
  33260. 'is-active': activeStyle.name === style.name
  33261. }),
  33262. key: style.name,
  33263. variant: "secondary",
  33264. label: buttonText,
  33265. onMouseEnter: () => styleItemHandler(style),
  33266. onFocus: () => styleItemHandler(style),
  33267. onMouseLeave: () => styleItemHandler(null),
  33268. onBlur: () => styleItemHandler(null),
  33269. onKeyDown: event => {
  33270. if (external_wp_keycodes_namespaceObject.ENTER === event.keyCode || external_wp_keycodes_namespaceObject.SPACE === event.keyCode) {
  33271. event.preventDefault();
  33272. onSelectStylePreview(style);
  33273. }
  33274. },
  33275. onClick: () => onSelectStylePreview(style),
  33276. role: "button",
  33277. tabIndex: "0"
  33278. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, {
  33279. numberOfLines: 1,
  33280. className: "block-editor-block-styles__item-text"
  33281. }, buttonText));
  33282. })), hoveredStyle && !isMobileViewport && (0,external_wp_element_namespaceObject.createElement)(BlockStylesPreviewPanelFill, {
  33283. scope: scope,
  33284. className: "block-editor-block-styles__preview-panel",
  33285. style: {
  33286. top: containerScrollTop
  33287. },
  33288. onMouseLeave: () => styleItemHandler(null)
  33289. }, (0,external_wp_element_namespaceObject.createElement)(BlockStylesPreviewPanel, {
  33290. activeStyle: activeStyle,
  33291. className: previewClassName,
  33292. genericPreviewBlock: genericPreviewBlock,
  33293. style: hoveredStyle
  33294. })));
  33295. }
  33296. BlockStyles.Slot = BlockStylesPreviewPanelSlot;
  33297. /* harmony default export */ var block_styles = (BlockStyles);
  33298. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js
  33299. /**
  33300. * WordPress dependencies
  33301. */
  33302. const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  33303. xmlns: "http://www.w3.org/2000/svg",
  33304. viewBox: "0 0 24 24"
  33305. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  33306. 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"
  33307. }));
  33308. /* harmony default export */ var library_layout = (layout);
  33309. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-variation-picker/index.js
  33310. /**
  33311. * External dependencies
  33312. */
  33313. /**
  33314. * WordPress dependencies
  33315. */
  33316. function BlockVariationPicker(_ref) {
  33317. let {
  33318. icon = library_layout,
  33319. label = (0,external_wp_i18n_namespaceObject.__)('Choose variation'),
  33320. instructions = (0,external_wp_i18n_namespaceObject.__)('Select a variation to start with.'),
  33321. variations,
  33322. onSelect,
  33323. allowSkip
  33324. } = _ref;
  33325. const classes = classnames_default()('block-editor-block-variation-picker', {
  33326. 'has-many-variations': variations.length > 4
  33327. });
  33328. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
  33329. icon: icon,
  33330. label: label,
  33331. instructions: instructions,
  33332. className: classes
  33333. }, (0,external_wp_element_namespaceObject.createElement)("ul", {
  33334. className: "block-editor-block-variation-picker__variations",
  33335. role: "list",
  33336. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block variations')
  33337. }, variations.map(variation => (0,external_wp_element_namespaceObject.createElement)("li", {
  33338. key: variation.name
  33339. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33340. variant: "secondary",
  33341. icon: variation.icon,
  33342. iconSize: 48,
  33343. onClick: () => onSelect(variation),
  33344. className: "block-editor-block-variation-picker__variation",
  33345. label: variation.description || variation.title
  33346. }), (0,external_wp_element_namespaceObject.createElement)("span", {
  33347. className: "block-editor-block-variation-picker__variation-label",
  33348. role: "presentation"
  33349. }, variation.title)))), allowSkip && (0,external_wp_element_namespaceObject.createElement)("div", {
  33350. className: "block-editor-block-variation-picker__skip"
  33351. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33352. variant: "link",
  33353. onClick: () => onSelect()
  33354. }, (0,external_wp_i18n_namespaceObject.__)('Skip'))));
  33355. }
  33356. /* harmony default export */ var block_variation_picker = (BlockVariationPicker);
  33357. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/grid.js
  33358. /**
  33359. * WordPress dependencies
  33360. */
  33361. const grid = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  33362. xmlns: "http://www.w3.org/2000/svg",
  33363. viewBox: "0 0 24 24"
  33364. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  33365. 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",
  33366. fillRule: "evenodd",
  33367. clipRule: "evenodd"
  33368. }));
  33369. /* harmony default export */ var library_grid = (grid);
  33370. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/constants.js
  33371. const VIEWMODES = {
  33372. carousel: 'carousel',
  33373. grid: 'grid'
  33374. };
  33375. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/setup-toolbar.js
  33376. /**
  33377. * WordPress dependencies
  33378. */
  33379. /**
  33380. * Internal dependencies
  33381. */
  33382. const Actions = _ref => {
  33383. let {
  33384. onStartBlank,
  33385. onBlockPatternSelect
  33386. } = _ref;
  33387. return (0,external_wp_element_namespaceObject.createElement)("div", {
  33388. className: "block-editor-block-pattern-setup__actions"
  33389. }, onStartBlank && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33390. onClick: onStartBlank
  33391. }, (0,external_wp_i18n_namespaceObject.__)('Start blank')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33392. variant: "primary",
  33393. onClick: onBlockPatternSelect
  33394. }, (0,external_wp_i18n_namespaceObject.__)('Choose')));
  33395. };
  33396. const CarouselNavigation = _ref2 => {
  33397. let {
  33398. handlePrevious,
  33399. handleNext,
  33400. activeSlide,
  33401. totalSlides
  33402. } = _ref2;
  33403. return (0,external_wp_element_namespaceObject.createElement)("div", {
  33404. className: "block-editor-block-pattern-setup__navigation"
  33405. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33406. icon: chevron_left,
  33407. label: (0,external_wp_i18n_namespaceObject.__)('Previous pattern'),
  33408. onClick: handlePrevious,
  33409. disabled: activeSlide === 0
  33410. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33411. icon: chevron_right,
  33412. label: (0,external_wp_i18n_namespaceObject.__)('Next pattern'),
  33413. onClick: handleNext,
  33414. disabled: activeSlide === totalSlides - 1
  33415. }));
  33416. };
  33417. const SetupToolbar = _ref3 => {
  33418. let {
  33419. viewMode,
  33420. setViewMode,
  33421. handlePrevious,
  33422. handleNext,
  33423. activeSlide,
  33424. totalSlides,
  33425. onBlockPatternSelect,
  33426. onStartBlank
  33427. } = _ref3;
  33428. const isCarouselView = viewMode === VIEWMODES.carousel;
  33429. const displayControls = (0,external_wp_element_namespaceObject.createElement)("div", {
  33430. className: "block-editor-block-pattern-setup__display-controls"
  33431. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33432. icon: stretch_full_width,
  33433. label: (0,external_wp_i18n_namespaceObject.__)('Carousel view'),
  33434. onClick: () => setViewMode(VIEWMODES.carousel),
  33435. isPressed: isCarouselView
  33436. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33437. icon: library_grid,
  33438. label: (0,external_wp_i18n_namespaceObject.__)('Grid view'),
  33439. onClick: () => setViewMode(VIEWMODES.grid),
  33440. isPressed: viewMode === VIEWMODES.grid
  33441. }));
  33442. return (0,external_wp_element_namespaceObject.createElement)("div", {
  33443. className: "block-editor-block-pattern-setup__toolbar"
  33444. }, isCarouselView && (0,external_wp_element_namespaceObject.createElement)(CarouselNavigation, {
  33445. handlePrevious: handlePrevious,
  33446. handleNext: handleNext,
  33447. activeSlide: activeSlide,
  33448. totalSlides: totalSlides
  33449. }), displayControls, isCarouselView && (0,external_wp_element_namespaceObject.createElement)(Actions, {
  33450. onBlockPatternSelect: onBlockPatternSelect,
  33451. onStartBlank: onStartBlank
  33452. }));
  33453. };
  33454. /* harmony default export */ var setup_toolbar = (SetupToolbar);
  33455. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/use-patterns-setup.js
  33456. /**
  33457. * WordPress dependencies
  33458. */
  33459. /**
  33460. * Internal dependencies
  33461. */
  33462. function usePatternsSetup(clientId, blockName, filterPatternsFn) {
  33463. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  33464. const {
  33465. getBlockRootClientId,
  33466. __experimentalGetPatternsByBlockTypes,
  33467. __experimentalGetAllowedPatterns
  33468. } = select(store);
  33469. const rootClientId = getBlockRootClientId(clientId);
  33470. if (filterPatternsFn) {
  33471. return __experimentalGetAllowedPatterns(rootClientId).filter(filterPatternsFn);
  33472. }
  33473. return __experimentalGetPatternsByBlockTypes(blockName, rootClientId);
  33474. }, [clientId, blockName, filterPatternsFn]);
  33475. }
  33476. /* harmony default export */ var use_patterns_setup = (usePatternsSetup);
  33477. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/index.js
  33478. /**
  33479. * WordPress dependencies
  33480. */
  33481. /**
  33482. * Internal dependencies
  33483. */
  33484. const SetupContent = _ref => {
  33485. let {
  33486. viewMode,
  33487. activeSlide,
  33488. patterns,
  33489. onBlockPatternSelect,
  33490. height
  33491. } = _ref;
  33492. const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)();
  33493. const containerClass = 'block-editor-block-pattern-setup__container';
  33494. if (viewMode === VIEWMODES.carousel) {
  33495. const slideClass = new Map([[activeSlide, 'active-slide'], [activeSlide - 1, 'previous-slide'], [activeSlide + 1, 'next-slide']]);
  33496. return (0,external_wp_element_namespaceObject.createElement)("div", {
  33497. className: "block-editor-block-pattern-setup__carousel",
  33498. style: {
  33499. height
  33500. }
  33501. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  33502. className: containerClass
  33503. }, (0,external_wp_element_namespaceObject.createElement)("ul", {
  33504. className: "carousel-container"
  33505. }, patterns.map((pattern, index) => (0,external_wp_element_namespaceObject.createElement)(BlockPatternSlide, {
  33506. className: slideClass.get(index) || '',
  33507. key: pattern.name,
  33508. pattern: pattern,
  33509. minHeight: height
  33510. })))));
  33511. }
  33512. return (0,external_wp_element_namespaceObject.createElement)("div", {
  33513. style: {
  33514. height
  33515. },
  33516. className: "block-editor-block-pattern-setup__grid"
  33517. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
  33518. role: "listbox",
  33519. className: containerClass,
  33520. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Patterns list')
  33521. }), patterns.map(pattern => (0,external_wp_element_namespaceObject.createElement)(block_pattern_setup_BlockPattern, {
  33522. key: pattern.name,
  33523. pattern: pattern,
  33524. onSelect: onBlockPatternSelect,
  33525. composite: composite
  33526. }))));
  33527. };
  33528. function block_pattern_setup_BlockPattern(_ref2) {
  33529. let {
  33530. pattern,
  33531. onSelect,
  33532. composite
  33533. } = _ref2;
  33534. const baseClassName = 'block-editor-block-pattern-setup-list';
  33535. const {
  33536. blocks,
  33537. description,
  33538. viewportWidth = 700
  33539. } = pattern;
  33540. const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(block_pattern_setup_BlockPattern, `${baseClassName}__item-description`);
  33541. return (0,external_wp_element_namespaceObject.createElement)("div", {
  33542. className: `${baseClassName}__list-item`,
  33543. "aria-label": pattern.title,
  33544. "aria-describedby": pattern.description ? descriptionId : undefined
  33545. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
  33546. role: "option",
  33547. as: "div"
  33548. }, composite, {
  33549. className: `${baseClassName}__item`,
  33550. onClick: () => onSelect(blocks)
  33551. }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  33552. blocks: blocks,
  33553. viewportWidth: viewportWidth
  33554. })), !!description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  33555. id: descriptionId
  33556. }, description));
  33557. }
  33558. function BlockPatternSlide(_ref3) {
  33559. let {
  33560. className,
  33561. pattern,
  33562. minHeight
  33563. } = _ref3;
  33564. const {
  33565. blocks,
  33566. title,
  33567. description
  33568. } = pattern;
  33569. const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockPatternSlide, 'block-editor-block-pattern-setup-list__item-description');
  33570. return (0,external_wp_element_namespaceObject.createElement)("li", {
  33571. className: `pattern-slide ${className}`,
  33572. "aria-label": title,
  33573. "aria-describedby": description ? descriptionId : undefined
  33574. }, (0,external_wp_element_namespaceObject.createElement)(block_preview, {
  33575. blocks: blocks,
  33576. __experimentalMinHeight: minHeight
  33577. }), !!description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  33578. id: descriptionId
  33579. }, description));
  33580. }
  33581. const BlockPatternSetup = _ref4 => {
  33582. let {
  33583. clientId,
  33584. blockName,
  33585. filterPatternsFn,
  33586. startBlankComponent,
  33587. onBlockPatternSelect
  33588. } = _ref4;
  33589. const [viewMode, setViewMode] = (0,external_wp_element_namespaceObject.useState)(VIEWMODES.carousel);
  33590. const [activeSlide, setActiveSlide] = (0,external_wp_element_namespaceObject.useState)(0);
  33591. const [showBlank, setShowBlank] = (0,external_wp_element_namespaceObject.useState)(false);
  33592. const {
  33593. replaceBlock
  33594. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  33595. const patterns = use_patterns_setup(clientId, blockName, filterPatternsFn);
  33596. const [contentResizeListener, {
  33597. height: contentHeight
  33598. }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
  33599. if (!(patterns !== null && patterns !== void 0 && patterns.length) || showBlank) {
  33600. return startBlankComponent;
  33601. }
  33602. const onBlockPatternSelectDefault = blocks => {
  33603. const clonedBlocks = blocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
  33604. replaceBlock(clientId, clonedBlocks);
  33605. };
  33606. const onPatternSelectCallback = onBlockPatternSelect || onBlockPatternSelectDefault;
  33607. const onStartBlank = startBlankComponent ? () => {
  33608. setShowBlank(true);
  33609. } : undefined;
  33610. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, contentResizeListener, (0,external_wp_element_namespaceObject.createElement)("div", {
  33611. className: `block-editor-block-pattern-setup view-mode-${viewMode}`
  33612. }, (0,external_wp_element_namespaceObject.createElement)(SetupContent, {
  33613. viewMode: viewMode,
  33614. activeSlide: activeSlide,
  33615. patterns: patterns,
  33616. onBlockPatternSelect: onPatternSelectCallback,
  33617. height: contentHeight - 2 * 60
  33618. }), (0,external_wp_element_namespaceObject.createElement)(setup_toolbar, {
  33619. viewMode: viewMode,
  33620. setViewMode: setViewMode,
  33621. activeSlide: activeSlide,
  33622. totalSlides: patterns.length,
  33623. handleNext: () => {
  33624. setActiveSlide(active => active + 1);
  33625. },
  33626. handlePrevious: () => {
  33627. setActiveSlide(active => active - 1);
  33628. },
  33629. onBlockPatternSelect: () => {
  33630. onPatternSelectCallback(patterns[activeSlide].blocks);
  33631. },
  33632. onStartBlank: onStartBlank
  33633. })));
  33634. };
  33635. /* harmony default export */ var block_pattern_setup = (BlockPatternSetup);
  33636. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-variation-transforms/index.js
  33637. /**
  33638. * WordPress dependencies
  33639. */
  33640. /**
  33641. * Internal dependencies
  33642. */
  33643. function VariationsButtons(_ref) {
  33644. let {
  33645. className,
  33646. onSelectVariation,
  33647. selectedValue,
  33648. variations
  33649. } = _ref;
  33650. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  33651. className: className
  33652. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  33653. as: "legend"
  33654. }, (0,external_wp_i18n_namespaceObject.__)('Transform to variation')), variations.map(variation => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  33655. key: variation.name,
  33656. icon: variation.icon,
  33657. isPressed: selectedValue === variation.name,
  33658. label: selectedValue === variation.name ? variation.title : (0,external_wp_i18n_namespaceObject.sprintf)(
  33659. /* translators: %s: Name of the block variation */
  33660. (0,external_wp_i18n_namespaceObject.__)('Transform to %s'), variation.title),
  33661. onClick: () => onSelectVariation(variation.name),
  33662. "aria-label": variation.title,
  33663. showTooltip: true
  33664. })));
  33665. }
  33666. function VariationsDropdown(_ref2) {
  33667. let {
  33668. className,
  33669. onSelectVariation,
  33670. selectedValue,
  33671. variations
  33672. } = _ref2;
  33673. const selectOptions = variations.map(_ref3 => {
  33674. let {
  33675. name,
  33676. title,
  33677. description
  33678. } = _ref3;
  33679. return {
  33680. value: name,
  33681. label: title,
  33682. info: description
  33683. };
  33684. });
  33685. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
  33686. className: className,
  33687. label: (0,external_wp_i18n_namespaceObject.__)('Transform to variation'),
  33688. text: (0,external_wp_i18n_namespaceObject.__)('Transform to variation'),
  33689. popoverProps: {
  33690. position: 'bottom center',
  33691. className: `${className}__popover`
  33692. },
  33693. icon: chevron_down,
  33694. toggleProps: {
  33695. iconPosition: 'right'
  33696. }
  33697. }, () => (0,external_wp_element_namespaceObject.createElement)("div", {
  33698. className: `${className}__container`
  33699. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
  33700. choices: selectOptions,
  33701. value: selectedValue,
  33702. onSelect: onSelectVariation
  33703. }))));
  33704. }
  33705. function __experimentalBlockVariationTransforms(_ref4) {
  33706. let {
  33707. blockClientId
  33708. } = _ref4;
  33709. const {
  33710. updateBlockAttributes
  33711. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  33712. const {
  33713. activeBlockVariation,
  33714. variations
  33715. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  33716. const {
  33717. getActiveBlockVariation,
  33718. getBlockVariations
  33719. } = select(external_wp_blocks_namespaceObject.store);
  33720. const {
  33721. getBlockName,
  33722. getBlockAttributes
  33723. } = select(store);
  33724. const name = blockClientId && getBlockName(blockClientId);
  33725. return {
  33726. activeBlockVariation: getActiveBlockVariation(name, getBlockAttributes(blockClientId)),
  33727. variations: name && getBlockVariations(name, 'transform')
  33728. };
  33729. }, [blockClientId]);
  33730. const selectedValue = activeBlockVariation === null || activeBlockVariation === void 0 ? void 0 : activeBlockVariation.name; // Check if each variation has a unique icon.
  33731. const hasUniqueIcons = (0,external_wp_element_namespaceObject.useMemo)(() => {
  33732. const variationIcons = new Set();
  33733. if (!variations) {
  33734. return false;
  33735. }
  33736. variations.forEach(variation => {
  33737. if (variation.icon) {
  33738. variationIcons.add(variation.icon);
  33739. }
  33740. });
  33741. return variationIcons.size === variations.length;
  33742. }, [variations]);
  33743. const onSelectVariation = variationName => {
  33744. updateBlockAttributes(blockClientId, { ...variations.find(_ref5 => {
  33745. let {
  33746. name
  33747. } = _ref5;
  33748. return name === variationName;
  33749. }).attributes
  33750. });
  33751. };
  33752. const baseClass = 'block-editor-block-variation-transforms'; // Skip rendering if there are no variations
  33753. if (!(variations !== null && variations !== void 0 && variations.length)) return null;
  33754. const Component = hasUniqueIcons ? VariationsButtons : VariationsDropdown;
  33755. return (0,external_wp_element_namespaceObject.createElement)(Component, {
  33756. className: baseClass,
  33757. onSelectVariation: onSelectVariation,
  33758. selectedValue: selectedValue,
  33759. variations: variations
  33760. });
  33761. }
  33762. /* harmony default export */ var block_variation_transforms = (__experimentalBlockVariationTransforms);
  33763. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/with-color-context.js
  33764. /**
  33765. * External dependencies
  33766. */
  33767. /**
  33768. * WordPress dependencies
  33769. */
  33770. /**
  33771. * Internal dependencies
  33772. */
  33773. /* harmony default export */ var with_color_context = ((0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => {
  33774. return props => {
  33775. const colorsFeature = useSetting('color.palette');
  33776. const disableCustomColorsFeature = !useSetting('color.custom');
  33777. const colors = props.colors === undefined ? colorsFeature : props.colors;
  33778. const disableCustomColors = props.disableCustomColors === undefined ? disableCustomColorsFeature : props.disableCustomColors;
  33779. const hasColorsToChoose = !(0,external_lodash_namespaceObject.isEmpty)(colors) || !disableCustomColors;
  33780. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  33781. colors,
  33782. disableCustomColors,
  33783. hasColorsToChoose
  33784. }));
  33785. };
  33786. }, 'withColorContext'));
  33787. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/index.js
  33788. /**
  33789. * WordPress dependencies
  33790. */
  33791. /**
  33792. * Internal dependencies
  33793. */
  33794. /* harmony default export */ var color_palette = (with_color_context(external_wp_components_namespaceObject.ColorPalette));
  33795. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/control.js
  33796. /**
  33797. * Internal dependencies
  33798. */
  33799. function ColorPaletteControl(_ref) {
  33800. let {
  33801. onChange,
  33802. value,
  33803. ...otherProps
  33804. } = _ref;
  33805. return (0,external_wp_element_namespaceObject.createElement)(control, _extends({}, otherProps, {
  33806. onColorChange: onChange,
  33807. colorValue: value,
  33808. gradients: [],
  33809. disableCustomGradients: true
  33810. }));
  33811. }
  33812. ;// CONCATENATED MODULE: external ["wp","date"]
  33813. var external_wp_date_namespaceObject = window["wp"]["date"];
  33814. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/date-format-picker/index.js
  33815. /**
  33816. * External dependencies
  33817. */
  33818. /**
  33819. * WordPress dependencies
  33820. */
  33821. // So that we can illustrate the different formats in the dropdown properly,
  33822. // show a date that has a day greater than 12 and a month with more than three
  33823. // letters. Here we're using 2022-01-25 which is when WordPress 5.9 was
  33824. // released.
  33825. const EXAMPLE_DATE = new Date(2022, 0, 25);
  33826. /**
  33827. * The `DateFormatPicker` component renders controls that let the user choose a
  33828. * _date format_. That is, how they want their dates to be formatted.
  33829. *
  33830. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/date-format-picker/README.md
  33831. *
  33832. * @param {Object} props
  33833. * @param {string|null} props.format The selected date
  33834. * format. If
  33835. * `null`,
  33836. * _Default_ is
  33837. * selected.
  33838. * @param {string} props.defaultFormat The date format that
  33839. * will be used if the
  33840. * user selects
  33841. * 'Default'.
  33842. * @param {( format: string|null ) => void} props.onChange Called when a
  33843. * selection is
  33844. * made. If `null`,
  33845. * _Default_ is
  33846. * selected.
  33847. */
  33848. function DateFormatPicker(_ref) {
  33849. let {
  33850. format,
  33851. defaultFormat,
  33852. onChange
  33853. } = _ref;
  33854. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  33855. className: "block-editor-date-format-picker"
  33856. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  33857. as: "legend"
  33858. }, (0,external_wp_i18n_namespaceObject.__)('Date format')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  33859. 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", {
  33860. className: "block-editor-date-format-picker__default-format-toggle-control__hint"
  33861. }, (0,external_wp_date_namespaceObject.dateI18n)(defaultFormat, EXAMPLE_DATE))),
  33862. checked: !format,
  33863. onChange: checked => onChange(checked ? null : defaultFormat)
  33864. }), format && (0,external_wp_element_namespaceObject.createElement)(NonDefaultControls, {
  33865. format: format,
  33866. onChange: onChange
  33867. }));
  33868. }
  33869. function NonDefaultControls(_ref2) {
  33870. var _suggestedOptions$fin;
  33871. let {
  33872. format,
  33873. onChange
  33874. } = _ref2;
  33875. // Suggest a short format, medium format, long format, and a standardised
  33876. // (YYYY-MM-DD) format. The short, medium, and long formats are localised as
  33877. // different languages have different ways of writing these. For example, 'F
  33878. // j, Y' (April 20, 2022) in American English (en_US) is 'j. F Y' (20. April
  33879. // 2022) in German (de). The resultant array is de-duplicated as some
  33880. // languages will use the same format string for short, medium, and long
  33881. // formats.
  33882. const suggestedFormats = (0,external_lodash_namespaceObject.uniq)(['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')]);
  33883. const suggestedOptions = suggestedFormats.map((suggestedFormat, index) => ({
  33884. key: `suggested-${index}`,
  33885. name: (0,external_wp_date_namespaceObject.dateI18n)(suggestedFormat, EXAMPLE_DATE),
  33886. format: suggestedFormat
  33887. }));
  33888. const customOption = {
  33889. key: 'custom',
  33890. name: (0,external_wp_i18n_namespaceObject.__)('Custom'),
  33891. className: 'block-editor-date-format-picker__custom-format-select-control__custom-option',
  33892. __experimentalHint: (0,external_wp_i18n_namespaceObject.__)('Enter your own date format')
  33893. };
  33894. const [isCustom, setIsCustom] = (0,external_wp_element_namespaceObject.useState)(() => !!format && !suggestedFormats.includes(format));
  33895. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, {
  33896. className: "block-editor-date-format-picker__custom-format-select-control"
  33897. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CustomSelectControl, {
  33898. label: (0,external_wp_i18n_namespaceObject.__)('Choose a format'),
  33899. options: [...suggestedOptions, customOption],
  33900. value: isCustom ? customOption : (_suggestedOptions$fin = suggestedOptions.find(option => option.format === format)) !== null && _suggestedOptions$fin !== void 0 ? _suggestedOptions$fin : customOption,
  33901. onChange: _ref3 => {
  33902. let {
  33903. selectedItem
  33904. } = _ref3;
  33905. if (selectedItem === customOption) {
  33906. setIsCustom(true);
  33907. } else {
  33908. setIsCustom(false);
  33909. onChange(selectedItem.format);
  33910. }
  33911. }
  33912. })), isCustom && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  33913. label: (0,external_wp_i18n_namespaceObject.__)('Custom format'),
  33914. hideLabelFromVision: true,
  33915. help: (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Enter a date or time <Link>format string</Link>.'), {
  33916. Link: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  33917. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/formatting-date-and-time/')
  33918. })
  33919. }),
  33920. value: format,
  33921. onChange: value => onChange(value)
  33922. }));
  33923. }
  33924. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/panel-color-gradient-settings.js
  33925. /**
  33926. * External dependencies
  33927. */
  33928. /**
  33929. * WordPress dependencies
  33930. */
  33931. /**
  33932. * Internal dependencies
  33933. */
  33934. // translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000)
  33935. const colorIndicatorAriaLabel = (0,external_wp_i18n_namespaceObject.__)('(%s: color %s)'); // translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000)
  33936. const gradientIndicatorAriaLabel = (0,external_wp_i18n_namespaceObject.__)('(%s: gradient %s)');
  33937. const panel_color_gradient_settings_colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients'];
  33938. const Indicators = _ref => {
  33939. let {
  33940. colors,
  33941. gradients,
  33942. settings
  33943. } = _ref;
  33944. return settings.map((_ref2, index) => {
  33945. let {
  33946. colorValue,
  33947. gradientValue,
  33948. label,
  33949. colors: availableColors,
  33950. gradients: availableGradients
  33951. } = _ref2;
  33952. if (!colorValue && !gradientValue) {
  33953. return null;
  33954. }
  33955. let ariaLabel;
  33956. if (colorValue) {
  33957. const colorObject = getColorObjectByColorValue(availableColors || colors, colorValue);
  33958. ariaLabel = (0,external_wp_i18n_namespaceObject.sprintf)(colorIndicatorAriaLabel, label.toLowerCase(), colorObject && colorObject.name || colorValue);
  33959. } else {
  33960. const gradientObject = __experimentalGetGradientObjectByGradientValue(availableGradients || gradients, colorValue);
  33961. ariaLabel = (0,external_wp_i18n_namespaceObject.sprintf)(gradientIndicatorAriaLabel, label.toLowerCase(), gradientObject && gradientObject.name || gradientValue);
  33962. }
  33963. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
  33964. key: index,
  33965. colorValue: colorValue || gradientValue,
  33966. "aria-label": ariaLabel
  33967. });
  33968. });
  33969. };
  33970. const PanelColorGradientSettingsInner = _ref3 => {
  33971. let {
  33972. className,
  33973. colors,
  33974. gradients,
  33975. disableCustomColors,
  33976. disableCustomGradients,
  33977. children,
  33978. settings,
  33979. title,
  33980. showTitle = true,
  33981. __experimentalHasMultipleOrigins,
  33982. __experimentalIsRenderedInSidebar,
  33983. enableAlpha,
  33984. ...props
  33985. } = _ref3;
  33986. 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))) {
  33987. return null;
  33988. }
  33989. const titleElement = (0,external_wp_element_namespaceObject.createElement)("span", {
  33990. className: "block-editor-panel-color-gradient-settings__panel-title"
  33991. }, title, (0,external_wp_element_namespaceObject.createElement)(Indicators, {
  33992. colors: colors,
  33993. gradients: gradients,
  33994. settings: settings
  33995. }));
  33996. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, _extends({
  33997. className: classnames_default()('block-editor-panel-color-gradient-settings', className),
  33998. title: showTitle ? titleElement : undefined
  33999. }, props), (0,external_wp_element_namespaceObject.createElement)(ColorGradientSettingsDropdown, {
  34000. settings: settings,
  34001. colors,
  34002. gradients,
  34003. disableCustomColors,
  34004. disableCustomGradients,
  34005. __experimentalHasMultipleOrigins,
  34006. __experimentalIsRenderedInSidebar,
  34007. enableAlpha
  34008. }), !!children && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
  34009. marginY: 4
  34010. }), " ", children));
  34011. };
  34012. const PanelColorGradientSettingsSingleSelect = props => {
  34013. const colorGradientSettings = useCommonSingleMultipleSelects();
  34014. colorGradientSettings.colors = useSetting('color.palette');
  34015. colorGradientSettings.gradients = useSetting('color.gradients');
  34016. return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsInner, _extends({}, colorGradientSettings, props));
  34017. };
  34018. const PanelColorGradientSettingsMultipleSelect = props => {
  34019. const colorGradientSettings = useMultipleOriginColorsAndGradients();
  34020. return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsInner, _extends({}, colorGradientSettings, props));
  34021. };
  34022. const PanelColorGradientSettings = props => {
  34023. if ((0,external_lodash_namespaceObject.every)(panel_color_gradient_settings_colorsAndGradientKeys, key => props.hasOwnProperty(key))) {
  34024. return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsInner, props);
  34025. }
  34026. if (props.__experimentalHasMultipleOrigins) {
  34027. return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsMultipleSelect, props);
  34028. }
  34029. return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsSingleSelect, props);
  34030. };
  34031. /* harmony default export */ var panel_color_gradient_settings = (PanelColorGradientSettings);
  34032. ;// CONCATENATED MODULE: ./node_modules/react-easy-crop/node_modules/tslib/tslib.es6.js
  34033. /*! *****************************************************************************
  34034. Copyright (c) Microsoft Corporation.
  34035. Permission to use, copy, modify, and/or distribute this software for any
  34036. purpose with or without fee is hereby granted.
  34037. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  34038. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  34039. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  34040. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  34041. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  34042. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  34043. PERFORMANCE OF THIS SOFTWARE.
  34044. ***************************************************************************** */
  34045. /* global Reflect, Promise */
  34046. var extendStatics = function(d, b) {
  34047. extendStatics = Object.setPrototypeOf ||
  34048. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34049. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  34050. return extendStatics(d, b);
  34051. };
  34052. function __extends(d, b) {
  34053. extendStatics(d, b);
  34054. function __() { this.constructor = d; }
  34055. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34056. }
  34057. var __assign = function() {
  34058. __assign = Object.assign || function __assign(t) {
  34059. for (var s, i = 1, n = arguments.length; i < n; i++) {
  34060. s = arguments[i];
  34061. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  34062. }
  34063. return t;
  34064. }
  34065. return __assign.apply(this, arguments);
  34066. }
  34067. function __rest(s, e) {
  34068. var t = {};
  34069. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  34070. t[p] = s[p];
  34071. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  34072. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  34073. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  34074. t[p[i]] = s[p[i]];
  34075. }
  34076. return t;
  34077. }
  34078. function __decorate(decorators, target, key, desc) {
  34079. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34080. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34081. 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;
  34082. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34083. }
  34084. function __param(paramIndex, decorator) {
  34085. return function (target, key) { decorator(target, key, paramIndex); }
  34086. }
  34087. function __metadata(metadataKey, metadataValue) {
  34088. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  34089. }
  34090. function __awaiter(thisArg, _arguments, P, generator) {
  34091. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  34092. return new (P || (P = Promise))(function (resolve, reject) {
  34093. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  34094. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  34095. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  34096. step((generator = generator.apply(thisArg, _arguments || [])).next());
  34097. });
  34098. }
  34099. function __generator(thisArg, body) {
  34100. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  34101. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  34102. function verb(n) { return function (v) { return step([n, v]); }; }
  34103. function step(op) {
  34104. if (f) throw new TypeError("Generator is already executing.");
  34105. while (_) try {
  34106. 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;
  34107. if (y = 0, t) op = [op[0] & 2, t.value];
  34108. switch (op[0]) {
  34109. case 0: case 1: t = op; break;
  34110. case 4: _.label++; return { value: op[1], done: false };
  34111. case 5: _.label++; y = op[1]; op = [0]; continue;
  34112. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  34113. default:
  34114. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  34115. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  34116. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  34117. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  34118. if (t[2]) _.ops.pop();
  34119. _.trys.pop(); continue;
  34120. }
  34121. op = body.call(thisArg, _);
  34122. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  34123. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  34124. }
  34125. }
  34126. var __createBinding = Object.create ? (function(o, m, k, k2) {
  34127. if (k2 === undefined) k2 = k;
  34128. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  34129. }) : (function(o, m, k, k2) {
  34130. if (k2 === undefined) k2 = k;
  34131. o[k2] = m[k];
  34132. });
  34133. function __exportStar(m, o) {
  34134. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
  34135. }
  34136. function __values(o) {
  34137. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  34138. if (m) return m.call(o);
  34139. if (o && typeof o.length === "number") return {
  34140. next: function () {
  34141. if (o && i >= o.length) o = void 0;
  34142. return { value: o && o[i++], done: !o };
  34143. }
  34144. };
  34145. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  34146. }
  34147. function __read(o, n) {
  34148. var m = typeof Symbol === "function" && o[Symbol.iterator];
  34149. if (!m) return o;
  34150. var i = m.call(o), r, ar = [], e;
  34151. try {
  34152. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  34153. }
  34154. catch (error) { e = { error: error }; }
  34155. finally {
  34156. try {
  34157. if (r && !r.done && (m = i["return"])) m.call(i);
  34158. }
  34159. finally { if (e) throw e.error; }
  34160. }
  34161. return ar;
  34162. }
  34163. function __spread() {
  34164. for (var ar = [], i = 0; i < arguments.length; i++)
  34165. ar = ar.concat(__read(arguments[i]));
  34166. return ar;
  34167. }
  34168. function __spreadArrays() {
  34169. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  34170. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  34171. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  34172. r[k] = a[j];
  34173. return r;
  34174. };
  34175. function __await(v) {
  34176. return this instanceof __await ? (this.v = v, this) : new __await(v);
  34177. }
  34178. function __asyncGenerator(thisArg, _arguments, generator) {
  34179. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  34180. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  34181. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  34182. 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); }); }; }
  34183. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  34184. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  34185. function fulfill(value) { resume("next", value); }
  34186. function reject(value) { resume("throw", value); }
  34187. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  34188. }
  34189. function __asyncDelegator(o) {
  34190. var i, p;
  34191. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  34192. 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; }
  34193. }
  34194. function __asyncValues(o) {
  34195. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  34196. var m = o[Symbol.asyncIterator], i;
  34197. 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);
  34198. 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); }); }; }
  34199. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  34200. }
  34201. function __makeTemplateObject(cooked, raw) {
  34202. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  34203. return cooked;
  34204. };
  34205. var __setModuleDefault = Object.create ? (function(o, v) {
  34206. Object.defineProperty(o, "default", { enumerable: true, value: v });
  34207. }) : function(o, v) {
  34208. o["default"] = v;
  34209. };
  34210. function __importStar(mod) {
  34211. if (mod && mod.__esModule) return mod;
  34212. var result = {};
  34213. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  34214. __setModuleDefault(result, mod);
  34215. return result;
  34216. }
  34217. function __importDefault(mod) {
  34218. return (mod && mod.__esModule) ? mod : { default: mod };
  34219. }
  34220. function __classPrivateFieldGet(receiver, privateMap) {
  34221. if (!privateMap.has(receiver)) {
  34222. throw new TypeError("attempted to get private field on non-instance");
  34223. }
  34224. return privateMap.get(receiver);
  34225. }
  34226. function __classPrivateFieldSet(receiver, privateMap, value) {
  34227. if (!privateMap.has(receiver)) {
  34228. throw new TypeError("attempted to set private field on non-instance");
  34229. }
  34230. privateMap.set(receiver, value);
  34231. return value;
  34232. }
  34233. // EXTERNAL MODULE: ./node_modules/normalize-wheel/index.js
  34234. var normalize_wheel = __webpack_require__(7970);
  34235. var normalize_wheel_default = /*#__PURE__*/__webpack_require__.n(normalize_wheel);
  34236. ;// CONCATENATED MODULE: ./node_modules/react-easy-crop/index.module.js
  34237. /**
  34238. * Compute the dimension of the crop area based on media size,
  34239. * aspect ratio and optionally rotation
  34240. */
  34241. function getCropSize(mediaWidth, mediaHeight, containerWidth, containerHeight, aspect, rotation) {
  34242. if (rotation === void 0) {
  34243. rotation = 0;
  34244. }
  34245. var _a = translateSize(mediaWidth, mediaHeight, rotation),
  34246. width = _a.width,
  34247. height = _a.height;
  34248. var fittingWidth = Math.min(width, containerWidth);
  34249. var fittingHeight = Math.min(height, containerHeight);
  34250. if (fittingWidth > fittingHeight * aspect) {
  34251. return {
  34252. width: fittingHeight * aspect,
  34253. height: fittingHeight
  34254. };
  34255. }
  34256. return {
  34257. width: fittingWidth,
  34258. height: fittingWidth / aspect
  34259. };
  34260. }
  34261. /**
  34262. * Ensure a new media position stays in the crop area.
  34263. */
  34264. function restrictPosition(position, mediaSize, cropSize, zoom, rotation) {
  34265. if (rotation === void 0) {
  34266. rotation = 0;
  34267. }
  34268. var _a = translateSize(mediaSize.width, mediaSize.height, rotation),
  34269. width = _a.width,
  34270. height = _a.height;
  34271. return {
  34272. x: restrictPositionCoord(position.x, width, cropSize.width, zoom),
  34273. y: restrictPositionCoord(position.y, height, cropSize.height, zoom)
  34274. };
  34275. }
  34276. function restrictPositionCoord(position, mediaSize, cropSize, zoom) {
  34277. var maxPosition = mediaSize * zoom / 2 - cropSize / 2;
  34278. return Math.min(maxPosition, Math.max(position, -maxPosition));
  34279. }
  34280. function getDistanceBetweenPoints(pointA, pointB) {
  34281. return Math.sqrt(Math.pow(pointA.y - pointB.y, 2) + Math.pow(pointA.x - pointB.x, 2));
  34282. }
  34283. function getRotationBetweenPoints(pointA, pointB) {
  34284. return Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x) * 180 / Math.PI;
  34285. }
  34286. /**
  34287. * Compute the output cropped area of the media in percentages and pixels.
  34288. * x/y are the top-left coordinates on the src media
  34289. */
  34290. function computeCroppedArea(crop, mediaSize, cropSize, aspect, zoom, rotation, restrictPosition) {
  34291. if (rotation === void 0) {
  34292. rotation = 0;
  34293. }
  34294. if (restrictPosition === void 0) {
  34295. restrictPosition = true;
  34296. } // if the media is rotated by the user, we cannot limit the position anymore
  34297. // as it might need to be negative.
  34298. var limitAreaFn = restrictPosition && rotation === 0 ? limitArea : noOp;
  34299. var croppedAreaPercentages = {
  34300. x: limitAreaFn(100, ((mediaSize.width - cropSize.width / zoom) / 2 - crop.x / zoom) / mediaSize.width * 100),
  34301. y: limitAreaFn(100, ((mediaSize.height - cropSize.height / zoom) / 2 - crop.y / zoom) / mediaSize.height * 100),
  34302. width: limitAreaFn(100, cropSize.width / mediaSize.width * 100 / zoom),
  34303. height: limitAreaFn(100, cropSize.height / mediaSize.height * 100 / zoom)
  34304. }; // we compute the pixels size naively
  34305. var widthInPixels = Math.round(limitAreaFn(mediaSize.naturalWidth, croppedAreaPercentages.width * mediaSize.naturalWidth / 100));
  34306. var heightInPixels = Math.round(limitAreaFn(mediaSize.naturalHeight, croppedAreaPercentages.height * mediaSize.naturalHeight / 100));
  34307. var isImgWiderThanHigh = mediaSize.naturalWidth >= mediaSize.naturalHeight * aspect; // then we ensure the width and height exactly match the aspect (to avoid rounding approximations)
  34308. // if the media is wider than high, when zoom is 0, the crop height will be equals to iamge height
  34309. // thus we want to compute the width from the height and aspect for accuracy.
  34310. // Otherwise, we compute the height from width and aspect.
  34311. var sizePixels = isImgWiderThanHigh ? {
  34312. width: Math.round(heightInPixels * aspect),
  34313. height: heightInPixels
  34314. } : {
  34315. width: widthInPixels,
  34316. height: Math.round(widthInPixels / aspect)
  34317. };
  34318. var croppedAreaPixels = __assign(__assign({}, sizePixels), {
  34319. x: Math.round(limitAreaFn(mediaSize.naturalWidth - sizePixels.width, croppedAreaPercentages.x * mediaSize.naturalWidth / 100)),
  34320. y: Math.round(limitAreaFn(mediaSize.naturalHeight - sizePixels.height, croppedAreaPercentages.y * mediaSize.naturalHeight / 100))
  34321. });
  34322. return {
  34323. croppedAreaPercentages: croppedAreaPercentages,
  34324. croppedAreaPixels: croppedAreaPixels
  34325. };
  34326. }
  34327. /**
  34328. * Ensure the returned value is between 0 and max
  34329. */
  34330. function limitArea(max, value) {
  34331. return Math.min(max, Math.max(0, value));
  34332. }
  34333. function noOp(_max, value) {
  34334. return value;
  34335. }
  34336. /**
  34337. * Compute the crop and zoom from the croppedAreaPixels
  34338. */
  34339. function getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize) {
  34340. var mediaZoom = mediaSize.width / mediaSize.naturalWidth;
  34341. if (cropSize) {
  34342. var isHeightMaxSize_1 = cropSize.height > cropSize.width;
  34343. return isHeightMaxSize_1 ? cropSize.height / mediaZoom / croppedAreaPixels.height : cropSize.width / mediaZoom / croppedAreaPixels.width;
  34344. }
  34345. var aspect = croppedAreaPixels.width / croppedAreaPixels.height;
  34346. var isHeightMaxSize = mediaSize.naturalWidth >= mediaSize.naturalHeight * aspect;
  34347. return isHeightMaxSize ? mediaSize.naturalHeight / croppedAreaPixels.height : mediaSize.naturalWidth / croppedAreaPixels.width;
  34348. }
  34349. /**
  34350. * Compute the crop and zoom from the croppedAreaPixels
  34351. */
  34352. function getInitialCropFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize) {
  34353. var mediaZoom = mediaSize.width / mediaSize.naturalWidth;
  34354. var zoom = getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize);
  34355. var cropZoom = mediaZoom * zoom;
  34356. var crop = {
  34357. x: ((mediaSize.naturalWidth - croppedAreaPixels.width) / 2 - croppedAreaPixels.x) * cropZoom,
  34358. y: ((mediaSize.naturalHeight - croppedAreaPixels.height) / 2 - croppedAreaPixels.y) * cropZoom
  34359. };
  34360. return {
  34361. crop: crop,
  34362. zoom: zoom
  34363. };
  34364. }
  34365. /**
  34366. * Return the point that is the center of point a and b
  34367. */
  34368. function getCenter(a, b) {
  34369. return {
  34370. x: (b.x + a.x) / 2,
  34371. y: (b.y + a.y) / 2
  34372. };
  34373. }
  34374. /**
  34375. *
  34376. * Returns an x,y point once rotated around xMid,yMid
  34377. */
  34378. function rotateAroundMidPoint(x, y, xMid, yMid, degrees) {
  34379. var cos = Math.cos;
  34380. var sin = Math.sin;
  34381. var radian = degrees * Math.PI / 180; // Convert to radians
  34382. // Subtract midpoints, so that midpoint is translated to origin
  34383. // and add it in the end again
  34384. var xr = (x - xMid) * cos(radian) - (y - yMid) * sin(radian) + xMid;
  34385. var yr = (x - xMid) * sin(radian) + (y - yMid) * cos(radian) + yMid;
  34386. return [xr, yr];
  34387. }
  34388. /**
  34389. * Returns the new bounding area of a rotated rectangle.
  34390. */
  34391. function translateSize(width, height, rotation) {
  34392. var centerX = width / 2;
  34393. var centerY = height / 2;
  34394. var outerBounds = [rotateAroundMidPoint(0, 0, centerX, centerY, rotation), rotateAroundMidPoint(width, 0, centerX, centerY, rotation), rotateAroundMidPoint(width, height, centerX, centerY, rotation), rotateAroundMidPoint(0, height, centerX, centerY, rotation)];
  34395. var minX = Math.min.apply(Math, outerBounds.map(function (p) {
  34396. return p[0];
  34397. }));
  34398. var maxX = Math.max.apply(Math, outerBounds.map(function (p) {
  34399. return p[0];
  34400. }));
  34401. var minY = Math.min.apply(Math, outerBounds.map(function (p) {
  34402. return p[1];
  34403. }));
  34404. var maxY = Math.max.apply(Math, outerBounds.map(function (p) {
  34405. return p[1];
  34406. }));
  34407. return {
  34408. width: maxX - minX,
  34409. height: maxY - minY
  34410. };
  34411. }
  34412. /**
  34413. * Combine multiple class names into a single string.
  34414. */
  34415. function classNames() {
  34416. var args = [];
  34417. for (var _i = 0; _i < arguments.length; _i++) {
  34418. args[_i] = arguments[_i];
  34419. }
  34420. return args.filter(function (value) {
  34421. if (typeof value === 'string' && value.length > 0) {
  34422. return true;
  34423. }
  34424. return false;
  34425. }).join(' ').trim();
  34426. }
  34427. 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";
  34428. var MIN_ZOOM = 1;
  34429. var MAX_ZOOM = 3;
  34430. var Cropper =
  34431. /** @class */
  34432. function (_super) {
  34433. __extends(Cropper, _super);
  34434. function Cropper() {
  34435. var _this = _super !== null && _super.apply(this, arguments) || this;
  34436. _this.imageRef = null;
  34437. _this.videoRef = null;
  34438. _this.containerRef = null;
  34439. _this.styleRef = null;
  34440. _this.containerRect = null;
  34441. _this.mediaSize = {
  34442. width: 0,
  34443. height: 0,
  34444. naturalWidth: 0,
  34445. naturalHeight: 0
  34446. };
  34447. _this.dragStartPosition = {
  34448. x: 0,
  34449. y: 0
  34450. };
  34451. _this.dragStartCrop = {
  34452. x: 0,
  34453. y: 0
  34454. };
  34455. _this.lastPinchDistance = 0;
  34456. _this.lastPinchRotation = 0;
  34457. _this.rafDragTimeout = null;
  34458. _this.rafPinchTimeout = null;
  34459. _this.wheelTimer = null;
  34460. _this.state = {
  34461. cropSize: null,
  34462. hasWheelJustStarted: false
  34463. }; // this is to prevent Safari on iOS >= 10 to zoom the page
  34464. _this.preventZoomSafari = function (e) {
  34465. return e.preventDefault();
  34466. };
  34467. _this.cleanEvents = function () {
  34468. document.removeEventListener('mousemove', _this.onMouseMove);
  34469. document.removeEventListener('mouseup', _this.onDragStopped);
  34470. document.removeEventListener('touchmove', _this.onTouchMove);
  34471. document.removeEventListener('touchend', _this.onDragStopped);
  34472. };
  34473. _this.clearScrollEvent = function () {
  34474. if (_this.containerRef) _this.containerRef.removeEventListener('wheel', _this.onWheel);
  34475. if (_this.wheelTimer) {
  34476. clearTimeout(_this.wheelTimer);
  34477. }
  34478. };
  34479. _this.onMediaLoad = function () {
  34480. _this.computeSizes();
  34481. _this.emitCropData();
  34482. _this.setInitialCrop();
  34483. if (_this.props.onMediaLoaded) {
  34484. _this.props.onMediaLoaded(_this.mediaSize);
  34485. }
  34486. };
  34487. _this.setInitialCrop = function () {
  34488. var _a = _this.props,
  34489. initialCroppedAreaPixels = _a.initialCroppedAreaPixels,
  34490. cropSize = _a.cropSize;
  34491. if (!initialCroppedAreaPixels) {
  34492. return;
  34493. }
  34494. var _b = getInitialCropFromCroppedAreaPixels(initialCroppedAreaPixels, _this.mediaSize, cropSize),
  34495. crop = _b.crop,
  34496. zoom = _b.zoom;
  34497. _this.props.onCropChange(crop);
  34498. _this.props.onZoomChange && _this.props.onZoomChange(zoom);
  34499. };
  34500. _this.computeSizes = function () {
  34501. var _a, _b, _c, _d, _e, _f;
  34502. var mediaRef = _this.imageRef || _this.videoRef;
  34503. if (mediaRef && _this.containerRef) {
  34504. _this.containerRect = _this.containerRef.getBoundingClientRect();
  34505. _this.mediaSize = {
  34506. width: mediaRef.offsetWidth,
  34507. height: mediaRef.offsetHeight,
  34508. naturalWidth: ((_a = _this.imageRef) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = _this.videoRef) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0,
  34509. naturalHeight: ((_c = _this.imageRef) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = _this.videoRef) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0
  34510. };
  34511. var cropSize = _this.props.cropSize ? _this.props.cropSize : getCropSize(mediaRef.offsetWidth, mediaRef.offsetHeight, _this.containerRect.width, _this.containerRect.height, _this.props.aspect, _this.props.rotation);
  34512. 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) {
  34513. _this.props.onCropSizeChange && _this.props.onCropSizeChange(cropSize);
  34514. }
  34515. _this.setState({
  34516. cropSize: cropSize
  34517. }, _this.recomputeCropPosition);
  34518. }
  34519. };
  34520. _this.onMouseDown = function (e) {
  34521. e.preventDefault();
  34522. document.addEventListener('mousemove', _this.onMouseMove);
  34523. document.addEventListener('mouseup', _this.onDragStopped);
  34524. _this.onDragStart(Cropper.getMousePoint(e));
  34525. };
  34526. _this.onMouseMove = function (e) {
  34527. return _this.onDrag(Cropper.getMousePoint(e));
  34528. };
  34529. _this.onTouchStart = function (e) {
  34530. document.addEventListener('touchmove', _this.onTouchMove, {
  34531. passive: false
  34532. }); // iOS 11 now defaults to passive: true
  34533. document.addEventListener('touchend', _this.onDragStopped);
  34534. if (e.touches.length === 2) {
  34535. _this.onPinchStart(e);
  34536. } else if (e.touches.length === 1) {
  34537. _this.onDragStart(Cropper.getTouchPoint(e.touches[0]));
  34538. }
  34539. };
  34540. _this.onTouchMove = function (e) {
  34541. // Prevent whole page from scrolling on iOS.
  34542. e.preventDefault();
  34543. if (e.touches.length === 2) {
  34544. _this.onPinchMove(e);
  34545. } else if (e.touches.length === 1) {
  34546. _this.onDrag(Cropper.getTouchPoint(e.touches[0]));
  34547. }
  34548. };
  34549. _this.onDragStart = function (_a) {
  34550. var _b, _c;
  34551. var x = _a.x,
  34552. y = _a.y;
  34553. _this.dragStartPosition = {
  34554. x: x,
  34555. y: y
  34556. };
  34557. _this.dragStartCrop = __assign({}, _this.props.crop);
  34558. (_c = (_b = _this.props).onInteractionStart) === null || _c === void 0 ? void 0 : _c.call(_b);
  34559. };
  34560. _this.onDrag = function (_a) {
  34561. var x = _a.x,
  34562. y = _a.y;
  34563. if (_this.rafDragTimeout) window.cancelAnimationFrame(_this.rafDragTimeout);
  34564. _this.rafDragTimeout = window.requestAnimationFrame(function () {
  34565. if (!_this.state.cropSize) return;
  34566. if (x === undefined || y === undefined) return;
  34567. var offsetX = x - _this.dragStartPosition.x;
  34568. var offsetY = y - _this.dragStartPosition.y;
  34569. var requestedPosition = {
  34570. x: _this.dragStartCrop.x + offsetX,
  34571. y: _this.dragStartCrop.y + offsetY
  34572. };
  34573. var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : requestedPosition;
  34574. _this.props.onCropChange(newPosition);
  34575. });
  34576. };
  34577. _this.onDragStopped = function () {
  34578. var _a, _b;
  34579. _this.cleanEvents();
  34580. _this.emitCropData();
  34581. (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
  34582. };
  34583. _this.onWheel = function (e) {
  34584. e.preventDefault();
  34585. var point = Cropper.getMousePoint(e);
  34586. var pixelY = normalize_wheel_default()(e).pixelY;
  34587. var newZoom = _this.props.zoom - pixelY * _this.props.zoomSpeed / 200;
  34588. _this.setNewZoom(newZoom, point);
  34589. if (!_this.state.hasWheelJustStarted) {
  34590. _this.setState({
  34591. hasWheelJustStarted: true
  34592. }, function () {
  34593. var _a, _b;
  34594. return (_b = (_a = _this.props).onInteractionStart) === null || _b === void 0 ? void 0 : _b.call(_a);
  34595. });
  34596. }
  34597. if (_this.wheelTimer) {
  34598. clearTimeout(_this.wheelTimer);
  34599. }
  34600. _this.wheelTimer = window.setTimeout(function () {
  34601. return _this.setState({
  34602. hasWheelJustStarted: false
  34603. }, function () {
  34604. var _a, _b;
  34605. return (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
  34606. });
  34607. }, 250);
  34608. };
  34609. _this.getPointOnContainer = function (_a) {
  34610. var x = _a.x,
  34611. y = _a.y;
  34612. if (!_this.containerRect) {
  34613. throw new Error('The Cropper is not mounted');
  34614. }
  34615. return {
  34616. x: _this.containerRect.width / 2 - (x - _this.containerRect.left),
  34617. y: _this.containerRect.height / 2 - (y - _this.containerRect.top)
  34618. };
  34619. };
  34620. _this.getPointOnMedia = function (_a) {
  34621. var x = _a.x,
  34622. y = _a.y;
  34623. var _b = _this.props,
  34624. crop = _b.crop,
  34625. zoom = _b.zoom;
  34626. return {
  34627. x: (x + crop.x) / zoom,
  34628. y: (y + crop.y) / zoom
  34629. };
  34630. };
  34631. _this.setNewZoom = function (zoom, point) {
  34632. if (!_this.state.cropSize || !_this.props.onZoomChange) return;
  34633. var zoomPoint = _this.getPointOnContainer(point);
  34634. var zoomTarget = _this.getPointOnMedia(zoomPoint);
  34635. var newZoom = Math.min(_this.props.maxZoom, Math.max(zoom, _this.props.minZoom));
  34636. var requestedPosition = {
  34637. x: zoomTarget.x * newZoom - zoomPoint.x,
  34638. y: zoomTarget.y * newZoom - zoomPoint.y
  34639. };
  34640. var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, newZoom, _this.props.rotation) : requestedPosition;
  34641. _this.props.onCropChange(newPosition);
  34642. _this.props.onZoomChange(newZoom);
  34643. };
  34644. _this.getCropData = function () {
  34645. if (!_this.state.cropSize) {
  34646. return null;
  34647. } // this is to ensure the crop is correctly restricted after a zoom back (https://github.com/ricardo-ch/react-easy-crop/issues/6)
  34648. var restrictedPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop;
  34649. return computeCroppedArea(restrictedPosition, _this.mediaSize, _this.state.cropSize, _this.getAspect(), _this.props.zoom, _this.props.rotation, _this.props.restrictPosition);
  34650. };
  34651. _this.emitCropData = function () {
  34652. var cropData = _this.getCropData();
  34653. if (!cropData) return;
  34654. var croppedAreaPercentages = cropData.croppedAreaPercentages,
  34655. croppedAreaPixels = cropData.croppedAreaPixels;
  34656. if (_this.props.onCropComplete) {
  34657. _this.props.onCropComplete(croppedAreaPercentages, croppedAreaPixels);
  34658. }
  34659. if (_this.props.onCropAreaChange) {
  34660. _this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels);
  34661. }
  34662. };
  34663. _this.emitCropAreaChange = function () {
  34664. var cropData = _this.getCropData();
  34665. if (!cropData) return;
  34666. var croppedAreaPercentages = cropData.croppedAreaPercentages,
  34667. croppedAreaPixels = cropData.croppedAreaPixels;
  34668. if (_this.props.onCropAreaChange) {
  34669. _this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels);
  34670. }
  34671. };
  34672. _this.recomputeCropPosition = function () {
  34673. if (!_this.state.cropSize) return;
  34674. var newPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop;
  34675. _this.props.onCropChange(newPosition);
  34676. _this.emitCropData();
  34677. };
  34678. return _this;
  34679. }
  34680. Cropper.prototype.componentDidMount = function () {
  34681. window.addEventListener('resize', this.computeSizes);
  34682. if (this.containerRef) {
  34683. this.props.zoomWithScroll && this.containerRef.addEventListener('wheel', this.onWheel, {
  34684. passive: false
  34685. });
  34686. this.containerRef.addEventListener('gesturestart', this.preventZoomSafari);
  34687. this.containerRef.addEventListener('gesturechange', this.preventZoomSafari);
  34688. }
  34689. if (!this.props.disableAutomaticStylesInjection) {
  34690. this.styleRef = document.createElement('style');
  34691. this.styleRef.setAttribute('type', 'text/css');
  34692. this.styleRef.innerHTML = css_248z;
  34693. document.head.appendChild(this.styleRef);
  34694. } // when rendered via SSR, the image can already be loaded and its onLoad callback will never be called
  34695. if (this.imageRef && this.imageRef.complete) {
  34696. this.onMediaLoad();
  34697. }
  34698. };
  34699. Cropper.prototype.componentWillUnmount = function () {
  34700. var _a;
  34701. window.removeEventListener('resize', this.computeSizes);
  34702. if (this.containerRef) {
  34703. this.containerRef.removeEventListener('gesturestart', this.preventZoomSafari);
  34704. this.containerRef.removeEventListener('gesturechange', this.preventZoomSafari);
  34705. }
  34706. if (this.styleRef) {
  34707. (_a = this.styleRef.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.styleRef);
  34708. }
  34709. this.cleanEvents();
  34710. this.props.zoomWithScroll && this.clearScrollEvent();
  34711. };
  34712. Cropper.prototype.componentDidUpdate = function (prevProps) {
  34713. var _a, _b, _c, _d, _e, _f, _g, _h, _j;
  34714. if (prevProps.rotation !== this.props.rotation) {
  34715. this.computeSizes();
  34716. this.recomputeCropPosition();
  34717. } else if (prevProps.aspect !== this.props.aspect) {
  34718. this.computeSizes();
  34719. } else if (prevProps.zoom !== this.props.zoom) {
  34720. this.recomputeCropPosition();
  34721. } 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)) {
  34722. this.computeSizes();
  34723. } 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)) {
  34724. this.emitCropAreaChange();
  34725. }
  34726. if (prevProps.zoomWithScroll !== this.props.zoomWithScroll && this.containerRef) {
  34727. this.props.zoomWithScroll ? this.containerRef.addEventListener('wheel', this.onWheel, {
  34728. passive: false
  34729. }) : this.clearScrollEvent();
  34730. }
  34731. if (prevProps.video !== this.props.video) {
  34732. (_j = this.videoRef) === null || _j === void 0 ? void 0 : _j.load();
  34733. }
  34734. };
  34735. Cropper.prototype.getAspect = function () {
  34736. var _a = this.props,
  34737. cropSize = _a.cropSize,
  34738. aspect = _a.aspect;
  34739. if (cropSize) {
  34740. return cropSize.width / cropSize.height;
  34741. }
  34742. return aspect;
  34743. };
  34744. Cropper.prototype.onPinchStart = function (e) {
  34745. var pointA = Cropper.getTouchPoint(e.touches[0]);
  34746. var pointB = Cropper.getTouchPoint(e.touches[1]);
  34747. this.lastPinchDistance = getDistanceBetweenPoints(pointA, pointB);
  34748. this.lastPinchRotation = getRotationBetweenPoints(pointA, pointB);
  34749. this.onDragStart(getCenter(pointA, pointB));
  34750. };
  34751. Cropper.prototype.onPinchMove = function (e) {
  34752. var _this = this;
  34753. var pointA = Cropper.getTouchPoint(e.touches[0]);
  34754. var pointB = Cropper.getTouchPoint(e.touches[1]);
  34755. var center = getCenter(pointA, pointB);
  34756. this.onDrag(center);
  34757. if (this.rafPinchTimeout) window.cancelAnimationFrame(this.rafPinchTimeout);
  34758. this.rafPinchTimeout = window.requestAnimationFrame(function () {
  34759. var distance = getDistanceBetweenPoints(pointA, pointB);
  34760. var newZoom = _this.props.zoom * (distance / _this.lastPinchDistance);
  34761. _this.setNewZoom(newZoom, center);
  34762. _this.lastPinchDistance = distance;
  34763. var rotation = getRotationBetweenPoints(pointA, pointB);
  34764. var newRotation = _this.props.rotation + (rotation - _this.lastPinchRotation);
  34765. _this.props.onRotationChange && _this.props.onRotationChange(newRotation);
  34766. _this.lastPinchRotation = rotation;
  34767. });
  34768. };
  34769. Cropper.prototype.render = function () {
  34770. var _this = this;
  34771. var _a = this.props,
  34772. image = _a.image,
  34773. video = _a.video,
  34774. mediaProps = _a.mediaProps,
  34775. transform = _a.transform,
  34776. _b = _a.crop,
  34777. x = _b.x,
  34778. y = _b.y,
  34779. rotation = _a.rotation,
  34780. zoom = _a.zoom,
  34781. cropShape = _a.cropShape,
  34782. showGrid = _a.showGrid,
  34783. _c = _a.style,
  34784. containerStyle = _c.containerStyle,
  34785. cropAreaStyle = _c.cropAreaStyle,
  34786. mediaStyle = _c.mediaStyle,
  34787. _d = _a.classes,
  34788. containerClassName = _d.containerClassName,
  34789. cropAreaClassName = _d.cropAreaClassName,
  34790. mediaClassName = _d.mediaClassName,
  34791. objectFit = _a.objectFit;
  34792. return /*#__PURE__*/external_React_default().createElement("div", {
  34793. onMouseDown: this.onMouseDown,
  34794. onTouchStart: this.onTouchStart,
  34795. ref: function ref(el) {
  34796. return _this.containerRef = el;
  34797. },
  34798. "data-testid": "container",
  34799. style: containerStyle,
  34800. className: classNames('reactEasyCrop_Container', containerClassName)
  34801. }, image ? /*#__PURE__*/external_React_default().createElement("img", __assign({
  34802. alt: "",
  34803. className: classNames('reactEasyCrop_Image', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', mediaClassName)
  34804. }, mediaProps, {
  34805. src: image,
  34806. ref: function ref(el) {
  34807. return _this.imageRef = el;
  34808. },
  34809. style: __assign(__assign({}, mediaStyle), {
  34810. transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")"
  34811. }),
  34812. onLoad: this.onMediaLoad
  34813. })) : video && /*#__PURE__*/external_React_default().createElement("video", __assign({
  34814. autoPlay: true,
  34815. loop: true,
  34816. muted: true,
  34817. className: classNames('reactEasyCrop_Video', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', mediaClassName)
  34818. }, mediaProps, {
  34819. ref: function ref(el) {
  34820. return _this.videoRef = el;
  34821. },
  34822. onLoadedMetadata: this.onMediaLoad,
  34823. style: __assign(__assign({}, mediaStyle), {
  34824. transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")"
  34825. }),
  34826. controls: false
  34827. }), (Array.isArray(video) ? video : [{
  34828. src: video
  34829. }]).map(function (item) {
  34830. return /*#__PURE__*/external_React_default().createElement("source", __assign({
  34831. key: item.src
  34832. }, item));
  34833. })), this.state.cropSize && /*#__PURE__*/external_React_default().createElement("div", {
  34834. style: __assign(__assign({}, cropAreaStyle), {
  34835. width: this.state.cropSize.width,
  34836. height: this.state.cropSize.height
  34837. }),
  34838. "data-testid": "cropper",
  34839. className: classNames('reactEasyCrop_CropArea', cropShape === 'round' && 'reactEasyCrop_CropAreaRound', showGrid && 'reactEasyCrop_CropAreaGrid', cropAreaClassName)
  34840. }));
  34841. };
  34842. Cropper.defaultProps = {
  34843. zoom: 1,
  34844. rotation: 0,
  34845. aspect: 4 / 3,
  34846. maxZoom: MAX_ZOOM,
  34847. minZoom: MIN_ZOOM,
  34848. cropShape: 'rect',
  34849. objectFit: 'contain',
  34850. showGrid: true,
  34851. style: {},
  34852. classes: {},
  34853. mediaProps: {},
  34854. zoomSpeed: 1,
  34855. restrictPosition: true,
  34856. zoomWithScroll: true
  34857. };
  34858. Cropper.getMousePoint = function (e) {
  34859. return {
  34860. x: Number(e.clientX),
  34861. y: Number(e.clientY)
  34862. };
  34863. };
  34864. Cropper.getTouchPoint = function (touch) {
  34865. return {
  34866. x: Number(touch.clientX),
  34867. y: Number(touch.clientY)
  34868. };
  34869. };
  34870. return Cropper;
  34871. }((external_React_default()).Component);
  34872. /* harmony default export */ var index_module = (Cropper);
  34873. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/constants.js
  34874. const constants_MIN_ZOOM = 100;
  34875. const constants_MAX_ZOOM = 300;
  34876. const constants_POPOVER_PROPS = {
  34877. position: 'bottom right',
  34878. isAlternate: true
  34879. };
  34880. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/use-save-image.js
  34881. /**
  34882. * WordPress dependencies
  34883. */
  34884. function useSaveImage(_ref) {
  34885. let {
  34886. crop,
  34887. rotation,
  34888. height,
  34889. width,
  34890. aspect,
  34891. url,
  34892. id,
  34893. onSaveImage,
  34894. onFinishEditing
  34895. } = _ref;
  34896. const {
  34897. createErrorNotice
  34898. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
  34899. const [isInProgress, setIsInProgress] = (0,external_wp_element_namespaceObject.useState)(false);
  34900. const cancel = (0,external_wp_element_namespaceObject.useCallback)(() => {
  34901. setIsInProgress(false);
  34902. onFinishEditing();
  34903. }, [setIsInProgress, onFinishEditing]);
  34904. const apply = (0,external_wp_element_namespaceObject.useCallback)(() => {
  34905. setIsInProgress(true);
  34906. let attrs = {}; // The crop script may return some very small, sub-pixel values when the image was not cropped.
  34907. // Crop only when the new size has changed by more than 0.1%.
  34908. if (crop.width < 99.9 || crop.height < 99.9) {
  34909. attrs = crop;
  34910. }
  34911. if (rotation > 0) {
  34912. attrs.rotation = rotation;
  34913. }
  34914. attrs.src = url;
  34915. external_wp_apiFetch_default()({
  34916. path: `/wp/v2/media/${id}/edit`,
  34917. method: 'POST',
  34918. data: attrs
  34919. }).then(response => {
  34920. onSaveImage({
  34921. id: response.id,
  34922. url: response.source_url,
  34923. height: height && width ? width / aspect : undefined
  34924. });
  34925. }).catch(error => {
  34926. createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)(
  34927. /* translators: 1. Error message */
  34928. (0,external_wp_i18n_namespaceObject.__)('Could not edit image. %s'), error.message), {
  34929. id: 'image-editing-error',
  34930. type: 'snackbar'
  34931. });
  34932. }).finally(() => {
  34933. setIsInProgress(false);
  34934. onFinishEditing();
  34935. });
  34936. }, [setIsInProgress, crop, rotation, height, width, aspect, url, onSaveImage, createErrorNotice, setIsInProgress, onFinishEditing]);
  34937. return (0,external_wp_element_namespaceObject.useMemo)(() => ({
  34938. isInProgress,
  34939. apply,
  34940. cancel
  34941. }), [isInProgress, apply, cancel]);
  34942. }
  34943. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/use-transform-image.js
  34944. /**
  34945. * WordPress dependencies
  34946. */
  34947. function useTransformState(_ref) {
  34948. let {
  34949. url,
  34950. naturalWidth,
  34951. naturalHeight
  34952. } = _ref;
  34953. const [editedUrl, setEditedUrl] = (0,external_wp_element_namespaceObject.useState)();
  34954. const [crop, setCrop] = (0,external_wp_element_namespaceObject.useState)();
  34955. const [position, setPosition] = (0,external_wp_element_namespaceObject.useState)({
  34956. x: 0,
  34957. y: 0
  34958. });
  34959. const [zoom, setZoom] = (0,external_wp_element_namespaceObject.useState)();
  34960. const [rotation, setRotation] = (0,external_wp_element_namespaceObject.useState)();
  34961. const [aspect, setAspect] = (0,external_wp_element_namespaceObject.useState)();
  34962. const [defaultAspect, setDefaultAspect] = (0,external_wp_element_namespaceObject.useState)();
  34963. const initializeTransformValues = (0,external_wp_element_namespaceObject.useCallback)(() => {
  34964. setPosition({
  34965. x: 0,
  34966. y: 0
  34967. });
  34968. setZoom(100);
  34969. setRotation(0);
  34970. setAspect(naturalWidth / naturalHeight);
  34971. setDefaultAspect(naturalWidth / naturalHeight);
  34972. }, [naturalWidth, naturalHeight, setPosition, setZoom, setRotation, setAspect, setDefaultAspect]);
  34973. const rotateClockwise = (0,external_wp_element_namespaceObject.useCallback)(() => {
  34974. const angle = (rotation + 90) % 360;
  34975. let naturalAspectRatio = naturalWidth / naturalHeight;
  34976. if (rotation % 180 === 90) {
  34977. naturalAspectRatio = naturalHeight / naturalWidth;
  34978. }
  34979. if (angle === 0) {
  34980. setEditedUrl();
  34981. setRotation(angle);
  34982. setAspect(1 / aspect);
  34983. setPosition({
  34984. x: -(position.y * naturalAspectRatio),
  34985. y: position.x * naturalAspectRatio
  34986. });
  34987. return;
  34988. }
  34989. function editImage(event) {
  34990. const canvas = document.createElement('canvas');
  34991. let translateX = 0;
  34992. let translateY = 0;
  34993. if (angle % 180) {
  34994. canvas.width = event.target.height;
  34995. canvas.height = event.target.width;
  34996. } else {
  34997. canvas.width = event.target.width;
  34998. canvas.height = event.target.height;
  34999. }
  35000. if (angle === 90 || angle === 180) {
  35001. translateX = canvas.width;
  35002. }
  35003. if (angle === 270 || angle === 180) {
  35004. translateY = canvas.height;
  35005. }
  35006. const context = canvas.getContext('2d');
  35007. context.translate(translateX, translateY);
  35008. context.rotate(angle * Math.PI / 180);
  35009. context.drawImage(event.target, 0, 0);
  35010. canvas.toBlob(blob => {
  35011. setEditedUrl(URL.createObjectURL(blob));
  35012. setRotation(angle);
  35013. setAspect(1 / aspect);
  35014. setPosition({
  35015. x: -(position.y * naturalAspectRatio),
  35016. y: position.x * naturalAspectRatio
  35017. });
  35018. });
  35019. }
  35020. const el = new window.Image();
  35021. el.src = url;
  35022. el.onload = editImage;
  35023. const imgCrossOrigin = (0,external_wp_hooks_namespaceObject.applyFilters)('media.crossOrigin', undefined, url);
  35024. if (typeof imgCrossOrigin === 'string') {
  35025. el.crossOrigin = imgCrossOrigin;
  35026. }
  35027. }, [rotation, naturalWidth, naturalHeight, setEditedUrl, setRotation, setAspect, setPosition]);
  35028. return (0,external_wp_element_namespaceObject.useMemo)(() => ({
  35029. editedUrl,
  35030. setEditedUrl,
  35031. crop,
  35032. setCrop,
  35033. position,
  35034. setPosition,
  35035. zoom,
  35036. setZoom,
  35037. rotation,
  35038. setRotation,
  35039. rotateClockwise,
  35040. aspect,
  35041. setAspect,
  35042. defaultAspect,
  35043. initializeTransformValues
  35044. }), [editedUrl, setEditedUrl, crop, setCrop, position, setPosition, zoom, setZoom, rotation, setRotation, rotateClockwise, aspect, setAspect, defaultAspect, initializeTransformValues]);
  35045. }
  35046. function useTransformImage(imageProperties, isEditing) {
  35047. const transformState = useTransformState(imageProperties);
  35048. const {
  35049. initializeTransformValues
  35050. } = transformState;
  35051. (0,external_wp_element_namespaceObject.useEffect)(() => {
  35052. if (isEditing) {
  35053. initializeTransformValues();
  35054. }
  35055. }, [isEditing, initializeTransformValues]);
  35056. return transformState;
  35057. }
  35058. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/context.js
  35059. /**
  35060. * WordPress dependencies
  35061. */
  35062. /**
  35063. * Internal dependencies
  35064. */
  35065. const ImageEditingContext = (0,external_wp_element_namespaceObject.createContext)({});
  35066. const useImageEditingContext = () => (0,external_wp_element_namespaceObject.useContext)(ImageEditingContext);
  35067. function ImageEditingProvider(_ref) {
  35068. let {
  35069. id,
  35070. url,
  35071. naturalWidth,
  35072. naturalHeight,
  35073. isEditing,
  35074. onFinishEditing,
  35075. onSaveImage,
  35076. children
  35077. } = _ref;
  35078. const transformImage = useTransformImage({
  35079. url,
  35080. naturalWidth,
  35081. naturalHeight
  35082. }, isEditing);
  35083. const saveImage = useSaveImage({
  35084. id,
  35085. url,
  35086. onSaveImage,
  35087. onFinishEditing,
  35088. ...transformImage
  35089. });
  35090. const providerValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...transformImage,
  35091. ...saveImage
  35092. }), [transformImage, saveImage]);
  35093. return (0,external_wp_element_namespaceObject.createElement)(ImageEditingContext.Provider, {
  35094. value: providerValue
  35095. }, children);
  35096. }
  35097. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/cropper.js
  35098. /**
  35099. * External dependencies
  35100. */
  35101. /**
  35102. * WordPress dependencies
  35103. */
  35104. /**
  35105. * Internal dependencies
  35106. */
  35107. function ImageCropper(_ref) {
  35108. let {
  35109. url,
  35110. width,
  35111. height,
  35112. clientWidth,
  35113. naturalHeight,
  35114. naturalWidth
  35115. } = _ref;
  35116. const {
  35117. isInProgress,
  35118. editedUrl,
  35119. position,
  35120. zoom,
  35121. aspect,
  35122. setPosition,
  35123. setCrop,
  35124. setZoom,
  35125. rotation
  35126. } = useImageEditingContext();
  35127. let editedHeight = height || clientWidth * naturalHeight / naturalWidth;
  35128. if (rotation % 180 === 90) {
  35129. editedHeight = clientWidth * naturalWidth / naturalHeight;
  35130. }
  35131. return (0,external_wp_element_namespaceObject.createElement)("div", {
  35132. className: classnames_default()('wp-block-image__crop-area', {
  35133. 'is-applying': isInProgress
  35134. }),
  35135. style: {
  35136. width: width || clientWidth,
  35137. height: editedHeight
  35138. }
  35139. }, (0,external_wp_element_namespaceObject.createElement)(index_module, {
  35140. image: editedUrl || url,
  35141. disabled: isInProgress,
  35142. minZoom: constants_MIN_ZOOM / 100,
  35143. maxZoom: constants_MAX_ZOOM / 100,
  35144. crop: position,
  35145. zoom: zoom / 100,
  35146. aspect: aspect,
  35147. onCropChange: setPosition,
  35148. onCropComplete: newCropPercent => {
  35149. setCrop(newCropPercent);
  35150. },
  35151. onZoomChange: newZoom => {
  35152. setZoom(newZoom * 100);
  35153. }
  35154. }), isInProgress && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null));
  35155. }
  35156. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/search.js
  35157. /**
  35158. * WordPress dependencies
  35159. */
  35160. const search = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  35161. xmlns: "http://www.w3.org/2000/svg",
  35162. viewBox: "0 0 24 24"
  35163. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  35164. 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"
  35165. }));
  35166. /* harmony default export */ var library_search = (search);
  35167. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/zoom-dropdown.js
  35168. /**
  35169. * WordPress dependencies
  35170. */
  35171. /**
  35172. * Internal dependencies
  35173. */
  35174. function ZoomDropdown() {
  35175. const {
  35176. isInProgress,
  35177. zoom,
  35178. setZoom
  35179. } = useImageEditingContext();
  35180. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  35181. contentClassName: "wp-block-image__zoom",
  35182. popoverProps: constants_POPOVER_PROPS,
  35183. renderToggle: _ref => {
  35184. let {
  35185. isOpen,
  35186. onToggle
  35187. } = _ref;
  35188. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  35189. icon: library_search,
  35190. label: (0,external_wp_i18n_namespaceObject.__)('Zoom'),
  35191. onClick: onToggle,
  35192. "aria-expanded": isOpen,
  35193. disabled: isInProgress
  35194. });
  35195. },
  35196. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.RangeControl, {
  35197. label: (0,external_wp_i18n_namespaceObject.__)('Zoom'),
  35198. min: constants_MIN_ZOOM,
  35199. max: constants_MAX_ZOOM,
  35200. value: Math.round(zoom),
  35201. onChange: setZoom
  35202. })
  35203. });
  35204. }
  35205. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/aspect-ratio.js
  35206. /**
  35207. * WordPress dependencies
  35208. */
  35209. const aspectRatio = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  35210. xmlns: "http://www.w3.org/2000/svg",
  35211. viewBox: "0 0 24 24"
  35212. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  35213. 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"
  35214. }));
  35215. /* harmony default export */ var aspect_ratio = (aspectRatio);
  35216. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/aspect-ratio-dropdown.js
  35217. /**
  35218. * WordPress dependencies
  35219. */
  35220. /**
  35221. * Internal dependencies
  35222. */
  35223. function AspectGroup(_ref) {
  35224. let {
  35225. aspectRatios,
  35226. isDisabled,
  35227. label,
  35228. onClick,
  35229. value
  35230. } = _ref;
  35231. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  35232. label: label
  35233. }, aspectRatios.map(_ref2 => {
  35234. let {
  35235. title,
  35236. aspect
  35237. } = _ref2;
  35238. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  35239. key: aspect,
  35240. disabled: isDisabled,
  35241. onClick: () => {
  35242. onClick(aspect);
  35243. },
  35244. role: "menuitemradio",
  35245. isSelected: aspect === value,
  35246. icon: aspect === value ? library_check : undefined
  35247. }, title);
  35248. }));
  35249. }
  35250. function AspectRatioDropdown(_ref3) {
  35251. let {
  35252. toggleProps
  35253. } = _ref3;
  35254. const {
  35255. isInProgress,
  35256. aspect,
  35257. setAspect,
  35258. defaultAspect
  35259. } = useImageEditingContext();
  35260. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
  35261. icon: aspect_ratio,
  35262. label: (0,external_wp_i18n_namespaceObject.__)('Aspect Ratio'),
  35263. popoverProps: constants_POPOVER_PROPS,
  35264. toggleProps: toggleProps,
  35265. className: "wp-block-image__aspect-ratio"
  35266. }, _ref4 => {
  35267. let {
  35268. onClose
  35269. } = _ref4;
  35270. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(AspectGroup, {
  35271. isDisabled: isInProgress,
  35272. onClick: newAspect => {
  35273. setAspect(newAspect);
  35274. onClose();
  35275. },
  35276. value: aspect,
  35277. aspectRatios: [{
  35278. title: (0,external_wp_i18n_namespaceObject.__)('Original'),
  35279. aspect: defaultAspect
  35280. }, {
  35281. title: (0,external_wp_i18n_namespaceObject.__)('Square'),
  35282. aspect: 1
  35283. }]
  35284. }), (0,external_wp_element_namespaceObject.createElement)(AspectGroup, {
  35285. label: (0,external_wp_i18n_namespaceObject.__)('Landscape'),
  35286. isDisabled: isInProgress,
  35287. onClick: newAspect => {
  35288. setAspect(newAspect);
  35289. onClose();
  35290. },
  35291. value: aspect,
  35292. aspectRatios: [{
  35293. title: (0,external_wp_i18n_namespaceObject.__)('16:10'),
  35294. aspect: 16 / 10
  35295. }, {
  35296. title: (0,external_wp_i18n_namespaceObject.__)('16:9'),
  35297. aspect: 16 / 9
  35298. }, {
  35299. title: (0,external_wp_i18n_namespaceObject.__)('4:3'),
  35300. aspect: 4 / 3
  35301. }, {
  35302. title: (0,external_wp_i18n_namespaceObject.__)('3:2'),
  35303. aspect: 3 / 2
  35304. }]
  35305. }), (0,external_wp_element_namespaceObject.createElement)(AspectGroup, {
  35306. label: (0,external_wp_i18n_namespaceObject.__)('Portrait'),
  35307. isDisabled: isInProgress,
  35308. onClick: newAspect => {
  35309. setAspect(newAspect);
  35310. onClose();
  35311. },
  35312. value: aspect,
  35313. aspectRatios: [{
  35314. title: (0,external_wp_i18n_namespaceObject.__)('10:16'),
  35315. aspect: 10 / 16
  35316. }, {
  35317. title: (0,external_wp_i18n_namespaceObject.__)('9:16'),
  35318. aspect: 9 / 16
  35319. }, {
  35320. title: (0,external_wp_i18n_namespaceObject.__)('3:4'),
  35321. aspect: 3 / 4
  35322. }, {
  35323. title: (0,external_wp_i18n_namespaceObject.__)('2:3'),
  35324. aspect: 2 / 3
  35325. }]
  35326. }));
  35327. });
  35328. }
  35329. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/rotate-right.js
  35330. /**
  35331. * WordPress dependencies
  35332. */
  35333. const rotateRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  35334. xmlns: "http://www.w3.org/2000/svg",
  35335. viewBox: "0 0 24 24"
  35336. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  35337. 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"
  35338. }));
  35339. /* harmony default export */ var rotate_right = (rotateRight);
  35340. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/rotation-button.js
  35341. /**
  35342. * WordPress dependencies
  35343. */
  35344. /**
  35345. * Internal dependencies
  35346. */
  35347. function RotationButton() {
  35348. const {
  35349. isInProgress,
  35350. rotateClockwise
  35351. } = useImageEditingContext();
  35352. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  35353. icon: rotate_right,
  35354. label: (0,external_wp_i18n_namespaceObject.__)('Rotate'),
  35355. onClick: rotateClockwise,
  35356. disabled: isInProgress
  35357. });
  35358. }
  35359. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/form-controls.js
  35360. /**
  35361. * WordPress dependencies
  35362. */
  35363. /**
  35364. * Internal dependencies
  35365. */
  35366. function FormControls() {
  35367. const {
  35368. isInProgress,
  35369. apply,
  35370. cancel
  35371. } = useImageEditingContext();
  35372. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  35373. onClick: apply,
  35374. disabled: isInProgress
  35375. }, (0,external_wp_i18n_namespaceObject.__)('Apply')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  35376. onClick: cancel
  35377. }, (0,external_wp_i18n_namespaceObject.__)('Cancel')));
  35378. }
  35379. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/index.js
  35380. /**
  35381. * WordPress dependencies
  35382. */
  35383. /**
  35384. * Internal dependencies
  35385. */
  35386. function ImageEditor(_ref) {
  35387. let {
  35388. url,
  35389. width,
  35390. height,
  35391. clientWidth,
  35392. naturalHeight,
  35393. naturalWidth
  35394. } = _ref;
  35395. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ImageCropper, {
  35396. url: url,
  35397. width: width,
  35398. height: height,
  35399. clientWidth: clientWidth,
  35400. naturalHeight: naturalHeight,
  35401. naturalWidth: naturalWidth
  35402. }), (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, {
  35403. toggleProps: toggleProps
  35404. })), (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))));
  35405. }
  35406. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-size-control/use-dimension-handler.js
  35407. /**
  35408. * WordPress dependencies
  35409. */
  35410. function useDimensionHandler(customHeight, customWidth, defaultHeight, defaultWidth, onChange) {
  35411. var _ref, _ref2;
  35412. const [currentWidth, setCurrentWidth] = (0,external_wp_element_namespaceObject.useState)((_ref = customWidth !== null && customWidth !== void 0 ? customWidth : defaultWidth) !== null && _ref !== void 0 ? _ref : '');
  35413. 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
  35414. // undefined. This effect updates the dimensions when the default values
  35415. // come through.
  35416. (0,external_wp_element_namespaceObject.useEffect)(() => {
  35417. if (customWidth === undefined && defaultWidth !== undefined) {
  35418. setCurrentWidth(defaultWidth);
  35419. }
  35420. if (customHeight === undefined && defaultHeight !== undefined) {
  35421. setCurrentHeight(defaultHeight);
  35422. }
  35423. }, [defaultWidth, defaultHeight]); // If custom values change, it means an outsider has resized the image using some other method (eg resize box)
  35424. // this keeps track of these values too. We need to parse before comparing; custom values can be strings.
  35425. (0,external_wp_element_namespaceObject.useEffect)(() => {
  35426. if (customWidth !== undefined && Number.parseInt(customWidth) !== Number.parseInt(currentWidth)) {
  35427. setCurrentWidth(customWidth);
  35428. }
  35429. if (customHeight !== undefined && Number.parseInt(customHeight) !== Number.parseInt(currentHeight)) {
  35430. setCurrentHeight(customHeight);
  35431. }
  35432. }, [customWidth, customHeight]);
  35433. const updateDimension = (dimension, value) => {
  35434. if (dimension === 'width') {
  35435. setCurrentWidth(value);
  35436. } else {
  35437. setCurrentHeight(value);
  35438. }
  35439. onChange({
  35440. [dimension]: value === '' ? undefined : parseInt(value, 10)
  35441. });
  35442. };
  35443. const updateDimensions = (nextHeight, nextWidth) => {
  35444. setCurrentHeight(nextHeight !== null && nextHeight !== void 0 ? nextHeight : defaultHeight);
  35445. setCurrentWidth(nextWidth !== null && nextWidth !== void 0 ? nextWidth : defaultWidth);
  35446. onChange({
  35447. height: nextHeight,
  35448. width: nextWidth
  35449. });
  35450. };
  35451. return {
  35452. currentHeight,
  35453. currentWidth,
  35454. updateDimension,
  35455. updateDimensions
  35456. };
  35457. }
  35458. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-size-control/index.js
  35459. /**
  35460. * External dependencies
  35461. */
  35462. /**
  35463. * WordPress dependencies
  35464. */
  35465. /**
  35466. * Internal dependencies
  35467. */
  35468. const IMAGE_SIZE_PRESETS = [25, 50, 75, 100];
  35469. function ImageSizeControl(_ref) {
  35470. let {
  35471. imageWidth,
  35472. imageHeight,
  35473. imageSizeOptions = [],
  35474. isResizable = true,
  35475. slug,
  35476. width,
  35477. height,
  35478. onChange,
  35479. onChangeImage = external_lodash_namespaceObject.noop
  35480. } = _ref;
  35481. const {
  35482. currentHeight,
  35483. currentWidth,
  35484. updateDimension,
  35485. updateDimensions
  35486. } = useDimensionHandler(height, width, imageHeight, imageWidth, onChange);
  35487. 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, {
  35488. label: (0,external_wp_i18n_namespaceObject.__)('Image size'),
  35489. value: slug,
  35490. options: imageSizeOptions,
  35491. onChange: onChangeImage
  35492. }), isResizable && (0,external_wp_element_namespaceObject.createElement)("div", {
  35493. className: "block-editor-image-size-control"
  35494. }, (0,external_wp_element_namespaceObject.createElement)("p", {
  35495. className: "block-editor-image-size-control__row"
  35496. }, (0,external_wp_i18n_namespaceObject.__)('Image dimensions')), (0,external_wp_element_namespaceObject.createElement)("div", {
  35497. className: "block-editor-image-size-control__row"
  35498. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  35499. type: "number",
  35500. className: "block-editor-image-size-control__width",
  35501. label: (0,external_wp_i18n_namespaceObject.__)('Width'),
  35502. value: currentWidth,
  35503. min: 1,
  35504. onChange: value => updateDimension('width', value)
  35505. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  35506. type: "number",
  35507. className: "block-editor-image-size-control__height",
  35508. label: (0,external_wp_i18n_namespaceObject.__)('Height'),
  35509. value: currentHeight,
  35510. min: 1,
  35511. onChange: value => updateDimension('height', value)
  35512. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  35513. className: "block-editor-image-size-control__row"
  35514. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ButtonGroup, {
  35515. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Image size presets')
  35516. }, IMAGE_SIZE_PRESETS.map(scale => {
  35517. const scaledWidth = Math.round(imageWidth * (scale / 100));
  35518. const scaledHeight = Math.round(imageHeight * (scale / 100));
  35519. const isCurrent = currentWidth === scaledWidth && currentHeight === scaledHeight;
  35520. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  35521. key: scale,
  35522. isSmall: true,
  35523. variant: isCurrent ? 'primary' : undefined,
  35524. isPressed: isCurrent,
  35525. onClick: () => updateDimensions(scaledHeight, scaledWidth)
  35526. }, scale, "%");
  35527. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  35528. isSmall: true,
  35529. onClick: () => updateDimensions()
  35530. }, (0,external_wp_i18n_namespaceObject.__)('Reset')))));
  35531. }
  35532. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard-return.js
  35533. /**
  35534. * WordPress dependencies
  35535. */
  35536. const keyboardReturn = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  35537. xmlns: "http://www.w3.org/2000/svg",
  35538. viewBox: "-2 -2 24 24"
  35539. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  35540. 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"
  35541. }));
  35542. /* harmony default export */ var keyboard_return = (keyboardReturn);
  35543. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/settings-drawer.js
  35544. /**
  35545. * External dependencies
  35546. */
  35547. /**
  35548. * WordPress dependencies
  35549. */
  35550. const LinkControlSettingsDrawer = _ref => {
  35551. let {
  35552. value,
  35553. onChange = external_lodash_namespaceObject.noop,
  35554. settings
  35555. } = _ref;
  35556. if (!settings || !settings.length) {
  35557. return null;
  35558. }
  35559. const handleSettingChange = setting => newValue => {
  35560. onChange({ ...value,
  35561. [setting.id]: newValue
  35562. });
  35563. };
  35564. const theSettings = settings.map(setting => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  35565. className: "block-editor-link-control__setting",
  35566. key: setting.id,
  35567. label: setting.title,
  35568. onChange: handleSettingChange(setting),
  35569. checked: value ? !!value[setting.id] : false
  35570. }));
  35571. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  35572. className: "block-editor-link-control__settings"
  35573. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  35574. as: "legend"
  35575. }, (0,external_wp_i18n_namespaceObject.__)('Currently selected link settings')), theSettings);
  35576. };
  35577. /* harmony default export */ var settings_drawer = (LinkControlSettingsDrawer);
  35578. // EXTERNAL MODULE: ./node_modules/dom-scroll-into-view/lib/index.js
  35579. var dom_scroll_into_view_lib = __webpack_require__(5425);
  35580. var lib_default = /*#__PURE__*/__webpack_require__.n(dom_scroll_into_view_lib);
  35581. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/index.js
  35582. /**
  35583. * External dependencies
  35584. */
  35585. /**
  35586. * WordPress dependencies
  35587. */
  35588. /**
  35589. * Internal dependencies
  35590. */
  35591. class URLInput extends external_wp_element_namespaceObject.Component {
  35592. constructor(props) {
  35593. super(props);
  35594. this.onChange = this.onChange.bind(this);
  35595. this.onFocus = this.onFocus.bind(this);
  35596. this.onKeyDown = this.onKeyDown.bind(this);
  35597. this.selectLink = this.selectLink.bind(this);
  35598. this.handleOnClick = this.handleOnClick.bind(this);
  35599. this.bindSuggestionNode = this.bindSuggestionNode.bind(this);
  35600. this.autocompleteRef = props.autocompleteRef || (0,external_wp_element_namespaceObject.createRef)();
  35601. this.inputRef = (0,external_wp_element_namespaceObject.createRef)();
  35602. this.updateSuggestions = (0,external_lodash_namespaceObject.debounce)(this.updateSuggestions.bind(this), 200);
  35603. this.suggestionNodes = [];
  35604. this.isUpdatingSuggestions = false;
  35605. this.state = {
  35606. suggestions: [],
  35607. showSuggestions: false,
  35608. selectedSuggestion: null,
  35609. suggestionsListboxId: '',
  35610. suggestionOptionIdPrefix: ''
  35611. };
  35612. }
  35613. componentDidUpdate(prevProps) {
  35614. const {
  35615. showSuggestions,
  35616. selectedSuggestion
  35617. } = this.state;
  35618. const {
  35619. value,
  35620. __experimentalShowInitialSuggestions = false
  35621. } = this.props; // Only have to worry about scrolling selected suggestion into view
  35622. // when already expanded.
  35623. if (showSuggestions && selectedSuggestion !== null && this.suggestionNodes[selectedSuggestion] && !this.scrollingIntoView) {
  35624. this.scrollingIntoView = true;
  35625. lib_default()(this.suggestionNodes[selectedSuggestion], this.autocompleteRef.current, {
  35626. onlyScrollIfNeeded: true
  35627. });
  35628. this.props.setTimeout(() => {
  35629. this.scrollingIntoView = false;
  35630. }, 100);
  35631. } // Update suggestions when the value changes.
  35632. if (prevProps.value !== value && !this.props.disableSuggestions && !this.isUpdatingSuggestions) {
  35633. if (value !== null && value !== void 0 && value.length) {
  35634. // If the new value is not empty we need to update with suggestions for it.
  35635. this.updateSuggestions(value);
  35636. } else if (__experimentalShowInitialSuggestions) {
  35637. // If the new value is empty and we can show initial suggestions, then show initial suggestions.
  35638. this.updateSuggestions();
  35639. }
  35640. }
  35641. }
  35642. componentDidMount() {
  35643. if (this.shouldShowInitialSuggestions()) {
  35644. this.updateSuggestions();
  35645. }
  35646. }
  35647. componentWillUnmount() {
  35648. var _this$suggestionsRequ, _this$suggestionsRequ2;
  35649. (_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);
  35650. delete this.suggestionsRequest;
  35651. }
  35652. bindSuggestionNode(index) {
  35653. return ref => {
  35654. this.suggestionNodes[index] = ref;
  35655. };
  35656. }
  35657. shouldShowInitialSuggestions() {
  35658. const {
  35659. suggestions
  35660. } = this.state;
  35661. const {
  35662. __experimentalShowInitialSuggestions = false,
  35663. value
  35664. } = this.props;
  35665. return !this.isUpdatingSuggestions && __experimentalShowInitialSuggestions && !(value && value.length) && !(suggestions && suggestions.length);
  35666. }
  35667. updateSuggestions() {
  35668. var _value;
  35669. let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  35670. const {
  35671. __experimentalFetchLinkSuggestions: fetchLinkSuggestions,
  35672. __experimentalHandleURLSuggestions: handleURLSuggestions
  35673. } = this.props;
  35674. if (!fetchLinkSuggestions) {
  35675. return;
  35676. } // Initial suggestions may only show if there is no value
  35677. // (note: this includes whitespace).
  35678. const isInitialSuggestions = !((_value = value) !== null && _value !== void 0 && _value.length); // Trim only now we've determined whether or not it originally had a "length"
  35679. // (even if that value was all whitespace).
  35680. value = value.trim(); // Allow a suggestions request if:
  35681. // - there are at least 2 characters in the search input (except manual searches where
  35682. // search input length is not required to trigger a fetch)
  35683. // - this is a direct entry (eg: a URL)
  35684. if (!isInitialSuggestions && (value.length < 2 || !handleURLSuggestions && (0,external_wp_url_namespaceObject.isURL)(value))) {
  35685. this.setState({
  35686. showSuggestions: false,
  35687. selectedSuggestion: null,
  35688. loading: false
  35689. });
  35690. return;
  35691. }
  35692. this.isUpdatingSuggestions = true;
  35693. this.setState({
  35694. selectedSuggestion: null,
  35695. loading: true
  35696. });
  35697. const request = fetchLinkSuggestions(value, {
  35698. isInitialSuggestions
  35699. });
  35700. request.then(suggestions => {
  35701. // A fetch Promise doesn't have an abort option. It's mimicked by
  35702. // comparing the request reference in on the instance, which is
  35703. // reset or deleted on subsequent requests or unmounting.
  35704. if (this.suggestionsRequest !== request) {
  35705. return;
  35706. }
  35707. this.setState({
  35708. suggestions,
  35709. loading: false,
  35710. showSuggestions: !!suggestions.length
  35711. });
  35712. if (!!suggestions.length) {
  35713. this.props.debouncedSpeak((0,external_wp_i18n_namespaceObject.sprintf)(
  35714. /* translators: %s: number of results. */
  35715. (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');
  35716. } else {
  35717. this.props.debouncedSpeak((0,external_wp_i18n_namespaceObject.__)('No results.'), 'assertive');
  35718. }
  35719. this.isUpdatingSuggestions = false;
  35720. }).catch(() => {
  35721. if (this.suggestionsRequest === request) {
  35722. this.setState({
  35723. loading: false
  35724. });
  35725. this.isUpdatingSuggestions = false;
  35726. }
  35727. }); // Note that this assignment is handled *before* the async search request
  35728. // as a Promise always resolves on the next tick of the event loop.
  35729. this.suggestionsRequest = request;
  35730. }
  35731. onChange(event) {
  35732. const inputValue = event.target.value;
  35733. this.props.onChange(inputValue);
  35734. if (!this.props.disableSuggestions) {
  35735. this.updateSuggestions(inputValue);
  35736. }
  35737. }
  35738. onFocus() {
  35739. const {
  35740. suggestions
  35741. } = this.state;
  35742. const {
  35743. disableSuggestions,
  35744. value
  35745. } = 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
  35746. // Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)
  35747. if (value && !disableSuggestions && !this.isUpdatingSuggestions && !(suggestions && suggestions.length)) {
  35748. // Ensure the suggestions are updated with the current input value.
  35749. this.updateSuggestions(value);
  35750. }
  35751. }
  35752. onKeyDown(event) {
  35753. const {
  35754. showSuggestions,
  35755. selectedSuggestion,
  35756. suggestions,
  35757. loading
  35758. } = this.state; // If the suggestions are not shown or loading, we shouldn't handle the arrow keys
  35759. // We shouldn't preventDefault to allow block arrow keys navigation.
  35760. if (!showSuggestions || !suggestions.length || loading) {
  35761. // In the Windows version of Firefox the up and down arrows don't move the caret
  35762. // within an input field like they do for Mac Firefox/Chrome/Safari. This causes
  35763. // a form of focus trapping that is disruptive to the user experience. This disruption
  35764. // only happens if the caret is not in the first or last position in the text input.
  35765. // See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747
  35766. switch (event.keyCode) {
  35767. // When UP is pressed, if the caret is at the start of the text, move it to the 0
  35768. // position.
  35769. case external_wp_keycodes_namespaceObject.UP:
  35770. {
  35771. if (0 !== event.target.selectionStart) {
  35772. event.preventDefault(); // Set the input caret to position 0.
  35773. event.target.setSelectionRange(0, 0);
  35774. }
  35775. break;
  35776. }
  35777. // When DOWN is pressed, if the caret is not at the end of the text, move it to the
  35778. // last position.
  35779. case external_wp_keycodes_namespaceObject.DOWN:
  35780. {
  35781. if (this.props.value.length !== event.target.selectionStart) {
  35782. event.preventDefault(); // Set the input caret to the last position.
  35783. event.target.setSelectionRange(this.props.value.length, this.props.value.length);
  35784. }
  35785. break;
  35786. }
  35787. // Submitting while loading should trigger onSubmit.
  35788. case external_wp_keycodes_namespaceObject.ENTER:
  35789. {
  35790. if (this.props.onSubmit) {
  35791. this.props.onSubmit(null, event);
  35792. }
  35793. break;
  35794. }
  35795. }
  35796. return;
  35797. }
  35798. const suggestion = this.state.suggestions[this.state.selectedSuggestion];
  35799. switch (event.keyCode) {
  35800. case external_wp_keycodes_namespaceObject.UP:
  35801. {
  35802. event.preventDefault();
  35803. const previousIndex = !selectedSuggestion ? suggestions.length - 1 : selectedSuggestion - 1;
  35804. this.setState({
  35805. selectedSuggestion: previousIndex
  35806. });
  35807. break;
  35808. }
  35809. case external_wp_keycodes_namespaceObject.DOWN:
  35810. {
  35811. event.preventDefault();
  35812. const nextIndex = selectedSuggestion === null || selectedSuggestion === suggestions.length - 1 ? 0 : selectedSuggestion + 1;
  35813. this.setState({
  35814. selectedSuggestion: nextIndex
  35815. });
  35816. break;
  35817. }
  35818. case external_wp_keycodes_namespaceObject.TAB:
  35819. {
  35820. if (this.state.selectedSuggestion !== null) {
  35821. this.selectLink(suggestion); // Announce a link has been selected when tabbing away from the input field.
  35822. this.props.speak((0,external_wp_i18n_namespaceObject.__)('Link selected.'));
  35823. }
  35824. break;
  35825. }
  35826. case external_wp_keycodes_namespaceObject.ENTER:
  35827. {
  35828. if (this.state.selectedSuggestion !== null) {
  35829. this.selectLink(suggestion);
  35830. if (this.props.onSubmit) {
  35831. this.props.onSubmit(suggestion, event);
  35832. }
  35833. } else if (this.props.onSubmit) {
  35834. this.props.onSubmit(null, event);
  35835. }
  35836. break;
  35837. }
  35838. }
  35839. }
  35840. selectLink(suggestion) {
  35841. this.props.onChange(suggestion.url, suggestion);
  35842. this.setState({
  35843. selectedSuggestion: null,
  35844. showSuggestions: false
  35845. });
  35846. }
  35847. handleOnClick(suggestion) {
  35848. this.selectLink(suggestion); // Move focus to the input field when a link suggestion is clicked.
  35849. this.inputRef.current.focus();
  35850. }
  35851. static getDerivedStateFromProps(_ref, _ref2) {
  35852. let {
  35853. value,
  35854. instanceId,
  35855. disableSuggestions,
  35856. __experimentalShowInitialSuggestions = false
  35857. } = _ref;
  35858. let {
  35859. showSuggestions
  35860. } = _ref2;
  35861. let shouldShowSuggestions = showSuggestions;
  35862. const hasValue = value && value.length;
  35863. if (!__experimentalShowInitialSuggestions && !hasValue) {
  35864. shouldShowSuggestions = false;
  35865. }
  35866. if (disableSuggestions === true) {
  35867. shouldShowSuggestions = false;
  35868. }
  35869. return {
  35870. showSuggestions: shouldShowSuggestions,
  35871. suggestionsListboxId: `block-editor-url-input-suggestions-${instanceId}`,
  35872. suggestionOptionIdPrefix: `block-editor-url-input-suggestion-${instanceId}`
  35873. };
  35874. }
  35875. render() {
  35876. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, this.renderControl(), this.renderSuggestions());
  35877. }
  35878. renderControl() {
  35879. const {
  35880. label,
  35881. className,
  35882. isFullWidth,
  35883. instanceId,
  35884. placeholder = (0,external_wp_i18n_namespaceObject.__)('Paste URL or type to search'),
  35885. __experimentalRenderControl: renderControl,
  35886. value = ''
  35887. } = this.props;
  35888. const {
  35889. loading,
  35890. showSuggestions,
  35891. selectedSuggestion,
  35892. suggestionsListboxId,
  35893. suggestionOptionIdPrefix
  35894. } = this.state;
  35895. const controlProps = {
  35896. id: `url-input-control-${instanceId}`,
  35897. label,
  35898. className: classnames_default()('block-editor-url-input', className, {
  35899. 'is-full-width': isFullWidth
  35900. })
  35901. };
  35902. const inputProps = {
  35903. value,
  35904. required: true,
  35905. className: 'block-editor-url-input__input',
  35906. type: 'text',
  35907. onChange: this.onChange,
  35908. onFocus: this.onFocus,
  35909. placeholder,
  35910. onKeyDown: this.onKeyDown,
  35911. role: 'combobox',
  35912. 'aria-label': (0,external_wp_i18n_namespaceObject.__)('URL'),
  35913. 'aria-expanded': showSuggestions,
  35914. 'aria-autocomplete': 'list',
  35915. 'aria-owns': suggestionsListboxId,
  35916. 'aria-activedescendant': selectedSuggestion !== null ? `${suggestionOptionIdPrefix}-${selectedSuggestion}` : undefined,
  35917. ref: this.inputRef
  35918. };
  35919. if (renderControl) {
  35920. return renderControl(controlProps, inputProps, loading);
  35921. }
  35922. 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));
  35923. }
  35924. renderSuggestions() {
  35925. const {
  35926. className,
  35927. __experimentalRenderSuggestions: renderSuggestions,
  35928. value = '',
  35929. __experimentalShowInitialSuggestions = false
  35930. } = this.props;
  35931. const {
  35932. showSuggestions,
  35933. suggestions,
  35934. selectedSuggestion,
  35935. suggestionsListboxId,
  35936. suggestionOptionIdPrefix,
  35937. loading
  35938. } = this.state;
  35939. const suggestionsListProps = {
  35940. id: suggestionsListboxId,
  35941. ref: this.autocompleteRef,
  35942. role: 'listbox'
  35943. };
  35944. const buildSuggestionItemProps = (suggestion, index) => {
  35945. return {
  35946. role: 'option',
  35947. tabIndex: '-1',
  35948. id: `${suggestionOptionIdPrefix}-${index}`,
  35949. ref: this.bindSuggestionNode(index),
  35950. 'aria-selected': index === selectedSuggestion
  35951. };
  35952. };
  35953. if ((0,external_lodash_namespaceObject.isFunction)(renderSuggestions) && showSuggestions && !!suggestions.length) {
  35954. return renderSuggestions({
  35955. suggestions,
  35956. selectedSuggestion,
  35957. suggestionsListProps,
  35958. buildSuggestionItemProps,
  35959. isLoading: loading,
  35960. handleSuggestionClick: this.handleOnClick,
  35961. isInitialSuggestions: __experimentalShowInitialSuggestions && !(value && value.length)
  35962. });
  35963. }
  35964. if (!(0,external_lodash_namespaceObject.isFunction)(renderSuggestions) && showSuggestions && !!suggestions.length) {
  35965. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  35966. position: "bottom",
  35967. noArrow: true,
  35968. focusOnMount: false
  35969. }, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, suggestionsListProps, {
  35970. className: classnames_default()('block-editor-url-input__suggestions', `${className}__suggestions`)
  35971. }), suggestions.map((suggestion, index) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, buildSuggestionItemProps(suggestion, index), {
  35972. key: suggestion.id,
  35973. className: classnames_default()('block-editor-url-input__suggestion', {
  35974. 'is-selected': index === selectedSuggestion
  35975. }),
  35976. onClick: () => this.handleOnClick(suggestion)
  35977. }), suggestion.title))));
  35978. }
  35979. return null;
  35980. }
  35981. }
  35982. /**
  35983. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md
  35984. */
  35985. /* 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) => {
  35986. // If a link suggestions handler is already provided then
  35987. // bail.
  35988. if ((0,external_lodash_namespaceObject.isFunction)(props.__experimentalFetchLinkSuggestions)) {
  35989. return;
  35990. }
  35991. const {
  35992. getSettings
  35993. } = select(store);
  35994. return {
  35995. __experimentalFetchLinkSuggestions: getSettings().__experimentalFetchLinkSuggestions
  35996. };
  35997. }))(URLInput));
  35998. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-create-button.js
  35999. /**
  36000. * External dependencies
  36001. */
  36002. /**
  36003. * WordPress dependencies
  36004. */
  36005. const LinkControlSearchCreate = _ref => {
  36006. let {
  36007. searchTerm,
  36008. onClick,
  36009. itemProps,
  36010. isSelected,
  36011. buttonText
  36012. } = _ref;
  36013. if (!searchTerm) {
  36014. return null;
  36015. }
  36016. let text;
  36017. if (buttonText) {
  36018. text = (0,external_lodash_namespaceObject.isFunction)(buttonText) ? buttonText(searchTerm) : buttonText;
  36019. } else {
  36020. text = (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(
  36021. /* translators: %s: search term. */
  36022. (0,external_wp_i18n_namespaceObject.__)('Create: <mark>%s</mark>'), searchTerm), {
  36023. mark: (0,external_wp_element_namespaceObject.createElement)("mark", null)
  36024. });
  36025. }
  36026. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, itemProps, {
  36027. className: classnames_default()('block-editor-link-control__search-create block-editor-link-control__search-item', {
  36028. 'is-selected': isSelected
  36029. }),
  36030. onClick: onClick
  36031. }), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  36032. className: "block-editor-link-control__search-item-icon",
  36033. icon: library_plus
  36034. }), (0,external_wp_element_namespaceObject.createElement)("span", {
  36035. className: "block-editor-link-control__search-item-header"
  36036. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  36037. className: "block-editor-link-control__search-item-title"
  36038. }, text)));
  36039. };
  36040. /* harmony default export */ var search_create_button = (LinkControlSearchCreate);
  36041. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/globe.js
  36042. /**
  36043. * WordPress dependencies
  36044. */
  36045. const globe = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  36046. xmlns: "http://www.w3.org/2000/svg",
  36047. viewBox: "0 0 24 24"
  36048. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  36049. 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"
  36050. }));
  36051. /* harmony default export */ var library_globe = (globe);
  36052. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-item.js
  36053. /**
  36054. * External dependencies
  36055. */
  36056. /**
  36057. * WordPress dependencies
  36058. */
  36059. const LinkControlSearchItem = _ref => {
  36060. let {
  36061. itemProps,
  36062. suggestion,
  36063. isSelected = false,
  36064. onClick,
  36065. isURL = false,
  36066. searchTerm = '',
  36067. shouldShowType = false
  36068. } = _ref;
  36069. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, itemProps, {
  36070. onClick: onClick,
  36071. className: classnames_default()('block-editor-link-control__search-item', {
  36072. 'is-selected': isSelected,
  36073. 'is-url': isURL,
  36074. 'is-entity': !isURL
  36075. })
  36076. }), isURL && (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  36077. className: "block-editor-link-control__search-item-icon",
  36078. icon: library_globe
  36079. }), (0,external_wp_element_namespaceObject.createElement)("span", {
  36080. className: "block-editor-link-control__search-item-header"
  36081. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  36082. className: "block-editor-link-control__search-item-title"
  36083. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextHighlight, {
  36084. text: suggestion.title,
  36085. highlight: searchTerm
  36086. })), (0,external_wp_element_namespaceObject.createElement)("span", {
  36087. "aria-hidden": !isURL,
  36088. className: "block-editor-link-control__search-item-info"
  36089. }, !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", {
  36090. className: "block-editor-link-control__search-item-type"
  36091. }, getVisualTypeName(suggestion)));
  36092. };
  36093. function getVisualTypeName(suggestion) {
  36094. if (suggestion.isFrontPage) {
  36095. return 'front page';
  36096. } // Rename 'post_tag' to 'tag'. Ideally, the API would return the localised CPT or taxonomy label.
  36097. return suggestion.type === 'post_tag' ? 'tag' : suggestion.type;
  36098. }
  36099. /* harmony default export */ var search_item = (LinkControlSearchItem);
  36100. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/constants.js
  36101. /**
  36102. * WordPress dependencies
  36103. */
  36104. // Used as a unique identifier for the "Create" option within search results.
  36105. // Used to help distinguish the "Create" suggestion within the search results in
  36106. // order to handle it as a unique case.
  36107. const CREATE_TYPE = '__CREATE__';
  36108. const DEFAULT_LINK_SETTINGS = [{
  36109. id: 'opensInNewTab',
  36110. title: (0,external_wp_i18n_namespaceObject.__)('Open in new tab')
  36111. }];
  36112. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-results.js
  36113. /**
  36114. * WordPress dependencies
  36115. */
  36116. /**
  36117. * External dependencies
  36118. */
  36119. /**
  36120. * Internal dependencies
  36121. */
  36122. function LinkControlSearchResults(_ref) {
  36123. let {
  36124. instanceId,
  36125. withCreateSuggestion,
  36126. currentInputValue,
  36127. handleSuggestionClick,
  36128. suggestionsListProps,
  36129. buildSuggestionItemProps,
  36130. suggestions,
  36131. selectedSuggestion,
  36132. isLoading,
  36133. isInitialSuggestions,
  36134. createSuggestionButtonText,
  36135. suggestionsQuery
  36136. } = _ref;
  36137. const resultsListClasses = classnames_default()('block-editor-link-control__search-results', {
  36138. 'is-loading': isLoading
  36139. });
  36140. const directLinkEntryTypes = ['url', 'mailto', 'tel', 'internal'];
  36141. const isSingleDirectEntryResult = suggestions.length === 1 && directLinkEntryTypes.includes(suggestions[0].type.toLowerCase());
  36142. const shouldShowCreateSuggestion = withCreateSuggestion && !isSingleDirectEntryResult && !isInitialSuggestions; // If the query has a specified type, then we can skip showing them in the result. See #24839.
  36143. const shouldShowSuggestionsTypes = !(suggestionsQuery !== null && suggestionsQuery !== void 0 && suggestionsQuery.type); // According to guidelines aria-label should be added if the label
  36144. // itself is not visible.
  36145. // See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role
  36146. const searchResultsLabelId = `block-editor-link-control-search-results-label-${instanceId}`;
  36147. const labelText = isInitialSuggestions ? (0,external_wp_i18n_namespaceObject.__)('Recently updated') : (0,external_wp_i18n_namespaceObject.sprintf)(
  36148. /* translators: %s: search term. */
  36149. (0,external_wp_i18n_namespaceObject.__)('Search results for "%s"'), currentInputValue); // VisuallyHidden rightly doesn't accept custom classNames
  36150. // so we conditionally render it as a wrapper to visually hide the label
  36151. // when that is required.
  36152. const searchResultsLabel = (0,external_wp_element_namespaceObject.createElement)(isInitialSuggestions ? external_wp_element_namespaceObject.Fragment : external_wp_components_namespaceObject.VisuallyHidden, {}, // Empty props.
  36153. (0,external_wp_element_namespaceObject.createElement)("span", {
  36154. className: "block-editor-link-control__search-results-label",
  36155. id: searchResultsLabelId
  36156. }, labelText));
  36157. return (0,external_wp_element_namespaceObject.createElement)("div", {
  36158. className: "block-editor-link-control__search-results-wrapper"
  36159. }, searchResultsLabel, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, suggestionsListProps, {
  36160. className: resultsListClasses,
  36161. "aria-labelledby": searchResultsLabelId
  36162. }), suggestions.map((suggestion, index) => {
  36163. if (shouldShowCreateSuggestion && CREATE_TYPE === suggestion.type) {
  36164. return (0,external_wp_element_namespaceObject.createElement)(search_create_button, {
  36165. searchTerm: currentInputValue,
  36166. buttonText: createSuggestionButtonText,
  36167. onClick: () => handleSuggestionClick(suggestion) // Intentionally only using `type` here as
  36168. // the constant is enough to uniquely
  36169. // identify the single "CREATE" suggestion.
  36170. ,
  36171. key: suggestion.type,
  36172. itemProps: buildSuggestionItemProps(suggestion, index),
  36173. isSelected: index === selectedSuggestion
  36174. });
  36175. } // If we're not handling "Create" suggestions above then
  36176. // we don't want them in the main results so exit early.
  36177. if (CREATE_TYPE === suggestion.type) {
  36178. return null;
  36179. }
  36180. return (0,external_wp_element_namespaceObject.createElement)(search_item, {
  36181. key: `${suggestion.id}-${suggestion.type}`,
  36182. itemProps: buildSuggestionItemProps(suggestion, index),
  36183. suggestion: suggestion,
  36184. index: index,
  36185. onClick: () => {
  36186. handleSuggestionClick(suggestion);
  36187. },
  36188. isSelected: index === selectedSuggestion,
  36189. isURL: directLinkEntryTypes.includes(suggestion.type.toLowerCase()),
  36190. searchTerm: currentInputValue,
  36191. shouldShowType: shouldShowSuggestionsTypes,
  36192. isFrontPage: suggestion === null || suggestion === void 0 ? void 0 : suggestion.isFrontPage
  36193. });
  36194. })));
  36195. }
  36196. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/is-url-like.js
  36197. /**
  36198. * External dependencies
  36199. */
  36200. /**
  36201. * WordPress dependencies
  36202. */
  36203. /**
  36204. * Determines whether a given value could be a URL. Note this does not
  36205. * guarantee the value is a URL only that it looks like it might be one. For
  36206. * example, just because a string has `www.` in it doesn't make it a URL,
  36207. * but it does make it highly likely that it will be so in the context of
  36208. * creating a link it makes sense to treat it like one.
  36209. *
  36210. * @param {string} val the candidate for being URL-like (or not).
  36211. *
  36212. * @return {boolean} whether or not the value is potentially a URL.
  36213. */
  36214. function isURLLike(val) {
  36215. const isInternal = (0,external_lodash_namespaceObject.startsWith)(val, '#');
  36216. return (0,external_wp_url_namespaceObject.isURL)(val) || val && val.includes('www.') || isInternal;
  36217. }
  36218. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-search-handler.js
  36219. /**
  36220. * WordPress dependencies
  36221. */
  36222. /**
  36223. * External dependencies
  36224. */
  36225. /**
  36226. * Internal dependencies
  36227. */
  36228. const handleNoop = () => Promise.resolve([]);
  36229. const handleDirectEntry = val => {
  36230. let type = 'URL';
  36231. const protocol = (0,external_wp_url_namespaceObject.getProtocol)(val) || '';
  36232. if (protocol.includes('mailto')) {
  36233. type = 'mailto';
  36234. }
  36235. if (protocol.includes('tel')) {
  36236. type = 'tel';
  36237. }
  36238. if ((0,external_lodash_namespaceObject.startsWith)(val, '#')) {
  36239. type = 'internal';
  36240. }
  36241. return Promise.resolve([{
  36242. id: val,
  36243. title: val,
  36244. url: type === 'URL' ? (0,external_wp_url_namespaceObject.prependHTTP)(val) : val,
  36245. type
  36246. }]);
  36247. };
  36248. const handleEntitySearch = async (val, suggestionsQuery, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion, pageOnFront) => {
  36249. const {
  36250. isInitialSuggestions
  36251. } = suggestionsQuery;
  36252. let resultsIncludeFrontPage = false;
  36253. let results = await Promise.all([fetchSearchSuggestions(val, suggestionsQuery), directEntryHandler(val)]); // Identify front page and update type to match.
  36254. results[0] = results[0].map(result => {
  36255. if (Number(result.id) === pageOnFront) {
  36256. resultsIncludeFrontPage = true;
  36257. result.isFrontPage = true;
  36258. return result;
  36259. }
  36260. return result;
  36261. });
  36262. const couldBeURL = !val.includes(' '); // If it's potentially a URL search then concat on a URL search suggestion
  36263. // just for good measure. That way once the actual results run out we always
  36264. // have a URL option to fallback on.
  36265. if (!resultsIncludeFrontPage && couldBeURL && withURLSuggestion && !isInitialSuggestions) {
  36266. results = results[0].concat(results[1]);
  36267. } else {
  36268. results = results[0];
  36269. } // If displaying initial suggestions just return plain results.
  36270. if (isInitialSuggestions) {
  36271. return results;
  36272. } // Here we append a faux suggestion to represent a "CREATE" option. This
  36273. // is detected in the rendering of the search results and handled as a
  36274. // special case. This is currently necessary because the suggestions
  36275. // dropdown will only appear if there are valid suggestions and
  36276. // therefore unless the create option is a suggestion it will not
  36277. // display in scenarios where there are no results returned from the
  36278. // API. In addition promoting CREATE to a first class suggestion affords
  36279. // the a11y benefits afforded by `URLInput` to all suggestions (eg:
  36280. // keyboard handling, ARIA roles...etc).
  36281. //
  36282. // Note also that the value of the `title` and `url` properties must correspond
  36283. // to the text value of the `<input>`. This is because `title` is used
  36284. // when creating the suggestion. Similarly `url` is used when using keyboard to select
  36285. // the suggestion (the <form> `onSubmit` handler falls-back to `url`).
  36286. return isURLLike(val) || !withCreateSuggestion ? results : results.concat({
  36287. // the `id` prop is intentionally ommitted here because it
  36288. // is never exposed as part of the component's public API.
  36289. // see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.
  36290. title: val,
  36291. // Must match the existing `<input>`s text value.
  36292. url: val,
  36293. // Must match the existing `<input>`s text value.
  36294. type: CREATE_TYPE
  36295. });
  36296. };
  36297. function useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion) {
  36298. const {
  36299. fetchSearchSuggestions,
  36300. pageOnFront
  36301. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  36302. const {
  36303. getSettings
  36304. } = select(store);
  36305. return {
  36306. pageOnFront: getSettings().pageOnFront,
  36307. fetchSearchSuggestions: getSettings().__experimentalFetchLinkSuggestions
  36308. };
  36309. }, []);
  36310. const directEntryHandler = allowDirectEntry ? handleDirectEntry : handleNoop;
  36311. return (0,external_wp_element_namespaceObject.useCallback)((val, _ref) => {
  36312. let {
  36313. isInitialSuggestions
  36314. } = _ref;
  36315. return isURLLike(val) ? directEntryHandler(val, {
  36316. isInitialSuggestions
  36317. }) : handleEntitySearch(val, { ...suggestionsQuery,
  36318. isInitialSuggestions
  36319. }, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion, pageOnFront);
  36320. }, [directEntryHandler, fetchSearchSuggestions, withCreateSuggestion]);
  36321. }
  36322. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-input.js
  36323. /**
  36324. * External dependencies
  36325. */
  36326. /**
  36327. * WordPress dependencies
  36328. */
  36329. /**
  36330. * Internal dependencies
  36331. */
  36332. // Must be a function as otherwise URLInput will default
  36333. // to the fetchLinkSuggestions passed in block editor settings
  36334. // which will cause an unintended http request.
  36335. const noopSearchHandler = () => Promise.resolve([]);
  36336. const LinkControlSearchInput = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => {
  36337. let {
  36338. value,
  36339. children,
  36340. currentLink = {},
  36341. className = null,
  36342. placeholder = null,
  36343. withCreateSuggestion = false,
  36344. onCreateSuggestion = external_lodash_namespaceObject.noop,
  36345. onChange = external_lodash_namespaceObject.noop,
  36346. onSelect = external_lodash_namespaceObject.noop,
  36347. showSuggestions = true,
  36348. renderSuggestions = props => (0,external_wp_element_namespaceObject.createElement)(LinkControlSearchResults, props),
  36349. fetchSuggestions = null,
  36350. allowDirectEntry = true,
  36351. showInitialSuggestions = false,
  36352. suggestionsQuery = {},
  36353. withURLSuggestion = true,
  36354. createSuggestionButtonText,
  36355. useLabel = false
  36356. } = _ref;
  36357. const genericSearchHandler = useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion);
  36358. const searchHandler = showSuggestions ? fetchSuggestions || genericSearchHandler : noopSearchHandler;
  36359. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(LinkControlSearchInput);
  36360. const [focusedSuggestion, setFocusedSuggestion] = (0,external_wp_element_namespaceObject.useState)();
  36361. /**
  36362. * Handles the user moving between different suggestions. Does not handle
  36363. * choosing an individual item.
  36364. *
  36365. * @param {string} selection the url of the selected suggestion.
  36366. * @param {Object} suggestion the suggestion object.
  36367. */
  36368. const onInputChange = (selection, suggestion) => {
  36369. onChange(selection);
  36370. setFocusedSuggestion(suggestion);
  36371. };
  36372. const handleRenderSuggestions = props => renderSuggestions({ ...props,
  36373. instanceId,
  36374. withCreateSuggestion,
  36375. currentInputValue: value,
  36376. createSuggestionButtonText,
  36377. suggestionsQuery,
  36378. handleSuggestionClick: suggestion => {
  36379. if (props.handleSuggestionClick) {
  36380. props.handleSuggestionClick(suggestion);
  36381. }
  36382. onSuggestionSelected(suggestion);
  36383. }
  36384. });
  36385. const onSuggestionSelected = async selectedSuggestion => {
  36386. let suggestion = selectedSuggestion;
  36387. if (CREATE_TYPE === selectedSuggestion.type) {
  36388. // Create a new page and call onSelect with the output from the onCreateSuggestion callback.
  36389. try {
  36390. var _suggestion;
  36391. suggestion = await onCreateSuggestion(selectedSuggestion.title);
  36392. if ((_suggestion = suggestion) !== null && _suggestion !== void 0 && _suggestion.url) {
  36393. onSelect(suggestion);
  36394. }
  36395. } catch (e) {}
  36396. return;
  36397. }
  36398. if (allowDirectEntry || suggestion && Object.keys(suggestion).length >= 1) {
  36399. onSelect( // Some direct entries don't have types or IDs, and we still need to clear the previous ones.
  36400. { ...(0,external_lodash_namespaceObject.omit)(currentLink, 'id', 'url'),
  36401. ...suggestion
  36402. }, suggestion);
  36403. }
  36404. };
  36405. const inputClasses = classnames_default()(className, {
  36406. 'has-no-label': !useLabel
  36407. });
  36408. return (0,external_wp_element_namespaceObject.createElement)("div", {
  36409. className: "block-editor-link-control__search-input-container"
  36410. }, (0,external_wp_element_namespaceObject.createElement)(url_input, {
  36411. label: useLabel ? 'URL' : undefined,
  36412. className: inputClasses,
  36413. value: value,
  36414. onChange: onInputChange,
  36415. placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : (0,external_wp_i18n_namespaceObject.__)('Search or type url'),
  36416. __experimentalRenderSuggestions: showSuggestions ? handleRenderSuggestions : null,
  36417. __experimentalFetchLinkSuggestions: searchHandler,
  36418. __experimentalHandleURLSuggestions: true,
  36419. __experimentalShowInitialSuggestions: showInitialSuggestions,
  36420. onSubmit: (suggestion, event) => {
  36421. var _value$trim;
  36422. const hasSuggestion = suggestion || focusedSuggestion; // If there is no suggestion and the value (ie: any manually entered URL) is empty
  36423. // then don't allow submission otherwise we get empty links.
  36424. if (!hasSuggestion && !(value !== null && value !== void 0 && (_value$trim = value.trim()) !== null && _value$trim !== void 0 && _value$trim.length)) {
  36425. event.preventDefault();
  36426. } else {
  36427. onSuggestionSelected(hasSuggestion || {
  36428. url: value
  36429. });
  36430. }
  36431. },
  36432. ref: ref
  36433. }), children);
  36434. });
  36435. /* harmony default export */ var search_input = (LinkControlSearchInput);
  36436. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/info.js
  36437. /**
  36438. * WordPress dependencies
  36439. */
  36440. const info = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  36441. xmlns: "http://www.w3.org/2000/svg",
  36442. viewBox: "0 0 24 24"
  36443. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  36444. 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"
  36445. }));
  36446. /* harmony default export */ var library_info = (info);
  36447. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pencil.js
  36448. /**
  36449. * WordPress dependencies
  36450. */
  36451. const pencil = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  36452. xmlns: "http://www.w3.org/2000/svg",
  36453. viewBox: "0 0 24 24"
  36454. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  36455. 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"
  36456. }));
  36457. /* harmony default export */ var library_pencil = (pencil);
  36458. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/edit.js
  36459. /**
  36460. * Internal dependencies
  36461. */
  36462. /* harmony default export */ var library_edit = (library_pencil);
  36463. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/viewer-slot.js
  36464. /**
  36465. * WordPress dependencies
  36466. */
  36467. const {
  36468. Slot: ViewerSlot,
  36469. Fill: ViewerFill
  36470. } = (0,external_wp_components_namespaceObject.createSlotFill)('BlockEditorLinkControlViewer');
  36471. /* harmony default export */ var viewer_slot = ((/* unused pure expression or super */ null && (ViewerSlot)));
  36472. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-rich-url-data.js
  36473. /**
  36474. * Internal dependencies
  36475. */
  36476. /**
  36477. * WordPress dependencies
  36478. */
  36479. function use_rich_url_data_reducer(state, action) {
  36480. switch (action.type) {
  36481. case 'RESOLVED':
  36482. return { ...state,
  36483. isFetching: false,
  36484. richData: action.richData
  36485. };
  36486. case 'ERROR':
  36487. return { ...state,
  36488. isFetching: false,
  36489. richData: null
  36490. };
  36491. case 'LOADING':
  36492. return { ...state,
  36493. isFetching: true
  36494. };
  36495. default:
  36496. throw new Error(`Unexpected action type ${action.type}`);
  36497. }
  36498. }
  36499. function useRemoteUrlData(url) {
  36500. const [state, dispatch] = (0,external_wp_element_namespaceObject.useReducer)(use_rich_url_data_reducer, {
  36501. richData: null,
  36502. isFetching: false
  36503. });
  36504. const {
  36505. fetchRichUrlData
  36506. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  36507. const {
  36508. getSettings
  36509. } = select(store);
  36510. return {
  36511. fetchRichUrlData: getSettings().__experimentalFetchRichUrlData
  36512. };
  36513. }, []);
  36514. (0,external_wp_element_namespaceObject.useEffect)(() => {
  36515. // Only make the request if we have an actual URL
  36516. // and the fetching util is available. In some editors
  36517. // there may not be such a util.
  36518. if (url !== null && url !== void 0 && url.length && fetchRichUrlData && typeof AbortController !== 'undefined') {
  36519. dispatch({
  36520. type: 'LOADING'
  36521. });
  36522. const controller = new window.AbortController();
  36523. const signal = controller.signal;
  36524. fetchRichUrlData(url, {
  36525. signal
  36526. }).then(urlData => {
  36527. dispatch({
  36528. type: 'RESOLVED',
  36529. richData: urlData
  36530. });
  36531. }).catch(() => {
  36532. // Avoid setting state on unmounted component
  36533. if (!signal.aborted) {
  36534. dispatch({
  36535. type: 'ERROR'
  36536. });
  36537. }
  36538. }); // Cleanup: when the URL changes the abort the current request.
  36539. return () => {
  36540. controller.abort();
  36541. };
  36542. }
  36543. }, [url]);
  36544. return state;
  36545. }
  36546. /* harmony default export */ var use_rich_url_data = (useRemoteUrlData);
  36547. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/link-preview.js
  36548. /**
  36549. * External dependencies
  36550. */
  36551. /**
  36552. * WordPress dependencies
  36553. */
  36554. /**
  36555. * Internal dependencies
  36556. */
  36557. function LinkPreview(_ref) {
  36558. var _value$url;
  36559. let {
  36560. value,
  36561. onEditClick,
  36562. hasRichPreviews = false,
  36563. hasUnlinkControl = false,
  36564. onRemove
  36565. } = _ref;
  36566. // Avoid fetching if rich previews are not desired.
  36567. const showRichPreviews = hasRichPreviews ? value === null || value === void 0 ? void 0 : value.url : null;
  36568. const {
  36569. richData,
  36570. isFetching
  36571. } = use_rich_url_data(showRichPreviews); // Rich data may be an empty object so test for that.
  36572. const hasRichData = richData && Object.keys(richData).length;
  36573. const displayURL = value && (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURI)(value.url), 16) || '';
  36574. 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
  36575. const isEmptyURL = !(value !== null && value !== void 0 && (_value$url = value.url) !== null && _value$url !== void 0 && _value$url.length);
  36576. let icon;
  36577. if (richData !== null && richData !== void 0 && richData.icon) {
  36578. icon = (0,external_wp_element_namespaceObject.createElement)("img", {
  36579. src: richData === null || richData === void 0 ? void 0 : richData.icon,
  36580. alt: ""
  36581. });
  36582. } else if (isEmptyURL) {
  36583. icon = (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  36584. icon: library_info,
  36585. size: 32
  36586. });
  36587. } else {
  36588. icon = (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  36589. icon: library_globe
  36590. });
  36591. }
  36592. return (0,external_wp_element_namespaceObject.createElement)("div", {
  36593. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Currently selected'),
  36594. "aria-selected": "true",
  36595. className: classnames_default()('block-editor-link-control__search-item', {
  36596. 'is-current': true,
  36597. 'is-rich': hasRichData,
  36598. 'is-fetching': !!isFetching,
  36599. 'is-preview': true,
  36600. 'is-error': isEmptyURL
  36601. })
  36602. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  36603. className: "block-editor-link-control__search-item-top"
  36604. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  36605. className: "block-editor-link-control__search-item-header"
  36606. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  36607. className: classnames_default()('block-editor-link-control__search-item-icon', {
  36608. 'is-image': richData === null || richData === void 0 ? void 0 : richData.icon
  36609. })
  36610. }, icon), (0,external_wp_element_namespaceObject.createElement)("span", {
  36611. className: "block-editor-link-control__search-item-details"
  36612. }, !isEmptyURL ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  36613. className: "block-editor-link-control__search-item-title",
  36614. href: value.url
  36615. }, (0,external_wp_dom_namespaceObject.__unstableStripHTML)(displayTitle)), (value === null || value === void 0 ? void 0 : value.url) && (0,external_wp_element_namespaceObject.createElement)("span", {
  36616. className: "block-editor-link-control__search-item-info"
  36617. }, displayURL)) : (0,external_wp_element_namespaceObject.createElement)("span", {
  36618. className: "block-editor-link-control__search-item-error-notice"
  36619. }, (0,external_wp_i18n_namespaceObject.__)('Link is empty')))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  36620. icon: library_edit,
  36621. label: (0,external_wp_i18n_namespaceObject.__)('Edit'),
  36622. className: "block-editor-link-control__search-item-action",
  36623. onClick: onEditClick,
  36624. iconSize: 24
  36625. }), hasUnlinkControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  36626. icon: link_off,
  36627. label: (0,external_wp_i18n_namespaceObject.__)('Unlink'),
  36628. className: "block-editor-link-control__search-item-action block-editor-link-control__unlink",
  36629. onClick: onRemove,
  36630. iconSize: 24
  36631. }), (0,external_wp_element_namespaceObject.createElement)(ViewerSlot, {
  36632. fillProps: value
  36633. })), (hasRichData && ((richData === null || richData === void 0 ? void 0 : richData.image) || (richData === null || richData === void 0 ? void 0 : richData.description)) || isFetching) && (0,external_wp_element_namespaceObject.createElement)("div", {
  36634. className: "block-editor-link-control__search-item-bottom"
  36635. }, ((richData === null || richData === void 0 ? void 0 : richData.image) || isFetching) && (0,external_wp_element_namespaceObject.createElement)("div", {
  36636. "aria-hidden": !(richData !== null && richData !== void 0 && richData.image),
  36637. className: classnames_default()('block-editor-link-control__search-item-image', {
  36638. 'is-placeholder': !(richData !== null && richData !== void 0 && richData.image)
  36639. })
  36640. }, (richData === null || richData === void 0 ? void 0 : richData.image) && (0,external_wp_element_namespaceObject.createElement)("img", {
  36641. src: richData === null || richData === void 0 ? void 0 : richData.image,
  36642. alt: ""
  36643. })), ((richData === null || richData === void 0 ? void 0 : richData.description) || isFetching) && (0,external_wp_element_namespaceObject.createElement)("div", {
  36644. "aria-hidden": !(richData !== null && richData !== void 0 && richData.description),
  36645. className: classnames_default()('block-editor-link-control__search-item-description', {
  36646. 'is-placeholder': !(richData !== null && richData !== void 0 && richData.description)
  36647. })
  36648. }, (richData === null || richData === void 0 ? void 0 : richData.description) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
  36649. truncate: true,
  36650. numberOfLines: "2"
  36651. }, richData.description))));
  36652. }
  36653. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-create-page.js
  36654. /**
  36655. * WordPress dependencies
  36656. */
  36657. function useCreatePage(handleCreatePage) {
  36658. const cancelableCreateSuggestion = (0,external_wp_element_namespaceObject.useRef)();
  36659. const [isCreatingPage, setIsCreatingPage] = (0,external_wp_element_namespaceObject.useState)(false);
  36660. const [errorMessage, setErrorMessage] = (0,external_wp_element_namespaceObject.useState)(null);
  36661. const createPage = async function (suggestionTitle) {
  36662. setIsCreatingPage(true);
  36663. setErrorMessage(null);
  36664. try {
  36665. // Make cancellable in order that we can avoid setting State
  36666. // if the component unmounts during the call to `createSuggestion`
  36667. cancelableCreateSuggestion.current = makeCancelable( // Using Promise.resolve to allow createSuggestion to return a
  36668. // non-Promise based value.
  36669. Promise.resolve(handleCreatePage(suggestionTitle)));
  36670. return await cancelableCreateSuggestion.current.promise;
  36671. } catch (error) {
  36672. if (error && error.isCanceled) {
  36673. return; // bail if canceled to avoid setting state
  36674. }
  36675. setErrorMessage(error.message || (0,external_wp_i18n_namespaceObject.__)('An unknown error occurred during creation. Please try again.'));
  36676. throw error;
  36677. } finally {
  36678. setIsCreatingPage(false);
  36679. }
  36680. };
  36681. /**
  36682. * Handles cancelling any pending Promises that have been made cancelable.
  36683. */
  36684. (0,external_wp_element_namespaceObject.useEffect)(() => {
  36685. return () => {
  36686. // componentDidUnmount
  36687. if (cancelableCreateSuggestion.current) {
  36688. cancelableCreateSuggestion.current.cancel();
  36689. }
  36690. };
  36691. }, []);
  36692. return {
  36693. createPage,
  36694. isCreatingPage,
  36695. errorMessage
  36696. };
  36697. }
  36698. /**
  36699. * Creates a wrapper around a promise which allows it to be programmatically
  36700. * cancelled.
  36701. * See: https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html
  36702. *
  36703. * @param {Promise} promise the Promise to make cancelable
  36704. */
  36705. const makeCancelable = promise => {
  36706. let hasCanceled_ = false;
  36707. const wrappedPromise = new Promise((resolve, reject) => {
  36708. promise.then(val => hasCanceled_ ? reject({
  36709. isCanceled: true
  36710. }) : resolve(val), error => hasCanceled_ ? reject({
  36711. isCanceled: true
  36712. }) : reject(error));
  36713. });
  36714. return {
  36715. promise: wrappedPromise,
  36716. cancel() {
  36717. hasCanceled_ = true;
  36718. }
  36719. };
  36720. };
  36721. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/index.js
  36722. /**
  36723. * External dependencies
  36724. */
  36725. /**
  36726. * WordPress dependencies
  36727. */
  36728. /**
  36729. * Internal dependencies
  36730. */
  36731. /**
  36732. * Default properties associated with a link control value.
  36733. *
  36734. * @typedef WPLinkControlDefaultValue
  36735. *
  36736. * @property {string} url Link URL.
  36737. * @property {string=} title Link title.
  36738. * @property {boolean=} opensInNewTab Whether link should open in a new browser
  36739. * tab. This value is only assigned if not
  36740. * providing a custom `settings` prop.
  36741. */
  36742. /* eslint-disable jsdoc/valid-types */
  36743. /**
  36744. * Custom settings values associated with a link.
  36745. *
  36746. * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue
  36747. */
  36748. /* eslint-enable */
  36749. /**
  36750. * Custom settings values associated with a link.
  36751. *
  36752. * @typedef WPLinkControlSetting
  36753. *
  36754. * @property {string} id Identifier to use as property for setting value.
  36755. * @property {string} title Human-readable label to show in user interface.
  36756. */
  36757. /**
  36758. * Properties associated with a link control value, composed as a union of the
  36759. * default properties and any custom settings values.
  36760. *
  36761. * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue
  36762. */
  36763. /** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */
  36764. /**
  36765. * Properties associated with a search suggestion used within the LinkControl.
  36766. *
  36767. * @typedef WPLinkControlSuggestion
  36768. *
  36769. * @property {string} id Identifier to use to uniquely identify the suggestion.
  36770. * @property {string} type Identifies the type of the suggestion (eg: `post`,
  36771. * `page`, `url`...etc)
  36772. * @property {string} title Human-readable label to show in user interface.
  36773. * @property {string} url A URL for the suggestion.
  36774. */
  36775. /** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */
  36776. /**
  36777. * @typedef WPLinkControlProps
  36778. *
  36779. * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to
  36780. * render a `ToggleControl` for that setting.
  36781. * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the
  36782. * internal editing state of the component to respective
  36783. * show or not show the URL input field.
  36784. * @property {WPLinkControlValue=} value Current link value.
  36785. * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if
  36786. * the user selects a new link or updates settings.
  36787. * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.
  36788. * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.
  36789. * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.
  36790. * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.
  36791. * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.
  36792. * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.
  36793. * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.
  36794. * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.
  36795. */
  36796. /**
  36797. * Renders a link control. A link control is a controlled input which maintains
  36798. * a value associated with a link (HTML anchor element) and relevant settings
  36799. * for how that link is expected to behave.
  36800. *
  36801. * @param {WPLinkControlProps} props Component props.
  36802. */
  36803. function LinkControl(_ref) {
  36804. var _currentInputValue$tr, _value$url, _value$url$trim;
  36805. let {
  36806. searchInputPlaceholder,
  36807. value,
  36808. settings = DEFAULT_LINK_SETTINGS,
  36809. onChange = external_lodash_namespaceObject.noop,
  36810. onRemove,
  36811. noDirectEntry = false,
  36812. showSuggestions = true,
  36813. showInitialSuggestions,
  36814. forceIsEditingLink,
  36815. createSuggestion,
  36816. withCreateSuggestion,
  36817. inputValue: propInputValue = '',
  36818. suggestionsQuery = {},
  36819. noURLSuggestion = false,
  36820. createSuggestionButtonText,
  36821. hasRichPreviews = false,
  36822. hasTextControl = false,
  36823. renderControlBottom = null
  36824. } = _ref;
  36825. if (withCreateSuggestion === undefined && createSuggestion) {
  36826. withCreateSuggestion = true;
  36827. }
  36828. const isMounting = (0,external_wp_element_namespaceObject.useRef)(true);
  36829. const wrapperNode = (0,external_wp_element_namespaceObject.useRef)();
  36830. const textInputRef = (0,external_wp_element_namespaceObject.useRef)();
  36831. const [internalInputValue, setInternalInputValue] = (0,external_wp_element_namespaceObject.useState)((value === null || value === void 0 ? void 0 : value.url) || '');
  36832. const [internalTextValue, setInternalTextValue] = (0,external_wp_element_namespaceObject.useState)((value === null || value === void 0 ? void 0 : value.title) || '');
  36833. const currentInputValue = propInputValue || internalInputValue;
  36834. const [isEditingLink, setIsEditingLink] = (0,external_wp_element_namespaceObject.useState)(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url);
  36835. const isEndingEditWithFocus = (0,external_wp_element_namespaceObject.useRef)(false);
  36836. const currentInputIsEmpty = !(currentInputValue !== null && currentInputValue !== void 0 && (_currentInputValue$tr = currentInputValue.trim()) !== null && _currentInputValue$tr !== void 0 && _currentInputValue$tr.length);
  36837. const {
  36838. createPage,
  36839. isCreatingPage,
  36840. errorMessage
  36841. } = useCreatePage(createSuggestion);
  36842. (0,external_wp_element_namespaceObject.useEffect)(() => {
  36843. if (forceIsEditingLink !== undefined && forceIsEditingLink !== isEditingLink) {
  36844. setIsEditingLink(forceIsEditingLink);
  36845. }
  36846. }, [forceIsEditingLink]);
  36847. (0,external_wp_element_namespaceObject.useEffect)(() => {
  36848. // We don't auto focus into the Link UI on mount
  36849. // because otherwise using the keyboard to select text
  36850. // *within* the link format is not possible.
  36851. if (isMounting.current) {
  36852. isMounting.current = false;
  36853. return;
  36854. } // Unless we are mounting, we always want to focus either:
  36855. // - the URL input
  36856. // - the first focusable element in the Link UI.
  36857. // But in editing mode if there is a text input present then
  36858. // the URL input is at index 1. If not then it is at index 0.
  36859. const whichFocusTargetIndex = textInputRef !== null && textInputRef !== void 0 && textInputRef.current ? 1 : 0; // Scenario - when:
  36860. // - switching between editable and non editable LinkControl
  36861. // - clicking on a link
  36862. // ...then move focus to the *first* element to avoid focus loss
  36863. // and to ensure focus is *within* the Link UI.
  36864. const nextFocusTarget = external_wp_dom_namespaceObject.focus.focusable.find(wrapperNode.current)[whichFocusTargetIndex] || wrapperNode.current;
  36865. nextFocusTarget.focus();
  36866. isEndingEditWithFocus.current = false;
  36867. }, [isEditingLink, isCreatingPage]);
  36868. (0,external_wp_element_namespaceObject.useEffect)(() => {
  36869. /**
  36870. * If the value's `text` property changes then sync this
  36871. * back up with state.
  36872. */
  36873. if (value !== null && value !== void 0 && value.title && value.title !== internalTextValue) {
  36874. setInternalTextValue(value.title);
  36875. }
  36876. /**
  36877. * Update the state value internalInputValue if the url value changes
  36878. * for example when clicking on another anchor
  36879. */
  36880. if (value !== null && value !== void 0 && value.url) {
  36881. setInternalInputValue(value.url);
  36882. }
  36883. }, [value]);
  36884. /**
  36885. * Cancels editing state and marks that focus may need to be restored after
  36886. * the next render, if focus was within the wrapper when editing finished.
  36887. */
  36888. function stopEditing() {
  36889. var _wrapperNode$current;
  36890. isEndingEditWithFocus.current = !!((_wrapperNode$current = wrapperNode.current) !== null && _wrapperNode$current !== void 0 && _wrapperNode$current.contains(wrapperNode.current.ownerDocument.activeElement));
  36891. setIsEditingLink(false);
  36892. }
  36893. const handleSelectSuggestion = updatedValue => {
  36894. onChange({ ...updatedValue,
  36895. title: internalTextValue || (updatedValue === null || updatedValue === void 0 ? void 0 : updatedValue.title)
  36896. });
  36897. stopEditing();
  36898. };
  36899. const handleSubmit = () => {
  36900. if (currentInputValue !== (value === null || value === void 0 ? void 0 : value.url) || internalTextValue !== (value === null || value === void 0 ? void 0 : value.title)) {
  36901. onChange({
  36902. url: currentInputValue,
  36903. title: internalTextValue
  36904. });
  36905. }
  36906. stopEditing();
  36907. };
  36908. const handleSubmitWithEnter = event => {
  36909. const {
  36910. keyCode
  36911. } = event;
  36912. if (keyCode === external_wp_keycodes_namespaceObject.ENTER && !currentInputIsEmpty // Disallow submitting empty values.
  36913. ) {
  36914. event.preventDefault();
  36915. handleSubmit();
  36916. }
  36917. };
  36918. const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage;
  36919. const showSettingsDrawer = !!(settings !== null && settings !== void 0 && settings.length); // Only show text control once a URL value has been committed
  36920. // and it isn't just empty whitespace.
  36921. // See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
  36922. 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;
  36923. return (0,external_wp_element_namespaceObject.createElement)("div", {
  36924. tabIndex: -1,
  36925. ref: wrapperNode,
  36926. className: "block-editor-link-control"
  36927. }, isCreatingPage && (0,external_wp_element_namespaceObject.createElement)("div", {
  36928. className: "block-editor-link-control__loading"
  36929. }, (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", {
  36930. className: classnames_default()({
  36931. 'block-editor-link-control__search-input-wrapper': true,
  36932. 'has-text-control': showTextControl
  36933. })
  36934. }, showTextControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  36935. ref: textInputRef,
  36936. className: "block-editor-link-control__field block-editor-link-control__text-content",
  36937. label: "Text",
  36938. value: internalTextValue,
  36939. onChange: setInternalTextValue,
  36940. onKeyDown: handleSubmitWithEnter
  36941. }), (0,external_wp_element_namespaceObject.createElement)(search_input, {
  36942. currentLink: value,
  36943. className: "block-editor-link-control__field block-editor-link-control__search-input",
  36944. placeholder: searchInputPlaceholder,
  36945. value: currentInputValue,
  36946. withCreateSuggestion: withCreateSuggestion,
  36947. onCreateSuggestion: createPage,
  36948. onChange: setInternalInputValue,
  36949. onSelect: handleSelectSuggestion,
  36950. showInitialSuggestions: showInitialSuggestions,
  36951. allowDirectEntry: !noDirectEntry,
  36952. showSuggestions: showSuggestions,
  36953. suggestionsQuery: suggestionsQuery,
  36954. withURLSuggestion: !noURLSuggestion,
  36955. createSuggestionButtonText: createSuggestionButtonText,
  36956. useLabel: showTextControl
  36957. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  36958. className: "block-editor-link-control__search-actions"
  36959. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  36960. onClick: handleSubmit,
  36961. label: (0,external_wp_i18n_namespaceObject.__)('Submit'),
  36962. icon: keyboard_return,
  36963. className: "block-editor-link-control__search-submit",
  36964. disabled: currentInputIsEmpty // Disallow submitting empty values.
  36965. })))), errorMessage && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
  36966. className: "block-editor-link-control__search-error",
  36967. status: "error",
  36968. isDismissible: false
  36969. }, errorMessage)), value && !isEditingLink && !isCreatingPage && (0,external_wp_element_namespaceObject.createElement)(LinkPreview, {
  36970. key: value === null || value === void 0 ? void 0 : value.url // force remount when URL changes to avoid race conditions for rich previews
  36971. ,
  36972. value: value,
  36973. onEditClick: () => setIsEditingLink(true),
  36974. hasRichPreviews: hasRichPreviews,
  36975. hasUnlinkControl: shownUnlinkControl,
  36976. onRemove: onRemove
  36977. }), showSettingsDrawer && (0,external_wp_element_namespaceObject.createElement)("div", {
  36978. className: "block-editor-link-control__tools"
  36979. }, (0,external_wp_element_namespaceObject.createElement)(settings_drawer, {
  36980. value: value,
  36981. settings: settings,
  36982. onChange: onChange
  36983. })), renderControlBottom && renderControlBottom());
  36984. }
  36985. LinkControl.ViewerFill = ViewerFill;
  36986. /* harmony default export */ var link_control = (LinkControl);
  36987. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/media.js
  36988. /**
  36989. * WordPress dependencies
  36990. */
  36991. const media = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  36992. xmlns: "http://www.w3.org/2000/svg",
  36993. viewBox: "0 0 24 24"
  36994. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  36995. 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"
  36996. }));
  36997. /* harmony default export */ var library_media = (media);
  36998. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/upload.js
  36999. /**
  37000. * WordPress dependencies
  37001. */
  37002. const upload = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  37003. xmlns: "http://www.w3.org/2000/svg",
  37004. viewBox: "0 0 24 24"
  37005. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  37006. 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"
  37007. }));
  37008. /* harmony default export */ var library_upload = (upload);
  37009. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/index.js
  37010. /**
  37011. * WordPress dependencies
  37012. */
  37013. /**
  37014. * This is a placeholder for the media upload component necessary to make it possible to provide
  37015. * an integration with the core blocks that handle media files. By default it renders nothing but
  37016. * it provides a way to have it overridden with the `editor.MediaUpload` filter.
  37017. *
  37018. * @return {WPComponent} The component to be rendered.
  37019. */
  37020. const MediaUpload = () => null;
  37021. /**
  37022. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md
  37023. */
  37024. /* harmony default export */ var media_upload = ((0,external_wp_components_namespaceObject.withFilters)('editor.MediaUpload')(MediaUpload));
  37025. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/check.js
  37026. /**
  37027. * WordPress dependencies
  37028. */
  37029. /**
  37030. * Internal dependencies
  37031. */
  37032. function MediaUploadCheck(_ref) {
  37033. let {
  37034. fallback = null,
  37035. children
  37036. } = _ref;
  37037. const hasUploadPermissions = (0,external_wp_data_namespaceObject.useSelect)(select => {
  37038. const {
  37039. getSettings
  37040. } = select(store);
  37041. return !!getSettings().mediaUpload;
  37042. }, []);
  37043. return hasUploadPermissions ? children : fallback;
  37044. }
  37045. /**
  37046. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md
  37047. */
  37048. /* harmony default export */ var media_upload_check = (MediaUploadCheck);
  37049. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-replace-flow/index.js
  37050. /**
  37051. * External dependencies
  37052. */
  37053. /**
  37054. * WordPress dependencies
  37055. */
  37056. /**
  37057. * Internal dependencies
  37058. */
  37059. const MediaReplaceFlow = _ref => {
  37060. let {
  37061. mediaURL,
  37062. mediaId,
  37063. mediaIds,
  37064. allowedTypes,
  37065. accept,
  37066. onError,
  37067. onSelect,
  37068. onSelectURL,
  37069. onFilesUpload = external_lodash_namespaceObject.noop,
  37070. name = (0,external_wp_i18n_namespaceObject.__)('Replace'),
  37071. createNotice,
  37072. removeNotice,
  37073. children,
  37074. multiple = false,
  37075. addToGallery,
  37076. handleUpload = true
  37077. } = _ref;
  37078. const [mediaURLValue, setMediaURLValue] = (0,external_wp_element_namespaceObject.useState)(mediaURL);
  37079. const mediaUpload = (0,external_wp_data_namespaceObject.useSelect)(select => {
  37080. return select(store).getSettings().mediaUpload;
  37081. }, []);
  37082. const editMediaButtonRef = (0,external_wp_element_namespaceObject.useRef)();
  37083. const errorNoticeID = (0,external_lodash_namespaceObject.uniqueId)('block-editor/media-replace-flow/error-notice/');
  37084. const onUploadError = message => {
  37085. const safeMessage = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(message);
  37086. if (onError) {
  37087. onError(safeMessage);
  37088. return;
  37089. } // We need to set a timeout for showing the notice
  37090. // so that VoiceOver and possibly other screen readers
  37091. // can announce the error afer the toolbar button
  37092. // regains focus once the upload dialog closes.
  37093. // Otherwise VO simply skips over the notice and announces
  37094. // the focused element and the open menu.
  37095. setTimeout(() => {
  37096. createNotice('error', safeMessage, {
  37097. speak: true,
  37098. id: errorNoticeID,
  37099. isDismissible: true
  37100. });
  37101. }, 1000);
  37102. };
  37103. const selectMedia = (media, closeMenu) => {
  37104. closeMenu();
  37105. setMediaURLValue(media === null || media === void 0 ? void 0 : media.url); // Calling `onSelect` after the state update since it might unmount the component.
  37106. onSelect(media);
  37107. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('The media file has been replaced'));
  37108. removeNotice(errorNoticeID);
  37109. };
  37110. const uploadFiles = (event, closeMenu) => {
  37111. const files = event.target.files;
  37112. if (!handleUpload) {
  37113. closeMenu();
  37114. return onSelect(files);
  37115. }
  37116. onFilesUpload(files);
  37117. mediaUpload({
  37118. allowedTypes,
  37119. filesList: files,
  37120. onFileChange: _ref2 => {
  37121. let [media] = _ref2;
  37122. selectMedia(media, closeMenu);
  37123. },
  37124. onError: onUploadError
  37125. });
  37126. };
  37127. const openOnArrowDown = event => {
  37128. if (event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
  37129. event.preventDefault();
  37130. event.target.click();
  37131. }
  37132. };
  37133. const onlyAllowsImages = () => {
  37134. if (!allowedTypes || allowedTypes.length === 0) {
  37135. return false;
  37136. }
  37137. return allowedTypes.every(allowedType => allowedType === 'image' || allowedType.startsWith('image/'));
  37138. };
  37139. const gallery = multiple && onlyAllowsImages();
  37140. const POPOVER_PROPS = {
  37141. isAlternate: true
  37142. };
  37143. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  37144. popoverProps: POPOVER_PROPS,
  37145. contentClassName: "block-editor-media-replace-flow__options",
  37146. renderToggle: _ref3 => {
  37147. let {
  37148. isOpen,
  37149. onToggle
  37150. } = _ref3;
  37151. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  37152. ref: editMediaButtonRef,
  37153. "aria-expanded": isOpen,
  37154. "aria-haspopup": "true",
  37155. onClick: onToggle,
  37156. onKeyDown: openOnArrowDown
  37157. }, name);
  37158. },
  37159. renderContent: _ref4 => {
  37160. let {
  37161. onClose
  37162. } = _ref4;
  37163. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, {
  37164. className: "block-editor-media-replace-flow__media-upload-menu"
  37165. }, (0,external_wp_element_namespaceObject.createElement)(media_upload, {
  37166. gallery: gallery,
  37167. addToGallery: addToGallery,
  37168. multiple: multiple,
  37169. value: multiple ? mediaIds : mediaId,
  37170. onSelect: media => selectMedia(media, onClose),
  37171. allowedTypes: allowedTypes,
  37172. render: _ref5 => {
  37173. let {
  37174. open
  37175. } = _ref5;
  37176. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  37177. icon: library_media,
  37178. onClick: open
  37179. }, (0,external_wp_i18n_namespaceObject.__)('Open Media Library'));
  37180. }
  37181. }), (0,external_wp_element_namespaceObject.createElement)(media_upload_check, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormFileUpload, {
  37182. onChange: event => {
  37183. uploadFiles(event, onClose);
  37184. },
  37185. accept: accept,
  37186. multiple: multiple,
  37187. render: _ref6 => {
  37188. let {
  37189. openFileDialog
  37190. } = _ref6;
  37191. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  37192. icon: library_upload,
  37193. onClick: () => {
  37194. openFileDialog();
  37195. }
  37196. }, (0,external_wp_i18n_namespaceObject.__)('Upload'));
  37197. }
  37198. })), children), onSelectURL && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
  37199. (0,external_wp_element_namespaceObject.createElement)("form", {
  37200. className: "block-editor-media-flow__url-input"
  37201. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  37202. className: "block-editor-media-replace-flow__image-url-label"
  37203. }, (0,external_wp_i18n_namespaceObject.__)('Current media URL:')), (0,external_wp_element_namespaceObject.createElement)(link_control, {
  37204. value: {
  37205. url: mediaURLValue
  37206. },
  37207. settings: [],
  37208. showSuggestions: false,
  37209. onChange: _ref7 => {
  37210. let {
  37211. url
  37212. } = _ref7;
  37213. setMediaURLValue(url);
  37214. onSelectURL(url);
  37215. editMediaButtonRef.current.focus();
  37216. }
  37217. })));
  37218. }
  37219. });
  37220. };
  37221. /**
  37222. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md
  37223. */
  37224. /* harmony default export */ var media_replace_flow = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
  37225. const {
  37226. createNotice,
  37227. removeNotice
  37228. } = dispatch(external_wp_notices_namespaceObject.store);
  37229. return {
  37230. createNotice,
  37231. removeNotice
  37232. };
  37233. }), (0,external_wp_components_namespaceObject.withFilters)('editor.MediaReplaceFlow')])(MediaReplaceFlow));
  37234. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-viewer-url.js
  37235. /**
  37236. * External dependencies
  37237. */
  37238. /**
  37239. * WordPress dependencies
  37240. */
  37241. function LinkViewerURL(_ref) {
  37242. let {
  37243. url,
  37244. urlLabel,
  37245. className
  37246. } = _ref;
  37247. const linkClassName = classnames_default()(className, 'block-editor-url-popover__link-viewer-url');
  37248. if (!url) {
  37249. return (0,external_wp_element_namespaceObject.createElement)("span", {
  37250. className: linkClassName
  37251. });
  37252. }
  37253. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  37254. className: linkClassName,
  37255. href: url
  37256. }, urlLabel || (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURI)(url)));
  37257. }
  37258. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-viewer.js
  37259. /**
  37260. * External dependencies
  37261. */
  37262. /**
  37263. * WordPress dependencies
  37264. */
  37265. /**
  37266. * Internal dependencies
  37267. */
  37268. function LinkViewer(_ref) {
  37269. let {
  37270. className,
  37271. linkClassName,
  37272. onEditLinkClick,
  37273. url,
  37274. urlLabel,
  37275. ...props
  37276. } = _ref;
  37277. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  37278. className: classnames_default()('block-editor-url-popover__link-viewer', className)
  37279. }, props), (0,external_wp_element_namespaceObject.createElement)(LinkViewerURL, {
  37280. url: url,
  37281. urlLabel: urlLabel,
  37282. className: linkClassName
  37283. }), onEditLinkClick && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  37284. icon: library_edit,
  37285. label: (0,external_wp_i18n_namespaceObject.__)('Edit'),
  37286. onClick: onEditLinkClick
  37287. }));
  37288. }
  37289. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-editor.js
  37290. /**
  37291. * External dependencies
  37292. */
  37293. /**
  37294. * WordPress dependencies
  37295. */
  37296. /**
  37297. * Internal dependencies
  37298. */
  37299. function LinkEditor(_ref) {
  37300. let {
  37301. autocompleteRef,
  37302. className,
  37303. onChangeInputValue,
  37304. value,
  37305. ...props
  37306. } = _ref;
  37307. return (0,external_wp_element_namespaceObject.createElement)("form", _extends({
  37308. className: classnames_default()('block-editor-url-popover__link-editor', className)
  37309. }, props), (0,external_wp_element_namespaceObject.createElement)(url_input, {
  37310. value: value,
  37311. onChange: onChangeInputValue,
  37312. autocompleteRef: autocompleteRef
  37313. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  37314. icon: keyboard_return,
  37315. label: (0,external_wp_i18n_namespaceObject.__)('Apply'),
  37316. type: "submit"
  37317. }));
  37318. }
  37319. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/index.js
  37320. /**
  37321. * WordPress dependencies
  37322. */
  37323. /**
  37324. * Internal dependencies
  37325. */
  37326. function URLPopover(_ref) {
  37327. let {
  37328. additionalControls,
  37329. children,
  37330. renderSettings,
  37331. position = 'bottom center',
  37332. focusOnMount = 'firstElement',
  37333. ...popoverProps
  37334. } = _ref;
  37335. const [isSettingsExpanded, setIsSettingsExpanded] = (0,external_wp_element_namespaceObject.useState)(false);
  37336. const showSettings = !!renderSettings && isSettingsExpanded;
  37337. const toggleSettingsVisibility = () => {
  37338. setIsSettingsExpanded(!isSettingsExpanded);
  37339. };
  37340. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, _extends({
  37341. className: "block-editor-url-popover",
  37342. focusOnMount: focusOnMount,
  37343. position: position
  37344. }, popoverProps), (0,external_wp_element_namespaceObject.createElement)("div", {
  37345. className: "block-editor-url-popover__input-container"
  37346. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  37347. className: "block-editor-url-popover__row"
  37348. }, children, !!renderSettings && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  37349. className: "block-editor-url-popover__settings-toggle",
  37350. icon: chevron_down,
  37351. label: (0,external_wp_i18n_namespaceObject.__)('Link settings'),
  37352. onClick: toggleSettingsVisibility,
  37353. "aria-expanded": isSettingsExpanded
  37354. })), showSettings && (0,external_wp_element_namespaceObject.createElement)("div", {
  37355. className: "block-editor-url-popover__row block-editor-url-popover__settings"
  37356. }, renderSettings())), additionalControls && !showSettings && (0,external_wp_element_namespaceObject.createElement)("div", {
  37357. className: "block-editor-url-popover__additional-controls"
  37358. }, additionalControls));
  37359. }
  37360. URLPopover.LinkEditor = LinkEditor;
  37361. URLPopover.LinkViewer = LinkViewer;
  37362. /**
  37363. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-popover/README.md
  37364. */
  37365. /* harmony default export */ var url_popover = (URLPopover);
  37366. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-placeholder/index.js
  37367. /**
  37368. * External dependencies
  37369. */
  37370. /**
  37371. * WordPress dependencies
  37372. */
  37373. /**
  37374. * Internal dependencies
  37375. */
  37376. const InsertFromURLPopover = _ref => {
  37377. let {
  37378. src,
  37379. onChange,
  37380. onSubmit,
  37381. onClose
  37382. } = _ref;
  37383. return (0,external_wp_element_namespaceObject.createElement)(url_popover, {
  37384. onClose: onClose
  37385. }, (0,external_wp_element_namespaceObject.createElement)("form", {
  37386. className: "block-editor-media-placeholder__url-input-form",
  37387. onSubmit: onSubmit
  37388. }, (0,external_wp_element_namespaceObject.createElement)("input", {
  37389. className: "block-editor-media-placeholder__url-input-field",
  37390. type: "text",
  37391. "aria-label": (0,external_wp_i18n_namespaceObject.__)('URL'),
  37392. placeholder: (0,external_wp_i18n_namespaceObject.__)('Paste or type URL'),
  37393. onChange: onChange,
  37394. value: src
  37395. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  37396. className: "block-editor-media-placeholder__url-input-submit-button",
  37397. icon: keyboard_return,
  37398. label: (0,external_wp_i18n_namespaceObject.__)('Apply'),
  37399. type: "submit"
  37400. })));
  37401. };
  37402. function MediaPlaceholder(_ref2) {
  37403. let {
  37404. value = {},
  37405. allowedTypes,
  37406. className,
  37407. icon,
  37408. labels = {},
  37409. mediaPreview,
  37410. notices,
  37411. isAppender,
  37412. accept,
  37413. addToGallery,
  37414. multiple = false,
  37415. handleUpload = true,
  37416. disableDropZone,
  37417. disableMediaButtons,
  37418. onError,
  37419. onSelect,
  37420. onCancel,
  37421. onSelectURL,
  37422. onDoubleClick,
  37423. onFilesPreUpload = external_lodash_namespaceObject.noop,
  37424. onHTMLDrop = external_lodash_namespaceObject.noop,
  37425. children,
  37426. mediaLibraryButton,
  37427. placeholder,
  37428. style
  37429. } = _ref2;
  37430. const mediaUpload = (0,external_wp_data_namespaceObject.useSelect)(select => {
  37431. const {
  37432. getSettings
  37433. } = select(store);
  37434. return getSettings().mediaUpload;
  37435. }, []);
  37436. const [src, setSrc] = (0,external_wp_element_namespaceObject.useState)('');
  37437. const [isURLInputVisible, setIsURLInputVisible] = (0,external_wp_element_namespaceObject.useState)(false);
  37438. (0,external_wp_element_namespaceObject.useEffect)(() => {
  37439. var _value$src;
  37440. setSrc((_value$src = value === null || value === void 0 ? void 0 : value.src) !== null && _value$src !== void 0 ? _value$src : '');
  37441. }, [value === null || value === void 0 ? void 0 : value.src]);
  37442. const onlyAllowsImages = () => {
  37443. if (!allowedTypes || allowedTypes.length === 0) {
  37444. return false;
  37445. }
  37446. return allowedTypes.every(allowedType => allowedType === 'image' || allowedType.startsWith('image/'));
  37447. };
  37448. const onChangeSrc = event => {
  37449. setSrc(event.target.value);
  37450. };
  37451. const openURLInput = () => {
  37452. setIsURLInputVisible(true);
  37453. };
  37454. const closeURLInput = () => {
  37455. setIsURLInputVisible(false);
  37456. };
  37457. const onSubmitSrc = event => {
  37458. event.preventDefault();
  37459. if (src && onSelectURL) {
  37460. onSelectURL(src);
  37461. closeURLInput();
  37462. }
  37463. };
  37464. const onFilesUpload = files => {
  37465. if (!handleUpload) {
  37466. return onSelect(files);
  37467. }
  37468. onFilesPreUpload(files);
  37469. let setMedia;
  37470. if (multiple) {
  37471. if (addToGallery) {
  37472. // Since the setMedia function runs multiple times per upload group
  37473. // and is passed newMedia containing every item in its group each time, we must
  37474. // filter out whatever this upload group had previously returned to the
  37475. // gallery before adding and returning the image array with replacement newMedia
  37476. // values.
  37477. // Define an array to store urls from newMedia between subsequent function calls.
  37478. let lastMediaPassed = [];
  37479. setMedia = newMedia => {
  37480. // Remove any images this upload group is responsible for (lastMediaPassed).
  37481. // Their replacements are contained in newMedia.
  37482. const filteredMedia = (value !== null && value !== void 0 ? value : []).filter(item => {
  37483. // If Item has id, only remove it if lastMediaPassed has an item with that id.
  37484. if (item.id) {
  37485. return !lastMediaPassed.some( // Be sure to convert to number for comparison.
  37486. _ref3 => {
  37487. let {
  37488. id
  37489. } = _ref3;
  37490. return Number(id) === Number(item.id);
  37491. });
  37492. } // Compare transient images via .includes since gallery may append extra info onto the url.
  37493. return !lastMediaPassed.some(_ref4 => {
  37494. let {
  37495. urlSlug
  37496. } = _ref4;
  37497. return item.url.includes(urlSlug);
  37498. });
  37499. }); // Return the filtered media array along with newMedia.
  37500. onSelect(filteredMedia.concat(newMedia)); // Reset lastMediaPassed and set it with ids and urls from newMedia.
  37501. lastMediaPassed = newMedia.map(media => {
  37502. // Add everything up to '.fileType' to compare via .includes.
  37503. const cutOffIndex = media.url.lastIndexOf('.');
  37504. const urlSlug = media.url.slice(0, cutOffIndex);
  37505. return {
  37506. id: media.id,
  37507. urlSlug
  37508. };
  37509. });
  37510. };
  37511. } else {
  37512. setMedia = onSelect;
  37513. }
  37514. } else {
  37515. setMedia = _ref5 => {
  37516. let [media] = _ref5;
  37517. return onSelect(media);
  37518. };
  37519. }
  37520. mediaUpload({
  37521. allowedTypes,
  37522. filesList: files,
  37523. onFileChange: setMedia,
  37524. onError
  37525. });
  37526. };
  37527. const onUpload = event => {
  37528. onFilesUpload(event.target.files);
  37529. };
  37530. const defaultRenderPlaceholder = content => {
  37531. let {
  37532. instructions,
  37533. title
  37534. } = labels;
  37535. if (!mediaUpload && !onSelectURL) {
  37536. instructions = (0,external_wp_i18n_namespaceObject.__)('To edit this block, you need permission to upload media.');
  37537. }
  37538. if (instructions === undefined || title === undefined) {
  37539. const typesAllowed = allowedTypes !== null && allowedTypes !== void 0 ? allowedTypes : [];
  37540. const [firstAllowedType] = typesAllowed;
  37541. const isOneType = 1 === typesAllowed.length;
  37542. const isAudio = isOneType && 'audio' === firstAllowedType;
  37543. const isImage = isOneType && 'image' === firstAllowedType;
  37544. const isVideo = isOneType && 'video' === firstAllowedType;
  37545. if (instructions === undefined && mediaUpload) {
  37546. instructions = (0,external_wp_i18n_namespaceObject.__)('Upload a media file or pick one from your media library.');
  37547. if (isAudio) {
  37548. instructions = (0,external_wp_i18n_namespaceObject.__)('Upload an audio file, pick one from your media library, or add one with a URL.');
  37549. } else if (isImage) {
  37550. instructions = (0,external_wp_i18n_namespaceObject.__)('Upload an image file, pick one from your media library, or add one with a URL.');
  37551. } else if (isVideo) {
  37552. instructions = (0,external_wp_i18n_namespaceObject.__)('Upload a video file, pick one from your media library, or add one with a URL.');
  37553. }
  37554. }
  37555. if (title === undefined) {
  37556. title = (0,external_wp_i18n_namespaceObject.__)('Media');
  37557. if (isAudio) {
  37558. title = (0,external_wp_i18n_namespaceObject.__)('Audio');
  37559. } else if (isImage) {
  37560. title = (0,external_wp_i18n_namespaceObject.__)('Image');
  37561. } else if (isVideo) {
  37562. title = (0,external_wp_i18n_namespaceObject.__)('Video');
  37563. }
  37564. }
  37565. }
  37566. const placeholderClassName = classnames_default()('block-editor-media-placeholder', className, {
  37567. 'is-appender': isAppender
  37568. });
  37569. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
  37570. icon: icon,
  37571. label: title,
  37572. instructions: instructions,
  37573. className: placeholderClassName,
  37574. notices: notices,
  37575. onDoubleClick: onDoubleClick,
  37576. preview: mediaPreview,
  37577. style: style
  37578. }, content, children);
  37579. };
  37580. const renderPlaceholder = placeholder !== null && placeholder !== void 0 ? placeholder : defaultRenderPlaceholder;
  37581. const renderDropZone = () => {
  37582. if (disableDropZone) {
  37583. return null;
  37584. }
  37585. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropZone, {
  37586. onFilesDrop: onFilesUpload,
  37587. onHTMLDrop: onHTMLDrop
  37588. });
  37589. };
  37590. const renderCancelLink = () => {
  37591. return onCancel && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  37592. className: "block-editor-media-placeholder__cancel-button",
  37593. title: (0,external_wp_i18n_namespaceObject.__)('Cancel'),
  37594. variant: "link",
  37595. onClick: onCancel
  37596. }, (0,external_wp_i18n_namespaceObject.__)('Cancel'));
  37597. };
  37598. const renderUrlSelectionUI = () => {
  37599. return onSelectURL && (0,external_wp_element_namespaceObject.createElement)("div", {
  37600. className: "block-editor-media-placeholder__url-input-container"
  37601. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  37602. className: "block-editor-media-placeholder__button",
  37603. onClick: openURLInput,
  37604. isPressed: isURLInputVisible,
  37605. variant: "tertiary"
  37606. }, (0,external_wp_i18n_namespaceObject.__)('Insert from URL')), isURLInputVisible && (0,external_wp_element_namespaceObject.createElement)(InsertFromURLPopover, {
  37607. src: src,
  37608. onChange: onChangeSrc,
  37609. onSubmit: onSubmitSrc,
  37610. onClose: closeURLInput
  37611. }));
  37612. };
  37613. const renderMediaUploadChecked = () => {
  37614. const defaultButton = _ref6 => {
  37615. let {
  37616. open
  37617. } = _ref6;
  37618. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  37619. variant: "tertiary",
  37620. onClick: () => {
  37621. open();
  37622. }
  37623. }, (0,external_wp_i18n_namespaceObject.__)('Media Library'));
  37624. };
  37625. const libraryButton = mediaLibraryButton !== null && mediaLibraryButton !== void 0 ? mediaLibraryButton : defaultButton;
  37626. const uploadMediaLibraryButton = (0,external_wp_element_namespaceObject.createElement)(media_upload, {
  37627. addToGallery: addToGallery,
  37628. gallery: multiple && onlyAllowsImages(),
  37629. multiple: multiple,
  37630. onSelect: onSelect,
  37631. allowedTypes: allowedTypes,
  37632. value: Array.isArray(value) ? value.map(_ref7 => {
  37633. let {
  37634. id
  37635. } = _ref7;
  37636. return id;
  37637. }) : value.id,
  37638. render: libraryButton
  37639. });
  37640. if (mediaUpload && isAppender) {
  37641. 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, {
  37642. onChange: onUpload,
  37643. accept: accept,
  37644. multiple: multiple,
  37645. render: _ref8 => {
  37646. let {
  37647. openFileDialog
  37648. } = _ref8;
  37649. 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, {
  37650. variant: "primary",
  37651. className: classnames_default()('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button'),
  37652. onClick: openFileDialog
  37653. }, (0,external_wp_i18n_namespaceObject.__)('Upload')), uploadMediaLibraryButton, renderUrlSelectionUI(), renderCancelLink());
  37654. return renderPlaceholder(content);
  37655. }
  37656. }));
  37657. }
  37658. if (mediaUpload) {
  37659. 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, {
  37660. variant: "primary",
  37661. className: classnames_default()('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button'),
  37662. onChange: onUpload,
  37663. accept: accept,
  37664. multiple: multiple
  37665. }, (0,external_wp_i18n_namespaceObject.__)('Upload')), uploadMediaLibraryButton, renderUrlSelectionUI(), renderCancelLink());
  37666. return renderPlaceholder(content);
  37667. }
  37668. return renderPlaceholder(uploadMediaLibraryButton);
  37669. };
  37670. if (disableMediaButtons) {
  37671. return (0,external_wp_element_namespaceObject.createElement)(media_upload_check, null, renderDropZone());
  37672. }
  37673. return (0,external_wp_element_namespaceObject.createElement)(media_upload_check, {
  37674. fallback: renderPlaceholder(renderUrlSelectionUI())
  37675. }, renderMediaUploadChecked());
  37676. }
  37677. /**
  37678. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md
  37679. */
  37680. /* harmony default export */ var media_placeholder = ((0,external_wp_components_namespaceObject.withFilters)('editor.MediaPlaceholder')(MediaPlaceholder));
  37681. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/panel-color-settings/index.js
  37682. /**
  37683. * Internal dependencies
  37684. */
  37685. const PanelColorSettings = _ref => {
  37686. let {
  37687. colorSettings,
  37688. ...props
  37689. } = _ref;
  37690. const settings = colorSettings.map(setting => {
  37691. if (!setting) {
  37692. return setting;
  37693. }
  37694. const {
  37695. value,
  37696. onChange,
  37697. ...otherSettings
  37698. } = setting;
  37699. return { ...otherSettings,
  37700. colorValue: value,
  37701. onColorChange: onChange
  37702. };
  37703. });
  37704. return (0,external_wp_element_namespaceObject.createElement)(panel_color_gradient_settings, _extends({
  37705. settings: settings,
  37706. gradients: [],
  37707. disableCustomGradients: true
  37708. }, props));
  37709. };
  37710. /* harmony default export */ var panel_color_settings = (PanelColorSettings);
  37711. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar/index.js
  37712. /**
  37713. * External dependencies
  37714. */
  37715. /**
  37716. * WordPress dependencies
  37717. */
  37718. const format_toolbar_POPOVER_PROPS = {
  37719. position: 'bottom right',
  37720. isAlternate: true
  37721. };
  37722. const FormatToolbar = () => {
  37723. 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, {
  37724. name: `RichText.ToolbarControls.${format}`,
  37725. key: format
  37726. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
  37727. name: "RichText.ToolbarControls"
  37728. }, fills => {
  37729. if (!fills.length) {
  37730. return null;
  37731. }
  37732. const allProps = fills.map(_ref => {
  37733. let [{
  37734. props
  37735. }] = _ref;
  37736. return props;
  37737. });
  37738. const hasActive = allProps.some(_ref2 => {
  37739. let {
  37740. isActive
  37741. } = _ref2;
  37742. return isActive;
  37743. });
  37744. 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, {
  37745. icon: chevron_down
  37746. /* translators: button label text should, if possible, be under 16 characters. */
  37747. ,
  37748. label: (0,external_wp_i18n_namespaceObject.__)('More'),
  37749. toggleProps: { ...toggleProps,
  37750. className: classnames_default()(toggleProps.className, {
  37751. 'is-pressed': hasActive
  37752. }),
  37753. describedBy: (0,external_wp_i18n_namespaceObject.__)('Displays more block tools')
  37754. },
  37755. controls: (0,external_lodash_namespaceObject.orderBy)(fills.map(_ref3 => {
  37756. let [{
  37757. props
  37758. }] = _ref3;
  37759. return props;
  37760. }), 'title'),
  37761. popoverProps: format_toolbar_POPOVER_PROPS
  37762. }));
  37763. }));
  37764. };
  37765. /* harmony default export */ var format_toolbar = (FormatToolbar);
  37766. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar-container.js
  37767. /**
  37768. * WordPress dependencies
  37769. */
  37770. /**
  37771. * Internal dependencies
  37772. */
  37773. const FormatToolbarContainer = _ref => {
  37774. let {
  37775. inline,
  37776. anchorRef
  37777. } = _ref;
  37778. if (inline) {
  37779. // Render in popover.
  37780. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  37781. noArrow: true,
  37782. position: "top center",
  37783. focusOnMount: false,
  37784. anchorRef: anchorRef,
  37785. className: "block-editor-rich-text__inline-format-toolbar",
  37786. __unstableSlotName: "block-toolbar"
  37787. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  37788. className: "block-editor-rich-text__inline-format-toolbar-group"
  37789. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(format_toolbar, null))));
  37790. } // Render regular toolbar.
  37791. return (0,external_wp_element_namespaceObject.createElement)(block_controls, {
  37792. group: "inline"
  37793. }, (0,external_wp_element_namespaceObject.createElement)(format_toolbar, null));
  37794. };
  37795. /* harmony default export */ var format_toolbar_container = (FormatToolbarContainer);
  37796. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-undo-automatic-change.js
  37797. /**
  37798. * WordPress dependencies
  37799. */
  37800. /**
  37801. * Internal dependencies
  37802. */
  37803. function useUndoAutomaticChange() {
  37804. const {
  37805. didAutomaticChange,
  37806. getSettings
  37807. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  37808. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  37809. function onKeyDown(event) {
  37810. const {
  37811. keyCode
  37812. } = event;
  37813. if (event.defaultPrevented) {
  37814. return;
  37815. }
  37816. if (keyCode !== external_wp_keycodes_namespaceObject.DELETE && keyCode !== external_wp_keycodes_namespaceObject.BACKSPACE && keyCode !== external_wp_keycodes_namespaceObject.ESCAPE) {
  37817. return;
  37818. }
  37819. if (!didAutomaticChange()) {
  37820. return;
  37821. }
  37822. event.preventDefault();
  37823. getSettings().__experimentalUndo();
  37824. }
  37825. element.addEventListener('keydown', onKeyDown);
  37826. return () => {
  37827. element.removeEventListener('keydown', onKeyDown);
  37828. };
  37829. }, []);
  37830. }
  37831. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-caret-in-format.js
  37832. /**
  37833. * WordPress dependencies
  37834. */
  37835. /**
  37836. * Internal dependencies
  37837. */
  37838. function useCaretInFormat(_ref) {
  37839. let {
  37840. value
  37841. } = _ref;
  37842. const hasActiveFormats = value.activeFormats && !!value.activeFormats.length;
  37843. const {
  37844. isCaretWithinFormattedText
  37845. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  37846. const {
  37847. enterFormattedText,
  37848. exitFormattedText
  37849. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  37850. (0,external_wp_element_namespaceObject.useEffect)(() => {
  37851. if (hasActiveFormats) {
  37852. if (!isCaretWithinFormattedText()) {
  37853. enterFormattedText();
  37854. }
  37855. } else if (isCaretWithinFormattedText()) {
  37856. exitFormattedText();
  37857. }
  37858. }, [hasActiveFormats]);
  37859. }
  37860. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-mark-persistent.js
  37861. /**
  37862. * WordPress dependencies
  37863. */
  37864. /**
  37865. * Internal dependencies
  37866. */
  37867. function useMarkPersistent(_ref) {
  37868. let {
  37869. html,
  37870. value
  37871. } = _ref;
  37872. const previousText = (0,external_wp_element_namespaceObject.useRef)();
  37873. const hasActiveFormats = value.activeFormats && !!value.activeFormats.length;
  37874. const {
  37875. __unstableMarkLastChangeAsPersistent
  37876. } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Must be set synchronously to make sure it applies to the last change.
  37877. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  37878. // Ignore mount.
  37879. if (!previousText.current) {
  37880. previousText.current = value.text;
  37881. return;
  37882. } // Text input, so don't create an undo level for every character.
  37883. // Create an undo level after 1 second of no input.
  37884. if (previousText.current !== value.text) {
  37885. const timeout = window.setTimeout(() => {
  37886. __unstableMarkLastChangeAsPersistent();
  37887. }, 1000);
  37888. previousText.current = value.text;
  37889. return () => {
  37890. window.clearTimeout(timeout);
  37891. };
  37892. }
  37893. __unstableMarkLastChangeAsPersistent();
  37894. }, [html, hasActiveFormats]);
  37895. }
  37896. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/file-paste-handler.js
  37897. /**
  37898. * WordPress dependencies
  37899. */
  37900. function filePasteHandler(files) {
  37901. return files.filter(_ref => {
  37902. let {
  37903. type
  37904. } = _ref;
  37905. return /^image\/(?:jpe?g|png|gif|webp)$/.test(type);
  37906. }).map(file => `<img src="${(0,external_wp_blob_namespaceObject.createBlobURL)(file)}">`).join('');
  37907. }
  37908. ;// CONCATENATED MODULE: external ["wp","shortcode"]
  37909. var external_wp_shortcode_namespaceObject = window["wp"]["shortcode"];
  37910. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/utils.js
  37911. /**
  37912. * WordPress dependencies
  37913. */
  37914. function addActiveFormats(value, activeFormats) {
  37915. if (activeFormats !== null && activeFormats !== void 0 && activeFormats.length) {
  37916. let index = value.formats.length;
  37917. while (index--) {
  37918. value.formats[index] = [...activeFormats, ...(value.formats[index] || [])];
  37919. }
  37920. }
  37921. }
  37922. /**
  37923. * Get the multiline tag based on the multiline prop.
  37924. *
  37925. * @param {?(string|boolean)} multiline The multiline prop.
  37926. *
  37927. * @return {?string} The multiline tag.
  37928. */
  37929. function getMultilineTag(multiline) {
  37930. if (multiline !== true && multiline !== 'p' && multiline !== 'li') {
  37931. return;
  37932. }
  37933. return multiline === true ? 'p' : multiline;
  37934. }
  37935. function getAllowedFormats(_ref) {
  37936. let {
  37937. allowedFormats,
  37938. formattingControls,
  37939. disableFormats
  37940. } = _ref;
  37941. if (disableFormats) {
  37942. return getAllowedFormats.EMPTY_ARRAY;
  37943. }
  37944. if (!allowedFormats && !formattingControls) {
  37945. return;
  37946. }
  37947. if (allowedFormats) {
  37948. return allowedFormats;
  37949. }
  37950. external_wp_deprecated_default()('wp.blockEditor.RichText formattingControls prop', {
  37951. since: '5.4',
  37952. alternative: 'allowedFormats',
  37953. version: '6.2'
  37954. });
  37955. return formattingControls.map(name => `core/${name}`);
  37956. }
  37957. getAllowedFormats.EMPTY_ARRAY = [];
  37958. const isShortcode = text => (0,external_wp_shortcode_namespaceObject.regexp)('.*').test(text);
  37959. /**
  37960. * Creates a link from pasted URL.
  37961. * Creates a paragraph block containing a link to the URL, and calls `onReplace`.
  37962. *
  37963. * @param {string} url The URL that could not be embedded.
  37964. * @param {Function} onReplace Function to call with the created fallback block.
  37965. */
  37966. function createLinkInParagraph(url, onReplace) {
  37967. const link = createElement("a", {
  37968. href: url
  37969. }, url);
  37970. onReplace(createBlock('core/paragraph', {
  37971. content: renderToString(link)
  37972. }));
  37973. }
  37974. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/split-value.js
  37975. /**
  37976. * WordPress dependencies
  37977. */
  37978. /*
  37979. * Signals to the RichText owner that the block can be replaced with two blocks
  37980. * as a result of splitting the block by pressing enter, or with blocks as a
  37981. * result of splitting the block by pasting block content in the instance.
  37982. */
  37983. function splitValue(_ref) {
  37984. let {
  37985. value,
  37986. pastedBlocks = [],
  37987. onReplace,
  37988. onSplit,
  37989. onSplitMiddle,
  37990. multilineTag
  37991. } = _ref;
  37992. if (!onReplace || !onSplit) {
  37993. return;
  37994. } // Ensure the value has a selection. This might happen when trying to split
  37995. // an empty value before there was a `selectionchange` event.
  37996. const {
  37997. start = 0,
  37998. end = 0
  37999. } = value;
  38000. const valueWithEnsuredSelection = { ...value,
  38001. start,
  38002. end
  38003. };
  38004. const blocks = [];
  38005. const [before, after] = (0,external_wp_richText_namespaceObject.split)(valueWithEnsuredSelection);
  38006. const hasPastedBlocks = pastedBlocks.length > 0;
  38007. let lastPastedBlockIndex = -1; // Consider the after value to be the original it is not empty and the
  38008. // before value *is* empty.
  38009. 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
  38010. // blocks, or if there are pasted blocks and the value is not empty. We do
  38011. // not want a leading empty block on paste, but we do if split with e.g. the
  38012. // enter key.
  38013. if (!hasPastedBlocks || !(0,external_wp_richText_namespaceObject.isEmpty)(before)) {
  38014. blocks.push(onSplit((0,external_wp_richText_namespaceObject.toHTMLString)({
  38015. value: before,
  38016. multilineTag
  38017. }), !isAfterOriginal));
  38018. lastPastedBlockIndex += 1;
  38019. }
  38020. if (hasPastedBlocks) {
  38021. blocks.push(...pastedBlocks);
  38022. lastPastedBlockIndex += pastedBlocks.length;
  38023. } else if (onSplitMiddle) {
  38024. blocks.push(onSplitMiddle());
  38025. } // If there's pasted blocks, append a block with non empty content / after
  38026. // the caret. Otherwise, do append an empty block if there is no
  38027. // `onSplitMiddle` prop, but if there is and the content is empty, the
  38028. // middle block is enough to set focus in.
  38029. if (hasPastedBlocks ? !(0,external_wp_richText_namespaceObject.isEmpty)(after) : !onSplitMiddle || !(0,external_wp_richText_namespaceObject.isEmpty)(after)) {
  38030. blocks.push(onSplit((0,external_wp_richText_namespaceObject.toHTMLString)({
  38031. value: after,
  38032. multilineTag
  38033. }), isAfterOriginal));
  38034. } // If there are pasted blocks, set the selection to the last one. Otherwise,
  38035. // set the selection to the second block.
  38036. const indexToSelect = hasPastedBlocks ? lastPastedBlockIndex : 1; // If there are pasted blocks, move the caret to the end of the selected
  38037. // block Otherwise, retain the default value.
  38038. const initialPosition = hasPastedBlocks ? -1 : 0;
  38039. onReplace(blocks, indexToSelect, initialPosition);
  38040. }
  38041. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-paste-handler.js
  38042. /**
  38043. * WordPress dependencies
  38044. */
  38045. /**
  38046. * Internal dependencies
  38047. */
  38048. /** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */
  38049. /**
  38050. * Replaces line separators with line breaks if not multiline.
  38051. * Replaces line breaks with line separators if multiline.
  38052. *
  38053. * @param {RichTextValue} value Value to adjust.
  38054. * @param {boolean} isMultiline Whether to adjust to multiline or not.
  38055. *
  38056. * @return {RichTextValue} Adjusted value.
  38057. */
  38058. function adjustLines(value, isMultiline) {
  38059. if (isMultiline) {
  38060. return (0,external_wp_richText_namespaceObject.replace)(value, /\n+/g, external_wp_richText_namespaceObject.__UNSTABLE_LINE_SEPARATOR);
  38061. }
  38062. return (0,external_wp_richText_namespaceObject.replace)(value, new RegExp(external_wp_richText_namespaceObject.__UNSTABLE_LINE_SEPARATOR, 'g'), '\n');
  38063. }
  38064. function usePasteHandler(props) {
  38065. const propsRef = (0,external_wp_element_namespaceObject.useRef)(props);
  38066. propsRef.current = props;
  38067. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  38068. function _onPaste(event) {
  38069. const {
  38070. isSelected,
  38071. disableFormats,
  38072. onChange,
  38073. value,
  38074. formatTypes,
  38075. tagName,
  38076. onReplace,
  38077. onSplit,
  38078. onSplitMiddle,
  38079. __unstableEmbedURLOnPaste,
  38080. multilineTag,
  38081. preserveWhiteSpace,
  38082. pastePlainText
  38083. } = propsRef.current;
  38084. if (!isSelected) {
  38085. return;
  38086. }
  38087. const {
  38088. clipboardData
  38089. } = event;
  38090. let plainText = '';
  38091. let html = ''; // IE11 only supports `Text` as an argument for `getData` and will
  38092. // otherwise throw an invalid argument error, so we try the standard
  38093. // arguments first, then fallback to `Text` if they fail.
  38094. try {
  38095. plainText = clipboardData.getData('text/plain');
  38096. html = clipboardData.getData('text/html');
  38097. } catch (error1) {
  38098. try {
  38099. html = clipboardData.getData('Text');
  38100. } catch (error2) {
  38101. // Some browsers like UC Browser paste plain text by default and
  38102. // don't support clipboardData at all, so allow default
  38103. // behaviour.
  38104. return;
  38105. }
  38106. } // Remove Windows-specific metadata appended within copied HTML text.
  38107. html = removeWindowsFragments(html); // Strip meta tag.
  38108. html = removeCharsetMetaTag(html);
  38109. event.preventDefault(); // Allows us to ask for this information when we get a report.
  38110. window.console.log('Received HTML:\n\n', html);
  38111. window.console.log('Received plain text:\n\n', plainText);
  38112. if (disableFormats) {
  38113. onChange((0,external_wp_richText_namespaceObject.insert)(value, plainText));
  38114. return;
  38115. }
  38116. const transformed = formatTypes.reduce((accumlator, _ref) => {
  38117. let {
  38118. __unstablePasteRule
  38119. } = _ref;
  38120. // Only allow one transform.
  38121. if (__unstablePasteRule && accumlator === value) {
  38122. accumlator = __unstablePasteRule(value, {
  38123. html,
  38124. plainText
  38125. });
  38126. }
  38127. return accumlator;
  38128. }, value);
  38129. if (transformed !== value) {
  38130. onChange(transformed);
  38131. return;
  38132. }
  38133. const files = [...(0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(clipboardData)];
  38134. const isInternal = clipboardData.getData('rich-text') === 'true'; // If the data comes from a rich text instance, we can directly use it
  38135. // without filtering the data. The filters are only meant for externally
  38136. // pasted content and remove inline styles.
  38137. if (isInternal) {
  38138. const pastedMultilineTag = clipboardData.getData('rich-text-multi-line-tag') || undefined;
  38139. let pastedValue = (0,external_wp_richText_namespaceObject.create)({
  38140. html,
  38141. multilineTag: pastedMultilineTag,
  38142. multilineWrapperTags: pastedMultilineTag === 'li' ? ['ul', 'ol'] : undefined,
  38143. preserveWhiteSpace
  38144. });
  38145. pastedValue = adjustLines(pastedValue, !!multilineTag);
  38146. addActiveFormats(pastedValue, value.activeFormats);
  38147. onChange((0,external_wp_richText_namespaceObject.insert)(value, pastedValue));
  38148. return;
  38149. }
  38150. if (pastePlainText) {
  38151. onChange((0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.create)({
  38152. text: plainText
  38153. })));
  38154. return;
  38155. } // Process any attached files, unless we infer that the files in
  38156. // question are redundant "screenshots" of the actual HTML payload,
  38157. // as created by certain office-type programs.
  38158. //
  38159. // @see shouldDismissPastedFiles
  38160. if (files !== null && files !== void 0 && files.length && !shouldDismissPastedFiles(files, html, plainText)) {
  38161. const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
  38162. HTML: filePasteHandler(files),
  38163. mode: 'BLOCKS',
  38164. tagName,
  38165. preserveWhiteSpace
  38166. }); // Allows us to ask for this information when we get a report.
  38167. // eslint-disable-next-line no-console
  38168. window.console.log('Received items:\n\n', files);
  38169. if (onReplace && (0,external_wp_richText_namespaceObject.isEmpty)(value)) {
  38170. onReplace(content);
  38171. } else {
  38172. splitValue({
  38173. value,
  38174. pastedBlocks: content,
  38175. onReplace,
  38176. onSplit,
  38177. onSplitMiddle,
  38178. multilineTag
  38179. });
  38180. }
  38181. return;
  38182. }
  38183. let mode = onReplace && onSplit ? 'AUTO' : 'INLINE'; // Force the blocks mode when the user is pasting
  38184. // on a new line & the content resembles a shortcode.
  38185. // Otherwise it's going to be detected as inline
  38186. // and the shortcode won't be replaced.
  38187. if (mode === 'AUTO' && (0,external_wp_richText_namespaceObject.isEmpty)(value) && isShortcode(plainText)) {
  38188. mode = 'BLOCKS';
  38189. }
  38190. if (__unstableEmbedURLOnPaste && (0,external_wp_richText_namespaceObject.isEmpty)(value) && (0,external_wp_url_namespaceObject.isURL)(plainText.trim())) {
  38191. mode = 'BLOCKS';
  38192. }
  38193. const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
  38194. HTML: html,
  38195. plainText,
  38196. mode,
  38197. tagName,
  38198. preserveWhiteSpace
  38199. });
  38200. if (typeof content === 'string') {
  38201. let valueToInsert = (0,external_wp_richText_namespaceObject.create)({
  38202. html: content
  38203. }); // If the content should be multiline, we should process text
  38204. // separated by a line break as separate lines.
  38205. valueToInsert = adjustLines(valueToInsert, !!multilineTag);
  38206. addActiveFormats(valueToInsert, value.activeFormats);
  38207. onChange((0,external_wp_richText_namespaceObject.insert)(value, valueToInsert));
  38208. } else if (content.length > 0) {
  38209. if (onReplace && (0,external_wp_richText_namespaceObject.isEmpty)(value)) {
  38210. onReplace(content, content.length - 1, -1);
  38211. } else {
  38212. splitValue({
  38213. value,
  38214. pastedBlocks: content,
  38215. onReplace,
  38216. onSplit,
  38217. onSplitMiddle,
  38218. multilineTag
  38219. });
  38220. }
  38221. }
  38222. }
  38223. element.addEventListener('paste', _onPaste);
  38224. return () => {
  38225. element.removeEventListener('paste', _onPaste);
  38226. };
  38227. }, []);
  38228. }
  38229. /**
  38230. * Normalizes a given string of HTML to remove the Windows-specific "Fragment"
  38231. * comments and any preceeding and trailing content.
  38232. *
  38233. * @param {string} html the html to be normalized
  38234. * @return {string} the normalized html
  38235. */
  38236. function removeWindowsFragments(html) {
  38237. const startStr = '<!--StartFragment-->';
  38238. const startIdx = html.indexOf(startStr);
  38239. if (startIdx > -1) {
  38240. html = html.substring(startIdx + startStr.length);
  38241. } else {
  38242. // No point looking for EndFragment
  38243. return html;
  38244. }
  38245. const endStr = '<!--EndFragment-->';
  38246. const endIdx = html.indexOf(endStr);
  38247. if (endIdx > -1) {
  38248. html = html.substring(0, endIdx);
  38249. }
  38250. return html;
  38251. }
  38252. /**
  38253. * Removes the charset meta tag inserted by Chromium.
  38254. * See:
  38255. * - https://github.com/WordPress/gutenberg/issues/33585
  38256. * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4
  38257. *
  38258. * @param {string} html the html to be stripped of the meta tag.
  38259. * @return {string} the cleaned html
  38260. */
  38261. function removeCharsetMetaTag(html) {
  38262. const metaTag = `<meta charset='utf-8'>`;
  38263. if (html.startsWith(metaTag)) {
  38264. return html.slice(metaTag.length);
  38265. }
  38266. return html;
  38267. }
  38268. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/prevent-event-discovery.js
  38269. /**
  38270. * WordPress dependencies
  38271. */
  38272. function preventEventDiscovery(value) {
  38273. const searchText = 'tales of gutenberg';
  38274. const addText = ' 🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️';
  38275. const {
  38276. start,
  38277. text
  38278. } = value;
  38279. if (start < searchText.length) {
  38280. return value;
  38281. }
  38282. const charactersBefore = text.slice(start - searchText.length, start);
  38283. if (charactersBefore.toLowerCase() !== searchText) {
  38284. return value;
  38285. }
  38286. return (0,external_wp_richText_namespaceObject.insert)(value, addText);
  38287. }
  38288. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-input-rules.js
  38289. /**
  38290. * External dependencies
  38291. */
  38292. /**
  38293. * WordPress dependencies
  38294. */
  38295. /**
  38296. * Internal dependencies
  38297. */
  38298. // A robust way to retain selection position through various
  38299. // transforms is to insert a special character at the position and
  38300. // then recover it.
  38301. const START_OF_SELECTED_AREA = '\u0086';
  38302. function findSelection(blocks) {
  38303. let i = blocks.length;
  38304. while (i--) {
  38305. const attributeKey = (0,external_lodash_namespaceObject.findKey)(blocks[i].attributes, v => typeof v === 'string' && v.indexOf(START_OF_SELECTED_AREA) !== -1);
  38306. if (attributeKey) {
  38307. blocks[i].attributes[attributeKey] = blocks[i].attributes[attributeKey].replace(START_OF_SELECTED_AREA, '');
  38308. return blocks[i].clientId;
  38309. }
  38310. const nestedSelection = findSelection(blocks[i].innerBlocks);
  38311. if (nestedSelection) {
  38312. return nestedSelection;
  38313. }
  38314. }
  38315. }
  38316. function useInputRules(props) {
  38317. const {
  38318. __unstableMarkLastChangeAsPersistent,
  38319. __unstableMarkAutomaticChange
  38320. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  38321. const propsRef = (0,external_wp_element_namespaceObject.useRef)(props);
  38322. propsRef.current = props;
  38323. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  38324. function inputRule() {
  38325. const {
  38326. value,
  38327. onReplace,
  38328. selectionChange
  38329. } = propsRef.current;
  38330. if (!onReplace) {
  38331. return;
  38332. }
  38333. const {
  38334. start,
  38335. text
  38336. } = value;
  38337. const characterBefore = text.slice(start - 1, start); // The character right before the caret must be a plain space.
  38338. if (characterBefore !== ' ') {
  38339. return;
  38340. }
  38341. const trimmedTextBefore = text.slice(0, start).trim();
  38342. const prefixTransforms = (0,external_wp_blocks_namespaceObject.getBlockTransforms)('from').filter(_ref => {
  38343. let {
  38344. type
  38345. } = _ref;
  38346. return type === 'prefix';
  38347. });
  38348. const transformation = (0,external_wp_blocks_namespaceObject.findTransform)(prefixTransforms, _ref2 => {
  38349. let {
  38350. prefix
  38351. } = _ref2;
  38352. return trimmedTextBefore === prefix;
  38353. });
  38354. if (!transformation) {
  38355. return;
  38356. }
  38357. const content = (0,external_wp_richText_namespaceObject.toHTMLString)({
  38358. value: (0,external_wp_richText_namespaceObject.insert)(value, START_OF_SELECTED_AREA, 0, start)
  38359. });
  38360. const block = transformation.transform(content);
  38361. selectionChange(findSelection([block]));
  38362. onReplace([block]);
  38363. __unstableMarkAutomaticChange();
  38364. }
  38365. function onInput(event) {
  38366. const {
  38367. inputType,
  38368. type
  38369. } = event;
  38370. const {
  38371. value,
  38372. onChange,
  38373. __unstableAllowPrefixTransformations,
  38374. formatTypes
  38375. } = propsRef.current; // Only run input rules when inserting text.
  38376. if (inputType !== 'insertText' && type !== 'compositionend') {
  38377. return;
  38378. }
  38379. if (__unstableAllowPrefixTransformations && inputRule) {
  38380. inputRule();
  38381. }
  38382. const transformed = formatTypes.reduce((accumlator, _ref3) => {
  38383. let {
  38384. __unstableInputRule
  38385. } = _ref3;
  38386. if (__unstableInputRule) {
  38387. accumlator = __unstableInputRule(accumlator);
  38388. }
  38389. return accumlator;
  38390. }, preventEventDiscovery(value));
  38391. if (transformed !== value) {
  38392. __unstableMarkLastChangeAsPersistent();
  38393. onChange({ ...transformed,
  38394. activeFormats: value.activeFormats
  38395. });
  38396. __unstableMarkAutomaticChange();
  38397. }
  38398. }
  38399. element.addEventListener('input', onInput);
  38400. element.addEventListener('compositionend', onInput);
  38401. return () => {
  38402. element.removeEventListener('input', onInput);
  38403. element.removeEventListener('compositionend', onInput);
  38404. };
  38405. }, []);
  38406. }
  38407. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-enter.js
  38408. /**
  38409. * WordPress dependencies
  38410. */
  38411. /**
  38412. * WordPress dependencies
  38413. */
  38414. /**
  38415. * Internal dependencies
  38416. */
  38417. function useEnter(props) {
  38418. const {
  38419. __unstableMarkAutomaticChange
  38420. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  38421. const propsRef = (0,external_wp_element_namespaceObject.useRef)(props);
  38422. propsRef.current = props;
  38423. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  38424. function onKeyDown(event) {
  38425. if (event.defaultPrevented) {
  38426. return;
  38427. }
  38428. const {
  38429. removeEditorOnlyFormats,
  38430. value,
  38431. onReplace,
  38432. onSplit,
  38433. onSplitMiddle,
  38434. multilineTag,
  38435. onChange,
  38436. disableLineBreaks,
  38437. onSplitAtEnd
  38438. } = propsRef.current;
  38439. if (event.keyCode !== external_wp_keycodes_namespaceObject.ENTER) {
  38440. return;
  38441. }
  38442. event.preventDefault();
  38443. const _value = { ...value
  38444. };
  38445. _value.formats = removeEditorOnlyFormats(value);
  38446. const canSplit = onReplace && onSplit;
  38447. if (onReplace) {
  38448. const transforms = (0,external_wp_blocks_namespaceObject.getBlockTransforms)('from').filter(_ref => {
  38449. let {
  38450. type
  38451. } = _ref;
  38452. return type === 'enter';
  38453. });
  38454. const transformation = (0,external_wp_blocks_namespaceObject.findTransform)(transforms, item => {
  38455. return item.regExp.test(_value.text);
  38456. });
  38457. if (transformation) {
  38458. onReplace([transformation.transform({
  38459. content: _value.text
  38460. })]);
  38461. __unstableMarkAutomaticChange();
  38462. }
  38463. }
  38464. if (multilineTag) {
  38465. if (event.shiftKey) {
  38466. if (!disableLineBreaks) {
  38467. onChange((0,external_wp_richText_namespaceObject.insert)(_value, '\n'));
  38468. }
  38469. } else if (canSplit && (0,external_wp_richText_namespaceObject.__unstableIsEmptyLine)(_value)) {
  38470. splitValue({
  38471. value: _value,
  38472. onReplace,
  38473. onSplit,
  38474. onSplitMiddle,
  38475. multilineTag
  38476. });
  38477. } else {
  38478. onChange((0,external_wp_richText_namespaceObject.__unstableInsertLineSeparator)(_value));
  38479. }
  38480. } else {
  38481. const {
  38482. text,
  38483. start,
  38484. end
  38485. } = _value;
  38486. const canSplitAtEnd = onSplitAtEnd && start === end && end === text.length;
  38487. if (event.shiftKey || !canSplit && !canSplitAtEnd) {
  38488. if (!disableLineBreaks) {
  38489. onChange((0,external_wp_richText_namespaceObject.insert)(_value, '\n'));
  38490. }
  38491. } else if (!canSplit && canSplitAtEnd) {
  38492. onSplitAtEnd();
  38493. } else if (canSplit) {
  38494. splitValue({
  38495. value: _value,
  38496. onReplace,
  38497. onSplit,
  38498. onSplitMiddle,
  38499. multilineTag
  38500. });
  38501. }
  38502. }
  38503. }
  38504. element.addEventListener('keydown', onKeyDown);
  38505. return () => {
  38506. element.removeEventListener('keydown', onKeyDown);
  38507. };
  38508. }, []);
  38509. }
  38510. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-format-types.js
  38511. /**
  38512. * WordPress dependencies
  38513. */
  38514. /**
  38515. * Internal dependencies
  38516. */
  38517. function formatTypesSelector(select) {
  38518. return select(external_wp_richText_namespaceObject.store).getFormatTypes();
  38519. }
  38520. /**
  38521. * Set of all interactive content tags.
  38522. *
  38523. * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content
  38524. */
  38525. const interactiveContentTags = new Set(['a', 'audio', 'button', 'details', 'embed', 'iframe', 'input', 'label', 'select', 'textarea', 'video']);
  38526. /**
  38527. * This hook provides RichText with the `formatTypes` and its derived props from
  38528. * experimental format type settings.
  38529. *
  38530. * @param {Object} $0 Options
  38531. * @param {string} $0.clientId Block client ID.
  38532. * @param {string} $0.identifier Block attribute.
  38533. * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.
  38534. * @param {Array} $0.allowedFormats Allowed formats
  38535. */
  38536. function useFormatTypes(_ref) {
  38537. let {
  38538. clientId,
  38539. identifier,
  38540. withoutInteractiveFormatting,
  38541. allowedFormats
  38542. } = _ref;
  38543. const allFormatTypes = (0,external_wp_data_namespaceObject.useSelect)(formatTypesSelector, []);
  38544. const formatTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
  38545. return allFormatTypes.filter(_ref2 => {
  38546. let {
  38547. name,
  38548. tagName
  38549. } = _ref2;
  38550. if (allowedFormats && !allowedFormats.includes(name)) {
  38551. return false;
  38552. }
  38553. if (withoutInteractiveFormatting && interactiveContentTags.has(tagName)) {
  38554. return false;
  38555. }
  38556. return true;
  38557. });
  38558. }, [allFormatTypes, allowedFormats, interactiveContentTags]);
  38559. const keyedSelected = (0,external_wp_data_namespaceObject.useSelect)(select => formatTypes.reduce((accumulator, type) => {
  38560. if (type.__experimentalGetPropsForEditableTreePreparation) {
  38561. accumulator[type.name] = type.__experimentalGetPropsForEditableTreePreparation(select, {
  38562. richTextIdentifier: identifier,
  38563. blockClientId: clientId
  38564. });
  38565. }
  38566. return accumulator;
  38567. }, {}), [formatTypes, clientId, identifier]);
  38568. const dispatch = (0,external_wp_data_namespaceObject.useDispatch)();
  38569. const prepareHandlers = [];
  38570. const valueHandlers = [];
  38571. const changeHandlers = [];
  38572. const dependencies = [];
  38573. formatTypes.forEach(type => {
  38574. if (type.__experimentalCreatePrepareEditableTree) {
  38575. const selected = keyedSelected[type.name];
  38576. const handler = type.__experimentalCreatePrepareEditableTree(selected, {
  38577. richTextIdentifier: identifier,
  38578. blockClientId: clientId
  38579. });
  38580. if (type.__experimentalCreateOnChangeEditableValue) {
  38581. valueHandlers.push(handler);
  38582. } else {
  38583. prepareHandlers.push(handler);
  38584. }
  38585. for (const key in selected) {
  38586. dependencies.push(selected[key]);
  38587. }
  38588. }
  38589. if (type.__experimentalCreateOnChangeEditableValue) {
  38590. let dispatchers = {};
  38591. if (type.__experimentalGetPropsForEditableTreeChangeHandler) {
  38592. dispatchers = type.__experimentalGetPropsForEditableTreeChangeHandler(dispatch, {
  38593. richTextIdentifier: identifier,
  38594. blockClientId: clientId
  38595. });
  38596. }
  38597. changeHandlers.push(type.__experimentalCreateOnChangeEditableValue({ ...(keyedSelected[type.name] || {}),
  38598. ...dispatchers
  38599. }, {
  38600. richTextIdentifier: identifier,
  38601. blockClientId: clientId
  38602. }));
  38603. }
  38604. });
  38605. return {
  38606. formatTypes,
  38607. prepareHandlers,
  38608. valueHandlers,
  38609. changeHandlers,
  38610. dependencies
  38611. };
  38612. }
  38613. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-remove-browser-shortcuts.js
  38614. /**
  38615. * WordPress dependencies
  38616. */
  38617. /**
  38618. * Hook to prevent default behaviors for key combinations otherwise handled
  38619. * internally by RichText.
  38620. *
  38621. * @return {import('react').RefObject} The component to be rendered.
  38622. */
  38623. function useRemoveBrowserShortcuts() {
  38624. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  38625. function onKeydown(event) {
  38626. 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')) {
  38627. event.preventDefault();
  38628. }
  38629. }
  38630. node.addEventListener('keydown', onKeydown);
  38631. return () => {
  38632. node.addEventListener('keydown', onKeydown);
  38633. };
  38634. }, []);
  38635. }
  38636. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-shortcuts.js
  38637. /**
  38638. * WordPress dependencies
  38639. */
  38640. function useShortcuts(keyboardShortcuts) {
  38641. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  38642. function onKeyDown(event) {
  38643. for (const keyboardShortcut of keyboardShortcuts.current) {
  38644. keyboardShortcut(event);
  38645. }
  38646. }
  38647. element.addEventListener('keydown', onKeyDown);
  38648. return () => {
  38649. element.removeEventListener('keydown', onKeyDown);
  38650. };
  38651. }, []);
  38652. }
  38653. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-input-events.js
  38654. /**
  38655. * WordPress dependencies
  38656. */
  38657. function useInputEvents(inputEvents) {
  38658. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  38659. function onInput(event) {
  38660. for (const keyboardShortcut of inputEvents.current) {
  38661. keyboardShortcut(event);
  38662. }
  38663. }
  38664. element.addEventListener('input', onInput);
  38665. return () => {
  38666. element.removeEventListener('input', onInput);
  38667. };
  38668. }, []);
  38669. }
  38670. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-firefox-compat.js
  38671. /**
  38672. * WordPress dependencies
  38673. */
  38674. /**
  38675. * Internal dependencies
  38676. */
  38677. function useFirefoxCompat() {
  38678. const {
  38679. isMultiSelecting
  38680. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  38681. return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
  38682. function onFocus() {
  38683. if (!isMultiSelecting()) {
  38684. return;
  38685. } // This is a little hack to work around focus issues with nested
  38686. // editable elements in Firefox. For some reason the editable child
  38687. // element sometimes regains focus, while it should not be focusable
  38688. // and focus should remain on the editable parent element.
  38689. // To do: try to find the cause of the shifting focus.
  38690. const parentEditable = element.parentElement.closest('[contenteditable="true"]');
  38691. if (parentEditable) {
  38692. parentEditable.focus();
  38693. }
  38694. }
  38695. element.addEventListener('focus', onFocus);
  38696. return () => {
  38697. element.removeEventListener('focus', onFocus);
  38698. };
  38699. }, []);
  38700. }
  38701. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-edit.js
  38702. /**
  38703. * WordPress dependencies
  38704. */
  38705. /**
  38706. * External dependencies
  38707. */
  38708. function FormatEdit(_ref) {
  38709. let {
  38710. formatTypes,
  38711. onChange,
  38712. onFocus,
  38713. value,
  38714. forwardedRef
  38715. } = _ref;
  38716. return formatTypes.map(settings => {
  38717. const {
  38718. name,
  38719. edit: Edit
  38720. } = settings;
  38721. if (!Edit) {
  38722. return null;
  38723. }
  38724. const activeFormat = (0,external_wp_richText_namespaceObject.getActiveFormat)(value, name);
  38725. let isActive = activeFormat !== undefined;
  38726. const activeObject = (0,external_wp_richText_namespaceObject.getActiveObject)(value);
  38727. const isObjectActive = activeObject !== undefined && activeObject.type === name; // Edge case: un-collapsed link formats.
  38728. // If there is a missing link format at either end of the selection
  38729. // then we shouldn't show the Edit UI because the selection has exceeded
  38730. // the bounds of the link format.
  38731. // Also if the format objects don't match then we're dealing with two separate
  38732. // links so we should not allow the link to be modified over the top.
  38733. if (name === 'core/link' && !(0,external_wp_richText_namespaceObject.isCollapsed)(value)) {
  38734. const formats = value.formats;
  38735. const linkFormatAtStart = (0,external_lodash_namespaceObject.find)(formats[value.start], {
  38736. type: 'core/link'
  38737. });
  38738. const linkFormatAtEnd = (0,external_lodash_namespaceObject.find)(formats[value.end - 1], {
  38739. type: 'core/link'
  38740. });
  38741. if (!linkFormatAtStart || !linkFormatAtEnd || linkFormatAtStart !== linkFormatAtEnd) {
  38742. isActive = false;
  38743. }
  38744. }
  38745. return (0,external_wp_element_namespaceObject.createElement)(Edit, {
  38746. key: name,
  38747. isActive: isActive,
  38748. activeAttributes: isActive ? activeFormat.attributes || {} : {},
  38749. isObjectActive: isObjectActive,
  38750. activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
  38751. value: value,
  38752. onChange: onChange,
  38753. onFocus: onFocus,
  38754. contentRef: forwardedRef
  38755. });
  38756. });
  38757. }
  38758. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/index.js
  38759. /**
  38760. * External dependencies
  38761. */
  38762. /**
  38763. * WordPress dependencies
  38764. */
  38765. /**
  38766. * Internal dependencies
  38767. */
  38768. const keyboardShortcutContext = (0,external_wp_element_namespaceObject.createContext)();
  38769. const inputEventContext = (0,external_wp_element_namespaceObject.createContext)();
  38770. /**
  38771. * Removes props used for the native version of RichText so that they are not
  38772. * passed to the DOM element and log warnings.
  38773. *
  38774. * @param {Object} props Props to filter.
  38775. *
  38776. * @return {Object} Filtered props.
  38777. */
  38778. function removeNativeProps(props) {
  38779. return (0,external_lodash_namespaceObject.omit)(props, ['__unstableMobileNoFocusOnMount', 'deleteEnter', 'placeholderTextColor', 'textAlign', 'selectionColor', 'tagsToEliminate', 'rootTagsToEliminate', 'disableEditingMenu', 'fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'minWidth', 'maxWidth', 'setRef']);
  38780. }
  38781. function RichTextWrapper(_ref, forwardedRef) {
  38782. let {
  38783. children,
  38784. tagName = 'div',
  38785. value: originalValue = '',
  38786. onChange: originalOnChange,
  38787. isSelected: originalIsSelected,
  38788. multiline,
  38789. inlineToolbar,
  38790. wrapperClassName,
  38791. autocompleters,
  38792. onReplace,
  38793. placeholder,
  38794. allowedFormats,
  38795. formattingControls,
  38796. withoutInteractiveFormatting,
  38797. onRemove,
  38798. onMerge,
  38799. onSplit,
  38800. __unstableOnSplitAtEnd: onSplitAtEnd,
  38801. __unstableOnSplitMiddle: onSplitMiddle,
  38802. identifier,
  38803. preserveWhiteSpace,
  38804. __unstablePastePlainText: pastePlainText,
  38805. __unstableEmbedURLOnPaste,
  38806. __unstableDisableFormats: disableFormats,
  38807. disableLineBreaks,
  38808. unstableOnFocus,
  38809. __unstableAllowPrefixTransformations,
  38810. ...props
  38811. } = _ref;
  38812. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(RichTextWrapper);
  38813. identifier = identifier || instanceId;
  38814. props = removeNativeProps(props);
  38815. const anchorRef = (0,external_wp_element_namespaceObject.useRef)();
  38816. const {
  38817. clientId
  38818. } = useBlockEditContext();
  38819. const selector = select => {
  38820. const {
  38821. getSelectionStart,
  38822. getSelectionEnd
  38823. } = select(store);
  38824. const selectionStart = getSelectionStart();
  38825. const selectionEnd = getSelectionEnd();
  38826. let isSelected;
  38827. if (originalIsSelected === undefined) {
  38828. isSelected = selectionStart.clientId === clientId && selectionEnd.clientId === clientId && selectionStart.attributeKey === identifier;
  38829. } else if (originalIsSelected) {
  38830. isSelected = selectionStart.clientId === clientId;
  38831. }
  38832. return {
  38833. selectionStart: isSelected ? selectionStart.offset : undefined,
  38834. selectionEnd: isSelected ? selectionEnd.offset : undefined,
  38835. isSelected
  38836. };
  38837. }; // This selector must run on every render so the right selection state is
  38838. // retreived from the store on merge.
  38839. // To do: fix this somehow.
  38840. const {
  38841. selectionStart,
  38842. selectionEnd,
  38843. isSelected
  38844. } = (0,external_wp_data_namespaceObject.useSelect)(selector);
  38845. const {
  38846. selectionChange
  38847. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  38848. const multilineTag = getMultilineTag(multiline);
  38849. const adjustedAllowedFormats = getAllowedFormats({
  38850. allowedFormats,
  38851. formattingControls,
  38852. disableFormats
  38853. });
  38854. const hasFormats = !adjustedAllowedFormats || adjustedAllowedFormats.length > 0;
  38855. let adjustedValue = originalValue;
  38856. let adjustedOnChange = originalOnChange; // Handle deprecated format.
  38857. if (Array.isArray(originalValue)) {
  38858. adjustedValue = external_wp_blocks_namespaceObject.children.toHTML(originalValue);
  38859. adjustedOnChange = newValue => originalOnChange(external_wp_blocks_namespaceObject.children.fromDOM((0,external_wp_richText_namespaceObject.__unstableCreateElement)(document, newValue).childNodes));
  38860. }
  38861. const onSelectionChange = (0,external_wp_element_namespaceObject.useCallback)((start, end) => {
  38862. const selection = {};
  38863. const unset = start === undefined && end === undefined;
  38864. if (typeof start === 'number' || unset) {
  38865. selection.start = {
  38866. clientId,
  38867. attributeKey: identifier,
  38868. offset: start
  38869. };
  38870. }
  38871. if (typeof end === 'number' || unset) {
  38872. selection.end = {
  38873. clientId,
  38874. attributeKey: identifier,
  38875. offset: end
  38876. };
  38877. }
  38878. selectionChange(selection);
  38879. }, [clientId, identifier]);
  38880. const {
  38881. formatTypes,
  38882. prepareHandlers,
  38883. valueHandlers,
  38884. changeHandlers,
  38885. dependencies
  38886. } = useFormatTypes({
  38887. clientId,
  38888. identifier,
  38889. withoutInteractiveFormatting,
  38890. allowedFormats: adjustedAllowedFormats
  38891. });
  38892. function addEditorOnlyFormats(value) {
  38893. return valueHandlers.reduce((accumulator, fn) => fn(accumulator, value.text), value.formats);
  38894. }
  38895. function removeEditorOnlyFormats(value) {
  38896. formatTypes.forEach(formatType => {
  38897. // Remove formats created by prepareEditableTree, because they are editor only.
  38898. if (formatType.__experimentalCreatePrepareEditableTree) {
  38899. value = (0,external_wp_richText_namespaceObject.removeFormat)(value, formatType.name, 0, value.text.length);
  38900. }
  38901. });
  38902. return value.formats;
  38903. }
  38904. function addInvisibleFormats(value) {
  38905. return prepareHandlers.reduce((accumulator, fn) => fn(accumulator, value.text), value.formats);
  38906. }
  38907. const {
  38908. value,
  38909. onChange,
  38910. ref: richTextRef
  38911. } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({
  38912. value: adjustedValue,
  38913. onChange(html, _ref2) {
  38914. let {
  38915. __unstableFormats,
  38916. __unstableText
  38917. } = _ref2;
  38918. adjustedOnChange(html);
  38919. Object.values(changeHandlers).forEach(changeHandler => {
  38920. changeHandler(__unstableFormats, __unstableText);
  38921. });
  38922. },
  38923. selectionStart,
  38924. selectionEnd,
  38925. onSelectionChange,
  38926. placeholder,
  38927. __unstableIsSelected: isSelected,
  38928. __unstableMultilineTag: multilineTag,
  38929. __unstableDisableFormats: disableFormats,
  38930. preserveWhiteSpace,
  38931. __unstableDependencies: [...dependencies, tagName],
  38932. __unstableAfterParse: addEditorOnlyFormats,
  38933. __unstableBeforeSerialize: removeEditorOnlyFormats,
  38934. __unstableAddInvisibleFormats: addInvisibleFormats
  38935. });
  38936. const autocompleteProps = useBlockEditorAutocompleteProps({
  38937. onReplace,
  38938. completers: autocompleters,
  38939. record: value,
  38940. onChange
  38941. });
  38942. useCaretInFormat({
  38943. value
  38944. });
  38945. useMarkPersistent({
  38946. html: adjustedValue,
  38947. value
  38948. });
  38949. const keyboardShortcuts = (0,external_wp_element_namespaceObject.useRef)(new Set());
  38950. const inputEvents = (0,external_wp_element_namespaceObject.useRef)(new Set());
  38951. function onKeyDown(event) {
  38952. const {
  38953. keyCode
  38954. } = event;
  38955. if (event.defaultPrevented) {
  38956. return;
  38957. }
  38958. if (keyCode === external_wp_keycodes_namespaceObject.DELETE || keyCode === external_wp_keycodes_namespaceObject.BACKSPACE) {
  38959. const {
  38960. start,
  38961. end,
  38962. text
  38963. } = value;
  38964. const isReverse = keyCode === external_wp_keycodes_namespaceObject.BACKSPACE;
  38965. const hasActiveFormats = value.activeFormats && !!value.activeFormats.length; // Only process delete if the key press occurs at an uncollapsed edge.
  38966. if (!(0,external_wp_richText_namespaceObject.isCollapsed)(value) || hasActiveFormats || isReverse && start !== 0 || !isReverse && end !== text.length) {
  38967. return;
  38968. }
  38969. if (onMerge) {
  38970. onMerge(!isReverse);
  38971. } // Only handle remove on Backspace. This serves dual-purpose of being
  38972. // an intentional user interaction distinguishing between Backspace and
  38973. // Delete to remove the empty field, but also to avoid merge & remove
  38974. // causing destruction of two fields (merge, then removed merged).
  38975. if (onRemove && (0,external_wp_richText_namespaceObject.isEmpty)(value) && isReverse) {
  38976. onRemove(!isReverse);
  38977. }
  38978. event.preventDefault();
  38979. }
  38980. }
  38981. function onFocus() {
  38982. anchorRef.current.focus();
  38983. }
  38984. const TagName = tagName;
  38985. const content = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isSelected && (0,external_wp_element_namespaceObject.createElement)(keyboardShortcutContext.Provider, {
  38986. value: keyboardShortcuts
  38987. }, (0,external_wp_element_namespaceObject.createElement)(inputEventContext.Provider, {
  38988. value: inputEvents
  38989. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.__unstableSlotNameProvider, {
  38990. value: "__unstable-block-tools-after"
  38991. }, children && children({
  38992. value,
  38993. onChange,
  38994. onFocus
  38995. }), (0,external_wp_element_namespaceObject.createElement)(FormatEdit, {
  38996. value: value,
  38997. onChange: onChange,
  38998. onFocus: onFocus,
  38999. formatTypes: formatTypes,
  39000. forwardedRef: anchorRef
  39001. })))), isSelected && hasFormats && (0,external_wp_element_namespaceObject.createElement)(format_toolbar_container, {
  39002. inline: inlineToolbar,
  39003. anchorRef: anchorRef.current
  39004. }), (0,external_wp_element_namespaceObject.createElement)(TagName // Overridable props.
  39005. , _extends({
  39006. role: "textbox",
  39007. "aria-multiline": !disableLineBreaks,
  39008. "aria-label": placeholder
  39009. }, props, autocompleteProps, {
  39010. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([forwardedRef, autocompleteProps.ref, props.ref, richTextRef, useInputRules({
  39011. value,
  39012. onChange,
  39013. __unstableAllowPrefixTransformations,
  39014. formatTypes,
  39015. onReplace,
  39016. selectionChange
  39017. }), useRemoveBrowserShortcuts(), useShortcuts(keyboardShortcuts), useInputEvents(inputEvents), useUndoAutomaticChange(), usePasteHandler({
  39018. isSelected,
  39019. disableFormats,
  39020. onChange,
  39021. value,
  39022. formatTypes,
  39023. tagName,
  39024. onReplace,
  39025. onSplit,
  39026. onSplitMiddle,
  39027. __unstableEmbedURLOnPaste,
  39028. multilineTag,
  39029. preserveWhiteSpace,
  39030. pastePlainText
  39031. }), useEnter({
  39032. removeEditorOnlyFormats,
  39033. value,
  39034. onReplace,
  39035. onSplit,
  39036. onSplitMiddle,
  39037. multilineTag,
  39038. onChange,
  39039. disableLineBreaks,
  39040. onSplitAtEnd
  39041. }), useFirefoxCompat(), anchorRef]),
  39042. contentEditable: true,
  39043. suppressContentEditableWarning: true,
  39044. className: classnames_default()('block-editor-rich-text__editable', props.className, 'rich-text'),
  39045. onFocus: unstableOnFocus,
  39046. onKeyDown: onKeyDown
  39047. })));
  39048. if (!wrapperClassName) {
  39049. return content;
  39050. }
  39051. external_wp_deprecated_default()('wp.blockEditor.RichText wrapperClassName prop', {
  39052. since: '5.4',
  39053. alternative: 'className prop or create your own wrapper div',
  39054. version: '6.2'
  39055. });
  39056. const className = classnames_default()('block-editor-rich-text', wrapperClassName);
  39057. return (0,external_wp_element_namespaceObject.createElement)("div", {
  39058. className: className
  39059. }, content);
  39060. }
  39061. const ForwardedRichTextContainer = (0,external_wp_element_namespaceObject.forwardRef)(RichTextWrapper);
  39062. ForwardedRichTextContainer.Content = _ref3 => {
  39063. let {
  39064. value,
  39065. tagName: Tag,
  39066. multiline,
  39067. ...props
  39068. } = _ref3;
  39069. // Handle deprecated `children` and `node` sources.
  39070. if (Array.isArray(value)) {
  39071. value = external_wp_blocks_namespaceObject.children.toHTML(value);
  39072. }
  39073. const MultilineTag = getMultilineTag(multiline);
  39074. if (!value && MultilineTag) {
  39075. value = `<${MultilineTag}></${MultilineTag}>`;
  39076. }
  39077. const content = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, value);
  39078. if (Tag) {
  39079. return (0,external_wp_element_namespaceObject.createElement)(Tag, (0,external_lodash_namespaceObject.omit)(props, ['format']), content);
  39080. }
  39081. return content;
  39082. };
  39083. ForwardedRichTextContainer.isEmpty = value => {
  39084. return !value || value.length === 0;
  39085. };
  39086. /**
  39087. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
  39088. */
  39089. /* harmony default export */ var rich_text = (ForwardedRichTextContainer);
  39090. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/editable-text/index.js
  39091. /**
  39092. * WordPress dependencies
  39093. */
  39094. /**
  39095. * Internal dependencies
  39096. */
  39097. const EditableText = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  39098. return (0,external_wp_element_namespaceObject.createElement)(rich_text, _extends({
  39099. ref: ref
  39100. }, props, {
  39101. __unstableDisableFormats: true,
  39102. preserveWhiteSpace: true
  39103. }));
  39104. });
  39105. EditableText.Content = _ref => {
  39106. let {
  39107. value = '',
  39108. tagName: Tag = 'div',
  39109. ...props
  39110. } = _ref;
  39111. return (0,external_wp_element_namespaceObject.createElement)(Tag, props, value);
  39112. };
  39113. /**
  39114. * Renders an editable text input in which text formatting is not allowed.
  39115. */
  39116. /* harmony default export */ var editable_text = (EditableText);
  39117. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/plain-text/index.js
  39118. /**
  39119. * External dependencies
  39120. */
  39121. /**
  39122. * WordPress dependencies
  39123. */
  39124. /**
  39125. * Internal dependencies
  39126. */
  39127. /**
  39128. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/plain-text/README.md
  39129. */
  39130. const PlainText = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => {
  39131. let {
  39132. __experimentalVersion,
  39133. ...props
  39134. } = _ref;
  39135. if (__experimentalVersion === 2) {
  39136. return (0,external_wp_element_namespaceObject.createElement)(editable_text, _extends({
  39137. ref: ref
  39138. }, props));
  39139. }
  39140. const {
  39141. className,
  39142. onChange,
  39143. ...remainingProps
  39144. } = props;
  39145. return (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, _extends({
  39146. ref: ref,
  39147. className: classnames_default()('block-editor-plain-text', className),
  39148. onChange: event => onChange(event.target.value)
  39149. }, remainingProps));
  39150. });
  39151. /* harmony default export */ var plain_text = (PlainText);
  39152. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/responsive-block-control/label.js
  39153. /**
  39154. * WordPress dependencies
  39155. */
  39156. function ResponsiveBlockControlLabel(_ref) {
  39157. let {
  39158. property,
  39159. viewport,
  39160. desc
  39161. } = _ref;
  39162. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ResponsiveBlockControlLabel);
  39163. const accessibleLabel = desc || (0,external_wp_i18n_namespaceObject.sprintf)(
  39164. /* translators: 1: property name. 2: viewport name. */
  39165. (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);
  39166. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("span", {
  39167. "aria-describedby": `rbc-desc-${instanceId}`
  39168. }, viewport.label), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  39169. as: "span",
  39170. id: `rbc-desc-${instanceId}`
  39171. }, accessibleLabel));
  39172. }
  39173. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/responsive-block-control/index.js
  39174. /**
  39175. * External dependencies
  39176. */
  39177. /**
  39178. * WordPress dependencies
  39179. */
  39180. /**
  39181. * Internal dependencies
  39182. */
  39183. function ResponsiveBlockControl(props) {
  39184. const {
  39185. title,
  39186. property,
  39187. toggleLabel,
  39188. onIsResponsiveChange,
  39189. renderDefaultControl,
  39190. renderResponsiveControls,
  39191. isResponsive = false,
  39192. defaultLabel = {
  39193. id: 'all',
  39194. /* translators: 'Label. Used to signify a layout property (eg: margin, padding) will apply uniformly to all screensizes.' */
  39195. label: (0,external_wp_i18n_namespaceObject.__)('All')
  39196. },
  39197. viewports = [{
  39198. id: 'small',
  39199. label: (0,external_wp_i18n_namespaceObject.__)('Small screens')
  39200. }, {
  39201. id: 'medium',
  39202. label: (0,external_wp_i18n_namespaceObject.__)('Medium screens')
  39203. }, {
  39204. id: 'large',
  39205. label: (0,external_wp_i18n_namespaceObject.__)('Large screens')
  39206. }]
  39207. } = props;
  39208. if (!title || !property || !renderDefaultControl) {
  39209. return null;
  39210. }
  39211. const toggleControlLabel = toggleLabel || (0,external_wp_i18n_namespaceObject.sprintf)(
  39212. /* 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) */
  39213. (0,external_wp_i18n_namespaceObject.__)('Use the same %s on all screensizes.'), property);
  39214. /* translators: 'Help text for the responsive mode toggle control.' */
  39215. 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.');
  39216. const defaultControl = renderDefaultControl((0,external_wp_element_namespaceObject.createElement)(ResponsiveBlockControlLabel, {
  39217. property: property,
  39218. viewport: defaultLabel
  39219. }), defaultLabel);
  39220. const defaultResponsiveControls = () => {
  39221. return viewports.map(viewport => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
  39222. key: viewport.id
  39223. }, renderDefaultControl((0,external_wp_element_namespaceObject.createElement)(ResponsiveBlockControlLabel, {
  39224. property: property,
  39225. viewport: viewport
  39226. }), viewport)));
  39227. };
  39228. return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
  39229. className: "block-editor-responsive-block-control"
  39230. }, (0,external_wp_element_namespaceObject.createElement)("legend", {
  39231. className: "block-editor-responsive-block-control__title"
  39232. }, title), (0,external_wp_element_namespaceObject.createElement)("div", {
  39233. className: "block-editor-responsive-block-control__inner"
  39234. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
  39235. className: "block-editor-responsive-block-control__toggle",
  39236. label: toggleControlLabel,
  39237. checked: !isResponsive,
  39238. onChange: onIsResponsiveChange,
  39239. help: toggleHelpText
  39240. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  39241. className: classnames_default()('block-editor-responsive-block-control__group', {
  39242. 'is-responsive': isResponsive
  39243. })
  39244. }, !isResponsive && defaultControl, isResponsive && (renderResponsiveControls ? renderResponsiveControls(viewports) : defaultResponsiveControls()))));
  39245. }
  39246. /* harmony default export */ var responsive_block_control = (ResponsiveBlockControl);
  39247. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/shortcut.js
  39248. /**
  39249. * WordPress dependencies
  39250. */
  39251. /**
  39252. * Internal dependencies
  39253. */
  39254. function RichTextShortcut(_ref) {
  39255. let {
  39256. character,
  39257. type,
  39258. onUse
  39259. } = _ref;
  39260. const keyboardShortcuts = (0,external_wp_element_namespaceObject.useContext)(keyboardShortcutContext);
  39261. const onUseRef = (0,external_wp_element_namespaceObject.useRef)();
  39262. onUseRef.current = onUse;
  39263. (0,external_wp_element_namespaceObject.useEffect)(() => {
  39264. function callback(event) {
  39265. if (external_wp_keycodes_namespaceObject.isKeyboardEvent[type](event, character)) {
  39266. onUseRef.current();
  39267. event.preventDefault();
  39268. }
  39269. }
  39270. keyboardShortcuts.current.add(callback);
  39271. return () => {
  39272. keyboardShortcuts.current.delete(callback);
  39273. };
  39274. }, [character, type]);
  39275. return null;
  39276. }
  39277. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/toolbar-button.js
  39278. /**
  39279. * WordPress dependencies
  39280. */
  39281. function RichTextToolbarButton(_ref) {
  39282. let {
  39283. name,
  39284. shortcutType,
  39285. shortcutCharacter,
  39286. ...props
  39287. } = _ref;
  39288. let shortcut;
  39289. let fillName = 'RichText.ToolbarControls';
  39290. if (name) {
  39291. fillName += `.${name}`;
  39292. }
  39293. if (shortcutType && shortcutCharacter) {
  39294. shortcut = external_wp_keycodes_namespaceObject.displayShortcut[shortcutType](shortcutCharacter);
  39295. }
  39296. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
  39297. name: fillName
  39298. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, _extends({}, props, {
  39299. shortcut: shortcut
  39300. })));
  39301. }
  39302. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/input-event.js
  39303. /**
  39304. * WordPress dependencies
  39305. */
  39306. /**
  39307. * Internal dependencies
  39308. */
  39309. function __unstableRichTextInputEvent(_ref) {
  39310. let {
  39311. inputType,
  39312. onInput
  39313. } = _ref;
  39314. const callbacks = (0,external_wp_element_namespaceObject.useContext)(inputEventContext);
  39315. const onInputRef = (0,external_wp_element_namespaceObject.useRef)();
  39316. onInputRef.current = onInput;
  39317. (0,external_wp_element_namespaceObject.useEffect)(() => {
  39318. function callback(event) {
  39319. if (event.inputType === inputType) {
  39320. onInputRef.current();
  39321. event.preventDefault();
  39322. }
  39323. }
  39324. callbacks.current.add(callback);
  39325. return () => {
  39326. callbacks.current.delete(callback);
  39327. };
  39328. }, [inputType]);
  39329. return null;
  39330. }
  39331. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/tool-selector/index.js
  39332. /**
  39333. * WordPress dependencies
  39334. */
  39335. /**
  39336. * Internal dependencies
  39337. */
  39338. const selectIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  39339. xmlns: "http://www.w3.org/2000/svg",
  39340. width: "24",
  39341. height: "24",
  39342. viewBox: "0 0 24 24"
  39343. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  39344. 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"
  39345. }));
  39346. function ToolSelector(props, ref) {
  39347. const isNavigationTool = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isNavigationMode(), []);
  39348. const {
  39349. setNavigationMode
  39350. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  39351. const onSwitchMode = mode => {
  39352. setNavigationMode(mode === 'edit' ? false : true);
  39353. };
  39354. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  39355. renderToggle: _ref => {
  39356. let {
  39357. isOpen,
  39358. onToggle
  39359. } = _ref;
  39360. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
  39361. ref: ref,
  39362. icon: isNavigationTool ? selectIcon : library_edit,
  39363. "aria-expanded": isOpen,
  39364. "aria-haspopup": "true",
  39365. onClick: onToggle
  39366. /* translators: button label text should, if possible, be under 16 characters. */
  39367. ,
  39368. label: (0,external_wp_i18n_namespaceObject.__)('Tools')
  39369. }));
  39370. },
  39371. position: "bottom right",
  39372. renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, {
  39373. role: "menu",
  39374. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Tools')
  39375. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
  39376. value: isNavigationTool ? 'select' : 'edit',
  39377. onSelect: onSwitchMode,
  39378. choices: [{
  39379. value: 'edit',
  39380. label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, {
  39381. icon: library_edit
  39382. }), (0,external_wp_i18n_namespaceObject.__)('Edit'))
  39383. }, {
  39384. value: 'select',
  39385. label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, selectIcon, (0,external_wp_i18n_namespaceObject.__)('Select'))
  39386. }]
  39387. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  39388. className: "block-editor-tool-selector__help"
  39389. }, (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.')))
  39390. });
  39391. }
  39392. /* harmony default export */ var tool_selector = ((0,external_wp_element_namespaceObject.forwardRef)(ToolSelector));
  39393. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/unit-control/index.js
  39394. /**
  39395. * WordPress dependencies
  39396. */
  39397. /**
  39398. * Internal dependencies
  39399. */
  39400. function UnitControl(_ref) {
  39401. let {
  39402. units: unitsProp,
  39403. ...props
  39404. } = _ref;
  39405. const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
  39406. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw'],
  39407. units: unitsProp
  39408. });
  39409. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, _extends({
  39410. units: units
  39411. }, props));
  39412. }
  39413. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-left.js
  39414. /**
  39415. * WordPress dependencies
  39416. */
  39417. const arrowLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  39418. xmlns: "http://www.w3.org/2000/svg",
  39419. viewBox: "0 0 24 24"
  39420. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  39421. 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"
  39422. }));
  39423. /* harmony default export */ var arrow_left = (arrowLeft);
  39424. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/button.js
  39425. /**
  39426. * WordPress dependencies
  39427. */
  39428. /**
  39429. * Internal dependencies
  39430. */
  39431. class URLInputButton extends external_wp_element_namespaceObject.Component {
  39432. constructor() {
  39433. super(...arguments);
  39434. this.toggle = this.toggle.bind(this);
  39435. this.submitLink = this.submitLink.bind(this);
  39436. this.state = {
  39437. expanded: false
  39438. };
  39439. }
  39440. toggle() {
  39441. this.setState({
  39442. expanded: !this.state.expanded
  39443. });
  39444. }
  39445. submitLink(event) {
  39446. event.preventDefault();
  39447. this.toggle();
  39448. }
  39449. render() {
  39450. const {
  39451. url,
  39452. onChange
  39453. } = this.props;
  39454. const {
  39455. expanded
  39456. } = this.state;
  39457. const buttonLabel = url ? (0,external_wp_i18n_namespaceObject.__)('Edit link') : (0,external_wp_i18n_namespaceObject.__)('Insert link');
  39458. return (0,external_wp_element_namespaceObject.createElement)("div", {
  39459. className: "block-editor-url-input__button"
  39460. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  39461. icon: library_link,
  39462. label: buttonLabel,
  39463. onClick: this.toggle,
  39464. className: "components-toolbar__control",
  39465. isPressed: !!url
  39466. }), expanded && (0,external_wp_element_namespaceObject.createElement)("form", {
  39467. className: "block-editor-url-input__button-modal",
  39468. onSubmit: this.submitLink
  39469. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  39470. className: "block-editor-url-input__button-modal-line"
  39471. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  39472. className: "block-editor-url-input__back",
  39473. icon: arrow_left,
  39474. label: (0,external_wp_i18n_namespaceObject.__)('Close'),
  39475. onClick: this.toggle
  39476. }), (0,external_wp_element_namespaceObject.createElement)(url_input, {
  39477. value: url || '',
  39478. onChange: onChange
  39479. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  39480. icon: keyboard_return,
  39481. label: (0,external_wp_i18n_namespaceObject.__)('Submit'),
  39482. type: "submit"
  39483. }))));
  39484. }
  39485. }
  39486. /**
  39487. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md
  39488. */
  39489. /* harmony default export */ var url_input_button = (URLInputButton);
  39490. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js
  39491. /**
  39492. * WordPress dependencies
  39493. */
  39494. const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  39495. xmlns: "http://www.w3.org/2000/svg",
  39496. viewBox: "0 0 24 24"
  39497. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  39498. 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"
  39499. }));
  39500. /* harmony default export */ var library_close = (close_close);
  39501. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/image-url-input-ui.js
  39502. /**
  39503. * External dependencies
  39504. */
  39505. /**
  39506. * WordPress dependencies
  39507. */
  39508. /**
  39509. * Internal dependencies
  39510. */
  39511. const LINK_DESTINATION_NONE = 'none';
  39512. const LINK_DESTINATION_CUSTOM = 'custom';
  39513. const LINK_DESTINATION_MEDIA = 'media';
  39514. const LINK_DESTINATION_ATTACHMENT = 'attachment';
  39515. const NEW_TAB_REL = ['noreferrer', 'noopener'];
  39516. const icon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  39517. viewBox: "0 0 24 24",
  39518. xmlns: "http://www.w3.org/2000/svg"
  39519. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  39520. d: "M0,0h24v24H0V0z",
  39521. fill: "none"
  39522. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  39523. 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"
  39524. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  39525. d: "m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z"
  39526. }));
  39527. const ImageURLInputUI = _ref => {
  39528. let {
  39529. linkDestination,
  39530. onChangeUrl,
  39531. url,
  39532. mediaType = 'image',
  39533. mediaUrl,
  39534. mediaLink,
  39535. linkTarget,
  39536. linkClass,
  39537. rel
  39538. } = _ref;
  39539. const [isOpen, setIsOpen] = (0,external_wp_element_namespaceObject.useState)(false);
  39540. const openLinkUI = (0,external_wp_element_namespaceObject.useCallback)(() => {
  39541. setIsOpen(true);
  39542. });
  39543. const [isEditingLink, setIsEditingLink] = (0,external_wp_element_namespaceObject.useState)(false);
  39544. const [urlInput, setUrlInput] = (0,external_wp_element_namespaceObject.useState)(null);
  39545. const autocompleteRef = (0,external_wp_element_namespaceObject.useRef)(null);
  39546. const startEditLink = (0,external_wp_element_namespaceObject.useCallback)(() => {
  39547. if (linkDestination === LINK_DESTINATION_MEDIA || linkDestination === LINK_DESTINATION_ATTACHMENT) {
  39548. setUrlInput('');
  39549. }
  39550. setIsEditingLink(true);
  39551. });
  39552. const stopEditLink = (0,external_wp_element_namespaceObject.useCallback)(() => {
  39553. setIsEditingLink(false);
  39554. });
  39555. const closeLinkUI = (0,external_wp_element_namespaceObject.useCallback)(() => {
  39556. setUrlInput(null);
  39557. stopEditLink();
  39558. setIsOpen(false);
  39559. });
  39560. const getUpdatedLinkTargetSettings = value => {
  39561. const newLinkTarget = value ? '_blank' : undefined;
  39562. let updatedRel;
  39563. if (newLinkTarget) {
  39564. const rels = (rel !== null && rel !== void 0 ? rel : '').split(' ');
  39565. NEW_TAB_REL.forEach(relVal => {
  39566. if (!rels.includes(relVal)) {
  39567. rels.push(relVal);
  39568. }
  39569. });
  39570. updatedRel = rels.join(' ');
  39571. } else {
  39572. const rels = (rel !== null && rel !== void 0 ? rel : '').split(' ').filter(relVal => NEW_TAB_REL.includes(relVal) === false);
  39573. updatedRel = rels.length ? rels.join(' ') : undefined;
  39574. }
  39575. return {
  39576. linkTarget: newLinkTarget,
  39577. rel: updatedRel
  39578. };
  39579. };
  39580. const onFocusOutside = (0,external_wp_element_namespaceObject.useCallback)(() => {
  39581. return event => {
  39582. // The autocomplete suggestions list renders in a separate popover (in a portal),
  39583. // so onFocusOutside fails to detect that a click on a suggestion occurred in the
  39584. // LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and
  39585. // return to avoid the popover being closed.
  39586. const autocompleteElement = autocompleteRef.current;
  39587. if (autocompleteElement && autocompleteElement.contains(event.target)) {
  39588. return;
  39589. }
  39590. setIsOpen(false);
  39591. setUrlInput(null);
  39592. stopEditLink();
  39593. };
  39594. });
  39595. const onSubmitLinkChange = (0,external_wp_element_namespaceObject.useCallback)(() => {
  39596. return event => {
  39597. if (urlInput) {
  39598. var _getLinkDestinations$;
  39599. // It is possible the entered URL actually matches a named link destination.
  39600. // This check will ensure our link destination is correct.
  39601. const selectedDestination = ((_getLinkDestinations$ = getLinkDestinations().find(destination => destination.url === urlInput)) === null || _getLinkDestinations$ === void 0 ? void 0 : _getLinkDestinations$.linkDestination) || LINK_DESTINATION_CUSTOM;
  39602. onChangeUrl({
  39603. href: urlInput,
  39604. linkDestination: selectedDestination
  39605. });
  39606. }
  39607. stopEditLink();
  39608. setUrlInput(null);
  39609. event.preventDefault();
  39610. };
  39611. });
  39612. const onLinkRemove = (0,external_wp_element_namespaceObject.useCallback)(() => {
  39613. onChangeUrl({
  39614. linkDestination: LINK_DESTINATION_NONE,
  39615. href: ''
  39616. });
  39617. });
  39618. const getLinkDestinations = () => {
  39619. const linkDestinations = [{
  39620. linkDestination: LINK_DESTINATION_MEDIA,
  39621. title: (0,external_wp_i18n_namespaceObject.__)('Media File'),
  39622. url: mediaType === 'image' ? mediaUrl : undefined,
  39623. icon
  39624. }];
  39625. if (mediaType === 'image' && mediaLink) {
  39626. linkDestinations.push({
  39627. linkDestination: LINK_DESTINATION_ATTACHMENT,
  39628. title: (0,external_wp_i18n_namespaceObject.__)('Attachment Page'),
  39629. url: mediaType === 'image' ? mediaLink : undefined,
  39630. icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  39631. viewBox: "0 0 24 24",
  39632. xmlns: "http://www.w3.org/2000/svg"
  39633. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  39634. d: "M0 0h24v24H0V0z",
  39635. fill: "none"
  39636. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  39637. 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"
  39638. }))
  39639. });
  39640. }
  39641. return linkDestinations;
  39642. };
  39643. const onSetHref = value => {
  39644. const linkDestinations = getLinkDestinations();
  39645. let linkDestinationInput;
  39646. if (!value) {
  39647. linkDestinationInput = LINK_DESTINATION_NONE;
  39648. } else {
  39649. linkDestinationInput = ((0,external_lodash_namespaceObject.find)(linkDestinations, destination => {
  39650. return destination.url === value;
  39651. }) || {
  39652. linkDestination: LINK_DESTINATION_CUSTOM
  39653. }).linkDestination;
  39654. }
  39655. onChangeUrl({
  39656. linkDestination: linkDestinationInput,
  39657. href: value
  39658. });
  39659. };
  39660. const onSetNewTab = value => {
  39661. const updatedLinkTarget = getUpdatedLinkTargetSettings(value);
  39662. onChangeUrl(updatedLinkTarget);
  39663. };
  39664. const onSetLinkRel = value => {
  39665. onChangeUrl({
  39666. rel: value
  39667. });
  39668. };
  39669. const onSetLinkClass = value => {
  39670. onChangeUrl({
  39671. linkClass: value
  39672. });
  39673. };
  39674. 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, {
  39675. label: (0,external_wp_i18n_namespaceObject.__)('Open in new tab'),
  39676. onChange: onSetNewTab,
  39677. checked: linkTarget === '_blank'
  39678. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  39679. label: (0,external_wp_i18n_namespaceObject.__)('Link Rel'),
  39680. value: rel !== null && rel !== void 0 ? rel : '',
  39681. onChange: onSetLinkRel
  39682. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  39683. label: (0,external_wp_i18n_namespaceObject.__)('Link CSS Class'),
  39684. value: linkClass || '',
  39685. onChange: onSetLinkClass
  39686. }));
  39687. const linkEditorValue = urlInput !== null ? urlInput : url;
  39688. const urlLabel = ((0,external_lodash_namespaceObject.find)(getLinkDestinations(), ['linkDestination', linkDestination]) || {}).title;
  39689. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  39690. icon: library_link,
  39691. className: "components-toolbar__control",
  39692. label: url ? (0,external_wp_i18n_namespaceObject.__)('Edit link') : (0,external_wp_i18n_namespaceObject.__)('Insert link'),
  39693. "aria-expanded": isOpen,
  39694. onClick: openLinkUI
  39695. }), isOpen && (0,external_wp_element_namespaceObject.createElement)(url_popover, {
  39696. onFocusOutside: onFocusOutside(),
  39697. onClose: closeLinkUI,
  39698. renderSettings: () => advancedOptions,
  39699. 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, {
  39700. key: link.linkDestination,
  39701. icon: link.icon,
  39702. onClick: () => {
  39703. setUrlInput(null);
  39704. onSetHref(link.url);
  39705. stopEditLink();
  39706. }
  39707. }, link.title)))
  39708. }, (!url || isEditingLink) && (0,external_wp_element_namespaceObject.createElement)(url_popover.LinkEditor, {
  39709. className: "block-editor-format-toolbar__link-container-content",
  39710. value: linkEditorValue,
  39711. onChangeInputValue: setUrlInput,
  39712. onSubmit: onSubmitLinkChange(),
  39713. autocompleteRef: autocompleteRef
  39714. }), url && !isEditingLink && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(url_popover.LinkViewer, {
  39715. className: "block-editor-format-toolbar__link-container-content",
  39716. url: url,
  39717. onEditLinkClick: startEditLink,
  39718. urlLabel: urlLabel
  39719. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  39720. icon: library_close,
  39721. label: (0,external_wp_i18n_namespaceObject.__)('Remove link'),
  39722. onClick: onLinkRemove
  39723. }))));
  39724. };
  39725. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/preview-options/index.js
  39726. /**
  39727. * External dependencies
  39728. */
  39729. /**
  39730. * WordPress dependencies
  39731. */
  39732. function PreviewOptions(_ref) {
  39733. let {
  39734. children,
  39735. className,
  39736. isEnabled = true,
  39737. deviceType,
  39738. setDeviceType
  39739. } = _ref;
  39740. const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
  39741. if (isMobile) return null;
  39742. const popoverProps = {
  39743. className: classnames_default()(className, 'block-editor-post-preview__dropdown-content'),
  39744. position: 'bottom left'
  39745. };
  39746. const toggleProps = {
  39747. variant: 'tertiary',
  39748. className: 'block-editor-post-preview__button-toggle',
  39749. disabled: !isEnabled,
  39750. /* translators: button label text should, if possible, be under 16 characters. */
  39751. children: (0,external_wp_i18n_namespaceObject.__)('Preview')
  39752. };
  39753. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
  39754. className: "block-editor-post-preview__dropdown",
  39755. popoverProps: popoverProps,
  39756. toggleProps: toggleProps,
  39757. icon: null
  39758. }, () => (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, {
  39759. className: "block-editor-post-preview__button-resize",
  39760. onClick: () => setDeviceType('Desktop'),
  39761. icon: deviceType === 'Desktop' && library_check
  39762. }, (0,external_wp_i18n_namespaceObject.__)('Desktop')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  39763. className: "block-editor-post-preview__button-resize",
  39764. onClick: () => setDeviceType('Tablet'),
  39765. icon: deviceType === 'Tablet' && library_check
  39766. }, (0,external_wp_i18n_namespaceObject.__)('Tablet')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  39767. className: "block-editor-post-preview__button-resize",
  39768. onClick: () => setDeviceType('Mobile'),
  39769. icon: deviceType === 'Mobile' && library_check
  39770. }, (0,external_wp_i18n_namespaceObject.__)('Mobile'))), children));
  39771. }
  39772. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-resize-canvas/index.js
  39773. /**
  39774. * WordPress dependencies
  39775. */
  39776. /**
  39777. * Function to resize the editor window.
  39778. *
  39779. * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)
  39780. *
  39781. * @return {Object} Inline styles to be added to resizable container.
  39782. */
  39783. function useResizeCanvas(deviceType) {
  39784. const [actualWidth, updateActualWidth] = (0,external_wp_element_namespaceObject.useState)(window.innerWidth);
  39785. (0,external_wp_element_namespaceObject.useEffect)(() => {
  39786. if (deviceType === 'Desktop') {
  39787. return;
  39788. }
  39789. const resizeListener = () => updateActualWidth(window.innerWidth);
  39790. window.addEventListener('resize', resizeListener);
  39791. return () => {
  39792. window.removeEventListener('resize', resizeListener);
  39793. };
  39794. }, [deviceType]);
  39795. const getCanvasWidth = device => {
  39796. let deviceWidth;
  39797. switch (device) {
  39798. case 'Tablet':
  39799. deviceWidth = 780;
  39800. break;
  39801. case 'Mobile':
  39802. deviceWidth = 360;
  39803. break;
  39804. default:
  39805. return null;
  39806. }
  39807. return deviceWidth < actualWidth ? deviceWidth : actualWidth;
  39808. };
  39809. const marginValue = () => window.innerHeight < 800 ? 36 : 72;
  39810. const contentInlineStyles = device => {
  39811. const height = device === 'Mobile' ? '768px' : '1024px';
  39812. switch (device) {
  39813. case 'Tablet':
  39814. case 'Mobile':
  39815. return {
  39816. width: getCanvasWidth(device),
  39817. margin: marginValue() + 'px auto',
  39818. height,
  39819. borderRadius: '2px 2px 2px 2px',
  39820. border: '1px solid #ddd',
  39821. overflowY: 'auto'
  39822. };
  39823. default:
  39824. return null;
  39825. }
  39826. };
  39827. return contentInlineStyles(deviceType);
  39828. }
  39829. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/skip-to-selected-block/index.js
  39830. /**
  39831. * WordPress dependencies
  39832. */
  39833. /**
  39834. * Internal dependencies
  39835. */
  39836. const SkipToSelectedBlock = _ref => {
  39837. let {
  39838. selectedBlockClientId
  39839. } = _ref;
  39840. const ref = useBlockRef(selectedBlockClientId);
  39841. const onClick = () => {
  39842. ref.current.focus();
  39843. };
  39844. return selectedBlockClientId ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  39845. variant: "secondary",
  39846. className: "block-editor-skip-to-selected-block",
  39847. onClick: onClick
  39848. }, (0,external_wp_i18n_namespaceObject.__)('Skip to the selected block')) : null;
  39849. };
  39850. /**
  39851. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/skip-to-selected-block/README.md
  39852. */
  39853. /* harmony default export */ var skip_to_selected_block = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  39854. return {
  39855. selectedBlockClientId: select(store).getBlockSelectionStart()
  39856. };
  39857. })(SkipToSelectedBlock));
  39858. ;// CONCATENATED MODULE: external ["wp","wordcount"]
  39859. var external_wp_wordcount_namespaceObject = window["wp"]["wordcount"];
  39860. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/multi-selection-inspector/index.js
  39861. /**
  39862. * WordPress dependencies
  39863. */
  39864. /**
  39865. * Internal dependencies
  39866. */
  39867. function MultiSelectionInspector(_ref) {
  39868. let {
  39869. blocks
  39870. } = _ref;
  39871. const words = (0,external_wp_wordcount_namespaceObject.count)((0,external_wp_blocks_namespaceObject.serialize)(blocks), 'words');
  39872. return (0,external_wp_element_namespaceObject.createElement)("div", {
  39873. className: "block-editor-multi-selection-inspector__card"
  39874. }, (0,external_wp_element_namespaceObject.createElement)(block_icon, {
  39875. icon: library_copy,
  39876. showColors: true
  39877. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  39878. className: "block-editor-multi-selection-inspector__card-content"
  39879. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  39880. className: "block-editor-multi-selection-inspector__card-title"
  39881. }, (0,external_wp_i18n_namespaceObject.sprintf)(
  39882. /* translators: %d: number of blocks */
  39883. (0,external_wp_i18n_namespaceObject._n)('%d block', '%d blocks', blocks.length), blocks.length)), (0,external_wp_element_namespaceObject.createElement)("div", {
  39884. className: "block-editor-multi-selection-inspector__card-description"
  39885. }, (0,external_wp_i18n_namespaceObject.sprintf)(
  39886. /* translators: %d: number of words */
  39887. (0,external_wp_i18n_namespaceObject._n)('%d word', '%d words', words), words))));
  39888. }
  39889. /* harmony default export */ var multi_selection_inspector = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  39890. const {
  39891. getMultiSelectedBlocks
  39892. } = select(store);
  39893. return {
  39894. blocks: getMultiSelectedBlocks()
  39895. };
  39896. })(MultiSelectionInspector));
  39897. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-style-picker/index.js
  39898. /**
  39899. * WordPress dependencies
  39900. */
  39901. /**
  39902. * Internal dependencies
  39903. */
  39904. function DefaultStylePicker(_ref) {
  39905. let {
  39906. blockName
  39907. } = _ref;
  39908. const {
  39909. preferredStyle,
  39910. onUpdatePreferredStyleVariations,
  39911. styles
  39912. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  39913. var _preferredStyleVariat, _preferredStyleVariat2;
  39914. const settings = select(store).getSettings();
  39915. const preferredStyleVariations = settings.__experimentalPreferredStyleVariations;
  39916. return {
  39917. preferredStyle: preferredStyleVariations === null || preferredStyleVariations === void 0 ? void 0 : (_preferredStyleVariat = preferredStyleVariations.value) === null || _preferredStyleVariat === void 0 ? void 0 : _preferredStyleVariat[blockName],
  39918. onUpdatePreferredStyleVariations: (_preferredStyleVariat2 = preferredStyleVariations === null || preferredStyleVariations === void 0 ? void 0 : preferredStyleVariations.onChange) !== null && _preferredStyleVariat2 !== void 0 ? _preferredStyleVariat2 : null,
  39919. styles: select(external_wp_blocks_namespaceObject.store).getBlockStyles(blockName)
  39920. };
  39921. }, [blockName]);
  39922. const selectOptions = (0,external_wp_element_namespaceObject.useMemo)(() => [{
  39923. label: (0,external_wp_i18n_namespaceObject.__)('Not set'),
  39924. value: ''
  39925. }, ...styles.map(_ref2 => {
  39926. let {
  39927. label,
  39928. name
  39929. } = _ref2;
  39930. return {
  39931. label,
  39932. value: name
  39933. };
  39934. })], [styles]);
  39935. const defaultStyleName = (0,external_wp_element_namespaceObject.useMemo)(() => {
  39936. var _getDefaultStyle;
  39937. return (_getDefaultStyle = getDefaultStyle(styles)) === null || _getDefaultStyle === void 0 ? void 0 : _getDefaultStyle.name;
  39938. }, [styles]);
  39939. const selectOnChange = (0,external_wp_element_namespaceObject.useCallback)(blockStyle => {
  39940. onUpdatePreferredStyleVariations(blockName, blockStyle);
  39941. }, [blockName, onUpdatePreferredStyleVariations]); // Until the functionality is migrated to global styles,
  39942. // only show the default style picker if a non-default style has already been selected.
  39943. if (!preferredStyle || preferredStyle === defaultStyleName) {
  39944. return null;
  39945. }
  39946. return onUpdatePreferredStyleVariations && (0,external_wp_element_namespaceObject.createElement)("div", {
  39947. className: "default-style-picker__default-switcher"
  39948. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
  39949. options: selectOptions,
  39950. value: preferredStyle || '',
  39951. label: (0,external_wp_i18n_namespaceObject.__)('Default Style'),
  39952. onChange: selectOnChange
  39953. }));
  39954. }
  39955. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-inspector/index.js
  39956. /**
  39957. * WordPress dependencies
  39958. */
  39959. /**
  39960. * Internal dependencies
  39961. */
  39962. const BlockInspector = _ref => {
  39963. let {
  39964. showNoBlockSelectedMessage = true
  39965. } = _ref;
  39966. const {
  39967. count,
  39968. hasBlockStyles,
  39969. selectedBlockName,
  39970. selectedBlockClientId,
  39971. blockType
  39972. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  39973. const {
  39974. getSelectedBlockClientId,
  39975. getSelectedBlockCount,
  39976. getBlockName
  39977. } = select(store);
  39978. const {
  39979. getBlockStyles
  39980. } = select(external_wp_blocks_namespaceObject.store);
  39981. const _selectedBlockClientId = getSelectedBlockClientId();
  39982. const _selectedBlockName = _selectedBlockClientId && getBlockName(_selectedBlockClientId);
  39983. const _blockType = _selectedBlockName && (0,external_wp_blocks_namespaceObject.getBlockType)(_selectedBlockName);
  39984. const blockStyles = _selectedBlockName && getBlockStyles(_selectedBlockName);
  39985. return {
  39986. count: getSelectedBlockCount(),
  39987. selectedBlockClientId: _selectedBlockClientId,
  39988. selectedBlockName: _selectedBlockName,
  39989. blockType: _blockType,
  39990. hasBlockStyles: blockStyles && blockStyles.length > 0
  39991. };
  39992. }, []);
  39993. if (count > 1) {
  39994. return (0,external_wp_element_namespaceObject.createElement)("div", {
  39995. className: "block-editor-block-inspector"
  39996. }, (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, {
  39997. __experimentalGroup: "color",
  39998. label: (0,external_wp_i18n_namespaceObject.__)('Color'),
  39999. className: "color-block-support-panel__inner-wrapper"
  40000. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  40001. __experimentalGroup: "typography",
  40002. label: (0,external_wp_i18n_namespaceObject.__)('Typography')
  40003. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  40004. __experimentalGroup: "dimensions",
  40005. label: (0,external_wp_i18n_namespaceObject.__)('Dimensions')
  40006. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  40007. __experimentalGroup: "border",
  40008. label: (0,external_wp_i18n_namespaceObject.__)('Border')
  40009. }));
  40010. }
  40011. const isSelectedBlockUnregistered = selectedBlockName === (0,external_wp_blocks_namespaceObject.getUnregisteredTypeHandlerName)();
  40012. /*
  40013. * If the selected block is of an unregistered type, avoid showing it as an actual selection
  40014. * because we want the user to focus on the unregistered block warning, not block settings.
  40015. */
  40016. if (!blockType || !selectedBlockClientId || isSelectedBlockUnregistered) {
  40017. if (showNoBlockSelectedMessage) {
  40018. return (0,external_wp_element_namespaceObject.createElement)("span", {
  40019. className: "block-editor-block-inspector__no-blocks"
  40020. }, (0,external_wp_i18n_namespaceObject.__)('No block selected.'));
  40021. }
  40022. return null;
  40023. }
  40024. return (0,external_wp_element_namespaceObject.createElement)(BlockInspectorSingleBlock, {
  40025. clientId: selectedBlockClientId,
  40026. blockName: blockType.name,
  40027. hasBlockStyles: hasBlockStyles
  40028. });
  40029. };
  40030. const BlockInspectorSingleBlock = _ref2 => {
  40031. let {
  40032. clientId,
  40033. blockName,
  40034. hasBlockStyles
  40035. } = _ref2;
  40036. const blockInformation = useBlockDisplayInformation(clientId);
  40037. return (0,external_wp_element_namespaceObject.createElement)("div", {
  40038. className: "block-editor-block-inspector"
  40039. }, (0,external_wp_element_namespaceObject.createElement)(block_card, blockInformation), (0,external_wp_element_namespaceObject.createElement)(block_variation_transforms, {
  40040. blockClientId: clientId
  40041. }), hasBlockStyles && (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  40042. title: (0,external_wp_i18n_namespaceObject.__)('Styles')
  40043. }, (0,external_wp_element_namespaceObject.createElement)(block_styles, {
  40044. scope: "core/block-inspector",
  40045. clientId: clientId
  40046. }), (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'defaultStylePicker', true) && (0,external_wp_element_namespaceObject.createElement)(DefaultStylePicker, {
  40047. blockName: blockName
  40048. }))), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, null), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  40049. __experimentalGroup: "color",
  40050. label: (0,external_wp_i18n_namespaceObject.__)('Color'),
  40051. className: "color-block-support-panel__inner-wrapper"
  40052. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  40053. __experimentalGroup: "typography",
  40054. label: (0,external_wp_i18n_namespaceObject.__)('Typography')
  40055. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  40056. __experimentalGroup: "dimensions",
  40057. label: (0,external_wp_i18n_namespaceObject.__)('Dimensions')
  40058. }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  40059. __experimentalGroup: "border",
  40060. label: (0,external_wp_i18n_namespaceObject.__)('Border')
  40061. }), (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, {
  40062. key: "back"
  40063. }));
  40064. };
  40065. const AdvancedControls = () => {
  40066. const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(InspectorAdvancedControls.slotName);
  40067. const hasFills = Boolean(slot.fills && slot.fills.length);
  40068. if (!hasFills) {
  40069. return null;
  40070. }
  40071. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  40072. className: "block-editor-block-inspector__advanced",
  40073. title: (0,external_wp_i18n_namespaceObject.__)('Advanced'),
  40074. initialOpen: false
  40075. }, (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, {
  40076. __experimentalGroup: "advanced"
  40077. }));
  40078. };
  40079. /**
  40080. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-inspector/README.md
  40081. */
  40082. /* harmony default export */ var block_inspector = (BlockInspector);
  40083. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/index.js
  40084. /**
  40085. * External dependencies
  40086. */
  40087. /**
  40088. * WordPress dependencies
  40089. */
  40090. /**
  40091. * Internal dependencies
  40092. */
  40093. /**
  40094. * Renders block tools (the block toolbar, select/navigation mode toolbar, the
  40095. * insertion point and a slot for the inline rich text toolbar). Must be wrapped
  40096. * around the block content and editor styles wrapper or iframe.
  40097. *
  40098. * @param {Object} $0 Props.
  40099. * @param {Object} $0.children The block content and style container.
  40100. * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.
  40101. */
  40102. function BlockTools(_ref) {
  40103. let {
  40104. children,
  40105. __unstableContentRef,
  40106. ...props
  40107. } = _ref;
  40108. const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
  40109. const hasFixedToolbar = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().hasFixedToolbar, []);
  40110. const isMatch = (0,external_wp_keyboardShortcuts_namespaceObject.__unstableUseShortcutEventMatch)();
  40111. const {
  40112. getSelectedBlockClientIds,
  40113. getBlockRootClientId
  40114. } = (0,external_wp_data_namespaceObject.useSelect)(store);
  40115. const {
  40116. duplicateBlocks,
  40117. removeBlocks,
  40118. insertAfterBlock,
  40119. insertBeforeBlock,
  40120. clearSelectedBlock,
  40121. moveBlocksUp,
  40122. moveBlocksDown
  40123. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  40124. function onKeyDown(event) {
  40125. if (isMatch('core/block-editor/move-up', event)) {
  40126. const clientIds = getSelectedBlockClientIds();
  40127. if (clientIds.length) {
  40128. event.preventDefault();
  40129. const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.first)(clientIds));
  40130. moveBlocksUp(clientIds, rootClientId);
  40131. }
  40132. } else if (isMatch('core/block-editor/move-down', event)) {
  40133. const clientIds = getSelectedBlockClientIds();
  40134. if (clientIds.length) {
  40135. event.preventDefault();
  40136. const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.first)(clientIds));
  40137. moveBlocksDown(clientIds, rootClientId);
  40138. }
  40139. } else if (isMatch('core/block-editor/duplicate', event)) {
  40140. const clientIds = getSelectedBlockClientIds();
  40141. if (clientIds.length) {
  40142. event.preventDefault();
  40143. duplicateBlocks(clientIds);
  40144. }
  40145. } else if (isMatch('core/block-editor/remove', event)) {
  40146. const clientIds = getSelectedBlockClientIds();
  40147. if (clientIds.length) {
  40148. event.preventDefault();
  40149. removeBlocks(clientIds);
  40150. }
  40151. } else if (isMatch('core/block-editor/insert-after', event)) {
  40152. const clientIds = getSelectedBlockClientIds();
  40153. if (clientIds.length) {
  40154. event.preventDefault();
  40155. insertAfterBlock((0,external_lodash_namespaceObject.last)(clientIds));
  40156. }
  40157. } else if (isMatch('core/block-editor/insert-before', event)) {
  40158. const clientIds = getSelectedBlockClientIds();
  40159. if (clientIds.length) {
  40160. event.preventDefault();
  40161. insertBeforeBlock((0,external_lodash_namespaceObject.first)(clientIds));
  40162. }
  40163. } else if (isMatch('core/block-editor/unselect', event)) {
  40164. const clientIds = getSelectedBlockClientIds();
  40165. if (clientIds.length > 1) {
  40166. event.preventDefault();
  40167. clearSelectedBlock();
  40168. event.target.ownerDocument.defaultView.getSelection().removeAllRanges();
  40169. }
  40170. }
  40171. }
  40172. return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions
  40173. (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, props, {
  40174. onKeyDown: onKeyDown
  40175. }), (0,external_wp_element_namespaceObject.createElement)(InsertionPoint, {
  40176. __unstableContentRef: __unstableContentRef
  40177. }, (hasFixedToolbar || !isLargeViewport) && (0,external_wp_element_namespaceObject.createElement)(block_contextual_toolbar, {
  40178. isFixed: true
  40179. }), (0,external_wp_element_namespaceObject.createElement)(WrappedBlockPopover, {
  40180. __unstableContentRef: __unstableContentRef
  40181. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, {
  40182. name: "block-toolbar",
  40183. ref: usePopoverScroll(__unstableContentRef)
  40184. }), children, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, {
  40185. name: "__unstable-block-tools-after",
  40186. ref: usePopoverScroll(__unstableContentRef)
  40187. })))
  40188. );
  40189. }
  40190. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/library.js
  40191. /**
  40192. * External dependencies
  40193. */
  40194. /**
  40195. * WordPress dependencies
  40196. */
  40197. /**
  40198. * Internal dependencies
  40199. */
  40200. function InserterLibrary(_ref, ref) {
  40201. let {
  40202. rootClientId,
  40203. clientId,
  40204. isAppender,
  40205. showInserterHelpPanel,
  40206. showMostUsedBlocks = false,
  40207. __experimentalInsertionIndex,
  40208. __experimentalFilterValue,
  40209. onSelect = external_lodash_namespaceObject.noop,
  40210. shouldFocusBlock = false
  40211. } = _ref;
  40212. const destinationRootClientId = (0,external_wp_data_namespaceObject.useSelect)(select => {
  40213. const {
  40214. getBlockRootClientId
  40215. } = select(store);
  40216. return rootClientId || getBlockRootClientId(clientId) || undefined;
  40217. }, [clientId, rootClientId]);
  40218. return (0,external_wp_element_namespaceObject.createElement)(menu, {
  40219. onSelect: onSelect,
  40220. rootClientId: destinationRootClientId,
  40221. clientId: clientId,
  40222. isAppender: isAppender,
  40223. showInserterHelpPanel: showInserterHelpPanel,
  40224. showMostUsedBlocks: showMostUsedBlocks,
  40225. __experimentalInsertionIndex: __experimentalInsertionIndex,
  40226. __experimentalFilterValue: __experimentalFilterValue,
  40227. shouldFocusBlock: shouldFocusBlock,
  40228. ref: ref
  40229. });
  40230. }
  40231. /* harmony default export */ var library = ((0,external_wp_element_namespaceObject.forwardRef)(InserterLibrary));
  40232. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/keyboard-shortcuts/index.js
  40233. /**
  40234. * WordPress dependencies
  40235. */
  40236. function KeyboardShortcuts() {
  40237. return null;
  40238. }
  40239. function KeyboardShortcutsRegister() {
  40240. // Registering the shortcuts.
  40241. const {
  40242. registerShortcut
  40243. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
  40244. (0,external_wp_element_namespaceObject.useEffect)(() => {
  40245. registerShortcut({
  40246. name: 'core/block-editor/duplicate',
  40247. category: 'block',
  40248. description: (0,external_wp_i18n_namespaceObject.__)('Duplicate the selected block(s).'),
  40249. keyCombination: {
  40250. modifier: 'primaryShift',
  40251. character: 'd'
  40252. }
  40253. });
  40254. registerShortcut({
  40255. name: 'core/block-editor/remove',
  40256. category: 'block',
  40257. description: (0,external_wp_i18n_namespaceObject.__)('Remove the selected block(s).'),
  40258. keyCombination: {
  40259. modifier: 'access',
  40260. character: 'z'
  40261. }
  40262. });
  40263. registerShortcut({
  40264. name: 'core/block-editor/insert-before',
  40265. category: 'block',
  40266. description: (0,external_wp_i18n_namespaceObject.__)('Insert a new block before the selected block(s).'),
  40267. keyCombination: {
  40268. modifier: 'primaryAlt',
  40269. character: 't'
  40270. }
  40271. });
  40272. registerShortcut({
  40273. name: 'core/block-editor/insert-after',
  40274. category: 'block',
  40275. description: (0,external_wp_i18n_namespaceObject.__)('Insert a new block after the selected block(s).'),
  40276. keyCombination: {
  40277. modifier: 'primaryAlt',
  40278. character: 'y'
  40279. }
  40280. });
  40281. registerShortcut({
  40282. name: 'core/block-editor/delete-multi-selection',
  40283. category: 'block',
  40284. description: (0,external_wp_i18n_namespaceObject.__)('Delete selection.'),
  40285. keyCombination: {
  40286. character: 'del'
  40287. },
  40288. aliases: [{
  40289. character: 'backspace'
  40290. }]
  40291. });
  40292. registerShortcut({
  40293. name: 'core/block-editor/select-all',
  40294. category: 'selection',
  40295. description: (0,external_wp_i18n_namespaceObject.__)('Select all text when typing. Press again to select all blocks.'),
  40296. keyCombination: {
  40297. modifier: 'primary',
  40298. character: 'a'
  40299. }
  40300. });
  40301. registerShortcut({
  40302. name: 'core/block-editor/unselect',
  40303. category: 'selection',
  40304. description: (0,external_wp_i18n_namespaceObject.__)('Clear selection.'),
  40305. keyCombination: {
  40306. character: 'escape'
  40307. }
  40308. });
  40309. registerShortcut({
  40310. name: 'core/block-editor/focus-toolbar',
  40311. category: 'global',
  40312. description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the nearest toolbar.'),
  40313. keyCombination: {
  40314. modifier: 'alt',
  40315. character: 'F10'
  40316. }
  40317. });
  40318. registerShortcut({
  40319. name: 'core/block-editor/move-up',
  40320. category: 'block',
  40321. description: (0,external_wp_i18n_namespaceObject.__)('Move the selected block(s) up.'),
  40322. keyCombination: {
  40323. modifier: 'secondary',
  40324. character: 't'
  40325. }
  40326. });
  40327. registerShortcut({
  40328. name: 'core/block-editor/move-down',
  40329. category: 'block',
  40330. description: (0,external_wp_i18n_namespaceObject.__)('Move the selected block(s) down.'),
  40331. keyCombination: {
  40332. modifier: 'secondary',
  40333. character: 'y'
  40334. }
  40335. });
  40336. }, [registerShortcut]);
  40337. return null;
  40338. }
  40339. KeyboardShortcuts.Register = KeyboardShortcutsRegister;
  40340. /* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts);
  40341. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/selection-scroll-into-view/index.js
  40342. /**
  40343. * WordPress dependencies
  40344. */
  40345. /**
  40346. * Scrolls the multi block selection end into view if not in view already. This
  40347. * is important to do after selection by keyboard.
  40348. *
  40349. * @deprecated
  40350. */
  40351. function MultiSelectScrollIntoView() {
  40352. external_wp_deprecated_default()('wp.blockEditor.MultiSelectScrollIntoView', {
  40353. hint: 'This behaviour is now built-in.',
  40354. since: '5.8'
  40355. });
  40356. return null;
  40357. }
  40358. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/observe-typing/index.js
  40359. /**
  40360. * WordPress dependencies
  40361. */
  40362. /**
  40363. * Internal dependencies
  40364. */
  40365. /**
  40366. * Set of key codes upon which typing is to be initiated on a keydown event.
  40367. *
  40368. * @type {Set<number>}
  40369. */
  40370. 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]);
  40371. /**
  40372. * Returns true if a given keydown event can be inferred as intent to start
  40373. * typing, or false otherwise. A keydown is considered eligible if it is a
  40374. * text navigation without shift active.
  40375. *
  40376. * @param {KeyboardEvent} event Keydown event to test.
  40377. *
  40378. * @return {boolean} Whether event is eligible to start typing.
  40379. */
  40380. function isKeyDownEligibleForStartTyping(event) {
  40381. const {
  40382. keyCode,
  40383. shiftKey
  40384. } = event;
  40385. return !shiftKey && KEY_DOWN_ELIGIBLE_KEY_CODES.has(keyCode);
  40386. }
  40387. /**
  40388. * Removes the `isTyping` flag when the mouse moves in the document of the given
  40389. * element.
  40390. */
  40391. function useMouseMoveTypingReset() {
  40392. const isTyping = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isTyping(), []);
  40393. const {
  40394. stopTyping
  40395. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  40396. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  40397. if (!isTyping) {
  40398. return;
  40399. }
  40400. const {
  40401. ownerDocument
  40402. } = node;
  40403. let lastClientX;
  40404. let lastClientY;
  40405. /**
  40406. * On mouse move, unset typing flag if user has moved cursor.
  40407. *
  40408. * @param {MouseEvent} event Mousemove event.
  40409. */
  40410. function stopTypingOnMouseMove(event) {
  40411. const {
  40412. clientX,
  40413. clientY
  40414. } = event; // We need to check that the mouse really moved because Safari
  40415. // triggers mousemove events when shift or ctrl are pressed.
  40416. if (lastClientX && lastClientY && (lastClientX !== clientX || lastClientY !== clientY)) {
  40417. stopTyping();
  40418. }
  40419. lastClientX = clientX;
  40420. lastClientY = clientY;
  40421. }
  40422. ownerDocument.addEventListener('mousemove', stopTypingOnMouseMove);
  40423. return () => {
  40424. ownerDocument.removeEventListener('mousemove', stopTypingOnMouseMove);
  40425. };
  40426. }, [isTyping, stopTyping]);
  40427. }
  40428. /**
  40429. * Sets and removes the `isTyping` flag based on user actions:
  40430. *
  40431. * - Sets the flag if the user types within the given element.
  40432. * - Removes the flag when the user selects some text, focusses a non-text
  40433. * field, presses ESC or TAB, or moves the mouse in the document.
  40434. */
  40435. function useTypingObserver() {
  40436. const isTyping = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isTyping());
  40437. const {
  40438. startTyping,
  40439. stopTyping
  40440. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  40441. const ref1 = useMouseMoveTypingReset();
  40442. const ref2 = (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  40443. const {
  40444. ownerDocument
  40445. } = node;
  40446. const {
  40447. defaultView
  40448. } = ownerDocument; // Listeners to stop typing should only be added when typing.
  40449. // Listeners to start typing should only be added when not typing.
  40450. if (isTyping) {
  40451. let timerId;
  40452. /**
  40453. * Stops typing when focus transitions to a non-text field element.
  40454. *
  40455. * @param {FocusEvent} event Focus event.
  40456. */
  40457. function stopTypingOnNonTextField(event) {
  40458. const {
  40459. target
  40460. } = event; // Since focus to a non-text field via arrow key will trigger
  40461. // before the keydown event, wait until after current stack
  40462. // before evaluating whether typing is to be stopped. Otherwise,
  40463. // typing will re-start.
  40464. timerId = defaultView.setTimeout(() => {
  40465. if (!(0,external_wp_dom_namespaceObject.isTextField)(target)) {
  40466. stopTyping();
  40467. }
  40468. });
  40469. }
  40470. /**
  40471. * Unsets typing flag if user presses Escape while typing flag is
  40472. * active.
  40473. *
  40474. * @param {KeyboardEvent} event Keypress or keydown event to
  40475. * interpret.
  40476. */
  40477. function stopTypingOnEscapeKey(event) {
  40478. const {
  40479. keyCode
  40480. } = event;
  40481. if (keyCode === external_wp_keycodes_namespaceObject.ESCAPE || keyCode === external_wp_keycodes_namespaceObject.TAB) {
  40482. stopTyping();
  40483. }
  40484. }
  40485. /**
  40486. * On selection change, unset typing flag if user has made an
  40487. * uncollapsed (shift) selection.
  40488. */
  40489. function stopTypingOnSelectionUncollapse() {
  40490. const selection = defaultView.getSelection();
  40491. const isCollapsed = selection.rangeCount > 0 && selection.getRangeAt(0).collapsed;
  40492. if (!isCollapsed) {
  40493. stopTyping();
  40494. }
  40495. }
  40496. node.addEventListener('focus', stopTypingOnNonTextField);
  40497. node.addEventListener('keydown', stopTypingOnEscapeKey);
  40498. ownerDocument.addEventListener('selectionchange', stopTypingOnSelectionUncollapse);
  40499. return () => {
  40500. defaultView.clearTimeout(timerId);
  40501. node.removeEventListener('focus', stopTypingOnNonTextField);
  40502. node.removeEventListener('keydown', stopTypingOnEscapeKey);
  40503. ownerDocument.removeEventListener('selectionchange', stopTypingOnSelectionUncollapse);
  40504. };
  40505. }
  40506. /**
  40507. * Handles a keypress or keydown event to infer intention to start
  40508. * typing.
  40509. *
  40510. * @param {KeyboardEvent} event Keypress or keydown event to interpret.
  40511. */
  40512. function startTypingInTextField(event) {
  40513. const {
  40514. type,
  40515. target
  40516. } = event; // Abort early if already typing, or key press is incurred outside a
  40517. // text field (e.g. arrow-ing through toolbar buttons).
  40518. // Ignore typing if outside the current DOM container
  40519. if (!(0,external_wp_dom_namespaceObject.isTextField)(target) || !node.contains(target)) {
  40520. return;
  40521. } // Special-case keydown because certain keys do not emit a keypress
  40522. // event. Conversely avoid keydown as the canonical event since
  40523. // there are many keydown which are explicitly not targeted for
  40524. // typing.
  40525. if (type === 'keydown' && !isKeyDownEligibleForStartTyping(event)) {
  40526. return;
  40527. }
  40528. startTyping();
  40529. }
  40530. node.addEventListener('keypress', startTypingInTextField);
  40531. node.addEventListener('keydown', startTypingInTextField);
  40532. return () => {
  40533. node.removeEventListener('keypress', startTypingInTextField);
  40534. node.removeEventListener('keydown', startTypingInTextField);
  40535. };
  40536. }, [isTyping, startTyping, stopTyping]);
  40537. return (0,external_wp_compose_namespaceObject.useMergeRefs)([ref1, ref2]);
  40538. }
  40539. function ObserveTyping(_ref) {
  40540. let {
  40541. children
  40542. } = _ref;
  40543. return (0,external_wp_element_namespaceObject.createElement)("div", {
  40544. ref: useTypingObserver()
  40545. }, children);
  40546. }
  40547. /**
  40548. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md
  40549. */
  40550. /* harmony default export */ var observe_typing = (ObserveTyping);
  40551. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/typewriter/index.js
  40552. /**
  40553. * WordPress dependencies
  40554. */
  40555. /**
  40556. * Internal dependencies
  40557. */
  40558. const isIE = window.navigator.userAgent.indexOf('Trident') !== -1;
  40559. const arrowKeyCodes = new Set([external_wp_keycodes_namespaceObject.UP, external_wp_keycodes_namespaceObject.DOWN, external_wp_keycodes_namespaceObject.LEFT, external_wp_keycodes_namespaceObject.RIGHT]);
  40560. const initialTriggerPercentage = 0.75;
  40561. function useTypewriter() {
  40562. const hasSelectedBlock = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).hasSelectedBlock(), []);
  40563. return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
  40564. if (!hasSelectedBlock) {
  40565. return;
  40566. }
  40567. const {
  40568. ownerDocument
  40569. } = node;
  40570. const {
  40571. defaultView
  40572. } = ownerDocument;
  40573. let scrollResizeRafId;
  40574. let onKeyDownRafId;
  40575. let caretRect;
  40576. function onScrollResize() {
  40577. if (scrollResizeRafId) {
  40578. return;
  40579. }
  40580. scrollResizeRafId = defaultView.requestAnimationFrame(() => {
  40581. computeCaretRectangle();
  40582. scrollResizeRafId = null;
  40583. });
  40584. }
  40585. function onKeyDown(event) {
  40586. // Ensure the any remaining request is cancelled.
  40587. if (onKeyDownRafId) {
  40588. defaultView.cancelAnimationFrame(onKeyDownRafId);
  40589. } // Use an animation frame for a smooth result.
  40590. onKeyDownRafId = defaultView.requestAnimationFrame(() => {
  40591. maintainCaretPosition(event);
  40592. onKeyDownRafId = null;
  40593. });
  40594. }
  40595. /**
  40596. * Maintains the scroll position after a selection change caused by a
  40597. * keyboard event.
  40598. *
  40599. * @param {KeyboardEvent} event Keyboard event.
  40600. */
  40601. function maintainCaretPosition(_ref) {
  40602. let {
  40603. keyCode
  40604. } = _ref;
  40605. if (!isSelectionEligibleForScroll()) {
  40606. return;
  40607. }
  40608. const currentCaretRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView);
  40609. if (!currentCaretRect) {
  40610. return;
  40611. } // If for some reason there is no position set to be scrolled to, let
  40612. // this be the position to be scrolled to in the future.
  40613. if (!caretRect) {
  40614. caretRect = currentCaretRect;
  40615. return;
  40616. } // Even though enabling the typewriter effect for arrow keys results in
  40617. // a pleasant experience, it may not be the case for everyone, so, for
  40618. // now, let's disable it.
  40619. if (arrowKeyCodes.has(keyCode)) {
  40620. // Reset the caret position to maintain.
  40621. caretRect = currentCaretRect;
  40622. return;
  40623. }
  40624. const diff = currentCaretRect.top - caretRect.top;
  40625. if (diff === 0) {
  40626. return;
  40627. }
  40628. const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(node); // The page must be scrollable.
  40629. if (!scrollContainer) {
  40630. return;
  40631. }
  40632. const windowScroll = scrollContainer === ownerDocument.body;
  40633. const scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop;
  40634. const scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top;
  40635. 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
  40636. // is the last one, and the caret is positioned within the initial
  40637. // trigger percentage of the page, do not scroll the page.
  40638. // The typewriter effect should not kick in until an empty page has been
  40639. // filled with the initial trigger percentage or the user scrolls
  40640. // intentionally down.
  40641. if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) {
  40642. // Reset the caret position to maintain.
  40643. caretRect = currentCaretRect;
  40644. return;
  40645. }
  40646. const scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight; // Abort if the target scroll position would scroll the caret out of
  40647. // view.
  40648. if ( // The caret is under the lower fold.
  40649. caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold.
  40650. caretRect.top < scrollContainerY) {
  40651. // Reset the caret position to maintain.
  40652. caretRect = currentCaretRect;
  40653. return;
  40654. }
  40655. if (windowScroll) {
  40656. defaultView.scrollBy(0, diff);
  40657. } else {
  40658. scrollContainer.scrollTop += diff;
  40659. }
  40660. }
  40661. /**
  40662. * Adds a `selectionchange` listener to reset the scroll position to be
  40663. * maintained.
  40664. */
  40665. function addSelectionChangeListener() {
  40666. ownerDocument.addEventListener('selectionchange', computeCaretRectOnSelectionChange);
  40667. }
  40668. /**
  40669. * Resets the scroll position to be maintained during a `selectionchange`
  40670. * event. Also removes the listener, so it acts as a one-time listener.
  40671. */
  40672. function computeCaretRectOnSelectionChange() {
  40673. ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange);
  40674. computeCaretRectangle();
  40675. }
  40676. /**
  40677. * Resets the scroll position to be maintained.
  40678. */
  40679. function computeCaretRectangle() {
  40680. if (isSelectionEligibleForScroll()) {
  40681. caretRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView);
  40682. }
  40683. }
  40684. /**
  40685. * Checks if the current situation is elegible for scroll:
  40686. * - There should be one and only one block selected.
  40687. * - The component must contain the selection.
  40688. * - The active element must be contenteditable.
  40689. */
  40690. function isSelectionEligibleForScroll() {
  40691. return node.contains(ownerDocument.activeElement) && ownerDocument.activeElement.isContentEditable;
  40692. }
  40693. function isLastEditableNode() {
  40694. const editableNodes = node.querySelectorAll('[contenteditable="true"]');
  40695. const lastEditableNode = editableNodes[editableNodes.length - 1];
  40696. return lastEditableNode === ownerDocument.activeElement;
  40697. } // When the user scrolls or resizes, the scroll position should be
  40698. // reset.
  40699. defaultView.addEventListener('scroll', onScrollResize, true);
  40700. defaultView.addEventListener('resize', onScrollResize, true);
  40701. node.addEventListener('keydown', onKeyDown);
  40702. node.addEventListener('keyup', maintainCaretPosition);
  40703. node.addEventListener('mousedown', addSelectionChangeListener);
  40704. node.addEventListener('touchstart', addSelectionChangeListener);
  40705. return () => {
  40706. defaultView.removeEventListener('scroll', onScrollResize, true);
  40707. defaultView.removeEventListener('resize', onScrollResize, true);
  40708. node.removeEventListener('keydown', onKeyDown);
  40709. node.removeEventListener('keyup', maintainCaretPosition);
  40710. node.removeEventListener('mousedown', addSelectionChangeListener);
  40711. node.removeEventListener('touchstart', addSelectionChangeListener);
  40712. ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange);
  40713. defaultView.cancelAnimationFrame(scrollResizeRafId);
  40714. defaultView.cancelAnimationFrame(onKeyDownRafId);
  40715. };
  40716. }, [hasSelectedBlock]);
  40717. }
  40718. function Typewriter(_ref2) {
  40719. let {
  40720. children
  40721. } = _ref2;
  40722. return (0,external_wp_element_namespaceObject.createElement)("div", {
  40723. ref: useTypewriter(),
  40724. className: "block-editor__typewriter"
  40725. }, children);
  40726. }
  40727. /**
  40728. * The exported component. The implementation of Typewriter faced technical
  40729. * challenges in Internet Explorer, and is simply skipped, rendering the given
  40730. * props children instead.
  40731. *
  40732. * @type {WPComponent}
  40733. */
  40734. const TypewriterOrIEBypass = isIE ? props => props.children : Typewriter;
  40735. /**
  40736. * Ensures that the text selection keeps the same vertical distance from the
  40737. * viewport during keyboard events within this component. The vertical distance
  40738. * can vary. It is the last clicked or scrolled to position.
  40739. */
  40740. /* harmony default export */ var typewriter = (TypewriterOrIEBypass);
  40741. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-no-recursive-renders/index.js
  40742. /**
  40743. * WordPress dependencies
  40744. */
  40745. /**
  40746. * Internal dependencies
  40747. */
  40748. const RenderedRefsContext = (0,external_wp_element_namespaceObject.createContext)({});
  40749. /**
  40750. * Immutably adds an unique identifier to a set scoped for a given block type.
  40751. *
  40752. * @param {Object} renderedBlocks Rendered blocks grouped by block name
  40753. * @param {string} blockName Name of the block.
  40754. * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.
  40755. *
  40756. * @return {Object} The list of rendered blocks grouped by block name.
  40757. */
  40758. function addToBlockType(renderedBlocks, blockName, uniqueId) {
  40759. const result = { ...renderedBlocks,
  40760. [blockName]: renderedBlocks[blockName] ? new Set(renderedBlocks[blockName]) : new Set()
  40761. };
  40762. result[blockName].add(uniqueId);
  40763. return result;
  40764. }
  40765. /**
  40766. * A React hook for keeping track of blocks previously rendered up in the block
  40767. * tree. Blocks susceptible to recursion can use this hook in their `Edit`
  40768. * function to prevent said recursion.
  40769. *
  40770. * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.
  40771. * @param {string} blockName Optional block name.
  40772. *
  40773. * @return {[boolean, Function]} A tuple of:
  40774. * - a boolean describing whether the provided id
  40775. * has already been rendered;
  40776. * - a React context provider to be used to wrap
  40777. * other elements.
  40778. */
  40779. function useNoRecursiveRenders(uniqueId) {
  40780. var _previouslyRenderedBl;
  40781. let blockName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  40782. const previouslyRenderedBlocks = (0,external_wp_element_namespaceObject.useContext)(RenderedRefsContext);
  40783. const {
  40784. name
  40785. } = useBlockEditContext();
  40786. blockName = blockName || name;
  40787. const hasAlreadyRendered = Boolean((_previouslyRenderedBl = previouslyRenderedBlocks[blockName]) === null || _previouslyRenderedBl === void 0 ? void 0 : _previouslyRenderedBl.has(uniqueId));
  40788. const newRenderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => addToBlockType(previouslyRenderedBlocks, blockName, uniqueId), [previouslyRenderedBlocks, blockName, uniqueId]);
  40789. const Provider = (0,external_wp_element_namespaceObject.useCallback)(_ref => {
  40790. let {
  40791. children
  40792. } = _ref;
  40793. return (0,external_wp_element_namespaceObject.createElement)(RenderedRefsContext.Provider, {
  40794. value: newRenderedBlocks
  40795. }, children);
  40796. }, [newRenderedBlocks]);
  40797. return [hasAlreadyRendered, Provider];
  40798. }
  40799. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/index.js
  40800. /*
  40801. * Block Creation Components
  40802. */
  40803. /*
  40804. * Content Related Components
  40805. */
  40806. /*
  40807. * State Related Components
  40808. */
  40809. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/block-variation-transforms.js
  40810. /**
  40811. * External dependencies
  40812. */
  40813. /** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
  40814. /**
  40815. * Matches the provided block variations with a block's attributes. If no match
  40816. * or more than one matches are found it returns `undefined`. If a single match is
  40817. * found it returns it.
  40818. *
  40819. * This is a simple implementation for now as it takes into account only the attributes
  40820. * of a block variation and not `InnerBlocks`.
  40821. *
  40822. * @param {Object} blockAttributes - The block attributes to try to find a match.
  40823. * @param {WPBlockVariation[]} variations - A list of block variations to test for a match.
  40824. * @return {?WPBlockVariation} - If a match is found returns it. If not or more than one matches are found returns `undefined`.
  40825. */
  40826. const __experimentalGetMatchingVariation = (blockAttributes, variations) => {
  40827. if (!variations || !blockAttributes) return;
  40828. const matches = variations.filter(_ref => {
  40829. let {
  40830. attributes
  40831. } = _ref;
  40832. if (!attributes || !Object.keys(attributes).length) return false;
  40833. return (0,external_lodash_namespaceObject.isMatch)(blockAttributes, attributes);
  40834. });
  40835. if (matches.length !== 1) return;
  40836. return matches[0];
  40837. };
  40838. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/parse-css-unit-to-px.js
  40839. /**
  40840. * Converts string to object { value, unit }.
  40841. *
  40842. * @param {string} cssUnit
  40843. * @return {Object} parsedUnit
  40844. */
  40845. function parseUnit(cssUnit) {
  40846. 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)$/);
  40847. if (!isNaN(cssUnit) && !isNaN(parseFloat(cssUnit))) {
  40848. return {
  40849. value: parseFloat(cssUnit),
  40850. unit: 'px'
  40851. };
  40852. }
  40853. return match ? {
  40854. value: parseFloat(match[1]) || match[1],
  40855. unit: match[2]
  40856. } : {
  40857. value: cssUnit,
  40858. unit: undefined
  40859. };
  40860. }
  40861. /**
  40862. * Evaluate a math expression.
  40863. *
  40864. * @param {string} expression
  40865. * @return {number} evaluated expression.
  40866. */
  40867. function calculate(expression) {
  40868. return Function(`'use strict'; return (${expression})`)();
  40869. }
  40870. /**
  40871. * Calculates the css function value for the supported css functions such as max, min, clamp and calc.
  40872. *
  40873. * @param {string} functionUnitValue string should be in a particular format (for example min(12px,12px) ) no nested loops.
  40874. * @param {Object} options
  40875. * @return {string} unit containing the unit in PX.
  40876. */
  40877. function getFunctionUnitValue(functionUnitValue, options) {
  40878. const functionUnit = functionUnitValue.split(/[(),]/g).filter(Boolean);
  40879. const units = functionUnit.slice(1).map(unit => parseUnit(getPxFromCssUnit(unit, options)).value).filter(Boolean);
  40880. switch (functionUnit[0]) {
  40881. case 'min':
  40882. return Math.min(...units) + 'px';
  40883. case 'max':
  40884. return Math.max(...units) + 'px';
  40885. case 'clamp':
  40886. if (units.length !== 3) {
  40887. return null;
  40888. }
  40889. if (units[1] < units[0]) {
  40890. return units[0] + 'px';
  40891. }
  40892. if (units[1] > units[2]) {
  40893. return units[2] + 'px';
  40894. }
  40895. return units[1] + 'px';
  40896. case 'calc':
  40897. return units[0] + 'px';
  40898. }
  40899. }
  40900. /**
  40901. * Take a css function such as min, max, calc, clamp and returns parsedUnit
  40902. *
  40903. * How this works for the nested function is that it first replaces the inner function call.
  40904. * Then it tackles the outer onces.
  40905. * So for example: min( max(25px, 35px), 40px )
  40906. * in the first pass we would replace max(25px, 35px) with 35px.
  40907. * then we would try to evaluate min( 35px, 40px )
  40908. * and then finally return 35px.
  40909. *
  40910. * @param {string} cssUnit
  40911. * @return {Object} parsedUnit object.
  40912. */
  40913. function parseUnitFunction(cssUnit) {
  40914. while (true) {
  40915. const currentCssUnit = cssUnit;
  40916. const regExp = /(max|min|calc|clamp)\(([^()]*)\)/g;
  40917. const matches = regExp.exec(cssUnit) || [];
  40918. if (matches[0]) {
  40919. const functionUnitValue = getFunctionUnitValue(matches[0]);
  40920. cssUnit = cssUnit.replace(matches[0], functionUnitValue);
  40921. } // If the unit hasn't been modified or we have a single value break free.
  40922. if (cssUnit === currentCssUnit || parseFloat(cssUnit)) {
  40923. break;
  40924. }
  40925. }
  40926. return parseUnit(cssUnit);
  40927. }
  40928. /**
  40929. * Return true if we think this is a math expression.
  40930. *
  40931. * @param {string} cssUnit the cssUnit value being evaluted.
  40932. * @return {boolean} Whether the cssUnit is a math expression.
  40933. */
  40934. function isMathExpression(cssUnit) {
  40935. for (let i = 0; i < cssUnit.length; i++) {
  40936. if (['+', '-', '/', '*'].includes(cssUnit[i])) {
  40937. return true;
  40938. }
  40939. }
  40940. return false;
  40941. }
  40942. /**
  40943. * Evaluates the math expression and return a px value.
  40944. *
  40945. * @param {string} cssUnit the cssUnit value being evaluted.
  40946. * @return {string} return a converfted value to px.
  40947. */
  40948. function evalMathExpression(cssUnit) {
  40949. let errorFound = false; // Convert every part of the expression to px values.
  40950. const cssUnitsBits = cssUnit.split(/[+-/*/]/g).filter(Boolean);
  40951. for (const unit of cssUnitsBits) {
  40952. // Standardize the unit to px and extract the value.
  40953. const parsedUnit = parseUnit(getPxFromCssUnit(unit));
  40954. if (!parseFloat(parsedUnit.value)) {
  40955. errorFound = true; // End early since we are dealing with a null value.
  40956. break;
  40957. }
  40958. cssUnit = cssUnit.replace(unit, parsedUnit.value);
  40959. }
  40960. return errorFound ? null : calculate(cssUnit).toFixed(0) + 'px';
  40961. }
  40962. /**
  40963. * Convert a parsedUnit object to px value.
  40964. *
  40965. * @param {Object} parsedUnit
  40966. * @param {Object} options
  40967. * @return {string} or {null} returns the converted with in a px value format.
  40968. */
  40969. function convertParsedUnitToPx(parsedUnit, options) {
  40970. const PIXELS_PER_INCH = 96;
  40971. const ONE_PERCENT = 0.01;
  40972. const defaultProperties = {
  40973. fontSize: 16,
  40974. lineHeight: 16,
  40975. width: 375,
  40976. height: 812,
  40977. type: 'font'
  40978. };
  40979. const setOptions = Object.assign({}, defaultProperties, options);
  40980. const relativeUnits = {
  40981. em: setOptions.fontSize,
  40982. rem: setOptions.fontSize,
  40983. vh: setOptions.height * ONE_PERCENT,
  40984. vw: setOptions.width * ONE_PERCENT,
  40985. vmin: (setOptions.width < setOptions.height ? setOptions.width : setOptions.height) * ONE_PERCENT,
  40986. vmax: (setOptions.width > setOptions.height ? setOptions.width : setOptions.height) * ONE_PERCENT,
  40987. '%': (setOptions.type === 'font' ? setOptions.fontSize : setOptions.width) * ONE_PERCENT,
  40988. ch: 8,
  40989. // The advance measure (width) of the glyph "0" of the element's font. Approximate
  40990. ex: 7.15625,
  40991. // X-height of the element's font. Approximate.
  40992. lh: setOptions.lineHeight
  40993. };
  40994. const absoluteUnits = {
  40995. in: PIXELS_PER_INCH,
  40996. cm: PIXELS_PER_INCH / 2.54,
  40997. mm: PIXELS_PER_INCH / 25.4,
  40998. pt: PIXELS_PER_INCH / 72,
  40999. pc: PIXELS_PER_INCH / 6,
  41000. px: 1,
  41001. Q: PIXELS_PER_INCH / 2.54 / 40
  41002. };
  41003. if (relativeUnits[parsedUnit.unit]) {
  41004. return (relativeUnits[parsedUnit.unit] * parsedUnit.value).toFixed(0) + 'px';
  41005. }
  41006. if (absoluteUnits[parsedUnit.unit]) {
  41007. return (absoluteUnits[parsedUnit.unit] * parsedUnit.value).toFixed(0) + 'px';
  41008. }
  41009. return null;
  41010. }
  41011. /**
  41012. * Returns the px value of a cssUnit.
  41013. *
  41014. * @param {string} cssUnit
  41015. * @param {Object} options
  41016. * @return {string} returns the cssUnit value in a simple px format.
  41017. */
  41018. function getPxFromCssUnit(cssUnit) {
  41019. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  41020. if (Number.isFinite(cssUnit)) {
  41021. return cssUnit.toFixed(0) + 'px';
  41022. }
  41023. if (cssUnit === undefined) {
  41024. return null;
  41025. }
  41026. let parsedUnit = parseUnit(cssUnit);
  41027. if (!parsedUnit.unit) {
  41028. parsedUnit = parseUnitFunction(cssUnit, options);
  41029. }
  41030. if (isMathExpression(cssUnit) && !parsedUnit.unit) {
  41031. return evalMathExpression(cssUnit);
  41032. }
  41033. return convertParsedUnitToPx(parsedUnit, options);
  41034. } // Use simple cache.
  41035. const cache = {};
  41036. /**
  41037. * Returns the px value of a cssUnit. The memoized version of getPxFromCssUnit;
  41038. *
  41039. * @param {string} cssUnit
  41040. * @param {Object} options
  41041. * @return {string} returns the cssUnit value in a simple px format.
  41042. */
  41043. function memoizedGetPxFromCssUnit(cssUnit) {
  41044. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  41045. const hash = cssUnit + hashOptions(options);
  41046. if (!cache[hash]) {
  41047. cache[hash] = getPxFromCssUnit(cssUnit, options);
  41048. }
  41049. return cache[hash];
  41050. }
  41051. function hashOptions(options) {
  41052. let hash = '';
  41053. if (options.hasOwnProperty('fontSize')) {
  41054. hash = ':' + options.width;
  41055. }
  41056. if (options.hasOwnProperty('lineHeight')) {
  41057. hash = ':' + options.lineHeight;
  41058. }
  41059. if (options.hasOwnProperty('width')) {
  41060. hash = ':' + options.width;
  41061. }
  41062. if (options.hasOwnProperty('height')) {
  41063. hash = ':' + options.height;
  41064. }
  41065. if (options.hasOwnProperty('type')) {
  41066. hash = ':' + options.type;
  41067. }
  41068. return hash;
  41069. }
  41070. /* harmony default export */ var parse_css_unit_to_px = (memoizedGetPxFromCssUnit);
  41071. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/index.js
  41072. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/index.js
  41073. /**
  41074. * Internal dependencies
  41075. */
  41076. }();
  41077. (window.wp = window.wp || {}).blockEditor = __webpack_exports__;
  41078. /******/ })()
  41079. ;