@jiess/core
Version:
基于javascript的配置式渲染库,同时支持vue2,vue3和react
1 lines • 48.4 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.JiessEnv=t():e.JiessEnv=t()}(globalThis,()=>(()=>{"use strict";var e={d:(t,s)=>{for(var r in s)e.o(s,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:s[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>we});const s=new Set(["@keyframes","@-webkit-keyframes","@-moz-keyframes","@-o-keyframes","@font-face","@import","@charset","@namespace","@layer","@media","@supports","@page","@counter-style","@font-feature-values","@property","@color-profile"]);class r{static classify(e){if(!e||"string"!=typeof e||!e.trim())return{isolated:"",global:""};const t=this.splitRules(e),s=[],r=[];for(const e of t)this.isGlobalRule(e)?r.push(e):s.push(e);return{isolated:s.join("\n"),global:r.join("\n")}}static splitRules(e){const t=[];let s=0,r=0;for(let n=0;n<e.length;n++){const o=e[n];if("{"===o)s++;else if("}"===o&&(s--,0===s)){const s=e.substring(r,n+1).trim();s&&t.push(s),r=n+1}}if(r<e.length){const s=e.substring(r).trim();s&&t.push(s)}return t}static isGlobalRule(e){const t=e.trim();for(const e of s)if(t.startsWith(e))return!0;return!!t.includes(":global")}}class n{static mount(e,t){t.isolated&&this.insertRules(e.isolated,t.isolated),t.global&&this.insertRules(e.global,t.global)}static mountStyleInfo(e,t,s){for(const n of s){if(!n.style||!n.style.trim())continue;const s=r.classify(n.style);s.isolated&&this.insertRules(e,s.isolated),s.global&&this.insertRules(t,s.global)}}static mountStyle(e,t){if(!e||"object"!=typeof e)throw new Error("jiessEnv 必须是有效的环境对象");if(!Array.isArray(t))throw new Error("styleInfo 必须是数组类型");if("undefined"!=typeof window){if(!e.styleNode)return Array.isArray(e.recordStyleInfo)||(e.recordStyleInfo=[]),void e.recordStyleInfo.push(...t);try{const s=e.styleNode.sheet;t.forEach(({style:e})=>{if(e&&"string"==typeof e&&e.trim())try{e.split("}").filter(e=>e.trim()).forEach(e=>{e.trim()&&s.insertRule(e+"}",s.cssRules.length)})}catch(e){console.error("StyleInjector.mountStyle: 插入 CSS 规则失败",e)}})}catch(e){console.error("StyleInjector.mountStyle 执行失败:",e)}}else console.warn("StyleInjector.mountStyle: 非浏览器环境,样式挂载被跳过")}static insertRules(e,t){const s=t.split("}").filter(e=>e.trim());for(const t of s)if(t.trim())try{e.insertRule(t+"}",e.cssRules.length)}catch(e){console.error("StyleInjector.insertRules: 插入规则失败",e)}}}class o{_disposed=!1;_resources=[];add(e){if(this._disposed)throw new Error("ResourceManager has been disposed");return this._resources.push(e),this}remove(e){if(this._disposed)return;const t=this._resources.indexOf(e);-1!==t&&this._resources.splice(t,1)}get disposed(){return this._disposed}dispose(){if(!this._disposed){this._disposed=!0;for(let e=this._resources.length-1;e>=0;e--)try{this._resources[e].dispose()}catch(e){}this._resources=[]}}get size(){return this._resources.length}}const i="JIESS_CONSTRUCTOR",c="isJiess",a="THIS_IS_JIESS",l="JIESS_INIT_VALUE",h="__JIESS_REF__",f="__JIESS_COMPUTED__",u="__JIESS_PARENT__",p=new Set(["is","component","$exclude"]),d=(e,t)=>Array.isArray(e)?[...e]:P(e,"object")?{...e}:t?void(()=>{throw new Error("shallowCopy Error:须提供对象或数组")})():e;function y(e){return!(!e||"object"!=typeof e||!e[a])}const g=e=>!!P(e,"object")&&Reflect.has(e,"$proxy"),_=e=>{if(g(e)){const{$proxy:t,field:s="value"}=e;return t[s]}return e},m=(e,t)=>{throw new Error(`${e} Error:${t}`)};function b(e,t,s=N,r="数据类型"){return P(e,t)?s():m(r,`须提供 ${t} 类型`)}const v=(e,t,s=i)=>!!P(e,"object")&&Object.is(e[s],t),w=e=>null!==e&&"object"==typeof e&&(!!y(e)||(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||(e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer||(e instanceof Promise||(!!(Reflect.has(e,"__v_isReactive")||Reflect.has(e,"__v_isReadonly")||Reflect.has(e,"$")||Reflect.has(e,"_")||Reflect.has(e,"__")||Reflect.has(e,"is")||Reflect.has(e,"$slots")||Reflect.has(e,"$$typeof")||Reflect.has(e,"nodeType"))||(!!Object.keys(e).some(e=>e.startsWith("__v_")||e.startsWith("__react")||e.startsWith("El")||e.startsWith("a-")||e.startsWith("van-"))||"function"==typeof e.install))))));function x(e={},t="toString"){if("function"==typeof e[t]){if("string"==typeof t){const s=new RegExp(t,"g");return(e[t]+"").replace(s,"")}return e[t]+""}return""}const j=(()=>{const e=x();return(t,s)=>x(t,s)===e})(),S=(e,t,s={})=>(e.has(t)?s=e.get(t):e.set(t,s),s),R=e=>v(e,"JsRender");function $(e,t){R(e)?t(e):Array.isArray(e)&&e.forEach(e=>{R(e)&&t(e)})}function O(e){$(e,e=>{O(e._resData.children),e.destroy()})}const C=!0,E=e=>{const{$proxy:t,field:s,done:r}=e;return r?r(t):s?t[s]:t},A=(e,t)=>Array.isArray(e)?function(e){let t=null;return e.filter(e=>{if(R(e)){const s=e,{_resConfig:r}=s;let{$if:n=C,$elseIf:o}=r;if(n=_(n),o=_(o),W(o,!0)){"boolean"!=typeof t&&m("$elseIf","须配合$if");const e=!t&&!!o;return t=e,e}if(r.hasOwnProperty("$if")){const e=!!n;return t=e,e}return t=null,n}return t=null,!0})}(e).map(A):R(e)?e.getNative(t):W(e)?e:void 0;function k(e,t,s=new WeakMap){if(Object.is(e,t))return!0;const r=typeof e;if(r!==typeof t)return!1;if(!e||!t||"object"!==r)return!1;if(s.has(e)&&s.has(t))return s.get(e)===t&&s.get(t)===e;s.set(e,t),s.set(t,e);const n=Object.prototype.toString.call(e);if(n!==Object.prototype.toString.call(t))return!1;switch(n){case"[object Date]":return e.getTime()===t.getTime();case"[object Promise]":return!1;case"[object Function]":case"[object RegExp]":case"[object Symbol]":return String(e)===String(t);case"[object ArrayBuffer]":case"[object SharedArrayBuffer]":if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),n=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==n[t])return!1;return!0;case"[object BigInt]":return e===t;case"[object TypedArray]":return JSON.stringify(Array.from(e))===JSON.stringify(Array.from(t));case"[object Map]":if(e.size!==t.size)return!1;for(const[r,n]of e)if(!t.has(r)||!k(n,t.get(r),s))return!1;return!0;case"[object Set]":if(e.size!==t.size)return!1;const o=[...e],i=[...t];for(let e=0;e<o.length;e++){let t=!1;for(let r=0;r<i.length;r++)if(k(o[e],i[r],s)){t=!0;break}if(!t)return!1}return!0}if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!k(e[r],t[r],s))return!1;return!0}const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;const c=new Set(i);for(let r of o)if(!c.has(r)||!k(e[r],t[r],s))return!1;return!0}const M=(e,t,s=!0)=>{if(Object.is(e,t))return!0;const r=typeof e;if(r!==typeof t)return!1;if(!e||!t||"object"!==r)return!1;if(s)if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++){const r=e[s],n=t[s];if(!Object.is(r,n)){if(typeof r!=typeof n)return!1;if(!r||!n||"object"!=typeof r)return!1}}}else{if(Array.isArray(t))return!1;{const s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;const n=new Set(r);for(const r of s){if(!n.has(r))return!1;const s=e[r],o=t[r];if(!Object.is(s,o)){if(typeof s!=typeof o)return!1;if(!s||!o||"object"!=typeof s)return!1}}}}let n=e,o=t;if(s){const s=(e,t)=>{if(!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(w(e))return e;const r=Array.isArray(e)?[]:{};t.set(e,r);for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Array.isArray(r)?r[Number(n)]=s(e[n],t):r[n]=s(e[n],t));return r},r=new WeakMap;n=s(e,r),o=s(t,r)}return k(n,o,new WeakMap)},N=(...e)=>{};function T(e,t,s=!0){if(Array.isArray(t))return t.some(t=>T(e,t));if("string"==typeof t){const e=t.toLowerCase();"exp"!==e&&"regex"!==e||(t="RegExp")}else if(s)throw new Error(`${t} Error:须提供字符串`);const r="string"==typeof t?t.charAt(0).toUpperCase()+t.slice(1):t,n=Object.prototype.toString.call(e)===`[object ${r}]`;if(!n&&"Object"===r&&null!==e&&"object"==typeof e){const t=Object.prototype.toString.call(e);return t.includes("ArrayBuffer")||t.includes("TypedArray")||t.startsWith("[object ")}return n}const P=T,I=(e,t,s=new WeakMap)=>{if(!e||"object"!=typeof e){if(t){const s=t(e,"filter");return void 0!==s?s:void 0}return e}if(s.has(e))return s.get(e);if(e instanceof Date){const t=new Date(e.getTime());return s.set(e,t),t}if(e instanceof RegExp){const t=new RegExp(e.source,e.flags);return s.set(e,t),t}if(w(e)){const s=t?.(e,"filter");return void 0!==s?s:e}let r;if(r=Array.isArray(e)?new Array(e.length):{},s.set(e,r),Array.isArray(e))for(let n=0;n<e.length;n++){const o=I(e[n],t,s);void 0!==o&&(r[n]=o)}else{for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const o=I(e[n],t,s);void 0!==o&&(r[n]=o)}Object.getOwnPropertySymbols(e).forEach(n=>{const o=I(e[n],t,s);void 0!==o&&(r[n]=o)})}if(t){const e=t(r,"clone");if(void 0!==e)return e}return r},D=(e,t)=>!(!t||""!==e)||[null,void 0,NaN].some(t=>Object.is(t,e)),W=(e,t)=>!D(e,t);function J(){let e=null;return(t,...s)=>(e||(e=Promise.resolve().then(()=>(e=null,t.call(this,...s)))),e)}const U=(e,t=!1)=>{let s;return function(r,n=100){const o=()=>"function"==typeof e?e():"function"==typeof r?r():void 0;W(s,!0)?clearTimeout(s):t&&o(),s=setTimeout(o,n)}};(((U(),e=>{let t;return function(s,r=100){W(t,!0)&&clearTimeout(t),t=setTimeout(()=>"function"==typeof e?e():"function"==typeof s?s():void 0,r)}})(),e=>{let t=!0;return function(s,r=100){t&&(t=!1,setTimeout(()=>{t=!0,"function"==typeof e?e():"function"==typeof s&&s()},r))}})(),e=>{let t,s=0;return function(r,n=100){const o="function"==typeof e?e:r;let i=Date.now();i-s>=n?(s=i,"function"==typeof o&&o()):W(t,!0)||(t=setTimeout(()=>{s=Date.now(),t=void 0,"function"==typeof o&&o()},n))}})(),"undefined"==typeof window||"undefined"==typeof document||!window.document||window.document.createElement;class V extends Error{code;timestamp;context;constructor(e,t,s){super(e),this.name="JiessError",this.code=t,this.timestamp=Date.now(),this.context=s,Error.captureStackTrace&&Error.captureStackTrace(this,V)}toJSON(){return{name:this.name,message:this.message,code:this.code,timestamp:this.timestamp,context:this.context,stack:this.stack}}}class F extends V{constructor(e,t){super(e,"JIESS_ADAPTER_ERROR",t),this.name="AdapterError"}}class B extends V{constructor(e,t){super(e,"JIESS_COMPONENT_CREATION_ERROR",t),this.name="ComponentCreationError"}}class K{static uid=1;constructor(e,t={}){this[i]=e,this.J_uid=K.uid++,"function"==typeof t&&(t=t(this)),Object.assign(this,t),this.bindCxt()}bindCxt(){for(const e of Reflect.ownKeys(this.__proto__))if("constructor"!==e&&"string"==typeof e){if(e.startsWith("_"))continue;const t=Object.getOwnPropertyDescriptor(this.__proto__,e);if(t&&t.get)continue;"function"==typeof this[e]&&(this[e]=this[e].bind(this)),this.freezeField(e)}}resetField(e,t){Object.prototype.hasOwnProperty.call(this,e)&&Object.defineProperty(this,e,{value:t})}freezeField(e){Object.prototype.hasOwnProperty.call(this,e)&&Object.defineProperty(this,e,{writable:!1,enumerable:!0,configurable:!0})}}class z extends K{watcher;fn;flush;effecting="start";value;computer=!1;debounce2;debounce1=U();dirty=!0;get isDirty(){return this.dirty}target;proxy;constructor(e,t,s="pre"){super("Composite"),this.watcher=e,this.fn=t,this.flush=s,this.debounce2=J.call(this)}initComputed(e,t){this.computer=!0,this.target=e,this.proxy=t}_initCounter=0;_initBaseTime=0;init(e,t,s,r){const n=Date.now();if(n-this._initBaseTime>1e3&&(this._initCounter=0,this._initBaseTime=n),!this.computer&&++this._initCounter>500)throw new Error(`[死循环检测] Composite.init 循环调用超过 500 次,key=${String(t)}`);return this.computer&&!this.dirty||(this.computer||("function"==typeof this.value&&this.value(),this.watcher.effecter.stop(this)),this.watcher.effecter.addCurrent(this),this.done(e,t,s,r),this.watcher.effecter.removeCurrent(),this.dirty=!1),this.value}done(e,t,s,r){return this.computer?"doned"===this.effecting?this.recomputeWithDependency(e,t,s,r):(this.effecting="start",this.value=this.fn(s,t,e,r),this.effecting="computed",this.computer&&(this.proxy.value=this.value),this.effecting="doned"):(this.effecting="start",this.value=this.fn(s,t,e,r),this.effecting="computed",this.effecting="doned"),this.value}recomputeWithDependency(e,t,s,r){this.effecting="start";try{this.value=this.fn(s,t,e,r),this.effecting="computed",this.computer&&(this.proxy.value=this.value)}finally{this.effecting="doned"}}check(e){this.computer?"start"===this.effecting?m("Computed","计算中禁止赋值"):"function"==typeof e&&e(e=>{this.target.value=e,this.watcher.effecter.trigger(this.target,"value",e,this.proxy)}):"function"==typeof e&&e()}trigger(e,t,s,r){this.dirty=!0,this.check((n=N)=>{"sync"===this.flush?n(this.init(e,t,s,r)):"pre"===this.flush?this.debounce2(()=>n(this.init())):this.debounce1(()=>n(this.init()),0)})}stop(){"function"==typeof this.value&&this.value(),this.watcher.effecter.stop(this)}}const L=new Set([Symbol.iterator,"constructor","__proto__","prototype",NaN,null,void 0,1/0]),H=new Set(["push","pop","shift","unshift","splice","sort","reverse"]);class G extends K{watcher;current;execStack=[];mapStore;reverseMap;collectCache;constructor(e){super("Effecter"),this.watcher=e,this.mapStore=new WeakMap,this.reverseMap=new WeakMap,this.collectCache=new WeakMap}addCurrent(e){this.current&&this.execStack.push(this.current),this.current=e,this.collectCache.set(e,new WeakMap)}removeCurrent(){this.current&&this.collectCache.delete(this.current),this.current=this.execStack.pop()}shouldExclude(e,t){return(!Array.isArray(e)||"string"!=typeof t||!H.has(t))&&(L.has(t)||j(e,t))}getCacheKey(e,t){try{return`${e.constructor.name}-${JSON.stringify(t)}-${e[Symbol.toStringTag]||""}`}catch(s){return`${e.constructor.name}-${String(t)}-${e[Symbol.toStringTag]||""}`}}collect(e,t){if(!this.current||"start"!==this.current.effecting)return;if(this.shouldExclude(e,t))return;const s=this.current,r=t,n=this.collectCache.get(s);if(n){const s=n.get(e);if(s&&s.has(t))return}const o=S(this.mapStore,e);if(o[r]=o[r]||new Set,o[r].add(s),this.mapStore.set(e,o),n){const s=n.get(e)||new Set;s.add(t),n.set(e,s)}const i=this.reverseMap.get(s)||new Set;i.add({target:e,key:r}),this.reverseMap.set(s,i)}trigger(e,t,s,r){if(this.shouldExclude(e,t))return;this.current?.check();const n=S(this.mapStore,e),o=t;if(n.hasOwnProperty(o)){const i=new Set(n[o]),c=new Set;i.forEach(n=>{n===this.current||c.has(n)||(n.trigger(e,t,s,r),c.add(n))})}this.watcher.update(r,t,s)}stop(e){const t=this.reverseMap.get(e);t&&(t.forEach(({target:t,key:s})=>{const r=this.mapStore.get(t);r&&r[s]&&(r[s].delete(e),0===r[s].size&&delete r[s],0===Object.keys(r).length&&this.mapStore.delete(t))}),this.reverseMap.delete(e),this.collectCache.delete(e))}}const q=new Set(["push","pop","shift","unshift","splice","sort","reverse"]);class Z extends K{watcher;_targetToProxy=new WeakMap;_childKeyMap=new WeakMap;constructor(e){super("Observer"),this.watcher=e}create(e,t,s=new WeakSet,r=!1){return w(e)&&"Target"!==e[i]?e:b(e,["array","object"],()=>{if(s.has(e))return this._targetToProxy.get(e)||e;s.add(e);const n=new Proxy(e,this.getProxyHandler(t));if(this._targetToProxy.set(e,n),!r)for(const t in e)if(!p.has(t)&&T(e[t],["array","object"])){const r=this.create(e[t],n,s,!1);this._childKeyMap.set(r,t),e[t]=r}return n},"创建响应式数据")}getProxyHandler(e){return{has:(e,t)=>(this.watcher.effecter.collect(e,t),t in e),get:(t,s,r)=>{if(s===a)return!0;if("__JIESS_TARGET__"===s)return t;if(s===u)return e;if(s===Symbol.toStringTag)return Array.isArray(t)?"Array":t instanceof Map?"Map":t instanceof Set?"Set":t instanceof Date?"Date":t instanceof RegExp?"RegExp":"Object";if(this.watcher.effecter.collect(t,s),v(t,!0,f)&&"value"===s)return t.getValue();if(t instanceof Map||t instanceof Set||t instanceof Date||t instanceof RegExp){const e=Reflect.get(t,s);return"function"==typeof e?e.bind(t):e}const n=Reflect.get(t,s,r);if(Array.isArray(t)&&"string"==typeof s&&q.has(s)){const e=this,n=Array.prototype[s];return function(...o){const i=t.length,c="sort"===s||"reverse"===s||"unshift"===s||"shift"===s,a=c?[...t]:null,l=n.apply(t,o);if("push"===s||"unshift"===s||"splice"===s){const n=[...o];"splice"===s&&n.splice(0,2),n.forEach((i,c)=>{if(T(i,["array","object"])&&!(i instanceof Map)&&!(i instanceof Set)&&!(i instanceof Date)&&!(i instanceof RegExp)){const a=new WeakSet,l=e.create(i,r,a,!1);let h=0;"push"===s?h=t.length-n.length+c:"unshift"===s?h=c:"splice"===s&&(h=o[0]+c),e._childKeyMap.set(l,h),t[h]=l}})}if("splice"===s)for(let s="number"==typeof o[0]?o[0]:0;s<t.length;s++){const r=t[s];r&&"object"==typeof r&&e._childKeyMap.has(r)&&e._childKeyMap.set(r,s)}else if("sort"===s||"reverse"===s||"shift"===s||"unshift"===s)for(let s=0;s<t.length;s++){const r=t[s];r&&"object"==typeof r&&e._childKeyMap.has(r)&&e._childKeyMap.set(r,s)}if(c&&a)for(let e=0;e<Math.max(i,t.length);e++)Object.is(a[e],t[e])||(r[e]=t[e]);else{let e=0,n=Math.max(i,t.length);"push"===s?(e=i,n=t.length):"pop"===s?(e=t.length,n=i):"splice"===s&&(e="number"==typeof o[0]?o[0]:0);for(let s=e;s<n;s++)r[s]=t[s]}return r.length=t.length,e.trigger(t,s,l,r),l}}return n},set:(t,s,r,n)=>{if(s===u)return e=r,!0;if(Object.is(t[s],r))return!0;const o=Reflect.set(t,s,r,n);return this.trigger(t,s,r,n),o},deleteProperty:(e,t)=>{if(t in e){const s=Reflect.deleteProperty(e,t),r=this._targetToProxy.get(e)||e;return this.trigger(e,t,void 0,r),s}return Reflect.deleteProperty(e,t)}}}trigger(e,t,s,r){const{effecter:n}=this.watcher;if(v(e,!0,f))e.setValue(s,t);else if(n.trigger(e,t,s,r),Array.isArray(e)&&"string"==typeof t&&q.has(t)&&n.trigger(e,"length",e.length,r),r&&r[u]){const e=r[u],t=this._childKeyMap.get(r);void 0!==t&&n.trigger(e,t,r,e)}}}const Q=(e,t)=>void 0===e?t:e;class X extends K{proxy;field;config;value;result;oldValue;isDestory=!1;cbs;debounce1;other;_resourceManager;get disposed(){return this._resourceManager.disposed}constructor(e,t,s={}){super("Observe"),this.proxy=e,this.field=t,this.config=s,this._resourceManager=new o,this.cbs=new Set,this.debounce1=U(),this._resourceManager.add({disposed:!1,dispose:()=>{this.debounce1=null}});const{hasKey:r,defaultValue:n,observe:i,...c}=s;this.other=c,this.observe(i),this.value=d(r?e[t]:e);const a=this.value=Q(this.value,n);this.getValue((e,t)=>{this.result=e,t&&this.dispatch(e,{value:a,...c})})}getValue(e){const{value:t,config:s,result:r}=this,{defaultValue:n,done:o}=s;"function"==typeof o?P(o,"AsyncFunction")?(o(t,this).then(t=>e(t,!0)).catch(e=>{console.error("Observe.getValue async done error:",e)}),e(Q(r,n))):e(o(t,this)):e(t)}observe(e){return"function"==typeof e&&this.cbs.add(e),this}remove(e){return"function"==typeof e&&this.cbs.delete(e),this}destroy(){this.dispose()}dispose(){this._resourceManager.disposed||(this.isDestory=!0,this._resourceManager.dispose(),this.cbs.clear(),this.proxy=null,this.field=null,this.config=null,this.other=null)}resolve(e){if(this.isDestory||!this.config)return;const t=this.value,s={value:e,oldValue:t,...this.other};let{isSync:r,hasKey:n,sameState:o=!1,done:i}=this.config;if(n){try{o=M(t,e)}catch(e){console.error(e)}this.value=d(e),this.oldValue=t,o&&"function"!=typeof i||this.getValue(e=>this.dispatch(e,s))}else{const t=()=>{this.value=d(e),this.getValue(e=>this.dispatch(e,s))};r?t():this.debounce1(()=>t(),0)}}dispatch(e,t){t.oldResult=this.result,t.result=this.result=e,this.cbs.forEach(s=>{s(e,t.oldResult,t)})}}class Y extends K{_setter;_composite;value;constructor(){super("Target"),this[a]=!0,this.value=l,this[f]=!0}initSetter(e){this._setter=e}initComposite(e){this._composite=e}getValue(){return(this.value===l||this._composite&&this._composite.isDirty)&&(this.value=this._composite?.init()),this.value}setValue(e,t){"value"!==t?m("Computed","仅允许对value赋值"):"function"==typeof this._setter?(this._setter(e),this.update()):"computed"===this._composite?.effecting||m("Computed","须提供setter")}update(){this._composite&&this._composite.trigger(this,"value",this.value,this)}}class ee extends K{static _default;static getDefault(){return ee._default&&!ee._default.disposed||(ee._default=new ee),ee._default}static _globalResourceManager;_proxyToObserve=new WeakMap;_proxyToObserveNo=new WeakMap;_pathCache=new WeakMap;_dependencyCache=new WeakMap;effecter;observer;_resourceManager;get disposed(){return this._resourceManager?.disposed??ee._globalResourceManager?.disposed??!1}constructor(){super("Watcher"),this._resourceManager=new o,this.observer=new Z(this),this.effecter=new G(this)}static getGlobalResourceManager(){return ee._globalResourceManager||(ee._globalResourceManager=new o),ee._globalResourceManager}clearProxyResources(e){this.clearObservers(e),this._proxyToObserve.delete(e),this._proxyToObserveNo.delete(e)}dispose(){this._resourceManager?.disposed||(this._resourceManager?.dispose(),ee._globalResourceManager&&!ee._globalResourceManager.disposed&&(ee._globalResourceManager.dispose(),ee._globalResourceManager=void 0),this._proxyToObserve=new WeakMap,this._proxyToObserveNo=new WeakMap,this._pathCache=new WeakMap,this._dependencyCache=new WeakMap,ee._default===this&&(ee._default=void 0))}static disposeAll(){ee.getGlobalResourceManager().dispose()}hasLoopReference(e,t=new WeakSet){if("object"!=typeof e||null===e)return!1;if(t.has(e))return!0;t.add(e);let s=0;const r=[{obj:e,keys:Object.keys(e),index:0}];for(;r.length>0&&s<1e3;){const e=r[r.length-1];if(!e)break;const{obj:n,keys:o,index:i}=e;if(i>=o.length){t.delete(n),r.pop(),s--;continue}const c=o[i];e&&(e.index=i+1);const a=n[c];if("object"==typeof a&&null!==a){if(t.has(a))return!0;t.add(a),r.push({obj:a,keys:Object.keys(a),index:0}),s++}}return r.forEach(e=>t.delete(e.obj)),!1}createProxy(e){let t=e;return this.hasLoopReference(e)&&(t=I(e)),this.observer?.create(t)}createShallowProxy(e){return this.observer?.create(e,void 0,new WeakSet,!0)}createComputed(e,t){const s=new Y,r=this.createProxy(s);if(P(e,"object")){const{get:t,set:r}=e;"function"==typeof t&&(e=t),"function"==typeof r&&s.initSetter(r)}const n=new z(this,e,t);return s.initComposite(n),n.initComputed(s,r),r}watchEffect(e,t){const s=new z(this,e,t);return s.init(),()=>s.stop()}observe(e={$proxy:{}}){let{$proxy:t,field:s,warn:r=!0,...n}=e,o=t,i=s;if("string"==typeof s&&s.includes(".")){let e=this._pathCache.get(t);e||(e=new Map,this._pathCache.set(t,e));const r=s,n=e.get(r);if(n)o=n.target,i=n.field;else{const n=s.split("."),c=n.pop(),a=function(e,t){if(!e||!t)return;let s;if(s=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=s.filter(Boolean),0===s.length)return;let r=e;for(const e of s)try{const t=Number(e);r=!isNaN(t)&&Number.isInteger(t)&&Array.isArray(r)?r[t]:r[e]}catch(e){return}return r}(t,n);e.set(r,{target:a,field:c}),o=a,i=c}}const c=P(o,"object")&&(Reflect.has(o,f)||Reflect.has(o,h))?"value":i,a=n.hasKey=P(c,["number","string"]);if(y(o)){const e=new X(o,c,n);if(a){const t=S(this._proxyToObserve,o,{}),s=c;t[s]=t[s]||[],t[s].push(e),this._proxyToObserve.set(o,t)}else{const t=S(this._proxyToObserveNo,o,[]);this._proxyToObserveNo.set(o,t),t.push(e)}return e}if(r){if("function"==typeof r){const e=n.done,t=r(o,c);return e?e(t):t}console.warn("$proxy:需要定义为响应式对象")}return E(e)}bind(e,t,s,{cb:r}){if(!P(s,["number","string"])&&null!=s){const n=s,o=this.createProxy(n);return o[u]=e,"function"==typeof r?r(o):t&&(e[t]=o),o}e[t]=s}update(e,t,s){const r=this._proxyToObserve.get(e);if(r&&Object.keys(r).length>0){const n=r[t];if(n&&Array.isArray(n)&&n.length>0){const o=n.filter(e=>!e.isDestory);o.length>0&&(o.forEach(e=>e.resolve(s)),r[t]=o,0===o.length&&(delete r[t],0===Object.keys(r).length&&this._proxyToObserve.delete(e)))}}this.resolveParent(e)}clearObservers(e){if(this._proxyToObserve.has(e)){const t=this._proxyToObserve.get(e);if(t)for(const e in t){const s=t[e];Array.isArray(s)&&s.forEach(e=>e.destroy())}this._proxyToObserve.delete(e)}if(this._proxyToObserveNo.has(e)){const t=this._proxyToObserveNo.get(e);Array.isArray(t)&&t.forEach(e=>e.destroy()),this._proxyToObserveNo.delete(e)}}resolveParent(e){if(this._proxyToObserveNo.has(e)){const t=this._proxyToObserveNo.get(e);if(Array.isArray(t)){const s=t.filter(t=>!t.isDestory&&(t.resolve(e),!0));s.length!==t.length&&(0===s.length?this._proxyToObserveNo.delete(e):this._proxyToObserveNo.set(e,s))}}const t=e[u];t?.[a]&&this.resolveParent(t)}}class te{static removeComments(e){if("string"!=typeof e)return e;const t=[];let s=0;const r=e.length;for(;s<r;)if("/"===e[s]&&"/"===e[s+1])for(;s<r&&"\n"!==e[s];)s++;else if("/"===e[s]&&"*"===e[s+1]){for(s+=2;s<r-1&&("*"!==e[s]||"/"!==e[s+1]);)s++;s+=2}else{const r=e[s];void 0!==r&&t.push(r),s++}return t.join("")}static dedupeStyleString(e){if("string"!=typeof e)throw new Error("styleString 必须是字符串类型");if(""===e.trim())return e;try{const t=new Map,s=/([^{]+)\{([^}]+)\}/g;e.replace(s,(e,s,r)=>{const n=s.trim(),o=r.trim();return t.set(n,o),e});const r=[];for(const[e,s]of t)r.push(`${e}{${s}}`);return r.join("")}catch(e){throw new Error(`去重样式规则时发生错误:${e instanceof Error?e.message:String(e)}`)}}static parseSassLikeSyntax(e){if("string"!=typeof e||""===e.trim())return"";const t=this.removeComments(e),s={variables:new Map},r=(e,t)=>{for(;t<e.length;){const s=e[t];if(!s||!/\s/.test(s))break;t++}return t},n=(e,t=new Set)=>{let r,o=e;do{r=!1,o=o.replace(/\$([a-zA-Z0-9_-]+)/g,(e,o)=>{const i=s.variables.get(o);if(i){if(t.has(o))return console.warn(`变量循环引用检测到:$${o}`),e;const s=new Set(t);s.add(o);const c=n(i,s);return c!==e?(r=!0,c):e}return e})}while(r);return o},o=(e,t="",i=0)=>{if(i>50)return console.warn("Sass 解析递归深度超过限制"),"";const c=[];let a=0;try{for(;a<e.length&&(a=r(e,a),!(a>=e.length));){if("$"===e[a]){let t=a+1;for(;t<e.length;){const s=e[t];if(!s||!/[a-zA-Z0-9_-]/.test(s))break;t++}if(t<e.length&&":"===e.substring(t,t+2).trim()){const r=e.substring(a+1,t).trim();for(t+=2;t<e.length;){const s=e[t];if(!s||!/\s/.test(s))break;t++}const n=[];let o=!1,i="";for(;t<e.length;){const s=e[t];if(!s||";"===s&&!o)break;'"'!==s&&"'"!==s||"\\"===e[t-1]||(o?s===i&&(o=!1):(o=!0,i=s)),n.push(s),t++}s.variables.set(r,n.join("").trim()),a=t+1;continue}}const r=[];for(;a<e.length;){const t=e[a];if(!t||"{"===t)break;r.push(t),a++}if(a>=e.length||"{"!==e[a])break;a++;const i=[];let l=1;for(;a<e.length&&l>0;){const t=e[a];if(!t)break;if("{"===t)l++;else if("}"===t&&(l--,0===l))break;i.push(t),a++}a++;const h=r.join("").split(",").map(e=>e.trim()).filter(Boolean);for(const e of h){let s=e;if(t)if(s=e.replace(/&/g,t),s.startsWith(t)){const e=s[t.length];void 0!==e&&/[\w-]/.test(e)&&(s=`${t} ${s}`)}else s=`${t} ${s}`;const r=[],a=[];let h=0;for(;h<i.length;){for(;h<i.length;){const e=i[h];if(!e||!/\s/.test(e))break;h++}if(h>=i.length)break;let e=h;for(;e<i.length;){const t=i[e];if(!t||"{"===t||";"===t)break;e++}if(e<i.length&&"{"===i[e]){const t=i.slice(h,e).join("").trim();let s=1;const r=[];for(e++;e<i.length&&s>0;){const t=i[e];if(!t)break;if("{"===t)s++;else if("}"===t&&(s--,0===s))break;r.push(t),e++}a.push(`${t}{${r.join("")}} `),h=e+1}else{let e=!1,t="";for(;h<i.length;){const s=i[h];if(!s||";"===s&&!e)break;'"'!==s&&"'"!==s||"\\"===i[h-1]||(e?s===t&&(e=!1):(e=!0,t=s)),r.push(s),h++}h<i.length&&(r.push(";"),h++)}}let f=n(r.join("")),u=n(a.join(""));f=f.trim(),f&&c.push(`${s}{${f}}`),u&&c.push(o(u,s,l+1))}}return c.join("")}catch(e){return console.error("Sass 解析错误:",e),""}};return o(t)}}const se=new Map;let re=0;class ne{static generateScopeId(){if(se.size>=1e4){const e=Math.floor(1e3);let t=0;for(const s of se.keys()){if(t>=e)break;se.delete(s),t++}}return"jiess-scope"+ ++re}static escapeCssIdentifier(e){return e.replace(/[^\w-]/g,"-")}static sanitizeCss(e){return"string"!=typeof e?"":e.replace(/javascript\s*:/gi,"").replace(/data\s*:/gi,"").replace(/@import[^;]+;/gi,"").replace(/url\s*\(\s*['"]?\s*(javascript|data|vbscript)\s*:[^)]*\)/gi,"url(about:blank)").trim()}static scopeStyleString(e,t){if("string"!=typeof e)throw new Error("styleString 必须是字符串类型");if(""===e.trim())throw new Error("styleString 必须是非空字符串");if("string"!=typeof t)throw new Error("scopeId 必须是字符串类型");if(""===t.trim())throw new Error("scopeId 必须是非空字符串");const s=`${e}__${t}`;if(se.has(s))return se.get(s);t=t.trim();try{const r=te.parseSassLikeSyntax(e),n=/([^{]+)\{([^}]+)\}/g,o=r.replace(n,(e,s,r)=>{const n=s.trim();if(!n)return n;if(n.includes(t))return n;let[o,...i]=n.split(":global");return o=o.replace(/([.#])([\w-]+)/g,(e,s,r)=>{const n=this.escapeCssIdentifier(r);return`${s}${t}_${n}`}),i&&(o+=i.join(" ")),o=o.replace(/\s+/g," ").trim(),`${o}{${r}}`}),i=te.dedupeStyleString(o);return se.set(s,i),i}catch(e){throw new Error(`处理样式时发生错误:${e instanceof Error?e.message:String(e)}`)}}static clearCache(){se.clear()}static getCacheSize(){return se.size}}let oe=1,ie="jiess",ce="_static_";const ae=new Map,le=[];function he(e){const t=le.indexOf(e);t>-1&&le.splice(t,1),le.push(e)}class fe extends K{ctx;expose={};_childrenHistory={};_childrenCurrent={};isDestory=!1;observeInstance;_resourceManager=new o;get disposed(){return this._resourceManager.disposed}constructor(e,t){super("JsRender"),this.ctx=e;let s=null;const{key:r}=t.data;if(r&&`${r}`.startsWith(ce)){if(s=ae.get(r),s)return he(r),s.ctx=e,s;!function(e,t){ae.size>=1e3&&function(){if(le.length>0){const e=le.shift();if(e&&ae.has(e)){const t=ae.get(e);t&&"function"==typeof t.dispose?t.dispose():t&&"function"==typeof t.destroy&&t.destroy(),ae.delete(e)}}}(),ae.set(e,t),he(e)}(r,this)}this.attrs=t,this._buildNode(t)}_buildNode({config:e,data:t}){this[c]=v(t.is,!0,c),this._resData=this._initData(t),this._resConfig=this._initConfig(e);const{$ref:s}=this._resConfig;var r;"function"==typeof s?this.ctx.nextTick(()=>{((e=N,t=0)=>{let s=setTimeout(()=>{null!==s&&clearTimeout(s),e()},t)})(()=>s(this.expose,this))}):P(r=s,"object")&&r[h]&&(s.value=this.expose)}_initData({id:e,class:t,className:s,...r}){const n={id:e,class:t,className:s};if(this.attrs&&"function"==typeof this.attrs.initAttrs&&this.attrs.initAttrs(n),r.$proxy&&r.field){const e={$proxy:r.$proxy,field:r.field,done:r.done};r.update&&(e.update=r.update),this._analyObserve(n,"children",e),delete r.$proxy,delete r.field,delete r.done,delete r.update,delete r.children}for(const e in r){const t=r[e];P(t,["object","array"])?this._analyObserve(n,e,t):n[e]=t}return n}_initConfig(e){const t={};for(const s in e){const r=e[s];P(r,["object","array"])?this._analyObserve(t,s,r):t[s]=r}return t}_analyObserve(e,t,s){this._isJiessComponentField(t)?e[t]=s:g(s)?this._handleProxyObject(e,t,s):"children"===t?this._handleChildrenField(e,t,s):e[t]=s}_isJiessComponentField(e){return"$if"!==e&&"$elseIf"!==e&&this[c]}_handleProxyObject(e,t,s){const{$proxy:r,update:n}=s;n&&this._handleTwoWayBinding(e,s),y(r)?this._handleReactiveProxy(e,t,s):e[t]=E(s)}_handleTwoWayBinding(e,t){let s=null,{$proxy:r,update:n,field:o}=t;if(s="string"==typeof n?n:"vue3"===this.ctx.jiess.$env?"onUpdate:modelValue":"onInput",o&&"string"==typeof o||(o="vue3"===this.ctx.jiess.$env?"modelValue":"value"),"function"==typeof e[s]){const t=e[s];e[s]=e=>{t(e),r[o]=e}}else e[s]=e=>r[o]=e}_handleReactiveProxy(e,t,s){const r=this.ctx._toObserve(s,s=>{this.isDestory||("children"===t?(O(e[t]),this._handleChildrenField(e,t,s)):e[t]=s,this.ctx.forceUpdate())},this),n=this.ctx._slotRender;e[t]="children"===t?n.initNodes(r):r}_handleChildrenField(e,t,s){const r=this.ctx._slotRender;if(Array.isArray(s)){const n=s.flat(3);n.forEach((e,t)=>{g(e)&&e.is||this._analyObserve(n,t,e)}),e[t]=r.initNodes(n)}else e[t]=r.initNodes(s)}_initKey(e,t){return P(e,"object")&&D(e.key)&&(e.key=W(t)?`${ie}_${t}`:"auto_"+oe++),e}_injectKey({J_uid:e}){let{key:t}=this._resData;if(t){if("string"==typeof t){if(t.startsWith(ce))return;const s=t.split("_"),r=s[1]?parseInt(s[1],10):NaN;if(s.length>2&&!isNaN(r)&&r===e)return}}else t=this.J_uid;this._resData.key=`${ie}_${e}_${t}`}getNative(e){const{ctx:t,_resData:s}=this,{is:r,key:n,slot:o,children:i,...a}=s;if(v(r,!0,c)){const{jiessEnv:s}=t.component;return this._vnode=this._vnode||s.createVNode(this._initKey({is:r,key:n,slot:o},e),()=>(this.component=new me(r,s),{NativeComponent:this.component.start(a,i,this),component:this.component})),this._vnode}return t._slotRender.toRender(this,e)}destroy(){this.dispose()}dispose(){this._resourceManager.disposed||this.isDestory||(this.isDestory=!0,this._vnode=void 0,this._resourceManager.dispose(),"function"==typeof this.observeInstance?.dispose?this.observeInstance.dispose():this.observeInstance&&this.observeInstance.destroy(),this[c]&&!this.component||this._resData&&this._resData.children&&O(this._resData.children))}}class ue extends K{ctx;debounce1=U();constructor(e,t){super("Attrs"),this.data={},this.config={},this.ctx=e.ctx,this.init(t)}handleAttrs({id:e,cs:t,cn:s,...r}={}){const{env:n}=this.ctx.component.jiessEnv,o=this.ctx.styleScope;"string"==typeof e&&e.trim()&&(o&&(e=`${o}_${e.trim()}`),r.id=e);let i=[];if(t&&(Array.isArray(t)?i=t.map(e=>e?.trim()).filter(Boolean):"string"==typeof t&&(i=t.split(" ").map(e=>e?.trim()).filter(Boolean))),s){let e=[];Array.isArray(s)?e=s.map(e=>e?.trim()).filter(Boolean):"string"==typeof s&&(e=s.split(" ").map(e=>e?.trim()).filter(Boolean)),o&&(e=e.map(e=>`${o}_${e?.trim()}`)),i=[...i,...e]}const c=[...new Set(i)];return c.length&&(r["vue3"===n?"class":"className"]=c.join(" ")),r}initCssValue(e,t){if(e){if(g(e)&&y(e.$proxy)){const s=ee.getDefault().observe(e);s.observe(e=>{P(e,["string","number","array"])&&t&&t(e)}),e=s.result}if(P(e,["string","number","array"]))return e}}debounceUpdate(e,{id:t,cs:s,cn:r}){this.debounce1(()=>{Object.assign(e,this.handleAttrs({id:t,cs:s,cn:r})),this.ctx.forceUpdate()},0)}initAttrs(e){let t=e.className,s=e.class,r=e.id;delete e.className,delete e.class,delete e.id,t=this.initCssValue(t,n=>{t=n,this.debounceUpdate(e,{id:r,cs:s,cn:t})}),s=this.initCssValue(s,n=>{s=n,this.debounceUpdate(e,{id:r,cs:s,cn:t})}),r=this.initCssValue(r,n=>{r=n,this.debounceUpdate(e,{id:r,cs:s,cn:t})}),Object.assign(e,this.handleAttrs({id:r,cs:s,cn:t}))}init(e){const t=this.ctx.component?.jiessEnv?.env||"vue3",{children:s,...r}=function(e,t){const{$mergeAttrs:s,...r}=t||{};return Object.assign(r,s?.[e])}(t,e);var n,o,i;return n=["$if","$ref","$elseIf","$name","$slots","$mergeAttrs"],o=r,i=this.config,n.forEach(e=>{o.hasOwnProperty(e)&&(i[e]=o[e],delete o[e])}),W(s)&&(r.children=s),this.data=r,this}}const pe=new WeakMap;class de extends K{ctx;attrs;constructor(e,t){if(super("Done"),this.ctx=e,this.attrs=t,pe.has(t)){const s=pe.get(t);return s.ctx=e,s}pe.set(t,this)}beginSetup(e){const{ctx:t}=this,s={},{setup:r,props:o,name:i,style:c}=e,{$slots:a}=t.PJR?._resConfig||{},l=i?`【组件-${i}】`:"";let f=this.ctx.inject("jiess_css-scope",1/0);const u={default:()=>{const{default:e,children:s}=t.PJR?._resData||{};return e??s??null}};if(c&&!e.styleInfo){let s=null;s="function"==typeof c?c(this.ctx.jiess):c,b(s,["string","object"],()=>{let r="",o="";if("string"==typeof s?r=s:"object"==typeof s&&(s.scope&&(o=s.scope),r=s.css),"string"==typeof r&&r.trim()){const s=e.styleInfo={styleScope:"",style:""},i="web-component"===this.ctx.component.jiessEnv.env;if(o)if(i)s.style=r,e.styleMode=["share","break"].includes(o)?o:"self";else{const t=ne.generateScopeId();s.styleScope=e.styleScope=t,s.style=ne.scopeStyleString(r,t),e.styleMode=["share","break"].includes(o)?o:"self"}else s.style=r;if(!i){const e=t.jiess.getFrameworkAPI("jiessEnv");n.mountStyle(e,[s])}}},"function"==typeof c?`${l}style返回`:`${l}style参数`)}e.styleScope?(this.ctx.styleScope=e.styleScope,"share"===e.styleMode?this.ctx.provide({"jiess_css-scope":e.styleScope}):"break"===e.styleMode?this.ctx.provide({"jiess_css-scope":null}):e.styleMode):f&&(this.ctx.styleScope=f);for(const e in a)"function"==typeof a[e]?u[e]=(...s)=>a[e].call(t,...s):u[e]=()=>a[e];const p=new ue(this,this.attrs);s.$param={slots:u,data:p.data},s.$props=function(e,t,s=""){if(t){let r="",n={};return s&&(r=`${s} 组件 `),b(t,"function",()=>{let s=t();b(s,"object",()=>{for(let t in s){const o=s[t];let i,c=!1,a=null,l=!1,f=!1;if("string"==typeof o)a=o;else if("object"==typeof o){const e=o;a=e.type,i=e.default,f=!!e.isRef,c=!!e.required,l=!!e.isResponsive}c&&!e.hasOwnProperty(t)&&m(`${r}${t}`,"必须");const u=e=>{if(null!=e)return"string"!=typeof a||P(e,a)||m(`${r}${t}`,`须提供 ${a} 类型`),e},p=e=>e&&"object"==typeof e&&e[h],d=e.hasOwnProperty(t)?e[t]:i;l&&!y(d)&&m(`${r}${t}`,"须提供 Jiess 响应式数据"),p(d)?(u(d.value),n[t]=d):void 0!==d&&f?m(`${r}${t}`,"须提供 JiessRef 响应式数据"):n[t]=u(d)}},`${r}Props 返回`)},`${r}Props 定义`),n}return{...e}}(p.data,o,i),t.expose(s),b(r,["function","asyncFunction"],()=>{r.call(t,s.$props,s.$param)},"setup函数")}buildRender(e=this.attrs){return this.jsRender&&!this.jsRender.isDestory||(this.jsRender=new fe(this.ctx,new ue(this,e))),this.jsRender}}class ye extends K{ctx;children;_resourceManager;get disposed(){return this._resourceManager.disposed}constructor(e,t){super("SlotRender"),this.ctx=e,this.children=t,this._resourceManager=new o}dispose(){this._resourceManager.disposed||this._resourceManager.dispose()}initNodes(e){return D(e)?e:[e].flat(1/0).filter(e=>W(e)).map(e=>"function"==typeof e?e:"object"==typeof e?R(e)?e:new de(this.ctx,e).buildRender():e+"")}toRender(e,t){const{$env:s}=this.ctx.jiess,r=this.ctx.jiess.getFrameworkAPI("$tag","div"),{is:n=r,children:o,...i}=e._resData;e._initKey(i,t);const c=this.getSlots(o,e);return"JiessFragment"===n?"vue3"===s?c.default?.call(this):c:this.$h(n,i,c)}$h(e,t,s){const{jiessEnv:r}=this.ctx.component;return r.createElement(e,t,s)}getSlots(e,t){const{ctx:s}=this,{env:r}=s.component.jiessEnv,n=e=>{const s=this.initNodes(e);return $(s,e=>e._injectKey(t)),A(s)};let{$slots:o}=t._resConfig||{};if("react"===r){if(W(e)){let t=n(e);return t.length>1?t:t[0]}return null}{o={...o};let t={};for(let e in o){const r=o[e],i=P(r,"function");t[e]=e=>n(i?r.call(s,e):r)}return t.hasOwnProperty("default")||W(e)&&(t.default=()=>n(e)),t}}}function ge(e,t=10,s){let r=null;if(s?.ctx){const{_provideData:n,PJR:o}=s?.ctx;P(n,"object")&&n.hasOwnProperty(e)?r=n[e]:o&&t>0&&(r=ge(e,--t,o))}return r}class _e extends K{component;PJR;_funcToObserve=new WeakMap;_provideData={};_slotRender;_nodes=[];_lifts={beforeRender:[],beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[]};_resourceManager;_forceUpdating=!1;_pendingForceUpdate=!1;get disposed(){return this._resourceManager.disposed}static createInitCallback(e){return t=>{if(!e||!e.contextParam)return;const{$page:s,...r}=e.contextParam;return"function"==typeof s&&(r.$page=s.call(t,e)),r}}constructor(e,t,s,r){const{jiess:n}=e.jiessEnv;super("Context",_e.createInitCallback(n)),this.PJR=r,this.jiess=n,this.component=e,this._resourceManager=new o,this._slotRender=new ye(this,s||[]),new de(this,t||{}).beginSetup(e.IS)}dropStaticJsRender(e){ae.has(e)&&ae.delete(e)}forceUpdate(){const{forceUpdate:e}=this.component?.frame||{};if("function"==typeof e)if(this._forceUpdating||ee.getDefault()?.effecter?.current)this._pendingForceUpdate||(this._pendingForceUpdate=!0,requestAnimationFrame(()=>{this._pendingForceUpdate=!1,this.forceUpdate()}));else{this._forceUpdating=!0;try{const t=ee.getDefault()?.effecter,s=t?.current;t&&(t.current=void 0);try{e()}finally{t&&(t.current=s)}}finally{this._forceUpdating=!1}}}onBeforeRender(e){this._lifts.beforeRender.push({fn:e,once:!1})}onBeforeMount(e){this._lifts.beforeMount.push({fn:e,once:!1})}onMounted(e,t=!1){this._lifts.mounted.push({fn:e,once:t})}onBeforeUpdate(e,t=!1){this._lifts.beforeUpdate.push({fn:e,once:t})}onUpdated(e,t=!1){this._lifts.updated.push({fn:e,once:t})}onBeforeUnmount(e){this._lifts.beforeUnmount.push({fn:e,once:!1})}nextTick(e){const t=Promise.resolve();return e?t.then(this?e.bind(this):e):t}add(...e){const t=this._nodes.length,s=this._slotRender,r=e=>{e=this._toObserve(e,r),O(this._nodes[t]),this._nodes[t]=s.initNodes(e),this.forceUpdate()};return 0===(e=this._toObserve(e,r)).length||this._nodes.push(s.initNodes(e)),this}_toObserve(e,t,s){const r=e=>{if(g(e)){if(y(e.$proxy)){const r=ee.getDefault().observe(e);s&&(s.observeInstance=r);let n=this._funcToObserve.get(t);return n=n?[...n,r]:[r],this._funcToObserve.set(t,n),r.observe((e,s)=>{const n=this._funcToObserve.get(t),o=n.indexOf(r),i=[];n.forEach((e,t)=>{o<t?e.destroy():i.push(e)}),this._funcToObserve.set(t,i),t(e,s,r)}),this._toObserve(r.result,t,s)}return this._toObserve(E(e),t,s)}return e};return Array.isArray(e)?e.flat(1/0).map(r):r(e)}native(...e){return A(this._slotRender.initNodes(e))}provide(e={}){Object.assign(this._provideData,e)}inject(e,t=10){return P(this._provideData,"object")&&this._provideData.hasOwnProperty(e)?this._provideData[e]:t>0&&this.PJR?ge(e,t-1,this.PJR):null}expose(e){this.PJR&&this.PJR.expose&&Object.assign(this.PJR.expose,e)}_buildVNodeTree(){const e=ee.getDefault()?.effecter;if(e){const t=e.current;e.current=void 0;try{return this._buildVNodeTreeInner()}finally{e.current=t}}return this._buildVNodeTreeInner()}_buildVNodeTreeInner(){let e=A(this._nodes);for(let t=this._lifts.beforeRender.length-1;t>=0;t--){const s=this._lifts.beforeRender[t];s&&"function"==typeof s.fn&&(e=s.fn(e)||e,s.once&&this._lifts.beforeRender.splice(t,1))}return e}dispose(){this._resourceManager.disposed||(this._resourceManager.dispose(),Object.values(this._lifts).forEach(e=>{e.forEach(e=>{e.fn=void 0})}),this._slotRender&&"function"==typeof this._slotRender.dispose&&this._slotRender.dispose(),this._slotRender=null,this._funcToObserve=new WeakMap,this.component=null,this.PJR=void 0,this._nodes=[])}destroy(){this.dispose()}}class me extends K{IS;jiessEnv;cpn;ctx;frame;frameProps={};constructor(e,t){super("Component"),this.IS=e,this.jiessEnv=t,this[c]=!0}start(e={},t,s){return this.cpn=this.cpn||this.component(e,t,s)}component(e,t,s){return this.jiessEnv.component(this,()=>(this.ctx=new _e(this,e,t,s),e=>{this.ctx._lifts[e].forEach(e=>{"function"==typeof e.fn&&(e.fn(),e.once&&delete e.fn)})}))}}const be={},ve=class extends K{contextParam;$env="";$name="default";JiessComponent;_frameworkProps={};_envProps={};constructor(e,t={},s={}){const{$name:r="default",...n}=t,o=be[r];if(o)return o;super("Jiess"),this.contextParam=s,this.$name=r,this._envProps=e,this._frameworkProps=n,be[r]=this,this.$env=e.$env}createElement(e,t={},s){const r=this._frameworkProps.createElement;if("function"==typeof r)return r(e,t,s)}getFrameworkAPI(e,t){if(void 0!==this._frameworkProps[e])return this._frameworkProps[e];if(void 0!==this._envProps[e])return this._envProps[e];if(void 0!==t)return t;throw new Error(`[Jiess] getFrameworkAPI: "${e}" 未在 $entry 时传入`)}},we=class{env="web-component";styleNode;recordStyleInfo=[];jiess;_resourceManager;_disposed=!1;constructor(e,t){let s;try{if(s=new ve({jiessEnv:this,$env:"web-component"},e,t),this.jiess=s,this._resourceManager=new o,"undefined"!=typeof window&&window.document){const e=document.createElement("style");document.head.appendChild(e),this.styleNode=e,this._resourceManager.add({disposed:!1,dispose:()=>{this.styleNode&&this.styleNode.parentNode&&(this.styleNode.parentNode.removeChild(this.styleNode),this.styleNode=void 0)}})}this.jiess.JiessComponent=({is:e,setup:t,style:s,children:r,...o})=>{try{if(this.recordStyleInfo.length>0&&this.styleNode&&(n.mountStyle(this,this.recordStyleInfo),this.recordStyleInfo=[]),v(e,!0,c));else{if("function"!=typeof t)throw new Error("须提供(组件 is)或(setup 函数)");e={isJiess:!0,name:"JiessComponent",style:s,setup:t}}const i=new me(e,this);return this.createElement(i.start(o,r))}catch(s){throw console.error("[Jiess Web Components 适配器]创建组件失败:",s),new B("创建 Web Components 组件失败",{is:e,setup:t,error:s})}}}catch(e){throw new F("初始化 Web Components 适配器失败",{error:e,jiess:s})}}createElement(e,t={},s){if(e&&"object"==typeof e&&e.__jiessComponent){const{that:t,initCycle:s,frame:n}=e,o=t.ctx.jiess.getFrameworkAPI("$tag","div"),i=document.createElement(o);i.className="jiess-component",n._container=i;const c=i.attachShadow({mode:"open"});n._shadowRoot=c;const a=document.createElement("style"),l=document.createElement("style");c.appendChild(a),c.appendChild(l);const h=document.createElement("div");if(c.appendChild(h),n._contentContainer=h,t.IS?.styleInfo?.style){const e=r.classify(t.IS.styleInfo.style);a.textContent=e.isolated,l.textContent=e.global}s("beforeMount");const f=t.ctx._buildVNodeTree(),u=this.resolveSlots(f);return this.appendChildren(h,u),s("mounted"),i}if("string"==typeof e){const r=document.createElement(e),{ref:n,...o}=t||{},i=[];r.__jiessEvents=i;for(const[e,t]of Object.entries(o))if(null!=t&&!1!==t)if(e.startsWith("on")&&"function"==typeof t){const s=e.slice(2).toLowerCase();r.addEventListener(s,t),i.push({eventName:s,handler:t})}else if("style"===e&&"object"==typeof t)Object.assign(r.style,t);else if("className"===e||"class"===e)r.className=String(t);else if("attrs"===e&&"object"==typeof t)for(const[e,s]of Object.entries(t))r.setAttribute(e,String(s));else if("innerHTML"===e)r.innerHTML=String(t);else if("textContent"===e)r.textContent=String(t);else if(e.startsWith("data-")||e.startsWith("aria-")||e.includes("-"))r.setAttribute(e,String(t));else try{r[e]=t}catch{r.setAttribute(e,String(t))}"function"==typeof n&&n(r),o&&null!=o.key&&r.setAttribute("data-key",String(o.key));const c=this.resolveSlots(s);return this.appendChildren(r,c),r}console.warn("[Jiess Web Components 适配器] 不支持的元素类型:",typeof e)}createVNode({key:e},t){const{NativeComponent:s}=t(this);return this.createElement(s,{key:e})}component(e,t){const s=this,r={forceUpdate:()=>{if(r._contentContainer){const t=e.ctx._buildVNodeTree(),n=s.resolveSlots(t);s.reconcileChildren(r._contentContainer,n)}},$nextTick:e=>setTimeout(e,0),$set:N,props:{},_container:null,_shadowRoot:null,_contentContainer:null};e.frame=r;const n=t();return{__jiessComponent:!0,that:e,initCycle:n,frame:r}}resolveSlots(e){if(e&&"object"==typeof e&&!Array.isArray(e)&&!(e instanceof Node)){const t=e;if("function"==typeof t.default)return t.default()}return e}appendChildren(e,t){null!=t&&!1!==t&&!0!==t&&("string"==typeof t||"number"==typeof t?e.appendChild(document.createTextNode(String(t))):t instanceof Node?e.appendChild(t):Array.isArray(t)&&t.forEach(t=>this.appendChildren(e,t)))}syncElementAttributes(e,t){e.className!==t.className&&(e.className=t.className);const s=t.style.cssText;e.style.cssText!==s&&(e.style.cssText=s);const r=t.attributes,n=Array.from(e.attributes).map(e=>e.name);for(const t of n)"data-key"!==t&&(r.getNamedItem(t)||e.removeAttribute(t));for(let t=0;t<r.length;t++){const s=r[t];"data-key"!==s.name&&e.getAttribute(s.name)!==s.value&&e.setAttribute(s.name,s.value)}const o=e.__jiessEvents||[],i=t.__jiessEvents||[];for(const{eventName:t,handler:s}of o)e.removeEventListener(t,s);for(const{eventName:t,handler:s}of i)e.addEventListener(t,s);e.__jiessEvents=i}reconcileChildren(e,t){const s=e=>null==e||!1===e||!0===e?[]:"string"==typeof e||"number"==typeof e?[e]:e instanceof Node?3===e.nodeType?[e.textContent||""]:[e]:Array.isArray(e)?e.flatMap(s):[],r=s(t),n=Array.from(e.childNodes),o=Math.max(n.length,r.length);for(let t=0;t<o;t++){const s=n[t],o=r[t];if(t>=r.length){s&&e.removeChild(s);continue}if(t>=n.length){"string"==typeof o||"number"==typeof o?e.appendChild(document.createTextNode(String(o))):o instanceof Node&&e.appendChild(o);continue}const i=s&&1===s.nodeType,c=o instanceof Node&&1===o.nodeType;if(i&&c){const t=s,r=o;t.tagName===r.tagName?(this.syncElementAttributes(t,r),this.reconcileChildren(t,Array.from(r.childNodes))):e.replaceChild(r,t)}else i&&!c?"string"==typeof o||"number"==typeof o?e.replaceChild(document.createTextNode(String(o)),s):e.removeChild(s):!i&&c?e.replaceChild(o,s):!s||3!==s.nodeType||"string"!=typeof o&&"number"!=typeof o?e.replaceChild(document.createTextNode(String(o)),s):s.textContent=String(o)}}get disposed(){return this._disposed}dispose(){if(!this._disposed){this._disposed=!0;try{this._resourceManager.dispose(),this.styleNode&&this.styleNode.parentNode&&(this.styleNode.parentNode.removeChild(this.styleNode),this.styleNode=void 0),this.recordStyleInfo=[]}catch(e){console.error("[Jiess Web Components 适配器] 清理资源失败:",e)}}}};return t.default})());