data.js 143 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 2167:
  4. /***/ (function(module) {
  5. "use strict";
  6. function _typeof(obj) {
  7. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  8. _typeof = function (obj) {
  9. return typeof obj;
  10. };
  11. } else {
  12. _typeof = function (obj) {
  13. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  14. };
  15. }
  16. return _typeof(obj);
  17. }
  18. function _classCallCheck(instance, Constructor) {
  19. if (!(instance instanceof Constructor)) {
  20. throw new TypeError("Cannot call a class as a function");
  21. }
  22. }
  23. function _defineProperties(target, props) {
  24. for (var i = 0; i < props.length; i++) {
  25. var descriptor = props[i];
  26. descriptor.enumerable = descriptor.enumerable || false;
  27. descriptor.configurable = true;
  28. if ("value" in descriptor) descriptor.writable = true;
  29. Object.defineProperty(target, descriptor.key, descriptor);
  30. }
  31. }
  32. function _createClass(Constructor, protoProps, staticProps) {
  33. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  34. if (staticProps) _defineProperties(Constructor, staticProps);
  35. return Constructor;
  36. }
  37. /**
  38. * Given an instance of EquivalentKeyMap, returns its internal value pair tuple
  39. * for a key, if one exists. The tuple members consist of the last reference
  40. * value for the key (used in efficient subsequent lookups) and the value
  41. * assigned for the key at the leaf node.
  42. *
  43. * @param {EquivalentKeyMap} instance EquivalentKeyMap instance.
  44. * @param {*} key The key for which to return value pair.
  45. *
  46. * @return {?Array} Value pair, if exists.
  47. */
  48. function getValuePair(instance, key) {
  49. var _map = instance._map,
  50. _arrayTreeMap = instance._arrayTreeMap,
  51. _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the
  52. // value, which can be used to shortcut immediately to the value.
  53. if (_map.has(key)) {
  54. return _map.get(key);
  55. } // Sort keys to ensure stable retrieval from tree.
  56. var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value.
  57. var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap;
  58. for (var i = 0; i < properties.length; i++) {
  59. var property = properties[i];
  60. map = map.get(property);
  61. if (map === undefined) {
  62. return;
  63. }
  64. var propertyValue = key[property];
  65. map = map.get(propertyValue);
  66. if (map === undefined) {
  67. return;
  68. }
  69. }
  70. var valuePair = map.get('_ekm_value');
  71. if (!valuePair) {
  72. return;
  73. } // If reached, it implies that an object-like key was set with another
  74. // reference, so delete the reference and replace with the current.
  75. _map.delete(valuePair[0]);
  76. valuePair[0] = key;
  77. map.set('_ekm_value', valuePair);
  78. _map.set(key, valuePair);
  79. return valuePair;
  80. }
  81. /**
  82. * Variant of a Map object which enables lookup by equivalent (deeply equal)
  83. * object and array keys.
  84. */
  85. var EquivalentKeyMap =
  86. /*#__PURE__*/
  87. function () {
  88. /**
  89. * Constructs a new instance of EquivalentKeyMap.
  90. *
  91. * @param {Iterable.<*>} iterable Initial pair of key, value for map.
  92. */
  93. function EquivalentKeyMap(iterable) {
  94. _classCallCheck(this, EquivalentKeyMap);
  95. this.clear();
  96. if (iterable instanceof EquivalentKeyMap) {
  97. // Map#forEach is only means of iterating with support for IE11.
  98. var iterablePairs = [];
  99. iterable.forEach(function (value, key) {
  100. iterablePairs.push([key, value]);
  101. });
  102. iterable = iterablePairs;
  103. }
  104. if (iterable != null) {
  105. for (var i = 0; i < iterable.length; i++) {
  106. this.set(iterable[i][0], iterable[i][1]);
  107. }
  108. }
  109. }
  110. /**
  111. * Accessor property returning the number of elements.
  112. *
  113. * @return {number} Number of elements.
  114. */
  115. _createClass(EquivalentKeyMap, [{
  116. key: "set",
  117. /**
  118. * Add or update an element with a specified key and value.
  119. *
  120. * @param {*} key The key of the element to add.
  121. * @param {*} value The value of the element to add.
  122. *
  123. * @return {EquivalentKeyMap} Map instance.
  124. */
  125. value: function set(key, value) {
  126. // Shortcut non-object-like to set on internal Map.
  127. if (key === null || _typeof(key) !== 'object') {
  128. this._map.set(key, value);
  129. return this;
  130. } // Sort keys to ensure stable assignment into tree.
  131. var properties = Object.keys(key).sort();
  132. var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value.
  133. var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap;
  134. for (var i = 0; i < properties.length; i++) {
  135. var property = properties[i];
  136. if (!map.has(property)) {
  137. map.set(property, new EquivalentKeyMap());
  138. }
  139. map = map.get(property);
  140. var propertyValue = key[property];
  141. if (!map.has(propertyValue)) {
  142. map.set(propertyValue, new EquivalentKeyMap());
  143. }
  144. map = map.get(propertyValue);
  145. } // If an _ekm_value exists, there was already an equivalent key. Before
  146. // overriding, ensure that the old key reference is removed from map to
  147. // avoid memory leak of accumulating equivalent keys. This is, in a
  148. // sense, a poor man's WeakMap, while still enabling iterability.
  149. var previousValuePair = map.get('_ekm_value');
  150. if (previousValuePair) {
  151. this._map.delete(previousValuePair[0]);
  152. }
  153. map.set('_ekm_value', valuePair);
  154. this._map.set(key, valuePair);
  155. return this;
  156. }
  157. /**
  158. * Returns a specified element.
  159. *
  160. * @param {*} key The key of the element to return.
  161. *
  162. * @return {?*} The element associated with the specified key or undefined
  163. * if the key can't be found.
  164. */
  165. }, {
  166. key: "get",
  167. value: function get(key) {
  168. // Shortcut non-object-like to get from internal Map.
  169. if (key === null || _typeof(key) !== 'object') {
  170. return this._map.get(key);
  171. }
  172. var valuePair = getValuePair(this, key);
  173. if (valuePair) {
  174. return valuePair[1];
  175. }
  176. }
  177. /**
  178. * Returns a boolean indicating whether an element with the specified key
  179. * exists or not.
  180. *
  181. * @param {*} key The key of the element to test for presence.
  182. *
  183. * @return {boolean} Whether an element with the specified key exists.
  184. */
  185. }, {
  186. key: "has",
  187. value: function has(key) {
  188. if (key === null || _typeof(key) !== 'object') {
  189. return this._map.has(key);
  190. } // Test on the _presence_ of the pair, not its value, as even undefined
  191. // can be a valid member value for a key.
  192. return getValuePair(this, key) !== undefined;
  193. }
  194. /**
  195. * Removes the specified element.
  196. *
  197. * @param {*} key The key of the element to remove.
  198. *
  199. * @return {boolean} Returns true if an element existed and has been
  200. * removed, or false if the element does not exist.
  201. */
  202. }, {
  203. key: "delete",
  204. value: function _delete(key) {
  205. if (!this.has(key)) {
  206. return false;
  207. } // This naive implementation will leave orphaned child trees. A better
  208. // implementation should traverse and remove orphans.
  209. this.set(key, undefined);
  210. return true;
  211. }
  212. /**
  213. * Executes a provided function once per each key/value pair, in insertion
  214. * order.
  215. *
  216. * @param {Function} callback Function to execute for each element.
  217. * @param {*} thisArg Value to use as `this` when executing
  218. * `callback`.
  219. */
  220. }, {
  221. key: "forEach",
  222. value: function forEach(callback) {
  223. var _this = this;
  224. var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
  225. this._map.forEach(function (value, key) {
  226. // Unwrap value from object-like value pair.
  227. if (key !== null && _typeof(key) === 'object') {
  228. value = value[1];
  229. }
  230. callback.call(thisArg, value, key, _this);
  231. });
  232. }
  233. /**
  234. * Removes all elements.
  235. */
  236. }, {
  237. key: "clear",
  238. value: function clear() {
  239. this._map = new Map();
  240. this._arrayTreeMap = new Map();
  241. this._objectTreeMap = new Map();
  242. }
  243. }, {
  244. key: "size",
  245. get: function get() {
  246. return this._map.size;
  247. }
  248. }]);
  249. return EquivalentKeyMap;
  250. }();
  251. module.exports = EquivalentKeyMap;
  252. /***/ }),
  253. /***/ 9125:
  254. /***/ (function(module) {
  255. function combineReducers( reducers ) {
  256. var keys = Object.keys( reducers ),
  257. getNextState;
  258. getNextState = ( function() {
  259. var fn, i, key;
  260. fn = 'return {';
  261. for ( i = 0; i < keys.length; i++ ) {
  262. // Rely on Quoted escaping of JSON.stringify with guarantee that
  263. // each member of Object.keys is a string.
  264. //
  265. // "If Type(value) is String, then return the result of calling the
  266. // abstract operation Quote with argument value. [...] The abstract
  267. // operation Quote(value) wraps a String value in double quotes and
  268. // escapes characters within it."
  269. //
  270. // https://www.ecma-international.org/ecma-262/5.1/#sec-15.12.3
  271. key = JSON.stringify( keys[ i ] );
  272. fn += key + ':r[' + key + '](s[' + key + '],a),';
  273. }
  274. fn += '}';
  275. return new Function( 'r,s,a', fn );
  276. } )();
  277. return function combinedReducer( state, action ) {
  278. var nextState, i, key;
  279. // Assumed changed if initial state.
  280. if ( state === undefined ) {
  281. return getNextState( reducers, {}, action );
  282. }
  283. nextState = getNextState( reducers, state, action );
  284. // Determine whether state has changed.
  285. i = keys.length;
  286. while ( i-- ) {
  287. key = keys[ i ];
  288. if ( state[ key ] !== nextState[ key ] ) {
  289. // Return immediately if a changed value is encountered.
  290. return nextState;
  291. }
  292. }
  293. return state;
  294. };
  295. }
  296. module.exports = combineReducers;
  297. /***/ })
  298. /******/ });
  299. /************************************************************************/
  300. /******/ // The module cache
  301. /******/ var __webpack_module_cache__ = {};
  302. /******/
  303. /******/ // The require function
  304. /******/ function __webpack_require__(moduleId) {
  305. /******/ // Check if module is in cache
  306. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  307. /******/ if (cachedModule !== undefined) {
  308. /******/ return cachedModule.exports;
  309. /******/ }
  310. /******/ // Create a new module (and put it into the cache)
  311. /******/ var module = __webpack_module_cache__[moduleId] = {
  312. /******/ // no module.id needed
  313. /******/ // no module.loaded needed
  314. /******/ exports: {}
  315. /******/ };
  316. /******/
  317. /******/ // Execute the module function
  318. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  319. /******/
  320. /******/ // Return the exports of the module
  321. /******/ return module.exports;
  322. /******/ }
  323. /******/
  324. /************************************************************************/
  325. /******/ /* webpack/runtime/compat get default export */
  326. /******/ !function() {
  327. /******/ // getDefaultExport function for compatibility with non-harmony modules
  328. /******/ __webpack_require__.n = function(module) {
  329. /******/ var getter = module && module.__esModule ?
  330. /******/ function() { return module['default']; } :
  331. /******/ function() { return module; };
  332. /******/ __webpack_require__.d(getter, { a: getter });
  333. /******/ return getter;
  334. /******/ };
  335. /******/ }();
  336. /******/
  337. /******/ /* webpack/runtime/define property getters */
  338. /******/ !function() {
  339. /******/ // define getter functions for harmony exports
  340. /******/ __webpack_require__.d = function(exports, definition) {
  341. /******/ for(var key in definition) {
  342. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  343. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  344. /******/ }
  345. /******/ }
  346. /******/ };
  347. /******/ }();
  348. /******/
  349. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  350. /******/ !function() {
  351. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  352. /******/ }();
  353. /******/
  354. /******/ /* webpack/runtime/make namespace object */
  355. /******/ !function() {
  356. /******/ // define __esModule on exports
  357. /******/ __webpack_require__.r = function(exports) {
  358. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  359. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  360. /******/ }
  361. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  362. /******/ };
  363. /******/ }();
  364. /******/
  365. /************************************************************************/
  366. var __webpack_exports__ = {};
  367. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  368. !function() {
  369. "use strict";
  370. // ESM COMPAT FLAG
  371. __webpack_require__.r(__webpack_exports__);
  372. // EXPORTS
  373. __webpack_require__.d(__webpack_exports__, {
  374. "AsyncModeProvider": function() { return /* reexport */ async_mode_provider_context; },
  375. "RegistryConsumer": function() { return /* reexport */ RegistryConsumer; },
  376. "RegistryProvider": function() { return /* reexport */ context; },
  377. "combineReducers": function() { return /* binding */ build_module_combineReducers; },
  378. "controls": function() { return /* reexport */ controls; },
  379. "createReduxStore": function() { return /* reexport */ createReduxStore; },
  380. "createRegistry": function() { return /* reexport */ createRegistry; },
  381. "createRegistryControl": function() { return /* reexport */ createRegistryControl; },
  382. "createRegistrySelector": function() { return /* reexport */ createRegistrySelector; },
  383. "dispatch": function() { return /* binding */ build_module_dispatch; },
  384. "plugins": function() { return /* reexport */ plugins_namespaceObject; },
  385. "register": function() { return /* binding */ register; },
  386. "registerGenericStore": function() { return /* binding */ registerGenericStore; },
  387. "registerStore": function() { return /* binding */ registerStore; },
  388. "resolveSelect": function() { return /* binding */ build_module_resolveSelect; },
  389. "select": function() { return /* binding */ build_module_select; },
  390. "subscribe": function() { return /* binding */ subscribe; },
  391. "suspendSelect": function() { return /* binding */ suspendSelect; },
  392. "use": function() { return /* binding */ use; },
  393. "useDispatch": function() { return /* reexport */ use_dispatch; },
  394. "useRegistry": function() { return /* reexport */ useRegistry; },
  395. "useSelect": function() { return /* reexport */ useSelect; },
  396. "useSuspenseSelect": function() { return /* reexport */ useSuspenseSelect; },
  397. "withDispatch": function() { return /* reexport */ with_dispatch; },
  398. "withRegistry": function() { return /* reexport */ with_registry; },
  399. "withSelect": function() { return /* reexport */ with_select; }
  400. });
  401. // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js
  402. var selectors_namespaceObject = {};
  403. __webpack_require__.r(selectors_namespaceObject);
  404. __webpack_require__.d(selectors_namespaceObject, {
  405. "getCachedResolvers": function() { return getCachedResolvers; },
  406. "getIsResolving": function() { return getIsResolving; },
  407. "getResolutionError": function() { return getResolutionError; },
  408. "getResolutionState": function() { return getResolutionState; },
  409. "hasFinishedResolution": function() { return hasFinishedResolution; },
  410. "hasResolutionFailed": function() { return hasResolutionFailed; },
  411. "hasStartedResolution": function() { return hasStartedResolution; },
  412. "isResolving": function() { return isResolving; }
  413. });
  414. // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js
  415. var actions_namespaceObject = {};
  416. __webpack_require__.r(actions_namespaceObject);
  417. __webpack_require__.d(actions_namespaceObject, {
  418. "failResolution": function() { return failResolution; },
  419. "failResolutions": function() { return failResolutions; },
  420. "finishResolution": function() { return finishResolution; },
  421. "finishResolutions": function() { return finishResolutions; },
  422. "invalidateResolution": function() { return invalidateResolution; },
  423. "invalidateResolutionForStore": function() { return invalidateResolutionForStore; },
  424. "invalidateResolutionForStoreSelector": function() { return invalidateResolutionForStoreSelector; },
  425. "startResolution": function() { return startResolution; },
  426. "startResolutions": function() { return startResolutions; }
  427. });
  428. // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js
  429. var plugins_namespaceObject = {};
  430. __webpack_require__.r(plugins_namespaceObject);
  431. __webpack_require__.d(plugins_namespaceObject, {
  432. "persistence": function() { return persistence; }
  433. });
  434. // EXTERNAL MODULE: ./node_modules/turbo-combine-reducers/index.js
  435. var turbo_combine_reducers = __webpack_require__(9125);
  436. var turbo_combine_reducers_default = /*#__PURE__*/__webpack_require__.n(turbo_combine_reducers);
  437. ;// CONCATENATED MODULE: external "lodash"
  438. var external_lodash_namespaceObject = window["lodash"];
  439. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  440. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  441. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  442. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
  443. function _defineProperty(obj, key, value) {
  444. if (key in obj) {
  445. Object.defineProperty(obj, key, {
  446. value: value,
  447. enumerable: true,
  448. configurable: true,
  449. writable: true
  450. });
  451. } else {
  452. obj[key] = value;
  453. }
  454. return obj;
  455. }
  456. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js
  457. function ownKeys(object, enumerableOnly) {
  458. var keys = Object.keys(object);
  459. if (Object.getOwnPropertySymbols) {
  460. var symbols = Object.getOwnPropertySymbols(object);
  461. enumerableOnly && (symbols = symbols.filter(function (sym) {
  462. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  463. })), keys.push.apply(keys, symbols);
  464. }
  465. return keys;
  466. }
  467. function _objectSpread2(target) {
  468. for (var i = 1; i < arguments.length; i++) {
  469. var source = null != arguments[i] ? arguments[i] : {};
  470. i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
  471. _defineProperty(target, key, source[key]);
  472. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
  473. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  474. });
  475. }
  476. return target;
  477. }
  478. ;// CONCATENATED MODULE: ./node_modules/redux/es/redux.js
  479. /**
  480. * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
  481. *
  482. * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
  483. * during build.
  484. * @param {number} code
  485. */
  486. function formatProdErrorMessage(code) {
  487. return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
  488. }
  489. // Inlined version of the `symbol-observable` polyfill
  490. var $$observable = (function () {
  491. return typeof Symbol === 'function' && Symbol.observable || '@@observable';
  492. })();
  493. /**
  494. * These are private action types reserved by Redux.
  495. * For any unknown actions, you must return the current state.
  496. * If the current state is undefined, you must return the initial state.
  497. * Do not reference these action types directly in your code.
  498. */
  499. var randomString = function randomString() {
  500. return Math.random().toString(36).substring(7).split('').join('.');
  501. };
  502. var ActionTypes = {
  503. INIT: "@@redux/INIT" + randomString(),
  504. REPLACE: "@@redux/REPLACE" + randomString(),
  505. PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
  506. return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
  507. }
  508. };
  509. /**
  510. * @param {any} obj The object to inspect.
  511. * @returns {boolean} True if the argument appears to be a plain object.
  512. */
  513. function isPlainObject(obj) {
  514. if (typeof obj !== 'object' || obj === null) return false;
  515. var proto = obj;
  516. while (Object.getPrototypeOf(proto) !== null) {
  517. proto = Object.getPrototypeOf(proto);
  518. }
  519. return Object.getPrototypeOf(obj) === proto;
  520. }
  521. // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
  522. function miniKindOf(val) {
  523. if (val === void 0) return 'undefined';
  524. if (val === null) return 'null';
  525. var type = typeof val;
  526. switch (type) {
  527. case 'boolean':
  528. case 'string':
  529. case 'number':
  530. case 'symbol':
  531. case 'function':
  532. {
  533. return type;
  534. }
  535. }
  536. if (Array.isArray(val)) return 'array';
  537. if (isDate(val)) return 'date';
  538. if (isError(val)) return 'error';
  539. var constructorName = ctorName(val);
  540. switch (constructorName) {
  541. case 'Symbol':
  542. case 'Promise':
  543. case 'WeakMap':
  544. case 'WeakSet':
  545. case 'Map':
  546. case 'Set':
  547. return constructorName;
  548. } // other
  549. return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
  550. }
  551. function ctorName(val) {
  552. return typeof val.constructor === 'function' ? val.constructor.name : null;
  553. }
  554. function isError(val) {
  555. return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
  556. }
  557. function isDate(val) {
  558. if (val instanceof Date) return true;
  559. return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
  560. }
  561. function kindOf(val) {
  562. var typeOfVal = typeof val;
  563. if (false) {}
  564. return typeOfVal;
  565. }
  566. /**
  567. * @deprecated
  568. *
  569. * **We recommend using the `configureStore` method
  570. * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
  571. *
  572. * Redux Toolkit is our recommended approach for writing Redux logic today,
  573. * including store setup, reducers, data fetching, and more.
  574. *
  575. * **For more details, please read this Redux docs page:**
  576. * **https://redux.js.org/introduction/why-rtk-is-redux-today**
  577. *
  578. * `configureStore` from Redux Toolkit is an improved version of `createStore` that
  579. * simplifies setup and helps avoid common bugs.
  580. *
  581. * You should not be using the `redux` core package by itself today, except for learning purposes.
  582. * The `createStore` method from the core `redux` package will not be removed, but we encourage
  583. * all users to migrate to using Redux Toolkit for all Redux code.
  584. *
  585. * If you want to use `createStore` without this visual deprecation warning, use
  586. * the `legacy_createStore` import instead:
  587. *
  588. * `import { legacy_createStore as createStore} from 'redux'`
  589. *
  590. */
  591. function createStore(reducer, preloadedState, enhancer) {
  592. var _ref2;
  593. if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
  594. throw new Error( true ? formatProdErrorMessage(0) : 0);
  595. }
  596. if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
  597. enhancer = preloadedState;
  598. preloadedState = undefined;
  599. }
  600. if (typeof enhancer !== 'undefined') {
  601. if (typeof enhancer !== 'function') {
  602. throw new Error( true ? formatProdErrorMessage(1) : 0);
  603. }
  604. return enhancer(createStore)(reducer, preloadedState);
  605. }
  606. if (typeof reducer !== 'function') {
  607. throw new Error( true ? formatProdErrorMessage(2) : 0);
  608. }
  609. var currentReducer = reducer;
  610. var currentState = preloadedState;
  611. var currentListeners = [];
  612. var nextListeners = currentListeners;
  613. var isDispatching = false;
  614. /**
  615. * This makes a shallow copy of currentListeners so we can use
  616. * nextListeners as a temporary list while dispatching.
  617. *
  618. * This prevents any bugs around consumers calling
  619. * subscribe/unsubscribe in the middle of a dispatch.
  620. */
  621. function ensureCanMutateNextListeners() {
  622. if (nextListeners === currentListeners) {
  623. nextListeners = currentListeners.slice();
  624. }
  625. }
  626. /**
  627. * Reads the state tree managed by the store.
  628. *
  629. * @returns {any} The current state tree of your application.
  630. */
  631. function getState() {
  632. if (isDispatching) {
  633. throw new Error( true ? formatProdErrorMessage(3) : 0);
  634. }
  635. return currentState;
  636. }
  637. /**
  638. * Adds a change listener. It will be called any time an action is dispatched,
  639. * and some part of the state tree may potentially have changed. You may then
  640. * call `getState()` to read the current state tree inside the callback.
  641. *
  642. * You may call `dispatch()` from a change listener, with the following
  643. * caveats:
  644. *
  645. * 1. The subscriptions are snapshotted just before every `dispatch()` call.
  646. * If you subscribe or unsubscribe while the listeners are being invoked, this
  647. * will not have any effect on the `dispatch()` that is currently in progress.
  648. * However, the next `dispatch()` call, whether nested or not, will use a more
  649. * recent snapshot of the subscription list.
  650. *
  651. * 2. The listener should not expect to see all state changes, as the state
  652. * might have been updated multiple times during a nested `dispatch()` before
  653. * the listener is called. It is, however, guaranteed that all subscribers
  654. * registered before the `dispatch()` started will be called with the latest
  655. * state by the time it exits.
  656. *
  657. * @param {Function} listener A callback to be invoked on every dispatch.
  658. * @returns {Function} A function to remove this change listener.
  659. */
  660. function subscribe(listener) {
  661. if (typeof listener !== 'function') {
  662. throw new Error( true ? formatProdErrorMessage(4) : 0);
  663. }
  664. if (isDispatching) {
  665. throw new Error( true ? formatProdErrorMessage(5) : 0);
  666. }
  667. var isSubscribed = true;
  668. ensureCanMutateNextListeners();
  669. nextListeners.push(listener);
  670. return function unsubscribe() {
  671. if (!isSubscribed) {
  672. return;
  673. }
  674. if (isDispatching) {
  675. throw new Error( true ? formatProdErrorMessage(6) : 0);
  676. }
  677. isSubscribed = false;
  678. ensureCanMutateNextListeners();
  679. var index = nextListeners.indexOf(listener);
  680. nextListeners.splice(index, 1);
  681. currentListeners = null;
  682. };
  683. }
  684. /**
  685. * Dispatches an action. It is the only way to trigger a state change.
  686. *
  687. * The `reducer` function, used to create the store, will be called with the
  688. * current state tree and the given `action`. Its return value will
  689. * be considered the **next** state of the tree, and the change listeners
  690. * will be notified.
  691. *
  692. * The base implementation only supports plain object actions. If you want to
  693. * dispatch a Promise, an Observable, a thunk, or something else, you need to
  694. * wrap your store creating function into the corresponding middleware. For
  695. * example, see the documentation for the `redux-thunk` package. Even the
  696. * middleware will eventually dispatch plain object actions using this method.
  697. *
  698. * @param {Object} action A plain object representing “what changed”. It is
  699. * a good idea to keep actions serializable so you can record and replay user
  700. * sessions, or use the time travelling `redux-devtools`. An action must have
  701. * a `type` property which may not be `undefined`. It is a good idea to use
  702. * string constants for action types.
  703. *
  704. * @returns {Object} For convenience, the same action object you dispatched.
  705. *
  706. * Note that, if you use a custom middleware, it may wrap `dispatch()` to
  707. * return something else (for example, a Promise you can await).
  708. */
  709. function dispatch(action) {
  710. if (!isPlainObject(action)) {
  711. throw new Error( true ? formatProdErrorMessage(7) : 0);
  712. }
  713. if (typeof action.type === 'undefined') {
  714. throw new Error( true ? formatProdErrorMessage(8) : 0);
  715. }
  716. if (isDispatching) {
  717. throw new Error( true ? formatProdErrorMessage(9) : 0);
  718. }
  719. try {
  720. isDispatching = true;
  721. currentState = currentReducer(currentState, action);
  722. } finally {
  723. isDispatching = false;
  724. }
  725. var listeners = currentListeners = nextListeners;
  726. for (var i = 0; i < listeners.length; i++) {
  727. var listener = listeners[i];
  728. listener();
  729. }
  730. return action;
  731. }
  732. /**
  733. * Replaces the reducer currently used by the store to calculate the state.
  734. *
  735. * You might need this if your app implements code splitting and you want to
  736. * load some of the reducers dynamically. You might also need this if you
  737. * implement a hot reloading mechanism for Redux.
  738. *
  739. * @param {Function} nextReducer The reducer for the store to use instead.
  740. * @returns {void}
  741. */
  742. function replaceReducer(nextReducer) {
  743. if (typeof nextReducer !== 'function') {
  744. throw new Error( true ? formatProdErrorMessage(10) : 0);
  745. }
  746. currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
  747. // Any reducers that existed in both the new and old rootReducer
  748. // will receive the previous state. This effectively populates
  749. // the new state tree with any relevant data from the old one.
  750. dispatch({
  751. type: ActionTypes.REPLACE
  752. });
  753. }
  754. /**
  755. * Interoperability point for observable/reactive libraries.
  756. * @returns {observable} A minimal observable of state changes.
  757. * For more information, see the observable proposal:
  758. * https://github.com/tc39/proposal-observable
  759. */
  760. function observable() {
  761. var _ref;
  762. var outerSubscribe = subscribe;
  763. return _ref = {
  764. /**
  765. * The minimal observable subscription method.
  766. * @param {Object} observer Any object that can be used as an observer.
  767. * The observer object should have a `next` method.
  768. * @returns {subscription} An object with an `unsubscribe` method that can
  769. * be used to unsubscribe the observable from the store, and prevent further
  770. * emission of values from the observable.
  771. */
  772. subscribe: function subscribe(observer) {
  773. if (typeof observer !== 'object' || observer === null) {
  774. throw new Error( true ? formatProdErrorMessage(11) : 0);
  775. }
  776. function observeState() {
  777. if (observer.next) {
  778. observer.next(getState());
  779. }
  780. }
  781. observeState();
  782. var unsubscribe = outerSubscribe(observeState);
  783. return {
  784. unsubscribe: unsubscribe
  785. };
  786. }
  787. }, _ref[$$observable] = function () {
  788. return this;
  789. }, _ref;
  790. } // When a store is created, an "INIT" action is dispatched so that every
  791. // reducer returns their initial state. This effectively populates
  792. // the initial state tree.
  793. dispatch({
  794. type: ActionTypes.INIT
  795. });
  796. return _ref2 = {
  797. dispatch: dispatch,
  798. subscribe: subscribe,
  799. getState: getState,
  800. replaceReducer: replaceReducer
  801. }, _ref2[$$observable] = observable, _ref2;
  802. }
  803. /**
  804. * Creates a Redux store that holds the state tree.
  805. *
  806. * **We recommend using `configureStore` from the
  807. * `@reduxjs/toolkit` package**, which replaces `createStore`:
  808. * **https://redux.js.org/introduction/why-rtk-is-redux-today**
  809. *
  810. * The only way to change the data in the store is to call `dispatch()` on it.
  811. *
  812. * There should only be a single store in your app. To specify how different
  813. * parts of the state tree respond to actions, you may combine several reducers
  814. * into a single reducer function by using `combineReducers`.
  815. *
  816. * @param {Function} reducer A function that returns the next state tree, given
  817. * the current state tree and the action to handle.
  818. *
  819. * @param {any} [preloadedState] The initial state. You may optionally specify it
  820. * to hydrate the state from the server in universal apps, or to restore a
  821. * previously serialized user session.
  822. * If you use `combineReducers` to produce the root reducer function, this must be
  823. * an object with the same shape as `combineReducers` keys.
  824. *
  825. * @param {Function} [enhancer] The store enhancer. You may optionally specify it
  826. * to enhance the store with third-party capabilities such as middleware,
  827. * time travel, persistence, etc. The only store enhancer that ships with Redux
  828. * is `applyMiddleware()`.
  829. *
  830. * @returns {Store} A Redux store that lets you read the state, dispatch actions
  831. * and subscribe to changes.
  832. */
  833. var legacy_createStore = (/* unused pure expression or super */ null && (createStore));
  834. /**
  835. * Prints a warning in the console if it exists.
  836. *
  837. * @param {String} message The warning message.
  838. * @returns {void}
  839. */
  840. function warning(message) {
  841. /* eslint-disable no-console */
  842. if (typeof console !== 'undefined' && typeof console.error === 'function') {
  843. console.error(message);
  844. }
  845. /* eslint-enable no-console */
  846. try {
  847. // This error was thrown as a convenience so that if you enable
  848. // "break on all exceptions" in your console,
  849. // it would pause the execution at this line.
  850. throw new Error(message);
  851. } catch (e) {} // eslint-disable-line no-empty
  852. }
  853. function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
  854. var reducerKeys = Object.keys(reducers);
  855. var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
  856. if (reducerKeys.length === 0) {
  857. return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
  858. }
  859. if (!isPlainObject(inputState)) {
  860. return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
  861. }
  862. var unexpectedKeys = Object.keys(inputState).filter(function (key) {
  863. return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
  864. });
  865. unexpectedKeys.forEach(function (key) {
  866. unexpectedKeyCache[key] = true;
  867. });
  868. if (action && action.type === ActionTypes.REPLACE) return;
  869. if (unexpectedKeys.length > 0) {
  870. return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
  871. }
  872. }
  873. function assertReducerShape(reducers) {
  874. Object.keys(reducers).forEach(function (key) {
  875. var reducer = reducers[key];
  876. var initialState = reducer(undefined, {
  877. type: ActionTypes.INIT
  878. });
  879. if (typeof initialState === 'undefined') {
  880. throw new Error( true ? formatProdErrorMessage(12) : 0);
  881. }
  882. if (typeof reducer(undefined, {
  883. type: ActionTypes.PROBE_UNKNOWN_ACTION()
  884. }) === 'undefined') {
  885. throw new Error( true ? formatProdErrorMessage(13) : 0);
  886. }
  887. });
  888. }
  889. /**
  890. * Turns an object whose values are different reducer functions, into a single
  891. * reducer function. It will call every child reducer, and gather their results
  892. * into a single state object, whose keys correspond to the keys of the passed
  893. * reducer functions.
  894. *
  895. * @param {Object} reducers An object whose values correspond to different
  896. * reducer functions that need to be combined into one. One handy way to obtain
  897. * it is to use ES6 `import * as reducers` syntax. The reducers may never return
  898. * undefined for any action. Instead, they should return their initial state
  899. * if the state passed to them was undefined, and the current state for any
  900. * unrecognized action.
  901. *
  902. * @returns {Function} A reducer function that invokes every reducer inside the
  903. * passed object, and builds a state object with the same shape.
  904. */
  905. function combineReducers(reducers) {
  906. var reducerKeys = Object.keys(reducers);
  907. var finalReducers = {};
  908. for (var i = 0; i < reducerKeys.length; i++) {
  909. var key = reducerKeys[i];
  910. if (false) {}
  911. if (typeof reducers[key] === 'function') {
  912. finalReducers[key] = reducers[key];
  913. }
  914. }
  915. var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
  916. // keys multiple times.
  917. var unexpectedKeyCache;
  918. if (false) {}
  919. var shapeAssertionError;
  920. try {
  921. assertReducerShape(finalReducers);
  922. } catch (e) {
  923. shapeAssertionError = e;
  924. }
  925. return function combination(state, action) {
  926. if (state === void 0) {
  927. state = {};
  928. }
  929. if (shapeAssertionError) {
  930. throw shapeAssertionError;
  931. }
  932. if (false) { var warningMessage; }
  933. var hasChanged = false;
  934. var nextState = {};
  935. for (var _i = 0; _i < finalReducerKeys.length; _i++) {
  936. var _key = finalReducerKeys[_i];
  937. var reducer = finalReducers[_key];
  938. var previousStateForKey = state[_key];
  939. var nextStateForKey = reducer(previousStateForKey, action);
  940. if (typeof nextStateForKey === 'undefined') {
  941. var actionType = action && action.type;
  942. throw new Error( true ? formatProdErrorMessage(14) : 0);
  943. }
  944. nextState[_key] = nextStateForKey;
  945. hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
  946. }
  947. hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
  948. return hasChanged ? nextState : state;
  949. };
  950. }
  951. function bindActionCreator(actionCreator, dispatch) {
  952. return function () {
  953. return dispatch(actionCreator.apply(this, arguments));
  954. };
  955. }
  956. /**
  957. * Turns an object whose values are action creators, into an object with the
  958. * same keys, but with every function wrapped into a `dispatch` call so they
  959. * may be invoked directly. This is just a convenience method, as you can call
  960. * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
  961. *
  962. * For convenience, you can also pass an action creator as the first argument,
  963. * and get a dispatch wrapped function in return.
  964. *
  965. * @param {Function|Object} actionCreators An object whose values are action
  966. * creator functions. One handy way to obtain it is to use ES6 `import * as`
  967. * syntax. You may also pass a single function.
  968. *
  969. * @param {Function} dispatch The `dispatch` function available on your Redux
  970. * store.
  971. *
  972. * @returns {Function|Object} The object mimicking the original object, but with
  973. * every action creator wrapped into the `dispatch` call. If you passed a
  974. * function as `actionCreators`, the return value will also be a single
  975. * function.
  976. */
  977. function bindActionCreators(actionCreators, dispatch) {
  978. if (typeof actionCreators === 'function') {
  979. return bindActionCreator(actionCreators, dispatch);
  980. }
  981. if (typeof actionCreators !== 'object' || actionCreators === null) {
  982. throw new Error( true ? formatProdErrorMessage(16) : 0);
  983. }
  984. var boundActionCreators = {};
  985. for (var key in actionCreators) {
  986. var actionCreator = actionCreators[key];
  987. if (typeof actionCreator === 'function') {
  988. boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
  989. }
  990. }
  991. return boundActionCreators;
  992. }
  993. /**
  994. * Composes single-argument functions from right to left. The rightmost
  995. * function can take multiple arguments as it provides the signature for
  996. * the resulting composite function.
  997. *
  998. * @param {...Function} funcs The functions to compose.
  999. * @returns {Function} A function obtained by composing the argument functions
  1000. * from right to left. For example, compose(f, g, h) is identical to doing
  1001. * (...args) => f(g(h(...args))).
  1002. */
  1003. function compose() {
  1004. for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
  1005. funcs[_key] = arguments[_key];
  1006. }
  1007. if (funcs.length === 0) {
  1008. return function (arg) {
  1009. return arg;
  1010. };
  1011. }
  1012. if (funcs.length === 1) {
  1013. return funcs[0];
  1014. }
  1015. return funcs.reduce(function (a, b) {
  1016. return function () {
  1017. return a(b.apply(void 0, arguments));
  1018. };
  1019. });
  1020. }
  1021. /**
  1022. * Creates a store enhancer that applies middleware to the dispatch method
  1023. * of the Redux store. This is handy for a variety of tasks, such as expressing
  1024. * asynchronous actions in a concise manner, or logging every action payload.
  1025. *
  1026. * See `redux-thunk` package as an example of the Redux middleware.
  1027. *
  1028. * Because middleware is potentially asynchronous, this should be the first
  1029. * store enhancer in the composition chain.
  1030. *
  1031. * Note that each middleware will be given the `dispatch` and `getState` functions
  1032. * as named arguments.
  1033. *
  1034. * @param {...Function} middlewares The middleware chain to be applied.
  1035. * @returns {Function} A store enhancer applying the middleware.
  1036. */
  1037. function applyMiddleware() {
  1038. for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
  1039. middlewares[_key] = arguments[_key];
  1040. }
  1041. return function (createStore) {
  1042. return function () {
  1043. var store = createStore.apply(void 0, arguments);
  1044. var _dispatch = function dispatch() {
  1045. throw new Error( true ? formatProdErrorMessage(15) : 0);
  1046. };
  1047. var middlewareAPI = {
  1048. getState: store.getState,
  1049. dispatch: function dispatch() {
  1050. return _dispatch.apply(void 0, arguments);
  1051. }
  1052. };
  1053. var chain = middlewares.map(function (middleware) {
  1054. return middleware(middlewareAPI);
  1055. });
  1056. _dispatch = compose.apply(void 0, chain)(store.dispatch);
  1057. return _objectSpread2(_objectSpread2({}, store), {}, {
  1058. dispatch: _dispatch
  1059. });
  1060. };
  1061. };
  1062. }
  1063. /*
  1064. * This is a dummy function to check if the function name has been altered by minification.
  1065. * If the function has been minified and NODE_ENV !== 'production', warn the user.
  1066. */
  1067. function isCrushed() {}
  1068. if (false) {}
  1069. // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
  1070. var equivalent_key_map = __webpack_require__(2167);
  1071. var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
  1072. ;// CONCATENATED MODULE: external ["wp","reduxRoutine"]
  1073. var external_wp_reduxRoutine_namespaceObject = window["wp"]["reduxRoutine"];
  1074. var external_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_wp_reduxRoutine_namespaceObject);
  1075. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js
  1076. /**
  1077. * Creates a selector function that takes additional curried argument with the
  1078. * registry `select` function. While a regular selector has signature
  1079. * ```js
  1080. * ( state, ...selectorArgs ) => ( result )
  1081. * ```
  1082. * that allows to select data from the store's `state`, a registry selector
  1083. * has signature:
  1084. * ```js
  1085. * ( select ) => ( state, ...selectorArgs ) => ( result )
  1086. * ```
  1087. * that supports also selecting from other registered stores.
  1088. *
  1089. * @example
  1090. * ```js
  1091. * import { store as coreStore } from '@wordpress/core-data';
  1092. * import { store as editorStore } from '@wordpress/editor';
  1093. *
  1094. * const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => {
  1095. * return select( editorStore ).getCurrentPostId();
  1096. * } );
  1097. *
  1098. * const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {
  1099. * // calling another registry selector just like any other function
  1100. * const postType = getCurrentPostType( state );
  1101. * const postId = getCurrentPostId( state );
  1102. * return select( coreStore ).getEntityRecordEdits( 'postType', postType, postId );
  1103. * } );
  1104. * ```
  1105. *
  1106. * Note how the `getCurrentPostId` selector can be called just like any other function,
  1107. * (it works even inside a regular non-registry selector) and we don't need to pass the
  1108. * registry as argument. The registry binding happens automatically when registering the selector
  1109. * with a store.
  1110. *
  1111. * @param {Function} registrySelector Function receiving a registry `select`
  1112. * function and returning a state selector.
  1113. *
  1114. * @return {Function} Registry selector that can be registered with a store.
  1115. */
  1116. function createRegistrySelector(registrySelector) {
  1117. // Create a selector function that is bound to the registry referenced by `selector.registry`
  1118. // and that has the same API as a regular selector. Binding it in such a way makes it
  1119. // possible to call the selector directly from another selector.
  1120. const selector = function () {
  1121. return registrySelector(selector.registry.select)(...arguments);
  1122. };
  1123. /**
  1124. * Flag indicating that the selector is a registry selector that needs the correct registry
  1125. * reference to be assigned to `selecto.registry` to make it work correctly.
  1126. * be mapped as a registry selector.
  1127. *
  1128. * @type {boolean}
  1129. */
  1130. selector.isRegistrySelector = true;
  1131. return selector;
  1132. }
  1133. /**
  1134. * Creates a control function that takes additional curried argument with the `registry` object.
  1135. * While a regular control has signature
  1136. * ```js
  1137. * ( action ) => ( iteratorOrPromise )
  1138. * ```
  1139. * where the control works with the `action` that it's bound to, a registry control has signature:
  1140. * ```js
  1141. * ( registry ) => ( action ) => ( iteratorOrPromise )
  1142. * ```
  1143. * A registry control is typically used to select data or dispatch an action to a registered
  1144. * store.
  1145. *
  1146. * When registering a control created with `createRegistryControl` with a store, the store
  1147. * knows which calling convention to use when executing the control.
  1148. *
  1149. * @param {Function} registryControl Function receiving a registry object and returning a control.
  1150. *
  1151. * @return {Function} Registry control that can be registered with a store.
  1152. */
  1153. function createRegistryControl(registryControl) {
  1154. registryControl.isRegistryControl = true;
  1155. return registryControl;
  1156. }
  1157. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js
  1158. /**
  1159. * Internal dependencies
  1160. */
  1161. /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
  1162. const SELECT = '@@data/SELECT';
  1163. const RESOLVE_SELECT = '@@data/RESOLVE_SELECT';
  1164. const DISPATCH = '@@data/DISPATCH';
  1165. function isObject(object) {
  1166. return object !== null && typeof object === 'object';
  1167. }
  1168. /**
  1169. * Dispatches a control action for triggering a synchronous registry select.
  1170. *
  1171. * Note: This control synchronously returns the current selector value, triggering the
  1172. * resolution, but not waiting for it.
  1173. *
  1174. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  1175. * @param {string} selectorName The name of the selector.
  1176. * @param {Array} args Arguments for the selector.
  1177. *
  1178. * @example
  1179. * ```js
  1180. * import { controls } from '@wordpress/data';
  1181. *
  1182. * // Action generator using `select`.
  1183. * export function* myAction() {
  1184. * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );
  1185. * // Do stuff with the result from the `select`.
  1186. * }
  1187. * ```
  1188. *
  1189. * @return {Object} The control descriptor.
  1190. */
  1191. function controls_select(storeNameOrDescriptor, selectorName) {
  1192. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  1193. args[_key - 2] = arguments[_key];
  1194. }
  1195. return {
  1196. type: SELECT,
  1197. storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
  1198. selectorName,
  1199. args
  1200. };
  1201. }
  1202. /**
  1203. * Dispatches a control action for triggering and resolving a registry select.
  1204. *
  1205. * Note: when this control action is handled, it automatically considers
  1206. * selectors that may have a resolver. In such case, it will return a `Promise` that resolves
  1207. * after the selector finishes resolving, with the final result value.
  1208. *
  1209. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  1210. * @param {string} selectorName The name of the selector
  1211. * @param {Array} args Arguments for the selector.
  1212. *
  1213. * @example
  1214. * ```js
  1215. * import { controls } from '@wordpress/data';
  1216. *
  1217. * // Action generator using resolveSelect
  1218. * export function* myAction() {
  1219. * const isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );
  1220. * // do stuff with the result from the select.
  1221. * }
  1222. * ```
  1223. *
  1224. * @return {Object} The control descriptor.
  1225. */
  1226. function resolveSelect(storeNameOrDescriptor, selectorName) {
  1227. for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  1228. args[_key2 - 2] = arguments[_key2];
  1229. }
  1230. return {
  1231. type: RESOLVE_SELECT,
  1232. storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
  1233. selectorName,
  1234. args
  1235. };
  1236. }
  1237. /**
  1238. * Dispatches a control action for triggering a registry dispatch.
  1239. *
  1240. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  1241. * @param {string} actionName The name of the action to dispatch
  1242. * @param {Array} args Arguments for the dispatch action.
  1243. *
  1244. * @example
  1245. * ```js
  1246. * import { controls } from '@wordpress/data-controls';
  1247. *
  1248. * // Action generator using dispatch
  1249. * export function* myAction() {
  1250. * yield controls.dispatch( 'core/edit-post', 'togglePublishSidebar' );
  1251. * // do some other things.
  1252. * }
  1253. * ```
  1254. *
  1255. * @return {Object} The control descriptor.
  1256. */
  1257. function dispatch(storeNameOrDescriptor, actionName) {
  1258. for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
  1259. args[_key3 - 2] = arguments[_key3];
  1260. }
  1261. return {
  1262. type: DISPATCH,
  1263. storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
  1264. actionName,
  1265. args
  1266. };
  1267. }
  1268. const controls = {
  1269. select: controls_select,
  1270. resolveSelect,
  1271. dispatch
  1272. };
  1273. const builtinControls = {
  1274. [SELECT]: createRegistryControl(registry => _ref => {
  1275. let {
  1276. storeKey,
  1277. selectorName,
  1278. args
  1279. } = _ref;
  1280. return registry.select(storeKey)[selectorName](...args);
  1281. }),
  1282. [RESOLVE_SELECT]: createRegistryControl(registry => _ref2 => {
  1283. let {
  1284. storeKey,
  1285. selectorName,
  1286. args
  1287. } = _ref2;
  1288. const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select';
  1289. return registry[method](storeKey)[selectorName](...args);
  1290. }),
  1291. [DISPATCH]: createRegistryControl(registry => _ref3 => {
  1292. let {
  1293. storeKey,
  1294. actionName,
  1295. args
  1296. } = _ref3;
  1297. return registry.dispatch(storeKey)[actionName](...args);
  1298. })
  1299. };
  1300. ;// CONCATENATED MODULE: ./node_modules/is-promise/index.mjs
  1301. function isPromise(obj) {
  1302. return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
  1303. }
  1304. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js
  1305. /**
  1306. * External dependencies
  1307. */
  1308. /**
  1309. * Simplest possible promise redux middleware.
  1310. *
  1311. * @type {import('redux').Middleware}
  1312. */
  1313. const promiseMiddleware = () => next => action => {
  1314. if (isPromise(action)) {
  1315. return action.then(resolvedAction => {
  1316. if (resolvedAction) {
  1317. return next(resolvedAction);
  1318. }
  1319. });
  1320. }
  1321. return next(action);
  1322. };
  1323. /* harmony default export */ var promise_middleware = (promiseMiddleware);
  1324. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js
  1325. const coreDataStore = {
  1326. name: 'core/data',
  1327. instantiate(registry) {
  1328. const getCoreDataSelector = selectorName => function (key) {
  1329. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1330. args[_key - 1] = arguments[_key];
  1331. }
  1332. return registry.select(key)[selectorName](...args);
  1333. };
  1334. const getCoreDataAction = actionName => function (key) {
  1335. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  1336. args[_key2 - 1] = arguments[_key2];
  1337. }
  1338. return registry.dispatch(key)[actionName](...args);
  1339. };
  1340. return {
  1341. getSelectors() {
  1342. return Object.fromEntries(['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].map(selectorName => [selectorName, getCoreDataSelector(selectorName)]));
  1343. },
  1344. getActions() {
  1345. return Object.fromEntries(['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].map(actionName => [actionName, getCoreDataAction(actionName)]));
  1346. },
  1347. subscribe() {
  1348. // There's no reasons to trigger any listener when we subscribe to this store
  1349. // because there's no state stored in this store that need to retrigger selectors
  1350. // if a change happens, the corresponding store where the tracking stated live
  1351. // would have already triggered a "subscribe" call.
  1352. return () => () => {};
  1353. }
  1354. };
  1355. }
  1356. };
  1357. /* harmony default export */ var store = (coreDataStore);
  1358. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js
  1359. /**
  1360. * External dependencies
  1361. */
  1362. /**
  1363. * Internal dependencies
  1364. */
  1365. /** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */
  1366. /**
  1367. * Creates a middleware handling resolvers cache invalidation.
  1368. *
  1369. * @param {WPDataRegistry} registry The registry reference for which to create
  1370. * the middleware.
  1371. * @param {string} reducerKey The namespace for which to create the
  1372. * middleware.
  1373. *
  1374. * @return {Function} Middleware function.
  1375. */
  1376. const createResolversCacheMiddleware = (registry, reducerKey) => () => next => action => {
  1377. const resolvers = registry.select(store).getCachedResolvers(reducerKey);
  1378. Object.entries(resolvers).forEach(_ref => {
  1379. let [selectorName, resolversByArgs] = _ref;
  1380. const resolver = (0,external_lodash_namespaceObject.get)(registry.stores, [reducerKey, 'resolvers', selectorName]);
  1381. if (!resolver || !resolver.shouldInvalidate) {
  1382. return;
  1383. }
  1384. resolversByArgs.forEach((value, args) => {
  1385. // resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.
  1386. // If the value is "finished" or "error" it means this resolver has finished its resolution which means we need
  1387. // to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.
  1388. if ((value === null || value === void 0 ? void 0 : value.status) !== 'finished' && (value === null || value === void 0 ? void 0 : value.status) !== 'error' || !resolver.shouldInvalidate(action, ...args)) {
  1389. return;
  1390. } // Trigger cache invalidation
  1391. registry.dispatch(store).invalidateResolution(reducerKey, selectorName, args);
  1392. });
  1393. });
  1394. return next(action);
  1395. };
  1396. /* harmony default export */ var resolvers_cache_middleware = (createResolversCacheMiddleware);
  1397. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js
  1398. function createThunkMiddleware(args) {
  1399. return () => next => action => {
  1400. if (typeof action === 'function') {
  1401. return action(args);
  1402. }
  1403. return next(action);
  1404. };
  1405. }
  1406. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js
  1407. /**
  1408. * External dependencies
  1409. */
  1410. /**
  1411. * Higher-order reducer creator which creates a combined reducer object, keyed
  1412. * by a property on the action object.
  1413. *
  1414. * @param actionProperty Action property by which to key object.
  1415. * @return Higher-order reducer.
  1416. */
  1417. const onSubKey = actionProperty => reducer => function () {
  1418. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1419. let action = arguments.length > 1 ? arguments[1] : undefined;
  1420. // Retrieve subkey from action. Do not track if undefined; useful for cases
  1421. // where reducer is scoped by action shape.
  1422. const key = action[actionProperty];
  1423. if (key === undefined) {
  1424. return state;
  1425. } // Avoid updating state if unchanged. Note that this also accounts for a
  1426. // reducer which returns undefined on a key which is not yet tracked.
  1427. const nextKeyState = reducer(state[key], action);
  1428. if (nextKeyState === state[key]) {
  1429. return state;
  1430. }
  1431. return { ...state,
  1432. [key]: nextKeyState
  1433. };
  1434. };
  1435. /**
  1436. * Normalize selector argument array by defaulting `undefined` value to an empty array
  1437. * and removing trailing `undefined` values.
  1438. *
  1439. * @param args Selector argument array
  1440. * @return Normalized state key array
  1441. */
  1442. function selectorArgsToStateKey(args) {
  1443. if (args === undefined || args === null) {
  1444. return [];
  1445. }
  1446. const len = args.length;
  1447. let idx = len;
  1448. while (idx > 0 && args[idx - 1] === undefined) {
  1449. idx--;
  1450. }
  1451. return idx === len ? args : args.slice(0, idx);
  1452. }
  1453. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js
  1454. /**
  1455. * External dependencies
  1456. */
  1457. /**
  1458. * Internal dependencies
  1459. */
  1460. /**
  1461. * Reducer function returning next state for selector resolution of
  1462. * subkeys, object form:
  1463. *
  1464. * selectorName -> EquivalentKeyMap<Array,boolean>
  1465. */
  1466. const subKeysIsResolved = onSubKey('selectorName')(function () {
  1467. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new (equivalent_key_map_default())();
  1468. let action = arguments.length > 1 ? arguments[1] : undefined;
  1469. switch (action.type) {
  1470. case 'START_RESOLUTION':
  1471. {
  1472. const nextState = new (equivalent_key_map_default())(state);
  1473. nextState.set(selectorArgsToStateKey(action.args), {
  1474. status: 'resolving'
  1475. });
  1476. return nextState;
  1477. }
  1478. case 'FINISH_RESOLUTION':
  1479. {
  1480. const nextState = new (equivalent_key_map_default())(state);
  1481. nextState.set(selectorArgsToStateKey(action.args), {
  1482. status: 'finished'
  1483. });
  1484. return nextState;
  1485. }
  1486. case 'FAIL_RESOLUTION':
  1487. {
  1488. const nextState = new (equivalent_key_map_default())(state);
  1489. nextState.set(selectorArgsToStateKey(action.args), {
  1490. status: 'error',
  1491. error: action.error
  1492. });
  1493. return nextState;
  1494. }
  1495. case 'START_RESOLUTIONS':
  1496. {
  1497. const nextState = new (equivalent_key_map_default())(state);
  1498. for (const resolutionArgs of action.args) {
  1499. nextState.set(selectorArgsToStateKey(resolutionArgs), {
  1500. status: 'resolving'
  1501. });
  1502. }
  1503. return nextState;
  1504. }
  1505. case 'FINISH_RESOLUTIONS':
  1506. {
  1507. const nextState = new (equivalent_key_map_default())(state);
  1508. for (const resolutionArgs of action.args) {
  1509. nextState.set(selectorArgsToStateKey(resolutionArgs), {
  1510. status: 'finished'
  1511. });
  1512. }
  1513. return nextState;
  1514. }
  1515. case 'FAIL_RESOLUTIONS':
  1516. {
  1517. const nextState = new (equivalent_key_map_default())(state);
  1518. action.args.forEach((resolutionArgs, idx) => {
  1519. const resolutionState = {
  1520. status: 'error',
  1521. error: undefined
  1522. };
  1523. const error = action.errors[idx];
  1524. if (error) {
  1525. resolutionState.error = error;
  1526. }
  1527. nextState.set(selectorArgsToStateKey(resolutionArgs), resolutionState);
  1528. });
  1529. return nextState;
  1530. }
  1531. case 'INVALIDATE_RESOLUTION':
  1532. {
  1533. const nextState = new (equivalent_key_map_default())(state);
  1534. nextState.delete(selectorArgsToStateKey(action.args));
  1535. return nextState;
  1536. }
  1537. }
  1538. return state;
  1539. });
  1540. /**
  1541. * Reducer function returning next state for selector resolution, object form:
  1542. *
  1543. * selectorName -> EquivalentKeyMap<Array, boolean>
  1544. *
  1545. * @param state Current state.
  1546. * @param action Dispatched action.
  1547. *
  1548. * @return Next state.
  1549. */
  1550. const isResolved = function () {
  1551. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1552. let action = arguments.length > 1 ? arguments[1] : undefined;
  1553. switch (action.type) {
  1554. case 'INVALIDATE_RESOLUTION_FOR_STORE':
  1555. return {};
  1556. case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR':
  1557. {
  1558. if (action.selectorName in state) {
  1559. const {
  1560. [action.selectorName]: removedSelector,
  1561. ...restState
  1562. } = state;
  1563. return restState;
  1564. }
  1565. return state;
  1566. }
  1567. case 'START_RESOLUTION':
  1568. case 'FINISH_RESOLUTION':
  1569. case 'FAIL_RESOLUTION':
  1570. case 'START_RESOLUTIONS':
  1571. case 'FINISH_RESOLUTIONS':
  1572. case 'FAIL_RESOLUTIONS':
  1573. case 'INVALIDATE_RESOLUTION':
  1574. return subKeysIsResolved(state, action);
  1575. }
  1576. return state;
  1577. };
  1578. /* harmony default export */ var metadata_reducer = (isResolved);
  1579. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js
  1580. /**
  1581. * External dependencies
  1582. */
  1583. /**
  1584. * Internal dependencies
  1585. */
  1586. /** @typedef {Record<string, import('./reducer').State>} State */
  1587. /** @typedef {import('./reducer').StateValue} StateValue */
  1588. /** @typedef {import('./reducer').Status} Status */
  1589. /**
  1590. * Returns the raw resolution state value for a given selector name,
  1591. * and arguments set. May be undefined if the selector has never been resolved
  1592. * or not resolved for the given set of arguments, otherwise true or false for
  1593. * resolution started and completed respectively.
  1594. *
  1595. * @param {State} state Data state.
  1596. * @param {string} selectorName Selector name.
  1597. * @param {unknown[]?} args Arguments passed to selector.
  1598. *
  1599. * @return {StateValue|undefined} isResolving value.
  1600. */
  1601. function getResolutionState(state, selectorName, args) {
  1602. const map = (0,external_lodash_namespaceObject.get)(state, [selectorName]);
  1603. if (!map) {
  1604. return;
  1605. }
  1606. return map.get(selectorArgsToStateKey(args));
  1607. }
  1608. /**
  1609. * Returns the raw `isResolving` value for a given selector name,
  1610. * and arguments set. May be undefined if the selector has never been resolved
  1611. * or not resolved for the given set of arguments, otherwise true or false for
  1612. * resolution started and completed respectively.
  1613. *
  1614. * @param {State} state Data state.
  1615. * @param {string} selectorName Selector name.
  1616. * @param {unknown[]?} args Arguments passed to selector.
  1617. *
  1618. * @return {boolean | undefined} isResolving value.
  1619. */
  1620. function getIsResolving(state, selectorName, args) {
  1621. const resolutionState = getResolutionState(state, selectorName, args);
  1622. return resolutionState && resolutionState.status === 'resolving';
  1623. }
  1624. /**
  1625. * Returns true if resolution has already been triggered for a given
  1626. * selector name, and arguments set.
  1627. *
  1628. * @param {State} state Data state.
  1629. * @param {string} selectorName Selector name.
  1630. * @param {unknown[]?} args Arguments passed to selector.
  1631. *
  1632. * @return {boolean} Whether resolution has been triggered.
  1633. */
  1634. function hasStartedResolution(state, selectorName, args) {
  1635. return getResolutionState(state, selectorName, args) !== undefined;
  1636. }
  1637. /**
  1638. * Returns true if resolution has completed for a given selector
  1639. * name, and arguments set.
  1640. *
  1641. * @param {State} state Data state.
  1642. * @param {string} selectorName Selector name.
  1643. * @param {unknown[]?} args Arguments passed to selector.
  1644. *
  1645. * @return {boolean} Whether resolution has completed.
  1646. */
  1647. function hasFinishedResolution(state, selectorName, args) {
  1648. var _getResolutionState;
  1649. const status = (_getResolutionState = getResolutionState(state, selectorName, args)) === null || _getResolutionState === void 0 ? void 0 : _getResolutionState.status;
  1650. return status === 'finished' || status === 'error';
  1651. }
  1652. /**
  1653. * Returns true if resolution has failed for a given selector
  1654. * name, and arguments set.
  1655. *
  1656. * @param {State} state Data state.
  1657. * @param {string} selectorName Selector name.
  1658. * @param {unknown[]?} args Arguments passed to selector.
  1659. *
  1660. * @return {boolean} Has resolution failed
  1661. */
  1662. function hasResolutionFailed(state, selectorName, args) {
  1663. var _getResolutionState2;
  1664. return ((_getResolutionState2 = getResolutionState(state, selectorName, args)) === null || _getResolutionState2 === void 0 ? void 0 : _getResolutionState2.status) === 'error';
  1665. }
  1666. /**
  1667. * Returns the resolution error for a given selector name, and arguments set.
  1668. * Note it may be of an Error type, but may also be null, undefined, or anything else
  1669. * that can be `throw`-n.
  1670. *
  1671. * @param {State} state Data state.
  1672. * @param {string} selectorName Selector name.
  1673. * @param {unknown[]?} args Arguments passed to selector.
  1674. *
  1675. * @return {Error|unknown} Last resolution error
  1676. */
  1677. function getResolutionError(state, selectorName, args) {
  1678. const resolutionState = getResolutionState(state, selectorName, args);
  1679. return (resolutionState === null || resolutionState === void 0 ? void 0 : resolutionState.status) === 'error' ? resolutionState.error : null;
  1680. }
  1681. /**
  1682. * Returns true if resolution has been triggered but has not yet completed for
  1683. * a given selector name, and arguments set.
  1684. *
  1685. * @param {State} state Data state.
  1686. * @param {string} selectorName Selector name.
  1687. * @param {unknown[]?} args Arguments passed to selector.
  1688. *
  1689. * @return {boolean} Whether resolution is in progress.
  1690. */
  1691. function isResolving(state, selectorName, args) {
  1692. var _getResolutionState3;
  1693. return ((_getResolutionState3 = getResolutionState(state, selectorName, args)) === null || _getResolutionState3 === void 0 ? void 0 : _getResolutionState3.status) === 'resolving';
  1694. }
  1695. /**
  1696. * Returns the list of the cached resolvers.
  1697. *
  1698. * @param {State} state Data state.
  1699. *
  1700. * @return {State} Resolvers mapped by args and selectorName.
  1701. */
  1702. function getCachedResolvers(state) {
  1703. return state;
  1704. }
  1705. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js
  1706. /**
  1707. * Returns an action object used in signalling that selector resolution has
  1708. * started.
  1709. *
  1710. * @param {string} selectorName Name of selector for which resolver triggered.
  1711. * @param {unknown[]} args Arguments to associate for uniqueness.
  1712. *
  1713. * @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object.
  1714. */
  1715. function startResolution(selectorName, args) {
  1716. return {
  1717. type: 'START_RESOLUTION',
  1718. selectorName,
  1719. args
  1720. };
  1721. }
  1722. /**
  1723. * Returns an action object used in signalling that selector resolution has
  1724. * completed.
  1725. *
  1726. * @param {string} selectorName Name of selector for which resolver triggered.
  1727. * @param {unknown[]} args Arguments to associate for uniqueness.
  1728. *
  1729. * @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object.
  1730. */
  1731. function finishResolution(selectorName, args) {
  1732. return {
  1733. type: 'FINISH_RESOLUTION',
  1734. selectorName,
  1735. args
  1736. };
  1737. }
  1738. /**
  1739. * Returns an action object used in signalling that selector resolution has
  1740. * failed.
  1741. *
  1742. * @param {string} selectorName Name of selector for which resolver triggered.
  1743. * @param {unknown[]} args Arguments to associate for uniqueness.
  1744. * @param {Error|unknown} error The error that caused the failure.
  1745. *
  1746. * @return {{ type: 'FAIL_RESOLUTION', selectorName: string, args: unknown[], error: Error|unknown }} Action object.
  1747. */
  1748. function failResolution(selectorName, args, error) {
  1749. return {
  1750. type: 'FAIL_RESOLUTION',
  1751. selectorName,
  1752. args,
  1753. error
  1754. };
  1755. }
  1756. /**
  1757. * Returns an action object used in signalling that a batch of selector resolutions has
  1758. * started.
  1759. *
  1760. * @param {string} selectorName Name of selector for which resolver triggered.
  1761. * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
  1762. * is associated to a resolution.
  1763. *
  1764. * @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
  1765. */
  1766. function startResolutions(selectorName, args) {
  1767. return {
  1768. type: 'START_RESOLUTIONS',
  1769. selectorName,
  1770. args
  1771. };
  1772. }
  1773. /**
  1774. * Returns an action object used in signalling that a batch of selector resolutions has
  1775. * completed.
  1776. *
  1777. * @param {string} selectorName Name of selector for which resolver triggered.
  1778. * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
  1779. * is associated to a resolution.
  1780. *
  1781. * @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
  1782. */
  1783. function finishResolutions(selectorName, args) {
  1784. return {
  1785. type: 'FINISH_RESOLUTIONS',
  1786. selectorName,
  1787. args
  1788. };
  1789. }
  1790. /**
  1791. * Returns an action object used in signalling that a batch of selector resolutions has
  1792. * completed and at least one of them has failed.
  1793. *
  1794. * @param {string} selectorName Name of selector for which resolver triggered.
  1795. * @param {unknown[]} args Array of arguments to associate for uniqueness, each item
  1796. * is associated to a resolution.
  1797. * @param {(Error|unknown)[]} errors Array of errors to associate for uniqueness, each item
  1798. * is associated to a resolution.
  1799. * @return {{ type: 'FAIL_RESOLUTIONS', selectorName: string, args: unknown[], errors: Array<Error|unknown> }} Action object.
  1800. */
  1801. function failResolutions(selectorName, args, errors) {
  1802. return {
  1803. type: 'FAIL_RESOLUTIONS',
  1804. selectorName,
  1805. args,
  1806. errors
  1807. };
  1808. }
  1809. /**
  1810. * Returns an action object used in signalling that we should invalidate the resolution cache.
  1811. *
  1812. * @param {string} selectorName Name of selector for which resolver should be invalidated.
  1813. * @param {unknown[]} args Arguments to associate for uniqueness.
  1814. *
  1815. * @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object.
  1816. */
  1817. function invalidateResolution(selectorName, args) {
  1818. return {
  1819. type: 'INVALIDATE_RESOLUTION',
  1820. selectorName,
  1821. args
  1822. };
  1823. }
  1824. /**
  1825. * Returns an action object used in signalling that the resolution
  1826. * should be invalidated.
  1827. *
  1828. * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE' }} Action object.
  1829. */
  1830. function invalidateResolutionForStore() {
  1831. return {
  1832. type: 'INVALIDATE_RESOLUTION_FOR_STORE'
  1833. };
  1834. }
  1835. /**
  1836. * Returns an action object used in signalling that the resolution cache for a
  1837. * given selectorName should be invalidated.
  1838. *
  1839. * @param {string} selectorName Name of selector for which all resolvers should
  1840. * be invalidated.
  1841. *
  1842. * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', selectorName: string }} Action object.
  1843. */
  1844. function invalidateResolutionForStoreSelector(selectorName) {
  1845. return {
  1846. type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR',
  1847. selectorName
  1848. };
  1849. }
  1850. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js
  1851. /**
  1852. * External dependencies
  1853. */
  1854. /**
  1855. * WordPress dependencies
  1856. */
  1857. /**
  1858. * Internal dependencies
  1859. */
  1860. /** @typedef {import('../types').DataRegistry} DataRegistry */
  1861. /**
  1862. * @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor
  1863. * @template C
  1864. */
  1865. /**
  1866. * @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
  1867. * @template State,Actions,Selectors
  1868. */
  1869. const trimUndefinedValues = array => {
  1870. const result = [...array];
  1871. for (let i = result.length - 1; i >= 0; i--) {
  1872. if (result[i] === undefined) {
  1873. result.splice(i, 1);
  1874. }
  1875. }
  1876. return result;
  1877. };
  1878. /**
  1879. * Create a cache to track whether resolvers started running or not.
  1880. *
  1881. * @return {Object} Resolvers Cache.
  1882. */
  1883. function createResolversCache() {
  1884. const cache = {};
  1885. return {
  1886. isRunning(selectorName, args) {
  1887. return cache[selectorName] && cache[selectorName].get(trimUndefinedValues(args));
  1888. },
  1889. clear(selectorName, args) {
  1890. if (cache[selectorName]) {
  1891. cache[selectorName].delete(trimUndefinedValues(args));
  1892. }
  1893. },
  1894. markAsRunning(selectorName, args) {
  1895. if (!cache[selectorName]) {
  1896. cache[selectorName] = new (equivalent_key_map_default())();
  1897. }
  1898. cache[selectorName].set(trimUndefinedValues(args), true);
  1899. }
  1900. };
  1901. }
  1902. /**
  1903. * Creates a data store descriptor for the provided Redux store configuration containing
  1904. * properties describing reducer, actions, selectors, controls and resolvers.
  1905. *
  1906. * @example
  1907. * ```js
  1908. * import { createReduxStore } from '@wordpress/data';
  1909. *
  1910. * const store = createReduxStore( 'demo', {
  1911. * reducer: ( state = 'OK' ) => state,
  1912. * selectors: {
  1913. * getValue: ( state ) => state,
  1914. * },
  1915. * } );
  1916. * ```
  1917. *
  1918. * @template State,Actions,Selectors
  1919. * @param {string} key Unique namespace identifier.
  1920. * @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties
  1921. * describing reducer, actions, selectors,
  1922. * and resolvers.
  1923. *
  1924. * @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.
  1925. */
  1926. function createReduxStore(key, options) {
  1927. return {
  1928. name: key,
  1929. instantiate: registry => {
  1930. const reducer = options.reducer;
  1931. const thunkArgs = {
  1932. registry,
  1933. get dispatch() {
  1934. return Object.assign(action => store.dispatch(action), getActions());
  1935. },
  1936. get select() {
  1937. return Object.assign(selector => selector(store.__unstableOriginalGetState()), getSelectors());
  1938. },
  1939. get resolveSelect() {
  1940. return getResolveSelectors();
  1941. }
  1942. };
  1943. const store = instantiateReduxStore(key, options, registry, thunkArgs);
  1944. const resolversCache = createResolversCache();
  1945. let resolvers;
  1946. const actions = mapActions({ ...actions_namespaceObject,
  1947. ...options.actions
  1948. }, store);
  1949. let selectors = mapSelectors({ ...(0,external_lodash_namespaceObject.mapValues)(selectors_namespaceObject, selector => function (state) {
  1950. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1951. args[_key - 1] = arguments[_key];
  1952. }
  1953. return selector(state.metadata, ...args);
  1954. }),
  1955. ...(0,external_lodash_namespaceObject.mapValues)(options.selectors, selector => {
  1956. if (selector.isRegistrySelector) {
  1957. selector.registry = registry;
  1958. }
  1959. return function (state) {
  1960. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  1961. args[_key2 - 1] = arguments[_key2];
  1962. }
  1963. return selector(state.root, ...args);
  1964. };
  1965. })
  1966. }, store);
  1967. if (options.resolvers) {
  1968. const result = mapResolvers(options.resolvers, selectors, store, resolversCache);
  1969. resolvers = result.resolvers;
  1970. selectors = result.selectors;
  1971. }
  1972. const resolveSelectors = mapResolveSelectors(selectors, store);
  1973. const suspendSelectors = mapSuspendSelectors(selectors, store);
  1974. const getSelectors = () => selectors;
  1975. const getActions = () => actions;
  1976. const getResolveSelectors = () => resolveSelectors;
  1977. const getSuspendSelectors = () => suspendSelectors; // We have some modules monkey-patching the store object
  1978. // It's wrong to do so but until we refactor all of our effects to controls
  1979. // We need to keep the same "store" instance here.
  1980. store.__unstableOriginalGetState = store.getState;
  1981. store.getState = () => store.__unstableOriginalGetState().root; // Customize subscribe behavior to call listeners only on effective change,
  1982. // not on every dispatch.
  1983. const subscribe = store && (listener => {
  1984. let lastState = store.__unstableOriginalGetState();
  1985. return store.subscribe(() => {
  1986. const state = store.__unstableOriginalGetState();
  1987. const hasChanged = state !== lastState;
  1988. lastState = state;
  1989. if (hasChanged) {
  1990. listener();
  1991. }
  1992. });
  1993. }); // This can be simplified to just { subscribe, getSelectors, getActions }
  1994. // Once we remove the use function.
  1995. return {
  1996. reducer,
  1997. store,
  1998. actions,
  1999. selectors,
  2000. resolvers,
  2001. getSelectors,
  2002. getResolveSelectors,
  2003. getSuspendSelectors,
  2004. getActions,
  2005. subscribe
  2006. };
  2007. }
  2008. };
  2009. }
  2010. /**
  2011. * Creates a redux store for a namespace.
  2012. *
  2013. * @param {string} key Unique namespace identifier.
  2014. * @param {Object} options Registered store options, with properties
  2015. * describing reducer, actions, selectors,
  2016. * and resolvers.
  2017. * @param {DataRegistry} registry Registry reference.
  2018. * @param {Object} thunkArgs Argument object for the thunk middleware.
  2019. * @return {Object} Newly created redux store.
  2020. */
  2021. function instantiateReduxStore(key, options, registry, thunkArgs) {
  2022. const controls = { ...options.controls,
  2023. ...builtinControls
  2024. };
  2025. const normalizedControls = (0,external_lodash_namespaceObject.mapValues)(controls, control => control.isRegistryControl ? control(registry) : control);
  2026. const middlewares = [resolvers_cache_middleware(registry, key), promise_middleware, external_wp_reduxRoutine_default()(normalizedControls), createThunkMiddleware(thunkArgs)];
  2027. const enhancers = [applyMiddleware(...middlewares)];
  2028. if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
  2029. enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__({
  2030. name: key,
  2031. instanceId: key
  2032. }));
  2033. }
  2034. const {
  2035. reducer,
  2036. initialState
  2037. } = options;
  2038. const enhancedReducer = turbo_combine_reducers_default()({
  2039. metadata: metadata_reducer,
  2040. root: reducer
  2041. });
  2042. return createStore(enhancedReducer, {
  2043. root: initialState
  2044. }, (0,external_lodash_namespaceObject.flowRight)(enhancers));
  2045. }
  2046. /**
  2047. * Maps selectors to a store.
  2048. *
  2049. * @param {Object} selectors Selectors to register. Keys will be used as the
  2050. * public facing API. Selectors will get passed the
  2051. * state as first argument.
  2052. * @param {Object} store The store to which the selectors should be mapped.
  2053. * @return {Object} Selectors mapped to the provided store.
  2054. */
  2055. function mapSelectors(selectors, store) {
  2056. const createStateSelector = registrySelector => {
  2057. const selector = function runSelector() {
  2058. // This function is an optimized implementation of:
  2059. //
  2060. // selector( store.getState(), ...arguments )
  2061. //
  2062. // Where the above would incur an `Array#concat` in its application,
  2063. // the logic here instead efficiently constructs an arguments array via
  2064. // direct assignment.
  2065. const argsLength = arguments.length;
  2066. const args = new Array(argsLength + 1);
  2067. args[0] = store.__unstableOriginalGetState();
  2068. for (let i = 0; i < argsLength; i++) {
  2069. args[i + 1] = arguments[i];
  2070. }
  2071. return registrySelector(...args);
  2072. };
  2073. selector.hasResolver = false;
  2074. return selector;
  2075. };
  2076. return (0,external_lodash_namespaceObject.mapValues)(selectors, createStateSelector);
  2077. }
  2078. /**
  2079. * Maps actions to dispatch from a given store.
  2080. *
  2081. * @param {Object} actions Actions to register.
  2082. * @param {Object} store The redux store to which the actions should be mapped.
  2083. *
  2084. * @return {Object} Actions mapped to the redux store provided.
  2085. */
  2086. function mapActions(actions, store) {
  2087. const createBoundAction = action => function () {
  2088. return Promise.resolve(store.dispatch(action(...arguments)));
  2089. };
  2090. return (0,external_lodash_namespaceObject.mapValues)(actions, createBoundAction);
  2091. }
  2092. /**
  2093. * Maps selectors to functions that return a resolution promise for them
  2094. *
  2095. * @param {Object} selectors Selectors to map.
  2096. * @param {Object} store The redux store the selectors select from.
  2097. *
  2098. * @return {Object} Selectors mapped to their resolution functions.
  2099. */
  2100. function mapResolveSelectors(selectors, store) {
  2101. const {
  2102. getIsResolving,
  2103. hasStartedResolution,
  2104. hasFinishedResolution,
  2105. hasResolutionFailed,
  2106. isResolving,
  2107. getCachedResolvers,
  2108. getResolutionState,
  2109. getResolutionError,
  2110. ...storeSelectors
  2111. } = selectors;
  2112. return (0,external_lodash_namespaceObject.mapValues)(storeSelectors, (selector, selectorName) => {
  2113. // If the selector doesn't have a resolver, just convert the return value
  2114. // (including exceptions) to a Promise, no additional extra behavior is needed.
  2115. if (!selector.hasResolver) {
  2116. return async function () {
  2117. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  2118. args[_key3] = arguments[_key3];
  2119. }
  2120. return selector.apply(null, args);
  2121. };
  2122. }
  2123. return function () {
  2124. for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  2125. args[_key4] = arguments[_key4];
  2126. }
  2127. return new Promise((resolve, reject) => {
  2128. const hasFinished = () => selectors.hasFinishedResolution(selectorName, args);
  2129. const finalize = result => {
  2130. const hasFailed = selectors.hasResolutionFailed(selectorName, args);
  2131. if (hasFailed) {
  2132. const error = selectors.getResolutionError(selectorName, args);
  2133. reject(error);
  2134. } else {
  2135. resolve(result);
  2136. }
  2137. };
  2138. const getResult = () => selector.apply(null, args); // Trigger the selector (to trigger the resolver)
  2139. const result = getResult();
  2140. if (hasFinished()) {
  2141. return finalize(result);
  2142. }
  2143. const unsubscribe = store.subscribe(() => {
  2144. if (hasFinished()) {
  2145. unsubscribe();
  2146. finalize(getResult());
  2147. }
  2148. });
  2149. });
  2150. };
  2151. });
  2152. }
  2153. /**
  2154. * Maps selectors to functions that throw a suspense promise if not yet resolved.
  2155. *
  2156. * @param {Object} selectors Selectors to map.
  2157. * @param {Object} store The redux store the selectors select from.
  2158. *
  2159. * @return {Object} Selectors mapped to their suspense functions.
  2160. */
  2161. function mapSuspendSelectors(selectors, store) {
  2162. return (0,external_lodash_namespaceObject.mapValues)(selectors, (selector, selectorName) => {
  2163. // Selector without a resolver doesn't have any extra suspense behavior.
  2164. if (!selector.hasResolver) {
  2165. return selector;
  2166. }
  2167. return function () {
  2168. for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  2169. args[_key5] = arguments[_key5];
  2170. }
  2171. const result = selector.apply(null, args);
  2172. if (selectors.hasFinishedResolution(selectorName, args)) {
  2173. if (selectors.hasResolutionFailed(selectorName, args)) {
  2174. throw selectors.getResolutionError(selectorName, args);
  2175. }
  2176. return result;
  2177. }
  2178. throw new Promise(resolve => {
  2179. const unsubscribe = store.subscribe(() => {
  2180. if (selectors.hasFinishedResolution(selectorName, args)) {
  2181. resolve();
  2182. unsubscribe();
  2183. }
  2184. });
  2185. });
  2186. };
  2187. });
  2188. }
  2189. /**
  2190. * Returns resolvers with matched selectors for a given namespace.
  2191. * Resolvers are side effects invoked once per argument set of a given selector call,
  2192. * used in ensuring that the data needs for the selector are satisfied.
  2193. *
  2194. * @param {Object} resolvers Resolvers to register.
  2195. * @param {Object} selectors The current selectors to be modified.
  2196. * @param {Object} store The redux store to which the resolvers should be mapped.
  2197. * @param {Object} resolversCache Resolvers Cache.
  2198. */
  2199. function mapResolvers(resolvers, selectors, store, resolversCache) {
  2200. // The `resolver` can be either a function that does the resolution, or, in more advanced
  2201. // cases, an object with a `fullfill` method and other optional methods like `isFulfilled`.
  2202. // Here we normalize the `resolver` function to an object with `fulfill` method.
  2203. const mappedResolvers = (0,external_lodash_namespaceObject.mapValues)(resolvers, resolver => {
  2204. if (resolver.fulfill) {
  2205. return resolver;
  2206. }
  2207. return { ...resolver,
  2208. // Copy the enumerable properties of the resolver function.
  2209. fulfill: resolver // Add the fulfill method.
  2210. };
  2211. });
  2212. const mapSelector = (selector, selectorName) => {
  2213. const resolver = resolvers[selectorName];
  2214. if (!resolver) {
  2215. selector.hasResolver = false;
  2216. return selector;
  2217. }
  2218. const selectorResolver = function () {
  2219. for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  2220. args[_key6] = arguments[_key6];
  2221. }
  2222. async function fulfillSelector() {
  2223. const state = store.getState();
  2224. if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) {
  2225. return;
  2226. }
  2227. const {
  2228. metadata
  2229. } = store.__unstableOriginalGetState();
  2230. if (hasStartedResolution(metadata, selectorName, args)) {
  2231. return;
  2232. }
  2233. resolversCache.markAsRunning(selectorName, args);
  2234. setTimeout(async () => {
  2235. resolversCache.clear(selectorName, args);
  2236. store.dispatch(startResolution(selectorName, args));
  2237. try {
  2238. await fulfillResolver(store, mappedResolvers, selectorName, ...args);
  2239. store.dispatch(finishResolution(selectorName, args));
  2240. } catch (error) {
  2241. store.dispatch(failResolution(selectorName, args, error));
  2242. }
  2243. });
  2244. }
  2245. fulfillSelector(...args);
  2246. return selector(...args);
  2247. };
  2248. selectorResolver.hasResolver = true;
  2249. return selectorResolver;
  2250. };
  2251. return {
  2252. resolvers: mappedResolvers,
  2253. selectors: (0,external_lodash_namespaceObject.mapValues)(selectors, mapSelector)
  2254. };
  2255. }
  2256. /**
  2257. * Calls a resolver given arguments
  2258. *
  2259. * @param {Object} store Store reference, for fulfilling via resolvers
  2260. * @param {Object} resolvers Store Resolvers
  2261. * @param {string} selectorName Selector name to fulfill.
  2262. * @param {Array} args Selector Arguments.
  2263. */
  2264. async function fulfillResolver(store, resolvers, selectorName) {
  2265. const resolver = (0,external_lodash_namespaceObject.get)(resolvers, [selectorName]);
  2266. if (!resolver) {
  2267. return;
  2268. }
  2269. for (var _len7 = arguments.length, args = new Array(_len7 > 3 ? _len7 - 3 : 0), _key7 = 3; _key7 < _len7; _key7++) {
  2270. args[_key7 - 3] = arguments[_key7];
  2271. }
  2272. const action = resolver.fulfill(...args);
  2273. if (action) {
  2274. await store.dispatch(action);
  2275. }
  2276. }
  2277. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/utils/emitter.js
  2278. /**
  2279. * Create an event emitter.
  2280. *
  2281. * @return {import("../types").DataEmitter} Emitter.
  2282. */
  2283. function createEmitter() {
  2284. let isPaused = false;
  2285. let isPending = false;
  2286. const listeners = new Set();
  2287. const notifyListeners = () => // We use Array.from to clone the listeners Set
  2288. // This ensures that we don't run a listener
  2289. // that was added as a response to another listener.
  2290. Array.from(listeners).forEach(listener => listener());
  2291. return {
  2292. get isPaused() {
  2293. return isPaused;
  2294. },
  2295. subscribe(listener) {
  2296. listeners.add(listener);
  2297. return () => listeners.delete(listener);
  2298. },
  2299. pause() {
  2300. isPaused = true;
  2301. },
  2302. resume() {
  2303. isPaused = false;
  2304. if (isPending) {
  2305. isPending = false;
  2306. notifyListeners();
  2307. }
  2308. },
  2309. emit() {
  2310. if (isPaused) {
  2311. isPending = true;
  2312. return;
  2313. }
  2314. notifyListeners();
  2315. }
  2316. };
  2317. }
  2318. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js
  2319. /**
  2320. * External dependencies
  2321. */
  2322. /**
  2323. * WordPress dependencies
  2324. */
  2325. /**
  2326. * Internal dependencies
  2327. */
  2328. /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
  2329. /**
  2330. * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.
  2331. *
  2332. * @property {Function} registerGenericStore Given a namespace key and settings
  2333. * object, registers a new generic
  2334. * store.
  2335. * @property {Function} registerStore Given a namespace key and settings
  2336. * object, registers a new namespace
  2337. * store.
  2338. * @property {Function} subscribe Given a function callback, invokes
  2339. * the callback on any change to state
  2340. * within any registered store.
  2341. * @property {Function} select Given a namespace key, returns an
  2342. * object of the store's registered
  2343. * selectors.
  2344. * @property {Function} dispatch Given a namespace key, returns an
  2345. * object of the store's registered
  2346. * action dispatchers.
  2347. */
  2348. /**
  2349. * @typedef {Object} WPDataPlugin An object of registry function overrides.
  2350. *
  2351. * @property {Function} registerStore registers store.
  2352. */
  2353. function registry_isObject(object) {
  2354. return object !== null && typeof object === 'object';
  2355. }
  2356. /**
  2357. * Creates a new store registry, given an optional object of initial store
  2358. * configurations.
  2359. *
  2360. * @param {Object} storeConfigs Initial store configurations.
  2361. * @param {Object?} parent Parent registry.
  2362. *
  2363. * @return {WPDataRegistry} Data registry.
  2364. */
  2365. function createRegistry() {
  2366. let storeConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2367. let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2368. const stores = {};
  2369. const emitter = createEmitter();
  2370. const listeningStores = new Set();
  2371. /**
  2372. * Global listener called for each store's update.
  2373. */
  2374. function globalListener() {
  2375. emitter.emit();
  2376. }
  2377. /**
  2378. * Subscribe to changes to any data.
  2379. *
  2380. * @param {Function} listener Listener function.
  2381. *
  2382. * @return {Function} Unsubscribe function.
  2383. */
  2384. const subscribe = listener => {
  2385. return emitter.subscribe(listener);
  2386. };
  2387. /**
  2388. * Calls a selector given the current state and extra arguments.
  2389. *
  2390. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  2391. * or the store descriptor.
  2392. *
  2393. * @return {*} The selector's returned value.
  2394. */
  2395. function select(storeNameOrDescriptor) {
  2396. const storeName = registry_isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor;
  2397. listeningStores.add(storeName);
  2398. const store = stores[storeName];
  2399. if (store) {
  2400. return store.getSelectors();
  2401. }
  2402. return parent === null || parent === void 0 ? void 0 : parent.select(storeName);
  2403. }
  2404. function __unstableMarkListeningStores(callback, ref) {
  2405. listeningStores.clear();
  2406. try {
  2407. return callback.call(this);
  2408. } finally {
  2409. ref.current = Array.from(listeningStores);
  2410. }
  2411. }
  2412. /**
  2413. * Given a store descriptor, returns an object containing the store's selectors pre-bound to
  2414. * state so that you only need to supply additional arguments, and modified so that they return
  2415. * promises that resolve to their eventual values, after any resolvers have ran.
  2416. *
  2417. * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
  2418. * convention of passing the store name is
  2419. * also supported.
  2420. *
  2421. * @return {Object} Each key of the object matches the name of a selector.
  2422. */
  2423. function resolveSelect(storeNameOrDescriptor) {
  2424. const storeName = registry_isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor;
  2425. listeningStores.add(storeName);
  2426. const store = stores[storeName];
  2427. if (store) {
  2428. return store.getResolveSelectors();
  2429. }
  2430. return parent && parent.resolveSelect(storeName);
  2431. }
  2432. /**
  2433. * Given a store descriptor, returns an object containing the store's selectors pre-bound to
  2434. * state so that you only need to supply additional arguments, and modified so that they throw
  2435. * promises in case the selector is not resolved yet.
  2436. *
  2437. * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
  2438. * convention of passing the store name is
  2439. * also supported.
  2440. *
  2441. * @return {Object} Object containing the store's suspense-wrapped selectors.
  2442. */
  2443. function suspendSelect(storeNameOrDescriptor) {
  2444. const storeName = registry_isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor;
  2445. listeningStores.add(storeName);
  2446. const store = stores[storeName];
  2447. if (store) {
  2448. return store.getSuspendSelectors();
  2449. }
  2450. return parent && parent.suspendSelect(storeName);
  2451. }
  2452. /**
  2453. * Returns the available actions for a part of the state.
  2454. *
  2455. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  2456. * or the store descriptor.
  2457. *
  2458. * @return {*} The action's returned value.
  2459. */
  2460. function dispatch(storeNameOrDescriptor) {
  2461. const storeName = registry_isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor;
  2462. const store = stores[storeName];
  2463. if (store) {
  2464. return store.getActions();
  2465. }
  2466. return parent && parent.dispatch(storeName);
  2467. } //
  2468. // Deprecated
  2469. // TODO: Remove this after `use()` is removed.
  2470. function withPlugins(attributes) {
  2471. return (0,external_lodash_namespaceObject.mapValues)(attributes, (attribute, key) => {
  2472. if (typeof attribute !== 'function') {
  2473. return attribute;
  2474. }
  2475. return function () {
  2476. return registry[key].apply(null, arguments);
  2477. };
  2478. });
  2479. }
  2480. /**
  2481. * Registers a store instance.
  2482. *
  2483. * @param {string} name Store registry name.
  2484. * @param {Object} store Store instance object (getSelectors, getActions, subscribe).
  2485. */
  2486. function registerStoreInstance(name, store) {
  2487. if (typeof store.getSelectors !== 'function') {
  2488. throw new TypeError('store.getSelectors must be a function');
  2489. }
  2490. if (typeof store.getActions !== 'function') {
  2491. throw new TypeError('store.getActions must be a function');
  2492. }
  2493. if (typeof store.subscribe !== 'function') {
  2494. throw new TypeError('store.subscribe must be a function');
  2495. } // The emitter is used to keep track of active listeners when the registry
  2496. // get paused, that way, when resumed we should be able to call all these
  2497. // pending listeners.
  2498. store.emitter = createEmitter();
  2499. const currentSubscribe = store.subscribe;
  2500. store.subscribe = listener => {
  2501. const unsubscribeFromEmitter = store.emitter.subscribe(listener);
  2502. const unsubscribeFromStore = currentSubscribe(() => {
  2503. if (store.emitter.isPaused) {
  2504. store.emitter.emit();
  2505. return;
  2506. }
  2507. listener();
  2508. });
  2509. return () => {
  2510. unsubscribeFromStore === null || unsubscribeFromStore === void 0 ? void 0 : unsubscribeFromStore();
  2511. unsubscribeFromEmitter === null || unsubscribeFromEmitter === void 0 ? void 0 : unsubscribeFromEmitter();
  2512. };
  2513. };
  2514. stores[name] = store;
  2515. store.subscribe(globalListener);
  2516. }
  2517. /**
  2518. * Registers a new store given a store descriptor.
  2519. *
  2520. * @param {StoreDescriptor} store Store descriptor.
  2521. */
  2522. function register(store) {
  2523. registerStoreInstance(store.name, store.instantiate(registry));
  2524. }
  2525. function registerGenericStore(name, store) {
  2526. external_wp_deprecated_default()('wp.data.registerGenericStore', {
  2527. since: '5.9',
  2528. alternative: 'wp.data.register( storeDescriptor )'
  2529. });
  2530. registerStoreInstance(name, store);
  2531. }
  2532. /**
  2533. * Registers a standard `@wordpress/data` store.
  2534. *
  2535. * @param {string} storeName Unique namespace identifier.
  2536. * @param {Object} options Store description (reducer, actions, selectors, resolvers).
  2537. *
  2538. * @return {Object} Registered store object.
  2539. */
  2540. function registerStore(storeName, options) {
  2541. if (!options.reducer) {
  2542. throw new TypeError('Must specify store reducer');
  2543. }
  2544. const store = createReduxStore(storeName, options).instantiate(registry);
  2545. registerStoreInstance(storeName, store);
  2546. return store.store;
  2547. }
  2548. /**
  2549. * Subscribe handler to a store.
  2550. *
  2551. * @param {string[]} storeName The store name.
  2552. * @param {Function} handler The function subscribed to the store.
  2553. * @return {Function} A function to unsubscribe the handler.
  2554. */
  2555. function __unstableSubscribeStore(storeName, handler) {
  2556. if (storeName in stores) {
  2557. return stores[storeName].subscribe(handler);
  2558. } // Trying to access a store that hasn't been registered,
  2559. // this is a pattern rarely used but seen in some places.
  2560. // We fallback to regular `subscribe` here for backward-compatibility for now.
  2561. // See https://github.com/WordPress/gutenberg/pull/27466 for more info.
  2562. if (!parent) {
  2563. return subscribe(handler);
  2564. }
  2565. return parent.__unstableSubscribeStore(storeName, handler);
  2566. }
  2567. function batch(callback) {
  2568. emitter.pause();
  2569. Object.values(stores).forEach(store => store.emitter.pause());
  2570. callback();
  2571. emitter.resume();
  2572. Object.values(stores).forEach(store => store.emitter.resume());
  2573. }
  2574. let registry = {
  2575. batch,
  2576. stores,
  2577. namespaces: stores,
  2578. // TODO: Deprecate/remove this.
  2579. subscribe,
  2580. select,
  2581. resolveSelect,
  2582. suspendSelect,
  2583. dispatch,
  2584. use,
  2585. register,
  2586. registerGenericStore,
  2587. registerStore,
  2588. __unstableMarkListeningStores,
  2589. __unstableSubscribeStore
  2590. }; //
  2591. // TODO:
  2592. // This function will be deprecated as soon as it is no longer internally referenced.
  2593. function use(plugin, options) {
  2594. if (!plugin) {
  2595. return;
  2596. }
  2597. registry = { ...registry,
  2598. ...plugin(registry, options)
  2599. };
  2600. return registry;
  2601. }
  2602. registry.register(store);
  2603. for (const [name, config] of Object.entries(storeConfigs)) {
  2604. registry.register(createReduxStore(name, config));
  2605. }
  2606. if (parent) {
  2607. parent.subscribe(globalListener);
  2608. }
  2609. return withPlugins(registry);
  2610. }
  2611. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js
  2612. /**
  2613. * Internal dependencies
  2614. */
  2615. /* harmony default export */ var default_registry = (createRegistry());
  2616. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/node_modules/is-plain-object/dist/is-plain-object.mjs
  2617. /*!
  2618. * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
  2619. *
  2620. * Copyright (c) 2014-2017, Jon Schlinkert.
  2621. * Released under the MIT License.
  2622. */
  2623. function is_plain_object_isObject(o) {
  2624. return Object.prototype.toString.call(o) === '[object Object]';
  2625. }
  2626. function is_plain_object_isPlainObject(o) {
  2627. var ctor,prot;
  2628. if (is_plain_object_isObject(o) === false) return false;
  2629. // If has modified constructor
  2630. ctor = o.constructor;
  2631. if (ctor === undefined) return true;
  2632. // If has modified prototype
  2633. prot = ctor.prototype;
  2634. if (is_plain_object_isObject(prot) === false) return false;
  2635. // If constructor does not have an Object-specific method
  2636. if (prot.hasOwnProperty('isPrototypeOf') === false) {
  2637. return false;
  2638. }
  2639. // Most likely a plain Object
  2640. return true;
  2641. }
  2642. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js
  2643. let objectStorage;
  2644. const storage = {
  2645. getItem(key) {
  2646. if (!objectStorage || !objectStorage[key]) {
  2647. return null;
  2648. }
  2649. return objectStorage[key];
  2650. },
  2651. setItem(key, value) {
  2652. if (!objectStorage) {
  2653. storage.clear();
  2654. }
  2655. objectStorage[key] = String(value);
  2656. },
  2657. clear() {
  2658. objectStorage = Object.create(null);
  2659. }
  2660. };
  2661. /* harmony default export */ var object = (storage);
  2662. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js
  2663. /**
  2664. * Internal dependencies
  2665. */
  2666. let default_storage;
  2667. try {
  2668. // Private Browsing in Safari 10 and earlier will throw an error when
  2669. // attempting to set into localStorage. The test here is intentional in
  2670. // causing a thrown error as condition for using fallback object storage.
  2671. default_storage = window.localStorage;
  2672. default_storage.setItem('__wpDataTestLocalStorage', '');
  2673. default_storage.removeItem('__wpDataTestLocalStorage');
  2674. } catch (error) {
  2675. default_storage = object;
  2676. }
  2677. /* harmony default export */ var storage_default = (default_storage);
  2678. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js
  2679. /**
  2680. * External dependencies
  2681. */
  2682. /**
  2683. * Internal dependencies
  2684. */
  2685. /** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */
  2686. /** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */
  2687. /**
  2688. * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options.
  2689. *
  2690. * @property {Storage} storage Persistent storage implementation. This must
  2691. * at least implement `getItem` and `setItem` of
  2692. * the Web Storage API.
  2693. * @property {string} storageKey Key on which to set in persistent storage.
  2694. *
  2695. */
  2696. /**
  2697. * Default plugin storage.
  2698. *
  2699. * @type {Storage}
  2700. */
  2701. const DEFAULT_STORAGE = storage_default;
  2702. /**
  2703. * Default plugin storage key.
  2704. *
  2705. * @type {string}
  2706. */
  2707. const DEFAULT_STORAGE_KEY = 'WP_DATA';
  2708. /**
  2709. * Higher-order reducer which invokes the original reducer only if state is
  2710. * inequal from that of the action's `nextState` property, otherwise returning
  2711. * the original state reference.
  2712. *
  2713. * @param {Function} reducer Original reducer.
  2714. *
  2715. * @return {Function} Enhanced reducer.
  2716. */
  2717. const withLazySameState = reducer => (state, action) => {
  2718. if (action.nextState === state) {
  2719. return state;
  2720. }
  2721. return reducer(state, action);
  2722. };
  2723. /**
  2724. * Creates a persistence interface, exposing getter and setter methods (`get`
  2725. * and `set` respectively).
  2726. *
  2727. * @param {WPDataPersistencePluginOptions} options Plugin options.
  2728. *
  2729. * @return {Object} Persistence interface.
  2730. */
  2731. function createPersistenceInterface(options) {
  2732. const {
  2733. storage = DEFAULT_STORAGE,
  2734. storageKey = DEFAULT_STORAGE_KEY
  2735. } = options;
  2736. let data;
  2737. /**
  2738. * Returns the persisted data as an object, defaulting to an empty object.
  2739. *
  2740. * @return {Object} Persisted data.
  2741. */
  2742. function getData() {
  2743. if (data === undefined) {
  2744. // If unset, getItem is expected to return null. Fall back to
  2745. // empty object.
  2746. const persisted = storage.getItem(storageKey);
  2747. if (persisted === null) {
  2748. data = {};
  2749. } else {
  2750. try {
  2751. data = JSON.parse(persisted);
  2752. } catch (error) {
  2753. // Similarly, should any error be thrown during parse of
  2754. // the string (malformed JSON), fall back to empty object.
  2755. data = {};
  2756. }
  2757. }
  2758. }
  2759. return data;
  2760. }
  2761. /**
  2762. * Merges an updated reducer state into the persisted data.
  2763. *
  2764. * @param {string} key Key to update.
  2765. * @param {*} value Updated value.
  2766. */
  2767. function setData(key, value) {
  2768. data = { ...data,
  2769. [key]: value
  2770. };
  2771. storage.setItem(storageKey, JSON.stringify(data));
  2772. }
  2773. return {
  2774. get: getData,
  2775. set: setData
  2776. };
  2777. }
  2778. /**
  2779. * Data plugin to persist store state into a single storage key.
  2780. *
  2781. * @param {WPDataRegistry} registry Data registry.
  2782. * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.
  2783. *
  2784. * @return {WPDataPlugin} Data plugin.
  2785. */
  2786. function persistencePlugin(registry, pluginOptions) {
  2787. const persistence = createPersistenceInterface(pluginOptions);
  2788. /**
  2789. * Creates an enhanced store dispatch function, triggering the state of the
  2790. * given store name to be persisted when changed.
  2791. *
  2792. * @param {Function} getState Function which returns current state.
  2793. * @param {string} storeName Store name.
  2794. * @param {?Array<string>} keys Optional subset of keys to save.
  2795. *
  2796. * @return {Function} Enhanced dispatch function.
  2797. */
  2798. function createPersistOnChange(getState, storeName, keys) {
  2799. let getPersistedState;
  2800. if (Array.isArray(keys)) {
  2801. // Given keys, the persisted state should by produced as an object
  2802. // of the subset of keys. This implementation uses combineReducers
  2803. // to leverage its behavior of returning the same object when none
  2804. // of the property values changes. This allows a strict reference
  2805. // equality to bypass a persistence set on an unchanging state.
  2806. const reducers = keys.reduce((accumulator, key) => Object.assign(accumulator, {
  2807. [key]: (state, action) => action.nextState[key]
  2808. }), {});
  2809. getPersistedState = withLazySameState(build_module_combineReducers(reducers));
  2810. } else {
  2811. getPersistedState = (state, action) => action.nextState;
  2812. }
  2813. let lastState = getPersistedState(undefined, {
  2814. nextState: getState()
  2815. });
  2816. return () => {
  2817. const state = getPersistedState(lastState, {
  2818. nextState: getState()
  2819. });
  2820. if (state !== lastState) {
  2821. persistence.set(storeName, state);
  2822. lastState = state;
  2823. }
  2824. };
  2825. }
  2826. return {
  2827. registerStore(storeName, options) {
  2828. if (!options.persist) {
  2829. return registry.registerStore(storeName, options);
  2830. } // Load from persistence to use as initial state.
  2831. const persistedState = persistence.get()[storeName];
  2832. if (persistedState !== undefined) {
  2833. let initialState = options.reducer(options.initialState, {
  2834. type: '@@WP/PERSISTENCE_RESTORE'
  2835. });
  2836. if (is_plain_object_isPlainObject(initialState) && is_plain_object_isPlainObject(persistedState)) {
  2837. // If state is an object, ensure that:
  2838. // - Other keys are left intact when persisting only a
  2839. // subset of keys.
  2840. // - New keys in what would otherwise be used as initial
  2841. // state are deeply merged as base for persisted value.
  2842. initialState = (0,external_lodash_namespaceObject.merge)({}, initialState, persistedState);
  2843. } else {
  2844. // If there is a mismatch in object-likeness of default
  2845. // initial or persisted state, defer to persisted value.
  2846. initialState = persistedState;
  2847. }
  2848. options = { ...options,
  2849. initialState
  2850. };
  2851. }
  2852. const store = registry.registerStore(storeName, options);
  2853. store.subscribe(createPersistOnChange(store.getState, storeName, options.persist));
  2854. return store;
  2855. }
  2856. };
  2857. }
  2858. persistencePlugin.__unstableMigrate = () => {};
  2859. /* harmony default export */ var persistence = (persistencePlugin);
  2860. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js
  2861. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  2862. function _extends() {
  2863. _extends = Object.assign ? Object.assign.bind() : function (target) {
  2864. for (var i = 1; i < arguments.length; i++) {
  2865. var source = arguments[i];
  2866. for (var key in source) {
  2867. if (Object.prototype.hasOwnProperty.call(source, key)) {
  2868. target[key] = source[key];
  2869. }
  2870. }
  2871. }
  2872. return target;
  2873. };
  2874. return _extends.apply(this, arguments);
  2875. }
  2876. ;// CONCATENATED MODULE: external ["wp","element"]
  2877. var external_wp_element_namespaceObject = window["wp"]["element"];
  2878. ;// CONCATENATED MODULE: external ["wp","compose"]
  2879. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  2880. ;// CONCATENATED MODULE: external "React"
  2881. var external_React_namespaceObject = window["React"];
  2882. ;// CONCATENATED MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js
  2883. function areInputsEqual(newInputs, lastInputs) {
  2884. if (newInputs.length !== lastInputs.length) {
  2885. return false;
  2886. }
  2887. for (var i = 0; i < newInputs.length; i++) {
  2888. if (newInputs[i] !== lastInputs[i]) {
  2889. return false;
  2890. }
  2891. }
  2892. return true;
  2893. }
  2894. function useMemoOne(getResult, inputs) {
  2895. var initial = (0,external_React_namespaceObject.useState)(function () {
  2896. return {
  2897. inputs: inputs,
  2898. result: getResult()
  2899. };
  2900. })[0];
  2901. var isFirstRun = (0,external_React_namespaceObject.useRef)(true);
  2902. var committed = (0,external_React_namespaceObject.useRef)(initial);
  2903. var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));
  2904. var cache = useCache ? committed.current : {
  2905. inputs: inputs,
  2906. result: getResult()
  2907. };
  2908. (0,external_React_namespaceObject.useEffect)(function () {
  2909. isFirstRun.current = false;
  2910. committed.current = cache;
  2911. }, [cache]);
  2912. return cache.result;
  2913. }
  2914. function useCallbackOne(callback, inputs) {
  2915. return useMemoOne(function () {
  2916. return callback;
  2917. }, inputs);
  2918. }
  2919. var useMemo = (/* unused pure expression or super */ null && (useMemoOne));
  2920. var useCallback = (/* unused pure expression or super */ null && (useCallbackOne));
  2921. ;// CONCATENATED MODULE: external ["wp","priorityQueue"]
  2922. var external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"];
  2923. ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
  2924. var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
  2925. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
  2926. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js
  2927. /**
  2928. * WordPress dependencies
  2929. */
  2930. /**
  2931. * Internal dependencies
  2932. */
  2933. const Context = (0,external_wp_element_namespaceObject.createContext)(default_registry);
  2934. const {
  2935. Consumer,
  2936. Provider
  2937. } = Context;
  2938. /**
  2939. * A custom react Context consumer exposing the provided `registry` to
  2940. * children components. Used along with the RegistryProvider.
  2941. *
  2942. * You can read more about the react context api here:
  2943. * https://reactjs.org/docs/context.html#contextprovider
  2944. *
  2945. * @example
  2946. * ```js
  2947. * import {
  2948. * RegistryProvider,
  2949. * RegistryConsumer,
  2950. * createRegistry
  2951. * } from '@wordpress/data';
  2952. *
  2953. * const registry = createRegistry( {} );
  2954. *
  2955. * const App = ( { props } ) => {
  2956. * return <RegistryProvider value={ registry }>
  2957. * <div>Hello There</div>
  2958. * <RegistryConsumer>
  2959. * { ( registry ) => (
  2960. * <ComponentUsingRegistry
  2961. * { ...props }
  2962. * registry={ registry }
  2963. * ) }
  2964. * </RegistryConsumer>
  2965. * </RegistryProvider>
  2966. * }
  2967. * ```
  2968. */
  2969. const RegistryConsumer = Consumer;
  2970. /**
  2971. * A custom Context provider for exposing the provided `registry` to children
  2972. * components via a consumer.
  2973. *
  2974. * See <a name="#RegistryConsumer">RegistryConsumer</a> documentation for
  2975. * example.
  2976. */
  2977. /* harmony default export */ var context = (Provider);
  2978. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js
  2979. /**
  2980. * WordPress dependencies
  2981. */
  2982. /**
  2983. * Internal dependencies
  2984. */
  2985. /**
  2986. * A custom react hook exposing the registry context for use.
  2987. *
  2988. * This exposes the `registry` value provided via the
  2989. * <a href="#RegistryProvider">Registry Provider</a> to a component implementing
  2990. * this hook.
  2991. *
  2992. * It acts similarly to the `useContext` react hook.
  2993. *
  2994. * Note: Generally speaking, `useRegistry` is a low level hook that in most cases
  2995. * won't be needed for implementation. Most interactions with the `@wordpress/data`
  2996. * API can be performed via the `useSelect` hook, or the `withSelect` and
  2997. * `withDispatch` higher order components.
  2998. *
  2999. * @example
  3000. * ```js
  3001. * import {
  3002. * RegistryProvider,
  3003. * createRegistry,
  3004. * useRegistry,
  3005. * } from '@wordpress/data';
  3006. *
  3007. * const registry = createRegistry( {} );
  3008. *
  3009. * const SomeChildUsingRegistry = ( props ) => {
  3010. * const registry = useRegistry();
  3011. * // ...logic implementing the registry in other react hooks.
  3012. * };
  3013. *
  3014. *
  3015. * const ParentProvidingRegistry = ( props ) => {
  3016. * return <RegistryProvider value={ registry }>
  3017. * <SomeChildUsingRegistry { ...props } />
  3018. * </RegistryProvider>
  3019. * };
  3020. * ```
  3021. *
  3022. * @return {Function} A custom react hook exposing the registry context value.
  3023. */
  3024. function useRegistry() {
  3025. return (0,external_wp_element_namespaceObject.useContext)(Context);
  3026. }
  3027. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js
  3028. /**
  3029. * WordPress dependencies
  3030. */
  3031. const context_Context = (0,external_wp_element_namespaceObject.createContext)(false);
  3032. const {
  3033. Consumer: context_Consumer,
  3034. Provider: context_Provider
  3035. } = context_Context;
  3036. const AsyncModeConsumer = (/* unused pure expression or super */ null && (context_Consumer));
  3037. /**
  3038. * Context Provider Component used to switch the data module component rerendering
  3039. * between Sync and Async modes.
  3040. *
  3041. * @example
  3042. *
  3043. * ```js
  3044. * import { useSelect, AsyncModeProvider } from '@wordpress/data';
  3045. * import { store as blockEditorStore } from '@wordpress/block-editor';
  3046. *
  3047. * function BlockCount() {
  3048. * const count = useSelect( ( select ) => {
  3049. * return select( blockEditorStore ).getBlockCount()
  3050. * }, [] );
  3051. *
  3052. * return count;
  3053. * }
  3054. *
  3055. * function App() {
  3056. * return (
  3057. * <AsyncModeProvider value={ true }>
  3058. * <BlockCount />
  3059. * </AsyncModeProvider>
  3060. * );
  3061. * }
  3062. * ```
  3063. *
  3064. * In this example, the BlockCount component is rerendered asynchronously.
  3065. * It means if a more critical task is being performed (like typing in an input),
  3066. * the rerendering is delayed until the browser becomes IDLE.
  3067. * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior.
  3068. *
  3069. * @param {boolean} props.value Enable Async Mode.
  3070. * @return {WPComponent} The component to be rendered.
  3071. */
  3072. /* harmony default export */ var async_mode_provider_context = (context_Provider);
  3073. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js
  3074. /**
  3075. * WordPress dependencies
  3076. */
  3077. /**
  3078. * Internal dependencies
  3079. */
  3080. function useAsyncMode() {
  3081. return (0,external_wp_element_namespaceObject.useContext)(context_Context);
  3082. }
  3083. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js
  3084. /**
  3085. * External dependencies
  3086. */
  3087. /**
  3088. * WordPress dependencies
  3089. */
  3090. /**
  3091. * Internal dependencies
  3092. */
  3093. const noop = () => {};
  3094. const renderQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)();
  3095. /**
  3096. * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor
  3097. * @template C
  3098. */
  3099. /**
  3100. * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
  3101. * @template State,Actions,Selectors
  3102. */
  3103. /**
  3104. * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn
  3105. * @template T
  3106. */
  3107. /** @typedef {import('../../types').MapSelect} MapSelect */
  3108. /**
  3109. * Custom react hook for retrieving props from registered selectors.
  3110. *
  3111. * In general, this custom React hook follows the
  3112. * [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
  3113. *
  3114. * @template {MapSelect | StoreDescriptor<any>} T
  3115. * @param {T} mapSelect Function called on every state change. The returned value is
  3116. * exposed to the component implementing this hook. The function
  3117. * receives the `registry.select` method on the first argument
  3118. * and the `registry` on the second argument.
  3119. * When a store key is passed, all selectors for the store will be
  3120. * returned. This is only meant for usage of these selectors in event
  3121. * callbacks, not for data needed to create the element tree.
  3122. * @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is
  3123. * invoked on every state change unless the dependencies change.
  3124. *
  3125. * @example
  3126. * ```js
  3127. * import { useSelect } from '@wordpress/data';
  3128. * import { store as myCustomStore } from 'my-custom-store';
  3129. *
  3130. * function HammerPriceDisplay( { currency } ) {
  3131. * const price = useSelect( ( select ) => {
  3132. * return select( myCustomStore ).getPrice( 'hammer', currency );
  3133. * }, [ currency ] );
  3134. * return new Intl.NumberFormat( 'en-US', {
  3135. * style: 'currency',
  3136. * currency,
  3137. * } ).format( price );
  3138. * }
  3139. *
  3140. * // Rendered in the application:
  3141. * // <HammerPriceDisplay currency="USD" />
  3142. * ```
  3143. *
  3144. * In the above example, when `HammerPriceDisplay` is rendered into an
  3145. * application, the price will be retrieved from the store state using the
  3146. * `mapSelect` callback on `useSelect`. If the currency prop changes then
  3147. * any price in the state for that currency is retrieved. If the currency prop
  3148. * doesn't change and other props are passed in that do change, the price will
  3149. * not change because the dependency is just the currency.
  3150. *
  3151. * When data is only used in an event callback, the data should not be retrieved
  3152. * on render, so it may be useful to get the selectors function instead.
  3153. *
  3154. * **Don't use `useSelect` this way when calling the selectors in the render
  3155. * function because your component won't re-render on a data change.**
  3156. *
  3157. * ```js
  3158. * import { useSelect } from '@wordpress/data';
  3159. * import { store as myCustomStore } from 'my-custom-store';
  3160. *
  3161. * function Paste( { children } ) {
  3162. * const { getSettings } = useSelect( myCustomStore );
  3163. * function onPaste() {
  3164. * // Do something with the settings.
  3165. * const settings = getSettings();
  3166. * }
  3167. * return <div onPaste={ onPaste }>{ children }</div>;
  3168. * }
  3169. * ```
  3170. * @return {UseSelectReturn<T>} A custom react hook.
  3171. */
  3172. function useSelect(mapSelect, deps) {
  3173. const hasMappingFunction = 'function' === typeof mapSelect; // If we're recalling a store by its name or by
  3174. // its descriptor then we won't be caching the
  3175. // calls to `mapSelect` because we won't be calling it.
  3176. if (!hasMappingFunction) {
  3177. deps = [];
  3178. } // Because of the "rule of hooks" we have to call `useCallback`
  3179. // on every invocation whether or not we have a real function
  3180. // for `mapSelect`. we'll create this intermediate variable to
  3181. // fulfill that need and then reference it with our "real"
  3182. // `_mapSelect` if we can.
  3183. const callbackMapper = (0,external_wp_element_namespaceObject.useCallback)(hasMappingFunction ? mapSelect : noop, deps);
  3184. const _mapSelect = hasMappingFunction ? callbackMapper : null;
  3185. const registry = useRegistry();
  3186. const isAsync = useAsyncMode();
  3187. const latestRegistry = (0,external_wp_element_namespaceObject.useRef)(registry);
  3188. const latestMapSelect = (0,external_wp_element_namespaceObject.useRef)();
  3189. const latestIsAsync = (0,external_wp_element_namespaceObject.useRef)(isAsync);
  3190. const latestMapOutput = (0,external_wp_element_namespaceObject.useRef)();
  3191. const latestMapOutputError = (0,external_wp_element_namespaceObject.useRef)(); // Keep track of the stores being selected in the _mapSelect function,
  3192. // and only subscribe to those stores later.
  3193. const listeningStores = (0,external_wp_element_namespaceObject.useRef)([]);
  3194. const wrapSelect = (0,external_wp_element_namespaceObject.useCallback)(callback => registry.__unstableMarkListeningStores(() => callback(registry.select, registry), listeningStores), [registry]); // Generate a "flag" for used in the effect dependency array.
  3195. // It's different than just using `mapSelect` since deps could be undefined,
  3196. // in that case, we would still want to memoize it.
  3197. const depsChangedFlag = (0,external_wp_element_namespaceObject.useMemo)(() => ({}), deps || []);
  3198. let mapOutput;
  3199. if (_mapSelect) {
  3200. mapOutput = latestMapOutput.current;
  3201. const hasReplacedRegistry = latestRegistry.current !== registry;
  3202. const hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;
  3203. const hasLeftAsyncMode = latestIsAsync.current && !isAsync;
  3204. const lastMapSelectFailed = !!latestMapOutputError.current;
  3205. if (hasReplacedRegistry || hasReplacedMapSelect || hasLeftAsyncMode || lastMapSelectFailed) {
  3206. try {
  3207. mapOutput = wrapSelect(_mapSelect);
  3208. } catch (error) {
  3209. let errorMessage = `An error occurred while running 'mapSelect': ${error.message}`;
  3210. if (latestMapOutputError.current) {
  3211. errorMessage += `\nThe error may be correlated with this previous error:\n`;
  3212. errorMessage += `${latestMapOutputError.current.stack}\n\n`;
  3213. errorMessage += 'Original stack trace:';
  3214. } // eslint-disable-next-line no-console
  3215. console.error(errorMessage);
  3216. }
  3217. }
  3218. }
  3219. (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => {
  3220. if (!hasMappingFunction) {
  3221. return;
  3222. }
  3223. latestRegistry.current = registry;
  3224. latestMapSelect.current = _mapSelect;
  3225. latestIsAsync.current = isAsync;
  3226. latestMapOutput.current = mapOutput;
  3227. latestMapOutputError.current = undefined;
  3228. }); // React can sometimes clear the `useMemo` cache.
  3229. // We use the cache-stable `useMemoOne` to avoid
  3230. // losing queues.
  3231. const queueContext = useMemoOne(() => ({
  3232. queue: true
  3233. }), [registry]);
  3234. const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(s => s + 1, 0);
  3235. const isMounted = (0,external_wp_element_namespaceObject.useRef)(false);
  3236. (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => {
  3237. if (!hasMappingFunction) {
  3238. return;
  3239. }
  3240. const onStoreChange = () => {
  3241. try {
  3242. const newMapOutput = wrapSelect(latestMapSelect.current);
  3243. if (external_wp_isShallowEqual_default()(latestMapOutput.current, newMapOutput)) {
  3244. return;
  3245. }
  3246. latestMapOutput.current = newMapOutput;
  3247. } catch (error) {
  3248. latestMapOutputError.current = error;
  3249. }
  3250. forceRender();
  3251. };
  3252. const onChange = () => {
  3253. if (!isMounted.current) {
  3254. return;
  3255. }
  3256. if (latestIsAsync.current) {
  3257. renderQueue.add(queueContext, onStoreChange);
  3258. } else {
  3259. onStoreChange();
  3260. }
  3261. }; // Catch any possible state changes during mount before the subscription
  3262. // could be set.
  3263. onStoreChange();
  3264. const unsubscribers = listeningStores.current.map(storeName => registry.__unstableSubscribeStore(storeName, onChange));
  3265. isMounted.current = true;
  3266. return () => {
  3267. // The return value of the subscribe function could be undefined if the store is a custom generic store.
  3268. unsubscribers.forEach(unsubscribe => unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe());
  3269. renderQueue.cancel(queueContext);
  3270. isMounted.current = false;
  3271. }; // If you're tempted to eliminate the spread dependencies below don't do it!
  3272. // We're passing these in from the calling function and want to make sure we're
  3273. // examining every individual value inside the `deps` array.
  3274. }, [registry, wrapSelect, hasMappingFunction, depsChangedFlag]);
  3275. (0,external_wp_element_namespaceObject.useDebugValue)(mapOutput);
  3276. return hasMappingFunction ? mapOutput : registry.select(mapSelect);
  3277. }
  3278. /**
  3279. * A variant of the `useSelect` hook that has the same API, but will throw a
  3280. * suspense Promise if any of the called selectors is in an unresolved state.
  3281. *
  3282. * @param {Function} mapSelect Function called on every state change. The
  3283. * returned value is exposed to the component
  3284. * using this hook. The function receives the
  3285. * `registry.suspendSelect` method as the first
  3286. * argument and the `registry` as the second one.
  3287. * @param {Array} deps A dependency array used to memoize the `mapSelect`
  3288. * so that the same `mapSelect` is invoked on every
  3289. * state change unless the dependencies change.
  3290. *
  3291. * @return {Object} Data object returned by the `mapSelect` function.
  3292. */
  3293. function useSuspenseSelect(mapSelect, deps) {
  3294. const _mapSelect = (0,external_wp_element_namespaceObject.useCallback)(mapSelect, deps);
  3295. const registry = useRegistry();
  3296. const isAsync = useAsyncMode();
  3297. const latestRegistry = (0,external_wp_element_namespaceObject.useRef)(registry);
  3298. const latestMapSelect = (0,external_wp_element_namespaceObject.useRef)();
  3299. const latestIsAsync = (0,external_wp_element_namespaceObject.useRef)(isAsync);
  3300. const latestMapOutput = (0,external_wp_element_namespaceObject.useRef)();
  3301. const latestMapOutputError = (0,external_wp_element_namespaceObject.useRef)(); // Keep track of the stores being selected in the `mapSelect` function,
  3302. // and only subscribe to those stores later.
  3303. const listeningStores = (0,external_wp_element_namespaceObject.useRef)([]);
  3304. const wrapSelect = (0,external_wp_element_namespaceObject.useCallback)(callback => registry.__unstableMarkListeningStores(() => callback(registry.suspendSelect, registry), listeningStores), [registry]); // Generate a "flag" for used in the effect dependency array.
  3305. // It's different than just using `mapSelect` since deps could be undefined,
  3306. // in that case, we would still want to memoize it.
  3307. const depsChangedFlag = (0,external_wp_element_namespaceObject.useMemo)(() => ({}), deps || []);
  3308. let mapOutput = latestMapOutput.current;
  3309. let mapOutputError = latestMapOutputError.current;
  3310. const hasReplacedRegistry = latestRegistry.current !== registry;
  3311. const hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;
  3312. const hasLeftAsyncMode = latestIsAsync.current && !isAsync;
  3313. if (hasReplacedRegistry || hasReplacedMapSelect || hasLeftAsyncMode) {
  3314. try {
  3315. mapOutput = wrapSelect(_mapSelect);
  3316. } catch (error) {
  3317. mapOutputError = error;
  3318. }
  3319. }
  3320. (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => {
  3321. latestRegistry.current = registry;
  3322. latestMapSelect.current = _mapSelect;
  3323. latestIsAsync.current = isAsync;
  3324. latestMapOutput.current = mapOutput;
  3325. latestMapOutputError.current = mapOutputError;
  3326. }); // React can sometimes clear the `useMemo` cache.
  3327. // We use the cache-stable `useMemoOne` to avoid
  3328. // losing queues.
  3329. const queueContext = useMemoOne(() => ({
  3330. queue: true
  3331. }), [registry]);
  3332. const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(s => s + 1, 0);
  3333. const isMounted = (0,external_wp_element_namespaceObject.useRef)(false);
  3334. (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => {
  3335. const onStoreChange = () => {
  3336. try {
  3337. const newMapOutput = wrapSelect(latestMapSelect.current);
  3338. if (external_wp_isShallowEqual_default()(latestMapOutput.current, newMapOutput)) {
  3339. return;
  3340. }
  3341. latestMapOutput.current = newMapOutput;
  3342. } catch (error) {
  3343. latestMapOutputError.current = error;
  3344. }
  3345. forceRender();
  3346. };
  3347. const onChange = () => {
  3348. if (!isMounted.current) {
  3349. return;
  3350. }
  3351. if (latestIsAsync.current) {
  3352. renderQueue.add(queueContext, onStoreChange);
  3353. } else {
  3354. onStoreChange();
  3355. }
  3356. }; // catch any possible state changes during mount before the subscription
  3357. // could be set.
  3358. onStoreChange();
  3359. const unsubscribers = listeningStores.current.map(storeName => registry.__unstableSubscribeStore(storeName, onChange));
  3360. isMounted.current = true;
  3361. return () => {
  3362. // The return value of the subscribe function could be undefined if the store is a custom generic store.
  3363. unsubscribers.forEach(unsubscribe => unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe());
  3364. renderQueue.cancel(queueContext);
  3365. isMounted.current = false;
  3366. };
  3367. }, [registry, wrapSelect, depsChangedFlag]);
  3368. if (mapOutputError) {
  3369. throw mapOutputError;
  3370. }
  3371. return mapOutput;
  3372. }
  3373. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js
  3374. /**
  3375. * WordPress dependencies
  3376. */
  3377. /**
  3378. * Internal dependencies
  3379. */
  3380. /**
  3381. * Higher-order component used to inject state-derived props using registered
  3382. * selectors.
  3383. *
  3384. * @param {Function} mapSelectToProps Function called on every state change,
  3385. * expected to return object of props to
  3386. * merge with the component's own props.
  3387. *
  3388. * @example
  3389. * ```js
  3390. * import { withSelect } from '@wordpress/data';
  3391. * import { store as myCustomStore } from 'my-custom-store';
  3392. *
  3393. * function PriceDisplay( { price, currency } ) {
  3394. * return new Intl.NumberFormat( 'en-US', {
  3395. * style: 'currency',
  3396. * currency,
  3397. * } ).format( price );
  3398. * }
  3399. *
  3400. * const HammerPriceDisplay = withSelect( ( select, ownProps ) => {
  3401. * const { getPrice } = select( myCustomStore );
  3402. * const { currency } = ownProps;
  3403. *
  3404. * return {
  3405. * price: getPrice( 'hammer', currency ),
  3406. * };
  3407. * } )( PriceDisplay );
  3408. *
  3409. * // Rendered in the application:
  3410. * //
  3411. * // <HammerPriceDisplay currency="USD" />
  3412. * ```
  3413. * In the above example, when `HammerPriceDisplay` is rendered into an
  3414. * application, it will pass the price into the underlying `PriceDisplay`
  3415. * component and update automatically if the price of a hammer ever changes in
  3416. * the store.
  3417. *
  3418. * @return {WPComponent} Enhanced component with merged state data props.
  3419. */
  3420. const withSelect = mapSelectToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_compose_namespaceObject.pure)(ownProps => {
  3421. const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry);
  3422. const mergeProps = useSelect(mapSelect);
  3423. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, ownProps, mergeProps));
  3424. }), 'withSelect');
  3425. /* harmony default export */ var with_select = (withSelect);
  3426. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js
  3427. /**
  3428. * External dependencies
  3429. */
  3430. /**
  3431. * WordPress dependencies
  3432. */
  3433. /**
  3434. * Internal dependencies
  3435. */
  3436. /**
  3437. * Custom react hook for returning aggregate dispatch actions using the provided
  3438. * dispatchMap.
  3439. *
  3440. * Currently this is an internal api only and is implemented by `withDispatch`
  3441. *
  3442. * @param {Function} dispatchMap Receives the `registry.dispatch` function as
  3443. * the first argument and the `registry` object
  3444. * as the second argument. Should return an
  3445. * object mapping props to functions.
  3446. * @param {Array} deps An array of dependencies for the hook.
  3447. * @return {Object} An object mapping props to functions created by the passed
  3448. * in dispatchMap.
  3449. */
  3450. const useDispatchWithMap = (dispatchMap, deps) => {
  3451. const registry = useRegistry();
  3452. const currentDispatchMap = (0,external_wp_element_namespaceObject.useRef)(dispatchMap);
  3453. (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => {
  3454. currentDispatchMap.current = dispatchMap;
  3455. });
  3456. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  3457. const currentDispatchProps = currentDispatchMap.current(registry.dispatch, registry);
  3458. return (0,external_lodash_namespaceObject.mapValues)(currentDispatchProps, (dispatcher, propName) => {
  3459. if (typeof dispatcher !== 'function') {
  3460. // eslint-disable-next-line no-console
  3461. console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`);
  3462. }
  3463. return function () {
  3464. return currentDispatchMap.current(registry.dispatch, registry)[propName](...arguments);
  3465. };
  3466. });
  3467. }, [registry, ...deps]);
  3468. };
  3469. /* harmony default export */ var use_dispatch_with_map = (useDispatchWithMap);
  3470. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js
  3471. /**
  3472. * WordPress dependencies
  3473. */
  3474. /**
  3475. * Internal dependencies
  3476. */
  3477. /**
  3478. * Higher-order component used to add dispatch props using registered action
  3479. * creators.
  3480. *
  3481. * @param {Function} mapDispatchToProps A function of returning an object of
  3482. * prop names where value is a
  3483. * dispatch-bound action creator, or a
  3484. * function to be called with the
  3485. * component's props and returning an
  3486. * action creator.
  3487. *
  3488. * @example
  3489. * ```jsx
  3490. * function Button( { onClick, children } ) {
  3491. * return <button type="button" onClick={ onClick }>{ children }</button>;
  3492. * }
  3493. *
  3494. * import { withDispatch } from '@wordpress/data';
  3495. * import { store as myCustomStore } from 'my-custom-store';
  3496. *
  3497. * const SaleButton = withDispatch( ( dispatch, ownProps ) => {
  3498. * const { startSale } = dispatch( myCustomStore );
  3499. * const { discountPercent } = ownProps;
  3500. *
  3501. * return {
  3502. * onClick() {
  3503. * startSale( discountPercent );
  3504. * },
  3505. * };
  3506. * } )( Button );
  3507. *
  3508. * // Rendered in the application:
  3509. * //
  3510. * // <SaleButton discountPercent="20">Start Sale!</SaleButton>
  3511. * ```
  3512. *
  3513. * @example
  3514. * In the majority of cases, it will be sufficient to use only two first params
  3515. * passed to `mapDispatchToProps` as illustrated in the previous example.
  3516. * However, there might be some very advanced use cases where using the
  3517. * `registry` object might be used as a tool to optimize the performance of
  3518. * your component. Using `select` function from the registry might be useful
  3519. * when you need to fetch some dynamic data from the store at the time when the
  3520. * event is fired, but at the same time, you never use it to render your
  3521. * component. In such scenario, you can avoid using the `withSelect` higher
  3522. * order component to compute such prop, which might lead to unnecessary
  3523. * re-renders of your component caused by its frequent value change.
  3524. * Keep in mind, that `mapDispatchToProps` must return an object with functions
  3525. * only.
  3526. *
  3527. * ```jsx
  3528. * function Button( { onClick, children } ) {
  3529. * return <button type="button" onClick={ onClick }>{ children }</button>;
  3530. * }
  3531. *
  3532. * import { withDispatch } from '@wordpress/data';
  3533. * import { store as myCustomStore } from 'my-custom-store';
  3534. *
  3535. * const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {
  3536. * // Stock number changes frequently.
  3537. * const { getStockNumber } = select( myCustomStore );
  3538. * const { startSale } = dispatch( myCustomStore );
  3539. * return {
  3540. * onClick() {
  3541. * const discountPercent = getStockNumber() > 50 ? 10 : 20;
  3542. * startSale( discountPercent );
  3543. * },
  3544. * };
  3545. * } )( Button );
  3546. *
  3547. * // Rendered in the application:
  3548. * //
  3549. * // <SaleButton>Start Sale!</SaleButton>
  3550. * ```
  3551. *
  3552. * _Note:_ It is important that the `mapDispatchToProps` function always
  3553. * returns an object with the same keys. For example, it should not contain
  3554. * conditions under which a different value would be returned.
  3555. *
  3556. * @return {WPComponent} Enhanced component with merged dispatcher props.
  3557. */
  3558. const withDispatch = mapDispatchToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ownProps => {
  3559. const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry);
  3560. const dispatchProps = use_dispatch_with_map(mapDispatch, []);
  3561. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, ownProps, dispatchProps));
  3562. }, 'withDispatch');
  3563. /* harmony default export */ var with_dispatch = (withDispatch);
  3564. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js
  3565. /**
  3566. * WordPress dependencies
  3567. */
  3568. /**
  3569. * Internal dependencies
  3570. */
  3571. /**
  3572. * Higher-order component which renders the original component with the current
  3573. * registry context passed as its `registry` prop.
  3574. *
  3575. * @param {WPComponent} OriginalComponent Original component.
  3576. *
  3577. * @return {WPComponent} Enhanced component.
  3578. */
  3579. const withRegistry = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => props => (0,external_wp_element_namespaceObject.createElement)(RegistryConsumer, null, registry => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, props, {
  3580. registry: registry
  3581. }))), 'withRegistry');
  3582. /* harmony default export */ var with_registry = (withRegistry);
  3583. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js
  3584. /**
  3585. * Internal dependencies
  3586. */
  3587. /**
  3588. * @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor
  3589. * @template StoreConfig
  3590. */
  3591. /**
  3592. * @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn
  3593. * @template StoreNameOrDescriptor
  3594. */
  3595. /**
  3596. * A custom react hook returning the current registry dispatch actions creators.
  3597. *
  3598. * Note: The component using this hook must be within the context of a
  3599. * RegistryProvider.
  3600. *
  3601. * @template {undefined | string | StoreDescriptor<any>} [StoreNameOrDescriptor=undefined]
  3602. * @param {StoreNameOrDescriptor} [storeNameOrDescriptor] Optionally provide the name of the
  3603. * store or its descriptor from which to
  3604. * retrieve action creators. If not
  3605. * provided, the registry.dispatch
  3606. * function is returned instead.
  3607. *
  3608. * @example
  3609. * This illustrates a pattern where you may need to retrieve dynamic data from
  3610. * the server via the `useSelect` hook to use in combination with the dispatch
  3611. * action.
  3612. *
  3613. * ```jsx
  3614. * import { useDispatch, useSelect } from '@wordpress/data';
  3615. * import { useCallback } from '@wordpress/element';
  3616. * import { store as myCustomStore } from 'my-custom-store';
  3617. *
  3618. * function Button( { onClick, children } ) {
  3619. * return <button type="button" onClick={ onClick }>{ children }</button>
  3620. * }
  3621. *
  3622. * const SaleButton = ( { children } ) => {
  3623. * const { stockNumber } = useSelect(
  3624. * ( select ) => select( myCustomStore ).getStockNumber(),
  3625. * []
  3626. * );
  3627. * const { startSale } = useDispatch( myCustomStore );
  3628. * const onClick = useCallback( () => {
  3629. * const discountPercent = stockNumber > 50 ? 10: 20;
  3630. * startSale( discountPercent );
  3631. * }, [ stockNumber ] );
  3632. * return <Button onClick={ onClick }>{ children }</Button>
  3633. * }
  3634. *
  3635. * // Rendered somewhere in the application:
  3636. * //
  3637. * // <SaleButton>Start Sale!</SaleButton>
  3638. * ```
  3639. * @return {UseDispatchReturn<StoreNameOrDescriptor>} A custom react hook.
  3640. */
  3641. const useDispatch = storeNameOrDescriptor => {
  3642. const {
  3643. dispatch
  3644. } = useRegistry();
  3645. return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor);
  3646. };
  3647. /* harmony default export */ var use_dispatch = (useDispatch);
  3648. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js
  3649. /**
  3650. * External dependencies
  3651. */
  3652. /**
  3653. * Internal dependencies
  3654. */
  3655. /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
  3656. /**
  3657. * Object of available plugins to use with a registry.
  3658. *
  3659. * @see [use](#use)
  3660. *
  3661. * @type {Object}
  3662. */
  3663. /**
  3664. * The combineReducers helper function turns an object whose values are different
  3665. * reducing functions into a single reducing function you can pass to registerReducer.
  3666. *
  3667. * @type {import('./types').combineReducers}
  3668. * @param {Object} reducers An object whose values correspond to different reducing
  3669. * functions that need to be combined into one.
  3670. *
  3671. * @example
  3672. * ```js
  3673. * import { combineReducers, createReduxStore, register } from '@wordpress/data';
  3674. *
  3675. * const prices = ( state = {}, action ) => {
  3676. * return action.type === 'SET_PRICE' ?
  3677. * {
  3678. * ...state,
  3679. * [ action.item ]: action.price,
  3680. * } :
  3681. * state;
  3682. * };
  3683. *
  3684. * const discountPercent = ( state = 0, action ) => {
  3685. * return action.type === 'START_SALE' ?
  3686. * action.discountPercent :
  3687. * state;
  3688. * };
  3689. *
  3690. * const store = createReduxStore( 'my-shop', {
  3691. * reducer: combineReducers( {
  3692. * prices,
  3693. * discountPercent,
  3694. * } ),
  3695. * } );
  3696. * register( store );
  3697. * ```
  3698. *
  3699. * @return {Function} A reducer that invokes every reducer inside the reducers
  3700. * object, and constructs a state object with the same shape.
  3701. */
  3702. const build_module_combineReducers = (turbo_combine_reducers_default());
  3703. /**
  3704. * Given a store descriptor, returns an object of the store's selectors.
  3705. * The selector functions are been pre-bound to pass the current state automatically.
  3706. * As a consumer, you need only pass arguments of the selector, if applicable.
  3707. *
  3708. * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
  3709. * convention of passing the store name is
  3710. * also supported.
  3711. *
  3712. * @example
  3713. * ```js
  3714. * import { select } from '@wordpress/data';
  3715. * import { store as myCustomStore } from 'my-custom-store';
  3716. *
  3717. * select( myCustomStore ).getPrice( 'hammer' );
  3718. * ```
  3719. *
  3720. * @return {Object} Object containing the store's selectors.
  3721. */
  3722. const build_module_select = default_registry.select;
  3723. /**
  3724. * Given a store descriptor, returns an object containing the store's selectors pre-bound to state
  3725. * so that you only need to supply additional arguments, and modified so that they return promises
  3726. * that resolve to their eventual values, after any resolvers have ran.
  3727. *
  3728. * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
  3729. * convention of passing the store name is
  3730. * also supported.
  3731. *
  3732. * @example
  3733. * ```js
  3734. * import { resolveSelect } from '@wordpress/data';
  3735. * import { store as myCustomStore } from 'my-custom-store';
  3736. *
  3737. * resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log)
  3738. * ```
  3739. *
  3740. * @return {Object} Object containing the store's promise-wrapped selectors.
  3741. */
  3742. const build_module_resolveSelect = default_registry.resolveSelect;
  3743. /**
  3744. * Given a store descriptor, returns an object containing the store's selectors pre-bound to state
  3745. * so that you only need to supply additional arguments, and modified so that they throw promises
  3746. * in case the selector is not resolved yet.
  3747. *
  3748. * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
  3749. * convention of passing the store name is
  3750. * also supported.
  3751. *
  3752. * @return {Object} Object containing the store's suspense-wrapped selectors.
  3753. */
  3754. const suspendSelect = default_registry.suspendSelect;
  3755. /**
  3756. * Given a store descriptor, returns an object of the store's action creators.
  3757. * Calling an action creator will cause it to be dispatched, updating the state value accordingly.
  3758. *
  3759. * Note: Action creators returned by the dispatch will return a promise when
  3760. * they are called.
  3761. *
  3762. * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
  3763. * convention of passing the store name is
  3764. * also supported.
  3765. *
  3766. * @example
  3767. * ```js
  3768. * import { dispatch } from '@wordpress/data';
  3769. * import { store as myCustomStore } from 'my-custom-store';
  3770. *
  3771. * dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );
  3772. * ```
  3773. * @return {Object} Object containing the action creators.
  3774. */
  3775. const build_module_dispatch = default_registry.dispatch;
  3776. /**
  3777. * Given a listener function, the function will be called any time the state value
  3778. * of one of the registered stores has changed. This function returns a `unsubscribe`
  3779. * function used to stop the subscription.
  3780. *
  3781. * @param {Function} listener Callback function.
  3782. *
  3783. * @example
  3784. * ```js
  3785. * import { subscribe } from '@wordpress/data';
  3786. *
  3787. * const unsubscribe = subscribe( () => {
  3788. * // You could use this opportunity to test whether the derived result of a
  3789. * // selector has subsequently changed as the result of a state update.
  3790. * } );
  3791. *
  3792. * // Later, if necessary...
  3793. * unsubscribe();
  3794. * ```
  3795. */
  3796. const subscribe = default_registry.subscribe;
  3797. /**
  3798. * Registers a generic store instance.
  3799. *
  3800. * @deprecated Use `register( storeDescriptor )` instead.
  3801. *
  3802. * @param {string} name Store registry name.
  3803. * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`).
  3804. */
  3805. const registerGenericStore = default_registry.registerGenericStore;
  3806. /**
  3807. * Registers a standard `@wordpress/data` store.
  3808. *
  3809. * @deprecated Use `register` instead.
  3810. *
  3811. * @param {string} storeName Unique namespace identifier for the store.
  3812. * @param {Object} options Store description (reducer, actions, selectors, resolvers).
  3813. *
  3814. * @return {Object} Registered store object.
  3815. */
  3816. const registerStore = default_registry.registerStore;
  3817. /**
  3818. * Extends a registry to inherit functionality provided by a given plugin. A
  3819. * plugin is an object with properties aligning to that of a registry, merged
  3820. * to extend the default registry behavior.
  3821. *
  3822. * @param {Object} plugin Plugin object.
  3823. */
  3824. const use = default_registry.use;
  3825. /**
  3826. * Registers a standard `@wordpress/data` store descriptor.
  3827. *
  3828. * @example
  3829. * ```js
  3830. * import { createReduxStore, register } from '@wordpress/data';
  3831. *
  3832. * const store = createReduxStore( 'demo', {
  3833. * reducer: ( state = 'OK' ) => state,
  3834. * selectors: {
  3835. * getValue: ( state ) => state,
  3836. * },
  3837. * } );
  3838. * register( store );
  3839. * ```
  3840. *
  3841. * @param {StoreDescriptor} store Store descriptor.
  3842. */
  3843. const register = default_registry.register;
  3844. }();
  3845. (window.wp = window.wp || {}).data = __webpack_exports__;
  3846. /******/ })()
  3847. ;