No Description

compose.js 131KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316
  1. this["wp"] = this["wp"] || {}; this["wp"]["compose"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = "PD33");
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ "1CF3":
  90. /***/ (function(module, exports) {
  91. (function() { module.exports = window["wp"]["dom"]; }());
  92. /***/ }),
  93. /***/ "GRId":
  94. /***/ (function(module, exports) {
  95. (function() { module.exports = window["wp"]["element"]; }());
  96. /***/ }),
  97. /***/ "NMb1":
  98. /***/ (function(module, exports) {
  99. (function() { module.exports = window["wp"]["deprecated"]; }());
  100. /***/ }),
  101. /***/ "PD33":
  102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103. "use strict";
  104. // ESM COMPAT FLAG
  105. __webpack_require__.r(__webpack_exports__);
  106. // EXPORTS
  107. __webpack_require__.d(__webpack_exports__, "createHigherOrderComponent", function() { return /* reexport */ create_higher_order_component; });
  108. __webpack_require__.d(__webpack_exports__, "compose", function() { return /* reexport */ compose; });
  109. __webpack_require__.d(__webpack_exports__, "ifCondition", function() { return /* reexport */ if_condition; });
  110. __webpack_require__.d(__webpack_exports__, "pure", function() { return /* reexport */ higher_order_pure; });
  111. __webpack_require__.d(__webpack_exports__, "withGlobalEvents", function() { return /* reexport */ withGlobalEvents; });
  112. __webpack_require__.d(__webpack_exports__, "withInstanceId", function() { return /* reexport */ with_instance_id; });
  113. __webpack_require__.d(__webpack_exports__, "withSafeTimeout", function() { return /* reexport */ with_safe_timeout; });
  114. __webpack_require__.d(__webpack_exports__, "withState", function() { return /* reexport */ withState; });
  115. __webpack_require__.d(__webpack_exports__, "useConstrainedTabbing", function() { return /* reexport */ use_constrained_tabbing; });
  116. __webpack_require__.d(__webpack_exports__, "useCopyOnClick", function() { return /* reexport */ useCopyOnClick; });
  117. __webpack_require__.d(__webpack_exports__, "useCopyToClipboard", function() { return /* reexport */ useCopyToClipboard; });
  118. __webpack_require__.d(__webpack_exports__, "__experimentalUseDialog", function() { return /* reexport */ use_dialog; });
  119. __webpack_require__.d(__webpack_exports__, "__experimentalUseDragging", function() { return /* reexport */ useDragging; });
  120. __webpack_require__.d(__webpack_exports__, "useFocusOnMount", function() { return /* reexport */ useFocusOnMount; });
  121. __webpack_require__.d(__webpack_exports__, "__experimentalUseFocusOutside", function() { return /* reexport */ useFocusOutside; });
  122. __webpack_require__.d(__webpack_exports__, "useFocusReturn", function() { return /* reexport */ use_focus_return; });
  123. __webpack_require__.d(__webpack_exports__, "useInstanceId", function() { return /* reexport */ useInstanceId; });
  124. __webpack_require__.d(__webpack_exports__, "useIsomorphicLayoutEffect", function() { return /* reexport */ use_isomorphic_layout_effect; });
  125. __webpack_require__.d(__webpack_exports__, "useKeyboardShortcut", function() { return /* reexport */ use_keyboard_shortcut; });
  126. __webpack_require__.d(__webpack_exports__, "useMediaQuery", function() { return /* reexport */ useMediaQuery; });
  127. __webpack_require__.d(__webpack_exports__, "usePrevious", function() { return /* reexport */ usePrevious; });
  128. __webpack_require__.d(__webpack_exports__, "useReducedMotion", function() { return /* reexport */ use_reduced_motion; });
  129. __webpack_require__.d(__webpack_exports__, "useViewportMatch", function() { return /* reexport */ use_viewport_match; });
  130. __webpack_require__.d(__webpack_exports__, "useResizeObserver", function() { return /* reexport */ use_resize_observer; });
  131. __webpack_require__.d(__webpack_exports__, "useAsyncList", function() { return /* reexport */ use_async_list; });
  132. __webpack_require__.d(__webpack_exports__, "useWarnOnChange", function() { return /* reexport */ use_warn_on_change; });
  133. __webpack_require__.d(__webpack_exports__, "useDebounce", function() { return /* reexport */ useDebounce; });
  134. __webpack_require__.d(__webpack_exports__, "useThrottle", function() { return /* reexport */ useThrottle; });
  135. __webpack_require__.d(__webpack_exports__, "useMergeRefs", function() { return /* reexport */ useMergeRefs; });
  136. __webpack_require__.d(__webpack_exports__, "useRefEffect", function() { return /* reexport */ useRefEffect; });
  137. __webpack_require__.d(__webpack_exports__, "__experimentalUseDropZone", function() { return /* reexport */ useDropZone; });
  138. // EXTERNAL MODULE: external "lodash"
  139. var external_lodash_ = __webpack_require__("YLtl");
  140. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js
  141. /**
  142. * External dependencies
  143. */
  144. // eslint-disable-next-line no-restricted-imports
  145. /**
  146. * Given a function mapping a component to an enhanced component and modifier
  147. * name, returns the enhanced component augmented with a generated displayName.
  148. *
  149. * @param mapComponentToEnhancedComponent Function mapping component to enhanced component.
  150. * @param modifierName Seed name from which to generated display name.
  151. *
  152. * @return Component class with generated display name assigned.
  153. */
  154. function createHigherOrderComponent(mapComponent, modifierName) {
  155. return Inner => {
  156. const Outer = mapComponent(Inner);
  157. const displayName = Inner.displayName || Inner.name || 'Component';
  158. Outer.displayName = `${Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(modifierName))}(${displayName})`;
  159. return Outer;
  160. };
  161. }
  162. /* harmony default export */ var create_higher_order_component = (createHigherOrderComponent);
  163. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/compose.js
  164. /**
  165. * External dependencies
  166. */
  167. /**
  168. * Composes multiple higher-order components into a single higher-order component. Performs right-to-left function
  169. * composition, where each successive invocation is supplied the return value of the previous.
  170. *
  171. * @param {...Function} hocs The HOC functions to invoke.
  172. *
  173. * @return {Function} Returns the new composite function.
  174. */
  175. /* harmony default export */ var compose = (external_lodash_["flowRight"]);
  176. // EXTERNAL MODULE: external ["wp","element"]
  177. var external_wp_element_ = __webpack_require__("GRId");
  178. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js
  179. /**
  180. * Internal dependencies
  181. */
  182. // eslint-disable-next-line no-duplicate-imports
  183. /**
  184. * Higher-order component creator, creating a new component which renders if
  185. * the given condition is satisfied or with the given optional prop name.
  186. *
  187. * @example
  188. * ```ts
  189. * type Props = { foo: string };
  190. * const Component = ( props: Props ) => <div>{ props.foo }</div>;
  191. * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component );
  192. * <ConditionalComponent foo="" />; // => null
  193. * <ConditionalComponent foo="bar" />; // => <div>bar</div>;
  194. * ```
  195. *
  196. * @param predicate Function to test condition.
  197. *
  198. * @return Higher-order component.
  199. */
  200. const ifCondition = predicate => create_higher_order_component(WrappedComponent => props => {
  201. if (!predicate(props)) {
  202. return null;
  203. }
  204. return Object(external_wp_element_["createElement"])(WrappedComponent, props);
  205. }, 'ifCondition');
  206. /* harmony default export */ var if_condition = (ifCondition);
  207. // EXTERNAL MODULE: external ["wp","isShallowEqual"]
  208. var external_wp_isShallowEqual_ = __webpack_require__("rl8x");
  209. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_);
  210. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pure/index.js
  211. /**
  212. * WordPress dependencies
  213. */
  214. /**
  215. * Internal dependencies
  216. */
  217. // eslint-disable-next-line no-duplicate-imports
  218. /**
  219. * Given a component returns the enhanced component augmented with a component
  220. * only rerendering when its props/state change
  221. */
  222. const pure = create_higher_order_component(Wrapped => {
  223. if (Wrapped.prototype instanceof external_wp_element_["Component"]) {
  224. return class extends Wrapped {
  225. shouldComponentUpdate(nextProps, nextState) {
  226. return !external_wp_isShallowEqual_default()(nextProps, this.props) || !external_wp_isShallowEqual_default()(nextState, this.state);
  227. }
  228. };
  229. }
  230. return class extends external_wp_element_["Component"] {
  231. shouldComponentUpdate(nextProps) {
  232. return !external_wp_isShallowEqual_default()(nextProps, this.props);
  233. }
  234. render() {
  235. return Object(external_wp_element_["createElement"])(Wrapped, this.props);
  236. }
  237. };
  238. }, 'pure');
  239. /* harmony default export */ var higher_order_pure = (pure);
  240. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  241. var esm_extends = __webpack_require__("wx14");
  242. // EXTERNAL MODULE: external ["wp","deprecated"]
  243. var external_wp_deprecated_ = __webpack_require__("NMb1");
  244. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_);
  245. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/listener.js
  246. /**
  247. * External dependencies
  248. */
  249. /**
  250. * Class responsible for orchestrating event handling on the global window,
  251. * binding a single event to be shared across all handling instances, and
  252. * removing the handler when no instances are listening for the event.
  253. */
  254. class listener_Listener {
  255. constructor() {
  256. this.listeners = {};
  257. this.handleEvent = this.handleEvent.bind(this);
  258. }
  259. add(eventType, instance) {
  260. if (!this.listeners[eventType]) {
  261. // Adding first listener for this type, so bind event.
  262. window.addEventListener(eventType, this.handleEvent);
  263. this.listeners[eventType] = [];
  264. }
  265. this.listeners[eventType].push(instance);
  266. }
  267. remove(eventType, instance) {
  268. this.listeners[eventType] = Object(external_lodash_["without"])(this.listeners[eventType], instance);
  269. if (!this.listeners[eventType].length) {
  270. // Removing last listener for this type, so unbind event.
  271. window.removeEventListener(eventType, this.handleEvent);
  272. delete this.listeners[eventType];
  273. }
  274. }
  275. handleEvent(event) {
  276. Object(external_lodash_["forEach"])(this.listeners[event.type], instance => {
  277. instance.handleEvent(event);
  278. });
  279. }
  280. }
  281. /* harmony default export */ var listener = (listener_Listener);
  282. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/index.js
  283. /**
  284. * External dependencies
  285. */
  286. /**
  287. * WordPress dependencies
  288. */
  289. /**
  290. * Internal dependencies
  291. */
  292. /**
  293. * Listener instance responsible for managing document event handling.
  294. *
  295. * @type {Listener}
  296. */
  297. const with_global_events_listener = new listener();
  298. /**
  299. * Higher-order component creator which, given an object of DOM event types and
  300. * values corresponding to a callback function name on the component, will
  301. * create or update a window event handler to invoke the callback when an event
  302. * occurs. On behalf of the consuming developer, the higher-order component
  303. * manages unbinding when the component unmounts, and binding at most a single
  304. * event handler for the entire application.
  305. *
  306. * @deprecated
  307. *
  308. * @param {Object<string,string>} eventTypesToHandlers Object with keys of DOM
  309. * event type, the value a
  310. * name of the function on
  311. * the original component's
  312. * instance which handles
  313. * the event.
  314. *
  315. * @return {Function} Higher-order component.
  316. */
  317. function withGlobalEvents(eventTypesToHandlers) {
  318. external_wp_deprecated_default()('wp.compose.withGlobalEvents', {
  319. since: '5.7',
  320. alternative: 'useEffect'
  321. });
  322. return create_higher_order_component(WrappedComponent => {
  323. class Wrapper extends external_wp_element_["Component"] {
  324. constructor() {
  325. super(...arguments);
  326. this.handleEvent = this.handleEvent.bind(this);
  327. this.handleRef = this.handleRef.bind(this);
  328. }
  329. componentDidMount() {
  330. Object(external_lodash_["forEach"])(eventTypesToHandlers, (handler, eventType) => {
  331. with_global_events_listener.add(eventType, this);
  332. });
  333. }
  334. componentWillUnmount() {
  335. Object(external_lodash_["forEach"])(eventTypesToHandlers, (handler, eventType) => {
  336. with_global_events_listener.remove(eventType, this);
  337. });
  338. }
  339. handleEvent(event) {
  340. const handler = eventTypesToHandlers[event.type];
  341. if (typeof this.wrappedRef[handler] === 'function') {
  342. this.wrappedRef[handler](event);
  343. }
  344. }
  345. handleRef(el) {
  346. this.wrappedRef = el; // Any component using `withGlobalEvents` that is not setting a `ref`
  347. // will cause `this.props.forwardedRef` to be `null`, so we need this
  348. // check.
  349. if (this.props.forwardedRef) {
  350. this.props.forwardedRef(el);
  351. }
  352. }
  353. render() {
  354. return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, this.props.ownProps, {
  355. ref: this.handleRef
  356. }));
  357. }
  358. }
  359. return Object(external_wp_element_["forwardRef"])((props, ref) => {
  360. return Object(external_wp_element_["createElement"])(Wrapper, {
  361. ownProps: props,
  362. forwardedRef: ref
  363. });
  364. });
  365. }, 'withGlobalEvents');
  366. }
  367. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js
  368. // Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case
  369. // but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript
  370. /* eslint-disable jsdoc/check-types */
  371. /**
  372. * WordPress dependencies
  373. */
  374. /**
  375. * @type {WeakMap<object, number>}
  376. */
  377. const instanceMap = new WeakMap();
  378. /**
  379. * Creates a new id for a given object.
  380. *
  381. * @param {object} object Object reference to create an id for.
  382. * @return {number} The instance id (index).
  383. */
  384. function createId(object) {
  385. const instances = instanceMap.get(object) || 0;
  386. instanceMap.set(object, instances + 1);
  387. return instances;
  388. }
  389. /**
  390. * Provides a unique instance ID.
  391. *
  392. * @param {object} object Object reference to create an id for.
  393. * @param {string} [prefix] Prefix for the unique id.
  394. * @param {string} [preferredId=''] Default ID to use.
  395. * @return {string | number} The unique instance id.
  396. */
  397. function useInstanceId(object, prefix, preferredId = '') {
  398. return Object(external_wp_element_["useMemo"])(() => {
  399. if (preferredId) return preferredId;
  400. const id = createId(object);
  401. return prefix ? `${prefix}-${id}` : id;
  402. }, [object]);
  403. }
  404. /* eslint-enable jsdoc/check-types */
  405. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-instance-id/index.js
  406. /**
  407. * External dependencies
  408. */
  409. // eslint-disable-next-line no-restricted-imports
  410. /**
  411. * Internal dependencies
  412. */
  413. // eslint-disable-next-line no-duplicate-imports
  414. /**
  415. * A Higher Order Component used to be provide a unique instance ID by
  416. * component.
  417. */
  418. const withInstanceId = create_higher_order_component(WrappedComponent => {
  419. return props => {
  420. const instanceId = useInstanceId(WrappedComponent);
  421. return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
  422. instanceId: instanceId
  423. }));
  424. };
  425. }, 'withInstanceId');
  426. /* harmony default export */ var with_instance_id = (withInstanceId);
  427. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-safe-timeout/index.js
  428. /**
  429. * External dependencies
  430. */
  431. /**
  432. * WordPress dependencies
  433. */
  434. /**
  435. * Internal dependencies
  436. */
  437. /**
  438. * A higher-order component used to provide and manage delayed function calls
  439. * that ought to be bound to a component's lifecycle.
  440. *
  441. * @param {WPComponent} OriginalComponent Component requiring setTimeout
  442. *
  443. * @return {WPComponent} Wrapped component.
  444. */
  445. const withSafeTimeout = create_higher_order_component(OriginalComponent => {
  446. return class WrappedComponent extends external_wp_element_["Component"] {
  447. constructor() {
  448. super(...arguments);
  449. this.timeouts = [];
  450. this.setTimeout = this.setTimeout.bind(this);
  451. this.clearTimeout = this.clearTimeout.bind(this);
  452. }
  453. componentWillUnmount() {
  454. this.timeouts.forEach(clearTimeout);
  455. }
  456. setTimeout(fn, delay) {
  457. const id = setTimeout(() => {
  458. fn();
  459. this.clearTimeout(id);
  460. }, delay);
  461. this.timeouts.push(id);
  462. return id;
  463. }
  464. clearTimeout(id) {
  465. clearTimeout(id);
  466. this.timeouts = Object(external_lodash_["without"])(this.timeouts, id);
  467. }
  468. render() {
  469. return Object(external_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, this.props, {
  470. setTimeout: this.setTimeout,
  471. clearTimeout: this.clearTimeout
  472. }));
  473. }
  474. };
  475. }, 'withSafeTimeout');
  476. /* harmony default export */ var with_safe_timeout = (withSafeTimeout);
  477. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-state/index.js
  478. /**
  479. * WordPress dependencies
  480. */
  481. /**
  482. * Internal dependencies
  483. */
  484. /**
  485. * A Higher Order Component used to provide and manage internal component state
  486. * via props.
  487. *
  488. * @param {?Object} initialState Optional initial state of the component.
  489. *
  490. * @return {WPComponent} Wrapped component.
  491. */
  492. function withState(initialState = {}) {
  493. return create_higher_order_component(OriginalComponent => {
  494. return class WrappedComponent extends external_wp_element_["Component"] {
  495. constructor() {
  496. super(...arguments);
  497. this.setState = this.setState.bind(this);
  498. this.state = initialState;
  499. }
  500. render() {
  501. return Object(external_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, this.props, this.state, {
  502. setState: this.setState
  503. }));
  504. }
  505. };
  506. }, 'withState');
  507. }
  508. // EXTERNAL MODULE: external ["wp","keycodes"]
  509. var external_wp_keycodes_ = __webpack_require__("RxS6");
  510. // EXTERNAL MODULE: external ["wp","dom"]
  511. var external_wp_dom_ = __webpack_require__("1CF3");
  512. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-constrained-tabbing/index.js
  513. /**
  514. * WordPress dependencies
  515. */
  516. /**
  517. * In Dialogs/modals, the tabbing must be constrained to the content of
  518. * the wrapper element. This hook adds the behavior to the returned ref.
  519. *
  520. * @return {Object|Function} Element Ref.
  521. *
  522. * @example
  523. * ```js
  524. * import { useConstrainedTabbing } from '@wordpress/compose';
  525. *
  526. * const ConstrainedTabbingExample = () => {
  527. * const constrainedTabbingRef = useConstrainedTabbing()
  528. * return (
  529. * <div ref={ constrainedTabbingRef }>
  530. * <Button />
  531. * <Button />
  532. * </div>
  533. * );
  534. * }
  535. * ```
  536. */
  537. function useConstrainedTabbing() {
  538. const ref = Object(external_wp_element_["useCallback"])(
  539. /** @type {Element} */
  540. node => {
  541. if (!node) {
  542. return;
  543. }
  544. node.addEventListener('keydown',
  545. /** @type {Event} */
  546. event => {
  547. if (!(event instanceof window.KeyboardEvent)) {
  548. return;
  549. }
  550. if (event.keyCode !== external_wp_keycodes_["TAB"]) {
  551. return;
  552. }
  553. const tabbables = external_wp_dom_["focus"].tabbable.find(node);
  554. if (!tabbables.length) {
  555. return;
  556. }
  557. const firstTabbable = tabbables[0];
  558. const lastTabbable = tabbables[tabbables.length - 1];
  559. if (event.shiftKey && event.target === firstTabbable) {
  560. event.preventDefault();
  561. /** @type {HTMLElement} */
  562. lastTabbable.focus();
  563. } else if (!event.shiftKey && event.target === lastTabbable) {
  564. event.preventDefault();
  565. /** @type {HTMLElement} */
  566. firstTabbable.focus();
  567. /*
  568. * When pressing Tab and none of the tabbables has focus, the keydown
  569. * event happens on the wrapper div: move focus on the first tabbable.
  570. */
  571. } else if (!tabbables.includes(
  572. /** @type {Element} */
  573. event.target)) {
  574. event.preventDefault();
  575. /** @type {HTMLElement} */
  576. firstTabbable.focus();
  577. }
  578. });
  579. }, []);
  580. return ref;
  581. }
  582. /* harmony default export */ var use_constrained_tabbing = (useConstrainedTabbing);
  583. // EXTERNAL MODULE: ./node_modules/clipboard/dist/clipboard.js
  584. var dist_clipboard = __webpack_require__("sxGJ");
  585. var clipboard_default = /*#__PURE__*/__webpack_require__.n(dist_clipboard);
  586. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-on-click/index.js
  587. /**
  588. * External dependencies
  589. */
  590. /**
  591. * WordPress dependencies
  592. */
  593. /**
  594. * Copies the text to the clipboard when the element is clicked.
  595. *
  596. * @deprecated
  597. *
  598. * @param {Object} ref Reference with the element.
  599. * @param {string|Function} text The text to copy.
  600. * @param {number} timeout Optional timeout to reset the returned
  601. * state. 4 seconds by default.
  602. *
  603. * @return {boolean} Whether or not the text has been copied. Resets after the
  604. * timeout.
  605. */
  606. function useCopyOnClick(ref, text, timeout = 4000) {
  607. external_wp_deprecated_default()('wp.compose.useCopyOnClick', {
  608. since: '10.3',
  609. plugin: 'Gutenberg',
  610. alternative: 'wp.compose.useCopyToClipboard'
  611. });
  612. const clipboard = Object(external_wp_element_["useRef"])();
  613. const [hasCopied, setHasCopied] = Object(external_wp_element_["useState"])(false);
  614. Object(external_wp_element_["useEffect"])(() => {
  615. let timeoutId; // Clipboard listens to click events.
  616. clipboard.current = new clipboard_default.a(ref.current, {
  617. text: () => typeof text === 'function' ? text() : text
  618. });
  619. clipboard.current.on('success', ({
  620. clearSelection,
  621. trigger
  622. }) => {
  623. // Clearing selection will move focus back to the triggering button,
  624. // ensuring that it is not reset to the body, and further that it is
  625. // kept within the rendered node.
  626. clearSelection(); // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
  627. if (trigger) {
  628. trigger.focus();
  629. }
  630. if (timeout) {
  631. setHasCopied(true);
  632. clearTimeout(timeoutId);
  633. timeoutId = setTimeout(() => setHasCopied(false), timeout);
  634. }
  635. });
  636. return () => {
  637. clipboard.current.destroy();
  638. clearTimeout(timeoutId);
  639. };
  640. }, [text, timeout, setHasCopied]);
  641. return hasCopied;
  642. }
  643. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-ref-effect/index.js
  644. /**
  645. * WordPress dependencies
  646. */
  647. /**
  648. * Effect-like ref callback. Just like with `useEffect`, this allows you to
  649. * return a cleanup function to be run if the ref changes or one of the
  650. * dependencies changes. The ref is provided as an argument to the callback
  651. * functions. The main difference between this and `useEffect` is that
  652. * the `useEffect` callback is not called when the ref changes, but this is.
  653. * Pass the returned ref callback as the component's ref and merge multiple refs
  654. * with `useMergeRefs`.
  655. *
  656. * It's worth noting that if the dependencies array is empty, there's not
  657. * strictly a need to clean up event handlers for example, because the node is
  658. * to be removed. It *is* necessary if you add dependencies because the ref
  659. * callback will be called multiple times for the same node.
  660. *
  661. * @param {Function} callback Callback with ref as argument.
  662. * @param {Array} dependencies Dependencies of the callback.
  663. *
  664. * @return {Function} Ref callback.
  665. */
  666. function useRefEffect(callback, dependencies) {
  667. const cleanup = Object(external_wp_element_["useRef"])();
  668. return Object(external_wp_element_["useCallback"])(node => {
  669. if (node) {
  670. cleanup.current = callback(node);
  671. } else if (cleanup.current) {
  672. cleanup.current();
  673. }
  674. }, dependencies);
  675. }
  676. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-to-clipboard/index.js
  677. /**
  678. * External dependencies
  679. */
  680. /**
  681. * WordPress dependencies
  682. */
  683. /**
  684. * Internal dependencies
  685. */
  686. /** @typedef {import('@wordpress/element').RefObject} RefObject */
  687. function useUpdatedRef(value) {
  688. const ref = Object(external_wp_element_["useRef"])(value);
  689. ref.current = value;
  690. return ref;
  691. }
  692. /**
  693. * Copies the given text to the clipboard when the element is clicked.
  694. *
  695. * @param {text|Function} text The text to copy. Use a function if not
  696. * already available and expensive to compute.
  697. * @param {Function} onSuccess Called when to text is copied.
  698. *
  699. * @return {RefObject} A ref to assign to the target element.
  700. */
  701. function useCopyToClipboard(text, onSuccess) {
  702. // Store the dependencies as refs and continuesly update them so they're
  703. // fresh when the callback is called.
  704. const textRef = useUpdatedRef(text);
  705. const onSuccesRef = useUpdatedRef(onSuccess);
  706. return useRefEffect(node => {
  707. // Clipboard listens to click events.
  708. const clipboard = new clipboard_default.a(node, {
  709. text() {
  710. return typeof textRef.current === 'function' ? textRef.current() : textRef.current;
  711. }
  712. });
  713. clipboard.on('success', ({
  714. clearSelection
  715. }) => {
  716. // Clearing selection will move focus back to the triggering
  717. // button, ensuring that it is not reset to the body, and
  718. // further that it is kept within the rendered node.
  719. clearSelection(); // Handle ClipboardJS focus bug, see
  720. // https://github.com/zenorocha/clipboard.js/issues/680
  721. node.focus();
  722. if (onSuccesRef.current) {
  723. onSuccesRef.current();
  724. }
  725. });
  726. return () => {
  727. clipboard.destroy();
  728. };
  729. }, []);
  730. }
  731. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-on-mount/index.js
  732. /**
  733. * WordPress dependencies
  734. */
  735. /**
  736. * Hook used to focus the first tabbable element on mount.
  737. *
  738. * @param {boolean|string} focusOnMount Focus on mount mode.
  739. * @return {Function} Ref callback.
  740. *
  741. * @example
  742. * ```js
  743. * import { useFocusOnMount } from '@wordpress/compose';
  744. *
  745. * const WithFocusOnMount = () => {
  746. * const ref = useFocusOnMount()
  747. * return (
  748. * <div ref={ ref }>
  749. * <Button />
  750. * <Button />
  751. * </div>
  752. * );
  753. * }
  754. * ```
  755. */
  756. function useFocusOnMount(focusOnMount = 'firstElement') {
  757. const focusOnMountRef = Object(external_wp_element_["useRef"])(focusOnMount);
  758. Object(external_wp_element_["useEffect"])(() => {
  759. focusOnMountRef.current = focusOnMount;
  760. }, [focusOnMount]);
  761. return Object(external_wp_element_["useCallback"])(node => {
  762. if (!node || focusOnMountRef.current === false) {
  763. return;
  764. }
  765. if (node.contains(node.ownerDocument.activeElement)) {
  766. return;
  767. }
  768. let target = node;
  769. if (focusOnMountRef.current === 'firstElement') {
  770. const firstTabbable = external_wp_dom_["focus"].tabbable.find(node)[0];
  771. if (firstTabbable) {
  772. target = firstTabbable;
  773. }
  774. }
  775. target.focus();
  776. }, []);
  777. }
  778. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-return/index.js
  779. /**
  780. * WordPress dependencies
  781. */
  782. /**
  783. * When opening modals/sidebars/dialogs, the focus
  784. * must move to the opened area and return to the
  785. * previously focused element when closed.
  786. * The current hook implements the returning behavior.
  787. *
  788. * @param {Function?} onFocusReturn Overrides the default return behavior.
  789. * @return {Function} Element Ref.
  790. *
  791. * @example
  792. * ```js
  793. * import { useFocusReturn } from '@wordpress/compose';
  794. *
  795. * const WithFocusReturn = () => {
  796. * const ref = useFocusReturn()
  797. * return (
  798. * <div ref={ ref }>
  799. * <Button />
  800. * <Button />
  801. * </div>
  802. * );
  803. * }
  804. * ```
  805. */
  806. function useFocusReturn(onFocusReturn) {
  807. const ref = Object(external_wp_element_["useRef"])();
  808. const focusedBeforeMount = Object(external_wp_element_["useRef"])();
  809. const onFocusReturnRef = Object(external_wp_element_["useRef"])(onFocusReturn);
  810. Object(external_wp_element_["useEffect"])(() => {
  811. onFocusReturnRef.current = onFocusReturn;
  812. }, [onFocusReturn]);
  813. return Object(external_wp_element_["useCallback"])(node => {
  814. if (node) {
  815. // Set ref to be used when unmounting.
  816. ref.current = node; // Only set when the node mounts.
  817. if (focusedBeforeMount.current) {
  818. return;
  819. }
  820. focusedBeforeMount.current = node.ownerDocument.activeElement;
  821. } else if (focusedBeforeMount.current) {
  822. const isFocused = ref.current.contains(ref.current.ownerDocument.activeElement);
  823. if (ref.current.isConnected && !isFocused) {
  824. return;
  825. } // Defer to the component's own explicit focus return behavior, if
  826. // specified. This allows for support that the `onFocusReturn`
  827. // decides to allow the default behavior to occur under some
  828. // conditions.
  829. if (onFocusReturnRef.current) {
  830. onFocusReturnRef.current();
  831. } else {
  832. focusedBeforeMount.current.focus();
  833. }
  834. }
  835. }, []);
  836. }
  837. /* harmony default export */ var use_focus_return = (useFocusReturn);
  838. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js
  839. /**
  840. * External dependencies
  841. */
  842. /**
  843. * WordPress dependencies
  844. */
  845. /**
  846. * Input types which are classified as button types, for use in considering
  847. * whether element is a (focus-normalized) button.
  848. *
  849. * @type {string[]}
  850. */
  851. const INPUT_BUTTON_TYPES = ['button', 'submit'];
  852. /**
  853. * @typedef {HTMLButtonElement | HTMLLinkElement | HTMLInputElement} FocusNormalizedButton
  854. */
  855. // Disable reason: Rule doesn't support predicate return types
  856. /* eslint-disable jsdoc/valid-types */
  857. /**
  858. * Returns true if the given element is a button element subject to focus
  859. * normalization, or false otherwise.
  860. *
  861. * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  862. *
  863. * @param {EventTarget} eventTarget The target from a mouse or touch event.
  864. *
  865. * @return {eventTarget is FocusNormalizedButton} Whether element is a button.
  866. */
  867. function isFocusNormalizedButton(eventTarget) {
  868. if (!(eventTarget instanceof window.HTMLElement)) {
  869. return false;
  870. }
  871. switch (eventTarget.nodeName) {
  872. case 'A':
  873. case 'BUTTON':
  874. return true;
  875. case 'INPUT':
  876. return Object(external_lodash_["includes"])(INPUT_BUTTON_TYPES,
  877. /** @type {HTMLInputElement} */
  878. eventTarget.type);
  879. }
  880. return false;
  881. }
  882. /* eslint-enable jsdoc/valid-types */
  883. /**
  884. * @typedef {import('react').SyntheticEvent} SyntheticEvent
  885. */
  886. /**
  887. * @callback EventCallback
  888. * @param {SyntheticEvent} event input related event.
  889. */
  890. /**
  891. * @typedef FocusOutsideReactElement
  892. * @property {EventCallback} handleFocusOutside callback for a focus outside event.
  893. */
  894. /**
  895. * @typedef {import('react').MutableRefObject<FocusOutsideReactElement | undefined>} FocusOutsideRef
  896. */
  897. /**
  898. * @typedef {Object} FocusOutsideReturnValue
  899. * @property {EventCallback} onFocus An event handler for focus events.
  900. * @property {EventCallback} onBlur An event handler for blur events.
  901. * @property {EventCallback} onMouseDown An event handler for mouse down events.
  902. * @property {EventCallback} onMouseUp An event handler for mouse up events.
  903. * @property {EventCallback} onTouchStart An event handler for touch start events.
  904. * @property {EventCallback} onTouchEnd An event handler for touch end events.
  905. */
  906. /**
  907. * A react hook that can be used to check whether focus has moved outside the
  908. * element the event handlers are bound to.
  909. *
  910. * @param {EventCallback} onFocusOutside A callback triggered when focus moves outside
  911. * the element the event handlers are bound to.
  912. *
  913. * @return {FocusOutsideReturnValue} An object containing event handlers. Bind the event handlers
  914. * to a wrapping element element to capture when focus moves
  915. * outside that element.
  916. */
  917. function useFocusOutside(onFocusOutside) {
  918. const currentOnFocusOutside = Object(external_wp_element_["useRef"])(onFocusOutside);
  919. Object(external_wp_element_["useEffect"])(() => {
  920. currentOnFocusOutside.current = onFocusOutside;
  921. }, [onFocusOutside]);
  922. const preventBlurCheck = Object(external_wp_element_["useRef"])(false);
  923. /**
  924. * @type {import('react').MutableRefObject<number | undefined>}
  925. */
  926. const blurCheckTimeoutId = Object(external_wp_element_["useRef"])();
  927. /**
  928. * Cancel a blur check timeout.
  929. */
  930. const cancelBlurCheck = Object(external_wp_element_["useCallback"])(() => {
  931. clearTimeout(blurCheckTimeoutId.current);
  932. }, []); // Cancel blur checks on unmount.
  933. Object(external_wp_element_["useEffect"])(() => {
  934. return () => cancelBlurCheck();
  935. }, []); // Cancel a blur check if the callback or ref is no longer provided.
  936. Object(external_wp_element_["useEffect"])(() => {
  937. if (!onFocusOutside) {
  938. cancelBlurCheck();
  939. }
  940. }, [onFocusOutside, cancelBlurCheck]);
  941. /**
  942. * Handles a mousedown or mouseup event to respectively assign and
  943. * unassign a flag for preventing blur check on button elements. Some
  944. * browsers, namely Firefox and Safari, do not emit a focus event on
  945. * button elements when clicked, while others do. The logic here
  946. * intends to normalize this as treating click on buttons as focus.
  947. *
  948. * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  949. *
  950. * @param {SyntheticEvent} event Event for mousedown or mouseup.
  951. */
  952. const normalizeButtonFocus = Object(external_wp_element_["useCallback"])(event => {
  953. const {
  954. type,
  955. target
  956. } = event;
  957. const isInteractionEnd = Object(external_lodash_["includes"])(['mouseup', 'touchend'], type);
  958. if (isInteractionEnd) {
  959. preventBlurCheck.current = false;
  960. } else if (isFocusNormalizedButton(target)) {
  961. preventBlurCheck.current = true;
  962. }
  963. }, []);
  964. /**
  965. * A callback triggered when a blur event occurs on the element the handler
  966. * is bound to.
  967. *
  968. * Calls the `onFocusOutside` callback in an immediate timeout if focus has
  969. * move outside the bound element and is still within the document.
  970. *
  971. * @param {SyntheticEvent} event Blur event.
  972. */
  973. const queueBlurCheck = Object(external_wp_element_["useCallback"])(event => {
  974. // React does not allow using an event reference asynchronously
  975. // due to recycling behavior, except when explicitly persisted.
  976. event.persist(); // Skip blur check if clicking button. See `normalizeButtonFocus`.
  977. if (preventBlurCheck.current) {
  978. return;
  979. }
  980. blurCheckTimeoutId.current = setTimeout(() => {
  981. // If document is not focused then focus should remain
  982. // inside the wrapped component and therefore we cancel
  983. // this blur event thereby leaving focus in place.
  984. // https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus.
  985. if (!document.hasFocus()) {
  986. event.preventDefault();
  987. return;
  988. }
  989. if ('function' === typeof currentOnFocusOutside.current) {
  990. currentOnFocusOutside.current(event);
  991. }
  992. }, 0);
  993. }, []);
  994. return {
  995. onFocus: cancelBlurCheck,
  996. onMouseDown: normalizeButtonFocus,
  997. onMouseUp: normalizeButtonFocus,
  998. onTouchStart: normalizeButtonFocus,
  999. onTouchEnd: normalizeButtonFocus,
  1000. onBlur: queueBlurCheck
  1001. };
  1002. }
  1003. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-merge-refs/index.js
  1004. /**
  1005. * WordPress dependencies
  1006. */
  1007. /** @typedef {import('@wordpress/element').RefObject} RefObject */
  1008. /** @typedef {import('@wordpress/element').RefCallback} RefCallback */
  1009. function assignRef(ref, value) {
  1010. if (typeof ref === 'function') {
  1011. ref(value);
  1012. } else if (ref && ref.hasOwnProperty('current')) {
  1013. ref.current = value;
  1014. }
  1015. }
  1016. /**
  1017. * Merges refs into one ref callback. Ensures the merged ref callbacks are only
  1018. * called when it changes (as a result of a `useCallback` dependency update) or
  1019. * when the ref value changes. If you don't wish a ref callback to be called on
  1020. * every render, wrap it with `useCallback( ref, [] )`.
  1021. * Dependencies can be added, but when a dependency changes, the old ref
  1022. * callback will be called with `null` and the new ref callback will be called
  1023. * with the same node.
  1024. *
  1025. * @param {Array<RefObject|RefCallback>} refs The refs to be merged.
  1026. *
  1027. * @return {RefCallback} The merged ref callback.
  1028. */
  1029. function useMergeRefs(refs) {
  1030. const element = Object(external_wp_element_["useRef"])();
  1031. const didElementChange = Object(external_wp_element_["useRef"])(false);
  1032. const previousRefs = Object(external_wp_element_["useRef"])([]);
  1033. const currentRefs = Object(external_wp_element_["useRef"])(refs); // Update on render before the ref callback is called, so the ref callback
  1034. // always has access to the current refs.
  1035. currentRefs.current = refs; // If any of the refs change, call the previous ref with `null` and the new
  1036. // ref with the node, except when the element changes in the same cycle, in
  1037. // which case the ref callbacks will already have been called.
  1038. Object(external_wp_element_["useLayoutEffect"])(() => {
  1039. if (didElementChange.current === false) {
  1040. refs.forEach((ref, index) => {
  1041. const previousRef = previousRefs.current[index];
  1042. if (ref !== previousRef) {
  1043. assignRef(previousRef, null);
  1044. assignRef(ref, element.current);
  1045. }
  1046. });
  1047. }
  1048. previousRefs.current = refs;
  1049. }, refs); // No dependencies, must be reset after every render so ref callbacks are
  1050. // correctly called after a ref change.
  1051. Object(external_wp_element_["useLayoutEffect"])(() => {
  1052. didElementChange.current = false;
  1053. }); // There should be no dependencies so that `callback` is only called when
  1054. // the node changes.
  1055. return Object(external_wp_element_["useCallback"])(value => {
  1056. // Update the element so it can be used when calling ref callbacks on a
  1057. // dependency change.
  1058. assignRef(element, value);
  1059. didElementChange.current = true; // When an element changes, the current ref callback should be called
  1060. // with the new element and the previous one with `null`.
  1061. const refsToAssign = value ? currentRefs.current : previousRefs.current; // Update the latest refs.
  1062. for (const ref of refsToAssign) {
  1063. assignRef(ref, value);
  1064. }
  1065. }, []);
  1066. }
  1067. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js
  1068. /**
  1069. * WordPress dependencies
  1070. */
  1071. /**
  1072. * Internal dependencies
  1073. */
  1074. /**
  1075. * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors:
  1076. * - constrained tabbing.
  1077. * - focus on mount.
  1078. * - return focus on unmount.
  1079. * - focus outside.
  1080. *
  1081. * @param {Object} options Dialog Options.
  1082. */
  1083. function useDialog(options) {
  1084. const onClose = Object(external_wp_element_["useRef"])();
  1085. Object(external_wp_element_["useEffect"])(() => {
  1086. onClose.current = options.onClose;
  1087. }, [options.onClose]);
  1088. const constrainedTabbingRef = use_constrained_tabbing();
  1089. const focusOnMountRef = useFocusOnMount();
  1090. const focusReturnRef = use_focus_return();
  1091. const focusOutsideProps = useFocusOutside(options.onClose);
  1092. const closeOnEscapeRef = Object(external_wp_element_["useCallback"])(node => {
  1093. if (!node) {
  1094. return;
  1095. }
  1096. node.addEventListener('keydown', event => {
  1097. // Close on escape
  1098. if (event.keyCode === external_wp_keycodes_["ESCAPE"] && onClose.current) {
  1099. event.stopPropagation();
  1100. onClose.current();
  1101. }
  1102. });
  1103. }, []);
  1104. return [useMergeRefs([constrainedTabbingRef, focusReturnRef, focusOnMountRef, closeOnEscapeRef]), { ...focusOutsideProps,
  1105. tabIndex: '-1'
  1106. }];
  1107. }
  1108. /* harmony default export */ var use_dialog = (useDialog);
  1109. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-isomorphic-layout-effect/index.js
  1110. /**
  1111. * WordPress dependencies
  1112. */
  1113. /**
  1114. * Preferred over direct usage of `useLayoutEffect` when supporting
  1115. * server rendered components (SSR) because currently React
  1116. * throws a warning when using useLayoutEffect in that environment.
  1117. */
  1118. const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external_wp_element_["useLayoutEffect"] : external_wp_element_["useEffect"];
  1119. /* harmony default export */ var use_isomorphic_layout_effect = (useIsomorphicLayoutEffect);
  1120. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dragging/index.js
  1121. /**
  1122. * WordPress dependencies
  1123. */
  1124. /**
  1125. * Internal dependencies
  1126. */
  1127. function useDragging({
  1128. onDragStart,
  1129. onDragMove,
  1130. onDragEnd
  1131. }) {
  1132. const [isDragging, setIsDragging] = Object(external_wp_element_["useState"])(false);
  1133. const eventsRef = Object(external_wp_element_["useRef"])({
  1134. onDragStart,
  1135. onDragMove,
  1136. onDragEnd
  1137. });
  1138. use_isomorphic_layout_effect(() => {
  1139. eventsRef.current.onDragStart = onDragStart;
  1140. eventsRef.current.onDragMove = onDragMove;
  1141. eventsRef.current.onDragEnd = onDragEnd;
  1142. }, [onDragStart, onDragMove, onDragEnd]);
  1143. const onMouseMove = Object(external_wp_element_["useCallback"])((...args) => eventsRef.current.onDragMove && eventsRef.current.onDragMove(...args), []);
  1144. const endDrag = Object(external_wp_element_["useCallback"])((...args) => {
  1145. if (eventsRef.current.onDragEnd) {
  1146. eventsRef.current.onDragEnd(...args);
  1147. }
  1148. document.removeEventListener('mousemove', onMouseMove);
  1149. document.removeEventListener('mouseup', endDrag);
  1150. setIsDragging(false);
  1151. }, []);
  1152. const startDrag = Object(external_wp_element_["useCallback"])((...args) => {
  1153. if (eventsRef.current.onDragStart) {
  1154. eventsRef.current.onDragStart(...args);
  1155. }
  1156. document.addEventListener('mousemove', onMouseMove);
  1157. document.addEventListener('mouseup', endDrag);
  1158. setIsDragging(true);
  1159. }, []); // Remove the global events when unmounting if needed.
  1160. Object(external_wp_element_["useEffect"])(() => {
  1161. return () => {
  1162. if (isDragging) {
  1163. document.removeEventListener('mousemove', onMouseMove);
  1164. document.removeEventListener('mouseup', endDrag);
  1165. }
  1166. };
  1167. }, [isDragging]);
  1168. return {
  1169. startDrag,
  1170. endDrag,
  1171. isDragging
  1172. };
  1173. }
  1174. // EXTERNAL MODULE: ./node_modules/mousetrap/mousetrap.js
  1175. var mousetrap_mousetrap = __webpack_require__("imBb");
  1176. var mousetrap_default = /*#__PURE__*/__webpack_require__.n(mousetrap_mousetrap);
  1177. // EXTERNAL MODULE: ./node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js
  1178. var mousetrap_global_bind = __webpack_require__("VcSt");
  1179. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-keyboard-shortcut/index.js
  1180. /**
  1181. * External dependencies
  1182. */
  1183. /**
  1184. * WordPress dependencies
  1185. */
  1186. /**
  1187. * A block selection object.
  1188. *
  1189. * @typedef {Object} WPKeyboardShortcutConfig
  1190. *
  1191. * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields.
  1192. * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown.
  1193. * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true.
  1194. * @property {Object} [target] React reference to the DOM element used to catch the keyboard event.
  1195. */
  1196. /**
  1197. * Return true if platform is MacOS.
  1198. *
  1199. * @param {Object} _window window object by default; used for DI testing.
  1200. *
  1201. * @return {boolean} True if MacOS; false otherwise.
  1202. */
  1203. function isAppleOS(_window = window) {
  1204. const {
  1205. platform
  1206. } = _window.navigator;
  1207. return platform.indexOf('Mac') !== -1 || Object(external_lodash_["includes"])(['iPad', 'iPhone'], platform);
  1208. }
  1209. /**
  1210. * Attach a keyboard shortcut handler.
  1211. *
  1212. * @param {string[]|string} shortcuts Keyboard Shortcuts.
  1213. * @param {Function} callback Shortcut callback.
  1214. * @param {WPKeyboardShortcutConfig} options Shortcut options.
  1215. */
  1216. function useKeyboardShortcut(shortcuts, callback, {
  1217. bindGlobal = false,
  1218. eventName = 'keydown',
  1219. isDisabled = false,
  1220. // This is important for performance considerations.
  1221. target
  1222. } = {}) {
  1223. const currentCallback = Object(external_wp_element_["useRef"])(callback);
  1224. Object(external_wp_element_["useEffect"])(() => {
  1225. currentCallback.current = callback;
  1226. }, [callback]);
  1227. Object(external_wp_element_["useEffect"])(() => {
  1228. if (isDisabled) {
  1229. return;
  1230. }
  1231. const mousetrap = new mousetrap_default.a(target ? target.current : document);
  1232. Object(external_lodash_["castArray"])(shortcuts).forEach(shortcut => {
  1233. const keys = shortcut.split('+'); // Determines whether a key is a modifier by the length of the string.
  1234. // E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that
  1235. // the modifiers are Shift and Cmd because they're not a single character.
  1236. const modifiers = new Set(keys.filter(value => value.length > 1));
  1237. const hasAlt = modifiers.has('alt');
  1238. const hasShift = modifiers.has('shift'); // This should be better moved to the shortcut registration instead.
  1239. if (isAppleOS() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) {
  1240. throw new Error(`Cannot bind ${shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`);
  1241. }
  1242. const bindFn = bindGlobal ? 'bindGlobal' : 'bind';
  1243. mousetrap[bindFn](shortcut, (...args) => currentCallback.current(...args), eventName);
  1244. });
  1245. return () => {
  1246. mousetrap.reset();
  1247. };
  1248. }, [shortcuts, bindGlobal, eventName, target, isDisabled]);
  1249. }
  1250. /* harmony default export */ var use_keyboard_shortcut = (useKeyboardShortcut);
  1251. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js
  1252. /**
  1253. * WordPress dependencies
  1254. */
  1255. /**
  1256. * Runs a media query and returns its value when it changes.
  1257. *
  1258. * @param {string} [query] Media Query.
  1259. * @return {boolean} return value of the media query.
  1260. */
  1261. function useMediaQuery(query) {
  1262. const [match, setMatch] = Object(external_wp_element_["useState"])(() => !!(query && typeof window !== 'undefined' && window.matchMedia(query).matches));
  1263. Object(external_wp_element_["useEffect"])(() => {
  1264. if (!query) {
  1265. return;
  1266. }
  1267. const updateMatch = () => setMatch(window.matchMedia(query).matches);
  1268. updateMatch();
  1269. const list = window.matchMedia(query);
  1270. list.addListener(updateMatch);
  1271. return () => {
  1272. list.removeListener(updateMatch);
  1273. };
  1274. }, [query]);
  1275. return query && match;
  1276. }
  1277. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js
  1278. /**
  1279. * WordPress dependencies
  1280. */
  1281. /**
  1282. * Use something's value from the previous render.
  1283. * Based on https://usehooks.com/usePrevious/.
  1284. *
  1285. * @template T
  1286. *
  1287. * @param {T} value The value to track.
  1288. *
  1289. * @return {T|undefined} The value from the previous render.
  1290. */
  1291. function usePrevious(value) {
  1292. // Disable reason: without an explicit type detail, the type of ref will be
  1293. // inferred based on the initial useRef argument, which is undefined.
  1294. // https://github.com/WordPress/gutenberg/pull/22597#issuecomment-633588366
  1295. /* eslint-disable jsdoc/no-undefined-types */
  1296. const ref = Object(external_wp_element_["useRef"])(
  1297. /** @type {T|undefined} */
  1298. undefined);
  1299. /* eslint-enable jsdoc/no-undefined-types */
  1300. // Store current value in ref.
  1301. Object(external_wp_element_["useEffect"])(() => {
  1302. ref.current = value;
  1303. }, [value]); // Re-run when value changes.
  1304. // Return previous value (happens before update in useEffect above).
  1305. return ref.current;
  1306. }
  1307. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js
  1308. /**
  1309. * Internal dependencies
  1310. */
  1311. /**
  1312. * Whether or not the user agent is Internet Explorer.
  1313. *
  1314. * @type {boolean}
  1315. */
  1316. const IS_IE = typeof window !== 'undefined' && window.navigator.userAgent.indexOf('Trident') >= 0;
  1317. /**
  1318. * Hook returning whether the user has a preference for reduced motion.
  1319. *
  1320. * @return {boolean} Reduced motion preference value.
  1321. */
  1322. const useReducedMotion = undefined || IS_IE ? () => true : () => useMediaQuery('(prefers-reduced-motion: reduce)');
  1323. /* harmony default export */ var use_reduced_motion = (useReducedMotion);
  1324. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js
  1325. /**
  1326. * WordPress dependencies
  1327. */
  1328. /**
  1329. * Internal dependencies
  1330. */
  1331. /**
  1332. * @typedef {"huge"|"wide"|"large"|"medium"|"small"|"mobile"} WPBreakpoint
  1333. */
  1334. /**
  1335. * Hash of breakpoint names with pixel width at which it becomes effective.
  1336. *
  1337. * @see _breakpoints.scss
  1338. *
  1339. * @type {Object<WPBreakpoint,number>}
  1340. */
  1341. const BREAKPOINTS = {
  1342. huge: 1440,
  1343. wide: 1280,
  1344. large: 960,
  1345. medium: 782,
  1346. small: 600,
  1347. mobile: 480
  1348. };
  1349. /**
  1350. * @typedef {">="|"<"} WPViewportOperator
  1351. */
  1352. /**
  1353. * Object mapping media query operators to the condition to be used.
  1354. *
  1355. * @type {Object<WPViewportOperator,string>}
  1356. */
  1357. const CONDITIONS = {
  1358. '>=': 'min-width',
  1359. '<': 'max-width'
  1360. };
  1361. /**
  1362. * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values.
  1363. *
  1364. * @type {Object<WPViewportOperator,Function>}
  1365. */
  1366. const OPERATOR_EVALUATORS = {
  1367. '>=': (breakpointValue, width) => width >= breakpointValue,
  1368. '<': (breakpointValue, width) => width < breakpointValue
  1369. };
  1370. const ViewportMatchWidthContext = Object(external_wp_element_["createContext"])(null);
  1371. /**
  1372. * Returns true if the viewport matches the given query, or false otherwise.
  1373. *
  1374. * @param {WPBreakpoint} breakpoint Breakpoint size name.
  1375. * @param {WPViewportOperator} [operator=">="] Viewport operator.
  1376. *
  1377. * @example
  1378. *
  1379. * ```js
  1380. * useViewportMatch( 'huge', '<' );
  1381. * useViewportMatch( 'medium' );
  1382. * ```
  1383. *
  1384. * @return {boolean} Whether viewport matches query.
  1385. */
  1386. const useViewportMatch = (breakpoint, operator = '>=') => {
  1387. const simulatedWidth = Object(external_wp_element_["useContext"])(ViewportMatchWidthContext);
  1388. const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`;
  1389. const mediaQueryResult = useMediaQuery(mediaQuery);
  1390. if (simulatedWidth) {
  1391. return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth);
  1392. }
  1393. return mediaQueryResult;
  1394. };
  1395. useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider;
  1396. /* harmony default export */ var use_viewport_match = (useViewportMatch);
  1397. // EXTERNAL MODULE: ./node_modules/react-resize-aware/dist/index.js
  1398. var dist = __webpack_require__("SSiF");
  1399. var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
  1400. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js
  1401. /**
  1402. * External dependencies
  1403. */
  1404. /**
  1405. * Hook which allows to listen the resize event of any target element when it changes sizes.
  1406. * _Note: `useResizeObserver` will report `null` until after first render_
  1407. *
  1408. * @return {Array} An array of {Element} `resizeListener` and {?Object} `sizes` with properties `width` and `height`
  1409. *
  1410. * @example
  1411. *
  1412. * ```js
  1413. * const App = () => {
  1414. * const [ resizeListener, sizes ] = useResizeObserver();
  1415. *
  1416. * return (
  1417. * <div>
  1418. * { resizeListener }
  1419. * Your content here
  1420. * </div>
  1421. * );
  1422. * };
  1423. * ```
  1424. *
  1425. */
  1426. /* harmony default export */ var use_resize_observer = (dist_default.a);
  1427. // EXTERNAL MODULE: external ["wp","priorityQueue"]
  1428. var external_wp_priorityQueue_ = __webpack_require__("XI5e");
  1429. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-async-list/index.js
  1430. /**
  1431. * WordPress dependencies
  1432. */
  1433. /**
  1434. * Returns the first items from list that are present on state.
  1435. *
  1436. * @param list New array.
  1437. * @param state Current state.
  1438. * @return First items present iin state.
  1439. */
  1440. function getFirstItemsPresentInState(list, state) {
  1441. const firstItems = [];
  1442. for (let i = 0; i < list.length; i++) {
  1443. const item = list[i];
  1444. if (!state.includes(item)) {
  1445. break;
  1446. }
  1447. firstItems.push(item);
  1448. }
  1449. return firstItems;
  1450. }
  1451. /**
  1452. * React hook returns an array which items get asynchronously appended from a source array.
  1453. * This behavior is useful if we want to render a list of items asynchronously for performance reasons.
  1454. *
  1455. * @param list Source array.
  1456. * @return Async array.
  1457. */
  1458. function useAsyncList(list) {
  1459. const [current, setCurrent] = Object(external_wp_element_["useState"])([]);
  1460. Object(external_wp_element_["useEffect"])(() => {
  1461. // On reset, we keep the first items that were previously rendered.
  1462. const firstItems = getFirstItemsPresentInState(list, current);
  1463. setCurrent(firstItems);
  1464. const asyncQueue = Object(external_wp_priorityQueue_["createQueue"])();
  1465. const append = index => () => {
  1466. if (list.length <= index) {
  1467. return;
  1468. }
  1469. setCurrent(state => [...state, list[index]]);
  1470. asyncQueue.add({}, append(index + 1));
  1471. };
  1472. asyncQueue.add({}, append(firstItems.length));
  1473. return () => asyncQueue.reset();
  1474. }, [list]);
  1475. return current;
  1476. }
  1477. /* harmony default export */ var use_async_list = (useAsyncList);
  1478. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-warn-on-change/index.js
  1479. /**
  1480. * Internal dependencies
  1481. */
  1482. /**
  1483. * Hook that performs a shallow comparison between the preview value of an object
  1484. * and the new one, if there's a difference, it prints it to the console.
  1485. * this is useful in performance related work, to check why a component re-renders.
  1486. *
  1487. * @example
  1488. *
  1489. * ```jsx
  1490. * function MyComponent(props) {
  1491. * useWarnOnChange(props);
  1492. *
  1493. * return "Something";
  1494. * }
  1495. * ```
  1496. *
  1497. * @param {Object} object Object which changes to compare.
  1498. * @param {string} prefix Just a prefix to show when console logging.
  1499. */
  1500. function useWarnOnChange(object, prefix = 'Change detection') {
  1501. const previousValues = usePrevious(object);
  1502. Object.entries(previousValues !== null && previousValues !== void 0 ? previousValues : []).forEach(([key, value]) => {
  1503. if (value !== object[key]) {
  1504. // eslint-disable-next-line no-console
  1505. console.warn(`${prefix}: ${key} key changed:`, value, object[key]);
  1506. }
  1507. });
  1508. }
  1509. /* harmony default export */ var use_warn_on_change = (useWarnOnChange);
  1510. // EXTERNAL MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js
  1511. var use_memo_one_esm = __webpack_require__("mHlH");
  1512. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-debounce/index.js
  1513. /**
  1514. * External dependencies
  1515. */
  1516. /**
  1517. * WordPress dependencies
  1518. */
  1519. /**
  1520. * Debounces a function with Lodash's `debounce`. A new debounced function will
  1521. * be returned and any scheduled calls cancelled if any of the arguments change,
  1522. * including the function to debounce, so please wrap functions created on
  1523. * render in components in `useCallback`.
  1524. *
  1525. * @param {...any} args Arguments passed to Lodash's `debounce`.
  1526. *
  1527. * @return {Function} Debounced function.
  1528. */
  1529. function useDebounce(...args) {
  1530. const debounced = Object(use_memo_one_esm["a" /* useMemoOne */])(() => Object(external_lodash_["debounce"])(...args), args);
  1531. Object(external_wp_element_["useEffect"])(() => () => debounced.cancel(), [debounced]);
  1532. return debounced;
  1533. }
  1534. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-throttle/index.js
  1535. /**
  1536. * External dependencies
  1537. */
  1538. /**
  1539. * WordPress dependencies
  1540. */
  1541. /**
  1542. * Throttles a function with Lodash's `throttle`. A new throttled function will
  1543. * be returned and any scheduled calls cancelled if any of the arguments change,
  1544. * including the function to throttle, so please wrap functions created on
  1545. * render in components in `useCallback`.
  1546. *
  1547. * @param {...any} args Arguments passed to Lodash's `throttle`.
  1548. *
  1549. * @return {Function} Throttled function.
  1550. */
  1551. function useThrottle(...args) {
  1552. const throttled = Object(use_memo_one_esm["a" /* useMemoOne */])(() => Object(external_lodash_["throttle"])(...args), args);
  1553. Object(external_wp_element_["useEffect"])(() => () => throttled.cancel(), [throttled]);
  1554. return throttled;
  1555. }
  1556. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-drop-zone/index.js
  1557. /**
  1558. * WordPress dependencies
  1559. */
  1560. /**
  1561. * Internal dependencies
  1562. */
  1563. /** @typedef {import('@wordpress/element').RefCallback} RefCallback */
  1564. function useFreshRef(value) {
  1565. const ref = Object(external_wp_element_["useRef"])();
  1566. ref.current = value;
  1567. return ref;
  1568. }
  1569. /**
  1570. * A hook to facilitate drag and drop handling.
  1571. *
  1572. * @param {Object} $1 Named parameters.
  1573. * @param {boolean} $1.isDisabled Whether or not to disable the drop zone.
  1574. * @param {DragEvent} $1.onDragStart Called when dragging has started.
  1575. * @param {DragEvent} $1.onDragEnter Called when the zone is entered.
  1576. * @param {DragEvent} $1.onDragOver Called when the zone is moved within.
  1577. * @param {DragEvent} $1.onDragLeave Called when the zone is left.
  1578. * @param {MouseEvent} $1.onDragEnd Called when dragging has ended.
  1579. * @param {DragEvent} $1.onDrop Called when dropping in the zone.
  1580. *
  1581. * @return {RefCallback} Ref callback to be passed to the drop zone element.
  1582. */
  1583. function useDropZone({
  1584. isDisabled,
  1585. onDrop: _onDrop,
  1586. onDragStart: _onDragStart,
  1587. onDragEnter: _onDragEnter,
  1588. onDragLeave: _onDragLeave,
  1589. onDragEnd: _onDragEnd,
  1590. onDragOver: _onDragOver
  1591. }) {
  1592. const onDropRef = useFreshRef(_onDrop);
  1593. const onDragStartRef = useFreshRef(_onDragStart);
  1594. const onDragEnterRef = useFreshRef(_onDragEnter);
  1595. const onDragLeaveRef = useFreshRef(_onDragLeave);
  1596. const onDragEndRef = useFreshRef(_onDragEnd);
  1597. const onDragOverRef = useFreshRef(_onDragOver);
  1598. return useRefEffect(element => {
  1599. if (isDisabled) {
  1600. return;
  1601. }
  1602. let isDragging = false;
  1603. const {
  1604. ownerDocument
  1605. } = element;
  1606. /**
  1607. * Checks if an element is in the drop zone.
  1608. *
  1609. * @param {HTMLElement|null} elementToCheck
  1610. *
  1611. * @return {boolean} True if in drop zone, false if not.
  1612. */
  1613. function isElementInZone(elementToCheck) {
  1614. if (!elementToCheck || !element.contains(elementToCheck)) {
  1615. return false;
  1616. }
  1617. do {
  1618. if (elementToCheck.dataset.isDropZone) {
  1619. return elementToCheck === element;
  1620. }
  1621. } while (elementToCheck = elementToCheck.parentElement);
  1622. return false;
  1623. }
  1624. function maybeDragStart(
  1625. /** @type {DragEvent} */
  1626. event) {
  1627. if (isDragging) {
  1628. return;
  1629. }
  1630. isDragging = true;
  1631. ownerDocument.removeEventListener('dragenter', maybeDragStart); // Note that `dragend` doesn't fire consistently for file and
  1632. // HTML drag events where the drag origin is outside the browser
  1633. // window. In Firefox it may also not fire if the originating
  1634. // node is removed.
  1635. ownerDocument.addEventListener('dragend', maybeDragEnd);
  1636. ownerDocument.addEventListener('mousemove', maybeDragEnd);
  1637. if (onDragStartRef.current) {
  1638. onDragStartRef.current(event);
  1639. }
  1640. }
  1641. function onDragEnter(event) {
  1642. event.preventDefault(); // The `dragenter` event will also fire when entering child
  1643. // elements, but we only want to call `onDragEnter` when
  1644. // entering the drop zone, which means the `relatedTarget`
  1645. // (element that has been left) should be outside the drop zone.
  1646. if (element.contains(event.relatedTarget)) {
  1647. return;
  1648. }
  1649. if (onDragEnterRef.current) {
  1650. onDragEnterRef.current(event);
  1651. }
  1652. }
  1653. function onDragOver(event) {
  1654. // Only call onDragOver for the innermost hovered drop zones.
  1655. if (!event.defaultPrevented && onDragOverRef.current) {
  1656. onDragOverRef.current(event);
  1657. } // Prevent the browser default while also signalling to parent
  1658. // drop zones that `onDragOver` is already handled.
  1659. event.preventDefault();
  1660. }
  1661. function onDragLeave(event) {
  1662. // The `dragleave` event will also fire when leaving child
  1663. // elements, but we only want to call `onDragLeave` when
  1664. // leaving the drop zone, which means the `relatedTarget`
  1665. // (element that has been entered) should be outside the drop
  1666. // zone.
  1667. if (isElementInZone(event.relatedTarget)) {
  1668. return;
  1669. }
  1670. if (onDragLeaveRef.current) {
  1671. onDragLeaveRef.current(event);
  1672. }
  1673. }
  1674. function onDrop(event) {
  1675. // Don't handle drop if an inner drop zone already handled it.
  1676. if (event.defaultPrevented) {
  1677. return;
  1678. } // Prevent the browser default while also signalling to parent
  1679. // drop zones that `onDrop` is already handled.
  1680. event.preventDefault(); // This seemingly useless line has been shown to resolve a
  1681. // Safari issue where files dragged directly from the dock are
  1682. // not recognized.
  1683. // eslint-disable-next-line no-unused-expressions
  1684. event.dataTransfer && event.dataTransfer.files.length;
  1685. if (onDropRef.current) {
  1686. onDropRef.current(event);
  1687. }
  1688. maybeDragEnd(event);
  1689. }
  1690. function maybeDragEnd(event) {
  1691. if (!isDragging) {
  1692. return;
  1693. }
  1694. isDragging = false;
  1695. ownerDocument.addEventListener('dragenter', maybeDragStart);
  1696. ownerDocument.removeEventListener('dragend', maybeDragEnd);
  1697. ownerDocument.removeEventListener('mousemove', maybeDragEnd);
  1698. if (onDragEndRef.current) {
  1699. onDragEndRef.current(event);
  1700. }
  1701. }
  1702. element.dataset.isDropZone = 'true';
  1703. element.addEventListener('drop', onDrop);
  1704. element.addEventListener('dragenter', onDragEnter);
  1705. element.addEventListener('dragover', onDragOver);
  1706. element.addEventListener('dragleave', onDragLeave); // The `dragstart` event doesn't fire if the drag started outside
  1707. // the document.
  1708. ownerDocument.addEventListener('dragenter', maybeDragStart);
  1709. return () => {
  1710. delete element.dataset.isDropZone;
  1711. element.removeEventListener('drop', onDrop);
  1712. element.removeEventListener('dragenter', onDragEnter);
  1713. element.removeEventListener('dragover', onDragOver);
  1714. element.removeEventListener('dragleave', onDragLeave);
  1715. ownerDocument.removeEventListener('dragend', maybeDragEnd);
  1716. ownerDocument.removeEventListener('mousemove', maybeDragEnd);
  1717. ownerDocument.addEventListener('dragenter', maybeDragStart);
  1718. };
  1719. }, [isDisabled]);
  1720. }
  1721. // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/index.js
  1722. // Utils
  1723. // Compose helper (aliased flowRight from Lodash)
  1724. // Higher-order components
  1725. // Hooks
  1726. /***/ }),
  1727. /***/ "RxS6":
  1728. /***/ (function(module, exports) {
  1729. (function() { module.exports = window["wp"]["keycodes"]; }());
  1730. /***/ }),
  1731. /***/ "SSiF":
  1732. /***/ (function(module, exports, __webpack_require__) {
  1733. var e=__webpack_require__("cDcd"),n={display:"block",opacity:0,position:"absolute",top:0,left:0,height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",zIndex:-1},t=function(t){var r=t.onResize,u=e.useRef();return function(n,t){var r=function(){return n.current&&n.current.contentDocument&&n.current.contentDocument.defaultView};function u(){t();var e=r();e&&e.addEventListener("resize",t)}e.useEffect((function(){return r()?u():n.current&&n.current.addEventListener&&n.current.addEventListener("load",u),function(){var e=r();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("resize",t)}}),[])}(u,(function(){return r(u)})),e.createElement("iframe",{style:n,src:"about:blank",ref:u,"aria-hidden":!0,tabIndex:-1,frameBorder:0})},r=function(e){return{width:null!=e?e.offsetWidth:null,height:null!=e?e.offsetHeight:null}};module.exports=function(n){void 0===n&&(n=r);var u=e.useState(n(null)),o=u[0],i=u[1],c=e.useCallback((function(e){return i(n(e.current))}),[n]);return[e.useMemo((function(){return e.createElement(t,{onResize:c})}),[c]),o]};
  1734. /***/ }),
  1735. /***/ "VcSt":
  1736. /***/ (function(module, exports) {
  1737. /**
  1738. * adds a bindGlobal method to Mousetrap that allows you to
  1739. * bind specific keyboard shortcuts that will still work
  1740. * inside a text input field
  1741. *
  1742. * usage:
  1743. * Mousetrap.bindGlobal('ctrl+s', _saveChanges);
  1744. */
  1745. /* global Mousetrap:true */
  1746. (function(Mousetrap) {
  1747. if (! Mousetrap) {
  1748. return;
  1749. }
  1750. var _globalCallbacks = {};
  1751. var _originalStopCallback = Mousetrap.prototype.stopCallback;
  1752. Mousetrap.prototype.stopCallback = function(e, element, combo, sequence) {
  1753. var self = this;
  1754. if (self.paused) {
  1755. return true;
  1756. }
  1757. if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
  1758. return false;
  1759. }
  1760. return _originalStopCallback.call(self, e, element, combo);
  1761. };
  1762. Mousetrap.prototype.bindGlobal = function(keys, callback, action) {
  1763. var self = this;
  1764. self.bind(keys, callback, action);
  1765. if (keys instanceof Array) {
  1766. for (var i = 0; i < keys.length; i++) {
  1767. _globalCallbacks[keys[i]] = true;
  1768. }
  1769. return;
  1770. }
  1771. _globalCallbacks[keys] = true;
  1772. };
  1773. Mousetrap.init();
  1774. }) (typeof Mousetrap !== "undefined" ? Mousetrap : undefined);
  1775. /***/ }),
  1776. /***/ "XI5e":
  1777. /***/ (function(module, exports) {
  1778. (function() { module.exports = window["wp"]["priorityQueue"]; }());
  1779. /***/ }),
  1780. /***/ "YLtl":
  1781. /***/ (function(module, exports) {
  1782. (function() { module.exports = window["lodash"]; }());
  1783. /***/ }),
  1784. /***/ "cDcd":
  1785. /***/ (function(module, exports) {
  1786. (function() { module.exports = window["React"]; }());
  1787. /***/ }),
  1788. /***/ "imBb":
  1789. /***/ (function(module, exports, __webpack_require__) {
  1790. var __WEBPACK_AMD_DEFINE_RESULT__;/*global define:false */
  1791. /**
  1792. * Copyright 2012-2017 Craig Campbell
  1793. *
  1794. * Licensed under the Apache License, Version 2.0 (the "License");
  1795. * you may not use this file except in compliance with the License.
  1796. * You may obtain a copy of the License at
  1797. *
  1798. * http://www.apache.org/licenses/LICENSE-2.0
  1799. *
  1800. * Unless required by applicable law or agreed to in writing, software
  1801. * distributed under the License is distributed on an "AS IS" BASIS,
  1802. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1803. * See the License for the specific language governing permissions and
  1804. * limitations under the License.
  1805. *
  1806. * Mousetrap is a simple keyboard shortcut library for Javascript with
  1807. * no external dependencies
  1808. *
  1809. * @version 1.6.5
  1810. * @url craig.is/killing/mice
  1811. */
  1812. (function(window, document, undefined) {
  1813. // Check if mousetrap is used inside browser, if not, return
  1814. if (!window) {
  1815. return;
  1816. }
  1817. /**
  1818. * mapping of special keycodes to their corresponding keys
  1819. *
  1820. * everything in this dictionary cannot use keypress events
  1821. * so it has to be here to map to the correct keycodes for
  1822. * keyup/keydown events
  1823. *
  1824. * @type {Object}
  1825. */
  1826. var _MAP = {
  1827. 8: 'backspace',
  1828. 9: 'tab',
  1829. 13: 'enter',
  1830. 16: 'shift',
  1831. 17: 'ctrl',
  1832. 18: 'alt',
  1833. 20: 'capslock',
  1834. 27: 'esc',
  1835. 32: 'space',
  1836. 33: 'pageup',
  1837. 34: 'pagedown',
  1838. 35: 'end',
  1839. 36: 'home',
  1840. 37: 'left',
  1841. 38: 'up',
  1842. 39: 'right',
  1843. 40: 'down',
  1844. 45: 'ins',
  1845. 46: 'del',
  1846. 91: 'meta',
  1847. 93: 'meta',
  1848. 224: 'meta'
  1849. };
  1850. /**
  1851. * mapping for special characters so they can support
  1852. *
  1853. * this dictionary is only used incase you want to bind a
  1854. * keyup or keydown event to one of these keys
  1855. *
  1856. * @type {Object}
  1857. */
  1858. var _KEYCODE_MAP = {
  1859. 106: '*',
  1860. 107: '+',
  1861. 109: '-',
  1862. 110: '.',
  1863. 111 : '/',
  1864. 186: ';',
  1865. 187: '=',
  1866. 188: ',',
  1867. 189: '-',
  1868. 190: '.',
  1869. 191: '/',
  1870. 192: '`',
  1871. 219: '[',
  1872. 220: '\\',
  1873. 221: ']',
  1874. 222: '\''
  1875. };
  1876. /**
  1877. * this is a mapping of keys that require shift on a US keypad
  1878. * back to the non shift equivelents
  1879. *
  1880. * this is so you can use keyup events with these keys
  1881. *
  1882. * note that this will only work reliably on US keyboards
  1883. *
  1884. * @type {Object}
  1885. */
  1886. var _SHIFT_MAP = {
  1887. '~': '`',
  1888. '!': '1',
  1889. '@': '2',
  1890. '#': '3',
  1891. '$': '4',
  1892. '%': '5',
  1893. '^': '6',
  1894. '&': '7',
  1895. '*': '8',
  1896. '(': '9',
  1897. ')': '0',
  1898. '_': '-',
  1899. '+': '=',
  1900. ':': ';',
  1901. '\"': '\'',
  1902. '<': ',',
  1903. '>': '.',
  1904. '?': '/',
  1905. '|': '\\'
  1906. };
  1907. /**
  1908. * this is a list of special strings you can use to map
  1909. * to modifier keys when you specify your keyboard shortcuts
  1910. *
  1911. * @type {Object}
  1912. */
  1913. var _SPECIAL_ALIASES = {
  1914. 'option': 'alt',
  1915. 'command': 'meta',
  1916. 'return': 'enter',
  1917. 'escape': 'esc',
  1918. 'plus': '+',
  1919. 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
  1920. };
  1921. /**
  1922. * variable to store the flipped version of _MAP from above
  1923. * needed to check if we should use keypress or not when no action
  1924. * is specified
  1925. *
  1926. * @type {Object|undefined}
  1927. */
  1928. var _REVERSE_MAP;
  1929. /**
  1930. * loop through the f keys, f1 to f19 and add them to the map
  1931. * programatically
  1932. */
  1933. for (var i = 1; i < 20; ++i) {
  1934. _MAP[111 + i] = 'f' + i;
  1935. }
  1936. /**
  1937. * loop through to map numbers on the numeric keypad
  1938. */
  1939. for (i = 0; i <= 9; ++i) {
  1940. // This needs to use a string cause otherwise since 0 is falsey
  1941. // mousetrap will never fire for numpad 0 pressed as part of a keydown
  1942. // event.
  1943. //
  1944. // @see https://github.com/ccampbell/mousetrap/pull/258
  1945. _MAP[i + 96] = i.toString();
  1946. }
  1947. /**
  1948. * cross browser add event method
  1949. *
  1950. * @param {Element|HTMLDocument} object
  1951. * @param {string} type
  1952. * @param {Function} callback
  1953. * @returns void
  1954. */
  1955. function _addEvent(object, type, callback) {
  1956. if (object.addEventListener) {
  1957. object.addEventListener(type, callback, false);
  1958. return;
  1959. }
  1960. object.attachEvent('on' + type, callback);
  1961. }
  1962. /**
  1963. * takes the event and returns the key character
  1964. *
  1965. * @param {Event} e
  1966. * @return {string}
  1967. */
  1968. function _characterFromEvent(e) {
  1969. // for keypress events we should return the character as is
  1970. if (e.type == 'keypress') {
  1971. var character = String.fromCharCode(e.which);
  1972. // if the shift key is not pressed then it is safe to assume
  1973. // that we want the character to be lowercase. this means if
  1974. // you accidentally have caps lock on then your key bindings
  1975. // will continue to work
  1976. //
  1977. // the only side effect that might not be desired is if you
  1978. // bind something like 'A' cause you want to trigger an
  1979. // event when capital A is pressed caps lock will no longer
  1980. // trigger the event. shift+a will though.
  1981. if (!e.shiftKey) {
  1982. character = character.toLowerCase();
  1983. }
  1984. return character;
  1985. }
  1986. // for non keypress events the special maps are needed
  1987. if (_MAP[e.which]) {
  1988. return _MAP[e.which];
  1989. }
  1990. if (_KEYCODE_MAP[e.which]) {
  1991. return _KEYCODE_MAP[e.which];
  1992. }
  1993. // if it is not in the special map
  1994. // with keydown and keyup events the character seems to always
  1995. // come in as an uppercase character whether you are pressing shift
  1996. // or not. we should make sure it is always lowercase for comparisons
  1997. return String.fromCharCode(e.which).toLowerCase();
  1998. }
  1999. /**
  2000. * checks if two arrays are equal
  2001. *
  2002. * @param {Array} modifiers1
  2003. * @param {Array} modifiers2
  2004. * @returns {boolean}
  2005. */
  2006. function _modifiersMatch(modifiers1, modifiers2) {
  2007. return modifiers1.sort().join(',') === modifiers2.sort().join(',');
  2008. }
  2009. /**
  2010. * takes a key event and figures out what the modifiers are
  2011. *
  2012. * @param {Event} e
  2013. * @returns {Array}
  2014. */
  2015. function _eventModifiers(e) {
  2016. var modifiers = [];
  2017. if (e.shiftKey) {
  2018. modifiers.push('shift');
  2019. }
  2020. if (e.altKey) {
  2021. modifiers.push('alt');
  2022. }
  2023. if (e.ctrlKey) {
  2024. modifiers.push('ctrl');
  2025. }
  2026. if (e.metaKey) {
  2027. modifiers.push('meta');
  2028. }
  2029. return modifiers;
  2030. }
  2031. /**
  2032. * prevents default for this event
  2033. *
  2034. * @param {Event} e
  2035. * @returns void
  2036. */
  2037. function _preventDefault(e) {
  2038. if (e.preventDefault) {
  2039. e.preventDefault();
  2040. return;
  2041. }
  2042. e.returnValue = false;
  2043. }
  2044. /**
  2045. * stops propogation for this event
  2046. *
  2047. * @param {Event} e
  2048. * @returns void
  2049. */
  2050. function _stopPropagation(e) {
  2051. if (e.stopPropagation) {
  2052. e.stopPropagation();
  2053. return;
  2054. }
  2055. e.cancelBubble = true;
  2056. }
  2057. /**
  2058. * determines if the keycode specified is a modifier key or not
  2059. *
  2060. * @param {string} key
  2061. * @returns {boolean}
  2062. */
  2063. function _isModifier(key) {
  2064. return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';
  2065. }
  2066. /**
  2067. * reverses the map lookup so that we can look for specific keys
  2068. * to see what can and can't use keypress
  2069. *
  2070. * @return {Object}
  2071. */
  2072. function _getReverseMap() {
  2073. if (!_REVERSE_MAP) {
  2074. _REVERSE_MAP = {};
  2075. for (var key in _MAP) {
  2076. // pull out the numeric keypad from here cause keypress should
  2077. // be able to detect the keys from the character
  2078. if (key > 95 && key < 112) {
  2079. continue;
  2080. }
  2081. if (_MAP.hasOwnProperty(key)) {
  2082. _REVERSE_MAP[_MAP[key]] = key;
  2083. }
  2084. }
  2085. }
  2086. return _REVERSE_MAP;
  2087. }
  2088. /**
  2089. * picks the best action based on the key combination
  2090. *
  2091. * @param {string} key - character for key
  2092. * @param {Array} modifiers
  2093. * @param {string=} action passed in
  2094. */
  2095. function _pickBestAction(key, modifiers, action) {
  2096. // if no action was picked in we should try to pick the one
  2097. // that we think would work best for this key
  2098. if (!action) {
  2099. action = _getReverseMap()[key] ? 'keydown' : 'keypress';
  2100. }
  2101. // modifier keys don't work as expected with keypress,
  2102. // switch to keydown
  2103. if (action == 'keypress' && modifiers.length) {
  2104. action = 'keydown';
  2105. }
  2106. return action;
  2107. }
  2108. /**
  2109. * Converts from a string key combination to an array
  2110. *
  2111. * @param {string} combination like "command+shift+l"
  2112. * @return {Array}
  2113. */
  2114. function _keysFromString(combination) {
  2115. if (combination === '+') {
  2116. return ['+'];
  2117. }
  2118. combination = combination.replace(/\+{2}/g, '+plus');
  2119. return combination.split('+');
  2120. }
  2121. /**
  2122. * Gets info for a specific key combination
  2123. *
  2124. * @param {string} combination key combination ("command+s" or "a" or "*")
  2125. * @param {string=} action
  2126. * @returns {Object}
  2127. */
  2128. function _getKeyInfo(combination, action) {
  2129. var keys;
  2130. var key;
  2131. var i;
  2132. var modifiers = [];
  2133. // take the keys from this pattern and figure out what the actual
  2134. // pattern is all about
  2135. keys = _keysFromString(combination);
  2136. for (i = 0; i < keys.length; ++i) {
  2137. key = keys[i];
  2138. // normalize key names
  2139. if (_SPECIAL_ALIASES[key]) {
  2140. key = _SPECIAL_ALIASES[key];
  2141. }
  2142. // if this is not a keypress event then we should
  2143. // be smart about using shift keys
  2144. // this will only work for US keyboards however
  2145. if (action && action != 'keypress' && _SHIFT_MAP[key]) {
  2146. key = _SHIFT_MAP[key];
  2147. modifiers.push('shift');
  2148. }
  2149. // if this key is a modifier then add it to the list of modifiers
  2150. if (_isModifier(key)) {
  2151. modifiers.push(key);
  2152. }
  2153. }
  2154. // depending on what the key combination is
  2155. // we will try to pick the best event for it
  2156. action = _pickBestAction(key, modifiers, action);
  2157. return {
  2158. key: key,
  2159. modifiers: modifiers,
  2160. action: action
  2161. };
  2162. }
  2163. function _belongsTo(element, ancestor) {
  2164. if (element === null || element === document) {
  2165. return false;
  2166. }
  2167. if (element === ancestor) {
  2168. return true;
  2169. }
  2170. return _belongsTo(element.parentNode, ancestor);
  2171. }
  2172. function Mousetrap(targetElement) {
  2173. var self = this;
  2174. targetElement = targetElement || document;
  2175. if (!(self instanceof Mousetrap)) {
  2176. return new Mousetrap(targetElement);
  2177. }
  2178. /**
  2179. * element to attach key events to
  2180. *
  2181. * @type {Element}
  2182. */
  2183. self.target = targetElement;
  2184. /**
  2185. * a list of all the callbacks setup via Mousetrap.bind()
  2186. *
  2187. * @type {Object}
  2188. */
  2189. self._callbacks = {};
  2190. /**
  2191. * direct map of string combinations to callbacks used for trigger()
  2192. *
  2193. * @type {Object}
  2194. */
  2195. self._directMap = {};
  2196. /**
  2197. * keeps track of what level each sequence is at since multiple
  2198. * sequences can start out with the same sequence
  2199. *
  2200. * @type {Object}
  2201. */
  2202. var _sequenceLevels = {};
  2203. /**
  2204. * variable to store the setTimeout call
  2205. *
  2206. * @type {null|number}
  2207. */
  2208. var _resetTimer;
  2209. /**
  2210. * temporary state where we will ignore the next keyup
  2211. *
  2212. * @type {boolean|string}
  2213. */
  2214. var _ignoreNextKeyup = false;
  2215. /**
  2216. * temporary state where we will ignore the next keypress
  2217. *
  2218. * @type {boolean}
  2219. */
  2220. var _ignoreNextKeypress = false;
  2221. /**
  2222. * are we currently inside of a sequence?
  2223. * type of action ("keyup" or "keydown" or "keypress") or false
  2224. *
  2225. * @type {boolean|string}
  2226. */
  2227. var _nextExpectedAction = false;
  2228. /**
  2229. * resets all sequence counters except for the ones passed in
  2230. *
  2231. * @param {Object} doNotReset
  2232. * @returns void
  2233. */
  2234. function _resetSequences(doNotReset) {
  2235. doNotReset = doNotReset || {};
  2236. var activeSequences = false,
  2237. key;
  2238. for (key in _sequenceLevels) {
  2239. if (doNotReset[key]) {
  2240. activeSequences = true;
  2241. continue;
  2242. }
  2243. _sequenceLevels[key] = 0;
  2244. }
  2245. if (!activeSequences) {
  2246. _nextExpectedAction = false;
  2247. }
  2248. }
  2249. /**
  2250. * finds all callbacks that match based on the keycode, modifiers,
  2251. * and action
  2252. *
  2253. * @param {string} character
  2254. * @param {Array} modifiers
  2255. * @param {Event|Object} e
  2256. * @param {string=} sequenceName - name of the sequence we are looking for
  2257. * @param {string=} combination
  2258. * @param {number=} level
  2259. * @returns {Array}
  2260. */
  2261. function _getMatches(character, modifiers, e, sequenceName, combination, level) {
  2262. var i;
  2263. var callback;
  2264. var matches = [];
  2265. var action = e.type;
  2266. // if there are no events related to this keycode
  2267. if (!self._callbacks[character]) {
  2268. return [];
  2269. }
  2270. // if a modifier key is coming up on its own we should allow it
  2271. if (action == 'keyup' && _isModifier(character)) {
  2272. modifiers = [character];
  2273. }
  2274. // loop through all callbacks for the key that was pressed
  2275. // and see if any of them match
  2276. for (i = 0; i < self._callbacks[character].length; ++i) {
  2277. callback = self._callbacks[character][i];
  2278. // if a sequence name is not specified, but this is a sequence at
  2279. // the wrong level then move onto the next match
  2280. if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
  2281. continue;
  2282. }
  2283. // if the action we are looking for doesn't match the action we got
  2284. // then we should keep going
  2285. if (action != callback.action) {
  2286. continue;
  2287. }
  2288. // if this is a keypress event and the meta key and control key
  2289. // are not pressed that means that we need to only look at the
  2290. // character, otherwise check the modifiers as well
  2291. //
  2292. // chrome will not fire a keypress if meta or control is down
  2293. // safari will fire a keypress if meta or meta+shift is down
  2294. // firefox will fire a keypress if meta or control is down
  2295. if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {
  2296. // when you bind a combination or sequence a second time it
  2297. // should overwrite the first one. if a sequenceName or
  2298. // combination is specified in this call it does just that
  2299. //
  2300. // @todo make deleting its own method?
  2301. var deleteCombo = !sequenceName && callback.combo == combination;
  2302. var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
  2303. if (deleteCombo || deleteSequence) {
  2304. self._callbacks[character].splice(i, 1);
  2305. }
  2306. matches.push(callback);
  2307. }
  2308. }
  2309. return matches;
  2310. }
  2311. /**
  2312. * actually calls the callback function
  2313. *
  2314. * if your callback function returns false this will use the jquery
  2315. * convention - prevent default and stop propogation on the event
  2316. *
  2317. * @param {Function} callback
  2318. * @param {Event} e
  2319. * @returns void
  2320. */
  2321. function _fireCallback(callback, e, combo, sequence) {
  2322. // if this event should not happen stop here
  2323. if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
  2324. return;
  2325. }
  2326. if (callback(e, combo) === false) {
  2327. _preventDefault(e);
  2328. _stopPropagation(e);
  2329. }
  2330. }
  2331. /**
  2332. * handles a character key event
  2333. *
  2334. * @param {string} character
  2335. * @param {Array} modifiers
  2336. * @param {Event} e
  2337. * @returns void
  2338. */
  2339. self._handleKey = function(character, modifiers, e) {
  2340. var callbacks = _getMatches(character, modifiers, e);
  2341. var i;
  2342. var doNotReset = {};
  2343. var maxLevel = 0;
  2344. var processedSequenceCallback = false;
  2345. // Calculate the maxLevel for sequences so we can only execute the longest callback sequence
  2346. for (i = 0; i < callbacks.length; ++i) {
  2347. if (callbacks[i].seq) {
  2348. maxLevel = Math.max(maxLevel, callbacks[i].level);
  2349. }
  2350. }
  2351. // loop through matching callbacks for this key event
  2352. for (i = 0; i < callbacks.length; ++i) {
  2353. // fire for all sequence callbacks
  2354. // this is because if for example you have multiple sequences
  2355. // bound such as "g i" and "g t" they both need to fire the
  2356. // callback for matching g cause otherwise you can only ever
  2357. // match the first one
  2358. if (callbacks[i].seq) {
  2359. // only fire callbacks for the maxLevel to prevent
  2360. // subsequences from also firing
  2361. //
  2362. // for example 'a option b' should not cause 'option b' to fire
  2363. // even though 'option b' is part of the other sequence
  2364. //
  2365. // any sequences that do not match here will be discarded
  2366. // below by the _resetSequences call
  2367. if (callbacks[i].level != maxLevel) {
  2368. continue;
  2369. }
  2370. processedSequenceCallback = true;
  2371. // keep a list of which sequences were matches for later
  2372. doNotReset[callbacks[i].seq] = 1;
  2373. _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);
  2374. continue;
  2375. }
  2376. // if there were no sequence matches but we are still here
  2377. // that means this is a regular match so we should fire that
  2378. if (!processedSequenceCallback) {
  2379. _fireCallback(callbacks[i].callback, e, callbacks[i].combo);
  2380. }
  2381. }
  2382. // if the key you pressed matches the type of sequence without
  2383. // being a modifier (ie "keyup" or "keypress") then we should
  2384. // reset all sequences that were not matched by this event
  2385. //
  2386. // this is so, for example, if you have the sequence "h a t" and you
  2387. // type "h e a r t" it does not match. in this case the "e" will
  2388. // cause the sequence to reset
  2389. //
  2390. // modifier keys are ignored because you can have a sequence
  2391. // that contains modifiers such as "enter ctrl+space" and in most
  2392. // cases the modifier key will be pressed before the next key
  2393. //
  2394. // also if you have a sequence such as "ctrl+b a" then pressing the
  2395. // "b" key will trigger a "keypress" and a "keydown"
  2396. //
  2397. // the "keydown" is expected when there is a modifier, but the
  2398. // "keypress" ends up matching the _nextExpectedAction since it occurs
  2399. // after and that causes the sequence to reset
  2400. //
  2401. // we ignore keypresses in a sequence that directly follow a keydown
  2402. // for the same character
  2403. var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
  2404. if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
  2405. _resetSequences(doNotReset);
  2406. }
  2407. _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
  2408. };
  2409. /**
  2410. * handles a keydown event
  2411. *
  2412. * @param {Event} e
  2413. * @returns void
  2414. */
  2415. function _handleKeyEvent(e) {
  2416. // normalize e.which for key events
  2417. // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
  2418. if (typeof e.which !== 'number') {
  2419. e.which = e.keyCode;
  2420. }
  2421. var character = _characterFromEvent(e);
  2422. // no character found then stop
  2423. if (!character) {
  2424. return;
  2425. }
  2426. // need to use === for the character check because the character can be 0
  2427. if (e.type == 'keyup' && _ignoreNextKeyup === character) {
  2428. _ignoreNextKeyup = false;
  2429. return;
  2430. }
  2431. self.handleKey(character, _eventModifiers(e), e);
  2432. }
  2433. /**
  2434. * called to set a 1 second timeout on the specified sequence
  2435. *
  2436. * this is so after each key press in the sequence you have 1 second
  2437. * to press the next key before you have to start over
  2438. *
  2439. * @returns void
  2440. */
  2441. function _resetSequenceTimer() {
  2442. clearTimeout(_resetTimer);
  2443. _resetTimer = setTimeout(_resetSequences, 1000);
  2444. }
  2445. /**
  2446. * binds a key sequence to an event
  2447. *
  2448. * @param {string} combo - combo specified in bind call
  2449. * @param {Array} keys
  2450. * @param {Function} callback
  2451. * @param {string=} action
  2452. * @returns void
  2453. */
  2454. function _bindSequence(combo, keys, callback, action) {
  2455. // start off by adding a sequence level record for this combination
  2456. // and setting the level to 0
  2457. _sequenceLevels[combo] = 0;
  2458. /**
  2459. * callback to increase the sequence level for this sequence and reset
  2460. * all other sequences that were active
  2461. *
  2462. * @param {string} nextAction
  2463. * @returns {Function}
  2464. */
  2465. function _increaseSequence(nextAction) {
  2466. return function() {
  2467. _nextExpectedAction = nextAction;
  2468. ++_sequenceLevels[combo];
  2469. _resetSequenceTimer();
  2470. };
  2471. }
  2472. /**
  2473. * wraps the specified callback inside of another function in order
  2474. * to reset all sequence counters as soon as this sequence is done
  2475. *
  2476. * @param {Event} e
  2477. * @returns void
  2478. */
  2479. function _callbackAndReset(e) {
  2480. _fireCallback(callback, e, combo);
  2481. // we should ignore the next key up if the action is key down
  2482. // or keypress. this is so if you finish a sequence and
  2483. // release the key the final key will not trigger a keyup
  2484. if (action !== 'keyup') {
  2485. _ignoreNextKeyup = _characterFromEvent(e);
  2486. }
  2487. // weird race condition if a sequence ends with the key
  2488. // another sequence begins with
  2489. setTimeout(_resetSequences, 10);
  2490. }
  2491. // loop through keys one at a time and bind the appropriate callback
  2492. // function. for any key leading up to the final one it should
  2493. // increase the sequence. after the final, it should reset all sequences
  2494. //
  2495. // if an action is specified in the original bind call then that will
  2496. // be used throughout. otherwise we will pass the action that the
  2497. // next key in the sequence should match. this allows a sequence
  2498. // to mix and match keypress and keydown events depending on which
  2499. // ones are better suited to the key provided
  2500. for (var i = 0; i < keys.length; ++i) {
  2501. var isFinal = i + 1 === keys.length;
  2502. var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action);
  2503. _bindSingle(keys[i], wrappedCallback, action, combo, i);
  2504. }
  2505. }
  2506. /**
  2507. * binds a single keyboard combination
  2508. *
  2509. * @param {string} combination
  2510. * @param {Function} callback
  2511. * @param {string=} action
  2512. * @param {string=} sequenceName - name of sequence if part of sequence
  2513. * @param {number=} level - what part of the sequence the command is
  2514. * @returns void
  2515. */
  2516. function _bindSingle(combination, callback, action, sequenceName, level) {
  2517. // store a direct mapped reference for use with Mousetrap.trigger
  2518. self._directMap[combination + ':' + action] = callback;
  2519. // make sure multiple spaces in a row become a single space
  2520. combination = combination.replace(/\s+/g, ' ');
  2521. var sequence = combination.split(' ');
  2522. var info;
  2523. // if this pattern is a sequence of keys then run through this method
  2524. // to reprocess each pattern one key at a time
  2525. if (sequence.length > 1) {
  2526. _bindSequence(combination, sequence, callback, action);
  2527. return;
  2528. }
  2529. info = _getKeyInfo(combination, action);
  2530. // make sure to initialize array if this is the first time
  2531. // a callback is added for this key
  2532. self._callbacks[info.key] = self._callbacks[info.key] || [];
  2533. // remove an existing match if there is one
  2534. _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);
  2535. // add this call back to the array
  2536. // if it is a sequence put it at the beginning
  2537. // if not put it at the end
  2538. //
  2539. // this is important because the way these are processed expects
  2540. // the sequence ones to come first
  2541. self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({
  2542. callback: callback,
  2543. modifiers: info.modifiers,
  2544. action: info.action,
  2545. seq: sequenceName,
  2546. level: level,
  2547. combo: combination
  2548. });
  2549. }
  2550. /**
  2551. * binds multiple combinations to the same callback
  2552. *
  2553. * @param {Array} combinations
  2554. * @param {Function} callback
  2555. * @param {string|undefined} action
  2556. * @returns void
  2557. */
  2558. self._bindMultiple = function(combinations, callback, action) {
  2559. for (var i = 0; i < combinations.length; ++i) {
  2560. _bindSingle(combinations[i], callback, action);
  2561. }
  2562. };
  2563. // start!
  2564. _addEvent(targetElement, 'keypress', _handleKeyEvent);
  2565. _addEvent(targetElement, 'keydown', _handleKeyEvent);
  2566. _addEvent(targetElement, 'keyup', _handleKeyEvent);
  2567. }
  2568. /**
  2569. * binds an event to mousetrap
  2570. *
  2571. * can be a single key, a combination of keys separated with +,
  2572. * an array of keys, or a sequence of keys separated by spaces
  2573. *
  2574. * be sure to list the modifier keys first to make sure that the
  2575. * correct key ends up getting bound (the last key in the pattern)
  2576. *
  2577. * @param {string|Array} keys
  2578. * @param {Function} callback
  2579. * @param {string=} action - 'keypress', 'keydown', or 'keyup'
  2580. * @returns void
  2581. */
  2582. Mousetrap.prototype.bind = function(keys, callback, action) {
  2583. var self = this;
  2584. keys = keys instanceof Array ? keys : [keys];
  2585. self._bindMultiple.call(self, keys, callback, action);
  2586. return self;
  2587. };
  2588. /**
  2589. * unbinds an event to mousetrap
  2590. *
  2591. * the unbinding sets the callback function of the specified key combo
  2592. * to an empty function and deletes the corresponding key in the
  2593. * _directMap dict.
  2594. *
  2595. * TODO: actually remove this from the _callbacks dictionary instead
  2596. * of binding an empty function
  2597. *
  2598. * the keycombo+action has to be exactly the same as
  2599. * it was defined in the bind method
  2600. *
  2601. * @param {string|Array} keys
  2602. * @param {string} action
  2603. * @returns void
  2604. */
  2605. Mousetrap.prototype.unbind = function(keys, action) {
  2606. var self = this;
  2607. return self.bind.call(self, keys, function() {}, action);
  2608. };
  2609. /**
  2610. * triggers an event that has already been bound
  2611. *
  2612. * @param {string} keys
  2613. * @param {string=} action
  2614. * @returns void
  2615. */
  2616. Mousetrap.prototype.trigger = function(keys, action) {
  2617. var self = this;
  2618. if (self._directMap[keys + ':' + action]) {
  2619. self._directMap[keys + ':' + action]({}, keys);
  2620. }
  2621. return self;
  2622. };
  2623. /**
  2624. * resets the library back to its initial state. this is useful
  2625. * if you want to clear out the current keyboard shortcuts and bind
  2626. * new ones - for example if you switch to another page
  2627. *
  2628. * @returns void
  2629. */
  2630. Mousetrap.prototype.reset = function() {
  2631. var self = this;
  2632. self._callbacks = {};
  2633. self._directMap = {};
  2634. return self;
  2635. };
  2636. /**
  2637. * should we stop this event before firing off callbacks
  2638. *
  2639. * @param {Event} e
  2640. * @param {Element} element
  2641. * @return {boolean}
  2642. */
  2643. Mousetrap.prototype.stopCallback = function(e, element) {
  2644. var self = this;
  2645. // if the element has the class "mousetrap" then no need to stop
  2646. if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
  2647. return false;
  2648. }
  2649. if (_belongsTo(element, self.target)) {
  2650. return false;
  2651. }
  2652. // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host,
  2653. // not the initial event target in the shadow tree. Note that not all events cross the
  2654. // shadow boundary.
  2655. // For shadow trees with `mode: 'open'`, the initial event target is the first element in
  2656. // the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event
  2657. // target cannot be obtained.
  2658. if ('composedPath' in e && typeof e.composedPath === 'function') {
  2659. // For open shadow trees, update `element` so that the following check works.
  2660. var initialEventTarget = e.composedPath()[0];
  2661. if (initialEventTarget !== e.target) {
  2662. element = initialEventTarget;
  2663. }
  2664. }
  2665. // stop for input, select, and textarea
  2666. return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
  2667. };
  2668. /**
  2669. * exposes _handleKey publicly so it can be overwritten by extensions
  2670. */
  2671. Mousetrap.prototype.handleKey = function() {
  2672. var self = this;
  2673. return self._handleKey.apply(self, arguments);
  2674. };
  2675. /**
  2676. * allow custom key mappings
  2677. */
  2678. Mousetrap.addKeycodes = function(object) {
  2679. for (var key in object) {
  2680. if (object.hasOwnProperty(key)) {
  2681. _MAP[key] = object[key];
  2682. }
  2683. }
  2684. _REVERSE_MAP = null;
  2685. };
  2686. /**
  2687. * Init the global mousetrap functions
  2688. *
  2689. * This method is needed to allow the global mousetrap functions to work
  2690. * now that mousetrap is a constructor function.
  2691. */
  2692. Mousetrap.init = function() {
  2693. var documentMousetrap = Mousetrap(document);
  2694. for (var method in documentMousetrap) {
  2695. if (method.charAt(0) !== '_') {
  2696. Mousetrap[method] = (function(method) {
  2697. return function() {
  2698. return documentMousetrap[method].apply(documentMousetrap, arguments);
  2699. };
  2700. } (method));
  2701. }
  2702. }
  2703. };
  2704. Mousetrap.init();
  2705. // expose mousetrap to the global object
  2706. window.Mousetrap = Mousetrap;
  2707. // expose as a common js module
  2708. if ( true && module.exports) {
  2709. module.exports = Mousetrap;
  2710. }
  2711. // expose mousetrap as an AMD module
  2712. if (true) {
  2713. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  2714. return Mousetrap;
  2715. }).call(exports, __webpack_require__, exports, module),
  2716. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  2717. }
  2718. }) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null);
  2719. /***/ }),
  2720. /***/ "mHlH":
  2721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2722. "use strict";
  2723. /* unused harmony export useCallback */
  2724. /* unused harmony export useCallbackOne */
  2725. /* unused harmony export useMemo */
  2726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return useMemoOne; });
  2727. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("cDcd");
  2728. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  2729. function areInputsEqual(newInputs, lastInputs) {
  2730. if (newInputs.length !== lastInputs.length) {
  2731. return false;
  2732. }
  2733. for (var i = 0; i < newInputs.length; i++) {
  2734. if (newInputs[i] !== lastInputs[i]) {
  2735. return false;
  2736. }
  2737. }
  2738. return true;
  2739. }
  2740. function useMemoOne(getResult, inputs) {
  2741. var initial = Object(react__WEBPACK_IMPORTED_MODULE_0__["useState"])(function () {
  2742. return {
  2743. inputs: inputs,
  2744. result: getResult()
  2745. };
  2746. })[0];
  2747. var isFirstRun = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(true);
  2748. var committed = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(initial);
  2749. var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));
  2750. var cache = useCache ? committed.current : {
  2751. inputs: inputs,
  2752. result: getResult()
  2753. };
  2754. Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () {
  2755. isFirstRun.current = false;
  2756. committed.current = cache;
  2757. }, [cache]);
  2758. return cache.result;
  2759. }
  2760. function useCallbackOne(callback, inputs) {
  2761. return useMemoOne(function () {
  2762. return callback;
  2763. }, inputs);
  2764. }
  2765. var useMemo = useMemoOne;
  2766. var useCallback = useCallbackOne;
  2767. /***/ }),
  2768. /***/ "rl8x":
  2769. /***/ (function(module, exports) {
  2770. (function() { module.exports = window["wp"]["isShallowEqual"]; }());
  2771. /***/ }),
  2772. /***/ "sxGJ":
  2773. /***/ (function(module, exports, __webpack_require__) {
  2774. /*!
  2775. * clipboard.js v2.0.8
  2776. * https://clipboardjs.com/
  2777. *
  2778. * Licensed MIT © Zeno Rocha
  2779. */
  2780. (function webpackUniversalModuleDefinition(root, factory) {
  2781. if(true)
  2782. module.exports = factory();
  2783. else {}
  2784. })(this, function() {
  2785. return /******/ (function() { // webpackBootstrap
  2786. /******/ var __webpack_modules__ = ({
  2787. /***/ 134:
  2788. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2789. "use strict";
  2790. // EXPORTS
  2791. __webpack_require__.d(__webpack_exports__, {
  2792. "default": function() { return /* binding */ clipboard; }
  2793. });
  2794. // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js
  2795. var tiny_emitter = __webpack_require__(279);
  2796. var tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter);
  2797. // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js
  2798. var listen = __webpack_require__(370);
  2799. var listen_default = /*#__PURE__*/__webpack_require__.n(listen);
  2800. // EXTERNAL MODULE: ./node_modules/select/src/select.js
  2801. var src_select = __webpack_require__(817);
  2802. var select_default = /*#__PURE__*/__webpack_require__.n(src_select);
  2803. ;// CONCATENATED MODULE: ./src/clipboard-action.js
  2804. 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); }
  2805. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2806. 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); } }
  2807. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2808. /**
  2809. * Inner class which performs selection from either `text` or `target`
  2810. * properties and then executes copy or cut operations.
  2811. */
  2812. var ClipboardAction = /*#__PURE__*/function () {
  2813. /**
  2814. * @param {Object} options
  2815. */
  2816. function ClipboardAction(options) {
  2817. _classCallCheck(this, ClipboardAction);
  2818. this.resolveOptions(options);
  2819. this.initSelection();
  2820. }
  2821. /**
  2822. * Defines base properties passed from constructor.
  2823. * @param {Object} options
  2824. */
  2825. _createClass(ClipboardAction, [{
  2826. key: "resolveOptions",
  2827. value: function resolveOptions() {
  2828. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2829. this.action = options.action;
  2830. this.container = options.container;
  2831. this.emitter = options.emitter;
  2832. this.target = options.target;
  2833. this.text = options.text;
  2834. this.trigger = options.trigger;
  2835. this.selectedText = '';
  2836. }
  2837. /**
  2838. * Decides which selection strategy is going to be applied based
  2839. * on the existence of `text` and `target` properties.
  2840. */
  2841. }, {
  2842. key: "initSelection",
  2843. value: function initSelection() {
  2844. if (this.text) {
  2845. this.selectFake();
  2846. } else if (this.target) {
  2847. this.selectTarget();
  2848. }
  2849. }
  2850. /**
  2851. * Creates a fake textarea element, sets its value from `text` property,
  2852. */
  2853. }, {
  2854. key: "createFakeElement",
  2855. value: function createFakeElement() {
  2856. var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
  2857. this.fakeElem = document.createElement('textarea'); // Prevent zooming on iOS
  2858. this.fakeElem.style.fontSize = '12pt'; // Reset box model
  2859. this.fakeElem.style.border = '0';
  2860. this.fakeElem.style.padding = '0';
  2861. this.fakeElem.style.margin = '0'; // Move element out of screen horizontally
  2862. this.fakeElem.style.position = 'absolute';
  2863. this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically
  2864. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  2865. this.fakeElem.style.top = "".concat(yPosition, "px");
  2866. this.fakeElem.setAttribute('readonly', '');
  2867. this.fakeElem.value = this.text;
  2868. return this.fakeElem;
  2869. }
  2870. /**
  2871. * Get's the value of fakeElem,
  2872. * and makes a selection on it.
  2873. */
  2874. }, {
  2875. key: "selectFake",
  2876. value: function selectFake() {
  2877. var _this = this;
  2878. var fakeElem = this.createFakeElement();
  2879. this.fakeHandlerCallback = function () {
  2880. return _this.removeFake();
  2881. };
  2882. this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
  2883. this.container.appendChild(fakeElem);
  2884. this.selectedText = select_default()(fakeElem);
  2885. this.copyText();
  2886. this.removeFake();
  2887. }
  2888. /**
  2889. * Only removes the fake element after another click event, that way
  2890. * a user can hit `Ctrl+C` to copy because selection still exists.
  2891. */
  2892. }, {
  2893. key: "removeFake",
  2894. value: function removeFake() {
  2895. if (this.fakeHandler) {
  2896. this.container.removeEventListener('click', this.fakeHandlerCallback);
  2897. this.fakeHandler = null;
  2898. this.fakeHandlerCallback = null;
  2899. }
  2900. if (this.fakeElem) {
  2901. this.container.removeChild(this.fakeElem);
  2902. this.fakeElem = null;
  2903. }
  2904. }
  2905. /**
  2906. * Selects the content from element passed on `target` property.
  2907. */
  2908. }, {
  2909. key: "selectTarget",
  2910. value: function selectTarget() {
  2911. this.selectedText = select_default()(this.target);
  2912. this.copyText();
  2913. }
  2914. /**
  2915. * Executes the copy operation based on the current selection.
  2916. */
  2917. }, {
  2918. key: "copyText",
  2919. value: function copyText() {
  2920. var succeeded;
  2921. try {
  2922. succeeded = document.execCommand(this.action);
  2923. } catch (err) {
  2924. succeeded = false;
  2925. }
  2926. this.handleResult(succeeded);
  2927. }
  2928. /**
  2929. * Fires an event based on the copy operation result.
  2930. * @param {Boolean} succeeded
  2931. */
  2932. }, {
  2933. key: "handleResult",
  2934. value: function handleResult(succeeded) {
  2935. this.emitter.emit(succeeded ? 'success' : 'error', {
  2936. action: this.action,
  2937. text: this.selectedText,
  2938. trigger: this.trigger,
  2939. clearSelection: this.clearSelection.bind(this)
  2940. });
  2941. }
  2942. /**
  2943. * Moves focus away from `target` and back to the trigger, removes current selection.
  2944. */
  2945. }, {
  2946. key: "clearSelection",
  2947. value: function clearSelection() {
  2948. if (this.trigger) {
  2949. this.trigger.focus();
  2950. }
  2951. document.activeElement.blur();
  2952. window.getSelection().removeAllRanges();
  2953. }
  2954. /**
  2955. * Sets the `action` to be performed which can be either 'copy' or 'cut'.
  2956. * @param {String} action
  2957. */
  2958. }, {
  2959. key: "destroy",
  2960. /**
  2961. * Destroy lifecycle.
  2962. */
  2963. value: function destroy() {
  2964. this.removeFake();
  2965. }
  2966. }, {
  2967. key: "action",
  2968. set: function set() {
  2969. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
  2970. this._action = action;
  2971. if (this._action !== 'copy' && this._action !== 'cut') {
  2972. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  2973. }
  2974. }
  2975. /**
  2976. * Gets the `action` property.
  2977. * @return {String}
  2978. */
  2979. ,
  2980. get: function get() {
  2981. return this._action;
  2982. }
  2983. /**
  2984. * Sets the `target` property using an element
  2985. * that will be have its content copied.
  2986. * @param {Element} target
  2987. */
  2988. }, {
  2989. key: "target",
  2990. set: function set(target) {
  2991. if (target !== undefined) {
  2992. if (target && _typeof(target) === 'object' && target.nodeType === 1) {
  2993. if (this.action === 'copy' && target.hasAttribute('disabled')) {
  2994. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  2995. }
  2996. if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  2997. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  2998. }
  2999. this._target = target;
  3000. } else {
  3001. throw new Error('Invalid "target" value, use a valid Element');
  3002. }
  3003. }
  3004. }
  3005. /**
  3006. * Gets the `target` property.
  3007. * @return {String|HTMLElement}
  3008. */
  3009. ,
  3010. get: function get() {
  3011. return this._target;
  3012. }
  3013. }]);
  3014. return ClipboardAction;
  3015. }();
  3016. /* harmony default export */ var clipboard_action = (ClipboardAction);
  3017. ;// CONCATENATED MODULE: ./src/clipboard.js
  3018. 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); }
  3019. function clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3020. function clipboard_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); } }
  3021. function clipboard_createClass(Constructor, protoProps, staticProps) { if (protoProps) clipboard_defineProperties(Constructor.prototype, protoProps); if (staticProps) clipboard_defineProperties(Constructor, staticProps); return Constructor; }
  3022. 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); }
  3023. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3024. 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); }; }
  3025. function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3026. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3027. 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; } }
  3028. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3029. /**
  3030. * Helper function to retrieve attribute value.
  3031. * @param {String} suffix
  3032. * @param {Element} element
  3033. */
  3034. function getAttributeValue(suffix, element) {
  3035. var attribute = "data-clipboard-".concat(suffix);
  3036. if (!element.hasAttribute(attribute)) {
  3037. return;
  3038. }
  3039. return element.getAttribute(attribute);
  3040. }
  3041. /**
  3042. * Base class which takes one or more elements, adds event listeners to them,
  3043. * and instantiates a new `ClipboardAction` on each click.
  3044. */
  3045. var Clipboard = /*#__PURE__*/function (_Emitter) {
  3046. _inherits(Clipboard, _Emitter);
  3047. var _super = _createSuper(Clipboard);
  3048. /**
  3049. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  3050. * @param {Object} options
  3051. */
  3052. function Clipboard(trigger, options) {
  3053. var _this;
  3054. clipboard_classCallCheck(this, Clipboard);
  3055. _this = _super.call(this);
  3056. _this.resolveOptions(options);
  3057. _this.listenClick(trigger);
  3058. return _this;
  3059. }
  3060. /**
  3061. * Defines if attributes would be resolved using internal setter functions
  3062. * or custom functions that were passed in the constructor.
  3063. * @param {Object} options
  3064. */
  3065. clipboard_createClass(Clipboard, [{
  3066. key: "resolveOptions",
  3067. value: function resolveOptions() {
  3068. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3069. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  3070. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  3071. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  3072. this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;
  3073. }
  3074. /**
  3075. * Adds a click event listener to the passed trigger.
  3076. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  3077. */
  3078. }, {
  3079. key: "listenClick",
  3080. value: function listenClick(trigger) {
  3081. var _this2 = this;
  3082. this.listener = listen_default()(trigger, 'click', function (e) {
  3083. return _this2.onClick(e);
  3084. });
  3085. }
  3086. /**
  3087. * Defines a new `ClipboardAction` on each click event.
  3088. * @param {Event} e
  3089. */
  3090. }, {
  3091. key: "onClick",
  3092. value: function onClick(e) {
  3093. var trigger = e.delegateTarget || e.currentTarget;
  3094. if (this.clipboardAction) {
  3095. this.clipboardAction = null;
  3096. }
  3097. this.clipboardAction = new clipboard_action({
  3098. action: this.action(trigger),
  3099. target: this.target(trigger),
  3100. text: this.text(trigger),
  3101. container: this.container,
  3102. trigger: trigger,
  3103. emitter: this
  3104. });
  3105. }
  3106. /**
  3107. * Default `action` lookup function.
  3108. * @param {Element} trigger
  3109. */
  3110. }, {
  3111. key: "defaultAction",
  3112. value: function defaultAction(trigger) {
  3113. return getAttributeValue('action', trigger);
  3114. }
  3115. /**
  3116. * Default `target` lookup function.
  3117. * @param {Element} trigger
  3118. */
  3119. }, {
  3120. key: "defaultTarget",
  3121. value: function defaultTarget(trigger) {
  3122. var selector = getAttributeValue('target', trigger);
  3123. if (selector) {
  3124. return document.querySelector(selector);
  3125. }
  3126. }
  3127. /**
  3128. * Returns the support of the given action, or all actions if no action is
  3129. * given.
  3130. * @param {String} [action]
  3131. */
  3132. }, {
  3133. key: "defaultText",
  3134. /**
  3135. * Default `text` lookup function.
  3136. * @param {Element} trigger
  3137. */
  3138. value: function defaultText(trigger) {
  3139. return getAttributeValue('text', trigger);
  3140. }
  3141. /**
  3142. * Destroy lifecycle.
  3143. */
  3144. }, {
  3145. key: "destroy",
  3146. value: function destroy() {
  3147. this.listener.destroy();
  3148. if (this.clipboardAction) {
  3149. this.clipboardAction.destroy();
  3150. this.clipboardAction = null;
  3151. }
  3152. }
  3153. }], [{
  3154. key: "isSupported",
  3155. value: function isSupported() {
  3156. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  3157. var actions = typeof action === 'string' ? [action] : action;
  3158. var support = !!document.queryCommandSupported;
  3159. actions.forEach(function (action) {
  3160. support = support && !!document.queryCommandSupported(action);
  3161. });
  3162. return support;
  3163. }
  3164. }]);
  3165. return Clipboard;
  3166. }((tiny_emitter_default()));
  3167. /* harmony default export */ var clipboard = (Clipboard);
  3168. /***/ }),
  3169. /***/ 828:
  3170. /***/ (function(module) {
  3171. var DOCUMENT_NODE_TYPE = 9;
  3172. /**
  3173. * A polyfill for Element.matches()
  3174. */
  3175. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  3176. var proto = Element.prototype;
  3177. proto.matches = proto.matchesSelector ||
  3178. proto.mozMatchesSelector ||
  3179. proto.msMatchesSelector ||
  3180. proto.oMatchesSelector ||
  3181. proto.webkitMatchesSelector;
  3182. }
  3183. /**
  3184. * Finds the closest parent that matches a selector.
  3185. *
  3186. * @param {Element} element
  3187. * @param {String} selector
  3188. * @return {Function}
  3189. */
  3190. function closest (element, selector) {
  3191. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  3192. if (typeof element.matches === 'function' &&
  3193. element.matches(selector)) {
  3194. return element;
  3195. }
  3196. element = element.parentNode;
  3197. }
  3198. }
  3199. module.exports = closest;
  3200. /***/ }),
  3201. /***/ 438:
  3202. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  3203. var closest = __webpack_require__(828);
  3204. /**
  3205. * Delegates event to a selector.
  3206. *
  3207. * @param {Element} element
  3208. * @param {String} selector
  3209. * @param {String} type
  3210. * @param {Function} callback
  3211. * @param {Boolean} useCapture
  3212. * @return {Object}
  3213. */
  3214. function _delegate(element, selector, type, callback, useCapture) {
  3215. var listenerFn = listener.apply(this, arguments);
  3216. element.addEventListener(type, listenerFn, useCapture);
  3217. return {
  3218. destroy: function() {
  3219. element.removeEventListener(type, listenerFn, useCapture);
  3220. }
  3221. }
  3222. }
  3223. /**
  3224. * Delegates event to a selector.
  3225. *
  3226. * @param {Element|String|Array} [elements]
  3227. * @param {String} selector
  3228. * @param {String} type
  3229. * @param {Function} callback
  3230. * @param {Boolean} useCapture
  3231. * @return {Object}
  3232. */
  3233. function delegate(elements, selector, type, callback, useCapture) {
  3234. // Handle the regular Element usage
  3235. if (typeof elements.addEventListener === 'function') {
  3236. return _delegate.apply(null, arguments);
  3237. }
  3238. // Handle Element-less usage, it defaults to global delegation
  3239. if (typeof type === 'function') {
  3240. // Use `document` as the first parameter, then apply arguments
  3241. // This is a short way to .unshift `arguments` without running into deoptimizations
  3242. return _delegate.bind(null, document).apply(null, arguments);
  3243. }
  3244. // Handle Selector-based usage
  3245. if (typeof elements === 'string') {
  3246. elements = document.querySelectorAll(elements);
  3247. }
  3248. // Handle Array-like based usage
  3249. return Array.prototype.map.call(elements, function (element) {
  3250. return _delegate(element, selector, type, callback, useCapture);
  3251. });
  3252. }
  3253. /**
  3254. * Finds closest match and invokes callback.
  3255. *
  3256. * @param {Element} element
  3257. * @param {String} selector
  3258. * @param {String} type
  3259. * @param {Function} callback
  3260. * @return {Function}
  3261. */
  3262. function listener(element, selector, type, callback) {
  3263. return function(e) {
  3264. e.delegateTarget = closest(e.target, selector);
  3265. if (e.delegateTarget) {
  3266. callback.call(element, e);
  3267. }
  3268. }
  3269. }
  3270. module.exports = delegate;
  3271. /***/ }),
  3272. /***/ 879:
  3273. /***/ (function(__unused_webpack_module, exports) {
  3274. /**
  3275. * Check if argument is a HTML element.
  3276. *
  3277. * @param {Object} value
  3278. * @return {Boolean}
  3279. */
  3280. exports.node = function(value) {
  3281. return value !== undefined
  3282. && value instanceof HTMLElement
  3283. && value.nodeType === 1;
  3284. };
  3285. /**
  3286. * Check if argument is a list of HTML elements.
  3287. *
  3288. * @param {Object} value
  3289. * @return {Boolean}
  3290. */
  3291. exports.nodeList = function(value) {
  3292. var type = Object.prototype.toString.call(value);
  3293. return value !== undefined
  3294. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  3295. && ('length' in value)
  3296. && (value.length === 0 || exports.node(value[0]));
  3297. };
  3298. /**
  3299. * Check if argument is a string.
  3300. *
  3301. * @param {Object} value
  3302. * @return {Boolean}
  3303. */
  3304. exports.string = function(value) {
  3305. return typeof value === 'string'
  3306. || value instanceof String;
  3307. };
  3308. /**
  3309. * Check if argument is a function.
  3310. *
  3311. * @param {Object} value
  3312. * @return {Boolean}
  3313. */
  3314. exports.fn = function(value) {
  3315. var type = Object.prototype.toString.call(value);
  3316. return type === '[object Function]';
  3317. };
  3318. /***/ }),
  3319. /***/ 370:
  3320. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  3321. var is = __webpack_require__(879);
  3322. var delegate = __webpack_require__(438);
  3323. /**
  3324. * Validates all params and calls the right
  3325. * listener function based on its target type.
  3326. *
  3327. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  3328. * @param {String} type
  3329. * @param {Function} callback
  3330. * @return {Object}
  3331. */
  3332. function listen(target, type, callback) {
  3333. if (!target && !type && !callback) {
  3334. throw new Error('Missing required arguments');
  3335. }
  3336. if (!is.string(type)) {
  3337. throw new TypeError('Second argument must be a String');
  3338. }
  3339. if (!is.fn(callback)) {
  3340. throw new TypeError('Third argument must be a Function');
  3341. }
  3342. if (is.node(target)) {
  3343. return listenNode(target, type, callback);
  3344. }
  3345. else if (is.nodeList(target)) {
  3346. return listenNodeList(target, type, callback);
  3347. }
  3348. else if (is.string(target)) {
  3349. return listenSelector(target, type, callback);
  3350. }
  3351. else {
  3352. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  3353. }
  3354. }
  3355. /**
  3356. * Adds an event listener to a HTML element
  3357. * and returns a remove listener function.
  3358. *
  3359. * @param {HTMLElement} node
  3360. * @param {String} type
  3361. * @param {Function} callback
  3362. * @return {Object}
  3363. */
  3364. function listenNode(node, type, callback) {
  3365. node.addEventListener(type, callback);
  3366. return {
  3367. destroy: function() {
  3368. node.removeEventListener(type, callback);
  3369. }
  3370. }
  3371. }
  3372. /**
  3373. * Add an event listener to a list of HTML elements
  3374. * and returns a remove listener function.
  3375. *
  3376. * @param {NodeList|HTMLCollection} nodeList
  3377. * @param {String} type
  3378. * @param {Function} callback
  3379. * @return {Object}
  3380. */
  3381. function listenNodeList(nodeList, type, callback) {
  3382. Array.prototype.forEach.call(nodeList, function(node) {
  3383. node.addEventListener(type, callback);
  3384. });
  3385. return {
  3386. destroy: function() {
  3387. Array.prototype.forEach.call(nodeList, function(node) {
  3388. node.removeEventListener(type, callback);
  3389. });
  3390. }
  3391. }
  3392. }
  3393. /**
  3394. * Add an event listener to a selector
  3395. * and returns a remove listener function.
  3396. *
  3397. * @param {String} selector
  3398. * @param {String} type
  3399. * @param {Function} callback
  3400. * @return {Object}
  3401. */
  3402. function listenSelector(selector, type, callback) {
  3403. return delegate(document.body, selector, type, callback);
  3404. }
  3405. module.exports = listen;
  3406. /***/ }),
  3407. /***/ 817:
  3408. /***/ (function(module) {
  3409. function select(element) {
  3410. var selectedText;
  3411. if (element.nodeName === 'SELECT') {
  3412. element.focus();
  3413. selectedText = element.value;
  3414. }
  3415. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  3416. var isReadOnly = element.hasAttribute('readonly');
  3417. if (!isReadOnly) {
  3418. element.setAttribute('readonly', '');
  3419. }
  3420. element.select();
  3421. element.setSelectionRange(0, element.value.length);
  3422. if (!isReadOnly) {
  3423. element.removeAttribute('readonly');
  3424. }
  3425. selectedText = element.value;
  3426. }
  3427. else {
  3428. if (element.hasAttribute('contenteditable')) {
  3429. element.focus();
  3430. }
  3431. var selection = window.getSelection();
  3432. var range = document.createRange();
  3433. range.selectNodeContents(element);
  3434. selection.removeAllRanges();
  3435. selection.addRange(range);
  3436. selectedText = selection.toString();
  3437. }
  3438. return selectedText;
  3439. }
  3440. module.exports = select;
  3441. /***/ }),
  3442. /***/ 279:
  3443. /***/ (function(module) {
  3444. function E () {
  3445. // Keep this empty so it's easier to inherit from
  3446. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  3447. }
  3448. E.prototype = {
  3449. on: function (name, callback, ctx) {
  3450. var e = this.e || (this.e = {});
  3451. (e[name] || (e[name] = [])).push({
  3452. fn: callback,
  3453. ctx: ctx
  3454. });
  3455. return this;
  3456. },
  3457. once: function (name, callback, ctx) {
  3458. var self = this;
  3459. function listener () {
  3460. self.off(name, listener);
  3461. callback.apply(ctx, arguments);
  3462. };
  3463. listener._ = callback
  3464. return this.on(name, listener, ctx);
  3465. },
  3466. emit: function (name) {
  3467. var data = [].slice.call(arguments, 1);
  3468. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  3469. var i = 0;
  3470. var len = evtArr.length;
  3471. for (i; i < len; i++) {
  3472. evtArr[i].fn.apply(evtArr[i].ctx, data);
  3473. }
  3474. return this;
  3475. },
  3476. off: function (name, callback) {
  3477. var e = this.e || (this.e = {});
  3478. var evts = e[name];
  3479. var liveEvents = [];
  3480. if (evts && callback) {
  3481. for (var i = 0, len = evts.length; i < len; i++) {
  3482. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  3483. liveEvents.push(evts[i]);
  3484. }
  3485. }
  3486. // Remove event from queue to prevent memory leak
  3487. // Suggested by https://github.com/lazd
  3488. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  3489. (liveEvents.length)
  3490. ? e[name] = liveEvents
  3491. : delete e[name];
  3492. return this;
  3493. }
  3494. };
  3495. module.exports = E;
  3496. module.exports.TinyEmitter = E;
  3497. /***/ })
  3498. /******/ });
  3499. /************************************************************************/
  3500. /******/ // The module cache
  3501. /******/ var __webpack_module_cache__ = {};
  3502. /******/
  3503. /******/ // The require function
  3504. /******/ function __webpack_require__(moduleId) {
  3505. /******/ // Check if module is in cache
  3506. /******/ if(__webpack_module_cache__[moduleId]) {
  3507. /******/ return __webpack_module_cache__[moduleId].exports;
  3508. /******/ }
  3509. /******/ // Create a new module (and put it into the cache)
  3510. /******/ var module = __webpack_module_cache__[moduleId] = {
  3511. /******/ // no module.id needed
  3512. /******/ // no module.loaded needed
  3513. /******/ exports: {}
  3514. /******/ };
  3515. /******/
  3516. /******/ // Execute the module function
  3517. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  3518. /******/
  3519. /******/ // Return the exports of the module
  3520. /******/ return module.exports;
  3521. /******/ }
  3522. /******/
  3523. /************************************************************************/
  3524. /******/ /* webpack/runtime/compat get default export */
  3525. /******/ !function() {
  3526. /******/ // getDefaultExport function for compatibility with non-harmony modules
  3527. /******/ __webpack_require__.n = function(module) {
  3528. /******/ var getter = module && module.__esModule ?
  3529. /******/ function() { return module['default']; } :
  3530. /******/ function() { return module; };
  3531. /******/ __webpack_require__.d(getter, { a: getter });
  3532. /******/ return getter;
  3533. /******/ };
  3534. /******/ }();
  3535. /******/
  3536. /******/ /* webpack/runtime/define property getters */
  3537. /******/ !function() {
  3538. /******/ // define getter functions for harmony exports
  3539. /******/ __webpack_require__.d = function(exports, definition) {
  3540. /******/ for(var key in definition) {
  3541. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  3542. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  3543. /******/ }
  3544. /******/ }
  3545. /******/ };
  3546. /******/ }();
  3547. /******/
  3548. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  3549. /******/ !function() {
  3550. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  3551. /******/ }();
  3552. /******/
  3553. /************************************************************************/
  3554. /******/ // module exports must be returned from runtime so entry inlining is disabled
  3555. /******/ // startup
  3556. /******/ // Load entry module and return exports
  3557. /******/ return __webpack_require__(134);
  3558. /******/ })()
  3559. .default;
  3560. });
  3561. /***/ }),
  3562. /***/ "wx14":
  3563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3564. "use strict";
  3565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
  3566. function _extends() {
  3567. _extends = Object.assign || function (target) {
  3568. for (var i = 1; i < arguments.length; i++) {
  3569. var source = arguments[i];
  3570. for (var key in source) {
  3571. if (Object.prototype.hasOwnProperty.call(source, key)) {
  3572. target[key] = source[key];
  3573. }
  3574. }
  3575. }
  3576. return target;
  3577. };
  3578. return _extends.apply(this, arguments);
  3579. }
  3580. /***/ })
  3581. /******/ });