"use strict"; (wx["webpackJsonp"] = wx["webpackJsonp"] || []).push([["pages/Clock"],{ /***/ "./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/Clock.tsx": /*!**************************************************************************************************!*\ !*** ./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/Clock.tsx ***! \**************************************************************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ IndexPage; } /* harmony export */ }); /* harmony import */ var _Users_Work_hola_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js */ "./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js"); /* harmony import */ var _Users_Work_hola_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */ "./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js"); /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js"); /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/taro */ "webpack/container/remote/@tarojs/taro"); /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-redux */ "webpack/container/remote/react-redux"); /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_redux__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _store_user__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/store/user */ "./src/store/user.tsx"); /* harmony import */ var _services_permission__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/services/permission */ "./src/services/permission.tsx"); /* harmony import */ var _features_trackTimeDuration_components_Clock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/features/trackTimeDuration/components/Clock */ "./src/features/trackTimeDuration/components/Clock.tsx"); /* harmony import */ var _features_trackTimeDuration_components_Console__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/features/trackTimeDuration/components/Console */ "./src/features/trackTimeDuration/components/Console.tsx"); /* harmony import */ var _features_trackTimeDuration_components_More__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/features/trackTimeDuration/components/More */ "./src/features/trackTimeDuration/components/More.tsx"); /* harmony import */ var _services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/services/trackTimeDuration */ "./src/services/trackTimeDuration.tsx"); /* harmony import */ var _store_scenario__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/store/scenario */ "./src/store/scenario.tsx"); /* harmony import */ var _store_trackTimeMachine__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/store/trackTimeMachine */ "./src/store/trackTimeMachine.tsx"); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime"); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__); // import ComponentA from './component' // import TabBar from '../../components/Tabbar'; function IndexPage() { var dispatch = (0,react_redux__WEBPACK_IMPORTED_MODULE_1__.useDispatch)(); var array = []; var user = (0,react_redux__WEBPACK_IMPORTED_MODULE_1__.useSelector)(function (state) { return state.user; }); var permission = (0,react_redux__WEBPACK_IMPORTED_MODULE_1__.useSelector)(function (state) { return state.permission; }); var common = (0,react_redux__WEBPACK_IMPORTED_MODULE_1__.useSelector)(function (state) { return state.common; }); array.push('ffff'); array.push( /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_11__.Text, { children: "ffff" })); // array.push() (0,_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__.useReady)( /*#__PURE__*/(0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_12__["default"])( /*#__PURE__*/(0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_13__["default"])().mark(function _callee() { var userData; return (0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_13__["default"])().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return getStorage('userData'); case 2: userData = _context.sent; if (userData) { dispatch((0,_store_user__WEBPACK_IMPORTED_MODULE_2__.getInfoSuccess)(JSON.parse(userData))); // return JSON.parse(userData as string) as UserState; setTimeout(function () { checkWXPubFollow(); getCheckData(); }, 200); } case 4: case "end": return _context.stop(); } }, _callee); }))); (0,_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__.useDidShow)(function () { if (user.isLogin) getCheckData(); }); function getCheckData() { (0,_services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_7__.getChecks)().then(function (res) { if (res.scenario) { dispatch((0,_store_scenario__WEBPACK_IMPORTED_MODULE_8__.setScenario)(res.scenario)); console.log(res.scenario.name + ' ' + res.status); // trackTimeService.send({type:(res as any).scenario.name}); // setSpecifiedStatus('FAST_SLEEP', 'ON_GOING'); // 初始化状态机 // const initialState = machine.initialState; // 设置指定状态为 C->3 // const nextState = machine.transition(initialState, 'SET_SPECIFIED_STATE'); // const specifiedState = setSpecifiedState(nextState, 'FAST_SLEEP'); // setSpecifiedState(); console.log('name:' + res.scenario.name); // machine.reset(); _store_trackTimeMachine__WEBPACK_IMPORTED_MODULE_9__["default"].send({ type: 'RESET' }); _store_trackTimeMachine__WEBPACK_IMPORTED_MODULE_9__["default"].send({ type: res.scenario.name }); // trackTimeService.send({type:'START_FAST'}); // trackTimeService.send({type:'START_SLEEP'}); // trackTimeService.send({type:'END_SLEEP'}); // trackTimeService.send({type:'END_SLEEP'}); // trackTimeService.send({type:'START_FAST'}); // trackTimeService.send({type:'END_FAST'}); // trackTimeService.send({type:'START_SLEEP'}); // const currentState = trackTimeService.getSnapshot(); // console.log(currentState.value); // trackTimeService.send('setCurrentStatus', {status:(res as any).status}); // setCurrentStatus((res as any).status); // trackTimeService.send({type:'START_FAST'}); } }); } function checkWXPubFollow() { (0,_services_permission__WEBPACK_IMPORTED_MODULE_3__.wxPubFollow)().then(function (res) { console.log(res); }); } function followWxPub() { var resource = common.resources.filter(function (item) { return item.code == 'follow_wx_pub'; }); _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().showModal({ title: '提示', content: '关注公众号后可接收提醒\n点击确定,前往关注', showCancel: true, success: function success(result) { if (result.confirm) { _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().navigateTo({ url: '/pages/H5?title=fast16cc 关注服务号&url=' + resource[0].url }); } } }); } function getStorage(_x) { return _getStorage.apply(this, arguments); } function _getStorage() { _getStorage = (0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_12__["default"])( /*#__PURE__*/(0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_13__["default"])().mark(function _callee2(key) { var res; return (0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_13__["default"])().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.prev = 0; _context2.next = 3; return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorage({ key: key }); case 3: res = _context2.sent; return _context2.abrupt("return", res.data); case 7: _context2.prev = 7; _context2.t0 = _context2["catch"](0); return _context2.abrupt("return", ''); case 10: case "end": return _context2.stop(); } }, _callee2, null, [[0, 7]]); })); return _getStorage.apply(this, arguments); } function goDetail() { _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().navigateTo({ // url: '/pages/index/detail' //src/moduleA/pages/third.tsx url: '../../moduleA/pages/third' }); } function login() { if (user.isLogin) { _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().navigateTo({ url: '/pages/ChooseScenario' }); } else { _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().navigateTo({ url: '/pages/ChooseAuth' }); } } return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_11__.View, { style: { backgroundColor: '#fff', flex: 1, flexDirection: 'column', display: 'flex' }, children: [permission.wxPubFollow == false && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_11__.Text, { onClick: function onClick() { return followWxPub(); }, children: "\u53BB\u5173\u6CE8\u516C\u4F17\u53F7111" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_11__.Button, { onClick: function onClick() { return goDetail(); }, children: "go detail" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_11__.Text, { className: "login", onClick: function onClick() { return login(); }, children: "sss" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_features_trackTimeDuration_components_Clock__WEBPACK_IMPORTED_MODULE_4__["default"], {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_features_trackTimeDuration_components_Console__WEBPACK_IMPORTED_MODULE_5__["default"], {}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx)(_features_trackTimeDuration_components_More__WEBPACK_IMPORTED_MODULE_6__["default"], {})] }); } /***/ }), /***/ "./src/features/trackTimeDuration/components/Clock.tsx": /*!*************************************************************!*\ !*** ./src/features/trackTimeDuration/components/Clock.tsx ***! \*************************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ Component; } /* harmony export */ }); /* harmony import */ var _components_Rings__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/components/Rings */ "./src/components/Rings.weapp.tsx"); /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js"); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime"); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__); function Component() { return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.View, { children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_components_Rings__WEBPACK_IMPORTED_MODULE_0__["default"], { radius: 50 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.Text, { children: "Clock Component" })] }); } /***/ }), /***/ "./src/features/trackTimeDuration/components/Console.tsx": /*!***************************************************************!*\ !*** ./src/features/trackTimeDuration/components/Console.tsx ***! \***************************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ Component; } /* harmony export */ }); /* harmony import */ var _Users_Work_hola_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */ "./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"); /* harmony import */ var _services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/services/trackTimeDuration */ "./src/services/trackTimeDuration.tsx"); /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js"); /* harmony import */ var _store_trackTimeMachine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/store/trackTimeMachine */ "./src/store/trackTimeMachine.tsx"); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ "webpack/container/remote/react"); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime"); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__); function Component() { // const [current,send] = useService(machine) // const currentState = trackTimeService.getSnapshot(); // console.log(currentState.value); // debugger var _useState = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(''), _useState2 = (0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_4__["default"])(_useState, 2), key = _useState2[0], setKey = _useState2[1]; var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(''), _useState4 = (0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_4__["default"])(_useState3, 2), value = _useState4[0], setValue = _useState4[1]; (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () { // trackTimeService.send({type:'FAST_SLEEP'}); _store_trackTimeMachine__WEBPACK_IMPORTED_MODULE_1__["default"].onTransition(function (state) { console.log(state.value); if (state.value.mixed) { setKey('mixed'); setValue(state.value.mixed); } if (state.value.fasting) { setKey('fasting'); setValue(state.value.fasting); } if (state.value.sleeping) { setKey('sleeping'); setValue(state.value.sleeping); } }); }, []); function isMap(obj) { return obj instanceof Map; } function startFast() { _store_trackTimeMachine__WEBPACK_IMPORTED_MODULE_1__["default"].send({ type: 'START_FAST' }); console.log('start fast'); var start_time = new Date().getTime(); var duration = 8 * 3600 * 1000; var extra = { set_time: start_time - 20 * 1000, confirm_time: start_time + 50 * 1000 }; (0,_services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_0__.recordCheck)({ action: 'FAST_START', real_check_time: start_time, target_duration: duration, extra: extra }).then(function (res) { console.log(res); }); // dispatch(startFast()); } function startSleep() { _store_trackTimeMachine__WEBPACK_IMPORTED_MODULE_1__["default"].send({ type: 'START_SLEEP' }); var start_time = new Date().getTime(); var duration = 8 * 3600 * 1000; var extra = { set_time: start_time - 20 * 1000, confirm_time: start_time + 50 * 1000 }; (0,_services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_0__.recordCheck)({ action: 'SLEEP_START', real_check_time: start_time, target_duration: duration, extra: extra }).then(function (res) { console.log(res); }); // dispatch(startSleep()); } function endSleep() { _store_trackTimeMachine__WEBPACK_IMPORTED_MODULE_1__["default"].send({ type: 'END_SLEEP' }); var start_time = new Date().getTime(); // const duration = 8 * 3600 * 1000; var extra = { set_time: start_time - 20 * 1000, confirm_time: start_time + 50 * 1000 }; (0,_services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_0__.recordCheck)({ action: 'SLEEP_END', real_check_time: start_time, extra: extra }).then(function (res) { console.log(res); }); } function endFast() { _store_trackTimeMachine__WEBPACK_IMPORTED_MODULE_1__["default"].send({ type: 'END_FAST' }); var start_time = new Date().getTime(); // const duration = 8 * 3600 * 1000; var extra = { set_time: start_time - 20 * 1000, confirm_time: start_time + 50 * 1000 }; (0,_services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_0__.recordCheck)({ action: 'FAST_END', real_check_time: start_time, extra: extra }).then(function (res) { console.log(res); }); } function mixedBtns() { return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.View, { children: [(value == 'WAIT_TO_START' || value == 'DONE') && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.Text, { onClick: startFast, children: "Start Fast" }), (value == 'ON_GOING' || value == 'ON_GOING2' || value == 'ON_GOING3') && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.Text, { onClick: endFast, children: "End Fast" }), value == 'ON_GOING' && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.Text, { onClick: startSleep, children: "Start Sleep" }), value == 'ON_GOING2' && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.Text, { onClick: endSleep, children: "End Sleep" })] }); } function fastBtns() { return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.View, { children: value == 'ON_GOING' ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.Text, { onClick: endFast, children: "End Fast" }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.Text, { onClick: startFast, children: "Start Fast" }) }); } function sleepBtns() { return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.View, { children: value == 'ON_GOING' ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.Text, { onClick: endSleep, children: "End Sleep" }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.Text, { onClick: startSleep, children: "Start Sleep" }) }); } return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.View, { children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.Text, { children: "Console Component" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_5__.View, { children: [key === 'mixed' && mixedBtns(), key === 'fasting' && fastBtns(), key === 'sleeping' && sleepBtns()] })] }); } /***/ }), /***/ "./src/features/trackTimeDuration/components/More.tsx": /*!************************************************************!*\ !*** ./src/features/trackTimeDuration/components/More.tsx ***! \************************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ Component; } /* harmony export */ }); /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js"); /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/taro */ "webpack/container/remote/@tarojs/taro"); /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var react_i18next__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-i18next */ "webpack/container/remote/react-i18next"); /* harmony import */ var react_i18next__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_i18next__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-redux */ "webpack/container/remote/react-redux"); /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_redux__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime"); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__); function Component() { var _useTranslation = (0,react_i18next__WEBPACK_IMPORTED_MODULE_1__.useTranslation)(), t = _useTranslation.t; var scenario = (0,react_redux__WEBPACK_IMPORTED_MODULE_2__.useSelector)(function (state) { return state.scenario; }); function waitActionSheet() { _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().showActionSheet({ itemList: [t('feature.track_time_duration.action_sheet.change_schedule'), t('feature.track_time_duration.action_sheet.switch_scenario')] }).then(function (res) { console.log(res.tapIndex); switch (res.tapIndex) { case 0: _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().navigateTo({ url: '/pages/SetSchedule' }); break; case 1: _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().navigateTo({ url: '/pages/ChooseScenario' }); break; } }).catch(function (err) { console.log(err.errMsg); }); } function ongoingActionSheet() { _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().showActionSheet({ itemList: [t('feature.track_time_duration.action_sheet.give_up'), t('feature.track_time_duration.action_sheet.switch_scenario')] }).then(function (res) { console.log(res.tapIndex); }).catch(function (err) { console.log(err.errMsg); }); } return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_4__.View, { children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_4__.Text, { onClick: waitActionSheet, children: "More Component" }) }); } /***/ }), /***/ "./src/pages/Clock.tsx": /*!*****************************!*\ !*** ./src/pages/Clock.tsx ***! \*****************************/ /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) { /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/runtime */ "webpack/container/remote/@tarojs/runtime"); /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_Clock_tsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./Clock.tsx */ "./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/Clock.tsx"); var config = {}; var inst = Page((0,_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__.createPageConfig)(_node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_Clock_tsx__WEBPACK_IMPORTED_MODULE_1__["default"], 'pages/Clock', {root:{cn:[]}}, config || {})) /* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_Clock_tsx__WEBPACK_IMPORTED_MODULE_1__["default"]); /***/ }), /***/ "./src/store/trackTimeMachine.tsx": /*!****************************************!*\ !*** ./src/store/trackTimeMachine.tsx ***! \****************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* unused harmony exports machine, setSpecifiedState, setSpecifiedStatus */ /* harmony import */ var _Users_Work_hola_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */ "./node_modules/@babel/runtime/helpers/esm/objectSpread2.js"); /* harmony import */ var xstate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! xstate */ "./node_modules/xstate/es/Machine.js"); /* harmony import */ var xstate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! xstate */ "./node_modules/xstate/es/index.js"); /* harmony import */ var xstate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! xstate */ "./node_modules/xstate/es/interpreter.js"); var machine = (0,xstate__WEBPACK_IMPORTED_MODULE_0__.createMachine)({ id: "trackTime", initial: "choose", context: { currentStatus: '' }, on: { RESET: { target: '.choose', actions: (0,xstate__WEBPACK_IMPORTED_MODULE_1__.assign)(function (context) { console.log('reset state'); return { currentStatus: '' }; }) } }, states: { choose: { on: { SLEEP: { target: "sleeping", actions: ['demo'] }, FAST_SLEEP: { target: "mixed", actions: ['demo1'] }, FAST: { target: "fasting", actions: ['demo2'] } } }, sleeping: { initial: "WAIT_TO_START", states: { WAIT_TO_START: { on: { START_SLEEP: { target: "ON_GOING", actions: ['demo3'] } } }, ON_GOING: { on: { END_SLEEP: { target: "DONE", actions: ['demo4'] } } }, DONE: {} } }, mixed: { initial: "WAIT_TO_START", states: { WAIT_TO_START: { on: { START_FAST: { target: "ON_GOING", actions: ['demo5'] } } }, ON_GOING: { on: { START_SLEEP: { target: "ON_GOING2", actions: ['demo6'] }, END_FAST: { target: "DONE", actions: ['demo7'] } } }, ON_GOING2: { on: { END_FAST: { target: "DONE", actions: ['demo8'] }, END_SLEEP: { target: "ON_GOING3", actions: ['demo9'] } } }, DONE: {}, ON_GOING3: { on: { END_FAST: { target: "DONE", actions: ['demo10'] } } } } }, fasting: { initial: "WAIT_TO_START", states: { WAIT_TO_START: { on: { START_FAST: { target: "ON_GOING", actions: ['demo11'] } } }, ON_GOING: { on: { END_FAST: { target: "DONE", actions: ['demo12'] } } }, DONE: {} } } }, schema: { events: {} }, predictableActionArguments: true, preserveActionOrder: true }, { actions: { demo: function demo() { console.log('demo'); }, demo1: function demo1() { console.log('demo1'); }, demo2: function demo2() { console.log('demo2'); }, demo3: function demo3() { console.log('demo3'); }, demo4: function demo4() { console.log('demo4'); }, demo5: function demo5() { console.log('demo5'); }, demo6: function demo6() { console.log('demo6'); }, demo7: function demo7() { console.log('demo7'); }, demo8: function demo8() { console.log('demo8'); }, demo9: function demo9() { console.log('demo9'); }, demo10: function demo10() { console.log('demo10'); }, demo11: function demo11() { console.log('demo11'); }, setCurrentStatus: (0,xstate__WEBPACK_IMPORTED_MODULE_1__.assign)(function (context, event) { return { currentStatus: event.type }; }) }, services: {}, guards: {}, delays: {} }); var setSpecifiedState = function setSpecifiedState(currentState, specifiedState) { return (0,xstate__WEBPACK_IMPORTED_MODULE_1__.assign)({ myMachine: (0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_2__["default"])((0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_2__["default"])({}, currentState.myMachine), {}, { value: specifiedState }) }); }; var setSpecifiedStatus = function setSpecifiedStatus(currentState, specifiedState) { return (0,xstate__WEBPACK_IMPORTED_MODULE_1__.assign)({ machine: { currentState: currentState, specifiedState: specifiedState } }); }; var service = (0,xstate__WEBPACK_IMPORTED_MODULE_3__.interpret)(machine).start(); // const service = machine.withContext(initialContext).start(); /* harmony default export */ __webpack_exports__["default"] = (service); /***/ }), /***/ "./node_modules/xstate/es/Actor.js": /*!*****************************************!*\ !*** ./node_modules/xstate/es/Actor.js ***! \*****************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ createDeferredActor: function() { return /* binding */ createDeferredActor; }, /* harmony export */ createInvocableActor: function() { return /* binding */ createInvocableActor; }, /* harmony export */ isSpawnedActor: function() { return /* binding */ isSpawnedActor; }, /* harmony export */ toActorRef: function() { return /* binding */ toActorRef; } /* harmony export */ }); /* unused harmony exports createNullActor, isActor */ /* harmony import */ var _virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_virtual/_tslib.js */ "./node_modules/xstate/es/_virtual/_tslib.js"); /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/xstate/es/utils.js"); /* harmony import */ var _serviceScope_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./serviceScope.js */ "./node_modules/xstate/es/serviceScope.js"); function createNullActor(id) { var _a; return _a = { id: id, send: function () { return void 0; }, subscribe: function () { return { unsubscribe: function () { return void 0; } }; }, getSnapshot: function () { return undefined; }, toJSON: function () { return { id: id }; } }, _a[_utils_js__WEBPACK_IMPORTED_MODULE_0__.symbolObservable] = function () { return this; }, _a; } /** * Creates a deferred actor that is able to be invoked given the provided * invocation information in its `.meta` value. * * @param invokeDefinition The meta information needed to invoke the actor. */ function createInvocableActor(invokeDefinition, machine, context, _event) { var _a; var invokeSrc = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toInvokeSource)(invokeDefinition.src); var serviceCreator = (_a = machine === null || machine === void 0 ? void 0 : machine.options.services) === null || _a === void 0 ? void 0 : _a[invokeSrc.type]; var resolvedData = invokeDefinition.data ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.mapContext)(invokeDefinition.data, context, _event) : undefined; var tempActor = serviceCreator ? createDeferredActor(serviceCreator, invokeDefinition.id, resolvedData) : createNullActor(invokeDefinition.id); // @ts-ignore tempActor.meta = invokeDefinition; return tempActor; } function createDeferredActor(entity, id, data) { var tempActor = createNullActor(id); // @ts-ignore tempActor.deferred = true; if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isMachine)(entity)) { // "mute" the existing service scope so potential spawned actors within the `.initialState` stay deferred here var initialState_1 = tempActor.state = (0,_serviceScope_js__WEBPACK_IMPORTED_MODULE_1__.provide)(undefined, function () { return (data ? entity.withContext(data) : entity).initialState; }); tempActor.getSnapshot = function () { return initialState_1; }; } return tempActor; } function isActor(item) { try { return typeof item.send === 'function'; } catch (e) { return false; } } function isSpawnedActor(item) { return isActor(item) && 'id' in item; } // TODO: refactor the return type, this could be written in a better way but it's best to avoid unneccessary breaking changes now function toActorRef(actorRefLike) { var _a; return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((_a = { subscribe: function () { return { unsubscribe: function () { return void 0; } }; }, id: 'anonymous', getSnapshot: function () { return undefined; } }, _a[_utils_js__WEBPACK_IMPORTED_MODULE_0__.symbolObservable] = function () { return this; }, _a), actorRefLike); } /***/ }), /***/ "./node_modules/xstate/es/Machine.js": /*!*******************************************!*\ !*** ./node_modules/xstate/es/Machine.js ***! \*******************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ createMachine: function() { return /* binding */ createMachine; } /* harmony export */ }); /* unused harmony export Machine */ /* harmony import */ var _StateNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./StateNode.js */ "./node_modules/xstate/es/StateNode.js"); /* harmony import */ var _environment_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./environment.js */ "./node_modules/xstate/es/environment.js"); var warned = false; function Machine(config, options, initialContext) { if (initialContext === void 0) { initialContext = config.context; } return new _StateNode_js__WEBPACK_IMPORTED_MODULE_0__.StateNode(config, options, initialContext); } function createMachine(config, options) { if (!_environment_js__WEBPACK_IMPORTED_MODULE_1__.IS_PRODUCTION && !('predictableActionArguments' in config) && !warned) { warned = true; console.warn('It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html'); } return new _StateNode_js__WEBPACK_IMPORTED_MODULE_0__.StateNode(config, options); } /***/ }), /***/ "./node_modules/xstate/es/State.js": /*!*****************************************!*\ !*** ./node_modules/xstate/es/State.js ***! \*****************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ State: function() { return /* binding */ State; }, /* harmony export */ bindActionToState: function() { return /* binding */ bindActionToState; }, /* harmony export */ isStateConfig: function() { return /* binding */ isStateConfig; }, /* harmony export */ stateValuesEqual: function() { return /* binding */ stateValuesEqual; } /* harmony export */ }); /* unused harmony export isState */ /* harmony import */ var _virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_virtual/_tslib.js */ "./node_modules/xstate/es/_virtual/_tslib.js"); /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants.js */ "./node_modules/xstate/es/constants.js"); /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/xstate/es/utils.js"); /* harmony import */ var _stateUtils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stateUtils.js */ "./node_modules/xstate/es/stateUtils.js"); /* harmony import */ var _actions_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actions.js */ "./node_modules/xstate/es/actions.js"); /* harmony import */ var _environment_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environment.js */ "./node_modules/xstate/es/environment.js"); function stateValuesEqual(a, b) { if (a === b) { return true; } if (a === undefined || b === undefined) { return false; } if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(a) || (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(b)) { return a === b; } var aKeys = Object.keys(a); var bKeys = Object.keys(b); return aKeys.length === bKeys.length && aKeys.every(function (key) { return stateValuesEqual(a[key], b[key]); }); } function isStateConfig(state) { if (typeof state !== 'object' || state === null) { return false; } return 'value' in state && '_event' in state; } /** * @deprecated Use `isStateConfig(object)` or `state instanceof State` instead. */ var isState = isStateConfig; function bindActionToState(action, state) { var exec = action.exec; var boundAction = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__assign)({}, action), { exec: exec !== undefined ? function () { return exec(state.context, state.event, { action: action, state: state, _event: state._event }); } : undefined }); return boundAction; } var State = /*#__PURE__*/ /** @class */ function () { /** * Creates a new State instance. * @param value The state value * @param context The extended state * @param historyValue The tree representing historical values of the state nodes * @param history The previous state * @param actions An array of action objects to execute as side-effects * @param activities A mapping of activities and whether they are started (`true`) or stopped (`false`). * @param meta * @param events Internal event queue. Should be empty with run-to-completion semantics. * @param configuration */ function State(config) { var _this = this; var _a; this.actions = []; this.activities = _constants_js__WEBPACK_IMPORTED_MODULE_2__.EMPTY_ACTIVITY_MAP; this.meta = {}; this.events = []; this.value = config.value; this.context = config.context; this._event = config._event; this._sessionid = config._sessionid; this.event = this._event.data; this.historyValue = config.historyValue; this.history = config.history; this.actions = config.actions || []; this.activities = config.activities || _constants_js__WEBPACK_IMPORTED_MODULE_2__.EMPTY_ACTIVITY_MAP; this.meta = (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_3__.getMeta)(config.configuration); this.events = config.events || []; this.matches = this.matches.bind(this); this.toStrings = this.toStrings.bind(this); this.configuration = config.configuration; this.transitions = config.transitions; this.children = config.children; this.done = !!config.done; this.tags = (_a = Array.isArray(config.tags) ? new Set(config.tags) : config.tags) !== null && _a !== void 0 ? _a : new Set(); this.machine = config.machine; Object.defineProperty(this, 'nextEvents', { get: function () { return (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_3__.nextEvents)(_this.configuration); } }); } /** * Creates a new State instance for the given `stateValue` and `context`. * @param stateValue * @param context */ State.from = function (stateValue, context) { if (stateValue instanceof State) { if (stateValue.context !== context) { return new State({ value: stateValue.value, context: context, _event: stateValue._event, _sessionid: null, historyValue: stateValue.historyValue, history: stateValue.history, actions: [], activities: stateValue.activities, meta: {}, events: [], configuration: [], transitions: [], children: {} }); } return stateValue; } var _event = _actions_js__WEBPACK_IMPORTED_MODULE_4__.initEvent; return new State({ value: stateValue, context: context, _event: _event, _sessionid: null, historyValue: undefined, history: undefined, actions: [], activities: undefined, meta: undefined, events: [], configuration: [], transitions: [], children: {} }); }; /** * Creates a new State instance for the given `config`. * @param config The state config */ State.create = function (config) { return new State(config); }; /** * Creates a new `State` instance for the given `stateValue` and `context` with no actions (side-effects). * @param stateValue * @param context */ State.inert = function (stateValue, context) { if (stateValue instanceof State) { if (!stateValue.actions.length) { return stateValue; } var _event = _actions_js__WEBPACK_IMPORTED_MODULE_4__.initEvent; return new State({ value: stateValue.value, context: context, _event: _event, _sessionid: null, historyValue: stateValue.historyValue, history: stateValue.history, activities: stateValue.activities, configuration: stateValue.configuration, transitions: [], children: {} }); } return State.from(stateValue, context); }; /** * Returns an array of all the string leaf state node paths. * @param stateValue * @param delimiter The character(s) that separate each subpath in the string state node path. */ State.prototype.toStrings = function (stateValue, delimiter) { var _this = this; if (stateValue === void 0) { stateValue = this.value; } if (delimiter === void 0) { delimiter = '.'; } if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(stateValue)) { return [stateValue]; } var valueKeys = Object.keys(stateValue); return valueKeys.concat.apply(valueKeys, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__read)(valueKeys.map(function (key) { return _this.toStrings(stateValue[key], delimiter).map(function (s) { return key + delimiter + s; }); })), false)); }; State.prototype.toJSON = function () { var _a = this; _a.configuration; _a.transitions; var tags = _a.tags; _a.machine; var jsonValues = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__rest)(_a, ["configuration", "transitions", "tags", "machine"]); return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__assign)({}, jsonValues), { tags: Array.from(tags) }); }; State.prototype.matches = function (parentStateValue) { return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.matchesState)(parentStateValue, this.value); }; /** * Whether the current state configuration has a state node with the specified `tag`. * @param tag */ State.prototype.hasTag = function (tag) { return this.tags.has(tag); }; /** * Determines whether sending the `event` will cause a non-forbidden transition * to be selected, even if the transitions have no actions nor * change the state value. * * @param event The event to test * @returns Whether the event will cause a transition */ State.prototype.can = function (event) { var _a; if (_environment_js__WEBPACK_IMPORTED_MODULE_5__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(!!this.machine, "state.can(...) used outside of a machine-created State object; this will always return false."); } var transitionData = (_a = this.machine) === null || _a === void 0 ? void 0 : _a.getTransitionData(this, event); return !!(transitionData === null || transitionData === void 0 ? void 0 : transitionData.transitions.length) && // Check that at least one transition is not forbidden transitionData.transitions.some(function (t) { return t.target !== undefined || t.actions.length; }); }; return State; }(); /***/ }), /***/ "./node_modules/xstate/es/StateNode.js": /*!*********************************************!*\ !*** ./node_modules/xstate/es/StateNode.js ***! \*********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ StateNode: function() { return /* binding */ StateNode; } /* harmony export */ }); /* harmony import */ var _virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_virtual/_tslib.js */ "./node_modules/xstate/es/_virtual/_tslib.js"); /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/xstate/es/utils.js"); /* harmony import */ var _State_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./State.js */ "./node_modules/xstate/es/State.js"); /* harmony import */ var _actionTypes_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./actionTypes.js */ "./node_modules/xstate/es/actionTypes.js"); /* harmony import */ var _actions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actions.js */ "./node_modules/xstate/es/actions.js"); /* harmony import */ var _environment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./environment.js */ "./node_modules/xstate/es/environment.js"); /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ "./node_modules/xstate/es/constants.js"); /* harmony import */ var _stateUtils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stateUtils.js */ "./node_modules/xstate/es/stateUtils.js"); /* harmony import */ var _Actor_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Actor.js */ "./node_modules/xstate/es/Actor.js"); /* harmony import */ var _invokeUtils_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./invokeUtils.js */ "./node_modules/xstate/es/invokeUtils.js"); var NULL_EVENT = ''; var STATE_IDENTIFIER = '#'; var WILDCARD = '*'; var EMPTY_OBJECT = {}; var isStateId = function (str) { return str[0] === STATE_IDENTIFIER; }; var createDefaultOptions = function () { return { actions: {}, guards: {}, services: {}, activities: {}, delays: {} }; }; var validateArrayifiedTransitions = function (stateNode, event, transitions) { var hasNonLastUnguardedTarget = transitions.slice(0, -1).some(function (transition) { return !('cond' in transition) && !('in' in transition) && ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(transition.target) || (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isMachine)(transition.target)); }); var eventText = event === NULL_EVENT ? 'the transient event' : "event '".concat(event, "'"); (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.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."); }; var StateNode = /*#__PURE__*/ /** @class */ function () { function StateNode( /** * The raw config used to create the machine. */ config, options, /** * The initial extended state */ _context, // TODO: this is unsafe, but we're removing it in v5 anyway _stateInfo) { if (_context === void 0) { _context = 'context' in config ? config.context : undefined; } var _this = this; var _a; this.config = config; this._context = _context; /** * The order this state node appears. Corresponds to the implicit SCXML document order. */ this.order = -1; this.__xstatenode = true; this.__cache = { events: undefined, relativeValue: new Map(), initialStateValue: undefined, initialState: undefined, on: undefined, transitions: undefined, candidates: {}, delayedTransitions: undefined }; this.idMap = {}; this.tags = []; this.options = Object.assign(createDefaultOptions(), options); this.parent = _stateInfo === null || _stateInfo === void 0 ? void 0 : _stateInfo.parent; this.key = this.config.key || (_stateInfo === null || _stateInfo === void 0 ? void 0 : _stateInfo.key) || this.config.id || '(machine)'; this.machine = this.parent ? this.parent.machine : this; this.path = this.parent ? this.parent.path.concat(this.key) : []; this.delimiter = this.config.delimiter || (this.parent ? this.parent.delimiter : _constants_js__WEBPACK_IMPORTED_MODULE_1__.STATE_DELIMITER); this.id = this.config.id || (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([this.machine.key], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(this.path), false).join(this.delimiter); this.version = this.parent ? this.parent.version : this.config.version; this.type = this.config.type || (this.config.parallel ? 'parallel' : this.config.states && Object.keys(this.config.states).length ? 'compound' : this.config.history ? 'history' : 'atomic'); this.schema = this.parent ? this.machine.schema : (_a = this.config.schema) !== null && _a !== void 0 ? _a : {}; this.description = this.config.description; if (!_environment_js__WEBPACK_IMPORTED_MODULE_3__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.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.")); } this.initial = this.config.initial; this.states = this.config.states ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.mapValues)(this.config.states, function (stateConfig, key) { var _a; var stateNode = new StateNode(stateConfig, {}, undefined, { parent: _this, key: key }); Object.assign(_this.idMap, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((_a = {}, _a[stateNode.id] = stateNode, _a), stateNode.idMap)); return stateNode; }) : EMPTY_OBJECT; // Document order var order = 0; function dfs(stateNode) { var e_1, _a; stateNode.order = order++; try { for (var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)((0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.getAllChildren)(stateNode)), _c = _b.next(); !_c.done; _c = _b.next()) { var child = _c.value; dfs(child); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } } dfs(this); // History config this.history = this.config.history === true ? 'shallow' : this.config.history || false; this._transient = !!this.config.always || (!this.config.on ? false : Array.isArray(this.config.on) ? this.config.on.some(function (_a) { var event = _a.event; return event === NULL_EVENT; }) : NULL_EVENT in this.config.on); this.strict = !!this.config.strict; // TODO: deprecate (entry) this.onEntry = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toArray)(this.config.entry || this.config.onEntry).map(function (action) { return (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.toActionObject)(action); }); // TODO: deprecate (exit) this.onExit = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toArray)(this.config.exit || this.config.onExit).map(function (action) { return (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.toActionObject)(action); }); this.meta = this.config.meta; this.doneData = this.type === 'final' ? this.config.data : undefined; this.invoke = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toArray)(this.config.invoke).map(function (invokeConfig, i) { var _a, _b; if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isMachine)(invokeConfig)) { var invokeId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.createInvokeId)(_this.id, i); _this.machine.options.services = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((_a = {}, _a[invokeId] = invokeConfig, _a), _this.machine.options.services); return (0,_invokeUtils_js__WEBPACK_IMPORTED_MODULE_6__.toInvokeDefinition)({ src: invokeId, id: invokeId }); } else if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(invokeConfig.src)) { var invokeId = invokeConfig.id || (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.createInvokeId)(_this.id, i); return (0,_invokeUtils_js__WEBPACK_IMPORTED_MODULE_6__.toInvokeDefinition)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, invokeConfig), { id: invokeId, src: invokeConfig.src })); } else if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isMachine)(invokeConfig.src) || (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(invokeConfig.src)) { var invokeId = invokeConfig.id || (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.createInvokeId)(_this.id, i); _this.machine.options.services = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((_b = {}, _b[invokeId] = invokeConfig.src, _b), _this.machine.options.services); return (0,_invokeUtils_js__WEBPACK_IMPORTED_MODULE_6__.toInvokeDefinition)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({ id: invokeId }, invokeConfig), { src: invokeId })); } else { var invokeSource = invokeConfig.src; return (0,_invokeUtils_js__WEBPACK_IMPORTED_MODULE_6__.toInvokeDefinition)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({ id: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.createInvokeId)(_this.id, i) }, invokeConfig), { src: invokeSource })); } }); this.activities = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toArray)(this.config.activities).concat(this.invoke).map(function (activity) { return (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.toActivityDefinition)(activity); }); this.transition = this.transition.bind(this); this.tags = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toArray)(this.config.tags); // TODO: this is the real fix for initialization once // state node getters are deprecated // if (!this.parent) { // this._init(); // } } StateNode.prototype._init = function () { if (this.__cache.transitions) { return; } (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.getAllStateNodes)(this).forEach(function (stateNode) { return stateNode.on; }); }; /** * Clones this state machine with custom options and context. * * @param options Options (actions, guards, activities, services) to recursively merge with the existing options. * @param context Custom context (will override predefined context) */ StateNode.prototype.withConfig = function (options, context) { var _a = this.options, actions = _a.actions, activities = _a.activities, guards = _a.guards, services = _a.services, delays = _a.delays; return new StateNode(this.config, { actions: (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, actions), options.actions), activities: (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, activities), options.activities), guards: (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, guards), options.guards), services: (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, services), options.services), delays: (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, delays), options.delays) }, context !== null && context !== void 0 ? context : this.context); }; /** * Clones this state machine with custom context. * * @param context Custom context (will override predefined context, not recursive) */ StateNode.prototype.withContext = function (context) { return new StateNode(this.config, this.options, context); }; Object.defineProperty(StateNode.prototype, "context", { get: function () { return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(this._context) ? this._context() : this._context; }, enumerable: false, configurable: true }); Object.defineProperty(StateNode.prototype, "definition", { /** * The well-structured state node definition. */ get: function () { return { id: this.id, key: this.key, version: this.version, context: this.context, type: this.type, initial: this.initial, history: this.history, states: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.mapValues)(this.states, function (state) { return state.definition; }), on: this.on, transitions: this.transitions, entry: this.onEntry, exit: this.onExit, activities: this.activities || [], meta: this.meta, order: this.order || -1, data: this.doneData, invoke: this.invoke, description: this.description, tags: this.tags }; }, enumerable: false, configurable: true }); StateNode.prototype.toJSON = function () { return this.definition; }; Object.defineProperty(StateNode.prototype, "on", { /** * The mapping of events to transitions. */ get: function () { if (this.__cache.on) { return this.__cache.on; } var transitions = this.transitions; return this.__cache.on = transitions.reduce(function (map, transition) { map[transition.eventType] = map[transition.eventType] || []; map[transition.eventType].push(transition); return map; }, {}); }, enumerable: false, configurable: true }); Object.defineProperty(StateNode.prototype, "after", { get: function () { return this.__cache.delayedTransitions || (this.__cache.delayedTransitions = this.getDelayedTransitions(), this.__cache.delayedTransitions); }, enumerable: false, configurable: true }); Object.defineProperty(StateNode.prototype, "transitions", { /** * All the transitions that can be taken from this state node. */ get: function () { return this.__cache.transitions || (this.__cache.transitions = this.formatTransitions(), this.__cache.transitions); }, enumerable: false, configurable: true }); StateNode.prototype.getCandidates = function (eventName) { if (this.__cache.candidates[eventName]) { return this.__cache.candidates[eventName]; } var transient = eventName === NULL_EVENT; var candidates = this.transitions.filter(function (transition) { var sameEventType = transition.eventType === eventName; // null events should only match against eventless transitions return transient ? sameEventType : sameEventType || transition.eventType === WILDCARD; }); this.__cache.candidates[eventName] = candidates; return candidates; }; /** * All delayed transitions from the config. */ StateNode.prototype.getDelayedTransitions = function () { var _this = this; var afterConfig = this.config.after; if (!afterConfig) { return []; } var mutateEntryExit = function (delay, i) { var delayRef = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(delay) ? "".concat(_this.id, ":delay[").concat(i, "]") : delay; var eventType = (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.after)(delayRef, _this.id); _this.onEntry.push((0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.send)(eventType, { delay: delay })); _this.onExit.push((0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.cancel)(eventType)); return eventType; }; var delayedTransitions = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isArray)(afterConfig) ? afterConfig.map(function (transition, i) { var eventType = mutateEntryExit(transition.delay, i); return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, transition), { event: eventType }); }) : (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(Object.keys(afterConfig).map(function (delay, i) { var configTransition = afterConfig[delay]; var resolvedTransition = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(configTransition) ? { target: configTransition } : configTransition; var resolvedDelay = !isNaN(+delay) ? +delay : delay; var eventType = mutateEntryExit(resolvedDelay, i); return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toArray)(resolvedTransition).map(function (transition) { return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, transition), { event: eventType, delay: resolvedDelay }); }); })); return delayedTransitions.map(function (delayedTransition) { var delay = delayedTransition.delay; return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, _this.formatTransition(delayedTransition)), { delay: delay }); }); }; /** * Returns the state nodes represented by the current state value. * * @param state The state value or State instance */ StateNode.prototype.getStateNodes = function (state) { var _a; var _this = this; if (!state) { return []; } var stateValue = state instanceof _State_js__WEBPACK_IMPORTED_MODULE_7__.State ? state.value : (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toStateValue)(state, this.delimiter); if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(stateValue)) { var initialStateValue = this.getStateNode(stateValue).initial; return initialStateValue !== undefined ? this.getStateNodes((_a = {}, _a[stateValue] = initialStateValue, _a)) : [this, this.states[stateValue]]; } var subStateKeys = Object.keys(stateValue); var subStateNodes = [this]; subStateNodes.push.apply(subStateNodes, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(subStateKeys.map(function (subStateKey) { return _this.getStateNode(subStateKey).getStateNodes(stateValue[subStateKey]); }))), false)); return subStateNodes; }; /** * Returns `true` if this state node explicitly handles the given event. * * @param event The event in question */ StateNode.prototype.handles = function (event) { var eventType = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.getEventType)(event); return this.events.includes(eventType); }; /** * Resolves the given `state` to a new `State` instance relative to this machine. * * This ensures that `.events` and `.nextEvents` represent the correct values. * * @param state The state to resolve */ StateNode.prototype.resolveState = function (state) { var stateFromConfig = state instanceof _State_js__WEBPACK_IMPORTED_MODULE_7__.State ? state : _State_js__WEBPACK_IMPORTED_MODULE_7__.State.create(state); var configuration = Array.from((0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.getConfiguration)([], this.getStateNodes(stateFromConfig.value))); return new _State_js__WEBPACK_IMPORTED_MODULE_7__.State((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, stateFromConfig), { value: this.resolve(stateFromConfig.value), configuration: configuration, done: (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.isInFinalState)(configuration, this), tags: (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.getTagsFromConfiguration)(configuration), machine: this.machine })); }; StateNode.prototype.transitionLeafNode = function (stateValue, state, _event) { var stateNode = this.getStateNode(stateValue); var next = stateNode.next(state, _event); if (!next || !next.transitions.length) { return this.next(state, _event); } return next; }; StateNode.prototype.transitionCompoundNode = function (stateValue, state, _event) { var subStateKeys = Object.keys(stateValue); var stateNode = this.getStateNode(subStateKeys[0]); var next = stateNode._transition(stateValue[subStateKeys[0]], state, _event); if (!next || !next.transitions.length) { return this.next(state, _event); } return next; }; StateNode.prototype.transitionParallelNode = function (stateValue, state, _event) { var e_2, _a; var transitionMap = {}; try { for (var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(Object.keys(stateValue)), _c = _b.next(); !_c.done; _c = _b.next()) { var subStateKey = _c.value; var subStateValue = stateValue[subStateKey]; if (!subStateValue) { continue; } var subStateNode = this.getStateNode(subStateKey); var next = subStateNode._transition(subStateValue, state, _event); if (next) { transitionMap[subStateKey] = next; } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } var stateTransitions = Object.keys(transitionMap).map(function (key) { return transitionMap[key]; }); var enabledTransitions = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(stateTransitions.map(function (st) { return st.transitions; })); var willTransition = stateTransitions.some(function (st) { return st.transitions.length > 0; }); if (!willTransition) { return this.next(state, _event); } var configuration = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(Object.keys(transitionMap).map(function (key) { return transitionMap[key].configuration; })); return { transitions: enabledTransitions, exitSet: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(stateTransitions.map(function (t) { return t.exitSet; })), configuration: configuration, source: state, actions: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(Object.keys(transitionMap).map(function (key) { return transitionMap[key].actions; })) }; }; StateNode.prototype._transition = function (stateValue, state, _event) { // leaf node if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(stateValue)) { return this.transitionLeafNode(stateValue, state, _event); } // hierarchical node if (Object.keys(stateValue).length === 1) { return this.transitionCompoundNode(stateValue, state, _event); } // orthogonal node return this.transitionParallelNode(stateValue, state, _event); }; StateNode.prototype.getTransitionData = function (state, event) { return this._transition(state.value, state, (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)(event)); }; StateNode.prototype.next = function (state, _event) { var e_3, _a; var _this = this; var eventName = _event.name; var actions = []; var nextStateNodes = []; var selectedTransition; try { for (var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(this.getCandidates(eventName)), _c = _b.next(); !_c.done; _c = _b.next()) { var candidate = _c.value; var cond = candidate.cond, stateIn = candidate.in; var resolvedContext = state.context; var isInState = stateIn ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(stateIn) && isStateId(stateIn) ? // Check if in state by ID state.matches((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toStateValue)(this.getStateNodeById(stateIn).path, this.delimiter)) : // Check if in state by relative grandparent (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.matchesState)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toStateValue)(stateIn, this.delimiter), (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.path)(this.path.slice(0, -2))(state.value)) : true; var guardPassed = false; try { guardPassed = !cond || (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.evaluateGuard)(this.machine, cond, resolvedContext, _event, state); } catch (err) { 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)); } if (guardPassed && isInState) { if (candidate.target !== undefined) { nextStateNodes = candidate.target; } actions.push.apply(actions, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(candidate.actions), false)); selectedTransition = candidate; break; } } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_3) throw e_3.error; } } if (!selectedTransition) { return undefined; } if (!nextStateNodes.length) { return { transitions: [selectedTransition], exitSet: [], configuration: state.value ? [this] : [], source: state, actions: actions }; } var allNextStateNodes = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(nextStateNodes.map(function (stateNode) { return _this.getRelativeStateNodes(stateNode, state.historyValue); })); var isInternal = !!selectedTransition.internal; return { transitions: [selectedTransition], exitSet: isInternal ? [] : (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(nextStateNodes.map(function (targetNode) { return _this.getPotentiallyReenteringNodes(targetNode); })), configuration: allNextStateNodes, source: state, actions: actions }; }; // even though the name of this function mentions reentry nodes // we are pushing its result into `exitSet` // that's because what we exit might be reentered (it's an invariant of reentrancy) StateNode.prototype.getPotentiallyReenteringNodes = function (targetNode) { if (this.order < targetNode.order) { return [this]; } var nodes = []; var marker = this; var possibleAncestor = targetNode; while (marker && marker !== possibleAncestor) { nodes.push(marker); marker = marker.parent; } if (marker !== possibleAncestor) { // we never got to `possibleAncestor`, therefore the initial `marker` "escapes" it // it's in a different part of the tree so no states will be reentered for such an external transition return []; } nodes.push(possibleAncestor); return nodes; }; StateNode.prototype.getActions = function (resolvedConfig, isDone, transition, currentContext, _event, prevState, predictableExec) { var e_4, _a, e_5, _b; var _this = this; var prevConfig = prevState ? (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.getConfiguration)([], this.getStateNodes(prevState.value)) : []; var entrySet = new Set(); try { for (var _c = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(Array.from(resolvedConfig).sort(function (a, b) { return a.order - b.order; })), _d = _c.next(); !_d.done; _d = _c.next()) { var sn = _d.value; if (!(0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.has)(prevConfig, sn) || (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.has)(transition.exitSet, sn) || sn.parent && entrySet.has(sn.parent)) { entrySet.add(sn); } } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_d && !_d.done && (_a = _c.return)) _a.call(_c); } finally { if (e_4) throw e_4.error; } } try { for (var prevConfig_1 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(prevConfig), prevConfig_1_1 = prevConfig_1.next(); !prevConfig_1_1.done; prevConfig_1_1 = prevConfig_1.next()) { var sn = prevConfig_1_1.value; if (!(0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.has)(resolvedConfig, sn) || (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.has)(transition.exitSet, sn.parent)) { transition.exitSet.push(sn); } } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (prevConfig_1_1 && !prevConfig_1_1.done && (_b = prevConfig_1.return)) _b.call(prevConfig_1); } finally { if (e_5) throw e_5.error; } } transition.exitSet.sort(function (a, b) { return b.order - a.order; }); var entryStates = Array.from(entrySet).sort(function (a, b) { return a.order - b.order; }); var exitStates = new Set(transition.exitSet); var doneEvents = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(entryStates.map(function (sn) { var events = []; if (sn.type !== 'final') { return events; } var parent = sn.parent; if (!parent.parent) { return events; } events.push((0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.done)(sn.id, sn.doneData), // TODO: deprecate - final states should not emit done events for their own state. (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.done)(parent.id, sn.doneData ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.mapContext)(sn.doneData, currentContext, _event) : undefined)); var grandparent = parent.parent; if (grandparent.type === 'parallel') { if ((0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.getChildren)(grandparent).every(function (parentNode) { return (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.isInFinalState)(transition.configuration, parentNode); })) { events.push((0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.done)(grandparent.id)); } } return events; })); var entryActions = entryStates.map(function (stateNode) { var entryActions = stateNode.onEntry; var invokeActions = stateNode.activities.map(function (activity) { return (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.start)(activity); }); return { type: 'entry', actions: (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.toActionObjects)(predictableExec ? (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(entryActions), false), (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(invokeActions), false) : (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(invokeActions), false), (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(entryActions), false), _this.machine.options.actions) }; }).concat({ type: 'state_done', actions: doneEvents.map(function (event) { return (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.raise)(event); }) }); var exitActions = Array.from(exitStates).map(function (stateNode) { return { type: 'exit', actions: (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.toActionObjects)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(stateNode.onExit), false), (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(stateNode.activities.map(function (activity) { return (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.stop)(activity); })), false), _this.machine.options.actions) }; }); var actions = exitActions.concat({ type: 'transition', actions: (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.toActionObjects)(transition.actions, this.machine.options.actions) }).concat(entryActions); if (isDone) { var stopActions = (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.toActionObjects)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(resolvedConfig), false).sort(function (a, b) { return b.order - a.order; }).map(function (stateNode) { return stateNode.onExit; })), this.machine.options.actions).filter(function (action) { return !(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isRaisableAction)(action); }); return actions.concat({ type: 'stop', actions: stopActions }); } return actions; }; /** * Determines the next state given the current `state` and sent `event`. * * @param state The current State instance or state value * @param event The event that was sent at the current state * @param context The current context (extended state) of the current state */ StateNode.prototype.transition = function (state, event, context, exec) { if (state === void 0) { state = this.initialState; } var _event = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)(event); var currentState; if (state instanceof _State_js__WEBPACK_IMPORTED_MODULE_7__.State) { currentState = context === undefined ? state : this.resolveState(_State_js__WEBPACK_IMPORTED_MODULE_7__.State.from(state, context)); } else { var resolvedStateValue = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(state) ? this.resolve((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.pathToStateValue)(this.getResolvedPath(state))) : this.resolve(state); var resolvedContext = context !== null && context !== void 0 ? context : this.machine.context; currentState = this.resolveState(_State_js__WEBPACK_IMPORTED_MODULE_7__.State.from(resolvedStateValue, resolvedContext)); } if (!_environment_js__WEBPACK_IMPORTED_MODULE_3__.IS_PRODUCTION && _event.name === WILDCARD) { throw new Error("An event cannot have the wildcard type ('".concat(WILDCARD, "')")); } if (this.strict) { if (!this.events.includes(_event.name) && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isBuiltInEvent)(_event.name)) { throw new Error("Machine '".concat(this.id, "' does not accept event '").concat(_event.name, "'")); } } var stateTransition = this._transition(currentState.value, currentState, _event) || { transitions: [], configuration: [], exitSet: [], source: currentState, actions: [] }; var prevConfig = (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.getConfiguration)([], this.getStateNodes(currentState.value)); var resolvedConfig = stateTransition.configuration.length ? (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.getConfiguration)(prevConfig, stateTransition.configuration) : prevConfig; stateTransition.configuration = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(resolvedConfig), false); return this.resolveTransition(stateTransition, currentState, currentState.context, exec, _event); }; StateNode.prototype.resolveRaisedTransition = function (state, _event, originalEvent, predictableExec) { var _a; var currentActions = state.actions; state = this.transition(state, _event, undefined, predictableExec); // Save original event to state // TODO: this should be the raised event! Delete in V5 (breaking) state._event = originalEvent; state.event = originalEvent.data; (_a = state.actions).unshift.apply(_a, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(currentActions), false)); return state; }; StateNode.prototype.resolveTransition = function (stateTransition, currentState, context, predictableExec, _event) { var e_6, _a, e_7, _b; var _this = this; if (_event === void 0) { _event = _actions_js__WEBPACK_IMPORTED_MODULE_5__.initEvent; } var configuration = stateTransition.configuration; // Transition will "apply" if: // - this is the initial state (there is no current state) // - OR there are transitions var willTransition = !currentState || stateTransition.transitions.length > 0; var resolvedConfiguration = willTransition ? stateTransition.configuration : currentState ? currentState.configuration : []; var isDone = (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.isInFinalState)(resolvedConfiguration, this); var resolvedStateValue = willTransition ? (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.getValue)(this.machine, configuration) : undefined; var historyValue = currentState ? currentState.historyValue ? currentState.historyValue : stateTransition.source ? this.machine.historyValue(currentState.value) : undefined : undefined; var actionBlocks = this.getActions(new Set(resolvedConfiguration), isDone, stateTransition, context, _event, currentState, predictableExec); var activities = currentState ? (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, currentState.activities) : {}; try { for (var actionBlocks_1 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(actionBlocks), actionBlocks_1_1 = actionBlocks_1.next(); !actionBlocks_1_1.done; actionBlocks_1_1 = actionBlocks_1.next()) { var block = actionBlocks_1_1.value; try { for (var _c = (e_7 = void 0, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(block.actions)), _d = _c.next(); !_d.done; _d = _c.next()) { var action = _d.value; if (action.type === _actionTypes_js__WEBPACK_IMPORTED_MODULE_8__.start) { activities[action.activity.id || action.activity.type] = action; } else if (action.type === _actionTypes_js__WEBPACK_IMPORTED_MODULE_8__.stop) { activities[action.activity.id || action.activity.type] = false; } } } catch (e_7_1) { e_7 = { error: e_7_1 }; } finally { try { if (_d && !_d.done && (_b = _c.return)) _b.call(_c); } finally { if (e_7) throw e_7.error; } } } } catch (e_6_1) { e_6 = { error: e_6_1 }; } finally { try { if (actionBlocks_1_1 && !actionBlocks_1_1.done && (_a = actionBlocks_1.return)) _a.call(actionBlocks_1); } finally { if (e_6) throw e_6.error; } } var _e = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)((0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.resolveActions)(this, currentState, context, _event, actionBlocks, predictableExec, this.machine.config.predictableActionArguments || this.machine.config.preserveActionOrder), 2), resolvedActions = _e[0], updatedContext = _e[1]; var _f = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.partition)(resolvedActions, _utils_js__WEBPACK_IMPORTED_MODULE_0__.isRaisableAction), 2), raisedEvents = _f[0], nonRaisedActions = _f[1]; var invokeActions = resolvedActions.filter(function (action) { var _a; return action.type === _actionTypes_js__WEBPACK_IMPORTED_MODULE_8__.start && ((_a = action.activity) === null || _a === void 0 ? void 0 : _a.type) === _actionTypes_js__WEBPACK_IMPORTED_MODULE_8__.invoke; }); var children = invokeActions.reduce(function (acc, action) { acc[action.activity.id] = (0,_Actor_js__WEBPACK_IMPORTED_MODULE_9__.createInvocableActor)(action.activity, _this.machine, updatedContext, _event); return acc; }, currentState ? (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, currentState.children) : {}); var nextState = new _State_js__WEBPACK_IMPORTED_MODULE_7__.State({ value: resolvedStateValue || currentState.value, context: updatedContext, _event: _event, // Persist _sessionid between states _sessionid: currentState ? currentState._sessionid : null, historyValue: resolvedStateValue ? historyValue ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.updateHistoryValue)(historyValue, resolvedStateValue) : undefined : currentState ? currentState.historyValue : undefined, history: !resolvedStateValue || stateTransition.source ? currentState : undefined, actions: resolvedStateValue ? nonRaisedActions : [], activities: resolvedStateValue ? activities : currentState ? currentState.activities : {}, events: [], configuration: resolvedConfiguration, transitions: stateTransition.transitions, children: children, done: isDone, tags: (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.getTagsFromConfiguration)(resolvedConfiguration), machine: this }); var didUpdateContext = context !== updatedContext; nextState.changed = _event.name === _actionTypes_js__WEBPACK_IMPORTED_MODULE_8__.update || didUpdateContext; // Dispose of penultimate histories to prevent memory leaks var history = nextState.history; if (history) { delete history.history; } // There are transient transitions if the machine is not in a final state // and if some of the state nodes have transient ("always") transitions. var hasAlwaysTransitions = !isDone && (this._transient || configuration.some(function (stateNode) { return stateNode._transient; })); // If there are no enabled transitions, check if there are transient transitions. // If there are transient transitions, continue checking for more transitions // because an transient transition should be triggered even if there are no // enabled transitions. // // If we're already working on an transient transition then stop to prevent an infinite loop. // // Otherwise, if there are no enabled nor transient transitions, we are done. if (!willTransition && (!hasAlwaysTransitions || _event.name === NULL_EVENT)) { return nextState; } var maybeNextState = nextState; if (!isDone) { if (hasAlwaysTransitions) { maybeNextState = this.resolveRaisedTransition(maybeNextState, { type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_8__.nullEvent }, _event, predictableExec); } while (raisedEvents.length) { var raisedEvent = raisedEvents.shift(); maybeNextState = this.resolveRaisedTransition(maybeNextState, raisedEvent._event, _event, predictableExec); } } // Detect if state changed var changed = maybeNextState.changed || (history ? !!maybeNextState.actions.length || didUpdateContext || typeof history.value !== typeof maybeNextState.value || !(0,_State_js__WEBPACK_IMPORTED_MODULE_7__.stateValuesEqual)(maybeNextState.value, history.value) : undefined); maybeNextState.changed = changed; // Preserve original history after raised events maybeNextState.history = history; return maybeNextState; }; /** * Returns the child state node from its relative `stateKey`, or throws. */ StateNode.prototype.getStateNode = function (stateKey) { if (isStateId(stateKey)) { return this.machine.getStateNodeById(stateKey); } if (!this.states) { throw new Error("Unable to retrieve child state '".concat(stateKey, "' from '").concat(this.id, "'; no child states exist.")); } var result = this.states[stateKey]; if (!result) { throw new Error("Child state '".concat(stateKey, "' does not exist on '").concat(this.id, "'")); } return result; }; /** * Returns the state node with the given `stateId`, or throws. * * @param stateId The state ID. The prefix "#" is removed. */ StateNode.prototype.getStateNodeById = function (stateId) { var resolvedStateId = isStateId(stateId) ? stateId.slice(STATE_IDENTIFIER.length) : stateId; if (resolvedStateId === this.id) { return this; } var stateNode = this.machine.idMap[resolvedStateId]; if (!stateNode) { throw new Error("Child state node '#".concat(resolvedStateId, "' does not exist on machine '").concat(this.id, "'")); } return stateNode; }; /** * Returns the relative state node from the given `statePath`, or throws. * * @param statePath The string or string array relative path to the state node. */ StateNode.prototype.getStateNodeByPath = function (statePath) { if (typeof statePath === 'string' && isStateId(statePath)) { try { return this.getStateNodeById(statePath.slice(1)); } catch (e) {// try individual paths // throw e; } } var arrayStatePath = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toStatePath)(statePath, this.delimiter).slice(); var currentStateNode = this; while (arrayStatePath.length) { var key = arrayStatePath.shift(); if (!key.length) { break; } currentStateNode = currentStateNode.getStateNode(key); } return currentStateNode; }; /** * Resolves a partial state value with its full representation in this machine. * * @param stateValue The partial state value to resolve. */ StateNode.prototype.resolve = function (stateValue) { var _a; var _this = this; if (!stateValue) { return this.initialStateValue || EMPTY_OBJECT; // TODO: type-specific properties } switch (this.type) { case 'parallel': return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.mapValues)(this.initialStateValue, function (subStateValue, subStateKey) { return subStateValue ? _this.getStateNode(subStateKey).resolve(stateValue[subStateKey] || subStateValue) : EMPTY_OBJECT; }); case 'compound': if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(stateValue)) { var subStateNode = this.getStateNode(stateValue); if (subStateNode.type === 'parallel' || subStateNode.type === 'compound') { return _a = {}, _a[stateValue] = subStateNode.initialStateValue, _a; } return stateValue; } if (!Object.keys(stateValue).length) { return this.initialStateValue || {}; } return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.mapValues)(stateValue, function (subStateValue, subStateKey) { return subStateValue ? _this.getStateNode(subStateKey).resolve(subStateValue) : EMPTY_OBJECT; }); default: return stateValue || EMPTY_OBJECT; } }; StateNode.prototype.getResolvedPath = function (stateIdentifier) { if (isStateId(stateIdentifier)) { var stateNode = this.machine.idMap[stateIdentifier.slice(STATE_IDENTIFIER.length)]; if (!stateNode) { throw new Error("Unable to find state node '".concat(stateIdentifier, "'")); } return stateNode.path; } return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toStatePath)(stateIdentifier, this.delimiter); }; Object.defineProperty(StateNode.prototype, "initialStateValue", { get: function () { var _a; if (this.__cache.initialStateValue) { return this.__cache.initialStateValue; } var initialStateValue; if (this.type === 'parallel') { initialStateValue = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.mapFilterValues)(this.states, function (state) { return state.initialStateValue || EMPTY_OBJECT; }, function (stateNode) { return !(stateNode.type === 'history'); }); } else if (this.initial !== undefined) { if (!this.states[this.initial]) { throw new Error("Initial state '".concat(this.initial, "' not found on '").concat(this.key, "'")); } initialStateValue = (0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.isLeafNode)(this.states[this.initial]) ? this.initial : (_a = {}, _a[this.initial] = this.states[this.initial].initialStateValue, _a); } else { // The finite state value of a machine without child states is just an empty object initialStateValue = {}; } this.__cache.initialStateValue = initialStateValue; return this.__cache.initialStateValue; }, enumerable: false, configurable: true }); StateNode.prototype.getInitialState = function (stateValue, context) { this._init(); // TODO: this should be in the constructor (see note in constructor) var configuration = this.getStateNodes(stateValue); return this.resolveTransition({ configuration: configuration, exitSet: [], transitions: [], source: undefined, actions: [] }, undefined, context !== null && context !== void 0 ? context : this.machine.context, undefined); }; Object.defineProperty(StateNode.prototype, "initialState", { /** * The initial State instance, which includes all actions to be executed from * entering the initial state. */ get: function () { var initialStateValue = this.initialStateValue; if (!initialStateValue) { throw new Error("Cannot retrieve initial state from simple state '".concat(this.id, "'.")); } return this.getInitialState(initialStateValue); }, enumerable: false, configurable: true }); Object.defineProperty(StateNode.prototype, "target", { /** * The target state value of the history state node, if it exists. This represents the * default state value to transition to if no history value exists yet. */ get: function () { var target; if (this.type === 'history') { var historyConfig = this.config; if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(historyConfig.target)) { target = isStateId(historyConfig.target) ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.pathToStateValue)(this.machine.getStateNodeById(historyConfig.target).path.slice(this.path.length - 1)) : historyConfig.target; } else { target = historyConfig.target; } } return target; }, enumerable: false, configurable: true }); /** * Returns the leaf nodes from a state path relative to this state node. * * @param relativeStateId The relative state path to retrieve the state nodes * @param history The previous state to retrieve history * @param resolve Whether state nodes should resolve to initial child state nodes */ StateNode.prototype.getRelativeStateNodes = function (relativeStateId, historyValue, resolve) { if (resolve === void 0) { resolve = true; } return resolve ? relativeStateId.type === 'history' ? relativeStateId.resolveHistory(historyValue) : relativeStateId.initialStateNodes : [relativeStateId]; }; Object.defineProperty(StateNode.prototype, "initialStateNodes", { get: function () { var _this = this; if ((0,_stateUtils_js__WEBPACK_IMPORTED_MODULE_4__.isLeafNode)(this)) { return [this]; } // Case when state node is compound but no initial state is defined if (this.type === 'compound' && !this.initial) { if (!_environment_js__WEBPACK_IMPORTED_MODULE_3__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(false, "Compound state node '".concat(this.id, "' has no initial state.")); } return [this]; } var initialStateNodePaths = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toStatePaths)(this.initialStateValue); return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(initialStateNodePaths.map(function (initialPath) { return _this.getFromRelativePath(initialPath); })); }, enumerable: false, configurable: true }); /** * Retrieves state nodes from a relative path to this state node. * * @param relativePath The relative path from this state node * @param historyValue */ StateNode.prototype.getFromRelativePath = function (relativePath) { if (!relativePath.length) { return [this]; } var _a = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(relativePath), stateKey = _a[0], childStatePath = _a.slice(1); if (!this.states) { throw new Error("Cannot retrieve subPath '".concat(stateKey, "' from node with no states")); } var childStateNode = this.getStateNode(stateKey); if (childStateNode.type === 'history') { return childStateNode.resolveHistory(); } if (!this.states[stateKey]) { throw new Error("Child state '".concat(stateKey, "' does not exist on '").concat(this.id, "'")); } return this.states[stateKey].getFromRelativePath(childStatePath); }; StateNode.prototype.historyValue = function (relativeStateValue) { if (!Object.keys(this.states).length) { return undefined; } return { current: relativeStateValue || this.initialStateValue, states: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.mapFilterValues)(this.states, function (stateNode, key) { if (!relativeStateValue) { return stateNode.historyValue(); } var subStateValue = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(relativeStateValue) ? undefined : relativeStateValue[key]; return stateNode.historyValue(subStateValue || stateNode.initialStateValue); }, function (stateNode) { return !stateNode.history; }) }; }; /** * Resolves to the historical value(s) of the parent state node, * represented by state nodes. * * @param historyValue */ StateNode.prototype.resolveHistory = function (historyValue) { var _this = this; if (this.type !== 'history') { return [this]; } var parent = this.parent; if (!historyValue) { var historyTarget = this.target; return historyTarget ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toStatePaths)(historyTarget).map(function (relativeChildPath) { return parent.getFromRelativePath(relativeChildPath); })) : parent.initialStateNodes; } var subHistoryValue = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.nestedPath)(parent.path, 'states')(historyValue).current; if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(subHistoryValue)) { return [parent.getStateNode(subHistoryValue)]; } return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toStatePaths)(subHistoryValue).map(function (subStatePath) { return _this.history === 'deep' ? parent.getFromRelativePath(subStatePath) : [parent.states[subStatePath[0]]]; })); }; Object.defineProperty(StateNode.prototype, "stateIds", { /** * All the state node IDs of this state node and its descendant state nodes. */ get: function () { var _this = this; var childStateIds = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(Object.keys(this.states).map(function (stateKey) { return _this.states[stateKey].stateIds; })); return [this.id].concat(childStateIds); }, enumerable: false, configurable: true }); Object.defineProperty(StateNode.prototype, "events", { /** * All the event types accepted by this state node and its descendants. */ get: function () { var e_8, _a, e_9, _b; if (this.__cache.events) { return this.__cache.events; } var states = this.states; var events = new Set(this.ownEvents); if (states) { try { for (var _c = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(Object.keys(states)), _d = _c.next(); !_d.done; _d = _c.next()) { var stateId = _d.value; var state = states[stateId]; if (state.states) { try { for (var _e = (e_9 = void 0, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(state.events)), _f = _e.next(); !_f.done; _f = _e.next()) { var event_1 = _f.value; events.add("".concat(event_1)); } } catch (e_9_1) { e_9 = { error: e_9_1 }; } finally { try { if (_f && !_f.done && (_b = _e.return)) _b.call(_e); } finally { if (e_9) throw e_9.error; } } } } } catch (e_8_1) { e_8 = { error: e_8_1 }; } finally { try { if (_d && !_d.done && (_a = _c.return)) _a.call(_c); } finally { if (e_8) throw e_8.error; } } } return this.__cache.events = Array.from(events); }, enumerable: false, configurable: true }); Object.defineProperty(StateNode.prototype, "ownEvents", { /** * All the events that have transitions directly from this state node. * * Excludes any inert events. */ get: function () { var events = new Set(this.transitions.filter(function (transition) { return !(!transition.target && !transition.actions.length && transition.internal); }).map(function (transition) { return transition.eventType; })); return Array.from(events); }, enumerable: false, configurable: true }); StateNode.prototype.resolveTarget = function (_target) { var _this = this; if (_target === undefined) { // an undefined target signals that the state node should not transition from that state when receiving that event return undefined; } return _target.map(function (target) { if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(target)) { return target; } var isInternalTarget = target[0] === _this.delimiter; // If internal target is defined on machine, // do not include machine key on target if (isInternalTarget && !_this.parent) { return _this.getStateNodeByPath(target.slice(1)); } var resolvedTarget = isInternalTarget ? _this.key + target : target; if (_this.parent) { try { var targetStateNode = _this.parent.getStateNodeByPath(resolvedTarget); return targetStateNode; } catch (err) { throw new Error("Invalid transition definition for state node '".concat(_this.id, "':\n").concat(err.message)); } } else { return _this.getStateNodeByPath(resolvedTarget); } }); }; StateNode.prototype.formatTransition = function (transitionConfig) { var _this = this; var normalizedTarget = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.normalizeTarget)(transitionConfig.target); var internal = 'internal' in transitionConfig ? transitionConfig.internal : normalizedTarget ? normalizedTarget.some(function (_target) { return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(_target) && _target[0] === _this.delimiter; }) : true; var guards = this.machine.options.guards; var target = this.resolveTarget(normalizedTarget); var transition = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, transitionConfig), { actions: (0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.toActionObjects)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toArray)(transitionConfig.actions)), cond: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toGuard)(transitionConfig.cond, guards), target: target, source: this, internal: internal, eventType: transitionConfig.event, toJSON: function () { return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, transition), { target: transition.target ? transition.target.map(function (t) { return "#".concat(t.id); }) : undefined, source: "#".concat(_this.id) }); } }); return transition; }; StateNode.prototype.formatTransitions = function () { var e_10, _a; var _this = this; var onConfig; if (!this.config.on) { onConfig = []; } else if (Array.isArray(this.config.on)) { onConfig = this.config.on; } else { var _b = this.config.on, _c = WILDCARD, _d = _b[_c], wildcardConfigs = _d === void 0 ? [] : _d, strictTransitionConfigs_1 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__rest)(_b, [typeof _c === "symbol" ? _c : _c + ""]); onConfig = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(Object.keys(strictTransitionConfigs_1).map(function (key) { if (!_environment_js__WEBPACK_IMPORTED_MODULE_3__.IS_PRODUCTION && key === NULL_EVENT) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.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, "\".")); } var transitionConfigArray = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toTransitionConfigArray)(key, strictTransitionConfigs_1[key]); if (!_environment_js__WEBPACK_IMPORTED_MODULE_3__.IS_PRODUCTION) { validateArrayifiedTransitions(_this, key, transitionConfigArray); } return transitionConfigArray; }).concat((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toTransitionConfigArray)(WILDCARD, wildcardConfigs))); } var eventlessConfig = this.config.always ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toTransitionConfigArray)('', this.config.always) : []; var doneConfig = this.config.onDone ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toTransitionConfigArray)(String((0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.done)(this.id)), this.config.onDone) : []; if (!_environment_js__WEBPACK_IMPORTED_MODULE_3__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(!(this.config.onDone && !this.parent), "Root nodes cannot have an \".onDone\" transition. Please check the config of \"".concat(this.id, "\".")); } var invokeConfig = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(this.invoke.map(function (invokeDef) { var settleTransitions = []; if (invokeDef.onDone) { settleTransitions.push.apply(settleTransitions, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toTransitionConfigArray)(String((0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.doneInvoke)(invokeDef.id)), invokeDef.onDone)), false)); } if (invokeDef.onError) { settleTransitions.push.apply(settleTransitions, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toTransitionConfigArray)(String((0,_actions_js__WEBPACK_IMPORTED_MODULE_5__.error)(invokeDef.id)), invokeDef.onError)), false)); } return settleTransitions; })); var delayedTransitions = this.after; var formattedTransitions = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(doneConfig), false), (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(invokeConfig), false), (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(onConfig), false), (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(eventlessConfig), false).map(function (transitionConfig) { return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toArray)(transitionConfig).map(function (transition) { return _this.formatTransition(transition); }); })); try { for (var delayedTransitions_1 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(delayedTransitions), delayedTransitions_1_1 = delayedTransitions_1.next(); !delayedTransitions_1_1.done; delayedTransitions_1_1 = delayedTransitions_1.next()) { var delayedTransition = delayedTransitions_1_1.value; formattedTransitions.push(delayedTransition); } } catch (e_10_1) { e_10 = { error: e_10_1 }; } finally { try { if (delayedTransitions_1_1 && !delayedTransitions_1_1.done && (_a = delayedTransitions_1.return)) _a.call(delayedTransitions_1); } finally { if (e_10) throw e_10.error; } } return formattedTransitions; }; return StateNode; }(); /***/ }), /***/ "./node_modules/xstate/es/_virtual/_tslib.js": /*!***************************************************!*\ !*** ./node_modules/xstate/es/_virtual/_tslib.js ***! \***************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ __assign: function() { return /* binding */ __assign; }, /* harmony export */ __read: function() { return /* binding */ __read; }, /* harmony export */ __rest: function() { return /* binding */ __rest; }, /* harmony export */ __spreadArray: function() { return /* binding */ __spreadArray; }, /* harmony export */ __values: function() { return /* binding */ __values; } /* harmony export */ }); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } /***/ }), /***/ "./node_modules/xstate/es/actionTypes.js": /*!***********************************************!*\ !*** ./node_modules/xstate/es/actionTypes.js ***! \***********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ assign: function() { return /* binding */ assign; }, /* harmony export */ cancel: function() { return /* binding */ cancel; }, /* harmony export */ choose: function() { return /* binding */ choose; }, /* harmony export */ error: function() { return /* binding */ error; }, /* harmony export */ errorPlatform: function() { return /* binding */ errorPlatform; }, /* harmony export */ init: function() { return /* binding */ init; }, /* harmony export */ invoke: function() { return /* binding */ invoke; }, /* harmony export */ log: function() { return /* binding */ log; }, /* harmony export */ nullEvent: function() { return /* binding */ nullEvent; }, /* harmony export */ pure: function() { return /* binding */ pure; }, /* harmony export */ raise: function() { return /* binding */ raise; }, /* harmony export */ send: function() { return /* binding */ send; }, /* harmony export */ start: function() { return /* binding */ start; }, /* harmony export */ stop: function() { return /* binding */ stop; }, /* harmony export */ update: function() { return /* binding */ update; } /* harmony export */ }); /* unused harmony exports after, doneState, errorExecution */ /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types.js */ "./node_modules/xstate/es/types.js"); var start = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Start; var stop = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Stop; var raise = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Raise; var send = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Send; var cancel = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Cancel; var nullEvent = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.NullEvent; var assign = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Assign; var after = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.After; var doneState = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.DoneState; var log = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Log; var init = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Init; var invoke = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Invoke; var errorExecution = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.ErrorExecution; var errorPlatform = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.ErrorPlatform; var error = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.ErrorCustom; var update = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Update; var choose = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Choose; var pure = _types_js__WEBPACK_IMPORTED_MODULE_0__.ActionTypes.Pure; /***/ }), /***/ "./node_modules/xstate/es/actions.js": /*!*******************************************!*\ !*** ./node_modules/xstate/es/actions.js ***! \*******************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ after: function() { return /* binding */ after; }, /* harmony export */ assign: function() { return /* binding */ assign; }, /* harmony export */ cancel: function() { return /* binding */ cancel; }, /* harmony export */ choose: function() { return /* binding */ choose; }, /* harmony export */ done: function() { return /* binding */ done; }, /* harmony export */ doneInvoke: function() { return /* binding */ doneInvoke; }, /* harmony export */ error: function() { return /* binding */ error; }, /* harmony export */ forwardTo: function() { return /* binding */ forwardTo; }, /* harmony export */ getActionFunction: function() { return /* binding */ getActionFunction; }, /* harmony export */ initEvent: function() { return /* binding */ initEvent; }, /* harmony export */ log: function() { return /* binding */ log; }, /* harmony export */ pure: function() { return /* binding */ pure; }, /* harmony export */ raise: function() { return /* binding */ raise; }, /* harmony export */ resolveActions: function() { return /* binding */ resolveActions; }, /* harmony export */ send: function() { return /* binding */ send; }, /* harmony export */ sendParent: function() { return /* binding */ sendParent; }, /* harmony export */ sendTo: function() { return /* binding */ sendTo; }, /* harmony export */ sendUpdate: function() { return /* binding */ sendUpdate; }, /* harmony export */ start: function() { return /* binding */ start; }, /* harmony export */ stop: function() { return /* binding */ stop; }, /* harmony export */ toActionObject: function() { return /* binding */ toActionObject; }, /* harmony export */ toActionObjects: function() { return /* binding */ toActionObjects; }, /* harmony export */ toActivityDefinition: function() { return /* binding */ toActivityDefinition; } /* harmony export */ }); /* unused harmony exports escalate, isActionObject, resolveLog, resolveRaise, resolveSend, resolveStop, respond */ /* harmony import */ var _virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_virtual/_tslib.js */ "./node_modules/xstate/es/_virtual/_tslib.js"); /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./types.js */ "./node_modules/xstate/es/types.js"); /* harmony import */ var _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionTypes.js */ "./node_modules/xstate/es/actionTypes.js"); /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/xstate/es/utils.js"); /* harmony import */ var _environment_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./environment.js */ "./node_modules/xstate/es/environment.js"); var initEvent = /*#__PURE__*/(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)({ type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.init }); function getActionFunction(actionType, actionFunctionMap) { return actionFunctionMap ? actionFunctionMap[actionType] || undefined : undefined; } function toActionObject(action, actionFunctionMap) { var actionObject; if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(action) || typeof action === 'number') { var exec = getActionFunction(action, actionFunctionMap); if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(exec)) { actionObject = { type: action, exec: exec }; } else if (exec) { actionObject = exec; } else { actionObject = { type: action, exec: undefined }; } } else if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(action)) { actionObject = { // Convert action to string if unnamed type: action.name || action.toString(), exec: action }; } else { var exec = getActionFunction(action.type, actionFunctionMap); if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(exec)) { actionObject = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, action), { exec: exec }); } else if (exec) { var actionType = exec.type || action.type; actionObject = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, exec), action), { type: actionType }); } else { actionObject = action; } } return actionObject; } var toActionObjects = function (action, actionFunctionMap) { if (!action) { return []; } var actions = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isArray)(action) ? action : [action]; return actions.map(function (subAction) { return toActionObject(subAction, actionFunctionMap); }); }; function toActivityDefinition(action) { var actionObject = toActionObject(action); return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({ id: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(action) ? action : actionObject.id }, actionObject), { type: actionObject.type }); } /** * Raises an event. This places the event in the internal event queue, so that * the event is immediately consumed by the machine in the current step. * * @param eventType The event to raise. */ function raise(event, options) { return { type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.raise, event: typeof event === 'function' ? event : (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toEventObject)(event), delay: options ? options.delay : undefined, id: options === null || options === void 0 ? void 0 : options.id }; } function resolveRaise(action, ctx, _event, delaysMap) { var meta = { _event: _event }; var resolvedEvent = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(action.event) ? action.event(ctx, _event.data, meta) : action.event); var resolvedDelay; if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(action.delay)) { var configDelay = delaysMap && delaysMap[action.delay]; resolvedDelay = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(configDelay) ? configDelay(ctx, _event.data, meta) : configDelay; } else { resolvedDelay = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(action.delay) ? action.delay(ctx, _event.data, meta) : action.delay; } return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, action), { type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.raise, _event: resolvedEvent, delay: resolvedDelay }); } /** * Sends an event. This returns an action that will be read by an interpreter to * send the event in the next step, after the current step is finished executing. * * @deprecated Use the `sendTo(...)` action creator instead. * * @param event The event to send. * @param options Options to pass into the send event: * - `id` - The unique send event identifier (used with `cancel()`). * - `delay` - The number of milliseconds to delay the sending of the event. * - `to` - The target of this event (by default, the machine the event was sent from). */ function send(event, options) { return { to: options ? options.to : undefined, type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.send, event: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(event) ? event : (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toEventObject)(event), delay: options ? options.delay : undefined, // TODO: don't auto-generate IDs here like that // there is too big chance of the ID collision id: options && options.id !== undefined ? options.id : (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(event) ? event.name : (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.getEventType)(event) }; } function resolveSend(action, ctx, _event, delaysMap) { var meta = { _event: _event }; // TODO: helper function for resolving Expr var resolvedEvent = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(action.event) ? action.event(ctx, _event.data, meta) : action.event); var resolvedDelay; if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(action.delay)) { var configDelay = delaysMap && delaysMap[action.delay]; resolvedDelay = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(configDelay) ? configDelay(ctx, _event.data, meta) : configDelay; } else { resolvedDelay = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(action.delay) ? action.delay(ctx, _event.data, meta) : action.delay; } var resolvedTarget = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(action.to) ? action.to(ctx, _event.data, meta) : action.to; return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, action), { to: resolvedTarget, _event: resolvedEvent, event: resolvedEvent.data, delay: resolvedDelay }); } /** * Sends an event to this machine's parent. * * @param event The event to send to the parent machine. * @param options Options to pass into the send event. */ function sendParent(event, options) { return send(event, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, options), { to: _types_js__WEBPACK_IMPORTED_MODULE_3__.SpecialTargets.Parent })); } /** * Sends an event to an actor. * * @param actor The `ActorRef` to send the event to. * @param event The event to send, or an expression that evaluates to the event to send * @param options Send action options * @returns An XState send action object */ function sendTo(actor, event, options) { return send(event, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, options), { to: actor })); } /** * Sends an update event to this machine's parent. */ function sendUpdate() { return sendParent(_actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.update); } /** * Sends an event back to the sender of the original event. * * @param event The event to send back to the sender * @param options Options to pass into the send event */ function respond(event, options) { return send(event, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, options), { to: function (_, __, _a) { var _event = _a._event; return _event.origin; // TODO: handle when _event.origin is undefined } })); } var defaultLogExpr = function (context, event) { return { context: context, event: event }; }; /** * * @param expr The expression function to evaluate which will be logged. * Takes in 2 arguments: * - `ctx` - the current state context * - `event` - the event that caused this action to be executed. * @param label The label to give to the logged expression. */ function log(expr, label) { if (expr === void 0) { expr = defaultLogExpr; } return { type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.log, label: label, expr: expr }; } var resolveLog = function (action, ctx, _event) { return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, action), { value: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(action.expr) ? action.expr : action.expr(ctx, _event.data, { _event: _event }) }); }; /** * Cancels an in-flight `send(...)` action. A canceled sent action will not * be executed, nor will its event be sent, unless it has already been sent * (e.g., if `cancel(...)` is called after the `send(...)` action's `delay`). * * @param sendId The `id` of the `send(...)` action to cancel. */ var cancel = function (sendId) { return { type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.cancel, sendId: sendId }; }; /** * Starts an activity. * * @param activity The activity to start. */ function start(activity) { var activityDef = toActivityDefinition(activity); return { type: _types_js__WEBPACK_IMPORTED_MODULE_3__.ActionTypes.Start, activity: activityDef, exec: undefined }; } /** * Stops an activity. * * @param actorRef The activity to stop. */ function stop(actorRef) { var activity = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(actorRef) ? actorRef : toActivityDefinition(actorRef); return { type: _types_js__WEBPACK_IMPORTED_MODULE_3__.ActionTypes.Stop, activity: activity, exec: undefined }; } function resolveStop(action, context, _event) { var actorRefOrString = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(action.activity) ? action.activity(context, _event.data) : action.activity; var resolvedActorRef = typeof actorRefOrString === 'string' ? { id: actorRefOrString } : actorRefOrString; var actionObject = { type: _types_js__WEBPACK_IMPORTED_MODULE_3__.ActionTypes.Stop, activity: resolvedActorRef }; return actionObject; } /** * Updates the current context of the machine. * * @param assignment An object that represents the partial context to update. */ var assign = function (assignment) { return { type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.assign, assignment: assignment }; }; function isActionObject(action) { return typeof action === 'object' && 'type' in action; } /** * Returns an event type that represents an implicit event that * is sent after the specified `delay`. * * @param delayRef The delay in milliseconds * @param id The state node ID where this event is handled */ function after(delayRef, id) { var idSuffix = id ? "#".concat(id) : ''; return "".concat(_types_js__WEBPACK_IMPORTED_MODULE_3__.ActionTypes.After, "(").concat(delayRef, ")").concat(idSuffix); } /** * Returns an event that represents that a final state node * has been reached in the parent state node. * * @param id The final state node's parent state node `id` * @param data The data to pass into the event */ function done(id, data) { var type = "".concat(_types_js__WEBPACK_IMPORTED_MODULE_3__.ActionTypes.DoneState, ".").concat(id); var eventObject = { type: type, data: data }; eventObject.toString = function () { return type; }; return eventObject; } /** * Returns an event that represents that an invoked service has terminated. * * An invoked service is terminated when it has reached a top-level final state node, * but not when it is canceled. * * @param id The final state node ID * @param data The data to pass into the event */ function doneInvoke(id, data) { var type = "".concat(_types_js__WEBPACK_IMPORTED_MODULE_3__.ActionTypes.DoneInvoke, ".").concat(id); var eventObject = { type: type, data: data }; eventObject.toString = function () { return type; }; return eventObject; } function error(id, data) { var type = "".concat(_types_js__WEBPACK_IMPORTED_MODULE_3__.ActionTypes.ErrorPlatform, ".").concat(id); var eventObject = { type: type, data: data }; eventObject.toString = function () { return type; }; return eventObject; } function pure(getActions) { return { type: _types_js__WEBPACK_IMPORTED_MODULE_3__.ActionTypes.Pure, get: getActions }; } /** * Forwards (sends) an event to a specified service. * * @param target The target service to forward the event to. * @param options Options to pass into the send action creator. */ function forwardTo(target, options) { if (!_environment_js__WEBPACK_IMPORTED_MODULE_4__.IS_PRODUCTION && (!target || typeof target === 'function')) { var originalTarget_1 = target; target = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var resolvedTarget = typeof originalTarget_1 === 'function' ? originalTarget_1.apply(void 0, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(args), false)) : originalTarget_1; if (!resolvedTarget) { throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender."); } return resolvedTarget; }; } return send(function (_, event) { return event; }, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, options), { to: target })); } /** * Escalates an error by sending it as an event to this machine's parent. * * @param errorData The error data to send, or the expression function that * takes in the `context`, `event`, and `meta`, and returns the error data to send. * @param options Options to pass into the send action creator. */ function escalate(errorData, options) { return sendParent(function (context, event, meta) { return { type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.error, data: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(errorData) ? errorData(context, event, meta) : errorData }; }, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, options), { to: _types_js__WEBPACK_IMPORTED_MODULE_3__.SpecialTargets.Parent })); } function choose(conds) { return { type: _types_js__WEBPACK_IMPORTED_MODULE_3__.ActionTypes.Choose, conds: conds }; } var pluckAssigns = function (actionBlocks) { var e_1, _a; var assignActions = []; try { for (var actionBlocks_1 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(actionBlocks), actionBlocks_1_1 = actionBlocks_1.next(); !actionBlocks_1_1.done; actionBlocks_1_1 = actionBlocks_1.next()) { var block = actionBlocks_1_1.value; var i = 0; while (i < block.actions.length) { if (block.actions[i].type === _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.assign) { assignActions.push(block.actions[i]); block.actions.splice(i, 1); continue; } i++; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (actionBlocks_1_1 && !actionBlocks_1_1.done && (_a = actionBlocks_1.return)) _a.call(actionBlocks_1); } finally { if (e_1) throw e_1.error; } } return assignActions; }; function resolveActions(machine, currentState, currentContext, _event, actionBlocks, predictableExec, preserveActionOrder) { if (preserveActionOrder === void 0) { preserveActionOrder = false; } var assignActions = preserveActionOrder ? [] : pluckAssigns(actionBlocks); var updatedContext = assignActions.length ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.updateContext)(currentContext, _event, assignActions, currentState) : currentContext; var preservedContexts = preserveActionOrder ? [currentContext] : undefined; var deferredToBlockEnd = []; function handleAction(blockType, actionObject) { var _a; switch (actionObject.type) { case _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.raise: { var raisedAction = resolveRaise(actionObject, updatedContext, _event, machine.options.delays); if (predictableExec && typeof raisedAction.delay === 'number') { predictableExec(raisedAction, updatedContext, _event); } return raisedAction; } case _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.send: var sendAction = resolveSend(actionObject, updatedContext, _event, machine.options.delays); // TODO: fix ActionTypes.Init if (!_environment_js__WEBPACK_IMPORTED_MODULE_4__.IS_PRODUCTION) { var configuredDelay = actionObject.delay; // warn after resolving as we can create better contextual message here (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(!(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(configuredDelay) || typeof sendAction.delay === 'number', // tslint:disable-next-line:max-line-length "No delay reference for delay expression '".concat(configuredDelay, "' was found on machine '").concat(machine.id, "'")); } if (predictableExec && sendAction.to !== _types_js__WEBPACK_IMPORTED_MODULE_3__.SpecialTargets.Internal) { if (blockType === 'entry') { deferredToBlockEnd.push(sendAction); } else { predictableExec(sendAction, updatedContext, _event); } } return sendAction; case _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.log: { var resolved = resolveLog(actionObject, updatedContext, _event); predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(resolved, updatedContext, _event); return resolved; } case _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.choose: { var chooseAction = actionObject; var matchedActions = (_a = chooseAction.conds.find(function (condition) { var guard = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toGuard)(condition.cond, machine.options.guards); return !guard || (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.evaluateGuard)(machine, guard, updatedContext, _event, !predictableExec ? currentState : undefined); })) === null || _a === void 0 ? void 0 : _a.actions; if (!matchedActions) { return []; } var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(resolveActions(machine, currentState, updatedContext, _event, [{ type: blockType, actions: toActionObjects((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toArray)(matchedActions), machine.options.actions) }], predictableExec, preserveActionOrder), 2), resolvedActionsFromChoose = _b[0], resolvedContextFromChoose = _b[1]; updatedContext = resolvedContextFromChoose; preservedContexts === null || preservedContexts === void 0 ? void 0 : preservedContexts.push(updatedContext); return resolvedActionsFromChoose; } case _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.pure: { var matchedActions = actionObject.get(updatedContext, _event.data); if (!matchedActions) { return []; } var _c = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(resolveActions(machine, currentState, updatedContext, _event, [{ type: blockType, actions: toActionObjects((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toArray)(matchedActions), machine.options.actions) }], predictableExec, preserveActionOrder), 2), resolvedActionsFromPure = _c[0], resolvedContext = _c[1]; updatedContext = resolvedContext; preservedContexts === null || preservedContexts === void 0 ? void 0 : preservedContexts.push(updatedContext); return resolvedActionsFromPure; } case _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.stop: { var resolved = resolveStop(actionObject, updatedContext, _event); predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(resolved, currentContext, _event); return resolved; } case _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.assign: { updatedContext = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.updateContext)(updatedContext, _event, [actionObject], !predictableExec ? currentState : undefined); preservedContexts === null || preservedContexts === void 0 ? void 0 : preservedContexts.push(updatedContext); break; } default: var resolvedActionObject = toActionObject(actionObject, machine.options.actions); var exec_1 = resolvedActionObject.exec; if (predictableExec) { predictableExec(resolvedActionObject, updatedContext, _event); } else if (exec_1 && preservedContexts) { var contextIndex_1 = preservedContexts.length - 1; var wrapped = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, resolvedActionObject), { exec: function (_ctx) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } exec_1.apply(void 0, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__spreadArray)([preservedContexts[contextIndex_1]], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__read)(args), false)); } }); resolvedActionObject = wrapped; } return resolvedActionObject; } } function processBlock(block) { var e_2, _a; var resolvedActions = []; try { for (var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_2__.__values)(block.actions), _c = _b.next(); !_c.done; _c = _b.next()) { var action = _c.value; var resolved = handleAction(block.type, action); if (resolved) { resolvedActions = resolvedActions.concat(resolved); } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } deferredToBlockEnd.forEach(function (action) { predictableExec(action, updatedContext, _event); }); deferredToBlockEnd.length = 0; return resolvedActions; } var resolvedActions = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(actionBlocks.map(processBlock)); return [resolvedActions, updatedContext]; } /***/ }), /***/ "./node_modules/xstate/es/behaviors.js": /*!*********************************************!*\ !*** ./node_modules/xstate/es/behaviors.js ***! \*********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ spawnBehavior: function() { return /* binding */ spawnBehavior; } /* harmony export */ }); /* unused harmony exports fromPromise, fromReducer */ /* harmony import */ var _actions_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./actions.js */ "./node_modules/xstate/es/actions.js"); /* harmony import */ var _Actor_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actor.js */ "./node_modules/xstate/es/Actor.js"); /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ "./node_modules/xstate/es/utils.js"); /** * Returns an actor behavior from a reducer and its initial state. * * @param transition The pure reducer that returns the next state given the current state and event. * @param initialState The initial state of the reducer. * @returns An actor behavior */ function fromReducer(transition, initialState) { return { transition: transition, initialState: initialState }; } function fromPromise(promiseFn) { var initialState = { error: undefined, data: undefined, status: 'pending' }; return { transition: function (state, event, _a) { var parent = _a.parent, id = _a.id, observers = _a.observers; switch (event.type) { case 'fulfill': parent === null || parent === void 0 ? void 0 : parent.send((0,_actions_js__WEBPACK_IMPORTED_MODULE_0__.doneInvoke)(id, event.data)); return { error: undefined, data: event.data, status: 'fulfilled' }; case 'reject': parent === null || parent === void 0 ? void 0 : parent.send((0,_actions_js__WEBPACK_IMPORTED_MODULE_0__.error)(id, event.error)); observers.forEach(function (observer) { observer.error(event.error); }); return { error: event.error, data: undefined, status: 'rejected' }; default: return state; } }, initialState: initialState, start: function (_a) { var self = _a.self; promiseFn().then(function (data) { self.send({ type: 'fulfill', data: data }); }, function (reason) { self.send({ type: 'reject', error: reason }); }); return initialState; } }; } function spawnBehavior(behavior, options) { if (options === void 0) { options = {}; } var state = behavior.initialState; var observers = new Set(); var mailbox = []; var flushing = false; var flush = function () { if (flushing) { return; } flushing = true; while (mailbox.length > 0) { var event_1 = mailbox.shift(); state = behavior.transition(state, event_1, actorCtx); observers.forEach(function (observer) { return observer.next(state); }); } flushing = false; }; var actor = (0,_Actor_js__WEBPACK_IMPORTED_MODULE_1__.toActorRef)({ id: options.id, send: function (event) { mailbox.push(event); flush(); }, getSnapshot: function () { return state; }, subscribe: function (next, handleError, complete) { var observer = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.toObserver)(next, handleError, complete); observers.add(observer); observer.next(state); return { unsubscribe: function () { observers.delete(observer); } }; } }); var actorCtx = { parent: options.parent, self: actor, id: options.id || 'anonymous', observers: observers }; state = behavior.start ? behavior.start(actorCtx) : state; return actor; } /***/ }), /***/ "./node_modules/xstate/es/constants.js": /*!*********************************************!*\ !*** ./node_modules/xstate/es/constants.js ***! \*********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ DEFAULT_GUARD_TYPE: function() { return /* binding */ DEFAULT_GUARD_TYPE; }, /* harmony export */ EMPTY_ACTIVITY_MAP: function() { return /* binding */ EMPTY_ACTIVITY_MAP; }, /* harmony export */ STATE_DELIMITER: function() { return /* binding */ STATE_DELIMITER; }, /* harmony export */ TARGETLESS_KEY: function() { return /* binding */ TARGETLESS_KEY; } /* harmony export */ }); var STATE_DELIMITER = '.'; var EMPTY_ACTIVITY_MAP = {}; var DEFAULT_GUARD_TYPE = 'xstate.guard'; var TARGETLESS_KEY = ''; /***/ }), /***/ "./node_modules/xstate/es/devTools.js": /*!********************************************!*\ !*** ./node_modules/xstate/es/devTools.js ***! \********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getGlobal: function() { return /* binding */ getGlobal; }, /* harmony export */ registerService: function() { return /* binding */ registerService; } /* harmony export */ }); /* harmony import */ var _environment_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environment.js */ "./node_modules/xstate/es/environment.js"); /* provided dependency */ var window = __webpack_require__(/*! @tarojs/runtime */ "webpack/container/remote/@tarojs/runtime")["window"]; function getGlobal() { if (typeof globalThis !== 'undefined') { return globalThis; } if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof __webpack_require__.g !== 'undefined') { return __webpack_require__.g; } if (!_environment_js__WEBPACK_IMPORTED_MODULE_0__.IS_PRODUCTION) { 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'); } } function getDevTools() { var global = getGlobal(); if (global && '__xstate__' in global) { return global.__xstate__; } return undefined; } function registerService(service) { if (!getGlobal()) { return; } var devTools = getDevTools(); if (devTools) { devTools.register(service); } } /***/ }), /***/ "./node_modules/xstate/es/environment.js": /*!***********************************************!*\ !*** ./node_modules/xstate/es/environment.js ***! \***********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ IS_PRODUCTION: function() { return /* binding */ IS_PRODUCTION; } /* harmony export */ }); var IS_PRODUCTION = "development" === 'production'; /***/ }), /***/ "./node_modules/xstate/es/index.js": /*!*****************************************!*\ !*** ./node_modules/xstate/es/index.js ***! \*****************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ assign: function() { return /* binding */ assign; } /* harmony export */ }); /* unused harmony exports cancel, choose, doneInvoke, forwardTo, log, pure, raise, send, sendParent, sendTo, sendUpdate, stop */ /* harmony import */ var _actions_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./actions.js */ "./node_modules/xstate/es/actions.js"); var assign = _actions_js__WEBPACK_IMPORTED_MODULE_0__.assign, cancel = _actions_js__WEBPACK_IMPORTED_MODULE_0__.cancel, send = _actions_js__WEBPACK_IMPORTED_MODULE_0__.send, sendTo = _actions_js__WEBPACK_IMPORTED_MODULE_0__.sendTo, sendParent = _actions_js__WEBPACK_IMPORTED_MODULE_0__.sendParent, sendUpdate = _actions_js__WEBPACK_IMPORTED_MODULE_0__.sendUpdate, forwardTo = _actions_js__WEBPACK_IMPORTED_MODULE_0__.forwardTo, doneInvoke = _actions_js__WEBPACK_IMPORTED_MODULE_0__.doneInvoke, raise = _actions_js__WEBPACK_IMPORTED_MODULE_0__.raise, log = _actions_js__WEBPACK_IMPORTED_MODULE_0__.log, pure = _actions_js__WEBPACK_IMPORTED_MODULE_0__.pure, choose = _actions_js__WEBPACK_IMPORTED_MODULE_0__.choose, stop = _actions_js__WEBPACK_IMPORTED_MODULE_0__.stop; /***/ }), /***/ "./node_modules/xstate/es/interpreter.js": /*!***********************************************!*\ !*** ./node_modules/xstate/es/interpreter.js ***! \***********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ interpret: function() { return /* binding */ interpret; } /* harmony export */ }); /* unused harmony exports Interpreter, InterpreterStatus, spawn */ /* harmony import */ var _virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./_virtual/_tslib.js */ "./node_modules/xstate/es/_virtual/_tslib.js"); /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/xstate/es/types.js"); /* harmony import */ var _State_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./State.js */ "./node_modules/xstate/es/State.js"); /* harmony import */ var _actionTypes_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actionTypes.js */ "./node_modules/xstate/es/actionTypes.js"); /* harmony import */ var _actions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions.js */ "./node_modules/xstate/es/actions.js"); /* harmony import */ var _environment_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./environment.js */ "./node_modules/xstate/es/environment.js"); /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/xstate/es/utils.js"); /* harmony import */ var _scheduler_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./scheduler.js */ "./node_modules/xstate/es/scheduler.js"); /* harmony import */ var _Actor_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Actor.js */ "./node_modules/xstate/es/Actor.js"); /* harmony import */ var _registry_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./registry.js */ "./node_modules/xstate/es/registry.js"); /* harmony import */ var _devTools_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./devTools.js */ "./node_modules/xstate/es/devTools.js"); /* harmony import */ var _serviceScope_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./serviceScope.js */ "./node_modules/xstate/es/serviceScope.js"); /* harmony import */ var _behaviors_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./behaviors.js */ "./node_modules/xstate/es/behaviors.js"); var DEFAULT_SPAWN_OPTIONS = { sync: false, autoForward: false }; var InterpreterStatus; (function (InterpreterStatus) { InterpreterStatus[InterpreterStatus["NotStarted"] = 0] = "NotStarted"; InterpreterStatus[InterpreterStatus["Running"] = 1] = "Running"; InterpreterStatus[InterpreterStatus["Stopped"] = 2] = "Stopped"; })(InterpreterStatus || (InterpreterStatus = {})); var Interpreter = /*#__PURE__*/ /** @class */ function () { /** * Creates a new Interpreter instance (i.e., service) for the given machine with the provided options, if any. * * @param machine The machine to be interpreted * @param options Interpreter options */ function Interpreter(machine, options) { if (options === void 0) { options = Interpreter.defaultOptions; } var _this = this; this.machine = machine; this.delayedEventsMap = {}; this.listeners = new Set(); this.contextListeners = new Set(); this.stopListeners = new Set(); this.doneListeners = new Set(); this.eventListeners = new Set(); this.sendListeners = new Set(); /** * Whether the service is started. */ this.initialized = false; this.status = InterpreterStatus.NotStarted; this.children = new Map(); this.forwardTo = new Set(); this._outgoingQueue = []; /** * Alias for Interpreter.prototype.start */ this.init = this.start; /** * Sends an event to the running interpreter to trigger a transition. * * An array of events (batched) can be sent as well, which will send all * batched events to the running interpreter. The listeners will be * notified only **once** when all events are processed. * * @param event The event(s) to send */ this.send = function (event, payload) { if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isArray)(event)) { _this.batch(event); return _this.state; } var _event = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toEventObject)(event, payload)); if (_this.status === InterpreterStatus.Stopped) { // do nothing if (!_environment_js__WEBPACK_IMPORTED_MODULE_1__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.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))); } return _this.state; } if (_this.status !== InterpreterStatus.Running && !_this.options.deferEvents) { throw new Error("Event \"".concat(_event.name, "\" was sent to uninitialized service \"").concat(_this.machine.id // tslint:disable-next-line:max-line-length , "\". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: ").concat(JSON.stringify(_event.data))); } _this.scheduler.schedule(function () { // Forward copy of event to child actors _this.forward(_event); var nextState = _this._nextState(_event); _this.update(nextState, _event); }); return _this._state; // TODO: deprecate (should return void) // tslint:disable-next-line:semicolon }; this.sendTo = function (event, to, immediate) { var isParent = _this.parent && (to === _types_js__WEBPACK_IMPORTED_MODULE_2__.SpecialTargets.Parent || _this.parent.id === to); var target = isParent ? _this.parent : (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(to) ? to === _types_js__WEBPACK_IMPORTED_MODULE_2__.SpecialTargets.Internal ? _this : _this.children.get(to) || _registry_js__WEBPACK_IMPORTED_MODULE_3__.registry.get(to) : (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isActor)(to) ? to : undefined; if (!target) { if (!isParent) { throw new Error("Unable to send event to child '".concat(to, "' from service '").concat(_this.id, "'.")); } // tslint:disable-next-line:no-console if (!_environment_js__WEBPACK_IMPORTED_MODULE_1__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(false, "Service '".concat(_this.id, "' has no parent: unable to send event ").concat(event.type)); } return; } if ('machine' in target) { // perhaps those events should be rejected in the parent // but atm it doesn't have easy access to all of the information that is required to do it reliably if (_this.status !== InterpreterStatus.Stopped || _this.parent !== target || // we need to send events to the parent from exit handlers of a machine that reached its final state _this.state.done) { // Send SCXML events to machines var scxmlEvent = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, event), { name: event.name === _actionTypes_js__WEBPACK_IMPORTED_MODULE_5__.error ? "".concat((0,_actions_js__WEBPACK_IMPORTED_MODULE_6__.error)(_this.id)) : event.name, origin: _this.sessionId }); if (!immediate && _this.machine.config.predictableActionArguments) { _this._outgoingQueue.push([target, scxmlEvent]); } else { target.send(scxmlEvent); } } } else { // Send normal events to other targets if (!immediate && _this.machine.config.predictableActionArguments) { _this._outgoingQueue.push([target, event.data]); } else { target.send(event.data); } } }; this._exec = function (action, context, _event, actionFunctionMap) { if (actionFunctionMap === void 0) { actionFunctionMap = _this.machine.options.actions; } var actionOrExec = action.exec || (0,_actions_js__WEBPACK_IMPORTED_MODULE_6__.getActionFunction)(action.type, actionFunctionMap); var exec = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(actionOrExec) ? actionOrExec : actionOrExec ? actionOrExec.exec : action.exec; if (exec) { try { return exec(context, _event.data, !_this.machine.config.predictableActionArguments ? { action: action, state: _this.state, _event: _event } : { action: action, _event: _event }); } catch (err) { if (_this.parent) { _this.parent.send({ type: 'xstate.error', data: err }); } throw err; } } switch (action.type) { case _actionTypes_js__WEBPACK_IMPORTED_MODULE_5__.raise: { // if raise action reached the interpreter then it's a delayed one var sendAction_1 = action; _this.defer(sendAction_1); break; } case _actionTypes_js__WEBPACK_IMPORTED_MODULE_5__.send: var sendAction = action; if (typeof sendAction.delay === 'number') { _this.defer(sendAction); return; } else { if (sendAction.to) { _this.sendTo(sendAction._event, sendAction.to, _event === _actions_js__WEBPACK_IMPORTED_MODULE_6__.initEvent); } else { _this.send(sendAction._event); } } break; case _actionTypes_js__WEBPACK_IMPORTED_MODULE_5__.cancel: _this.cancel(action.sendId); break; case _actionTypes_js__WEBPACK_IMPORTED_MODULE_5__.start: { if (_this.status !== InterpreterStatus.Running) { return; } var activity = action.activity; // If the activity will be stopped right after it's started // (such as in transient states) // don't bother starting the activity. if ( // in v4 with `predictableActionArguments` invokes are called eagerly when the `this.state` still points to the previous state !_this.machine.config.predictableActionArguments && !_this.state.activities[activity.id || activity.type]) { break; } // Invoked services if (activity.type === _types_js__WEBPACK_IMPORTED_MODULE_2__.ActionTypes.Invoke) { var invokeSource = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toInvokeSource)(activity.src); var serviceCreator = _this.machine.options.services ? _this.machine.options.services[invokeSource.type] : undefined; var id = activity.id, data = activity.data; if (!_environment_js__WEBPACK_IMPORTED_MODULE_1__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(!('forward' in activity), // tslint:disable-next-line:max-line-length "`forward` property is deprecated (found in invocation of '".concat(activity.src, "' in in machine '").concat(_this.machine.id, "'). ") + "Please use `autoForward` instead."); } var autoForward = 'autoForward' in activity ? activity.autoForward : !!activity.forward; if (!serviceCreator) { // tslint:disable-next-line:no-console if (!_environment_js__WEBPACK_IMPORTED_MODULE_1__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(false, "No service found for invocation '".concat(activity.src, "' in machine '").concat(_this.machine.id, "'.")); } return; } var resolvedData = data ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.mapContext)(data, context, _event) : undefined; if (typeof serviceCreator === 'string') { // TODO: warn return; } var source = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(serviceCreator) ? serviceCreator(context, _event.data, { data: resolvedData, src: invokeSource, meta: activity.meta }) : serviceCreator; if (!source) { // TODO: warn? return; } var options = void 0; if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isMachine)(source)) { source = resolvedData ? source.withContext(resolvedData) : source; options = { autoForward: autoForward }; } _this.spawn(source, id, options); } else { _this.spawnActivity(activity); } break; } case _actionTypes_js__WEBPACK_IMPORTED_MODULE_5__.stop: { _this.stopChild(action.activity.id); break; } case _actionTypes_js__WEBPACK_IMPORTED_MODULE_5__.log: var _a = action, label = _a.label, value = _a.value; if (label) { _this.logger(label, value); } else { _this.logger(value); } break; default: if (!_environment_js__WEBPACK_IMPORTED_MODULE_1__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(false, "No implementation found for action type '".concat(action.type, "'")); } break; } }; var resolvedOptions = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, Interpreter.defaultOptions), options); var clock = resolvedOptions.clock, logger = resolvedOptions.logger, parent = resolvedOptions.parent, id = resolvedOptions.id; var resolvedId = id !== undefined ? id : machine.id; this.id = resolvedId; this.logger = logger; this.clock = clock; this.parent = parent; this.options = resolvedOptions; this.scheduler = new _scheduler_js__WEBPACK_IMPORTED_MODULE_7__.Scheduler({ deferEvents: this.options.deferEvents }); this.sessionId = _registry_js__WEBPACK_IMPORTED_MODULE_3__.registry.bookId(); } Object.defineProperty(Interpreter.prototype, "initialState", { get: function () { var _this = this; if (this._initialState) { return this._initialState; } return (0,_serviceScope_js__WEBPACK_IMPORTED_MODULE_8__.provide)(this, function () { _this._initialState = _this.machine.initialState; return _this._initialState; }); }, enumerable: false, configurable: true }); Object.defineProperty(Interpreter.prototype, "state", { /** * @deprecated Use `.getSnapshot()` instead. */ get: function () { if (!_environment_js__WEBPACK_IMPORTED_MODULE_1__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(this.status !== InterpreterStatus.NotStarted, "Attempted to read state from uninitialized service '".concat(this.id, "'. Make sure the service is started first.")); } return this._state; }, enumerable: false, configurable: true }); /** * Executes the actions of the given state, with that state's `context` and `event`. * * @param state The state whose actions will be executed * @param actionsConfig The action implementations to use */ Interpreter.prototype.execute = function (state, actionsConfig) { var e_1, _a; try { for (var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(state.actions), _c = _b.next(); !_c.done; _c = _b.next()) { var action = _c.value; this.exec(action, state, actionsConfig); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } }; Interpreter.prototype.update = function (state, _event) { var e_2, _a, e_3, _b, e_4, _c, e_5, _d; var _this = this; // Attach session ID to state state._sessionid = this.sessionId; // Update state this._state = state; // Execute actions if ((!this.machine.config.predictableActionArguments || // this is currently required to execute initial actions as the `initialState` gets cached // we can't just recompute it (and execute actions while doing so) because we try to preserve identity of actors created within initial assigns _event === _actions_js__WEBPACK_IMPORTED_MODULE_6__.initEvent) && this.options.execute) { this.execute(this.state); } else { var item = void 0; while (item = this._outgoingQueue.shift()) { item[0].send(item[1]); } } // Update children this.children.forEach(function (child) { _this.state.children[child.id] = child; }); // Dev tools if (this.devTools) { this.devTools.send(_event.data, state); } // Execute listeners if (state.event) { try { for (var _e = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(this.eventListeners), _f = _e.next(); !_f.done; _f = _e.next()) { var listener = _f.value; listener(state.event); } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_f && !_f.done && (_a = _e.return)) _a.call(_e); } finally { if (e_2) throw e_2.error; } } } try { for (var _g = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(this.listeners), _h = _g.next(); !_h.done; _h = _g.next()) { var listener = _h.value; listener(state, state.event); } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_h && !_h.done && (_b = _g.return)) _b.call(_g); } finally { if (e_3) throw e_3.error; } } try { for (var _j = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(this.contextListeners), _k = _j.next(); !_k.done; _k = _j.next()) { var contextListener = _k.value; contextListener(this.state.context, this.state.history ? this.state.history.context : undefined); } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_k && !_k.done && (_c = _j.return)) _c.call(_j); } finally { if (e_4) throw e_4.error; } } if (this.state.done) { // get final child state node var finalChildStateNode = state.configuration.find(function (sn) { return sn.type === 'final' && sn.parent === _this.machine; }); var doneData = finalChildStateNode && finalChildStateNode.doneData ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.mapContext)(finalChildStateNode.doneData, state.context, _event) : undefined; this._doneEvent = (0,_actions_js__WEBPACK_IMPORTED_MODULE_6__.doneInvoke)(this.id, doneData); try { for (var _l = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(this.doneListeners), _m = _l.next(); !_m.done; _m = _l.next()) { var listener = _m.value; listener(this._doneEvent); } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (_m && !_m.done && (_d = _l.return)) _d.call(_l); } finally { if (e_5) throw e_5.error; } } this._stop(); this._stopChildren(); _registry_js__WEBPACK_IMPORTED_MODULE_3__.registry.free(this.sessionId); } }; /* * Adds a listener that is notified whenever a state transition happens. The listener is called with * the next state and the event object that caused the state transition. * * @param listener The state listener */ Interpreter.prototype.onTransition = function (listener) { this.listeners.add(listener); // Send current state to listener if (this.status === InterpreterStatus.Running) { listener(this.state, this.state.event); } return this; }; Interpreter.prototype.subscribe = function (nextListenerOrObserver, _, // TODO: error listener completeListener) { var _this = this; var observer = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toObserver)(nextListenerOrObserver, _, completeListener); this.listeners.add(observer.next); // Send current state to listener if (this.status !== InterpreterStatus.NotStarted) { observer.next(this.state); } var completeOnce = function () { _this.doneListeners.delete(completeOnce); _this.stopListeners.delete(completeOnce); observer.complete(); }; if (this.status === InterpreterStatus.Stopped) { observer.complete(); } else { this.onDone(completeOnce); this.onStop(completeOnce); } return { unsubscribe: function () { _this.listeners.delete(observer.next); _this.doneListeners.delete(completeOnce); _this.stopListeners.delete(completeOnce); } }; }; /** * Adds an event listener that is notified whenever an event is sent to the running interpreter. * @param listener The event listener */ Interpreter.prototype.onEvent = function (listener) { this.eventListeners.add(listener); return this; }; /** * Adds an event listener that is notified whenever a `send` event occurs. * @param listener The event listener */ Interpreter.prototype.onSend = function (listener) { this.sendListeners.add(listener); return this; }; /** * Adds a context listener that is notified whenever the state context changes. * @param listener The context listener */ Interpreter.prototype.onChange = function (listener) { this.contextListeners.add(listener); return this; }; /** * Adds a listener that is notified when the machine is stopped. * @param listener The listener */ Interpreter.prototype.onStop = function (listener) { this.stopListeners.add(listener); return this; }; /** * Adds a state listener that is notified when the statechart has reached its final state. * @param listener The state listener */ Interpreter.prototype.onDone = function (listener) { if (this.status === InterpreterStatus.Stopped && this._doneEvent) { listener(this._doneEvent); } else { this.doneListeners.add(listener); } return this; }; /** * Removes a listener. * @param listener The listener to remove */ Interpreter.prototype.off = function (listener) { this.listeners.delete(listener); this.eventListeners.delete(listener); this.sendListeners.delete(listener); this.stopListeners.delete(listener); this.doneListeners.delete(listener); this.contextListeners.delete(listener); return this; }; /** * Starts the interpreter from the given state, or the initial state. * @param initialState The state to start the statechart from */ Interpreter.prototype.start = function (initialState) { var _this = this; if (this.status === InterpreterStatus.Running) { // Do not restart the service if it is already started return this; } // yes, it's a hack but we need the related cache to be populated for some things to work (like delayed transitions) // this is usually called by `machine.getInitialState` but if we rehydrate from a state we might bypass this call // we also don't want to call this method here as it resolves the full initial state which might involve calling assign actions // and that could potentially lead to some unwanted side-effects (even such as creating some rogue actors) this.machine._init(); _registry_js__WEBPACK_IMPORTED_MODULE_3__.registry.register(this.sessionId, this); this.initialized = true; this.status = InterpreterStatus.Running; var resolvedState = initialState === undefined ? this.initialState : (0,_serviceScope_js__WEBPACK_IMPORTED_MODULE_8__.provide)(this, function () { return (0,_State_js__WEBPACK_IMPORTED_MODULE_9__.isStateConfig)(initialState) ? _this.machine.resolveState(initialState) : _this.machine.resolveState(_State_js__WEBPACK_IMPORTED_MODULE_9__.State.from(initialState, _this.machine.context)); }); if (this.options.devTools) { this.attachDev(); } this.scheduler.initialize(function () { _this.update(resolvedState, _actions_js__WEBPACK_IMPORTED_MODULE_6__.initEvent); }); return this; }; Interpreter.prototype._stopChildren = function () { // TODO: think about converting those to actions this.children.forEach(function (child) { if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(child.stop)) { child.stop(); } }); this.children.clear(); }; Interpreter.prototype._stop = function () { var e_6, _a, e_7, _b, e_8, _c, e_9, _d, e_10, _e; try { for (var _f = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(this.listeners), _g = _f.next(); !_g.done; _g = _f.next()) { var listener = _g.value; this.listeners.delete(listener); } } catch (e_6_1) { e_6 = { error: e_6_1 }; } finally { try { if (_g && !_g.done && (_a = _f.return)) _a.call(_f); } finally { if (e_6) throw e_6.error; } } try { for (var _h = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(this.stopListeners), _j = _h.next(); !_j.done; _j = _h.next()) { var listener = _j.value; // call listener, then remove listener(); this.stopListeners.delete(listener); } } catch (e_7_1) { e_7 = { error: e_7_1 }; } finally { try { if (_j && !_j.done && (_b = _h.return)) _b.call(_h); } finally { if (e_7) throw e_7.error; } } try { for (var _k = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(this.contextListeners), _l = _k.next(); !_l.done; _l = _k.next()) { var listener = _l.value; this.contextListeners.delete(listener); } } catch (e_8_1) { e_8 = { error: e_8_1 }; } finally { try { if (_l && !_l.done && (_c = _k.return)) _c.call(_k); } finally { if (e_8) throw e_8.error; } } try { for (var _m = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(this.doneListeners), _o = _m.next(); !_o.done; _o = _m.next()) { var listener = _o.value; this.doneListeners.delete(listener); } } catch (e_9_1) { e_9 = { error: e_9_1 }; } finally { try { if (_o && !_o.done && (_d = _m.return)) _d.call(_m); } finally { if (e_9) throw e_9.error; } } if (!this.initialized) { // Interpreter already stopped; do nothing return this; } this.initialized = false; this.status = InterpreterStatus.Stopped; this._initialState = undefined; try { // we are going to stop within the current sync frame // so we can safely just cancel this here as nothing async should be fired anyway for (var _p = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(Object.keys(this.delayedEventsMap)), _q = _p.next(); !_q.done; _q = _p.next()) { var key = _q.value; this.clock.clearTimeout(this.delayedEventsMap[key]); } } catch (e_10_1) { e_10 = { error: e_10_1 }; } finally { try { if (_q && !_q.done && (_e = _p.return)) _e.call(_p); } finally { if (e_10) throw e_10.error; } } // clear everything that might be enqueued this.scheduler.clear(); this.scheduler = new _scheduler_js__WEBPACK_IMPORTED_MODULE_7__.Scheduler({ deferEvents: this.options.deferEvents }); }; /** * Stops the interpreter and unsubscribe all listeners. * * This will also notify the `onStop` listeners. */ Interpreter.prototype.stop = function () { // TODO: add warning for stopping non-root interpreters var _this = this; // grab the current scheduler as it will be replaced in _stop var scheduler = this.scheduler; this._stop(); // let what is currently processed to be finished scheduler.schedule(function () { // it feels weird to handle this here but we need to handle this even slightly "out of band" var _event = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)({ type: 'xstate.stop' }); var nextState = (0,_serviceScope_js__WEBPACK_IMPORTED_MODULE_8__.provide)(_this, function () { var exitActions = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__read)(_this.state.configuration), false).sort(function (a, b) { return b.order - a.order; }).map(function (stateNode) { return (0,_actions_js__WEBPACK_IMPORTED_MODULE_6__.toActionObjects)(stateNode.onExit, _this.machine.options.actions); })); var _a = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__read)((0,_actions_js__WEBPACK_IMPORTED_MODULE_6__.resolveActions)(_this.machine, _this.state, _this.state.context, _event, [{ type: 'exit', actions: exitActions }], _this.machine.config.predictableActionArguments ? _this._exec : undefined, _this.machine.config.predictableActionArguments || _this.machine.config.preserveActionOrder), 2), resolvedActions = _a[0], updatedContext = _a[1]; var newState = new _State_js__WEBPACK_IMPORTED_MODULE_9__.State({ value: _this.state.value, context: updatedContext, _event: _event, _sessionid: _this.sessionId, historyValue: undefined, history: _this.state, actions: resolvedActions.filter(function (action) { return !(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isRaisableAction)(action); }), activities: {}, events: [], configuration: [], transitions: [], children: {}, done: _this.state.done, tags: _this.state.tags, machine: _this.machine }); newState.changed = true; return newState; }); _this.update(nextState, _event); _this._stopChildren(); _registry_js__WEBPACK_IMPORTED_MODULE_3__.registry.free(_this.sessionId); }); return this; }; Interpreter.prototype.batch = function (events) { var _this = this; if (this.status === InterpreterStatus.NotStarted && this.options.deferEvents) { // tslint:disable-next-line:no-console if (!_environment_js__WEBPACK_IMPORTED_MODULE_1__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.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))); } } else if (this.status !== InterpreterStatus.Running) { throw new Error( // tslint:disable-next-line:max-line-length "".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.")); } if (!events.length) { return; } var exec = !!this.machine.config.predictableActionArguments && this._exec; this.scheduler.schedule(function () { var e_11, _a; var nextState = _this.state; var batchChanged = false; var batchedActions = []; var _loop_1 = function (event_1) { var _event = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)(event_1); _this.forward(_event); nextState = (0,_serviceScope_js__WEBPACK_IMPORTED_MODULE_8__.provide)(_this, function () { return _this.machine.transition(nextState, _event, undefined, exec || undefined); }); batchedActions.push.apply(batchedActions, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__read)(_this.machine.config.predictableActionArguments ? nextState.actions : nextState.actions.map(function (a) { return (0,_State_js__WEBPACK_IMPORTED_MODULE_9__.bindActionToState)(a, nextState); })), false)); batchChanged = batchChanged || !!nextState.changed; }; try { for (var events_1 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) { var event_1 = events_1_1.value; _loop_1(event_1); } } catch (e_11_1) { e_11 = { error: e_11_1 }; } finally { try { if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1); } finally { if (e_11) throw e_11.error; } } nextState.changed = batchChanged; nextState.actions = batchedActions; _this.update(nextState, (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)(events[events.length - 1])); }); }; /** * Returns a send function bound to this interpreter instance. * * @param event The event to be sent by the sender. */ Interpreter.prototype.sender = function (event) { return this.send.bind(this, event); }; Interpreter.prototype._nextState = function (event, exec) { var _this = this; if (exec === void 0) { exec = !!this.machine.config.predictableActionArguments && this._exec; } var _event = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)(event); if (_event.name.indexOf(_actionTypes_js__WEBPACK_IMPORTED_MODULE_5__.errorPlatform) === 0 && !this.state.nextEvents.some(function (nextEvent) { return nextEvent.indexOf(_actionTypes_js__WEBPACK_IMPORTED_MODULE_5__.errorPlatform) === 0; })) { throw _event.data.data; } var nextState = (0,_serviceScope_js__WEBPACK_IMPORTED_MODULE_8__.provide)(this, function () { return _this.machine.transition(_this.state, _event, undefined, exec || undefined); }); return nextState; }; /** * Returns the next state given the interpreter's current state and the event. * * This is a pure method that does _not_ update the interpreter's state. * * @param event The event to determine the next state */ Interpreter.prototype.nextState = function (event) { return this._nextState(event, false); }; Interpreter.prototype.forward = function (event) { var e_12, _a; try { for (var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__values)(this.forwardTo), _c = _b.next(); !_c.done; _c = _b.next()) { var id = _c.value; var child = this.children.get(id); if (!child) { throw new Error("Unable to forward event '".concat(event, "' from interpreter '").concat(this.id, "' to nonexistant child '").concat(id, "'.")); } child.send(event); } } catch (e_12_1) { e_12 = { error: e_12_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_12) throw e_12.error; } } }; Interpreter.prototype.defer = function (sendAction) { var _this = this; var timerId = this.clock.setTimeout(function () { if ('to' in sendAction && sendAction.to) { _this.sendTo(sendAction._event, sendAction.to, true); } else { _this.send(sendAction._event); } }, sendAction.delay); if (sendAction.id) { this.delayedEventsMap[sendAction.id] = timerId; } }; Interpreter.prototype.cancel = function (sendId) { this.clock.clearTimeout(this.delayedEventsMap[sendId]); delete this.delayedEventsMap[sendId]; }; Interpreter.prototype.exec = function (action, state, actionFunctionMap) { if (actionFunctionMap === void 0) { actionFunctionMap = this.machine.options.actions; } this._exec(action, state.context, state._event, actionFunctionMap); }; Interpreter.prototype.removeChild = function (childId) { var _a; this.children.delete(childId); this.forwardTo.delete(childId); // this.state might not exist at the time this is called, // such as when a child is added then removed while initializing the state (_a = this.state) === null || _a === void 0 ? true : delete _a.children[childId]; }; Interpreter.prototype.stopChild = function (childId) { var child = this.children.get(childId); if (!child) { return; } this.removeChild(childId); if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(child.stop)) { child.stop(); } }; Interpreter.prototype.spawn = function (entity, name, options) { if (this.status !== InterpreterStatus.Running) { return (0,_Actor_js__WEBPACK_IMPORTED_MODULE_10__.createDeferredActor)(entity, name); } if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isPromiseLike)(entity)) { return this.spawnPromise(Promise.resolve(entity), name); } else if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(entity)) { return this.spawnCallback(entity, name); } else if ((0,_Actor_js__WEBPACK_IMPORTED_MODULE_10__.isSpawnedActor)(entity)) { return this.spawnActor(entity, name); } else if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isObservable)(entity)) { return this.spawnObservable(entity, name); } else if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isMachine)(entity)) { return this.spawnMachine(entity, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, options), { id: name })); } else if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isBehavior)(entity)) { return this.spawnBehavior(entity, name); } else { throw new Error("Unable to spawn entity \"".concat(name, "\" of type \"").concat(typeof entity, "\".")); } }; Interpreter.prototype.spawnMachine = function (machine, options) { var _this = this; if (options === void 0) { options = {}; } var childService = new Interpreter(machine, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, this.options), { parent: this, id: options.id || machine.id })); var resolvedOptions = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, DEFAULT_SPAWN_OPTIONS), options); if (resolvedOptions.sync) { childService.onTransition(function (state) { _this.send(_actionTypes_js__WEBPACK_IMPORTED_MODULE_5__.update, { state: state, id: childService.id }); }); } var actor = childService; this.children.set(childService.id, actor); if (resolvedOptions.autoForward) { this.forwardTo.add(childService.id); } childService.onDone(function (doneEvent) { _this.removeChild(childService.id); _this.send((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)(doneEvent, { origin: childService.id })); }).start(); return actor; }; Interpreter.prototype.spawnBehavior = function (behavior, id) { var actorRef = (0,_behaviors_js__WEBPACK_IMPORTED_MODULE_11__.spawnBehavior)(behavior, { id: id, parent: this }); this.children.set(id, actorRef); return actorRef; }; Interpreter.prototype.spawnPromise = function (promise, id) { var _a; var _this = this; var canceled = false; var resolvedData; promise.then(function (response) { if (!canceled) { resolvedData = response; _this.removeChild(id); _this.send((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)((0,_actions_js__WEBPACK_IMPORTED_MODULE_6__.doneInvoke)(id, response), { origin: id })); } }, function (errorData) { if (!canceled) { _this.removeChild(id); var errorEvent = (0,_actions_js__WEBPACK_IMPORTED_MODULE_6__.error)(id, errorData); try { // Send "error.platform.id" to this (parent). _this.send((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)(errorEvent, { origin: id })); } catch (error) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reportUnhandledExceptionOnInvocation)(errorData, error, id); if (_this.devTools) { _this.devTools.send(errorEvent, _this.state); } if (_this.machine.strict) { // it would be better to always stop the state machine if unhandled // exception/promise rejection happens but because we don't want to // break existing code so enforce it on strict mode only especially so // because documentation says that onError is optional _this.stop(); } } } }); var actor = (_a = { id: id, send: function () { return void 0; }, subscribe: function (next, handleError, complete) { var observer = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toObserver)(next, handleError, complete); var unsubscribed = false; promise.then(function (response) { if (unsubscribed) { return; } observer.next(response); if (unsubscribed) { return; } observer.complete(); }, function (err) { if (unsubscribed) { return; } observer.error(err); }); return { unsubscribe: function () { return unsubscribed = true; } }; }, stop: function () { canceled = true; }, toJSON: function () { return { id: id }; }, getSnapshot: function () { return resolvedData; } }, _a[_utils_js__WEBPACK_IMPORTED_MODULE_0__.symbolObservable] = function () { return this; }, _a); this.children.set(id, actor); return actor; }; Interpreter.prototype.spawnCallback = function (callback, id) { var _a; var _this = this; var canceled = false; var receivers = new Set(); var listeners = new Set(); var emitted; var receive = function (e) { emitted = e; listeners.forEach(function (listener) { return listener(e); }); if (canceled) { return; } _this.send((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)(e, { origin: id })); }; var callbackStop; try { callbackStop = callback(receive, function (newListener) { receivers.add(newListener); }); } catch (err) { this.send((0,_actions_js__WEBPACK_IMPORTED_MODULE_6__.error)(id, err)); } if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isPromiseLike)(callbackStop)) { // it turned out to be an async function, can't reliably check this before calling `callback` // because transpiled async functions are not recognizable return this.spawnPromise(callbackStop, id); } var actor = (_a = { id: id, send: function (event) { return receivers.forEach(function (receiver) { return receiver(event); }); }, subscribe: function (next) { var observer = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toObserver)(next); listeners.add(observer.next); return { unsubscribe: function () { listeners.delete(observer.next); } }; }, stop: function () { canceled = true; if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(callbackStop)) { callbackStop(); } }, toJSON: function () { return { id: id }; }, getSnapshot: function () { return emitted; } }, _a[_utils_js__WEBPACK_IMPORTED_MODULE_0__.symbolObservable] = function () { return this; }, _a); this.children.set(id, actor); return actor; }; Interpreter.prototype.spawnObservable = function (source, id) { var _a; var _this = this; var emitted; var subscription = source.subscribe(function (value) { emitted = value; _this.send((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)(value, { origin: id })); }, function (err) { _this.removeChild(id); _this.send((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)((0,_actions_js__WEBPACK_IMPORTED_MODULE_6__.error)(id, err), { origin: id })); }, function () { _this.removeChild(id); _this.send((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toSCXMLEvent)((0,_actions_js__WEBPACK_IMPORTED_MODULE_6__.doneInvoke)(id), { origin: id })); }); var actor = (_a = { id: id, send: function () { return void 0; }, subscribe: function (next, handleError, complete) { return source.subscribe(next, handleError, complete); }, stop: function () { return subscription.unsubscribe(); }, getSnapshot: function () { return emitted; }, toJSON: function () { return { id: id }; } }, _a[_utils_js__WEBPACK_IMPORTED_MODULE_0__.symbolObservable] = function () { return this; }, _a); this.children.set(id, actor); return actor; }; Interpreter.prototype.spawnActor = function (actor, name) { this.children.set(name, actor); return actor; }; Interpreter.prototype.spawnActivity = function (activity) { var implementation = this.machine.options && this.machine.options.activities ? this.machine.options.activities[activity.type] : undefined; if (!implementation) { if (!_environment_js__WEBPACK_IMPORTED_MODULE_1__.IS_PRODUCTION) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(false, "No implementation found for activity '".concat(activity.type, "'")); } // tslint:disable-next-line:no-console return; } // Start implementation var dispose = implementation(this.state.context, activity); this.spawnEffect(activity.id, dispose); }; Interpreter.prototype.spawnEffect = function (id, dispose) { var _a; this.children.set(id, (_a = { id: id, send: function () { return void 0; }, subscribe: function () { return { unsubscribe: function () { return void 0; } }; }, stop: dispose || undefined, getSnapshot: function () { return undefined; }, toJSON: function () { return { id: id }; } }, _a[_utils_js__WEBPACK_IMPORTED_MODULE_0__.symbolObservable] = function () { return this; }, _a)); }; Interpreter.prototype.attachDev = function () { var global = (0,_devTools_js__WEBPACK_IMPORTED_MODULE_12__.getGlobal)(); if (this.options.devTools && global) { if (global.__REDUX_DEVTOOLS_EXTENSION__) { var devToolsOptions = typeof this.options.devTools === 'object' ? this.options.devTools : undefined; this.devTools = global.__REDUX_DEVTOOLS_EXTENSION__.connect((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)({ name: this.id, autoPause: true, stateSanitizer: function (state) { return { value: state.value, context: state.context, actions: state.actions }; } }, devToolsOptions), { features: (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)({ jump: false, skip: false }, devToolsOptions ? devToolsOptions.features : undefined) }), this.machine); this.devTools.init(this.state); } // add XState-specific dev tooling hook (0,_devTools_js__WEBPACK_IMPORTED_MODULE_12__.registerService)(this); } }; Interpreter.prototype.toJSON = function () { return { id: this.id }; }; Interpreter.prototype[_utils_js__WEBPACK_IMPORTED_MODULE_0__.symbolObservable] = function () { return this; }; Interpreter.prototype.getSnapshot = function () { if (this.status === InterpreterStatus.NotStarted) { return this.initialState; } return this._state; }; /** * The default interpreter options: * * - `clock` uses the global `setTimeout` and `clearTimeout` functions * - `logger` uses the global `console.log()` method */ Interpreter.defaultOptions = { execute: true, deferEvents: true, clock: { setTimeout: function (fn, ms) { return setTimeout(fn, ms); }, clearTimeout: function (id) { return clearTimeout(id); } }, logger: /*#__PURE__*/console.log.bind(console), devTools: false }; Interpreter.interpret = interpret; return Interpreter; }(); var resolveSpawnOptions = function (nameOrOptions) { if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isString)(nameOrOptions)) { return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, DEFAULT_SPAWN_OPTIONS), { name: nameOrOptions }); } return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_4__.__assign)({}, DEFAULT_SPAWN_OPTIONS), { name: (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.uniqueId)() }), nameOrOptions); }; function spawn(entity, nameOrOptions) { var resolvedOptions = resolveSpawnOptions(nameOrOptions); return (0,_serviceScope_js__WEBPACK_IMPORTED_MODULE_8__.consume)(function (service) { if (!_environment_js__WEBPACK_IMPORTED_MODULE_1__.IS_PRODUCTION) { var isLazyEntity = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isMachine)(entity) || (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isFunction)(entity); (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.warn)(!!service || isLazyEntity, "Attempted to spawn an Actor (ID: \"".concat((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isMachine)(entity) ? entity.id : 'undefined', "\") outside of a service. This will have no effect.")); } if (service) { return service.spawn(entity, resolvedOptions.name, resolvedOptions); } else { return (0,_Actor_js__WEBPACK_IMPORTED_MODULE_10__.createDeferredActor)(entity, resolvedOptions.name); } }); } /** * Creates a new Interpreter instance for the given machine with the provided options, if any. * * @param machine The machine to interpret * @param options Interpreter options */ function interpret(machine, options) { var interpreter = new Interpreter(machine, options); return interpreter; } /***/ }), /***/ "./node_modules/xstate/es/invokeUtils.js": /*!***********************************************!*\ !*** ./node_modules/xstate/es/invokeUtils.js ***! \***********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ toInvokeDefinition: function() { return /* binding */ toInvokeDefinition; } /* harmony export */ }); /* unused harmony export toInvokeSource */ /* harmony import */ var _virtual_tslib_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_virtual/_tslib.js */ "./node_modules/xstate/es/_virtual/_tslib.js"); /* harmony import */ var _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionTypes.js */ "./node_modules/xstate/es/actionTypes.js"); function toInvokeSource(src) { if (typeof src === 'string') { var simpleSrc = { type: src }; simpleSrc.toString = function () { return src; }; // v4 compat - TODO: remove in v5 return simpleSrc; } return src; } function toInvokeDefinition(invokeConfig) { return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_0__.__assign)({ type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.invoke }, invokeConfig), { toJSON: function () { invokeConfig.onDone; invokeConfig.onError; var invokeDef = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_0__.__rest)(invokeConfig, ["onDone", "onError"]); return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, invokeDef), { type: _actionTypes_js__WEBPACK_IMPORTED_MODULE_1__.invoke, src: toInvokeSource(invokeConfig.src) }); } }); } /***/ }), /***/ "./node_modules/xstate/es/registry.js": /*!********************************************!*\ !*** ./node_modules/xstate/es/registry.js ***! \********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ registry: function() { return /* binding */ registry; } /* harmony export */ }); var children = /*#__PURE__*/new Map(); var sessionIdIndex = 0; var registry = { bookId: function () { return "x:".concat(sessionIdIndex++); }, register: function (id, actor) { children.set(id, actor); return id; }, get: function (id) { return children.get(id); }, free: function (id) { children.delete(id); } }; /***/ }), /***/ "./node_modules/xstate/es/scheduler.js": /*!*********************************************!*\ !*** ./node_modules/xstate/es/scheduler.js ***! \*********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Scheduler: function() { return /* binding */ Scheduler; } /* harmony export */ }); /* harmony import */ var _virtual_tslib_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_virtual/_tslib.js */ "./node_modules/xstate/es/_virtual/_tslib.js"); var defaultOptions = { deferEvents: false }; var Scheduler = /*#__PURE__*/ /** @class */ function () { function Scheduler(options) { this.processingEvent = false; this.queue = []; this.initialized = false; this.options = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, defaultOptions), options); } Scheduler.prototype.initialize = function (callback) { this.initialized = true; if (callback) { if (!this.options.deferEvents) { this.schedule(callback); return; } this.process(callback); } this.flushEvents(); }; Scheduler.prototype.schedule = function (task) { if (!this.initialized || this.processingEvent) { this.queue.push(task); return; } if (this.queue.length !== 0) { throw new Error('Event queue should be empty when it is not processing events'); } this.process(task); this.flushEvents(); }; Scheduler.prototype.clear = function () { this.queue = []; }; Scheduler.prototype.flushEvents = function () { var nextCallback = this.queue.shift(); while (nextCallback) { this.process(nextCallback); nextCallback = this.queue.shift(); } }; Scheduler.prototype.process = function (callback) { this.processingEvent = true; try { callback(); } catch (e) { // there is no use to keep the future events // as the situation is not anymore the same this.clear(); throw e; } finally { this.processingEvent = false; } }; return Scheduler; }(); /***/ }), /***/ "./node_modules/xstate/es/serviceScope.js": /*!************************************************!*\ !*** ./node_modules/xstate/es/serviceScope.js ***! \************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ consume: function() { return /* binding */ consume; }, /* harmony export */ provide: function() { return /* binding */ provide; } /* harmony export */ }); /** * Maintains a stack of the current service in scope. * This is used to provide the correct service to spawn(). */ var serviceStack = []; var provide = function (service, fn) { serviceStack.push(service); var result = fn(service); serviceStack.pop(); return result; }; var consume = function (fn) { return fn(serviceStack[serviceStack.length - 1]); }; /***/ }), /***/ "./node_modules/xstate/es/stateUtils.js": /*!**********************************************!*\ !*** ./node_modules/xstate/es/stateUtils.js ***! \**********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getAllChildren: function() { return /* binding */ getAllChildren; }, /* harmony export */ getAllStateNodes: function() { return /* binding */ getAllStateNodes; }, /* harmony export */ getChildren: function() { return /* binding */ getChildren; }, /* harmony export */ getConfiguration: function() { return /* binding */ getConfiguration; }, /* harmony export */ getMeta: function() { return /* binding */ getMeta; }, /* harmony export */ getTagsFromConfiguration: function() { return /* binding */ getTagsFromConfiguration; }, /* harmony export */ getValue: function() { return /* binding */ getValue; }, /* harmony export */ has: function() { return /* binding */ has; }, /* harmony export */ isInFinalState: function() { return /* binding */ isInFinalState; }, /* harmony export */ isLeafNode: function() { return /* binding */ isLeafNode; }, /* harmony export */ nextEvents: function() { return /* binding */ nextEvents; } /* harmony export */ }); /* unused harmony export getAdjList */ /* harmony import */ var _virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_virtual/_tslib.js */ "./node_modules/xstate/es/_virtual/_tslib.js"); /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/xstate/es/utils.js"); var isLeafNode = function (stateNode) { return stateNode.type === 'atomic' || stateNode.type === 'final'; }; function getAllChildren(stateNode) { return Object.keys(stateNode.states).map(function (key) { return stateNode.states[key]; }); } function getChildren(stateNode) { return getAllChildren(stateNode).filter(function (sn) { return sn.type !== 'history'; }); } function getAllStateNodes(stateNode) { var stateNodes = [stateNode]; if (isLeafNode(stateNode)) { return stateNodes; } return stateNodes.concat((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(getChildren(stateNode).map(getAllStateNodes))); } function getConfiguration(prevStateNodes, stateNodes) { var e_1, _a, e_2, _b, e_3, _c, e_4, _d; var prevConfiguration = new Set(prevStateNodes); var prevAdjList = getAdjList(prevConfiguration); var configuration = new Set(stateNodes); try { // add all ancestors for (var configuration_1 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(configuration), configuration_1_1 = configuration_1.next(); !configuration_1_1.done; configuration_1_1 = configuration_1.next()) { var s = configuration_1_1.value; var m = s.parent; while (m && !configuration.has(m)) { configuration.add(m); m = m.parent; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (configuration_1_1 && !configuration_1_1.done && (_a = configuration_1.return)) _a.call(configuration_1); } finally { if (e_1) throw e_1.error; } } var adjList = getAdjList(configuration); try { // add descendants for (var configuration_2 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(configuration), configuration_2_1 = configuration_2.next(); !configuration_2_1.done; configuration_2_1 = configuration_2.next()) { var s = configuration_2_1.value; // if previously active, add existing child nodes if (s.type === 'compound' && (!adjList.get(s) || !adjList.get(s).length)) { if (prevAdjList.get(s)) { prevAdjList.get(s).forEach(function (sn) { return configuration.add(sn); }); } else { s.initialStateNodes.forEach(function (sn) { return configuration.add(sn); }); } } else { if (s.type === 'parallel') { try { for (var _e = (e_3 = void 0, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(getChildren(s))), _f = _e.next(); !_f.done; _f = _e.next()) { var child = _f.value; if (!configuration.has(child)) { configuration.add(child); if (prevAdjList.get(child)) { prevAdjList.get(child).forEach(function (sn) { return configuration.add(sn); }); } else { child.initialStateNodes.forEach(function (sn) { return configuration.add(sn); }); } } } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_f && !_f.done && (_c = _e.return)) _c.call(_e); } finally { if (e_3) throw e_3.error; } } } } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (configuration_2_1 && !configuration_2_1.done && (_b = configuration_2.return)) _b.call(configuration_2); } finally { if (e_2) throw e_2.error; } } try { // add all ancestors for (var configuration_3 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(configuration), configuration_3_1 = configuration_3.next(); !configuration_3_1.done; configuration_3_1 = configuration_3.next()) { var s = configuration_3_1.value; var m = s.parent; while (m && !configuration.has(m)) { configuration.add(m); m = m.parent; } } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (configuration_3_1 && !configuration_3_1.done && (_d = configuration_3.return)) _d.call(configuration_3); } finally { if (e_4) throw e_4.error; } } return configuration; } function getValueFromAdj(baseNode, adjList) { var childStateNodes = adjList.get(baseNode); if (!childStateNodes) { return {}; // todo: fix? } if (baseNode.type === 'compound') { var childStateNode = childStateNodes[0]; if (childStateNode) { if (isLeafNode(childStateNode)) { return childStateNode.key; } } else { return {}; } } var stateValue = {}; childStateNodes.forEach(function (csn) { stateValue[csn.key] = getValueFromAdj(csn, adjList); }); return stateValue; } function getAdjList(configuration) { var e_5, _a; var adjList = new Map(); try { for (var configuration_4 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(configuration), configuration_4_1 = configuration_4.next(); !configuration_4_1.done; configuration_4_1 = configuration_4.next()) { var s = configuration_4_1.value; if (!adjList.has(s)) { adjList.set(s, []); } if (s.parent) { if (!adjList.has(s.parent)) { adjList.set(s.parent, []); } adjList.get(s.parent).push(s); } } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (configuration_4_1 && !configuration_4_1.done && (_a = configuration_4.return)) _a.call(configuration_4); } finally { if (e_5) throw e_5.error; } } return adjList; } function getValue(rootNode, configuration) { var config = getConfiguration([rootNode], configuration); return getValueFromAdj(rootNode, getAdjList(config)); } function has(iterable, item) { if (Array.isArray(iterable)) { return iterable.some(function (member) { return member === item; }); } if (iterable instanceof Set) { return iterable.has(item); } return false; // TODO: fix } function nextEvents(configuration) { return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__read)(new Set((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__read)(configuration.map(function (sn) { return sn.ownEvents; })), false)))), false); } function isInFinalState(configuration, stateNode) { if (stateNode.type === 'compound') { return getChildren(stateNode).some(function (s) { return s.type === 'final' && has(configuration, s); }); } if (stateNode.type === 'parallel') { return getChildren(stateNode).every(function (sn) { return isInFinalState(configuration, sn); }); } return false; } function getMeta(configuration) { if (configuration === void 0) { configuration = []; } return configuration.reduce(function (acc, stateNode) { if (stateNode.meta !== undefined) { acc[stateNode.id] = stateNode.meta; } return acc; }, {}); } function getTagsFromConfiguration(configuration) { return new Set((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.flatten)(configuration.map(function (sn) { return sn.tags; }))); } /***/ }), /***/ "./node_modules/xstate/es/types.js": /*!*****************************************!*\ !*** ./node_modules/xstate/es/types.js ***! \*****************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ ActionTypes: function() { return /* binding */ ActionTypes; }, /* harmony export */ SpecialTargets: function() { return /* binding */ SpecialTargets; } /* harmony export */ }); var ActionTypes; (function (ActionTypes) { ActionTypes["Start"] = "xstate.start"; ActionTypes["Stop"] = "xstate.stop"; ActionTypes["Raise"] = "xstate.raise"; ActionTypes["Send"] = "xstate.send"; ActionTypes["Cancel"] = "xstate.cancel"; ActionTypes["NullEvent"] = ""; ActionTypes["Assign"] = "xstate.assign"; ActionTypes["After"] = "xstate.after"; ActionTypes["DoneState"] = "done.state"; ActionTypes["DoneInvoke"] = "done.invoke"; ActionTypes["Log"] = "xstate.log"; ActionTypes["Init"] = "xstate.init"; ActionTypes["Invoke"] = "xstate.invoke"; ActionTypes["ErrorExecution"] = "error.execution"; ActionTypes["ErrorCommunication"] = "error.communication"; ActionTypes["ErrorPlatform"] = "error.platform"; ActionTypes["ErrorCustom"] = "xstate.error"; ActionTypes["Update"] = "xstate.update"; ActionTypes["Pure"] = "xstate.pure"; ActionTypes["Choose"] = "xstate.choose"; })(ActionTypes || (ActionTypes = {})); var SpecialTargets; (function (SpecialTargets) { SpecialTargets["Parent"] = "#_parent"; SpecialTargets["Internal"] = "#_internal"; })(SpecialTargets || (SpecialTargets = {})); /***/ }), /***/ "./node_modules/xstate/es/utils.js": /*!*****************************************!*\ !*** ./node_modules/xstate/es/utils.js ***! \*****************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ createInvokeId: function() { return /* binding */ createInvokeId; }, /* harmony export */ evaluateGuard: function() { return /* binding */ evaluateGuard; }, /* harmony export */ flatten: function() { return /* binding */ flatten; }, /* harmony export */ getEventType: function() { return /* binding */ getEventType; }, /* harmony export */ isActor: function() { return /* binding */ isActor; }, /* harmony export */ isArray: function() { return /* binding */ isArray; }, /* harmony export */ isBehavior: function() { return /* binding */ isBehavior; }, /* harmony export */ isBuiltInEvent: function() { return /* binding */ isBuiltInEvent; }, /* harmony export */ isFunction: function() { return /* binding */ isFunction; }, /* harmony export */ isMachine: function() { return /* binding */ isMachine; }, /* harmony export */ isObservable: function() { return /* binding */ isObservable; }, /* harmony export */ isPromiseLike: function() { return /* binding */ isPromiseLike; }, /* harmony export */ isRaisableAction: function() { return /* binding */ isRaisableAction; }, /* harmony export */ isString: function() { return /* binding */ isString; }, /* harmony export */ mapContext: function() { return /* binding */ mapContext; }, /* harmony export */ mapFilterValues: function() { return /* binding */ mapFilterValues; }, /* harmony export */ mapValues: function() { return /* binding */ mapValues; }, /* harmony export */ matchesState: function() { return /* binding */ matchesState; }, /* harmony export */ nestedPath: function() { return /* binding */ nestedPath; }, /* harmony export */ normalizeTarget: function() { return /* binding */ normalizeTarget; }, /* harmony export */ partition: function() { return /* binding */ partition; }, /* harmony export */ path: function() { return /* binding */ path; }, /* harmony export */ pathToStateValue: function() { return /* binding */ pathToStateValue; }, /* harmony export */ reportUnhandledExceptionOnInvocation: function() { return /* binding */ reportUnhandledExceptionOnInvocation; }, /* harmony export */ symbolObservable: function() { return /* binding */ symbolObservable; }, /* harmony export */ toArray: function() { return /* binding */ toArray; }, /* harmony export */ toEventObject: function() { return /* binding */ toEventObject; }, /* harmony export */ toGuard: function() { return /* binding */ toGuard; }, /* harmony export */ toInvokeSource: function() { return /* binding */ toInvokeSource; }, /* harmony export */ toObserver: function() { return /* binding */ toObserver; }, /* harmony export */ toSCXMLEvent: function() { return /* binding */ toSCXMLEvent; }, /* harmony export */ toStatePath: function() { return /* binding */ toStatePath; }, /* harmony export */ toStatePaths: function() { return /* binding */ toStatePaths; }, /* harmony export */ toStateValue: function() { return /* binding */ toStateValue; }, /* harmony export */ toTransitionConfigArray: function() { return /* binding */ toTransitionConfigArray; }, /* harmony export */ uniqueId: function() { return /* binding */ uniqueId; }, /* harmony export */ updateContext: function() { return /* binding */ updateContext; }, /* harmony export */ updateHistoryValue: function() { return /* binding */ updateHistoryValue; }, /* harmony export */ warn: function() { return /* binding */ warn; } /* harmony export */ }); /* unused harmony exports getActionType, interopSymbols, isStateLike, keys, pathsToStateValue, toArrayStrict, updateHistoryStates */ /* harmony import */ var _virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_virtual/_tslib.js */ "./node_modules/xstate/es/_virtual/_tslib.js"); /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./types.js */ "./node_modules/xstate/es/types.js"); /* harmony import */ var _actionTypes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./actionTypes.js */ "./node_modules/xstate/es/actionTypes.js"); /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ "./node_modules/xstate/es/constants.js"); /* harmony import */ var _environment_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./environment.js */ "./node_modules/xstate/es/environment.js"); var _a; function keys(value) { return Object.keys(value); } function matchesState(parentStateId, childStateId, delimiter) { if (delimiter === void 0) { delimiter = _constants_js__WEBPACK_IMPORTED_MODULE_0__.STATE_DELIMITER; } var parentStateValue = toStateValue(parentStateId, delimiter); var childStateValue = toStateValue(childStateId, delimiter); if (isString(childStateValue)) { if (isString(parentStateValue)) { return childStateValue === parentStateValue; } // Parent more specific than child return false; } if (isString(parentStateValue)) { return parentStateValue in childStateValue; } return Object.keys(parentStateValue).every(function (key) { if (!(key in childStateValue)) { return false; } return matchesState(parentStateValue[key], childStateValue[key]); }); } function getEventType(event) { try { return isString(event) || typeof event === 'number' ? "".concat(event) : event.type; } catch (e) { throw new Error('Events must be strings or objects with a string event.type property.'); } } function getActionType(action) { try { return isString(action) || typeof action === 'number' ? "".concat(action) : isFunction(action) ? action.name : action.type; } catch (e) { throw new Error('Actions must be strings or objects with a string action.type property.'); } } function toStatePath(stateId, delimiter) { try { if (isArray(stateId)) { return stateId; } return stateId.toString().split(delimiter); } catch (e) { throw new Error("'".concat(stateId, "' is not a valid state path.")); } } function isStateLike(state) { return typeof state === 'object' && 'value' in state && 'context' in state && 'event' in state && '_event' in state; } function toStateValue(stateValue, delimiter) { if (isStateLike(stateValue)) { return stateValue.value; } if (isArray(stateValue)) { return pathToStateValue(stateValue); } if (typeof stateValue !== 'string') { return stateValue; } var statePath = toStatePath(stateValue, delimiter); return pathToStateValue(statePath); } function pathToStateValue(statePath) { if (statePath.length === 1) { return statePath[0]; } var value = {}; var marker = value; for (var i = 0; i < statePath.length - 1; i++) { if (i === statePath.length - 2) { marker[statePath[i]] = statePath[i + 1]; } else { marker[statePath[i]] = {}; marker = marker[statePath[i]]; } } return value; } function mapValues(collection, iteratee) { var result = {}; var collectionKeys = Object.keys(collection); for (var i = 0; i < collectionKeys.length; i++) { var key = collectionKeys[i]; result[key] = iteratee(collection[key], key, collection, i); } return result; } function mapFilterValues(collection, iteratee, predicate) { var e_1, _a; var result = {}; try { for (var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(Object.keys(collection)), _c = _b.next(); !_c.done; _c = _b.next()) { var key = _c.value; var item = collection[key]; if (!predicate(item)) { continue; } result[key] = iteratee(item, key, collection); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return result; } /** * Retrieves a value at the given path. * @param props The deep path to the prop of the desired value */ var path = function (props) { return function (object) { var e_2, _a; var result = object; try { for (var props_1 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) { var prop = props_1_1.value; result = result[prop]; } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1); } finally { if (e_2) throw e_2.error; } } return result; }; }; /** * Retrieves a value at the given path via the nested accessor prop. * @param props The deep path to the prop of the desired value */ function nestedPath(props, accessorProp) { return function (object) { var e_3, _a; var result = object; try { for (var props_2 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(props), props_2_1 = props_2.next(); !props_2_1.done; props_2_1 = props_2.next()) { var prop = props_2_1.value; result = result[accessorProp][prop]; } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (props_2_1 && !props_2_1.done && (_a = props_2.return)) _a.call(props_2); } finally { if (e_3) throw e_3.error; } } return result; }; } function toStatePaths(stateValue) { if (!stateValue) { return [[]]; } if (isString(stateValue)) { return [[stateValue]]; } var result = flatten(Object.keys(stateValue).map(function (key) { var subStateValue = stateValue[key]; if (typeof subStateValue !== 'string' && (!subStateValue || !Object.keys(subStateValue).length)) { return [[key]]; } return toStatePaths(stateValue[key]).map(function (subPath) { return [key].concat(subPath); }); })); return result; } function pathsToStateValue(paths) { var e_4, _a; var result = {}; if (paths && paths.length === 1 && paths[0].length === 1) { return paths[0][0]; } try { for (var paths_1 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(paths), paths_1_1 = paths_1.next(); !paths_1_1.done; paths_1_1 = paths_1.next()) { var currentPath = paths_1_1.value; var marker = result; // tslint:disable-next-line:prefer-for-of for (var i = 0; i < currentPath.length; i++) { var subPath = currentPath[i]; if (i === currentPath.length - 2) { marker[subPath] = currentPath[i + 1]; break; } marker[subPath] = marker[subPath] || {}; marker = marker[subPath]; } } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (paths_1_1 && !paths_1_1.done && (_a = paths_1.return)) _a.call(paths_1); } finally { if (e_4) throw e_4.error; } } return result; } function flatten(array) { var _a; return (_a = []).concat.apply(_a, (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__spreadArray)([], (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__read)(array), false)); } function toArrayStrict(value) { if (isArray(value)) { return value; } return [value]; } function toArray(value) { if (value === undefined) { return []; } return toArrayStrict(value); } function mapContext(mapper, context, _event) { var e_5, _a; if (isFunction(mapper)) { return mapper(context, _event.data); } var result = {}; try { for (var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(Object.keys(mapper)), _c = _b.next(); !_c.done; _c = _b.next()) { var key = _c.value; var subMapper = mapper[key]; if (isFunction(subMapper)) { result[key] = subMapper(context, _event.data); } else { result[key] = subMapper; } } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_5) throw e_5.error; } } return result; } function isBuiltInEvent(eventType) { return /^(done|error)\./.test(eventType); } function isPromiseLike(value) { if (value instanceof Promise) { return true; } // Check if shape matches the Promise/A+ specification for a "thenable". if (value !== null && (isFunction(value) || typeof value === 'object') && isFunction(value.then)) { return true; } return false; } function isBehavior(value) { return value !== null && typeof value === 'object' && 'transition' in value && typeof value.transition === 'function'; } function partition(items, predicate) { var e_6, _a; var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__read)([[], []], 2), truthy = _b[0], falsy = _b[1]; try { for (var items_1 = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) { var item = items_1_1.value; if (predicate(item)) { truthy.push(item); } else { falsy.push(item); } } } catch (e_6_1) { e_6 = { error: e_6_1 }; } finally { try { if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1); } finally { if (e_6) throw e_6.error; } } return [truthy, falsy]; } function updateHistoryStates(hist, stateValue) { return mapValues(hist.states, function (subHist, key) { if (!subHist) { return undefined; } var subStateValue = (isString(stateValue) ? undefined : stateValue[key]) || (subHist ? subHist.current : undefined); if (!subStateValue) { return undefined; } return { current: subStateValue, states: updateHistoryStates(subHist, subStateValue) }; }); } function updateHistoryValue(hist, stateValue) { return { current: stateValue, states: updateHistoryStates(hist, stateValue) }; } function updateContext(context, _event, assignActions, state) { if (!_environment_js__WEBPACK_IMPORTED_MODULE_2__.IS_PRODUCTION) { warn(!!context, 'Attempting to update undefined context'); } var updatedContext = context ? assignActions.reduce(function (acc, assignAction) { var e_7, _a; var assignment = assignAction.assignment; var meta = { state: state, action: assignAction, _event: _event }; var partialUpdate = {}; if (isFunction(assignment)) { partialUpdate = assignment(acc, _event.data, meta); } else { try { for (var _b = (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__values)(Object.keys(assignment)), _c = _b.next(); !_c.done; _c = _b.next()) { var key = _c.value; var propAssignment = assignment[key]; partialUpdate[key] = isFunction(propAssignment) ? propAssignment(acc, _event.data, meta) : propAssignment; } } catch (e_7_1) { e_7 = { error: e_7_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_7) throw e_7.error; } } } return Object.assign({}, acc, partialUpdate); }, context) : context; return updatedContext; } // tslint:disable-next-line:no-empty var warn = function () {}; if (!_environment_js__WEBPACK_IMPORTED_MODULE_2__.IS_PRODUCTION) { warn = function (condition, message) { var error = condition instanceof Error ? condition : undefined; if (!error && condition) { return; } if (console !== undefined) { var args = ["Warning: ".concat(message)]; if (error) { args.push(error); } // tslint:disable-next-line:no-console console.warn.apply(console, args); } }; } function isArray(value) { return Array.isArray(value); } // tslint:disable-next-line:ban-types function isFunction(value) { return typeof value === 'function'; } function isString(value) { return typeof value === 'string'; } function toGuard(condition, guardMap) { if (!condition) { return undefined; } if (isString(condition)) { return { type: _constants_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_GUARD_TYPE, name: condition, predicate: guardMap ? guardMap[condition] : undefined }; } if (isFunction(condition)) { return { type: _constants_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_GUARD_TYPE, name: condition.name, predicate: condition }; } return condition; } function isObservable(value) { try { return 'subscribe' in value && isFunction(value.subscribe); } catch (e) { return false; } } var symbolObservable = /*#__PURE__*/function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; }(); // TODO: to be removed in v5, left it out just to minimize the scope of the change and maintain compatibility with older versions of integration paackages var interopSymbols = (_a = {}, _a[symbolObservable] = function () { return this; }, _a[Symbol.observable] = function () { return this; }, _a); function isMachine(value) { return !!value && '__xstatenode' in value; } function isActor(value) { return !!value && typeof value.send === 'function'; } var uniqueId = /*#__PURE__*/function () { var currentId = 0; return function () { currentId++; return currentId.toString(16); }; }(); function toEventObject(event, payload // id?: TEvent['type'] ) { if (isString(event) || typeof event === 'number') { return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__assign)({ type: event }, payload); } return event; } function toSCXMLEvent(event, scxmlEvent) { if (!isString(event) && '$$type' in event && event.$$type === 'scxml') { return event; } var eventObject = toEventObject(event); return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__assign)({ name: eventObject.type, data: eventObject, $$type: 'scxml', type: 'external' }, scxmlEvent); } function toTransitionConfigArray(event, configLike) { var transitions = toArrayStrict(configLike).map(function (transitionLike) { if (typeof transitionLike === 'undefined' || typeof transitionLike === 'string' || isMachine(transitionLike)) { return { target: transitionLike, event: event }; } return (0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__assign)((0,_virtual_tslib_js__WEBPACK_IMPORTED_MODULE_1__.__assign)({}, transitionLike), { event: event }); }); return transitions; } function normalizeTarget(target) { if (target === undefined || target === _constants_js__WEBPACK_IMPORTED_MODULE_0__.TARGETLESS_KEY) { return undefined; } return toArray(target); } function reportUnhandledExceptionOnInvocation(originalError, currentError, id) { if (!_environment_js__WEBPACK_IMPORTED_MODULE_2__.IS_PRODUCTION) { var originalStackTrace = originalError.stack ? " Stacktrace was '".concat(originalError.stack, "'") : ''; if (originalError === currentError) { // tslint:disable-next-line:no-console console.error("Missing onError handler for invocation '".concat(id, "', error was '").concat(originalError, "'.").concat(originalStackTrace)); } else { var stackTrace = currentError.stack ? " Stacktrace was '".concat(currentError.stack, "'") : ''; // tslint:disable-next-line:no-console 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)); } } } function evaluateGuard(machine, guard, context, _event, state) { var guards = machine.options.guards; var guardMeta = { state: state, cond: guard, _event: _event }; // TODO: do not hardcode! if (guard.type === _constants_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_GUARD_TYPE) { return ((guards === null || guards === void 0 ? void 0 : guards[guard.name]) || guard.predicate)(context, _event.data, guardMeta); } var condFn = guards === null || guards === void 0 ? void 0 : guards[guard.type]; if (!condFn) { throw new Error("Guard '".concat(guard.type, "' is not implemented on machine '").concat(machine.id, "'.")); } return condFn(context, _event.data, guardMeta); } function toInvokeSource(src) { if (typeof src === 'string') { return { type: src }; } return src; } function toObserver(nextHandler, errorHandler, completionHandler) { var noop = function () {}; var isObserver = typeof nextHandler === 'object'; var self = isObserver ? nextHandler : null; return { next: ((isObserver ? nextHandler.next : nextHandler) || noop).bind(self), error: ((isObserver ? nextHandler.error : errorHandler) || noop).bind(self), complete: ((isObserver ? nextHandler.complete : completionHandler) || noop).bind(self) }; } function createInvokeId(stateNodeId, index) { return "".concat(stateNodeId, ":invocation[").concat(index, "]"); } function isRaisableAction(action) { return (action.type === _actionTypes_js__WEBPACK_IMPORTED_MODULE_3__.raise || action.type === _actionTypes_js__WEBPACK_IMPORTED_MODULE_3__.send && action.to === _types_js__WEBPACK_IMPORTED_MODULE_4__.SpecialTargets.Internal) && typeof action.delay !== 'number'; } /***/ }) }, /******/ function(__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); } /******/ __webpack_require__.O(0, ["taro","vendors","common"], function() { return __webpack_exec__("./src/pages/Clock.tsx"); }); /******/ var __webpack_exports__ = __webpack_require__.O(); /******/ } ]); //# sourceMappingURL=Clock.js.map