(function(v,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("@easy-coder/sdk/helper"),require("@easy-coder/sdk/variable")):typeof define=="function"&&define.amd?define(["exports","react","@easy-coder/sdk/helper","@easy-coder/sdk/variable"],s):(v=typeof globalThis<"u"?globalThis:v||self,s(v.index={},v.require$$0,v.helper,v.variable))})(this,function(v,s,m,me){"use strict";var Ee={exports:{}},te={};/**
 * @license React
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var De;function yt(){if(De)return te;De=1;var t=s,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,u=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function f(y,c,p){var d,E={},_=null,g=null;p!==void 0&&(_=""+p),c.key!==void 0&&(_=""+c.key),c.ref!==void 0&&(g=c.ref);for(d in c)r.call(c,d)&&!i.hasOwnProperty(d)&&(E[d]=c[d]);if(y&&y.defaultProps)for(d in c=y.defaultProps,c)E[d]===void 0&&(E[d]=c[d]);return{$$typeof:n,type:y,key:_,ref:g,props:E,_owner:u.current}}return te.Fragment=a,te.jsx=f,te.jsxs=f,te}var ne={};/**
 * @license React
 * react-jsx-runtime.development.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var ke;function bt(){return ke||(ke=1,process.env.NODE_ENV!=="production"&&function(){var t=s,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),f=Symbol.for("react.provider"),y=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),R=Symbol.iterator,w="@@iterator";function j(e){if(e===null||typeof e!="object")return null;var o=R&&e[R]||e[w];return typeof o=="function"?o:null}var D=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(e){{for(var o=arguments.length,l=new Array(o>1?o-1:0),b=1;b<o;b++)l[b-1]=arguments[b];x("error",e,l)}}function x(e,o,l){{var b=D.ReactDebugCurrentFrame,C=b.getStackAddendum();C!==""&&(o+="%s",l=l.concat([C]));var M=l.map(function(h){return String(h)});M.unshift("Warning: "+o),Function.prototype.apply.call(console[e],console,M)}}var W=!1,H=!1,I=!1,F=!1,Y=!1,K;K=Symbol.for("react.module.reference");function A(e){return!!(typeof e=="string"||typeof e=="function"||e===r||e===i||Y||e===u||e===p||e===d||F||e===g||W||H||I||typeof e=="object"&&e!==null&&(e.$$typeof===_||e.$$typeof===E||e.$$typeof===f||e.$$typeof===y||e.$$typeof===c||e.$$typeof===K||e.getModuleId!==void 0))}function k(e,o,l){var b=e.displayName;if(b)return b;var C=o.displayName||o.name||"";return C!==""?l+"("+C+")":l}function U(e){return e.displayName||"Context"}function L(e){if(e==null)return null;if(typeof e.tag=="number"&&S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case r:return"Fragment";case a:return"Portal";case i:return"Profiler";case u:return"StrictMode";case p:return"Suspense";case d:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case y:var o=e;return U(o)+".Consumer";case f:var l=e;return U(l._context)+".Provider";case c:return k(e,e.render,"ForwardRef");case E:var b=e.displayName||null;return b!==null?b:L(e.type)||"Memo";case _:{var C=e,M=C._payload,h=C._init;try{return L(h(M))}catch{return null}}}return null}var Z=Object.assign,ie=0,Je,Ke,He,Ze,Qe,qe,$e;function et(){}et.__reactDisabledLog=!0;function en(){{if(ie===0){Je=console.log,Ke=console.info,He=console.warn,Ze=console.error,Qe=console.group,qe=console.groupCollapsed,$e=console.groupEnd;var e={configurable:!0,enumerable:!0,value:et,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}ie++}}function tn(){{if(ie--,ie===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Z({},e,{value:Je}),info:Z({},e,{value:Ke}),warn:Z({},e,{value:He}),error:Z({},e,{value:Ze}),group:Z({},e,{value:Qe}),groupCollapsed:Z({},e,{value:qe}),groupEnd:Z({},e,{value:$e})})}ie<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var _e=D.ReactCurrentDispatcher,Se;function pe(e,o,l){{if(Se===void 0)try{throw Error()}catch(C){var b=C.stack.trim().match(/\n( *(at )?)/);Se=b&&b[1]||""}return`
`+Se+e}}var Pe=!1,ve;{var nn=typeof WeakMap=="function"?WeakMap:Map;ve=new nn}function tt(e,o){if(!e||Pe)return"";{var l=ve.get(e);if(l!==void 0)return l}var b;Pe=!0;var C=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var M;M=_e.current,_e.current=null,en();try{if(o){var h=function(){throw Error()};if(Object.defineProperty(h.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(h,[])}catch(N){b=N}Reflect.construct(e,[],h)}else{try{h.call()}catch(N){b=N}e.call(h.prototype)}}else{try{throw Error()}catch(N){b=N}e()}}catch(N){if(N&&b&&typeof N.stack=="string"){for(var V=N.stack.split(`
`),G=b.stack.split(`
`),T=V.length-1,O=G.length-1;T>=1&&O>=0&&V[T]!==G[O];)O--;for(;T>=1&&O>=0;T--,O--)if(V[T]!==G[O]){if(T!==1||O!==1)do if(T--,O--,O<0||V[T]!==G[O]){var B=`
`+V[T].replace(" at new "," at ");return e.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",e.displayName)),typeof e=="function"&&ve.set(e,B),B}while(T>=1&&O>=0);break}}}finally{Pe=!1,_e.current=M,tn(),Error.prepareStackTrace=C}var ee=e?e.displayName||e.name:"",q=ee?pe(ee):"";return typeof e=="function"&&ve.set(e,q),q}function rn(e,o,l){return tt(e,!1)}function an(e){var o=e.prototype;return!!(o&&o.isReactComponent)}function ye(e,o,l){if(e==null)return"";if(typeof e=="function")return tt(e,an(e));if(typeof e=="string")return pe(e);switch(e){case p:return pe("Suspense");case d:return pe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case c:return rn(e.render);case E:return ye(e.type,o,l);case _:{var b=e,C=b._payload,M=b._init;try{return ye(M(C),o,l)}catch{}}}return""}var ue=Object.prototype.hasOwnProperty,nt={},rt=D.ReactDebugCurrentFrame;function be(e){if(e){var o=e._owner,l=ye(e.type,e._source,o?o.type:null);rt.setExtraStackFrame(l)}else rt.setExtraStackFrame(null)}function on(e,o,l,b,C){{var M=Function.call.bind(ue);for(var h in e)if(M(e,h)){var V=void 0;try{if(typeof e[h]!="function"){var G=Error((b||"React class")+": "+l+" type `"+h+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[h]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw G.name="Invariant Violation",G}V=e[h](o,h,b,l,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(T){V=T}V&&!(V instanceof Error)&&(be(C),S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",b||"React class",l,h,typeof V),be(null)),V instanceof Error&&!(V.message in nt)&&(nt[V.message]=!0,be(C),S("Failed %s type: %s",l,V.message),be(null))}}}var sn=Array.isArray;function Me(e){return sn(e)}function un(e){{var o=typeof Symbol=="function"&&Symbol.toStringTag,l=o&&e[Symbol.toStringTag]||e.constructor.name||"Object";return l}}function ln(e){try{return at(e),!1}catch{return!0}}function at(e){return""+e}function ot(e){if(ln(e))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",un(e)),at(e)}var le=D.ReactCurrentOwner,cn={key:!0,ref:!0,__self:!0,__source:!0},st,it,we;we={};function fn(e){if(ue.call(e,"ref")){var o=Object.getOwnPropertyDescriptor(e,"ref").get;if(o&&o.isReactWarning)return!1}return e.ref!==void 0}function dn(e){if(ue.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function pn(e,o){if(typeof e.ref=="string"&&le.current&&o&&le.current.stateNode!==o){var l=L(le.current.type);we[l]||(S('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',L(le.current.type),e.ref),we[l]=!0)}}function vn(e,o){{var l=function(){st||(st=!0,S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};l.isReactWarning=!0,Object.defineProperty(e,"key",{get:l,configurable:!0})}}function yn(e,o){{var l=function(){it||(it=!0,S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};l.isReactWarning=!0,Object.defineProperty(e,"ref",{get:l,configurable:!0})}}var bn=function(e,o,l,b,C,M,h){var V={$$typeof:n,type:e,key:o,ref:l,props:h,_owner:M};return V._store={},Object.defineProperty(V._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(V,"_self",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.defineProperty(V,"_source",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.freeze&&(Object.freeze(V.props),Object.freeze(V)),V};function mn(e,o,l,b,C){{var M,h={},V=null,G=null;l!==void 0&&(ot(l),V=""+l),dn(o)&&(ot(o.key),V=""+o.key),fn(o)&&(G=o.ref,pn(o,C));for(M in o)ue.call(o,M)&&!cn.hasOwnProperty(M)&&(h[M]=o[M]);if(e&&e.defaultProps){var T=e.defaultProps;for(M in T)h[M]===void 0&&(h[M]=T[M])}if(V||G){var O=typeof e=="function"?e.displayName||e.name||"Unknown":e;V&&vn(h,O),G&&yn(h,O)}return bn(e,V,G,C,b,le.current,h)}}var Ae=D.ReactCurrentOwner,ut=D.ReactDebugCurrentFrame;function $(e){if(e){var o=e._owner,l=ye(e.type,e._source,o?o.type:null);ut.setExtraStackFrame(l)}else ut.setExtraStackFrame(null)}var Le;Le=!1;function Te(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function lt(){{if(Ae.current){var e=L(Ae.current.type);if(e)return`

Check the render method of \``+e+"`."}return""}}function En(e){{if(e!==void 0){var o=e.fileName.replace(/^.*[\\\/]/,""),l=e.lineNumber;return`

Check your code at `+o+":"+l+"."}return""}}var ct={};function gn(e){{var o=lt();if(!o){var l=typeof e=="string"?e:e.displayName||e.name;l&&(o=`

Check the top-level render call using <`+l+">.")}return o}}function ft(e,o){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var l=gn(o);if(ct[l])return;ct[l]=!0;var b="";e&&e._owner&&e._owner!==Ae.current&&(b=" It was passed a child from "+L(e._owner.type)+"."),$(e),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',l,b),$(null)}}function dt(e,o){{if(typeof e!="object")return;if(Me(e))for(var l=0;l<e.length;l++){var b=e[l];Te(b)&&ft(b,o)}else if(Te(e))e._store&&(e._store.validated=!0);else if(e){var C=j(e);if(typeof C=="function"&&C!==e.entries)for(var M=C.call(e),h;!(h=M.next()).done;)Te(h.value)&&ft(h.value,o)}}}function Vn(e){{var o=e.type;if(o==null||typeof o=="string")return;var l;if(typeof o=="function")l=o.propTypes;else if(typeof o=="object"&&(o.$$typeof===c||o.$$typeof===E))l=o.propTypes;else return;if(l){var b=L(o);on(l,e.props,"prop",b,e)}else if(o.PropTypes!==void 0&&!Le){Le=!0;var C=L(o);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",C||"Unknown")}typeof o.getDefaultProps=="function"&&!o.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Rn(e){{for(var o=Object.keys(e.props),l=0;l<o.length;l++){var b=o[l];if(b!=="children"&&b!=="key"){$(e),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),$(null);break}}e.ref!==null&&($(e),S("Invalid attribute `ref` supplied to `React.Fragment`."),$(null))}}var pt={};function vt(e,o,l,b,C,M){{var h=A(e);if(!h){var V="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(V+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var G=En(C);G?V+=G:V+=lt();var T;e===null?T="null":Me(e)?T="array":e!==void 0&&e.$$typeof===n?(T="<"+(L(e.type)||"Unknown")+" />",V=" Did you accidentally export a JSX literal instead of a component?"):T=typeof e,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",T,V)}var O=mn(e,o,l,C,M);if(O==null)return O;if(h){var B=o.children;if(B!==void 0)if(b)if(Me(B)){for(var ee=0;ee<B.length;ee++)dt(B[ee],e);Object.freeze&&Object.freeze(B)}else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else dt(B,e)}if(ue.call(o,"key")){var q=L(e),N=Object.keys(o).filter(function(Mn){return Mn!=="key"}),Oe=N.length>0?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}";if(!pt[q+Oe]){var Pn=N.length>0?"{"+N.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX:
  let props = %s;
  <%s {...props} />
React keys must be passed directly to JSX without using spread:
  let props = %s;
  <%s key={someKey} {...props} />`,Oe,q,Pn,q),pt[q+Oe]=!0}}return e===r?Rn(O):Vn(O),O}}function hn(e,o,l){return vt(e,o,l,!0)}function Cn(e,o,l){return vt(e,o,l,!1)}var _n=Cn,Sn=hn;ne.Fragment=r,ne.jsx=_n,ne.jsxs=Sn}()),ne}process.env.NODE_ENV==="production"?Ee.exports=yt():Ee.exports=bt();var re=Ee.exports;const ce=s.createContext({});function mt({children:t}){return re.jsx(ce.Provider,{value:{},children:t})}const P=s.createContext({state:new m.LazyActive({editorMap:{},elementMap:{}}),globalVariable:new m.LazyActive({}),globalClassName:new m.LazyActive({}),globalStyleVarGroups:new m.LazyActive([]),variableStore:new m.LazyActive({}),variableDefine:new m.LazyActive({}),elements:new m.LazyActive({}),eventFlow:new m.LazyActive({}),eventDefine:new m.LazyActive({}),env:{isPreviewing:!1}}),Q="componentVariable",ae="componentEvent",z="slotVariable",oe="globalVariable",X=[Q],fe=[ae],ge=[z],se=[oe];function Ve(){return{padding:[{value:8,unit:"px"},{value:8,unit:"px"},{value:8,unit:"px"},{value:8,unit:"px"}],boxSizing:"border-box"}}function je(){return{id:m.generateId("style_var_group"),alias:"默认",vars:{},active:!0}}function Et(t){return!!t.elements}function Re(t,n,a){const r=t.editorMap[a];if(r)return r.type!=="slot"?!1:r.elementId===n?!0:Re(t,n,r.elementId);const u=t.elementMap[a];return u?u.editorId===n?!0:Re(t,n,u.editorId):!1}function xe(t){return t.type==="ref"}function gt(t,n){if(!t)return;let a=n;for(const r of t)a=a==null?void 0:a[r];return a}function J(t,n){if(t.type==="object"){const a={};for(const r in t.prototype)a[r]=J(t.prototype[r],r);return{...t,apiName:n,prototype:a}}return t.type==="array"?{...t,apiName:n,item:J(t.item,void 0)}:{...t,apiName:n}}async function Ie(t,n,a){const r={type:"object",label:"全局变量",apiName:oe,prototype:{}};for(const p in a)r.prototype[p]=a[p].define;const u={type:"object",label:"组件变量",apiName:Q,prototype:{}},i={type:"object",label:"插槽变量",apiName:z,prototype:{}},f={[Q]:u,[z]:i};Object.keys(r.prototype).length>0&&(f[oe]=r);const y={type:"path",label:"组件方法",children:{}},c={[ae]:y};for(const p in t.editorMap){const d=t.editorMap[p];d.type==="modal"&&(u.prototype[p]=ht(p,d.alias),y.children[p]=Ct(p,d.alias))}for(const p in t.elementMap){const d=await Vt(t,n,p,f);d&&(Object.keys(d.elementVariableDefine.prototype).length>0&&(u.prototype[p]=d.elementVariableDefine),i.prototype={...i.prototype,...d.slotVariableMap});const E=await Rt(t,n,p,f);E&&(y.children[p]=E)}return Object.keys(u.prototype).length===0&&delete f[Q],Object.keys(i.prototype).length===0&&delete f[z],Object.keys(y.children).length===0&&delete c[ae],{variableDefine:f,eventDefine:c}}async function Vt(t,n,a,r){var E,_,g;const u=t.elementMap[a],i=n[u==null?void 0:u.type];if(!i)return;const f={};for(const R in i.attr){const w=(E=u.props)==null?void 0:E[R];f[R]=w}const y={type:"object",label:u.alias||i.label,apiName:a,prototype:{}},c=R=>de(t,n,r,a,R,[]),p=((_=i.export)==null?void 0:_.attr)||{};for(const R in p){const w=p[R];if(typeof w=="function"){const j=await w(f,c);j&&(y.prototype[R]=J(j,R))}else y.prototype[R]=J(w,R)}const d={};for(const R in u.slotMap){const w=u.slotMap[R],j={type:"object",label:`${t.editorMap[w].alias}(${u.alias||i.label})`,apiName:w,prototype:{}},D=(g=i.slot)==null?void 0:g[R];if(D!=null&&D.payload){for(const S in D.payload){const x=D.payload[S];if(typeof x=="function"){const W=await x(f,c);W&&(j.prototype[S]=J(W,S))}else j.prototype[S]=J(x,S)}Object.keys(j.prototype).length>0&&(d[w]=j)}}return{elementVariableDefine:y,slotVariableMap:d}}async function Rt(t,n,a,r){var y;const u=t.elementMap[a],i=n[u==null?void 0:u.type];if(!i)return;const f={};for(const c in(y=i.export)==null?void 0:y.event){const p=i.export.event[c],d=await Fe(a,p,t,n,r);f[c]={...d,type:"event"}}if(Object.keys(f).length!==0)return{type:"path",label:u.alias||i.label,children:f}}async function Fe(t,n,a,r,u){const i=[];let f;const y=c=>de(a,r,u,t,c,[]);if(n.params)for(const c of n.params)if(typeof c=="function"){const p=await c(a.elementMap[t].props,y);if(!p){i.length=0;break}i.push(J(p,""))}else i.push(J(c,""));return typeof n.return=="function"&&(n.return=await n.return(a.elementMap[t].props,y)),n.return&&(f=J(n.return,"")),{label:n.label,params:i,return:f}}async function de(t,n,a,r,u,i){var _,g,R,w,j,D,S;if(i.some(x=>x.id===r&&x.key===u)){console.error("计算属性值错误：存在循环依赖");return}const f=[...i,{id:r,key:u}],y=t.elementMap[r];if(!y)return;const c=n[y.type];if(!c)return;const p=(_=c.attr)==null?void 0:_[u];if(!p)return;if(!xe(p))return p;const d=(g=y.props)==null?void 0:g[u];if(!d)return;const E=await me.getVariableByPath(d,a);if(E)return E;if(d[0]===Q){const x=d[1],W=d[2],H=d.slice(3),I=t.elementMap[x];if(!I)return;const F=n[I.type];if(!F)return;const Y=(w=(R=F.export)==null?void 0:R.attr)==null?void 0:w[W];if(!Y)return;const K=k=>de(t,n,a,x,k,f),A=typeof Y=="function"?await Y(I.props,K):Y;return A?H.length===0?A:A.type!=="object"?void 0:await me.getVariableByPath(H,A.prototype):void 0}if(d[0]===z){const x=d[1],W=d[2],H=d.slice(3),I=t.editorMap[x];if(!I||I.type!=="slot")return;const F=t.elementMap[I.elementId];if(!y)return;const Y=n[F.type];if(!Y)return;let K;for(const L in F.slotMap)F.slotMap[L]===x&&(K=L);if(!K)return;const A=(S=(D=(j=Y.slot)==null?void 0:j[K])==null?void 0:D.payload)==null?void 0:S[W];if(!A)return;const k=L=>de(t,n,a,I.elementId,L,f),U=typeof A=="function"?await A(F.props,k):A;return U?H.length===0?U:U.type!=="object"?void 0:await me.getVariableByPath(H,U.prototype):void 0}}function ht(t,n){return{type:"object",label:n||"弹窗",apiName:t,prototype:{visible:{type:"boolean",label:"是否打开",apiName:"visible"}}}}function Ct(t,n){return{type:"path",label:n||"弹窗",children:{open:{type:"event",label:"打开"},close:{type:"event",label:"关闭"}}}}function Ge(t,n,a){return t.some(r=>{if(r[0]==="elementMap"&&r.length>2&&r[2]==="alias")return!0;if(r[0]==="elementMap"&&r.length>2&&r[2]==="props"){const u=r[1],i=n.elementMap[u],f=a[i==null?void 0:i.type];if(!f)return!1;for(const y in f.attr){const c=f.attr[y];if((c==null?void 0:c.type)==="ref")return!0}}return r.length<=2})}function _t(t){const n=t.variableStore.getValue(fe);function a(i,f){t.state.getValue().editorMap[i].type==="modal"&&t.variableStore.updateValueByPath([...X,i,"visible"],f)}const r={},{editorMap:u}=t.state.getValue();for(const i in u)u[i].type==="modal"&&(r[i]={open:()=>a(i,!0),close:()=>a(i,!1)});return{[ae]:{...n,...r}}}function Ne(t,n){var u;const a=t.getValue(ge),r={};for(const i in n){const f=n[i];r[i]=(u=a==null?void 0:a[i])==null?void 0:u[f]}return{[Q]:t.getValue(X),[z]:r,[oe]:t.getValue(se)}}function St({children:t,state:n,elements:a,env:r,globalVariable:u,globalClassName:i,globalStyleVarGroups:f,eventFlow:y,fetchElementByType:c,getModalContainer:p,onChange:d}){const E=s.useRef(new m.LazyActive(n||{elementMap:{},editorMap:{[m.generateId("root")]:{type:"root",alias:"页面",elements:[],style:Ve()}}})),_=s.useRef(new m.LazyActive(a||{})),g=s.useRef(new m.LazyActive(u||{})),R=s.useRef(new m.LazyActive(i||{})),w=s.useRef(new m.LazyActive(f||[je()])),j=s.useRef(new m.LazyActive(y||{})),D=s.useRef(new m.LazyActive({})),S=s.useRef(new m.LazyActive({})),x=s.useRef(new m.LazyActive({})),[W,H]=s.useState(r||{isPreviewing:!1});s.useEffect(()=>{n&&E.current.updateValue(n)},[n]),s.useEffect(()=>{a&&_.current.updateValue(a)},[a]),s.useEffect(()=>{r&&H(r)},[r]),s.useEffect(()=>{u&&g.current.updateValue(u)},[u]),s.useEffect(()=>{i&&R.current.updateValue(i)},[i]),s.useEffect(()=>{f&&w.current.updateValue(f)},[f]),s.useEffect(()=>{y&&j.current.updateValue(y)},[y]),s.useEffect(()=>{const A={};for(const k in u)A[k]=u[k].defaultValue;D.current.updateValueByPath(se,JSON.parse(JSON.stringify(A)))},[u]);const I=s.useCallback(async()=>{const{variableDefine:A,eventDefine:k}=await Ie(E.current.getValue(),_.current.getValue(),g.current.getValue());x.current.updateValue(k),S.current.updateValue(A)},[]);s.useEffect(()=>{I();const A=E.current.addChangeListener(L=>{Ge(L,E.current.getValue(),_.current.getValue())&&I()}),k=_.current.addChangeListener(L=>{I()}),U=g.current.addChangeListener(L=>{I()});return()=>{A(),k(),U()}},[]);const F=m.useEffectCallback(()=>{d&&d({state:E.current.getValue(),globalVariable:g.current.getValue(),globalClassName:R.current.getValue(),globalStyleVarGroups:w.current.getValue(),eventFlow:j.current.getValue()})},[d]),Y=m.useEffectCallback(async A=>{if(!c)return;const k=await c(A);return k&&_.current.updateValueByPath([A],k),k},[c]);s.useEffect(()=>{const A=E.current.addChangeListener(F),k=g.current.addChangeListener(F),U=R.current.addChangeListener(F),L=w.current.addChangeListener(F),Z=j.current.addChangeListener(F);return()=>{A(),k(),U(),L(),Z()}},[]);const K=s.useMemo(()=>({state:E.current,elements:_.current,env:W,globalVariable:g.current,globalClassName:R.current,globalStyleVarGroups:w.current,variableStore:D.current,variableDefine:S.current,eventFlow:j.current,eventDefine:x.current,fetchElementByType:Y,getModalContainer:p}),[W,p]);return re.jsx(P.Provider,{value:K,children:re.jsx(mt,{children:t})})}function Pt(){const{state:t}=s.useContext(P),[n,a,r]=m.useRefState(Be(t.getValue()));return s.useEffect(()=>t.addChangeListener(u=>{const i=Be(t.getValue(),a.current);i!==a.current&&r(i)}),[]),n}function Be(t,n){var a;if(n&&((a=t.editorMap[n])==null?void 0:a.type)==="root")return n;for(const r in t.editorMap)if(t.editorMap[r].type==="root")return r}function Mt(t){const n=s.useContext(P);return s.useCallback((...r)=>{n[t].updateValue(...r)},[t])}function wt(t,n){const{state:a}=s.useContext(P),r=s.useMemo(()=>[t==="editor"?"editorMap":"elementMap",n],[t,n]);return m.useLazyActive(a,r,!0)}function At(){const{state:t}=s.useContext(P),n=s.useMemo(()=>[],[]);return m.useLazyActive(t,n,!0)}function Lt(){const{state:t}=s.useContext(P);return s.useCallback(a=>{t.updateValue(r=>{const u={...t.getValue().editorMap},i={...t.getValue().elementMap};ze(u,i,a),r.editorMap=u,r.elementMap=i})},[])}function ze(t,n,a){const r=n[a];if(!r)return;delete n[a];const u=t[r.editorId];u&&(u.elements=u.elements.filter(i=>i!==a));for(const i in r.slotMap)We(t,n,r.slotMap[i])}function We(t,n,a){const r=t[a];!r||r.type==="root"||(delete t[a],r.elements.map(u=>ze(t,n,u)))}function Tt(){const{state:t}=s.useContext(P);return s.useCallback(a=>{t.updateValue(r=>{We(r.editorMap,r.elementMap,a)})},[])}function Ot(){const{state:t,variableStore:n}=s.useContext(P);return s.useCallback((r,u)=>{const i=t.getValue().editorMap[r];(i==null?void 0:i.type)==="modal"&&n.updateValueByPath([...X,r,"visible"],u)},[])}function Dt(){return s.useContext(P)}function kt(t){const{elements:n,fetchElementByType:a}=s.useContext(P);s.useEffect(()=>{n.getValue([t])||a==null||a(t)},[t]);const r=s.useMemo(()=>[t],[t]);return m.useLazyActive(n,r,!0)}function jt(){const{state:t,elements:n,fetchElementByType:a}=s.useContext(P);return s.useCallback(async(u,i,f)=>{const y=n.getValue();return new Promise(c=>{t.updateValue(async p=>{const d=await Ye(p,y,u,i,void 0,a),E=p.editorMap[i],_=[...t.getValue(["editorMap",i,"elements"])];if(!f)_.push(d);else{const g=_.findIndex(R=>R===f);if(g===-1){c();return}_.splice(g,0,d)}E.elements=_,c(d)})})},[])}async function Ye(t,n,a,r,u,i){var E,_;let f=n[a];if(!f&&i){const g=await i(a);g&&(f=g)}if(!f)throw new Error(`未找到type: ${a}的组件`);const y=m.generateId("element"),c={};for(const g in f.slot){const R=f.slot[g],w=m.generateId("slot");t.editorMap[w]={type:"slot",alias:R.label,elementId:y,elements:[],style:R.defaultStyle||Ve()},c[g]=w}const p={...f.defaultAttr};for(const g in f.style){const R=(E=f.style[g])==null?void 0:E.defaultValue;R&&(p[g]=JSON.parse(JSON.stringify(R)))}const d={type:a,editorId:r,alias:f.label,slotMap:c,props:{...p,...u}};return await((_=f.onCreate)==null?void 0:_.call(f,{currentElement:d,getEditorById:g=>t.editorMap[g],getElementById:g=>t.elementMap[g],createElement:(g,R,w)=>Ye(t,n,g,R,w,i)})),t.elementMap[y]=d,y}function xt(){const{state:t,variableStore:n}=s.useContext(P),[a,r]=s.useState(he(t.getValue(),n));return s.useEffect(()=>{const u=n.addChangeListener(f=>{f.some(c=>{if(m.isPrefixPath(c,X))return!0;if(!m.isPrefixPath(X,c))return!1;const p=c.slice(X.length);if(p.length===0)return!1;const d=t.getValue(["editorMap",p[0]]);return(d==null?void 0:d.type)!=="modal"?!1:p[1]==="visible"})&&r(he(t.getValue(),n))}),i=t.addChangeListener(()=>{r(he(t.getValue(),n))});return()=>{u(),i()}},[]),a}function he(t,n){const a=[];for(const r in t.editorMap){const u=t.editorMap[r];u.type==="modal"&&n.getValue([...X,r,"visible"])&&a.push({id:r,modal:u})}return a}function It(){const{state:t}=s.useContext(P);return s.useCallback(()=>new Promise(a=>{t.updateValue(r=>{const u={type:"modal",elements:[],header:"弹窗",alias:"弹窗"},i=m.generateId("modal");a(i),r.editorMap[i]=u})}),[])}function Ft(){const{globalVariable:t,variableStore:n}=s.useContext(P);return s.useCallback((r,u)=>{const i=m.generateId("global_variable");t.updateValue(f=>{f[i]={define:r,defaultValue:u}}),n.updateValueByPath([...se,i],u)},[])}function Gt(){const{globalVariable:t,variableStore:n}=s.useContext(P);return s.useCallback((r,u,i)=>{t.updateValue(f=>{f[r]={define:u,defaultValue:i}}),n.updateValueByPath([...se,r],i)},[])}function Nt(){const{globalVariable:t}=s.useContext(P),n=s.useMemo(()=>[],[]);return m.useLazyActive(t,n,!0)}function Bt({id:t,payload:n,children:a}){const r=s.useContext(ce),u=s.useRef(m.generateId("slot_key")),{variableStore:i}=s.useContext(P),f=s.useMemo(()=>({...r,[t]:u.current}),[r,n,t]);return s.useEffect(()=>{i.updateValueByPath([...ge,t,u.current],n)},[n,t]),re.jsx(ce.Provider,{value:f,children:a})}function Ce(){return s.useContext(ce)}function zt(){const{variableDefine:t}=s.useContext(P),[n,a]=s.useState({}),r=s.useRef(!1),u=Ce(),i=s.useCallback(async()=>{var d;const f=t.getValue(),y={...f},c={...f[z]},p={};for(const E in u)(d=c.prototype)!=null&&d[E]&&(p[E]=c.prototype[E]);Object.keys(p).length>0?(c.prototype=p,y[z]=c):delete y[z],a(y),r.current=!0},[u]);return s.useEffect(()=>(i(),t.addChangeListener(y=>{i()})),[i]),{variableDefine:n,initComplete:r.current}}function Wt(){const{state:t,variableStore:n}=s.useContext(P),[a,r]=s.useState({}),u=s.useRef([]),i=Ce(),f=s.useCallback((p=[])=>{u.current.push(p)},[]),y=s.useCallback(()=>{u.current=[]},[]),c=m.useEffectCallback(()=>{r(Ne(n,i))},[t,i,n]);return s.useEffect(()=>(c(),n.addChangeListener(d=>{u.current.some(_=>d.some(g=>Yt(g,_)))&&c()})),[n]),s.useEffect(()=>{y()},[a]),{variableValue:a,addDependent:f,clearDependent:y}}function Yt(t,n){const a=[...t];if(a[0]===z&&a.splice(2,1),a.length>n.length)return!1;for(let r=0;r<a.length;r++)if(a[r]!==n[r])return!1;return!0}function Ut(){const{env:t}=s.useContext(P);return t}function Xt(){const{getModalContainer:t}=s.useContext(P);return t}function Jt(){const{globalClassName:t}=s.useContext(P),n=s.useMemo(()=>[],[]);return m.useLazyActive(t,n,!0)}function Kt(){const{globalStyleVarGroups:t}=s.useContext(P),[n,a]=s.useState(Ue(t.getValue()));return s.useEffect(()=>t.addChangeListener(r=>{a(Ue(t.getValue()))}),[]),n}function Ue(t){return t.find(n=>n.active)}function Ht(){const{globalStyleVarGroups:t}=s.useContext(P),n=s.useMemo(()=>[],[]);return m.useLazyActive(t,n,!0)}function Zt(t){const{eventFlow:n}=s.useContext(P),a=s.useMemo(()=>t?[t]:[],[t]);return m.useLazyActive(n,a,!0)}function Qt(){const{eventDefine:t}=s.useContext(P),n=s.useMemo(()=>[],[]);return m.useLazyActive(t,n,!0)}const Xe=s.createContext({id:"",exportAttr:()=>{},exportEvent:()=>{},updateProps:()=>{}});function qt({id:t,children:n}){const{variableStore:a,state:r}=s.useContext(P),u=m.useEffectCallback((c,p)=>{typeof c=="object"?a.updateValueByPath([...X,t],c):a.updateValueByPath([...X,t,c],p)},[t,a]),i=m.useEffectCallback((c,p)=>{typeof c=="object"?a.updateValueByPath([...fe,t],c):a.updateValueByPath([...fe,t,c],p)},[t,a]),f=m.useEffectCallback((c,p)=>{r.updateValue(d=>{const E=d.elementMap[t];E&&(E.props=typeof c=="object"?c:{...r.getValue(["elementMap",t,"props"]),[c]:p})})},[t]),y=s.useMemo(()=>({id:t,exportAttr:u,exportEvent:i,updateProps:f}),[t]);return re.jsx(Xe.Provider,{value:y,children:n})}function $t(){return s.useContext(Xe)}v.COMPONENT_EVENT=ae,v.COMPONENT_EXPORT_EVENT_PREFIX=fe,v.COMPONENT_EXPORT_VARIABLE_PREFIX=X,v.COMPONENT_VARIABLE=Q,v.ElementProvider=qt,v.GLOBAL_VARIABLE=oe,v.GLOBAL_VARIABLE_PREFIX=se,v.SLOT_VARIABLE=z,v.SLOT_VARIABLE_PREFIX=ge,v.SlotProvider=Bt,v.StoreProvider=St,v.computedDefine=Ie,v.fillVariableApiName=J,v.getDefaultGlobalStyleVarGroup=je,v.getEditorStyleDefaultValue=Ve,v.getElementVariable=Ne,v.getMethodFromStore=_t,v.getValueByPath=gt,v.isEditor=Et,v.isOffspring=Re,v.isRefVariableDefine=xe,v.needRecomputedDefineWhenUpdateState=Ge,v.parseEvent=Fe,v.useActiveGlobalStyleVarGroup=Kt,v.useAddGlobalVariable=Ft,v.useChangeModalVisible=Ot,v.useElement=kt,v.useElementContext=$t,v.useEnv=Ut,v.useEventDefine=Qt,v.useEventFlow=Zt,v.useGetModalContainer=Xt,v.useGlobalClassName=Jt,v.useGlobalStyleVarGroup=Ht,v.useGlobalVariable=Nt,v.useInsertElement=jt,v.useInsertModal=It,v.useRemoveElement=Lt,v.useRemoveModal=Tt,v.useRootId=Pt,v.useSlotContext=Ce,v.useStateById=wt,v.useStateValue=At,v.useStore=Dt,v.useUpdateGlobalVariable=Gt,v.useUpdateStore=Mt,v.useVariableDefine=zt,v.useVariableValue=Wt,v.useVisibleModals=xt,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
