compose.js 174 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 8294:
  4. /***/ (function(module) {
  5. /*!
  6. * clipboard.js v2.0.11
  7. * https://clipboardjs.com/
  8. *
  9. * Licensed MIT © Zeno Rocha
  10. */
  11. (function webpackUniversalModuleDefinition(root, factory) {
  12. if(true)
  13. module.exports = factory();
  14. else {}
  15. })(this, function() {
  16. return /******/ (function() { // webpackBootstrap
  17. /******/ var __webpack_modules__ = ({
  18. /***/ 686:
  19. /***/ (function(__unused_webpack_module, __webpack_exports__, __nested_webpack_require_623__) {
  20. "use strict";
  21. // EXPORTS
  22. __nested_webpack_require_623__.d(__webpack_exports__, {
  23. "default": function() { return /* binding */ clipboard; }
  24. });
  25. // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js
  26. var tiny_emitter = __nested_webpack_require_623__(279);
  27. var tiny_emitter_default = /*#__PURE__*/__nested_webpack_require_623__.n(tiny_emitter);
  28. // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js
  29. var listen = __nested_webpack_require_623__(370);
  30. var listen_default = /*#__PURE__*/__nested_webpack_require_623__.n(listen);
  31. // EXTERNAL MODULE: ./node_modules/select/src/select.js
  32. var src_select = __nested_webpack_require_623__(817);
  33. var select_default = /*#__PURE__*/__nested_webpack_require_623__.n(src_select);
  34. ;// CONCATENATED MODULE: ./src/common/command.js
  35. /**
  36. * Executes a given operation type.
  37. * @param {String} type
  38. * @return {Boolean}
  39. */
  40. function command(type) {
  41. try {
  42. return document.execCommand(type);
  43. } catch (err) {
  44. return false;
  45. }
  46. }
  47. ;// CONCATENATED MODULE: ./src/actions/cut.js
  48. /**
  49. * Cut action wrapper.
  50. * @param {String|HTMLElement} target
  51. * @return {String}
  52. */
  53. var ClipboardActionCut = function ClipboardActionCut(target) {
  54. var selectedText = select_default()(target);
  55. command('cut');
  56. return selectedText;
  57. };
  58. /* harmony default export */ var actions_cut = (ClipboardActionCut);
  59. ;// CONCATENATED MODULE: ./src/common/create-fake-element.js
  60. /**
  61. * Creates a fake textarea element with a value.
  62. * @param {String} value
  63. * @return {HTMLElement}
  64. */
  65. function createFakeElement(value) {
  66. var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
  67. var fakeElement = document.createElement('textarea'); // Prevent zooming on iOS
  68. fakeElement.style.fontSize = '12pt'; // Reset box model
  69. fakeElement.style.border = '0';
  70. fakeElement.style.padding = '0';
  71. fakeElement.style.margin = '0'; // Move element out of screen horizontally
  72. fakeElement.style.position = 'absolute';
  73. fakeElement.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically
  74. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  75. fakeElement.style.top = "".concat(yPosition, "px");
  76. fakeElement.setAttribute('readonly', '');
  77. fakeElement.value = value;
  78. return fakeElement;
  79. }
  80. ;// CONCATENATED MODULE: ./src/actions/copy.js
  81. /**
  82. * Create fake copy action wrapper using a fake element.
  83. * @param {String} target
  84. * @param {Object} options
  85. * @return {String}
  86. */
  87. var fakeCopyAction = function fakeCopyAction(value, options) {
  88. var fakeElement = createFakeElement(value);
  89. options.container.appendChild(fakeElement);
  90. var selectedText = select_default()(fakeElement);
  91. command('copy');
  92. fakeElement.remove();
  93. return selectedText;
  94. };
  95. /**
  96. * Copy action wrapper.
  97. * @param {String|HTMLElement} target
  98. * @param {Object} options
  99. * @return {String}
  100. */
  101. var ClipboardActionCopy = function ClipboardActionCopy(target) {
  102. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  103. container: document.body
  104. };
  105. var selectedText = '';
  106. if (typeof target === 'string') {
  107. selectedText = fakeCopyAction(target, options);
  108. } else if (target instanceof HTMLInputElement && !['text', 'search', 'url', 'tel', 'password'].includes(target === null || target === void 0 ? void 0 : target.type)) {
  109. // If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
  110. selectedText = fakeCopyAction(target.value, options);
  111. } else {
  112. selectedText = select_default()(target);
  113. command('copy');
  114. }
  115. return selectedText;
  116. };
  117. /* harmony default export */ var actions_copy = (ClipboardActionCopy);
  118. ;// CONCATENATED MODULE: ./src/actions/default.js
  119. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  120. /**
  121. * Inner function which performs selection from either `text` or `target`
  122. * properties and then executes copy or cut operations.
  123. * @param {Object} options
  124. */
  125. var ClipboardActionDefault = function ClipboardActionDefault() {
  126. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  127. // Defines base properties passed from constructor.
  128. var _options$action = options.action,
  129. action = _options$action === void 0 ? 'copy' : _options$action,
  130. container = options.container,
  131. target = options.target,
  132. text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'.
  133. if (action !== 'copy' && action !== 'cut') {
  134. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  135. } // Sets the `target` property using an element that will be have its content copied.
  136. if (target !== undefined) {
  137. if (target && _typeof(target) === 'object' && target.nodeType === 1) {
  138. if (action === 'copy' && target.hasAttribute('disabled')) {
  139. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  140. }
  141. if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  142. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  143. }
  144. } else {
  145. throw new Error('Invalid "target" value, use a valid Element');
  146. }
  147. } // Define selection strategy based on `text` property.
  148. if (text) {
  149. return actions_copy(text, {
  150. container: container
  151. });
  152. } // Defines which selection strategy based on `target` property.
  153. if (target) {
  154. return action === 'cut' ? actions_cut(target) : actions_copy(target, {
  155. container: container
  156. });
  157. }
  158. };
  159. /* harmony default export */ var actions_default = (ClipboardActionDefault);
  160. ;// CONCATENATED MODULE: ./src/clipboard.js
  161. function clipboard_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clipboard_typeof(obj); }
  162. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  163. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  164. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  165. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  166. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  167. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  168. function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  169. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  170. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  171. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  172. /**
  173. * Helper function to retrieve attribute value.
  174. * @param {String} suffix
  175. * @param {Element} element
  176. */
  177. function getAttributeValue(suffix, element) {
  178. var attribute = "data-clipboard-".concat(suffix);
  179. if (!element.hasAttribute(attribute)) {
  180. return;
  181. }
  182. return element.getAttribute(attribute);
  183. }
  184. /**
  185. * Base class which takes one or more elements, adds event listeners to them,
  186. * and instantiates a new `ClipboardAction` on each click.
  187. */
  188. var Clipboard = /*#__PURE__*/function (_Emitter) {
  189. _inherits(Clipboard, _Emitter);
  190. var _super = _createSuper(Clipboard);
  191. /**
  192. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  193. * @param {Object} options
  194. */
  195. function Clipboard(trigger, options) {
  196. var _this;
  197. _classCallCheck(this, Clipboard);
  198. _this = _super.call(this);
  199. _this.resolveOptions(options);
  200. _this.listenClick(trigger);
  201. return _this;
  202. }
  203. /**
  204. * Defines if attributes would be resolved using internal setter functions
  205. * or custom functions that were passed in the constructor.
  206. * @param {Object} options
  207. */
  208. _createClass(Clipboard, [{
  209. key: "resolveOptions",
  210. value: function resolveOptions() {
  211. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  212. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  213. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  214. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  215. this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;
  216. }
  217. /**
  218. * Adds a click event listener to the passed trigger.
  219. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  220. */
  221. }, {
  222. key: "listenClick",
  223. value: function listenClick(trigger) {
  224. var _this2 = this;
  225. this.listener = listen_default()(trigger, 'click', function (e) {
  226. return _this2.onClick(e);
  227. });
  228. }
  229. /**
  230. * Defines a new `ClipboardAction` on each click event.
  231. * @param {Event} e
  232. */
  233. }, {
  234. key: "onClick",
  235. value: function onClick(e) {
  236. var trigger = e.delegateTarget || e.currentTarget;
  237. var action = this.action(trigger) || 'copy';
  238. var text = actions_default({
  239. action: action,
  240. container: this.container,
  241. target: this.target(trigger),
  242. text: this.text(trigger)
  243. }); // Fires an event based on the copy operation result.
  244. this.emit(text ? 'success' : 'error', {
  245. action: action,
  246. text: text,
  247. trigger: trigger,
  248. clearSelection: function clearSelection() {
  249. if (trigger) {
  250. trigger.focus();
  251. }
  252. window.getSelection().removeAllRanges();
  253. }
  254. });
  255. }
  256. /**
  257. * Default `action` lookup function.
  258. * @param {Element} trigger
  259. */
  260. }, {
  261. key: "defaultAction",
  262. value: function defaultAction(trigger) {
  263. return getAttributeValue('action', trigger);
  264. }
  265. /**
  266. * Default `target` lookup function.
  267. * @param {Element} trigger
  268. */
  269. }, {
  270. key: "defaultTarget",
  271. value: function defaultTarget(trigger) {
  272. var selector = getAttributeValue('target', trigger);
  273. if (selector) {
  274. return document.querySelector(selector);
  275. }
  276. }
  277. /**
  278. * Allow fire programmatically a copy action
  279. * @param {String|HTMLElement} target
  280. * @param {Object} options
  281. * @returns Text copied.
  282. */
  283. }, {
  284. key: "defaultText",
  285. /**
  286. * Default `text` lookup function.
  287. * @param {Element} trigger
  288. */
  289. value: function defaultText(trigger) {
  290. return getAttributeValue('text', trigger);
  291. }
  292. /**
  293. * Destroy lifecycle.
  294. */
  295. }, {
  296. key: "destroy",
  297. value: function destroy() {
  298. this.listener.destroy();
  299. }
  300. }], [{
  301. key: "copy",
  302. value: function copy(target) {
  303. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  304. container: document.body
  305. };
  306. return actions_copy(target, options);
  307. }
  308. /**
  309. * Allow fire programmatically a cut action
  310. * @param {String|HTMLElement} target
  311. * @returns Text cutted.
  312. */
  313. }, {
  314. key: "cut",
  315. value: function cut(target) {
  316. return actions_cut(target);
  317. }
  318. /**
  319. * Returns the support of the given action, or all actions if no action is
  320. * given.
  321. * @param {String} [action]
  322. */
  323. }, {
  324. key: "isSupported",
  325. value: function isSupported() {
  326. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  327. var actions = typeof action === 'string' ? [action] : action;
  328. var support = !!document.queryCommandSupported;
  329. actions.forEach(function (action) {
  330. support = support && !!document.queryCommandSupported(action);
  331. });
  332. return support;
  333. }
  334. }]);
  335. return Clipboard;
  336. }((tiny_emitter_default()));
  337. /* harmony default export */ var clipboard = (Clipboard);
  338. /***/ }),
  339. /***/ 828:
  340. /***/ (function(module) {
  341. var DOCUMENT_NODE_TYPE = 9;
  342. /**
  343. * A polyfill for Element.matches()
  344. */
  345. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  346. var proto = Element.prototype;
  347. proto.matches = proto.matchesSelector ||
  348. proto.mozMatchesSelector ||
  349. proto.msMatchesSelector ||
  350. proto.oMatchesSelector ||
  351. proto.webkitMatchesSelector;
  352. }
  353. /**
  354. * Finds the closest parent that matches a selector.
  355. *
  356. * @param {Element} element
  357. * @param {String} selector
  358. * @return {Function}
  359. */
  360. function closest (element, selector) {
  361. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  362. if (typeof element.matches === 'function' &&
  363. element.matches(selector)) {
  364. return element;
  365. }
  366. element = element.parentNode;
  367. }
  368. }
  369. module.exports = closest;
  370. /***/ }),
  371. /***/ 438:
  372. /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_15749__) {
  373. var closest = __nested_webpack_require_15749__(828);
  374. /**
  375. * Delegates event to a selector.
  376. *
  377. * @param {Element} element
  378. * @param {String} selector
  379. * @param {String} type
  380. * @param {Function} callback
  381. * @param {Boolean} useCapture
  382. * @return {Object}
  383. */
  384. function _delegate(element, selector, type, callback, useCapture) {
  385. var listenerFn = listener.apply(this, arguments);
  386. element.addEventListener(type, listenerFn, useCapture);
  387. return {
  388. destroy: function() {
  389. element.removeEventListener(type, listenerFn, useCapture);
  390. }
  391. }
  392. }
  393. /**
  394. * Delegates event to a selector.
  395. *
  396. * @param {Element|String|Array} [elements]
  397. * @param {String} selector
  398. * @param {String} type
  399. * @param {Function} callback
  400. * @param {Boolean} useCapture
  401. * @return {Object}
  402. */
  403. function delegate(elements, selector, type, callback, useCapture) {
  404. // Handle the regular Element usage
  405. if (typeof elements.addEventListener === 'function') {
  406. return _delegate.apply(null, arguments);
  407. }
  408. // Handle Element-less usage, it defaults to global delegation
  409. if (typeof type === 'function') {
  410. // Use `document` as the first parameter, then apply arguments
  411. // This is a short way to .unshift `arguments` without running into deoptimizations
  412. return _delegate.bind(null, document).apply(null, arguments);
  413. }
  414. // Handle Selector-based usage
  415. if (typeof elements === 'string') {
  416. elements = document.querySelectorAll(elements);
  417. }
  418. // Handle Array-like based usage
  419. return Array.prototype.map.call(elements, function (element) {
  420. return _delegate(element, selector, type, callback, useCapture);
  421. });
  422. }
  423. /**
  424. * Finds closest match and invokes callback.
  425. *
  426. * @param {Element} element
  427. * @param {String} selector
  428. * @param {String} type
  429. * @param {Function} callback
  430. * @return {Function}
  431. */
  432. function listener(element, selector, type, callback) {
  433. return function(e) {
  434. e.delegateTarget = closest(e.target, selector);
  435. if (e.delegateTarget) {
  436. callback.call(element, e);
  437. }
  438. }
  439. }
  440. module.exports = delegate;
  441. /***/ }),
  442. /***/ 879:
  443. /***/ (function(__unused_webpack_module, exports) {
  444. /**
  445. * Check if argument is a HTML element.
  446. *
  447. * @param {Object} value
  448. * @return {Boolean}
  449. */
  450. exports.node = function(value) {
  451. return value !== undefined
  452. && value instanceof HTMLElement
  453. && value.nodeType === 1;
  454. };
  455. /**
  456. * Check if argument is a list of HTML elements.
  457. *
  458. * @param {Object} value
  459. * @return {Boolean}
  460. */
  461. exports.nodeList = function(value) {
  462. var type = Object.prototype.toString.call(value);
  463. return value !== undefined
  464. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  465. && ('length' in value)
  466. && (value.length === 0 || exports.node(value[0]));
  467. };
  468. /**
  469. * Check if argument is a string.
  470. *
  471. * @param {Object} value
  472. * @return {Boolean}
  473. */
  474. exports.string = function(value) {
  475. return typeof value === 'string'
  476. || value instanceof String;
  477. };
  478. /**
  479. * Check if argument is a function.
  480. *
  481. * @param {Object} value
  482. * @return {Boolean}
  483. */
  484. exports.fn = function(value) {
  485. var type = Object.prototype.toString.call(value);
  486. return type === '[object Function]';
  487. };
  488. /***/ }),
  489. /***/ 370:
  490. /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_19113__) {
  491. var is = __nested_webpack_require_19113__(879);
  492. var delegate = __nested_webpack_require_19113__(438);
  493. /**
  494. * Validates all params and calls the right
  495. * listener function based on its target type.
  496. *
  497. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  498. * @param {String} type
  499. * @param {Function} callback
  500. * @return {Object}
  501. */
  502. function listen(target, type, callback) {
  503. if (!target && !type && !callback) {
  504. throw new Error('Missing required arguments');
  505. }
  506. if (!is.string(type)) {
  507. throw new TypeError('Second argument must be a String');
  508. }
  509. if (!is.fn(callback)) {
  510. throw new TypeError('Third argument must be a Function');
  511. }
  512. if (is.node(target)) {
  513. return listenNode(target, type, callback);
  514. }
  515. else if (is.nodeList(target)) {
  516. return listenNodeList(target, type, callback);
  517. }
  518. else if (is.string(target)) {
  519. return listenSelector(target, type, callback);
  520. }
  521. else {
  522. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  523. }
  524. }
  525. /**
  526. * Adds an event listener to a HTML element
  527. * and returns a remove listener function.
  528. *
  529. * @param {HTMLElement} node
  530. * @param {String} type
  531. * @param {Function} callback
  532. * @return {Object}
  533. */
  534. function listenNode(node, type, callback) {
  535. node.addEventListener(type, callback);
  536. return {
  537. destroy: function() {
  538. node.removeEventListener(type, callback);
  539. }
  540. }
  541. }
  542. /**
  543. * Add an event listener to a list of HTML elements
  544. * and returns a remove listener function.
  545. *
  546. * @param {NodeList|HTMLCollection} nodeList
  547. * @param {String} type
  548. * @param {Function} callback
  549. * @return {Object}
  550. */
  551. function listenNodeList(nodeList, type, callback) {
  552. Array.prototype.forEach.call(nodeList, function(node) {
  553. node.addEventListener(type, callback);
  554. });
  555. return {
  556. destroy: function() {
  557. Array.prototype.forEach.call(nodeList, function(node) {
  558. node.removeEventListener(type, callback);
  559. });
  560. }
  561. }
  562. }
  563. /**
  564. * Add an event listener to a selector
  565. * and returns a remove listener function.
  566. *
  567. * @param {String} selector
  568. * @param {String} type
  569. * @param {Function} callback
  570. * @return {Object}
  571. */
  572. function listenSelector(selector, type, callback) {
  573. return delegate(document.body, selector, type, callback);
  574. }
  575. module.exports = listen;
  576. /***/ }),
  577. /***/ 817:
  578. /***/ (function(module) {
  579. function select(element) {
  580. var selectedText;
  581. if (element.nodeName === 'SELECT') {
  582. element.focus();
  583. selectedText = element.value;
  584. }
  585. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  586. var isReadOnly = element.hasAttribute('readonly');
  587. if (!isReadOnly) {
  588. element.setAttribute('readonly', '');
  589. }
  590. element.select();
  591. element.setSelectionRange(0, element.value.length);
  592. if (!isReadOnly) {
  593. element.removeAttribute('readonly');
  594. }
  595. selectedText = element.value;
  596. }
  597. else {
  598. if (element.hasAttribute('contenteditable')) {
  599. element.focus();
  600. }
  601. var selection = window.getSelection();
  602. var range = document.createRange();
  603. range.selectNodeContents(element);
  604. selection.removeAllRanges();
  605. selection.addRange(range);
  606. selectedText = selection.toString();
  607. }
  608. return selectedText;
  609. }
  610. module.exports = select;
  611. /***/ }),
  612. /***/ 279:
  613. /***/ (function(module) {
  614. function E () {
  615. // Keep this empty so it's easier to inherit from
  616. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  617. }
  618. E.prototype = {
  619. on: function (name, callback, ctx) {
  620. var e = this.e || (this.e = {});
  621. (e[name] || (e[name] = [])).push({
  622. fn: callback,
  623. ctx: ctx
  624. });
  625. return this;
  626. },
  627. once: function (name, callback, ctx) {
  628. var self = this;
  629. function listener () {
  630. self.off(name, listener);
  631. callback.apply(ctx, arguments);
  632. };
  633. listener._ = callback
  634. return this.on(name, listener, ctx);
  635. },
  636. emit: function (name) {
  637. var data = [].slice.call(arguments, 1);
  638. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  639. var i = 0;
  640. var len = evtArr.length;
  641. for (i; i < len; i++) {
  642. evtArr[i].fn.apply(evtArr[i].ctx, data);
  643. }
  644. return this;
  645. },
  646. off: function (name, callback) {
  647. var e = this.e || (this.e = {});
  648. var evts = e[name];
  649. var liveEvents = [];
  650. if (evts && callback) {
  651. for (var i = 0, len = evts.length; i < len; i++) {
  652. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  653. liveEvents.push(evts[i]);
  654. }
  655. }
  656. // Remove event from queue to prevent memory leak
  657. // Suggested by https://github.com/lazd
  658. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  659. (liveEvents.length)
  660. ? e[name] = liveEvents
  661. : delete e[name];
  662. return this;
  663. }
  664. };
  665. module.exports = E;
  666. module.exports.TinyEmitter = E;
  667. /***/ })
  668. /******/ });
  669. /************************************************************************/
  670. /******/ // The module cache
  671. /******/ var __webpack_module_cache__ = {};
  672. /******/
  673. /******/ // The require function
  674. /******/ function __nested_webpack_require_24495__(moduleId) {
  675. /******/ // Check if module is in cache
  676. /******/ if(__webpack_module_cache__[moduleId]) {
  677. /******/ return __webpack_module_cache__[moduleId].exports;
  678. /******/ }
  679. /******/ // Create a new module (and put it into the cache)
  680. /******/ var module = __webpack_module_cache__[moduleId] = {
  681. /******/ // no module.id needed
  682. /******/ // no module.loaded needed
  683. /******/ exports: {}
  684. /******/ };
  685. /******/
  686. /******/ // Execute the module function
  687. /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_24495__);
  688. /******/
  689. /******/ // Return the exports of the module
  690. /******/ return module.exports;
  691. /******/ }
  692. /******/
  693. /************************************************************************/
  694. /******/ /* webpack/runtime/compat get default export */
  695. /******/ !function() {
  696. /******/ // getDefaultExport function for compatibility with non-harmony modules
  697. /******/ __nested_webpack_require_24495__.n = function(module) {
  698. /******/ var getter = module && module.__esModule ?
  699. /******/ function() { return module['default']; } :
  700. /******/ function() { return module; };
  701. /******/ __nested_webpack_require_24495__.d(getter, { a: getter });
  702. /******/ return getter;
  703. /******/ };
  704. /******/ }();
  705. /******/
  706. /******/ /* webpack/runtime/define property getters */
  707. /******/ !function() {
  708. /******/ // define getter functions for harmony exports
  709. /******/ __nested_webpack_require_24495__.d = function(exports, definition) {
  710. /******/ for(var key in definition) {
  711. /******/ if(__nested_webpack_require_24495__.o(definition, key) && !__nested_webpack_require_24495__.o(exports, key)) {
  712. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  713. /******/ }
  714. /******/ }
  715. /******/ };
  716. /******/ }();
  717. /******/
  718. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  719. /******/ !function() {
  720. /******/ __nested_webpack_require_24495__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  721. /******/ }();
  722. /******/
  723. /************************************************************************/
  724. /******/ // module exports must be returned from runtime so entry inlining is disabled
  725. /******/ // startup
  726. /******/ // Load entry module and return exports
  727. /******/ return __nested_webpack_require_24495__(686);
  728. /******/ })()
  729. .default;
  730. });
  731. /***/ }),
  732. /***/ 7973:
  733. /***/ (function(module, exports, __webpack_require__) {
  734. var __WEBPACK_AMD_DEFINE_RESULT__;/*global define:false */
  735. /**
  736. * Copyright 2012-2017 Craig Campbell
  737. *
  738. * Licensed under the Apache License, Version 2.0 (the "License");
  739. * you may not use this file except in compliance with the License.
  740. * You may obtain a copy of the License at
  741. *
  742. * http://www.apache.org/licenses/LICENSE-2.0
  743. *
  744. * Unless required by applicable law or agreed to in writing, software
  745. * distributed under the License is distributed on an "AS IS" BASIS,
  746. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  747. * See the License for the specific language governing permissions and
  748. * limitations under the License.
  749. *
  750. * Mousetrap is a simple keyboard shortcut library for Javascript with
  751. * no external dependencies
  752. *
  753. * @version 1.6.5
  754. * @url craig.is/killing/mice
  755. */
  756. (function(window, document, undefined) {
  757. // Check if mousetrap is used inside browser, if not, return
  758. if (!window) {
  759. return;
  760. }
  761. /**
  762. * mapping of special keycodes to their corresponding keys
  763. *
  764. * everything in this dictionary cannot use keypress events
  765. * so it has to be here to map to the correct keycodes for
  766. * keyup/keydown events
  767. *
  768. * @type {Object}
  769. */
  770. var _MAP = {
  771. 8: 'backspace',
  772. 9: 'tab',
  773. 13: 'enter',
  774. 16: 'shift',
  775. 17: 'ctrl',
  776. 18: 'alt',
  777. 20: 'capslock',
  778. 27: 'esc',
  779. 32: 'space',
  780. 33: 'pageup',
  781. 34: 'pagedown',
  782. 35: 'end',
  783. 36: 'home',
  784. 37: 'left',
  785. 38: 'up',
  786. 39: 'right',
  787. 40: 'down',
  788. 45: 'ins',
  789. 46: 'del',
  790. 91: 'meta',
  791. 93: 'meta',
  792. 224: 'meta'
  793. };
  794. /**
  795. * mapping for special characters so they can support
  796. *
  797. * this dictionary is only used incase you want to bind a
  798. * keyup or keydown event to one of these keys
  799. *
  800. * @type {Object}
  801. */
  802. var _KEYCODE_MAP = {
  803. 106: '*',
  804. 107: '+',
  805. 109: '-',
  806. 110: '.',
  807. 111 : '/',
  808. 186: ';',
  809. 187: '=',
  810. 188: ',',
  811. 189: '-',
  812. 190: '.',
  813. 191: '/',
  814. 192: '`',
  815. 219: '[',
  816. 220: '\\',
  817. 221: ']',
  818. 222: '\''
  819. };
  820. /**
  821. * this is a mapping of keys that require shift on a US keypad
  822. * back to the non shift equivelents
  823. *
  824. * this is so you can use keyup events with these keys
  825. *
  826. * note that this will only work reliably on US keyboards
  827. *
  828. * @type {Object}
  829. */
  830. var _SHIFT_MAP = {
  831. '~': '`',
  832. '!': '1',
  833. '@': '2',
  834. '#': '3',
  835. '$': '4',
  836. '%': '5',
  837. '^': '6',
  838. '&': '7',
  839. '*': '8',
  840. '(': '9',
  841. ')': '0',
  842. '_': '-',
  843. '+': '=',
  844. ':': ';',
  845. '\"': '\'',
  846. '<': ',',
  847. '>': '.',
  848. '?': '/',
  849. '|': '\\'
  850. };
  851. /**
  852. * this is a list of special strings you can use to map
  853. * to modifier keys when you specify your keyboard shortcuts
  854. *
  855. * @type {Object}
  856. */
  857. var _SPECIAL_ALIASES = {
  858. 'option': 'alt',
  859. 'command': 'meta',
  860. 'return': 'enter',
  861. 'escape': 'esc',
  862. 'plus': '+',
  863. 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
  864. };
  865. /**
  866. * variable to store the flipped version of _MAP from above
  867. * needed to check if we should use keypress or not when no action
  868. * is specified
  869. *
  870. * @type {Object|undefined}
  871. */
  872. var _REVERSE_MAP;
  873. /**
  874. * loop through the f keys, f1 to f19 and add them to the map
  875. * programatically
  876. */
  877. for (var i = 1; i < 20; ++i) {
  878. _MAP[111 + i] = 'f' + i;
  879. }
  880. /**
  881. * loop through to map numbers on the numeric keypad
  882. */
  883. for (i = 0; i <= 9; ++i) {
  884. // This needs to use a string cause otherwise since 0 is falsey
  885. // mousetrap will never fire for numpad 0 pressed as part of a keydown
  886. // event.
  887. //
  888. // @see https://github.com/ccampbell/mousetrap/pull/258
  889. _MAP[i + 96] = i.toString();
  890. }
  891. /**
  892. * cross browser add event method
  893. *
  894. * @param {Element|HTMLDocument} object
  895. * @param {string} type
  896. * @param {Function} callback
  897. * @returns void
  898. */
  899. function _addEvent(object, type, callback) {
  900. if (object.addEventListener) {
  901. object.addEventListener(type, callback, false);
  902. return;
  903. }
  904. object.attachEvent('on' + type, callback);
  905. }
  906. /**
  907. * takes the event and returns the key character
  908. *
  909. * @param {Event} e
  910. * @return {string}
  911. */
  912. function _characterFromEvent(e) {
  913. // for keypress events we should return the character as is
  914. if (e.type == 'keypress') {
  915. var character = String.fromCharCode(e.which);
  916. // if the shift key is not pressed then it is safe to assume
  917. // that we want the character to be lowercase. this means if
  918. // you accidentally have caps lock on then your key bindings
  919. // will continue to work
  920. //
  921. // the only side effect that might not be desired is if you
  922. // bind something like 'A' cause you want to trigger an
  923. // event when capital A is pressed caps lock will no longer
  924. // trigger the event. shift+a will though.
  925. if (!e.shiftKey) {
  926. character = character.toLowerCase();
  927. }
  928. return character;
  929. }
  930. // for non keypress events the special maps are needed
  931. if (_MAP[e.which]) {
  932. return _MAP[e.which];
  933. }
  934. if (_KEYCODE_MAP[e.which]) {
  935. return _KEYCODE_MAP[e.which];
  936. }
  937. // if it is not in the special map
  938. // with keydown and keyup events the character seems to always
  939. // come in as an uppercase character whether you are pressing shift
  940. // or not. we should make sure it is always lowercase for comparisons
  941. return String.fromCharCode(e.which).toLowerCase();
  942. }
  943. /**
  944. * checks if two arrays are equal
  945. *
  946. * @param {Array} modifiers1
  947. * @param {Array} modifiers2
  948. * @returns {boolean}
  949. */
  950. function _modifiersMatch(modifiers1, modifiers2) {
  951. return modifiers1.sort().join(',') === modifiers2.sort().join(',');
  952. }
  953. /**
  954. * takes a key event and figures out what the modifiers are
  955. *
  956. * @param {Event} e
  957. * @returns {Array}
  958. */
  959. function _eventModifiers(e) {
  960. var modifiers = [];
  961. if (e.shiftKey) {
  962. modifiers.push('shift');
  963. }
  964. if (e.altKey) {
  965. modifiers.push('alt');
  966. }
  967. if (e.ctrlKey) {
  968. modifiers.push('ctrl');
  969. }
  970. if (e.metaKey) {
  971. modifiers.push('meta');
  972. }
  973. return modifiers;
  974. }
  975. /**
  976. * prevents default for this event
  977. *
  978. * @param {Event} e
  979. * @returns void
  980. */
  981. function _preventDefault(e) {
  982. if (e.preventDefault) {
  983. e.preventDefault();
  984. return;
  985. }
  986. e.returnValue = false;
  987. }
  988. /**
  989. * stops propogation for this event
  990. *
  991. * @param {Event} e
  992. * @returns void
  993. */
  994. function _stopPropagation(e) {
  995. if (e.stopPropagation) {
  996. e.stopPropagation();
  997. return;
  998. }
  999. e.cancelBubble = true;
  1000. }
  1001. /**
  1002. * determines if the keycode specified is a modifier key or not
  1003. *
  1004. * @param {string} key
  1005. * @returns {boolean}
  1006. */
  1007. function _isModifier(key) {
  1008. return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';
  1009. }
  1010. /**
  1011. * reverses the map lookup so that we can look for specific keys
  1012. * to see what can and can't use keypress
  1013. *
  1014. * @return {Object}
  1015. */
  1016. function _getReverseMap() {
  1017. if (!_REVERSE_MAP) {
  1018. _REVERSE_MAP = {};
  1019. for (var key in _MAP) {
  1020. // pull out the numeric keypad from here cause keypress should
  1021. // be able to detect the keys from the character
  1022. if (key > 95 && key < 112) {
  1023. continue;
  1024. }
  1025. if (_MAP.hasOwnProperty(key)) {
  1026. _REVERSE_MAP[_MAP[key]] = key;
  1027. }
  1028. }
  1029. }
  1030. return _REVERSE_MAP;
  1031. }
  1032. /**
  1033. * picks the best action based on the key combination
  1034. *
  1035. * @param {string} key - character for key
  1036. * @param {Array} modifiers
  1037. * @param {string=} action passed in
  1038. */
  1039. function _pickBestAction(key, modifiers, action) {
  1040. // if no action was picked in we should try to pick the one
  1041. // that we think would work best for this key
  1042. if (!action) {
  1043. action = _getReverseMap()[key] ? 'keydown' : 'keypress';
  1044. }
  1045. // modifier keys don't work as expected with keypress,
  1046. // switch to keydown
  1047. if (action == 'keypress' && modifiers.length) {
  1048. action = 'keydown';
  1049. }
  1050. return action;
  1051. }
  1052. /**
  1053. * Converts from a string key combination to an array
  1054. *
  1055. * @param {string} combination like "command+shift+l"
  1056. * @return {Array}
  1057. */
  1058. function _keysFromString(combination) {
  1059. if (combination === '+') {
  1060. return ['+'];
  1061. }
  1062. combination = combination.replace(/\+{2}/g, '+plus');
  1063. return combination.split('+');
  1064. }
  1065. /**
  1066. * Gets info for a specific key combination
  1067. *
  1068. * @param {string} combination key combination ("command+s" or "a" or "*")
  1069. * @param {string=} action
  1070. * @returns {Object}
  1071. */
  1072. function _getKeyInfo(combination, action) {
  1073. var keys;
  1074. var key;
  1075. var i;
  1076. var modifiers = [];
  1077. // take the keys from this pattern and figure out what the actual
  1078. // pattern is all about
  1079. keys = _keysFromString(combination);
  1080. for (i = 0; i < keys.length; ++i) {
  1081. key = keys[i];
  1082. // normalize key names
  1083. if (_SPECIAL_ALIASES[key]) {
  1084. key = _SPECIAL_ALIASES[key];
  1085. }
  1086. // if this is not a keypress event then we should
  1087. // be smart about using shift keys
  1088. // this will only work for US keyboards however
  1089. if (action && action != 'keypress' && _SHIFT_MAP[key]) {
  1090. key = _SHIFT_MAP[key];
  1091. modifiers.push('shift');
  1092. }
  1093. // if this key is a modifier then add it to the list of modifiers
  1094. if (_isModifier(key)) {
  1095. modifiers.push(key);
  1096. }
  1097. }
  1098. // depending on what the key combination is
  1099. // we will try to pick the best event for it
  1100. action = _pickBestAction(key, modifiers, action);
  1101. return {
  1102. key: key,
  1103. modifiers: modifiers,
  1104. action: action
  1105. };
  1106. }
  1107. function _belongsTo(element, ancestor) {
  1108. if (element === null || element === document) {
  1109. return false;
  1110. }
  1111. if (element === ancestor) {
  1112. return true;
  1113. }
  1114. return _belongsTo(element.parentNode, ancestor);
  1115. }
  1116. function Mousetrap(targetElement) {
  1117. var self = this;
  1118. targetElement = targetElement || document;
  1119. if (!(self instanceof Mousetrap)) {
  1120. return new Mousetrap(targetElement);
  1121. }
  1122. /**
  1123. * element to attach key events to
  1124. *
  1125. * @type {Element}
  1126. */
  1127. self.target = targetElement;
  1128. /**
  1129. * a list of all the callbacks setup via Mousetrap.bind()
  1130. *
  1131. * @type {Object}
  1132. */
  1133. self._callbacks = {};
  1134. /**
  1135. * direct map of string combinations to callbacks used for trigger()
  1136. *
  1137. * @type {Object}
  1138. */
  1139. self._directMap = {};
  1140. /**
  1141. * keeps track of what level each sequence is at since multiple
  1142. * sequences can start out with the same sequence
  1143. *
  1144. * @type {Object}
  1145. */
  1146. var _sequenceLevels = {};
  1147. /**
  1148. * variable to store the setTimeout call
  1149. *
  1150. * @type {null|number}
  1151. */
  1152. var _resetTimer;
  1153. /**
  1154. * temporary state where we will ignore the next keyup
  1155. *
  1156. * @type {boolean|string}
  1157. */
  1158. var _ignoreNextKeyup = false;
  1159. /**
  1160. * temporary state where we will ignore the next keypress
  1161. *
  1162. * @type {boolean}
  1163. */
  1164. var _ignoreNextKeypress = false;
  1165. /**
  1166. * are we currently inside of a sequence?
  1167. * type of action ("keyup" or "keydown" or "keypress") or false
  1168. *
  1169. * @type {boolean|string}
  1170. */
  1171. var _nextExpectedAction = false;
  1172. /**
  1173. * resets all sequence counters except for the ones passed in
  1174. *
  1175. * @param {Object} doNotReset
  1176. * @returns void
  1177. */
  1178. function _resetSequences(doNotReset) {
  1179. doNotReset = doNotReset || {};
  1180. var activeSequences = false,
  1181. key;
  1182. for (key in _sequenceLevels) {
  1183. if (doNotReset[key]) {
  1184. activeSequences = true;
  1185. continue;
  1186. }
  1187. _sequenceLevels[key] = 0;
  1188. }
  1189. if (!activeSequences) {
  1190. _nextExpectedAction = false;
  1191. }
  1192. }
  1193. /**
  1194. * finds all callbacks that match based on the keycode, modifiers,
  1195. * and action
  1196. *
  1197. * @param {string} character
  1198. * @param {Array} modifiers
  1199. * @param {Event|Object} e
  1200. * @param {string=} sequenceName - name of the sequence we are looking for
  1201. * @param {string=} combination
  1202. * @param {number=} level
  1203. * @returns {Array}
  1204. */
  1205. function _getMatches(character, modifiers, e, sequenceName, combination, level) {
  1206. var i;
  1207. var callback;
  1208. var matches = [];
  1209. var action = e.type;
  1210. // if there are no events related to this keycode
  1211. if (!self._callbacks[character]) {
  1212. return [];
  1213. }
  1214. // if a modifier key is coming up on its own we should allow it
  1215. if (action == 'keyup' && _isModifier(character)) {
  1216. modifiers = [character];
  1217. }
  1218. // loop through all callbacks for the key that was pressed
  1219. // and see if any of them match
  1220. for (i = 0; i < self._callbacks[character].length; ++i) {
  1221. callback = self._callbacks[character][i];
  1222. // if a sequence name is not specified, but this is a sequence at
  1223. // the wrong level then move onto the next match
  1224. if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
  1225. continue;
  1226. }
  1227. // if the action we are looking for doesn't match the action we got
  1228. // then we should keep going
  1229. if (action != callback.action) {
  1230. continue;
  1231. }
  1232. // if this is a keypress event and the meta key and control key
  1233. // are not pressed that means that we need to only look at the
  1234. // character, otherwise check the modifiers as well
  1235. //
  1236. // chrome will not fire a keypress if meta or control is down
  1237. // safari will fire a keypress if meta or meta+shift is down
  1238. // firefox will fire a keypress if meta or control is down
  1239. if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {
  1240. // when you bind a combination or sequence a second time it
  1241. // should overwrite the first one. if a sequenceName or
  1242. // combination is specified in this call it does just that
  1243. //
  1244. // @todo make deleting its own method?
  1245. var deleteCombo = !sequenceName && callback.combo == combination;
  1246. var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
  1247. if (deleteCombo || deleteSequence) {
  1248. self._callbacks[character].splice(i, 1);
  1249. }
  1250. matches.push(callback);
  1251. }
  1252. }
  1253. return matches;
  1254. }
  1255. /**
  1256. * actually calls the callback function
  1257. *
  1258. * if your callback function returns false this will use the jquery
  1259. * convention - prevent default and stop propogation on the event
  1260. *
  1261. * @param {Function} callback
  1262. * @param {Event} e
  1263. * @returns void
  1264. */
  1265. function _fireCallback(callback, e, combo, sequence) {
  1266. // if this event should not happen stop here
  1267. if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
  1268. return;
  1269. }
  1270. if (callback(e, combo) === false) {
  1271. _preventDefault(e);
  1272. _stopPropagation(e);
  1273. }
  1274. }
  1275. /**
  1276. * handles a character key event
  1277. *
  1278. * @param {string} character
  1279. * @param {Array} modifiers
  1280. * @param {Event} e
  1281. * @returns void
  1282. */
  1283. self._handleKey = function(character, modifiers, e) {
  1284. var callbacks = _getMatches(character, modifiers, e);
  1285. var i;
  1286. var doNotReset = {};
  1287. var maxLevel = 0;
  1288. var processedSequenceCallback = false;
  1289. // Calculate the maxLevel for sequences so we can only execute the longest callback sequence
  1290. for (i = 0; i < callbacks.length; ++i) {
  1291. if (callbacks[i].seq) {
  1292. maxLevel = Math.max(maxLevel, callbacks[i].level);
  1293. }
  1294. }
  1295. // loop through matching callbacks for this key event
  1296. for (i = 0; i < callbacks.length; ++i) {
  1297. // fire for all sequence callbacks
  1298. // this is because if for example you have multiple sequences
  1299. // bound such as "g i" and "g t" they both need to fire the
  1300. // callback for matching g cause otherwise you can only ever
  1301. // match the first one
  1302. if (callbacks[i].seq) {
  1303. // only fire callbacks for the maxLevel to prevent
  1304. // subsequences from also firing
  1305. //
  1306. // for example 'a option b' should not cause 'option b' to fire
  1307. // even though 'option b' is part of the other sequence
  1308. //
  1309. // any sequences that do not match here will be discarded
  1310. // below by the _resetSequences call
  1311. if (callbacks[i].level != maxLevel) {
  1312. continue;
  1313. }
  1314. processedSequenceCallback = true;
  1315. // keep a list of which sequences were matches for later
  1316. doNotReset[callbacks[i].seq] = 1;
  1317. _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);
  1318. continue;
  1319. }
  1320. // if there were no sequence matches but we are still here
  1321. // that means this is a regular match so we should fire that
  1322. if (!processedSequenceCallback) {
  1323. _fireCallback(callbacks[i].callback, e, callbacks[i].combo);
  1324. }
  1325. }
  1326. // if the key you pressed matches the type of sequence without
  1327. // being a modifier (ie "keyup" or "keypress") then we should
  1328. // reset all sequences that were not matched by this event
  1329. //
  1330. // this is so, for example, if you have the sequence "h a t" and you
  1331. // type "h e a r t" it does not match. in this case the "e" will
  1332. // cause the sequence to reset
  1333. //
  1334. // modifier keys are ignored because you can have a sequence
  1335. // that contains modifiers such as "enter ctrl+space" and in most
  1336. // cases the modifier key will be pressed before the next key
  1337. //
  1338. // also if you have a sequence such as "ctrl+b a" then pressing the
  1339. // "b" key will trigger a "keypress" and a "keydown"
  1340. //
  1341. // the "keydown" is expected when there is a modifier, but the
  1342. // "keypress" ends up matching the _nextExpectedAction since it occurs
  1343. // after and that causes the sequence to reset
  1344. //
  1345. // we ignore keypresses in a sequence that directly follow a keydown
  1346. // for the same character
  1347. var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
  1348. if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
  1349. _resetSequences(doNotReset);
  1350. }
  1351. _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
  1352. };
  1353. /**
  1354. * handles a keydown event
  1355. *
  1356. * @param {Event} e
  1357. * @returns void
  1358. */
  1359. function _handleKeyEvent(e) {
  1360. // normalize e.which for key events
  1361. // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
  1362. if (typeof e.which !== 'number') {
  1363. e.which = e.keyCode;
  1364. }
  1365. var character = _characterFromEvent(e);
  1366. // no character found then stop
  1367. if (!character) {
  1368. return;
  1369. }
  1370. // need to use === for the character check because the character can be 0
  1371. if (e.type == 'keyup' && _ignoreNextKeyup === character) {
  1372. _ignoreNextKeyup = false;
  1373. return;
  1374. }
  1375. self.handleKey(character, _eventModifiers(e), e);
  1376. }
  1377. /**
  1378. * called to set a 1 second timeout on the specified sequence
  1379. *
  1380. * this is so after each key press in the sequence you have 1 second
  1381. * to press the next key before you have to start over
  1382. *
  1383. * @returns void
  1384. */
  1385. function _resetSequenceTimer() {
  1386. clearTimeout(_resetTimer);
  1387. _resetTimer = setTimeout(_resetSequences, 1000);
  1388. }
  1389. /**
  1390. * binds a key sequence to an event
  1391. *
  1392. * @param {string} combo - combo specified in bind call
  1393. * @param {Array} keys
  1394. * @param {Function} callback
  1395. * @param {string=} action
  1396. * @returns void
  1397. */
  1398. function _bindSequence(combo, keys, callback, action) {
  1399. // start off by adding a sequence level record for this combination
  1400. // and setting the level to 0
  1401. _sequenceLevels[combo] = 0;
  1402. /**
  1403. * callback to increase the sequence level for this sequence and reset
  1404. * all other sequences that were active
  1405. *
  1406. * @param {string} nextAction
  1407. * @returns {Function}
  1408. */
  1409. function _increaseSequence(nextAction) {
  1410. return function() {
  1411. _nextExpectedAction = nextAction;
  1412. ++_sequenceLevels[combo];
  1413. _resetSequenceTimer();
  1414. };
  1415. }
  1416. /**
  1417. * wraps the specified callback inside of another function in order
  1418. * to reset all sequence counters as soon as this sequence is done
  1419. *
  1420. * @param {Event} e
  1421. * @returns void
  1422. */
  1423. function _callbackAndReset(e) {
  1424. _fireCallback(callback, e, combo);
  1425. // we should ignore the next key up if the action is key down
  1426. // or keypress. this is so if you finish a sequence and
  1427. // release the key the final key will not trigger a keyup
  1428. if (action !== 'keyup') {
  1429. _ignoreNextKeyup = _characterFromEvent(e);
  1430. }
  1431. // weird race condition if a sequence ends with the key
  1432. // another sequence begins with
  1433. setTimeout(_resetSequences, 10);
  1434. }
  1435. // loop through keys one at a time and bind the appropriate callback
  1436. // function. for any key leading up to the final one it should
  1437. // increase the sequence. after the final, it should reset all sequences
  1438. //
  1439. // if an action is specified in the original bind call then that will
  1440. // be used throughout. otherwise we will pass the action that the
  1441. // next key in the sequence should match. this allows a sequence
  1442. // to mix and match keypress and keydown events depending on which
  1443. // ones are better suited to the key provided
  1444. for (var i = 0; i < keys.length; ++i) {
  1445. var isFinal = i + 1 === keys.length;
  1446. var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action);
  1447. _bindSingle(keys[i], wrappedCallback, action, combo, i);
  1448. }
  1449. }
  1450. /**
  1451. * binds a single keyboard combination
  1452. *
  1453. * @param {string} combination
  1454. * @param {Function} callback
  1455. * @param {string=} action
  1456. * @param {string=} sequenceName - name of sequence if part of sequence
  1457. * @param {number=} level - what part of the sequence the command is
  1458. * @returns void
  1459. */
  1460. function _bindSingle(combination, callback, action, sequenceName, level) {
  1461. // store a direct mapped reference for use with Mousetrap.trigger
  1462. self._directMap[combination + ':' + action] = callback;
  1463. // make sure multiple spaces in a row become a single space
  1464. combination = combination.replace(/\s+/g, ' ');
  1465. var sequence = combination.split(' ');
  1466. var info;
  1467. // if this pattern is a sequence of keys then run through this method
  1468. // to reprocess each pattern one key at a time
  1469. if (sequence.length > 1) {
  1470. _bindSequence(combination, sequence, callback, action);
  1471. return;
  1472. }
  1473. info = _getKeyInfo(combination, action);
  1474. // make sure to initialize array if this is the first time
  1475. // a callback is added for this key
  1476. self._callbacks[info.key] = self._callbacks[info.key] || [];
  1477. // remove an existing match if there is one
  1478. _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);
  1479. // add this call back to the array
  1480. // if it is a sequence put it at the beginning
  1481. // if not put it at the end
  1482. //
  1483. // this is important because the way these are processed expects
  1484. // the sequence ones to come first
  1485. self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({
  1486. callback: callback,
  1487. modifiers: info.modifiers,
  1488. action: info.action,
  1489. seq: sequenceName,
  1490. level: level,
  1491. combo: combination
  1492. });
  1493. }
  1494. /**
  1495. * binds multiple combinations to the same callback
  1496. *
  1497. * @param {Array} combinations
  1498. * @param {Function} callback
  1499. * @param {string|undefined} action
  1500. * @returns void
  1501. */
  1502. self._bindMultiple = function(combinations, callback, action) {
  1503. for (var i = 0; i < combinations.length; ++i) {
  1504. _bindSingle(combinations[i], callback, action);
  1505. }
  1506. };
  1507. // start!
  1508. _addEvent(targetElement, 'keypress', _handleKeyEvent);
  1509. _addEvent(targetElement, 'keydown', _handleKeyEvent);
  1510. _addEvent(targetElement, 'keyup', _handleKeyEvent);
  1511. }
  1512. /**
  1513. * binds an event to mousetrap
  1514. *
  1515. * can be a single key, a combination of keys separated with +,
  1516. * an array of keys, or a sequence of keys separated by spaces
  1517. *
  1518. * be sure to list the modifier keys first to make sure that the
  1519. * correct key ends up getting bound (the last key in the pattern)
  1520. *
  1521. * @param {string|Array} keys
  1522. * @param {Function} callback
  1523. * @param {string=} action - 'keypress', 'keydown', or 'keyup'
  1524. * @returns void
  1525. */
  1526. Mousetrap.prototype.bind = function(keys, callback, action) {
  1527. var self = this;
  1528. keys = keys instanceof Array ? keys : [keys];
  1529. self._bindMultiple.call(self, keys, callback, action);
  1530. return self;
  1531. };
  1532. /**
  1533. * unbinds an event to mousetrap
  1534. *
  1535. * the unbinding sets the callback function of the specified key combo
  1536. * to an empty function and deletes the corresponding key in the
  1537. * _directMap dict.
  1538. *
  1539. * TODO: actually remove this from the _callbacks dictionary instead
  1540. * of binding an empty function
  1541. *
  1542. * the keycombo+action has to be exactly the same as
  1543. * it was defined in the bind method
  1544. *
  1545. * @param {string|Array} keys
  1546. * @param {string} action
  1547. * @returns void
  1548. */
  1549. Mousetrap.prototype.unbind = function(keys, action) {
  1550. var self = this;
  1551. return self.bind.call(self, keys, function() {}, action);
  1552. };
  1553. /**
  1554. * triggers an event that has already been bound
  1555. *
  1556. * @param {string} keys
  1557. * @param {string=} action
  1558. * @returns void
  1559. */
  1560. Mousetrap.prototype.trigger = function(keys, action) {
  1561. var self = this;
  1562. if (self._directMap[keys + ':' + action]) {
  1563. self._directMap[keys + ':' + action]({}, keys);
  1564. }
  1565. return self;
  1566. };
  1567. /**
  1568. * resets the library back to its initial state. this is useful
  1569. * if you want to clear out the current keyboard shortcuts and bind
  1570. * new ones - for example if you switch to another page
  1571. *
  1572. * @returns void
  1573. */
  1574. Mousetrap.prototype.reset = function() {
  1575. var self = this;
  1576. self._callbacks = {};
  1577. self._directMap = {};
  1578. return self;
  1579. };
  1580. /**
  1581. * should we stop this event before firing off callbacks
  1582. *
  1583. * @param {Event} e
  1584. * @param {Element} element
  1585. * @return {boolean}
  1586. */
  1587. Mousetrap.prototype.stopCallback = function(e, element) {
  1588. var self = this;
  1589. // if the element has the class "mousetrap" then no need to stop
  1590. if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
  1591. return false;
  1592. }
  1593. if (_belongsTo(element, self.target)) {
  1594. return false;
  1595. }
  1596. // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host,
  1597. // not the initial event target in the shadow tree. Note that not all events cross the
  1598. // shadow boundary.
  1599. // For shadow trees with `mode: 'open'`, the initial event target is the first element in
  1600. // the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event
  1601. // target cannot be obtained.
  1602. if ('composedPath' in e && typeof e.composedPath === 'function') {
  1603. // For open shadow trees, update `element` so that the following check works.
  1604. var initialEventTarget = e.composedPath()[0];
  1605. if (initialEventTarget !== e.target) {
  1606. element = initialEventTarget;
  1607. }
  1608. }
  1609. // stop for input, select, and textarea
  1610. return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
  1611. };
  1612. /**
  1613. * exposes _handleKey publicly so it can be overwritten by extensions
  1614. */
  1615. Mousetrap.prototype.handleKey = function() {
  1616. var self = this;
  1617. return self._handleKey.apply(self, arguments);
  1618. };
  1619. /**
  1620. * allow custom key mappings
  1621. */
  1622. Mousetrap.addKeycodes = function(object) {
  1623. for (var key in object) {
  1624. if (object.hasOwnProperty(key)) {
  1625. _MAP[key] = object[key];
  1626. }
  1627. }
  1628. _REVERSE_MAP = null;
  1629. };
  1630. /**
  1631. * Init the global mousetrap functions
  1632. *
  1633. * This method is needed to allow the global mousetrap functions to work
  1634. * now that mousetrap is a constructor function.
  1635. */
  1636. Mousetrap.init = function() {
  1637. var documentMousetrap = Mousetrap(document);
  1638. for (var method in documentMousetrap) {
  1639. if (method.charAt(0) !== '_') {
  1640. Mousetrap[method] = (function(method) {
  1641. return function() {
  1642. return documentMousetrap[method].apply(documentMousetrap, arguments);
  1643. };
  1644. } (method));
  1645. }
  1646. }
  1647. };
  1648. Mousetrap.init();
  1649. // expose mousetrap to the global object
  1650. window.Mousetrap = Mousetrap;
  1651. // expose as a common js module
  1652. if ( true && module.exports) {
  1653. module.exports = Mousetrap;
  1654. }
  1655. // expose mousetrap as an AMD module
  1656. if (true) {
  1657. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  1658. return Mousetrap;
  1659. }).call(exports, __webpack_require__, exports, module),
  1660. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1661. }
  1662. }) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null);
  1663. /***/ }),
  1664. /***/ 5538:
  1665. /***/ (function() {
  1666. /**
  1667. * adds a bindGlobal method to Mousetrap that allows you to
  1668. * bind specific keyboard shortcuts that will still work
  1669. * inside a text input field
  1670. *
  1671. * usage:
  1672. * Mousetrap.bindGlobal('ctrl+s', _saveChanges);
  1673. */
  1674. /* global Mousetrap:true */
  1675. (function(Mousetrap) {
  1676. if (! Mousetrap) {
  1677. return;
  1678. }
  1679. var _globalCallbacks = {};
  1680. var _originalStopCallback = Mousetrap.prototype.stopCallback;
  1681. Mousetrap.prototype.stopCallback = function(e, element, combo, sequence) {
  1682. var self = this;
  1683. if (self.paused) {
  1684. return true;
  1685. }
  1686. if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
  1687. return false;
  1688. }
  1689. return _originalStopCallback.call(self, e, element, combo);
  1690. };
  1691. Mousetrap.prototype.bindGlobal = function(keys, callback, action) {
  1692. var self = this;
  1693. self.bind(keys, callback, action);
  1694. if (keys instanceof Array) {
  1695. for (var i = 0; i < keys.length; i++) {
  1696. _globalCallbacks[keys[i]] = true;
  1697. }
  1698. return;
  1699. }
  1700. _globalCallbacks[keys] = true;
  1701. };
  1702. Mousetrap.init();
  1703. }) (typeof Mousetrap !== "undefined" ? Mousetrap : undefined);
  1704. /***/ })
  1705. /******/ });
  1706. /************************************************************************/
  1707. /******/ // The module cache
  1708. /******/ var __webpack_module_cache__ = {};
  1709. /******/
  1710. /******/ // The require function
  1711. /******/ function __webpack_require__(moduleId) {
  1712. /******/ // Check if module is in cache
  1713. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  1714. /******/ if (cachedModule !== undefined) {
  1715. /******/ return cachedModule.exports;
  1716. /******/ }
  1717. /******/ // Create a new module (and put it into the cache)
  1718. /******/ var module = __webpack_module_cache__[moduleId] = {
  1719. /******/ // no module.id needed
  1720. /******/ // no module.loaded needed
  1721. /******/ exports: {}
  1722. /******/ };
  1723. /******/
  1724. /******/ // Execute the module function
  1725. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  1726. /******/
  1727. /******/ // Return the exports of the module
  1728. /******/ return module.exports;
  1729. /******/ }
  1730. /******/
  1731. /************************************************************************/
  1732. /******/ /* webpack/runtime/compat get default export */
  1733. /******/ !function() {
  1734. /******/ // getDefaultExport function for compatibility with non-harmony modules
  1735. /******/ __webpack_require__.n = function(module) {
  1736. /******/ var getter = module && module.__esModule ?
  1737. /******/ function() { return module['default']; } :
  1738. /******/ function() { return module; };
  1739. /******/ __webpack_require__.d(getter, { a: getter });
  1740. /******/ return getter;
  1741. /******/ };
  1742. /******/ }();
  1743. /******/
  1744. /******/ /* webpack/runtime/define property getters */
  1745. /******/ !function() {
  1746. /******/ // define getter functions for harmony exports
  1747. /******/ __webpack_require__.d = function(exports, definition) {
  1748. /******/ for(var key in definition) {
  1749. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  1750. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  1751. /******/ }
  1752. /******/ }
  1753. /******/ };
  1754. /******/ }();
  1755. /******/
  1756. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  1757. /******/ !function() {
  1758. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  1759. /******/ }();
  1760. /******/
  1761. /******/ /* webpack/runtime/make namespace object */
  1762. /******/ !function() {
  1763. /******/ // define __esModule on exports
  1764. /******/ __webpack_require__.r = function(exports) {
  1765. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  1766. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  1767. /******/ }
  1768. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  1769. /******/ };
  1770. /******/ }();
  1771. /******/
  1772. /************************************************************************/
  1773. var __webpack_exports__ = {};
  1774. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  1775. !function() {
  1776. "use strict";
  1777. // ESM COMPAT FLAG
  1778. __webpack_require__.r(__webpack_exports__);
  1779. // EXPORTS
  1780. __webpack_require__.d(__webpack_exports__, {
  1781. "__experimentalUseDialog": function() { return /* reexport */ use_dialog; },
  1782. "__experimentalUseDragging": function() { return /* reexport */ useDragging; },
  1783. "__experimentalUseDropZone": function() { return /* reexport */ useDropZone; },
  1784. "__experimentalUseFixedWindowList": function() { return /* reexport */ useFixedWindowList; },
  1785. "__experimentalUseFocusOutside": function() { return /* reexport */ useFocusOutside; },
  1786. "compose": function() { return /* reexport */ compose; },
  1787. "createHigherOrderComponent": function() { return /* reexport */ createHigherOrderComponent; },
  1788. "ifCondition": function() { return /* reexport */ if_condition; },
  1789. "pure": function() { return /* reexport */ higher_order_pure; },
  1790. "useAsyncList": function() { return /* reexport */ use_async_list; },
  1791. "useConstrainedTabbing": function() { return /* reexport */ use_constrained_tabbing; },
  1792. "useCopyOnClick": function() { return /* reexport */ useCopyOnClick; },
  1793. "useCopyToClipboard": function() { return /* reexport */ useCopyToClipboard; },
  1794. "useDebounce": function() { return /* reexport */ useDebounce; },
  1795. "useDisabled": function() { return /* reexport */ useDisabled; },
  1796. "useFocusOnMount": function() { return /* reexport */ useFocusOnMount; },
  1797. "useFocusReturn": function() { return /* reexport */ use_focus_return; },
  1798. "useFocusableIframe": function() { return /* reexport */ useFocusableIframe; },
  1799. "useInstanceId": function() { return /* reexport */ useInstanceId; },
  1800. "useIsomorphicLayoutEffect": function() { return /* reexport */ use_isomorphic_layout_effect; },
  1801. "useKeyboardShortcut": function() { return /* reexport */ use_keyboard_shortcut; },
  1802. "useMediaQuery": function() { return /* reexport */ useMediaQuery; },
  1803. "useMergeRefs": function() { return /* reexport */ useMergeRefs; },
  1804. "usePrevious": function() { return /* reexport */ usePrevious; },
  1805. "useReducedMotion": function() { return /* reexport */ use_reduced_motion; },
  1806. "useRefEffect": function() { return /* reexport */ useRefEffect; },
  1807. "useResizeObserver": function() { return /* reexport */ useResizeAware; },
  1808. "useThrottle": function() { return /* reexport */ useThrottle; },
  1809. "useViewportMatch": function() { return /* reexport */ use_viewport_match; },
  1810. "useWarnOnChange": function() { return /* reexport */ use_warn_on_change; },
  1811. "withGlobalEvents": function() { return /* reexport */ withGlobalEvents; },
  1812. "withInstanceId": function() { return /* reexport */ with_instance_id; },
  1813. "withSafeTimeout": function() { return /* reexport */ with_safe_timeout; },
  1814. "withState": function() { return /* reexport */ withState; }
  1815. });
  1816. ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.js
  1817. /*! *****************************************************************************
  1818. Copyright (c) Microsoft Corporation.
  1819. Permission to use, copy, modify, and/or distribute this software for any
  1820. purpose with or without fee is hereby granted.
  1821. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  1822. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  1823. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  1824. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1825. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  1826. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1827. PERFORMANCE OF THIS SOFTWARE.
  1828. ***************************************************************************** */
  1829. /* global Reflect, Promise */
  1830. var extendStatics = function(d, b) {
  1831. extendStatics = Object.setPrototypeOf ||
  1832. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1833. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1834. return extendStatics(d, b);
  1835. };
  1836. function __extends(d, b) {
  1837. if (typeof b !== "function" && b !== null)
  1838. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1839. extendStatics(d, b);
  1840. function __() { this.constructor = d; }
  1841. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1842. }
  1843. var __assign = function() {
  1844. __assign = Object.assign || function __assign(t) {
  1845. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1846. s = arguments[i];
  1847. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  1848. }
  1849. return t;
  1850. }
  1851. return __assign.apply(this, arguments);
  1852. }
  1853. function __rest(s, e) {
  1854. var t = {};
  1855. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  1856. t[p] = s[p];
  1857. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  1858. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  1859. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  1860. t[p[i]] = s[p[i]];
  1861. }
  1862. return t;
  1863. }
  1864. function __decorate(decorators, target, key, desc) {
  1865. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1866. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1867. 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;
  1868. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1869. }
  1870. function __param(paramIndex, decorator) {
  1871. return function (target, key) { decorator(target, key, paramIndex); }
  1872. }
  1873. function __metadata(metadataKey, metadataValue) {
  1874. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  1875. }
  1876. function __awaiter(thisArg, _arguments, P, generator) {
  1877. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1878. return new (P || (P = Promise))(function (resolve, reject) {
  1879. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1880. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1881. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1882. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1883. });
  1884. }
  1885. function __generator(thisArg, body) {
  1886. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1887. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1888. function verb(n) { return function (v) { return step([n, v]); }; }
  1889. function step(op) {
  1890. if (f) throw new TypeError("Generator is already executing.");
  1891. while (_) try {
  1892. 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;
  1893. if (y = 0, t) op = [op[0] & 2, t.value];
  1894. switch (op[0]) {
  1895. case 0: case 1: t = op; break;
  1896. case 4: _.label++; return { value: op[1], done: false };
  1897. case 5: _.label++; y = op[1]; op = [0]; continue;
  1898. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1899. default:
  1900. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1901. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1902. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1903. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1904. if (t[2]) _.ops.pop();
  1905. _.trys.pop(); continue;
  1906. }
  1907. op = body.call(thisArg, _);
  1908. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1909. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1910. }
  1911. }
  1912. var __createBinding = Object.create ? (function(o, m, k, k2) {
  1913. if (k2 === undefined) k2 = k;
  1914. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  1915. }) : (function(o, m, k, k2) {
  1916. if (k2 === undefined) k2 = k;
  1917. o[k2] = m[k];
  1918. });
  1919. function __exportStar(m, o) {
  1920. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
  1921. }
  1922. function __values(o) {
  1923. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  1924. if (m) return m.call(o);
  1925. if (o && typeof o.length === "number") return {
  1926. next: function () {
  1927. if (o && i >= o.length) o = void 0;
  1928. return { value: o && o[i++], done: !o };
  1929. }
  1930. };
  1931. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  1932. }
  1933. function __read(o, n) {
  1934. var m = typeof Symbol === "function" && o[Symbol.iterator];
  1935. if (!m) return o;
  1936. var i = m.call(o), r, ar = [], e;
  1937. try {
  1938. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  1939. }
  1940. catch (error) { e = { error: error }; }
  1941. finally {
  1942. try {
  1943. if (r && !r.done && (m = i["return"])) m.call(i);
  1944. }
  1945. finally { if (e) throw e.error; }
  1946. }
  1947. return ar;
  1948. }
  1949. /** @deprecated */
  1950. function __spread() {
  1951. for (var ar = [], i = 0; i < arguments.length; i++)
  1952. ar = ar.concat(__read(arguments[i]));
  1953. return ar;
  1954. }
  1955. /** @deprecated */
  1956. function __spreadArrays() {
  1957. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  1958. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  1959. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  1960. r[k] = a[j];
  1961. return r;
  1962. }
  1963. function __spreadArray(to, from, pack) {
  1964. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  1965. if (ar || !(i in from)) {
  1966. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  1967. ar[i] = from[i];
  1968. }
  1969. }
  1970. return to.concat(ar || Array.prototype.slice.call(from));
  1971. }
  1972. function __await(v) {
  1973. return this instanceof __await ? (this.v = v, this) : new __await(v);
  1974. }
  1975. function __asyncGenerator(thisArg, _arguments, generator) {
  1976. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  1977. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  1978. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  1979. 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); }); }; }
  1980. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  1981. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  1982. function fulfill(value) { resume("next", value); }
  1983. function reject(value) { resume("throw", value); }
  1984. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  1985. }
  1986. function __asyncDelegator(o) {
  1987. var i, p;
  1988. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  1989. 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; }
  1990. }
  1991. function __asyncValues(o) {
  1992. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  1993. var m = o[Symbol.asyncIterator], i;
  1994. 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);
  1995. 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); }); }; }
  1996. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  1997. }
  1998. function __makeTemplateObject(cooked, raw) {
  1999. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  2000. return cooked;
  2001. };
  2002. var __setModuleDefault = Object.create ? (function(o, v) {
  2003. Object.defineProperty(o, "default", { enumerable: true, value: v });
  2004. }) : function(o, v) {
  2005. o["default"] = v;
  2006. };
  2007. function __importStar(mod) {
  2008. if (mod && mod.__esModule) return mod;
  2009. var result = {};
  2010. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  2011. __setModuleDefault(result, mod);
  2012. return result;
  2013. }
  2014. function __importDefault(mod) {
  2015. return (mod && mod.__esModule) ? mod : { default: mod };
  2016. }
  2017. function __classPrivateFieldGet(receiver, state, kind, f) {
  2018. if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
  2019. if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  2020. return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
  2021. }
  2022. function __classPrivateFieldSet(receiver, state, value, kind, f) {
  2023. if (kind === "m") throw new TypeError("Private method is not writable");
  2024. if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
  2025. if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  2026. return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
  2027. }
  2028. ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
  2029. /**
  2030. * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
  2031. */
  2032. var SUPPORTED_LOCALE = {
  2033. tr: {
  2034. regexp: /\u0130|\u0049|\u0049\u0307/g,
  2035. map: {
  2036. İ: "\u0069",
  2037. I: "\u0131",
  2038. İ: "\u0069",
  2039. },
  2040. },
  2041. az: {
  2042. regexp: /\u0130/g,
  2043. map: {
  2044. İ: "\u0069",
  2045. I: "\u0131",
  2046. İ: "\u0069",
  2047. },
  2048. },
  2049. lt: {
  2050. regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
  2051. map: {
  2052. I: "\u0069\u0307",
  2053. J: "\u006A\u0307",
  2054. Į: "\u012F\u0307",
  2055. Ì: "\u0069\u0307\u0300",
  2056. Í: "\u0069\u0307\u0301",
  2057. Ĩ: "\u0069\u0307\u0303",
  2058. },
  2059. },
  2060. };
  2061. /**
  2062. * Localized lower case.
  2063. */
  2064. function localeLowerCase(str, locale) {
  2065. var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
  2066. if (lang)
  2067. return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
  2068. return lowerCase(str);
  2069. }
  2070. /**
  2071. * Lower case as a function.
  2072. */
  2073. function lowerCase(str) {
  2074. return str.toLowerCase();
  2075. }
  2076. ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
  2077. // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
  2078. var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
  2079. // Remove all non-word characters.
  2080. var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
  2081. /**
  2082. * Normalize the string into something other libraries can manipulate easier.
  2083. */
  2084. function noCase(input, options) {
  2085. if (options === void 0) { options = {}; }
  2086. var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
  2087. var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
  2088. var start = 0;
  2089. var end = result.length;
  2090. // Trim the delimiter from around the output string.
  2091. while (result.charAt(start) === "\0")
  2092. start++;
  2093. while (result.charAt(end - 1) === "\0")
  2094. end--;
  2095. // Transform each token independently.
  2096. return result.slice(start, end).split("\0").map(transform).join(delimiter);
  2097. }
  2098. /**
  2099. * Replace `re` in the input string with the replacement value.
  2100. */
  2101. function replace(input, re, value) {
  2102. if (re instanceof RegExp)
  2103. return input.replace(re, value);
  2104. return re.reduce(function (input, re) { return input.replace(re, value); }, input);
  2105. }
  2106. ;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js
  2107. function pascalCaseTransform(input, index) {
  2108. var firstChar = input.charAt(0);
  2109. var lowerChars = input.substr(1).toLowerCase();
  2110. if (index > 0 && firstChar >= "0" && firstChar <= "9") {
  2111. return "_" + firstChar + lowerChars;
  2112. }
  2113. return "" + firstChar.toUpperCase() + lowerChars;
  2114. }
  2115. function pascalCaseTransformMerge(input) {
  2116. return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
  2117. }
  2118. function pascalCase(input, options) {
  2119. if (options === void 0) { options = {}; }
  2120. return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
  2121. }
  2122. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js
  2123. /**
  2124. * External dependencies
  2125. */
  2126. /**
  2127. * Given a function mapping a component to an enhanced component and modifier
  2128. * name, returns the enhanced component augmented with a generated displayName.
  2129. *
  2130. * @param mapComponent Function mapping component to enhanced component.
  2131. * @param modifierName Seed name from which to generated display name.
  2132. *
  2133. * @return Component class with generated display name assigned.
  2134. */
  2135. function createHigherOrderComponent(mapComponent, modifierName) {
  2136. return Inner => {
  2137. const Outer = mapComponent(Inner);
  2138. Outer.displayName = hocName(modifierName, Inner);
  2139. return Outer;
  2140. };
  2141. }
  2142. /**
  2143. * Returns a displayName for a higher-order component, given a wrapper name.
  2144. *
  2145. * @example
  2146. * hocName( 'MyMemo', Widget ) === 'MyMemo(Widget)';
  2147. * hocName( 'MyMemo', <div /> ) === 'MyMemo(Component)';
  2148. *
  2149. * @param name Name assigned to higher-order component's wrapper component.
  2150. * @param Inner Wrapped component inside higher-order component.
  2151. * @return Wrapped name of higher-order component.
  2152. */
  2153. const hocName = (name, Inner) => {
  2154. const inner = Inner.displayName || Inner.name || 'Component';
  2155. const outer = pascalCase(name !== null && name !== void 0 ? name : '');
  2156. return `${outer}(${inner})`;
  2157. };
  2158. ;// CONCATENATED MODULE: external "lodash"
  2159. var external_lodash_namespaceObject = window["lodash"];
  2160. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/compose.js
  2161. /**
  2162. * External dependencies
  2163. */
  2164. /**
  2165. * Composes multiple higher-order components into a single higher-order component. Performs right-to-left function
  2166. * composition, where each successive invocation is supplied the return value of the previous.
  2167. *
  2168. * This is just a re-export of `lodash`'s `flowRight` function.
  2169. *
  2170. * @see https://docs-lodash.com/v4/flow-right/
  2171. */
  2172. /* harmony default export */ var compose = (external_lodash_namespaceObject.flowRight);
  2173. ;// CONCATENATED MODULE: external ["wp","element"]
  2174. var external_wp_element_namespaceObject = window["wp"]["element"];
  2175. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js
  2176. /**
  2177. * External dependencies
  2178. */
  2179. /**
  2180. * Internal dependencies
  2181. */
  2182. /**
  2183. * Higher-order component creator, creating a new component which renders if
  2184. * the given condition is satisfied or with the given optional prop name.
  2185. *
  2186. * @example
  2187. * ```ts
  2188. * type Props = { foo: string };
  2189. * const Component = ( props: Props ) => <div>{ props.foo }</div>;
  2190. * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component );
  2191. * <ConditionalComponent foo="" />; // => null
  2192. * <ConditionalComponent foo="bar" />; // => <div>bar</div>;
  2193. * ```
  2194. *
  2195. * @param predicate Function to test condition.
  2196. *
  2197. * @return Higher-order component.
  2198. */
  2199. function ifCondition(predicate) {
  2200. return createHigherOrderComponent(WrappedComponent => props => {
  2201. if (!predicate(props)) {
  2202. return null;
  2203. }
  2204. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, props);
  2205. }, 'ifCondition');
  2206. }
  2207. /* harmony default export */ var if_condition = (ifCondition);
  2208. ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
  2209. var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
  2210. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
  2211. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pure/index.js
  2212. /**
  2213. * External dependencies
  2214. */
  2215. /**
  2216. * WordPress dependencies
  2217. */
  2218. /**
  2219. * Internal dependencies
  2220. */
  2221. /**
  2222. * Given a component returns the enhanced component augmented with a component
  2223. * only re-rendering when its props/state change
  2224. */
  2225. const pure = createHigherOrderComponent(function (WrappedComponent) {
  2226. if (WrappedComponent.prototype instanceof external_wp_element_namespaceObject.Component) {
  2227. return class extends WrappedComponent {
  2228. shouldComponentUpdate(nextProps, nextState) {
  2229. return !external_wp_isShallowEqual_default()(nextProps, this.props) || !external_wp_isShallowEqual_default()(nextState, this.state);
  2230. }
  2231. };
  2232. }
  2233. return class extends external_wp_element_namespaceObject.Component {
  2234. shouldComponentUpdate(nextProps) {
  2235. return !external_wp_isShallowEqual_default()(nextProps, this.props);
  2236. }
  2237. render() {
  2238. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, this.props);
  2239. }
  2240. };
  2241. }, 'pure');
  2242. /* harmony default export */ var higher_order_pure = (pure);
  2243. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  2244. function _extends() {
  2245. _extends = Object.assign ? Object.assign.bind() : function (target) {
  2246. for (var i = 1; i < arguments.length; i++) {
  2247. var source = arguments[i];
  2248. for (var key in source) {
  2249. if (Object.prototype.hasOwnProperty.call(source, key)) {
  2250. target[key] = source[key];
  2251. }
  2252. }
  2253. }
  2254. return target;
  2255. };
  2256. return _extends.apply(this, arguments);
  2257. }
  2258. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  2259. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  2260. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  2261. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/listener.js
  2262. /**
  2263. * External dependencies
  2264. */
  2265. /**
  2266. * Class responsible for orchestrating event handling on the global window,
  2267. * binding a single event to be shared across all handling instances, and
  2268. * removing the handler when no instances are listening for the event.
  2269. */
  2270. class Listener {
  2271. constructor() {
  2272. /** @type {any} */
  2273. this.listeners = {};
  2274. this.handleEvent = this.handleEvent.bind(this);
  2275. }
  2276. add(
  2277. /** @type {any} */
  2278. eventType,
  2279. /** @type {any} */
  2280. instance) {
  2281. if (!this.listeners[eventType]) {
  2282. // Adding first listener for this type, so bind event.
  2283. window.addEventListener(eventType, this.handleEvent);
  2284. this.listeners[eventType] = [];
  2285. }
  2286. this.listeners[eventType].push(instance);
  2287. }
  2288. remove(
  2289. /** @type {any} */
  2290. eventType,
  2291. /** @type {any} */
  2292. instance) {
  2293. this.listeners[eventType] = (0,external_lodash_namespaceObject.without)(this.listeners[eventType], instance);
  2294. if (!this.listeners[eventType].length) {
  2295. // Removing last listener for this type, so unbind event.
  2296. window.removeEventListener(eventType, this.handleEvent);
  2297. delete this.listeners[eventType];
  2298. }
  2299. }
  2300. handleEvent(
  2301. /** @type {any} */
  2302. event) {
  2303. var _this$listeners$event;
  2304. (_this$listeners$event = this.listeners[event.type]) === null || _this$listeners$event === void 0 ? void 0 : _this$listeners$event.forEach((
  2305. /** @type {any} */
  2306. instance) => {
  2307. instance.handleEvent(event);
  2308. });
  2309. }
  2310. }
  2311. /* harmony default export */ var listener = (Listener);
  2312. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/index.js
  2313. /**
  2314. * WordPress dependencies
  2315. */
  2316. /**
  2317. * Internal dependencies
  2318. */
  2319. /**
  2320. * Listener instance responsible for managing document event handling.
  2321. */
  2322. const with_global_events_listener = new listener();
  2323. /* eslint-disable jsdoc/no-undefined-types */
  2324. /**
  2325. * Higher-order component creator which, given an object of DOM event types and
  2326. * values corresponding to a callback function name on the component, will
  2327. * create or update a window event handler to invoke the callback when an event
  2328. * occurs. On behalf of the consuming developer, the higher-order component
  2329. * manages unbinding when the component unmounts, and binding at most a single
  2330. * event handler for the entire application.
  2331. *
  2332. * @deprecated
  2333. *
  2334. * @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM
  2335. * event type, the value a
  2336. * name of the function on
  2337. * the original component's
  2338. * instance which handles
  2339. * the event.
  2340. *
  2341. * @return {any} Higher-order component.
  2342. */
  2343. function withGlobalEvents(eventTypesToHandlers) {
  2344. external_wp_deprecated_default()('wp.compose.withGlobalEvents', {
  2345. since: '5.7',
  2346. alternative: 'useEffect'
  2347. }); // @ts-ignore We don't need to fix the type-related issues because this is deprecated.
  2348. return createHigherOrderComponent(WrappedComponent => {
  2349. class Wrapper extends external_wp_element_namespaceObject.Component {
  2350. constructor(
  2351. /** @type {any} */
  2352. props) {
  2353. super(props);
  2354. this.handleEvent = this.handleEvent.bind(this);
  2355. this.handleRef = this.handleRef.bind(this);
  2356. }
  2357. componentDidMount() {
  2358. Object.keys(eventTypesToHandlers).forEach(eventType => {
  2359. with_global_events_listener.add(eventType, this);
  2360. });
  2361. }
  2362. componentWillUnmount() {
  2363. Object.keys(eventTypesToHandlers).forEach(eventType => {
  2364. with_global_events_listener.remove(eventType, this);
  2365. });
  2366. }
  2367. handleEvent(
  2368. /** @type {any} */
  2369. event) {
  2370. const handler = eventTypesToHandlers[
  2371. /** @type {keyof GlobalEventHandlersEventMap} */
  2372. event.type
  2373. /* eslint-enable jsdoc/no-undefined-types */
  2374. ];
  2375. if (typeof this.wrappedRef[handler] === 'function') {
  2376. this.wrappedRef[handler](event);
  2377. }
  2378. }
  2379. handleRef(
  2380. /** @type {any} */
  2381. el) {
  2382. this.wrappedRef = el; // Any component using `withGlobalEvents` that is not setting a `ref`
  2383. // will cause `this.props.forwardedRef` to be `null`, so we need this
  2384. // check.
  2385. if (this.props.forwardedRef) {
  2386. this.props.forwardedRef(el);
  2387. }
  2388. }
  2389. render() {
  2390. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props.ownProps, {
  2391. ref: this.handleRef
  2392. }));
  2393. }
  2394. }
  2395. return (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  2396. return (0,external_wp_element_namespaceObject.createElement)(Wrapper, {
  2397. ownProps: props,
  2398. forwardedRef: ref
  2399. });
  2400. });
  2401. }, 'withGlobalEvents');
  2402. }
  2403. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js
  2404. // Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case
  2405. // but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript
  2406. /* eslint-disable jsdoc/check-types */
  2407. /**
  2408. * WordPress dependencies
  2409. */
  2410. /**
  2411. * @type {WeakMap<object, number>}
  2412. */
  2413. const instanceMap = new WeakMap();
  2414. /**
  2415. * Creates a new id for a given object.
  2416. *
  2417. * @param {object} object Object reference to create an id for.
  2418. * @return {number} The instance id (index).
  2419. */
  2420. function createId(object) {
  2421. const instances = instanceMap.get(object) || 0;
  2422. instanceMap.set(object, instances + 1);
  2423. return instances;
  2424. }
  2425. /**
  2426. * Provides a unique instance ID.
  2427. *
  2428. * @param {object} object Object reference to create an id for.
  2429. * @param {string} [prefix] Prefix for the unique id.
  2430. * @param {string | number} [preferredId=''] Default ID to use.
  2431. * @return {string | number} The unique instance id.
  2432. */
  2433. function useInstanceId(object, prefix) {
  2434. let preferredId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  2435. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  2436. if (preferredId) return preferredId;
  2437. const id = createId(object);
  2438. return prefix ? `${prefix}-${id}` : id;
  2439. }, [object]);
  2440. }
  2441. /* eslint-enable jsdoc/check-types */
  2442. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-instance-id/index.js
  2443. /**
  2444. * Internal dependencies
  2445. */
  2446. /**
  2447. * A Higher Order Component used to be provide a unique instance ID by
  2448. * component.
  2449. */
  2450. const withInstanceId = createHigherOrderComponent(WrappedComponent => {
  2451. return props => {
  2452. const instanceId = useInstanceId(WrappedComponent); // @ts-ignore
  2453. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
  2454. instanceId: instanceId
  2455. }));
  2456. };
  2457. }, 'instanceId');
  2458. /* harmony default export */ var with_instance_id = (withInstanceId);
  2459. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-safe-timeout/index.js
  2460. /**
  2461. * External dependencies
  2462. */
  2463. /**
  2464. * WordPress dependencies
  2465. */
  2466. /**
  2467. * Internal dependencies
  2468. */
  2469. /**
  2470. * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`
  2471. * types here because those functions include functionality that is not handled
  2472. * by this component, like the ability to pass extra arguments.
  2473. *
  2474. * In the case of this component, we only handle the simplest case where
  2475. * `setTimeout` only accepts a function (not a string) and an optional delay.
  2476. */
  2477. /**
  2478. * A higher-order component used to provide and manage delayed function calls
  2479. * that ought to be bound to a component's lifecycle.
  2480. */
  2481. const withSafeTimeout = createHigherOrderComponent(OriginalComponent => {
  2482. return class WrappedComponent extends external_wp_element_namespaceObject.Component {
  2483. constructor(props) {
  2484. super(props);
  2485. this.timeouts = [];
  2486. this.setTimeout = this.setTimeout.bind(this);
  2487. this.clearTimeout = this.clearTimeout.bind(this);
  2488. }
  2489. componentWillUnmount() {
  2490. this.timeouts.forEach(clearTimeout);
  2491. }
  2492. setTimeout(fn, delay) {
  2493. const id = setTimeout(() => {
  2494. fn();
  2495. this.clearTimeout(id);
  2496. }, delay);
  2497. this.timeouts.push(id);
  2498. return id;
  2499. }
  2500. clearTimeout(id) {
  2501. clearTimeout(id);
  2502. this.timeouts = (0,external_lodash_namespaceObject.without)(this.timeouts, id);
  2503. }
  2504. render() {
  2505. return (// @ts-ignore
  2506. (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, this.props, {
  2507. setTimeout: this.setTimeout,
  2508. clearTimeout: this.clearTimeout
  2509. }))
  2510. );
  2511. }
  2512. };
  2513. }, 'withSafeTimeout');
  2514. /* harmony default export */ var with_safe_timeout = (withSafeTimeout);
  2515. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-state/index.js
  2516. /**
  2517. * WordPress dependencies
  2518. */
  2519. /**
  2520. * Internal dependencies
  2521. */
  2522. /**
  2523. * A Higher Order Component used to provide and manage internal component state
  2524. * via props.
  2525. *
  2526. * @deprecated Use `useState` instead.
  2527. *
  2528. * @param {any} initialState Optional initial state of the component.
  2529. *
  2530. * @return {any} A higher order component wrapper accepting a component that takes the state props + its own props + `setState` and returning a component that only accepts the own props.
  2531. */
  2532. function withState() {
  2533. let initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2534. external_wp_deprecated_default()('wp.compose.withState', {
  2535. since: '5.8',
  2536. alternative: 'wp.element.useState'
  2537. });
  2538. return createHigherOrderComponent(OriginalComponent => {
  2539. return class WrappedComponent extends external_wp_element_namespaceObject.Component {
  2540. constructor(
  2541. /** @type {any} */
  2542. props) {
  2543. super(props);
  2544. this.setState = this.setState.bind(this);
  2545. this.state = initialState;
  2546. }
  2547. render() {
  2548. return (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, this.props, this.state, {
  2549. setState: this.setState
  2550. }));
  2551. }
  2552. };
  2553. }, 'withState');
  2554. }
  2555. ;// CONCATENATED MODULE: external ["wp","keycodes"]
  2556. var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
  2557. ;// CONCATENATED MODULE: external ["wp","dom"]
  2558. var external_wp_dom_namespaceObject = window["wp"]["dom"];
  2559. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-ref-effect/index.js
  2560. /**
  2561. * External dependencies
  2562. */
  2563. /**
  2564. * WordPress dependencies
  2565. */
  2566. /**
  2567. * Effect-like ref callback. Just like with `useEffect`, this allows you to
  2568. * return a cleanup function to be run if the ref changes or one of the
  2569. * dependencies changes. The ref is provided as an argument to the callback
  2570. * functions. The main difference between this and `useEffect` is that
  2571. * the `useEffect` callback is not called when the ref changes, but this is.
  2572. * Pass the returned ref callback as the component's ref and merge multiple refs
  2573. * with `useMergeRefs`.
  2574. *
  2575. * It's worth noting that if the dependencies array is empty, there's not
  2576. * strictly a need to clean up event handlers for example, because the node is
  2577. * to be removed. It *is* necessary if you add dependencies because the ref
  2578. * callback will be called multiple times for the same node.
  2579. *
  2580. * @param callback Callback with ref as argument.
  2581. * @param dependencies Dependencies of the callback.
  2582. *
  2583. * @return Ref callback.
  2584. */
  2585. function useRefEffect(callback, dependencies) {
  2586. const cleanup = (0,external_wp_element_namespaceObject.useRef)();
  2587. return (0,external_wp_element_namespaceObject.useCallback)(node => {
  2588. if (node) {
  2589. cleanup.current = callback(node);
  2590. } else if (cleanup.current) {
  2591. cleanup.current();
  2592. }
  2593. }, dependencies);
  2594. }
  2595. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-constrained-tabbing/index.js
  2596. /**
  2597. * WordPress dependencies
  2598. */
  2599. /**
  2600. * Internal dependencies
  2601. */
  2602. /**
  2603. * In Dialogs/modals, the tabbing must be constrained to the content of
  2604. * the wrapper element. This hook adds the behavior to the returned ref.
  2605. *
  2606. * @return {import('react').RefCallback<Element>} Element Ref.
  2607. *
  2608. * @example
  2609. * ```js
  2610. * import { useConstrainedTabbing } from '@wordpress/compose';
  2611. *
  2612. * const ConstrainedTabbingExample = () => {
  2613. * const constrainedTabbingRef = useConstrainedTabbing()
  2614. * return (
  2615. * <div ref={ constrainedTabbingRef }>
  2616. * <Button />
  2617. * <Button />
  2618. * </div>
  2619. * );
  2620. * }
  2621. * ```
  2622. */
  2623. function useConstrainedTabbing() {
  2624. return useRefEffect((
  2625. /** @type {HTMLElement} */
  2626. node) => {
  2627. /** @type {number|undefined} */
  2628. let timeoutId;
  2629. function onKeyDown(
  2630. /** @type {KeyboardEvent} */
  2631. event) {
  2632. const {
  2633. keyCode,
  2634. shiftKey,
  2635. target
  2636. } = event;
  2637. if (keyCode !== external_wp_keycodes_namespaceObject.TAB) {
  2638. return;
  2639. }
  2640. const action = shiftKey ? 'findPrevious' : 'findNext';
  2641. const nextElement = external_wp_dom_namespaceObject.focus.tabbable[action](
  2642. /** @type {HTMLElement} */
  2643. target) || null; // If the element that is about to receive focus is outside the
  2644. // area, move focus to a div and insert it at the start or end of
  2645. // the area, depending on the direction. Without preventing default
  2646. // behaviour, the browser will then move focus to the next element.
  2647. if (node.contains(nextElement)) {
  2648. return;
  2649. }
  2650. const domAction = shiftKey ? 'append' : 'prepend';
  2651. const {
  2652. ownerDocument
  2653. } = node;
  2654. const trap = ownerDocument.createElement('div');
  2655. trap.tabIndex = -1;
  2656. node[domAction](trap);
  2657. trap.focus(); // Remove after the browser moves focus to the next element.
  2658. timeoutId = setTimeout(() => node.removeChild(trap));
  2659. }
  2660. node.addEventListener('keydown', onKeyDown);
  2661. return () => {
  2662. node.removeEventListener('keydown', onKeyDown);
  2663. clearTimeout(timeoutId);
  2664. };
  2665. }, []);
  2666. }
  2667. /* harmony default export */ var use_constrained_tabbing = (useConstrainedTabbing);
  2668. // EXTERNAL MODULE: ./node_modules/clipboard/dist/clipboard.js
  2669. var dist_clipboard = __webpack_require__(8294);
  2670. var clipboard_default = /*#__PURE__*/__webpack_require__.n(dist_clipboard);
  2671. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-on-click/index.js
  2672. /**
  2673. * External dependencies
  2674. */
  2675. /**
  2676. * WordPress dependencies
  2677. */
  2678. /* eslint-disable jsdoc/no-undefined-types */
  2679. /**
  2680. * Copies the text to the clipboard when the element is clicked.
  2681. *
  2682. * @deprecated
  2683. *
  2684. * @param {import('react').RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element.
  2685. * @param {string|Function} text The text to copy.
  2686. * @param {number} [timeout] Optional timeout to reset the returned
  2687. * state. 4 seconds by default.
  2688. *
  2689. * @return {boolean} Whether or not the text has been copied. Resets after the
  2690. * timeout.
  2691. */
  2692. function useCopyOnClick(ref, text) {
  2693. let timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 4000;
  2694. /* eslint-enable jsdoc/no-undefined-types */
  2695. external_wp_deprecated_default()('wp.compose.useCopyOnClick', {
  2696. since: '5.8',
  2697. alternative: 'wp.compose.useCopyToClipboard'
  2698. });
  2699. /** @type {import('react').MutableRefObject<Clipboard | undefined>} */
  2700. const clipboard = (0,external_wp_element_namespaceObject.useRef)();
  2701. const [hasCopied, setHasCopied] = (0,external_wp_element_namespaceObject.useState)(false);
  2702. (0,external_wp_element_namespaceObject.useEffect)(() => {
  2703. /** @type {number | undefined} */
  2704. let timeoutId;
  2705. if (!ref.current) {
  2706. return;
  2707. } // Clipboard listens to click events.
  2708. clipboard.current = new (clipboard_default())(ref.current, {
  2709. text: () => typeof text === 'function' ? text() : text
  2710. });
  2711. clipboard.current.on('success', _ref => {
  2712. let {
  2713. clearSelection,
  2714. trigger
  2715. } = _ref;
  2716. // Clearing selection will move focus back to the triggering button,
  2717. // ensuring that it is not reset to the body, and further that it is
  2718. // kept within the rendered node.
  2719. clearSelection(); // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
  2720. if (trigger) {
  2721. /** @type {HTMLElement} */
  2722. trigger.focus();
  2723. }
  2724. if (timeout) {
  2725. setHasCopied(true);
  2726. clearTimeout(timeoutId);
  2727. timeoutId = setTimeout(() => setHasCopied(false), timeout);
  2728. }
  2729. });
  2730. return () => {
  2731. if (clipboard.current) {
  2732. clipboard.current.destroy();
  2733. }
  2734. clearTimeout(timeoutId);
  2735. };
  2736. }, [text, timeout, setHasCopied]);
  2737. return hasCopied;
  2738. }
  2739. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-to-clipboard/index.js
  2740. /**
  2741. * External dependencies
  2742. */
  2743. /**
  2744. * WordPress dependencies
  2745. */
  2746. /**
  2747. * Internal dependencies
  2748. */
  2749. /**
  2750. * @template T
  2751. * @param {T} value
  2752. * @return {import('react').RefObject<T>} The updated ref
  2753. */
  2754. function useUpdatedRef(value) {
  2755. const ref = (0,external_wp_element_namespaceObject.useRef)(value);
  2756. ref.current = value;
  2757. return ref;
  2758. }
  2759. /**
  2760. * Copies the given text to the clipboard when the element is clicked.
  2761. *
  2762. * @template {HTMLElement} TElementType
  2763. * @param {string | (() => string)} text The text to copy. Use a function if not
  2764. * already available and expensive to compute.
  2765. * @param {Function} onSuccess Called when to text is copied.
  2766. *
  2767. * @return {import('react').Ref<TElementType>} A ref to assign to the target element.
  2768. */
  2769. function useCopyToClipboard(text, onSuccess) {
  2770. // Store the dependencies as refs and continuously update them so they're
  2771. // fresh when the callback is called.
  2772. const textRef = useUpdatedRef(text);
  2773. const onSuccessRef = useUpdatedRef(onSuccess);
  2774. return useRefEffect(node => {
  2775. // Clipboard listens to click events.
  2776. const clipboard = new (clipboard_default())(node, {
  2777. text() {
  2778. return typeof textRef.current === 'function' ? textRef.current() : textRef.current || '';
  2779. }
  2780. });
  2781. clipboard.on('success', _ref => {
  2782. let {
  2783. clearSelection
  2784. } = _ref;
  2785. // Clearing selection will move focus back to the triggering
  2786. // button, ensuring that it is not reset to the body, and
  2787. // further that it is kept within the rendered node.
  2788. clearSelection(); // Handle ClipboardJS focus bug, see
  2789. // https://github.com/zenorocha/clipboard.js/issues/680
  2790. node.focus();
  2791. if (onSuccessRef.current) {
  2792. onSuccessRef.current();
  2793. }
  2794. });
  2795. return () => {
  2796. clipboard.destroy();
  2797. };
  2798. }, []);
  2799. }
  2800. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-on-mount/index.js
  2801. /**
  2802. * WordPress dependencies
  2803. */
  2804. /**
  2805. * Hook used to focus the first tabbable element on mount.
  2806. *
  2807. * @param {boolean | 'firstElement'} focusOnMount Focus on mount mode.
  2808. * @return {import('react').RefCallback<HTMLElement>} Ref callback.
  2809. *
  2810. * @example
  2811. * ```js
  2812. * import { useFocusOnMount } from '@wordpress/compose';
  2813. *
  2814. * const WithFocusOnMount = () => {
  2815. * const ref = useFocusOnMount()
  2816. * return (
  2817. * <div ref={ ref }>
  2818. * <Button />
  2819. * <Button />
  2820. * </div>
  2821. * );
  2822. * }
  2823. * ```
  2824. */
  2825. function useFocusOnMount() {
  2826. let focusOnMount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'firstElement';
  2827. const focusOnMountRef = (0,external_wp_element_namespaceObject.useRef)(focusOnMount);
  2828. (0,external_wp_element_namespaceObject.useEffect)(() => {
  2829. focusOnMountRef.current = focusOnMount;
  2830. }, [focusOnMount]);
  2831. return (0,external_wp_element_namespaceObject.useCallback)(node => {
  2832. var _node$ownerDocument$a, _node$ownerDocument;
  2833. if (!node || focusOnMountRef.current === false) {
  2834. return;
  2835. }
  2836. if (node.contains((_node$ownerDocument$a = (_node$ownerDocument = node.ownerDocument) === null || _node$ownerDocument === void 0 ? void 0 : _node$ownerDocument.activeElement) !== null && _node$ownerDocument$a !== void 0 ? _node$ownerDocument$a : null)) {
  2837. return;
  2838. }
  2839. let target = node;
  2840. if (focusOnMountRef.current === 'firstElement') {
  2841. const firstTabbable = external_wp_dom_namespaceObject.focus.tabbable.find(node)[0];
  2842. if (firstTabbable) {
  2843. target =
  2844. /** @type {HTMLElement} */
  2845. firstTabbable;
  2846. }
  2847. }
  2848. target.focus({
  2849. // When focusing newly mounted dialogs,
  2850. // the position of the popover is often not right on the first render
  2851. // This prevents the layout shifts when focusing the dialogs.
  2852. preventScroll: true
  2853. });
  2854. }, []);
  2855. }
  2856. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-return/index.js
  2857. /**
  2858. * WordPress dependencies
  2859. */
  2860. /**
  2861. * When opening modals/sidebars/dialogs, the focus
  2862. * must move to the opened area and return to the
  2863. * previously focused element when closed.
  2864. * The current hook implements the returning behavior.
  2865. *
  2866. * @param {() => void} [onFocusReturn] Overrides the default return behavior.
  2867. * @return {import('react').RefCallback<HTMLElement>} Element Ref.
  2868. *
  2869. * @example
  2870. * ```js
  2871. * import { useFocusReturn } from '@wordpress/compose';
  2872. *
  2873. * const WithFocusReturn = () => {
  2874. * const ref = useFocusReturn()
  2875. * return (
  2876. * <div ref={ ref }>
  2877. * <Button />
  2878. * <Button />
  2879. * </div>
  2880. * );
  2881. * }
  2882. * ```
  2883. */
  2884. function useFocusReturn(onFocusReturn) {
  2885. /** @type {import('react').MutableRefObject<null | HTMLElement>} */
  2886. const ref = (0,external_wp_element_namespaceObject.useRef)(null);
  2887. /** @type {import('react').MutableRefObject<null | Element>} */
  2888. const focusedBeforeMount = (0,external_wp_element_namespaceObject.useRef)(null);
  2889. const onFocusReturnRef = (0,external_wp_element_namespaceObject.useRef)(onFocusReturn);
  2890. (0,external_wp_element_namespaceObject.useEffect)(() => {
  2891. onFocusReturnRef.current = onFocusReturn;
  2892. }, [onFocusReturn]);
  2893. return (0,external_wp_element_namespaceObject.useCallback)(node => {
  2894. if (node) {
  2895. // Set ref to be used when unmounting.
  2896. ref.current = node; // Only set when the node mounts.
  2897. if (focusedBeforeMount.current) {
  2898. return;
  2899. }
  2900. focusedBeforeMount.current = node.ownerDocument.activeElement;
  2901. } else if (focusedBeforeMount.current) {
  2902. var _ref$current, _ref$current2, _ref$current3;
  2903. const isFocused = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.contains((_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.ownerDocument.activeElement);
  2904. if ((_ref$current3 = ref.current) !== null && _ref$current3 !== void 0 && _ref$current3.isConnected && !isFocused) {
  2905. return;
  2906. } // Defer to the component's own explicit focus return behavior, if
  2907. // specified. This allows for support that the `onFocusReturn`
  2908. // decides to allow the default behavior to occur under some
  2909. // conditions.
  2910. if (onFocusReturnRef.current) {
  2911. onFocusReturnRef.current();
  2912. } else {
  2913. var _focusedBeforeMount$c;
  2914. /** @type {null | HTMLElement} */
  2915. (_focusedBeforeMount$c = focusedBeforeMount.current) === null || _focusedBeforeMount$c === void 0 ? void 0 : _focusedBeforeMount$c.focus();
  2916. }
  2917. }
  2918. }, []);
  2919. }
  2920. /* harmony default export */ var use_focus_return = (useFocusReturn);
  2921. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js
  2922. /**
  2923. * External dependencies
  2924. */
  2925. /**
  2926. * WordPress dependencies
  2927. */
  2928. /**
  2929. * Input types which are classified as button types, for use in considering
  2930. * whether element is a (focus-normalized) button.
  2931. *
  2932. * @type {string[]}
  2933. */
  2934. const INPUT_BUTTON_TYPES = ['button', 'submit'];
  2935. /**
  2936. * @typedef {HTMLButtonElement | HTMLLinkElement | HTMLInputElement} FocusNormalizedButton
  2937. */
  2938. // Disable reason: Rule doesn't support predicate return types.
  2939. /* eslint-disable jsdoc/valid-types */
  2940. /**
  2941. * Returns true if the given element is a button element subject to focus
  2942. * normalization, or false otherwise.
  2943. *
  2944. * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  2945. *
  2946. * @param {EventTarget} eventTarget The target from a mouse or touch event.
  2947. *
  2948. * @return {eventTarget is FocusNormalizedButton} Whether element is a button.
  2949. */
  2950. function isFocusNormalizedButton(eventTarget) {
  2951. if (!(eventTarget instanceof window.HTMLElement)) {
  2952. return false;
  2953. }
  2954. switch (eventTarget.nodeName) {
  2955. case 'A':
  2956. case 'BUTTON':
  2957. return true;
  2958. case 'INPUT':
  2959. return (0,external_lodash_namespaceObject.includes)(INPUT_BUTTON_TYPES,
  2960. /** @type {HTMLInputElement} */
  2961. eventTarget.type);
  2962. }
  2963. return false;
  2964. }
  2965. /* eslint-enable jsdoc/valid-types */
  2966. /**
  2967. * @typedef {import('react').SyntheticEvent} SyntheticEvent
  2968. */
  2969. /**
  2970. * @callback EventCallback
  2971. * @param {SyntheticEvent} event input related event.
  2972. */
  2973. /**
  2974. * @typedef FocusOutsideReactElement
  2975. * @property {EventCallback} handleFocusOutside callback for a focus outside event.
  2976. */
  2977. /**
  2978. * @typedef {import('react').MutableRefObject<FocusOutsideReactElement | undefined>} FocusOutsideRef
  2979. */
  2980. /**
  2981. * @typedef {Object} FocusOutsideReturnValue
  2982. * @property {EventCallback} onFocus An event handler for focus events.
  2983. * @property {EventCallback} onBlur An event handler for blur events.
  2984. * @property {EventCallback} onMouseDown An event handler for mouse down events.
  2985. * @property {EventCallback} onMouseUp An event handler for mouse up events.
  2986. * @property {EventCallback} onTouchStart An event handler for touch start events.
  2987. * @property {EventCallback} onTouchEnd An event handler for touch end events.
  2988. */
  2989. /**
  2990. * A react hook that can be used to check whether focus has moved outside the
  2991. * element the event handlers are bound to.
  2992. *
  2993. * @param {EventCallback} onFocusOutside A callback triggered when focus moves outside
  2994. * the element the event handlers are bound to.
  2995. *
  2996. * @return {FocusOutsideReturnValue} An object containing event handlers. Bind the event handlers
  2997. * to a wrapping element element to capture when focus moves
  2998. * outside that element.
  2999. */
  3000. function useFocusOutside(onFocusOutside) {
  3001. const currentOnFocusOutside = (0,external_wp_element_namespaceObject.useRef)(onFocusOutside);
  3002. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3003. currentOnFocusOutside.current = onFocusOutside;
  3004. }, [onFocusOutside]);
  3005. const preventBlurCheck = (0,external_wp_element_namespaceObject.useRef)(false);
  3006. /**
  3007. * @type {import('react').MutableRefObject<number | undefined>}
  3008. */
  3009. const blurCheckTimeoutId = (0,external_wp_element_namespaceObject.useRef)();
  3010. /**
  3011. * Cancel a blur check timeout.
  3012. */
  3013. const cancelBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(() => {
  3014. clearTimeout(blurCheckTimeoutId.current);
  3015. }, []); // Cancel blur checks on unmount.
  3016. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3017. return () => cancelBlurCheck();
  3018. }, []); // Cancel a blur check if the callback or ref is no longer provided.
  3019. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3020. if (!onFocusOutside) {
  3021. cancelBlurCheck();
  3022. }
  3023. }, [onFocusOutside, cancelBlurCheck]);
  3024. /**
  3025. * Handles a mousedown or mouseup event to respectively assign and
  3026. * unassign a flag for preventing blur check on button elements. Some
  3027. * browsers, namely Firefox and Safari, do not emit a focus event on
  3028. * button elements when clicked, while others do. The logic here
  3029. * intends to normalize this as treating click on buttons as focus.
  3030. *
  3031. * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  3032. *
  3033. * @param {SyntheticEvent} event Event for mousedown or mouseup.
  3034. */
  3035. const normalizeButtonFocus = (0,external_wp_element_namespaceObject.useCallback)(event => {
  3036. const {
  3037. type,
  3038. target
  3039. } = event;
  3040. const isInteractionEnd = (0,external_lodash_namespaceObject.includes)(['mouseup', 'touchend'], type);
  3041. if (isInteractionEnd) {
  3042. preventBlurCheck.current = false;
  3043. } else if (isFocusNormalizedButton(target)) {
  3044. preventBlurCheck.current = true;
  3045. }
  3046. }, []);
  3047. /**
  3048. * A callback triggered when a blur event occurs on the element the handler
  3049. * is bound to.
  3050. *
  3051. * Calls the `onFocusOutside` callback in an immediate timeout if focus has
  3052. * move outside the bound element and is still within the document.
  3053. *
  3054. * @param {SyntheticEvent} event Blur event.
  3055. */
  3056. const queueBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(event => {
  3057. // React does not allow using an event reference asynchronously
  3058. // due to recycling behavior, except when explicitly persisted.
  3059. event.persist(); // Skip blur check if clicking button. See `normalizeButtonFocus`.
  3060. if (preventBlurCheck.current) {
  3061. return;
  3062. }
  3063. blurCheckTimeoutId.current = setTimeout(() => {
  3064. // If document is not focused then focus should remain
  3065. // inside the wrapped component and therefore we cancel
  3066. // this blur event thereby leaving focus in place.
  3067. // https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus.
  3068. if (!document.hasFocus()) {
  3069. event.preventDefault();
  3070. return;
  3071. }
  3072. if ('function' === typeof currentOnFocusOutside.current) {
  3073. currentOnFocusOutside.current(event);
  3074. }
  3075. }, 0);
  3076. }, []);
  3077. return {
  3078. onFocus: cancelBlurCheck,
  3079. onMouseDown: normalizeButtonFocus,
  3080. onMouseUp: normalizeButtonFocus,
  3081. onTouchStart: normalizeButtonFocus,
  3082. onTouchEnd: normalizeButtonFocus,
  3083. onBlur: queueBlurCheck
  3084. };
  3085. }
  3086. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-merge-refs/index.js
  3087. /**
  3088. * WordPress dependencies
  3089. */
  3090. /* eslint-disable jsdoc/valid-types */
  3091. /**
  3092. * @template T
  3093. * @typedef {T extends import('react').Ref<infer R> ? R : never} TypeFromRef
  3094. */
  3095. /* eslint-enable jsdoc/valid-types */
  3096. /**
  3097. * @template T
  3098. * @param {import('react').Ref<T>} ref
  3099. * @param {T} value
  3100. */
  3101. function assignRef(ref, value) {
  3102. if (typeof ref === 'function') {
  3103. ref(value);
  3104. } else if (ref && ref.hasOwnProperty('current')) {
  3105. /* eslint-disable jsdoc/no-undefined-types */
  3106. /** @type {import('react').MutableRefObject<T>} */
  3107. ref.current = value;
  3108. /* eslint-enable jsdoc/no-undefined-types */
  3109. }
  3110. }
  3111. /**
  3112. * Merges refs into one ref callback.
  3113. *
  3114. * It also ensures that the merged ref callbacks are only called when they
  3115. * change (as a result of a `useCallback` dependency update) OR when the ref
  3116. * value changes, just as React does when passing a single ref callback to the
  3117. * component.
  3118. *
  3119. * As expected, if you pass a new function on every render, the ref callback
  3120. * will be called after every render.
  3121. *
  3122. * If you don't wish a ref callback to be called after every render, wrap it
  3123. * with `useCallback( callback, dependencies )`. When a dependency changes, the
  3124. * old ref callback will be called with `null` and the new ref callback will be
  3125. * called with the same value.
  3126. *
  3127. * To make ref callbacks easier to use, you can also pass the result of
  3128. * `useRefEffect`, which makes cleanup easier by allowing you to return a
  3129. * cleanup function instead of handling `null`.
  3130. *
  3131. * It's also possible to _disable_ a ref (and its behaviour) by simply not
  3132. * passing the ref.
  3133. *
  3134. * ```jsx
  3135. * const ref = useRefEffect( ( node ) => {
  3136. * node.addEventListener( ... );
  3137. * return () => {
  3138. * node.removeEventListener( ... );
  3139. * };
  3140. * }, [ ...dependencies ] );
  3141. * const otherRef = useRef();
  3142. * const mergedRefs useMergeRefs( [
  3143. * enabled && ref,
  3144. * otherRef,
  3145. * ] );
  3146. * return <div ref={ mergedRefs } />;
  3147. * ```
  3148. *
  3149. * @template {import('react').Ref<any>} TRef
  3150. * @param {Array<TRef>} refs The refs to be merged.
  3151. *
  3152. * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback.
  3153. */
  3154. function useMergeRefs(refs) {
  3155. const element = (0,external_wp_element_namespaceObject.useRef)();
  3156. const didElementChange = (0,external_wp_element_namespaceObject.useRef)(false);
  3157. /* eslint-disable jsdoc/no-undefined-types */
  3158. /** @type {import('react').MutableRefObject<TRef[]>} */
  3159. /* eslint-enable jsdoc/no-undefined-types */
  3160. const previousRefs = (0,external_wp_element_namespaceObject.useRef)([]);
  3161. const currentRefs = (0,external_wp_element_namespaceObject.useRef)(refs); // Update on render before the ref callback is called, so the ref callback
  3162. // always has access to the current refs.
  3163. currentRefs.current = refs; // If any of the refs change, call the previous ref with `null` and the new
  3164. // ref with the node, except when the element changes in the same cycle, in
  3165. // which case the ref callbacks will already have been called.
  3166. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  3167. if (didElementChange.current === false) {
  3168. refs.forEach((ref, index) => {
  3169. const previousRef = previousRefs.current[index];
  3170. if (ref !== previousRef) {
  3171. assignRef(previousRef, null);
  3172. assignRef(ref, element.current);
  3173. }
  3174. });
  3175. }
  3176. previousRefs.current = refs;
  3177. }, refs); // No dependencies, must be reset after every render so ref callbacks are
  3178. // correctly called after a ref change.
  3179. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  3180. didElementChange.current = false;
  3181. }); // There should be no dependencies so that `callback` is only called when
  3182. // the node changes.
  3183. return (0,external_wp_element_namespaceObject.useCallback)(value => {
  3184. // Update the element so it can be used when calling ref callbacks on a
  3185. // dependency change.
  3186. assignRef(element, value);
  3187. didElementChange.current = true; // When an element changes, the current ref callback should be called
  3188. // with the new element and the previous one with `null`.
  3189. const refsToAssign = value ? currentRefs.current : previousRefs.current; // Update the latest refs.
  3190. for (const ref of refsToAssign) {
  3191. assignRef(ref, value);
  3192. }
  3193. }, []);
  3194. }
  3195. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js
  3196. /**
  3197. * External dependencies
  3198. */
  3199. /**
  3200. * WordPress dependencies
  3201. */
  3202. /**
  3203. * Internal dependencies
  3204. */
  3205. /**
  3206. * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors:
  3207. * - constrained tabbing.
  3208. * - focus on mount.
  3209. * - return focus on unmount.
  3210. * - focus outside.
  3211. *
  3212. * @param options Dialog Options.
  3213. */
  3214. function useDialog(options) {
  3215. const currentOptions = (0,external_wp_element_namespaceObject.useRef)();
  3216. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3217. currentOptions.current = options;
  3218. }, Object.values(options));
  3219. const constrainedTabbingRef = use_constrained_tabbing();
  3220. const focusOnMountRef = useFocusOnMount(options.focusOnMount);
  3221. const focusReturnRef = use_focus_return();
  3222. const focusOutsideProps = useFocusOutside(event => {
  3223. var _currentOptions$curre, _currentOptions$curre2;
  3224. // This unstable prop is here only to manage backward compatibility
  3225. // for the Popover component otherwise, the onClose should be enough.
  3226. if ((_currentOptions$curre = currentOptions.current) !== null && _currentOptions$curre !== void 0 && _currentOptions$curre.__unstableOnClose) {
  3227. currentOptions.current.__unstableOnClose('focus-outside', event);
  3228. } else if ((_currentOptions$curre2 = currentOptions.current) !== null && _currentOptions$curre2 !== void 0 && _currentOptions$curre2.onClose) {
  3229. currentOptions.current.onClose();
  3230. }
  3231. });
  3232. const closeOnEscapeRef = (0,external_wp_element_namespaceObject.useCallback)(node => {
  3233. if (!node) {
  3234. return;
  3235. }
  3236. node.addEventListener('keydown', event => {
  3237. var _currentOptions$curre3;
  3238. // Close on escape.
  3239. if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented && (_currentOptions$curre3 = currentOptions.current) !== null && _currentOptions$curre3 !== void 0 && _currentOptions$curre3.onClose) {
  3240. event.preventDefault();
  3241. currentOptions.current.onClose();
  3242. }
  3243. });
  3244. }, []);
  3245. return [useMergeRefs([options.focusOnMount !== false ? constrainedTabbingRef : null, options.focusOnMount !== false ? focusReturnRef : null, options.focusOnMount !== false ? focusOnMountRef : null, closeOnEscapeRef]), { ...focusOutsideProps,
  3246. tabIndex: -1
  3247. }];
  3248. }
  3249. /* harmony default export */ var use_dialog = (useDialog);
  3250. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-disabled/index.js
  3251. /**
  3252. * External dependencies
  3253. */
  3254. /**
  3255. * WordPress dependencies
  3256. */
  3257. /**
  3258. * Internal dependencies
  3259. */
  3260. /**
  3261. * Names of control nodes which qualify for disabled behavior.
  3262. *
  3263. * See WHATWG HTML Standard: 4.10.18.5: "Enabling and disabling form controls: the disabled attribute".
  3264. *
  3265. * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute
  3266. *
  3267. * @type {string[]}
  3268. */
  3269. const DISABLED_ELIGIBLE_NODE_NAMES = ['BUTTON', 'FIELDSET', 'INPUT', 'OPTGROUP', 'OPTION', 'SELECT', 'TEXTAREA'];
  3270. /**
  3271. * In some circumstances, such as block previews, all focusable DOM elements
  3272. * (input fields, links, buttons, etc.) need to be disabled. This hook adds the
  3273. * behavior to disable nested DOM elements to the returned ref.
  3274. *
  3275. * @param {Object} config Configuration object.
  3276. * @param {boolean=} config.isDisabled Whether the element should be disabled.
  3277. * @return {import('react').RefCallback<HTMLElement>} Element Ref.
  3278. *
  3279. * @example
  3280. * ```js
  3281. * import { useDisabled } from '@wordpress/compose';
  3282. * const DisabledExample = () => {
  3283. * const disabledRef = useDisabled();
  3284. * return (
  3285. * <div ref={ disabledRef }>
  3286. * <a href="#">This link will have tabindex set to -1</a>
  3287. * <input placeholder="This input will have the disabled attribute added to it." type="text" />
  3288. * </div>
  3289. * );
  3290. * };
  3291. * ```
  3292. */
  3293. function useDisabled() {
  3294. let {
  3295. isDisabled: isDisabledProp = false
  3296. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3297. return useRefEffect(node => {
  3298. if (isDisabledProp) {
  3299. return;
  3300. }
  3301. /** A variable keeping track of the previous updates in order to restore them. */
  3302. /** @type {Function[]} */
  3303. const updates = [];
  3304. const disable = () => {
  3305. if (node.style.getPropertyValue('user-select') !== 'none') {
  3306. const previousValue = node.style.getPropertyValue('user-select');
  3307. node.style.setProperty('user-select', 'none');
  3308. node.style.setProperty('-webkit-user-select', 'none');
  3309. updates.push(() => {
  3310. if (!node.isConnected) {
  3311. return;
  3312. }
  3313. node.style.setProperty('user-select', previousValue);
  3314. node.style.setProperty('-webkit-user-select', previousValue);
  3315. });
  3316. }
  3317. external_wp_dom_namespaceObject.focus.focusable.find(node).forEach(focusable => {
  3318. var _node$ownerDocument$d;
  3319. if ((0,external_lodash_namespaceObject.includes)(DISABLED_ELIGIBLE_NODE_NAMES, focusable.nodeName) && // @ts-ignore
  3320. !focusable.disabled) {
  3321. focusable.setAttribute('disabled', '');
  3322. updates.push(() => {
  3323. if (!focusable.isConnected) {
  3324. return;
  3325. } // @ts-ignore
  3326. focusable.disabled = false;
  3327. });
  3328. }
  3329. if (focusable.nodeName === 'A' && focusable.getAttribute('tabindex') !== '-1') {
  3330. const previousValue = focusable.getAttribute('tabindex');
  3331. focusable.setAttribute('tabindex', '-1');
  3332. updates.push(() => {
  3333. if (!focusable.isConnected) {
  3334. return;
  3335. }
  3336. if (!previousValue) {
  3337. focusable.removeAttribute('tabindex');
  3338. } else {
  3339. focusable.setAttribute('tabindex', previousValue);
  3340. }
  3341. });
  3342. }
  3343. const tabIndex = focusable.getAttribute('tabindex');
  3344. if (tabIndex !== null && tabIndex !== '-1') {
  3345. focusable.removeAttribute('tabindex');
  3346. updates.push(() => {
  3347. if (!focusable.isConnected) {
  3348. return;
  3349. }
  3350. focusable.setAttribute('tabindex', tabIndex);
  3351. });
  3352. }
  3353. if (focusable.hasAttribute('contenteditable') && focusable.getAttribute('contenteditable') !== 'false') {
  3354. focusable.setAttribute('contenteditable', 'false');
  3355. updates.push(() => {
  3356. if (!focusable.isConnected) {
  3357. return;
  3358. }
  3359. focusable.setAttribute('contenteditable', 'true');
  3360. });
  3361. }
  3362. if ((_node$ownerDocument$d = node.ownerDocument.defaultView) !== null && _node$ownerDocument$d !== void 0 && _node$ownerDocument$d.HTMLElement && focusable instanceof node.ownerDocument.defaultView.HTMLElement) {
  3363. const previousValue = focusable.style.getPropertyValue('pointer-events');
  3364. focusable.style.setProperty('pointer-events', 'none');
  3365. updates.push(() => {
  3366. if (!focusable.isConnected) {
  3367. return;
  3368. }
  3369. focusable.style.setProperty('pointer-events', previousValue);
  3370. });
  3371. }
  3372. });
  3373. }; // Debounce re-disable since disabling process itself will incur
  3374. // additional mutations which should be ignored.
  3375. const debouncedDisable = (0,external_lodash_namespaceObject.debounce)(disable, undefined, {
  3376. leading: true
  3377. });
  3378. disable();
  3379. /** @type {MutationObserver | undefined} */
  3380. const observer = new window.MutationObserver(debouncedDisable);
  3381. observer.observe(node, {
  3382. childList: true,
  3383. attributes: true,
  3384. subtree: true
  3385. });
  3386. return () => {
  3387. if (observer) {
  3388. observer.disconnect();
  3389. }
  3390. debouncedDisable.cancel();
  3391. updates.forEach(update => update());
  3392. };
  3393. }, [isDisabledProp]);
  3394. }
  3395. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-isomorphic-layout-effect/index.js
  3396. /**
  3397. * WordPress dependencies
  3398. */
  3399. /**
  3400. * Preferred over direct usage of `useLayoutEffect` when supporting
  3401. * server rendered components (SSR) because currently React
  3402. * throws a warning when using useLayoutEffect in that environment.
  3403. */
  3404. const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external_wp_element_namespaceObject.useLayoutEffect : external_wp_element_namespaceObject.useEffect;
  3405. /* harmony default export */ var use_isomorphic_layout_effect = (useIsomorphicLayoutEffect);
  3406. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dragging/index.js
  3407. /**
  3408. * WordPress dependencies
  3409. */
  3410. /**
  3411. * Internal dependencies
  3412. */
  3413. // Event handlers that are triggered from `document` listeners accept a MouseEvent,
  3414. // while those triggered from React listeners accept a React.MouseEvent.
  3415. /**
  3416. * @param {Object} props
  3417. * @param {(e: import('react').MouseEvent) => void} props.onDragStart
  3418. * @param {(e: MouseEvent) => void} props.onDragMove
  3419. * @param {(e?: MouseEvent) => void} props.onDragEnd
  3420. */
  3421. function useDragging(_ref) {
  3422. let {
  3423. onDragStart,
  3424. onDragMove,
  3425. onDragEnd
  3426. } = _ref;
  3427. const [isDragging, setIsDragging] = (0,external_wp_element_namespaceObject.useState)(false);
  3428. const eventsRef = (0,external_wp_element_namespaceObject.useRef)({
  3429. onDragStart,
  3430. onDragMove,
  3431. onDragEnd
  3432. });
  3433. use_isomorphic_layout_effect(() => {
  3434. eventsRef.current.onDragStart = onDragStart;
  3435. eventsRef.current.onDragMove = onDragMove;
  3436. eventsRef.current.onDragEnd = onDragEnd;
  3437. }, [onDragStart, onDragMove, onDragEnd]);
  3438. /** @type {(e: MouseEvent) => void} */
  3439. const onMouseMove = (0,external_wp_element_namespaceObject.useCallback)(event => eventsRef.current.onDragMove && eventsRef.current.onDragMove(event), []);
  3440. /** @type {(e?: MouseEvent) => void} */
  3441. const endDrag = (0,external_wp_element_namespaceObject.useCallback)(event => {
  3442. if (eventsRef.current.onDragEnd) {
  3443. eventsRef.current.onDragEnd(event);
  3444. }
  3445. document.removeEventListener('mousemove', onMouseMove);
  3446. document.removeEventListener('mouseup', endDrag);
  3447. setIsDragging(false);
  3448. }, []);
  3449. /** @type {(e: import('react').MouseEvent) => void} */
  3450. const startDrag = (0,external_wp_element_namespaceObject.useCallback)(event => {
  3451. if (eventsRef.current.onDragStart) {
  3452. eventsRef.current.onDragStart(event);
  3453. }
  3454. document.addEventListener('mousemove', onMouseMove);
  3455. document.addEventListener('mouseup', endDrag);
  3456. setIsDragging(true);
  3457. }, []); // Remove the global events when unmounting if needed.
  3458. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3459. return () => {
  3460. if (isDragging) {
  3461. document.removeEventListener('mousemove', onMouseMove);
  3462. document.removeEventListener('mouseup', endDrag);
  3463. }
  3464. };
  3465. }, [isDragging]);
  3466. return {
  3467. startDrag,
  3468. endDrag,
  3469. isDragging
  3470. };
  3471. }
  3472. // EXTERNAL MODULE: ./node_modules/mousetrap/mousetrap.js
  3473. var mousetrap_mousetrap = __webpack_require__(7973);
  3474. var mousetrap_default = /*#__PURE__*/__webpack_require__.n(mousetrap_mousetrap);
  3475. // EXTERNAL MODULE: ./node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js
  3476. var mousetrap_global_bind = __webpack_require__(5538);
  3477. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-keyboard-shortcut/index.js
  3478. /**
  3479. * External dependencies
  3480. */
  3481. /**
  3482. * WordPress dependencies
  3483. */
  3484. /**
  3485. * A block selection object.
  3486. *
  3487. * @typedef {Object} WPKeyboardShortcutConfig
  3488. *
  3489. * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields.
  3490. * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown.
  3491. * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true.
  3492. * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event.
  3493. */
  3494. /* eslint-disable jsdoc/valid-types */
  3495. /**
  3496. * Attach a keyboard shortcut handler.
  3497. *
  3498. * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter.
  3499. *
  3500. * @param {string[]|string} shortcuts Keyboard Shortcuts.
  3501. * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback.
  3502. * @param {WPKeyboardShortcutConfig} options Shortcut options.
  3503. */
  3504. function useKeyboardShortcut(
  3505. /* eslint-enable jsdoc/valid-types */
  3506. shortcuts, callback) {
  3507. let {
  3508. bindGlobal = false,
  3509. eventName = 'keydown',
  3510. isDisabled = false,
  3511. // This is important for performance considerations.
  3512. target
  3513. } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  3514. const currentCallback = (0,external_wp_element_namespaceObject.useRef)(callback);
  3515. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3516. currentCallback.current = callback;
  3517. }, [callback]);
  3518. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3519. if (isDisabled) {
  3520. return;
  3521. }
  3522. const mousetrap = new (mousetrap_default())(target && target.current ? target.current : // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.
  3523. // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's
  3524. // necessary to maintain the existing behavior.
  3525. /** @type {Element} */
  3526. /** @type {unknown} */
  3527. document);
  3528. (0,external_lodash_namespaceObject.castArray)(shortcuts).forEach(shortcut => {
  3529. const keys = shortcut.split('+'); // Determines whether a key is a modifier by the length of the string.
  3530. // E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that
  3531. // the modifiers are Shift and Cmd because they're not a single character.
  3532. const modifiers = new Set(keys.filter(value => value.length > 1));
  3533. const hasAlt = modifiers.has('alt');
  3534. const hasShift = modifiers.has('shift'); // This should be better moved to the shortcut registration instead.
  3535. if ((0,external_wp_keycodes_namespaceObject.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) {
  3536. throw new Error(`Cannot bind ${shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`);
  3537. }
  3538. const bindFn = bindGlobal ? 'bindGlobal' : 'bind'; // @ts-ignore `bindGlobal` is an undocumented property
  3539. mousetrap[bindFn](shortcut, function () {
  3540. return (
  3541. /* eslint-enable jsdoc/valid-types */
  3542. currentCallback.current(...arguments)
  3543. );
  3544. }, eventName);
  3545. });
  3546. return () => {
  3547. mousetrap.reset();
  3548. };
  3549. }, [shortcuts, bindGlobal, eventName, target, isDisabled]);
  3550. }
  3551. /* harmony default export */ var use_keyboard_shortcut = (useKeyboardShortcut);
  3552. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js
  3553. /**
  3554. * WordPress dependencies
  3555. */
  3556. /**
  3557. * Runs a media query and returns its value when it changes.
  3558. *
  3559. * @param {string} [query] Media Query.
  3560. * @return {boolean} return value of the media query.
  3561. */
  3562. function useMediaQuery(query) {
  3563. const [match, setMatch] = (0,external_wp_element_namespaceObject.useState)(() => !!(query && typeof window !== 'undefined' && window.matchMedia(query).matches));
  3564. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3565. if (!query) {
  3566. return;
  3567. }
  3568. const updateMatch = () => setMatch(window.matchMedia(query).matches);
  3569. updateMatch();
  3570. const list = window.matchMedia(query);
  3571. list.addListener(updateMatch);
  3572. return () => {
  3573. list.removeListener(updateMatch);
  3574. };
  3575. }, [query]);
  3576. return !!query && match;
  3577. }
  3578. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js
  3579. /**
  3580. * WordPress dependencies
  3581. */
  3582. /**
  3583. * Use something's value from the previous render.
  3584. * Based on https://usehooks.com/usePrevious/.
  3585. *
  3586. * @param value The value to track.
  3587. *
  3588. * @return The value from the previous render.
  3589. */
  3590. function usePrevious(value) {
  3591. const ref = (0,external_wp_element_namespaceObject.useRef)(); // Store current value in ref.
  3592. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3593. ref.current = value;
  3594. }, [value]); // Re-run when value changes.
  3595. // Return previous value (happens before update in useEffect above).
  3596. return ref.current;
  3597. }
  3598. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js
  3599. /**
  3600. * Internal dependencies
  3601. */
  3602. /**
  3603. * Hook returning whether the user has a preference for reduced motion.
  3604. *
  3605. * @return {boolean} Reduced motion preference value.
  3606. */
  3607. const useReducedMotion = () => useMediaQuery('(prefers-reduced-motion: reduce)');
  3608. /* harmony default export */ var use_reduced_motion = (useReducedMotion);
  3609. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js
  3610. /**
  3611. * WordPress dependencies
  3612. */
  3613. /**
  3614. * Internal dependencies
  3615. */
  3616. /**
  3617. * @typedef {"huge" | "wide" | "large" | "medium" | "small" | "mobile"} WPBreakpoint
  3618. */
  3619. /**
  3620. * Hash of breakpoint names with pixel width at which it becomes effective.
  3621. *
  3622. * @see _breakpoints.scss
  3623. *
  3624. * @type {Record<WPBreakpoint, number>}
  3625. */
  3626. const BREAKPOINTS = {
  3627. huge: 1440,
  3628. wide: 1280,
  3629. large: 960,
  3630. medium: 782,
  3631. small: 600,
  3632. mobile: 480
  3633. };
  3634. /**
  3635. * @typedef {">=" | "<"} WPViewportOperator
  3636. */
  3637. /**
  3638. * Object mapping media query operators to the condition to be used.
  3639. *
  3640. * @type {Record<WPViewportOperator, string>}
  3641. */
  3642. const CONDITIONS = {
  3643. '>=': 'min-width',
  3644. '<': 'max-width'
  3645. };
  3646. /**
  3647. * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values.
  3648. *
  3649. * @type {Record<WPViewportOperator, (breakpointValue: number, width: number) => boolean>}
  3650. */
  3651. const OPERATOR_EVALUATORS = {
  3652. '>=': (breakpointValue, width) => width >= breakpointValue,
  3653. '<': (breakpointValue, width) => width < breakpointValue
  3654. };
  3655. const ViewportMatchWidthContext = (0,external_wp_element_namespaceObject.createContext)(
  3656. /** @type {null | number} */
  3657. null);
  3658. /**
  3659. * Returns true if the viewport matches the given query, or false otherwise.
  3660. *
  3661. * @param {WPBreakpoint} breakpoint Breakpoint size name.
  3662. * @param {WPViewportOperator} [operator=">="] Viewport operator.
  3663. *
  3664. * @example
  3665. *
  3666. * ```js
  3667. * useViewportMatch( 'huge', '<' );
  3668. * useViewportMatch( 'medium' );
  3669. * ```
  3670. *
  3671. * @return {boolean} Whether viewport matches query.
  3672. */
  3673. const useViewportMatch = function (breakpoint) {
  3674. let operator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '>=';
  3675. const simulatedWidth = (0,external_wp_element_namespaceObject.useContext)(ViewportMatchWidthContext);
  3676. const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`;
  3677. const mediaQueryResult = useMediaQuery(mediaQuery || undefined);
  3678. if (simulatedWidth) {
  3679. return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth);
  3680. }
  3681. return mediaQueryResult;
  3682. };
  3683. useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider;
  3684. /* harmony default export */ var use_viewport_match = (useViewportMatch);
  3685. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js
  3686. /**
  3687. * External dependencies
  3688. */
  3689. /**
  3690. * WordPress dependencies
  3691. */
  3692. // This of course could've been more streamlined with internal state instead of
  3693. // refs, but then host hooks / components could not opt out of renders.
  3694. // This could've been exported to its own module, but the current build doesn't
  3695. // seem to work with module imports and I had no more time to spend on this...
  3696. function useResolvedElement(subscriber, refOrElement) {
  3697. const callbackRefElement = (0,external_wp_element_namespaceObject.useRef)(null);
  3698. const lastReportRef = (0,external_wp_element_namespaceObject.useRef)(null);
  3699. const cleanupRef = (0,external_wp_element_namespaceObject.useRef)();
  3700. const callSubscriber = (0,external_wp_element_namespaceObject.useCallback)(() => {
  3701. let element = null;
  3702. if (callbackRefElement.current) {
  3703. element = callbackRefElement.current;
  3704. } else if (refOrElement) {
  3705. if (refOrElement instanceof HTMLElement) {
  3706. element = refOrElement;
  3707. } else {
  3708. element = refOrElement.current;
  3709. }
  3710. }
  3711. if (lastReportRef.current && lastReportRef.current.element === element && lastReportRef.current.reporter === callSubscriber) {
  3712. return;
  3713. }
  3714. if (cleanupRef.current) {
  3715. cleanupRef.current(); // Making sure the cleanup is not called accidentally multiple times.
  3716. cleanupRef.current = null;
  3717. }
  3718. lastReportRef.current = {
  3719. reporter: callSubscriber,
  3720. element
  3721. }; // Only calling the subscriber, if there's an actual element to report.
  3722. if (element) {
  3723. cleanupRef.current = subscriber(element);
  3724. }
  3725. }, [refOrElement, subscriber]); // On each render, we check whether a ref changed, or if we got a new raw
  3726. // element.
  3727. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3728. // With this we're *technically* supporting cases where ref objects' current value changes, but only if there's a
  3729. // render accompanying that change as well.
  3730. // To guarantee we always have the right element, one must use the ref callback provided instead, but we support
  3731. // RefObjects to make the hook API more convenient in certain cases.
  3732. callSubscriber();
  3733. }, [callSubscriber]);
  3734. return (0,external_wp_element_namespaceObject.useCallback)(element => {
  3735. callbackRefElement.current = element;
  3736. callSubscriber();
  3737. }, [callSubscriber]);
  3738. }
  3739. // We're only using the first element of the size sequences, until future versions of the spec solidify on how
  3740. // exactly it'll be used for fragments in multi-column scenarios:
  3741. // From the spec:
  3742. // > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments,
  3743. // > which occur in multi-column scenarios. However the current definitions of content rect and border box do not
  3744. // > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single
  3745. // > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column.
  3746. // > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information.
  3747. // (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface)
  3748. //
  3749. // Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback,
  3750. // regardless of the "box" option.
  3751. // The spec states the following on this:
  3752. // > This does not have any impact on which box dimensions are returned to the defined callback when the event
  3753. // > is fired, it solely defines which box the author wishes to observe layout changes on.
  3754. // (https://drafts.csswg.org/resize-observer/#resize-observer-interface)
  3755. // I'm not exactly clear on what this means, especially when you consider a later section stating the following:
  3756. // > This section is non-normative. An author may desire to observe more than one CSS box.
  3757. // > In this case, author will need to use multiple ResizeObservers.
  3758. // (https://drafts.csswg.org/resize-observer/#resize-observer-interface)
  3759. // Which is clearly not how current browser implementations behave, and seems to contradict the previous quote.
  3760. // For this reason I decided to only return the requested size,
  3761. // even though it seems we have access to results for all box types.
  3762. // This also means that we get to keep the current api, being able to return a simple { width, height } pair,
  3763. // regardless of box option.
  3764. const extractSize = (entry, boxProp, sizeType) => {
  3765. if (!entry[boxProp]) {
  3766. if (boxProp === 'contentBoxSize') {
  3767. // The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec.
  3768. // See the 6th step in the description for the RO algorithm:
  3769. // https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h
  3770. // > Set this.contentRect to logical this.contentBoxSize given target and observedBox of "content-box".
  3771. // In real browser implementations of course these objects differ, but the width/height values should be equivalent.
  3772. return entry.contentRect[sizeType === 'inlineSize' ? 'width' : 'height'];
  3773. }
  3774. return undefined;
  3775. } // A couple bytes smaller than calling Array.isArray() and just as effective here.
  3776. return entry[boxProp][0] ? entry[boxProp][0][sizeType] : // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current
  3777. // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.
  3778. // @ts-ignore
  3779. entry[boxProp][sizeType];
  3780. };
  3781. function useResizeObserver() {
  3782. let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3783. // Saving the callback as a ref. With this, I don't need to put onResize in the
  3784. // effect dep array, and just passing in an anonymous function without memoising
  3785. // will not reinstantiate the hook's ResizeObserver.
  3786. const onResize = opts.onResize;
  3787. const onResizeRef = (0,external_wp_element_namespaceObject.useRef)(undefined);
  3788. onResizeRef.current = onResize;
  3789. const round = opts.round || Math.round; // Using a single instance throughout the hook's lifetime
  3790. const resizeObserverRef = (0,external_wp_element_namespaceObject.useRef)();
  3791. const [size, setSize] = (0,external_wp_element_namespaceObject.useState)({
  3792. width: undefined,
  3793. height: undefined
  3794. }); // In certain edge cases the RO might want to report a size change just after
  3795. // the component unmounted.
  3796. const didUnmount = (0,external_wp_element_namespaceObject.useRef)(false);
  3797. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3798. return () => {
  3799. didUnmount.current = true;
  3800. };
  3801. }, []); // Using a ref to track the previous width / height to avoid unnecessary renders.
  3802. const previous = (0,external_wp_element_namespaceObject.useRef)({
  3803. width: undefined,
  3804. height: undefined
  3805. }); // This block is kinda like a useEffect, only it's called whenever a new
  3806. // element could be resolved based on the ref option. It also has a cleanup
  3807. // function.
  3808. const refCallback = useResolvedElement((0,external_wp_element_namespaceObject.useCallback)(element => {
  3809. // We only use a single Resize Observer instance, and we're instantiating it on demand, only once there's something to observe.
  3810. // This instance is also recreated when the `box` option changes, so that a new observation is fired if there was a previously observed element with a different box option.
  3811. if (!resizeObserverRef.current || resizeObserverRef.current.box !== opts.box || resizeObserverRef.current.round !== round) {
  3812. resizeObserverRef.current = {
  3813. box: opts.box,
  3814. round,
  3815. instance: new ResizeObserver(entries => {
  3816. const entry = entries[0];
  3817. let boxProp = 'borderBoxSize';
  3818. if (opts.box === 'border-box') {
  3819. boxProp = 'borderBoxSize';
  3820. } else {
  3821. boxProp = opts.box === 'device-pixel-content-box' ? 'devicePixelContentBoxSize' : 'contentBoxSize';
  3822. }
  3823. const reportedWidth = extractSize(entry, boxProp, 'inlineSize');
  3824. const reportedHeight = extractSize(entry, boxProp, 'blockSize');
  3825. const newWidth = reportedWidth ? round(reportedWidth) : undefined;
  3826. const newHeight = reportedHeight ? round(reportedHeight) : undefined;
  3827. if (previous.current.width !== newWidth || previous.current.height !== newHeight) {
  3828. const newSize = {
  3829. width: newWidth,
  3830. height: newHeight
  3831. };
  3832. previous.current.width = newWidth;
  3833. previous.current.height = newHeight;
  3834. if (onResizeRef.current) {
  3835. onResizeRef.current(newSize);
  3836. } else if (!didUnmount.current) {
  3837. setSize(newSize);
  3838. }
  3839. }
  3840. })
  3841. };
  3842. }
  3843. resizeObserverRef.current.instance.observe(element, {
  3844. box: opts.box
  3845. });
  3846. return () => {
  3847. if (resizeObserverRef.current) {
  3848. resizeObserverRef.current.instance.unobserve(element);
  3849. }
  3850. };
  3851. }, [opts.box, round]), opts.ref);
  3852. return (0,external_wp_element_namespaceObject.useMemo)(() => ({
  3853. ref: refCallback,
  3854. width: size.width,
  3855. height: size.height
  3856. }), [refCallback, size ? size.width : null, size ? size.height : null]);
  3857. }
  3858. /**
  3859. * Hook which allows to listen the resize event of any target element when it changes sizes.
  3860. * _Note: `useResizeObserver` will report `null` until after first render.
  3861. *
  3862. * @example
  3863. *
  3864. * ```js
  3865. * const App = () => {
  3866. * const [ resizeListener, sizes ] = useResizeObserver();
  3867. *
  3868. * return (
  3869. * <div>
  3870. * { resizeListener }
  3871. * Your content here
  3872. * </div>
  3873. * );
  3874. * };
  3875. * ```
  3876. */
  3877. function useResizeAware() {
  3878. const {
  3879. ref,
  3880. width,
  3881. height
  3882. } = useResizeObserver();
  3883. const sizes = (0,external_wp_element_namespaceObject.useMemo)(() => {
  3884. return {
  3885. width: width !== null && width !== void 0 ? width : null,
  3886. height: height !== null && height !== void 0 ? height : null
  3887. };
  3888. }, [width, height]);
  3889. const resizeListener = (0,external_wp_element_namespaceObject.createElement)("div", {
  3890. style: {
  3891. position: 'absolute',
  3892. top: 0,
  3893. left: 0,
  3894. right: 0,
  3895. bottom: 0,
  3896. pointerEvents: 'none',
  3897. opacity: 0,
  3898. overflow: 'hidden',
  3899. zIndex: -1
  3900. },
  3901. "aria-hidden": "true",
  3902. ref: ref
  3903. });
  3904. return [resizeListener, sizes];
  3905. }
  3906. ;// CONCATENATED MODULE: external ["wp","priorityQueue"]
  3907. var external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"];
  3908. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-async-list/index.js
  3909. /**
  3910. * WordPress dependencies
  3911. */
  3912. /**
  3913. * Returns the first items from list that are present on state.
  3914. *
  3915. * @param list New array.
  3916. * @param state Current state.
  3917. * @return First items present iin state.
  3918. */
  3919. function getFirstItemsPresentInState(list, state) {
  3920. const firstItems = [];
  3921. for (let i = 0; i < list.length; i++) {
  3922. const item = list[i];
  3923. if (!state.includes(item)) {
  3924. break;
  3925. }
  3926. firstItems.push(item);
  3927. }
  3928. return firstItems;
  3929. }
  3930. /**
  3931. * React hook returns an array which items get asynchronously appended from a source array.
  3932. * This behavior is useful if we want to render a list of items asynchronously for performance reasons.
  3933. *
  3934. * @param list Source array.
  3935. * @param config Configuration object.
  3936. *
  3937. * @return Async array.
  3938. */
  3939. function useAsyncList(list) {
  3940. let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  3941. step: 1
  3942. };
  3943. const {
  3944. step = 1
  3945. } = config;
  3946. const [current, setCurrent] = (0,external_wp_element_namespaceObject.useState)([]);
  3947. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3948. // On reset, we keep the first items that were previously rendered.
  3949. let firstItems = getFirstItemsPresentInState(list, current);
  3950. if (firstItems.length < step) {
  3951. firstItems = firstItems.concat(list.slice(firstItems.length, step));
  3952. }
  3953. setCurrent(firstItems);
  3954. let nextIndex = firstItems.length;
  3955. const asyncQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)();
  3956. const append = () => {
  3957. if (list.length <= nextIndex) {
  3958. return;
  3959. }
  3960. setCurrent(state => [...state, ...list.slice(nextIndex, nextIndex + step)]);
  3961. nextIndex += step;
  3962. asyncQueue.add({}, append);
  3963. };
  3964. asyncQueue.add({}, append);
  3965. return () => asyncQueue.reset();
  3966. }, [list]);
  3967. return current;
  3968. }
  3969. /* harmony default export */ var use_async_list = (useAsyncList);
  3970. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-warn-on-change/index.js
  3971. /**
  3972. * Internal dependencies
  3973. */
  3974. // Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case
  3975. // but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript
  3976. /* eslint-disable jsdoc/check-types */
  3977. /**
  3978. * Hook that performs a shallow comparison between the preview value of an object
  3979. * and the new one, if there's a difference, it prints it to the console.
  3980. * this is useful in performance related work, to check why a component re-renders.
  3981. *
  3982. * @example
  3983. *
  3984. * ```jsx
  3985. * function MyComponent(props) {
  3986. * useWarnOnChange(props);
  3987. *
  3988. * return "Something";
  3989. * }
  3990. * ```
  3991. *
  3992. * @param {object} object Object which changes to compare.
  3993. * @param {string} prefix Just a prefix to show when console logging.
  3994. */
  3995. function useWarnOnChange(object) {
  3996. let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Change detection';
  3997. const previousValues = usePrevious(object);
  3998. Object.entries(previousValues !== null && previousValues !== void 0 ? previousValues : []).forEach(_ref => {
  3999. let [key, value] = _ref;
  4000. if (value !== object[
  4001. /** @type {keyof typeof object} */
  4002. key]) {
  4003. // eslint-disable-next-line no-console
  4004. console.warn(`${prefix}: ${key} key changed:`, value, object[
  4005. /** @type {keyof typeof object} */
  4006. key]
  4007. /* eslint-enable jsdoc/check-types */
  4008. );
  4009. }
  4010. });
  4011. }
  4012. /* harmony default export */ var use_warn_on_change = (useWarnOnChange);
  4013. ;// CONCATENATED MODULE: external "React"
  4014. var external_React_namespaceObject = window["React"];
  4015. ;// CONCATENATED MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js
  4016. function areInputsEqual(newInputs, lastInputs) {
  4017. if (newInputs.length !== lastInputs.length) {
  4018. return false;
  4019. }
  4020. for (var i = 0; i < newInputs.length; i++) {
  4021. if (newInputs[i] !== lastInputs[i]) {
  4022. return false;
  4023. }
  4024. }
  4025. return true;
  4026. }
  4027. function useMemoOne(getResult, inputs) {
  4028. var initial = (0,external_React_namespaceObject.useState)(function () {
  4029. return {
  4030. inputs: inputs,
  4031. result: getResult()
  4032. };
  4033. })[0];
  4034. var isFirstRun = (0,external_React_namespaceObject.useRef)(true);
  4035. var committed = (0,external_React_namespaceObject.useRef)(initial);
  4036. var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));
  4037. var cache = useCache ? committed.current : {
  4038. inputs: inputs,
  4039. result: getResult()
  4040. };
  4041. (0,external_React_namespaceObject.useEffect)(function () {
  4042. isFirstRun.current = false;
  4043. committed.current = cache;
  4044. }, [cache]);
  4045. return cache.result;
  4046. }
  4047. function useCallbackOne(callback, inputs) {
  4048. return useMemoOne(function () {
  4049. return callback;
  4050. }, inputs);
  4051. }
  4052. var useMemo = (/* unused pure expression or super */ null && (useMemoOne));
  4053. var useCallback = (/* unused pure expression or super */ null && (useCallbackOne));
  4054. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-debounce/index.js
  4055. /**
  4056. * External dependencies
  4057. */
  4058. /**
  4059. * WordPress dependencies
  4060. */
  4061. /* eslint-disable jsdoc/valid-types */
  4062. /**
  4063. * Debounces a function with Lodash's `debounce`. A new debounced function will
  4064. * be returned and any scheduled calls cancelled if any of the arguments change,
  4065. * including the function to debounce, so please wrap functions created on
  4066. * render in components in `useCallback`.
  4067. *
  4068. * @see https://docs-lodash.com/v4/debounce/
  4069. *
  4070. * @template {(...args: any[]) => void} TFunc
  4071. *
  4072. * @param {TFunc} fn The function to debounce.
  4073. * @param {number} [wait] The number of milliseconds to delay.
  4074. * @param {import('lodash').DebounceSettings} [options] The options object.
  4075. * @return {import('lodash').DebouncedFunc<TFunc>} Debounced function.
  4076. */
  4077. function useDebounce(fn, wait, options) {
  4078. /* eslint-enable jsdoc/valid-types */
  4079. const debounced = useMemoOne(() => (0,external_lodash_namespaceObject.debounce)(fn, wait, options), [fn, wait, options]);
  4080. (0,external_wp_element_namespaceObject.useEffect)(() => () => debounced.cancel(), [debounced]);
  4081. return debounced;
  4082. }
  4083. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-throttle/index.js
  4084. /**
  4085. * External dependencies
  4086. */
  4087. /**
  4088. * WordPress dependencies
  4089. */
  4090. /**
  4091. * Throttles a function with Lodash's `throttle`. A new throttled function will
  4092. * be returned and any scheduled calls cancelled if any of the arguments change,
  4093. * including the function to throttle, so please wrap functions created on
  4094. * render in components in `useCallback`.
  4095. *
  4096. * @see https://docs-lodash.com/v4/throttle/
  4097. *
  4098. * @template {(...args: any[]) => void} TFunc
  4099. *
  4100. * @param {TFunc} fn The function to throttle.
  4101. * @param {number} [wait] The number of milliseconds to throttle invocations to.
  4102. * @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.
  4103. * @return {import('lodash').DebouncedFunc<TFunc>} Throttled function.
  4104. */
  4105. function useThrottle(fn, wait, options) {
  4106. const throttled = useMemoOne(() => (0,external_lodash_namespaceObject.throttle)(fn, wait, options), [fn, wait, options]);
  4107. (0,external_wp_element_namespaceObject.useEffect)(() => () => throttled.cancel(), [throttled]);
  4108. return throttled;
  4109. }
  4110. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-drop-zone/index.js
  4111. /**
  4112. * WordPress dependencies
  4113. */
  4114. /**
  4115. * Internal dependencies
  4116. */
  4117. /* eslint-disable jsdoc/valid-types */
  4118. /**
  4119. * @template T
  4120. * @param {T} value
  4121. * @return {import('react').MutableRefObject<T|null>} A ref with the value.
  4122. */
  4123. function useFreshRef(value) {
  4124. /* eslint-enable jsdoc/valid-types */
  4125. /* eslint-disable jsdoc/no-undefined-types */
  4126. /** @type {import('react').MutableRefObject<T>} */
  4127. /* eslint-enable jsdoc/no-undefined-types */
  4128. // Disable reason: We're doing something pretty JavaScript-y here where the
  4129. // ref will always have a current value that is not null or undefined but it
  4130. // needs to start as undefined. We don't want to change the return type so
  4131. // it's easier to just ts-ignore this specific line that's complaining about
  4132. // undefined not being part of T.
  4133. // @ts-ignore
  4134. const ref = (0,external_wp_element_namespaceObject.useRef)();
  4135. ref.current = value;
  4136. return ref;
  4137. }
  4138. /**
  4139. * A hook to facilitate drag and drop handling.
  4140. *
  4141. * @param {Object} props Named parameters.
  4142. * @param {boolean} [props.isDisabled] Whether or not to disable the drop zone.
  4143. * @param {(e: DragEvent) => void} [props.onDragStart] Called when dragging has started.
  4144. * @param {(e: DragEvent) => void} [props.onDragEnter] Called when the zone is entered.
  4145. * @param {(e: DragEvent) => void} [props.onDragOver] Called when the zone is moved within.
  4146. * @param {(e: DragEvent) => void} [props.onDragLeave] Called when the zone is left.
  4147. * @param {(e: MouseEvent) => void} [props.onDragEnd] Called when dragging has ended.
  4148. * @param {(e: DragEvent) => void} [props.onDrop] Called when dropping in the zone.
  4149. *
  4150. * @return {import('react').RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element.
  4151. */
  4152. function useDropZone(_ref) {
  4153. let {
  4154. isDisabled,
  4155. onDrop: _onDrop,
  4156. onDragStart: _onDragStart,
  4157. onDragEnter: _onDragEnter,
  4158. onDragLeave: _onDragLeave,
  4159. onDragEnd: _onDragEnd,
  4160. onDragOver: _onDragOver
  4161. } = _ref;
  4162. const onDropRef = useFreshRef(_onDrop);
  4163. const onDragStartRef = useFreshRef(_onDragStart);
  4164. const onDragEnterRef = useFreshRef(_onDragEnter);
  4165. const onDragLeaveRef = useFreshRef(_onDragLeave);
  4166. const onDragEndRef = useFreshRef(_onDragEnd);
  4167. const onDragOverRef = useFreshRef(_onDragOver);
  4168. return useRefEffect(element => {
  4169. if (isDisabled) {
  4170. return;
  4171. }
  4172. let isDragging = false;
  4173. const {
  4174. ownerDocument
  4175. } = element;
  4176. /**
  4177. * Checks if an element is in the drop zone.
  4178. *
  4179. * @param {EventTarget|null} targetToCheck
  4180. *
  4181. * @return {boolean} True if in drop zone, false if not.
  4182. */
  4183. function isElementInZone(targetToCheck) {
  4184. const {
  4185. defaultView
  4186. } = ownerDocument;
  4187. if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) {
  4188. return false;
  4189. }
  4190. /** @type {HTMLElement|null} */
  4191. let elementToCheck = targetToCheck;
  4192. do {
  4193. if (elementToCheck.dataset.isDropZone) {
  4194. return elementToCheck === element;
  4195. }
  4196. } while (elementToCheck = elementToCheck.parentElement);
  4197. return false;
  4198. }
  4199. function maybeDragStart(
  4200. /** @type {DragEvent} */
  4201. event) {
  4202. if (isDragging) {
  4203. return;
  4204. }
  4205. isDragging = true;
  4206. ownerDocument.removeEventListener('dragenter', maybeDragStart); // Note that `dragend` doesn't fire consistently for file and
  4207. // HTML drag events where the drag origin is outside the browser
  4208. // window. In Firefox it may also not fire if the originating
  4209. // node is removed.
  4210. ownerDocument.addEventListener('dragend', maybeDragEnd);
  4211. ownerDocument.addEventListener('mousemove', maybeDragEnd);
  4212. if (onDragStartRef.current) {
  4213. onDragStartRef.current(event);
  4214. }
  4215. }
  4216. function onDragEnter(
  4217. /** @type {DragEvent} */
  4218. event) {
  4219. event.preventDefault(); // The `dragenter` event will also fire when entering child
  4220. // elements, but we only want to call `onDragEnter` when
  4221. // entering the drop zone, which means the `relatedTarget`
  4222. // (element that has been left) should be outside the drop zone.
  4223. if (element.contains(
  4224. /** @type {Node} */
  4225. event.relatedTarget)) {
  4226. return;
  4227. }
  4228. if (onDragEnterRef.current) {
  4229. onDragEnterRef.current(event);
  4230. }
  4231. }
  4232. function onDragOver(
  4233. /** @type {DragEvent} */
  4234. event) {
  4235. // Only call onDragOver for the innermost hovered drop zones.
  4236. if (!event.defaultPrevented && onDragOverRef.current) {
  4237. onDragOverRef.current(event);
  4238. } // Prevent the browser default while also signalling to parent
  4239. // drop zones that `onDragOver` is already handled.
  4240. event.preventDefault();
  4241. }
  4242. function onDragLeave(
  4243. /** @type {DragEvent} */
  4244. event) {
  4245. // The `dragleave` event will also fire when leaving child
  4246. // elements, but we only want to call `onDragLeave` when
  4247. // leaving the drop zone, which means the `relatedTarget`
  4248. // (element that has been entered) should be outside the drop
  4249. // zone.
  4250. if (isElementInZone(event.relatedTarget)) {
  4251. return;
  4252. }
  4253. if (onDragLeaveRef.current) {
  4254. onDragLeaveRef.current(event);
  4255. }
  4256. }
  4257. function onDrop(
  4258. /** @type {DragEvent} */
  4259. event) {
  4260. // Don't handle drop if an inner drop zone already handled it.
  4261. if (event.defaultPrevented) {
  4262. return;
  4263. } // Prevent the browser default while also signalling to parent
  4264. // drop zones that `onDrop` is already handled.
  4265. event.preventDefault(); // This seemingly useless line has been shown to resolve a
  4266. // Safari issue where files dragged directly from the dock are
  4267. // not recognized.
  4268. // eslint-disable-next-line no-unused-expressions
  4269. event.dataTransfer && event.dataTransfer.files.length;
  4270. if (onDropRef.current) {
  4271. onDropRef.current(event);
  4272. }
  4273. maybeDragEnd(event);
  4274. }
  4275. function maybeDragEnd(
  4276. /** @type {MouseEvent} */
  4277. event) {
  4278. if (!isDragging) {
  4279. return;
  4280. }
  4281. isDragging = false;
  4282. ownerDocument.addEventListener('dragenter', maybeDragStart);
  4283. ownerDocument.removeEventListener('dragend', maybeDragEnd);
  4284. ownerDocument.removeEventListener('mousemove', maybeDragEnd);
  4285. if (onDragEndRef.current) {
  4286. onDragEndRef.current(event);
  4287. }
  4288. }
  4289. element.dataset.isDropZone = 'true';
  4290. element.addEventListener('drop', onDrop);
  4291. element.addEventListener('dragenter', onDragEnter);
  4292. element.addEventListener('dragover', onDragOver);
  4293. element.addEventListener('dragleave', onDragLeave); // The `dragstart` event doesn't fire if the drag started outside
  4294. // the document.
  4295. ownerDocument.addEventListener('dragenter', maybeDragStart);
  4296. return () => {
  4297. onDropRef.current = null;
  4298. onDragStartRef.current = null;
  4299. onDragEnterRef.current = null;
  4300. onDragLeaveRef.current = null;
  4301. onDragEndRef.current = null;
  4302. onDragOverRef.current = null;
  4303. delete element.dataset.isDropZone;
  4304. element.removeEventListener('drop', onDrop);
  4305. element.removeEventListener('dragenter', onDragEnter);
  4306. element.removeEventListener('dragover', onDragOver);
  4307. element.removeEventListener('dragleave', onDragLeave);
  4308. ownerDocument.removeEventListener('dragend', maybeDragEnd);
  4309. ownerDocument.removeEventListener('mousemove', maybeDragEnd);
  4310. ownerDocument.addEventListener('dragenter', maybeDragStart);
  4311. };
  4312. }, [isDisabled]);
  4313. }
  4314. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focusable-iframe/index.js
  4315. /**
  4316. * Internal dependencies
  4317. */
  4318. /**
  4319. * Dispatches a bubbling focus event when the iframe receives focus. Use
  4320. * `onFocus` as usual on the iframe or a parent element.
  4321. *
  4322. * @return {Object} Ref to pass to the iframe.
  4323. */
  4324. function useFocusableIframe() {
  4325. return useRefEffect(element => {
  4326. const {
  4327. ownerDocument
  4328. } = element;
  4329. if (!ownerDocument) return;
  4330. const {
  4331. defaultView
  4332. } = ownerDocument;
  4333. if (!defaultView) return;
  4334. /**
  4335. * Checks whether the iframe is the activeElement, inferring that it has
  4336. * then received focus, and dispatches a focus event.
  4337. */
  4338. function checkFocus() {
  4339. if (ownerDocument && ownerDocument.activeElement === element) {
  4340. /** @type {HTMLElement} */
  4341. element.focus();
  4342. }
  4343. }
  4344. defaultView.addEventListener('blur', checkFocus);
  4345. return () => {
  4346. defaultView.removeEventListener('blur', checkFocus);
  4347. };
  4348. }, []);
  4349. }
  4350. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-fixed-window-list/index.js
  4351. /**
  4352. * External dependencies
  4353. */
  4354. /**
  4355. * WordPress dependencies
  4356. */
  4357. const DEFAULT_INIT_WINDOW_SIZE = 30;
  4358. /**
  4359. * @typedef {Object} WPFixedWindowList
  4360. *
  4361. * @property {number} visibleItems Items visible in the current viewport
  4362. * @property {number} start Start index of the window
  4363. * @property {number} end End index of the window
  4364. * @property {(index:number)=>boolean} itemInView Returns true if item is in the window
  4365. */
  4366. /**
  4367. * @typedef {Object} WPFixedWindowListOptions
  4368. *
  4369. * @property {number} [windowOverscan] Renders windowOverscan number of items before and after the calculated visible window.
  4370. * @property {boolean} [useWindowing] When false avoids calculating the window size
  4371. * @property {number} [initWindowSize] Initial window size to use on first render before we can calculate the window size.
  4372. */
  4373. /**
  4374. *
  4375. * @param {import('react').RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element.
  4376. * @param { number } itemHeight Fixed item height in pixels
  4377. * @param { number } totalItems Total items in list
  4378. * @param { WPFixedWindowListOptions } [options] Options object
  4379. * @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter
  4380. */
  4381. function useFixedWindowList(elementRef, itemHeight, totalItems, options) {
  4382. var _options$initWindowSi, _options$useWindowing;
  4383. const initWindowSize = (_options$initWindowSi = options === null || options === void 0 ? void 0 : options.initWindowSize) !== null && _options$initWindowSi !== void 0 ? _options$initWindowSi : DEFAULT_INIT_WINDOW_SIZE;
  4384. const useWindowing = (_options$useWindowing = options === null || options === void 0 ? void 0 : options.useWindowing) !== null && _options$useWindowing !== void 0 ? _options$useWindowing : true;
  4385. const [fixedListWindow, setFixedListWindow] = (0,external_wp_element_namespaceObject.useState)({
  4386. visibleItems: initWindowSize,
  4387. start: 0,
  4388. end: initWindowSize,
  4389. itemInView: (
  4390. /** @type {number} */
  4391. index) => {
  4392. return index >= 0 && index <= initWindowSize;
  4393. }
  4394. });
  4395. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  4396. var _scrollContainer$owne, _scrollContainer$owne2, _scrollContainer$owne3, _scrollContainer$owne4;
  4397. if (!useWindowing) {
  4398. return;
  4399. }
  4400. const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current);
  4401. const measureWindow = (
  4402. /** @type {boolean | undefined} */
  4403. initRender) => {
  4404. var _options$windowOversc;
  4405. if (!scrollContainer) {
  4406. return;
  4407. }
  4408. const visibleItems = Math.ceil(scrollContainer.clientHeight / itemHeight); // Aim to keep opening list view fast, afterward we can optimize for scrolling.
  4409. const windowOverscan = initRender ? visibleItems : (_options$windowOversc = options === null || options === void 0 ? void 0 : options.windowOverscan) !== null && _options$windowOversc !== void 0 ? _options$windowOversc : visibleItems;
  4410. const firstViewableIndex = Math.floor(scrollContainer.scrollTop / itemHeight);
  4411. const start = Math.max(0, firstViewableIndex - windowOverscan);
  4412. const end = Math.min(totalItems - 1, firstViewableIndex + visibleItems + windowOverscan);
  4413. setFixedListWindow(lastWindow => {
  4414. const nextWindow = {
  4415. visibleItems,
  4416. start,
  4417. end,
  4418. itemInView: (
  4419. /** @type {number} */
  4420. index) => {
  4421. return start <= index && index <= end;
  4422. }
  4423. };
  4424. if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) {
  4425. return nextWindow;
  4426. }
  4427. return lastWindow;
  4428. });
  4429. };
  4430. measureWindow(true);
  4431. const debounceMeasureList = (0,external_lodash_namespaceObject.debounce)(() => {
  4432. measureWindow();
  4433. }, 16);
  4434. scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.addEventListener('scroll', debounceMeasureList);
  4435. scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne = scrollContainer.ownerDocument) === null || _scrollContainer$owne === void 0 ? void 0 : (_scrollContainer$owne2 = _scrollContainer$owne.defaultView) === null || _scrollContainer$owne2 === void 0 ? void 0 : _scrollContainer$owne2.addEventListener('resize', debounceMeasureList);
  4436. scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne3 = scrollContainer.ownerDocument) === null || _scrollContainer$owne3 === void 0 ? void 0 : (_scrollContainer$owne4 = _scrollContainer$owne3.defaultView) === null || _scrollContainer$owne4 === void 0 ? void 0 : _scrollContainer$owne4.addEventListener('resize', debounceMeasureList);
  4437. return () => {
  4438. var _scrollContainer$owne5, _scrollContainer$owne6;
  4439. scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.removeEventListener('scroll', debounceMeasureList);
  4440. scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne5 = scrollContainer.ownerDocument) === null || _scrollContainer$owne5 === void 0 ? void 0 : (_scrollContainer$owne6 = _scrollContainer$owne5.defaultView) === null || _scrollContainer$owne6 === void 0 ? void 0 : _scrollContainer$owne6.removeEventListener('resize', debounceMeasureList);
  4441. };
  4442. }, [itemHeight, elementRef, totalItems]);
  4443. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  4444. var _scrollContainer$owne7, _scrollContainer$owne8;
  4445. if (!useWindowing) {
  4446. return;
  4447. }
  4448. const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current);
  4449. const handleKeyDown = (
  4450. /** @type {KeyboardEvent} */
  4451. event) => {
  4452. switch (event.keyCode) {
  4453. case external_wp_keycodes_namespaceObject.HOME:
  4454. {
  4455. return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
  4456. top: 0
  4457. });
  4458. }
  4459. case external_wp_keycodes_namespaceObject.END:
  4460. {
  4461. return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
  4462. top: totalItems * itemHeight
  4463. });
  4464. }
  4465. case external_wp_keycodes_namespaceObject.PAGEUP:
  4466. {
  4467. return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
  4468. top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight
  4469. });
  4470. }
  4471. case external_wp_keycodes_namespaceObject.PAGEDOWN:
  4472. {
  4473. return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
  4474. top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight
  4475. });
  4476. }
  4477. }
  4478. };
  4479. scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne7 = scrollContainer.ownerDocument) === null || _scrollContainer$owne7 === void 0 ? void 0 : (_scrollContainer$owne8 = _scrollContainer$owne7.defaultView) === null || _scrollContainer$owne8 === void 0 ? void 0 : _scrollContainer$owne8.addEventListener('keydown', handleKeyDown);
  4480. return () => {
  4481. var _scrollContainer$owne9, _scrollContainer$owne10;
  4482. scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne9 = scrollContainer.ownerDocument) === null || _scrollContainer$owne9 === void 0 ? void 0 : (_scrollContainer$owne10 = _scrollContainer$owne9.defaultView) === null || _scrollContainer$owne10 === void 0 ? void 0 : _scrollContainer$owne10.removeEventListener('keydown', handleKeyDown);
  4483. };
  4484. }, [totalItems, itemHeight, elementRef, fixedListWindow.visibleItems]);
  4485. return [fixedListWindow, setFixedListWindow];
  4486. }
  4487. ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/index.js
  4488. // The `createHigherOrderComponent` helper and helper types.
  4489. // Compose helper (aliased flowRight from Lodash)
  4490. // Higher-order components.
  4491. // Hooks.
  4492. }();
  4493. (window.wp = window.wp || {}).compose = __webpack_exports__;
  4494. /******/ })()
  4495. ;