@joker.front/core 1.3.75 → 1.3.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -94,100 +94,3 @@ A front-end framework with built-in visual tools: [Low-code Platform](https://lo
94
94
  ## Wechat
95
95
 
96
96
  ![Wechat](https://static.jokers.pub/lowcode/wechat-group.jpg)
97
-
98
- # Joker
99
-
100
- Joker 是一个旨在为所有开发场景提供支持的框架平台。其中,Joker.front 是 Joker 平台下的前端开发框架,它提供标准化的前端开发标准,采用面向对象、组件化的编程模型,助力您高效开发用户界面。无论是简单还是复杂的界面,Joker.front 都能轻松应对。
101
-
102
- ## 什么是 Joker?
103
-
104
- Joker 是一个致力于为所有开发场景提供支持的框架平台。其中,Joker.front 作为 Joker 平台的一部分,是一个前端开发框架。它提供标准化的前端开发规范,并运用面向对象和组件化的编程方式来协助高效构建用户界面。不管界面是简单还是复杂,Joker.front 都能顺利处理。
105
-
106
- Joker 是一个基于 TypeScript 构建的全能开发平台。无论是应对简单的界面开发需求,还是处理复杂的用户界面任务,它都展现出卓越的性能与稳定性。它具备以下重要特性:
107
-
108
- - **强大的可扩展性**:Joker 提供基于组件的框架。其在设计之初就考虑到了扩展性,因此能够轻松集成到现有项目或系统中,支持构建可伸缩的 Web 应用,可根据项目需求进行定制化开发。
109
- - **丰富的组件库**:Joker.front 提供了一套完备的前端组件库,包括路由、脚手架等经过精心设计与优化的功能和 UI 组件,能够帮助开发者快速构建出美观且高性能的用户界面。
110
- - **完善的开发工具**:为进一步提升开发效率,Joker 还提供了一系列配套的开发工具,包括调试工具、构建工具等。这些精心设计的工具旨在让开发流程更加顺畅,助力开发者准确快速地开发、构建、测试以及更新代码。
111
- - **Class API**:Joker 以 TypeScript 作为脚本开发标准,并采用标准的 Class API 作为开发规范,更契合面向对象开发的要求。
112
- - **响应性**:Joker 会自动追踪 JavaScript 状态,当其发生变化时能即时响应式地更新 DOM,且不存在虚拟 DOM 的差异对比。
113
-
114
- ## 性能
115
-
116
- Joker 采用的特殊的渲染逻辑,实现了响应式数据于 DOM 的关联关系收集,并允许在数据变更时实现点对点的节点变更,而避免了对整个虚拟节点的重绘和二叉树的对比过程,极大的实现了渲染性能。
117
-
118
- ![](https://gitee.com/joker_pub/joker-front-core/raw/main/readme/render.png)
119
-
120
- ![](https://gitee.com/joker_pub/joker-front-core/raw/main/readme/ast-element.png)
121
-
122
- [详细说明](https://front.jokers.pub/base/render)
123
-
124
- ## 如何使用
125
-
126
- 您可以使用 Joker CLI 来创建项目、生成应用和库代码,以及执行各类持续开发任务,如测试、打包和部署。
127
-
128
- [帮助文档](https://front.jokers.pub)
129
-
130
- 要安装 Joker CLI,请打开终端/控制台窗口,并运行如下命令:
131
-
132
- ```
133
- pnpm i -g @joker.front/cli
134
- ```
135
-
136
- 1. 运行 CLI 命令 **joker create** 并提供 my-app 名称作为参数,如下所示:
137
-
138
- ```
139
- joker create my-app
140
- ```
141
-
142
- 2. 在 my-app 工作目录下,安装依赖项。
143
-
144
- ```
145
- cd my-app
146
-
147
- pnpm i
148
- ```
149
-
150
- CLI 将创建一个新的工作区以及一个简单的欢迎应用,您可以随时运行它。
151
-
152
- ## 运行应用
153
-
154
- Joker CLI 包含一个服务器命令以及一个构建命令,服务器命令便于您在本地构建并提供应用服务。
155
-
156
- 我们默认提供了`dev`和`build`两个命令,分别代表开发环境和代码构建。
157
-
158
- 1. 导航至工作区文件夹,比如 my-app。
159
-
160
- ```
161
- cd my-app
162
- ```
163
-
164
- 2. 运行以下命令:
165
-
166
- ```
167
- npm run dev
168
- ```
169
-
170
- 成功运行后,将会显示一个简单的示例页面。
171
-
172
- ## 可视化开发工具
173
-
174
- 一个自带可视化工具的前端框架:[低代码平台](https://lowcode.jokers.pub)
175
-
176
- ![Joker Platform](https://gitee.com/joker_pub/joker-front-core/raw/main/readme/img4.png)
177
- ![Joker Platform](https://gitee.com/joker_pub/joker-front-core/raw/main/readme/img2.png)
178
- ![Joker Platform](https://gitee.com/joker_pub/joker-front-core/raw/main/readme/img1.jpg)
179
- ![Joker Platform](https://gitee.com/joker_pub/joker-front-core/raw/main/readme/img3.jpg)
180
-
181
- ## 文档
182
-
183
- [帮助文档](https://front.jokers.pub)
184
-
185
- [官网](https://front.jokers.pub)
186
-
187
- [官方 UI 库](https://ui.jokers.pub)
188
-
189
- [低代码平台](https://jokers.pub)
190
-
191
- ## Wechat
192
-
193
- ![Wechat](https://static.jokers.pub/lowcode/wechat-group.jpg)
package/dist/bundle.es.js CHANGED
@@ -1 +1 @@
1
- import{EXPRESSHANDLERTAG as e,createFuntionBody as t,AST as i,RENDER_HANDLER as s,createComponent as n,createCommand as r}from"@joker.front/ast";export{AST,EXPRESSHANDLERTAG,RENDER_HANDLER,createCodeFunction,createCommand,createComment,createComponent,createElement,createFuntionBody,createText}from"@joker.front/ast";const o=new Map,a=new Map,h=new Map;let d={recordRender:(e,t)=>{a.set(e,t)},recordComponent:(e,t)=>{h.set(e,t)},record:(e,t)=>{void 0===o.get(e)&&o.set(e,new Set),o.get(e).add(t),t.$on("destroy",(()=>{o.get(e)?.delete(t)}))},reload:(e,t)=>{let i=h.get(e);if(!i)return;i.component=t;let s=o.get(e);if(!s)return;let n=Array.from(s);s.clear(),n.forEach((e=>{if(e.$root){if(!e.$rootVNode?.parent)return window.onbeforeunload=null,void location.reload();{let t=e.$rootVNode.parent;if(!(t instanceof z.Component&&t[z.PARSERKEY]&&t[z.PARSERKEY].canReload))return window.onbeforeunload=null,void location.reload();t[z.PARSERKEY].reload()}}}))},rerender:(e,t)=>{let i=a.get(e);i&&(i.render=t),o.get(e)?.forEach((e=>{e.$render(t)}))}};function l(e){return null!==e&&"object"==typeof e}function c(e,t){Object.getOwnPropertyNames(e).forEach((i=>{t(i,e[i])}))}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}function f(e){if(null===e)return e;if("object"!=typeof e)return e;let t;t=Array.isArray(e)?[]:{};let i=Object.keys(e);for(let s of i){let i=e[s];t[s]="object"==typeof i?f(i):i}return t}function p(e,t,i){return Array.isArray(e)&&Array.isArray(t)?function(e,t,i){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(i){if(e[s]!==t[s])return!1}else if(!1===m(e[s],t[s],i))return!1;return!0}(e,t,i):m(e,t,i)}function m(e,t,i){if(e===t)return!0;let s=l(e),n=l(t);if(s&&n){if(u(e)&&u(t)){let s=Object.keys(e);if(s.length!==Object.keys(t).length)return!1;if(i){for(let i of s)if(e[i]!==t[i])return!1;return!0}return JSON.stringify(e)===JSON.stringify(t)}return e===t}return!s&&!n&&String(e)===String(t)}function y(e,t){let i=e.indexOf(t);return i>-1&&e.splice(i,1),e}function E(e,t){let i=e.findIndex((e=>t(e)));return i>-1&&e.splice(i,1),e}function v(e){return!e||""===e.trim()}function g(e,t="-"){return(e=e||"").split(/(?=[A-Z])/).map((e=>e.toLowerCase())).join(t)}let b=(...e)=>{},w="warn";const N=["silent","error","warn","info"];function R(){let e=new Date;function t(e,t=2){return e.toString().padStart(t,"0")}return t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+":"+t(e.getMilliseconds(),3)}function $(e,t,i,s){N.indexOf(e)<=N.indexOf(w)&&(void 0===s?console[e](`${R()} [${t}]:`,i):console[e](`${R()} [${t}]:`,i,s))}let A={info:function(e,t,i){$("info",e,t,i)},warn:function(e,t,i){$("warn",e,t,i)},error:function(e,t,i){$("error",e,t,i)},setLoggerLeve:function(e){w=e}};const C={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"',"#39":"'"};function x(e){return e.replace(/&(lt|gt|nbsp|amp|quot|#39);/gi,((e,t)=>C[t]||""))}class O{static target;watchers=new Map;depend(e){O.target?.addDep(this,e)}addWatcher(e,t){let i=this.watchers.get(e)||[];i.push(t),this.watchers.set(e,i)}removeWatcher(e,t){let i=this.watchers.get(e);i&&y(i,t)}notify(e){let t=this.watchers.get(e);if(t){E(t,(e=>e.isDestroy)),[...t].forEach((e=>{!1===e.isDestroy&&e.update()}))}}}const S=Symbol.for("__JOKER_OBJECT_PROXY_DEP_ID__"),P=Symbol.for("__JOKER_OBJECT_PROXY_DATA_KEY__"),D=Symbol.for("__JOKER_OBJECTPROXY_DEPLEVE_ID__");function T(e){try{return null!=e&&l(e)&&e!==window.parent&&e instanceof Window==!1&&e instanceof F==!1&&e instanceof ze==!1&&e instanceof Te==!1&&(Array.isArray(e)||u(e)||e instanceof Set||e instanceof Map)&&!Object.isFrozen(e)&&!(e instanceof Element)&&!(q in e)&&!(I in e)&&!(Fe in e)}catch{return!1}}function k(e){if(K(e))return e;if(e&&e.hasOwnProperty(P)){let t=Reflect.get(e,P);if(t)return t}let t=new O,i=!0,s=new Proxy(e,{get(e,i,s){if(e instanceof Set||e instanceof Map){if("add"===i){let s=Reflect.get(e,i);return i=>{T(i)&&(i=_(i));let n=s.call(e,i);return j(t,"size"),j(t,D),n}}if("set"===i){let s=Reflect.get(e,i);return(i,n)=>{T(n)&&(n=_(n));let r=s.call(e,i,n);return j(t,"size"),j(t,D),r}}if("delete"===i||"clear"===i){let s=Reflect.get(e,i);return n=>{let r=s.call(e,n);return("clear"===i||r)&&(j(t,"size"),j(t,D)),r}}let s=Reflect.get(e,i);if("function"==typeof s)return s.bind(e)}if(i===P)return;if(i===S)return t;if(i===D)return;let n=Reflect.get(e,i);return i===Symbol.toStringTag||!1===function(e,t){return t in e}(e,i)&&"length"!==i&&"size"!==i||(t.depend(i),T(n)&&K(n)?.depend(D)),n},set(e,s,n){if(i)return Reflect.set(e,s,n),!0;T(n)&&(n=_(n));let r=!1===function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,s),o=Reflect.get(e,s)!==n;return Reflect.set(e,s,n),(o||"length"===s&&Array.isArray(e))&&j(t,s),Array.isArray(e)?"length"===s&&j(t,D):r&&j(t,D),!0},deleteProperty:(e,i)=>(Reflect.deleteProperty(e,i),!1===Array.isArray(e)&&j(t,D),!0)});var n,r,o,a;n=e,r=P,o=s,a=!1,Object.defineProperty(n,r,{value:o,enumerable:a,writable:!0,configurable:!0});for(let t in e){let i=e[t];T(i)&&!K(i)&&(s[t]=k(e[t]))}return i=!1,s}function K(e){if(l(e))return Reflect.get(e,S)}function _(e,t=!1){if(!1===T(e))throw new Error("当前传入的数据不是正确的数据类型,必须是数组或者对象");return k(t?f(e):e)}function W(e,t,i){let s=i;T(i)&&(s=_(i));let n=new O;Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:()=>(n.depend(t),K(s)?.depend(D),s),set:e=>{e!==s&&(T(e)&&(e=_(e)),s=e,j(n,t))}})}const I=Symbol.for("JOKER_SHALLOW_OBSERVER");class L{data;[I]=!0;dep=new O;constructor(e){this.data=e}isChanged=!1;get value(){return this.dep.depend(D),this.data}set value(e){!1===Object.is(e,this.data)&&(this.isChanged=!0,this.data=e,j(this.dep,D))}}let V=!1,M=new Map;function j(e,t){if(!1===V)e.notify(t);else{let i=M.get(e);void 0===i&&(i=[],M.set(e,i)),!1===i.includes(t)&&i.push(t)}}function Y(e){V=!0;try{e()}catch(e){return V=!1,M.clear(),void A.error("数据劫持","数据劫持组合回复在做变更采集时,遇到了阻塞错误,不做响应,请检查",e)}V=!1,function(e){let t=[],i=[];e.forEach(((e,i)=>{e.forEach((e=>{t.push(...i.watchers.get(e)||[])}))})),t.forEach((e=>{i.includes(e)||(!1===e.isDestroy&&e.update(),i.push(e))}))}(M),M.clear()}function B(e){return void 0!==K(e)}const H="数据观察",J=Symbol.for("JOKER_BREAK_WATCH_UPDATE");class F{ob;updateCallBack;forceCallBack;getter;value;isDestroy=!1;updating=!1;runRelations=new Map;relations=new Map;constructor(e,t,i,s){if(this.ob=e,this.updateCallBack=t,this.forceCallBack=s,void 0===e)throw new Error("无法对underfind进行变更观察");if(void 0===i)this.getter=e=>e;else if("function"==typeof i)this.getter=i;else{let e=function(e){if(/[^\w.$]/.test(e))return;let t=e.split(".");return function(e){let i=e;return t.forEach((e=>{i&&(i=i[e])})),i}}(i);if(void 0===e)throw new Error(i+"解析失败,无法明确读取表达式,请检查expOrFn参数,或采用function模式");this.getter=e}void 0===this.getter&&A.error(H,"getter创建失败",arguments),this.value=this.getValue()}getValue(){if(void 0===this.getter)return;O.target=this;let e,t="function"==typeof this.ob?this.ob():this.ob;try{e=this.getter.call(t,t)}catch(e){throw A.error(H,`获取值失败,执行方法:${this.getter.toString()}`),e}return O.target=void 0,this.clearnDeps(),e}addDep(e,t){let i=this.runRelations.get(e);if(void 0===i||!1===i.includes(t)){i=i||[],i.push(t),this.runRelations.set(e,i);let s=this.relations.get(e);void 0!==s&&!1!==s.includes(t)||e.addWatcher(t,this)}}update(){if(this.updating)return;let e=this.getValue();if(e===J)return;let t=this.value;if(this.forceCallBack||e!==t||l(e)){this.value=e;let i=e!==t&&p(e,t,!0);if(i&&!this.forceCallBack)return;this.updating=!0;try{this.updateCallBack(e,t,i,this)}catch(e){throw e}finally{this.updating=!1}}}destroy(){this.relations.forEach(((e,t)=>{for(let i of e)t.removeWatcher(i,this)})),this.isDestroy=!0,this.relations.clear(),this.runRelations.clear(),this.ob=void 0,this.value=void 0,this.getter=void 0}clearnDeps(){this.relations.forEach(((e,t)=>{let i=this.runRelations.get(t);for(let s of e)i?!1===i.includes(s)&&t.removeWatcher(s,this):t.removeWatcher(s,this)})),this.relations.clear(),this.relations=this.runRelations,this.runRelations=new Map}}var G;!function(e){let t=new Map;e.bind=function(e){return{to:i=>{if(t.has(e))throw new Error(`TagId:${e.toString()}已注入实现类,请勿重复注入。`);t.set(e,i)}}},e.get=function(e,...i){let s=t.get(e);if(s)return new s(...i)}}(G||(G={}));const q=Symbol.for("JOKER_VNODE_TAG");var z;!function(e){e.PARSERKEY=Symbol.for("JOKER_PARSER_KEY");class t{parent;[q]=!0;static;output;[e.PARSERKEY];childrens;ref;sleep=!1;constructor(e){this.parent=e}get prev(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)-1]}get next(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)+1]}closest(e,t){if(!0===e(this))return this;let i=this.parent;for(;i;){if(!0===e(i))return i;if(!0===t?.(i))break;i=i.parent}}find(e,t,i,s,n){let r=n??[];if(s??=this.childrens,s)for(let n of s){(!0!==e(n)||(r.push(n),i))&&(!0!==t?.(n)&&n.childrens&&this.find(e,t,i,n.childrens,r))}return r}contains(e,t){if(t??=this.childrens,t)for(let i of t){if(!0===e(i))return!0;if(i.childrens&&i.childrens.length&&this.contains(e,i.childrens))return!0}return!1}first(e,t){if(t??=this.childrens,t)for(let i of t){if(!0===e(i))return i;if(i.childrens&&i.childrens.length){let t=this.first(e,i.childrens);if(t)return t}}}}e.Node=t;e.Root=class extends t{childrens=[];component;constructor(){super()}};e.Text=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Html=class extends t{html;notShadow;static=!0;constructor(e,t,i){super(t),this.html=e,this.notShadow=i}};e.Comment=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Element=class extends t{tagName;static=!0;attributes={};childrens=[];events=[];_assistEventCache;constructor(e,t){super(t),this.tagName=e}};e.Component=class extends t{name;component;events=[];propValues={};keepalive;get firstElement(){if(this.childrens){let t=i=>{for(let s of i){if(s instanceof e.Element)return s;if(s.childrens){let e=t(s.childrens);if(e)return e}}};return t(this.childrens)}}get rootElements(){if(this.childrens){let t=[],i=s=>{for(let n of s)n instanceof e.Element||n instanceof e.Html?t.push(n):n.childrens&&i(n.childrens)};return i(this.childrens),t}return[]}};e.Condition=class extends t{cmdName;result=!1;childrens=[];isShow=!1;constructor(e,t){super(t),this.cmdName=e}};e.List=class extends t{childrens=[]};e.ListItem=class extends t{ob;childrens=[];constructor(e,t){super(t),this.ob=e}};e.RenderSection=class extends t{id="unknown";params=[];section;childrens=[];ob;constructor(e,t){super(t),"string"==typeof e?this.id=e:this.section=e}}}(z||(z={}));const Q="DOM渲染",X=["script","style","textarea","pre"];let U=0;const Z=["svg","defs","use","rect","circle","ellipse","line","polyline","polygon","path","text","g"];var ee;function te(e,t,i){return`${e}-${t}-${i}`}function ie(e,t,i,s){e._assistEventCache??=[],e._assistEventCache.push([t,i]),document.body.addEventListener(t,i,s)}function se(e,t,i){e._assistEventCache&&t&&i?(E(e._assistEventCache,(e=>e[0]===t&&e[1]===i)),document.body.removeEventListener(t,i)):(e._assistEventCache?.forEach((e=>{document.body.removeEventListener(e[0],e[1])})),e._assistEventCache&&(e._assistEventCache.length=0),e._assistEventCache=void 0)}!function(e){e.IRENDERIOCTAGID=Symbol.for("JOKER_IRENDERIOC_TAGID"),e.ROOT_CONTAINER="";e.DomRender=class{elements;constructor(){this.elements=document.createDocumentFragment()}mount(e){if(e instanceof Element)e.appendChild(this.elements);else if(e instanceof z.Component)if(e.parent)if(e.output){let t=e.output,i=he(e)||t.parentNode;i&&i.insertBefore(this.elements,t)}else A.error(Q,"组件挂载渲染时发现该节点未定义DOM定位节点",e);else A.error(Q,"mount子组件时,发现该组件无父级",e);else A.error(Q,"mount只支持挂载到Element或VNode.Node类型数据中",e)}appendNode(e,t){if(this.renderNode(e),e.output){let i=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];for(let s of i)this.appendNodeChildren(e,s,e.parent,t)}else A.error(Q,"未找自身节点的el属性,无法进行dom挂载",e)}updateNode(e,t){if(e instanceof z.Element)for(let t in e.attributes){let i=e.attributes[t];this.setAttribute(e.output,t,i)}else e instanceof z.Text?e.parent&&e.parent instanceof z.Element&&X.includes(e.parent.tagName)?(this.removeNode(e),this.appendNode(e)):e.output.textContent=x(e.text||""):e instanceof z.Html?e.notShadow?e.output.innerHTML=e.html:e.output.root.innerHTML=e.html:A.error(Q,`该节点不支持${t}的更新`,e)}removeNode(e,t){let i=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];i?.forEach((e=>{e?.remove()})),t||(e instanceof z.Element&&se(e),e.output=void 0)}destroy(){this.elements=void 0}elementToEnter(e,t,i,s){e.output&&this.transitionFrame(e,t,"enter",i,s)}elementToLeave(e,t,i,s){e.output&&this.transitionFrame(e,t,"leave",i,s)}triggerEvent(e,t,i){let s=[];for(let n of e.events){let[r,o]=n;if(r===t){let t=o.modifiers?.includes("self"),a=o.modifiers?.includes("outside");if(t||a){A.warn(Q,"事件修饰符:self、outside在组件事件中无法使用,组件无法确认元素",e);continue}let h=i.event;if((h instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(r)||h instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(r))&&!1===re(h,o.modifiers))continue;if(o.callBack(i),o.modifiers?.includes("prevent")&&i.preventDefault(),o.modifiers?.includes("once")&&s.push(n),o.modifiers?.includes("stop"))return i.stopPropagation(),!1}}s.length&&s.forEach((t=>{y(e.events,t)}))}transitionFrame(e,t,i,s,n){oe(e,te(t,i,"from")),s||="transition";let r=e.output.__TRANSITION_EVNETID__=U++;requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(!e.output)return;oe(e,te(t,i,"active")),ae(e,te(t,i,"from")),oe(e,te(t,i,"to"));let o=function(e,t){let i=window.getComputedStyle(e),s=e=>(i[e]||"").split(", ");if("transition"===t){let e=s("transitionDelay"),t=s("transitionDuration"),i=de(e,t);if(i>0)return{timeout:i,count:t.length}}else if("animation"===t){let e=s("animationDelay"),t=s("animationDuration"),i=de(e,t);if(i>0)return{timeout:i,count:t.length}}}(e.output,s);if(!o)return void n?.();let a=0,h=()=>{ae(e,te(t,i,"to")),ae(e,te(t,i,"active")),e.output&&(e.output.removeEventListener(`${s}end`,d),r===e.output.__TRANSITION_EVNETID__&&n?.())},d=t=>{t.target===e.output&&++a>=o.count&&h()};setTimeout((()=>{a<o.count&&h()}),o.timeout+1),e.output?.addEventListener(`${s}end`,d)}))}))}renderNode(e){if(!e.output)if(e instanceof z.Text)e.parent&&e.parent instanceof z.Element&&X.includes(e.parent.tagName)?e.output=this.parserHtml(e.text):e.output=document.createTextNode(x(e.text||""));else if(e instanceof z.Html)if(e.notShadow){let t=document.createElement("joker-html-container");t.JOKER_NODE=e,t.innerHTML=e.html,e.output=t}else{let t=document.createElement("joker-html-shadow");t.JOKER_NODE=e,t.style.lineHeight="1",t.root.innerHTML=e.html,e.output=t}else if(e instanceof z.Element){let t,i=e.tagName.toLowerCase();"svg"===i||Z.includes(i)||e.parent?.inSvg?(e.inSvg=!0,t=document.createElementNS("http://www.w3.org/2000/svg",e.tagName)):t=document.createElement(e.tagName);for(let i in e.attributes)this.setAttribute(t,i,e.attributes[i]);t.JOKER_NODE=e,e.output=t,e.events.some((e=>"click"===e[0]&&e[1].modifiers?.includes("outside")))?setTimeout((()=>{this.initElementEvents(t,e)})):this.initElementEvents(t,e)}else e instanceof z.Comment?e.output=document.createComment(e.text):e.output=document.createTextNode("")}initElementEvents(e,t){for(let[i,s]of t.events){let n=s.modifiers?.includes("self"),r=s.modifiers?.includes("outside");n&&r&&(A.warn(Q,"事件修饰符:self、outside不可以同时存在,将按照self处理",t),r=!1);let o,a=function(o){if(!(t.sleep||n&&o.target!==e)){if(r){if(o.target===e||e.contains(o.target))return;if(!1===document.contains(o.target))return;if(t.contains((e=>(e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output]).includes(o.target))))return!0}(o instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(i)||o instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(i))&&!1===re(o,s.modifiers)||(s.callBack({eventName:i,event:o,target:t,preventDefault:()=>o.preventDefault(),stopPropagation:()=>o.stopPropagation(),data:void 0}),s.modifiers?.includes("prevent")&&o.preventDefault(),s.modifiers?.includes("stop")&&o.stopPropagation(),s.modifiers?.includes("once")&&(r?se(t,i,a):e.removeEventListener(i,a)))}};s.modifiers?.includes("passive")&&(o={passive:!0}),r?ie(t,i,a,o):e.addEventListener(i,a,o)}}parserHtml(e){var t=document.createElement("div");return t.innerHTML=e,t.childNodes}isCommandGroup(e){return e instanceof z.Component||e instanceof z.Condition||e instanceof z.List||e instanceof z.ListItem||e instanceof z.RenderSection}appendNodeChildren(e,t,i,s){let n=he(e);if(n)n.appendChild(t);else if(void 0===i)this.elements?.appendChild(t);else if(i)if(i instanceof z.Root){let e=i.parent;if(e&&e instanceof z.Component&&e.output){let i=e.output,s=i?.parentNode;if(s)return void s.insertBefore(t,i)}this.elements?.appendChild(t)}else if(i instanceof z.Element){let e=i.output;if(void 0===e)return;e.appendChild(t)}else if(this.isCommandGroup(i)){let n=i.output?.parentNode;if(void 0!==s&&i.childrens?.length&&n){let r=s-1;if(r<0){let i=ce(e);return void(i&&n.contains(i.output)?i.output.after(t):n.insertBefore(t,n.firstChild))}{let e=i.childrens[r];if(e){let i=e.output;if(i)return void i.after(t)}}}n&&n.insertBefore(t,i.output)}else A.error(Q,"该节点不支持嵌套子集,请检查。",{node:e,parent:i})}setAttribute(e,t,i){if(e)if("boolean"!=typeof i){if("class"===t){if(Array.isArray(i)){let e=[];for(let t of i)if(l(t))for(let i in t)t[i]&&e.push(i);else t&&e.push(t);i=e.join(" ")}else if(l(i)){for(let t in i)t=t.trim(),t&&(i[t]?e.classList.add(t):e.classList.remove(t));return}}else if("style"===t&&l(i)){e.removeAttribute("style");for(let t in i){let s=!1;void 0!==i[t]&&!1!==i[t]||(s=!0);let n=String(i[t]);v(n)&&(s=!0),s||(e.style[t]=n)}return}i=(i??"").toString().trim(),"class"===t&&(i=i.split(/\s/).filter((e=>e.trim())).join(" ")),"value"===t&&"value"in e?e.value=i:"xlink:href"===t?e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",i):e.setAttribute(t,i)}else i?e.setAttribute(t,""):e.removeAttribute(t)}}}(ee||(ee={}));const ne={enter:"enter",backspace:"delete",tab:"tab",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right",escape:"esc"," ":"space"};function re(e,t){if(e instanceof KeyboardEvent){if(void 0===e.key)return!1;for(let i in ne)if(t?.includes(ne[i])&&e.key.toLowerCase()!==i)return!1}else{if(t?.includes("left")&&0!==e.button)return!1;if(t?.includes("right")&&2!==e.button)return!1;if(t?.includes("middle")&&1!==e.button)return!1}return(!t?.includes("ctrl")||!1!==e.ctrlKey)&&((!t?.includes("alt")||!1!==e.altKey)&&(!t?.includes("shift")||!1!==e.shiftKey))}function oe(e,t){e.output&&e.output.classList.add(t)}function ae(e,t){e.output&&e.output.classList.remove(t)}function he(e){if(e instanceof z.Element||e instanceof z.Component){let t=e instanceof z.Component?e.propValues["append-to"]:e.attributes["append-to"];if(t){if(t instanceof z.Element)return t.output;if("string"==typeof t){ee.ROOT_CONTAINER&&(t="body"===t?ee.ROOT_CONTAINER:`${ee.ROOT_CONTAINER} ${t}`);let e=document.querySelector(t);if(e)return e}A.warn(Q,"appendTo类型不支持",{appendTo:t,node:e})}}}function de(e,t){for(;e.length<t.length;)e.concat(e);return Math.max(...t.map(((t,i)=>le(t)+le(e[i]))))}function le(e){return"auto"===e?0:1e3*Number(e.slice(0,-1).replace(",","."))}function ce(e,t){let i=e.prev;for(;i;){if(i instanceof z.ListItem==!1)return i;i=i.prev}if(!t){let t=e.parent;for(;t;){if(t instanceof z.Element)return;let e=ce(t,!0);if(e)return e;t=t.parent}}}class ue extends HTMLElement{root;constructor(){super(),this.root=this.attachShadow({mode:"open"})}}!customElements.get("joker-html-shadow")&&customElements.define("joker-html-shadow",ue);const fe={};function pe(e){for(let t in e)fe[t]=e[t]}const me="Global",ye="渲染核心";function Ee(t){try{return new Function(e,me,`return ${t};`)}catch{throw new Error("创建表达式运行方法时出现未知错误,表达式为"+t)}}class ve{ast;ob;parent;ext;ref="";watchers=[];node;isDestroy=!1;constructor(e,t,i,s){this.ast=e,this.ob=t,this.parent=i,this.ext=s}init(e){this.parser(e),this.afterParser()}beforeDestroy(e){}destroy(e){if(this.isDestroy=!0,this.clearWatchers(),this.parent.childrens&&this.node){(this.node instanceof z.Element||this.node instanceof z.Component)&&this.ext.removeRef(this.node);let t=()=>{this.parent&&this.node&&(this.beforeDestroy(e),this.destroyChildrens(e),this.node&&(this.ext.render?.removeNode(this.node),this.parent.childrens&&y(this.parent.childrens,this.node),this.notifyNodeWatcher("remove"),this.destroyOtherData()))};if(this.ext.nodeTransition(this.node,"leave",void 0,(()=>{t()})))return y(this.parent.childrens,this.node),void this.destroyChildrensWatcher(this.node);t()}else this.destroyOtherData()}destroyWathcers(){this.isDestroy=!0,this.clearWatchers(),this.destroyChildrensWatcher(this.node)}destroyOtherData(){this.node&&(this.node[z.PARSERKEY]=void 0),this.node=void 0,this.parent=void 0}destroyChildrens(e){for(;this.node?.childrens?.length;){let t=this.node.childrens[0];t[z.PARSERKEY]?t[z.PARSERKEY].destroy(e):y(this.node.childrens,t)}}destroyChildrensWatcher(e){if(e?.childrens?.length)for(let t of e?.childrens)t[z.PARSERKEY]&&(t[z.PARSERKEY].clearWatchers(),this.destroyChildrensWatcher(t))}appendNode(e){this.parent?.childrens&&this.node&&!this.isDestroy&&(this.node[z.PARSERKEY]=this,this.node instanceof z.Element&&this.ob[Je]&&(this.node.attributes["data-scoped-"+this.ob[Je]]=void 0),this.ext.render?.appendNode(this.node,e),void 0===e?this.parent.childrens.push(this.node):this.parent.childrens.splice(e,0,this.node),this.notifyNodeWatcher("append"))}afterParser(){this.ext.nodeTransition(this.node,"enter")}notifyNodeWatcher(e,t){this.ext.notifyNodeWatcher(this.ref,this.node,e,t)}runExpress(e,t){try{return Ee(e).call(t,t,fe)}catch(i){A.error(ye,"运行表达式出现错误:"+e,{ob:t}),console.error(i)}}runExpressWithWatcher(e,t,i,s){if(this.isDestroy)return;let n="string"==typeof e?Ee(e):e,r=new F((()=>{if(this.isDestroy||t[Be])return J;try{return n.call(t,t,fe)}catch(i){return A.error(ye,"运行表达式出现错误",{ob:t,express:e,node:this.node}),console.error(i),J}}),i,void 0,s);return this.addWatch(r),r.value===J?void 0:r.value}addWatch(e){!1===this.watchers.includes(e)&&this.watchers.push(e)}clearWatchers(){this.watchers.forEach((e=>{e.destroy()})),this.watchers.length=0}}class ge extends ve{parser(){this.node=new z.Text(this.ast.text,this.parent),this.appendNode()}}class be extends ve{parser(){this.node=new z.Comment(this.ast.text,this.parent),this.appendNode()}}class we extends ve{parser(){if(this.node=new z.Condition(this.ast.kind,this.parent),"else"!==this.ast.kind){v(this.ast.condition)&&A.error("条件命令",`当前条件命令${this.ast.kind}没有判断条件,请检查`);let e=this.runExpressWithWatcher(this.ast.condition,this.ob,(e=>{let t=!!e;if(this.node?.result!==t){if(this.node.result=t,!1===t&&this.node?.isShow)this.destroyChildrens(!0);else if(t&&!this.node?.isShow){let e=this.getElseNode();if(e&&e.isShow&&e.childrens?.length){let t=e[z.PARSERKEY];t&&t instanceof we&&t.renderConditionChildren()}}this.reloadAllCondition()}}));this.node.result=!!e}this.appendNode(),this.renderConditionChildren()}renderId;getElseNode(){let e=this.node?.next;for(;e&&e instanceof z.Condition&&"if"!==e.cmdName;){if("else"===e.cmdName)return e;e=e.next}}renderConditionChildren(){let e=!1;return this.getPrevIfResult()?e=!1:"else"===this.ast.kind?e=!0:(this.node.result=!!this.runExpress(this.ast.condition,this.ob),this.node.result&&(e=!0)),e!==this.node.isShow&&(this.node.isShow=e,this.destroyChildrens(!0),e&&this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob),!0)}getPrevIfResult(){if("if"===this.ast.kind)return!1;let e=this.node?.prev;for(;e&&e instanceof z.Condition;){if(e.result)return!0;if("if"===e.cmdName)break;e=e.prev}return!1}reloadAllCondition(){if(this.renderConditionChildren()){let e=this.node?.next;for(;e&&e instanceof z.Condition&&"if"!==e.cmdName;){let t=e[z.PARSERKEY];t&&t instanceof we&&t.renderConditionChildren(),e=e.next}}let e=this.node?.next;for(this.node?.result||this.destroyChildrens(!0);e&&e instanceof z.Condition&&"if"!==e.cmdName;){let t=e[z.PARSERKEY];t&&t instanceof we&&t.renderConditionChildren(),e=e.next}}}class Ne extends ve{parser(){this.node=new z.List(this.parent),this.appendNode(),this.renderChildrens()}renderChildrens(){switch(this.ast.keyType){case"condition":this.renderConditionChildrens();break;case"in":case"of":this.renderInOrOfChildrens()}}renderConditionChildrens(){let t=this.ast.param,i=Object.create(this.ob),s=!!this.runExpressWithWatcher(function(t,i,s){try{return new Function(e,`${e}.${t}=${i}; return ${s};`)}catch{throw new Error(`For循环命令,表达式运行依赖采集出现未知错误,其中letKey:${t},keyVal:${i},condition:${s}`)}}(t.letKey,t.defaultKeyVal,t.condition),i,(()=>{this.clearWatchers(),this.renderChildrens()}),!0),n=0;for(;s;){let e=Object.create(this.ob);W(e,t.letKey,i[t.letKey]);let r=n++;this.renderItem(e,r),this.runExpressWithWatcher((()=>i[t.letKey]),i,(async(i,s,n,o)=>{await Promise.resolve(),o.isDestroy||(e[t.letKey]=i,n||this.updateListItemOb(e,r))}),!0),this.runExpress(t.step,i),s=!!this.runExpress(t.condition,i)}this.destroyOldChildrens(n)}renderInOrOfChildrens(){let e=this.ast.param,t=this.runExpressWithWatcher(e.dataKey,this.ob,(()=>{this.clearWatchers(),this.renderChildrens()})),i=0;if(t&&(Array.isArray(t)||u(t)))for(let s in t){let n=Object.create(this.ob),r=Array.isArray(t)?Number(s):s;e.indexKey&&W(n,e.indexKey,r),e.itemKey&&W(n,e.itemKey,t[s]);let o=i++;this.renderItem(n,o,e.indexKey),e.itemKey&&this.runExpressWithWatcher((()=>t[r]),t,(async(i,s,a,h)=>{await Promise.resolve(),h.isDestroy||r in t&&(n[e.itemKey]=i,a||this.updateListItemOb(n,o))}),!0)}this.destroyOldChildrens(i)}findIndexByIndex(e,t,i){let s=-1;if(this.node)for(let n=t;n<this.node.childrens.length;n++)if(this.checkObEqual(e,this.node.childrens[n]?.ob,i?[i]:void 0)){s=n;break}return s}renderItem(e,t,i){if(!this.ast.childrens?.length||!this.node)return;let s=this.node.childrens?.[t];if(s){if(this.checkObEqual(e,s.ob,i?[i]:void 0))return void(i&&s.ob[i]!==e[i]&&(s.ob[i]=e[i]));let n=this.findIndexByIndex(e,t+1,i);if(n>-1){if(t+1===n)this.node.childrens?.[t]?.[z.PARSERKEY]?.destroy();else for(let e=0;e<n-t-1;e++)this.node.childrens?.[t]?.[z.PARSERKEY]?.destroy();return this.renderItem(e,t,i)}return new Re(this.ast,e,this.node,this.ext).init(t)}return new Re(this.ast,e,this.node,this.ext).init()}updateListItemOb(e,t){if(!this.ast.childrens?.length||!this.node)return;let i=this.node.childrens?.[t];c(e,((e,t)=>{i.ob[e]!==t&&(i.ob[e]=t)}))}destroyOldChildrens(e){if(this.node)for(;this.node.childrens.length>e;){let e=this.node.childrens.pop();if(!e)break;e[z.PARSERKEY]?.destroy(!1)}}checkObEqual(e,t,i){let s=!0;return void 0!==t&&(c(e,((e,n)=>{i?.includes(e)||t?.[e]===n||(s=!1)})),s)}}class Re extends ve{parser(e){this.node=new z.ListItem(this.ob,this.parent),this.appendNode(e),this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}}class $e extends ve{parser(){if(v(this.ast.cmdName))throw A.error("模板指令","解析AST转换VNode时发生错误,未找到指令名称",this.ast),new Error("解析AST转换VNode时发生错误,未找到指令名称");let e;if("Html"===this.ast.cmdName||"Text"===this.ast.cmdName?e=this.ast.param:this.ast.cmdName.startsWith(me+".")?e=`${this.ast.cmdName}(${this.ast.param})`:this.ast.cmdName in this.ob&&"function"==typeof this.ob[this.ast.cmdName]&&(e=`${t(this.ast.cmdName)}(${this.ast.param})`),e){let t=this.runExpressWithWatcher(`[${e}]`,this.ob,(e=>{this.changeValue(e?.[0])}));return t||=[],"Html"===this.ast.cmdName?this.node=new z.Html(Ae(t[0]),this.parent,t[1]):this.node=new z.Text(Ae(t[0]),this.parent),void this.appendNode()}throw new Error(`未找到命令:${this.ast.cmdName}`)}changeValue(e){this.node&&(this.node instanceof z.Html?this.node.html=Ae(e):this.node.text=Ae(e),this.ext.render?.updateNode(this.node))}}function Ae(e){return null==e||"function"==typeof e?"":e.toString()}const Ce="default";class xe extends ve{parser(){let e=this.transformParam();this.node=new z.RenderSection(e.id,this.parent),this.node.params=e.params,this.node.section??=this.ob.$sections?.[e.id],this.appendNode(),this.node.section&&(this.node.section.params?(this.node.ob=Object.create(this.node.section.ob||this.ob),this.node.section.params?.forEach(((e,t)=>{W(this.node.ob,e,this.node.params[t])}))):this.node.ob=this.node.section.ob||this.ob,(this.node.section.parser||this.ext).parserNodes(this.node.section.asts,this.node,this.node.ob))}transformParam(){if(this.ast.param){let e=this.runExpressWithWatcher(`[${this.ast.param}]`,this.ob,(e=>{let t=e?.[0]||Ce;if("string"==typeof t&&t!==this.node.id)throw new Error("section id 不可动态变更");this.node.params=e.slice(1),this.node?.ob&&this.node.section&&this.node.section.params?.forEach(((e,t)=>{this.node?.ob&&this.node.ob[e]!==this.node.params[t]&&(this.node.ob[e]=this.node.params[t])}))}),!0);return{id:e?.[0]||Ce,params:e?.slice(1)||[]}}return{id:Ce,params:[]}}}const Oe="组件解析";function Se(e,t){return!!t.components[e]||!!Ue(e)}class Pe extends ve{loadPromise;parser(){if(this.ast.node)return this.node=this.ast.node,this.node.parent=this.parent,this.initPropData(),void(this.node&&(this.appendNode(),this.node.component?.$mount(this.node)));this.node=new z.Component(this.parent),this.initPropData(),this.appendNode(),this.initEvent(),this.loadPromise=this.renderChildren(),this.ext.promiseQueue.add(this.loadPromise),this.loadPromise.finally((()=>{this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0)}))}get canReload(){return"tagName"in this.ast||"function"==typeof this.ast.component}reload(){this.canReload?(this.beforeDestroy(),this.renderChildren()):A.warn(Oe,"当前组件无法实现reload",this.node)}initPropData(){for(let e of this.ast.attributes)if("ref"!==e.name)if("keep-alive"===e.name&&"false"!==e.value&&(this.node.keepalive=!0),e.express){let t=this.runExpressWithWatcher(e.express,this.ob,(t=>{this.node.propValues[e.name]=t,this.notifyNodeWatcher("update",e.name)}),!0);this.node.propValues[e.name]=t}else this.node.propValues[e.name]=e.value;else{if(v(e.value)){A.warn(Oe,"元素的ref值不可以为空");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}this.node.propValues=_(this.node.propValues)}initEvent(){this.ast.events.forEach((e=>{let t=e.functionName?this.ob[e.functionName]:void 0;void 0===e.functionName?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:b}]):t&&"function"==typeof t?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:i=>{let s=[];e.functionParam&&(s=this.runExpress(`[${e.functionParam}]`,this.ob)),t.call(this.ext.ob,i,...s)}}]):A.error(Oe,`${"tagName"in this.ast?this.ast.tagName:""}元素中${e.name}事件所指定的回调(${e.functionName})方法未找到,请检查`)}))}async renderChildren(){return new Promise((async(e,t)=>{if("tagName"in this.ast){let e=this.ob.components[this.ast.tagName]||Ue(this.ast.tagName);if(void 0===e)return void A.error(Oe,`渲染组件失败,未找到名称为'${this.ast.tagName}'的私有组件/全局组件`);if(Fe in e||(e=(await e()).default),!this.node)return;{let t=this.getSections();this.node.name=this.ast.tagName,this.node.component=new e(this.node?.propValues,t,this.node?.keepalive)}}else if("function"==typeof this.ast.component){let e=this.getSections();this.node.component=new this.ast.component(this.node?.propValues,e,this.node?.keepalive)}else this.node.component=this.ast.component;if(!this.node)return;!this.node.name&&"name"in this.node.component&&this.node.component.name&&"string"==typeof this.node.component.name&&(this.node.name=this.node.component.name);let i=this,s=function(){i.loadPromise&&e(void 0)};if(this.node.component.$on("mounted",(()=>{this.node?.component.$off("beforeDestroy",s),e(void 0)})),this.node.component.$on("beforeDestroy",s),this.node.component.$mount(this.node),!this.node)return;let n=this.node?.component;n.isKeepAlive&&(this.ast.node=this.node)}))}getSections(){let t={},s=[];return this.ast.childrens.forEach((t=>{if(t.type===i.NodeType.COMMAND&&"if"===t.cmdName&&t.childrens){let n=t,r=t.childrens.some((e=>e.type===i.NodeType.COMMAND&&"section"===e.cmdName)),o=n.condition.startsWith(e+".$sections");if(o){return this.runExpress(n.condition,this.ob)?void s.push(...t.childrens):void 0}if(r&&"if"===n.kind&&!o)return void A.warn(Oe,"在解析section时,发现该section包裹在一个条件语句中,该条件语句仅支持以$sections进行if判断,已作排出")}s.push(t)})),s.forEach((e=>{if(e.type===i.NodeType.COMMAND&&"section"===e.cmdName){let i=e,s=i.id||Ce;/^(\'|\")(.*?)((\'|\"))$/.test(s)&&(s=s.slice(1,-1)),t[s]=t[s]||{asts:[],ob:this.ob,params:i.paramKeys,parser:this.ext},t[s].asts.push(...e.childrens||[])}else t[Ce]=t[Ce]||{asts:[],ob:this.ob,parser:this.ext},t[Ce].asts.push(e)})),t}beforeDestroy(e){this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0),!0===e&&this.node?.component?.isKeepAlive?this.node?.component?.$destroy():(this.node?.component?.$destroy(!0),this.ast.node=void 0)}}class De extends ve{parser(){this.node=new z.Element(this.ast.tagName,this.parent),this.initAttributes(),this.initEvents(),this.appendNode(),this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}initAttributes(){for(let e of this.ast.attributes)if("ref"!==e.name)if(e.express){let t=t=>{this.node&&(this.node.attributes[e.name]=this.transformAttrVal(t),this.ext.render?.updateNode(this.node,e.name),this.notifyNodeWatcher("update",e.name))},i=this.runExpressWithWatcher(e.express,this.ob,(e=>{t(e)}));this.node.attributes[e.name]=this.transformAttrVal(i)}else this.node.attributes[e.name]=e.value;else{if(v(e.value)){A.warn("Element解析","元素的ref值不可以为空");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}}initEvents(){for(let e of this.ast.events){let t=e.functionName?this.ob[e.functionName]:void 0;if(!(void 0===e.functionName||t&&"function"==typeof t))throw new Error(`${this.ast.tagName}元素中${e.name}事件所指定的回调(${e.functionName})方法未找到,请检查`);this.node?.events.push([e.name,{modifiers:e.modifiers,callBack:i=>{if(void 0===t)return;let s=[];e.functionParam&&(s=this.runExpress(`[${e.functionParam}]`,this.ob)),t&&t.call(this.ext.ob,i,...s)}}])}}transformAttrVal(e){return void 0!==e&&("string"==typeof e||"boolean"==typeof e||"function"!=typeof e&&Object.prototype.toString()?e:void 0)}}class Te{asts;ob;root=new z.Root;refs={};sleeped=!1;promiseQueue=new Set;nodeWatcherEvents={};render;constructor(e,t,i){this.asts=e,this.ob=t,this.root.component=t,this.render=G.get(ee.IRENDERIOCTAGID)??new ee.DomRender,i&&i instanceof z.Node&&(this.root.parent=i,i.childrens??=[],i.childrens.push(this.root))}parser(){this.parserNodes(this.asts,this.root)}mount(e){this.sleeped&&this.weakup(),this.render?.mount(e)}parserNodes(e,t,s){if(0!==this.asts.length)for(let n of e)if(n.type===i.NodeType.TEXT)new ge(n,s??this.ob,t,this).init();else if(n.type===i.NodeType.COMMENT)new be(n,s??this.ob,t,this).init();else if(n.type===i.NodeType.COMPONENT)new Pe(n,s??this.ob,t,this).init();else if(n.type===i.NodeType.ELEMENT){let e=n;Se(e.tagName,s??this.ob)?new Pe(e,s??this.ob,t,this).init():new De(e,s??this.ob,t,this).init()}else if(n.type===i.NodeType.COMMAND){let e=n;switch(e.cmdName){case"if":case"elseif":case"else":new we(e,s??this.ob,t,this).init();break;case"for":new Ne(e,s??this.ob,t,this).init();break;case"RenderSection":new xe(e,s??this.ob,t,this).init();break;case"section":break;default:new $e(e,s??this.ob,t,this).init()}}}addRef(e,t){this.refs[e]=this.refs[e]||[],this.refs[e].push(t),t.ref=e}removeRef(e){for(let t in this.refs)this.refs[t].includes(e)&&y(this.refs[t],e)}addNodeWatcher(e,t){this.nodeWatcherEvents[e]=this.nodeWatcherEvents[e]||[],this.nodeWatcherEvents[e].push(t)}removeNodeWatcher(e,t){y(this.nodeWatcherEvents[e]||[],t)}notifyNodeWatcher(e,t,i,s){this.nodeWatcherEvents[e]?.forEach((e=>{e(t,i,s)}))}sleep(e){let t=e||this.root;t.childrens?.forEach((e=>{let t=()=>{e.childrens&&this.sleep(e),e.sleep=!0,this.render?.removeNode(e,!0)};this.nodeTransition(e,"leave",void 0,(()=>{t()}))||t()})),void 0===e&&(this.sleeped=!0)}weakup(e){let t=e||this.root;t.childrens?.forEach((e=>{e.sleep=!1,this.render?.appendNode(e),e.childrens&&this.weakup(e),this.nodeTransition(e,"enter")})),void 0===e&&(this.sleeped=!1)}destroy(e){for(;this.root.childrens.length;){let t=this.root.childrens[0];t[z.PARSERKEY]?t[z.PARSERKEY].destroy(e):y(this.root.childrens,t)}this.render.destroy(),this.refs={},this.root.childrens.length=0,this.nodeWatcherEvents={},this.asts.length=0}destroyWathcers(){for(let e of this.root.childrens)e[z.PARSERKEY]&&e[z.PARSERKEY].destroyWathcers()}reSetAsts(e,t){this.destroy(t),this.render=G.get(ee.IRENDERIOCTAGID)??new ee.DomRender,this.asts=e}nodeTransition(e,t,i,s,n){if(e&&e.parent?.childrens&&(e instanceof z.Element||e instanceof z.Component)){let r=function(e){if(e instanceof z.Element||e instanceof z.Component){let t=e instanceof z.Element?e.attributes:e.propValues;return{name:t["transition-name"],type:t["transition-type"]}}}(e);if(i??=r?.name,n??=r?.type,!i)return!1;let o=ke(e);if(o)return"enter"===t?this.render.elementToEnter(o,i,n,(()=>{let t=e[z.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-enter"),s?.()})):this.render.elementToLeave(o,i,n,(()=>{let t=e[z.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-leave"),s?.()})),!0;A.warn("渲染核心","在执行node动画时,发现数据不完备,请检查")}return!1}}function ke(e){if(e instanceof z.Element)return e;if(e.childrens&&e.childrens.length)for(let t of e.childrens)return t instanceof z.Element?t:ke(t)}function Ke(e,t,i){if(void 0===t)return;let s=Array.isArray(i)?i:[i];for(let e of s){if(e===Array&&t instanceof Array)return t;if(typeof t===e.name.toLocaleLowerCase())return t}switch(s[0]){case Number:let e=Number(t);if(!1===isNaN(e))return e;break;case String:return String(t)}throw new Error(`props中${e.toString()}的类型不符合约束类型`)}function _e(e,t,i){let s,n,r;if("symbol"!=typeof t&&(s=g(t)),t in e?n=e[t]:s&&(n=e[s]),i&&(t in i?r=i[t]:s&&s in i&&(r=i[s])),void 0!==r){if(u(r)&&("type"in r||"required"in r||"default"in r||"validate"in r)){let e=r;if(e.required&&void 0===n)throw new Error(`props中key:${t.toString()}是必须项,请检查`);if(e.type&&(n=Ke(t,n,e.type)),e.validate&&!1===e.validate(n))throw new Error(`props中key${t.toString()}的值校验错误`);n=n??e.default}else n=We(r)?Ke(t,n,r):n??r;return n}return n}function We(e){return!![String,Array,Number,Object,Function,Boolean].includes(e)||e instanceof Array&&We(e[0])}function Ie(e,t){if(!e.constructor)return!1;let i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);return i&&i.get}const Le="组件",Ve=Symbol.for("JOKER_PROPS_DATA_KEY"),Me=Symbol.for("JOKER_PROPS_DATA_PROXY"),je=Symbol.for("JOKER_PRIVATE_WATCHERS"),Ye=Symbol.for("JOKER_EVENT_DATA_KEY"),Be=Symbol.for("JOKER_IS_DESTROY"),He=Symbol.for("JOKER_PARSER_TEMPLATE_TARGET"),Je=Symbol.for("JOKER_SCOPE_ID"),Fe=Symbol.for("JOKER_COMPONENT_TAG"),Ge=Symbol();let qe=["constructor","$mount","$nodeTransition","$destroy","$getRef","$getRefs","$syncProp","$watchNode","$watch","$on","$off","$trigger","$render","created","mounted","beforeDestroy","sleeped","wakeup","destroyed"];class ze{$sections;isKeepAlive;static[Fe]=!0;[Je];model={};template;$root;isSleeped=!1;components={};propsOption;[Ve]={};[He];[Me];[je]=[];[Ye]=new Map;[Be]=!1;[Ge]=!1;constructor(e,t={},i){this.$sections=t,this.isKeepAlive=i,this[Ve]=e||{}}get props(){if(void 0===this[Me]){let e=this;this[Me]=new Proxy(e[Ve],{get:(t,i)=>_e(e[Ve],i,e.propsOption),set(){throw new Error("props 参数不允许变更,只允许单向数据传递")}})}return this[Me]}$mount(e){if(!1===this[Ge]){let e=()=>{let e=[],t=Object.getPrototypeOf(this);for(;null!==t&&t!==Object.prototype;)Object.getOwnPropertyNames(t).forEach((i=>{!1!==qe.includes(i)||Ie(t,i)||"function"!=typeof t[i]||t[i].prototype?.hasOwnProperty("constructor")||e.push(i)})),t=Object.getPrototypeOf(t);return e};for(let t of e())this[t]=this[t].bind(this);this[Ge]=!0}if(this.$root=e,this.isKeepAlive&&this.isSleeped)return this.isSleeped=!1,this[He]&&this.$root?(this[He].mount(this.$root),this.wakeup(),this.$trigger("wakeup"),this.$rootVNode&&et(this.$rootVNode),this):(A.error(Le,"当前组件在唤醒时,发现渲染处理程序已被销毁,无法进行唤醒操作",[this,this.$root]),this);this.isSleeped=!1,this.model=_(this.model);let t=this.created(),i=async()=>{this.$trigger("created"),this.template&&this.$render(),await this.$nextUpdatedRender(),this[Be]||(await this.mounted(),this[Be]||this.$trigger("mounted"))};return t&&t instanceof Promise?t.then((()=>{this[Be]||i()})):i(),this}$nextUpdatedRender(e){if(this[Be])return;let t=[...this[He]?.promiseQueue||[]],i=this.$rootVNode?.find((e=>e instanceof z.Component));if(i?.forEach((e=>{e?.component&&t.push(...e.component[He]?.promiseQueue||[])})),t.length)return Promise.all(t).finally((()=>{this[Be]||e?.()}));this[Be]||e?.()}$nodeTransition(e,t,i,s,n){if("string"==typeof e){let t=this.$getRef(e);if(!t)return void A.error(Le,`执行节点动画是找不到ref=${e}的节点`);e=t}this[He]?.nodeTransition(e,t,i,s,n)}$destroy(e){if(!e&&this.isKeepAlive)return this[He]?.sleep(),this.isSleeped=!0,this.sleeped(),this.$trigger("sleeped"),void(this.$rootVNode&&Ze(this.$rootVNode));this[Be]=!0;for(let e of this[je])e.destroy();this[je].length=0,this[He]?.destroyWathcers(),this.beforeDestroy(),this.$trigger("beforeDestroy"),this[He]?.destroy(),this[He]=void 0,this.template&&Array.isArray(this.template)&&(this.template.length=0),this.$trigger("destroy"),this[Ye].clear(),this.$root=void 0,this.isSleeped=!1,this.$sections={},this[Me]=void 0,this[Ve]={},this.destroyed()}get $refs(){return this[He]?.refs||{}}$getRef(e){return this.$refs[e]?.[0]}$getRefs(e){return this.$refs[e]}$syncProp(e,t,i){"function"==typeof t&&(i=t,t=void 0),t??=e,i??=e=>e,this.model[t]=i(this.props[e]),this.$watch((()=>this.props[e]),(()=>{this.model[t]=i?.(this.props[e])}))}get $rootVNode(){return this[He]?.root}$watchNode(e,t){if(this[He])return this[He]?.addNodeWatcher(e,t),()=>{this[He]?.removeNodeWatcher(e,t)};A.warn(Le,"该组件还未挂载,不可以进行节点观察监听")}$watch(e,t,i){let s=new F((()=>{if(this[Be]){for(let e of this[je])e.destroy();return J}return e()}),((e,i)=>{this[Be]||t(e,i)}),void 0,i);return this[je].push(s),[s.value,()=>{s.destroy(),y(this[je],s)}]}$on(e,t){let i=this[Ye].get(e);void 0===i&&(i=new Set,this[Ye].set(e,i)),!1===i?.has(t)&&i.add(t)}$off(e,t){let i=this[Ye].get(e);i&&(t?i.delete(t):i.clear())}$trigger(e,t,i){if(!this.$root)return;let s={eventName:e,stopPropagation:i?.stopPropagation??(()=>{}),preventDefault:i?.preventDefault??(()=>{}),data:t,target:i?.target??this.$rootVNode,event:i?.event};if(this.$rootVNode&&this.$rootVNode.parent&&this.$rootVNode.parent instanceof z.Component&&!1===this[He]?.render.triggerEvent(this.$rootVNode.parent,e,s))return;let n=this[Ye].get(e);n?.size&&[...n].forEach((e=>{e(s)}));let r=this[Ye].get("*");r?.size&&[...r].forEach((e=>{e(s)}))}$render(e,t){e??=this.template,this.template="function"==typeof e?e(s):e,this.$root&&(this.template??=[],this[He]?.reSetAsts(this.template,t),this[He]??=new Te(this.template,this,this.$root),this[He].parser(),this.$root&&this[He].mount(this.$root))}created(){}mounted(){}beforeDestroy(){}sleeped(){}wakeup(){}destroyed(){}}const Qe={};function Xe(e,t){if("string"==typeof e)t&&(Qe[e]=t);else for(let t in e)Qe[t]=e[t]}function Ue(e){return Qe[e]}function Ze(e){e.childrens?.forEach((e=>{e instanceof z.Component&&e.component?.sleeped(),Ze(e)}))}function et(e){e.childrens?.forEach((e=>{e instanceof z.Component&&e.component?.wakeup(),et(e)}))}class tt extends ze{template=[];cache=new Map;async mounted(){this.$watch((()=>this.props.name),(async e=>{this.$render([],!0),await Promise.resolve(),this.$root&&this.loadComponent(e)})),await this.loadComponent(this.props.name)}propsVaule;created(){this.initProps()}initProps(){let e={};this.props.props||(Object.keys(this.props).forEach((t=>{!1!==this.filterProps(t)&&(e[t]=this.props[t],this.$watch((()=>this.props[t]),(()=>{this.propsVaule[t]=this.props[t]})))})),this.propsVaule=_(e))}filterProps(e){if("string"!=typeof e)return!1;let t=g(e);return"transition-name"!==t&&"name"!==t&&"keep-alive"!==t&&"ref"!==t&&void 0}async loadComponent(e){if(!e)return void this.$render([],this.isKeepAlive);let t;if(this.isKeepAlive){let t=this.cache.get(e);if(t)return void this.$render([n(t,{"transition-name":this.props["transition-name"]})],!0)}let i=this.$rootVNode?.parent?.[z.PARSERKEY]?.ob.components,s=i?.[e];void 0===s&&(s=Ue(e)),s?(Fe in s||(s=(await s()).default),t=new s(this.props.props||this.propsVaule,this.$sections,this.isKeepAlive),t.$on("*",(e=>{this.$trigger(e.eventName,e.data,e)})),this.isKeepAlive&&this.cache.set(e,t),this.$render([n(t,{"transition-name":this.props["transition-name"]})],this.isKeepAlive)):A.warn("component",`未找到${e}的组件`)}beforeDestroy(){this.removeCache()}removeCache(e){if(e){let t=this.cache.get(e);this.cache.delete(e),t&&t.$destroy(!0)}else this.cache.forEach((e=>{e.$destroy(!0)})),this.cache.clear()}}class it extends ze{template=function(){return[r("RenderSection")]};async mounted(){await this.$nextUpdatedRender()}}Xe({template:it,component:tt});class st{eventDatas=new Map;on(e,t){let i=this.eventDatas.get(e);void 0===i&&(i=[],this.eventDatas.set(e,i));let s={callBack:t};return i.push(s),()=>{i&&y(i,s)}}once(e,t){let i=this.eventDatas.get(e);void 0===i&&(i=[],this.eventDatas.set(e,i));let s={callBack:t,once:!0};return i.push(s),()=>{i&&y(i,s)}}off(e,t){if(void 0!==e)if(t){let i=this.eventDatas.get(e),s=i?.find((e=>e.callBack===t));s&&y(i,s)}else this.eventDatas.delete(e);else this.eventDatas.clear()}async trigger(e,t){let i=[...this.eventDatas.get(e)||[]];if(i.push(...this.eventDatas.get("*")||[]),i&&i.length){let s=0,n=0,r=!1;for(;i[s];){let o=i[s],a=await o.callBack({stopPropagation:()=>r=!0,callTimes:n,eventName:e},t);if(o.once?y(i,o):s++,!1===a||r)return!1}}}}export{J as BREAK_WATCH_UPDATE,ze as Component,tt as ComponentContainer,O as Dep,st as EventBus,G as IContainer,Be as IS_DESTROY,Fe as JOKER_COMPONENT_TAG,q as JOKER_VNODE_TAG,S as OBJECTPROXY_DEPID,He as PARSER_TEMPLATE_TARGET,Te as ParserTemplate,ee as Render,Je as SCOPE_ID,L as ShallowObserver,it as Template,z as VNode,F as Watcher,fe as __GLONAL_FUNTIONS__,d as __JOKER_HMR_RUNTIME,Y as combinedReply,W as defineObserverProperty,Ue as getGlobalComponent,B as isObserverData,_ as observer,Xe as registerGlobalComponent,pe as registerGlobalFunction};
1
+ import{EXPRESSHANDLERTAG as e,createFuntionBody as t,AST as n,RENDER_HANDLER as s,createComponent as i,createCommand as o}from"@joker.front/ast";export{AST,EXPRESSHANDLERTAG,RENDER_HANDLER,createCodeFunction,createCommand,createComment,createComponent,createElement,createFuntionBody,createText}from"@joker.front/ast";const r=new Map,a=new Map,h=new Map;let d={recordRender:(e,t)=>{a.set(e,t)},recordComponent:(e,t)=>{h.set(e,t)},record:(e,t)=>{void 0===r.get(e)&&r.set(e,new Set),r.get(e).add(t),t.$on("destroy",(()=>{r.get(e)?.delete(t)}))},reload:(e,t)=>{let n=h.get(e);if(!n)return;n.component=t;let s=r.get(e);if(!s)return;let i=Array.from(s);s.clear(),i.forEach((e=>{if(e.$root){if(!e.$rootVNode?.parent)return window.onbeforeunload=null,void location.reload();{let t=e.$rootVNode.parent;if(!(t instanceof z.Component&&t[z.PARSERKEY]&&t[z.PARSERKEY].canReload))return window.onbeforeunload=null,void location.reload();t[z.PARSERKEY].reload()}}}))},rerender:(e,t)=>{let n=a.get(e);n&&(n.render=t),r.get(e)?.forEach((e=>{e.$render(t)}))}};function c(e){return null!==e&&"object"==typeof e}function l(e,t){Object.getOwnPropertyNames(e).forEach((n=>{t(n,e[n])}))}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}function f(e){if(null===e)return e;if("object"!=typeof e)return e;let t;t=Array.isArray(e)?[]:{};let n=Object.keys(e);for(let s of n){let n=e[s];t[s]="object"==typeof n?f(n):n}return t}function p(e,t,n){return Array.isArray(e)&&Array.isArray(t)?function(e,t,n){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(n){if(e[s]!==t[s])return!1}else if(!1===m(e[s],t[s],n))return!1;return!0}(e,t,n):m(e,t,n)}function m(e,t,n){if(e===t)return!0;let s=c(e),i=c(t);if(s&&i){if(u(e)&&u(t)){let s=Object.keys(e);if(s.length!==Object.keys(t).length)return!1;if(n){for(let n of s)if(e[n]!==t[n])return!1;return!0}return JSON.stringify(e)===JSON.stringify(t)}return e===t}return!s&&!i&&String(e)===String(t)}function y(e,t){let n=e.indexOf(t);return n>-1&&e.splice(n,1),e}function v(e,t){let n=e.findIndex((e=>t(e)));return n>-1&&e.splice(n,1),e}function g(e){return!e||""===e.trim()}function E(e,t="-"){return(e=e||"").split(/(?=[A-Z])/).map((e=>e.toLowerCase())).join(t)}let b=(...e)=>{},w="warn";const N=["silent","error","warn","info"];function $(){let e=new Date;function t(e,t=2){return e.toString().padStart(t,"0")}return t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+":"+t(e.getMilliseconds(),3)}function R(e,t,n,s){N.indexOf(e)<=N.indexOf(w)&&(void 0===s?console[e](`${$()} [${t}]:`,n):console[e](`${$()} [${t}]:`,n,s))}let C={info:function(e,t,n){R("info",e,t,n)},warn:function(e,t,n){R("warn",e,t,n)},error:function(e,t,n){R("error",e,t,n)},setLoggerLeve:function(e){w=e}};const x={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"',"#39":"'"};function A(e){return e.replace(/&(lt|gt|nbsp|amp|quot|#39);/gi,((e,t)=>x[t]||""))}class O{static target;watchers=new Map;depend(e){O.target?.addDep(this,e)}addWatcher(e,t){let n=this.watchers.get(e)||[];n.push(t),this.watchers.set(e,n)}removeWatcher(e,t){const n=this.watchers.get(e);n&&y(n,t)}notify(e){const t=this.watchers.get(e);if(t){v(t,(e=>e.isDestroy));[...t].forEach((e=>{e.isDestroy||e.update()}))}}}const S=Symbol.for("__JOKER_OBJECT_PROXY_DEP_ID__"),P=Symbol.for("__JOKER_OBJECT_PROXY_DATA_KEY__"),T=Symbol.for("__JOKER_OBJECTPROXY_DEPLEVE_ID__");function D(e){try{return null!=e&&c(e)&&e!==window.parent&&e instanceof Window==!1&&e instanceof F==!1&&e instanceof Qe==!1&&e instanceof _e==!1&&(Array.isArray(e)||u(e)||e instanceof Set||e instanceof Map)&&!Object.isFrozen(e)&&!(e instanceof Element)&&!(G in e)&&!(I in e)&&!(qe in e)}catch{return!1}}function _(e){if(k(e))return e;if(e&&e.hasOwnProperty(P)){let t=Reflect.get(e,P);if(t)return t}let t=new O,n=!0,s=new Proxy(e,{get(e,n,s){if(e instanceof Set||e instanceof Map){if("add"===n){let s=Reflect.get(e,n);return n=>{D(n)&&(n=K(n));let i=s.call(e,n);return j(t,"size"),j(t,T),i}}if("set"===n){let s=Reflect.get(e,n);return(n,i)=>{D(i)&&(i=K(i));let o=s.call(e,n,i);return j(t,"size"),j(t,T),o}}if("delete"===n||"clear"===n){let s=Reflect.get(e,n);return i=>{let o=s.call(e,i);return("clear"===n||o)&&(j(t,"size"),j(t,T)),o}}let s=Reflect.get(e,n);if("function"==typeof s)return s.bind(e)}if(n===P)return;if(n===S)return t;if(n===T)return;let i=Reflect.get(e,n);return n===Symbol.toStringTag||!1===function(e,t){return t in e}(e,n)&&"length"!==n&&"size"!==n||(t.depend(n),D(i)&&k(i)?.depend(T)),i},set(e,s,i){if(n)return Reflect.set(e,s,i),!0;D(i)&&(i=K(i));let o=!1===function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,s),r=Reflect.get(e,s)!==i;return Reflect.set(e,s,i),(r||"length"===s&&Array.isArray(e))&&j(t,s),Array.isArray(e)?"length"===s&&j(t,T):o&&j(t,T),!0},deleteProperty:(e,n)=>(Reflect.deleteProperty(e,n),!1===Array.isArray(e)&&j(t,T),!0)});var i,o,r,a;i=e,o=P,r=s,a=!1,Object.defineProperty(i,o,{value:r,enumerable:a,writable:!0,configurable:!0});for(let t in e){let n=e[t];D(n)&&!k(n)&&(s[t]=_(e[t]))}return n=!1,s}function k(e){if(c(e))return Reflect.get(e,S)}function K(e,t=!1){if(!1===D(e))throw new Error("The provided data is not of the correct type. It must be an array or an object.");return _(t?f(e):e)}function W(e,t,n){let s=n;D(n)&&(s=K(n));let i=new O;Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:()=>(i.depend(t),k(s)?.depend(T),s),set:e=>{e!==s&&(D(e)&&(e=K(e)),s=e,j(i,t))}})}const I=Symbol.for("JOKER_SHALLOW_OBSERVER");class V{data;[I]=!0;dep=new O;constructor(e){this.data=e}isChanged=!1;get value(){return this.dep.depend(T),this.data}set value(e){!1===Object.is(e,this.data)&&(this.isChanged=!0,this.data=e,j(this.dep,T))}}let L=!1,M=new Map;function j(e,t){if(!1===L)e.notify(t);else{let n=M.get(e);void 0===n&&(n=[],M.set(e,n)),n.includes(t)||n.push(t)}}function Y(e){L=!0;try{e()}catch(e){return L=!1,M.clear(),void C.error("Data Hijacking","Encountered a blocking error while collecting changes for data hijacking composite responses. No action will be taken. Please investigate.",e)}L=!1,function(e){const t=[],n=[];e.forEach(((e,n)=>{e.forEach((e=>{t.push(...n.watchers.get(e)||[])}))})),t.forEach((e=>{n.includes(e)||(!e.isDestroy&&e.update(),n.push(e))}))}(M),M.clear()}function B(e){return void 0!==k(e)}const H="Data Observation",J=Symbol.for("JOKER_BREAK_WATCH_UPDATE");class F{ob;updateCallBack;forceCallBack;getter;value;isDestroy=!1;updating=!1;runRelations=new Map;relations=new Map;constructor(e,t,n,s){if(this.ob=e,this.updateCallBack=t,this.forceCallBack=s,void 0===e)throw new Error("Cannot observe changes on undefined");if(void 0===n)this.getter=e=>e;else if("function"==typeof n)this.getter=n;else{const e=function(e){if(/[^\w.$]/.test(e))return;const t=e.split(".");return function(e){let n=e;return t.forEach((e=>{n&&(n=n[e])})),n}}(n);if(void 0===e)throw new Error(`${n} failed to parse. Unable to interpret the expression. Please check the expOrFn parameter or use the function mode instead.`);this.getter=e}void 0===this.getter&&C.error(H,"Failed to create getter",arguments),this.value=this.getValue()}getValue(){if(void 0===this.getter)return;O.target=this;const e="function"==typeof this.ob?this.ob():this.ob;let t;try{t=this.getter.call(e,e)}catch(e){throw C.error(H,"Failed to retrieve value. Executed method: "+this.getter.toString()),e}return O.target=void 0,this.clearnDeps(),t}addDep(e,t){let n=this.runRelations.get(e);if(void 0===n||!n.includes(t)){n=n||[],n.push(t),this.runRelations.set(e,n);const s=this.relations.get(e);void 0!==s&&s.includes(t)||e.addWatcher(t,this)}}update(){if(this.updating)return;const e=this.getValue();if(e===J)return;const t=this.value;if(this.forceCallBack||e!==t||c(e)){this.value=e;const n=e!==t&&p(e,t,!0);if(n&&!this.forceCallBack)return;this.updating=!0;try{this.updateCallBack(e,t,n,this)}catch(e){throw e}finally{this.updating=!1}}}destroy(){this.relations.forEach(((e,t)=>{for(const n of e)t.removeWatcher(n,this)})),this.isDestroy=!0,this.relations.clear(),this.runRelations.clear(),this.ob=void 0,this.value=void 0,this.getter=void 0}clearnDeps(){this.relations.forEach(((e,t)=>{const n=this.runRelations.get(t);for(const s of e)n&&n.includes(s)||t.removeWatcher(s,this)})),this.relations.clear(),this.relations=this.runRelations,this.runRelations=new Map}}var q;!function(e){let t=new Map;e.bind=function(e){return{to:n=>{if(t.has(e))throw new Error(`TagId:${e.toString()} already has an implementation bound. Do not bind again.`);t.set(e,n)}}},e.get=function(e,...n){const s=t.get(e);if(s)return new s(...n)}}(q||(q={}));const G=Symbol.for("JOKER_VNODE_TAG");var z;!function(e){e.PARSERKEY=Symbol.for("JOKER_PARSER_KEY");class t{parent;[G]=!0;static;output;[e.PARSERKEY];childrens;ref;sleep=!1;constructor(e){this.parent=e}get prev(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)-1]}get next(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)+1]}closest(e,t){if(!0===e(this))return this;let n=this.parent;for(;n;){if(!0===e(n))return n;if(!0===t?.(n))break;n=n.parent}}find(e,t,n,s,i){let o=i??[];if(s??=this.childrens,s)for(let i of s){(!0!==e(i)||(o.push(i),n))&&(!0!==t?.(i)&&i.childrens&&this.find(e,t,n,i.childrens,o))}return o}contains(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return!0;if(n.childrens&&n.childrens.length&&this.contains(e,n.childrens))return!0}return!1}first(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return n;if(n.childrens&&n.childrens.length){let t=this.first(e,n.childrens);if(t)return t}}}}e.Node=t;e.Root=class extends t{childrens=[];component;constructor(){super()}};e.Text=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Html=class extends t{html;notShadow;static=!0;scopedId;constructor(e,t,n){super(t),this.html=e,this.notShadow=n}};e.Comment=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Element=class extends t{tagName;static=!0;attributes={};childrens=[];events=[];_assistEventCache;constructor(e,t){super(t),this.tagName=e}};e.Component=class extends t{name;component;events=[];propValues={};keepalive;get firstElement(){if(this.childrens){let t=n=>{for(let s of n){if(s instanceof e.Element)return s;if(s.childrens){let e=t(s.childrens);if(e)return e}}};return t(this.childrens)}}get rootElements(){if(this.childrens){let t=[],n=s=>{for(let i of s)i instanceof e.Element||i instanceof e.Html?t.push(i):i.childrens&&n(i.childrens)};return n(this.childrens),t}return[]}};e.Condition=class extends t{cmdName;result=!1;childrens=[];isShow=!1;constructor(e,t){super(t),this.cmdName=e}};e.List=class extends t{childrens=[]};e.ListItem=class extends t{ob;childrens=[];constructor(e,t){super(t),this.ob=e}};e.RenderSection=class extends t{id="unknown";params=[];section;childrens=[];ob;constructor(e,t){super(t),"string"==typeof e?this.id=e:this.section=e}}}(z||(z={}));const Q="DOM Rendering",U=["script","style","textarea","pre"];let X=0;const Z=["svg","defs","use","rect","circle","ellipse","line","polyline","polygon","path","text","g"];var ee;function te(e,t,n){return`${e}-${t}-${n}`}function ne(e,t,n,s){e._assistEventCache??=[],e._assistEventCache.push([t,n]),document.body.addEventListener(t,n,s)}function se(e,t,n){e._assistEventCache&&t&&n?(v(e._assistEventCache,(e=>e[0]===t&&e[1]===n)),document.body.removeEventListener(t,n)):(e._assistEventCache?.forEach((e=>{document.body.removeEventListener(e[0],e[1])})),e._assistEventCache&&(e._assistEventCache.length=0),e._assistEventCache=void 0)}!function(e){e.IRENDERIOCTAGID=Symbol.for("JOKER_IRENDERIOC_TAGID"),e.ROOT_CONTAINER="";e.DomRender=class{elements;constructor(){this.elements=document.createDocumentFragment()}mount(e){if(e instanceof Element)e.appendChild(this.elements);else if(e instanceof z.Component)if(e.parent)if(e.output){const t=e.output,n=he(e)||t.parentNode;n&&n.insertBefore(this.elements,t)}else C.error(Q,"Component mount found no DOM target node",e);else C.error(Q,"Mounting child component with no parent",e);else C.error(Q,"Mount only supports Element or VNode.Node",e)}appendNode(e,t){if(this.renderNode(e),e.output){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];for(const s of n)this.appendNodeChildren(e,s,e.parent,t)}else C.error(Q,"No output found for node, cannot mount",e)}updateNode(e,t){if(e instanceof z.Element)for(const t in e.attributes){const n=e.attributes[t];this.setAttribute(e.output,t,n)}else e instanceof z.Text?e.parent&&e.parent instanceof z.Element&&U.includes(e.parent.tagName)?(this.removeNode(e),this.appendNode(e)):e.output.textContent=A(e.text||""):e instanceof z.Html?e.notShadow?(e.output.innerHTML=e.html,e.scopedId&&fe(e.output,e.scopedId)):e.output.root.innerHTML=e.html:C.error(Q,`Node does not support ${t} update`,e)}removeNode(e,t){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];n?.forEach((e=>e?.remove())),t||(e instanceof z.Element&&se(e),e.output=void 0)}destroy(){this.elements=void 0}elementToEnter(e,t,n,s){e.output&&this.transitionFrame(e,t,"enter",n,s)}elementToLeave(e,t,n,s){e.output&&this.transitionFrame(e,t,"leave",n,s)}triggerEvent(e,t,n){const s=[];for(const i of e.events){const[o,r]=i;if(o===t){const t=r.modifiers?.includes("self"),a=r.modifiers?.includes("outside");if(t||a){C.warn(Q,"Event modifiers 'self' and 'outside' not supported in components",e);continue}const h=n.event;if((h instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(o)||h instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(o))&&!1===oe(h,r.modifiers))continue;if(r.callBack(n),r.modifiers?.includes("prevent")&&n.preventDefault(),r.modifiers?.includes("once")&&s.push(i),r.modifiers?.includes("stop"))return n.stopPropagation(),!1}}s.length&&s.forEach((t=>y(e.events,t)))}transitionFrame(e,t,n,s,i){re(e,te(t,n,"from")),s||="transition";const o=e.output.__TRANSITION_EVNETID__=X++;requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(!e.output)return;re(e,te(t,n,"active")),ae(e,te(t,n,"from")),re(e,te(t,n,"to"));const r=function(e,t){const n=window.getComputedStyle(e),s=e=>(n[e]||"").split(", ");if("transition"===t){const e=s("transitionDelay"),t=s("transitionDuration"),n=de(e,t);if(n>0)return{timeout:n,count:t.length}}else if("animation"===t){const e=s("animationDelay"),t=s("animationDuration"),n=de(e,t);if(n>0)return{timeout:n,count:t.length}}}(e.output,s);if(!r)return void i?.();let a=0;const h=()=>{ae(e,te(t,n,"to")),ae(e,te(t,n,"active")),e.output&&(e.output.removeEventListener(`${s}end`,d),o===e.output.__TRANSITION_EVNETID__&&i?.())},d=t=>{t.target===e.output&&++a>=r.count&&h()};setTimeout((()=>{a<r.count&&h()}),r.timeout+1),e.output?.addEventListener(`${s}end`,d)}))}))}renderNode(e){if(!e.output)if(e instanceof z.Text)e.parent&&e.parent instanceof z.Element&&U.includes(e.parent.tagName)?e.output=this.parserHtml(e.text):e.output=document.createTextNode(A(e.text||""));else if(e instanceof z.Html)if(e.notShadow){const t=document.createElement("joker-html-container");t.JOKER_NODE=e,t.innerHTML=e.html,e.scopedId&&(t.setAttribute("data-scoped-"+e.scopedId,""),fe(t,e.scopedId)),e.output=t}else{const t=document.createElement("joker-html-shadow");t.JOKER_NODE=e,t.style.lineHeight="1",t.root.innerHTML=e.html,e.output=t}else if(e instanceof z.Element){let t;const n=e.tagName.toLowerCase();"svg"===n||Z.includes(n)||e.parent?.inSvg?(e.inSvg=!0,t=document.createElementNS("http://www.w3.org/2000/svg",e.tagName)):t=document.createElement(e.tagName);for(const n in e.attributes)this.setAttribute(t,n,e.attributes[n]);t.JOKER_NODE=e,e.output=t,e.events.some((e=>"click"===e[0]&&e[1].modifiers?.includes("outside")))?setTimeout((()=>{this.initElementEvents(t,e)})):this.initElementEvents(t,e)}else e instanceof z.Comment?e.output=document.createComment(e.text):e.output=document.createTextNode("")}initElementEvents(e,t){for(const[n,s]of t.events){const i=s.modifiers?.includes("self");let o=s.modifiers?.includes("outside");i&&o&&(C.warn(Q,"Event modifiers 'self' and 'outside' cannot coexist, using 'self'",t),o=!1);const r=a=>{if(!(t.sleep||i&&a.target!==e)){if(o){if(a.target===e||e.contains(a.target))return;if(!1===document.contains(a.target))return;if(t.contains((e=>(e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output]).includes(a.target))))return!0}(a instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(n)||a instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(n))&&!1===oe(a,s.modifiers)||(s.callBack({eventName:n,event:a,target:t,preventDefault:()=>a.preventDefault(),stopPropagation:()=>a.stopPropagation(),data:void 0}),s.modifiers?.includes("prevent")&&a.preventDefault(),s.modifiers?.includes("stop")&&a.stopPropagation(),s.modifiers?.includes("once")&&(o?se(t,n,r):e.removeEventListener(n,r)))}};let a;s.modifiers?.includes("passive")&&(a={passive:!0}),o?ne(t,n,r,a):e.addEventListener(n,r,a)}}parserHtml(e){const t=document.createElement("div");return t.innerHTML=e,t.childNodes}isCommandGroup(e){return e instanceof z.Component||e instanceof z.Condition||e instanceof z.List||e instanceof z.ListItem||e instanceof z.RenderSection}appendNodeChildren(e,t,n,s){let i=he(e);if(i)i.appendChild(t);else if(void 0===n)this.elements?.appendChild(t);else if(n)if(n instanceof z.Root){const e=n.parent;if(e&&e instanceof z.Component&&e.output){const n=e.output,s=n?.parentNode;if(s)return void s.insertBefore(t,n)}this.elements?.appendChild(t)}else if(n instanceof z.Element){const e=n.output;if(void 0===e)return;e.appendChild(t)}else if(this.isCommandGroup(n)){const i=n.output?.parentNode;if(void 0!==s&&n.childrens?.length&&i){const o=s-1;if(o<0){const n=le(e);return void(n&&i.contains(n.output)?n.output.after(t):i.insertBefore(t,i.firstChild))}{const e=n.childrens[o];if(e){const n=e.output;if(n)return void n.after(t)}}}i&&i.insertBefore(t,n.output)}else C.error(Q,"Node does not support nested children",{node:e,parent:n})}setAttribute(e,t,n){if(e)if("boolean"!=typeof n){if("class"===t){if(Array.isArray(n)){const e=[];for(const t of n)if(c(t))for(const n in t)t[n]&&e.push(n);else t&&e.push(t);n=e.join(" ")}else if(c(n)){for(const t in n){const s=t.trim();s&&(n[t]?e.classList.add(s):e.classList.remove(s))}return}}else if("style"===t&&c(n)){e.removeAttribute("style");for(const t in n){let s=!1;void 0!==n[t]&&!1!==n[t]||(s=!0);const i=String(n[t]);g(i)&&(s=!0),s||(e.style[t]=i)}return}n=(n??"").toString().trim(),"class"===t&&(n=n.split(/\s/).filter((e=>e.trim())).join(" ")),"value"===t&&"value"in e?e.value=n:"xlink:href"===t?e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n):e.setAttribute(t,n)}else n?e.setAttribute(t,""):e.removeAttribute(t)}}}(ee||(ee={}));const ie={enter:"enter",backspace:"delete",tab:"tab",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right",escape:"esc"," ":"space"};function oe(e,t){if(e instanceof KeyboardEvent){if(void 0===e.key)return!1;for(const n in ie)if(t?.includes(ie[n])&&e.key.toLowerCase()!==n)return!1}else{if(t?.includes("left")&&0!==e.button)return!1;if(t?.includes("right")&&2!==e.button)return!1;if(t?.includes("middle")&&1!==e.button)return!1}return(!t?.includes("ctrl")||!1!==e.ctrlKey)&&((!t?.includes("alt")||!1!==e.altKey)&&(!t?.includes("shift")||!1!==e.shiftKey))}function re(e,t){e.output&&e.output.classList.add(t)}function ae(e,t){e.output&&e.output.classList.remove(t)}function he(e){if(e instanceof z.Element||e instanceof z.Component){let t=e instanceof z.Component?e.propValues["append-to"]:e.attributes["append-to"];if(t){if(t instanceof z.Element)return t.output;if("string"==typeof t){ee.ROOT_CONTAINER&&(t="body"===t?ee.ROOT_CONTAINER:`${ee.ROOT_CONTAINER} ${t}`);const e=document.querySelector(t);if(e)return e}C.warn(Q,"Unsupported appendTo type",{appendTo:t,node:e})}}}function de(e,t){for(;e.length<t.length;)e.concat(e);return Math.max(...t.map(((t,n)=>ce(t)+ce(e[n]))))}function ce(e){return"auto"===e?0:1e3*Number(e.slice(0,-1).replace(",","."))}function le(e,t){let n=e.prev;for(;n;){if(n instanceof z.ListItem==!1)return n;n=n.prev}if(!t){let t=e.parent;for(;t;){if(t instanceof z.Element)return;const e=le(t,!0);if(e)return e;t=t.parent}}}class ue extends HTMLElement{root;constructor(){super(),this.root=this.attachShadow({mode:"open"})}}function fe(e,t){const n=e.childNodes;for(let e=0;e<n.length;e++){const s=n[e];if(1===s.nodeType){const e=s;e.setAttribute("data-scoped-"+t,""),fe(e,t)}}}!customElements.get("joker-html-shadow")&&customElements.define("joker-html-shadow",ue);const pe={};function me(e){for(const t in e)pe[t]=e[t]}const ye="Global",ve="Render Core";function ge(t,n){try{return new Function(e,ye,`return ${t};`)}catch(e){throw new Error(`An unknown error occurred while creating the expression execution method. The expression is:${e.message} \n${n?.()||t}`)}}class Ee{ast;ob;parent;ext;ref="";watchers=[];node;isDestroy=!1;constructor(e,t,n,s){this.ast=e,this.ob=t,this.parent=n,this.ext=s}init(e){this.parser(e),this.afterParser()}beforeDestroy(e){}destroy(e){if(this.isDestroy=!0,this.clearWatchers(),this.parent.childrens&&this.node){(this.node instanceof z.Element||this.node instanceof z.Component)&&this.ext.removeRef(this.node);let t=()=>{this.parent&&this.node&&(this.beforeDestroy(e),this.destroyChildrens(e),this.node&&(this.ext.render?.removeNode(this.node),this.parent.childrens&&y(this.parent.childrens,this.node),this.notifyNodeWatcher("remove"),this.destroyOtherData()))};if(this.ext.nodeTransition(this.node,"leave",void 0,(()=>{t()})))return y(this.parent.childrens,this.node),void this.destroyChildrensWatcher(this.node);t()}else this.destroyOtherData()}destroyWathcers(){this.isDestroy=!0,this.clearWatchers(),this.destroyChildrensWatcher(this.node)}destroyOtherData(){this.node&&(this.node[z.PARSERKEY]=void 0),this.node=void 0,this.parent=void 0}destroyChildrens(e){for(;this.node?.childrens?.length;){let t=this.node.childrens[0];t[z.PARSERKEY]?t[z.PARSERKEY].destroy(e):y(this.node.childrens,t)}}destroyChildrensWatcher(e){if(e?.childrens?.length)for(let t of e?.childrens)t[z.PARSERKEY]&&(t[z.PARSERKEY].clearWatchers(),this.destroyChildrensWatcher(t))}appendNode(e){this.parent?.childrens&&this.node&&!this.isDestroy&&(this.node[z.PARSERKEY]=this,this.node instanceof z.Element&&this.ob[Fe]?this.node.attributes["data-scoped-"+this.ob[Fe]]=void 0:this.node instanceof z.Html&&this.ob[Fe]&&(this.node.scopedId=this.ob[Fe]),this.ext.render?.appendNode(this.node,e),void 0===e?this.parent.childrens.push(this.node):this.parent.childrens.splice(e,0,this.node),this.notifyNodeWatcher("append"))}afterParser(){this.ext.nodeTransition(this.node,"enter")}notifyNodeWatcher(e,t){this.ext.notifyNodeWatcher(this.ref,this.node,e,t)}runExpress(e,t,n){try{return ge(e,n).call(t,t,pe)}catch(s){C.error(ve,`Expression error:${s.message}\n`+(n?.()||e),{ob:t}),console.error(s)}}runExpressWithWatcher(e,t,n,s,i){if(this.isDestroy)return;let o="string"==typeof e?ge(e,i):e,r=new F((()=>{if(this.isDestroy||t[He])return J;try{return o.call(t,t,pe)}catch(n){return C.error(ve,`Expression error:${n.message}\n${i?.()||e}`,{ob:t,express:e,node:this.node}),console.error(n),J}}),n,void 0,s);return this.addWatch(r),r.value===J?void 0:r.value}addWatch(e){!1===this.watchers.includes(e)&&this.watchers.push(e)}clearWatchers(){this.watchers.forEach((e=>{e.destroy()})),this.watchers.length=0}}class be extends Ee{parser(){this.node=new z.Text(this.ast.text,this.parent),this.appendNode()}}class we extends Ee{parser(){this.node=new z.Comment(this.ast.text,this.parent),this.appendNode()}}class Ne extends Ee{parser(){if(this.node=new z.Condition(this.ast.kind,this.parent),"else"!==this.ast.kind){g(this.ast.condition)&&C.error("Conditional Command",`The current conditional command ${this.ast.kind} has no judgment condition, please check`);let e=this.runExpressWithWatcher(this.ast.condition,this.ob,(e=>{let t=!!e;if(this.node?.result!==t){if(this.node.result=t,!1===t&&this.node?.isShow)this.destroyChildrens(!0);else if(t&&!this.node?.isShow){let e=this.getElseNode();if(e&&e.isShow&&e.childrens?.length){let t=e[z.PARSERKEY];t&&t instanceof Ne&&t.renderConditionChildren()}}this.reloadAllCondition()}}),!1,(()=>this.ast._code));this.node.result=!!e}this.appendNode(),this.renderConditionChildren()}renderId;getElseNode(){let e=this.node?.next;for(;e&&e instanceof z.Condition&&"if"!==e.cmdName;){if("else"===e.cmdName)return e;e=e.next}}renderConditionChildren(){let e=!1;return this.getPrevIfResult()?e=!1:"else"===this.ast.kind?e=!0:(this.node.result=!!this.runExpress(this.ast.condition,this.ob,(()=>{this.ast._code})),this.node.result&&(e=!0)),e!==this.node.isShow&&(this.node.isShow=e,this.destroyChildrens(!0),e&&this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob),!0)}getPrevIfResult(){if("if"===this.ast.kind)return!1;let e=this.node?.prev;for(;e&&e instanceof z.Condition;){if(e.result)return!0;if("if"===e.cmdName)break;e=e.prev}return!1}reloadAllCondition(){if(this.renderConditionChildren()){let e=this.node?.next;for(;e&&e instanceof z.Condition&&"if"!==e.cmdName;){let t=e[z.PARSERKEY];t&&t instanceof Ne&&t.renderConditionChildren(),e=e.next}}let e=this.node?.next;for(this.node?.result||this.destroyChildrens(!0);e&&e instanceof z.Condition&&"if"!==e.cmdName;){let t=e[z.PARSERKEY];t&&t instanceof Ne&&t.renderConditionChildren(),e=e.next}}}class $e extends Ee{parser(){this.node=new z.List(this.parent),this.appendNode(),this.renderChildrens()}renderChildrens(){switch(this.ast.keyType){case"condition":this.renderConditionChildrens();break;case"in":case"of":this.renderInOrOfChildrens()}}renderConditionChildrens(){let t=this.ast.param,n=Object.create(this.ob),s=!!this.runExpressWithWatcher(function(t,n,s){try{return new Function(e,`${e}.${t}=${n}; return ${s};`)}catch{throw new Error(`Dependency collection for the For loop command expression execution encountered an unknown error. Details: letKey: ${t}, keyVal: ${n}, condition: ${s}`)}}(t.letKey,t.defaultKeyVal,t.condition),n,(()=>{this.clearWatchers(),this.renderChildrens()}),!0,(()=>this.ast._code)),i=0;for(;s;){let e=Object.create(this.ob);W(e,t.letKey,n[t.letKey]);let o=i++;this.renderItem(e,o),this.runExpressWithWatcher((()=>n[t.letKey]),n,(async(n,s,i,r)=>{await Promise.resolve(),r.isDestroy||(e[t.letKey]=n,i||this.updateListItemOb(e,o))}),!0,(()=>this.ast._code)),this.runExpress(t.step,n,(()=>{this.ast._code})),s=!!this.runExpress(t.condition,n,(()=>this.ast._code))}this.destroyOldChildrens(i)}renderInOrOfChildrens(){let e=this.ast.param,t=this.runExpressWithWatcher(e.dataKey,this.ob,(()=>{this.clearWatchers(),this.renderChildrens()}),!1,(()=>this.ast._code)),n=0;if(t&&(Array.isArray(t)||u(t)))for(let s in t){let i=Object.create(this.ob),o=Array.isArray(t)?Number(s):s;e.indexKey&&W(i,e.indexKey,o),e.itemKey&&W(i,e.itemKey,t[s]);let r=n++;this.renderItem(i,r,e.indexKey),e.itemKey&&this.runExpressWithWatcher((()=>t[o]),t,(async(n,s,a,h)=>{await Promise.resolve(),h.isDestroy||o in t&&(i[e.itemKey]=n,a||this.updateListItemOb(i,r))}),!0,(()=>this.ast._code))}this.destroyOldChildrens(n)}findIndexByIndex(e,t,n){let s=-1;if(this.node)for(let i=t;i<this.node.childrens.length;i++)if(this.checkObEqual(e,this.node.childrens[i]?.ob,n?[n]:void 0)){s=i;break}return s}renderItem(e,t,n){if(!this.ast.childrens?.length||!this.node)return;let s=this.node.childrens?.[t];if(s){if(this.checkObEqual(e,s.ob,n?[n]:void 0))return void(n&&s.ob[n]!==e[n]&&(s.ob[n]=e[n]));let i=this.findIndexByIndex(e,t+1,n);if(i>-1){if(t+1===i)this.node.childrens?.[t]?.[z.PARSERKEY]?.destroy();else for(let e=0;e<i-t-1;e++)this.node.childrens?.[t]?.[z.PARSERKEY]?.destroy();return this.renderItem(e,t,n)}return new Re(this.ast,e,this.node,this.ext).init(t)}return new Re(this.ast,e,this.node,this.ext).init()}updateListItemOb(e,t){if(!this.ast.childrens?.length||!this.node)return;let n=this.node.childrens?.[t];l(e,((e,t)=>{n.ob[e]!==t&&(n.ob[e]=t)}))}destroyOldChildrens(e){if(this.node)for(;this.node.childrens.length>e;){let e=this.node.childrens.pop();if(!e)break;e[z.PARSERKEY]?.destroy(!1)}}checkObEqual(e,t,n){let s=!0;return void 0!==t&&(l(e,((e,i)=>{n?.includes(e)||t?.[e]===i||(s=!1)})),s)}}class Re extends Ee{parser(e){this.node=new z.ListItem(this.ob,this.parent),this.appendNode(e),this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}}class Ce extends Ee{parser(){if(g(this.ast.cmdName))throw C.error("Template Directive","Error occurred while converting AST to VNode: Directive name not found",this.ast),new Error("Error converting AST to VNode: Directive name not found");let e;if("Html"===this.ast.cmdName||"Text"===this.ast.cmdName?e=this.ast.param:this.ast.cmdName.startsWith(ye+".")?e=`${this.ast.cmdName}(${this.ast.param})`:this.ast.cmdName in this.ob&&"function"==typeof this.ob[this.ast.cmdName]&&(e=`${t(this.ast.cmdName)}(${this.ast.param})`),e){let t=this.runExpressWithWatcher(`[${e}]`,this.ob,(e=>{this.changeValue(e?.[0])}),!1,(()=>this.ast._code));return t||=[],"Html"===this.ast.cmdName?this.node=new z.Html(xe(t[0]),this.parent,t[1]):this.node=new z.Text(xe(t[0]),this.parent),void this.appendNode()}throw new Error("Command not found: "+this.ast.cmdName)}changeValue(e){this.node&&(this.node instanceof z.Html?this.node.html=xe(e):this.node.text=xe(e),this.ext.render?.updateNode(this.node))}}function xe(e){return null==e||"function"==typeof e?"":e.toString()}const Ae="default";class Oe extends Ee{parser(){let e=this.transformParam();this.node=new z.RenderSection(e.id,this.parent),this.node.params=e.params,this.node.section??=this.ob.$sections?.[e.id],this.appendNode(),this.node.section&&(this.node.section.params?(this.node.ob=Object.create(this.node.section.ob||this.ob),this.node.section.params?.forEach(((e,t)=>{W(this.node.ob,e,this.node.params[t])}))):this.node.ob=this.node.section.ob||this.ob,(this.node.section.parser||this.ext).parserNodes(this.node.section.asts,this.node,this.node.ob))}transformParam(){if(this.ast.param){let e=this.runExpressWithWatcher(`[${this.ast.param}]`,this.ob,(e=>{let t=e?.[0]||Ae;if("string"==typeof t&&t!==this.node.id)throw new Error("The section ID cannot be dynamically changed");this.node.params=e.slice(1),this.node?.ob&&this.node.section&&this.node.section.params?.forEach(((e,t)=>{this.node?.ob&&this.node.ob[e]!==this.node.params[t]&&(this.node.ob[e]=this.node.params[t])}))}),!0,(()=>this.ast._code));return{id:e?.[0]||Ae,params:e?.slice(1)||[]}}return{id:Ae,params:[]}}}const Se="Component Parsing";function Pe(e,t){return!!t.components[e]||!!Ze(e)}class Te extends Ee{loadPromise;parser(){if(this.ast.node)return this.node=this.ast.node,this.node.parent=this.parent,this.initPropData(),void(this.node&&(this.appendNode(),this.node.component?.$mount(this.node)));this.node=new z.Component(this.parent),this.initPropData(),this.appendNode(),this.initEvent(),this.loadPromise=this.renderChildren(),this.ext.promiseQueue.add(this.loadPromise),this.loadPromise.finally((()=>{this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0)}))}get canReload(){return"tagName"in this.ast||"function"==typeof this.ast.component}reload(){this.canReload?(this.beforeDestroy(),this.renderChildren()):C.warn(Se,"Reload operation is not supported for the current component",this.node)}initPropData(){for(let e of this.ast.attributes)if("ref"!==e.name)if("keep-alive"===e.name&&"false"!==e.value&&(this.node.keepalive=!0),e.express){let t=this.runExpressWithWatcher(e.express,this.ob,(t=>{this.node.propValues[e.name]=t,this.notifyNodeWatcher("update",e.name)}),!0,(()=>{if(e.value)return`express:${e.value} \nfrom <${"tagName"in this.ast?this.ast.tagName:"Component"} ${e.name}="${e.value}" ... /> `}));this.node.propValues[e.name]=t}else this.node.propValues[e.name]=e.value;else{if(g(e.value)){C.warn(Se,"The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}this.node.propValues=K(this.node.propValues)}initEvent(){this.ast.events.forEach((e=>{let t=e.functionName?this.ob[e.functionName]:void 0;void 0===e.functionName?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:b}]):t&&"function"==typeof t?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{let s=[];e.functionParam&&(s=this.runExpress(`[${e.functionParam}]`,this.ob,(()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code} \nfrom: <${"tagName"in this.ast?this.ast.tagName:"Component"} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}}))),t.call(this.ext.ob,n,...s)}}]):C.error(Se,`The callback method (${e.functionName}) specified for the ${e.name} event in the ${"tagName"in this.ast?this.ast.tagName:""} element was not found. Please check.`)}))}async renderChildren(){return new Promise((async(e,t)=>{if("tagName"in this.ast){let e=this.ob.components[this.ast.tagName]||Ze(this.ast.tagName);if(void 0===e)return void C.error(Se,`Failed to render component. Private or global component named '${this.ast.tagName}' not found.`);if(qe in e||(e=(await e()).default),!this.node)return;{let t=this.getSections();this.node.name=this.ast.tagName,this.node.component=new e(this.node?.propValues,t,this.node?.keepalive)}}else if("function"==typeof this.ast.component){let e=this.getSections();this.node.component=new this.ast.component(this.node?.propValues,e,this.node?.keepalive)}else this.node.component=this.ast.component;if(!this.node)return;!this.node.name&&"name"in this.node.component&&this.node.component.name&&"string"==typeof this.node.component.name&&(this.node.name=this.node.component.name);let n=this,s=function(){n.loadPromise&&e(void 0)};if(this.node.component.$on("mounted",(()=>{this.node?.component.$off("beforeDestroy",s),e(void 0)})),this.node.component.$on("beforeDestroy",s),this.node.component.$mount(this.node),!this.node)return;let i=this.node?.component;i.isKeepAlive&&(this.ast.node=this.node)}))}getSections(){let t={},s=[];return this.ast.childrens.forEach((t=>{if(t.type===n.NodeType.COMMAND&&"if"===t.cmdName&&t.childrens){let i=t,o=t.childrens.some((e=>e.type===n.NodeType.COMMAND&&"section"===e.cmdName)),r=i.condition.startsWith(e+".$sections");if(r){return this.runExpress(i.condition,this.ob,(()=>i._code))?void s.push(...t.childrens):void 0}if(o&&"if"===i.kind&&!r)return void C.warn(Se,"While parsing the section, it was found that this section is wrapped in a conditional statement. This conditional statement only supports if judgments using $sections. It has been excluded.")}s.push(t)})),s.forEach((e=>{if(e.type===n.NodeType.COMMAND&&"section"===e.cmdName){let n=e,s=n.id||Ae;/^(\'|\")(.*?)((\'|\"))$/.test(s)&&(s=s.slice(1,-1)),t[s]=t[s]||{asts:[],ob:this.ob,params:n.paramKeys,parser:this.ext},t[s].asts.push(...e.childrens||[])}else t[Ae]=t[Ae]||{asts:[],ob:this.ob,parser:this.ext},t[Ae].asts.push(e)})),t}beforeDestroy(e){this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0),!0===e&&this.node?.component?.isKeepAlive?this.node?.component?.$destroy():(this.node?.component?.$destroy(!0),this.ast.node=void 0)}}class De extends Ee{parser(){this.node=new z.Element(this.ast.tagName,this.parent),this.initAttributes(),this.initEvents(),this.appendNode(),this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}initAttributes(){for(let e of this.ast.attributes)if("ref"!==e.name)if(e.express){let t=t=>{this.node&&(this.node.attributes[e.name]=this.transformAttrVal(t),this.ext.render?.updateNode(this.node,e.name),this.notifyNodeWatcher("update",e.name))},n=this.runExpressWithWatcher(e.express,this.ob,(e=>{t(e)}),!1,(()=>{if(e.value)return`express:${e.value} \nfrom <${this.ast.tagName} ${e.name}="${e.value}" ... /> `}));this.node.attributes[e.name]=this.transformAttrVal(n)}else this.node.attributes[e.name]=e.value;else{if(g(e.value)){C.warn("Element","The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}}initEvents(){for(let e of this.ast.events){let t=e.functionName?this.ob[e.functionName]:void 0;if(!(void 0===e.functionName||t&&"function"==typeof t))throw new Error(`The callback method (${e.functionName}) specified for the ${e.name} event in the ${this.ast.tagName} element was not found. Please check.`);this.node?.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{if(void 0===t)return;let s=[];e.functionParam&&(s=this.runExpress(`[${e.functionParam}]`,this.ob,(()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code}\nfrom <${this.ast.tagName} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}}))),t&&t.call(this.ext.ob,n,...s)}}])}}transformAttrVal(e){return void 0!==e&&("string"==typeof e||"boolean"==typeof e||"function"!=typeof e&&Object.prototype.toString()?e:void 0)}}class _e{asts;ob;root=new z.Root;refs={};sleeped=!1;promiseQueue=new Set;nodeWatcherEvents={};render;constructor(e,t,n){this.asts=e,this.ob=t,this.root.component=t,this.render=q.get(ee.IRENDERIOCTAGID)??new ee.DomRender,n&&n instanceof z.Node&&(this.root.parent=n,n.childrens??=[],n.childrens.push(this.root))}parser(){this.parserNodes(this.asts,this.root)}mount(e){this.sleeped&&this.weakup(),this.render?.mount(e)}parserNodes(e,t,s){if(0!==this.asts.length)for(let i of e)if(i.type===n.NodeType.TEXT)new be(i,s??this.ob,t,this).init();else if(i.type===n.NodeType.COMMENT)new we(i,s??this.ob,t,this).init();else if(i.type===n.NodeType.COMPONENT)new Te(i,s??this.ob,t,this).init();else if(i.type===n.NodeType.ELEMENT){let e=i;Pe(e.tagName,s??this.ob)?new Te(e,s??this.ob,t,this).init():new De(e,s??this.ob,t,this).init()}else if(i.type===n.NodeType.COMMAND){let e=i;switch(e.cmdName){case"if":case"elseif":case"else":new Ne(e,s??this.ob,t,this).init();break;case"for":new $e(e,s??this.ob,t,this).init();break;case"RenderSection":new Oe(e,s??this.ob,t,this).init();break;case"section":break;default:new Ce(e,s??this.ob,t,this).init()}}}addRef(e,t){this.refs[e]=this.refs[e]||[],this.refs[e].push(t),t.ref=e}removeRef(e){for(let t in this.refs)this.refs[t].includes(e)&&y(this.refs[t],e)}addNodeWatcher(e,t){this.nodeWatcherEvents[e]=this.nodeWatcherEvents[e]||[],this.nodeWatcherEvents[e].push(t)}removeNodeWatcher(e,t){y(this.nodeWatcherEvents[e]||[],t)}notifyNodeWatcher(e,t,n,s){this.nodeWatcherEvents[e]?.forEach((e=>{e(t,n,s)}))}sleep(e){let t=e||this.root;t.childrens?.forEach((e=>{let t=()=>{e.childrens&&this.sleep(e),e.sleep=!0,this.render?.removeNode(e,!0)};this.nodeTransition(e,"leave",void 0,(()=>{t()}))||t()})),void 0===e&&(this.sleeped=!0)}weakup(e){let t=e||this.root;t.childrens?.forEach((e=>{e.sleep=!1,this.render?.appendNode(e),e.childrens&&this.weakup(e),this.nodeTransition(e,"enter")})),void 0===e&&(this.sleeped=!1)}destroy(e){for(;this.root.childrens.length;){let t=this.root.childrens[0];t[z.PARSERKEY]?t[z.PARSERKEY].destroy(e):y(this.root.childrens,t)}this.render.destroy(),this.refs={},this.root.childrens.length=0,this.nodeWatcherEvents={},this.asts.length=0}destroyWathcers(){for(let e of this.root.childrens)e[z.PARSERKEY]&&e[z.PARSERKEY].destroyWathcers()}reSetAsts(e,t){this.destroy(t),this.render=q.get(ee.IRENDERIOCTAGID)??new ee.DomRender,this.asts=e}nodeTransition(e,t,n,s,i){if(e&&e.parent?.childrens&&(e instanceof z.Element||e instanceof z.Component)){let o=function(e){if(e instanceof z.Element||e instanceof z.Component){let t=e instanceof z.Element?e.attributes:e.propValues;return{name:t["transition-name"],type:t["transition-type"]}}}(e);if(n??=o?.name,i??=o?.type,!n)return!1;let r=ke(e);if(r)return"enter"===t?this.render.elementToEnter(r,n,i,(()=>{let t=e[z.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-enter"),s?.()})):this.render.elementToLeave(r,n,i,(()=>{let t=e[z.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-leave"),s?.()})),!0;C.warn("Render Core","Incomplete data found when executing node animation, please check")}return!1}}function ke(e){if(e instanceof z.Element)return e;if(e.childrens&&e.childrens.length)for(let t of e.childrens)return t instanceof z.Element?t:ke(t)}function Ke(e,t,n){if(void 0===t)return;const s=Array.isArray(n)?n:[n];for(const e of s){if(e===Array&&Array.isArray(t))return t;if(typeof t===e.name.toLowerCase())return t}switch(s[0]){case Number:const e=Number(t);if(!isNaN(e))return e;break;case String:return String(t)}throw new Error(`The type of ${e.toString()} in props does not match the constrained type`)}function We(e,t,n){let s,i,o;if("symbol"!=typeof t&&(s=E(t)),t in e?i=e[t]:s&&(i=e[s]),n&&(t in n?o=n[t]:s&&s in n&&(o=n[s])),void 0!==o){if(u(o)&&("type"in o||"required"in o||"default"in o||"validate"in o)){const e=o;if(e.required&&void 0===i)throw new Error(`props key:${t.toString()} is required, please check`);if(e.type&&(i=Ke(t,i,e.type)),e.validate&&!1===e.validate(i))throw new Error(`Validation failed for props key ${t.toString()}`);i=i??e.default}else i=Ie(o)?Ke(t,i,o):i??o;return i}return i}function Ie(e){return!![String,Array,Number,Object,Function,Boolean].includes(e)||!!Array.isArray(e)&&Ie(e[0])}function Ve(e,t){if(!e.constructor)return!1;let n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);return n&&n.get}const Le="Component",Me=Symbol.for("JOKER_PROPS_DATA_KEY"),je=Symbol.for("JOKER_PROPS_DATA_PROXY"),Ye=Symbol.for("JOKER_PRIVATE_WATCHERS"),Be=Symbol.for("JOKER_EVENT_DATA_KEY"),He=Symbol.for("JOKER_IS_DESTROY"),Je=Symbol.for("JOKER_PARSER_TEMPLATE_TARGET"),Fe=Symbol.for("JOKER_SCOPE_ID"),qe=Symbol.for("JOKER_COMPONENT_TAG"),Ge=Symbol();let ze=["constructor","$mount","$nodeTransition","$destroy","$getRef","$getRefs","$syncProp","$watchNode","$watch","$on","$off","$trigger","$render","created","mounted","beforeDestroy","sleeped","wakeup","destroyed"];class Qe{$sections;isKeepAlive;static[qe]=!0;[Fe];model={};template;$root;isSleeped=!1;components={};propsOption;[Me]={};[Je];[je];[Ye]=[];[Be]=new Map;[He]=!1;[Ge]=!1;constructor(e,t={},n){this.$sections=t,this.isKeepAlive=n,this[Me]=e||{}}get props(){if(void 0===this[je]){let e=this;this[je]=new Proxy(e[Me],{get:(t,n)=>We(e[Me],n,e.propsOption),set(){throw new Error("props parameters are not allowed to be changed, only one-way data transfer is allowed")}})}return this[je]}$mount(e){if(!1===this[Ge]){let e=()=>{let e=[],t=Object.getPrototypeOf(this);for(;null!==t&&t!==Object.prototype;)Object.getOwnPropertyNames(t).forEach((n=>{!1!==ze.includes(n)||Ve(t,n)||"function"!=typeof t[n]||t[n].prototype?.hasOwnProperty("constructor")||e.push(n)})),t=Object.getPrototypeOf(t);return e};for(let t of e())this[t]=this[t].bind(this);this[Ge]=!0}if(this.$root=e,this.isKeepAlive&&this.isSleeped)return this.isSleeped=!1,this[Je]&&this.$root?(this[Je].mount(this.$root),this.wakeup(),this.$trigger("wakeup"),this.$rootVNode&&tt(this.$rootVNode),this):(C.error(Le,"When attempting to wake up the current component, it was found that the rendering handler has been destroyed. The wake-up operation cannot proceed.",[this,this.$root]),this);this.isSleeped=!1,this.model=K(this.model);let t=this.created(),n=async()=>{this.$trigger("created"),this.template&&this.$render(),await this.$nextUpdatedRender(),this[He]||(await this.mounted(),this[He]||this.$trigger("mounted"))};return t&&t instanceof Promise?t.then((()=>{this[He]||n()})):n(),this}$nextUpdatedRender(e){if(this[He])return;let t=[...this[Je]?.promiseQueue||[]],n=this.$rootVNode?.find((e=>e instanceof z.Component));if(n?.forEach((e=>{e?.component&&t.push(...e.component[Je]?.promiseQueue||[])})),t.length)return Promise.all(t).finally((()=>{this[He]||e?.()}));this[He]||e?.()}$nodeTransition(e,t,n,s,i){if("string"==typeof e){let t=this.$getRef(e);if(!t)return void C.error(Le,`Node with ref=${e} not found when executing node animation`);e=t}this[Je]?.nodeTransition(e,t,n,s,i)}$destroy(e){if(!e&&this.isKeepAlive)return this[Je]?.sleep(),this.isSleeped=!0,this.sleeped(),this.$trigger("sleeped"),void(this.$rootVNode&&et(this.$rootVNode));this[He]=!0;for(let e of this[Ye])e.destroy();this[Ye].length=0,this[Je]?.destroyWathcers(),this.beforeDestroy(),this.$trigger("beforeDestroy"),this[Je]?.destroy(),this[Je]=void 0,this.template&&Array.isArray(this.template)&&(this.template.length=0),this.$trigger("destroy"),this[Be].clear(),this.$root=void 0,this.isSleeped=!1,this.$sections={},this[je]=void 0,this[Me]={},this.destroyed()}get $refs(){return this[Je]?.refs||{}}$getRef(e){return this.$refs[e]?.[0]}$getRefs(e){return this.$refs[e]}$syncProp(e,t,n){"function"==typeof t&&(n=t,t=void 0),t??=e,n??=e=>e,this.model[t]=n(this.props[e]),this.$watch((()=>this.props[e]),(()=>{this.model[t]=n?.(this.props[e])}))}get $rootVNode(){return this[Je]?.root}$watchNode(e,t){if(this[Je])return this[Je]?.addNodeWatcher(e,t),()=>{this[Je]?.removeNodeWatcher(e,t)};C.warn(Le,"Component is not yet mounted. Node observation and monitoring cannot be performed.")}$watch(e,t,n){let s=new F((()=>{if(this[He]){for(let e of this[Ye])e.destroy();return J}return e()}),((e,n)=>{this[He]||t(e,n)}),void 0,n);return this[Ye].push(s),[s.value,()=>{s.destroy(),y(this[Ye],s)}]}$on(e,t){let n=this[Be].get(e);void 0===n&&(n=new Set,this[Be].set(e,n)),!1===n?.has(t)&&n.add(t)}$off(e,t){let n=this[Be].get(e);n&&(t?n.delete(t):n.clear())}$trigger(e,t,n){if(!this.$root)return;let s={eventName:e,stopPropagation:n?.stopPropagation??(()=>{}),preventDefault:n?.preventDefault??(()=>{}),data:t,target:n?.target??this.$rootVNode,event:n?.event};if(this.$rootVNode&&this.$rootVNode.parent&&this.$rootVNode.parent instanceof z.Component&&!1===this[Je]?.render.triggerEvent(this.$rootVNode.parent,e,s))return;let i=this[Be].get(e);i?.size&&[...i].forEach((e=>{e(s)}));let o=this[Be].get("*");o?.size&&[...o].forEach((e=>{e(s)}))}$render(e,t){e??=this.template,this.template="function"==typeof e?e(s):e,this.$root&&(this.template??=[],this[Je]?.reSetAsts(this.template,t),this[Je]??=new _e(this.template,this,this.$root),this[Je].parser(),this.$root&&this[Je].mount(this.$root))}created(){}mounted(){}beforeDestroy(){}sleeped(){}wakeup(){}destroyed(){}}const Ue={};function Xe(e,t){if("string"==typeof e)t&&(Ue[e]=t);else for(let t in e)Ue[t]=e[t]}function Ze(e){return Ue[e]}function et(e){e.childrens?.forEach((e=>{e instanceof z.Component&&e.component?.sleeped(),et(e)}))}function tt(e){e.childrens?.forEach((e=>{e instanceof z.Component&&e.component?.wakeup(),tt(e)}))}class nt extends Qe{template=[];cache=new Map;async mounted(){this.$watch((()=>this.props.name),(async e=>{this.$render([],!0),await Promise.resolve(),this.$root&&this.loadComponent(e)})),await this.loadComponent(this.props.name)}propsVaule;created(){this.initProps()}initProps(){let e={};this.props.props||(Object.keys(this.props).forEach((t=>{!1!==this.filterProps(t)&&(e[t]=this.props[t],this.$watch((()=>this.props[t]),(()=>{this.propsVaule[t]=this.props[t]})))})),this.propsVaule=K(e))}filterProps(e){if("string"!=typeof e)return!1;let t=E(e);return"transition-name"!==t&&"name"!==t&&"keep-alive"!==t&&"ref"!==t&&void 0}async loadComponent(e){if(!e)return void this.$render([],this.isKeepAlive);let t;if(this.isKeepAlive){let t=this.cache.get(e);if(t)return void this.$render([i(t,{"transition-name":this.props["transition-name"]})],!0)}let n=this.$rootVNode?.parent?.[z.PARSERKEY]?.ob.components,s=n?.[e];void 0===s&&(s=Ze(e)),s?(qe in s||(s=(await s()).default),t=new s(this.props.props||this.propsVaule,this.$sections,this.isKeepAlive),t.$on("*",(e=>{this.$trigger(e.eventName,e.data,e)})),this.isKeepAlive&&this.cache.set(e,t),this.$render([i(t,{"transition-name":this.props["transition-name"]})],this.isKeepAlive)):C.warn("component",`Component ${e} not found`)}beforeDestroy(){this.removeCache()}removeCache(e){if(e){let t=this.cache.get(e);this.cache.delete(e),t&&t.$destroy(!0)}else this.cache.forEach((e=>{e.$destroy(!0)})),this.cache.clear()}}class st extends Qe{template=function(){return[o("RenderSection")]};async mounted(){await this.$nextUpdatedRender()}}Xe({template:st,component:nt});class it{eventDatas=new Map;on(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const s={callBack:t};return n.push(s),()=>{n&&y(n,s)}}once(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const s={callBack:t,once:!0};return n.push(s),()=>{n&&y(n,s)}}off(e,t){if(void 0!==e)if(t){const n=this.eventDatas.get(e),s=n?.find((e=>e.callBack===t));s&&y(n,s)}else this.eventDatas.delete(e);else this.eventDatas.clear()}async trigger(e,t){let n=[...this.eventDatas.get(e)||[]];if(n.push(...this.eventDatas.get("*")||[]),n&&n.length){let s=0,i=0,o=!1;for(;n[s];){const r=n[s],a=await r.callBack({stopPropagation:()=>o=!0,callTimes:i,eventName:e},t);if(r.once?y(n,r):s++,!1===a||o)return!1}}}}export{J as BREAK_WATCH_UPDATE,Qe as Component,nt as ComponentContainer,O as Dep,it as EventBus,q as IContainer,He as IS_DESTROY,qe as JOKER_COMPONENT_TAG,G as JOKER_VNODE_TAG,S as OBJECTPROXY_DEPID,Je as PARSER_TEMPLATE_TARGET,_e as ParserTemplate,ee as Render,Fe as SCOPE_ID,V as ShallowObserver,st as Template,z as VNode,F as Watcher,pe as __GLONAL_FUNTIONS__,d as __JOKER_HMR_RUNTIME,Y as combinedReply,W as defineObserverProperty,Ze as getGlobalComponent,B as isObserverData,K as observer,Xe as registerGlobalComponent,me as registerGlobalFunction};