@turbox3d/design-engine
Version:
Large-scale design application engine library
2 lines • 170 kB
JavaScript
/*! For license information please see index.min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("THREE"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["THREE","react","react-dom"],t):"object"==typeof exports?exports["@turbox3d/design-engine"]=t(require("THREE"),require("react"),require("react-dom")):e.DesignEngine=t(e.THREE,e.React,e.ReactDOM)}(self,((e,t,n)=>(()=>{var i={12:e=>{"use strict";e.exports=t},33:e=>{"use strict";e.exports=n},498:(e,t,n)=>{var i=n(553).default;function r(){"use strict";e.exports=r=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},o=Object.prototype,a=o.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function h(e,t,n,i){Object.defineProperty(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i})}try{h({},"")}catch(t){h=function(e,t,n){return e[t]=n}}function y(e,n,i,r){var o=n&&n.prototype instanceof v?n:v,a=Object.create(o.prototype);return h(a,"_invoke",function(e,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:t,done:!0}}for(i.method=o,i.arg=a;;){var s=i.delegate;if(s){var u=T(s,i);if(u){if(u===f)continue;return u}}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 c=d(e,n,i);if("normal"===c.type){if(r=i.done?4:2,c.arg===f)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=4,i.method="throw",i.arg=c.arg)}}}(e,i,new C(r||[])),!0),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=y;var f={};function v(){}function p(){}function m(){}var g={};h(g,u,(function(){return this}));var x=Object.getPrototypeOf,k=x&&x(x(D([])));k&&k!==o&&a.call(k,u)&&(g=k);var w=m.prototype=v.prototype=Object.create(g);function M(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(r,o,s,u){var c=d(e[r],e,o);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==i(h)&&a.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(h).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,u)}))}u(c.arg)}var r;h(this,"_invoke",(function(e,i){function o(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(o,o):o()}),!0)}function T(e,n){var i=n.method,r=e.i[i];if(r===t)return n.delegate=null,"throw"===i&&e.i.return&&(n.method="return",n.arg=t,T(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),f;var o=d(r,e.i,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,f;var a=o.arg;return a?a.done?(n[e.r]=a.value,n.next=e.n,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,f):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,f)}function E(e){this.tryEntries.push(e)}function S(e){var n=e[4]||{};n.type="normal",n.arg=t,e[4]=n}function C(e){this.tryEntries=[[-1]],e.forEach(E,this),this.reset(!0)}function D(e){if(null!=e){var n=e[u];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function n(){for(;++r<e.length;)if(a.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(i(e)+" is not iterable")}return p.prototype=m,h(w,"constructor",m),h(m,"constructor",p),h(m,l,p.displayName="GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,h(e,l,"GeneratorFunction")),e.prototype=Object.create(w),e},n.awrap=function(e){return{__await:e}},M(b.prototype),h(b.prototype,c,(function(){return this})),n.AsyncIterator=b,n.async=function(e,t,i,r,o){void 0===o&&(o=Promise);var a=new b(y(e,t,i,r),o);return n.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},M(w),h(w,l,"Generator"),h(w,u,(function(){return this})),h(w,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var i in t)n.unshift(i);return function e(){for(;n.length;)if((i=n.pop())in t)return e.value=i,e.done=!1,e;return e.done=!0,e}},n.values=D,C.prototype={constructor:C,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(S),!e)for(var n in this)"t"===n.charAt(0)&&a.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0][4];if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function i(t){a.type="throw",a.arg=e,n.next=t}for(var r=n.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o[4],s=this.prev,u=o[1],c=o[2];if(-1===o[0])return i("end"),!1;if(!u&&!c)throw Error("try statement without catch or finally");if(null!=o[0]&&o[0]<=s){if(s<u)return this.method="next",this.arg=t,i(u),!0;if(s<c)return i(c),!1}}},abrupt:function(e,t){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"===e||"continue"===e)&&r[0]<=t&&t<=r[2]&&(r=null);var o=r?r[4]:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r[2],f):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n[2]===e)return this.complete(n[4],n[3]),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n[0]===e){var i=n[4];if("throw"===i.type){var r=i.arg;S(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={i:D(e),r:n,n:i},"next"===this.method&&(this.arg=t),f}},n}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},541:(e,t,n)=>{"use strict";var i=n(33);t.H=i.createRoot,i.hydrateRoot},553:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},713:(e,t,n)=>{var i=n(498)();e.exports=i;try{regeneratorRuntime=i}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}},858:t=>{"use strict";t.exports=e}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var n=r[e]={exports:{}};return i[e](n,n.exports,o),n.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var n=function(t){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(n)?n:n+""}function n(e,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(e,t(r.key),r)}}function i(e,t,i){return t&&n(e.prototype,t),i&&n(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(t,n){if(n&&("object"==e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function y(e,t){if(e){if("string"==typeof e)return h(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(e,t):void 0}}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){c=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}return s}}(e,t)||y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,n,i){return(n=t(n))in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i,e}function v(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(e)||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.")}()}o.r(a),o.d(a,{AssemblyEntityObject:()=>Et,CollisionEngine:()=>St,DocumentSystem:()=>At,EntityObject:()=>bt,EnvSystem:()=>Ft,FreeDrawCommand:()=>It,HintCommand:()=>Sn,InferenceEngine:()=>Cn,LoadSystem:()=>Dn,MaterialBrushCommand:()=>An,MaterialDragSystem:()=>Rn,MeasureCommand:()=>On,MountSystem:()=>Jn,PlacementEngine:()=>ei,RectSelectionCommand:()=>ti,SelectionCommand:()=>wn,SpaceEngine:()=>ni,UnitSystem:()=>ii});var p="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),m=new Array(36);function g(){for(var e=0,t=0;t<36;t++)if(8===t||13===t||18===t||23===t)m[t]="-";else if(14===t)m[t]="7";else{e<=2&&(e=33554432+16777216*Math.random()|0);var n=15&e;e>>=4,m[t]=p[19===t?3&n|8:n]}return m.join("")}function x(){return"undefined"!=typeof Symbol}var k=/^\[object (?:Object|Array|Map|Set|WeakMap|WeakSet)\]$/;function w(t){return null!==t&&"object"===e(t)}function M(e){return e&&"function"==typeof e.then}function b(t){if(null===t||"object"!==e(t))return!1;var n=Object.getPrototypeOf(t);return n===Object.prototype||null===n}function T(e,t){return e.indexOf(t)>-1}function E(e,t){var n=e.indexOf(t);n>-1&&e.splice(n,1)}function S(e,t){t.forEach((function(t){var n=e.indexOf(t);n>-1&&e.splice(n,1)}))}function C(e,t){t.forEach((function(t){e.delete(t)}))}var D,P,_=Promise.resolve();function A(e){return e?_.then(e):_}function z(e,t){return function(n){var i=arguments.length;return i?i>1?e.apply(t,arguments):e.call(t,n):e.call(t)}}function R(){return"undefined"!=typeof window?"browser":"vm"}(P=D||(D={}))[P.UserAction=0]="UserAction",P[P.UpdateState=1]="UpdateState",P[P.RenderReact=2]="RenderReact",P[P.RenderScene=-1]="RenderScene";var O=o(713),L=o.n(O);function F(e,t){if(!e)throw new Error("[turbox]: ".concat(t||"An invariant failed, however the error is obfuscated because this is an production build."))}function B(e){throw F(!1,e),"X"}function N(e){console.warn("[turbox]: ".concat(e))}function I(t){return t&&"object"===e(t)&&"[object RegExp]"!==Object.prototype.toString.call(t)&&"[object Date]"!==Object.prototype.toString.call(t)}function U(e,t){var n;return t&&!0===t.clone&&I(e)?V((n=e,Array.isArray(n)?[]:{}),e,t):e}function H(e,t,n){var i=e.slice();return t.forEach((function(t,r){void 0===i[r]?i[r]=U(t,n):I(t)?i[r]=V(e[r],t,n):-1===e.indexOf(t)&&i.push(U(t,n))})),i}function V(e,t,n){var i=Array.isArray(t),r=(n||{arrayMerge:H}).arrayMerge||H;return i?Array.isArray(e)?r(e,t,n):U(t,n):function(e,t,n){var i={};return I(e)&&Object.keys(e).forEach((function(t){i[t]=U(e[t],n)})),Object.keys(t).forEach((function(r){I(t[r])&&e[r]?i[r]=V(e[r],t[r],n):i[r]=U(t[r],n)})),i}(e,t,n)}function j(e){return(2===e.length||3===e.length)&&"string"==typeof e[1]}o(858),new(function(){return i((function e(){r(this,e),this.listeners={}}),[{key:"on",value:function(e,t){var n=this.listeners[e]||[];n.push(t),this.listeners[e]=n}},{key:"emit",value:function(e){for(var t=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[e];Array.isArray(o)&&o.forEach((function(e){try{e.apply(t,i)}catch(e){console.error(e)}}))}},{key:"off",value:function(e){this.listeners[e]&&(this.listeners[e]=[])}}])}());function G(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}Date.now;var X="@@TURBOX__";function q(e){return x()?Symbol(e):"".concat(X).concat(e)}var Z,Y,W,K,$,Q,J=q("namespace"),ee=q("reactive-component-name"),te=q("unsubscribe-handler"),ne="".concat(X,"materialType"),ie="".concat(X,"empty"),re="".concat(X,"field"),oe=!1,ae={middleware:{logger:oe,diffLogger:!0,effect:!1,perf:oe,skipNestLog:!0,skipNestPerfLog:!0},timeTravel:{isActive:!1,isNeedRecord:!1,maxStepNumber:20,keepActionChain:oe},disableReactive:!1,strictMode:oe,devTool:!1,batchUpdateOnFinish:void 0};!function(e){e.NOT_OBSERVED="notObserved",e.OBSERVED="observed",e.LATEST="latest"}(Z||(Z={})),function(e){e.ARRAY_LENGTH="length",e.ITERATE="iterate",e.COMPUTED="computed"}(Y||(Y={})),function(e){e.SET="set",e.MAP_SET="map-set",e.ADD="add",e.SET_ADD="set-add",e.DELETE="delete",e.MAP_DELETE="map-delete",e.SET_DELETE="set-delete"}(W||(W={})),(Q=K||(K={})).DEFAULT="default",Q.MUTATION="mutation",Q.ACTION="action",Q.UPDATE="update",Q.EFFECT="effect",Q.UNDO="undo",Q.REDO="redo",function(e){e.WORKING="working",e.COMPLETED="completed",e.ABORT="abort"}($||($={}));var se=function(){function e(){r(this,e),this.currentHistory=new Map,this.transactionHistories=[],this.cursor=-1}return i(e,[{key:"undoable",get:function(){return this.cursor>=0}},{key:"redoable",get:function(){return this.cursor<this.transactionHistories.length-1}},{key:"onChange",value:function(e,t,n,i){}},{key:"undo",value:function(){var t=this;if(this.undoable){var n=this.transactionHistories[this.cursor];Me||B("store is not ready, please init first.");var i=n.actionChain[0]||{name:"",displayName:""};Me.dispatch({name:"".concat(X,"UNDO_").concat(i.name),displayName:"UNDO_".concat(i.displayName),payload:[],original:function(){e.undoHandler(n.history)},type:K.UNDO,isInner:!0}),this.cursor-=1,A((function(){t.onChange(t.undoable,t.redoable,"undo")}))}}},{key:"redo",value:function(){var t=this;if(this.redoable){this.cursor+=1;var n=this.transactionHistories[this.cursor];Me||B("store is not ready, please init first.");var i=n.actionChain[0]||{name:"",displayName:""};Me.dispatch({name:"".concat(X,"REDO_").concat(i.name),displayName:"REDO_".concat(i.displayName),payload:[],original:function(){e.redoHandler(n.history)},type:K.REDO,isInner:!0}),A((function(){t.onChange(t.undoable,t.redoable,"redo")}))}}},{key:"clear",value:function(){var e=this;this.currentHistory=new Map,this.transactionHistories.length=0,this.cursor=-1,A((function(){e.onChange(e.undoable,e.redoable,"clear")}))}}],[{key:"undoable",get:function(){return e.currentTimeTravel&&e.currentTimeTravel.undoable}},{key:"redoable",get:function(){return e.currentTimeTravel&&e.currentTimeTravel.redoable}},{key:"undoHandler",value:function(e){e.forEach((function(e,t){e&&e.forEach((function(e,n){e&&e.beforeUpdate!==e.didUpdate&&(e.type===W.MAP_SET||e.type===W.MAP_DELETE?void 0===e.beforeUpdate?t.delete(n):t.set(n,e.beforeUpdate):e.type===W.SET_ADD?t.delete(n):e.type===W.SET_DELETE?t.add(n):Array.isArray(t)&&void 0===e.beforeUpdate?delete t[n]:t[n]=e.beforeUpdate)}))}))}},{key:"redoHandler",value:function(e){e.forEach((function(e,t){e&&e.forEach((function(e,n){e&&e.beforeUpdate!==e.didUpdate&&(e.type===W.MAP_SET?t.set(n,e.didUpdate):e.type===W.SET_ADD?t.add(n):e.type===W.SET_DELETE||e.type===W.MAP_DELETE?t.delete(n):t[n]=e.didUpdate)}))}))}}])}();se.timeTravels={},se.processing=!1,se.switch=function(e){se.currentTimeTravel=se.get(e)},se.create=function(e){var t=new se;return se.timeTravels[e]=t,t},se.get=function(e){return se.timeTravels[e]},se.pause=function(){ae.timeTravel.isActive=!1},se.resume=function(){ae.timeTravel.isActive=!0},se.undo=function(){se.currentTimeTravel&&se.currentTimeTravel.undo()},se.redo=function(){se.currentTimeTravel&&se.currentTimeTravel.redo()},se.clear=function(){se.currentTimeTravel&&se.currentTimeTravel.clear()};var ue,ce={freeze:!1};function le(){for(var e={deepProxy:!0,displayName:""},t=function(t,n,i){var r={enumerable:!0,configurable:!0,get:function(){var t=this;e.callback&&!ce.freeze&&(ce.freeze=!0,e.callback&&e.callback.call(t,t,n),ce.freeze=!1);var r=i&&i.initializer&&i.initializer();return t.propertyGet(n,e,!(!i||!i.initializer),r)},set:function(t){this.propertySet(n,t,e)}};return void 0===i?Object.defineProperty(t,n,r):r},n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];if(b(i[0])||Array.isArray(i[0])||i[0]&&i[0].constructor&&T(Se,i[0].constructor)){var o=i[1];o&&(void 0!==o.displayName&&(e.displayName=o.displayName),void 0!==o.isNeedRecord&&(e.isNeedRecord=o.isNeedRecord),void 0!==o.callback&&(e.callback=o.callback));var a=new Ce,s=e.displayName||re,u=t(a,s);return u[s]=i[0],u[s]}return j(i)?t.apply(null,i):(e.deepProxy=void 0===i[0]||i[0],void 0!==i[1]&&(e.isNeedRecord=i[1]),e.callback=i[2],t)}!function(e){e.storeOnActive="storeOnActive",e.beforeStoreChange="beforeStoreChange",e.afterStoreChange="afterStoreChange",e.asyncAfterStoreChange="asyncAfterStoreChange",e.setProperty="setProperty",e.materialCallStackChange="materialCallStackChange"}(ue||(ue={}));var he=new(function(){return i((function e(){r(this,e),this.listeners={}}),[{key:"on",value:function(e,t){var n=this.listeners[e]||[];n.push(t),this.listeners[e]=n}},{key:"emit",value:function(e,t){var n=this;ae.devTool&&window&&window.__TURBOX_DEVTOOL_GLOBAL_HOOKS__&&window.__TURBOX_DEVTOOL_GLOBAL_HOOKS__.emit(e,t);var i=this.listeners[e];Array.isArray(i)&&i.forEach((function(e){try{e.apply(n,[t])}catch(e){B(e)}}))}},{key:"off",value:function(e){this.listeners[e]&&(this.listeners[e]=[])}}])}()),ye=function(){return i((function e(t,n,i,o,a,s){r(this,e),this.name=t,this.runner=n,this.computed=i,this.lazy=o,this.deps=a,this.immediately=s}),[{key:"dispose",value:function(){void 0!==this.unsubscribeHandler&&this.unsubscribeHandler(),De.clear(this)}}])}();function de(e,t){var n=t&&t.name||e.name||"".concat(X,"REACTIVE_").concat(g()),i=!(!t||void 0===t.lazy)&&t.lazy,r=t&&t.deps||[],o=!t||void 0===t.immediately||t.immediately,a=!0,s=new ye(n,(function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{if(De.start(s),s.deps.length>0){var n=[];s.deps.forEach((function(e){var t=e();n.push(t)})),De.end(),!a&&e.call.apply(e,[null].concat(n))}else e.call(null),De.end();a&&(a=!1)}catch(e){if(De.end(),a&&(a=!1),!t)throw e}}),!(!t||!t.computed),i,r,o),u=function(){s.unsubscribeHandler=Me.subscribe((function(e){s.runner(e)}),s),s.runner()};return Me?u():he.on(ue.storeOnActive,(function(){u()})),s}function fe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];if("function"==typeof t[0]){var i,r,o=!0,a=!1,s=!1,u=t[0],c=t[1],l=de((function(){o=!0,a&&(i=u()),s&&Pe.trigger(r,Y.COMPUTED,{type:W.SET,beforeUpdate:void 0,didUpdate:void 0})}),{name:"computed",computed:!0,lazy:!(!c||void 0===c.lazy)&&c.lazy});return r={get:function(){return o&&(a=!0,s=!1,l.runner(),o=!1,a=!1,s=!0),De.collect(r,Y.COMPUTED),i},dispose:function(){l.dispose()}}}var h,y,d=function(e,t,n){return h={enumerable:!0,configurable:!0,get:function(){return this.computedPropertyGet(t,y)},set:function(e){this.computedPropertySet(t,e)}},void 0===n?Object.defineProperty(e,t,h):h={enumerable:!0,configurable:!0,get:function(){return this.computedPropertyGet(t,y,n)},set:n.set}};return j(t)?d.apply(null,t):(y=t[0],d)}function ve(t,n,i,r){var o,a="symbol"!==e(o=n)?o.toString():o.toString()+g(),s=function(){var e=this;t||(e=new Ce),Me||B("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 u=Me.dispatch({name:a,displayName:r.displayName||ie,payload:o,type:K.MUTATION,domain:e,original:z(i,e),immediately:!!r.immediately,forceSaveHistory:!!r.forceSaveHistory,isNeedRecord:!!r.isNeedRecord});if(M(u))return new Promise((function(e,t){u.then((function(t){e(t)}),(function(e){t(e)}))}));if(u&&u instanceof Error)throw u;return u};return s[ne]=K.MUTATION,s}function pe(){for(var e={immediately:!1,displayName:"",forceSaveHistory:!1,isNeedRecord:!0},t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];if("string"==typeof n[0]&&"function"==typeof n[1]){void 0!==n[2]&&(e.displayName=n[2].displayName,e.immediately=n[2].immediately,e.forceSaveHistory=!!n[2].forceSaveHistory,e.isNeedRecord=!!n[2].isNeedRecord);var r=n[0],o=n[1];return o[ne]===K.MUTATION?o:ve(void 0,r,o,e)}var a=function(t,n,i){var r;if(void 0===i)return Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:function(){return r},set:function(i){r=i[ne]===K.MUTATION?i:ve(t,n,i,e)}});if(void 0!==i.value){var o=i.value;return o[ne]===K.MUTATION?i.value=o:i.value=ve(t,n,o,e),i}var a=i.initializer;return i.initializer=function(){F(!!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[ne]===K.MUTATION?i:ve(t,n,i,e)},i};return j(n)?a.apply(null,n):(e.displayName=n[0]||"",e.immediately=void 0!==n[1]&&n[1],e.forceSaveHistory=void 0!==n[2]&&n[2],e.isNeedRecord=void 0===n[3]||n[3],a)}function me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function ge(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?me(Object(n),!0).forEach((function(t){f(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):me(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var xe,ke=new(function(){return i((function e(){r(this,e),this.stack=[],this.pendingToPopStack=[],this.stackId=0}),[{key:"push",value:function(e){this.stackId+=1;var t=ge(ge({},e),{},{stackId:this.stackId});return this.currentStack=t,this.stack.push(t),ae.devTool&&he.emit(ue.materialCallStackChange,{stack:v(this.stack),action:"PUSH",time:Date.now(),currentStack:t}),this.stackId}},{key:"pop",value:function(e){var t;if(0!==this.stack.length){if(this.stack[this.stack.length-1].stackId!==e)this.pendingToPopStack.unshift(e);else{this.currentStack=void 0;var n=this.stack.pop();ae.devTool&&he.emit(ue.materialCallStackChange,{stack:v(this.stack),action:"POP",time:Date.now(),currentStack:n})}for(var i=v(this.pendingToPopStack),r=0;r<this.pendingToPopStack.length;r+=1){var o=this.pendingToPopStack[r];if((null===(t=this.stack[this.stack.length-1])||void 0===t?void 0:t.stackId)!==o)break;var a=this.stack.pop();i.splice(r,1),this.currentStack=this.stack[this.stack.length-1],ae.devTool&&he.emit(ue.materialCallStackChange,{stack:v(this.stack),action:"POP",time:Date.now(),currentStack:a})}this.pendingToPopStack=i,0===this.pendingToPopStack.length&&(this.currentStack=void 0)}}}])}());function we(e){return e instanceof Ce}!function(e){e.property="property",e.index="index"}(xe||(xe={}));var Me,be=new WeakMap,Te=new WeakMap,Ee=new WeakMap,Se=[Map,Set,WeakMap,WeakSet],Ce=function(){return i((function e(){var t=this;r(this,e),this.$$turboxProperties={},this.reactorConfigMap={},this.computedProperties={},this.getCollectionHandlerMap=function(e,n){return f(f(f(f(f({get size(){var t=Reflect.getPrototypeOf(e);return De.collect(e,Y.ITERATE),Reflect.get(t,n,e)},get:function(t){var n=Reflect.getPrototypeOf(e).get;return De.collect(e,t),n.call(e,t)},has:function(t){var n=Reflect.getPrototypeOf(e).has;return De.collect(e,t),n.call(e,t)},forEach:function(t){var n=Reflect.getPrototypeOf(e).forEach;return De.collect(e,Y.ITERATE),n.call(e,t)},values:function(){var t=Reflect.getPrototypeOf(e).values;return De.collect(e,Y.ITERATE),t.call(e)},keys:function(){var t=Reflect.getPrototypeOf(e).keys;return De.collect(e,Y.ITERATE),t.call(e)},entries:function(){var t=Reflect.getPrototypeOf(e).entries;return De.collect(e,Y.ITERATE),t.call(e)}},Symbol.iterator,(function(){return e.constructor===Set?t.getCollectionHandlerMap(e,"values").values():e.constructor===Map?t.getCollectionHandlerMap(e,"entries").entries():void 0})),"add",(function(n){var i=Reflect.getPrototypeOf(e),r=i.add,o=i.has,a=Ee.get(e),s=a[0].value;return o.call(e,n)||(Pe.trigger(e,n,{type:W.SET_ADD,beforeUpdate:void 0,didUpdate:n},t.reactorConfigMap[s].isNeedRecord,{keyPath:a,domain:t.constructor.name}),Pe.trigger(e,Y.ITERATE,{type:W.SET_ADD},t.reactorConfigMap[s].isNeedRecord)),r.call(e,n)})),"set",(function(n,i){var r=Reflect.getPrototypeOf(e),o=r.set,a=r.get,s=r.has,u=Ee.get(e),c=u[0].value,l=s.call(e,n),h=a.call(e,n);return i!==h&&Pe.trigger(e,n,{type:W.MAP_SET,beforeUpdate:h,didUpdate:i},t.reactorConfigMap[c].isNeedRecord,{keyPath:u,domain:t.constructor.name}),l||Pe.trigger(e,Y.ITERATE,{type:W.MAP_SET},t.reactorConfigMap[c].isNeedRecord),o.call(e,n,i)})),"delete",(function(n){var i=Reflect.getPrototypeOf(e),r=Ee.get(e),o=r[0].value;if(!i.has.call(e,n))return i.delete.call(e,n);if(i.constructor===Map||i.constructor===WeakMap){var a=i.get.call(e,n);Pe.trigger(e,n,{type:W.MAP_DELETE,beforeUpdate:a},t.reactorConfigMap[o].isNeedRecord,{keyPath:r,domain:t.constructor.name}),Pe.trigger(e,Y.ITERATE,{type:W.MAP_DELETE},t.reactorConfigMap[o].isNeedRecord)}return i.constructor!==Set&&i.constructor!==WeakSet||(Pe.trigger(e,n,{type:W.SET_DELETE,beforeUpdate:n},t.reactorConfigMap[o].isNeedRecord,{keyPath:r,domain:t.constructor.name}),Pe.trigger(e,Y.ITERATE,{type:W.SET_DELETE},t.reactorConfigMap[o].isNeedRecord)),i.delete.call(e,n)})),"clear",(function(){var n=Reflect.getPrototypeOf(e),i=n.clear;return n.forEach.call(e,(function(n,i){t.getCollectionHandlerMap(e,i).delete(i)})),i.call(e)}))};var n=Object.getPrototypeOf(this).constructor.name||"TURBOX_DOMAIN",i="".concat(n,"_").concat(g());this[J]=i,this.context=this.initDomainContext()}),[{key:"initDomainContext",value:function(){return{isNeedRecord:ae.timeTravel.isNeedRecord}}},{key:"propertyGet",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,r=e in this.$$turboxProperties,o=n&&!r,a=o?i:this.$$turboxProperties[e];o&&this.propertySet(e,a,t);var s=Object.assign({},{isNeedRecord:this.context.isNeedRecord},t);return this.reactorConfigMap[e]=s,De.collect(this,e),w(a)&&!we(a)&&s.deepProxy?this.proxyReactive(a,[{type:xe.property,value:e}]):a}},{key:"propertySet",value:function(e,t,n){ae.strictMode&&this.illegalAssignmentCheck(this,e);var i=this.$$turboxProperties[e],r=Object.assign({},{isNeedRecord:this.context.isNeedRecord},n);this.reactorConfigMap[e]=r,i!==t&&(this.$$turboxProperties[e]=t,Pe.trigger(this,e,{type:W.SET,beforeUpdate:i,didUpdate:t},r.isNeedRecord,{keyPath:[{type:xe.property,value:e}],domain:this.constructor.name}))}},{key:"computedPropertyGet",value:function(e,t,n){var i=this;this.computedProperties[e]||(this.computedProperties[e]={dirty:!0,needReComputed:!1,needTrigger:!1});var r=this.computedProperties[e],o=!(!t||void 0===t.lazy)&&t.lazy;if(r.reaction||(r.reaction=de((function(){r.dirty=!0,r.needReComputed&&(r.value=r.computeRunner()),r.needTrigger&&Pe.trigger(i,e,{type:W.SET,beforeUpdate:void 0,didUpdate:void 0},!1)}),{name:e,computed:!0,lazy:o})),!r.computeRunner&&n&&(r.computeRunner=z(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 De.collect(this,e),r.value}},{key:"computedPropertySet",value:function(e,t){this.computedProperties[e]||(this.computedProperties[e]={dirty:!0,needReComputed:!1,needTrigger:!1}),this.computedProperties[e].computeRunner||(this.computedProperties[e].computeRunner=z(t,this))}},{key:"$update",value:function(e,t,n,i,r,o){F(b(e),"resetState(...) param type error. Param should be a plain object."),this.dispatch(e,t,n,i,r,o)}},{key:"proxySet",value:function(e,t,n,i){Array.isArray(e)&&e!==this.currentTarget&&(this.currentTarget=e,this.originalArrayLength=e[Y.ARRAY_LENGTH]),ae.strictMode&&this.illegalAssignmentCheck(e,t);var r=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t),o=e[t],a=Ee.get(e)[0].value;return e===be.get(i)&&(t!==Y.ARRAY_LENGTH&&n===o||(Pe.trigger(e,t,{type:W.SET,beforeUpdate:t===Y.ARRAY_LENGTH?this.originalArrayLength:o,didUpdate:n},this.reactorConfigMap[a].isNeedRecord,{keyPath:[{type:xe.property,value:t}],domain:this.constructor.name}),t===Y.ARRAY_LENGTH&&(this.currentTarget=void 0,this.originalArrayLength=void 0)),r||Pe.trigger(e,t,{type:W.ADD,beforeUpdate:o,didUpdate:n},this.reactorConfigMap[a].isNeedRecord,{keyPath:[{type:xe.property,value:t}],domain:this.constructor.name}),Reflect.set(e,t,n,i))}},{key:"proxyGet",value:function(e,t,n){var i=this,r=Reflect.get(e,t,n),o=Ee.get(e),a=o[0].value;return De.collect(e,t),this.reactorConfigMap[a].callback&&!ce.freeze&&(ce.freeze=!0,i.reactorConfigMap[a].callback&&i.reactorConfigMap[a].callback.call(i,e,t),ce.freeze=!1),w(r)&&!we(r)?this.proxyReactive(r,[].concat(v(o),[{type:Array.isArray(e)?xe.index:xe.property,value:t}])):r}},{key:"proxyDeleteProperty",value:function(e,t){var n=Ee.get(e)[0].value,i=e[t];return Pe.trigger(e,t,{type:W.DELETE,beforeUpdate:i,didUpdate:void 0},this.reactorConfigMap[n].isNeedRecord,{keyPath:[{type:xe.property,value:t}],domain:this.constructor.name}),Reflect.deleteProperty(e,t)}},{key:"proxyOwnKeys",value:function(e){return De.collect(e,Y.ITERATE),Reflect.ownKeys(e)}},{key:"proxyReactive",value:function(e,t){var n=this;Ee.set(e,t);var i,r=Te.get(e);if(void 0!==r)return r;if(be.has(e))return e;if(i=e,!k.test(function(e){return Object.prototype.toString.call(e)}(i)))return e;var o=T(Se,e.constructor)?{get:z(n.collectionProxyHandler,n)}:{get:z(n.proxyGet,n),set:z(n.proxySet,n),ownKeys:z(n.proxyOwnKeys,n),deleteProperty:z(n.proxyDeleteProperty,n)},a=new Proxy(e,o);return be.set(a,e),Te.set(e,a),a}},{key:"collectionProxyHandler",value:function(e,t){var n=this.getCollectionHandlerMap(e,t),i=t in e&&n[t]?n:e;return Reflect.get(i,t)}},{key:"illegalAssignmentCheck",value:function(e,t){if(De.isObserved(e,t)){var n=ke.stack.length,i=ke.stack[n-1]||K.DEFAULT;F(i.type===K.MUTATION||i.type===K.UPDATE||i.type===K.UNDO||i.type===K.REDO,"You cannot update value to observed '@reactor property' directly. Please use mutation or $update({}).")}}},{key:"dispatch",value:function(e,t,n,i,r,o){var a=function(){for(var t=Object.keys(e),n=0,i=t.length;n<i;n++){var r=t[n];this[r]=e[r]}};if(void 0===Me)return a.call(this),void ke.pop(-1);Me.dispatch({name:t||"".concat(X,"UPDATE"),displayName:n||ie,payload:[],type:K.UPDATE,domain:this,original:z(a,this),forceSaveHistory:i,isNeedRecord:r,immediately:o})}}])}(),De=new(function(){return i((function e(){r(this,e),this.dependencyGraph=new Map,this.reactionIdDeps=new Map,this.reactionIdStack=[]}),[{key:"start",value:function(e){this.reactionIdStack.push(e)}},{key:"collect",value:function(e,t){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}[t]){var n=this.reactionIdStack.length;if(0!==n){var i=this.reactionIdStack[n-1],r=this.dependencyGraph.get(e);if(void 0!==r){var o=r.get(t);void 0!==o?o.add(i):r.set(t,new Set([i]))}else{var a=new Map([[t,new Set([i])]]);this.dependencyGraph.set(e,a)}var s=this.reactionIdDeps.get(i);if(void 0!==s){var u=s.get(e);void 0!==u?u.set(t,Z.LATEST):s.set(e,new Map([[t,Z.LATEST]]))}else this.reactionIdDeps.set(i,new Map([[e,new Map([[t,Z.LATEST]])]]))}}}},{key:"end",value:function(){var e=this,t=this.reactionIdStack.pop();if(t){var n=this.reactionIdDeps.get(t);n&&n.forEach((function(n,i){n.forEach((function(r,o){if(r===Z.OBSERVED){var a=e.dependencyGraph.get(i);if(a){var s=a.get(o);s&&s.delete(t),n.set(o,Z.NOT_OBSERVED)}}r===Z.LATEST&&n.set(o,Z.OBSERVED)}))}))}}},{key:"clear",value:function(e){var t=this,n=this.reactionIdDeps.get(e);n&&(n.forEach((function(n,i){n.forEach((function(n,r){var o=t.dependencyGraph.get(i);if(o){var a=o.get(r);a&&a.delete(e)}}))})),this.reactionIdDeps.delete(e))}},{key:"isObserved",value:function(e,t){var n=this.dependencyGraph.get(e);return void 0!==n&&n.has(t)&&(n.get(t)||new Set).size>0}}])}()),Pe=new(function(){return i((function e(){r(this,e),this.waitTriggerIds=new Set}),[{key:"trigger",value:function(e,t,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,u=n.beforeUpdate,c=n.didUpdate;if(ae.devTool&&a)try{var l=null!==(i=window&&window.__TURBOX_DEVTOOL_GOLBAL_STRINGIFY__)&&void 0!==i?i:JSON.stringify,h={time:Date.now(),stackId:null===(r=ke.currentStack)||void 0===r?void 0:r.stackId,domain:a.domain,keyPath:a.keyPath,newValue:l(c),oldValue:l(u),type:s};he.emit(ue.setProperty,h),console.log(h)}catch(e){B(e)}var y=s===W.ADD?Y.ITERATE:t;this.collectComponentId(e,y),ae.timeTravel.isActive&&se.currentTimeTravel&&o&&!se.processing&&y!==Y.ITERATE&&y!==Y.COMPUTED&&(Oe.context?this.recordDiff(e,y,n,Oe.context.historyNode.history):this.recordDiff(e,y,n,se.currentTimeTravel.currentHistory))}},{key:"endBatch",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1?arguments[1]:void 0;if(t||this.waitTriggerIds.clear(),ae.timeTravel.isActive&&se.currentTimeTravel&&e){if(t)return t.historyNode.actionChain.length=0,t.historyNode.history.clear(),void A((function(){var e=se.currentTimeTravel;e&&e.onChange(e.undoable,e.redoable,"clear",t)}));_e.length=0,se.currentTimeTravel.currentHistory.clear()}}},{key:"save",value:function(e){if(ae.timeTravel.isActive&&se.currentTimeTravel&&!Oe.context){var t=se.currentTimeTravel;e?this.saveHistory(t,e.historyNode.actionChain,e.historyNode.history,e):this.saveHistory(t,_e,t.currentHistory)}}},{key:"collectComponentId",value:function(e,t){var n=this,i=De.dependencyGraph.get(e);if(void 0!==i){var r=i.get(t);void 0!==r&&r.size>0&&r.forEach((function(e){return n.waitTriggerIds.add(e)}))}}},{key:"recordDiff",value:function(e,t,n,i){var r,o=n.type,a=n.beforeUpdate,s=n.didUpdate;if(r=we(e)?e:Te.get(e)){var u=i.get(r);if(void 0!==u){var c=u.get(t);void 0!==c?c.didUpdate=s:u.set(t,{type:o,beforeUpdate:a,didUpdate:s})}else i.set(r,new Map([[t,{type:o,beforeUpdate:a,didUpdate:s}]]))}}},{key:"saveHistory",value:function(e,t,n,i){if(n&&0!==n.size){var r=ae.timeTravel.keepActionChain?t.slice():[],o=new Map(n);e.cursor===e.transactionHistories.length-1?(e.transactionHistories.push({actionChain:r,history:o}),e.cursor+=1):e.cursor<e.transactionHistories.length-1&&(e.transactionHistories=e.transactionHistories.slice(0,e.cursor+1),e.transactionHistories.push({actionChain:r,history:o}),e.cursor+=1),e.transactionHistories.length>ae.timeTravel.maxStepNumber&&(e.transactionHistories.shift(),e.cursor-=1),A((function(){e.onChange(e.undoable,e.redoable,"save",i)}))}}}])}()),_e=[],Ae=[];function ze(e){if(void 0!==e)return Me=e(ze);var t,n=new WeakMap,i=0,r=!1,o=function(e,t,i){if(e.length&&!ae.disableReactive){for(var r=[],o=0;o<e.length;o++){var a=e[o],s=n.get(a);s&&r.push(s)}var u=function(e){return function(){for(var t=0;t<r.length;t++){var n=r[t];if(n.idCustomType===e)for(var o=n.listeners,a=0;a<o.length;a++)(0,o[a])(i)}}};t?Ae.forEach((function(e){(0,e.handler)(u(e.idCustomType),(function(){ae.batchUpdateOnFinish&&ae.batchUpdateOnFinish()}))})):u()()}},a=function(e){var t=v(Pe.waitTriggerIds.values()).filter((function(e){return e instanceof ye&&!e.lazy&&e.computed}));t.length&&(ae.devTool&&console.log("keepAlive computed",t),o(t,!1,e),C(Pe.waitTriggerIds,t))},s=function(e){var t=v(Pe.waitTriggerIds.values()).filter((function(e){return e instanceof ye&&!e.computed&&e.immediately}));t.length&&(C(Pe.waitTriggerIds,t),ae.devTool&&console.log("immediately reactive",t),o(t,!1,e))},u=[],c=function(){if(!r){r=!0;var e=function(){A((function(){if(i>0)return r=!1,void u.shift();0!==u.length&&t&&t()}))};u.push(e),e()}},l=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];r=!1,t=void 0,u.shift(),_e.length=0,e&&Pe.endBatch()};return{dispatch:function(e){var n,r,u,h,y=e.payload,d=e.type,f=e.original,p=e.immediately,m=e.isInner,g=void 0!==m&&m,x=e.domain,k=e.name,w=e.forceSaveHistory,b=void 0!==w&&w,T=e.isNeedRecord,E=void 0===T||T;g&&(se.processing=!0);var S=ke.push({type:d,method:k,domain:null==x?void 0:x.constructor.name});if(g||d===K.MUTATION||d===K.UPDATE){var C;if(i+=1,(g||p&&Pe.waitTriggerIds.size>0)&&t&&t(),void 0===t&&(t=function(){var e=v(Pe.waitTriggerIds.values());if(e.length||b){!g&&E&&Pe.save();var t=e.filter((function(e){return e instanceof ye&&e.lazy&&e.computed}));ae.devTool&&console.log("lazy computed",t),o(t,!1,g);var n=v(Pe.waitTriggerIds.values()).filter((function(e){return e instanceof ye&&!e.computed&&!e.immediately})),i=v(Pe.waitTriggerIds.values()).filter((function(e){return!(e instanceof ye)}));l(),ae.devTool&&console.log("lazy reactive",n),o(n,!1,g),ae.devTool&&console.log("custom view Reactive",i),o(i,!0,g)}else l(!1)}),ae.devTool){var D={domain:null!==(n=null==x?void 0:x.constructor.name)&&void 0!==n?n:"UNKNOWN",method:k,args:y,state:null==x?void 0:x.$$turboxProperties,time:Date.now(),stackId:null===(r=ke.currentStack)||void 0===r?void 0:r.stackId};he.emit(ue.beforeStoreChange,D)}try{C=f.apply(void 0,v(y))}catch(e){return e}if(ae.devTool){var P={domain:null!==(u=null==x?void 0:x.constructor.name)&&void 0!==u?u:"UNKNOWN",method:k,args:y,state:null==x?void 0:x.$$turboxProperties,async:!1,time:Date.now(),stackId:null===(h=ke.currentStack)||void 0===h?void 0:h.stackId};he.emit(ue.afterStoreChange,P)}return M(C)?(ke.pop(S),new Promise((function(e,n){var r;Promise.resolve().then((function(){r=ke.push({type:d,method:k,domain:null==x?void 0:x.constructor.name,syncStackId:S})})),C.then((function(n){var o,u;ae.devTool&&he.emit(ue.asyncAfterStoreChange,{domain:null!==(o=null==x?void 0:x.constructor.name)&&void 0!==o?o:"UNKNOWN",method:k,args:y,state:null==x?void 0:x.$$turboxProperties,async:!0,time:Date.now(),stackId:null===(u=ke.currentStack)||void 0===u?void 0:u.stackId}),a(g),s(g),i-=1,p?t&&t():c(),ke.pop(r),e(n)})).catch((function(e){n(e)}))}))):(a(g),s(g),i-=1,g||p?(t&&t(),se.processing=!1):c(),ke.pop(S),C)}},subscribe:function(e,t,i){var r=!0,o=n.get(t);return void 0===o||void 0===o.listeners?n.set(t,{idCustomType:i,listeners:[e]}):T(o.listeners,e)||n.set(t,{idCustomType:i,listeners:o.listeners.concat(e)}),function(){r&&(r=!1,n.has(t)&&n.delete(t))}}}}var Re=[],Oe=function(){function e(){r(this,e),this.displayName=ie,this.status=$.WORKING,this.historyNode={actionChain:[],history:new Map}}return i(e,[{key:"execute",value:function(t){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!==$.ABORT){e.context=this;var o=(i?pe(this.name,t,r):t).apply(void 0,v(n));if(M(o))return o.then((function(){e.context=void 0}),(function(){e.context=void 0}));e.context=void 0}}},{key:"complete",value:function(){this.status!==$.ABORT&&(this.status=$.COMPLETED,Pe.save(this),Pe.endBatch(!0,this),E(Re,this))}},{key:"undo",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Me||B("store is not ready, please init first.");var n=this.historyNode.actionChain[0]||{name:"",displayName:""};Me.dispatch({name:"".concat(X,"UNDO_").concat(n.name),displayName:"UNDO_".concat(n.displayName),payload:[],original:function(){se.undoHandler(e.historyNode.history)},type:K.UNDO,isInner:!0}),t||(this.historyNode={actionChain:[],history:new Map},A((function(){var t=se.currentTimeTravel;t&&t.onChange(t.undoable,t.redoable,"undo",e)})))}},{key:"redo",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Me||B("store is not ready, please init first.");var n=this.historyNode.actionChain[0]||{name:"",displayName:""};Me.dispatch({name:"".concat(X,"REDO_").concat(n.name),displayName:"REDO_".concat(n.displayName),payload:[],original:function(){se.redoHandler(e.historyNode.history)},type:K.REDO,isInner:!0}),t||(this.historyNode={actionChain:[],history:new Map},A((function(){var t=se.currentTimeTravel;t&&t.onChange(t.undoable,t.redoable,"redo",e)})))}},{key:"abort",value:function(){(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&this.undo(),this.status=$.ABORT,Pe.endBatch(!0,this),E(Re,this)}}],[{key:"create",value:function(t,n){var i=new e;return i.name=t,n&&(i.displayName=n),i.historyNode.actionChain.push({name:t,displayName:i.displayName}),Re.push(i),i}},{key:"abortAll",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];Re.forEach((function(t){t.abort(e)}))}},{key:"get",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.length?1===t.length?Re.filter((function(e){return e.name===t[0]})):Re.filter((function(e){return T(t,e.name)})):Re}}])}();function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Fe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach((function(t){f(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Be=[];function Ne(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=Array.isArray(e)?e:[e];t?Be.unshift.apply(Be,v(n)):Be.push.apply(Be,v(n))}function Ie(e,t,n,i){var r=e(t);return M(r)?new Promise((function(e,t){r.then((function(t){n&&n(),e(t)})).catch((function(e){i&&i(e.stack||e.message),t(e)}))})):(r&&r instanceof Error?i&&i(r.stack||r.message):n&&n(),r)}const Ue=function(){return function(e){return function(t){var n=t.name,i=t.displayName,r=t.type;return t.isInner||r!==K.MUTATION&&r!==K.UPDATE||(Oe.context?Oe.context.historyNode.actionChain.push({name:n,displayName:i}):_e.push({name:n,displayName:i})),Ie(e,t)}}},He=function(){return function(e){return function(t){var n=t.name,i=t.displayName,r=t.domain;if(!r||!ae.middleware.logger)return Ie(e,t);var o=ke.stack.length;return ae.middleware.skipNestLog&&1!==o?Ie(e,t):ae.middleware.diffLogger?Ie(e,t,(function(){if(r){var e=new Map;Oe.context?e=new Map(Oe.context.historyNode.history):se.currentTimeTravel&&(e=new Map(se.currentTimeTravel.currentHistory));var t=[];e.forEach((function(e,n){e.forEach((function(e,i){t.push({name:n.constructor.name,target:we(n)?n.$$turboxProperties:n,property:i,before:e.beforeUpdate,after:e.didUpdate})}))})),t.length&&(console.group("%c[TURBOX LOG]: DIFF ".concat(r.constructor.name," ").concat(n," ").concat(i!==ie?i:""),"background: #FF5F0F; color: #fff; font-weight: bold; padding: 3px 5px;"),console.table(t),console.groupEnd())}})):(console.group("%c[TURBOX LOG]: PREV ".concat(r.constructor.name," ").concat(n," ").concat(i!==ie?i:""),"background: #929493; color: #fff; font-weight: bold; padding: 3px 5px;"),console.dir(V({},r.$$turboxProperties,{clone:!0})),console.groupEnd(),Ie(e,t,(function(){r&&(console.group("%c[TURBOX LOG]: NEXT ".concat(r.constructor.name," ").concat(n," ").concat(i!==ie?i:""),"background: #218D41; color: #fff; font-weight: bold; padding: 3px 5px;"),console.dir(V({},r.$$turboxProperties,{clone:!0})),console.groupEnd())})))}}},Ve=function(){return function(e){return function(t){if(!ae.middleware.perf)return Ie(e,t);var n=t.name,i=t.displayName,r=performance.now(),o=ke.stack.length;return ae.middleware.skipNestPerfLog&&1!==o?Ie(e,t):Ie(e,t,(function(){var e=performance.now();console.log("%c[TURBOX PERF]: ".concat(n," ").concat(i!==ie?i:""," ").concat((e-r).toFixed(3),"ms"),"background: #FA54FF; color: #fff; font-weight: bold; padding: 3px 5px;")}))}}};var je=!1;function Ge(){Pe.endBatch(),se.clear()}function Xe(e){if(Ge(),F("undefined"!=typeof Proxy&&x(),"Proxy or Symbol is not supported, please add polyfill."),!je){Ne(Ve),Ne(Ue),Ne(He);var t=[function(e){var t=e(),n=function(){B("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},i={getActionChain:function(){return Oe.context?Oe.context.historyNode.actionChain.slice():_e.slice()},getDependencyGraph:function(){return new Map(De.dependencyGraph)},dispatch:function(){return n.apply(void 0,arguments)}},r=Be.map((function(e){return e(i)}));return n=G.apply(void 0,v(r))(t.dispatch),Fe(Fe({},t),{},{dispatch:n})}];ze(G.apply(void 0,t)),he.emit(ue.storeOnActive)}if(je=!0,e){var n=pe("".concat(X,"init"),e,{immediately:!0,displayName:""})();if(M(n))return n.then((function(){Ge()}),(function(){Ge()}));Ge()}}Xe();var qe=function(){function e(t,n,i){r(this,e),this.cosTol=t||e.COS_TOL,this.distTol=n||e.DIST_TOL,this.numTol=i||e.NUM_TOL}return i(e,[{key:"setCosTolByAngle",value:function(e,t){var n=t?1:Math.PI/180;this.cosTol=1-Math.cos(e*n)}},{key:"clone",value:function(){return new e(this.cosTol,this.distTol,this.numTol)}}],[{key:"setGlobal",value:function(t,n,i){e.global=new e(t,n,i)}}])}();qe.COS_TOL=1e-6,qe.DIST_TOL=1e-6,qe.NUM_TOL=1e-6,qe.global=new qe;for(var Ze=[],Ye=0;Ye<256;Ye++)Ze[Ye]=(Ye<16?"0":"")+Ye.toString(16);var We=1234567,Ke={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return"".concat(Ze[255&e]+Ze[e>>8&255]+Ze[e>>16&255]+Ze[e>>24&255],"-").concat(Ze[255&t]).concat(Ze[t>>8&255],"-").concat(Ze[t>>16&15|64]).concat(Ze[t>>24&255],"-").concat(Ze[63&n|128]).concat(Ze[n>>8&255],"-").concat(Ze[n>>16&255]).concat(Ze[n>>24&255]).concat(Ze[255&i]).concat(Ze[i>>8&255]).concat(Ze[i>>16&255]).concat(Ze[i>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},damp:function(e,t,n,i){return Ke.lerp(e,t,1-Math.exp(-n*i))},pingpong:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t-Math.abs(Ke.euclideanModulo(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return void 0!==e&&(We=e%2147483647),((We=16807*We%2147483647)-1)/2147483646},degToRad:function(e){return e*Ke.DEG2RAD},radToDeg:function(e){return e*Ke.RAD2DEG},isPowerOfTwo:function(e){return!(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,n,i,r){var o=Math.cos,a=Math.sin,s=o(n/2),u=a(n/2),c=o((t+i)/2),l=a((t+i)/2),h=o((t-i)/2),y=a((t-i)/2),d=o((i-t)/2),f=a((i-t)/2);switch(r){case"XYX":e.set(s*l,u*h,u*y,s*c);break;case"YZY":e.set(u*y,s*l,u*h,s*c);break;case"ZXZ":e.set(u*h,u*y,s*l,s*c);break;case"XZX":e.set(s*l,u*f,u*d,s*c);break;case"YXY":e.set(u*d,s*l,u*f,s*c);break;case"ZYZ":e.set(u*f,u*d,s*l,s*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ".concat(r))}},isEqual:function(e,t,n){var i=n||qe.global.numTol;return e===t||Math.abs(e-t)<=i},isZero:function(e,t){return Ke.is