/*! * Vuex v0.4.1 * (c) 2016 Evan You * Released under the MIT License. */ !function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o(t.Vuex=t.Vuex||{})}(this,function(t){"use strict";function o(t){return t.reduce(function(t,o){return Object.keys(o).forEach(function(e){var n=t[e];n?Array.isArray(n)?n.push(o[e]):t[e]=[t[e],o[e]]:t[e]=o[e]}),t},{})}function e(t){if(Array.isArray(t))return t.map(e);if(t&&"object"===("undefined"==typeof t?"undefined":u["typeof"](t))){for(var o={},n=Object.keys(t),r=0,s=n.length;s>r;r++){var i=n[r];o[i]=e(t[i])}return o}return t}function n(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],o=t.collapsed,e=void 0===o?!0:o,n=(t.transformer,t.mutationTransformer),r=void 0===n?function(t){return t}:n;return{snapshot:!0,onMutation:function(t,o,n){if("undefined"!=typeof console){var i=new Date,a=" @ "+s(i.getHours(),2)+":"+s(i.getMinutes(),2)+":"+s(i.getSeconds(),2)+"."+s(i.getMilliseconds(),3),u=r(t),c="mutation "+t.type+a,h=e?console.groupCollapsed:console.group;try{h.call(console,c)}catch(l){console.log(c)}console.log("%c prev state","color: #9E9E9E; font-weight: bold",n),console.log("%c mutation","color: #03A9F4; font-weight: bold",u),console.log("%c next state","color: #4CAF50; font-weight: bold",o);try{console.groupEnd()}catch(l){console.log("\u2014\u2014 log end \u2014\u2014")}}}}}function r(t,o){return new Array(o+1).join(t)}function s(t,o){return r("0",o-t.toString().length)+t}function i(t){var o=t.prototype._init;t.prototype._init=function(t){var e=this;t=t||{};var n=this.constructor.options,r=t.store||n.store;r?this.$store=r:t.parent&&t.parent.$store&&(this.$store=t.parent.$store);var s=t.vuex||n.vuex;s&&!function(){e.$store||console.warn("[vuex] store not injected. make sure to provide the store option in your root component.");var o=s.state,n=s.actions;o&&(t.computed=t.computed||{},Object.keys(o).forEach(function(e){t.computed[e]=function(){return o[e].call(this,this.$store.state)}})),n&&(t.methods=t.methods||{},Object.keys(n).forEach(function(o){t.methods[o]=function(){for(var t,e=arguments.length,r=Array(e),s=0;e>s;s++)r[s]=arguments[s];return(t=n[o]).call.apply(t,[this,this.$store].concat(r))}}))}(),o.call(this,t)}}function a(t){h=t,i(h)}var u={};u["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},u.classCallCheck=function(t,o){if(!(t instanceof o))throw new TypeError("Cannot call a class as a function")},u.createClass=function(){function t(t,o){for(var e=0;en;n++)e[n]=arguments[n];v.apply(o,e)},this._vm=new h({data:r}),this._setupModuleState(r,c),this._setupModuleMutations(c),this._setupMiddlewares(f,r),p&&this._setupMutationCheck()}return u.createClass(t,[{key:"dispatch",value:function(t){for(var o=arguments.length,n=Array(o>1?o-1:0),r=1;o>r;r++)n[r-1]=arguments[r];var s=this._mutations[t],i=this._prevSnapshot,a=this.state,u=void 0,c=void 0;s?(this._dispatching=!0,Array.isArray(s)?s.forEach(function(t){return t.apply(void 0,[a].concat(n))}):s.apply(void 0,[a].concat(n)),this._dispatching=!1,this._needSnapshots&&(u=this._prevSnapshot=e(a),c=e(n)),this._middlewares.forEach(function(o){o.onMutation&&(o.snapshot?o.onMutation({type:t,payload:c},u,i):o.onMutation({type:t,payload:n},a))})):console.warn("[vuex] Unknown mutation: "+t)}},{key:"watch",value:function(t,o,e){var n=this;return this._vm.$watch(function(){return"function"==typeof t?t(n.state):n._vm.$get(t)},o,e)}},{key:"hotUpdate",value:function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],o=t.mutations,e=t.modules;this._rootMutations=this._mutations=o||this._rootMutations,this._setupModuleMutations(e||this._modules)}},{key:"_setupModuleState",value:function(t,o){var e=h.parsers.path.setPath;Object.keys(o).forEach(function(n){e(t,n,o[n].state)})}},{key:"_setupModuleMutations",value:function(t){this._modules=t;var e=h.parsers.path.getPath,n=[this._rootMutations];Object.keys(t).forEach(function(o){var r=t[o],s={};Object.keys(r.mutations).forEach(function(t){var n=r.mutations[t];s[t]=function(t){for(var r=arguments.length,s=Array(r>1?r-1:0),i=1;r>i;i++)s[i-1]=arguments[i];n.apply(void 0,[e(t,o)].concat(s))}}),n.push(s)}),this._mutations=o(n)}},{key:"_setupMutationCheck",value:function(){var t=this,o=this._vm.$watch("__vuex__",function(t){return t}),e=this._vm._watchers[0].constructor;o(),new e(this._vm,"$data",function(){if(!t._dispatching)throw new Error("[vuex] Do not mutate vuex store state outside mutation handlers.")},{deep:!0,sync:!0})}},{key:"_setupMiddlewares",value:function(t,o){this._middlewares=[c].concat(t),this._needSnapshots=t.some(function(t){return t.snapshot}),this._needSnapshots&&console.log("[vuex] One or more of your middlewares are taking state snapshots for each mutation. Make sure to use them only during development.");var n=this._prevSnapshot=this._needSnapshots?e(o):null;this._middlewares.forEach(function(t){t.onInit&&t.onInit(t.snapshot?n:o)})}},{key:"state",get:function(){return this._vm._data},set:function(t){throw new Error("[vuex] Vuex root state is read only.")}}]),t}(),f={Store:l,install:a,createLogger:n};t.Store=l,t.install=a,t.createLogger=n,t["default"]=f});