core-data.js 144 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809
  1. this["wp"] = this["wp"] || {}; this["wp"]["coreData"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = 349);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 10:
  90. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91. "use strict";
  92. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
  93. function _defineProperty(obj, key, value) {
  94. if (key in obj) {
  95. Object.defineProperty(obj, key, {
  96. value: value,
  97. enumerable: true,
  98. configurable: true,
  99. writable: true
  100. });
  101. } else {
  102. obj[key] = value;
  103. }
  104. return obj;
  105. }
  106. /***/ }),
  107. /***/ 17:
  108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109. "use strict";
  110. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
  111. function _arrayWithoutHoles(arr) {
  112. if (Array.isArray(arr)) {
  113. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  114. arr2[i] = arr[i];
  115. }
  116. return arr2;
  117. }
  118. }
  119. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
  120. var iterableToArray = __webpack_require__(30);
  121. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
  122. function _nonIterableSpread() {
  123. throw new TypeError("Invalid attempt to spread non-iterable instance");
  124. }
  125. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
  126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; });
  127. function _toConsumableArray(arr) {
  128. return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread();
  129. }
  130. /***/ }),
  131. /***/ 2:
  132. /***/ (function(module, exports) {
  133. (function() { module.exports = this["lodash"]; }());
  134. /***/ }),
  135. /***/ 20:
  136. /***/ (function(module, exports, __webpack_require__) {
  137. module.exports = __webpack_require__(47);
  138. /***/ }),
  139. /***/ 23:
  140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  141. "use strict";
  142. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
  143. var arrayWithHoles = __webpack_require__(38);
  144. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
  145. function _iterableToArrayLimit(arr, i) {
  146. var _arr = [];
  147. var _n = true;
  148. var _d = false;
  149. var _e = undefined;
  150. try {
  151. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  152. _arr.push(_s.value);
  153. if (i && _arr.length === i) break;
  154. }
  155. } catch (err) {
  156. _d = true;
  157. _e = err;
  158. } finally {
  159. try {
  160. if (!_n && _i["return"] != null) _i["return"]();
  161. } finally {
  162. if (_d) throw _e;
  163. }
  164. }
  165. return _arr;
  166. }
  167. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
  168. var nonIterableRest = __webpack_require__(39);
  169. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
  170. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _slicedToArray; });
  171. function _slicedToArray(arr, i) {
  172. return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(nonIterableRest["a" /* default */])();
  173. }
  174. /***/ }),
  175. /***/ 26:
  176. /***/ (function(module, exports) {
  177. (function() { module.exports = this["wp"]["url"]; }());
  178. /***/ }),
  179. /***/ 30:
  180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  181. "use strict";
  182. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
  183. function _iterableToArray(iter) {
  184. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  185. }
  186. /***/ }),
  187. /***/ 34:
  188. /***/ (function(module, exports) {
  189. (function() { module.exports = this["wp"]["apiFetch"]; }());
  190. /***/ }),
  191. /***/ 349:
  192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  193. "use strict";
  194. __webpack_require__.r(__webpack_exports__);
  195. var build_module_actions_namespaceObject = {};
  196. __webpack_require__.r(build_module_actions_namespaceObject);
  197. __webpack_require__.d(build_module_actions_namespaceObject, "receiveUserQuery", function() { return receiveUserQuery; });
  198. __webpack_require__.d(build_module_actions_namespaceObject, "receiveCurrentUser", function() { return receiveCurrentUser; });
  199. __webpack_require__.d(build_module_actions_namespaceObject, "addEntities", function() { return addEntities; });
  200. __webpack_require__.d(build_module_actions_namespaceObject, "receiveEntityRecords", function() { return receiveEntityRecords; });
  201. __webpack_require__.d(build_module_actions_namespaceObject, "receiveThemeSupports", function() { return receiveThemeSupports; });
  202. __webpack_require__.d(build_module_actions_namespaceObject, "receiveEmbedPreview", function() { return receiveEmbedPreview; });
  203. __webpack_require__.d(build_module_actions_namespaceObject, "editEntityRecord", function() { return editEntityRecord; });
  204. __webpack_require__.d(build_module_actions_namespaceObject, "undo", function() { return undo; });
  205. __webpack_require__.d(build_module_actions_namespaceObject, "redo", function() { return redo; });
  206. __webpack_require__.d(build_module_actions_namespaceObject, "__unstableCreateUndoLevel", function() { return __unstableCreateUndoLevel; });
  207. __webpack_require__.d(build_module_actions_namespaceObject, "saveEntityRecord", function() { return saveEntityRecord; });
  208. __webpack_require__.d(build_module_actions_namespaceObject, "saveEditedEntityRecord", function() { return saveEditedEntityRecord; });
  209. __webpack_require__.d(build_module_actions_namespaceObject, "receiveUploadPermissions", function() { return receiveUploadPermissions; });
  210. __webpack_require__.d(build_module_actions_namespaceObject, "receiveUserPermission", function() { return receiveUserPermission; });
  211. __webpack_require__.d(build_module_actions_namespaceObject, "receiveAutosaves", function() { return receiveAutosaves; });
  212. var build_module_selectors_namespaceObject = {};
  213. __webpack_require__.r(build_module_selectors_namespaceObject);
  214. __webpack_require__.d(build_module_selectors_namespaceObject, "isRequestingEmbedPreview", function() { return isRequestingEmbedPreview; });
  215. __webpack_require__.d(build_module_selectors_namespaceObject, "getAuthors", function() { return getAuthors; });
  216. __webpack_require__.d(build_module_selectors_namespaceObject, "getCurrentUser", function() { return getCurrentUser; });
  217. __webpack_require__.d(build_module_selectors_namespaceObject, "getUserQueryResults", function() { return getUserQueryResults; });
  218. __webpack_require__.d(build_module_selectors_namespaceObject, "getEntitiesByKind", function() { return getEntitiesByKind; });
  219. __webpack_require__.d(build_module_selectors_namespaceObject, "getEntity", function() { return getEntity; });
  220. __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecord", function() { return getEntityRecord; });
  221. __webpack_require__.d(build_module_selectors_namespaceObject, "getRawEntityRecord", function() { return getRawEntityRecord; });
  222. __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecords", function() { return getEntityRecords; });
  223. __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecordEdits", function() { return getEntityRecordEdits; });
  224. __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecordNonTransientEdits", function() { return getEntityRecordNonTransientEdits; });
  225. __webpack_require__.d(build_module_selectors_namespaceObject, "hasEditsForEntityRecord", function() { return hasEditsForEntityRecord; });
  226. __webpack_require__.d(build_module_selectors_namespaceObject, "getEditedEntityRecord", function() { return getEditedEntityRecord; });
  227. __webpack_require__.d(build_module_selectors_namespaceObject, "isAutosavingEntityRecord", function() { return isAutosavingEntityRecord; });
  228. __webpack_require__.d(build_module_selectors_namespaceObject, "isSavingEntityRecord", function() { return isSavingEntityRecord; });
  229. __webpack_require__.d(build_module_selectors_namespaceObject, "getLastEntitySaveError", function() { return getLastEntitySaveError; });
  230. __webpack_require__.d(build_module_selectors_namespaceObject, "getUndoEdit", function() { return getUndoEdit; });
  231. __webpack_require__.d(build_module_selectors_namespaceObject, "getRedoEdit", function() { return getRedoEdit; });
  232. __webpack_require__.d(build_module_selectors_namespaceObject, "hasUndo", function() { return hasUndo; });
  233. __webpack_require__.d(build_module_selectors_namespaceObject, "hasRedo", function() { return hasRedo; });
  234. __webpack_require__.d(build_module_selectors_namespaceObject, "getThemeSupports", function() { return getThemeSupports; });
  235. __webpack_require__.d(build_module_selectors_namespaceObject, "getEmbedPreview", function() { return getEmbedPreview; });
  236. __webpack_require__.d(build_module_selectors_namespaceObject, "isPreviewEmbedFallback", function() { return isPreviewEmbedFallback; });
  237. __webpack_require__.d(build_module_selectors_namespaceObject, "hasUploadPermissions", function() { return hasUploadPermissions; });
  238. __webpack_require__.d(build_module_selectors_namespaceObject, "canUser", function() { return canUser; });
  239. __webpack_require__.d(build_module_selectors_namespaceObject, "getAutosaves", function() { return getAutosaves; });
  240. __webpack_require__.d(build_module_selectors_namespaceObject, "getAutosave", function() { return getAutosave; });
  241. __webpack_require__.d(build_module_selectors_namespaceObject, "hasFetchedAutosaves", function() { return hasFetchedAutosaves; });
  242. __webpack_require__.d(build_module_selectors_namespaceObject, "getReferenceByDistinctEdits", function() { return getReferenceByDistinctEdits; });
  243. var resolvers_namespaceObject = {};
  244. __webpack_require__.r(resolvers_namespaceObject);
  245. __webpack_require__.d(resolvers_namespaceObject, "getAuthors", function() { return resolvers_getAuthors; });
  246. __webpack_require__.d(resolvers_namespaceObject, "getCurrentUser", function() { return resolvers_getCurrentUser; });
  247. __webpack_require__.d(resolvers_namespaceObject, "getEntityRecord", function() { return resolvers_getEntityRecord; });
  248. __webpack_require__.d(resolvers_namespaceObject, "getEntityRecords", function() { return resolvers_getEntityRecords; });
  249. __webpack_require__.d(resolvers_namespaceObject, "getThemeSupports", function() { return resolvers_getThemeSupports; });
  250. __webpack_require__.d(resolvers_namespaceObject, "getEmbedPreview", function() { return resolvers_getEmbedPreview; });
  251. __webpack_require__.d(resolvers_namespaceObject, "hasUploadPermissions", function() { return resolvers_hasUploadPermissions; });
  252. __webpack_require__.d(resolvers_namespaceObject, "canUser", function() { return resolvers_canUser; });
  253. __webpack_require__.d(resolvers_namespaceObject, "getAutosaves", function() { return resolvers_getAutosaves; });
  254. __webpack_require__.d(resolvers_namespaceObject, "getAutosave", function() { return resolvers_getAutosave; });
  255. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js
  256. var objectSpread = __webpack_require__(7);
  257. // EXTERNAL MODULE: external {"this":["wp","data"]}
  258. var external_this_wp_data_ = __webpack_require__(4);
  259. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
  260. var slicedToArray = __webpack_require__(23);
  261. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
  262. var toConsumableArray = __webpack_require__(17);
  263. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
  264. var defineProperty = __webpack_require__(10);
  265. // EXTERNAL MODULE: external "lodash"
  266. var external_lodash_ = __webpack_require__(2);
  267. // EXTERNAL MODULE: external {"this":["wp","isShallowEqual"]}
  268. var external_this_wp_isShallowEqual_ = __webpack_require__(41);
  269. var external_this_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_isShallowEqual_);
  270. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/conservative-map-item.js
  271. /**
  272. * External dependencies
  273. */
  274. /**
  275. * Given the current and next item entity, returns the minimally "modified"
  276. * result of the next item, preferring value references from the original item
  277. * if equal. If all values match, the original item is returned.
  278. *
  279. * @param {Object} item Original item.
  280. * @param {Object} nextItem Next item.
  281. *
  282. * @return {Object} Minimally modified merged item.
  283. */
  284. function conservativeMapItem(item, nextItem) {
  285. // Return next item in its entirety if there is no original item.
  286. if (!item) {
  287. return nextItem;
  288. }
  289. var hasChanges = false;
  290. var result = {};
  291. for (var key in nextItem) {
  292. if (Object(external_lodash_["isEqual"])(item[key], nextItem[key])) {
  293. result[key] = item[key];
  294. } else {
  295. hasChanges = true;
  296. result[key] = nextItem[key];
  297. }
  298. }
  299. if (!hasChanges) {
  300. return item;
  301. }
  302. return result;
  303. }
  304. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-matching-action.js
  305. /**
  306. * A higher-order reducer creator which invokes the original reducer only if
  307. * the dispatching action matches the given predicate, **OR** if state is
  308. * initializing (undefined).
  309. *
  310. * @param {Function} isMatch Function predicate for allowing reducer call.
  311. *
  312. * @return {Function} Higher-order reducer.
  313. */
  314. var ifMatchingAction = function ifMatchingAction(isMatch) {
  315. return function (reducer) {
  316. return function (state, action) {
  317. if (state === undefined || isMatch(action)) {
  318. return reducer(state, action);
  319. }
  320. return state;
  321. };
  322. };
  323. };
  324. /* harmony default export */ var if_matching_action = (ifMatchingAction);
  325. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/on-sub-key.js
  326. /**
  327. * Higher-order reducer creator which creates a combined reducer object, keyed
  328. * by a property on the action object.
  329. *
  330. * @param {string} actionProperty Action property by which to key object.
  331. *
  332. * @return {Function} Higher-order reducer.
  333. */
  334. var on_sub_key_onSubKey = function onSubKey(actionProperty) {
  335. return function (reducer) {
  336. return function () {
  337. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  338. var action = arguments.length > 1 ? arguments[1] : undefined;
  339. // Retrieve subkey from action. Do not track if undefined; useful for cases
  340. // where reducer is scoped by action shape.
  341. var key = action[actionProperty];
  342. if (key === undefined) {
  343. return state;
  344. } // Avoid updating state if unchanged. Note that this also accounts for a
  345. // reducer which returns undefined on a key which is not yet tracked.
  346. var nextKeyState = reducer(state[key], action);
  347. if (nextKeyState === state[key]) {
  348. return state;
  349. }
  350. return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, key, nextKeyState));
  351. };
  352. };
  353. };
  354. /* harmony default export */ var on_sub_key = (on_sub_key_onSubKey);
  355. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/replace-action.js
  356. /**
  357. * Higher-order reducer creator which substitutes the action object before
  358. * passing to the original reducer.
  359. *
  360. * @param {Function} replacer Function mapping original action to replacement.
  361. *
  362. * @return {Function} Higher-order reducer.
  363. */
  364. var replaceAction = function replaceAction(replacer) {
  365. return function (reducer) {
  366. return function (state, action) {
  367. return reducer(state, replacer(action));
  368. };
  369. };
  370. };
  371. /* harmony default export */ var replace_action = (replaceAction);
  372. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/with-weak-map-cache.js
  373. /**
  374. * External dependencies
  375. */
  376. /**
  377. * Given a function, returns an enhanced function which caches the result and
  378. * tracks in WeakMap. The result is only cached if the original function is
  379. * passed a valid object-like argument (requirement for WeakMap key).
  380. *
  381. * @param {Function} fn Original function.
  382. *
  383. * @return {Function} Enhanced caching function.
  384. */
  385. function withWeakMapCache(fn) {
  386. var cache = new WeakMap();
  387. return function (key) {
  388. var value;
  389. if (cache.has(key)) {
  390. value = cache.get(key);
  391. } else {
  392. value = fn(key); // Can reach here if key is not valid for WeakMap, since `has`
  393. // will return false for invalid key. Since `set` will throw,
  394. // ensure that key is valid before setting into cache.
  395. if (Object(external_lodash_["isObjectLike"])(key)) {
  396. cache.set(key, value);
  397. }
  398. }
  399. return value;
  400. };
  401. }
  402. /* harmony default export */ var with_weak_map_cache = (withWeakMapCache);
  403. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/index.js
  404. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/actions.js
  405. /**
  406. * External dependencies
  407. */
  408. /**
  409. * Returns an action object used in signalling that items have been received.
  410. *
  411. * @param {Array} items Items received.
  412. *
  413. * @return {Object} Action object.
  414. */
  415. function receiveItems(items) {
  416. return {
  417. type: 'RECEIVE_ITEMS',
  418. items: Object(external_lodash_["castArray"])(items)
  419. };
  420. }
  421. /**
  422. * Returns an action object used in signalling that queried data has been
  423. * received.
  424. *
  425. * @param {Array} items Queried items received.
  426. * @param {?Object} query Optional query object.
  427. *
  428. * @return {Object} Action object.
  429. */
  430. function receiveQueriedItems(items) {
  431. var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  432. return Object(objectSpread["a" /* default */])({}, receiveItems(items), {
  433. query: query
  434. });
  435. }
  436. // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js
  437. var rememo = __webpack_require__(36);
  438. // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
  439. var equivalent_key_map = __webpack_require__(74);
  440. var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
  441. // EXTERNAL MODULE: external {"this":["wp","url"]}
  442. var external_this_wp_url_ = __webpack_require__(26);
  443. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/get-query-parts.js
  444. /**
  445. * WordPress dependencies
  446. */
  447. /**
  448. * Internal dependencies
  449. */
  450. /**
  451. * An object of properties describing a specific query.
  452. *
  453. * @typedef {Object} WPQueriedDataQueryParts
  454. *
  455. * @property {number} page The query page (1-based index, default 1).
  456. * @property {number} perPage Items per page for query (default 10).
  457. * @property {string} stableKey An encoded stable string of all non-pagination
  458. * query parameters.
  459. */
  460. /**
  461. * Given a query object, returns an object of parts, including pagination
  462. * details (`page` and `perPage`, or default values). All other properties are
  463. * encoded into a stable (idempotent) `stableKey` value.
  464. *
  465. * @param {Object} query Optional query object.
  466. *
  467. * @return {WPQueriedDataQueryParts} Query parts.
  468. */
  469. function getQueryParts(query) {
  470. /**
  471. * @type {WPQueriedDataQueryParts}
  472. */
  473. var parts = {
  474. stableKey: '',
  475. page: 1,
  476. perPage: 10
  477. }; // Ensure stable key by sorting keys. Also more efficient for iterating.
  478. var keys = Object.keys(query).sort();
  479. for (var i = 0; i < keys.length; i++) {
  480. var key = keys[i];
  481. var value = query[key];
  482. switch (key) {
  483. case 'page':
  484. parts[key] = Number(value);
  485. break;
  486. case 'per_page':
  487. parts.perPage = Number(value);
  488. break;
  489. default:
  490. // While it could be any deterministic string, for simplicity's
  491. // sake mimic querystring encoding for stable key.
  492. //
  493. // TODO: For consistency with PHP implementation, addQueryArgs
  494. // should accept a key value pair, which may optimize its
  495. // implementation for our use here, vs. iterating an object
  496. // with only a single key.
  497. parts.stableKey += (parts.stableKey ? '&' : '') + Object(external_this_wp_url_["addQueryArgs"])('', Object(defineProperty["a" /* default */])({}, key, value)).slice(1);
  498. }
  499. }
  500. return parts;
  501. }
  502. /* harmony default export */ var get_query_parts = (with_weak_map_cache(getQueryParts));
  503. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/selectors.js
  504. /**
  505. * External dependencies
  506. */
  507. /**
  508. * Internal dependencies
  509. */
  510. /**
  511. * Cache of state keys to EquivalentKeyMap where the inner map tracks queries
  512. * to their resulting items set. WeakMap allows garbage collection on expired
  513. * state references.
  514. *
  515. * @type {WeakMap<Object,EquivalentKeyMap>}
  516. */
  517. var queriedItemsCacheByState = new WeakMap();
  518. /**
  519. * Returns items for a given query, or null if the items are not known.
  520. *
  521. * @param {Object} state State object.
  522. * @param {?Object} query Optional query.
  523. *
  524. * @return {?Array} Query items.
  525. */
  526. function getQueriedItemsUncached(state, query) {
  527. var _getQueryParts = get_query_parts(query),
  528. stableKey = _getQueryParts.stableKey,
  529. page = _getQueryParts.page,
  530. perPage = _getQueryParts.perPage;
  531. if (!state.queries[stableKey]) {
  532. return null;
  533. }
  534. var itemIds = state.queries[stableKey];
  535. if (!itemIds) {
  536. return null;
  537. }
  538. var startOffset = perPage === -1 ? 0 : (page - 1) * perPage;
  539. var endOffset = perPage === -1 ? itemIds.length : Math.min(startOffset + perPage, itemIds.length);
  540. var items = [];
  541. for (var i = startOffset; i < endOffset; i++) {
  542. var itemId = itemIds[i];
  543. items.push(state.items[itemId]);
  544. }
  545. return items;
  546. }
  547. /**
  548. * Returns items for a given query, or null if the items are not known. Caches
  549. * result both per state (by reference) and per query (by deep equality).
  550. * The caching approach is intended to be durable to query objects which are
  551. * deeply but not referentially equal, since otherwise:
  552. *
  553. * `getQueriedItems( state, {} ) !== getQueriedItems( state, {} )`
  554. *
  555. * @param {Object} state State object.
  556. * @param {?Object} query Optional query.
  557. *
  558. * @return {?Array} Query items.
  559. */
  560. var getQueriedItems = Object(rememo["a" /* default */])(function (state) {
  561. var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  562. var queriedItemsCache = queriedItemsCacheByState.get(state);
  563. if (queriedItemsCache) {
  564. var queriedItems = queriedItemsCache.get(query);
  565. if (queriedItems !== undefined) {
  566. return queriedItems;
  567. }
  568. } else {
  569. queriedItemsCache = new equivalent_key_map_default.a();
  570. queriedItemsCacheByState.set(state, queriedItemsCache);
  571. }
  572. var items = getQueriedItemsUncached(state, query);
  573. queriedItemsCache.set(query, items);
  574. return items;
  575. });
  576. // EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js
  577. var regenerator = __webpack_require__(20);
  578. var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);
  579. // EXTERNAL MODULE: external {"this":["wp","apiFetch"]}
  580. var external_this_wp_apiFetch_ = __webpack_require__(34);
  581. var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_);
  582. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/controls.js
  583. /**
  584. * WordPress dependencies
  585. */
  586. /**
  587. * Trigger an API Fetch request.
  588. *
  589. * @param {Object} request API Fetch Request Object.
  590. * @return {Object} control descriptor.
  591. */
  592. function apiFetch(request) {
  593. return {
  594. type: 'API_FETCH',
  595. request: request
  596. };
  597. }
  598. /**
  599. * Calls a selector using the current state.
  600. *
  601. * @param {string} selectorName Selector name.
  602. * @param {Array} args Selector arguments.
  603. *
  604. * @return {Object} control descriptor.
  605. */
  606. function controls_select(selectorName) {
  607. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  608. args[_key - 1] = arguments[_key];
  609. }
  610. return {
  611. type: 'SELECT',
  612. selectorName: selectorName,
  613. args: args
  614. };
  615. }
  616. /**
  617. * Dispatches a control action for triggering a registry select that has a
  618. * resolver.
  619. *
  620. * @param {string} selectorName
  621. * @param {Array} args Arguments for the select.
  622. *
  623. * @return {Object} control descriptor.
  624. */
  625. function resolveSelect(selectorName) {
  626. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  627. args[_key2 - 1] = arguments[_key2];
  628. }
  629. return {
  630. type: 'RESOLVE_SELECT',
  631. selectorName: selectorName,
  632. args: args
  633. };
  634. }
  635. var controls = {
  636. API_FETCH: function API_FETCH(_ref) {
  637. var request = _ref.request;
  638. return external_this_wp_apiFetch_default()(request);
  639. },
  640. SELECT: Object(external_this_wp_data_["createRegistryControl"])(function (registry) {
  641. return function (_ref2) {
  642. var _registry$select;
  643. var selectorName = _ref2.selectorName,
  644. args = _ref2.args;
  645. return (_registry$select = registry.select('core'))[selectorName].apply(_registry$select, Object(toConsumableArray["a" /* default */])(args));
  646. };
  647. }),
  648. RESOLVE_SELECT: Object(external_this_wp_data_["createRegistryControl"])(function (registry) {
  649. return function (_ref3) {
  650. var selectorName = _ref3.selectorName,
  651. args = _ref3.args;
  652. return new Promise(function (resolve) {
  653. var hasFinished = function hasFinished() {
  654. return registry.select('core/data').hasFinishedResolution('core', selectorName, args);
  655. };
  656. var getResult = function getResult() {
  657. return registry.select('core')[selectorName].apply(null, args);
  658. }; // trigger the selector (to trigger the resolver)
  659. var result = getResult();
  660. if (hasFinished()) {
  661. return resolve(result);
  662. }
  663. var unsubscribe = registry.subscribe(function () {
  664. if (hasFinished()) {
  665. unsubscribe();
  666. resolve(getResult());
  667. }
  668. });
  669. });
  670. };
  671. })
  672. };
  673. /* harmony default export */ var build_module_controls = (controls);
  674. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/actions.js
  675. var _marked =
  676. /*#__PURE__*/
  677. regenerator_default.a.mark(editEntityRecord),
  678. _marked2 =
  679. /*#__PURE__*/
  680. regenerator_default.a.mark(undo),
  681. _marked3 =
  682. /*#__PURE__*/
  683. regenerator_default.a.mark(redo),
  684. _marked4 =
  685. /*#__PURE__*/
  686. regenerator_default.a.mark(saveEntityRecord),
  687. _marked5 =
  688. /*#__PURE__*/
  689. regenerator_default.a.mark(saveEditedEntityRecord);
  690. /**
  691. * External dependencies
  692. */
  693. /**
  694. * Internal dependencies
  695. */
  696. /**
  697. * Returns an action object used in signalling that authors have been received.
  698. *
  699. * @param {string} queryID Query ID.
  700. * @param {Array|Object} users Users received.
  701. *
  702. * @return {Object} Action object.
  703. */
  704. function receiveUserQuery(queryID, users) {
  705. return {
  706. type: 'RECEIVE_USER_QUERY',
  707. users: Object(external_lodash_["castArray"])(users),
  708. queryID: queryID
  709. };
  710. }
  711. /**
  712. * Returns an action used in signalling that the current user has been received.
  713. *
  714. * @param {Object} currentUser Current user object.
  715. *
  716. * @return {Object} Action object.
  717. */
  718. function receiveCurrentUser(currentUser) {
  719. return {
  720. type: 'RECEIVE_CURRENT_USER',
  721. currentUser: currentUser
  722. };
  723. }
  724. /**
  725. * Returns an action object used in adding new entities.
  726. *
  727. * @param {Array} entities Entities received.
  728. *
  729. * @return {Object} Action object.
  730. */
  731. function addEntities(entities) {
  732. return {
  733. type: 'ADD_ENTITIES',
  734. entities: entities
  735. };
  736. }
  737. /**
  738. * Returns an action object used in signalling that entity records have been received.
  739. *
  740. * @param {string} kind Kind of the received entity.
  741. * @param {string} name Name of the received entity.
  742. * @param {Array|Object} records Records received.
  743. * @param {?Object} query Query Object.
  744. * @param {?boolean} invalidateCache Should invalidate query caches
  745. *
  746. * @return {Object} Action object.
  747. */
  748. function receiveEntityRecords(kind, name, records, query) {
  749. var invalidateCache = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  750. // Auto drafts should not have titles, but some plugins rely on them so we can't filter this
  751. // on the server.
  752. if (kind === 'postType') {
  753. records = Object(external_lodash_["castArray"])(records).map(function (record) {
  754. return record.status === 'auto-draft' ? Object(objectSpread["a" /* default */])({}, record, {
  755. title: ''
  756. }) : record;
  757. });
  758. }
  759. var action;
  760. if (query) {
  761. action = receiveQueriedItems(records, query);
  762. } else {
  763. action = receiveItems(records);
  764. }
  765. return Object(objectSpread["a" /* default */])({}, action, {
  766. kind: kind,
  767. name: name,
  768. invalidateCache: invalidateCache
  769. });
  770. }
  771. /**
  772. * Returns an action object used in signalling that the index has been received.
  773. *
  774. * @param {Object} themeSupports Theme support for the current theme.
  775. *
  776. * @return {Object} Action object.
  777. */
  778. function receiveThemeSupports(themeSupports) {
  779. return {
  780. type: 'RECEIVE_THEME_SUPPORTS',
  781. themeSupports: themeSupports
  782. };
  783. }
  784. /**
  785. * Returns an action object used in signalling that the preview data for
  786. * a given URl has been received.
  787. *
  788. * @param {string} url URL to preview the embed for.
  789. * @param {Mixed} preview Preview data.
  790. *
  791. * @return {Object} Action object.
  792. */
  793. function receiveEmbedPreview(url, preview) {
  794. return {
  795. type: 'RECEIVE_EMBED_PREVIEW',
  796. url: url,
  797. preview: preview
  798. };
  799. }
  800. /**
  801. * Returns an action object that triggers an
  802. * edit to an entity record.
  803. *
  804. * @param {string} kind Kind of the edited entity record.
  805. * @param {string} name Name of the edited entity record.
  806. * @param {number} recordId Record ID of the edited entity record.
  807. * @param {Object} edits The edits.
  808. * @param {Object} options Options for the edit.
  809. * @param {boolean} options.undoIgnore Whether to ignore the edit in undo history or not.
  810. *
  811. * @return {Object} Action object.
  812. */
  813. function editEntityRecord(kind, name, recordId, edits) {
  814. var options,
  815. _ref,
  816. _ref$transientEdits,
  817. transientEdits,
  818. _ref$mergedEdits,
  819. mergedEdits,
  820. record,
  821. editedRecord,
  822. edit,
  823. _args = arguments;
  824. return regenerator_default.a.wrap(function editEntityRecord$(_context) {
  825. while (1) {
  826. switch (_context.prev = _context.next) {
  827. case 0:
  828. options = _args.length > 4 && _args[4] !== undefined ? _args[4] : {};
  829. _context.next = 3;
  830. return controls_select('getEntity', kind, name);
  831. case 3:
  832. _ref = _context.sent;
  833. _ref$transientEdits = _ref.transientEdits;
  834. transientEdits = _ref$transientEdits === void 0 ? {} : _ref$transientEdits;
  835. _ref$mergedEdits = _ref.mergedEdits;
  836. mergedEdits = _ref$mergedEdits === void 0 ? {} : _ref$mergedEdits;
  837. _context.next = 10;
  838. return controls_select('getRawEntityRecord', kind, name, recordId);
  839. case 10:
  840. record = _context.sent;
  841. _context.next = 13;
  842. return controls_select('getEditedEntityRecord', kind, name, recordId);
  843. case 13:
  844. editedRecord = _context.sent;
  845. edit = {
  846. kind: kind,
  847. name: name,
  848. recordId: recordId,
  849. // Clear edits when they are equal to their persisted counterparts
  850. // so that the property is not considered dirty.
  851. edits: Object.keys(edits).reduce(function (acc, key) {
  852. var recordValue = record[key];
  853. var editedRecordValue = editedRecord[key];
  854. var value = mergedEdits[key] ? Object(objectSpread["a" /* default */])({}, editedRecordValue, edits[key]) : edits[key];
  855. acc[key] = Object(external_lodash_["isEqual"])(recordValue, value) ? undefined : value;
  856. return acc;
  857. }, {}),
  858. transientEdits: transientEdits
  859. };
  860. return _context.abrupt("return", Object(objectSpread["a" /* default */])({
  861. type: 'EDIT_ENTITY_RECORD'
  862. }, edit, {
  863. meta: {
  864. undo: !options.undoIgnore && Object(objectSpread["a" /* default */])({}, edit, {
  865. // Send the current values for things like the first undo stack entry.
  866. edits: Object.keys(edits).reduce(function (acc, key) {
  867. acc[key] = editedRecord[key];
  868. return acc;
  869. }, {})
  870. })
  871. }
  872. }));
  873. case 16:
  874. case "end":
  875. return _context.stop();
  876. }
  877. }
  878. }, _marked);
  879. }
  880. /**
  881. * Action triggered to undo the last edit to
  882. * an entity record, if any.
  883. */
  884. function undo() {
  885. var undoEdit;
  886. return regenerator_default.a.wrap(function undo$(_context2) {
  887. while (1) {
  888. switch (_context2.prev = _context2.next) {
  889. case 0:
  890. _context2.next = 2;
  891. return controls_select('getUndoEdit');
  892. case 2:
  893. undoEdit = _context2.sent;
  894. if (undoEdit) {
  895. _context2.next = 5;
  896. break;
  897. }
  898. return _context2.abrupt("return");
  899. case 5:
  900. _context2.next = 7;
  901. return Object(objectSpread["a" /* default */])({
  902. type: 'EDIT_ENTITY_RECORD'
  903. }, undoEdit, {
  904. meta: {
  905. isUndo: true
  906. }
  907. });
  908. case 7:
  909. case "end":
  910. return _context2.stop();
  911. }
  912. }
  913. }, _marked2);
  914. }
  915. /**
  916. * Action triggered to redo the last undoed
  917. * edit to an entity record, if any.
  918. */
  919. function redo() {
  920. var redoEdit;
  921. return regenerator_default.a.wrap(function redo$(_context3) {
  922. while (1) {
  923. switch (_context3.prev = _context3.next) {
  924. case 0:
  925. _context3.next = 2;
  926. return controls_select('getRedoEdit');
  927. case 2:
  928. redoEdit = _context3.sent;
  929. if (redoEdit) {
  930. _context3.next = 5;
  931. break;
  932. }
  933. return _context3.abrupt("return");
  934. case 5:
  935. _context3.next = 7;
  936. return Object(objectSpread["a" /* default */])({
  937. type: 'EDIT_ENTITY_RECORD'
  938. }, redoEdit, {
  939. meta: {
  940. isRedo: true
  941. }
  942. });
  943. case 7:
  944. case "end":
  945. return _context3.stop();
  946. }
  947. }
  948. }, _marked3);
  949. }
  950. /**
  951. * Forces the creation of a new undo level.
  952. *
  953. * @return {Object} Action object.
  954. */
  955. function __unstableCreateUndoLevel() {
  956. return {
  957. type: 'CREATE_UNDO_LEVEL'
  958. };
  959. }
  960. /**
  961. * Action triggered to save an entity record.
  962. *
  963. * @param {string} kind Kind of the received entity.
  964. * @param {string} name Name of the received entity.
  965. * @param {Object} record Record to be saved.
  966. * @param {Object} options Saving options.
  967. */
  968. function saveEntityRecord(kind, name, record) {
  969. var _ref2,
  970. _ref2$isAutosave,
  971. isAutosave,
  972. entities,
  973. entity,
  974. entityIdKey,
  975. recordId,
  976. updatedRecord,
  977. error,
  978. persistedEntity,
  979. currentEdits,
  980. path,
  981. persistedRecord,
  982. currentUser,
  983. currentUserId,
  984. autosavePost,
  985. data,
  986. newRecord,
  987. _data,
  988. _args4 = arguments;
  989. return regenerator_default.a.wrap(function saveEntityRecord$(_context4) {
  990. while (1) {
  991. switch (_context4.prev = _context4.next) {
  992. case 0:
  993. _ref2 = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : {
  994. isAutosave: false
  995. }, _ref2$isAutosave = _ref2.isAutosave, isAutosave = _ref2$isAutosave === void 0 ? false : _ref2$isAutosave;
  996. _context4.next = 3;
  997. return getKindEntities(kind);
  998. case 3:
  999. entities = _context4.sent;
  1000. entity = Object(external_lodash_["find"])(entities, {
  1001. kind: kind,
  1002. name: name
  1003. });
  1004. if (entity) {
  1005. _context4.next = 7;
  1006. break;
  1007. }
  1008. return _context4.abrupt("return");
  1009. case 7:
  1010. entityIdKey = entity.key || DEFAULT_ENTITY_KEY;
  1011. recordId = record[entityIdKey];
  1012. _context4.next = 11;
  1013. return {
  1014. type: 'SAVE_ENTITY_RECORD_START',
  1015. kind: kind,
  1016. name: name,
  1017. recordId: recordId,
  1018. isAutosave: isAutosave
  1019. };
  1020. case 11:
  1021. _context4.prev = 11;
  1022. path = "".concat(entity.baseURL).concat(recordId ? '/' + recordId : '');
  1023. _context4.next = 15;
  1024. return controls_select('getRawEntityRecord', kind, name, recordId);
  1025. case 15:
  1026. persistedRecord = _context4.sent;
  1027. if (!isAutosave) {
  1028. _context4.next = 40;
  1029. break;
  1030. }
  1031. _context4.next = 19;
  1032. return controls_select('getCurrentUser');
  1033. case 19:
  1034. currentUser = _context4.sent;
  1035. currentUserId = currentUser ? currentUser.id : undefined;
  1036. _context4.next = 23;
  1037. return controls_select('getAutosave', persistedRecord.type, persistedRecord.id, currentUserId);
  1038. case 23:
  1039. autosavePost = _context4.sent;
  1040. // Autosaves need all expected fields to be present.
  1041. // So we fallback to the previous autosave and then
  1042. // to the actual persisted entity if the edits don't
  1043. // have a value.
  1044. data = Object(objectSpread["a" /* default */])({}, persistedRecord, autosavePost, record);
  1045. data = Object.keys(data).reduce(function (acc, key) {
  1046. if (['title', 'excerpt', 'content'].includes(key)) {
  1047. // Edits should be the "raw" attribute values.
  1048. acc[key] = Object(external_lodash_["get"])(data[key], 'raw', data[key]);
  1049. }
  1050. return acc;
  1051. }, {
  1052. status: data.status === 'auto-draft' ? 'draft' : data.status
  1053. });
  1054. _context4.next = 28;
  1055. return apiFetch({
  1056. path: "".concat(path, "/autosaves"),
  1057. method: 'POST',
  1058. data: data
  1059. });
  1060. case 28:
  1061. updatedRecord = _context4.sent;
  1062. if (!(persistedRecord.id === updatedRecord.id)) {
  1063. _context4.next = 36;
  1064. break;
  1065. }
  1066. newRecord = Object(objectSpread["a" /* default */])({}, persistedRecord, data, updatedRecord);
  1067. newRecord = Object.keys(newRecord).reduce(function (acc, key) {
  1068. // These properties are persisted in autosaves.
  1069. if (['title', 'excerpt', 'content'].includes(key)) {
  1070. // Edits should be the "raw" attribute values.
  1071. acc[key] = Object(external_lodash_["get"])(newRecord[key], 'raw', newRecord[key]);
  1072. } else if (key === 'status') {
  1073. // Status is only persisted in autosaves when going from
  1074. // "auto-draft" to "draft".
  1075. acc[key] = persistedRecord.status === 'auto-draft' && newRecord.status === 'draft' ? newRecord.status : persistedRecord.status;
  1076. } else {
  1077. // These properties are not persisted in autosaves.
  1078. acc[key] = Object(external_lodash_["get"])(persistedRecord[key], 'raw', persistedRecord[key]);
  1079. }
  1080. return acc;
  1081. }, {});
  1082. _context4.next = 34;
  1083. return receiveEntityRecords(kind, name, newRecord, undefined, true);
  1084. case 34:
  1085. _context4.next = 38;
  1086. break;
  1087. case 36:
  1088. _context4.next = 38;
  1089. return receiveAutosaves(persistedRecord.id, updatedRecord);
  1090. case 38:
  1091. _context4.next = 55;
  1092. break;
  1093. case 40:
  1094. // Auto drafts should be converted to drafts on explicit saves and we should not respect their default title,
  1095. // but some plugins break with this behavior so we can't filter it on the server.
  1096. _data = record;
  1097. if (kind === 'postType' && persistedRecord && persistedRecord.status === 'auto-draft') {
  1098. if (!_data.status) {
  1099. _data = Object(objectSpread["a" /* default */])({}, _data, {
  1100. status: 'draft'
  1101. });
  1102. }
  1103. if (!_data.title || _data.title === 'Auto Draft') {
  1104. _data = Object(objectSpread["a" /* default */])({}, _data, {
  1105. title: ''
  1106. });
  1107. }
  1108. } // We perform an optimistic update here to clear all the edits that
  1109. // will be persisted so that if the server filters them, the new
  1110. // filtered values are always accepted.
  1111. _context4.next = 44;
  1112. return controls_select('getEntityRecord', kind, name, recordId);
  1113. case 44:
  1114. persistedEntity = _context4.sent;
  1115. _context4.next = 47;
  1116. return controls_select('getEntityRecordEdits', kind, name, recordId);
  1117. case 47:
  1118. currentEdits = _context4.sent;
  1119. _context4.next = 50;
  1120. return receiveEntityRecords(kind, name, Object(objectSpread["a" /* default */])({}, persistedEntity, _data), undefined, true);
  1121. case 50:
  1122. _context4.next = 52;
  1123. return apiFetch({
  1124. path: path,
  1125. method: recordId ? 'PUT' : 'POST',
  1126. data: _data
  1127. });
  1128. case 52:
  1129. updatedRecord = _context4.sent;
  1130. _context4.next = 55;
  1131. return receiveEntityRecords(kind, name, updatedRecord, undefined, true);
  1132. case 55:
  1133. _context4.next = 77;
  1134. break;
  1135. case 57:
  1136. _context4.prev = 57;
  1137. _context4.t0 = _context4["catch"](11);
  1138. error = _context4.t0; // If we got to the point in the try block where we made an optimistic update,
  1139. // we need to roll it back here.
  1140. if (!(persistedEntity && currentEdits)) {
  1141. _context4.next = 77;
  1142. break;
  1143. }
  1144. _context4.next = 63;
  1145. return receiveEntityRecords(kind, name, persistedEntity, undefined, true);
  1146. case 63:
  1147. _context4.t1 = editEntityRecord;
  1148. _context4.t2 = kind;
  1149. _context4.t3 = name;
  1150. _context4.t4 = recordId;
  1151. _context4.t5 = objectSpread["a" /* default */];
  1152. _context4.t6 = {};
  1153. _context4.t7 = currentEdits;
  1154. _context4.next = 72;
  1155. return controls_select('getEntityRecordEdits', kind, name, recordId);
  1156. case 72:
  1157. _context4.t8 = _context4.sent;
  1158. _context4.t9 = (0, _context4.t5)(_context4.t6, _context4.t7, _context4.t8);
  1159. _context4.t10 = {
  1160. undoIgnore: true
  1161. };
  1162. _context4.next = 77;
  1163. return (0, _context4.t1)(_context4.t2, _context4.t3, _context4.t4, _context4.t9, _context4.t10);
  1164. case 77:
  1165. _context4.next = 79;
  1166. return {
  1167. type: 'SAVE_ENTITY_RECORD_FINISH',
  1168. kind: kind,
  1169. name: name,
  1170. recordId: recordId,
  1171. error: error,
  1172. isAutosave: isAutosave
  1173. };
  1174. case 79:
  1175. return _context4.abrupt("return", updatedRecord);
  1176. case 80:
  1177. case "end":
  1178. return _context4.stop();
  1179. }
  1180. }
  1181. }, _marked4, null, [[11, 57]]);
  1182. }
  1183. /**
  1184. * Action triggered to save an entity record's edits.
  1185. *
  1186. * @param {string} kind Kind of the entity.
  1187. * @param {string} name Name of the entity.
  1188. * @param {Object} recordId ID of the record.
  1189. * @param {Object} options Saving options.
  1190. */
  1191. function saveEditedEntityRecord(kind, name, recordId, options) {
  1192. var edits, record;
  1193. return regenerator_default.a.wrap(function saveEditedEntityRecord$(_context5) {
  1194. while (1) {
  1195. switch (_context5.prev = _context5.next) {
  1196. case 0:
  1197. _context5.next = 2;
  1198. return controls_select('hasEditsForEntityRecord', kind, name, recordId);
  1199. case 2:
  1200. if (_context5.sent) {
  1201. _context5.next = 4;
  1202. break;
  1203. }
  1204. return _context5.abrupt("return");
  1205. case 4:
  1206. _context5.next = 6;
  1207. return controls_select('getEntityRecordNonTransientEdits', kind, name, recordId);
  1208. case 6:
  1209. edits = _context5.sent;
  1210. record = Object(objectSpread["a" /* default */])({
  1211. id: recordId
  1212. }, edits);
  1213. return _context5.delegateYield(saveEntityRecord(kind, name, record, options), "t0", 9);
  1214. case 9:
  1215. case "end":
  1216. return _context5.stop();
  1217. }
  1218. }
  1219. }, _marked5);
  1220. }
  1221. /**
  1222. * Returns an action object used in signalling that Upload permissions have been received.
  1223. *
  1224. * @param {boolean} hasUploadPermissions Does the user have permission to upload files?
  1225. *
  1226. * @return {Object} Action object.
  1227. */
  1228. function receiveUploadPermissions(hasUploadPermissions) {
  1229. return {
  1230. type: 'RECEIVE_USER_PERMISSION',
  1231. key: 'create/media',
  1232. isAllowed: hasUploadPermissions
  1233. };
  1234. }
  1235. /**
  1236. * Returns an action object used in signalling that the current user has
  1237. * permission to perform an action on a REST resource.
  1238. *
  1239. * @param {string} key A key that represents the action and REST resource.
  1240. * @param {boolean} isAllowed Whether or not the user can perform the action.
  1241. *
  1242. * @return {Object} Action object.
  1243. */
  1244. function receiveUserPermission(key, isAllowed) {
  1245. return {
  1246. type: 'RECEIVE_USER_PERMISSION',
  1247. key: key,
  1248. isAllowed: isAllowed
  1249. };
  1250. }
  1251. /**
  1252. * Returns an action object used in signalling that the autosaves for a
  1253. * post have been received.
  1254. *
  1255. * @param {number} postId The id of the post that is parent to the autosave.
  1256. * @param {Array|Object} autosaves An array of autosaves or singular autosave object.
  1257. *
  1258. * @return {Object} Action object.
  1259. */
  1260. function receiveAutosaves(postId, autosaves) {
  1261. return {
  1262. type: 'RECEIVE_AUTOSAVES',
  1263. postId: postId,
  1264. autosaves: Object(external_lodash_["castArray"])(autosaves)
  1265. };
  1266. }
  1267. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entities.js
  1268. var entities_marked =
  1269. /*#__PURE__*/
  1270. regenerator_default.a.mark(loadPostTypeEntities),
  1271. entities_marked2 =
  1272. /*#__PURE__*/
  1273. regenerator_default.a.mark(loadTaxonomyEntities),
  1274. entities_marked3 =
  1275. /*#__PURE__*/
  1276. regenerator_default.a.mark(getKindEntities);
  1277. /**
  1278. * External dependencies
  1279. */
  1280. /**
  1281. * Internal dependencies
  1282. */
  1283. var DEFAULT_ENTITY_KEY = 'id';
  1284. var defaultEntities = [{
  1285. name: 'postType',
  1286. kind: 'root',
  1287. key: 'slug',
  1288. baseURL: '/wp/v2/types'
  1289. }, {
  1290. name: 'media',
  1291. kind: 'root',
  1292. baseURL: '/wp/v2/media',
  1293. plural: 'mediaItems'
  1294. }, {
  1295. name: 'taxonomy',
  1296. kind: 'root',
  1297. key: 'slug',
  1298. baseURL: '/wp/v2/taxonomies',
  1299. plural: 'taxonomies'
  1300. }, {
  1301. name: 'widgetArea',
  1302. kind: 'root',
  1303. baseURL: '/__experimental/widget-areas',
  1304. plural: 'widgetAreas'
  1305. }];
  1306. var kinds = [{
  1307. name: 'postType',
  1308. loadEntities: loadPostTypeEntities
  1309. }, {
  1310. name: 'taxonomy',
  1311. loadEntities: loadTaxonomyEntities
  1312. }];
  1313. /**
  1314. * Returns the list of post type entities.
  1315. *
  1316. * @return {Promise} Entities promise
  1317. */
  1318. function loadPostTypeEntities() {
  1319. var postTypes;
  1320. return regenerator_default.a.wrap(function loadPostTypeEntities$(_context) {
  1321. while (1) {
  1322. switch (_context.prev = _context.next) {
  1323. case 0:
  1324. _context.next = 2;
  1325. return apiFetch({
  1326. path: '/wp/v2/types?context=edit'
  1327. });
  1328. case 2:
  1329. postTypes = _context.sent;
  1330. return _context.abrupt("return", Object(external_lodash_["map"])(postTypes, function (postType, name) {
  1331. return {
  1332. kind: 'postType',
  1333. baseURL: '/wp/v2/' + postType.rest_base,
  1334. name: name,
  1335. transientEdits: {
  1336. blocks: true
  1337. },
  1338. mergedEdits: {
  1339. meta: true
  1340. }
  1341. };
  1342. }));
  1343. case 4:
  1344. case "end":
  1345. return _context.stop();
  1346. }
  1347. }
  1348. }, entities_marked);
  1349. }
  1350. /**
  1351. * Returns the list of the taxonomies entities.
  1352. *
  1353. * @return {Promise} Entities promise
  1354. */
  1355. function loadTaxonomyEntities() {
  1356. var taxonomies;
  1357. return regenerator_default.a.wrap(function loadTaxonomyEntities$(_context2) {
  1358. while (1) {
  1359. switch (_context2.prev = _context2.next) {
  1360. case 0:
  1361. _context2.next = 2;
  1362. return apiFetch({
  1363. path: '/wp/v2/taxonomies?context=edit'
  1364. });
  1365. case 2:
  1366. taxonomies = _context2.sent;
  1367. return _context2.abrupt("return", Object(external_lodash_["map"])(taxonomies, function (taxonomy, name) {
  1368. return {
  1369. kind: 'taxonomy',
  1370. baseURL: '/wp/v2/' + taxonomy.rest_base,
  1371. name: name
  1372. };
  1373. }));
  1374. case 4:
  1375. case "end":
  1376. return _context2.stop();
  1377. }
  1378. }
  1379. }, entities_marked2);
  1380. }
  1381. /**
  1382. * Returns the entity's getter method name given its kind and name.
  1383. *
  1384. * @param {string} kind Entity kind.
  1385. * @param {string} name Entity name.
  1386. * @param {string} prefix Function prefix.
  1387. * @param {boolean} usePlural Whether to use the plural form or not.
  1388. *
  1389. * @return {string} Method name
  1390. */
  1391. var entities_getMethodName = function getMethodName(kind, name) {
  1392. var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'get';
  1393. var usePlural = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  1394. var entity = Object(external_lodash_["find"])(defaultEntities, {
  1395. kind: kind,
  1396. name: name
  1397. });
  1398. var kindPrefix = kind === 'root' ? '' : Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(kind));
  1399. var nameSuffix = Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(name)) + (usePlural ? 's' : '');
  1400. var suffix = usePlural && entity.plural ? Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(entity.plural)) : nameSuffix;
  1401. return "".concat(prefix).concat(kindPrefix).concat(suffix);
  1402. };
  1403. /**
  1404. * Loads the kind entities into the store.
  1405. *
  1406. * @param {string} kind Kind
  1407. *
  1408. * @return {Array} Entities
  1409. */
  1410. function getKindEntities(kind) {
  1411. var entities, kindConfig;
  1412. return regenerator_default.a.wrap(function getKindEntities$(_context3) {
  1413. while (1) {
  1414. switch (_context3.prev = _context3.next) {
  1415. case 0:
  1416. _context3.next = 2;
  1417. return controls_select('getEntitiesByKind', kind);
  1418. case 2:
  1419. entities = _context3.sent;
  1420. if (!(entities && entities.length !== 0)) {
  1421. _context3.next = 5;
  1422. break;
  1423. }
  1424. return _context3.abrupt("return", entities);
  1425. case 5:
  1426. kindConfig = Object(external_lodash_["find"])(kinds, {
  1427. name: kind
  1428. });
  1429. if (kindConfig) {
  1430. _context3.next = 8;
  1431. break;
  1432. }
  1433. return _context3.abrupt("return", []);
  1434. case 8:
  1435. _context3.next = 10;
  1436. return kindConfig.loadEntities();
  1437. case 10:
  1438. entities = _context3.sent;
  1439. _context3.next = 13;
  1440. return addEntities(entities);
  1441. case 13:
  1442. return _context3.abrupt("return", entities);
  1443. case 14:
  1444. case "end":
  1445. return _context3.stop();
  1446. }
  1447. }
  1448. }, entities_marked3);
  1449. }
  1450. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/reducer.js
  1451. /**
  1452. * External dependencies
  1453. */
  1454. /**
  1455. * WordPress dependencies
  1456. */
  1457. /**
  1458. * Internal dependencies
  1459. */
  1460. /**
  1461. * Returns a merged array of item IDs, given details of the received paginated
  1462. * items. The array is sparse-like with `undefined` entries where holes exist.
  1463. *
  1464. * @param {?Array<number>} itemIds Original item IDs (default empty array).
  1465. * @param {number[]} nextItemIds Item IDs to merge.
  1466. * @param {number} page Page of items merged.
  1467. * @param {number} perPage Number of items per page.
  1468. *
  1469. * @return {number[]} Merged array of item IDs.
  1470. */
  1471. function getMergedItemIds(itemIds, nextItemIds, page, perPage) {
  1472. var nextItemIdsStartIndex = (page - 1) * perPage; // If later page has already been received, default to the larger known
  1473. // size of the existing array, else calculate as extending the existing.
  1474. var size = Math.max(itemIds.length, nextItemIdsStartIndex + nextItemIds.length); // Preallocate array since size is known.
  1475. var mergedItemIds = new Array(size);
  1476. for (var i = 0; i < size; i++) {
  1477. // Preserve existing item ID except for subset of range of next items.
  1478. var isInNextItemsRange = i >= nextItemIdsStartIndex && i < nextItemIdsStartIndex + nextItemIds.length;
  1479. mergedItemIds[i] = isInNextItemsRange ? nextItemIds[i - nextItemIdsStartIndex] : itemIds[i];
  1480. }
  1481. return mergedItemIds;
  1482. }
  1483. /**
  1484. * Reducer tracking items state, keyed by ID. Items are assumed to be normal,
  1485. * where identifiers are common across all queries.
  1486. *
  1487. * @param {Object} state Current state.
  1488. * @param {Object} action Dispatched action.
  1489. *
  1490. * @return {Object} Next state.
  1491. */
  1492. function reducer_items() {
  1493. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1494. var action = arguments.length > 1 ? arguments[1] : undefined;
  1495. switch (action.type) {
  1496. case 'RECEIVE_ITEMS':
  1497. var key = action.key || DEFAULT_ENTITY_KEY;
  1498. return Object(objectSpread["a" /* default */])({}, state, action.items.reduce(function (acc, value) {
  1499. var itemId = value[key];
  1500. acc[itemId] = conservativeMapItem(state[itemId], value);
  1501. return acc;
  1502. }, {}));
  1503. }
  1504. return state;
  1505. }
  1506. /**
  1507. * Reducer tracking queries state, keyed by stable query key. Each reducer
  1508. * query object includes `itemIds` and `requestingPageByPerPage`.
  1509. *
  1510. * @param {Object} state Current state.
  1511. * @param {Object} action Dispatched action.
  1512. *
  1513. * @return {Object} Next state.
  1514. */
  1515. var queries = Object(external_lodash_["flowRight"])([// Limit to matching action type so we don't attempt to replace action on
  1516. // an unhandled action.
  1517. if_matching_action(function (action) {
  1518. return 'query' in action;
  1519. }), // Inject query parts into action for use both in `onSubKey` and reducer.
  1520. replace_action(function (action) {
  1521. // `ifMatchingAction` still passes on initialization, where state is
  1522. // undefined and a query is not assigned. Avoid attempting to parse
  1523. // parts. `onSubKey` will omit by lack of `stableKey`.
  1524. if (action.query) {
  1525. return Object(objectSpread["a" /* default */])({}, action, get_query_parts(action.query));
  1526. }
  1527. return action;
  1528. }), // Queries shape is shared, but keyed by query `stableKey` part. Original
  1529. // reducer tracks only a single query object.
  1530. on_sub_key('stableKey')])(function () {
  1531. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1532. var action = arguments.length > 1 ? arguments[1] : undefined;
  1533. var type = action.type,
  1534. page = action.page,
  1535. perPage = action.perPage,
  1536. _action$key = action.key,
  1537. key = _action$key === void 0 ? DEFAULT_ENTITY_KEY : _action$key;
  1538. if (type !== 'RECEIVE_ITEMS') {
  1539. return state;
  1540. }
  1541. return getMergedItemIds(state || [], Object(external_lodash_["map"])(action.items, key), page, perPage);
  1542. });
  1543. /* harmony default export */ var queried_data_reducer = (Object(external_this_wp_data_["combineReducers"])({
  1544. items: reducer_items,
  1545. queries: queries
  1546. }));
  1547. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/index.js
  1548. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/reducer.js
  1549. /**
  1550. * External dependencies
  1551. */
  1552. /**
  1553. * WordPress dependencies
  1554. */
  1555. /**
  1556. * Internal dependencies
  1557. */
  1558. /**
  1559. * Reducer managing terms state. Keyed by taxonomy slug, the value is either
  1560. * undefined (if no request has been made for given taxonomy), null (if a
  1561. * request is in-flight for given taxonomy), or the array of terms for the
  1562. * taxonomy.
  1563. *
  1564. * @param {Object} state Current state.
  1565. * @param {Object} action Dispatched action.
  1566. *
  1567. * @return {Object} Updated state.
  1568. */
  1569. function terms() {
  1570. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1571. var action = arguments.length > 1 ? arguments[1] : undefined;
  1572. switch (action.type) {
  1573. case 'RECEIVE_TERMS':
  1574. return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.taxonomy, action.terms));
  1575. }
  1576. return state;
  1577. }
  1578. /**
  1579. * Reducer managing authors state. Keyed by id.
  1580. *
  1581. * @param {Object} state Current state.
  1582. * @param {Object} action Dispatched action.
  1583. *
  1584. * @return {Object} Updated state.
  1585. */
  1586. function reducer_users() {
  1587. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  1588. byId: {},
  1589. queries: {}
  1590. };
  1591. var action = arguments.length > 1 ? arguments[1] : undefined;
  1592. switch (action.type) {
  1593. case 'RECEIVE_USER_QUERY':
  1594. return {
  1595. byId: Object(objectSpread["a" /* default */])({}, state.byId, Object(external_lodash_["keyBy"])(action.users, 'id')),
  1596. queries: Object(objectSpread["a" /* default */])({}, state.queries, Object(defineProperty["a" /* default */])({}, action.queryID, Object(external_lodash_["map"])(action.users, function (user) {
  1597. return user.id;
  1598. })))
  1599. };
  1600. }
  1601. return state;
  1602. }
  1603. /**
  1604. * Reducer managing current user state.
  1605. *
  1606. * @param {Object} state Current state.
  1607. * @param {Object} action Dispatched action.
  1608. *
  1609. * @return {Object} Updated state.
  1610. */
  1611. function reducer_currentUser() {
  1612. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1613. var action = arguments.length > 1 ? arguments[1] : undefined;
  1614. switch (action.type) {
  1615. case 'RECEIVE_CURRENT_USER':
  1616. return action.currentUser;
  1617. }
  1618. return state;
  1619. }
  1620. /**
  1621. * Reducer managing taxonomies.
  1622. *
  1623. * @param {Object} state Current state.
  1624. * @param {Object} action Dispatched action.
  1625. *
  1626. * @return {Object} Updated state.
  1627. */
  1628. function reducer_taxonomies() {
  1629. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  1630. var action = arguments.length > 1 ? arguments[1] : undefined;
  1631. switch (action.type) {
  1632. case 'RECEIVE_TAXONOMIES':
  1633. return action.taxonomies;
  1634. }
  1635. return state;
  1636. }
  1637. /**
  1638. * Reducer managing theme supports data.
  1639. *
  1640. * @param {Object} state Current state.
  1641. * @param {Object} action Dispatched action.
  1642. *
  1643. * @return {Object} Updated state.
  1644. */
  1645. function themeSupports() {
  1646. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1647. var action = arguments.length > 1 ? arguments[1] : undefined;
  1648. switch (action.type) {
  1649. case 'RECEIVE_THEME_SUPPORTS':
  1650. return Object(objectSpread["a" /* default */])({}, state, action.themeSupports);
  1651. }
  1652. return state;
  1653. }
  1654. /**
  1655. * Higher Order Reducer for a given entity config. It supports:
  1656. *
  1657. * - Fetching
  1658. * - Editing
  1659. * - Saving
  1660. *
  1661. * @param {Object} entityConfig Entity config.
  1662. *
  1663. * @return {Function} Reducer.
  1664. */
  1665. function reducer_entity(entityConfig) {
  1666. return Object(external_lodash_["flowRight"])([// Limit to matching action type so we don't attempt to replace action on
  1667. // an unhandled action.
  1668. if_matching_action(function (action) {
  1669. return action.name && action.kind && action.name === entityConfig.name && action.kind === entityConfig.kind;
  1670. }), // Inject the entity config into the action.
  1671. replace_action(function (action) {
  1672. return Object(objectSpread["a" /* default */])({}, action, {
  1673. key: entityConfig.key || DEFAULT_ENTITY_KEY
  1674. });
  1675. })])(Object(external_this_wp_data_["combineReducers"])({
  1676. queriedData: queried_data_reducer,
  1677. edits: function edits() {
  1678. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1679. var action = arguments.length > 1 ? arguments[1] : undefined;
  1680. switch (action.type) {
  1681. case 'RECEIVE_ITEMS':
  1682. var nextState = Object(objectSpread["a" /* default */])({}, state);
  1683. var _iteratorNormalCompletion = true;
  1684. var _didIteratorError = false;
  1685. var _iteratorError = undefined;
  1686. try {
  1687. var _loop = function _loop() {
  1688. var record = _step.value;
  1689. var recordId = record[action.key];
  1690. var edits = nextState[recordId];
  1691. if (!edits) {
  1692. return "continue";
  1693. }
  1694. var nextEdits = Object.keys(edits).reduce(function (acc, key) {
  1695. // If the edited value is still different to the persisted value,
  1696. // keep the edited value in edits.
  1697. if ( // Edits are the "raw" attribute values, but records may have
  1698. // objects with more properties, so we use `get` here for the
  1699. // comparison.
  1700. !Object(external_lodash_["isEqual"])(edits[key], Object(external_lodash_["get"])(record[key], 'raw', record[key]))) {
  1701. acc[key] = edits[key];
  1702. }
  1703. return acc;
  1704. }, {});
  1705. if (Object.keys(nextEdits).length) {
  1706. nextState[recordId] = nextEdits;
  1707. } else {
  1708. delete nextState[recordId];
  1709. }
  1710. };
  1711. for (var _iterator = action.items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  1712. var _ret = _loop();
  1713. if (_ret === "continue") continue;
  1714. }
  1715. } catch (err) {
  1716. _didIteratorError = true;
  1717. _iteratorError = err;
  1718. } finally {
  1719. try {
  1720. if (!_iteratorNormalCompletion && _iterator.return != null) {
  1721. _iterator.return();
  1722. }
  1723. } finally {
  1724. if (_didIteratorError) {
  1725. throw _iteratorError;
  1726. }
  1727. }
  1728. }
  1729. return nextState;
  1730. case 'EDIT_ENTITY_RECORD':
  1731. var nextEdits = Object(objectSpread["a" /* default */])({}, state[action.recordId], action.edits);
  1732. Object.keys(nextEdits).forEach(function (key) {
  1733. // Delete cleared edits so that the properties
  1734. // are not considered dirty.
  1735. if (nextEdits[key] === undefined) {
  1736. delete nextEdits[key];
  1737. }
  1738. });
  1739. return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.recordId, nextEdits));
  1740. }
  1741. return state;
  1742. },
  1743. saving: function saving() {
  1744. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1745. var action = arguments.length > 1 ? arguments[1] : undefined;
  1746. switch (action.type) {
  1747. case 'SAVE_ENTITY_RECORD_START':
  1748. case 'SAVE_ENTITY_RECORD_FINISH':
  1749. return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.recordId, {
  1750. pending: action.type === 'SAVE_ENTITY_RECORD_START',
  1751. error: action.error,
  1752. isAutosave: action.isAutosave
  1753. }));
  1754. }
  1755. return state;
  1756. }
  1757. }));
  1758. }
  1759. /**
  1760. * Reducer keeping track of the registered entities.
  1761. *
  1762. * @param {Object} state Current state.
  1763. * @param {Object} action Dispatched action.
  1764. *
  1765. * @return {Object} Updated state.
  1766. */
  1767. function entitiesConfig() {
  1768. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultEntities;
  1769. var action = arguments.length > 1 ? arguments[1] : undefined;
  1770. switch (action.type) {
  1771. case 'ADD_ENTITIES':
  1772. return [].concat(Object(toConsumableArray["a" /* default */])(state), Object(toConsumableArray["a" /* default */])(action.entities));
  1773. }
  1774. return state;
  1775. }
  1776. /**
  1777. * Reducer keeping track of the registered entities config and data.
  1778. *
  1779. * @param {Object} state Current state.
  1780. * @param {Object} action Dispatched action.
  1781. *
  1782. * @return {Object} Updated state.
  1783. */
  1784. var reducer_entities = function entities() {
  1785. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1786. var action = arguments.length > 1 ? arguments[1] : undefined;
  1787. var newConfig = entitiesConfig(state.config, action); // Generates a dynamic reducer for the entities
  1788. var entitiesDataReducer = state.reducer;
  1789. if (!entitiesDataReducer || newConfig !== state.config) {
  1790. var entitiesByKind = Object(external_lodash_["groupBy"])(newConfig, 'kind');
  1791. entitiesDataReducer = Object(external_this_wp_data_["combineReducers"])(Object.entries(entitiesByKind).reduce(function (memo, _ref) {
  1792. var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 2),
  1793. kind = _ref2[0],
  1794. subEntities = _ref2[1];
  1795. var kindReducer = Object(external_this_wp_data_["combineReducers"])(subEntities.reduce(function (kindMemo, entityConfig) {
  1796. return Object(objectSpread["a" /* default */])({}, kindMemo, Object(defineProperty["a" /* default */])({}, entityConfig.name, reducer_entity(entityConfig)));
  1797. }, {}));
  1798. memo[kind] = kindReducer;
  1799. return memo;
  1800. }, {}));
  1801. }
  1802. var newData = entitiesDataReducer(state.data, action);
  1803. if (newData === state.data && newConfig === state.config && entitiesDataReducer === state.reducer) {
  1804. return state;
  1805. }
  1806. return {
  1807. reducer: entitiesDataReducer,
  1808. data: newData,
  1809. config: newConfig
  1810. };
  1811. };
  1812. /**
  1813. * Reducer keeping track of entity edit undo history.
  1814. *
  1815. * @param {Object} state Current state.
  1816. * @param {Object} action Dispatched action.
  1817. *
  1818. * @return {Object} Updated state.
  1819. */
  1820. var UNDO_INITIAL_STATE = [];
  1821. UNDO_INITIAL_STATE.offset = 0;
  1822. var lastEditAction;
  1823. function reducer_undo() {
  1824. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UNDO_INITIAL_STATE;
  1825. var action = arguments.length > 1 ? arguments[1] : undefined;
  1826. switch (action.type) {
  1827. case 'EDIT_ENTITY_RECORD':
  1828. case 'CREATE_UNDO_LEVEL':
  1829. var isCreateUndoLevel = action.type === 'CREATE_UNDO_LEVEL';
  1830. var isUndoOrRedo = !isCreateUndoLevel && (action.meta.isUndo || action.meta.isRedo);
  1831. if (isCreateUndoLevel) {
  1832. action = lastEditAction;
  1833. } else if (!isUndoOrRedo) {
  1834. lastEditAction = action;
  1835. }
  1836. var nextState;
  1837. if (isUndoOrRedo) {
  1838. nextState = Object(toConsumableArray["a" /* default */])(state);
  1839. nextState.offset = state.offset + (action.meta.isUndo ? -1 : 1);
  1840. if (state.flattenedUndo) {
  1841. // The first undo in a sequence of undos might happen while we have
  1842. // flattened undos in state. If this is the case, we want execution
  1843. // to continue as if we were creating an explicit undo level. This
  1844. // will result in an extra undo level being appended with the flattened
  1845. // undo values.
  1846. isCreateUndoLevel = true;
  1847. action = lastEditAction;
  1848. } else {
  1849. return nextState;
  1850. }
  1851. }
  1852. if (!action.meta.undo) {
  1853. return state;
  1854. } // Transient edits don't create an undo level, but are
  1855. // reachable in the next meaningful edit to which they
  1856. // are merged. They are defined in the entity's config.
  1857. if (!isCreateUndoLevel && !Object.keys(action.edits).some(function (key) {
  1858. return !action.transientEdits[key];
  1859. })) {
  1860. nextState = Object(toConsumableArray["a" /* default */])(state);
  1861. nextState.flattenedUndo = Object(objectSpread["a" /* default */])({}, state.flattenedUndo, action.edits);
  1862. nextState.offset = state.offset;
  1863. return nextState;
  1864. } // Clear potential redos, because this only supports linear history.
  1865. nextState = nextState || state.slice(0, state.offset || undefined);
  1866. nextState.offset = nextState.offset || 0;
  1867. nextState.pop();
  1868. if (!isCreateUndoLevel) {
  1869. nextState.push({
  1870. kind: action.meta.undo.kind,
  1871. name: action.meta.undo.name,
  1872. recordId: action.meta.undo.recordId,
  1873. edits: Object(objectSpread["a" /* default */])({}, state.flattenedUndo, action.meta.undo.edits)
  1874. });
  1875. } // When an edit is a function it's an optimization to avoid running some expensive operation.
  1876. // We can't rely on the function references being the same so we opt out of comparing them here.
  1877. var comparisonUndoEdits = Object.values(action.meta.undo.edits).filter(function (edit) {
  1878. return typeof edit !== 'function';
  1879. });
  1880. var comparisonEdits = Object.values(action.edits).filter(function (edit) {
  1881. return typeof edit !== 'function';
  1882. });
  1883. if (!external_this_wp_isShallowEqual_default()(comparisonUndoEdits, comparisonEdits)) {
  1884. nextState.push({
  1885. kind: action.kind,
  1886. name: action.name,
  1887. recordId: action.recordId,
  1888. edits: isCreateUndoLevel ? Object(objectSpread["a" /* default */])({}, state.flattenedUndo, action.edits) : action.edits
  1889. });
  1890. }
  1891. return nextState;
  1892. }
  1893. return state;
  1894. }
  1895. /**
  1896. * Reducer managing embed preview data.
  1897. *
  1898. * @param {Object} state Current state.
  1899. * @param {Object} action Dispatched action.
  1900. *
  1901. * @return {Object} Updated state.
  1902. */
  1903. function embedPreviews() {
  1904. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1905. var action = arguments.length > 1 ? arguments[1] : undefined;
  1906. switch (action.type) {
  1907. case 'RECEIVE_EMBED_PREVIEW':
  1908. var url = action.url,
  1909. preview = action.preview;
  1910. return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, url, preview));
  1911. }
  1912. return state;
  1913. }
  1914. /**
  1915. * State which tracks whether the user can perform an action on a REST
  1916. * resource.
  1917. *
  1918. * @param {Object} state Current state.
  1919. * @param {Object} action Dispatched action.
  1920. *
  1921. * @return {Object} Updated state.
  1922. */
  1923. function userPermissions() {
  1924. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1925. var action = arguments.length > 1 ? arguments[1] : undefined;
  1926. switch (action.type) {
  1927. case 'RECEIVE_USER_PERMISSION':
  1928. return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.key, action.isAllowed));
  1929. }
  1930. return state;
  1931. }
  1932. /**
  1933. * Reducer returning autosaves keyed by their parent's post id.
  1934. *
  1935. * @param {Object} state Current state.
  1936. * @param {Object} action Dispatched action.
  1937. *
  1938. * @return {Object} Updated state.
  1939. */
  1940. function reducer_autosaves() {
  1941. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1942. var action = arguments.length > 1 ? arguments[1] : undefined;
  1943. switch (action.type) {
  1944. case 'RECEIVE_AUTOSAVES':
  1945. var postId = action.postId,
  1946. autosavesData = action.autosaves;
  1947. return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, postId, autosavesData));
  1948. }
  1949. return state;
  1950. }
  1951. /* harmony default export */ var build_module_reducer = (Object(external_this_wp_data_["combineReducers"])({
  1952. terms: terms,
  1953. users: reducer_users,
  1954. currentUser: reducer_currentUser,
  1955. taxonomies: reducer_taxonomies,
  1956. themeSupports: themeSupports,
  1957. entities: reducer_entities,
  1958. undo: reducer_undo,
  1959. embedPreviews: embedPreviews,
  1960. userPermissions: userPermissions,
  1961. autosaves: reducer_autosaves
  1962. }));
  1963. // EXTERNAL MODULE: external {"this":["wp","deprecated"]}
  1964. var external_this_wp_deprecated_ = __webpack_require__(37);
  1965. var external_this_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_deprecated_);
  1966. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/name.js
  1967. /**
  1968. * The reducer key used by core data in store registration.
  1969. * This is defined in a separate file to avoid cycle-dependency
  1970. *
  1971. * @type {string}
  1972. */
  1973. var REDUCER_KEY = 'core';
  1974. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/selectors.js
  1975. /**
  1976. * External dependencies
  1977. */
  1978. /**
  1979. * WordPress dependencies
  1980. */
  1981. /**
  1982. * Internal dependencies
  1983. */
  1984. /**
  1985. * Returns true if a request is in progress for embed preview data, or false
  1986. * otherwise.
  1987. *
  1988. * @param {Object} state Data state.
  1989. * @param {string} url URL the preview would be for.
  1990. *
  1991. * @return {boolean} Whether a request is in progress for an embed preview.
  1992. */
  1993. var isRequestingEmbedPreview = Object(external_this_wp_data_["createRegistrySelector"])(function (select) {
  1994. return function (state, url) {
  1995. return select('core/data').isResolving(REDUCER_KEY, 'getEmbedPreview', [url]);
  1996. };
  1997. });
  1998. /**
  1999. * Returns all available authors.
  2000. *
  2001. * @param {Object} state Data state.
  2002. *
  2003. * @return {Array} Authors list.
  2004. */
  2005. function getAuthors(state) {
  2006. return getUserQueryResults(state, 'authors');
  2007. }
  2008. /**
  2009. * Returns the current user.
  2010. *
  2011. * @param {Object} state Data state.
  2012. *
  2013. * @return {Object} Current user object.
  2014. */
  2015. function getCurrentUser(state) {
  2016. return state.currentUser;
  2017. }
  2018. /**
  2019. * Returns all the users returned by a query ID.
  2020. *
  2021. * @param {Object} state Data state.
  2022. * @param {string} queryID Query ID.
  2023. *
  2024. * @return {Array} Users list.
  2025. */
  2026. var getUserQueryResults = Object(rememo["a" /* default */])(function (state, queryID) {
  2027. var queryResults = state.users.queries[queryID];
  2028. return Object(external_lodash_["map"])(queryResults, function (id) {
  2029. return state.users.byId[id];
  2030. });
  2031. }, function (state, queryID) {
  2032. return [state.users.queries[queryID], state.users.byId];
  2033. });
  2034. /**
  2035. * Returns whether the entities for the give kind are loaded.
  2036. *
  2037. * @param {Object} state Data state.
  2038. * @param {string} kind Entity kind.
  2039. *
  2040. * @return {boolean} Whether the entities are loaded
  2041. */
  2042. function getEntitiesByKind(state, kind) {
  2043. return Object(external_lodash_["filter"])(state.entities.config, {
  2044. kind: kind
  2045. });
  2046. }
  2047. /**
  2048. * Returns the entity object given its kind and name.
  2049. *
  2050. * @param {Object} state Data state.
  2051. * @param {string} kind Entity kind.
  2052. * @param {string} name Entity name.
  2053. *
  2054. * @return {Object} Entity
  2055. */
  2056. function getEntity(state, kind, name) {
  2057. return Object(external_lodash_["find"])(state.entities.config, {
  2058. kind: kind,
  2059. name: name
  2060. });
  2061. }
  2062. /**
  2063. * Returns the Entity's record object by key.
  2064. *
  2065. * @param {Object} state State tree
  2066. * @param {string} kind Entity kind.
  2067. * @param {string} name Entity name.
  2068. * @param {number} key Record's key
  2069. *
  2070. * @return {Object?} Record.
  2071. */
  2072. function getEntityRecord(state, kind, name, key) {
  2073. return Object(external_lodash_["get"])(state.entities.data, [kind, name, 'queriedData', 'items', key]);
  2074. }
  2075. /**
  2076. * Returns the entity's record object by key,
  2077. * with its attributes mapped to their raw values.
  2078. *
  2079. * @param {Object} state State tree.
  2080. * @param {string} kind Entity kind.
  2081. * @param {string} name Entity name.
  2082. * @param {number} key Record's key.
  2083. *
  2084. * @return {Object?} Object with the entity's raw attributes.
  2085. */
  2086. var getRawEntityRecord = Object(rememo["a" /* default */])(function (state, kind, name, key) {
  2087. var record = getEntityRecord(state, kind, name, key);
  2088. return record && Object.keys(record).reduce(function (acc, _key) {
  2089. // Because edits are the "raw" attribute values,
  2090. // we return those from record selectors to make rendering,
  2091. // comparisons, and joins with edits easier.
  2092. acc[_key] = Object(external_lodash_["get"])(record[_key], 'raw', record[_key]);
  2093. return acc;
  2094. }, {});
  2095. }, function (state) {
  2096. return [state.entities.data];
  2097. });
  2098. /**
  2099. * Returns the Entity's records.
  2100. *
  2101. * @param {Object} state State tree
  2102. * @param {string} kind Entity kind.
  2103. * @param {string} name Entity name.
  2104. * @param {?Object} query Optional terms query.
  2105. *
  2106. * @return {Array} Records.
  2107. */
  2108. function getEntityRecords(state, kind, name, query) {
  2109. var queriedState = Object(external_lodash_["get"])(state.entities.data, [kind, name, 'queriedData']);
  2110. if (!queriedState) {
  2111. return [];
  2112. }
  2113. return getQueriedItems(queriedState, query);
  2114. }
  2115. /**
  2116. * Returns the specified entity record's edits.
  2117. *
  2118. * @param {Object} state State tree.
  2119. * @param {string} kind Entity kind.
  2120. * @param {string} name Entity name.
  2121. * @param {number} recordId Record ID.
  2122. *
  2123. * @return {Object?} The entity record's edits.
  2124. */
  2125. function getEntityRecordEdits(state, kind, name, recordId) {
  2126. return Object(external_lodash_["get"])(state.entities.data, [kind, name, 'edits', recordId]);
  2127. }
  2128. /**
  2129. * Returns the specified entity record's non transient edits.
  2130. *
  2131. * Transient edits don't create an undo level, and
  2132. * are not considered for change detection.
  2133. * They are defined in the entity's config.
  2134. *
  2135. * @param {Object} state State tree.
  2136. * @param {string} kind Entity kind.
  2137. * @param {string} name Entity name.
  2138. * @param {number} recordId Record ID.
  2139. *
  2140. * @return {Object?} The entity record's non transient edits.
  2141. */
  2142. var getEntityRecordNonTransientEdits = Object(rememo["a" /* default */])(function (state, kind, name, recordId) {
  2143. var _getEntity = getEntity(state, kind, name),
  2144. _getEntity$transientE = _getEntity.transientEdits,
  2145. transientEdits = _getEntity$transientE === void 0 ? {} : _getEntity$transientE;
  2146. var edits = getEntityRecordEdits(state, kind, name, recordId) || [];
  2147. return Object.keys(edits).reduce(function (acc, key) {
  2148. if (!transientEdits[key]) {
  2149. acc[key] = edits[key];
  2150. }
  2151. return acc;
  2152. }, {});
  2153. }, function (state) {
  2154. return [state.entities.config, state.entities.data];
  2155. });
  2156. /**
  2157. * Returns true if the specified entity record has edits,
  2158. * and false otherwise.
  2159. *
  2160. * @param {Object} state State tree.
  2161. * @param {string} kind Entity kind.
  2162. * @param {string} name Entity name.
  2163. * @param {number} recordId Record ID.
  2164. *
  2165. * @return {boolean} Whether the entity record has edits or not.
  2166. */
  2167. function hasEditsForEntityRecord(state, kind, name, recordId) {
  2168. return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(getEntityRecordNonTransientEdits(state, kind, name, recordId)).length > 0;
  2169. }
  2170. /**
  2171. * Returns the specified entity record, merged with its edits.
  2172. *
  2173. * @param {Object} state State tree.
  2174. * @param {string} kind Entity kind.
  2175. * @param {string} name Entity name.
  2176. * @param {number} recordId Record ID.
  2177. *
  2178. * @return {Object?} The entity record, merged with its edits.
  2179. */
  2180. var getEditedEntityRecord = Object(rememo["a" /* default */])(function (state, kind, name, recordId) {
  2181. return Object(objectSpread["a" /* default */])({}, getRawEntityRecord(state, kind, name, recordId), getEntityRecordEdits(state, kind, name, recordId));
  2182. }, function (state) {
  2183. return [state.entities.data];
  2184. });
  2185. /**
  2186. * Returns true if the specified entity record is autosaving, and false otherwise.
  2187. *
  2188. * @param {Object} state State tree.
  2189. * @param {string} kind Entity kind.
  2190. * @param {string} name Entity name.
  2191. * @param {number} recordId Record ID.
  2192. *
  2193. * @return {boolean} Whether the entity record is autosaving or not.
  2194. */
  2195. function isAutosavingEntityRecord(state, kind, name, recordId) {
  2196. var _get = Object(external_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId], {}),
  2197. pending = _get.pending,
  2198. isAutosave = _get.isAutosave;
  2199. return Boolean(pending && isAutosave);
  2200. }
  2201. /**
  2202. * Returns true if the specified entity record is saving, and false otherwise.
  2203. *
  2204. * @param {Object} state State tree.
  2205. * @param {string} kind Entity kind.
  2206. * @param {string} name Entity name.
  2207. * @param {number} recordId Record ID.
  2208. *
  2209. * @return {boolean} Whether the entity record is saving or not.
  2210. */
  2211. function isSavingEntityRecord(state, kind, name, recordId) {
  2212. return Object(external_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId, 'pending'], false);
  2213. }
  2214. /**
  2215. * Returns the specified entity record's last save error.
  2216. *
  2217. * @param {Object} state State tree.
  2218. * @param {string} kind Entity kind.
  2219. * @param {string} name Entity name.
  2220. * @param {number} recordId Record ID.
  2221. *
  2222. * @return {Object?} The entity record's save error.
  2223. */
  2224. function getLastEntitySaveError(state, kind, name, recordId) {
  2225. return Object(external_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId, 'error']);
  2226. }
  2227. /**
  2228. * Returns the current undo offset for the
  2229. * entity records edits history. The offset
  2230. * represents how many items from the end
  2231. * of the history stack we are at. 0 is the
  2232. * last edit, -1 is the second last, and so on.
  2233. *
  2234. * @param {Object} state State tree.
  2235. *
  2236. * @return {number} The current undo offset.
  2237. */
  2238. function getCurrentUndoOffset(state) {
  2239. return state.undo.offset;
  2240. }
  2241. /**
  2242. * Returns the previous edit from the current undo offset
  2243. * for the entity records edits history, if any.
  2244. *
  2245. * @param {Object} state State tree.
  2246. *
  2247. * @return {Object?} The edit.
  2248. */
  2249. function getUndoEdit(state) {
  2250. return state.undo[state.undo.length - 2 + getCurrentUndoOffset(state)];
  2251. }
  2252. /**
  2253. * Returns the next edit from the current undo offset
  2254. * for the entity records edits history, if any.
  2255. *
  2256. * @param {Object} state State tree.
  2257. *
  2258. * @return {Object?} The edit.
  2259. */
  2260. function getRedoEdit(state) {
  2261. return state.undo[state.undo.length + getCurrentUndoOffset(state)];
  2262. }
  2263. /**
  2264. * Returns true if there is a previous edit from the current undo offset
  2265. * for the entity records edits history, and false otherwise.
  2266. *
  2267. * @param {Object} state State tree.
  2268. *
  2269. * @return {boolean} Whether there is a previous edit or not.
  2270. */
  2271. function hasUndo(state) {
  2272. return Boolean(getUndoEdit(state));
  2273. }
  2274. /**
  2275. * Returns true if there is a next edit from the current undo offset
  2276. * for the entity records edits history, and false otherwise.
  2277. *
  2278. * @param {Object} state State tree.
  2279. *
  2280. * @return {boolean} Whether there is a next edit or not.
  2281. */
  2282. function hasRedo(state) {
  2283. return Boolean(getRedoEdit(state));
  2284. }
  2285. /**
  2286. * Return theme supports data in the index.
  2287. *
  2288. * @param {Object} state Data state.
  2289. *
  2290. * @return {*} Index data.
  2291. */
  2292. function getThemeSupports(state) {
  2293. return state.themeSupports;
  2294. }
  2295. /**
  2296. * Returns the embed preview for the given URL.
  2297. *
  2298. * @param {Object} state Data state.
  2299. * @param {string} url Embedded URL.
  2300. *
  2301. * @return {*} Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
  2302. */
  2303. function getEmbedPreview(state, url) {
  2304. return state.embedPreviews[url];
  2305. }
  2306. /**
  2307. * Determines if the returned preview is an oEmbed link fallback.
  2308. *
  2309. * WordPress can be configured to return a simple link to a URL if it is not embeddable.
  2310. * We need to be able to determine if a URL is embeddable or not, based on what we
  2311. * get back from the oEmbed preview API.
  2312. *
  2313. * @param {Object} state Data state.
  2314. * @param {string} url Embedded URL.
  2315. *
  2316. * @return {boolean} Is the preview for the URL an oEmbed link fallback.
  2317. */
  2318. function isPreviewEmbedFallback(state, url) {
  2319. var preview = state.embedPreviews[url];
  2320. var oEmbedLinkCheck = '<a href="' + url + '">' + url + '</a>';
  2321. if (!preview) {
  2322. return false;
  2323. }
  2324. return preview.html === oEmbedLinkCheck;
  2325. }
  2326. /**
  2327. * Returns whether the current user can upload media.
  2328. *
  2329. * Calling this may trigger an OPTIONS request to the REST API via the
  2330. * `canUser()` resolver.
  2331. *
  2332. * https://developer.wordpress.org/rest-api/reference/
  2333. *
  2334. * @deprecated since 5.0. Callers should use the more generic `canUser()` selector instead of
  2335. * `hasUploadPermissions()`, e.g. `canUser( 'create', 'media' )`.
  2336. *
  2337. * @param {Object} state Data state.
  2338. *
  2339. * @return {boolean} Whether or not the user can upload media. Defaults to `true` if the OPTIONS
  2340. * request is being made.
  2341. */
  2342. function hasUploadPermissions(state) {
  2343. external_this_wp_deprecated_default()("select( 'core' ).hasUploadPermissions()", {
  2344. alternative: "select( 'core' ).canUser( 'create', 'media' )"
  2345. });
  2346. return Object(external_lodash_["defaultTo"])(canUser(state, 'create', 'media'), true);
  2347. }
  2348. /**
  2349. * Returns whether the current user can perform the given action on the given
  2350. * REST resource.
  2351. *
  2352. * Calling this may trigger an OPTIONS request to the REST API via the
  2353. * `canUser()` resolver.
  2354. *
  2355. * https://developer.wordpress.org/rest-api/reference/
  2356. *
  2357. * @param {Object} state Data state.
  2358. * @param {string} action Action to check. One of: 'create', 'read', 'update', 'delete'.
  2359. * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.
  2360. * @param {string=} id Optional ID of the rest resource to check.
  2361. *
  2362. * @return {boolean|undefined} Whether or not the user can perform the action,
  2363. * or `undefined` if the OPTIONS request is still being made.
  2364. */
  2365. function canUser(state, action, resource, id) {
  2366. var key = Object(external_lodash_["compact"])([action, resource, id]).join('/');
  2367. return Object(external_lodash_["get"])(state, ['userPermissions', key]);
  2368. }
  2369. /**
  2370. * Returns the latest autosaves for the post.
  2371. *
  2372. * May return multiple autosaves since the backend stores one autosave per
  2373. * author for each post.
  2374. *
  2375. * @param {Object} state State tree.
  2376. * @param {string} postType The type of the parent post.
  2377. * @param {number} postId The id of the parent post.
  2378. *
  2379. * @return {?Array} An array of autosaves for the post, or undefined if there is none.
  2380. */
  2381. function getAutosaves(state, postType, postId) {
  2382. return state.autosaves[postId];
  2383. }
  2384. /**
  2385. * Returns the autosave for the post and author.
  2386. *
  2387. * @param {Object} state State tree.
  2388. * @param {string} postType The type of the parent post.
  2389. * @param {number} postId The id of the parent post.
  2390. * @param {number} authorId The id of the author.
  2391. *
  2392. * @return {?Object} The autosave for the post and author.
  2393. */
  2394. function getAutosave(state, postType, postId, authorId) {
  2395. if (authorId === undefined) {
  2396. return;
  2397. }
  2398. var autosaves = state.autosaves[postId];
  2399. return Object(external_lodash_["find"])(autosaves, {
  2400. author: authorId
  2401. });
  2402. }
  2403. /**
  2404. * Returns true if the REST request for autosaves has completed.
  2405. *
  2406. * @param {Object} state State tree.
  2407. * @param {string} postType The type of the parent post.
  2408. * @param {number} postId The id of the parent post.
  2409. *
  2410. * @return {boolean} True if the REST request was completed. False otherwise.
  2411. */
  2412. var hasFetchedAutosaves = Object(external_this_wp_data_["createRegistrySelector"])(function (select) {
  2413. return function (state, postType, postId) {
  2414. return select(REDUCER_KEY).hasFinishedResolution('getAutosaves', [postType, postId]);
  2415. };
  2416. });
  2417. /**
  2418. * Returns a new reference when edited values have changed. This is useful in
  2419. * inferring where an edit has been made between states by comparison of the
  2420. * return values using strict equality.
  2421. *
  2422. * @example
  2423. *
  2424. * ```
  2425. * const hasEditOccurred = (
  2426. * getReferenceByDistinctEdits( beforeState ) !==
  2427. * getReferenceByDistinctEdits( afterState )
  2428. * );
  2429. * ```
  2430. *
  2431. * @param {Object} state Editor state.
  2432. *
  2433. * @return {*} A value whose reference will change only when an edit occurs.
  2434. */
  2435. var getReferenceByDistinctEdits = Object(rememo["a" /* default */])(function () {
  2436. return [];
  2437. }, function (state) {
  2438. return [state.undo.length, state.undo.offset];
  2439. });
  2440. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/resolvers.js
  2441. var resolvers_marked =
  2442. /*#__PURE__*/
  2443. regenerator_default.a.mark(resolvers_getAuthors),
  2444. resolvers_marked2 =
  2445. /*#__PURE__*/
  2446. regenerator_default.a.mark(resolvers_getCurrentUser),
  2447. resolvers_marked3 =
  2448. /*#__PURE__*/
  2449. regenerator_default.a.mark(resolvers_getEntityRecord),
  2450. resolvers_marked4 =
  2451. /*#__PURE__*/
  2452. regenerator_default.a.mark(resolvers_getEntityRecords),
  2453. resolvers_marked5 =
  2454. /*#__PURE__*/
  2455. regenerator_default.a.mark(resolvers_getThemeSupports),
  2456. _marked6 =
  2457. /*#__PURE__*/
  2458. regenerator_default.a.mark(resolvers_getEmbedPreview),
  2459. _marked7 =
  2460. /*#__PURE__*/
  2461. regenerator_default.a.mark(resolvers_hasUploadPermissions),
  2462. _marked8 =
  2463. /*#__PURE__*/
  2464. regenerator_default.a.mark(resolvers_canUser),
  2465. _marked9 =
  2466. /*#__PURE__*/
  2467. regenerator_default.a.mark(resolvers_getAutosaves),
  2468. _marked10 =
  2469. /*#__PURE__*/
  2470. regenerator_default.a.mark(resolvers_getAutosave);
  2471. /**
  2472. * External dependencies
  2473. */
  2474. /**
  2475. * WordPress dependencies
  2476. */
  2477. /**
  2478. * Internal dependencies
  2479. */
  2480. /**
  2481. * Requests authors from the REST API.
  2482. */
  2483. function resolvers_getAuthors() {
  2484. var users;
  2485. return regenerator_default.a.wrap(function getAuthors$(_context) {
  2486. while (1) {
  2487. switch (_context.prev = _context.next) {
  2488. case 0:
  2489. _context.next = 2;
  2490. return apiFetch({
  2491. path: '/wp/v2/users/?who=authors&per_page=-1'
  2492. });
  2493. case 2:
  2494. users = _context.sent;
  2495. _context.next = 5;
  2496. return receiveUserQuery('authors', users);
  2497. case 5:
  2498. case "end":
  2499. return _context.stop();
  2500. }
  2501. }
  2502. }, resolvers_marked);
  2503. }
  2504. /**
  2505. * Requests the current user from the REST API.
  2506. */
  2507. function resolvers_getCurrentUser() {
  2508. var currentUser;
  2509. return regenerator_default.a.wrap(function getCurrentUser$(_context2) {
  2510. while (1) {
  2511. switch (_context2.prev = _context2.next) {
  2512. case 0:
  2513. _context2.next = 2;
  2514. return apiFetch({
  2515. path: '/wp/v2/users/me'
  2516. });
  2517. case 2:
  2518. currentUser = _context2.sent;
  2519. _context2.next = 5;
  2520. return receiveCurrentUser(currentUser);
  2521. case 5:
  2522. case "end":
  2523. return _context2.stop();
  2524. }
  2525. }
  2526. }, resolvers_marked2);
  2527. }
  2528. /**
  2529. * Requests an entity's record from the REST API.
  2530. *
  2531. * @param {string} kind Entity kind.
  2532. * @param {string} name Entity name.
  2533. * @param {number} key Record's key
  2534. */
  2535. function resolvers_getEntityRecord(kind, name, key) {
  2536. var entities, entity, record;
  2537. return regenerator_default.a.wrap(function getEntityRecord$(_context3) {
  2538. while (1) {
  2539. switch (_context3.prev = _context3.next) {
  2540. case 0:
  2541. _context3.next = 2;
  2542. return getKindEntities(kind);
  2543. case 2:
  2544. entities = _context3.sent;
  2545. entity = Object(external_lodash_["find"])(entities, {
  2546. kind: kind,
  2547. name: name
  2548. });
  2549. if (entity) {
  2550. _context3.next = 6;
  2551. break;
  2552. }
  2553. return _context3.abrupt("return");
  2554. case 6:
  2555. _context3.next = 8;
  2556. return apiFetch({
  2557. path: "".concat(entity.baseURL, "/").concat(key, "?context=edit")
  2558. });
  2559. case 8:
  2560. record = _context3.sent;
  2561. _context3.next = 11;
  2562. return receiveEntityRecords(kind, name, record);
  2563. case 11:
  2564. case "end":
  2565. return _context3.stop();
  2566. }
  2567. }
  2568. }, resolvers_marked3);
  2569. }
  2570. /**
  2571. * Requests the entity's records from the REST API.
  2572. *
  2573. * @param {string} kind Entity kind.
  2574. * @param {string} name Entity name.
  2575. * @param {Object?} query Query Object.
  2576. */
  2577. function resolvers_getEntityRecords(kind, name) {
  2578. var query,
  2579. entities,
  2580. entity,
  2581. path,
  2582. records,
  2583. _args4 = arguments;
  2584. return regenerator_default.a.wrap(function getEntityRecords$(_context4) {
  2585. while (1) {
  2586. switch (_context4.prev = _context4.next) {
  2587. case 0:
  2588. query = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
  2589. _context4.next = 3;
  2590. return getKindEntities(kind);
  2591. case 3:
  2592. entities = _context4.sent;
  2593. entity = Object(external_lodash_["find"])(entities, {
  2594. kind: kind,
  2595. name: name
  2596. });
  2597. if (entity) {
  2598. _context4.next = 7;
  2599. break;
  2600. }
  2601. return _context4.abrupt("return");
  2602. case 7:
  2603. path = Object(external_this_wp_url_["addQueryArgs"])(entity.baseURL, Object(objectSpread["a" /* default */])({}, query, {
  2604. context: 'edit'
  2605. }));
  2606. _context4.next = 10;
  2607. return apiFetch({
  2608. path: path
  2609. });
  2610. case 10:
  2611. records = _context4.sent;
  2612. _context4.next = 13;
  2613. return receiveEntityRecords(kind, name, Object.values(records), query);
  2614. case 13:
  2615. case "end":
  2616. return _context4.stop();
  2617. }
  2618. }
  2619. }, resolvers_marked4);
  2620. }
  2621. resolvers_getEntityRecords.shouldInvalidate = function (action, kind, name) {
  2622. return action.type === 'RECEIVE_ITEMS' && action.invalidateCache && kind === action.kind && name === action.name;
  2623. };
  2624. /**
  2625. * Requests theme supports data from the index.
  2626. */
  2627. function resolvers_getThemeSupports() {
  2628. var activeThemes;
  2629. return regenerator_default.a.wrap(function getThemeSupports$(_context5) {
  2630. while (1) {
  2631. switch (_context5.prev = _context5.next) {
  2632. case 0:
  2633. _context5.next = 2;
  2634. return apiFetch({
  2635. path: '/wp/v2/themes?status=active'
  2636. });
  2637. case 2:
  2638. activeThemes = _context5.sent;
  2639. _context5.next = 5;
  2640. return receiveThemeSupports(activeThemes[0].theme_supports);
  2641. case 5:
  2642. case "end":
  2643. return _context5.stop();
  2644. }
  2645. }
  2646. }, resolvers_marked5);
  2647. }
  2648. /**
  2649. * Requests a preview from the from the Embed API.
  2650. *
  2651. * @param {string} url URL to get the preview for.
  2652. */
  2653. function resolvers_getEmbedPreview(url) {
  2654. var embedProxyResponse;
  2655. return regenerator_default.a.wrap(function getEmbedPreview$(_context6) {
  2656. while (1) {
  2657. switch (_context6.prev = _context6.next) {
  2658. case 0:
  2659. _context6.prev = 0;
  2660. _context6.next = 3;
  2661. return apiFetch({
  2662. path: Object(external_this_wp_url_["addQueryArgs"])('/oembed/1.0/proxy', {
  2663. url: url
  2664. })
  2665. });
  2666. case 3:
  2667. embedProxyResponse = _context6.sent;
  2668. _context6.next = 6;
  2669. return receiveEmbedPreview(url, embedProxyResponse);
  2670. case 6:
  2671. _context6.next = 12;
  2672. break;
  2673. case 8:
  2674. _context6.prev = 8;
  2675. _context6.t0 = _context6["catch"](0);
  2676. _context6.next = 12;
  2677. return receiveEmbedPreview(url, false);
  2678. case 12:
  2679. case "end":
  2680. return _context6.stop();
  2681. }
  2682. }
  2683. }, _marked6, null, [[0, 8]]);
  2684. }
  2685. /**
  2686. * Requests Upload Permissions from the REST API.
  2687. *
  2688. * @deprecated since 5.0. Callers should use the more generic `canUser()` selector instead of
  2689. * `hasUploadPermissions()`, e.g. `canUser( 'create', 'media' )`.
  2690. */
  2691. function resolvers_hasUploadPermissions() {
  2692. return regenerator_default.a.wrap(function hasUploadPermissions$(_context7) {
  2693. while (1) {
  2694. switch (_context7.prev = _context7.next) {
  2695. case 0:
  2696. external_this_wp_deprecated_default()("select( 'core' ).hasUploadPermissions()", {
  2697. alternative: "select( 'core' ).canUser( 'create', 'media' )"
  2698. });
  2699. return _context7.delegateYield(resolvers_canUser('create', 'media'), "t0", 2);
  2700. case 2:
  2701. case "end":
  2702. return _context7.stop();
  2703. }
  2704. }
  2705. }, _marked7);
  2706. }
  2707. /**
  2708. * Checks whether the current user can perform the given action on the given
  2709. * REST resource.
  2710. *
  2711. * @param {string} action Action to check. One of: 'create', 'read', 'update',
  2712. * 'delete'.
  2713. * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.
  2714. * @param {?string} id ID of the rest resource to check.
  2715. */
  2716. function resolvers_canUser(action, resource, id) {
  2717. var methods, method, path, response, allowHeader, key, isAllowed;
  2718. return regenerator_default.a.wrap(function canUser$(_context8) {
  2719. while (1) {
  2720. switch (_context8.prev = _context8.next) {
  2721. case 0:
  2722. methods = {
  2723. create: 'POST',
  2724. read: 'GET',
  2725. update: 'PUT',
  2726. delete: 'DELETE'
  2727. };
  2728. method = methods[action];
  2729. if (method) {
  2730. _context8.next = 4;
  2731. break;
  2732. }
  2733. throw new Error("'".concat(action, "' is not a valid action."));
  2734. case 4:
  2735. path = id ? "/wp/v2/".concat(resource, "/").concat(id) : "/wp/v2/".concat(resource);
  2736. _context8.prev = 5;
  2737. _context8.next = 8;
  2738. return apiFetch({
  2739. path: path,
  2740. // Ideally this would always be an OPTIONS request, but unfortunately there's
  2741. // a bug in the REST API which causes the Allow header to not be sent on
  2742. // OPTIONS requests to /posts/:id routes.
  2743. // https://core.trac.wordpress.org/ticket/45753
  2744. method: id ? 'GET' : 'OPTIONS',
  2745. parse: false
  2746. });
  2747. case 8:
  2748. response = _context8.sent;
  2749. _context8.next = 14;
  2750. break;
  2751. case 11:
  2752. _context8.prev = 11;
  2753. _context8.t0 = _context8["catch"](5);
  2754. return _context8.abrupt("return");
  2755. case 14:
  2756. if (Object(external_lodash_["hasIn"])(response, ['headers', 'get'])) {
  2757. // If the request is fetched using the fetch api, the header can be
  2758. // retrieved using the 'get' method.
  2759. allowHeader = response.headers.get('allow');
  2760. } else {
  2761. // If the request was preloaded server-side and is returned by the
  2762. // preloading middleware, the header will be a simple property.
  2763. allowHeader = Object(external_lodash_["get"])(response, ['headers', 'Allow'], '');
  2764. }
  2765. key = Object(external_lodash_["compact"])([action, resource, id]).join('/');
  2766. isAllowed = Object(external_lodash_["includes"])(allowHeader, method);
  2767. _context8.next = 19;
  2768. return receiveUserPermission(key, isAllowed);
  2769. case 19:
  2770. case "end":
  2771. return _context8.stop();
  2772. }
  2773. }
  2774. }, _marked8, null, [[5, 11]]);
  2775. }
  2776. /**
  2777. * Request autosave data from the REST API.
  2778. *
  2779. * @param {string} postType The type of the parent post.
  2780. * @param {number} postId The id of the parent post.
  2781. */
  2782. function resolvers_getAutosaves(postType, postId) {
  2783. var _ref, restBase, autosaves;
  2784. return regenerator_default.a.wrap(function getAutosaves$(_context9) {
  2785. while (1) {
  2786. switch (_context9.prev = _context9.next) {
  2787. case 0:
  2788. _context9.next = 2;
  2789. return resolveSelect('getPostType', postType);
  2790. case 2:
  2791. _ref = _context9.sent;
  2792. restBase = _ref.rest_base;
  2793. _context9.next = 6;
  2794. return apiFetch({
  2795. path: "/wp/v2/".concat(restBase, "/").concat(postId, "/autosaves?context=edit")
  2796. });
  2797. case 6:
  2798. autosaves = _context9.sent;
  2799. if (!(autosaves && autosaves.length)) {
  2800. _context9.next = 10;
  2801. break;
  2802. }
  2803. _context9.next = 10;
  2804. return receiveAutosaves(postId, autosaves);
  2805. case 10:
  2806. case "end":
  2807. return _context9.stop();
  2808. }
  2809. }
  2810. }, _marked9);
  2811. }
  2812. /**
  2813. * Request autosave data from the REST API.
  2814. *
  2815. * This resolver exists to ensure the underlying autosaves are fetched via
  2816. * `getAutosaves` when a call to the `getAutosave` selector is made.
  2817. *
  2818. * @param {string} postType The type of the parent post.
  2819. * @param {number} postId The id of the parent post.
  2820. */
  2821. function resolvers_getAutosave(postType, postId) {
  2822. return regenerator_default.a.wrap(function getAutosave$(_context10) {
  2823. while (1) {
  2824. switch (_context10.prev = _context10.next) {
  2825. case 0:
  2826. _context10.next = 2;
  2827. return resolveSelect('getAutosaves', postType, postId);
  2828. case 2:
  2829. case "end":
  2830. return _context10.stop();
  2831. }
  2832. }
  2833. }, _marked10);
  2834. }
  2835. // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/index.js
  2836. /**
  2837. * WordPress dependencies
  2838. */
  2839. /**
  2840. * Internal dependencies
  2841. */
  2842. // The entity selectors/resolvers and actions are shortcuts to their generic equivalents
  2843. // (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecordss)
  2844. // Instead of getEntityRecord, the consumer could use more user-frieldly named selector: getPostType, getTaxonomy...
  2845. // The "kind" and the "name" of the entity are combined to generate these shortcuts.
  2846. var entitySelectors = defaultEntities.reduce(function (result, entity) {
  2847. var kind = entity.kind,
  2848. name = entity.name;
  2849. result[entities_getMethodName(kind, name)] = function (state, key) {
  2850. return getEntityRecord(state, kind, name, key);
  2851. };
  2852. result[entities_getMethodName(kind, name, 'get', true)] = function (state) {
  2853. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  2854. args[_key - 1] = arguments[_key];
  2855. }
  2856. return getEntityRecords.apply(build_module_selectors_namespaceObject, [state, kind, name].concat(args));
  2857. };
  2858. return result;
  2859. }, {});
  2860. var entityResolvers = defaultEntities.reduce(function (result, entity) {
  2861. var kind = entity.kind,
  2862. name = entity.name;
  2863. result[entities_getMethodName(kind, name)] = function (key) {
  2864. return resolvers_getEntityRecord(kind, name, key);
  2865. };
  2866. var pluralMethodName = entities_getMethodName(kind, name, 'get', true);
  2867. result[pluralMethodName] = function () {
  2868. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  2869. args[_key2] = arguments[_key2];
  2870. }
  2871. return resolvers_getEntityRecords.apply(resolvers_namespaceObject, [kind, name].concat(args));
  2872. };
  2873. result[pluralMethodName].shouldInvalidate = function (action) {
  2874. var _resolvers$getEntityR;
  2875. for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
  2876. args[_key3 - 1] = arguments[_key3];
  2877. }
  2878. return (_resolvers$getEntityR = resolvers_getEntityRecords).shouldInvalidate.apply(_resolvers$getEntityR, [action, kind, name].concat(args));
  2879. };
  2880. return result;
  2881. }, {});
  2882. var entityActions = defaultEntities.reduce(function (result, entity) {
  2883. var kind = entity.kind,
  2884. name = entity.name;
  2885. result[entities_getMethodName(kind, name, 'save')] = function (key) {
  2886. return saveEntityRecord(kind, name, key);
  2887. };
  2888. return result;
  2889. }, {});
  2890. Object(external_this_wp_data_["registerStore"])(REDUCER_KEY, {
  2891. reducer: build_module_reducer,
  2892. controls: build_module_controls,
  2893. actions: Object(objectSpread["a" /* default */])({}, build_module_actions_namespaceObject, entityActions),
  2894. selectors: Object(objectSpread["a" /* default */])({}, build_module_selectors_namespaceObject, entitySelectors),
  2895. resolvers: Object(objectSpread["a" /* default */])({}, resolvers_namespaceObject, entityResolvers)
  2896. });
  2897. /***/ }),
  2898. /***/ 36:
  2899. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2900. "use strict";
  2901. var LEAF_KEY, hasWeakMap;
  2902. /**
  2903. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  2904. *
  2905. * @type {Object}
  2906. */
  2907. LEAF_KEY = {};
  2908. /**
  2909. * Whether environment supports WeakMap.
  2910. *
  2911. * @type {boolean}
  2912. */
  2913. hasWeakMap = typeof WeakMap !== 'undefined';
  2914. /**
  2915. * Returns the first argument as the sole entry in an array.
  2916. *
  2917. * @param {*} value Value to return.
  2918. *
  2919. * @return {Array} Value returned as entry in array.
  2920. */
  2921. function arrayOf( value ) {
  2922. return [ value ];
  2923. }
  2924. /**
  2925. * Returns true if the value passed is object-like, or false otherwise. A value
  2926. * is object-like if it can support property assignment, e.g. object or array.
  2927. *
  2928. * @param {*} value Value to test.
  2929. *
  2930. * @return {boolean} Whether value is object-like.
  2931. */
  2932. function isObjectLike( value ) {
  2933. return !! value && 'object' === typeof value;
  2934. }
  2935. /**
  2936. * Creates and returns a new cache object.
  2937. *
  2938. * @return {Object} Cache object.
  2939. */
  2940. function createCache() {
  2941. var cache = {
  2942. clear: function() {
  2943. cache.head = null;
  2944. },
  2945. };
  2946. return cache;
  2947. }
  2948. /**
  2949. * Returns true if entries within the two arrays are strictly equal by
  2950. * reference from a starting index.
  2951. *
  2952. * @param {Array} a First array.
  2953. * @param {Array} b Second array.
  2954. * @param {number} fromIndex Index from which to start comparison.
  2955. *
  2956. * @return {boolean} Whether arrays are shallowly equal.
  2957. */
  2958. function isShallowEqual( a, b, fromIndex ) {
  2959. var i;
  2960. if ( a.length !== b.length ) {
  2961. return false;
  2962. }
  2963. for ( i = fromIndex; i < a.length; i++ ) {
  2964. if ( a[ i ] !== b[ i ] ) {
  2965. return false;
  2966. }
  2967. }
  2968. return true;
  2969. }
  2970. /**
  2971. * Returns a memoized selector function. The getDependants function argument is
  2972. * called before the memoized selector and is expected to return an immutable
  2973. * reference or array of references on which the selector depends for computing
  2974. * its own return value. The memoize cache is preserved only as long as those
  2975. * dependant references remain the same. If getDependants returns a different
  2976. * reference(s), the cache is cleared and the selector value regenerated.
  2977. *
  2978. * @param {Function} selector Selector function.
  2979. * @param {Function} getDependants Dependant getter returning an immutable
  2980. * reference or array of reference used in
  2981. * cache bust consideration.
  2982. *
  2983. * @return {Function} Memoized selector.
  2984. */
  2985. /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) {
  2986. var rootCache, getCache;
  2987. // Use object source as dependant if getter not provided
  2988. if ( ! getDependants ) {
  2989. getDependants = arrayOf;
  2990. }
  2991. /**
  2992. * Returns the root cache. If WeakMap is supported, this is assigned to the
  2993. * root WeakMap cache set, otherwise it is a shared instance of the default
  2994. * cache object.
  2995. *
  2996. * @return {(WeakMap|Object)} Root cache object.
  2997. */
  2998. function getRootCache() {
  2999. return rootCache;
  3000. }
  3001. /**
  3002. * Returns the cache for a given dependants array. When possible, a WeakMap
  3003. * will be used to create a unique cache for each set of dependants. This
  3004. * is feasible due to the nature of WeakMap in allowing garbage collection
  3005. * to occur on entries where the key object is no longer referenced. Since
  3006. * WeakMap requires the key to be an object, this is only possible when the
  3007. * dependant is object-like. The root cache is created as a hierarchy where
  3008. * each top-level key is the first entry in a dependants set, the value a
  3009. * WeakMap where each key is the next dependant, and so on. This continues
  3010. * so long as the dependants are object-like. If no dependants are object-
  3011. * like, then the cache is shared across all invocations.
  3012. *
  3013. * @see isObjectLike
  3014. *
  3015. * @param {Array} dependants Selector dependants.
  3016. *
  3017. * @return {Object} Cache object.
  3018. */
  3019. function getWeakMapCache( dependants ) {
  3020. var caches = rootCache,
  3021. isUniqueByDependants = true,
  3022. i, dependant, map, cache;
  3023. for ( i = 0; i < dependants.length; i++ ) {
  3024. dependant = dependants[ i ];
  3025. // Can only compose WeakMap from object-like key.
  3026. if ( ! isObjectLike( dependant ) ) {
  3027. isUniqueByDependants = false;
  3028. break;
  3029. }
  3030. // Does current segment of cache already have a WeakMap?
  3031. if ( caches.has( dependant ) ) {
  3032. // Traverse into nested WeakMap.
  3033. caches = caches.get( dependant );
  3034. } else {
  3035. // Create, set, and traverse into a new one.
  3036. map = new WeakMap();
  3037. caches.set( dependant, map );
  3038. caches = map;
  3039. }
  3040. }
  3041. // We use an arbitrary (but consistent) object as key for the last item
  3042. // in the WeakMap to serve as our running cache.
  3043. if ( ! caches.has( LEAF_KEY ) ) {
  3044. cache = createCache();
  3045. cache.isUniqueByDependants = isUniqueByDependants;
  3046. caches.set( LEAF_KEY, cache );
  3047. }
  3048. return caches.get( LEAF_KEY );
  3049. }
  3050. // Assign cache handler by availability of WeakMap
  3051. getCache = hasWeakMap ? getWeakMapCache : getRootCache;
  3052. /**
  3053. * Resets root memoization cache.
  3054. */
  3055. function clear() {
  3056. rootCache = hasWeakMap ? new WeakMap() : createCache();
  3057. }
  3058. // eslint-disable-next-line jsdoc/check-param-names
  3059. /**
  3060. * The augmented selector call, considering first whether dependants have
  3061. * changed before passing it to underlying memoize function.
  3062. *
  3063. * @param {Object} source Source object for derivation.
  3064. * @param {...*} extraArgs Additional arguments to pass to selector.
  3065. *
  3066. * @return {*} Selector result.
  3067. */
  3068. function callSelector( /* source, ...extraArgs */ ) {
  3069. var len = arguments.length,
  3070. cache, node, i, args, dependants;
  3071. // Create copy of arguments (avoid leaking deoptimization).
  3072. args = new Array( len );
  3073. for ( i = 0; i < len; i++ ) {
  3074. args[ i ] = arguments[ i ];
  3075. }
  3076. dependants = getDependants.apply( null, args );
  3077. cache = getCache( dependants );
  3078. // If not guaranteed uniqueness by dependants (primitive type or lack
  3079. // of WeakMap support), shallow compare against last dependants and, if
  3080. // references have changed, destroy cache to recalculate result.
  3081. if ( ! cache.isUniqueByDependants ) {
  3082. if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
  3083. cache.clear();
  3084. }
  3085. cache.lastDependants = dependants;
  3086. }
  3087. node = cache.head;
  3088. while ( node ) {
  3089. // Check whether node arguments match arguments
  3090. if ( ! isShallowEqual( node.args, args, 1 ) ) {
  3091. node = node.next;
  3092. continue;
  3093. }
  3094. // At this point we can assume we've found a match
  3095. // Surface matched node to head if not already
  3096. if ( node !== cache.head ) {
  3097. // Adjust siblings to point to each other.
  3098. node.prev.next = node.next;
  3099. if ( node.next ) {
  3100. node.next.prev = node.prev;
  3101. }
  3102. node.next = cache.head;
  3103. node.prev = null;
  3104. cache.head.prev = node;
  3105. cache.head = node;
  3106. }
  3107. // Return immediately
  3108. return node.val;
  3109. }
  3110. // No cached value found. Continue to insertion phase:
  3111. node = {
  3112. // Generate the result from original function
  3113. val: selector.apply( null, args ),
  3114. };
  3115. // Avoid including the source object in the cache.
  3116. args[ 0 ] = null;
  3117. node.args = args;
  3118. // Don't need to check whether node is already head, since it would
  3119. // have been returned above already if it was
  3120. // Shift existing head down list
  3121. if ( cache.head ) {
  3122. cache.head.prev = node;
  3123. node.next = cache.head;
  3124. }
  3125. cache.head = node;
  3126. return node.val;
  3127. }
  3128. callSelector.getDependants = getDependants;
  3129. callSelector.clear = clear;
  3130. clear();
  3131. return callSelector;
  3132. });
  3133. /***/ }),
  3134. /***/ 37:
  3135. /***/ (function(module, exports) {
  3136. (function() { module.exports = this["wp"]["deprecated"]; }());
  3137. /***/ }),
  3138. /***/ 38:
  3139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3140. "use strict";
  3141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
  3142. function _arrayWithHoles(arr) {
  3143. if (Array.isArray(arr)) return arr;
  3144. }
  3145. /***/ }),
  3146. /***/ 39:
  3147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3148. "use strict";
  3149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
  3150. function _nonIterableRest() {
  3151. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  3152. }
  3153. /***/ }),
  3154. /***/ 4:
  3155. /***/ (function(module, exports) {
  3156. (function() { module.exports = this["wp"]["data"]; }());
  3157. /***/ }),
  3158. /***/ 41:
  3159. /***/ (function(module, exports) {
  3160. (function() { module.exports = this["wp"]["isShallowEqual"]; }());
  3161. /***/ }),
  3162. /***/ 47:
  3163. /***/ (function(module, exports, __webpack_require__) {
  3164. /**
  3165. * Copyright (c) 2014-present, Facebook, Inc.
  3166. *
  3167. * This source code is licensed under the MIT license found in the
  3168. * LICENSE file in the root directory of this source tree.
  3169. */
  3170. var runtime = (function (exports) {
  3171. "use strict";
  3172. var Op = Object.prototype;
  3173. var hasOwn = Op.hasOwnProperty;
  3174. var undefined; // More compressible than void 0.
  3175. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  3176. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  3177. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  3178. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  3179. function wrap(innerFn, outerFn, self, tryLocsList) {
  3180. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  3181. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  3182. var generator = Object.create(protoGenerator.prototype);
  3183. var context = new Context(tryLocsList || []);
  3184. // The ._invoke method unifies the implementations of the .next,
  3185. // .throw, and .return methods.
  3186. generator._invoke = makeInvokeMethod(innerFn, self, context);
  3187. return generator;
  3188. }
  3189. exports.wrap = wrap;
  3190. // Try/catch helper to minimize deoptimizations. Returns a completion
  3191. // record like context.tryEntries[i].completion. This interface could
  3192. // have been (and was previously) designed to take a closure to be
  3193. // invoked without arguments, but in all the cases we care about we
  3194. // already have an existing method we want to call, so there's no need
  3195. // to create a new function object. We can even get away with assuming
  3196. // the method takes exactly one argument, since that happens to be true
  3197. // in every case, so we don't have to touch the arguments object. The
  3198. // only additional allocation required is the completion record, which
  3199. // has a stable shape and so hopefully should be cheap to allocate.
  3200. function tryCatch(fn, obj, arg) {
  3201. try {
  3202. return { type: "normal", arg: fn.call(obj, arg) };
  3203. } catch (err) {
  3204. return { type: "throw", arg: err };
  3205. }
  3206. }
  3207. var GenStateSuspendedStart = "suspendedStart";
  3208. var GenStateSuspendedYield = "suspendedYield";
  3209. var GenStateExecuting = "executing";
  3210. var GenStateCompleted = "completed";
  3211. // Returning this object from the innerFn has the same effect as
  3212. // breaking out of the dispatch switch statement.
  3213. var ContinueSentinel = {};
  3214. // Dummy constructor functions that we use as the .constructor and
  3215. // .constructor.prototype properties for functions that return Generator
  3216. // objects. For full spec compliance, you may wish to configure your
  3217. // minifier not to mangle the names of these two functions.
  3218. function Generator() {}
  3219. function GeneratorFunction() {}
  3220. function GeneratorFunctionPrototype() {}
  3221. // This is a polyfill for %IteratorPrototype% for environments that
  3222. // don't natively support it.
  3223. var IteratorPrototype = {};
  3224. IteratorPrototype[iteratorSymbol] = function () {
  3225. return this;
  3226. };
  3227. var getProto = Object.getPrototypeOf;
  3228. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  3229. if (NativeIteratorPrototype &&
  3230. NativeIteratorPrototype !== Op &&
  3231. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  3232. // This environment has a native %IteratorPrototype%; use it instead
  3233. // of the polyfill.
  3234. IteratorPrototype = NativeIteratorPrototype;
  3235. }
  3236. var Gp = GeneratorFunctionPrototype.prototype =
  3237. Generator.prototype = Object.create(IteratorPrototype);
  3238. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  3239. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  3240. GeneratorFunctionPrototype[toStringTagSymbol] =
  3241. GeneratorFunction.displayName = "GeneratorFunction";
  3242. // Helper for defining the .next, .throw, and .return methods of the
  3243. // Iterator interface in terms of a single ._invoke method.
  3244. function defineIteratorMethods(prototype) {
  3245. ["next", "throw", "return"].forEach(function(method) {
  3246. prototype[method] = function(arg) {
  3247. return this._invoke(method, arg);
  3248. };
  3249. });
  3250. }
  3251. exports.isGeneratorFunction = function(genFun) {
  3252. var ctor = typeof genFun === "function" && genFun.constructor;
  3253. return ctor
  3254. ? ctor === GeneratorFunction ||
  3255. // For the native GeneratorFunction constructor, the best we can
  3256. // do is to check its .name property.
  3257. (ctor.displayName || ctor.name) === "GeneratorFunction"
  3258. : false;
  3259. };
  3260. exports.mark = function(genFun) {
  3261. if (Object.setPrototypeOf) {
  3262. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  3263. } else {
  3264. genFun.__proto__ = GeneratorFunctionPrototype;
  3265. if (!(toStringTagSymbol in genFun)) {
  3266. genFun[toStringTagSymbol] = "GeneratorFunction";
  3267. }
  3268. }
  3269. genFun.prototype = Object.create(Gp);
  3270. return genFun;
  3271. };
  3272. // Within the body of any async function, `await x` is transformed to
  3273. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  3274. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  3275. // meant to be awaited.
  3276. exports.awrap = function(arg) {
  3277. return { __await: arg };
  3278. };
  3279. function AsyncIterator(generator) {
  3280. function invoke(method, arg, resolve, reject) {
  3281. var record = tryCatch(generator[method], generator, arg);
  3282. if (record.type === "throw") {
  3283. reject(record.arg);
  3284. } else {
  3285. var result = record.arg;
  3286. var value = result.value;
  3287. if (value &&
  3288. typeof value === "object" &&
  3289. hasOwn.call(value, "__await")) {
  3290. return Promise.resolve(value.__await).then(function(value) {
  3291. invoke("next", value, resolve, reject);
  3292. }, function(err) {
  3293. invoke("throw", err, resolve, reject);
  3294. });
  3295. }
  3296. return Promise.resolve(value).then(function(unwrapped) {
  3297. // When a yielded Promise is resolved, its final value becomes
  3298. // the .value of the Promise<{value,done}> result for the
  3299. // current iteration.
  3300. result.value = unwrapped;
  3301. resolve(result);
  3302. }, function(error) {
  3303. // If a rejected Promise was yielded, throw the rejection back
  3304. // into the async generator function so it can be handled there.
  3305. return invoke("throw", error, resolve, reject);
  3306. });
  3307. }
  3308. }
  3309. var previousPromise;
  3310. function enqueue(method, arg) {
  3311. function callInvokeWithMethodAndArg() {
  3312. return new Promise(function(resolve, reject) {
  3313. invoke(method, arg, resolve, reject);
  3314. });
  3315. }
  3316. return previousPromise =
  3317. // If enqueue has been called before, then we want to wait until
  3318. // all previous Promises have been resolved before calling invoke,
  3319. // so that results are always delivered in the correct order. If
  3320. // enqueue has not been called before, then it is important to
  3321. // call invoke immediately, without waiting on a callback to fire,
  3322. // so that the async generator function has the opportunity to do
  3323. // any necessary setup in a predictable way. This predictability
  3324. // is why the Promise constructor synchronously invokes its
  3325. // executor callback, and why async functions synchronously
  3326. // execute code before the first await. Since we implement simple
  3327. // async functions in terms of async generators, it is especially
  3328. // important to get this right, even though it requires care.
  3329. previousPromise ? previousPromise.then(
  3330. callInvokeWithMethodAndArg,
  3331. // Avoid propagating failures to Promises returned by later
  3332. // invocations of the iterator.
  3333. callInvokeWithMethodAndArg
  3334. ) : callInvokeWithMethodAndArg();
  3335. }
  3336. // Define the unified helper method that is used to implement .next,
  3337. // .throw, and .return (see defineIteratorMethods).
  3338. this._invoke = enqueue;
  3339. }
  3340. defineIteratorMethods(AsyncIterator.prototype);
  3341. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  3342. return this;
  3343. };
  3344. exports.AsyncIterator = AsyncIterator;
  3345. // Note that simple async functions are implemented on top of
  3346. // AsyncIterator objects; they just return a Promise for the value of
  3347. // the final result produced by the iterator.
  3348. exports.async = function(innerFn, outerFn, self, tryLocsList) {
  3349. var iter = new AsyncIterator(
  3350. wrap(innerFn, outerFn, self, tryLocsList)
  3351. );
  3352. return exports.isGeneratorFunction(outerFn)
  3353. ? iter // If outerFn is a generator, return the full iterator.
  3354. : iter.next().then(function(result) {
  3355. return result.done ? result.value : iter.next();
  3356. });
  3357. };
  3358. function makeInvokeMethod(innerFn, self, context) {
  3359. var state = GenStateSuspendedStart;
  3360. return function invoke(method, arg) {
  3361. if (state === GenStateExecuting) {
  3362. throw new Error("Generator is already running");
  3363. }
  3364. if (state === GenStateCompleted) {
  3365. if (method === "throw") {
  3366. throw arg;
  3367. }
  3368. // Be forgiving, per 25.3.3.3.3 of the spec:
  3369. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  3370. return doneResult();
  3371. }
  3372. context.method = method;
  3373. context.arg = arg;
  3374. while (true) {
  3375. var delegate = context.delegate;
  3376. if (delegate) {
  3377. var delegateResult = maybeInvokeDelegate(delegate, context);
  3378. if (delegateResult) {
  3379. if (delegateResult === ContinueSentinel) continue;
  3380. return delegateResult;
  3381. }
  3382. }
  3383. if (context.method === "next") {
  3384. // Setting context._sent for legacy support of Babel's
  3385. // function.sent implementation.
  3386. context.sent = context._sent = context.arg;
  3387. } else if (context.method === "throw") {
  3388. if (state === GenStateSuspendedStart) {
  3389. state = GenStateCompleted;
  3390. throw context.arg;
  3391. }
  3392. context.dispatchException(context.arg);
  3393. } else if (context.method === "return") {
  3394. context.abrupt("return", context.arg);
  3395. }
  3396. state = GenStateExecuting;
  3397. var record = tryCatch(innerFn, self, context);
  3398. if (record.type === "normal") {
  3399. // If an exception is thrown from innerFn, we leave state ===
  3400. // GenStateExecuting and loop back for another invocation.
  3401. state = context.done
  3402. ? GenStateCompleted
  3403. : GenStateSuspendedYield;
  3404. if (record.arg === ContinueSentinel) {
  3405. continue;
  3406. }
  3407. return {
  3408. value: record.arg,
  3409. done: context.done
  3410. };
  3411. } else if (record.type === "throw") {
  3412. state = GenStateCompleted;
  3413. // Dispatch the exception by looping back around to the
  3414. // context.dispatchException(context.arg) call above.
  3415. context.method = "throw";
  3416. context.arg = record.arg;
  3417. }
  3418. }
  3419. };
  3420. }
  3421. // Call delegate.iterator[context.method](context.arg) and handle the
  3422. // result, either by returning a { value, done } result from the
  3423. // delegate iterator, or by modifying context.method and context.arg,
  3424. // setting context.delegate to null, and returning the ContinueSentinel.
  3425. function maybeInvokeDelegate(delegate, context) {
  3426. var method = delegate.iterator[context.method];
  3427. if (method === undefined) {
  3428. // A .throw or .return when the delegate iterator has no .throw
  3429. // method always terminates the yield* loop.
  3430. context.delegate = null;
  3431. if (context.method === "throw") {
  3432. // Note: ["return"] must be used for ES3 parsing compatibility.
  3433. if (delegate.iterator["return"]) {
  3434. // If the delegate iterator has a return method, give it a
  3435. // chance to clean up.
  3436. context.method = "return";
  3437. context.arg = undefined;
  3438. maybeInvokeDelegate(delegate, context);
  3439. if (context.method === "throw") {
  3440. // If maybeInvokeDelegate(context) changed context.method from
  3441. // "return" to "throw", let that override the TypeError below.
  3442. return ContinueSentinel;
  3443. }
  3444. }
  3445. context.method = "throw";
  3446. context.arg = new TypeError(
  3447. "The iterator does not provide a 'throw' method");
  3448. }
  3449. return ContinueSentinel;
  3450. }
  3451. var record = tryCatch(method, delegate.iterator, context.arg);
  3452. if (record.type === "throw") {
  3453. context.method = "throw";
  3454. context.arg = record.arg;
  3455. context.delegate = null;
  3456. return ContinueSentinel;
  3457. }
  3458. var info = record.arg;
  3459. if (! info) {
  3460. context.method = "throw";
  3461. context.arg = new TypeError("iterator result is not an object");
  3462. context.delegate = null;
  3463. return ContinueSentinel;
  3464. }
  3465. if (info.done) {
  3466. // Assign the result of the finished delegate to the temporary
  3467. // variable specified by delegate.resultName (see delegateYield).
  3468. context[delegate.resultName] = info.value;
  3469. // Resume execution at the desired location (see delegateYield).
  3470. context.next = delegate.nextLoc;
  3471. // If context.method was "throw" but the delegate handled the
  3472. // exception, let the outer generator proceed normally. If
  3473. // context.method was "next", forget context.arg since it has been
  3474. // "consumed" by the delegate iterator. If context.method was
  3475. // "return", allow the original .return call to continue in the
  3476. // outer generator.
  3477. if (context.method !== "return") {
  3478. context.method = "next";
  3479. context.arg = undefined;
  3480. }
  3481. } else {
  3482. // Re-yield the result returned by the delegate method.
  3483. return info;
  3484. }
  3485. // The delegate iterator is finished, so forget it and continue with
  3486. // the outer generator.
  3487. context.delegate = null;
  3488. return ContinueSentinel;
  3489. }
  3490. // Define Generator.prototype.{next,throw,return} in terms of the
  3491. // unified ._invoke helper method.
  3492. defineIteratorMethods(Gp);
  3493. Gp[toStringTagSymbol] = "Generator";
  3494. // A Generator should always return itself as the iterator object when the
  3495. // @@iterator function is called on it. Some browsers' implementations of the
  3496. // iterator prototype chain incorrectly implement this, causing the Generator
  3497. // object to not be returned from this call. This ensures that doesn't happen.
  3498. // See https://github.com/facebook/regenerator/issues/274 for more details.
  3499. Gp[iteratorSymbol] = function() {
  3500. return this;
  3501. };
  3502. Gp.toString = function() {
  3503. return "[object Generator]";
  3504. };
  3505. function pushTryEntry(locs) {
  3506. var entry = { tryLoc: locs[0] };
  3507. if (1 in locs) {
  3508. entry.catchLoc = locs[1];
  3509. }
  3510. if (2 in locs) {
  3511. entry.finallyLoc = locs[2];
  3512. entry.afterLoc = locs[3];
  3513. }
  3514. this.tryEntries.push(entry);
  3515. }
  3516. function resetTryEntry(entry) {
  3517. var record = entry.completion || {};
  3518. record.type = "normal";
  3519. delete record.arg;
  3520. entry.completion = record;
  3521. }
  3522. function Context(tryLocsList) {
  3523. // The root entry object (effectively a try statement without a catch
  3524. // or a finally block) gives us a place to store values thrown from
  3525. // locations where there is no enclosing try statement.
  3526. this.tryEntries = [{ tryLoc: "root" }];
  3527. tryLocsList.forEach(pushTryEntry, this);
  3528. this.reset(true);
  3529. }
  3530. exports.keys = function(object) {
  3531. var keys = [];
  3532. for (var key in object) {
  3533. keys.push(key);
  3534. }
  3535. keys.reverse();
  3536. // Rather than returning an object with a next method, we keep
  3537. // things simple and return the next function itself.
  3538. return function next() {
  3539. while (keys.length) {
  3540. var key = keys.pop();
  3541. if (key in object) {
  3542. next.value = key;
  3543. next.done = false;
  3544. return next;
  3545. }
  3546. }
  3547. // To avoid creating an additional object, we just hang the .value
  3548. // and .done properties off the next function object itself. This
  3549. // also ensures that the minifier will not anonymize the function.
  3550. next.done = true;
  3551. return next;
  3552. };
  3553. };
  3554. function values(iterable) {
  3555. if (iterable) {
  3556. var iteratorMethod = iterable[iteratorSymbol];
  3557. if (iteratorMethod) {
  3558. return iteratorMethod.call(iterable);
  3559. }
  3560. if (typeof iterable.next === "function") {
  3561. return iterable;
  3562. }
  3563. if (!isNaN(iterable.length)) {
  3564. var i = -1, next = function next() {
  3565. while (++i < iterable.length) {
  3566. if (hasOwn.call(iterable, i)) {
  3567. next.value = iterable[i];
  3568. next.done = false;
  3569. return next;
  3570. }
  3571. }
  3572. next.value = undefined;
  3573. next.done = true;
  3574. return next;
  3575. };
  3576. return next.next = next;
  3577. }
  3578. }
  3579. // Return an iterator with no values.
  3580. return { next: doneResult };
  3581. }
  3582. exports.values = values;
  3583. function doneResult() {
  3584. return { value: undefined, done: true };
  3585. }
  3586. Context.prototype = {
  3587. constructor: Context,
  3588. reset: function(skipTempReset) {
  3589. this.prev = 0;
  3590. this.next = 0;
  3591. // Resetting context._sent for legacy support of Babel's
  3592. // function.sent implementation.
  3593. this.sent = this._sent = undefined;
  3594. this.done = false;
  3595. this.delegate = null;
  3596. this.method = "next";
  3597. this.arg = undefined;
  3598. this.tryEntries.forEach(resetTryEntry);
  3599. if (!skipTempReset) {
  3600. for (var name in this) {
  3601. // Not sure about the optimal order of these conditions:
  3602. if (name.charAt(0) === "t" &&
  3603. hasOwn.call(this, name) &&
  3604. !isNaN(+name.slice(1))) {
  3605. this[name] = undefined;
  3606. }
  3607. }
  3608. }
  3609. },
  3610. stop: function() {
  3611. this.done = true;
  3612. var rootEntry = this.tryEntries[0];
  3613. var rootRecord = rootEntry.completion;
  3614. if (rootRecord.type === "throw") {
  3615. throw rootRecord.arg;
  3616. }
  3617. return this.rval;
  3618. },
  3619. dispatchException: function(exception) {
  3620. if (this.done) {
  3621. throw exception;
  3622. }
  3623. var context = this;
  3624. function handle(loc, caught) {
  3625. record.type = "throw";
  3626. record.arg = exception;
  3627. context.next = loc;
  3628. if (caught) {
  3629. // If the dispatched exception was caught by a catch block,
  3630. // then let that catch block handle the exception normally.
  3631. context.method = "next";
  3632. context.arg = undefined;
  3633. }
  3634. return !! caught;
  3635. }
  3636. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3637. var entry = this.tryEntries[i];
  3638. var record = entry.completion;
  3639. if (entry.tryLoc === "root") {
  3640. // Exception thrown outside of any try block that could handle
  3641. // it, so set the completion value of the entire function to
  3642. // throw the exception.
  3643. return handle("end");
  3644. }
  3645. if (entry.tryLoc <= this.prev) {
  3646. var hasCatch = hasOwn.call(entry, "catchLoc");
  3647. var hasFinally = hasOwn.call(entry, "finallyLoc");
  3648. if (hasCatch && hasFinally) {
  3649. if (this.prev < entry.catchLoc) {
  3650. return handle(entry.catchLoc, true);
  3651. } else if (this.prev < entry.finallyLoc) {
  3652. return handle(entry.finallyLoc);
  3653. }
  3654. } else if (hasCatch) {
  3655. if (this.prev < entry.catchLoc) {
  3656. return handle(entry.catchLoc, true);
  3657. }
  3658. } else if (hasFinally) {
  3659. if (this.prev < entry.finallyLoc) {
  3660. return handle(entry.finallyLoc);
  3661. }
  3662. } else {
  3663. throw new Error("try statement without catch or finally");
  3664. }
  3665. }
  3666. }
  3667. },
  3668. abrupt: function(type, arg) {
  3669. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3670. var entry = this.tryEntries[i];
  3671. if (entry.tryLoc <= this.prev &&
  3672. hasOwn.call(entry, "finallyLoc") &&
  3673. this.prev < entry.finallyLoc) {
  3674. var finallyEntry = entry;
  3675. break;
  3676. }
  3677. }
  3678. if (finallyEntry &&
  3679. (type === "break" ||
  3680. type === "continue") &&
  3681. finallyEntry.tryLoc <= arg &&
  3682. arg <= finallyEntry.finallyLoc) {
  3683. // Ignore the finally entry if control is not jumping to a
  3684. // location outside the try/catch block.
  3685. finallyEntry = null;
  3686. }
  3687. var record = finallyEntry ? finallyEntry.completion : {};
  3688. record.type = type;
  3689. record.arg = arg;
  3690. if (finallyEntry) {
  3691. this.method = "next";
  3692. this.next = finallyEntry.finallyLoc;
  3693. return ContinueSentinel;
  3694. }
  3695. return this.complete(record);
  3696. },
  3697. complete: function(record, afterLoc) {
  3698. if (record.type === "throw") {
  3699. throw record.arg;
  3700. }
  3701. if (record.type === "break" ||
  3702. record.type === "continue") {
  3703. this.next = record.arg;
  3704. } else if (record.type === "return") {
  3705. this.rval = this.arg = record.arg;
  3706. this.method = "return";
  3707. this.next = "end";
  3708. } else if (record.type === "normal" && afterLoc) {
  3709. this.next = afterLoc;
  3710. }
  3711. return ContinueSentinel;
  3712. },
  3713. finish: function(finallyLoc) {
  3714. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3715. var entry = this.tryEntries[i];
  3716. if (entry.finallyLoc === finallyLoc) {
  3717. this.complete(entry.completion, entry.afterLoc);
  3718. resetTryEntry(entry);
  3719. return ContinueSentinel;
  3720. }
  3721. }
  3722. },
  3723. "catch": function(tryLoc) {
  3724. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3725. var entry = this.tryEntries[i];
  3726. if (entry.tryLoc === tryLoc) {
  3727. var record = entry.completion;
  3728. if (record.type === "throw") {
  3729. var thrown = record.arg;
  3730. resetTryEntry(entry);
  3731. }
  3732. return thrown;
  3733. }
  3734. }
  3735. // The context.catch method must only be called with a location
  3736. // argument that corresponds to a known catch block.
  3737. throw new Error("illegal catch attempt");
  3738. },
  3739. delegateYield: function(iterable, resultName, nextLoc) {
  3740. this.delegate = {
  3741. iterator: values(iterable),
  3742. resultName: resultName,
  3743. nextLoc: nextLoc
  3744. };
  3745. if (this.method === "next") {
  3746. // Deliberately forget the last sent value so that we don't
  3747. // accidentally pass it on to the delegate.
  3748. this.arg = undefined;
  3749. }
  3750. return ContinueSentinel;
  3751. }
  3752. };
  3753. // Regardless of whether this script is executing as a CommonJS module
  3754. // or not, return the runtime object so that we can declare the variable
  3755. // regeneratorRuntime in the outer scope, which allows this module to be
  3756. // injected easily by `bin/regenerator --include-runtime script.js`.
  3757. return exports;
  3758. }(
  3759. // If this script is executing as a CommonJS module, use module.exports
  3760. // as the regeneratorRuntime namespace. Otherwise create a new empty
  3761. // object. Either way, the resulting object will be used to initialize
  3762. // the regeneratorRuntime variable at the top of this file.
  3763. true ? module.exports : undefined
  3764. ));
  3765. try {
  3766. regeneratorRuntime = runtime;
  3767. } catch (accidentalStrictMode) {
  3768. // This module should not be running in strict mode, so the above
  3769. // assignment should always work unless something is misconfigured. Just
  3770. // in case runtime.js accidentally runs in strict mode, we can escape
  3771. // strict mode using a global Function call. This could conceivably fail
  3772. // if a Content Security Policy forbids using Function, but in that case
  3773. // the proper solution is to fix the accidental strict mode problem. If
  3774. // you've misconfigured your bundler to force strict mode and applied a
  3775. // CSP to forbid Function, and you're not willing to fix either of those
  3776. // problems, please detail your unique predicament in a GitHub issue.
  3777. Function("r", "regeneratorRuntime = r")(runtime);
  3778. }
  3779. /***/ }),
  3780. /***/ 7:
  3781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3782. "use strict";
  3783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; });
  3784. /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
  3785. function _objectSpread(target) {
  3786. for (var i = 1; i < arguments.length; i++) {
  3787. var source = arguments[i] != null ? arguments[i] : {};
  3788. var ownKeys = Object.keys(source);
  3789. if (typeof Object.getOwnPropertySymbols === 'function') {
  3790. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  3791. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  3792. }));
  3793. }
  3794. ownKeys.forEach(function (key) {
  3795. Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]);
  3796. });
  3797. }
  3798. return target;
  3799. }
  3800. /***/ }),
  3801. /***/ 74:
  3802. /***/ (function(module, exports, __webpack_require__) {
  3803. "use strict";
  3804. function _typeof(obj) {
  3805. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  3806. _typeof = function (obj) {
  3807. return typeof obj;
  3808. };
  3809. } else {
  3810. _typeof = function (obj) {
  3811. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  3812. };
  3813. }
  3814. return _typeof(obj);
  3815. }
  3816. function _classCallCheck(instance, Constructor) {
  3817. if (!(instance instanceof Constructor)) {
  3818. throw new TypeError("Cannot call a class as a function");
  3819. }
  3820. }
  3821. function _defineProperties(target, props) {
  3822. for (var i = 0; i < props.length; i++) {
  3823. var descriptor = props[i];
  3824. descriptor.enumerable = descriptor.enumerable || false;
  3825. descriptor.configurable = true;
  3826. if ("value" in descriptor) descriptor.writable = true;
  3827. Object.defineProperty(target, descriptor.key, descriptor);
  3828. }
  3829. }
  3830. function _createClass(Constructor, protoProps, staticProps) {
  3831. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  3832. if (staticProps) _defineProperties(Constructor, staticProps);
  3833. return Constructor;
  3834. }
  3835. /**
  3836. * Given an instance of EquivalentKeyMap, returns its internal value pair tuple
  3837. * for a key, if one exists. The tuple members consist of the last reference
  3838. * value for the key (used in efficient subsequent lookups) and the value
  3839. * assigned for the key at the leaf node.
  3840. *
  3841. * @param {EquivalentKeyMap} instance EquivalentKeyMap instance.
  3842. * @param {*} key The key for which to return value pair.
  3843. *
  3844. * @return {?Array} Value pair, if exists.
  3845. */
  3846. function getValuePair(instance, key) {
  3847. var _map = instance._map,
  3848. _arrayTreeMap = instance._arrayTreeMap,
  3849. _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the
  3850. // value, which can be used to shortcut immediately to the value.
  3851. if (_map.has(key)) {
  3852. return _map.get(key);
  3853. } // Sort keys to ensure stable retrieval from tree.
  3854. var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value.
  3855. var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap;
  3856. for (var i = 0; i < properties.length; i++) {
  3857. var property = properties[i];
  3858. map = map.get(property);
  3859. if (map === undefined) {
  3860. return;
  3861. }
  3862. var propertyValue = key[property];
  3863. map = map.get(propertyValue);
  3864. if (map === undefined) {
  3865. return;
  3866. }
  3867. }
  3868. var valuePair = map.get('_ekm_value');
  3869. if (!valuePair) {
  3870. return;
  3871. } // If reached, it implies that an object-like key was set with another
  3872. // reference, so delete the reference and replace with the current.
  3873. _map.delete(valuePair[0]);
  3874. valuePair[0] = key;
  3875. map.set('_ekm_value', valuePair);
  3876. _map.set(key, valuePair);
  3877. return valuePair;
  3878. }
  3879. /**
  3880. * Variant of a Map object which enables lookup by equivalent (deeply equal)
  3881. * object and array keys.
  3882. */
  3883. var EquivalentKeyMap =
  3884. /*#__PURE__*/
  3885. function () {
  3886. /**
  3887. * Constructs a new instance of EquivalentKeyMap.
  3888. *
  3889. * @param {Iterable.<*>} iterable Initial pair of key, value for map.
  3890. */
  3891. function EquivalentKeyMap(iterable) {
  3892. _classCallCheck(this, EquivalentKeyMap);
  3893. this.clear();
  3894. if (iterable instanceof EquivalentKeyMap) {
  3895. // Map#forEach is only means of iterating with support for IE11.
  3896. var iterablePairs = [];
  3897. iterable.forEach(function (value, key) {
  3898. iterablePairs.push([key, value]);
  3899. });
  3900. iterable = iterablePairs;
  3901. }
  3902. if (iterable != null) {
  3903. for (var i = 0; i < iterable.length; i++) {
  3904. this.set(iterable[i][0], iterable[i][1]);
  3905. }
  3906. }
  3907. }
  3908. /**
  3909. * Accessor property returning the number of elements.
  3910. *
  3911. * @return {number} Number of elements.
  3912. */
  3913. _createClass(EquivalentKeyMap, [{
  3914. key: "set",
  3915. /**
  3916. * Add or update an element with a specified key and value.
  3917. *
  3918. * @param {*} key The key of the element to add.
  3919. * @param {*} value The value of the element to add.
  3920. *
  3921. * @return {EquivalentKeyMap} Map instance.
  3922. */
  3923. value: function set(key, value) {
  3924. // Shortcut non-object-like to set on internal Map.
  3925. if (key === null || _typeof(key) !== 'object') {
  3926. this._map.set(key, value);
  3927. return this;
  3928. } // Sort keys to ensure stable assignment into tree.
  3929. var properties = Object.keys(key).sort();
  3930. var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value.
  3931. var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap;
  3932. for (var i = 0; i < properties.length; i++) {
  3933. var property = properties[i];
  3934. if (!map.has(property)) {
  3935. map.set(property, new EquivalentKeyMap());
  3936. }
  3937. map = map.get(property);
  3938. var propertyValue = key[property];
  3939. if (!map.has(propertyValue)) {
  3940. map.set(propertyValue, new EquivalentKeyMap());
  3941. }
  3942. map = map.get(propertyValue);
  3943. } // If an _ekm_value exists, there was already an equivalent key. Before
  3944. // overriding, ensure that the old key reference is removed from map to
  3945. // avoid memory leak of accumulating equivalent keys. This is, in a
  3946. // sense, a poor man's WeakMap, while still enabling iterability.
  3947. var previousValuePair = map.get('_ekm_value');
  3948. if (previousValuePair) {
  3949. this._map.delete(previousValuePair[0]);
  3950. }
  3951. map.set('_ekm_value', valuePair);
  3952. this._map.set(key, valuePair);
  3953. return this;
  3954. }
  3955. /**
  3956. * Returns a specified element.
  3957. *
  3958. * @param {*} key The key of the element to return.
  3959. *
  3960. * @return {?*} The element associated with the specified key or undefined
  3961. * if the key can't be found.
  3962. */
  3963. }, {
  3964. key: "get",
  3965. value: function get(key) {
  3966. // Shortcut non-object-like to get from internal Map.
  3967. if (key === null || _typeof(key) !== 'object') {
  3968. return this._map.get(key);
  3969. }
  3970. var valuePair = getValuePair(this, key);
  3971. if (valuePair) {
  3972. return valuePair[1];
  3973. }
  3974. }
  3975. /**
  3976. * Returns a boolean indicating whether an element with the specified key
  3977. * exists or not.
  3978. *
  3979. * @param {*} key The key of the element to test for presence.
  3980. *
  3981. * @return {boolean} Whether an element with the specified key exists.
  3982. */
  3983. }, {
  3984. key: "has",
  3985. value: function has(key) {
  3986. if (key === null || _typeof(key) !== 'object') {
  3987. return this._map.has(key);
  3988. } // Test on the _presence_ of the pair, not its value, as even undefined
  3989. // can be a valid member value for a key.
  3990. return getValuePair(this, key) !== undefined;
  3991. }
  3992. /**
  3993. * Removes the specified element.
  3994. *
  3995. * @param {*} key The key of the element to remove.
  3996. *
  3997. * @return {boolean} Returns true if an element existed and has been
  3998. * removed, or false if the element does not exist.
  3999. */
  4000. }, {
  4001. key: "delete",
  4002. value: function _delete(key) {
  4003. if (!this.has(key)) {
  4004. return false;
  4005. } // This naive implementation will leave orphaned child trees. A better
  4006. // implementation should traverse and remove orphans.
  4007. this.set(key, undefined);
  4008. return true;
  4009. }
  4010. /**
  4011. * Executes a provided function once per each key/value pair, in insertion
  4012. * order.
  4013. *
  4014. * @param {Function} callback Function to execute for each element.
  4015. * @param {*} thisArg Value to use as `this` when executing
  4016. * `callback`.
  4017. */
  4018. }, {
  4019. key: "forEach",
  4020. value: function forEach(callback) {
  4021. var _this = this;
  4022. var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
  4023. this._map.forEach(function (value, key) {
  4024. // Unwrap value from object-like value pair.
  4025. if (key !== null && _typeof(key) === 'object') {
  4026. value = value[1];
  4027. }
  4028. callback.call(thisArg, value, key, _this);
  4029. });
  4030. }
  4031. /**
  4032. * Removes all elements.
  4033. */
  4034. }, {
  4035. key: "clear",
  4036. value: function clear() {
  4037. this._map = new Map();
  4038. this._arrayTreeMap = new Map();
  4039. this._objectTreeMap = new Map();
  4040. }
  4041. }, {
  4042. key: "size",
  4043. get: function get() {
  4044. return this._map.size;
  4045. }
  4046. }]);
  4047. return EquivalentKeyMap;
  4048. }();
  4049. module.exports = EquivalentKeyMap;
  4050. /***/ })
  4051. /******/ });