2022-08-18 19:47:49 +08:00

3 lines
23 KiB
JavaScript

!function(){function t(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}System.register([],(function(e,n){"use strict";return{execute:function(){const i=function(t,e,n){return t()};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,s={exports:{}},o="object"==typeof Reflect?Reflect:null,a=o&&"function"==typeof o.apply?o.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};r=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var u=Number.isNaN||function(t){return t!=t};function c(){c.init.call(this)}s.exports=c,s.exports.once=function(t,e){return new Promise((function(n,i){function r(n){t.removeListener(e,s),i(n)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",r),n([].slice.call(arguments))}$(t,e,s,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&$(t,"error",e,n)}(t,r,{once:!0})}))},c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var f=10;function h(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?c.defaultMaxListeners:t._maxListeners}function d(t,e,n,i){var r,s,o,a;if(h(n),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),o=s[e]),void 0===o)o=s[e]=n,++t._eventsCount;else if("function"==typeof o?o=s[e]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(r=l(t))>0&&o.length>r&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=o.length,a=u,console&&console.warn&&console.warn(a)}return t}function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function v(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=p.bind(i);return r.listener=n,i.wrapFn=r,r}function g(t,e,n){var i=t._events;if(void 0===i)return[];var r=i[e];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(r):y(r,r.length)}function m(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function y(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}function $(t,e,n,i){if("function"==typeof t.on)i.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function r(s){i.once&&t.removeEventListener(e,r),n(s)}))}}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return f},set:function(t){if("number"!=typeof t||t<0||u(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");f=t}}),c.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||u(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},c.prototype.getMaxListeners=function(){return l(this)},c.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var i="error"===t,r=this._events;if(void 0!==r)i=i&&void 0===r.error;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var u=r[t];if(void 0===u)return!1;if("function"==typeof u)a(u,this,e);else{var c=u.length,f=y(u,c);for(n=0;n<c;++n)a(f[n],this,e)}return!0},c.prototype.addListener=function(t,e){return d(this,t,e,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(t,e){return d(this,t,e,!0)},c.prototype.once=function(t,e){return h(e),this.on(t,v(this,t,e)),this},c.prototype.prependOnceListener=function(t,e){return h(e),this.prependListener(t,v(this,t,e)),this},c.prototype.removeListener=function(t,e){var n,i,r,s,o;if(h(e),void 0===(i=this._events))return this;if(void 0===(n=i[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(r=-1,s=n.length-1;s>=0;s--)if(n[s]===e||n[s].listener===e){o=n[s].listener,r=s;break}if(r<0)return this;0===r?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,r),1===n.length&&(i[t]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",t,o||e)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(t){var e,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var r,s=Object.keys(n);for(i=0;i<s.length;++i)"removeListener"!==(r=s[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this},c.prototype.listeners=function(t){return g(this,t,!0)},c.prototype.rawListeners=function(t){return g(this,t,!1)},c.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},c.prototype.listenerCount=m,c.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};class w{constructor(e=globalThis.navigator.userAgent,n={}){t(this,"isIos",!1),t(this,"isIphone",!1),t(this,"isIpad",!1),t(this,"isAndroid",!1),t(this,"isAndroidPad",!1),t(this,"isMac",!1),t(this,"isWin",!1),t(this,"isMqq",!1),t(this,"isWechat",!1),t(this,"isWeb",!1),this.isIphone=e.indexOf("iPhone")>=0,this.isIpad=/(iPad).*OS\s([\d_]+)/.test(e),this.isIos=this.isIphone||this.isIpad,this.isAndroid=e.indexOf("Android")>=0,this.isAndroidPad=this.isAndroid&&e.indexOf("Mobile")<0,this.isMac=e.indexOf("Macintosh")>=0,this.isWin=e.indexOf("Windows")>=0,this.isMqq=/QQ\/([\d.]+)/.test(e),this.isWechat=e.indexOf("MicroMessenger")>=0&&e.indexOf("wxwork")<0,this.isWeb=!this.isIos&&!this.isAndroid&&!/(WebOS|BlackBerry)/.test(e),Object.entries(n).forEach((([t,e])=>{this[t]=e}))}}const M="magic:common:events:",b="magic:common:actions:",O="show",L="hide",E="scrollIntoView",S="scrollToTop",_=[{label:"点击",value:"magic:common:events:click"}],x=(t,e)=>{const n=`${t}:${e}`;return t.startsWith(M)?n:`magic:common:events:${n}`},C=(t,e)=>{var n;if(!t)return!1;if(!t.id)return C(t.parentElement,e);const i=null===(n=e.page)||void 0===n?void 0:n.getNode(t.id);return i||!1},D=(t,e,n)=>{const i=C(n.target,t);if(i){const{instance:n,data:r}=i;t.emit(x(e,r.id),n)}};class T{constructor(){t(this,"data",{})}set(t,e){this.data[t]=e}get(t){return this.data[t]}}class I extends s.exports.EventEmitter{constructor(e){super(),t(this,"data",void 0),t(this,"style",void 0),t(this,"events",void 0),t(this,"instance",void 0),t(this,"page",void 0),t(this,"parent",void 0),t(this,"app",void 0),t(this,"store",new T),this.page=e.page,this.parent=e.parent,this.app=e.app;const{events:n}=e.config;this.data=e.config,this.events=n,this.listenLifeSafe(),this.once("destroy",(()=>{this.instance=null,"function"==typeof this.data.destroy&&this.data.destroy(this),this.listenLifeSafe()}))}listenLifeSafe(){this.once("created",(t=>{this.instance=t,"function"==typeof this.data.created&&this.data.created(this)})),this.once("mounted",(t=>{this.instance=t;const e=this.app.eventQueueMap[t.config.id]||[];for(let n=e.shift();n;n=e.shift())this.app.eventHandler(n.eventConfig,n.fromCpt,n.args);"function"==typeof this.data.mounted&&this.data.mounted(this)}))}}class j extends I{constructor(e){super(e),t(this,"nodes",new Map),this.setNode(e.config.id,this),this.initNode(e.config,this)}initNode(t,e){var n;const i=new I({config:t,parent:e,page:this,app:this.app});this.setNode(t.id,i),null===(n=t.items)||void 0===n||n.forEach((t=>{this.initNode(t,i)}))}getNode(t){return this.nodes.get(t)}setNode(t,e){this.nodes.set(t,e)}deleteNode(t){this.nodes.delete(t)}}class A extends s.exports.EventEmitter{constructor(e){if(super(),t(this,"env",void 0),t(this,"pages",new Map),t(this,"page",void 0),t(this,"platform","mobile"),t(this,"jsEngine","browser"),t(this,"designWidth",375),t(this,"components",new Map),t(this,"eventQueueMap",{}),this.env=new w(e.ua),e.platform&&(this.platform=e.platform),e.jsEngine&&(this.jsEngine=e.jsEngine),e.designWidth&&(this.designWidth=e.designWidth),"mobile"===this.platform||"editor"===this.platform){const t=()=>{let{width:t}=document.documentElement.getBoundingClientRect();t=Math.min(800,t);const e=t/(this.designWidth/100);document.documentElement.style.fontSize=`${e}px`};t(),document.body.style.fontSize="14px",globalThis.addEventListener("resize",t)}var n;e.transformStyle&&(this.transformStyle=e.transformStyle),e.config&&this.setConfig(e.config,e.curPage),n=this,window.document.body.addEventListener("click",(t=>{D(n,"click",t)})),window.document.body.addEventListener("click",(t=>{D(n,"click:capture",t)}),!0)}transformStyle(t){if(!t)return{};let e={};const n={};e="string"==typeof t?(t=>{if("string"!=typeof t)return t;const e={};return t.split(";").forEach((t=>{if(!t)return;const n=t.split(":");let i=n.shift(),r=n.join(":");i&&(i=i.replace(/^\s*/,"").replace(/\s*$/,""),r=r.replace(/^\s*/,"").replace(/\s*$/,""),i=i.split("-").map(((t,e)=>e>0?`${t[0].toUpperCase()}${t.substr(1)}`:t)).join(""),e[i]=r)})),e})(t):{...t};const i=["zIndex","opacity","fontWeight"];return Object.entries(e).forEach((([t,e])=>{"backgroundImage"===t?e&&(n[t]=(t=>!t||/^url/.test(t)||/^linear-gradient/.test(t)?t:`url(${t})`)(e)):"transform"===t&&"string"!=typeof e?n[t]=Object.entries(e).map((([t,e])=>{let n=0;return"scale"===t&&(n=1),"rotate"===t&&(t=>/^(-?\d+)(\.\d+)?$/.test(t))(e)&&(e=`${e}deg`),`${t}(${e||n})`})).join(" "):!i.includes(t)&&e&&/^[-]?[0-9]*[.]?[0-9]*$/.test(e)?n[t]=e/100+"rem":n[t]=e})),n}setConfig(t,e){var n,i,r;this.pages=new Map,null===(n=t.items)||void 0===n||n.forEach((t=>{this.pages.set(t.id,new j({config:t,app:this}))})),this.setPage(e||(null===(i=this.page)||void 0===i||null===(r=i.data)||void 0===r?void 0:r.id))}setPage(t){let e;t&&(e=this.pages.get(t)),e||(e=this.pages.get(this.pages.keys().next().value)),this.page=e,"magic"!==this.platform&&this.bindEvents()}registerComponent(t,e){this.components.set(t,e)}unregisterComponent(t){this.components.delete(t)}resolveComponent(t){return this.components.get(t)}bindEvents(){if(this.page){this.removeAllListeners();for(const[,e]of this.page.nodes){var t;null===(t=e.events)||void 0===t||t.forEach((t=>this.bindEvent(t,`${e.data.id}`)))}}}bindEvent(t,e){let{name:n}=t;_.findIndex((t=>t.value===n))>-1&&(n=x(n,e)),this.on(n,((e,...n)=>{this.eventHandler(t,e,n)}))}eventHandler(t,e,n){if(!this.page)throw new Error("当前没有页面");const{method:i,to:r}=t,s=this.page.getNode(r);if(!s)throw`ID为${r}的组件不存在`;if((t=>t.startsWith(b))(i))return((t,e)=>{const{instance:n}=e;switch(t.replace(b,"")){case O:n.show();break;case L:n.hide();break;case E:n.$el.scrollIntoView({behavior:"smooth"});break;case S:window.scrollTo({top:0,behavior:"smooth"})}})(i,s);s.instance?"function"==typeof s.instance[i]&&s.instance[i](e,...n):this.addEventToMap({eventConfig:t,fromCpt:e,args:n})}destroy(){this.removeAllListeners(),this.pages.clear()}addEventToMap(t){this.eventQueueMap[t.eventConfig.to]?this.eventQueueMap[t.eventConfig.to].push(t):this.eventQueueMap[t.eventConfig.to]=[t]}}var W={exports:{}};!function(t,e){t.exports=function(){var t=1e3,e=6e4,n=36e5,i="millisecond",r="second",s="minute",o="hour",a="day",u="week",c="month",f="quarter",h="year",l="date",d="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},m=function(t,e,n){var i=String(t);return!i||i.length>=e?t:""+Array(e+1-i.length).join(n)+t},y={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),i=Math.floor(n/60),r=n%60;return(e<=0?"+":"-")+m(i,2,"0")+":"+m(r,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var i=12*(n.year()-e.year())+(n.month()-e.month()),r=e.clone().add(i,c),s=n-r<0,o=e.clone().add(i+(s?-1:1),c);return+(-(i+(n-r)/(s?r-o:o-r))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:c,y:h,w:u,d:a,D:l,h:o,m:s,s:r,ms:i,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},$="en",w={};w[$]=g;var M=function(t){return t instanceof E},b=function t(e,n,i){var r;if(!e)return $;if("string"==typeof e){var s=e.toLowerCase();w[s]&&(r=s),n&&(w[s]=n,r=s);var o=e.split("-");if(!r&&o.length>1)return t(o[0])}else{var a=e.name;w[a]=e,r=a}return!i&&r&&($=r),r||!i&&$},O=function(t,e){if(M(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new E(n)},L=y;L.l=b,L.i=M,L.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var E=function(){function g(t){this.$L=b(t.locale,null,!0),this.parse(t)}var m=g.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(L.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var i=e.match(p);if(i){var r=i[2]-1||0,s=(i[7]||"0").substring(0,3);return n?new Date(Date.UTC(i[1],r,i[3]||1,i[4]||0,i[5]||0,i[6]||0,s)):new Date(i[1],r,i[3]||1,i[4]||0,i[5]||0,i[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return L},m.isValid=function(){return!(this.$d.toString()===d)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return L.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,i=!!L.u(e)||e,f=L.p(t),d=function(t,e){var r=L.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return i?r:r.endOf(a)},p=function(t,e){return L.w(n.toDate()[t].apply(n.toDate("s"),(i?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},v=this.$W,g=this.$M,m=this.$D,y="set"+(this.$u?"UTC":"");switch(f){case h:return i?d(1,0):d(31,11);case c:return i?d(1,g):d(0,g+1);case u:var $=this.$locale().weekStart||0,w=(v<$?v+7:v)-$;return d(i?m-w:m+(6-w),g);case a:case l:return p(y+"Hours",0);case o:return p(y+"Minutes",1);case s:return p(y+"Seconds",2);case r:return p(y+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,u=L.p(t),f="set"+(this.$u?"UTC":""),d=(n={},n[a]=f+"Date",n[l]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[o]=f+"Hours",n[s]=f+"Minutes",n[r]=f+"Seconds",n[i]=f+"Milliseconds",n)[u],p=u===a?this.$D+(e-this.$W):e;if(u===c||u===h){var v=this.clone().set(l,1);v.$d[d](p),v.init(),this.$d=v.set(l,Math.min(this.$D,v.daysInMonth())).$d}else d&&this.$d[d](p);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[L.p(t)]()},m.add=function(i,f){var l,d=this;i=Number(i);var p=L.p(f),v=function(t){var e=O(d);return L.w(e.date(e.date()+Math.round(t*i)),d)};if(p===c)return this.set(c,this.$M+i);if(p===h)return this.set(h,this.$y+i);if(p===a)return v(1);if(p===u)return v(7);var g=(l={},l[s]=e,l[o]=n,l[r]=t,l)[p]||1,m=this.$d.getTime()+i*g;return L.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||d;var i=t||"YYYY-MM-DDTHH:mm:ssZ",r=L.z(this),s=this.$H,o=this.$m,a=this.$M,u=n.weekdays,c=n.months,f=function(t,n,r,s){return t&&(t[n]||t(e,i))||r[n].slice(0,s)},h=function(t){return L.s(s%12||12,t,"0")},l=n.meridiem||function(t,e,n){var i=t<12?"AM":"PM";return n?i.toLowerCase():i},p={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:L.s(a+1,2,"0"),MMM:f(n.monthsShort,a,c,3),MMMM:f(c,a),D:this.$D,DD:L.s(this.$D,2,"0"),d:String(this.$W),dd:f(n.weekdaysMin,this.$W,u,2),ddd:f(n.weekdaysShort,this.$W,u,3),dddd:u[this.$W],H:String(s),HH:L.s(s,2,"0"),h:h(1),hh:h(2),a:l(s,o,!0),A:l(s,o,!1),m:String(o),mm:L.s(o,2,"0"),s:String(this.$s),ss:L.s(this.$s,2,"0"),SSS:L.s(this.$ms,3,"0"),Z:r};return i.replace(v,(function(t,e){return e||p[t]||r.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(i,l,d){var p,v=L.p(l),g=O(i),m=(g.utcOffset()-this.utcOffset())*e,y=this-g,$=L.m(this,g);return $=(p={},p[h]=$/12,p[c]=$,p[f]=$/3,p[u]=(y-m)/6048e5,p[a]=(y-m)/864e5,p[o]=y/n,p[s]=y/e,p[r]=y/t,p)[v]||y,d?$:L.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return w[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),i=b(t,e,!0);return i&&(n.$L=i),n},m.clone=function(){return L.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},g}(),S=E.prototype;return O.prototype=S,[["$ms",i],["$s",r],["$m",s],["$H",o],["$W",a],["$M",c],["$y",h],["$D",l]].forEach((function(t){S[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),O.extend=function(t,e){return t.$i||(t(e,E,O),t.$i=!0),O},O.locale=b,O.isDayjs=M,O.unix=function(t){return O(1e3*t)},O.en=w[$],O.Ls=w,O.p={},O}()}(W);const k=W.exports;var N={exports:{}};!function(t,e){var n,i,r;t.exports=(n="minute",i=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g,function(t,e,s){var o=e.prototype;s.utc=function(t){return new e({date:t,utc:!0,args:arguments})},o.utc=function(t){var e=s(this.toDate(),{locale:this.$L,utc:!0});return t?e.add(this.utcOffset(),n):e},o.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var a=o.parse;o.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),a.call(this,t)};var u=o.init;o.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else u.call(this)};var c=o.utcOffset;o.utcOffset=function(t,e){var s=this.$utils().u;if(s(t))return this.$u?0:s(this.$offset)?c.call(this):this.$offset;if("string"==typeof t&&(t=function(t){void 0===t&&(t="");var e=t.match(i);if(!e)return null;var n=(""+e[0]).match(r)||["-",0,0],s=n[0],o=60*+n[1]+ +n[2];return 0===o?0:"+"===s?o:-o}(t),null===t))return this;var o=Math.abs(t)<=16?60*t:t,a=this;if(e)return a.$offset=o,a.$u=0===t,a;if(0!==t){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(a=this.local().add(o+u,n)).$offset=o,a.$x.$localOffset=u}else a=this.utc();return a};var f=o.format;o.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return f.call(this,e)},o.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},o.isUTC=function(){return!!this.$u},o.toISOString=function(){return this.toDate().toISOString()},o.toString=function(){return this.toDate().toUTCString()};var h=o.toDate;o.toDate=function(t){return"s"===t&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():h.call(this)};var l=o.diff;o.diff=function(t,e,n){if(t&&this.$u===t.$u)return l.call(this,t,e,n);var i=this.local(),r=s(t).local();return l.call(i,r,e,n)}})}(N);const Y=N.exports;k.extend(Y);e("t",((t="")=>t.replace(/\B([A-Z])/g,"-$1").toLowerCase()));const H=(t,e=[])=>{const n=[],i=function(t,e){if(!Array.isArray(e))return null;for(let r=0,s=e.length;r<s;r++){const s=e[r];if(n.push(s),`${s.id}`==`${t}`)return s;if(s.items){const e=i(t,s.items);if(e)return e}n.pop()}return null};return i(t,e),n},P=Vue.defineComponent({setup(){var t;const e=Vue.ref(),n=Vue.ref(),i=Vue.ref(),r=Vue.computed((()=>{var t,i,r,s;return(null===(t=e.value)||void 0===t||null===(i=t.items)||void 0===i?void 0:i.find((t=>t.id===n.value)))||(null===(r=e.value)||void 0===r||null===(s=r.items)||void 0===s?void 0:s[0])})),s=new A({config:e.value,platform:"editor"});return Vue.provide("app",s),Vue.watch(r,(async()=>{await Vue.nextTick();const t=document.querySelector(".magic-ui-page");t&&window.magic.onPageElUpdate(t)})),null===(t=window.magic)||void 0===t||t.onRuntimeReady({getApp:()=>s,updateRootConfig(t){console.log("update config",t),e.value=t,null==s||s.setConfig(t,n.value)},updatePageId(t){console.log("update page id",t),n.value=t,null==s||s.setPage(t)},select(t){console.log("select config",t),i.value=t;const e=document.getElementById(`${t}`);return e||Vue.nextTick().then((()=>document.getElementById(`${t}`)))},add({config:t,parentId:n}){var r;if(console.log("add config",t),!e.value)throw new Error("error");if(!i.value)throw new Error("error");const s=H(n,[e.value]).pop();if(!s)throw new Error("未找到父节点");null===(r=s.items)||void 0===r||r.push(t)},update({config:t,parentId:n}){var i;if(console.log("update config",t),!e.value)throw new Error("error");const r=H(t.id,[e.value]).pop(),s=H(n,[e.value]).pop();if(!r)throw new Error("未找到目标节点");if(!s)throw new Error("未找到父节点");const o=null===(i=s.items)||void 0===i?void 0:i.findIndex((t=>t.id===r.id));s.items.splice(o,1,Vue.reactive(t))},remove({id:t,parentId:n}){var i;if(!e.value)throw new Error("error");const r=H(t,[e.value]).pop();if(!r)throw new Error("未找到目标元素");const s=H(n,[e.value]).pop();if(!s)throw new Error("未找到父元素");const o=null===(i=s.items)||void 0===i?void 0:i.findIndex((t=>t.id===r.id));s.items.splice(o,1)}}),{pageConfig:r}}});const V=e("_",((t,e)=>{const n=t.__vccOpts||t;for(const[i,r]of e)n[i]=r;return n}))(P,[["render",function(t,e,n,i,r,s){const o=Vue.resolveComponent("magic-ui-page");return t.pageConfig?(Vue.openBlock(),Vue.createBlock(o,{key:0,config:t.pageConfig},null,8,["config"])):Vue.createCommentVNode("v-if",!0)}],["__file","/data/magic/tmagic-editor/runtime/vue3/playground/App.vue"]]);Promise.all([i((()=>n.import("./comp-entry-legacy.e6d0a969.js"))),i((()=>n.import("./plugin-entry-legacy.7d9da6d6.js")))]).then((([t,e])=>{const n=Vue.createApp(V);Object.values(t.default).forEach((t=>{n.component(t.name,t)})),Object.values(e.default).forEach((t=>{n.use(t)})),n.mount("#app")}))}}}))}();
//# sourceMappingURL=index-legacy.97f27bc4.js.map