UNPKG

@turbox3d/renderer-core

Version:

Large-scale declarative graphic ui core renderer

2 lines 146 kB
/*! For license information please see index.min.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("THREE")):"function"==typeof define&&define.amd?define(["THREE"],e):"object"==typeof exports?exports["@turbox3d/renderer-core"]=e(require("THREE")):t.RendererCore=e(t.THREE)}(self,(t=>(()=>{var e={498:(t,e,n)=>{var i=n(553).default;function r(){"use strict";t.exports=r=function(){return n},t.exports.__esModule=!0,t.exports.default=t.exports;var e,n={},o=Object.prototype,a=o.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},c=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",h=s.toStringTag||"@@toStringTag";function l(t,e,n,i){Object.defineProperty(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i})}try{l({},"")}catch(e){l=function(t,e,n){return t[e]=n}}function d(t,n,i,r){var o=n&&n.prototype instanceof f?n:f,a=Object.create(o.prototype);return l(a,"_invoke",function(t,n,i){var r=1;return function(o,a){if(3===r)throw Error("Generator is already running");if(4===r){if("throw"===o)throw a;return{value:e,done:!0}}for(i.method=o,i.arg=a;;){var s=i.delegate;if(s){var c=x(s,i);if(c){if(c===p)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(1===r)throw r=4,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=3;var u=v(t,n,i);if("normal"===u.type){if(r=i.done?4:2,u.arg===p)continue;return{value:u.arg,done:i.done}}"throw"===u.type&&(r=4,i.method="throw",i.arg=u.arg)}}}(t,i,new S(r||[])),!0),a}function v(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}n.wrap=d;var p={};function f(){}function y(){}function g(){}var m={};l(m,c,(function(){return this}));var k=Object.getPrototypeOf,T=k&&k(k(P([])));T&&T!==o&&a.call(T,c)&&(m=T);var w=g.prototype=f.prototype=Object.create(m);function C(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(r,o,s,c){var u=v(t[r],t,o);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==i(l)&&a.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):e.resolve(l).then((function(t){h.value=t,s(h)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var r;l(this,"_invoke",(function(t,i){function o(){return new e((function(e,r){n(t,i,e,r)}))}return r=r?r.then(o,o):o()}),!0)}function x(t,n){var i=n.method,r=t.i[i];if(r===e)return n.delegate=null,"throw"===i&&t.i.return&&(n.method="return",n.arg=e,x(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),p;var o=v(r,t.i,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,p;var a=o.arg;return a?a.done?(n[t.r]=a.value,n.next=t.n,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,p):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,p)}function M(t){this.tryEntries.push(t)}function E(t){var n=t[4]||{};n.type="normal",n.arg=e,t[4]=n}function S(t){this.tryEntries=[[-1]],t.forEach(M,this),this.reset(!0)}function P(t){if(null!=t){var n=t[c];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function n(){for(;++r<t.length;)if(a.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(i(t)+" is not iterable")}return y.prototype=g,l(w,"constructor",g),l(g,"constructor",y),l(g,h,y.displayName="GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,l(t,h,"GeneratorFunction")),t.prototype=Object.create(w),t},n.awrap=function(t){return{__await:t}},C(b.prototype),l(b.prototype,u,(function(){return this})),n.AsyncIterator=b,n.async=function(t,e,i,r,o){void 0===o&&(o=Promise);var a=new b(d(t,e,i,r),o);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},C(w),l(w,h,"Generator"),l(w,c,(function(){return this})),l(w,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=Object(t),n=[];for(var i in e)n.unshift(i);return function t(){for(;n.length;)if((i=n.pop())in e)return t.value=i,t.done=!1,t;return t.done=!0,t}},n.values=P,S.prototype={constructor:S,reset:function(t){if(this.prev=this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(E),!t)for(var n in this)"t"===n.charAt(0)&&a.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(e){a.type="throw",a.arg=t,n.next=e}for(var r=n.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o[4],s=this.prev,c=o[1],u=o[2];if(-1===o[0])return i("end"),!1;if(!c&&!u)throw Error("try statement without catch or finally");if(null!=o[0]&&o[0]<=s){if(s<c)return this.method="next",this.arg=e,i(c),!0;if(s<u)return i(u),!1}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i[0]>-1&&i[0]<=this.prev&&this.prev<i[2]){var r=i;break}}r&&("break"===t||"continue"===t)&&r[0]<=e&&e<=r[2]&&(r=null);var o=r?r[4]:{};return o.type=t,o.arg=e,r?(this.method="next",this.next=r[2],p):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[2]===t)return this.complete(n[4],n[3]),E(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[0]===t){var i=n[4];if("throw"===i.type){var r=i.arg;E(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={i:P(t),r:n,n:i},"next"===this.method&&(this.arg=e),p}},n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports},553:t=>{function e(n){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},713:(t,e,n)=>{var i=n(498)();t.exports=i;try{regeneratorRuntime=i}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}},858:e=>{"use strict";e.exports=t}},n={};function i(t){var r=n[t];if(void 0!==r)return r.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,i),o.exports}i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(e){var n=function(e){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==t(n)?n:n+""}function n(t,n,i){return(n=e(n))in t?Object.defineProperty(t,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[n]=i,t}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function a(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function s(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}i.r(r),i.d(r,{BaseMesh:()=>Qe,BaseScene:()=>qe,Component:()=>ie,PureComponent:()=>re,Reactive:()=>an,SceneType:()=>$e,VirtualNode:()=>Je,batchUpdate:()=>nn,g:()=>en,render:()=>tn});var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),u=new Array(36);function h(){for(var t=0,e=0;e<36;e++)if(8===e||13===e||18===e||23===e)u[e]="-";else if(14===e)u[e]="7";else{t<=2&&(t=33554432+16777216*Math.random()|0);var n=15&t;t>>=4,u[e]=c[19===e?3&n|8:n]}return u.join("")}function l(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,n){for(var i=0;i<n.length;i++){var r=n[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,e(r.key),r)}}function v(t,e,n){return e&&d(t.prototype,e),n&&d(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}var p=function(){function t(e,n){l(this,t),this.fn=e,this.priority=n}return v(t,null,[{key:"createTask",value:function(e,n){return new t(e,n)}}])}();function f(){return"undefined"!=typeof Symbol}var y=/^\[object (?:Object|Array|Map|Set|WeakMap|WeakSet)\]$/;function g(e){return null!==e&&"object"===t(e)}function m(t){return t&&"function"==typeof t.then}function k(e){if(null===e||"object"!==t(e))return!1;var n=Object.getPrototypeOf(e);return n===Object.prototype||null===n}function T(t,e){return t.indexOf(e)>-1}function w(t,e){var n=t.indexOf(e);n>-1&&t.splice(n,1)}function C(t,e){e.forEach((function(e){t.delete(e)}))}var b,x=Promise.resolve();function M(t){return t?x.then(t):x}function E(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function S(t,e){return function(n){var i=arguments.length;return i?i>1?t.apply(e,arguments):t.call(e,n):t.call(e)}}function P(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(E(e,n))return!0;if("object"!==t(e)||null===e||"object"!==t(n)||null===n)return!1;var r=[],o=[];if(i&&i.length>0){var a=new Set(i);r=Object.keys(e).filter((function(t){return!a.has(t)})),o=Object.keys(n).filter((function(t){return!a.has(t)}))}else r=Object.keys(e),o=Object.keys(n);if(r.length!==o.length)return!1;for(var s=0;s<r.length;s++)if(!n.hasOwnProperty(r[s])||!E(e[r[s]],n[r[s]]))return!1;return!0}function _(){return"undefined"!=typeof window?"browser":"vm"}function D(t){var e,n=_();return"browser"===n&&(e=window[t]),"vm"===n&&(e=i.g[t]),e}!function(t){t[t.UserAction=0]="UserAction",t[t.UpdateState=1]="UpdateState",t[t.RenderReact=2]="RenderReact",t[t.RenderScene=-1]="RenderScene"}(b||(b={}));var R=[],A=!1;function O(){var t=function(t,e){for(var n=t.length,i=0;i<n;i++)for(var r=i+1;r<n;r++){var o=t[i],a=t[r],s=e?e(o):o;(e?e(a):a)<s&&(t[i]=a,t[r]=o)}return t}(R,(function(t){return t.priority}));R=[],t.forEach((function(t){(0,t.fn)()})),A=!1}function L(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.UserAction,i=!1;function r(){i=!1,t.apply(void 0,s(e))}var o=function(t,e){var n=1e3/e,i=0;return function(){var e=Date.now();if(e-i>=n){for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];t.apply(this,o),i=e}}}((function(){for(var t=arguments.length,o=new Array(t),a=0;a<t;a++)o[a]=arguments[a];e=o,i||(i=!0,R.push(p.createTask(r,n)),A||(A=!0,M(O)))}),arguments.length>2&&void 0!==arguments[2]?arguments[2]:60);return o}function z(t,e){var n={x:t.x-e.x,y:t.y-e.y};if(!(n.x<=0||n.y<=0||n.x>e.width||n.y>e.height))return n}i(713),i(858),new(function(){return v((function t(){l(this,t),this.listeners={}}),[{key:"on",value:function(t,e){var n=this.listeners[t]||[];n.push(e),this.listeners[t]=n}},{key:"emit",value:function(t){for(var e=this,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];var o=this.listeners[t];Array.isArray(o)&&o.forEach((function(t){try{t.apply(e,i)}catch(t){console.error(t)}}))}},{key:"off",value:function(t){this.listeners[t]&&(this.listeners[t]=[])}}])}());var U="An invariant failed, however the error is obfuscated because this is an production build.";function I(t,e){if(!t)throw new Error("[turbox]: ".concat(e||U))}function N(t){throw I(!1,t),"X"}function V(t){console.warn("[turbox]: ".concat(t))}function F(e){return e&&"object"===t(e)&&"[object RegExp]"!==Object.prototype.toString.call(e)&&"[object Date]"!==Object.prototype.toString.call(e)}function H(t,e){var n;return e&&!0===e.clone&&F(t)?j((n=t,Array.isArray(n)?[]:{}),t,e):t}function B(t,e,n){var i=t.slice();return e.forEach((function(e,r){void 0===i[r]?i[r]=H(e,n):F(e)?i[r]=j(t[r],e,n):-1===t.indexOf(e)&&i.push(H(e,n))})),i}function j(t,e,n){var i=Array.isArray(e),r=(n||{arrayMerge:B}).arrayMerge||B;return i?Array.isArray(t)?r(t,e,n):H(e,n):function(t,e,n){var i={};return F(t)&&Object.keys(t).forEach((function(e){i[e]=H(t[e],n)})),Object.keys(e).forEach((function(r){F(e[r])&&t[r]?i[r]=j(t[r],e[r],n):i[r]=H(e[r],n)})),i}(t,e,n)}function G(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce((function(t,e){return function(){return t(e.apply(void 0,arguments))}}))}Date.now;var Z="@@TURBOX__";function X(t){return f()?Symbol(t):"".concat(Z).concat(t)}var $,Y,W,q,K,Q,J,tt,et=X("namespace"),nt=(X("reactive-component-name"),X("unsubscribe-handler")),it="".concat(Z,"materialType"),rt="".concat(Z,"empty"),ot=("".concat(Z,"field"),!1),at={middleware:{logger:ot,diffLogger:!0,effect:!1,perf:ot,skipNestLog:!0,skipNestPerfLog:!0},timeTravel:{isActive:!1,isNeedRecord:!1,maxStepNumber:20,keepActionChain:ot},disableReactive:!1,strictMode:ot,devTool:!1,batchUpdateOnFinish:void 0};!function(t){t.NOT_OBSERVED="notObserved",t.OBSERVED="observed",t.LATEST="latest"}($||($={})),(tt=Y||(Y={})).ARRAY_LENGTH="length",tt.ITERATE="iterate",tt.COMPUTED="computed",(J=W||(W={})).SET="set",J.MAP_SET="map-set",J.ADD="add",J.SET_ADD="set-add",J.DELETE="delete",J.MAP_DELETE="map-delete",J.SET_DELETE="set-delete",(Q=q||(q={})).DEFAULT="default",Q.MUTATION="mutation",Q.ACTION="action",Q.UPDATE="update",Q.EFFECT="effect",Q.UNDO="undo",Q.REDO="redo",function(t){t.WORKING="working",t.COMPLETED="completed",t.ABORT="abort"}(K||(K={}));var st=function(){function t(){l(this,t),this.currentHistory=new Map,this.transactionHistories=[],this.cursor=-1}return v(t,[{key:"undoable",get:function(){return this.cursor>=0}},{key:"redoable",get:function(){return this.cursor<this.transactionHistories.length-1}},{key:"onChange",value:function(t,e,n,i){}},{key:"undo",value:function(){var e=this;if(this.undoable){var n=this.transactionHistories[this.cursor];wt||N("store is not ready, please init first.");var i=n.actionChain[0]||{name:"",displayName:""};wt.dispatch({name:"".concat(Z,"UNDO_").concat(i.name),displayName:"UNDO_".concat(i.displayName),payload:[],original:function(){t.undoHandler(n.history)},type:q.UNDO,isInner:!0}),this.cursor-=1,M((function(){e.onChange(e.undoable,e.redoable,"undo")}))}}},{key:"redo",value:function(){var e=this;if(this.redoable){this.cursor+=1;var n=this.transactionHistories[this.cursor];wt||N("store is not ready, please init first.");var i=n.actionChain[0]||{name:"",displayName:""};wt.dispatch({name:"".concat(Z,"REDO_").concat(i.name),displayName:"REDO_".concat(i.displayName),payload:[],original:function(){t.redoHandler(n.history)},type:q.REDO,isInner:!0}),M((function(){e.onChange(e.undoable,e.redoable,"redo")}))}}},{key:"clear",value:function(){var t=this;this.currentHistory=new Map,this.transactionHistories.length=0,this.cursor=-1,M((function(){t.onChange(t.undoable,t.redoable,"clear")}))}}],[{key:"undoable",get:function(){return t.currentTimeTravel&&t.currentTimeTravel.undoable}},{key:"redoable",get:function(){return t.currentTimeTravel&&t.currentTimeTravel.redoable}},{key:"undoHandler",value:function(t){t.forEach((function(t,e){t&&t.forEach((function(t,n){t&&t.beforeUpdate!==t.didUpdate&&(t.type===W.MAP_SET||t.type===W.MAP_DELETE?void 0===t.beforeUpdate?e.delete(n):e.set(n,t.beforeUpdate):t.type===W.SET_ADD?e.delete(n):t.type===W.SET_DELETE?e.add(n):Array.isArray(e)&&void 0===t.beforeUpdate?delete e[n]:e[n]=t.beforeUpdate)}))}))}},{key:"redoHandler",value:function(t){t.forEach((function(t,e){t&&t.forEach((function(t,n){t&&t.beforeUpdate!==t.didUpdate&&(t.type===W.MAP_SET?e.set(n,t.didUpdate):t.type===W.SET_ADD?e.add(n):t.type===W.SET_DELETE||t.type===W.MAP_DELETE?e.delete(n):e[n]=t.didUpdate)}))}))}}])}();st.timeTravels={},st.processing=!1,st.switch=function(t){st.currentTimeTravel=st.get(t)},st.create=function(t){var e=new st;return st.timeTravels[t]=e,e},st.get=function(t){return st.timeTravels[t]},st.pause=function(){at.timeTravel.isActive=!1},st.resume=function(){at.timeTravel.isActive=!0},st.undo=function(){st.currentTimeTravel&&st.currentTimeTravel.undo()},st.redo=function(){st.currentTimeTravel&&st.currentTimeTravel.redo()},st.clear=function(){st.currentTimeTravel&&st.currentTimeTravel.clear()};var ct,ut={freeze:!1};!function(t){t.storeOnActive="storeOnActive",t.beforeStoreChange="beforeStoreChange",t.afterStoreChange="afterStoreChange",t.asyncAfterStoreChange="asyncAfterStoreChange",t.setProperty="setProperty",t.materialCallStackChange="materialCallStackChange"}(ct||(ct={}));var ht=new(function(){return v((function t(){l(this,t),this.listeners={}}),[{key:"on",value:function(t,e){var n=this.listeners[t]||[];n.push(e),this.listeners[t]=n}},{key:"emit",value:function(t,e){var n=this;at.devTool&&window&&window.__TURBOX_DEVTOOL_GLOBAL_HOOKS__&&window.__TURBOX_DEVTOOL_GLOBAL_HOOKS__.emit(t,e);var i=this.listeners[t];Array.isArray(i)&&i.forEach((function(t){try{t.apply(n,[e])}catch(t){N(t)}}))}},{key:"off",value:function(t){this.listeners[t]&&(this.listeners[t]=[])}}])}()),lt=function(){return v((function t(e,n,i,r,o,a){l(this,t),this.name=e,this.runner=n,this.computed=i,this.lazy=r,this.deps=o,this.immediately=a}),[{key:"dispose",value:function(){void 0!==this.unsubscribeHandler&&this.unsubscribeHandler(),St.clear(this)}}])}();function dt(t,e){var n=e&&e.name||t.name||"".concat(Z,"REACTIVE_").concat(h()),i=!(!e||void 0===e.lazy)&&e.lazy,r=e&&e.deps||[],o=!e||void 0===e.immediately||e.immediately,a=!0,s=new lt(n,(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{if(St.start(s),s.deps.length>0){var n=[];s.deps.forEach((function(t){var e=t();n.push(e)})),St.end(),!a&&t.call.apply(t,[null].concat(n))}else t.call(null),St.end();a&&(a=!1)}catch(t){if(St.end(),a&&(a=!1),!e)throw t}}),!(!e||!e.computed),i,r,o),c=function(){s.unsubscribeHandler=wt.subscribe((function(t){s.runner(t)}),s),s.runner()};return wt?c():ht.on(ct.storeOnActive,(function(){c()})),s}function vt(t,e){return dt(t,e)}function pt(e,n,i,r){var o,a="symbol"!==t(o=n)?o.toString():o.toString()+h(),s=function(){var t=this;e||(t=new Et),wt||N("store is not ready, please init first.");for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];var c=wt.dispatch({name:a,displayName:r.displayName||rt,payload:o,type:q.MUTATION,domain:t,original:S(i,t),immediately:!!r.immediately,forceSaveHistory:!!r.forceSaveHistory,isNeedRecord:!!r.isNeedRecord});if(m(c))return new Promise((function(t,e){c.then((function(e){t(e)}),(function(t){e(t)}))}));if(c&&c instanceof Error)throw c;return c};return s[it]=q.MUTATION,s}function ft(){for(var t={immediately:!1,displayName:"",forceSaveHistory:!1,isNeedRecord:!0},e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];if("string"==typeof n[0]&&"function"==typeof n[1]){void 0!==n[2]&&(t.displayName=n[2].displayName,t.immediately=n[2].immediately,t.forceSaveHistory=!!n[2].forceSaveHistory,t.isNeedRecord=!!n[2].isNeedRecord);var r=n[0],o=n[1];return o[it]===q.MUTATION?o:pt(void 0,r,o,t)}var a=function(e,n,i){var r;if(void 0===i)return Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get:function(){return r},set:function(i){r=i[it]===q.MUTATION?i:pt(e,n,i,t)}});if(void 0!==i.value){var o=i.value;return o[it]===q.MUTATION?i.value=o:i.value=pt(e,n,o,t),i}var a=i.initializer;return i.initializer=function(){I(!!a,"The initializer of the descriptor doesn't exist, please compile it by using babel and correspond decorator plugin.");var i=a&&a.call(this);return i[it]===q.MUTATION?i:pt(e,n,i,t)},i};return function(t){return(2===t.length||3===t.length)&&"string"==typeof t[1]}(n)?a.apply(null,n):(t.displayName=n[0]||"",t.immediately=void 0!==n[1]&&n[1],t.forceSaveHistory=void 0!==n[2]&&n[2],t.isNeedRecord=void 0===n[3]||n[3],a)}function yt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function gt(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?yt(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):yt(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}var mt,kt=new(function(){return v((function t(){l(this,t),this.stack=[],this.pendingToPopStack=[],this.stackId=0}),[{key:"push",value:function(t){this.stackId+=1;var e=gt(gt({},t),{},{stackId:this.stackId});return this.currentStack=e,this.stack.push(e),at.devTool&&ht.emit(ct.materialCallStackChange,{stack:s(this.stack),action:"PUSH",time:Date.now(),currentStack:e}),this.stackId}},{key:"pop",value:function(t){var e;if(0!==this.stack.length){if(this.stack[this.stack.length-1].stackId!==t)this.pendingToPopStack.unshift(t);else{this.currentStack=void 0;var n=this.stack.pop();at.devTool&&ht.emit(ct.materialCallStackChange,{stack:s(this.stack),action:"POP",time:Date.now(),currentStack:n})}for(var i=s(this.pendingToPopStack),r=0;r<this.pendingToPopStack.length;r+=1){var o=this.pendingToPopStack[r];if((null===(e=this.stack[this.stack.length-1])||void 0===e?void 0:e.stackId)!==o)break;var a=this.stack.pop();i.splice(r,1),this.currentStack=this.stack[this.stack.length-1],at.devTool&&ht.emit(ct.materialCallStackChange,{stack:s(this.stack),action:"POP",time:Date.now(),currentStack:a})}this.pendingToPopStack=i,0===this.pendingToPopStack.length&&(this.currentStack=void 0)}}}])}());function Tt(t){return t instanceof Et}!function(t){t.property="property",t.index="index"}(mt||(mt={}));var wt,Ct=new WeakMap,bt=new WeakMap,xt=new WeakMap,Mt=[Map,Set,WeakMap,WeakSet],Et=function(){return v((function t(){var e=this;l(this,t),this.$$turboxProperties={},this.reactorConfigMap={},this.computedProperties={},this.getCollectionHandlerMap=function(t,i){return n(n(n(n(n({get size(){var e=Reflect.getPrototypeOf(t);return St.collect(t,Y.ITERATE),Reflect.get(e,i,t)},get:function(e){var n=Reflect.getPrototypeOf(t).get;return St.collect(t,e),n.call(t,e)},has:function(e){var n=Reflect.getPrototypeOf(t).has;return St.collect(t,e),n.call(t,e)},forEach:function(e){var n=Reflect.getPrototypeOf(t).forEach;return St.collect(t,Y.ITERATE),n.call(t,e)},values:function(){var e=Reflect.getPrototypeOf(t).values;return St.collect(t,Y.ITERATE),e.call(t)},keys:function(){var e=Reflect.getPrototypeOf(t).keys;return St.collect(t,Y.ITERATE),e.call(t)},entries:function(){var e=Reflect.getPrototypeOf(t).entries;return St.collect(t,Y.ITERATE),e.call(t)}},Symbol.iterator,(function(){return t.constructor===Set?e.getCollectionHandlerMap(t,"values").values():t.constructor===Map?e.getCollectionHandlerMap(t,"entries").entries():void 0})),"add",(function(n){var i=Reflect.getPrototypeOf(t),r=i.add,o=i.has,a=xt.get(t),s=a[0].value;return o.call(t,n)||(Pt.trigger(t,n,{type:W.SET_ADD,beforeUpdate:void 0,didUpdate:n},e.reactorConfigMap[s].isNeedRecord,{keyPath:a,domain:e.constructor.name}),Pt.trigger(t,Y.ITERATE,{type:W.SET_ADD},e.reactorConfigMap[s].isNeedRecord)),r.call(t,n)})),"set",(function(n,i){var r=Reflect.getPrototypeOf(t),o=r.set,a=r.get,s=r.has,c=xt.get(t),u=c[0].value,h=s.call(t,n),l=a.call(t,n);return i!==l&&Pt.trigger(t,n,{type:W.MAP_SET,beforeUpdate:l,didUpdate:i},e.reactorConfigMap[u].isNeedRecord,{keyPath:c,domain:e.constructor.name}),h||Pt.trigger(t,Y.ITERATE,{type:W.MAP_SET},e.reactorConfigMap[u].isNeedRecord),o.call(t,n,i)})),"delete",(function(n){var i=Reflect.getPrototypeOf(t),r=xt.get(t),o=r[0].value;if(!i.has.call(t,n))return i.delete.call(t,n);if(i.constructor===Map||i.constructor===WeakMap){var a=i.get.call(t,n);Pt.trigger(t,n,{type:W.MAP_DELETE,beforeUpdate:a},e.reactorConfigMap[o].isNeedRecord,{keyPath:r,domain:e.constructor.name}),Pt.trigger(t,Y.ITERATE,{type:W.MAP_DELETE},e.reactorConfigMap[o].isNeedRecord)}return i.constructor!==Set&&i.constructor!==WeakSet||(Pt.trigger(t,n,{type:W.SET_DELETE,beforeUpdate:n},e.reactorConfigMap[o].isNeedRecord,{keyPath:r,domain:e.constructor.name}),Pt.trigger(t,Y.ITERATE,{type:W.SET_DELETE},e.reactorConfigMap[o].isNeedRecord)),i.delete.call(t,n)})),"clear",(function(){var n=Reflect.getPrototypeOf(t),i=n.clear;return n.forEach.call(t,(function(n,i){e.getCollectionHandlerMap(t,i).delete(i)})),i.call(t)}))};var i=Object.getPrototypeOf(this).constructor.name||"TURBOX_DOMAIN",r="".concat(i,"_").concat(h());this[et]=r,this.context=this.initDomainContext()}),[{key:"initDomainContext",value:function(){return{isNeedRecord:at.timeTravel.isNeedRecord}}},{key:"propertyGet",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,r=t in this.$$turboxProperties,o=n&&!r,a=o?i:this.$$turboxProperties[t];o&&this.propertySet(t,a,e);var s=Object.assign({},{isNeedRecord:this.context.isNeedRecord},e);return this.reactorConfigMap[t]=s,St.collect(this,t),g(a)&&!Tt(a)&&s.deepProxy?this.proxyReactive(a,[{type:mt.property,value:t}]):a}},{key:"propertySet",value:function(t,e,n){at.strictMode&&this.illegalAssignmentCheck(this,t);var i=this.$$turboxProperties[t],r=Object.assign({},{isNeedRecord:this.context.isNeedRecord},n);this.reactorConfigMap[t]=r,i!==e&&(this.$$turboxProperties[t]=e,Pt.trigger(this,t,{type:W.SET,beforeUpdate:i,didUpdate:e},r.isNeedRecord,{keyPath:[{type:mt.property,value:t}],domain:this.constructor.name}))}},{key:"computedPropertyGet",value:function(t,e,n){var i=this;this.computedProperties[t]||(this.computedProperties[t]={dirty:!0,needReComputed:!1,needTrigger:!1});var r=this.computedProperties[t],o=!(!e||void 0===e.lazy)&&e.lazy;if(r.reaction||(r.reaction=dt((function(){r.dirty=!0,r.needReComputed&&(r.value=r.computeRunner()),r.needTrigger&&Pt.trigger(i,t,{type:W.SET,beforeUpdate:void 0,didUpdate:void 0},!1)}),{name:t,computed:!0,lazy:o})),!r.computeRunner&&n&&(r.computeRunner=S(n.get,this)),r.dirty){r.needReComputed=!0,r.needTrigger=!1;try{r.reaction.runner()}finally{r.dirty=!1,r.needReComputed=!1,r.needTrigger=!0}}return St.collect(this,t),r.value}},{key:"computedPropertySet",value:function(t,e){this.computedProperties[t]||(this.computedProperties[t]={dirty:!0,needReComputed:!1,needTrigger:!1}),this.computedProperties[t].computeRunner||(this.computedProperties[t].computeRunner=S(e,this))}},{key:"$update",value:function(t,e,n,i,r,o){I(k(t),"resetState(...) param type error. Param should be a plain object."),this.dispatch(t,e,n,i,r,o)}},{key:"proxySet",value:function(t,e,n,i){Array.isArray(t)&&t!==this.currentTarget&&(this.currentTarget=t,this.originalArrayLength=t[Y.ARRAY_LENGTH]),at.strictMode&&this.illegalAssignmentCheck(t,e);var r=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e),o=t[e],a=xt.get(t)[0].value;return t===Ct.get(i)&&(e!==Y.ARRAY_LENGTH&&n===o||(Pt.trigger(t,e,{type:W.SET,beforeUpdate:e===Y.ARRAY_LENGTH?this.originalArrayLength:o,didUpdate:n},this.reactorConfigMap[a].isNeedRecord,{keyPath:[{type:mt.property,value:e}],domain:this.constructor.name}),e===Y.ARRAY_LENGTH&&(this.currentTarget=void 0,this.originalArrayLength=void 0)),r||Pt.trigger(t,e,{type:W.ADD,beforeUpdate:o,didUpdate:n},this.reactorConfigMap[a].isNeedRecord,{keyPath:[{type:mt.property,value:e}],domain:this.constructor.name}),Reflect.set(t,e,n,i))}},{key:"proxyGet",value:function(t,e,n){var i=this,r=Reflect.get(t,e,n),o=xt.get(t),a=o[0].value;return St.collect(t,e),this.reactorConfigMap[a].callback&&!ut.freeze&&(ut.freeze=!0,i.reactorConfigMap[a].callback&&i.reactorConfigMap[a].callback.call(i,t,e),ut.freeze=!1),g(r)&&!Tt(r)?this.proxyReactive(r,[].concat(s(o),[{type:Array.isArray(t)?mt.index:mt.property,value:e}])):r}},{key:"proxyDeleteProperty",value:function(t,e){var n=xt.get(t)[0].value,i=t[e];return Pt.trigger(t,e,{type:W.DELETE,beforeUpdate:i,didUpdate:void 0},this.reactorConfigMap[n].isNeedRecord,{keyPath:[{type:mt.property,value:e}],domain:this.constructor.name}),Reflect.deleteProperty(t,e)}},{key:"proxyOwnKeys",value:function(t){return St.collect(t,Y.ITERATE),Reflect.ownKeys(t)}},{key:"proxyReactive",value:function(t,e){var n=this;xt.set(t,e);var i,r=bt.get(t);if(void 0!==r)return r;if(Ct.has(t))return t;if(i=t,!y.test(function(t){return Object.prototype.toString.call(t)}(i)))return t;var o=T(Mt,t.constructor)?{get:S(n.collectionProxyHandler,n)}:{get:S(n.proxyGet,n),set:S(n.proxySet,n),ownKeys:S(n.proxyOwnKeys,n),deleteProperty:S(n.proxyDeleteProperty,n)},a=new Proxy(t,o);return Ct.set(a,t),bt.set(t,a),a}},{key:"collectionProxyHandler",value:function(t,e){var n=this.getCollectionHandlerMap(t,e),i=e in t&&n[e]?n:t;return Reflect.get(i,e)}},{key:"illegalAssignmentCheck",value:function(t,e){if(St.isObserved(t,e)){var n=kt.stack.length,i=kt.stack[n-1]||q.DEFAULT;I(i.type===q.MUTATION||i.type===q.UPDATE||i.type===q.UNDO||i.type===q.REDO,"You cannot update value to observed '@reactor property' directly. Please use mutation or $update({}).")}}},{key:"dispatch",value:function(t,e,n,i,r,o){var a=function(){for(var e=Object.keys(t),n=0,i=e.length;n<i;n++){var r=e[n];this[r]=t[r]}};if(void 0===wt)return a.call(this),void kt.pop(-1);wt.dispatch({name:e||"".concat(Z,"UPDATE"),displayName:n||rt,payload:[],type:q.UPDATE,domain:this,original:S(a,this),forceSaveHistory:i,isNeedRecord:r,immediately:o})}}])}(),St=new(function(){return v((function t(){l(this,t),this.dependencyGraph=new Map,this.reactionIdDeps=new Map,this.reactionIdStack=[]}),[{key:"start",value:function(t){this.reactionIdStack.push(t)}},{key:"collect",value:function(t,e){if(!{constructor:!0,$$turboxProperties:!0,context:!0,currentTarget:!0,originalArrayLength:!0,reactorConfigMap:!0,computedProperties:!0,propertyGet:!0,propertySet:!0,proxyDeleteProperty:!0,proxyOwnKeys:!0,proxySet:!0,proxyGet:!0,proxyReactive:!0,$update:!0,illegalAssignmentCheck:!0,dispatch:!0}[e]){var n=this.reactionIdStack.length;if(0!==n){var i=this.reactionIdStack[n-1],r=this.dependencyGraph.get(t);if(void 0!==r){var o=r.get(e);void 0!==o?o.add(i):r.set(e,new Set([i]))}else{var a=new Map([[e,new Set([i])]]);this.dependencyGraph.set(t,a)}var s=this.reactionIdDeps.get(i);if(void 0!==s){var c=s.get(t);void 0!==c?c.set(e,$.LATEST):s.set(t,new Map([[e,$.LATEST]]))}else this.reactionIdDeps.set(i,new Map([[t,new Map([[e,$.LATEST]])]]))}}}},{key:"end",value:function(){var t=this,e=this.reactionIdStack.pop();if(e){var n=this.reactionIdDeps.get(e);n&&n.forEach((function(n,i){n.forEach((function(r,o){if(r===$.OBSERVED){var a=t.dependencyGraph.get(i);if(a){var s=a.get(o);s&&s.delete(e),n.set(o,$.NOT_OBSERVED)}}r===$.LATEST&&n.set(o,$.OBSERVED)}))}))}}},{key:"clear",value:function(t){var e=this,n=this.reactionIdDeps.get(t);n&&(n.forEach((function(n,i){n.forEach((function(n,r){var o=e.dependencyGraph.get(i);if(o){var a=o.get(r);a&&a.delete(t)}}))})),this.reactionIdDeps.delete(t))}},{key:"isObserved",value:function(t,e){var n=this.dependencyGraph.get(t);return void 0!==n&&n.has(e)&&(n.get(e)||new Set).size>0}}])}()),Pt=new(function(){return v((function t(){l(this,t),this.waitTriggerIds=new Set}),[{key:"trigger",value:function(t,e,n){var i,r,o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4?arguments[4]:void 0,s=n.type,c=n.beforeUpdate,u=n.didUpdate;if(at.devTool&&a)try{var h=null!==(i=window&&window.__TURBOX_DEVTOOL_GOLBAL_STRINGIFY__)&&void 0!==i?i:JSON.stringify,l={time:Date.now(),stackId:null===(r=kt.currentStack)||void 0===r?void 0:r.stackId,domain:a.domain,keyPath:a.keyPath,newValue:h(u),oldValue:h(c),type:s};ht.emit(ct.setProperty,l),console.log(l)}catch(t){N(t)}var d=s===W.ADD?Y.ITERATE:e;this.collectComponentId(t,d),at.timeTravel.isActive&&st.currentTimeTravel&&o&&!st.processing&&d!==Y.ITERATE&&d!==Y.COMPUTED&&(Ot.context?this.recordDiff(t,d,n,Ot.context.historyNode.history):this.recordDiff(t,d,n,st.currentTimeTravel.currentHistory))}},{key:"endBatch",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1?arguments[1]:void 0;if(e||this.waitTriggerIds.clear(),at.timeTravel.isActive&&st.currentTimeTravel&&t){if(e)return e.historyNode.actionChain.length=0,e.historyNode.history.clear(),void M((function(){var t=st.currentTimeTravel;t&&t.onChange(t.undoable,t.redoable,"clear",e)}));_t.length=0,st.currentTimeTravel.currentHistory.clear()}}},{key:"save",value:function(t){if(at.timeTravel.isActive&&st.currentTimeTravel&&!Ot.context){var e=st.currentTimeTravel;t?this.saveHistory(e,t.historyNode.actionChain,t.historyNode.history,t):this.saveHistory(e,_t,e.currentHistory)}}},{key:"collectComponentId",value:function(t,e){var n=this,i=St.dependencyGraph.get(t);if(void 0!==i){var r=i.get(e);void 0!==r&&r.size>0&&r.forEach((function(t){return n.waitTriggerIds.add(t)}))}}},{key:"recordDiff",value:function(t,e,n,i){var r,o=n.type,a=n.beforeUpdate,s=n.didUpdate;if(r=Tt(t)?t:bt.get(t)){var c=i.get(r);if(void 0!==c){var u=c.get(e);void 0!==u?u.didUpdate=s:c.set(e,{type:o,beforeUpdate:a,didUpdate:s})}else i.set(r,new Map([[e,{type:o,beforeUpdate:a,didUpdate:s}]]))}}},{key:"saveHistory",value:function(t,e,n,i){if(n&&0!==n.size){var r=at.timeTravel.keepActionChain?e.slice():[],o=new Map(n);t.cursor===t.transactionHistories.length-1?(t.transactionHistories.push({actionChain:r,history:o}),t.cursor+=1):t.cursor<t.transactionHistories.length-1&&(t.transactionHistories=t.transactionHistories.slice(0,t.cursor+1),t.transactionHistories.push({actionChain:r,history:o}),t.cursor+=1),t.transactionHistories.length>at.timeTravel.maxStepNumber&&(t.transactionHistories.shift(),t.cursor-=1),M((function(){t.onChange(t.undoable,t.redoable,"save",i)}))}}}])}()),_t=[],Dt=[];function Rt(t){if(void 0!==t)return wt=t(Rt);var e,n=new WeakMap,i=0,r=!1,o=function(t,e,i){if(t.length&&!at.disableReactive){for(var r=[],o=0;o<t.length;o++){var a=t[o],s=n.get(a);s&&r.push(s)}var c=function(t){return function(){for(var e=0;e<r.length;e++){var n=r[e];if(n.idCustomType===t)for(var o=n.listeners,a=0;a<o.length;a++)(0,o[a])(i)}}};e?Dt.forEach((function(t){(0,t.handler)(c(t.idCustomType),(function(){at.batchUpdateOnFinish&&at.batchUpdateOnFinish()}))})):c()()}},a=function(t){var e=s(Pt.waitTriggerIds.values()).filter((function(t){return t instanceof lt&&!t.lazy&&t.computed}));e.length&&(at.devTool&&console.log("keepAlive computed",e),o(e,!1,t),C(Pt.waitTriggerIds,e))},c=function(t){var e=s(Pt.waitTriggerIds.values()).filter((function(t){return t instanceof lt&&!t.computed&&t.immediately}));e.length&&(C(Pt.waitTriggerIds,e),at.devTool&&console.log("immediately reactive",e),o(e,!1,t))},u=[],h=function(){if(!r){r=!0;var t=function(){M((function(){if(i>0)return r=!1,void u.shift();0!==u.length&&e&&e()}))};u.push(t),t()}},l=function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];r=!1,e=void 0,u.shift(),_t.length=0,t&&Pt.endBatch()};return{dispatch:function(t){var n,r,u,d,v=t.payload,p=t.type,f=t.original,y=t.immediately,g=t.isInner,k=void 0!==g&&g,T=t.domain,w=t.name,C=t.forceSaveHistory,b=void 0!==C&&C,x=t.isNeedRecord,M=void 0===x||x;k&&(st.processing=!0);var E=kt.push({type:p,method:w,domain:null==T?void 0:T.constructor.name});if(k||p===q.MUTATION||p===q.UPDATE){var S;if(i+=1,(k||y&&Pt.waitTriggerIds.size>0)&&e&&e(),void 0===e&&(e=function(){var t=s(Pt.waitTriggerIds.values());if(t.length||b){!k&&M&&Pt.save();var e=t.filter((function(t){return t instanceof lt&&t.lazy&&t.computed}));at.devTool&&console.log("lazy computed",e),o(e,!1,k);var n=s(Pt.waitTriggerIds.values()).filter((function(t){return t instanceof lt&&!t.computed&&!t.immediately})),i=s(Pt.waitTriggerIds.values()).filter((function(t){return!(t instanceof lt)}));l(),at.devTool&&console.log("lazy reactive",n),o(n,!1,k),at.devTool&&console.log("custom view Reactive",i),o(i,!0,k)}else l(!1)}),at.devTool){var P={domain:null!==(n=null==T?void 0:T.constructor.name)&&void 0!==n?n:"UNKNOWN",method:w,args:v,state:null==T?void 0:T.$$turboxProperties,time:Date.now(),stackId:null===(r=kt.currentStack)||void 0===r?void 0:r.stackId};ht.emit(ct.beforeStoreChange,P)}try{S=f.apply(void 0,s(v))}catch(t){return t}if(at.devTool){var _={domain:null!==(u=null==T?void 0:T.constructor.name)&&void 0!==u?u:"UNKNOWN",method:w,args:v,state:null==T?void 0:T.$$turboxProperties,async:!1,time:Date.now(),stackId:null===(d=kt.currentStack)||void 0===d?void 0:d.stackId};ht.emit(ct.afterStoreChange,_)}return m(S)?(kt.pop(E),new Promise((function(t,n){var r;Promise.resolve().then((function(){r=kt.push({type:p,method:w,domain:null==T?void 0:T.constructor.name,syncStackId:E})})),S.then((function(n){var o,s;at.devTool&&ht.emit(ct.asyncAfterStoreChange,{domain:null!==(o=null==T?void 0:T.constructor.name)&&void 0!==o?o:"UNKNOWN",method:w,args:v,state:null==T?void 0:T.$$turboxProperties,async:!0,time:Date.now(),stackId:null===(s=kt.currentStack)||void 0===s?void 0:s.stackId}),a(k),c(k),i-=1,y?e&&e():h(),kt.pop(r),t(n)})).catch((function(t){n(t)}))}))):(a(k),c(k),i-=1,k||y?(e&&e(),st.processing=!1):h(),kt.pop(E),S)}},subscribe:function(t,e,i){var r=!0,o=n.get(e);return void 0===o||void 0===o.listeners?n.set(e,{idCustomType:i,listeners:[t]}):T(o.listeners,t)||n.set(e,{idCustomType:i,listeners:o.listeners.concat(t)}),function(){r&&(r=!1,n.has(e)&&n.delete(e))}}}}var At=[],Ot=function(){function t(){l(this,t),this.displayName=rt,this.status=K.WORKING,this.historyNode={actionChain:[],history:new Map}}return v(t,[{key:"execute",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3?arguments[3]:void 0;if(this.status!==K.ABORT){t.context=this;var o=(i?ft(this.name,e,r):e).apply(void 0,s(n));if(m(o))return o.then((function(){t.context=void 0}),(function(){t.context=void 0}));t.context=void 0}}},{key:"complete",value:function(){this.status!==K.ABORT&&(this.status=K.COMPLETED,Pt.save(this),Pt.endBatch(!0,this),w(At,this))}},{key:"undo",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];wt||N("store is not ready, please init first.");var n=this.historyNode.actionChain[0]||{name:"",displayName:""};wt.dispatch({name:"".concat(Z,"UNDO_").concat(n.name),displayName:"UNDO_".concat(n.displayName),payload:[],original:function(){st.undoHandler(t.historyNode.history)},type:q.UNDO,isInner:!0}),e||(this.historyNode={actionChain:[],history:new Map},M((function(){var e=st.currentTimeTravel;e&&e.onChange(e.undoable,e.redoable,"undo",t)})))}},{key:"redo",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];wt||N("store is not ready, please init first.");var n=this.historyNode.actionChain[0]||{name:"",displayName:""};wt.dispatch({name:"".concat(Z,"REDO_").concat(n.name),displayName:"REDO_".concat(n.displayName),payload:[],original:function(){st.redoHandler(t.historyNode.history)},type:q.REDO,isInner:!0}),e||(this.historyNode={actionChain:[],history:new Map},M((function(){var e=st.currentTimeTravel;e&&e.onChange(e.undoable,e.redoable,"redo",t)})))}},{key:"abort",value:function(){(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&this.undo(),this.status=K.ABORT,Pt.endBatch(!0,this),w(At,this)}}],[{key:"create",value:function(e,n){var i=new t;return i.name=e,n&&(i.displayName=n),i.historyNode.actionChain.push({name:e,displayName:i.displayName}),At.push(i),i}},{key:"abortAll",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];At.forEach((function(e){e.abort(t)}))}},{key:"get",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.length?1===e.length?At.filter((function(t){return t.name===e[0]})):At.filter((function(t){return T(e,t.name)})):At}}])}();function Lt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function zt(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Lt(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Lt(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}var Ut=[];function It(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=Array.isArray(t)?t:[t];e?Ut.unshift.apply(Ut,s(n)):Ut.push.apply(Ut,s(n))}function Nt(t,e,n,i){var r=t(e);return m(r)?new Promise((function(t,e){r.then((function(e){n&&n(),t(e)})).catch((function(t){i&&i(t.stack||t.message),e(t)}))})):(r&&r instanceof Error?i&&i(r.stack||r.message):n&&n(),r)}const Vt=function(){return function(t){return function(e){var n=e.name,i=e.displayName,r=e.type;return e.isInner||r!==q.MUTATION&&r!==q.UPDATE||(Ot.context?Ot.context.historyNode.actionChain.push({name:n,displayName:i}):_t.push({name:n,displayName:i})),Nt(t,e)}}},Ft=function(){return function(t){return function(e){var n=e.name,i=e.displayName,r=e.domain;if(!r||!at.middleware.logger)return Nt(t,e);var o=kt.stack.length;return at.middleware.skipNestLog&&1!==o?Nt(t,e):at.middleware.diffLogger?Nt(t,e,(function(){if(r){var t=new Map;Ot.context?t=new Map(Ot.context.historyNode.history):st.currentTimeTravel&&(t=new Map(st.currentTimeTravel.currentHistory));var e=[];t.forEach((function(t,n){t.forEach((function(t,i){e.push({name:n.constructor.name,target:Tt(n)?n.$$turboxProperties:n,property:i,before:t.beforeUpdate,after:t.didUpdate})}))})),e.length&&(console.group("%c[TURBOX LOG]: DIFF ".concat(r.constructor.name," ").concat(n," ").concat(i!==rt?i:""),"background: #FF5F0F; color: #fff; font-weight: bold; padding: 3px 5px;"),console.table(e),console.groupEnd())}})):(console.group("%c[TURBOX LOG]: PREV ".concat(r.constructor.name," ").concat(n," ").concat(i!==rt?i:""),"background: #929493; color: #fff; font-weight: bold; padding: 3px 5px;"),console.dir(j({},r.$$turboxProperties,{clone:!0})),console.groupEnd(),Nt(t,e,(function(){r&&(console.group("%c[TURBOX LOG]: NEXT ".concat(r.constructor.name," ").concat(n," ").concat(i!==rt?i:""),"background: #218D41; color: #fff; font-weight: bold; padding: 3px 5px;"),console.dir(j({},r.$$turboxProperties,{clone:!0})),console.groupEnd())})))}}},Ht=function(){return function(t){return function(e){if(!at.middleware.perf)return Nt(t,e);var n=e.name,i=e.displayName,r=performance.now(),o=kt.stack.length;return at.middleware.skipNestPerfLog&&1!==o?Nt(t,e):Nt(t,e,(function(){var t=performance.now();console.log("%c[TURBOX PERF]: ".concat(n," ").concat(i!==rt?i:""," ").concat((t-r).toFixed(3),"ms"),"background: #FA54FF; color: #fff; font-weight: bold; padding: 3px 5px;")}))}}};var Bt=!1;function jt(){Pt.endBatch(),st.clear()}function Gt(t){if(jt(),I("undefined"!=typeof Proxy&&f(),"Proxy or Symbol is not supported, please add polyfill."),!Bt){It(Ht),It(Vt),It(Ft);var e=[function(t){var e=t(),n=function(){N("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},i={getActionChain:function(){return Ot.context?Ot.context.historyNode.actionChain.slice():_t.slice()},getDependencyGraph:function(){return new Map(St.dependencyGraph)},dispatch:function(){return n.apply(void 0,arguments)}},r=Ut.map((function(t){return t(i)}));return n=G.apply(void 0,s(r))(e.dispatch),zt(zt({},e),{},{dispatch:n})}];Rt(G.apply(void 0,e)),ht.emit(ct.storeOnActive)}if(Bt=!0,t){var n=ft("".concat(Z,"init"),t,{immediately:!0,displayName:""})();if(m(n))return n.then((function(){jt()}),(function(){jt()}));jt()}}function Zt(e,n){if(n&&("object"==t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)}function Xt(t){return Xt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Xt(t)}function $t(t,e){return $t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$t(t,e)}function Yt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&$t(t,e)}Gt();var Wt,qt,Kt="renderer";function Qt(t){var e=t._vNode;if(e)for(var n=e.parent;n;){if(n&&(n.tag===qt.SCENE||n.tag===qt.MESH))return n.instance;n=n.parent}}function Jt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Jt=function(){return!!t})()}!function(t){t[t.READY=1]="READY",t[t.UPDATE=2]="UPDATE",t[t.UPDATE_INTERACTIVE=4]="UPDATE_INTERACTIVE",t[t.UPDATE_CUSTOM_PROPS=8]="UPDATE_CUSTOM_PROPS",t[t.FAKE_UPDATE=16]="FAKE_UPDATE",t[t.REMOVE=32]="REMOVE",t[t.CREATE=64]="CREATE"}(Wt||(Wt={})),function(t){t[t.COMPONENT=1]="COMPONENT",t[t.SCENE=2]="SCENE",t[t.MESH=3]="MESH"}(qt||(qt={}));var te,ee,ne={key:void 0,clickable:void 0,hoverable:void 0,draggable:void 0,pinchable:void 0,rotatable:void 0,pressable:void 0,id:void 0,type:void 0},ie=function(){return v((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l(this,t),this.props=e}),[{key:"context",get:function(){var t=function(t){var e=t._vNode;if(e)for(var n=e.parent;n;){if(n&&n.tag===qt.SCENE)return n.instance;n=n.parent}}(this);return t&&t.sceneContext||{}}},{key:"forceUpdate",value:function(){this._vNode.update(!0)}},{key:"shouldComponentUpdate",value:function(){return!0}},{key:"shouldComponentInteractiveUpdate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return!P({clickable:this.props.clickable,hoverable:this.props.hoverable,draggable:this.props.draggable,pinchable:this.props.pinchable,rotatable:this.props.rotatable,pressable:this.props.pressable},{clickable:t.clickable,hoverable:t.hoverable,draggable:t.draggable,pinchable:t.pinchable,rotatable:t.rotatable,pressable:t.pressable})}},{key:"shouldComponentCustomPropsUpdate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.keys(ne);return!P(this.props,t,e)}},{key:"componentWillMount",value:function(){}},{key:"componentWillUpdate",value:function(){}},{key:"render",value:function(){return this.props.children||null}},{key:"componentDidMount",value:function(){}},{key:"componentDidUpdate",value:function(t){}},{key:"componentWillUnmount",value:function(){}}])}(),re=function(t){function e(){return l(this,e),t=this,i=arguments,n=Xt(n=e),Zt(t,Jt()?Reflect.construct(n,i||[],Xt(t).constructor):n.apply(t,i));var t,n,i}return Yt(e,t),v(e,[{key:"shouldComponentUpdate",value:function(t){var e=new Set(["clickable","hoverable","draggable","pinchable","rotatable","pressable"]),n=Object.keys(ne).filter((function(t){return!e.has(t)}));return!P(this.props,t,n)}}])}(ie);!function(t){t.Unidentified="Unidentified",t.Alt="Alt",t.AltGraph="AltGraph",t.CapsLock="CapsLock",t.Control="Control",t.Ctrl="Ctrl",t.Fn="Fn",t.FnLock="FnLock",t.Hyper="Hyper",t.Meta="Meta",t.NumLock="NumLock",t.ScrollLock="ScrollLock",t.Shift="Shift",t.Super="Super",t.Symbol="Symbol",t.SymbolLock="SymbolLock",t.Enter="Enter",t.Tab="Tab",t.ArrowDown="ArrowDown",t.ArrowLeft="ArrowLeft",t.ArrowRight="ArrowRight",t.ArrowUp="ArrowUp",t.End="End",t.Home="Home",t.PageDown="PageDown",t.PageUp="PageUp",t.Backspace="Backspace",t.Clear="Clear",t.Copy="Copy",t.CrSel="CrSel",t.Cut="Cut",t.Delete="Delete",t.EraseEof="EraseEof",t.ExSel="ExSel",t.Insert="Insert",t.Paste="Paste",t.Redo="Redo",t.Undo="Undo",t.Accept="Accept",t.Again="Again",t.Attn="Attn",t.Cancel="Cancel",t.ContextMenu="ContextMenu",t.Escape="Escape",t.Execute="Execute",t.Find="Find",t.Finish="Finish",t.Help="Help",t.Pause="Pause",t.Play="Play",t.Props="Props",t.Select="Select",t.ZoomIn="ZoomIn",t.ZoomOut="ZoomOut",t.BrightnessDown="BrightnessDown",t.BrightnessUp="BrightnessUp",t.Eject="Eject",t.LogOff="LogOff",t.Power="Power",t.PowerOff="PowerOff",t.PrintScreen="PrintScreen",t.Hibernate="Hibernate",t.Standby="Standby",t.WakeUp="WakeUp",t.AllCandidates="AllCandidates",t.Alphanumeric="Alphanumeric",t.CodeInput="CodeInput",t.Compose="Compose",t.Convert="Convert",t.Dead="Dead",t.FinalMode="FinalMode",t.GroupFirst="GroupFirst",t.GroupLast="GroupLast",t.GroupNext="GroupNext",t.GroupPrevious="GroupPrevious",t.ModeChange="ModeChange",t.NextCandidate="NextCandidate",t.NonConvert="NonConvert",t.PreviousCandidate="PreviousCandidate",t.Process="Process",t.SingleCandidate