var Oe=Object.defineProperty;var Me=(t,n,e)=>n in t?Oe(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var $=(t,n,e)=>(Me(t,typeof n!="symbol"?n+"":n,e),e);function Ge(){import("data:text/javascript,")}const be=function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function e(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerpolicy&&(o.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?o.credentials="include":i.crossorigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=e(i);fetch(i.href,o)}};be();const Se="modulepreload",Ce=function(t){return"/static/vue3/runtime/playground/"+t},re={},se=function(n,e,r){return!e||e.length===0?n():Promise.all(e.map(i=>{if(i=Ce(i),i in re)return;re[i]=!0;const o=i.endsWith(".css"),s=o?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${s}`))return;const a=document.createElement("link");if(a.rel=o?"stylesheet":Se,o||(a.as="script",a.crossOrigin=""),a.href=i,document.head.appendChild(a),o)return new Promise((l,v)=>{a.addEventListener("load",l),a.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>n())};var ce=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},G={exports:{}},F=typeof Reflect=="object"?Reflect:null,oe=F&&typeof F.apply=="function"?F.apply:function(n,e,r){return Function.prototype.apply.call(n,e,r)},X;F&&typeof F.ownKeys=="function"?X=F.ownKeys:Object.getOwnPropertySymbols?X=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:X=function(n){return Object.getOwnPropertyNames(n)};function xe(t){console&&console.warn&&console.warn(t)}var le=Number.isNaN||function(n){return n!==n};function w(){w.init.call(this)}G.exports=w;G.exports.once=Ie;w.EventEmitter=w;w.prototype._events=void 0;w.prototype._eventsCount=0;w.prototype._maxListeners=void 0;var ue=10;function ee(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return ue},set:function(t){if(typeof t!="number"||t<0||le(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ue=t}});w.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};w.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||le(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function de(t){return t._maxListeners===void 0?w.defaultMaxListeners:t._maxListeners}w.prototype.getMaxListeners=function(){return de(this)};w.prototype.emit=function(n){for(var e=[],r=1;r0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var l=o[n];if(l===void 0)return!1;if(typeof l=="function")oe(l,this,e);else for(var v=l.length,b=ve(l,v),r=0;r0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=n,a.count=s.length,xe(a)}return t}w.prototype.addListener=function(n,e){return he(this,n,e,!1)};w.prototype.on=w.prototype.addListener;w.prototype.prependListener=function(n,e){return he(this,n,e,!0)};function De(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function pe(t,n,e){var r={fired:!1,wrapFn:void 0,target:t,type:n,listener:e},i=De.bind(r);return i.listener=e,r.wrapFn=i,i}w.prototype.once=function(n,e){return ee(e),this.on(n,pe(this,n,e)),this};w.prototype.prependOnceListener=function(n,e){return ee(e),this.prependListener(n,pe(this,n,e)),this};w.prototype.removeListener=function(n,e){var r,i,o,s,a;if(ee(e),i=this._events,i===void 0)return this;if(r=i[n],r===void 0)return this;if(r===e||r.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[n],i.removeListener&&this.emit("removeListener",n,r.listener||e));else if(typeof r!="function"){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===e||r[s].listener===e){a=r[s].listener,o=s;break}if(o<0)return this;o===0?r.shift():Te(r,o),r.length===1&&(i[n]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",n,a||e)}return this};w.prototype.off=w.prototype.removeListener;w.prototype.removeAllListeners=function(n){var e,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[n]),this;if(arguments.length===0){var o=Object.keys(r),s;for(i=0;i=0;i--)this.removeListener(n,e[i]);return this};function me(t,n,e){var r=t._events;if(r===void 0)return[];var i=r[n];return i===void 0?[]:typeof i=="function"?e?[i.listener||i]:[i]:e?Ae(i):ve(i,i.length)}w.prototype.listeners=function(n){return me(this,n,!0)};w.prototype.rawListeners=function(n){return me(this,n,!1)};w.listenerCount=function(t,n){return typeof t.listenerCount=="function"?t.listenerCount(n):ge.call(t,n)};w.prototype.listenerCount=ge;function ge(t){var n=this._events;if(n!==void 0){var e=n[t];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}w.prototype.eventNames=function(){return this._eventsCount>0?X(this._events):[]};function ve(t,n){for(var e=new Array(n),r=0;r=0,this.isIpad=/(iPad).*OS\s([\d_]+)/.test(n),this.isIos=this.isIphone||this.isIpad,this.isAndroid=n.indexOf("Android")>=0,this.isAndroidPad=this.isAndroid&&n.indexOf("Mobile")<0,this.isMac=n.indexOf("Macintosh")>=0,this.isWin=n.indexOf("Windows")>=0,this.isMqq=/QQ\/([\d.]+)/.test(n),this.isWechat=n.indexOf("MicroMessenger")>=0&&n.indexOf("wxwork")<0,this.isWeb=!this.isIos&&!this.isAndroid&&!/(WebOS|BlackBerry)/.test(n),Object.entries(e).forEach(([r,i])=>{this[r]=i})}}const ne="magic:common:events:",ye="magic:common:actions:",K={SHOW:"show",HIDE:"hide",SCROLL_TO_VIEW:"scrollIntoView",SCROLL_TO_TOP:"scrollToTop"},Pe=[{label:"\u70B9\u51FB",value:`${ne}click`}],we=(t,n)=>{const e=`${t}:${n}`;return t.startsWith(ne)?e:`${ne}${e}`},We=t=>t.startsWith(ye),Ee=(t,n)=>{var r;if(!t)return!1;if(!t.id)return Ee(t.parentElement,n);const e=(r=n.page)==null?void 0:r.getNode(t.id);return e||!1},ae=(t,n,e)=>{const r=Ee(e.target,t);if(r){const{instance:i,data:o}=r;t.emit(we(n,o.id),i)}},He=t=>{window.document.body.addEventListener("click",n=>{ae(t,"click",n)}),window.document.body.addEventListener("click",n=>{ae(t,"click:capture",n)},!0)},Re=(t,n)=>{const{instance:e}=n;switch(t.replace(ye,"")){case K.SHOW:e.show();break;case K.HIDE:e.hide();break;case K.SCROLL_TO_VIEW:e.$el.scrollIntoView({behavior:"smooth"});break;case K.SCROLL_TO_TOP:window.scrollTo({top:0,behavior:"smooth"});break}};class ke{constructor(){$(this,"data",{})}set(n,e){this.data[n]=e}get(n){return this.data[n]}}class fe extends G.exports.EventEmitter{constructor(e){super();$(this,"data");$(this,"style");$(this,"events");$(this,"instance");$(this,"page");$(this,"parent");$(this,"app");$(this,"store",new ke);this.page=e.page,this.parent=e.parent,this.app=e.app;const{events:r}=e.config;this.data=e.config,this.events=r,this.listenLifeSafe(),this.once("destroy",()=>{this.instance=null,typeof this.data.destroy=="function"&&this.data.destroy(this),this.listenLifeSafe()})}listenLifeSafe(){this.once("created",e=>{this.instance=e,typeof this.data.created=="function"&&this.data.created(this)}),this.once("mounted",e=>{this.instance=e;const r=this.app.eventQueueMap[e.config.id]||[];for(let i=r.shift();i;i=r.shift())this.app.eventHandler(i.eventConfig,i.fromCpt,i.args);typeof this.data.mounted=="function"&&this.data.mounted(this)})}}class Ve extends fe{constructor(e){super(e);$(this,"nodes",new Map);this.setNode(e.config.id,this),this.initNode(e.config,this)}initNode(e,r){var o;const i=new fe({config:e,parent:r,page:this,app:this.app});this.setNode(e.id,i),(o=e.items)==null||o.forEach(s=>{this.initNode(s,i)})}getNode(e){return this.nodes.get(e)}setNode(e,r){this.nodes.set(e,r)}deleteNode(e){this.nodes.delete(e)}}const Ue=t=>{if(typeof t!="string")return t;const n={};return t.split(";").forEach(e=>{if(!e)return;const r=e.split(":");let i=r.shift(),o=r.join(":");!i||(i=i.replace(/^\s*/,"").replace(/\s*$/,""),o=o.replace(/^\s*/,"").replace(/\s*$/,""),i=i.split("-").map((s,a)=>a>0?`${s[0].toUpperCase()}${s.substr(1)}`:s).join(""),n[i]=o)}),n},Ye=t=>t&&!/^url/.test(t)&&!/^linear-gradient/.test(t)?`url(${t})`:t,Fe=t=>/^(-?\d+)(\.\d+)?$/.test(t);class Be extends G.exports.EventEmitter{constructor(e){super();$(this,"env");$(this,"pages",new Map);$(this,"page");$(this,"platform","mobile");$(this,"jsEngine","browser");$(this,"designWidth",375);$(this,"components",new Map);$(this,"eventQueueMap",{});if(this.env=new je(e.ua),e.platform&&(this.platform=e.platform),e.jsEngine&&(this.jsEngine=e.jsEngine),e.designWidth&&(this.designWidth=e.designWidth),this.platform==="mobile"||this.platform==="editor"){const r=()=>{let{width:i}=document.documentElement.getBoundingClientRect();i=Math.min(800,i);const o=i/(this.designWidth/100);document.documentElement.style.fontSize=`${o}px`};r(),document.body.style.fontSize="14px",globalThis.addEventListener("resize",r)}e.transformStyle&&(this.transformStyle=e.transformStyle),e.config&&this.setConfig(e.config,e.curPage),He(this)}transformStyle(e){if(!e)return{};let r={};const i={};typeof e=="string"?r=Ue(e):r={...e};const o=["zIndex","opacity","fontWeight"];return Object.entries(r).forEach(([s,a])=>{s==="backgroundImage"?a&&(i[s]=Ye(a)):s==="transform"&&typeof a!="string"?i[s]=Object.entries(a).map(([l,v])=>{let b=0;return l==="scale"&&(b=1),l==="rotate"&&Fe(v)&&(v=`${v}deg`),`${l}(${v||b})`}).join(" "):!o.includes(s)&&a&&/^[-]?[0-9]*[.]?[0-9]*$/.test(a)?i[s]=`${a/100}rem`:i[s]=a}),i}setConfig(e,r){var i,o,s;this.pages=new Map,(i=e.items)==null||i.forEach(a=>{this.pages.set(a.id,new Ve({config:a,app:this}))}),this.setPage(r||((s=(o=this.page)==null?void 0:o.data)==null?void 0:s.id))}setPage(e){let r;e&&(r=this.pages.get(e)),r||(r=this.pages.get(this.pages.keys().next().value)),this.page=r,this.platform!=="magic"&&this.bindEvents()}registerComponent(e,r){this.components.set(e,r)}unregisterComponent(e){this.components.delete(e)}resolveComponent(e){return this.components.get(e)}bindEvents(){var e;if(!!this.page){this.removeAllListeners();for(const[,r]of this.page.nodes)(e=r.events)==null||e.forEach(i=>this.bindEvent(i,`${r.data.id}`))}}bindEvent(e,r){let{name:i}=e;Pe.findIndex(o=>o.value===i)>-1&&(i=we(i,r)),this.on(i,(o,...s)=>{this.eventHandler(e,o,s)})}eventHandler(e,r,i){if(!this.page)throw new Error("\u5F53\u524D\u6CA1\u6709\u9875\u9762");const{method:o,to:s}=e,a=this.page.getNode(s);if(!a)throw`ID\u4E3A${s}\u7684\u7EC4\u4EF6\u4E0D\u5B58\u5728`;if(We(o))return Re(o,a);a.instance?typeof a.instance[o]=="function"&&a.instance[o](r,...i):this.addEventToMap({eventConfig:e,fromCpt:r,args:i})}destroy(){this.removeAllListeners(),this.pages.clear()}addEventToMap(e){this.eventQueueMap[e.eventConfig.to]?this.eventQueueMap[e.eventConfig.to].push(e):this.eventQueueMap[e.eventConfig.to]=[e]}}var _e={exports:{}};(function(t,n){(function(e,r){t.exports=r()})(ce,function(){var e=1e3,r=6e4,i=36e5,o="millisecond",s="second",a="minute",l="hour",v="day",b="week",M="month",P="quarter",T="year",I="date",d="Invalid Date",x=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,R=/\[([^\]]+)]|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,k={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("_")},D=function(g,c,u){var h=String(g);return!h||h.length>=c?g:""+Array(c+1-h.length).join(u)+g},q={s:D,z:function(g){var c=-g.utcOffset(),u=Math.abs(c),h=Math.floor(u/60),f=u%60;return(c<=0?"+":"-")+D(h,2,"0")+":"+D(f,2,"0")},m:function g(c,u){if(c.date()1)return g(p[0])}else{var y=c.name;A[y]=c,f=y}return!h&&f&&(N=f),f||!h&&N},_=function(g,c){if(V(g))return g.clone();var u=typeof c=="object"?c:{};return u.date=g,u.args=arguments,new Z(u)},E=q;E.l=U,E.i=V,E.w=function(g,c){return _(g,{locale:c.$L,utc:c.$u,x:c.$x,$offset:c.$offset})};var Z=function(){function g(u){this.$L=U(u.locale,null,!0),this.parse(u)}var c=g.prototype;return c.parse=function(u){this.$d=function(h){var f=h.date,m=h.utc;if(f===null)return new Date(NaN);if(E.u(f))return new Date;if(f instanceof Date)return new Date(f);if(typeof f=="string"&&!/Z$/i.test(f)){var p=f.match(x);if(p){var y=p[2]-1||0,O=(p[7]||"0").substring(0,3);return m?new Date(Date.UTC(p[1],y,p[3]||1,p[4]||0,p[5]||0,p[6]||0,O)):new Date(p[1],y,p[3]||1,p[4]||0,p[5]||0,p[6]||0,O)}}return new Date(f)}(u),this.$x=u.x||{},this.init()},c.init=function(){var u=this.$d;this.$y=u.getFullYear(),this.$M=u.getMonth(),this.$D=u.getDate(),this.$W=u.getDay(),this.$H=u.getHours(),this.$m=u.getMinutes(),this.$s=u.getSeconds(),this.$ms=u.getMilliseconds()},c.$utils=function(){return E},c.isValid=function(){return this.$d.toString()!==d},c.isSame=function(u,h){var f=_(u);return this.startOf(h)<=f&&f<=this.endOf(h)},c.isAfter=function(u,h){return _(u)t.replace(/\B([A-Z])/g,"-$1").toLowerCase(),Q=(t,n=[])=>{const e=[],r=function(i,o){if(!Array.isArray(o))return null;for(let s=0,a=o.length;s{var s,a,l,v;return((a=(s=t.value)==null?void 0:s.items)==null?void 0:a.find(b=>b.id===n.value))||((v=(l=t.value)==null?void 0:l.items)==null?void 0:v[0])}),i=new Be({config:t.value,platform:"editor"});return Vue.provide("app",i),Vue.watch(r,async()=>{await Vue.nextTick();const s=document.querySelector(".magic-ui-page");s&&window.magic.onPageElUpdate(s)}),(o=window.magic)==null||o.onRuntimeReady({getApp(){return i},updateRootConfig(s){console.log("update config",s),t.value=s,i==null||i.setConfig(s,n.value)},updatePageId(s){console.log("update page id",s),n.value=s,i==null||i.setPage(s)},select(s){console.log("select config",s),e.value=s;const a=document.getElementById(`${s}`);return a||Vue.nextTick().then(()=>document.getElementById(`${s}`))},add({config:s,parentId:a}){var v;if(console.log("add config",s),!t.value)throw new Error("error");if(!e.value)throw new Error("error");const l=Q(a,[t.value]).pop();if(!l)throw new Error("\u672A\u627E\u5230\u7236\u8282\u70B9");(v=l.items)==null||v.push(s)},update({config:s,parentId:a}){var M;if(console.log("update config",s),!t.value)throw new Error("error");const l=Q(s.id,[t.value]).pop(),v=Q(a,[t.value]).pop();if(!l)throw new Error("\u672A\u627E\u5230\u76EE\u6807\u8282\u70B9");if(!v)throw new Error("\u672A\u627E\u5230\u7236\u8282\u70B9");const b=(M=v.items)==null?void 0:M.findIndex(P=>P.id===l.id);v.items.splice(b,1,Vue.reactive(s))},remove({id:s,parentId:a}){var M;if(!t.value)throw new Error("error");const l=Q(s,[t.value]).pop();if(!l)throw new Error("\u672A\u627E\u5230\u76EE\u6807\u5143\u7D20");const v=Q(a,[t.value]).pop();if(!v)throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");const b=(M=v.items)==null?void 0:M.findIndex(P=>P.id===l.id);v.items.splice(b,1)}}),{pageConfig:r}}}),Ze=(t,n)=>{const e=t.__vccOpts||t;for(const[r,i]of n)e[r]=i;return e};function Je(t,n,e,r,i,o){const s=Vue.resolveComponent("magic-ui-page");return t.pageConfig?(Vue.openBlock(),Vue.createBlock(s,{key:0,config:t.pageConfig},null,8,["config"])):Vue.createCommentVNode("v-if",!0)}const Ke=Ze(qe,[["render",Je],["__file","/data/magic/tmagic-editor/runtime/vue3/playground/App.vue"]]);Promise.all([se(()=>import("./comp-entry.13d1f45f.js"),[]),se(()=>import("./plugin-entry.b765d2c2.js"),[])]).then(([t,n])=>{const e=Vue.createApp(Ke);Object.values(t.default).forEach(r=>{e.component(r.name,r)}),Object.values(n.default).forEach(r=>{e.use(r)}),e.mount("#app")});export{Ze as _,Ge as __vite_legacy_guard,et as t}; //# sourceMappingURL=index.6f272ec3.js.map