vendors-node_modules_taro_weapp_prebundle_xstate_js.js 160 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273
  1. "use strict";
  2. (wx["webpackJsonp"] = wx["webpackJsonp"] || []).push([["vendors-node_modules_taro_weapp_prebundle_xstate_js"],{
  3. /***/ "./node_modules/.taro/weapp/prebundle/xstate.js":
  4. /*!******************************************************!*\
  5. !*** ./node_modules/.taro/weapp/prebundle/xstate.js ***!
  6. \******************************************************/
  7. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  8. __webpack_require__.r(__webpack_exports__);
  9. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10. /* harmony export */ ActionTypes: function() { return /* binding */ ActionTypes; },
  11. /* harmony export */ Interpreter: function() { return /* binding */ Interpreter; },
  12. /* harmony export */ InterpreterStatus: function() { return /* binding */ InterpreterStatus; },
  13. /* harmony export */ Machine: function() { return /* binding */ Machine; },
  14. /* harmony export */ SpecialTargets: function() { return /* binding */ SpecialTargets; },
  15. /* harmony export */ State: function() { return /* binding */ State; },
  16. /* harmony export */ StateNode: function() { return /* binding */ StateNode; },
  17. /* harmony export */ actions: function() { return /* binding */ actions_exports; },
  18. /* harmony export */ assign: function() { return /* binding */ assign3; },
  19. /* harmony export */ cancel: function() { return /* binding */ cancel3; },
  20. /* harmony export */ choose: function() { return /* binding */ choose3; },
  21. /* harmony export */ createMachine: function() { return /* binding */ createMachine; },
  22. /* harmony export */ createSchema: function() { return /* binding */ createSchema; },
  23. /* harmony export */ doneInvoke: function() { return /* binding */ doneInvoke2; },
  24. /* harmony export */ forwardTo: function() { return /* binding */ forwardTo2; },
  25. /* harmony export */ interpret: function() { return /* binding */ interpret; },
  26. /* harmony export */ log: function() { return /* binding */ log3; },
  27. /* harmony export */ mapState: function() { return /* binding */ mapState; },
  28. /* harmony export */ matchState: function() { return /* binding */ matchState; },
  29. /* harmony export */ matchesState: function() { return /* binding */ matchesState; },
  30. /* harmony export */ pure: function() { return /* binding */ pure3; },
  31. /* harmony export */ raise: function() { return /* binding */ raise3; },
  32. /* harmony export */ send: function() { return /* binding */ send3; },
  33. /* harmony export */ sendParent: function() { return /* binding */ sendParent2; },
  34. /* harmony export */ sendTo: function() { return /* binding */ sendTo2; },
  35. /* harmony export */ sendUpdate: function() { return /* binding */ sendUpdate2; },
  36. /* harmony export */ spawn: function() { return /* binding */ spawn; },
  37. /* harmony export */ spawnBehavior: function() { return /* binding */ spawnBehavior; },
  38. /* harmony export */ stop: function() { return /* binding */ stop3; },
  39. /* harmony export */ t: function() { return /* binding */ t; },
  40. /* harmony export */ toActorRef: function() { return /* binding */ toActorRef; },
  41. /* harmony export */ toEventObject: function() { return /* binding */ toEventObject; },
  42. /* harmony export */ toObserver: function() { return /* binding */ toObserver; },
  43. /* harmony export */ toSCXMLEvent: function() { return /* binding */ toSCXMLEvent; }
  44. /* harmony export */ });
  45. /* harmony import */ var _chunk_P7VEE7PG_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./chunk-P7VEE7PG.js */ "./node_modules/.taro/weapp/prebundle/chunk-P7VEE7PG.js");
  46. /* provided dependency */ var window = __webpack_require__(/*! ./node_modules/.taro/weapp/prebundle/chunk-3EXGJ5BE.js */ "./node_modules/.taro/weapp/prebundle/chunk-3EXGJ5BE.js")["window$1"];
  47. // node_modules/xstate/es/actions.js
  48. var actions_exports = {};
  49. (0,_chunk_P7VEE7PG_js__WEBPACK_IMPORTED_MODULE_0__.__export)(actions_exports, {
  50. actionTypes: ()=>actionTypes_exports,
  51. after: ()=>after2,
  52. assign: ()=>assign2,
  53. cancel: ()=>cancel2,
  54. choose: ()=>choose2,
  55. done: ()=>done,
  56. doneInvoke: ()=>doneInvoke,
  57. error: ()=>error2,
  58. escalate: ()=>escalate,
  59. forwardTo: ()=>forwardTo,
  60. getActionFunction: ()=>getActionFunction,
  61. initEvent: ()=>initEvent,
  62. isActionObject: ()=>isActionObject,
  63. log: ()=>log2,
  64. pure: ()=>pure2,
  65. raise: ()=>raise2,
  66. resolveActions: ()=>resolveActions,
  67. resolveLog: ()=>resolveLog,
  68. resolveRaise: ()=>resolveRaise,
  69. resolveSend: ()=>resolveSend,
  70. resolveStop: ()=>resolveStop,
  71. respond: ()=>respond,
  72. send: ()=>send2,
  73. sendParent: ()=>sendParent,
  74. sendTo: ()=>sendTo,
  75. sendUpdate: ()=>sendUpdate,
  76. start: ()=>start2,
  77. stop: ()=>stop2,
  78. toActionObject: ()=>toActionObject,
  79. toActionObjects: ()=>toActionObjects,
  80. toActivityDefinition: ()=>toActivityDefinition
  81. });
  82. // node_modules/xstate/es/_virtual/_tslib.js
  83. var __assign = function() {
  84. __assign = Object.assign || function __assign2(t2) {
  85. for(var s, i = 1, n = arguments.length; i < n; i++){
  86. s = arguments[i];
  87. for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p)) t2[p] = s[p];
  88. }
  89. return t2;
  90. };
  91. return __assign.apply(this, arguments);
  92. };
  93. function __rest(s, e) {
  94. var t2 = {};
  95. for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t2[p] = s[p];
  96. if (s != null && typeof Object.getOwnPropertySymbols === "function") for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++){
  97. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t2[p[i]] = s[p[i]];
  98. }
  99. return t2;
  100. }
  101. function __values(o) {
  102. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  103. if (m) return m.call(o);
  104. if (o && typeof o.length === "number") return {
  105. next: function() {
  106. if (o && i >= o.length) o = void 0;
  107. return {
  108. value: o && o[i++],
  109. done: !o
  110. };
  111. }
  112. };
  113. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  114. }
  115. function __read(o, n) {
  116. var m = typeof Symbol === "function" && o[Symbol.iterator];
  117. if (!m) return o;
  118. var i = m.call(o), r, ar = [], e;
  119. try {
  120. while((n === void 0 || n-- > 0) && !(r = i.next()).done)ar.push(r.value);
  121. } catch (error3) {
  122. e = {
  123. error: error3
  124. };
  125. } finally{
  126. try {
  127. if (r && !r.done && (m = i["return"])) m.call(i);
  128. } finally{
  129. if (e) throw e.error;
  130. }
  131. }
  132. return ar;
  133. }
  134. function __spreadArray(to, from, pack) {
  135. if (pack || arguments.length === 2) for(var i = 0, l = from.length, ar; i < l; i++){
  136. if (ar || !(i in from)) {
  137. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  138. ar[i] = from[i];
  139. }
  140. }
  141. return to.concat(ar || Array.prototype.slice.call(from));
  142. }
  143. // node_modules/xstate/es/types.js
  144. var ActionTypes;
  145. (function(ActionTypes2) {
  146. ActionTypes2["Start"] = "xstate.start";
  147. ActionTypes2["Stop"] = "xstate.stop";
  148. ActionTypes2["Raise"] = "xstate.raise";
  149. ActionTypes2["Send"] = "xstate.send";
  150. ActionTypes2["Cancel"] = "xstate.cancel";
  151. ActionTypes2["NullEvent"] = "";
  152. ActionTypes2["Assign"] = "xstate.assign";
  153. ActionTypes2["After"] = "xstate.after";
  154. ActionTypes2["DoneState"] = "done.state";
  155. ActionTypes2["DoneInvoke"] = "done.invoke";
  156. ActionTypes2["Log"] = "xstate.log";
  157. ActionTypes2["Init"] = "xstate.init";
  158. ActionTypes2["Invoke"] = "xstate.invoke";
  159. ActionTypes2["ErrorExecution"] = "error.execution";
  160. ActionTypes2["ErrorCommunication"] = "error.communication";
  161. ActionTypes2["ErrorPlatform"] = "error.platform";
  162. ActionTypes2["ErrorCustom"] = "xstate.error";
  163. ActionTypes2["Update"] = "xstate.update";
  164. ActionTypes2["Pure"] = "xstate.pure";
  165. ActionTypes2["Choose"] = "xstate.choose";
  166. })(ActionTypes || (ActionTypes = {}));
  167. var SpecialTargets;
  168. (function(SpecialTargets2) {
  169. SpecialTargets2["Parent"] = "#_parent";
  170. SpecialTargets2["Internal"] = "#_internal";
  171. })(SpecialTargets || (SpecialTargets = {}));
  172. // node_modules/xstate/es/actionTypes.js
  173. var actionTypes_exports = {};
  174. (0,_chunk_P7VEE7PG_js__WEBPACK_IMPORTED_MODULE_0__.__export)(actionTypes_exports, {
  175. after: ()=>after,
  176. assign: ()=>assign,
  177. cancel: ()=>cancel,
  178. choose: ()=>choose,
  179. doneState: ()=>doneState,
  180. error: ()=>error,
  181. errorExecution: ()=>errorExecution,
  182. errorPlatform: ()=>errorPlatform,
  183. init: ()=>init,
  184. invoke: ()=>invoke,
  185. log: ()=>log,
  186. nullEvent: ()=>nullEvent,
  187. pure: ()=>pure,
  188. raise: ()=>raise,
  189. send: ()=>send,
  190. start: ()=>start,
  191. stop: ()=>stop,
  192. update: ()=>update
  193. });
  194. var start = ActionTypes.Start;
  195. var stop = ActionTypes.Stop;
  196. var raise = ActionTypes.Raise;
  197. var send = ActionTypes.Send;
  198. var cancel = ActionTypes.Cancel;
  199. var nullEvent = ActionTypes.NullEvent;
  200. var assign = ActionTypes.Assign;
  201. var after = ActionTypes.After;
  202. var doneState = ActionTypes.DoneState;
  203. var log = ActionTypes.Log;
  204. var init = ActionTypes.Init;
  205. var invoke = ActionTypes.Invoke;
  206. var errorExecution = ActionTypes.ErrorExecution;
  207. var errorPlatform = ActionTypes.ErrorPlatform;
  208. var error = ActionTypes.ErrorCustom;
  209. var update = ActionTypes.Update;
  210. var choose = ActionTypes.Choose;
  211. var pure = ActionTypes.Pure;
  212. // node_modules/xstate/es/constants.js
  213. var STATE_DELIMITER = ".";
  214. var EMPTY_ACTIVITY_MAP = {};
  215. var DEFAULT_GUARD_TYPE = "xstate.guard";
  216. var TARGETLESS_KEY = "";
  217. // node_modules/xstate/es/environment.js
  218. var IS_PRODUCTION = false;
  219. // node_modules/xstate/es/utils.js
  220. var _a;
  221. function matchesState(parentStateId, childStateId, delimiter) {
  222. if (delimiter === void 0) {
  223. delimiter = STATE_DELIMITER;
  224. }
  225. var parentStateValue = toStateValue(parentStateId, delimiter);
  226. var childStateValue = toStateValue(childStateId, delimiter);
  227. if (isString(childStateValue)) {
  228. if (isString(parentStateValue)) {
  229. return childStateValue === parentStateValue;
  230. }
  231. return false;
  232. }
  233. if (isString(parentStateValue)) {
  234. return parentStateValue in childStateValue;
  235. }
  236. return Object.keys(parentStateValue).every(function(key) {
  237. if (!(key in childStateValue)) {
  238. return false;
  239. }
  240. return matchesState(parentStateValue[key], childStateValue[key]);
  241. });
  242. }
  243. function getEventType(event2) {
  244. try {
  245. return isString(event2) || typeof event2 === "number" ? "".concat(event2) : event2.type;
  246. } catch (e) {
  247. throw new Error("Events must be strings or objects with a string event.type property.");
  248. }
  249. }
  250. function toStatePath(stateId, delimiter) {
  251. try {
  252. if (isArray(stateId)) {
  253. return stateId;
  254. }
  255. return stateId.toString().split(delimiter);
  256. } catch (e) {
  257. throw new Error("'".concat(stateId, "' is not a valid state path."));
  258. }
  259. }
  260. function isStateLike(state) {
  261. return typeof state === "object" && "value" in state && "context" in state && "event" in state && "_event" in state;
  262. }
  263. function toStateValue(stateValue, delimiter) {
  264. if (isStateLike(stateValue)) {
  265. return stateValue.value;
  266. }
  267. if (isArray(stateValue)) {
  268. return pathToStateValue(stateValue);
  269. }
  270. if (typeof stateValue !== "string") {
  271. return stateValue;
  272. }
  273. var statePath = toStatePath(stateValue, delimiter);
  274. return pathToStateValue(statePath);
  275. }
  276. function pathToStateValue(statePath) {
  277. if (statePath.length === 1) {
  278. return statePath[0];
  279. }
  280. var value = {};
  281. var marker = value;
  282. for(var i = 0; i < statePath.length - 1; i++){
  283. if (i === statePath.length - 2) {
  284. marker[statePath[i]] = statePath[i + 1];
  285. } else {
  286. marker[statePath[i]] = {};
  287. marker = marker[statePath[i]];
  288. }
  289. }
  290. return value;
  291. }
  292. function mapValues(collection, iteratee) {
  293. var result = {};
  294. var collectionKeys = Object.keys(collection);
  295. for(var i = 0; i < collectionKeys.length; i++){
  296. var key = collectionKeys[i];
  297. result[key] = iteratee(collection[key], key, collection, i);
  298. }
  299. return result;
  300. }
  301. function mapFilterValues(collection, iteratee, predicate) {
  302. var e_1, _a2;
  303. var result = {};
  304. try {
  305. for(var _b = __values(Object.keys(collection)), _c = _b.next(); !_c.done; _c = _b.next()){
  306. var key = _c.value;
  307. var item = collection[key];
  308. if (!predicate(item)) {
  309. continue;
  310. }
  311. result[key] = iteratee(item, key, collection);
  312. }
  313. } catch (e_1_1) {
  314. e_1 = {
  315. error: e_1_1
  316. };
  317. } finally{
  318. try {
  319. if (_c && !_c.done && (_a2 = _b.return)) _a2.call(_b);
  320. } finally{
  321. if (e_1) throw e_1.error;
  322. }
  323. }
  324. return result;
  325. }
  326. var path = function(props) {
  327. return function(object) {
  328. var e_2, _a2;
  329. var result = object;
  330. try {
  331. for(var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()){
  332. var prop = props_1_1.value;
  333. result = result[prop];
  334. }
  335. } catch (e_2_1) {
  336. e_2 = {
  337. error: e_2_1
  338. };
  339. } finally{
  340. try {
  341. if (props_1_1 && !props_1_1.done && (_a2 = props_1.return)) _a2.call(props_1);
  342. } finally{
  343. if (e_2) throw e_2.error;
  344. }
  345. }
  346. return result;
  347. };
  348. };
  349. function nestedPath(props, accessorProp) {
  350. return function(object) {
  351. var e_3, _a2;
  352. var result = object;
  353. try {
  354. for(var props_2 = __values(props), props_2_1 = props_2.next(); !props_2_1.done; props_2_1 = props_2.next()){
  355. var prop = props_2_1.value;
  356. result = result[accessorProp][prop];
  357. }
  358. } catch (e_3_1) {
  359. e_3 = {
  360. error: e_3_1
  361. };
  362. } finally{
  363. try {
  364. if (props_2_1 && !props_2_1.done && (_a2 = props_2.return)) _a2.call(props_2);
  365. } finally{
  366. if (e_3) throw e_3.error;
  367. }
  368. }
  369. return result;
  370. };
  371. }
  372. function toStatePaths(stateValue) {
  373. if (!stateValue) {
  374. return [
  375. []
  376. ];
  377. }
  378. if (isString(stateValue)) {
  379. return [
  380. [
  381. stateValue
  382. ]
  383. ];
  384. }
  385. var result = flatten(Object.keys(stateValue).map(function(key) {
  386. var subStateValue = stateValue[key];
  387. if (typeof subStateValue !== "string" && (!subStateValue || !Object.keys(subStateValue).length)) {
  388. return [
  389. [
  390. key
  391. ]
  392. ];
  393. }
  394. return toStatePaths(stateValue[key]).map(function(subPath) {
  395. return [
  396. key
  397. ].concat(subPath);
  398. });
  399. }));
  400. return result;
  401. }
  402. function flatten(array) {
  403. var _a2;
  404. return (_a2 = []).concat.apply(_a2, __spreadArray([], __read(array), false));
  405. }
  406. function toArrayStrict(value) {
  407. if (isArray(value)) {
  408. return value;
  409. }
  410. return [
  411. value
  412. ];
  413. }
  414. function toArray(value) {
  415. if (value === void 0) {
  416. return [];
  417. }
  418. return toArrayStrict(value);
  419. }
  420. function mapContext(mapper, context, _event) {
  421. var e_5, _a2;
  422. if (isFunction(mapper)) {
  423. return mapper(context, _event.data);
  424. }
  425. var result = {};
  426. try {
  427. for(var _b = __values(Object.keys(mapper)), _c = _b.next(); !_c.done; _c = _b.next()){
  428. var key = _c.value;
  429. var subMapper = mapper[key];
  430. if (isFunction(subMapper)) {
  431. result[key] = subMapper(context, _event.data);
  432. } else {
  433. result[key] = subMapper;
  434. }
  435. }
  436. } catch (e_5_1) {
  437. e_5 = {
  438. error: e_5_1
  439. };
  440. } finally{
  441. try {
  442. if (_c && !_c.done && (_a2 = _b.return)) _a2.call(_b);
  443. } finally{
  444. if (e_5) throw e_5.error;
  445. }
  446. }
  447. return result;
  448. }
  449. function isBuiltInEvent(eventType) {
  450. return /^(done|error)\./.test(eventType);
  451. }
  452. function isPromiseLike(value) {
  453. if (value instanceof Promise) {
  454. return true;
  455. }
  456. if (value !== null && (isFunction(value) || typeof value === "object") && isFunction(value.then)) {
  457. return true;
  458. }
  459. return false;
  460. }
  461. function isBehavior(value) {
  462. return value !== null && typeof value === "object" && "transition" in value && typeof value.transition === "function";
  463. }
  464. function partition(items, predicate) {
  465. var e_6, _a2;
  466. var _b = __read([
  467. [],
  468. []
  469. ], 2), truthy = _b[0], falsy = _b[1];
  470. try {
  471. for(var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()){
  472. var item = items_1_1.value;
  473. if (predicate(item)) {
  474. truthy.push(item);
  475. } else {
  476. falsy.push(item);
  477. }
  478. }
  479. } catch (e_6_1) {
  480. e_6 = {
  481. error: e_6_1
  482. };
  483. } finally{
  484. try {
  485. if (items_1_1 && !items_1_1.done && (_a2 = items_1.return)) _a2.call(items_1);
  486. } finally{
  487. if (e_6) throw e_6.error;
  488. }
  489. }
  490. return [
  491. truthy,
  492. falsy
  493. ];
  494. }
  495. function updateHistoryStates(hist, stateValue) {
  496. return mapValues(hist.states, function(subHist, key) {
  497. if (!subHist) {
  498. return void 0;
  499. }
  500. var subStateValue = (isString(stateValue) ? void 0 : stateValue[key]) || (subHist ? subHist.current : void 0);
  501. if (!subStateValue) {
  502. return void 0;
  503. }
  504. return {
  505. current: subStateValue,
  506. states: updateHistoryStates(subHist, subStateValue)
  507. };
  508. });
  509. }
  510. function updateHistoryValue(hist, stateValue) {
  511. return {
  512. current: stateValue,
  513. states: updateHistoryStates(hist, stateValue)
  514. };
  515. }
  516. function updateContext(context, _event, assignActions, state) {
  517. if (!IS_PRODUCTION) {
  518. warn(!!context, "Attempting to update undefined context");
  519. }
  520. var updatedContext = context ? assignActions.reduce(function(acc, assignAction) {
  521. var e_7, _a2;
  522. var assignment = assignAction.assignment;
  523. var meta = {
  524. state,
  525. action: assignAction,
  526. _event
  527. };
  528. var partialUpdate = {};
  529. if (isFunction(assignment)) {
  530. partialUpdate = assignment(acc, _event.data, meta);
  531. } else {
  532. try {
  533. for(var _b = __values(Object.keys(assignment)), _c = _b.next(); !_c.done; _c = _b.next()){
  534. var key = _c.value;
  535. var propAssignment = assignment[key];
  536. partialUpdate[key] = isFunction(propAssignment) ? propAssignment(acc, _event.data, meta) : propAssignment;
  537. }
  538. } catch (e_7_1) {
  539. e_7 = {
  540. error: e_7_1
  541. };
  542. } finally{
  543. try {
  544. if (_c && !_c.done && (_a2 = _b.return)) _a2.call(_b);
  545. } finally{
  546. if (e_7) throw e_7.error;
  547. }
  548. }
  549. }
  550. return Object.assign({}, acc, partialUpdate);
  551. }, context) : context;
  552. return updatedContext;
  553. }
  554. var warn = function() {};
  555. if (!IS_PRODUCTION) {
  556. warn = function(condition, message) {
  557. var error3 = condition instanceof Error ? condition : void 0;
  558. if (!error3 && condition) {
  559. return;
  560. }
  561. if (console !== void 0) {
  562. var args = [
  563. "Warning: ".concat(message)
  564. ];
  565. if (error3) {
  566. args.push(error3);
  567. }
  568. console.warn.apply(console, args);
  569. }
  570. };
  571. }
  572. function isArray(value) {
  573. return Array.isArray(value);
  574. }
  575. function isFunction(value) {
  576. return typeof value === "function";
  577. }
  578. function isString(value) {
  579. return typeof value === "string";
  580. }
  581. function toGuard(condition, guardMap) {
  582. if (!condition) {
  583. return void 0;
  584. }
  585. if (isString(condition)) {
  586. return {
  587. type: DEFAULT_GUARD_TYPE,
  588. name: condition,
  589. predicate: guardMap ? guardMap[condition] : void 0
  590. };
  591. }
  592. if (isFunction(condition)) {
  593. return {
  594. type: DEFAULT_GUARD_TYPE,
  595. name: condition.name,
  596. predicate: condition
  597. };
  598. }
  599. return condition;
  600. }
  601. function isObservable(value) {
  602. try {
  603. return "subscribe" in value && isFunction(value.subscribe);
  604. } catch (e) {
  605. return false;
  606. }
  607. }
  608. var symbolObservable = function() {
  609. return typeof Symbol === "function" && Symbol.observable || "@@observable";
  610. }();
  611. var interopSymbols = (_a = {}, _a[symbolObservable] = function() {
  612. return this;
  613. }, _a[Symbol.observable] = function() {
  614. return this;
  615. }, _a);
  616. function isMachine(value) {
  617. return !!value && "__xstatenode" in value;
  618. }
  619. function isActor(value) {
  620. return !!value && typeof value.send === "function";
  621. }
  622. var uniqueId = function() {
  623. var currentId = 0;
  624. return function() {
  625. currentId++;
  626. return currentId.toString(16);
  627. };
  628. }();
  629. function toEventObject(event2, payload) {
  630. if (isString(event2) || typeof event2 === "number") {
  631. return __assign({
  632. type: event2
  633. }, payload);
  634. }
  635. return event2;
  636. }
  637. function toSCXMLEvent(event2, scxmlEvent) {
  638. if (!isString(event2) && "$$type" in event2 && event2.$$type === "scxml") {
  639. return event2;
  640. }
  641. var eventObject = toEventObject(event2);
  642. return __assign({
  643. name: eventObject.type,
  644. data: eventObject,
  645. $$type: "scxml",
  646. type: "external"
  647. }, scxmlEvent);
  648. }
  649. function toTransitionConfigArray(event2, configLike) {
  650. var transitions = toArrayStrict(configLike).map(function(transitionLike) {
  651. if (typeof transitionLike === "undefined" || typeof transitionLike === "string" || isMachine(transitionLike)) {
  652. return {
  653. target: transitionLike,
  654. event: event2
  655. };
  656. }
  657. return __assign(__assign({}, transitionLike), {
  658. event: event2
  659. });
  660. });
  661. return transitions;
  662. }
  663. function normalizeTarget(target) {
  664. if (target === void 0 || target === TARGETLESS_KEY) {
  665. return void 0;
  666. }
  667. return toArray(target);
  668. }
  669. function reportUnhandledExceptionOnInvocation(originalError, currentError, id) {
  670. if (!IS_PRODUCTION) {
  671. var originalStackTrace = originalError.stack ? " Stacktrace was '".concat(originalError.stack, "'") : "";
  672. if (originalError === currentError) {
  673. console.error("Missing onError handler for invocation '".concat(id, "', error was '").concat(originalError, "'.").concat(originalStackTrace));
  674. } else {
  675. var stackTrace = currentError.stack ? " Stacktrace was '".concat(currentError.stack, "'") : "";
  676. console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(id, "'. ") + "Original error: '".concat(originalError, "'. ").concat(originalStackTrace, " Current error is '").concat(currentError, "'.").concat(stackTrace));
  677. }
  678. }
  679. }
  680. function evaluateGuard(machine, guard, context, _event, state) {
  681. var guards = machine.options.guards;
  682. var guardMeta = {
  683. state,
  684. cond: guard,
  685. _event
  686. };
  687. if (guard.type === DEFAULT_GUARD_TYPE) {
  688. return ((guards === null || guards === void 0 ? void 0 : guards[guard.name]) || guard.predicate)(context, _event.data, guardMeta);
  689. }
  690. var condFn = guards === null || guards === void 0 ? void 0 : guards[guard.type];
  691. if (!condFn) {
  692. throw new Error("Guard '".concat(guard.type, "' is not implemented on machine '").concat(machine.id, "'."));
  693. }
  694. return condFn(context, _event.data, guardMeta);
  695. }
  696. function toInvokeSource(src) {
  697. if (typeof src === "string") {
  698. return {
  699. type: src
  700. };
  701. }
  702. return src;
  703. }
  704. function toObserver(nextHandler, errorHandler, completionHandler) {
  705. var noop = function() {};
  706. var isObserver = typeof nextHandler === "object";
  707. var self2 = isObserver ? nextHandler : null;
  708. return {
  709. next: ((isObserver ? nextHandler.next : nextHandler) || noop).bind(self2),
  710. error: ((isObserver ? nextHandler.error : errorHandler) || noop).bind(self2),
  711. complete: ((isObserver ? nextHandler.complete : completionHandler) || noop).bind(self2)
  712. };
  713. }
  714. function createInvokeId(stateNodeId, index) {
  715. return "".concat(stateNodeId, ":invocation[").concat(index, "]");
  716. }
  717. function isRaisableAction(action) {
  718. return (action.type === raise || action.type === send && action.to === SpecialTargets.Internal) && typeof action.delay !== "number";
  719. }
  720. // node_modules/xstate/es/actions.js
  721. var initEvent = toSCXMLEvent({
  722. type: init
  723. });
  724. function getActionFunction(actionType, actionFunctionMap) {
  725. return actionFunctionMap ? actionFunctionMap[actionType] || void 0 : void 0;
  726. }
  727. function toActionObject(action, actionFunctionMap) {
  728. var actionObject;
  729. if (isString(action) || typeof action === "number") {
  730. var exec = getActionFunction(action, actionFunctionMap);
  731. if (isFunction(exec)) {
  732. actionObject = {
  733. type: action,
  734. exec
  735. };
  736. } else if (exec) {
  737. actionObject = exec;
  738. } else {
  739. actionObject = {
  740. type: action,
  741. exec: void 0
  742. };
  743. }
  744. } else if (isFunction(action)) {
  745. actionObject = {
  746. type: action.name || action.toString(),
  747. exec: action
  748. };
  749. } else {
  750. var exec = getActionFunction(action.type, actionFunctionMap);
  751. if (isFunction(exec)) {
  752. actionObject = __assign(__assign({}, action), {
  753. exec
  754. });
  755. } else if (exec) {
  756. var actionType = exec.type || action.type;
  757. actionObject = __assign(__assign(__assign({}, exec), action), {
  758. type: actionType
  759. });
  760. } else {
  761. actionObject = action;
  762. }
  763. }
  764. return actionObject;
  765. }
  766. var toActionObjects = function(action, actionFunctionMap) {
  767. if (!action) {
  768. return [];
  769. }
  770. var actions = isArray(action) ? action : [
  771. action
  772. ];
  773. return actions.map(function(subAction) {
  774. return toActionObject(subAction, actionFunctionMap);
  775. });
  776. };
  777. function toActivityDefinition(action) {
  778. var actionObject = toActionObject(action);
  779. return __assign(__assign({
  780. id: isString(action) ? action : actionObject.id
  781. }, actionObject), {
  782. type: actionObject.type
  783. });
  784. }
  785. function raise2(event2, options) {
  786. return {
  787. type: raise,
  788. event: typeof event2 === "function" ? event2 : toEventObject(event2),
  789. delay: options ? options.delay : void 0,
  790. id: options === null || options === void 0 ? void 0 : options.id
  791. };
  792. }
  793. function resolveRaise(action, ctx, _event, delaysMap) {
  794. var meta = {
  795. _event
  796. };
  797. var resolvedEvent = toSCXMLEvent(isFunction(action.event) ? action.event(ctx, _event.data, meta) : action.event);
  798. var resolvedDelay;
  799. if (isString(action.delay)) {
  800. var configDelay = delaysMap && delaysMap[action.delay];
  801. resolvedDelay = isFunction(configDelay) ? configDelay(ctx, _event.data, meta) : configDelay;
  802. } else {
  803. resolvedDelay = isFunction(action.delay) ? action.delay(ctx, _event.data, meta) : action.delay;
  804. }
  805. return __assign(__assign({}, action), {
  806. type: raise,
  807. _event: resolvedEvent,
  808. delay: resolvedDelay
  809. });
  810. }
  811. function send2(event2, options) {
  812. return {
  813. to: options ? options.to : void 0,
  814. type: send,
  815. event: isFunction(event2) ? event2 : toEventObject(event2),
  816. delay: options ? options.delay : void 0,
  817. id: options && options.id !== void 0 ? options.id : isFunction(event2) ? event2.name : getEventType(event2)
  818. };
  819. }
  820. function resolveSend(action, ctx, _event, delaysMap) {
  821. var meta = {
  822. _event
  823. };
  824. var resolvedEvent = toSCXMLEvent(isFunction(action.event) ? action.event(ctx, _event.data, meta) : action.event);
  825. var resolvedDelay;
  826. if (isString(action.delay)) {
  827. var configDelay = delaysMap && delaysMap[action.delay];
  828. resolvedDelay = isFunction(configDelay) ? configDelay(ctx, _event.data, meta) : configDelay;
  829. } else {
  830. resolvedDelay = isFunction(action.delay) ? action.delay(ctx, _event.data, meta) : action.delay;
  831. }
  832. var resolvedTarget = isFunction(action.to) ? action.to(ctx, _event.data, meta) : action.to;
  833. return __assign(__assign({}, action), {
  834. to: resolvedTarget,
  835. _event: resolvedEvent,
  836. event: resolvedEvent.data,
  837. delay: resolvedDelay
  838. });
  839. }
  840. function sendParent(event2, options) {
  841. return send2(event2, __assign(__assign({}, options), {
  842. to: SpecialTargets.Parent
  843. }));
  844. }
  845. function sendTo(actor, event2, options) {
  846. return send2(event2, __assign(__assign({}, options), {
  847. to: actor
  848. }));
  849. }
  850. function sendUpdate() {
  851. return sendParent(update);
  852. }
  853. function respond(event2, options) {
  854. return send2(event2, __assign(__assign({}, options), {
  855. to: function(_, __, _a2) {
  856. var _event = _a2._event;
  857. return _event.origin;
  858. }
  859. }));
  860. }
  861. var defaultLogExpr = function(context, event2) {
  862. return {
  863. context,
  864. event: event2
  865. };
  866. };
  867. function log2(expr, label) {
  868. if (expr === void 0) {
  869. expr = defaultLogExpr;
  870. }
  871. return {
  872. type: log,
  873. label,
  874. expr
  875. };
  876. }
  877. var resolveLog = function(action, ctx, _event) {
  878. return __assign(__assign({}, action), {
  879. value: isString(action.expr) ? action.expr : action.expr(ctx, _event.data, {
  880. _event
  881. })
  882. });
  883. };
  884. var cancel2 = function(sendId) {
  885. return {
  886. type: cancel,
  887. sendId
  888. };
  889. };
  890. function start2(activity) {
  891. var activityDef = toActivityDefinition(activity);
  892. return {
  893. type: ActionTypes.Start,
  894. activity: activityDef,
  895. exec: void 0
  896. };
  897. }
  898. function stop2(actorRef) {
  899. var activity = isFunction(actorRef) ? actorRef : toActivityDefinition(actorRef);
  900. return {
  901. type: ActionTypes.Stop,
  902. activity,
  903. exec: void 0
  904. };
  905. }
  906. function resolveStop(action, context, _event) {
  907. var actorRefOrString = isFunction(action.activity) ? action.activity(context, _event.data) : action.activity;
  908. var resolvedActorRef = typeof actorRefOrString === "string" ? {
  909. id: actorRefOrString
  910. } : actorRefOrString;
  911. var actionObject = {
  912. type: ActionTypes.Stop,
  913. activity: resolvedActorRef
  914. };
  915. return actionObject;
  916. }
  917. var assign2 = function(assignment) {
  918. return {
  919. type: assign,
  920. assignment
  921. };
  922. };
  923. function isActionObject(action) {
  924. return typeof action === "object" && "type" in action;
  925. }
  926. function after2(delayRef, id) {
  927. var idSuffix = id ? "#".concat(id) : "";
  928. return "".concat(ActionTypes.After, "(").concat(delayRef, ")").concat(idSuffix);
  929. }
  930. function done(id, data) {
  931. var type = "".concat(ActionTypes.DoneState, ".").concat(id);
  932. var eventObject = {
  933. type,
  934. data
  935. };
  936. eventObject.toString = function() {
  937. return type;
  938. };
  939. return eventObject;
  940. }
  941. function doneInvoke(id, data) {
  942. var type = "".concat(ActionTypes.DoneInvoke, ".").concat(id);
  943. var eventObject = {
  944. type,
  945. data
  946. };
  947. eventObject.toString = function() {
  948. return type;
  949. };
  950. return eventObject;
  951. }
  952. function error2(id, data) {
  953. var type = "".concat(ActionTypes.ErrorPlatform, ".").concat(id);
  954. var eventObject = {
  955. type,
  956. data
  957. };
  958. eventObject.toString = function() {
  959. return type;
  960. };
  961. return eventObject;
  962. }
  963. function pure2(getActions) {
  964. return {
  965. type: ActionTypes.Pure,
  966. get: getActions
  967. };
  968. }
  969. function forwardTo(target, options) {
  970. if (!IS_PRODUCTION && (!target || typeof target === "function")) {
  971. var originalTarget_1 = target;
  972. target = function() {
  973. var args = [];
  974. for(var _i = 0; _i < arguments.length; _i++){
  975. args[_i] = arguments[_i];
  976. }
  977. var resolvedTarget = typeof originalTarget_1 === "function" ? originalTarget_1.apply(void 0, __spreadArray([], __read(args), false)) : originalTarget_1;
  978. if (!resolvedTarget) {
  979. throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender.");
  980. }
  981. return resolvedTarget;
  982. };
  983. }
  984. return send2(function(_, event2) {
  985. return event2;
  986. }, __assign(__assign({}, options), {
  987. to: target
  988. }));
  989. }
  990. function escalate(errorData, options) {
  991. return sendParent(function(context, event2, meta) {
  992. return {
  993. type: error,
  994. data: isFunction(errorData) ? errorData(context, event2, meta) : errorData
  995. };
  996. }, __assign(__assign({}, options), {
  997. to: SpecialTargets.Parent
  998. }));
  999. }
  1000. function choose2(conds) {
  1001. return {
  1002. type: ActionTypes.Choose,
  1003. conds
  1004. };
  1005. }
  1006. var pluckAssigns = function(actionBlocks) {
  1007. var e_1, _a2;
  1008. var assignActions = [];
  1009. try {
  1010. for(var actionBlocks_1 = __values(actionBlocks), actionBlocks_1_1 = actionBlocks_1.next(); !actionBlocks_1_1.done; actionBlocks_1_1 = actionBlocks_1.next()){
  1011. var block = actionBlocks_1_1.value;
  1012. var i = 0;
  1013. while(i < block.actions.length){
  1014. if (block.actions[i].type === assign) {
  1015. assignActions.push(block.actions[i]);
  1016. block.actions.splice(i, 1);
  1017. continue;
  1018. }
  1019. i++;
  1020. }
  1021. }
  1022. } catch (e_1_1) {
  1023. e_1 = {
  1024. error: e_1_1
  1025. };
  1026. } finally{
  1027. try {
  1028. if (actionBlocks_1_1 && !actionBlocks_1_1.done && (_a2 = actionBlocks_1.return)) _a2.call(actionBlocks_1);
  1029. } finally{
  1030. if (e_1) throw e_1.error;
  1031. }
  1032. }
  1033. return assignActions;
  1034. };
  1035. function resolveActions(machine, currentState, currentContext, _event, actionBlocks, predictableExec, preserveActionOrder) {
  1036. if (preserveActionOrder === void 0) {
  1037. preserveActionOrder = false;
  1038. }
  1039. var assignActions = preserveActionOrder ? [] : pluckAssigns(actionBlocks);
  1040. var updatedContext = assignActions.length ? updateContext(currentContext, _event, assignActions, currentState) : currentContext;
  1041. var preservedContexts = preserveActionOrder ? [
  1042. currentContext
  1043. ] : void 0;
  1044. var deferredToBlockEnd = [];
  1045. function handleAction(blockType, actionObject) {
  1046. var _a2;
  1047. switch(actionObject.type){
  1048. case raise:
  1049. {
  1050. var raisedAction = resolveRaise(actionObject, updatedContext, _event, machine.options.delays);
  1051. if (predictableExec && typeof raisedAction.delay === "number") {
  1052. predictableExec(raisedAction, updatedContext, _event);
  1053. }
  1054. return raisedAction;
  1055. }
  1056. case send:
  1057. var sendAction = resolveSend(actionObject, updatedContext, _event, machine.options.delays);
  1058. if (!IS_PRODUCTION) {
  1059. var configuredDelay = actionObject.delay;
  1060. warn(!isString(configuredDelay) || typeof sendAction.delay === "number", "No delay reference for delay expression '".concat(configuredDelay, "' was found on machine '").concat(machine.id, "'"));
  1061. }
  1062. if (predictableExec && sendAction.to !== SpecialTargets.Internal) {
  1063. if (blockType === "entry") {
  1064. deferredToBlockEnd.push(sendAction);
  1065. } else {
  1066. predictableExec(sendAction, updatedContext, _event);
  1067. }
  1068. }
  1069. return sendAction;
  1070. case log:
  1071. {
  1072. var resolved = resolveLog(actionObject, updatedContext, _event);
  1073. predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(resolved, updatedContext, _event);
  1074. return resolved;
  1075. }
  1076. case choose:
  1077. {
  1078. var chooseAction = actionObject;
  1079. var matchedActions = (_a2 = chooseAction.conds.find(function(condition) {
  1080. var guard = toGuard(condition.cond, machine.options.guards);
  1081. return !guard || evaluateGuard(machine, guard, updatedContext, _event, !predictableExec ? currentState : void 0);
  1082. })) === null || _a2 === void 0 ? void 0 : _a2.actions;
  1083. if (!matchedActions) {
  1084. return [];
  1085. }
  1086. var _b = __read(resolveActions(machine, currentState, updatedContext, _event, [
  1087. {
  1088. type: blockType,
  1089. actions: toActionObjects(toArray(matchedActions), machine.options.actions)
  1090. }
  1091. ], predictableExec, preserveActionOrder), 2), resolvedActionsFromChoose = _b[0], resolvedContextFromChoose = _b[1];
  1092. updatedContext = resolvedContextFromChoose;
  1093. preservedContexts === null || preservedContexts === void 0 ? void 0 : preservedContexts.push(updatedContext);
  1094. return resolvedActionsFromChoose;
  1095. }
  1096. case pure:
  1097. {
  1098. var matchedActions = actionObject.get(updatedContext, _event.data);
  1099. if (!matchedActions) {
  1100. return [];
  1101. }
  1102. var _c = __read(resolveActions(machine, currentState, updatedContext, _event, [
  1103. {
  1104. type: blockType,
  1105. actions: toActionObjects(toArray(matchedActions), machine.options.actions)
  1106. }
  1107. ], predictableExec, preserveActionOrder), 2), resolvedActionsFromPure = _c[0], resolvedContext = _c[1];
  1108. updatedContext = resolvedContext;
  1109. preservedContexts === null || preservedContexts === void 0 ? void 0 : preservedContexts.push(updatedContext);
  1110. return resolvedActionsFromPure;
  1111. }
  1112. case stop:
  1113. {
  1114. var resolved = resolveStop(actionObject, updatedContext, _event);
  1115. predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(resolved, currentContext, _event);
  1116. return resolved;
  1117. }
  1118. case assign:
  1119. {
  1120. updatedContext = updateContext(updatedContext, _event, [
  1121. actionObject
  1122. ], !predictableExec ? currentState : void 0);
  1123. preservedContexts === null || preservedContexts === void 0 ? void 0 : preservedContexts.push(updatedContext);
  1124. break;
  1125. }
  1126. default:
  1127. var resolvedActionObject = toActionObject(actionObject, machine.options.actions);
  1128. var exec_1 = resolvedActionObject.exec;
  1129. if (predictableExec) {
  1130. predictableExec(resolvedActionObject, updatedContext, _event);
  1131. } else if (exec_1 && preservedContexts) {
  1132. var contextIndex_1 = preservedContexts.length - 1;
  1133. var wrapped = __assign(__assign({}, resolvedActionObject), {
  1134. exec: function(_ctx) {
  1135. var args = [];
  1136. for(var _i = 1; _i < arguments.length; _i++){
  1137. args[_i - 1] = arguments[_i];
  1138. }
  1139. exec_1.apply(void 0, __spreadArray([
  1140. preservedContexts[contextIndex_1]
  1141. ], __read(args), false));
  1142. }
  1143. });
  1144. resolvedActionObject = wrapped;
  1145. }
  1146. return resolvedActionObject;
  1147. }
  1148. }
  1149. function processBlock(block) {
  1150. var e_2, _a2;
  1151. var resolvedActions2 = [];
  1152. try {
  1153. for(var _b = __values(block.actions), _c = _b.next(); !_c.done; _c = _b.next()){
  1154. var action = _c.value;
  1155. var resolved = handleAction(block.type, action);
  1156. if (resolved) {
  1157. resolvedActions2 = resolvedActions2.concat(resolved);
  1158. }
  1159. }
  1160. } catch (e_2_1) {
  1161. e_2 = {
  1162. error: e_2_1
  1163. };
  1164. } finally{
  1165. try {
  1166. if (_c && !_c.done && (_a2 = _b.return)) _a2.call(_b);
  1167. } finally{
  1168. if (e_2) throw e_2.error;
  1169. }
  1170. }
  1171. deferredToBlockEnd.forEach(function(action2) {
  1172. predictableExec(action2, updatedContext, _event);
  1173. });
  1174. deferredToBlockEnd.length = 0;
  1175. return resolvedActions2;
  1176. }
  1177. var resolvedActions = flatten(actionBlocks.map(processBlock));
  1178. return [
  1179. resolvedActions,
  1180. updatedContext
  1181. ];
  1182. }
  1183. // node_modules/xstate/es/serviceScope.js
  1184. var serviceStack = [];
  1185. var provide = function(service, fn) {
  1186. serviceStack.push(service);
  1187. var result = fn(service);
  1188. serviceStack.pop();
  1189. return result;
  1190. };
  1191. var consume = function(fn) {
  1192. return fn(serviceStack[serviceStack.length - 1]);
  1193. };
  1194. // node_modules/xstate/es/Actor.js
  1195. function createNullActor(id) {
  1196. var _a2;
  1197. return _a2 = {
  1198. id,
  1199. send: function() {
  1200. return void 0;
  1201. },
  1202. subscribe: function() {
  1203. return {
  1204. unsubscribe: function() {
  1205. return void 0;
  1206. }
  1207. };
  1208. },
  1209. getSnapshot: function() {
  1210. return void 0;
  1211. },
  1212. toJSON: function() {
  1213. return {
  1214. id
  1215. };
  1216. }
  1217. }, _a2[symbolObservable] = function() {
  1218. return this;
  1219. }, _a2;
  1220. }
  1221. function createInvocableActor(invokeDefinition, machine, context, _event) {
  1222. var _a2;
  1223. var invokeSrc = toInvokeSource(invokeDefinition.src);
  1224. var serviceCreator = (_a2 = machine === null || machine === void 0 ? void 0 : machine.options.services) === null || _a2 === void 0 ? void 0 : _a2[invokeSrc.type];
  1225. var resolvedData = invokeDefinition.data ? mapContext(invokeDefinition.data, context, _event) : void 0;
  1226. var tempActor = serviceCreator ? createDeferredActor(serviceCreator, invokeDefinition.id, resolvedData) : createNullActor(invokeDefinition.id);
  1227. tempActor.meta = invokeDefinition;
  1228. return tempActor;
  1229. }
  1230. function createDeferredActor(entity, id, data) {
  1231. var tempActor = createNullActor(id);
  1232. tempActor.deferred = true;
  1233. if (isMachine(entity)) {
  1234. var initialState_1 = tempActor.state = provide(void 0, function() {
  1235. return (data ? entity.withContext(data) : entity).initialState;
  1236. });
  1237. tempActor.getSnapshot = function() {
  1238. return initialState_1;
  1239. };
  1240. }
  1241. return tempActor;
  1242. }
  1243. function isActor2(item) {
  1244. try {
  1245. return typeof item.send === "function";
  1246. } catch (e) {
  1247. return false;
  1248. }
  1249. }
  1250. function isSpawnedActor(item) {
  1251. return isActor2(item) && "id" in item;
  1252. }
  1253. function toActorRef(actorRefLike) {
  1254. var _a2;
  1255. return __assign((_a2 = {
  1256. subscribe: function() {
  1257. return {
  1258. unsubscribe: function() {
  1259. return void 0;
  1260. }
  1261. };
  1262. },
  1263. id: "anonymous",
  1264. getSnapshot: function() {
  1265. return void 0;
  1266. }
  1267. }, _a2[symbolObservable] = function() {
  1268. return this;
  1269. }, _a2), actorRefLike);
  1270. }
  1271. // node_modules/xstate/es/stateUtils.js
  1272. var isLeafNode = function(stateNode) {
  1273. return stateNode.type === "atomic" || stateNode.type === "final";
  1274. };
  1275. function getAllChildren(stateNode) {
  1276. return Object.keys(stateNode.states).map(function(key) {
  1277. return stateNode.states[key];
  1278. });
  1279. }
  1280. function getChildren(stateNode) {
  1281. return getAllChildren(stateNode).filter(function(sn) {
  1282. return sn.type !== "history";
  1283. });
  1284. }
  1285. function getAllStateNodes(stateNode) {
  1286. var stateNodes = [
  1287. stateNode
  1288. ];
  1289. if (isLeafNode(stateNode)) {
  1290. return stateNodes;
  1291. }
  1292. return stateNodes.concat(flatten(getChildren(stateNode).map(getAllStateNodes)));
  1293. }
  1294. function getConfiguration(prevStateNodes, stateNodes) {
  1295. var e_1, _a2, e_2, _b, e_3, _c, e_4, _d;
  1296. var prevConfiguration = new Set(prevStateNodes);
  1297. var prevAdjList = getAdjList(prevConfiguration);
  1298. var configuration = new Set(stateNodes);
  1299. try {
  1300. for(var configuration_1 = __values(configuration), configuration_1_1 = configuration_1.next(); !configuration_1_1.done; configuration_1_1 = configuration_1.next()){
  1301. var s = configuration_1_1.value;
  1302. var m = s.parent;
  1303. while(m && !configuration.has(m)){
  1304. configuration.add(m);
  1305. m = m.parent;
  1306. }
  1307. }
  1308. } catch (e_1_1) {
  1309. e_1 = {
  1310. error: e_1_1
  1311. };
  1312. } finally{
  1313. try {
  1314. if (configuration_1_1 && !configuration_1_1.done && (_a2 = configuration_1.return)) _a2.call(configuration_1);
  1315. } finally{
  1316. if (e_1) throw e_1.error;
  1317. }
  1318. }
  1319. var adjList = getAdjList(configuration);
  1320. try {
  1321. for(var configuration_2 = __values(configuration), configuration_2_1 = configuration_2.next(); !configuration_2_1.done; configuration_2_1 = configuration_2.next()){
  1322. var s = configuration_2_1.value;
  1323. if (s.type === "compound" && (!adjList.get(s) || !adjList.get(s).length)) {
  1324. if (prevAdjList.get(s)) {
  1325. prevAdjList.get(s).forEach(function(sn) {
  1326. return configuration.add(sn);
  1327. });
  1328. } else {
  1329. s.initialStateNodes.forEach(function(sn) {
  1330. return configuration.add(sn);
  1331. });
  1332. }
  1333. } else {
  1334. if (s.type === "parallel") {
  1335. try {
  1336. for(var _e = (e_3 = void 0, __values(getChildren(s))), _f = _e.next(); !_f.done; _f = _e.next()){
  1337. var child = _f.value;
  1338. if (!configuration.has(child)) {
  1339. configuration.add(child);
  1340. if (prevAdjList.get(child)) {
  1341. prevAdjList.get(child).forEach(function(sn) {
  1342. return configuration.add(sn);
  1343. });
  1344. } else {
  1345. child.initialStateNodes.forEach(function(sn) {
  1346. return configuration.add(sn);
  1347. });
  1348. }
  1349. }
  1350. }
  1351. } catch (e_3_1) {
  1352. e_3 = {
  1353. error: e_3_1
  1354. };
  1355. } finally{
  1356. try {
  1357. if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
  1358. } finally{
  1359. if (e_3) throw e_3.error;
  1360. }
  1361. }
  1362. }
  1363. }
  1364. }
  1365. } catch (e_2_1) {
  1366. e_2 = {
  1367. error: e_2_1
  1368. };
  1369. } finally{
  1370. try {
  1371. if (configuration_2_1 && !configuration_2_1.done && (_b = configuration_2.return)) _b.call(configuration_2);
  1372. } finally{
  1373. if (e_2) throw e_2.error;
  1374. }
  1375. }
  1376. try {
  1377. for(var configuration_3 = __values(configuration), configuration_3_1 = configuration_3.next(); !configuration_3_1.done; configuration_3_1 = configuration_3.next()){
  1378. var s = configuration_3_1.value;
  1379. var m = s.parent;
  1380. while(m && !configuration.has(m)){
  1381. configuration.add(m);
  1382. m = m.parent;
  1383. }
  1384. }
  1385. } catch (e_4_1) {
  1386. e_4 = {
  1387. error: e_4_1
  1388. };
  1389. } finally{
  1390. try {
  1391. if (configuration_3_1 && !configuration_3_1.done && (_d = configuration_3.return)) _d.call(configuration_3);
  1392. } finally{
  1393. if (e_4) throw e_4.error;
  1394. }
  1395. }
  1396. return configuration;
  1397. }
  1398. function getValueFromAdj(baseNode, adjList) {
  1399. var childStateNodes = adjList.get(baseNode);
  1400. if (!childStateNodes) {
  1401. return {};
  1402. }
  1403. if (baseNode.type === "compound") {
  1404. var childStateNode = childStateNodes[0];
  1405. if (childStateNode) {
  1406. if (isLeafNode(childStateNode)) {
  1407. return childStateNode.key;
  1408. }
  1409. } else {
  1410. return {};
  1411. }
  1412. }
  1413. var stateValue = {};
  1414. childStateNodes.forEach(function(csn) {
  1415. stateValue[csn.key] = getValueFromAdj(csn, adjList);
  1416. });
  1417. return stateValue;
  1418. }
  1419. function getAdjList(configuration) {
  1420. var e_5, _a2;
  1421. var adjList = /* @__PURE__ */ new Map();
  1422. try {
  1423. for(var configuration_4 = __values(configuration), configuration_4_1 = configuration_4.next(); !configuration_4_1.done; configuration_4_1 = configuration_4.next()){
  1424. var s = configuration_4_1.value;
  1425. if (!adjList.has(s)) {
  1426. adjList.set(s, []);
  1427. }
  1428. if (s.parent) {
  1429. if (!adjList.has(s.parent)) {
  1430. adjList.set(s.parent, []);
  1431. }
  1432. adjList.get(s.parent).push(s);
  1433. }
  1434. }
  1435. } catch (e_5_1) {
  1436. e_5 = {
  1437. error: e_5_1
  1438. };
  1439. } finally{
  1440. try {
  1441. if (configuration_4_1 && !configuration_4_1.done && (_a2 = configuration_4.return)) _a2.call(configuration_4);
  1442. } finally{
  1443. if (e_5) throw e_5.error;
  1444. }
  1445. }
  1446. return adjList;
  1447. }
  1448. function getValue(rootNode, configuration) {
  1449. var config = getConfiguration([
  1450. rootNode
  1451. ], configuration);
  1452. return getValueFromAdj(rootNode, getAdjList(config));
  1453. }
  1454. function has(iterable, item) {
  1455. if (Array.isArray(iterable)) {
  1456. return iterable.some(function(member) {
  1457. return member === item;
  1458. });
  1459. }
  1460. if (iterable instanceof Set) {
  1461. return iterable.has(item);
  1462. }
  1463. return false;
  1464. }
  1465. function nextEvents(configuration) {
  1466. return __spreadArray([], __read(new Set(flatten(__spreadArray([], __read(configuration.map(function(sn) {
  1467. return sn.ownEvents;
  1468. })), false)))), false);
  1469. }
  1470. function isInFinalState(configuration, stateNode) {
  1471. if (stateNode.type === "compound") {
  1472. return getChildren(stateNode).some(function(s) {
  1473. return s.type === "final" && has(configuration, s);
  1474. });
  1475. }
  1476. if (stateNode.type === "parallel") {
  1477. return getChildren(stateNode).every(function(sn) {
  1478. return isInFinalState(configuration, sn);
  1479. });
  1480. }
  1481. return false;
  1482. }
  1483. function getMeta(configuration) {
  1484. if (configuration === void 0) {
  1485. configuration = [];
  1486. }
  1487. return configuration.reduce(function(acc, stateNode) {
  1488. if (stateNode.meta !== void 0) {
  1489. acc[stateNode.id] = stateNode.meta;
  1490. }
  1491. return acc;
  1492. }, {});
  1493. }
  1494. function getTagsFromConfiguration(configuration) {
  1495. return new Set(flatten(configuration.map(function(sn) {
  1496. return sn.tags;
  1497. })));
  1498. }
  1499. // node_modules/xstate/es/State.js
  1500. function stateValuesEqual(a, b) {
  1501. if (a === b) {
  1502. return true;
  1503. }
  1504. if (a === void 0 || b === void 0) {
  1505. return false;
  1506. }
  1507. if (isString(a) || isString(b)) {
  1508. return a === b;
  1509. }
  1510. var aKeys = Object.keys(a);
  1511. var bKeys = Object.keys(b);
  1512. return aKeys.length === bKeys.length && aKeys.every(function(key) {
  1513. return stateValuesEqual(a[key], b[key]);
  1514. });
  1515. }
  1516. function isStateConfig(state) {
  1517. if (typeof state !== "object" || state === null) {
  1518. return false;
  1519. }
  1520. return "value" in state && "_event" in state;
  1521. }
  1522. function bindActionToState(action, state) {
  1523. var exec = action.exec;
  1524. var boundAction = __assign(__assign({}, action), {
  1525. exec: exec !== void 0 ? function() {
  1526. return exec(state.context, state.event, {
  1527. action,
  1528. state,
  1529. _event: state._event
  1530. });
  1531. } : void 0
  1532. });
  1533. return boundAction;
  1534. }
  1535. var State = function() {
  1536. function State2(config) {
  1537. var _this = this;
  1538. var _a2;
  1539. this.actions = [];
  1540. this.activities = EMPTY_ACTIVITY_MAP;
  1541. this.meta = {};
  1542. this.events = [];
  1543. this.value = config.value;
  1544. this.context = config.context;
  1545. this._event = config._event;
  1546. this._sessionid = config._sessionid;
  1547. this.event = this._event.data;
  1548. this.historyValue = config.historyValue;
  1549. this.history = config.history;
  1550. this.actions = config.actions || [];
  1551. this.activities = config.activities || EMPTY_ACTIVITY_MAP;
  1552. this.meta = getMeta(config.configuration);
  1553. this.events = config.events || [];
  1554. this.matches = this.matches.bind(this);
  1555. this.toStrings = this.toStrings.bind(this);
  1556. this.configuration = config.configuration;
  1557. this.transitions = config.transitions;
  1558. this.children = config.children;
  1559. this.done = !!config.done;
  1560. this.tags = (_a2 = Array.isArray(config.tags) ? new Set(config.tags) : config.tags) !== null && _a2 !== void 0 ? _a2 : /* @__PURE__ */ new Set();
  1561. this.machine = config.machine;
  1562. Object.defineProperty(this, "nextEvents", {
  1563. get: function() {
  1564. return nextEvents(_this.configuration);
  1565. }
  1566. });
  1567. }
  1568. State2.from = function(stateValue, context) {
  1569. if (stateValue instanceof State2) {
  1570. if (stateValue.context !== context) {
  1571. return new State2({
  1572. value: stateValue.value,
  1573. context,
  1574. _event: stateValue._event,
  1575. _sessionid: null,
  1576. historyValue: stateValue.historyValue,
  1577. history: stateValue.history,
  1578. actions: [],
  1579. activities: stateValue.activities,
  1580. meta: {},
  1581. events: [],
  1582. configuration: [],
  1583. transitions: [],
  1584. children: {}
  1585. });
  1586. }
  1587. return stateValue;
  1588. }
  1589. var _event = initEvent;
  1590. return new State2({
  1591. value: stateValue,
  1592. context,
  1593. _event,
  1594. _sessionid: null,
  1595. historyValue: void 0,
  1596. history: void 0,
  1597. actions: [],
  1598. activities: void 0,
  1599. meta: void 0,
  1600. events: [],
  1601. configuration: [],
  1602. transitions: [],
  1603. children: {}
  1604. });
  1605. };
  1606. State2.create = function(config) {
  1607. return new State2(config);
  1608. };
  1609. State2.inert = function(stateValue, context) {
  1610. if (stateValue instanceof State2) {
  1611. if (!stateValue.actions.length) {
  1612. return stateValue;
  1613. }
  1614. var _event = initEvent;
  1615. return new State2({
  1616. value: stateValue.value,
  1617. context,
  1618. _event,
  1619. _sessionid: null,
  1620. historyValue: stateValue.historyValue,
  1621. history: stateValue.history,
  1622. activities: stateValue.activities,
  1623. configuration: stateValue.configuration,
  1624. transitions: [],
  1625. children: {}
  1626. });
  1627. }
  1628. return State2.from(stateValue, context);
  1629. };
  1630. State2.prototype.toStrings = function(stateValue, delimiter) {
  1631. var _this = this;
  1632. if (stateValue === void 0) {
  1633. stateValue = this.value;
  1634. }
  1635. if (delimiter === void 0) {
  1636. delimiter = ".";
  1637. }
  1638. if (isString(stateValue)) {
  1639. return [
  1640. stateValue
  1641. ];
  1642. }
  1643. var valueKeys = Object.keys(stateValue);
  1644. return valueKeys.concat.apply(valueKeys, __spreadArray([], __read(valueKeys.map(function(key) {
  1645. return _this.toStrings(stateValue[key], delimiter).map(function(s) {
  1646. return key + delimiter + s;
  1647. });
  1648. })), false));
  1649. };
  1650. State2.prototype.toJSON = function() {
  1651. var _a2 = this;
  1652. _a2.configuration;
  1653. _a2.transitions;
  1654. var tags = _a2.tags;
  1655. _a2.machine;
  1656. var jsonValues = __rest(_a2, [
  1657. "configuration",
  1658. "transitions",
  1659. "tags",
  1660. "machine"
  1661. ]);
  1662. return __assign(__assign({}, jsonValues), {
  1663. tags: Array.from(tags)
  1664. });
  1665. };
  1666. State2.prototype.matches = function(parentStateValue) {
  1667. return matchesState(parentStateValue, this.value);
  1668. };
  1669. State2.prototype.hasTag = function(tag) {
  1670. return this.tags.has(tag);
  1671. };
  1672. State2.prototype.can = function(event2) {
  1673. var _a2;
  1674. if (IS_PRODUCTION) {
  1675. warn(!!this.machine, "state.can(...) used outside of a machine-created State object; this will always return false.");
  1676. }
  1677. var transitionData = (_a2 = this.machine) === null || _a2 === void 0 ? void 0 : _a2.getTransitionData(this, event2);
  1678. return !!(transitionData === null || transitionData === void 0 ? void 0 : transitionData.transitions.length) && transitionData.transitions.some(function(t2) {
  1679. return t2.target !== void 0 || t2.actions.length;
  1680. });
  1681. };
  1682. return State2;
  1683. }();
  1684. // node_modules/xstate/es/scheduler.js
  1685. var defaultOptions = {
  1686. deferEvents: false
  1687. };
  1688. var Scheduler = function() {
  1689. function Scheduler2(options) {
  1690. this.processingEvent = false;
  1691. this.queue = [];
  1692. this.initialized = false;
  1693. this.options = __assign(__assign({}, defaultOptions), options);
  1694. }
  1695. Scheduler2.prototype.initialize = function(callback) {
  1696. this.initialized = true;
  1697. if (callback) {
  1698. if (!this.options.deferEvents) {
  1699. this.schedule(callback);
  1700. return;
  1701. }
  1702. this.process(callback);
  1703. }
  1704. this.flushEvents();
  1705. };
  1706. Scheduler2.prototype.schedule = function(task) {
  1707. if (!this.initialized || this.processingEvent) {
  1708. this.queue.push(task);
  1709. return;
  1710. }
  1711. if (this.queue.length !== 0) {
  1712. throw new Error("Event queue should be empty when it is not processing events");
  1713. }
  1714. this.process(task);
  1715. this.flushEvents();
  1716. };
  1717. Scheduler2.prototype.clear = function() {
  1718. this.queue = [];
  1719. };
  1720. Scheduler2.prototype.flushEvents = function() {
  1721. var nextCallback = this.queue.shift();
  1722. while(nextCallback){
  1723. this.process(nextCallback);
  1724. nextCallback = this.queue.shift();
  1725. }
  1726. };
  1727. Scheduler2.prototype.process = function(callback) {
  1728. this.processingEvent = true;
  1729. try {
  1730. callback();
  1731. } catch (e) {
  1732. this.clear();
  1733. throw e;
  1734. } finally{
  1735. this.processingEvent = false;
  1736. }
  1737. };
  1738. return Scheduler2;
  1739. }();
  1740. // node_modules/xstate/es/registry.js
  1741. var children = /* @__PURE__ */ new Map();
  1742. var sessionIdIndex = 0;
  1743. var registry = {
  1744. bookId: function() {
  1745. return "x:".concat(sessionIdIndex++);
  1746. },
  1747. register: function(id, actor) {
  1748. children.set(id, actor);
  1749. return id;
  1750. },
  1751. get: function(id) {
  1752. return children.get(id);
  1753. },
  1754. free: function(id) {
  1755. children.delete(id);
  1756. }
  1757. };
  1758. // node_modules/xstate/es/devTools.js
  1759. function getGlobal() {
  1760. if (typeof globalThis !== "undefined") {
  1761. return globalThis;
  1762. }
  1763. if (typeof self !== "undefined") {
  1764. return self;
  1765. }
  1766. if (typeof window !== "undefined") {
  1767. return window;
  1768. }
  1769. if (typeof __webpack_require__.g !== "undefined") {
  1770. return __webpack_require__.g;
  1771. }
  1772. if (!IS_PRODUCTION) {
  1773. console.warn("XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues");
  1774. }
  1775. }
  1776. function getDevTools() {
  1777. var global2 = getGlobal();
  1778. if (global2 && "__xstate__" in global2) {
  1779. return global2.__xstate__;
  1780. }
  1781. return void 0;
  1782. }
  1783. function registerService(service) {
  1784. if (!getGlobal()) {
  1785. return;
  1786. }
  1787. var devTools = getDevTools();
  1788. if (devTools) {
  1789. devTools.register(service);
  1790. }
  1791. }
  1792. // node_modules/xstate/es/behaviors.js
  1793. function spawnBehavior(behavior, options) {
  1794. if (options === void 0) {
  1795. options = {};
  1796. }
  1797. var state = behavior.initialState;
  1798. var observers = /* @__PURE__ */ new Set();
  1799. var mailbox = [];
  1800. var flushing = false;
  1801. var flush = function() {
  1802. if (flushing) {
  1803. return;
  1804. }
  1805. flushing = true;
  1806. while(mailbox.length > 0){
  1807. var event_1 = mailbox.shift();
  1808. state = behavior.transition(state, event_1, actorCtx);
  1809. observers.forEach(function(observer) {
  1810. return observer.next(state);
  1811. });
  1812. }
  1813. flushing = false;
  1814. };
  1815. var actor = toActorRef({
  1816. id: options.id,
  1817. send: function(event2) {
  1818. mailbox.push(event2);
  1819. flush();
  1820. },
  1821. getSnapshot: function() {
  1822. return state;
  1823. },
  1824. subscribe: function(next, handleError, complete) {
  1825. var observer = toObserver(next, handleError, complete);
  1826. observers.add(observer);
  1827. observer.next(state);
  1828. return {
  1829. unsubscribe: function() {
  1830. observers.delete(observer);
  1831. }
  1832. };
  1833. }
  1834. });
  1835. var actorCtx = {
  1836. parent: options.parent,
  1837. self: actor,
  1838. id: options.id || "anonymous",
  1839. observers
  1840. };
  1841. state = behavior.start ? behavior.start(actorCtx) : state;
  1842. return actor;
  1843. }
  1844. // node_modules/xstate/es/interpreter.js
  1845. var DEFAULT_SPAWN_OPTIONS = {
  1846. sync: false,
  1847. autoForward: false
  1848. };
  1849. var InterpreterStatus;
  1850. (function(InterpreterStatus2) {
  1851. InterpreterStatus2[InterpreterStatus2["NotStarted"] = 0] = "NotStarted";
  1852. InterpreterStatus2[InterpreterStatus2["Running"] = 1] = "Running";
  1853. InterpreterStatus2[InterpreterStatus2["Stopped"] = 2] = "Stopped";
  1854. })(InterpreterStatus || (InterpreterStatus = {}));
  1855. var Interpreter = function() {
  1856. function Interpreter2(machine, options) {
  1857. if (options === void 0) {
  1858. options = Interpreter2.defaultOptions;
  1859. }
  1860. var _this = this;
  1861. this.machine = machine;
  1862. this.delayedEventsMap = {};
  1863. this.listeners = /* @__PURE__ */ new Set();
  1864. this.contextListeners = /* @__PURE__ */ new Set();
  1865. this.stopListeners = /* @__PURE__ */ new Set();
  1866. this.doneListeners = /* @__PURE__ */ new Set();
  1867. this.eventListeners = /* @__PURE__ */ new Set();
  1868. this.sendListeners = /* @__PURE__ */ new Set();
  1869. this.initialized = false;
  1870. this.status = InterpreterStatus.NotStarted;
  1871. this.children = /* @__PURE__ */ new Map();
  1872. this.forwardTo = /* @__PURE__ */ new Set();
  1873. this._outgoingQueue = [];
  1874. this.init = this.start;
  1875. this.send = function(event2, payload) {
  1876. if (isArray(event2)) {
  1877. _this.batch(event2);
  1878. return _this.state;
  1879. }
  1880. var _event = toSCXMLEvent(toEventObject(event2, payload));
  1881. if (_this.status === InterpreterStatus.Stopped) {
  1882. if (!IS_PRODUCTION) {
  1883. warn(false, 'Event "'.concat(_event.name, '" was sent to stopped service "').concat(_this.machine.id, '". This service has already reached its final state, and will not transition.\nEvent: ').concat(JSON.stringify(_event.data)));
  1884. }
  1885. return _this.state;
  1886. }
  1887. if (_this.status !== InterpreterStatus.Running && !_this.options.deferEvents) {
  1888. throw new Error('Event "'.concat(_event.name, '" was sent to uninitialized service "').concat(_this.machine.id, '". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: ').concat(JSON.stringify(_event.data)));
  1889. }
  1890. _this.scheduler.schedule(function() {
  1891. _this.forward(_event);
  1892. var nextState = _this._nextState(_event);
  1893. _this.update(nextState, _event);
  1894. });
  1895. return _this._state;
  1896. };
  1897. this.sendTo = function(event2, to, immediate) {
  1898. var isParent = _this.parent && (to === SpecialTargets.Parent || _this.parent.id === to);
  1899. var target = isParent ? _this.parent : isString(to) ? to === SpecialTargets.Internal ? _this : _this.children.get(to) || registry.get(to) : isActor(to) ? to : void 0;
  1900. if (!target) {
  1901. if (!isParent) {
  1902. throw new Error("Unable to send event to child '".concat(to, "' from service '").concat(_this.id, "'."));
  1903. }
  1904. if (!IS_PRODUCTION) {
  1905. warn(false, "Service '".concat(_this.id, "' has no parent: unable to send event ").concat(event2.type));
  1906. }
  1907. return;
  1908. }
  1909. if ("machine" in target) {
  1910. if (_this.status !== InterpreterStatus.Stopped || _this.parent !== target || _this.state.done) {
  1911. var scxmlEvent = __assign(__assign({}, event2), {
  1912. name: event2.name === error ? "".concat(error2(_this.id)) : event2.name,
  1913. origin: _this.sessionId
  1914. });
  1915. if (!immediate && _this.machine.config.predictableActionArguments) {
  1916. _this._outgoingQueue.push([
  1917. target,
  1918. scxmlEvent
  1919. ]);
  1920. } else {
  1921. target.send(scxmlEvent);
  1922. }
  1923. }
  1924. } else {
  1925. if (!immediate && _this.machine.config.predictableActionArguments) {
  1926. _this._outgoingQueue.push([
  1927. target,
  1928. event2.data
  1929. ]);
  1930. } else {
  1931. target.send(event2.data);
  1932. }
  1933. }
  1934. };
  1935. this._exec = function(action, context, _event, actionFunctionMap) {
  1936. if (actionFunctionMap === void 0) {
  1937. actionFunctionMap = _this.machine.options.actions;
  1938. }
  1939. var actionOrExec = action.exec || getActionFunction(action.type, actionFunctionMap);
  1940. var exec = isFunction(actionOrExec) ? actionOrExec : actionOrExec ? actionOrExec.exec : action.exec;
  1941. if (exec) {
  1942. try {
  1943. return exec(context, _event.data, !_this.machine.config.predictableActionArguments ? {
  1944. action,
  1945. state: _this.state,
  1946. _event
  1947. } : {
  1948. action,
  1949. _event
  1950. });
  1951. } catch (err) {
  1952. if (_this.parent) {
  1953. _this.parent.send({
  1954. type: "xstate.error",
  1955. data: err
  1956. });
  1957. }
  1958. throw err;
  1959. }
  1960. }
  1961. switch(action.type){
  1962. case raise:
  1963. {
  1964. var sendAction_1 = action;
  1965. _this.defer(sendAction_1);
  1966. break;
  1967. }
  1968. case send:
  1969. var sendAction = action;
  1970. if (typeof sendAction.delay === "number") {
  1971. _this.defer(sendAction);
  1972. return;
  1973. } else {
  1974. if (sendAction.to) {
  1975. _this.sendTo(sendAction._event, sendAction.to, _event === initEvent);
  1976. } else {
  1977. _this.send(sendAction._event);
  1978. }
  1979. }
  1980. break;
  1981. case cancel:
  1982. _this.cancel(action.sendId);
  1983. break;
  1984. case start:
  1985. {
  1986. if (_this.status !== InterpreterStatus.Running) {
  1987. return;
  1988. }
  1989. var activity = action.activity;
  1990. if (!_this.machine.config.predictableActionArguments && !_this.state.activities[activity.id || activity.type]) {
  1991. break;
  1992. }
  1993. if (activity.type === ActionTypes.Invoke) {
  1994. var invokeSource = toInvokeSource(activity.src);
  1995. var serviceCreator = _this.machine.options.services ? _this.machine.options.services[invokeSource.type] : void 0;
  1996. var id2 = activity.id, data = activity.data;
  1997. if (!IS_PRODUCTION) {
  1998. warn(!("forward" in activity), "`forward` property is deprecated (found in invocation of '".concat(activity.src, "' in in machine '").concat(_this.machine.id, "'). ") + "Please use `autoForward` instead.");
  1999. }
  2000. var autoForward = "autoForward" in activity ? activity.autoForward : !!activity.forward;
  2001. if (!serviceCreator) {
  2002. if (!IS_PRODUCTION) {
  2003. warn(false, "No service found for invocation '".concat(activity.src, "' in machine '").concat(_this.machine.id, "'."));
  2004. }
  2005. return;
  2006. }
  2007. var resolvedData = data ? mapContext(data, context, _event) : void 0;
  2008. if (typeof serviceCreator === "string") {
  2009. return;
  2010. }
  2011. var source = isFunction(serviceCreator) ? serviceCreator(context, _event.data, {
  2012. data: resolvedData,
  2013. src: invokeSource,
  2014. meta: activity.meta
  2015. }) : serviceCreator;
  2016. if (!source) {
  2017. return;
  2018. }
  2019. var options2 = void 0;
  2020. if (isMachine(source)) {
  2021. source = resolvedData ? source.withContext(resolvedData) : source;
  2022. options2 = {
  2023. autoForward
  2024. };
  2025. }
  2026. _this.spawn(source, id2, options2);
  2027. } else {
  2028. _this.spawnActivity(activity);
  2029. }
  2030. break;
  2031. }
  2032. case stop:
  2033. {
  2034. _this.stopChild(action.activity.id);
  2035. break;
  2036. }
  2037. case log:
  2038. var _a2 = action, label = _a2.label, value = _a2.value;
  2039. if (label) {
  2040. _this.logger(label, value);
  2041. } else {
  2042. _this.logger(value);
  2043. }
  2044. break;
  2045. default:
  2046. if (!IS_PRODUCTION) {
  2047. warn(false, "No implementation found for action type '".concat(action.type, "'"));
  2048. }
  2049. break;
  2050. }
  2051. };
  2052. var resolvedOptions = __assign(__assign({}, Interpreter2.defaultOptions), options);
  2053. var clock = resolvedOptions.clock, logger = resolvedOptions.logger, parent = resolvedOptions.parent, id = resolvedOptions.id;
  2054. var resolvedId = id !== void 0 ? id : machine.id;
  2055. this.id = resolvedId;
  2056. this.logger = logger;
  2057. this.clock = clock;
  2058. this.parent = parent;
  2059. this.options = resolvedOptions;
  2060. this.scheduler = new Scheduler({
  2061. deferEvents: this.options.deferEvents
  2062. });
  2063. this.sessionId = registry.bookId();
  2064. }
  2065. Object.defineProperty(Interpreter2.prototype, "initialState", {
  2066. get: function() {
  2067. var _this = this;
  2068. if (this._initialState) {
  2069. return this._initialState;
  2070. }
  2071. return provide(this, function() {
  2072. _this._initialState = _this.machine.initialState;
  2073. return _this._initialState;
  2074. });
  2075. },
  2076. enumerable: false,
  2077. configurable: true
  2078. });
  2079. Object.defineProperty(Interpreter2.prototype, "state", {
  2080. get: function() {
  2081. if (!IS_PRODUCTION) {
  2082. warn(this.status !== InterpreterStatus.NotStarted, "Attempted to read state from uninitialized service '".concat(this.id, "'. Make sure the service is started first."));
  2083. }
  2084. return this._state;
  2085. },
  2086. enumerable: false,
  2087. configurable: true
  2088. });
  2089. Interpreter2.prototype.execute = function(state, actionsConfig) {
  2090. var e_1, _a2;
  2091. try {
  2092. for(var _b = __values(state.actions), _c = _b.next(); !_c.done; _c = _b.next()){
  2093. var action = _c.value;
  2094. this.exec(action, state, actionsConfig);
  2095. }
  2096. } catch (e_1_1) {
  2097. e_1 = {
  2098. error: e_1_1
  2099. };
  2100. } finally{
  2101. try {
  2102. if (_c && !_c.done && (_a2 = _b.return)) _a2.call(_b);
  2103. } finally{
  2104. if (e_1) throw e_1.error;
  2105. }
  2106. }
  2107. };
  2108. Interpreter2.prototype.update = function(state, _event) {
  2109. var e_2, _a2, e_3, _b, e_4, _c, e_5, _d;
  2110. var _this = this;
  2111. state._sessionid = this.sessionId;
  2112. this._state = state;
  2113. if ((!this.machine.config.predictableActionArguments || _event === initEvent) && this.options.execute) {
  2114. this.execute(this.state);
  2115. } else {
  2116. var item = void 0;
  2117. while(item = this._outgoingQueue.shift()){
  2118. item[0].send(item[1]);
  2119. }
  2120. }
  2121. this.children.forEach(function(child) {
  2122. _this.state.children[child.id] = child;
  2123. });
  2124. if (this.devTools) {
  2125. this.devTools.send(_event.data, state);
  2126. }
  2127. if (state.event) {
  2128. try {
  2129. for(var _e = __values(this.eventListeners), _f = _e.next(); !_f.done; _f = _e.next()){
  2130. var listener = _f.value;
  2131. listener(state.event);
  2132. }
  2133. } catch (e_2_1) {
  2134. e_2 = {
  2135. error: e_2_1
  2136. };
  2137. } finally{
  2138. try {
  2139. if (_f && !_f.done && (_a2 = _e.return)) _a2.call(_e);
  2140. } finally{
  2141. if (e_2) throw e_2.error;
  2142. }
  2143. }
  2144. }
  2145. try {
  2146. for(var _g = __values(this.listeners), _h = _g.next(); !_h.done; _h = _g.next()){
  2147. var listener = _h.value;
  2148. listener(state, state.event);
  2149. }
  2150. } catch (e_3_1) {
  2151. e_3 = {
  2152. error: e_3_1
  2153. };
  2154. } finally{
  2155. try {
  2156. if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
  2157. } finally{
  2158. if (e_3) throw e_3.error;
  2159. }
  2160. }
  2161. try {
  2162. for(var _j = __values(this.contextListeners), _k = _j.next(); !_k.done; _k = _j.next()){
  2163. var contextListener = _k.value;
  2164. contextListener(this.state.context, this.state.history ? this.state.history.context : void 0);
  2165. }
  2166. } catch (e_4_1) {
  2167. e_4 = {
  2168. error: e_4_1
  2169. };
  2170. } finally{
  2171. try {
  2172. if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
  2173. } finally{
  2174. if (e_4) throw e_4.error;
  2175. }
  2176. }
  2177. if (this.state.done) {
  2178. var finalChildStateNode = state.configuration.find(function(sn) {
  2179. return sn.type === "final" && sn.parent === _this.machine;
  2180. });
  2181. var doneData = finalChildStateNode && finalChildStateNode.doneData ? mapContext(finalChildStateNode.doneData, state.context, _event) : void 0;
  2182. this._doneEvent = doneInvoke(this.id, doneData);
  2183. try {
  2184. for(var _l = __values(this.doneListeners), _m = _l.next(); !_m.done; _m = _l.next()){
  2185. var listener = _m.value;
  2186. listener(this._doneEvent);
  2187. }
  2188. } catch (e_5_1) {
  2189. e_5 = {
  2190. error: e_5_1
  2191. };
  2192. } finally{
  2193. try {
  2194. if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
  2195. } finally{
  2196. if (e_5) throw e_5.error;
  2197. }
  2198. }
  2199. this._stop();
  2200. this._stopChildren();
  2201. registry.free(this.sessionId);
  2202. }
  2203. };
  2204. Interpreter2.prototype.onTransition = function(listener) {
  2205. this.listeners.add(listener);
  2206. if (this.status === InterpreterStatus.Running) {
  2207. listener(this.state, this.state.event);
  2208. }
  2209. return this;
  2210. };
  2211. Interpreter2.prototype.subscribe = function(nextListenerOrObserver, _, completeListener) {
  2212. var _this = this;
  2213. var observer = toObserver(nextListenerOrObserver, _, completeListener);
  2214. this.listeners.add(observer.next);
  2215. if (this.status !== InterpreterStatus.NotStarted) {
  2216. observer.next(this.state);
  2217. }
  2218. var completeOnce = function() {
  2219. _this.doneListeners.delete(completeOnce);
  2220. _this.stopListeners.delete(completeOnce);
  2221. observer.complete();
  2222. };
  2223. if (this.status === InterpreterStatus.Stopped) {
  2224. observer.complete();
  2225. } else {
  2226. this.onDone(completeOnce);
  2227. this.onStop(completeOnce);
  2228. }
  2229. return {
  2230. unsubscribe: function() {
  2231. _this.listeners.delete(observer.next);
  2232. _this.doneListeners.delete(completeOnce);
  2233. _this.stopListeners.delete(completeOnce);
  2234. }
  2235. };
  2236. };
  2237. Interpreter2.prototype.onEvent = function(listener) {
  2238. this.eventListeners.add(listener);
  2239. return this;
  2240. };
  2241. Interpreter2.prototype.onSend = function(listener) {
  2242. this.sendListeners.add(listener);
  2243. return this;
  2244. };
  2245. Interpreter2.prototype.onChange = function(listener) {
  2246. this.contextListeners.add(listener);
  2247. return this;
  2248. };
  2249. Interpreter2.prototype.onStop = function(listener) {
  2250. this.stopListeners.add(listener);
  2251. return this;
  2252. };
  2253. Interpreter2.prototype.onDone = function(listener) {
  2254. if (this.status === InterpreterStatus.Stopped && this._doneEvent) {
  2255. listener(this._doneEvent);
  2256. } else {
  2257. this.doneListeners.add(listener);
  2258. }
  2259. return this;
  2260. };
  2261. Interpreter2.prototype.off = function(listener) {
  2262. this.listeners.delete(listener);
  2263. this.eventListeners.delete(listener);
  2264. this.sendListeners.delete(listener);
  2265. this.stopListeners.delete(listener);
  2266. this.doneListeners.delete(listener);
  2267. this.contextListeners.delete(listener);
  2268. return this;
  2269. };
  2270. Interpreter2.prototype.start = function(initialState) {
  2271. var _this = this;
  2272. if (this.status === InterpreterStatus.Running) {
  2273. return this;
  2274. }
  2275. this.machine._init();
  2276. registry.register(this.sessionId, this);
  2277. this.initialized = true;
  2278. this.status = InterpreterStatus.Running;
  2279. var resolvedState = initialState === void 0 ? this.initialState : provide(this, function() {
  2280. return isStateConfig(initialState) ? _this.machine.resolveState(initialState) : _this.machine.resolveState(State.from(initialState, _this.machine.context));
  2281. });
  2282. if (this.options.devTools) {
  2283. this.attachDev();
  2284. }
  2285. this.scheduler.initialize(function() {
  2286. _this.update(resolvedState, initEvent);
  2287. });
  2288. return this;
  2289. };
  2290. Interpreter2.prototype._stopChildren = function() {
  2291. this.children.forEach(function(child) {
  2292. if (isFunction(child.stop)) {
  2293. child.stop();
  2294. }
  2295. });
  2296. this.children.clear();
  2297. };
  2298. Interpreter2.prototype._stop = function() {
  2299. var e_6, _a2, e_7, _b, e_8, _c, e_9, _d, e_10, _e;
  2300. try {
  2301. for(var _f = __values(this.listeners), _g = _f.next(); !_g.done; _g = _f.next()){
  2302. var listener = _g.value;
  2303. this.listeners.delete(listener);
  2304. }
  2305. } catch (e_6_1) {
  2306. e_6 = {
  2307. error: e_6_1
  2308. };
  2309. } finally{
  2310. try {
  2311. if (_g && !_g.done && (_a2 = _f.return)) _a2.call(_f);
  2312. } finally{
  2313. if (e_6) throw e_6.error;
  2314. }
  2315. }
  2316. try {
  2317. for(var _h = __values(this.stopListeners), _j = _h.next(); !_j.done; _j = _h.next()){
  2318. var listener = _j.value;
  2319. listener();
  2320. this.stopListeners.delete(listener);
  2321. }
  2322. } catch (e_7_1) {
  2323. e_7 = {
  2324. error: e_7_1
  2325. };
  2326. } finally{
  2327. try {
  2328. if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
  2329. } finally{
  2330. if (e_7) throw e_7.error;
  2331. }
  2332. }
  2333. try {
  2334. for(var _k = __values(this.contextListeners), _l = _k.next(); !_l.done; _l = _k.next()){
  2335. var listener = _l.value;
  2336. this.contextListeners.delete(listener);
  2337. }
  2338. } catch (e_8_1) {
  2339. e_8 = {
  2340. error: e_8_1
  2341. };
  2342. } finally{
  2343. try {
  2344. if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
  2345. } finally{
  2346. if (e_8) throw e_8.error;
  2347. }
  2348. }
  2349. try {
  2350. for(var _m = __values(this.doneListeners), _o = _m.next(); !_o.done; _o = _m.next()){
  2351. var listener = _o.value;
  2352. this.doneListeners.delete(listener);
  2353. }
  2354. } catch (e_9_1) {
  2355. e_9 = {
  2356. error: e_9_1
  2357. };
  2358. } finally{
  2359. try {
  2360. if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
  2361. } finally{
  2362. if (e_9) throw e_9.error;
  2363. }
  2364. }
  2365. if (!this.initialized) {
  2366. return this;
  2367. }
  2368. this.initialized = false;
  2369. this.status = InterpreterStatus.Stopped;
  2370. this._initialState = void 0;
  2371. try {
  2372. for(var _p = __values(Object.keys(this.delayedEventsMap)), _q = _p.next(); !_q.done; _q = _p.next()){
  2373. var key = _q.value;
  2374. this.clock.clearTimeout(this.delayedEventsMap[key]);
  2375. }
  2376. } catch (e_10_1) {
  2377. e_10 = {
  2378. error: e_10_1
  2379. };
  2380. } finally{
  2381. try {
  2382. if (_q && !_q.done && (_e = _p.return)) _e.call(_p);
  2383. } finally{
  2384. if (e_10) throw e_10.error;
  2385. }
  2386. }
  2387. this.scheduler.clear();
  2388. this.scheduler = new Scheduler({
  2389. deferEvents: this.options.deferEvents
  2390. });
  2391. };
  2392. Interpreter2.prototype.stop = function() {
  2393. var _this = this;
  2394. var scheduler = this.scheduler;
  2395. this._stop();
  2396. scheduler.schedule(function() {
  2397. var _event = toSCXMLEvent({
  2398. type: "xstate.stop"
  2399. });
  2400. var nextState = provide(_this, function() {
  2401. var exitActions = flatten(__spreadArray([], __read(_this.state.configuration), false).sort(function(a, b) {
  2402. return b.order - a.order;
  2403. }).map(function(stateNode) {
  2404. return toActionObjects(stateNode.onExit, _this.machine.options.actions);
  2405. }));
  2406. var _a2 = __read(resolveActions(_this.machine, _this.state, _this.state.context, _event, [
  2407. {
  2408. type: "exit",
  2409. actions: exitActions
  2410. }
  2411. ], _this.machine.config.predictableActionArguments ? _this._exec : void 0, _this.machine.config.predictableActionArguments || _this.machine.config.preserveActionOrder), 2), resolvedActions = _a2[0], updatedContext = _a2[1];
  2412. var newState = new State({
  2413. value: _this.state.value,
  2414. context: updatedContext,
  2415. _event,
  2416. _sessionid: _this.sessionId,
  2417. historyValue: void 0,
  2418. history: _this.state,
  2419. actions: resolvedActions.filter(function(action) {
  2420. return !isRaisableAction(action);
  2421. }),
  2422. activities: {},
  2423. events: [],
  2424. configuration: [],
  2425. transitions: [],
  2426. children: {},
  2427. done: _this.state.done,
  2428. tags: _this.state.tags,
  2429. machine: _this.machine
  2430. });
  2431. newState.changed = true;
  2432. return newState;
  2433. });
  2434. _this.update(nextState, _event);
  2435. _this._stopChildren();
  2436. registry.free(_this.sessionId);
  2437. });
  2438. return this;
  2439. };
  2440. Interpreter2.prototype.batch = function(events) {
  2441. var _this = this;
  2442. if (this.status === InterpreterStatus.NotStarted && this.options.deferEvents) {
  2443. if (!IS_PRODUCTION) {
  2444. warn(false, "".concat(events.length, ' event(s) were sent to uninitialized service "').concat(this.machine.id, '" and are deferred. Make sure .start() is called for this service.\nEvent: ').concat(JSON.stringify(event)));
  2445. }
  2446. } else if (this.status !== InterpreterStatus.Running) {
  2447. throw new Error("".concat(events.length, ' event(s) were sent to uninitialized service "').concat(this.machine.id, '". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));
  2448. }
  2449. if (!events.length) {
  2450. return;
  2451. }
  2452. var exec = !!this.machine.config.predictableActionArguments && this._exec;
  2453. this.scheduler.schedule(function() {
  2454. var e_11, _a2;
  2455. var nextState = _this.state;
  2456. var batchChanged = false;
  2457. var batchedActions = [];
  2458. var _loop_1 = function(event_12) {
  2459. var _event = toSCXMLEvent(event_12);
  2460. _this.forward(_event);
  2461. nextState = provide(_this, function() {
  2462. return _this.machine.transition(nextState, _event, void 0, exec || void 0);
  2463. });
  2464. batchedActions.push.apply(batchedActions, __spreadArray([], __read(_this.machine.config.predictableActionArguments ? nextState.actions : nextState.actions.map(function(a) {
  2465. return bindActionToState(a, nextState);
  2466. })), false));
  2467. batchChanged = batchChanged || !!nextState.changed;
  2468. };
  2469. try {
  2470. for(var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()){
  2471. var event_1 = events_1_1.value;
  2472. _loop_1(event_1);
  2473. }
  2474. } catch (e_11_1) {
  2475. e_11 = {
  2476. error: e_11_1
  2477. };
  2478. } finally{
  2479. try {
  2480. if (events_1_1 && !events_1_1.done && (_a2 = events_1.return)) _a2.call(events_1);
  2481. } finally{
  2482. if (e_11) throw e_11.error;
  2483. }
  2484. }
  2485. nextState.changed = batchChanged;
  2486. nextState.actions = batchedActions;
  2487. _this.update(nextState, toSCXMLEvent(events[events.length - 1]));
  2488. });
  2489. };
  2490. Interpreter2.prototype.sender = function(event2) {
  2491. return this.send.bind(this, event2);
  2492. };
  2493. Interpreter2.prototype._nextState = function(event2, exec) {
  2494. var _this = this;
  2495. if (exec === void 0) {
  2496. exec = !!this.machine.config.predictableActionArguments && this._exec;
  2497. }
  2498. var _event = toSCXMLEvent(event2);
  2499. if (_event.name.indexOf(errorPlatform) === 0 && !this.state.nextEvents.some(function(nextEvent) {
  2500. return nextEvent.indexOf(errorPlatform) === 0;
  2501. })) {
  2502. throw _event.data.data;
  2503. }
  2504. var nextState = provide(this, function() {
  2505. return _this.machine.transition(_this.state, _event, void 0, exec || void 0);
  2506. });
  2507. return nextState;
  2508. };
  2509. Interpreter2.prototype.nextState = function(event2) {
  2510. return this._nextState(event2, false);
  2511. };
  2512. Interpreter2.prototype.forward = function(event2) {
  2513. var e_12, _a2;
  2514. try {
  2515. for(var _b = __values(this.forwardTo), _c = _b.next(); !_c.done; _c = _b.next()){
  2516. var id = _c.value;
  2517. var child = this.children.get(id);
  2518. if (!child) {
  2519. throw new Error("Unable to forward event '".concat(event2, "' from interpreter '").concat(this.id, "' to nonexistant child '").concat(id, "'."));
  2520. }
  2521. child.send(event2);
  2522. }
  2523. } catch (e_12_1) {
  2524. e_12 = {
  2525. error: e_12_1
  2526. };
  2527. } finally{
  2528. try {
  2529. if (_c && !_c.done && (_a2 = _b.return)) _a2.call(_b);
  2530. } finally{
  2531. if (e_12) throw e_12.error;
  2532. }
  2533. }
  2534. };
  2535. Interpreter2.prototype.defer = function(sendAction) {
  2536. var _this = this;
  2537. var timerId = this.clock.setTimeout(function() {
  2538. if ("to" in sendAction && sendAction.to) {
  2539. _this.sendTo(sendAction._event, sendAction.to, true);
  2540. } else {
  2541. _this.send(sendAction._event);
  2542. }
  2543. }, sendAction.delay);
  2544. if (sendAction.id) {
  2545. this.delayedEventsMap[sendAction.id] = timerId;
  2546. }
  2547. };
  2548. Interpreter2.prototype.cancel = function(sendId) {
  2549. this.clock.clearTimeout(this.delayedEventsMap[sendId]);
  2550. delete this.delayedEventsMap[sendId];
  2551. };
  2552. Interpreter2.prototype.exec = function(action, state, actionFunctionMap) {
  2553. if (actionFunctionMap === void 0) {
  2554. actionFunctionMap = this.machine.options.actions;
  2555. }
  2556. this._exec(action, state.context, state._event, actionFunctionMap);
  2557. };
  2558. Interpreter2.prototype.removeChild = function(childId) {
  2559. var _a2;
  2560. this.children.delete(childId);
  2561. this.forwardTo.delete(childId);
  2562. (_a2 = this.state) === null || _a2 === void 0 ? true : delete _a2.children[childId];
  2563. };
  2564. Interpreter2.prototype.stopChild = function(childId) {
  2565. var child = this.children.get(childId);
  2566. if (!child) {
  2567. return;
  2568. }
  2569. this.removeChild(childId);
  2570. if (isFunction(child.stop)) {
  2571. child.stop();
  2572. }
  2573. };
  2574. Interpreter2.prototype.spawn = function(entity, name, options) {
  2575. if (this.status !== InterpreterStatus.Running) {
  2576. return createDeferredActor(entity, name);
  2577. }
  2578. if (isPromiseLike(entity)) {
  2579. return this.spawnPromise(Promise.resolve(entity), name);
  2580. } else if (isFunction(entity)) {
  2581. return this.spawnCallback(entity, name);
  2582. } else if (isSpawnedActor(entity)) {
  2583. return this.spawnActor(entity, name);
  2584. } else if (isObservable(entity)) {
  2585. return this.spawnObservable(entity, name);
  2586. } else if (isMachine(entity)) {
  2587. return this.spawnMachine(entity, __assign(__assign({}, options), {
  2588. id: name
  2589. }));
  2590. } else if (isBehavior(entity)) {
  2591. return this.spawnBehavior(entity, name);
  2592. } else {
  2593. throw new Error('Unable to spawn entity "'.concat(name, '" of type "').concat(typeof entity, '".'));
  2594. }
  2595. };
  2596. Interpreter2.prototype.spawnMachine = function(machine, options) {
  2597. var _this = this;
  2598. if (options === void 0) {
  2599. options = {};
  2600. }
  2601. var childService = new Interpreter2(machine, __assign(__assign({}, this.options), {
  2602. parent: this,
  2603. id: options.id || machine.id
  2604. }));
  2605. var resolvedOptions = __assign(__assign({}, DEFAULT_SPAWN_OPTIONS), options);
  2606. if (resolvedOptions.sync) {
  2607. childService.onTransition(function(state) {
  2608. _this.send(update, {
  2609. state,
  2610. id: childService.id
  2611. });
  2612. });
  2613. }
  2614. var actor = childService;
  2615. this.children.set(childService.id, actor);
  2616. if (resolvedOptions.autoForward) {
  2617. this.forwardTo.add(childService.id);
  2618. }
  2619. childService.onDone(function(doneEvent) {
  2620. _this.removeChild(childService.id);
  2621. _this.send(toSCXMLEvent(doneEvent, {
  2622. origin: childService.id
  2623. }));
  2624. }).start();
  2625. return actor;
  2626. };
  2627. Interpreter2.prototype.spawnBehavior = function(behavior, id) {
  2628. var actorRef = spawnBehavior(behavior, {
  2629. id,
  2630. parent: this
  2631. });
  2632. this.children.set(id, actorRef);
  2633. return actorRef;
  2634. };
  2635. Interpreter2.prototype.spawnPromise = function(promise, id) {
  2636. var _a2;
  2637. var _this = this;
  2638. var canceled = false;
  2639. var resolvedData;
  2640. promise.then(function(response) {
  2641. if (!canceled) {
  2642. resolvedData = response;
  2643. _this.removeChild(id);
  2644. _this.send(toSCXMLEvent(doneInvoke(id, response), {
  2645. origin: id
  2646. }));
  2647. }
  2648. }, function(errorData) {
  2649. if (!canceled) {
  2650. _this.removeChild(id);
  2651. var errorEvent = error2(id, errorData);
  2652. try {
  2653. _this.send(toSCXMLEvent(errorEvent, {
  2654. origin: id
  2655. }));
  2656. } catch (error3) {
  2657. reportUnhandledExceptionOnInvocation(errorData, error3, id);
  2658. if (_this.devTools) {
  2659. _this.devTools.send(errorEvent, _this.state);
  2660. }
  2661. if (_this.machine.strict) {
  2662. _this.stop();
  2663. }
  2664. }
  2665. }
  2666. });
  2667. var actor = (_a2 = {
  2668. id,
  2669. send: function() {
  2670. return void 0;
  2671. },
  2672. subscribe: function(next, handleError, complete) {
  2673. var observer = toObserver(next, handleError, complete);
  2674. var unsubscribed = false;
  2675. promise.then(function(response) {
  2676. if (unsubscribed) {
  2677. return;
  2678. }
  2679. observer.next(response);
  2680. if (unsubscribed) {
  2681. return;
  2682. }
  2683. observer.complete();
  2684. }, function(err) {
  2685. if (unsubscribed) {
  2686. return;
  2687. }
  2688. observer.error(err);
  2689. });
  2690. return {
  2691. unsubscribe: function() {
  2692. return unsubscribed = true;
  2693. }
  2694. };
  2695. },
  2696. stop: function() {
  2697. canceled = true;
  2698. },
  2699. toJSON: function() {
  2700. return {
  2701. id
  2702. };
  2703. },
  2704. getSnapshot: function() {
  2705. return resolvedData;
  2706. }
  2707. }, _a2[symbolObservable] = function() {
  2708. return this;
  2709. }, _a2);
  2710. this.children.set(id, actor);
  2711. return actor;
  2712. };
  2713. Interpreter2.prototype.spawnCallback = function(callback, id) {
  2714. var _a2;
  2715. var _this = this;
  2716. var canceled = false;
  2717. var receivers = /* @__PURE__ */ new Set();
  2718. var listeners = /* @__PURE__ */ new Set();
  2719. var emitted;
  2720. var receive = function(e) {
  2721. emitted = e;
  2722. listeners.forEach(function(listener) {
  2723. return listener(e);
  2724. });
  2725. if (canceled) {
  2726. return;
  2727. }
  2728. _this.send(toSCXMLEvent(e, {
  2729. origin: id
  2730. }));
  2731. };
  2732. var callbackStop;
  2733. try {
  2734. callbackStop = callback(receive, function(newListener) {
  2735. receivers.add(newListener);
  2736. });
  2737. } catch (err) {
  2738. this.send(error2(id, err));
  2739. }
  2740. if (isPromiseLike(callbackStop)) {
  2741. return this.spawnPromise(callbackStop, id);
  2742. }
  2743. var actor = (_a2 = {
  2744. id,
  2745. send: function(event2) {
  2746. return receivers.forEach(function(receiver) {
  2747. return receiver(event2);
  2748. });
  2749. },
  2750. subscribe: function(next) {
  2751. var observer = toObserver(next);
  2752. listeners.add(observer.next);
  2753. return {
  2754. unsubscribe: function() {
  2755. listeners.delete(observer.next);
  2756. }
  2757. };
  2758. },
  2759. stop: function() {
  2760. canceled = true;
  2761. if (isFunction(callbackStop)) {
  2762. callbackStop();
  2763. }
  2764. },
  2765. toJSON: function() {
  2766. return {
  2767. id
  2768. };
  2769. },
  2770. getSnapshot: function() {
  2771. return emitted;
  2772. }
  2773. }, _a2[symbolObservable] = function() {
  2774. return this;
  2775. }, _a2);
  2776. this.children.set(id, actor);
  2777. return actor;
  2778. };
  2779. Interpreter2.prototype.spawnObservable = function(source, id) {
  2780. var _a2;
  2781. var _this = this;
  2782. var emitted;
  2783. var subscription = source.subscribe(function(value) {
  2784. emitted = value;
  2785. _this.send(toSCXMLEvent(value, {
  2786. origin: id
  2787. }));
  2788. }, function(err) {
  2789. _this.removeChild(id);
  2790. _this.send(toSCXMLEvent(error2(id, err), {
  2791. origin: id
  2792. }));
  2793. }, function() {
  2794. _this.removeChild(id);
  2795. _this.send(toSCXMLEvent(doneInvoke(id), {
  2796. origin: id
  2797. }));
  2798. });
  2799. var actor = (_a2 = {
  2800. id,
  2801. send: function() {
  2802. return void 0;
  2803. },
  2804. subscribe: function(next, handleError, complete) {
  2805. return source.subscribe(next, handleError, complete);
  2806. },
  2807. stop: function() {
  2808. return subscription.unsubscribe();
  2809. },
  2810. getSnapshot: function() {
  2811. return emitted;
  2812. },
  2813. toJSON: function() {
  2814. return {
  2815. id
  2816. };
  2817. }
  2818. }, _a2[symbolObservable] = function() {
  2819. return this;
  2820. }, _a2);
  2821. this.children.set(id, actor);
  2822. return actor;
  2823. };
  2824. Interpreter2.prototype.spawnActor = function(actor, name) {
  2825. this.children.set(name, actor);
  2826. return actor;
  2827. };
  2828. Interpreter2.prototype.spawnActivity = function(activity) {
  2829. var implementation = this.machine.options && this.machine.options.activities ? this.machine.options.activities[activity.type] : void 0;
  2830. if (!implementation) {
  2831. if (!IS_PRODUCTION) {
  2832. warn(false, "No implementation found for activity '".concat(activity.type, "'"));
  2833. }
  2834. return;
  2835. }
  2836. var dispose = implementation(this.state.context, activity);
  2837. this.spawnEffect(activity.id, dispose);
  2838. };
  2839. Interpreter2.prototype.spawnEffect = function(id, dispose) {
  2840. var _a2;
  2841. this.children.set(id, (_a2 = {
  2842. id,
  2843. send: function() {
  2844. return void 0;
  2845. },
  2846. subscribe: function() {
  2847. return {
  2848. unsubscribe: function() {
  2849. return void 0;
  2850. }
  2851. };
  2852. },
  2853. stop: dispose || void 0,
  2854. getSnapshot: function() {
  2855. return void 0;
  2856. },
  2857. toJSON: function() {
  2858. return {
  2859. id
  2860. };
  2861. }
  2862. }, _a2[symbolObservable] = function() {
  2863. return this;
  2864. }, _a2));
  2865. };
  2866. Interpreter2.prototype.attachDev = function() {
  2867. var global2 = getGlobal();
  2868. if (this.options.devTools && global2) {
  2869. if (global2.__REDUX_DEVTOOLS_EXTENSION__) {
  2870. var devToolsOptions = typeof this.options.devTools === "object" ? this.options.devTools : void 0;
  2871. this.devTools = global2.__REDUX_DEVTOOLS_EXTENSION__.connect(__assign(__assign({
  2872. name: this.id,
  2873. autoPause: true,
  2874. stateSanitizer: function(state) {
  2875. return {
  2876. value: state.value,
  2877. context: state.context,
  2878. actions: state.actions
  2879. };
  2880. }
  2881. }, devToolsOptions), {
  2882. features: __assign({
  2883. jump: false,
  2884. skip: false
  2885. }, devToolsOptions ? devToolsOptions.features : void 0)
  2886. }), this.machine);
  2887. this.devTools.init(this.state);
  2888. }
  2889. registerService(this);
  2890. }
  2891. };
  2892. Interpreter2.prototype.toJSON = function() {
  2893. return {
  2894. id: this.id
  2895. };
  2896. };
  2897. Interpreter2.prototype[symbolObservable] = function() {
  2898. return this;
  2899. };
  2900. Interpreter2.prototype.getSnapshot = function() {
  2901. if (this.status === InterpreterStatus.NotStarted) {
  2902. return this.initialState;
  2903. }
  2904. return this._state;
  2905. };
  2906. Interpreter2.defaultOptions = {
  2907. execute: true,
  2908. deferEvents: true,
  2909. clock: {
  2910. setTimeout: function(fn, ms) {
  2911. return setTimeout(fn, ms);
  2912. },
  2913. clearTimeout: function(id) {
  2914. return clearTimeout(id);
  2915. }
  2916. },
  2917. logger: console.log.bind(console),
  2918. devTools: false
  2919. };
  2920. Interpreter2.interpret = interpret;
  2921. return Interpreter2;
  2922. }();
  2923. var resolveSpawnOptions = function(nameOrOptions) {
  2924. if (isString(nameOrOptions)) {
  2925. return __assign(__assign({}, DEFAULT_SPAWN_OPTIONS), {
  2926. name: nameOrOptions
  2927. });
  2928. }
  2929. return __assign(__assign(__assign({}, DEFAULT_SPAWN_OPTIONS), {
  2930. name: uniqueId()
  2931. }), nameOrOptions);
  2932. };
  2933. function spawn(entity, nameOrOptions) {
  2934. var resolvedOptions = resolveSpawnOptions(nameOrOptions);
  2935. return consume(function(service) {
  2936. if (!IS_PRODUCTION) {
  2937. var isLazyEntity = isMachine(entity) || isFunction(entity);
  2938. warn(!!service || isLazyEntity, 'Attempted to spawn an Actor (ID: "'.concat(isMachine(entity) ? entity.id : "undefined", '") outside of a service. This will have no effect.'));
  2939. }
  2940. if (service) {
  2941. return service.spawn(entity, resolvedOptions.name, resolvedOptions);
  2942. } else {
  2943. return createDeferredActor(entity, resolvedOptions.name);
  2944. }
  2945. });
  2946. }
  2947. function interpret(machine, options) {
  2948. var interpreter = new Interpreter(machine, options);
  2949. return interpreter;
  2950. }
  2951. // node_modules/xstate/es/invokeUtils.js
  2952. function toInvokeSource2(src) {
  2953. if (typeof src === "string") {
  2954. var simpleSrc = {
  2955. type: src
  2956. };
  2957. simpleSrc.toString = function() {
  2958. return src;
  2959. };
  2960. return simpleSrc;
  2961. }
  2962. return src;
  2963. }
  2964. function toInvokeDefinition(invokeConfig) {
  2965. return __assign(__assign({
  2966. type: invoke
  2967. }, invokeConfig), {
  2968. toJSON: function() {
  2969. invokeConfig.onDone;
  2970. invokeConfig.onError;
  2971. var invokeDef = __rest(invokeConfig, [
  2972. "onDone",
  2973. "onError"
  2974. ]);
  2975. return __assign(__assign({}, invokeDef), {
  2976. type: invoke,
  2977. src: toInvokeSource2(invokeConfig.src)
  2978. });
  2979. }
  2980. });
  2981. }
  2982. // node_modules/xstate/es/StateNode.js
  2983. var NULL_EVENT = "";
  2984. var STATE_IDENTIFIER = "#";
  2985. var WILDCARD = "*";
  2986. var EMPTY_OBJECT = {};
  2987. var isStateId = function(str) {
  2988. return str[0] === STATE_IDENTIFIER;
  2989. };
  2990. var createDefaultOptions = function() {
  2991. return {
  2992. actions: {},
  2993. guards: {},
  2994. services: {},
  2995. activities: {},
  2996. delays: {}
  2997. };
  2998. };
  2999. var validateArrayifiedTransitions = function(stateNode, event2, transitions) {
  3000. var hasNonLastUnguardedTarget = transitions.slice(0, -1).some(function(transition) {
  3001. return !("cond" in transition) && !("in" in transition) && (isString(transition.target) || isMachine(transition.target));
  3002. });
  3003. var eventText = event2 === NULL_EVENT ? "the transient event" : "event '".concat(event2, "'");
  3004. warn(!hasNonLastUnguardedTarget, "One or more transitions for ".concat(eventText, " on state '").concat(stateNode.id, "' are unreachable. ") + "Make sure that the default transition is the last one defined.");
  3005. };
  3006. var StateNode = function() {
  3007. function StateNode2(config, options, _context, _stateInfo) {
  3008. if (_context === void 0) {
  3009. _context = "context" in config ? config.context : void 0;
  3010. }
  3011. var _this = this;
  3012. var _a2;
  3013. this.config = config;
  3014. this._context = _context;
  3015. this.order = -1;
  3016. this.__xstatenode = true;
  3017. this.__cache = {
  3018. events: void 0,
  3019. relativeValue: /* @__PURE__ */ new Map(),
  3020. initialStateValue: void 0,
  3021. initialState: void 0,
  3022. on: void 0,
  3023. transitions: void 0,
  3024. candidates: {},
  3025. delayedTransitions: void 0
  3026. };
  3027. this.idMap = {};
  3028. this.tags = [];
  3029. this.options = Object.assign(createDefaultOptions(), options);
  3030. this.parent = _stateInfo === null || _stateInfo === void 0 ? void 0 : _stateInfo.parent;
  3031. this.key = this.config.key || (_stateInfo === null || _stateInfo === void 0 ? void 0 : _stateInfo.key) || this.config.id || "(machine)";
  3032. this.machine = this.parent ? this.parent.machine : this;
  3033. this.path = this.parent ? this.parent.path.concat(this.key) : [];
  3034. this.delimiter = this.config.delimiter || (this.parent ? this.parent.delimiter : STATE_DELIMITER);
  3035. this.id = this.config.id || __spreadArray([
  3036. this.machine.key
  3037. ], __read(this.path), false).join(this.delimiter);
  3038. this.version = this.parent ? this.parent.version : this.config.version;
  3039. this.type = this.config.type || (this.config.parallel ? "parallel" : this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic");
  3040. this.schema = this.parent ? this.machine.schema : (_a2 = this.config.schema) !== null && _a2 !== void 0 ? _a2 : {};
  3041. this.description = this.config.description;
  3042. if (!IS_PRODUCTION) {
  3043. warn(!("parallel" in this.config), 'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel ? "Replace with `type: 'parallel'`" : "Use `type: '".concat(this.type, "'`"), " in the config for state node '").concat(this.id, "' instead."));
  3044. }
  3045. this.initial = this.config.initial;
  3046. this.states = this.config.states ? mapValues(this.config.states, function(stateConfig, key) {
  3047. var _a3;
  3048. var stateNode = new StateNode2(stateConfig, {}, void 0, {
  3049. parent: _this,
  3050. key
  3051. });
  3052. Object.assign(_this.idMap, __assign((_a3 = {}, _a3[stateNode.id] = stateNode, _a3), stateNode.idMap));
  3053. return stateNode;
  3054. }) : EMPTY_OBJECT;
  3055. var order = 0;
  3056. function dfs(stateNode) {
  3057. var e_1, _a3;
  3058. stateNode.order = order++;
  3059. try {
  3060. for(var _b = __values(getAllChildren(stateNode)), _c = _b.next(); !_c.done; _c = _b.next()){
  3061. var child = _c.value;
  3062. dfs(child);
  3063. }
  3064. } catch (e_1_1) {
  3065. e_1 = {
  3066. error: e_1_1
  3067. };
  3068. } finally{
  3069. try {
  3070. if (_c && !_c.done && (_a3 = _b.return)) _a3.call(_b);
  3071. } finally{
  3072. if (e_1) throw e_1.error;
  3073. }
  3074. }
  3075. }
  3076. dfs(this);
  3077. this.history = this.config.history === true ? "shallow" : this.config.history || false;
  3078. this._transient = !!this.config.always || (!this.config.on ? false : Array.isArray(this.config.on) ? this.config.on.some(function(_a3) {
  3079. var event2 = _a3.event;
  3080. return event2 === NULL_EVENT;
  3081. }) : NULL_EVENT in this.config.on);
  3082. this.strict = !!this.config.strict;
  3083. this.onEntry = toArray(this.config.entry || this.config.onEntry).map(function(action) {
  3084. return toActionObject(action);
  3085. });
  3086. this.onExit = toArray(this.config.exit || this.config.onExit).map(function(action) {
  3087. return toActionObject(action);
  3088. });
  3089. this.meta = this.config.meta;
  3090. this.doneData = this.type === "final" ? this.config.data : void 0;
  3091. this.invoke = toArray(this.config.invoke).map(function(invokeConfig, i) {
  3092. var _a3, _b;
  3093. if (isMachine(invokeConfig)) {
  3094. var invokeId = createInvokeId(_this.id, i);
  3095. _this.machine.options.services = __assign((_a3 = {}, _a3[invokeId] = invokeConfig, _a3), _this.machine.options.services);
  3096. return toInvokeDefinition({
  3097. src: invokeId,
  3098. id: invokeId
  3099. });
  3100. } else if (isString(invokeConfig.src)) {
  3101. var invokeId = invokeConfig.id || createInvokeId(_this.id, i);
  3102. return toInvokeDefinition(__assign(__assign({}, invokeConfig), {
  3103. id: invokeId,
  3104. src: invokeConfig.src
  3105. }));
  3106. } else if (isMachine(invokeConfig.src) || isFunction(invokeConfig.src)) {
  3107. var invokeId = invokeConfig.id || createInvokeId(_this.id, i);
  3108. _this.machine.options.services = __assign((_b = {}, _b[invokeId] = invokeConfig.src, _b), _this.machine.options.services);
  3109. return toInvokeDefinition(__assign(__assign({
  3110. id: invokeId
  3111. }, invokeConfig), {
  3112. src: invokeId
  3113. }));
  3114. } else {
  3115. var invokeSource = invokeConfig.src;
  3116. return toInvokeDefinition(__assign(__assign({
  3117. id: createInvokeId(_this.id, i)
  3118. }, invokeConfig), {
  3119. src: invokeSource
  3120. }));
  3121. }
  3122. });
  3123. this.activities = toArray(this.config.activities).concat(this.invoke).map(function(activity) {
  3124. return toActivityDefinition(activity);
  3125. });
  3126. this.transition = this.transition.bind(this);
  3127. this.tags = toArray(this.config.tags);
  3128. }
  3129. StateNode2.prototype._init = function() {
  3130. if (this.__cache.transitions) {
  3131. return;
  3132. }
  3133. getAllStateNodes(this).forEach(function(stateNode) {
  3134. return stateNode.on;
  3135. });
  3136. };
  3137. StateNode2.prototype.withConfig = function(options, context) {
  3138. var _a2 = this.options, actions = _a2.actions, activities = _a2.activities, guards = _a2.guards, services = _a2.services, delays = _a2.delays;
  3139. return new StateNode2(this.config, {
  3140. actions: __assign(__assign({}, actions), options.actions),
  3141. activities: __assign(__assign({}, activities), options.activities),
  3142. guards: __assign(__assign({}, guards), options.guards),
  3143. services: __assign(__assign({}, services), options.services),
  3144. delays: __assign(__assign({}, delays), options.delays)
  3145. }, context !== null && context !== void 0 ? context : this.context);
  3146. };
  3147. StateNode2.prototype.withContext = function(context) {
  3148. return new StateNode2(this.config, this.options, context);
  3149. };
  3150. Object.defineProperty(StateNode2.prototype, "context", {
  3151. get: function() {
  3152. return isFunction(this._context) ? this._context() : this._context;
  3153. },
  3154. enumerable: false,
  3155. configurable: true
  3156. });
  3157. Object.defineProperty(StateNode2.prototype, "definition", {
  3158. get: function() {
  3159. return {
  3160. id: this.id,
  3161. key: this.key,
  3162. version: this.version,
  3163. context: this.context,
  3164. type: this.type,
  3165. initial: this.initial,
  3166. history: this.history,
  3167. states: mapValues(this.states, function(state) {
  3168. return state.definition;
  3169. }),
  3170. on: this.on,
  3171. transitions: this.transitions,
  3172. entry: this.onEntry,
  3173. exit: this.onExit,
  3174. activities: this.activities || [],
  3175. meta: this.meta,
  3176. order: this.order || -1,
  3177. data: this.doneData,
  3178. invoke: this.invoke,
  3179. description: this.description,
  3180. tags: this.tags
  3181. };
  3182. },
  3183. enumerable: false,
  3184. configurable: true
  3185. });
  3186. StateNode2.prototype.toJSON = function() {
  3187. return this.definition;
  3188. };
  3189. Object.defineProperty(StateNode2.prototype, "on", {
  3190. get: function() {
  3191. if (this.__cache.on) {
  3192. return this.__cache.on;
  3193. }
  3194. var transitions = this.transitions;
  3195. return this.__cache.on = transitions.reduce(function(map, transition) {
  3196. map[transition.eventType] = map[transition.eventType] || [];
  3197. map[transition.eventType].push(transition);
  3198. return map;
  3199. }, {});
  3200. },
  3201. enumerable: false,
  3202. configurable: true
  3203. });
  3204. Object.defineProperty(StateNode2.prototype, "after", {
  3205. get: function() {
  3206. return this.__cache.delayedTransitions || (this.__cache.delayedTransitions = this.getDelayedTransitions(), this.__cache.delayedTransitions);
  3207. },
  3208. enumerable: false,
  3209. configurable: true
  3210. });
  3211. Object.defineProperty(StateNode2.prototype, "transitions", {
  3212. get: function() {
  3213. return this.__cache.transitions || (this.__cache.transitions = this.formatTransitions(), this.__cache.transitions);
  3214. },
  3215. enumerable: false,
  3216. configurable: true
  3217. });
  3218. StateNode2.prototype.getCandidates = function(eventName) {
  3219. if (this.__cache.candidates[eventName]) {
  3220. return this.__cache.candidates[eventName];
  3221. }
  3222. var transient = eventName === NULL_EVENT;
  3223. var candidates = this.transitions.filter(function(transition) {
  3224. var sameEventType = transition.eventType === eventName;
  3225. return transient ? sameEventType : sameEventType || transition.eventType === WILDCARD;
  3226. });
  3227. this.__cache.candidates[eventName] = candidates;
  3228. return candidates;
  3229. };
  3230. StateNode2.prototype.getDelayedTransitions = function() {
  3231. var _this = this;
  3232. var afterConfig = this.config.after;
  3233. if (!afterConfig) {
  3234. return [];
  3235. }
  3236. var mutateEntryExit = function(delay, i) {
  3237. var delayRef = isFunction(delay) ? "".concat(_this.id, ":delay[").concat(i, "]") : delay;
  3238. var eventType = after2(delayRef, _this.id);
  3239. _this.onEntry.push(send2(eventType, {
  3240. delay
  3241. }));
  3242. _this.onExit.push(cancel2(eventType));
  3243. return eventType;
  3244. };
  3245. var delayedTransitions = isArray(afterConfig) ? afterConfig.map(function(transition, i) {
  3246. var eventType = mutateEntryExit(transition.delay, i);
  3247. return __assign(__assign({}, transition), {
  3248. event: eventType
  3249. });
  3250. }) : flatten(Object.keys(afterConfig).map(function(delay, i) {
  3251. var configTransition = afterConfig[delay];
  3252. var resolvedTransition = isString(configTransition) ? {
  3253. target: configTransition
  3254. } : configTransition;
  3255. var resolvedDelay = !isNaN(+delay) ? +delay : delay;
  3256. var eventType = mutateEntryExit(resolvedDelay, i);
  3257. return toArray(resolvedTransition).map(function(transition) {
  3258. return __assign(__assign({}, transition), {
  3259. event: eventType,
  3260. delay: resolvedDelay
  3261. });
  3262. });
  3263. }));
  3264. return delayedTransitions.map(function(delayedTransition) {
  3265. var delay = delayedTransition.delay;
  3266. return __assign(__assign({}, _this.formatTransition(delayedTransition)), {
  3267. delay
  3268. });
  3269. });
  3270. };
  3271. StateNode2.prototype.getStateNodes = function(state) {
  3272. var _a2;
  3273. var _this = this;
  3274. if (!state) {
  3275. return [];
  3276. }
  3277. var stateValue = state instanceof State ? state.value : toStateValue(state, this.delimiter);
  3278. if (isString(stateValue)) {
  3279. var initialStateValue = this.getStateNode(stateValue).initial;
  3280. return initialStateValue !== void 0 ? this.getStateNodes((_a2 = {}, _a2[stateValue] = initialStateValue, _a2)) : [
  3281. this,
  3282. this.states[stateValue]
  3283. ];
  3284. }
  3285. var subStateKeys = Object.keys(stateValue);
  3286. var subStateNodes = [
  3287. this
  3288. ];
  3289. subStateNodes.push.apply(subStateNodes, __spreadArray([], __read(flatten(subStateKeys.map(function(subStateKey) {
  3290. return _this.getStateNode(subStateKey).getStateNodes(stateValue[subStateKey]);
  3291. }))), false));
  3292. return subStateNodes;
  3293. };
  3294. StateNode2.prototype.handles = function(event2) {
  3295. var eventType = getEventType(event2);
  3296. return this.events.includes(eventType);
  3297. };
  3298. StateNode2.prototype.resolveState = function(state) {
  3299. var stateFromConfig = state instanceof State ? state : State.create(state);
  3300. var configuration = Array.from(getConfiguration([], this.getStateNodes(stateFromConfig.value)));
  3301. return new State(__assign(__assign({}, stateFromConfig), {
  3302. value: this.resolve(stateFromConfig.value),
  3303. configuration,
  3304. done: isInFinalState(configuration, this),
  3305. tags: getTagsFromConfiguration(configuration),
  3306. machine: this.machine
  3307. }));
  3308. };
  3309. StateNode2.prototype.transitionLeafNode = function(stateValue, state, _event) {
  3310. var stateNode = this.getStateNode(stateValue);
  3311. var next = stateNode.next(state, _event);
  3312. if (!next || !next.transitions.length) {
  3313. return this.next(state, _event);
  3314. }
  3315. return next;
  3316. };
  3317. StateNode2.prototype.transitionCompoundNode = function(stateValue, state, _event) {
  3318. var subStateKeys = Object.keys(stateValue);
  3319. var stateNode = this.getStateNode(subStateKeys[0]);
  3320. var next = stateNode._transition(stateValue[subStateKeys[0]], state, _event);
  3321. if (!next || !next.transitions.length) {
  3322. return this.next(state, _event);
  3323. }
  3324. return next;
  3325. };
  3326. StateNode2.prototype.transitionParallelNode = function(stateValue, state, _event) {
  3327. var e_2, _a2;
  3328. var transitionMap = {};
  3329. try {
  3330. for(var _b = __values(Object.keys(stateValue)), _c = _b.next(); !_c.done; _c = _b.next()){
  3331. var subStateKey = _c.value;
  3332. var subStateValue = stateValue[subStateKey];
  3333. if (!subStateValue) {
  3334. continue;
  3335. }
  3336. var subStateNode = this.getStateNode(subStateKey);
  3337. var next = subStateNode._transition(subStateValue, state, _event);
  3338. if (next) {
  3339. transitionMap[subStateKey] = next;
  3340. }
  3341. }
  3342. } catch (e_2_1) {
  3343. e_2 = {
  3344. error: e_2_1
  3345. };
  3346. } finally{
  3347. try {
  3348. if (_c && !_c.done && (_a2 = _b.return)) _a2.call(_b);
  3349. } finally{
  3350. if (e_2) throw e_2.error;
  3351. }
  3352. }
  3353. var stateTransitions = Object.keys(transitionMap).map(function(key) {
  3354. return transitionMap[key];
  3355. });
  3356. var enabledTransitions = flatten(stateTransitions.map(function(st) {
  3357. return st.transitions;
  3358. }));
  3359. var willTransition = stateTransitions.some(function(st) {
  3360. return st.transitions.length > 0;
  3361. });
  3362. if (!willTransition) {
  3363. return this.next(state, _event);
  3364. }
  3365. var configuration = flatten(Object.keys(transitionMap).map(function(key) {
  3366. return transitionMap[key].configuration;
  3367. }));
  3368. return {
  3369. transitions: enabledTransitions,
  3370. exitSet: flatten(stateTransitions.map(function(t2) {
  3371. return t2.exitSet;
  3372. })),
  3373. configuration,
  3374. source: state,
  3375. actions: flatten(Object.keys(transitionMap).map(function(key) {
  3376. return transitionMap[key].actions;
  3377. }))
  3378. };
  3379. };
  3380. StateNode2.prototype._transition = function(stateValue, state, _event) {
  3381. if (isString(stateValue)) {
  3382. return this.transitionLeafNode(stateValue, state, _event);
  3383. }
  3384. if (Object.keys(stateValue).length === 1) {
  3385. return this.transitionCompoundNode(stateValue, state, _event);
  3386. }
  3387. return this.transitionParallelNode(stateValue, state, _event);
  3388. };
  3389. StateNode2.prototype.getTransitionData = function(state, event2) {
  3390. return this._transition(state.value, state, toSCXMLEvent(event2));
  3391. };
  3392. StateNode2.prototype.next = function(state, _event) {
  3393. var e_3, _a2;
  3394. var _this = this;
  3395. var eventName = _event.name;
  3396. var actions = [];
  3397. var nextStateNodes = [];
  3398. var selectedTransition;
  3399. try {
  3400. for(var _b = __values(this.getCandidates(eventName)), _c = _b.next(); !_c.done; _c = _b.next()){
  3401. var candidate = _c.value;
  3402. var cond = candidate.cond, stateIn = candidate.in;
  3403. var resolvedContext = state.context;
  3404. var isInState = stateIn ? isString(stateIn) && isStateId(stateIn) ? state.matches(toStateValue(this.getStateNodeById(stateIn).path, this.delimiter)) : matchesState(toStateValue(stateIn, this.delimiter), path(this.path.slice(0, -2))(state.value)) : true;
  3405. var guardPassed = false;
  3406. try {
  3407. guardPassed = !cond || evaluateGuard(this.machine, cond, resolvedContext, _event, state);
  3408. } catch (err) {
  3409. throw new Error("Unable to evaluate guard '".concat(cond.name || cond.type, "' in transition for event '").concat(eventName, "' in state node '").concat(this.id, "':\n").concat(err.message));
  3410. }
  3411. if (guardPassed && isInState) {
  3412. if (candidate.target !== void 0) {
  3413. nextStateNodes = candidate.target;
  3414. }
  3415. actions.push.apply(actions, __spreadArray([], __read(candidate.actions), false));
  3416. selectedTransition = candidate;
  3417. break;
  3418. }
  3419. }
  3420. } catch (e_3_1) {
  3421. e_3 = {
  3422. error: e_3_1
  3423. };
  3424. } finally{
  3425. try {
  3426. if (_c && !_c.done && (_a2 = _b.return)) _a2.call(_b);
  3427. } finally{
  3428. if (e_3) throw e_3.error;
  3429. }
  3430. }
  3431. if (!selectedTransition) {
  3432. return void 0;
  3433. }
  3434. if (!nextStateNodes.length) {
  3435. return {
  3436. transitions: [
  3437. selectedTransition
  3438. ],
  3439. exitSet: [],
  3440. configuration: state.value ? [
  3441. this
  3442. ] : [],
  3443. source: state,
  3444. actions
  3445. };
  3446. }
  3447. var allNextStateNodes = flatten(nextStateNodes.map(function(stateNode) {
  3448. return _this.getRelativeStateNodes(stateNode, state.historyValue);
  3449. }));
  3450. var isInternal = !!selectedTransition.internal;
  3451. return {
  3452. transitions: [
  3453. selectedTransition
  3454. ],
  3455. exitSet: isInternal ? [] : flatten(nextStateNodes.map(function(targetNode) {
  3456. return _this.getPotentiallyReenteringNodes(targetNode);
  3457. })),
  3458. configuration: allNextStateNodes,
  3459. source: state,
  3460. actions
  3461. };
  3462. };
  3463. StateNode2.prototype.getPotentiallyReenteringNodes = function(targetNode) {
  3464. if (this.order < targetNode.order) {
  3465. return [
  3466. this
  3467. ];
  3468. }
  3469. var nodes = [];
  3470. var marker = this;
  3471. var possibleAncestor = targetNode;
  3472. while(marker && marker !== possibleAncestor){
  3473. nodes.push(marker);
  3474. marker = marker.parent;
  3475. }
  3476. if (marker !== possibleAncestor) {
  3477. return [];
  3478. }
  3479. nodes.push(possibleAncestor);
  3480. return nodes;
  3481. };
  3482. StateNode2.prototype.getActions = function(resolvedConfig, isDone, transition, currentContext, _event, prevState, predictableExec) {
  3483. var e_4, _a2, e_5, _b;
  3484. var _this = this;
  3485. var prevConfig = prevState ? getConfiguration([], this.getStateNodes(prevState.value)) : [];
  3486. var entrySet = /* @__PURE__ */ new Set();
  3487. try {
  3488. for(var _c = __values(Array.from(resolvedConfig).sort(function(a, b) {
  3489. return a.order - b.order;
  3490. })), _d = _c.next(); !_d.done; _d = _c.next()){
  3491. var sn = _d.value;
  3492. if (!has(prevConfig, sn) || has(transition.exitSet, sn) || sn.parent && entrySet.has(sn.parent)) {
  3493. entrySet.add(sn);
  3494. }
  3495. }
  3496. } catch (e_4_1) {
  3497. e_4 = {
  3498. error: e_4_1
  3499. };
  3500. } finally{
  3501. try {
  3502. if (_d && !_d.done && (_a2 = _c.return)) _a2.call(_c);
  3503. } finally{
  3504. if (e_4) throw e_4.error;
  3505. }
  3506. }
  3507. try {
  3508. for(var prevConfig_1 = __values(prevConfig), prevConfig_1_1 = prevConfig_1.next(); !prevConfig_1_1.done; prevConfig_1_1 = prevConfig_1.next()){
  3509. var sn = prevConfig_1_1.value;
  3510. if (!has(resolvedConfig, sn) || has(transition.exitSet, sn.parent)) {
  3511. transition.exitSet.push(sn);
  3512. }
  3513. }
  3514. } catch (e_5_1) {
  3515. e_5 = {
  3516. error: e_5_1
  3517. };
  3518. } finally{
  3519. try {
  3520. if (prevConfig_1_1 && !prevConfig_1_1.done && (_b = prevConfig_1.return)) _b.call(prevConfig_1);
  3521. } finally{
  3522. if (e_5) throw e_5.error;
  3523. }
  3524. }
  3525. transition.exitSet.sort(function(a, b) {
  3526. return b.order - a.order;
  3527. });
  3528. var entryStates = Array.from(entrySet).sort(function(a, b) {
  3529. return a.order - b.order;
  3530. });
  3531. var exitStates = new Set(transition.exitSet);
  3532. var doneEvents = flatten(entryStates.map(function(sn2) {
  3533. var events = [];
  3534. if (sn2.type !== "final") {
  3535. return events;
  3536. }
  3537. var parent = sn2.parent;
  3538. if (!parent.parent) {
  3539. return events;
  3540. }
  3541. events.push(done(sn2.id, sn2.doneData), done(parent.id, sn2.doneData ? mapContext(sn2.doneData, currentContext, _event) : void 0));
  3542. var grandparent = parent.parent;
  3543. if (grandparent.type === "parallel") {
  3544. if (getChildren(grandparent).every(function(parentNode) {
  3545. return isInFinalState(transition.configuration, parentNode);
  3546. })) {
  3547. events.push(done(grandparent.id));
  3548. }
  3549. }
  3550. return events;
  3551. }));
  3552. var entryActions = entryStates.map(function(stateNode) {
  3553. var entryActions2 = stateNode.onEntry;
  3554. var invokeActions = stateNode.activities.map(function(activity) {
  3555. return start2(activity);
  3556. });
  3557. return {
  3558. type: "entry",
  3559. actions: toActionObjects(predictableExec ? __spreadArray(__spreadArray([], __read(entryActions2), false), __read(invokeActions), false) : __spreadArray(__spreadArray([], __read(invokeActions), false), __read(entryActions2), false), _this.machine.options.actions)
  3560. };
  3561. }).concat({
  3562. type: "state_done",
  3563. actions: doneEvents.map(function(event2) {
  3564. return raise2(event2);
  3565. })
  3566. });
  3567. var exitActions = Array.from(exitStates).map(function(stateNode) {
  3568. return {
  3569. type: "exit",
  3570. actions: toActionObjects(__spreadArray(__spreadArray([], __read(stateNode.onExit), false), __read(stateNode.activities.map(function(activity) {
  3571. return stop2(activity);
  3572. })), false), _this.machine.options.actions)
  3573. };
  3574. });
  3575. var actions = exitActions.concat({
  3576. type: "transition",
  3577. actions: toActionObjects(transition.actions, this.machine.options.actions)
  3578. }).concat(entryActions);
  3579. if (isDone) {
  3580. var stopActions = toActionObjects(flatten(__spreadArray([], __read(resolvedConfig), false).sort(function(a, b) {
  3581. return b.order - a.order;
  3582. }).map(function(stateNode) {
  3583. return stateNode.onExit;
  3584. })), this.machine.options.actions).filter(function(action) {
  3585. return !isRaisableAction(action);
  3586. });
  3587. return actions.concat({
  3588. type: "stop",
  3589. actions: stopActions
  3590. });
  3591. }
  3592. return actions;
  3593. };
  3594. StateNode2.prototype.transition = function(state, event2, context, exec) {
  3595. if (state === void 0) {
  3596. state = this.initialState;
  3597. }
  3598. var _event = toSCXMLEvent(event2);
  3599. var currentState;
  3600. if (state instanceof State) {
  3601. currentState = context === void 0 ? state : this.resolveState(State.from(state, context));
  3602. } else {
  3603. var resolvedStateValue = isString(state) ? this.resolve(pathToStateValue(this.getResolvedPath(state))) : this.resolve(state);
  3604. var resolvedContext = context !== null && context !== void 0 ? context : this.machine.context;
  3605. currentState = this.resolveState(State.from(resolvedStateValue, resolvedContext));
  3606. }
  3607. if (!IS_PRODUCTION && _event.name === WILDCARD) {
  3608. throw new Error("An event cannot have the wildcard type ('".concat(WILDCARD, "')"));
  3609. }
  3610. if (this.strict) {
  3611. if (!this.events.includes(_event.name) && !isBuiltInEvent(_event.name)) {
  3612. throw new Error("Machine '".concat(this.id, "' does not accept event '").concat(_event.name, "'"));
  3613. }
  3614. }
  3615. var stateTransition = this._transition(currentState.value, currentState, _event) || {
  3616. transitions: [],
  3617. configuration: [],
  3618. exitSet: [],
  3619. source: currentState,
  3620. actions: []
  3621. };
  3622. var prevConfig = getConfiguration([], this.getStateNodes(currentState.value));
  3623. var resolvedConfig = stateTransition.configuration.length ? getConfiguration(prevConfig, stateTransition.configuration) : prevConfig;
  3624. stateTransition.configuration = __spreadArray([], __read(resolvedConfig), false);
  3625. return this.resolveTransition(stateTransition, currentState, currentState.context, exec, _event);
  3626. };
  3627. StateNode2.prototype.resolveRaisedTransition = function(state, _event, originalEvent, predictableExec) {
  3628. var _a2;
  3629. var currentActions = state.actions;
  3630. state = this.transition(state, _event, void 0, predictableExec);
  3631. state._event = originalEvent;
  3632. state.event = originalEvent.data;
  3633. (_a2 = state.actions).unshift.apply(_a2, __spreadArray([], __read(currentActions), false));
  3634. return state;
  3635. };
  3636. StateNode2.prototype.resolveTransition = function(stateTransition, currentState, context, predictableExec, _event) {
  3637. var e_6, _a2, e_7, _b;
  3638. var _this = this;
  3639. if (_event === void 0) {
  3640. _event = initEvent;
  3641. }
  3642. var configuration = stateTransition.configuration;
  3643. var willTransition = !currentState || stateTransition.transitions.length > 0;
  3644. var resolvedConfiguration = willTransition ? stateTransition.configuration : currentState ? currentState.configuration : [];
  3645. var isDone = isInFinalState(resolvedConfiguration, this);
  3646. var resolvedStateValue = willTransition ? getValue(this.machine, configuration) : void 0;
  3647. var historyValue = currentState ? currentState.historyValue ? currentState.historyValue : stateTransition.source ? this.machine.historyValue(currentState.value) : void 0 : void 0;
  3648. var actionBlocks = this.getActions(new Set(resolvedConfiguration), isDone, stateTransition, context, _event, currentState, predictableExec);
  3649. var activities = currentState ? __assign({}, currentState.activities) : {};
  3650. try {
  3651. for(var actionBlocks_1 = __values(actionBlocks), actionBlocks_1_1 = actionBlocks_1.next(); !actionBlocks_1_1.done; actionBlocks_1_1 = actionBlocks_1.next()){
  3652. var block = actionBlocks_1_1.value;
  3653. try {
  3654. for(var _c = (e_7 = void 0, __values(block.actions)), _d = _c.next(); !_d.done; _d = _c.next()){
  3655. var action = _d.value;
  3656. if (action.type === start) {
  3657. activities[action.activity.id || action.activity.type] = action;
  3658. } else if (action.type === stop) {
  3659. activities[action.activity.id || action.activity.type] = false;
  3660. }
  3661. }
  3662. } catch (e_7_1) {
  3663. e_7 = {
  3664. error: e_7_1
  3665. };
  3666. } finally{
  3667. try {
  3668. if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
  3669. } finally{
  3670. if (e_7) throw e_7.error;
  3671. }
  3672. }
  3673. }
  3674. } catch (e_6_1) {
  3675. e_6 = {
  3676. error: e_6_1
  3677. };
  3678. } finally{
  3679. try {
  3680. if (actionBlocks_1_1 && !actionBlocks_1_1.done && (_a2 = actionBlocks_1.return)) _a2.call(actionBlocks_1);
  3681. } finally{
  3682. if (e_6) throw e_6.error;
  3683. }
  3684. }
  3685. var _e = __read(resolveActions(this, currentState, context, _event, actionBlocks, predictableExec, this.machine.config.predictableActionArguments || this.machine.config.preserveActionOrder), 2), resolvedActions = _e[0], updatedContext = _e[1];
  3686. var _f = __read(partition(resolvedActions, isRaisableAction), 2), raisedEvents = _f[0], nonRaisedActions = _f[1];
  3687. var invokeActions = resolvedActions.filter(function(action2) {
  3688. var _a3;
  3689. return action2.type === start && ((_a3 = action2.activity) === null || _a3 === void 0 ? void 0 : _a3.type) === invoke;
  3690. });
  3691. var children2 = invokeActions.reduce(function(acc, action2) {
  3692. acc[action2.activity.id] = createInvocableActor(action2.activity, _this.machine, updatedContext, _event);
  3693. return acc;
  3694. }, currentState ? __assign({}, currentState.children) : {});
  3695. var nextState = new State({
  3696. value: resolvedStateValue || currentState.value,
  3697. context: updatedContext,
  3698. _event,
  3699. _sessionid: currentState ? currentState._sessionid : null,
  3700. historyValue: resolvedStateValue ? historyValue ? updateHistoryValue(historyValue, resolvedStateValue) : void 0 : currentState ? currentState.historyValue : void 0,
  3701. history: !resolvedStateValue || stateTransition.source ? currentState : void 0,
  3702. actions: resolvedStateValue ? nonRaisedActions : [],
  3703. activities: resolvedStateValue ? activities : currentState ? currentState.activities : {},
  3704. events: [],
  3705. configuration: resolvedConfiguration,
  3706. transitions: stateTransition.transitions,
  3707. children: children2,
  3708. done: isDone,
  3709. tags: getTagsFromConfiguration(resolvedConfiguration),
  3710. machine: this
  3711. });
  3712. var didUpdateContext = context !== updatedContext;
  3713. nextState.changed = _event.name === update || didUpdateContext;
  3714. var history = nextState.history;
  3715. if (history) {
  3716. delete history.history;
  3717. }
  3718. var hasAlwaysTransitions = !isDone && (this._transient || configuration.some(function(stateNode) {
  3719. return stateNode._transient;
  3720. }));
  3721. if (!willTransition && (!hasAlwaysTransitions || _event.name === NULL_EVENT)) {
  3722. return nextState;
  3723. }
  3724. var maybeNextState = nextState;
  3725. if (!isDone) {
  3726. if (hasAlwaysTransitions) {
  3727. maybeNextState = this.resolveRaisedTransition(maybeNextState, {
  3728. type: nullEvent
  3729. }, _event, predictableExec);
  3730. }
  3731. while(raisedEvents.length){
  3732. var raisedEvent = raisedEvents.shift();
  3733. maybeNextState = this.resolveRaisedTransition(maybeNextState, raisedEvent._event, _event, predictableExec);
  3734. }
  3735. }
  3736. var changed = maybeNextState.changed || (history ? !!maybeNextState.actions.length || didUpdateContext || typeof history.value !== typeof maybeNextState.value || !stateValuesEqual(maybeNextState.value, history.value) : void 0);
  3737. maybeNextState.changed = changed;
  3738. maybeNextState.history = history;
  3739. return maybeNextState;
  3740. };
  3741. StateNode2.prototype.getStateNode = function(stateKey) {
  3742. if (isStateId(stateKey)) {
  3743. return this.machine.getStateNodeById(stateKey);
  3744. }
  3745. if (!this.states) {
  3746. throw new Error("Unable to retrieve child state '".concat(stateKey, "' from '").concat(this.id, "'; no child states exist."));
  3747. }
  3748. var result = this.states[stateKey];
  3749. if (!result) {
  3750. throw new Error("Child state '".concat(stateKey, "' does not exist on '").concat(this.id, "'"));
  3751. }
  3752. return result;
  3753. };
  3754. StateNode2.prototype.getStateNodeById = function(stateId) {
  3755. var resolvedStateId = isStateId(stateId) ? stateId.slice(STATE_IDENTIFIER.length) : stateId;
  3756. if (resolvedStateId === this.id) {
  3757. return this;
  3758. }
  3759. var stateNode = this.machine.idMap[resolvedStateId];
  3760. if (!stateNode) {
  3761. throw new Error("Child state node '#".concat(resolvedStateId, "' does not exist on machine '").concat(this.id, "'"));
  3762. }
  3763. return stateNode;
  3764. };
  3765. StateNode2.prototype.getStateNodeByPath = function(statePath) {
  3766. if (typeof statePath === "string" && isStateId(statePath)) {
  3767. try {
  3768. return this.getStateNodeById(statePath.slice(1));
  3769. } catch (e) {}
  3770. }
  3771. var arrayStatePath = toStatePath(statePath, this.delimiter).slice();
  3772. var currentStateNode = this;
  3773. while(arrayStatePath.length){
  3774. var key = arrayStatePath.shift();
  3775. if (!key.length) {
  3776. break;
  3777. }
  3778. currentStateNode = currentStateNode.getStateNode(key);
  3779. }
  3780. return currentStateNode;
  3781. };
  3782. StateNode2.prototype.resolve = function(stateValue) {
  3783. var _a2;
  3784. var _this = this;
  3785. if (!stateValue) {
  3786. return this.initialStateValue || EMPTY_OBJECT;
  3787. }
  3788. switch(this.type){
  3789. case "parallel":
  3790. return mapValues(this.initialStateValue, function(subStateValue, subStateKey) {
  3791. return subStateValue ? _this.getStateNode(subStateKey).resolve(stateValue[subStateKey] || subStateValue) : EMPTY_OBJECT;
  3792. });
  3793. case "compound":
  3794. if (isString(stateValue)) {
  3795. var subStateNode = this.getStateNode(stateValue);
  3796. if (subStateNode.type === "parallel" || subStateNode.type === "compound") {
  3797. return _a2 = {}, _a2[stateValue] = subStateNode.initialStateValue, _a2;
  3798. }
  3799. return stateValue;
  3800. }
  3801. if (!Object.keys(stateValue).length) {
  3802. return this.initialStateValue || {};
  3803. }
  3804. return mapValues(stateValue, function(subStateValue, subStateKey) {
  3805. return subStateValue ? _this.getStateNode(subStateKey).resolve(subStateValue) : EMPTY_OBJECT;
  3806. });
  3807. default:
  3808. return stateValue || EMPTY_OBJECT;
  3809. }
  3810. };
  3811. StateNode2.prototype.getResolvedPath = function(stateIdentifier) {
  3812. if (isStateId(stateIdentifier)) {
  3813. var stateNode = this.machine.idMap[stateIdentifier.slice(STATE_IDENTIFIER.length)];
  3814. if (!stateNode) {
  3815. throw new Error("Unable to find state node '".concat(stateIdentifier, "'"));
  3816. }
  3817. return stateNode.path;
  3818. }
  3819. return toStatePath(stateIdentifier, this.delimiter);
  3820. };
  3821. Object.defineProperty(StateNode2.prototype, "initialStateValue", {
  3822. get: function() {
  3823. var _a2;
  3824. if (this.__cache.initialStateValue) {
  3825. return this.__cache.initialStateValue;
  3826. }
  3827. var initialStateValue;
  3828. if (this.type === "parallel") {
  3829. initialStateValue = mapFilterValues(this.states, function(state) {
  3830. return state.initialStateValue || EMPTY_OBJECT;
  3831. }, function(stateNode) {
  3832. return !(stateNode.type === "history");
  3833. });
  3834. } else if (this.initial !== void 0) {
  3835. if (!this.states[this.initial]) {
  3836. throw new Error("Initial state '".concat(this.initial, "' not found on '").concat(this.key, "'"));
  3837. }
  3838. initialStateValue = isLeafNode(this.states[this.initial]) ? this.initial : (_a2 = {}, _a2[this.initial] = this.states[this.initial].initialStateValue, _a2);
  3839. } else {
  3840. initialStateValue = {};
  3841. }
  3842. this.__cache.initialStateValue = initialStateValue;
  3843. return this.__cache.initialStateValue;
  3844. },
  3845. enumerable: false,
  3846. configurable: true
  3847. });
  3848. StateNode2.prototype.getInitialState = function(stateValue, context) {
  3849. this._init();
  3850. var configuration = this.getStateNodes(stateValue);
  3851. return this.resolveTransition({
  3852. configuration,
  3853. exitSet: [],
  3854. transitions: [],
  3855. source: void 0,
  3856. actions: []
  3857. }, void 0, context !== null && context !== void 0 ? context : this.machine.context, void 0);
  3858. };
  3859. Object.defineProperty(StateNode2.prototype, "initialState", {
  3860. get: function() {
  3861. var initialStateValue = this.initialStateValue;
  3862. if (!initialStateValue) {
  3863. throw new Error("Cannot retrieve initial state from simple state '".concat(this.id, "'."));
  3864. }
  3865. return this.getInitialState(initialStateValue);
  3866. },
  3867. enumerable: false,
  3868. configurable: true
  3869. });
  3870. Object.defineProperty(StateNode2.prototype, "target", {
  3871. get: function() {
  3872. var target;
  3873. if (this.type === "history") {
  3874. var historyConfig = this.config;
  3875. if (isString(historyConfig.target)) {
  3876. target = isStateId(historyConfig.target) ? pathToStateValue(this.machine.getStateNodeById(historyConfig.target).path.slice(this.path.length - 1)) : historyConfig.target;
  3877. } else {
  3878. target = historyConfig.target;
  3879. }
  3880. }
  3881. return target;
  3882. },
  3883. enumerable: false,
  3884. configurable: true
  3885. });
  3886. StateNode2.prototype.getRelativeStateNodes = function(relativeStateId, historyValue, resolve) {
  3887. if (resolve === void 0) {
  3888. resolve = true;
  3889. }
  3890. return resolve ? relativeStateId.type === "history" ? relativeStateId.resolveHistory(historyValue) : relativeStateId.initialStateNodes : [
  3891. relativeStateId
  3892. ];
  3893. };
  3894. Object.defineProperty(StateNode2.prototype, "initialStateNodes", {
  3895. get: function() {
  3896. var _this = this;
  3897. if (isLeafNode(this)) {
  3898. return [
  3899. this
  3900. ];
  3901. }
  3902. if (this.type === "compound" && !this.initial) {
  3903. if (!IS_PRODUCTION) {
  3904. warn(false, "Compound state node '".concat(this.id, "' has no initial state."));
  3905. }
  3906. return [
  3907. this
  3908. ];
  3909. }
  3910. var initialStateNodePaths = toStatePaths(this.initialStateValue);
  3911. return flatten(initialStateNodePaths.map(function(initialPath) {
  3912. return _this.getFromRelativePath(initialPath);
  3913. }));
  3914. },
  3915. enumerable: false,
  3916. configurable: true
  3917. });
  3918. StateNode2.prototype.getFromRelativePath = function(relativePath) {
  3919. if (!relativePath.length) {
  3920. return [
  3921. this
  3922. ];
  3923. }
  3924. var _a2 = __read(relativePath), stateKey = _a2[0], childStatePath = _a2.slice(1);
  3925. if (!this.states) {
  3926. throw new Error("Cannot retrieve subPath '".concat(stateKey, "' from node with no states"));
  3927. }
  3928. var childStateNode = this.getStateNode(stateKey);
  3929. if (childStateNode.type === "history") {
  3930. return childStateNode.resolveHistory();
  3931. }
  3932. if (!this.states[stateKey]) {
  3933. throw new Error("Child state '".concat(stateKey, "' does not exist on '").concat(this.id, "'"));
  3934. }
  3935. return this.states[stateKey].getFromRelativePath(childStatePath);
  3936. };
  3937. StateNode2.prototype.historyValue = function(relativeStateValue) {
  3938. if (!Object.keys(this.states).length) {
  3939. return void 0;
  3940. }
  3941. return {
  3942. current: relativeStateValue || this.initialStateValue,
  3943. states: mapFilterValues(this.states, function(stateNode, key) {
  3944. if (!relativeStateValue) {
  3945. return stateNode.historyValue();
  3946. }
  3947. var subStateValue = isString(relativeStateValue) ? void 0 : relativeStateValue[key];
  3948. return stateNode.historyValue(subStateValue || stateNode.initialStateValue);
  3949. }, function(stateNode) {
  3950. return !stateNode.history;
  3951. })
  3952. };
  3953. };
  3954. StateNode2.prototype.resolveHistory = function(historyValue) {
  3955. var _this = this;
  3956. if (this.type !== "history") {
  3957. return [
  3958. this
  3959. ];
  3960. }
  3961. var parent = this.parent;
  3962. if (!historyValue) {
  3963. var historyTarget = this.target;
  3964. return historyTarget ? flatten(toStatePaths(historyTarget).map(function(relativeChildPath) {
  3965. return parent.getFromRelativePath(relativeChildPath);
  3966. })) : parent.initialStateNodes;
  3967. }
  3968. var subHistoryValue = nestedPath(parent.path, "states")(historyValue).current;
  3969. if (isString(subHistoryValue)) {
  3970. return [
  3971. parent.getStateNode(subHistoryValue)
  3972. ];
  3973. }
  3974. return flatten(toStatePaths(subHistoryValue).map(function(subStatePath) {
  3975. return _this.history === "deep" ? parent.getFromRelativePath(subStatePath) : [
  3976. parent.states[subStatePath[0]]
  3977. ];
  3978. }));
  3979. };
  3980. Object.defineProperty(StateNode2.prototype, "stateIds", {
  3981. get: function() {
  3982. var _this = this;
  3983. var childStateIds = flatten(Object.keys(this.states).map(function(stateKey) {
  3984. return _this.states[stateKey].stateIds;
  3985. }));
  3986. return [
  3987. this.id
  3988. ].concat(childStateIds);
  3989. },
  3990. enumerable: false,
  3991. configurable: true
  3992. });
  3993. Object.defineProperty(StateNode2.prototype, "events", {
  3994. get: function() {
  3995. var e_8, _a2, e_9, _b;
  3996. if (this.__cache.events) {
  3997. return this.__cache.events;
  3998. }
  3999. var states = this.states;
  4000. var events = new Set(this.ownEvents);
  4001. if (states) {
  4002. try {
  4003. for(var _c = __values(Object.keys(states)), _d = _c.next(); !_d.done; _d = _c.next()){
  4004. var stateId = _d.value;
  4005. var state = states[stateId];
  4006. if (state.states) {
  4007. try {
  4008. for(var _e = (e_9 = void 0, __values(state.events)), _f = _e.next(); !_f.done; _f = _e.next()){
  4009. var event_1 = _f.value;
  4010. events.add("".concat(event_1));
  4011. }
  4012. } catch (e_9_1) {
  4013. e_9 = {
  4014. error: e_9_1
  4015. };
  4016. } finally{
  4017. try {
  4018. if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
  4019. } finally{
  4020. if (e_9) throw e_9.error;
  4021. }
  4022. }
  4023. }
  4024. }
  4025. } catch (e_8_1) {
  4026. e_8 = {
  4027. error: e_8_1
  4028. };
  4029. } finally{
  4030. try {
  4031. if (_d && !_d.done && (_a2 = _c.return)) _a2.call(_c);
  4032. } finally{
  4033. if (e_8) throw e_8.error;
  4034. }
  4035. }
  4036. }
  4037. return this.__cache.events = Array.from(events);
  4038. },
  4039. enumerable: false,
  4040. configurable: true
  4041. });
  4042. Object.defineProperty(StateNode2.prototype, "ownEvents", {
  4043. get: function() {
  4044. var events = new Set(this.transitions.filter(function(transition) {
  4045. return !(!transition.target && !transition.actions.length && transition.internal);
  4046. }).map(function(transition) {
  4047. return transition.eventType;
  4048. }));
  4049. return Array.from(events);
  4050. },
  4051. enumerable: false,
  4052. configurable: true
  4053. });
  4054. StateNode2.prototype.resolveTarget = function(_target) {
  4055. var _this = this;
  4056. if (_target === void 0) {
  4057. return void 0;
  4058. }
  4059. return _target.map(function(target) {
  4060. if (!isString(target)) {
  4061. return target;
  4062. }
  4063. var isInternalTarget = target[0] === _this.delimiter;
  4064. if (isInternalTarget && !_this.parent) {
  4065. return _this.getStateNodeByPath(target.slice(1));
  4066. }
  4067. var resolvedTarget = isInternalTarget ? _this.key + target : target;
  4068. if (_this.parent) {
  4069. try {
  4070. var targetStateNode = _this.parent.getStateNodeByPath(resolvedTarget);
  4071. return targetStateNode;
  4072. } catch (err) {
  4073. throw new Error("Invalid transition definition for state node '".concat(_this.id, "':\n").concat(err.message));
  4074. }
  4075. } else {
  4076. return _this.getStateNodeByPath(resolvedTarget);
  4077. }
  4078. });
  4079. };
  4080. StateNode2.prototype.formatTransition = function(transitionConfig) {
  4081. var _this = this;
  4082. var normalizedTarget = normalizeTarget(transitionConfig.target);
  4083. var internal = "internal" in transitionConfig ? transitionConfig.internal : normalizedTarget ? normalizedTarget.some(function(_target) {
  4084. return isString(_target) && _target[0] === _this.delimiter;
  4085. }) : true;
  4086. var guards = this.machine.options.guards;
  4087. var target = this.resolveTarget(normalizedTarget);
  4088. var transition = __assign(__assign({}, transitionConfig), {
  4089. actions: toActionObjects(toArray(transitionConfig.actions)),
  4090. cond: toGuard(transitionConfig.cond, guards),
  4091. target,
  4092. source: this,
  4093. internal,
  4094. eventType: transitionConfig.event,
  4095. toJSON: function() {
  4096. return __assign(__assign({}, transition), {
  4097. target: transition.target ? transition.target.map(function(t2) {
  4098. return "#".concat(t2.id);
  4099. }) : void 0,
  4100. source: "#".concat(_this.id)
  4101. });
  4102. }
  4103. });
  4104. return transition;
  4105. };
  4106. StateNode2.prototype.formatTransitions = function() {
  4107. var e_10, _a2;
  4108. var _this = this;
  4109. var onConfig;
  4110. if (!this.config.on) {
  4111. onConfig = [];
  4112. } else if (Array.isArray(this.config.on)) {
  4113. onConfig = this.config.on;
  4114. } else {
  4115. var _b = this.config.on, _c = WILDCARD, _d = _b[_c], wildcardConfigs = _d === void 0 ? [] : _d, strictTransitionConfigs_1 = __rest(_b, [
  4116. typeof _c === "symbol" ? _c : _c + ""
  4117. ]);
  4118. onConfig = flatten(Object.keys(strictTransitionConfigs_1).map(function(key) {
  4119. if (!IS_PRODUCTION && key === NULL_EVENT) {
  4120. warn(false, "Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. " + 'Please check the `on` configuration for "#'.concat(_this.id, '".'));
  4121. }
  4122. var transitionConfigArray = toTransitionConfigArray(key, strictTransitionConfigs_1[key]);
  4123. if (!IS_PRODUCTION) {
  4124. validateArrayifiedTransitions(_this, key, transitionConfigArray);
  4125. }
  4126. return transitionConfigArray;
  4127. }).concat(toTransitionConfigArray(WILDCARD, wildcardConfigs)));
  4128. }
  4129. var eventlessConfig = this.config.always ? toTransitionConfigArray("", this.config.always) : [];
  4130. var doneConfig = this.config.onDone ? toTransitionConfigArray(String(done(this.id)), this.config.onDone) : [];
  4131. if (!IS_PRODUCTION) {
  4132. warn(!(this.config.onDone && !this.parent), 'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id, '".'));
  4133. }
  4134. var invokeConfig = flatten(this.invoke.map(function(invokeDef) {
  4135. var settleTransitions = [];
  4136. if (invokeDef.onDone) {
  4137. settleTransitions.push.apply(settleTransitions, __spreadArray([], __read(toTransitionConfigArray(String(doneInvoke(invokeDef.id)), invokeDef.onDone)), false));
  4138. }
  4139. if (invokeDef.onError) {
  4140. settleTransitions.push.apply(settleTransitions, __spreadArray([], __read(toTransitionConfigArray(String(error2(invokeDef.id)), invokeDef.onError)), false));
  4141. }
  4142. return settleTransitions;
  4143. }));
  4144. var delayedTransitions = this.after;
  4145. var formattedTransitions = flatten(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(doneConfig), false), __read(invokeConfig), false), __read(onConfig), false), __read(eventlessConfig), false).map(function(transitionConfig) {
  4146. return toArray(transitionConfig).map(function(transition) {
  4147. return _this.formatTransition(transition);
  4148. });
  4149. }));
  4150. try {
  4151. for(var delayedTransitions_1 = __values(delayedTransitions), delayedTransitions_1_1 = delayedTransitions_1.next(); !delayedTransitions_1_1.done; delayedTransitions_1_1 = delayedTransitions_1.next()){
  4152. var delayedTransition = delayedTransitions_1_1.value;
  4153. formattedTransitions.push(delayedTransition);
  4154. }
  4155. } catch (e_10_1) {
  4156. e_10 = {
  4157. error: e_10_1
  4158. };
  4159. } finally{
  4160. try {
  4161. if (delayedTransitions_1_1 && !delayedTransitions_1_1.done && (_a2 = delayedTransitions_1.return)) _a2.call(delayedTransitions_1);
  4162. } finally{
  4163. if (e_10) throw e_10.error;
  4164. }
  4165. }
  4166. return formattedTransitions;
  4167. };
  4168. return StateNode2;
  4169. }();
  4170. // node_modules/xstate/es/Machine.js
  4171. var warned = false;
  4172. function Machine(config, options, initialContext) {
  4173. if (initialContext === void 0) {
  4174. initialContext = config.context;
  4175. }
  4176. return new StateNode(config, options, initialContext);
  4177. }
  4178. function createMachine(config, options) {
  4179. if (!IS_PRODUCTION && !("predictableActionArguments" in config) && !warned) {
  4180. warned = true;
  4181. console.warn("It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html");
  4182. }
  4183. return new StateNode(config, options);
  4184. }
  4185. // node_modules/xstate/es/mapState.js
  4186. function mapState(stateMap, stateId) {
  4187. var e_1, _a2;
  4188. var foundStateId;
  4189. try {
  4190. for(var _b = __values(Object.keys(stateMap)), _c = _b.next(); !_c.done; _c = _b.next()){
  4191. var mappedStateId = _c.value;
  4192. if (matchesState(mappedStateId, stateId) && (!foundStateId || stateId.length > foundStateId.length)) {
  4193. foundStateId = mappedStateId;
  4194. }
  4195. }
  4196. } catch (e_1_1) {
  4197. e_1 = {
  4198. error: e_1_1
  4199. };
  4200. } finally{
  4201. try {
  4202. if (_c && !_c.done && (_a2 = _b.return)) _a2.call(_b);
  4203. } finally{
  4204. if (e_1) throw e_1.error;
  4205. }
  4206. }
  4207. return stateMap[foundStateId];
  4208. }
  4209. // node_modules/xstate/es/match.js
  4210. function matchState(state, patterns, defaultValue) {
  4211. var e_1, _a2;
  4212. var resolvedState = State.from(state, state instanceof State ? state.context : void 0);
  4213. try {
  4214. for(var patterns_1 = __values(patterns), patterns_1_1 = patterns_1.next(); !patterns_1_1.done; patterns_1_1 = patterns_1.next()){
  4215. var _b = __read(patterns_1_1.value, 2), stateValue = _b[0], getValue2 = _b[1];
  4216. if (resolvedState.matches(stateValue)) {
  4217. return getValue2(resolvedState);
  4218. }
  4219. }
  4220. } catch (e_1_1) {
  4221. e_1 = {
  4222. error: e_1_1
  4223. };
  4224. } finally{
  4225. try {
  4226. if (patterns_1_1 && !patterns_1_1.done && (_a2 = patterns_1.return)) _a2.call(patterns_1);
  4227. } finally{
  4228. if (e_1) throw e_1.error;
  4229. }
  4230. }
  4231. return defaultValue(resolvedState);
  4232. }
  4233. // node_modules/xstate/es/schema.js
  4234. function createSchema(schema) {
  4235. return schema;
  4236. }
  4237. var t = createSchema;
  4238. // node_modules/xstate/es/index.js
  4239. var assign3 = assign2;
  4240. var cancel3 = cancel2;
  4241. var send3 = send2;
  4242. var sendTo2 = sendTo;
  4243. var sendParent2 = sendParent;
  4244. var sendUpdate2 = sendUpdate;
  4245. var forwardTo2 = forwardTo;
  4246. var doneInvoke2 = doneInvoke;
  4247. var raise3 = raise2;
  4248. var log3 = log2;
  4249. var pure3 = pure2;
  4250. var choose3 = choose2;
  4251. var stop3 = stop2;
  4252. /*! *****************************************************************************
  4253. Copyright (c) Microsoft Corporation.
  4254. Permission to use, copy, modify, and/or distribute this software for any
  4255. purpose with or without fee is hereby granted.
  4256. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  4257. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  4258. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  4259. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  4260. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  4261. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  4262. PERFORMANCE OF THIS SOFTWARE.
  4263. ***************************************************************************** */
  4264. /***/ })
  4265. }]);