weifuwu 0.81.1 → 0.81.2
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/dist/ui-dom/index.js +8 -8
- package/dist/ui-dom/jsx-runtime.js +1 -1
- package/dist/ui-dom/testing.js +1 -1
- package/dist/ui-dom/vdom2/audit.d.ts +2 -0
- package/dist/ui-dom/vdom2/events.d.ts +61 -0
- package/dist/ui-dom/vdom2/lifecycle.d.ts +3 -2
- package/dist/ui-dom/vdom2/mount.d.ts +2 -1
- package/dist/ui-dom/vdom2/route.d.ts +1 -1
- package/dist/ui-dom/vdom2/trace.d.ts +6 -2
- package/dist/ui-dom/vdom2/transitions.d.ts +2 -1
- package/dist/ui-dom/vnode.d.ts +2 -0
- package/package.json +1 -1
package/dist/ui-dom/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
function At(e){let n=[],t=(e||"/").replace(/:(\w+)/g,(o,r)=>(n.push(r),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}var sn=class{_routes=[];_middlewares=[];_injections=[];_injected=!1;_mode;_notFound;constructor(n={}){this._mode=n.mode??"history"}get mode(){return this._mode}use(n,t){if(typeof n=="string"&&t){let o=this,r=n,i=async(s,l,d)=>{let u=l.__routePath??o.getPath(),a=null;return u===r?a="/":(r==="/"?u!=="/"&&u.startsWith("/"):u.startsWith(r+"/"))&&(a=u.slice(r.length)),a===null?d:async(c,f)=>{let p=await t._handle(a,c,f);return p===null?d(c,f):p}};return this._middlewares.push(i),this}return n.length<=1?(this._injections.push(n),this):(this._middlewares.push(n),this)}async _ensureInjected(n){if(!this._injected){this._injected=!0;for(let t of this._injections){let o=await t(n);o&&o!==n&&Object.assign(n,o)}}}get(n,t,o){return this._routes.push({path:n,handler:t,title:o?.title}),this}notFound(n){return this._notFound=n,this}getPath(){return this._getPath(void 0)}_getPath(n){let t=n?.location??(typeof window<"u"?window.location:null);return this._mode==="hash"?(t?.hash??"").replace(/^#/,"")||"/":t?.pathname??"/"}match(n){let t=null;for(let o of this._routes){let{re:r,keys:i}=At(o.path),s=n.match(r);if(!s)continue;let l={};for(let d=0;d<i.length;d++)l[i[d]]=decodeURIComponent(s[d+1]);t={handler:o.handler,params:l,title:o.title};break}return t||(t={handler:this._notFound??(()=>null),params:{}}),t}async _handle(n,t,o){await this._ensureInjected(o);let r=this.match(n);r.title&&typeof document<"u"&&(document.title=r.title),o.params=r.params,o.route&&(o.route.params=r.params);let s=r.handler,l=o.__routePath;o.__routePath=n;try{for(let d=this._middlewares.length-1;d>=0;d--){let u=this._middlewares[d],a=s;s=await u(t,o,a)??a}return await s(t,o)}finally{o.__routePath=l}}async execute(n,t,o){await this._ensureInjected(t);let r=this.match(o);r.title&&typeof document<"u"&&(document.title=r.title),t.params=r.params,t.route&&(t.route.params=r.params);let s=r.handler;for(let l=this._middlewares.length-1;l>=0;l--){let d=this._middlewares[l],u=s;s=await d(n,t,u)??u}return await s(n,t)}};var X=Symbol("Fragment"),B=Symbol("Portal");function De(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function ee(e){return e!=null&&typeof e=="object"&&e.type===X}function S(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function K(e){return e!=null&&typeof e=="object"&&e.type===B}function $e(e,n,t=null){return{type:e,props:n,key:t,_child:null,_parentNode:null,_refNode:null,_id:null,_customId:null,_parentVNode:null,_ctxVersion:null,_lifecycle:"fresh"}}function Te(e,n,t=null){return e===X?{...$e(e,n,t),type:e}:e===B?{...$e(e,n,t),type:e,_remoteEl:null,_placement:"remote"}:typeof e=="function"?{...$e(e,n,t),type:e,_render:null,_outputChild:null}:{...$e(e,n,t),type:e,el:null}}function me(e,n,...t){let o=qn(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),Te(e,o,n?.key??null)}function ln(e,n,t){return Te(e,qn(n),t??null)}var It=ln;function Lt(e,n,t){return ln(e,n,t)}function qn(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function R(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}function je(e,n){let t=Te(B,{children:e,portalKey:n});return t.key=n??null,t}function E(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,queryAll:e=>typeof document<"u"?document.querySelectorAll(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,createElementNS:(e,n)=>typeof document<"u"?document.createElementNS(e,n):null,createDocumentFragment:()=>typeof document<"u"?document.createDocumentFragment():null,createComment:e=>typeof document<"u"?document.createComment(e):null,createTextNode:e=>typeof document<"u"?document.createTextNode(e):null,addEventListener:(e,n,t)=>{typeof window<"u"&&window.addEventListener(e,n,t)},removeEventListener:(e,n,t)=>{typeof window<"u"&&window.removeEventListener(e,n,t)},scrollTo:e=>{typeof window<"u"&&window.scrollTo(0,e)},matchMedia:e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e):null,visualViewport:()=>(typeof window<"u"?window:null)?.visualViewport??null,scrollingElement:()=>typeof document<"u"?document.scrollingElement:null,bodyElement:()=>typeof document<"u"?document.body:null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},clearBody:()=>{typeof document<"u"&&(document.body.innerHTML="")},event:(e,n)=>{let t=typeof window<"u"?window:null,o=n&&(n.key||n.code)?"KeyboardEvent":n&&(n.clientX!==void 0||n.clientY!==void 0||n.pointerId!==void 0)?"PointerEvent":"Event";try{return new t[o](e,n)}catch{return new t.Event(e,n)}},dispatchEvent:(e,n)=>typeof e<"u"?e.dispatchEvent(n):!1,navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,viewportWidth:()=>typeof window<"u"?window.innerWidth:0,pathname:()=>typeof window<"u"?window.location.pathname:"",createTreeWalker:(e,n)=>typeof document<"u"?document.createTreeWalker(e,n??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}function Ht(e,n,t=400){let o=!1,r=()=>{o||(o=!0,e.removeEventListener("animationend",r),clearTimeout(i),n())};e.addEventListener("animationend",r);let i=setTimeout(r,t)}function Ne(e,n){return Object.assign(Object.create(e),n)}function Mt(e){let n={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},t=e?.onRequest,o=e?.onResponse,r=e?.timeout??0;async function i(s,l,d,u,a=!1){let c=n.baseURL+l,f={method:s,headers:{...n.headers,...u?.headers}},p=e?.token?.();p&&!f.headers.Authorization&&(f.headers.Authorization=`Bearer ${p}`);let m=r>0,g=!!u?.signal,h=null,v=null;(m||g)&&(h=new AbortController,f.signal=h.signal,m&&(v=setTimeout(()=>h.abort(new Error("Request timed out")),r)),g&&u.signal.addEventListener("abort",()=>h.abort())),d!==void 0&&s!=="GET"&&s!=="HEAD"&&(f.body=JSON.stringify(d));let y={url:c,init:f};t&&(y=t(y));try{let N=await fetch(y.url,y.init);if(N.status===401&&await e?.onUnauthorized?.()&&!a)return i(s,l,d,u,!0);if(o)return o(N);if(!N.ok){let j=await N.text().catch(()=>"");throw new an(N.status,j||N.statusText)}let w=N.headers.get("content-length");if(N.status===204||w==="0")return;let H=(N.headers.get("content-type")||"").toLowerCase();return H.includes("application/json")||H.includes("json")?N.json():N.text()}finally{v&&clearTimeout(v)}}return s=>Ne(s,{api:{get:(d,u)=>i("GET",d,void 0,u),post:(d,u,a)=>i("POST",d,u,a),put:(d,u,a)=>i("PUT",d,u,a),patch:(d,u,a)=>i("PATCH",d,u,a),delete:(d,u)=>i("DELETE",d,void 0,u)}})}var an=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function Ot(e){try{let n=e.split(".");if(n.length!==3)return null;let t=n[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t))}catch{return null}}function Ut(e){let n=Ot(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function $t(e){let n=e?.storage??localStorage,t=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",r=e?.refreshTokenKey??"weifuwu_refresh",i=e?.refreshEndpoint??"/api/auth/refresh";return s=>{let l=n.getItem(t),d=n.getItem(o),u=null,a={token:l,user:d?JSON.parse(d):null,get isLoggedIn(){return this.token!==null},login(f,p,m){a.token=f,a.user=p,n.setItem(t,f),n.setItem(o,JSON.stringify(p)),m&&n.setItem(r,m)},logout(){a.token=null,a.user=null,n.removeItem(t),n.removeItem(o),n.removeItem(r)},setUser(f){a.user=f,n.setItem(o,JSON.stringify(f))},async refresh(){return u||(u=c().finally(()=>{u=null}),u)}};async function c(){let f=n.getItem(r);if(!f)return!1;let p=n.getItem(t);try{let m=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:f})});if(n.getItem(t)!==p)return!1;if(!m.ok)return a.logout(),!1;let g=await m.json();return n.getItem(t)!==p?!1:(a.token=g.token,n.setItem(t,g.token),g.refreshToken&&n.setItem(r,g.refreshToken),!0)}catch{return!1}}return l&&Ut(l)&&a.refresh().catch(()=>{}),e?.onAuth?.(a),Ne(s,{auth:a})}}function Dt(e={}){let n=e.url??"/ws",t=e.reconnectInterval??3e3,o=e.maxReconnect??10,r=e.pingInterval??3e4,i=e.pingTimeout??1e4;return s=>{let l=new Set,d=null,u=0,a=null,c=null,f=null,p=!1,m=[],g={isConnected:!1,onMessage:w=>(l.add(w),()=>{l.delete(w)}),send:w=>{let H=JSON.stringify(w);d?.readyState===WebSocket.OPEN?d.send(H):m.push(H)},_connect:h,close:()=>{p=!0,N(),d?.close(),d=null,m=[],g.isConnected=!1}};async function h(){if(!p)try{d=new WebSocket(n),d.onopen=()=>{g.isConnected=!0,u=0;for(let w of m)d.send(w);m=[],v()},d.onmessage=w=>{try{let H=JSON.parse(w.data);for(let j of l)j(H)}catch{}y()},d.onclose=()=>{g.isConnected=!1,N(),!p&&u<o&&(u++,a=setTimeout(h,t*Math.min(u,5)))},d.onerror=()=>{d?.close()}}catch{p||(a=setTimeout(h,t))}}function v(){r<=0||(c=setInterval(()=>{d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"})),f=setTimeout(()=>{d?.close()},i)},r))}function y(){clearTimeout(f)}function N(){clearInterval(c),clearTimeout(f),clearTimeout(a)}return h(),Ne(s,{ws:g})}}var jt={fresh:{BUILD_START:"building",BUILD_DONE:"built",PRUNE:"pruned",DISPOSE:"disposed"},building:{BUILD_DONE:"built",DISPOSE:"disposed"},built:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},pruned:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},disposed:{BUILD_START:"building"}};function J(e){let n=0,t=e._parentVNode??null;for(let o=0;o<10&&t;o++)n++,t=t._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:n}}var We=new Map,Wt=50;function Ft(e,n,t,o){if(!e?.id)return;let r=We.get(e.id);r||(r={name:e.name??"?",events:[]},We.set(e.id,r)),r.events.push(`${n}--${t}-->${o}`),r.events.length>Wt&&r.events.shift()}function Gn(e){if(e){let n=We.get(e);return n?`${n.name}(${e}): ${n.events.join(" \u2192 ")}`:`no timeline for ${e}`}return[...We.entries()].map(([n,t])=>`${t.name}(${n}): ${t.events.join(" \u2192 ")}`).join(`
|
|
2
|
-
`)}function
|
|
3
|
-
`)),n.__vdom_lc==null&&(n.__vdom_lc=t=>Gn(t))}function L(e){return typeof e=="function"&&e.name||"anonymous"}function Fe(e){return e.ui?._ctxVersion??0}function mn(e,n){e.ui?.setMounting?.(n)}var zt=0;function pe(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${zt++}`}}function Be(e,n){return e.unmountHooks.push(n),()=>{let t=e.unmountHooks.indexOf(n);t>=0&&e.unmountHooks.splice(t,1)}}function Zn(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function Yt(e,n,t,o){try{e(n)}catch(r){console.error(`[weifuwu] ref ${t} error in <${o??"anonymous"}>`,r)}}function O(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let o=[...n.unmountHooks];for(let r of o)r(t._id);if(t._customId)for(let r of o)r(t._customId)}t._id=null,t._customId=null,S(t)&&(t._render=null),t._parentNode=null,t._refNode=null,t._lifecycle=Q(t._lifecycle,"DISPOSE",J(t))}else(S(t)||t._child!=null)&&(t._lifecycle=Q(t._lifecycle,"DISPOSE",J(t)));if(t._child!=null){if(Array.isArray(t._child))for(let o of t._child)o&&typeof o=="object"&&O(o,n);else O(t._child,n);t._child=null}if(t.props?.children&&typeof t.type=="string"){let o=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let r of o)r&&typeof r=="object"&&O(r,n)}if(typeof t.props?.ref=="function"&&Yt(t.props.ref,null,"cleanup"),K(t)){let o=t._remoteEl;if(o){let r=t._child;if(r!=null)if(Array.isArray(r))for(let i of r)i&&typeof i=="object"&&O(i,n);else typeof r=="object"&&O(r,n);o.remove(),t._remoteEl=null}}}function A(e,n){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||ee(e)){let o=n;if(o&&o.nodeType===8&&o.nodeValue?.includes("type=fragment-start")){let r=[o],i=/fid=([^\s"]+)/.exec(o.nodeValue)?.[1]??"",s=o.nextSibling;for(;s&&(r.push(s),!(s.nodeType===8&&s.nodeValue?.includes("type=fragment-end")&&(/fid=([^\s"]+)/.exec(s.nodeValue)?.[1]??i)===i));)s=s.nextSibling;return r}return null}let t=e;return S(t)?A(t._outputChild??t._child,n):null}function U(e){if(e==null||typeof e=="boolean")return"hole";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"arr";let n=e;return ee(n)?"frag":K(n)?"portal":S(n)?"comp":"native"}function et(e){let n=!1,t=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){t=!0;continue}let r=o;K(r)||(r.key!=null?n=!0:t=!0)}return n&&t?"mixed":n?"keyed":"unkeyed"}function Xt(e,n){if(e===n)return!0;let t=Object.keys(e),o=Object.keys(n);if(t.length!==o.length)return!1;for(let r of t)if(e[r]!==n[r])return!1;return!0}async function Jt(e,n,t,o){let r=e;r._id||(o?.reuse?._id?r._id=o.reuse._id:r._id=t.nextId(),t.idRegistry.set(r._id,r)),o?.reuse&&(o.reuse._parentNode&&(r._parentNode=o.reuse._parentNode),o.reuse._refNode&&(r._refNode=o.reuse._refNode),o.reuse._ctxVersion!=null&&(r._ctxVersion=o.reuse._ctxVersion));let i=Object.create(n);i.ui=Object.create(n.ui);let s=i.ui;if(s._selfId=r._id??null,s._selfVNode=r,s.render=function(l){let d=n.ui;return l==null&&r._id?d.render([r._id]):d.render(l)},typeof r._render!="function"&&S(o?.reuse)&&typeof o.reuse._render=="function"&&(r._render=o.reuse._render),typeof r._render!="function"){mn(n,!0);let l;try{l=await r.type(r.props??{},i)}finally{mn(n,!1)}if(typeof l!="function")throw new Error(`Component ${L(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);r._render=l}return{renderFn:r._render,childCtx:i}}function yn(e){return!!e&&typeof e.then=="function"}function G(e,n,t,o,r){return Qt[U(e)](e,n,t,o,r)}function gn(e,n){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===n.type?e:null}var Qt={hole:e=>e,text:e=>e,arr:Zt,comp:eo,frag:no,native:nt,portal:nt};function Zt(e,n,t,o,r){let i=e;x("build")&&V("build","debug","",`array in kids=${q(i)}`);for(let a=0;a<i.length;a++){let c=i[a];if(c!=null&&typeof c=="object"&&!Array.isArray(c)){let f=c;f.key!==null&&(f.key=String(f.key))}}let s=Array.isArray(t)?t:[],l=new Map;for(let a of s)a!=null&&typeof a=="object"&&!Array.isArray(a)&&a.key!=null&&l.set(a.key,a);let d=i.map((a,c)=>{let f=null;return a!=null&&typeof a=="object"&&!Array.isArray(a)&&a.key!=null&&(f=l.get(a.key)??null),f==null&&(f=s[c]??null),G(a,n,f,o,r)});x("build")&&V("build","debug","",`array out kids=${q(i)}`);let u=!1;for(let a=0;a<d.length;a++)if(yn(d[a])){u=!0;break}return u?Promise.all(d).then(()=>i):i}function eo(e,n,t,o,r){let i=e,s=o??n.__registry??pe(),l=gn(t,i);i._id||(i._id=l?._id??s.nextId(),s.idRegistry.set(i._id,i)),l&&(l._parentNode&&(i._parentNode=l._parentNode),l._refNode&&(i._refNode=l._refNode),l._ctxVersion!=null&&(i._ctxVersion=l._ctxVersion),S(i)&&S(l)&&typeof l._render=="function"&&(i._render=l._render));let d=Xt(l?.props??{},i.props??{}),u=Fe(n),a=(l?._ctxVersion??-1)===u;if(!r?.force&&d&&a&&ve(l)&&typeof i._render=="function"){let c=l;return i._lifecycle=Q(i._lifecycle,"PRUNE",J(i)),i._child=c._child,i._ctxVersion=c._ctxVersion,x("build")&&V("build","debug","",`prune comp=${ie(i)} propsSame=${d} verSame=${a}`),i}return i._lifecycle=Q(i._lifecycle,"BUILD_START",J(i)),x("build")&&V("build","debug","",`mount comp=${ie(i)} propsSame=${d} verSame=${a} force=${!!r?.force}`),(async()=>{let{childCtx:c}=await Jt(i,n,s,{reuse:l??null}),f=await G(await i._render(i.props),c,l?._child,s,r);return i._child=f??null,i._ctxVersion=u,i._lifecycle=Q(i._lifecycle,"BUILD_DONE",J(i)),i})()}function no(e,n,t,o,r){let i=e,s=o??n.__registry??pe(),l=gn(t,i);x("build")&&V("build","debug","",`fragment kids=${q(R(i.props?.children))}`);let d=G(i.props?.children??null,n,l?._child??l?.props?.children,s,r);return yn(d)?d.then(u=>(i._child=u??null,i._lifecycle=Q(i._lifecycle,"BUILD_DONE",J(i)),i)):(i._child=d??null,i._lifecycle=Q(i._lifecycle,"BUILD_DONE",J(i)),i)}function nt(e,n,t,o,r){let i=e;if(typeof i.type!="string"&&typeof i.type!="symbol")return i;let s=o??n.__registry??pe(),l=gn(t,i);x("build")&&V("build","trace","",`native <${String(i.type)}> kids=${q(R(i.props?.children))}`);let d=G(i.props?.children??null,n,l?.props?.children,s,r);return yn(d)?d.then(u=>(i._child=u??null,i._lifecycle=Q(i._lifecycle,"BUILD_DONE",J(i)),i)):(i._child=d??null,i._lifecycle=Q(i._lifecycle,"BUILD_DONE",J(i)),i)}function to(e){if(e===!1)return"false";if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0)return"true";if(typeof e=="object")try{let n=JSON.stringify(e);return`object ${n!=null&&n.length>80?n.slice(0,80)+"\u2026":n??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function Ke(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function W(e){let n=[`type=${e.type}`];return e.value!==void 0&&n.push(`value=${Ke(to(e.value))}`),e.key!=null&&n.push(`key=${Ke(e.key)}`),e.id!=null&&n.push(`id=${Ke(e.id)}`),e.fid!=null&&n.push(`fid=${Ke(e.fid)}`),`wf-hole: ${n.join(" ")}`}function ot(e){return typeof e!="string"&&typeof e!="function"&&e!==X&&e!==B}function rt(e){for(let n=0;n<e.length;n++){let t=e[n];if(t!=null&&typeof t=="object"&&!Array.isArray(t)){let o=t;o.key!==null&&(o.key=String(o.key))}}}var oo=/^on[A-Z]/,ro=/^on[A-Z].*Capture$/;function hn(e){let n=ro.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var Nn=new Set(["draggable","contenteditable","spellcheck","translate"]),io=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function vn(e){return Nn.has(e)?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":oo.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function tt(e,n,t){if(t!==!1){if(t===!0){e.setAttribute(n,"");return}try{e[n]=t,e.getAttribute(n)!==String(t)&&e.setAttribute(n,String(t))}catch{e.setAttribute(n,String(t))}}}var so={enumerated:(e,n,t)=>{e.setAttribute(n,t?"true":"false")},class:(e,n,t)=>{if(t!==!1)if(typeof t=="object")for(let[o,r]of Object.entries(t))r&&e.classList.add(o);else e.setAttribute("class",String(t))},style:(e,n,t)=>{if(t!==!1)if(typeof t=="string")e.setAttribute("style",t);else{let o=e.style;for(let[r,i]of Object.entries(t))i==null?o[r]="":r.startsWith("--")?o.setProperty(r,String(i)):typeof i=="number"&&!io.has(r)?o[r]=`${i}px`:o[r]=String(i)}},ref:(e,n,t)=>{if(typeof t=="function")try{t(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,n,t)=>{if(t===!1)return;let{type:o,capture:r}=hn(n);if(typeof t!="function"){console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof t} \u2014 ignored`);return}e.addEventListener(o,t,r?{capture:!0}:{})},value:(e,n,t)=>{t!==!1&&(e.value=t)},indeterminate:(e,n,t)=>{t!==!1&&(e.indeterminate=!!t)},innerHTML:(e,n,t)=>{t!==!1&&(e.innerHTML=String(t??""))},aria:(e,n,t)=>{if(t!==!1){if(typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}tt(e,n,t)}},default:tt};function oe(e,n,t){t!=null&&so[vn(n)](e,n,t)}function le(e,n){return e.createComment(W({type:"hole",value:n,key:null,id:null,fid:null}))}var lo=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function be(e,n){return le(e,n)}function $(e,n,t,o=null,r=null,i=null){let s=n?.browser??t;if(!s)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return ho[U(e)](e,n,s,o,r,i)}function ao(e,n,t){return null}function uo(e,n,t){return t.createTextNode(String(e))}function bn(e,n,t,o,r){if(e==null||typeof e=="boolean")return be(t,e);let i=$(e,n,t,String(o),null,r);return i??be(t,null)}function co(e,n,t,o=null,r=null,i=null){let s=e,l=t.createDocumentFragment();if(!l)return null;x("render")&&V("render","debug","",`array kids=${q(s)} fid=${i??"-"} key=${o??"-"}`);let d=t.createComment(W({type:"fragment-start",key:o,id:r,fid:i})),u=t.createComment(W({type:"fragment-end",key:o,id:r,fid:i}));d&&l.appendChild(d);for(let a=0;a<s.length;a++){let c=s[a],f=i!=null?`${i}-${a}`:String(a),p=bn(c,n,t,a,f);p!=null&&l.appendChild(p)}return u&&l.appendChild(u),l}function fo(e,n,t){let o=e,r=o,i=t.bodyElement();if(!i)return null;let s=i.querySelector("#__wf_portal");s||(s=t.createElement("div"),s&&(s.id="__wf_portal",i.appendChild(s)));let l=t.createElement("div");if(l){l.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let d=$(o.props?.children??null,n,t);d!=null&&l.appendChild(d),s&&s.appendChild(l),r._remoteEl=l;let u=R(o.props?.children);for(let a of u)a!=null&&typeof a=="object"&&!Array.isArray(a)&&(a._parentVNode=o)}return null}function po(e,n,t,o=null,r=null,i=null){let s=e,l=s,d=t.createDocumentFragment();if(!d)return null;let u=R(s.props?.children);x("render")&&V("render","debug","",`fragment kids=${q(u)} fid=${i??"-"}`);let a=t.createComment(W({type:"fragment-start",key:o,id:r,fid:i})),c=t.createComment(W({type:"fragment-end",key:o,id:r,fid:i}));a&&d.appendChild(a),l._refNode=a;for(let f=0;f<u.length;f++){let p=u[f],m=i!=null?`${i}-${f}`:String(f),g=bn(p,n,t,f,m);g!=null&&d.appendChild(g)}return c&&d.appendChild(c),d}function mo(e,n,t){let o=e,r=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return yo[r](o,n,t)}var yo={fresh:(e,n,t)=>{throw new Error(`[vdom2] component ${L(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,n,t)=>{throw new Error(`[vdom2] component ${L(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,n,t)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${L(e.type)} \u5728\u6E32\u67D3\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`),be(t,null)),built:it,pruned:it};function it(e,n,t){let o=e._child;if(o==null)return e._child=null,null;e._child=o,e._outputChild=o,typeof o=="object"&&!Array.isArray(o)&&(o._parentVNode=e);let r=$(o,n,t);if(r){if(e._refNode=r.nodeType===11?r.firstChild:r,e._id)if(r.nodeType===11)for(let i of Array.from(r.childNodes))i.nodeType===1&&i.setAttribute("data-wf-id",e._id);else r.nodeType===1&&r.setAttribute("data-wf-id",e._id);if(e.key!=null)if(r.nodeType===11)for(let i of Array.from(r.childNodes))i.nodeType===1&&i.setAttribute("data-wf-key",e.key);else r.nodeType===1&&r.setAttribute("data-wf-key",e.key)}return r}function go(e,n,t,o,r){let i=e,s=i,l=i.type,d=lo.has(l)?t.createElementNS("http://www.w3.org/2000/svg",l):t.createElement(l);if(!d)return null;s.el=d,s._refNode=d,x("render")&&V("render","trace","",`native <${l}> key=${i.key??"-"} kids=${q(R(i.props?.children))}`),i.key!=null&&d.setAttribute("data-wf-key",i.key);let u=null;for(let[a,c]of Object.entries(i.props??{}))if(!(a==="children"||a==="key")){if(a==="value"&&d instanceof HTMLSelectElement){u=c;continue}oe(d,a,c)}if(!("innerHTML"in(i.props??{}))){let a=R(i.props?.children);for(let c=0;c<a.length;c++){let f=a[c],p=r!=null?`${r}-${c}`:String(c),m=bn(f,n,t,c,p);if(m!=null&&(d.appendChild(m),f&&typeof f=="object"&&!Array.isArray(f)&&typeof f.type=="function")){let g=f;g._parentNode||(g._parentNode=d)}}x("render")&&V("render","trace","",`native <${l}> out=${se(d)}`)}return u!==null&&(d.value=String(u)),d}var ho={hole:ao,text:uo,arr:co,portal:fo,frag:po,comp:mo,native:go};function ae(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=$(e.newInput,r,r.browser??E());if(i==null)return null;if(t?.parentNode){let s=_e(o,t,n,r);return s&&s.parentNode===n?n.insertBefore(i,s):n.appendChild(i),i}return n.appendChild(i),i}function No(e){return _e(e.oldInput,e.oldNode,e.parent,e.ctx),null}function vo(e){let n=e.oldNode;if(n?.nodeType===8){let t=be(e.ctx.browser??E(),e.newInput);return t&&n.nodeValue!==t.nodeValue&&(n.nodeValue=t.nodeValue),n}return null}function we(e){let{parent:n,oldNode:t,ctx:o}=e,r=$(e.newInput,o,o.browser??E());return r==null?null:(t?.parentNode?t.parentNode.replaceChild(r,t):t?n.insertBefore(r,t):n.appendChild(r),r)}function bo(e){let{parent:n,oldNode:t,oldInput:o}=e,r=String(e.newInput);if(String(o)!==r){if(t&&t.nodeType===3)return t.nodeValue=r,t;let i=n.ownerDocument.createTextNode(r);return t?.parentNode?t.parentNode.replaceChild(i,t):n.appendChild(i),i}return t}function wo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=i.type;if(t&&t.nodeType===1&&(s?.type??null)===l&&De(i)){let d=t;return i.el=d,i._refNode=d,lt(d,s?.props??{},i.props??{}),"innerHTML"in(i.props??{})||Pe(d,s?._child??s?.props?.children??null,i._child??i.props?.children??null,r),d}return ae(e)}function Co(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=ee(s)?A(s,t):null,d=wn(n,s??o,i,r,l);return t?.parentNode?t:d[0]??null}function xo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput;if(!S(i)||typeof i._render!="function")throw new Error(`[vdom2] component ${L(i.type)} not built in diff \u2014 buildVNode must run before patchValue`);let s=o&&typeof o=="object"&&!Array.isArray(o)?o:null;if(s?.type!=null&&s.type!==i.type)return ae(e);let l=s?.type===i.type;if(!r.force&&s&&l&&ve(s)&&i._child===s._child)return t;s?.type===i.type&&s._id&&(i._id=s._id,r.registry.idRegistry.set(i._id,i)),i._parentNode=n,t&&(i._refNode=t);let d=i._child;if(d===null){i._outputChild=null,i._refNode=null;let a=t?.parentNode!=null,c=_e(s?._child??null,t,n,r);s&&(s._child=null);let f=be(r.browser??E(),null);return a&&f?(c&&c.parentNode===n?n.insertBefore(f,c):n.appendChild(f),f):Z(n,t,s?._child,null,r)}i._outputChild=d;let u=Z(n,t,s?._child,d,r);return u&&(i._refNode=u),u}function Vo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e;if(o===e.newInput&&t?.parentNode)return t;let i=n.ownerDocument.createDocumentFragment(),s=Pe(n,o,e.newInput,r,t?[t]:null);for(let l of s)l&&i.appendChild(l);return t?.parentNode?i.contains(t)?n.appendChild(i):t.parentNode.replaceChild(i,t):n.appendChild(i),i}function Eo(e){let{ctx:n,oldInput:t}=e,o=e.newInput,r=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(K(r)&&K(o)){let i=r._remoteEl;if(i){let s=r._child??r.props?.children??null,l=o._child??o.props?.children??null;Pe(i,s,l,n)}return o._remoteEl=r._remoteEl,null}return ae(e)}function ye(e){return{text:ae,native:ae,frag:ae,comp:ae,arr:ae,hole:No,portal:ae,...e}}var To={text:ye({text:bo}),hole:ye({text:we,native:we,frag:we,comp:we,arr:we,portal:we,hole:vo}),native:ye({native:wo}),frag:ye({frag:Co}),comp:ye({comp:xo}),arr:ye({arr:Vo}),portal:ye({portal:Eo})};function st(e){let n=U(e.oldInput),t=U(e.newInput);return To[n][t](e)}function Ce(){return!!globalThis?.__WF_VDOM_AUDIT}function qe(e,n,t){if(n==null||n.length===0)return;let o=Array.from(e.childNodes);if(!n.some(i=>{if(i==null||typeof i!="object")return!1;if(Array.isArray(i))return!0;let s=i.type;return s===X||s===B}))for(let i=0;i<n.length;i++){let s=n[i];if(s==null||typeof s=="boolean"){let l=o[i];(!l||l.nodeType!==8||!l.nodeValue?.includes("type=hole"))&&t(`[audit] \u5360\u4F4D\u9519\u4F4D\uFF1A\u4F4D\u7F6E ${i} \u671F\u671B\u6CE8\u91CA(wf-hole)\uFF0C\u5B9E\u9645 ${l?.nodeName??"null"}\uFF08${e.nodeName}\uFF09`)}else if(typeof s=="string"||typeof s=="number"){let l=o[i];l&&l.nodeType!==3&&t(`[audit] \u6587\u672C\u9519\u4F4D\uFF1A\u4F4D\u7F6E ${i} \u671F\u671B\u6587\u672C\u8282\u70B9\uFF0C\u5B9E\u9645 ${l.nodeName}\uFF08${e.nodeName}\uFF09`)}}}function xe(e,n,t){_o[U(n)](e,n,t)}var _o={hole:()=>{},text:()=>{},arr:Po,portal:()=>{},frag:ko,comp:So,native:Ro};function Po(e,n,t){let o=n;qe(e,o,t);for(let r of o)if(r!=null&&typeof r=="object"&&Array.isArray(r))for(let i of r)xe(e,i,t);else r!=null&&typeof r=="object"&&!Array.isArray(r)&&ee(r)&&qe(e,R(r.props?.children),t)}function ko(e,n,t){qe(e,R(n.props?.children),t)}function So(e,n,t){let o=n,r=o._refNode;r&&r.parentNode!==e&&t(`[audit] \u7EC4\u4EF6\u951A\u70B9\u9519\u4F4D\uFF1A${L(o.type)} _refNode \u4E0D\u5728\u7236\u8282\u70B9\u5185`),o._child!=null&&xe(e,o._child,t)}function Ro(e,n,t){let o=n;if(ot(o.type))return;let r=o.el??o._refNode;if(r&&r.nodeType===1&&r.tagName.toLowerCase()!==String(o.type)&&t(`[audit] \u5143\u7D20\u7C7B\u578B\u9519\u4F4D\uFF1A\u671F\u671B <${String(o.type)}>\uFF0C\u5B9E\u9645 ${r.tagName}`),r&&r.nodeType===1&&!("innerHTML"in(o.props??{}))){qe(r,R(o.props?.children),t);for(let i of R(o.props?.children))i!=null&&typeof i=="object"&&!Array.isArray(i)&&S(i)&&xe(r,i,t)}}function re(e,n){if(n&&typeof e.type=="function"&&e._id){try{O(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}Zn(n,e._id)}}function Re(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let n=e;return K(n)?typeof n.props?.portalKey=="string"?n.props.portalKey:null:n.key}function xn(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)){let t=A(e,n);if(t&&t.length>1)return t}return[n]}function Ge(e,n){let t=R(e.props?.children);for(let o of t){if(o==null||typeof o!="object"||Array.isArray(o))continue;let r=o;Ao[U(r)](r,n)}}var Ao={comp:(e,n)=>{re(e,n)},frag:(e,n)=>{Ge(e,n)},native:(e,n)=>{Ge(e,n)},portal:(e,n)=>{Ge(e,n)},arr:()=>{},text:()=>{},hole:()=>{}};function _e(e,n,t,o){return Io[U(e)](e,n,t,o)}var Io={arr:(e,n,t,o)=>{let r=A(e,n);if(r&&r.length){let i=(r[r.length-1]??n)?.nextSibling??null;for(let s of r)s.parentNode&&s.parentNode.removeChild(s);return i&&i.parentNode===t?i:null}return ke(e,n,t,o)},frag:(e,n,t,o)=>{let r=e,s=A(r,n)??[],l=(s[s.length-1]??n)?.nextSibling??null;for(let d of s)d.parentNode&&d.parentNode.removeChild(d);return Ge(r,o.registry),l&&l.parentNode===t?l:null},portal:(e,n,t,o)=>{let r=e,i=r._remoteEl;try{O(r.props?.children,o.registry)}catch(s){console.error("[weifuwu] portal ref cleanup error",s)}return i?.parentNode?.removeChild(i),null},comp:(e,n,t,o)=>{let r=e,i=A(r,n);if(re(r,o.registry),i&&i.length>1){let s=(i[i.length-1]??n)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return s&&s.parentNode===t?s:null}return ke(e,n,t,o)},native:(e,n,t,o)=>{try{O(e,o.registry)}catch(r){console.error("[weifuwu] ref cleanup error",r)}return ke(e,n,t,o)},text:(e,n,t,o)=>ke(e,n,t,o),hole:(e,n,t,o)=>ke(e,n,t,o)};function ke(e,n,t,o){let r=n?.nextSibling??null;return n?.parentNode&&n.parentNode.removeChild(n),r&&r.parentNode===t?r:null}function Z(e,n,t,o,r){return st({parent:e,oldNode:n,oldInput:t,newInput:o,ctx:r})}var Lo={event:(e,n,t,o)=>{let{type:r,capture:i}=hn(n);typeof t=="function"&&e.removeEventListener(r,t,i?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(r,o,i?{capture:!0}:{}))},class:(e,n,t,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",oe(e,n,o))},ref:(e,n,t,o)=>{if(o==null||o===!1){if(typeof t=="function")try{t(null)}catch(r){console.error("[weifuwu] ref cleanup error",r)}}else oe(e,n,o)},value:(e,n,t,o)=>{o==null||o===!1?e.value="":oe(e,n,o)},indeterminate:(e,n,t,o)=>{o==null||o===!1?e.indeterminate=!1:oe(e,n,o)},enumerated:Se,style:Se,innerHTML:Se,aria:Se,default:Se};function Se(e,n,t,o){if(o==null||o===!1){e.removeAttribute(n);try{delete e[n]}catch{}}else oe(e,n,o)}function lt(e,n,t){let o=Object.keys(n),r=Object.keys(t);if(o.length===r.length){let s=!0;for(let l=0;l<o.length;l++)if(o[l]!==r[l]||n[o[l]]!==t[o[l]]){s=!1;break}if(s)return}let i=new Set([...o,...r]);for(let s of i){if(s==="children"||s==="key")continue;let l=n[s],d=t[s];l!==d&&Lo[vn(s)](e,s,l,d)}}function wn(e,n,t,o,r){let i=Array.isArray(n)?n:n?._child??n?.props?.children??null,s=Array.isArray(t)?t:t?._child??t?.props?.children??null;return Pe(e,i,s,o,r)}function Pe(e,n,t,o,r,i){let s=R(n),l=R(t),d=r??Array.from(e.childNodes);x("diff")&&V("diff","debug","",`patchChildren parent=${te(e)} old=${q(s)} new=${q(l)} dom=${se(e)}`);let a=l.some(p=>Array.isArray(p))||s.some(p=>Array.isArray(p))?"unkeyed":et(l);if(x("diff")&&V("diff","debug","",`key-mode=${a}`),Ce()&&s.length!==l.length)for(let p=0;p<l.length;p++){let m=l[p];m!=null&&typeof m=="object"&&!Array.isArray(m)&&S(m)&&m.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${p} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\u2014\u2014\u5217\u8868\u589E\u5220/\u91CD\u6392\u4F1A\u9519\u4F4D\u7EC4\u4EF6\u5B9E\u4F8B\u72B6\u6001\u3002\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u8EAB\u4EFD key\uFF08\u5982 key={item.id}\uFF09\uFF1B\u65E0\u72B6\u6001 native \u9879\u8C41\u514D\u3002`)}let c=r&&r.length?r[r.length-1]:null;a==="mixed"&&(ze(l),ze(s));let f=(()=>{let p=d;p.length>=2&&p[0]?.nodeType===8&&p[0].nodeValue?.includes("fragment-start")&&p[p.length-1]?.nodeType===8&&p[p.length-1].nodeValue?.includes("fragment-end")&&(p=p.slice(1,-1));let m=[],g=0;for(let h=0;h<s.length;h++){let v=s[h];if(Array.isArray(v)){let N=p[g]??null;m.push(N);let w=A(v,N);g+=w?.length??1;continue}if(v==null||typeof v=="boolean"||typeof v=="string"||typeof v=="number"){m.push(p[g]??null),g++;continue}let y=v;if(K(y)){m.push(y._remoteEl??null);continue}if(m.push(y._refNode??p[g]??null),typeof y.type=="function"||ee(y)){let N=A(y,y._refNode??p[g]??null);g+=N?.length??1}else g++}return m})();return er[a]({parent:e,oldChildren:s,newChildren:l,oldNodes:f,ctx:o,arrEnd:c,anchorOut:i})}function Cn(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&ee(e)?"multi":"real"}function Ho(e){let{parent:n,oldC:t,oldNode:o,oldNodes:r,i,ctx:s,out:l,pushA:d}=e;if(Array.isArray(t)){x("diff")&&V("diff","trace","",`remove-arr-item i=${i} range=[${(A(t,r[i])??[]).map(te).join(" | ")}] before=${se(n)}`);let u=A(t,o);for(let a of u??[])a.parentNode?.removeChild(a);x("diff")&&V("diff","trace","",`remove-arr-item after=${se(n)}`);for(let a of t)a!=null&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"&&re(a,s.registry)}else if(t&&typeof t=="object"&&!Array.isArray(t)){if(typeof t.type=="function")re(t,s.registry);else try{O(t,s.registry)}catch(u){console.error("[weifuwu] ref cleanup error",u)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);l.push(null),d(null)}function Mo(e){let{parent:n,newC:t,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,u=le(d.browser??E(),t);if(o?.nodeType===8){u&&o.nodeValue!==u.nodeValue&&(o.nodeValue=u.nodeValue),s.push(o),l(o);return}if(u&&o?.parentNode)o.parentNode.replaceChild(u,o);else if(u){let a=null;for(let c=r+1;c<i.length;c++){let f=i[c];if(f&&f.parentNode===n){a=f;break}}if(!a){let c=null;for(let f=s.length-1;f>=0;f--)if(s[f]){c=s[f];break}c&&c.parentNode===n&&(a=c.nextSibling)}a&&a.parentNode===n?n.insertBefore(u,a):n.appendChild(u),s.push(u),l(u)}else s.push(u),l(u)}function at(e){let{parent:n,newC:t,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,u=$(t,d,d.browser??E(),String(r));if(u==null){s.push(null),l(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){o.parentNode?.replaceChild(u,o),s.push(u),l(u);return}let a=null;for(let c=r+1;c<i.length;c++){let f=i[c];if(f&&f.parentNode===n){a=f;break}}if(a==null){let c=null;for(let f=s.length-1;f>=0;f--)if(s[f]){c=s[f];break}if(c&&c.parentNode===n)a=c.nextSibling;else{let f=i[i.length-1];f&&f.parentNode===n&&(a=f.nextSibling)}}a&&a.parentNode===n?n.insertBefore(u,a):n.appendChild(u),s.push(u),l(u)}function Oo(e){let{parent:n,oldC:t,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e;if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.type=="function"){let u=ct(n,t,r,o,l);i.push(u),s(u);return}let d=ft(n,t,r,o,l);i.push(d),s(d)}function Uo(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,out:s,pushA:l,ctx:d}=e,u=d.browser??E(),a=$(o,d,u,String(i));if(a==null){s.push(null),l(null);return}let c=t&&typeof t=="object"?A(t,r):null;if(c&&c.length>1){let p=(c[c.length-1]??r)?.nextSibling??null;for(let m of c)m.parentNode&&m.parentNode.removeChild(m);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")re(t,d.registry);else try{O(t,d.registry)}catch(m){console.error("[weifuwu] ref cleanup error",m)}p&&p.parentNode===n?n.insertBefore(a,p):n.appendChild(a)}else r?.parentNode?r.parentNode.replaceChild(a,r):n.appendChild(a);let f=a.nodeType===11?Array.from(a.childNodes):[a];s.push(...f),l(f[0]??a)}function $o(e){let{parent:n,oldC:t,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e,d=ut(n,t,r,o,l);i.push(d),s(d)}function Do(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,oldNodes:s,out:l,pushA:d,ctx:u}=e,a=u.browser??E(),c=A(t,r);x("diff")&&V("diff","debug","",`multi-remove i=${i} range=${c?c.map(te).join(" | "):"null"}`);for(let m of c??[])m.parentNode?.removeChild(m);for(let m of R(t?.props?.children))m!=null&&typeof m=="object"&&!Array.isArray(m)&&typeof m.type=="function"&&re(m,u.registry);let f=$(o,u,a,String(i));if(f==null){l.push(null),d(null);return}let p=s[i+1]??null;p?.parentNode?p.parentNode.insertBefore(f,p):n.appendChild(f),l.push(f),d(f)}function jo(e){let{parent:n,oldC:t,newC:o,oldNode:r,oldNodes:i,i:s,out:l,pushA:d,ctx:u}=e,a=A(t,r),c=wn(n,t,o,u,a);l.push(...c),d(i[s]??c[0]??null)}function Wo(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,out:s,pushA:l,ctx:d}=e;if(o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.type=="function"&&o._lifecycle==="disposed"){let c=mt(n,r,d,L(o.type));s.push(c),l(c);return}let u=Z(n,r,t,o,d);x("diff")&&V("diff","trace","",`after-patch i=${i} new=${ie(o)} node=${te(u)} dom=${se(n)}`);let a=xn(o,u);s.push(...a),l(a[0]??u??null)}function ut(e,n,t,o,r){let i=le(r.browser??E(),o),s=A(n,t),l=((s??[])[s?.length?s.length-1:0]??t)?.nextSibling??null;for(let d of s??[])d.parentNode?.removeChild(d);for(let d of R(n?.props?.children))d!=null&&typeof d=="object"&&!Array.isArray(d)&&typeof d.type=="function"&&re(d,r.registry);return i&&l&&l.parentNode===e?e.insertBefore(i,l):i&&e.appendChild(i),i}function ct(e,n,t,o,r){let i=le(r.browser??E(),o),s=_e(n,t,e,r);return i&&s?e.insertBefore(i,s):i&&e.appendChild(i),i}function ft(e,n,t,o,r){let i=le(r.browser??E(),o);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")re(n,r.registry);else try{O(n,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}return i&&t?.parentNode?t.parentNode.replaceChild(i,t):i&&e.appendChild(i),i}var Fo={hole:{hole:Mo,real:at,multi:at},real:{hole:Oo,real:Wo,multi:Uo},multi:{hole:$o,real:Do,multi:jo}};function Bo(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,anchorOut:s}=e,l=Math.max(t.length,o.length),d=[],u=a=>{s&&s.push(a)};for(let a=0;a<l;a++){let c=a<t.length?t[a]:null,f=a<o.length?o[a]:null;if(x("diff")&&V("diff","trace","",`pos ${a} old=${ie(c)} new=${ie(f)} oldNode=${te(r[a])}`),a>=o.length){Ho({parent:n,oldC:c,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:u,ctx:i});continue}if(c!=null&&typeof c=="object"&&!Array.isArray(c)&&f!=null&&typeof f=="object"&&!Array.isArray(f)&&f===c&&ve(c)){d.push(r[a]),u(r[a]);continue}Fo[Cn(c)][Cn(f)]({parent:n,oldC:c,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:u,ctx:i})}return d}function dt(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,anchorOut:s,arrEnd:l}=e,d=new Map;t.forEach((p,m)=>{let g=Re(p);g!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&d.set(g,{vnode:p,nodes:[r[m]??null].filter(Boolean),index:m})});let u=[],a=new Set,c=p=>{s&&s.push(p)},f=null;return o.forEach((p,m)=>{let g=Re(p),h=p;if(g!==null&&d.has(g)){let v=d.get(g),y=v.nodes[0]??null;if(a.add(g),h&&typeof h=="object"&&typeof h.type=="function"&&h._lifecycle==="disposed"){let C=mt(n,y,i,L(h.type));u.push(C),c(C),C&&(f=C);return}let N=Z(n,y,v.vnode,h,i),w=xn(h,N),H=w[0]??N,j=w[w.length-1]??N;if(H&&H.parentNode===n&&f&&H.previousSibling!==f){x("diff")&&V("diff","debug","",`keyed-correct i=${m} k=${g} move=[${w.map(te).join(" | ")}] after=${te(f)} before=${se(n)}`);let C=f.nextSibling;for(let T of w)T&&T.parentNode===n&&n.insertBefore(T,C);x("diff")&&V("diff","debug","",`keyed-correct after=${se(n)}`)}u.push(...w),c(w[0]??N??null),j&&(f=j)}else{let v={current:f};Xo[Yo(p)]({parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,out:u,pushA:c,arrEnd:l,c:p,i:m},v),f=v.current}}),t.forEach((p,m)=>{qo[Ko(Re(p),a)](n,p,m,r,i,o.length)}),u}function Ko(e,n){return e===null?"unkeyed":n.has(e)?"moved":"stale-keyed"}var qo={moved:()=>{},"stale-keyed":Go,unkeyed:zo};function Go(e,n,t,o,r){let i=n&&typeof n=="object"&&!Array.isArray(n)?A(n,o[t]):null;if(x("diff")&&V("diff","trace","",`keyed-delete i=${t} k=${Re(n)} range=${i?.length??0} oldNode=${te(o[t])}`),n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")re(n,r.registry);else try{O(n,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}pt(i,o[t])}function zo(e,n,t,o,r,i){let s=o[t];if(s?.nodeType===8&&s.nodeValue?.includes("type=hole")&&t<i)return;if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")re(n,r.registry);else try{O(n,r.registry)}catch(u){console.error("[weifuwu] ref cleanup error",u)}let d=n&&typeof n=="object"&&!Array.isArray(n)?A(n,s):null;pt(d,s)}function pt(e,n){if(e&&e.length>1)for(let t of e)t.parentNode&&t.parentNode.removeChild(t);else n?.parentNode&&n.parentNode.removeChild(n)}function Yo(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&K(e)?"portal":"real"}var Xo={hole:Jo,portal:Qo,real:Zo};function Jo(e,n){let{parent:t,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:u}=e,a=o[u]??null,c=r[u]??null,f=Cn(a);if(f==="hole"){let m=le(i.browser??E(),d);c?.nodeType===8?(m&&c.nodeValue!==m.nodeValue&&(c.nodeValue=m.nodeValue),s.push(c),l(c),c&&(n.current=c)):(m&&c?.parentNode?c.parentNode.replaceChild(m,c):m&&t.appendChild(m),s.push(m),l(m),m&&(n.current=m));return}let p=f==="multi"?ut(t,a,c,d,i):a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"?ct(t,a,c,d,i):ft(t,a,c,d,i);s.push(p),l(p),p&&(n.current=p)}function Qo(e,n){let{parent:t,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:u}=e,a=d,c=o[u]??null,f=Z(t,r[u]??null,c,a,i),p=xn(a,f);s.push(...p),l(p[0]??f??null);let m=p[p.length-1]??f;m&&(n.current=m)}function Zo(e,n){let{parent:t,oldNodes:o,ctx:r,out:i,pushA:s,arrEnd:l,c:d,i:u}=e,c=$(d,r,r.browser??E());if(i.push(c),s(c??null),c!=null){let f=o[u];f&&f.nodeType===8&&f.nodeValue?.includes("type=hole")?(f.parentNode?.replaceChild(c,f),n.current=c):(n.current?t.insertBefore(c,n.current.nextSibling):l&&l.parentNode===t?t.insertBefore(c,l):t.insertBefore(c,t.firstChild),n.current=c)}}function ze(e){for(let n=0;n<e.length;n++){let t=e[n];t&&typeof t=="object"&&!Array.isArray(t)&&Re(t)===null&&(t.key=`pos:${n}`)}}function mt(e,n,t,o){Ce()?console.error(`[vdom2/audit] I1 \u8FDD\u53CD\uFF1Adiff \u6536\u5230 disposed \u7EC4\u4EF6 ${o}\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\uFF08portal \u5185\u5BB9\u72EC\u7ACB dispose\uFF09\u2014\u2014\u7236\u6811\u5C06\u91CD\u5EFA`):console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${o} \u5728 diff\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`);let r=le(t.browser??E(),null);if(r==null)return null;let i=n;if(i){let s=i.parentNode;s?s.replaceChild(r,i):e.appendChild(r)}else e.appendChild(r);return r}var er={unkeyed:Bo,keyed:dt,mixed:e=>(ze(e.newChildren),ze(e.oldChildren),dt(e))};function Ye(e){let{registry:n,ctx:t}=e;async function o(i){let s=n.idRegistry.get(i);if(!s||!S(s)||typeof s._render!="function")return;let l=s;try{let d=await l._render(l.props),u=await G(d,t,l._child,n)??null,a=l._child;if(l._child=u,l._lifecycle==="building")return;let c=l._id!=null&&l._id===t.ui?._rootVNodeId,f=l._parentNode??l._refNode?.parentNode??null;if(f==null&&c&&(f=e.rootEl??null),f){let p={browser:t.browser??E(),registry:n,ctxVersion:Fe(t)},m=Z(f,l._refNode??null,a,u,p);if(l._refNode=m,Ce())try{let g=[];xe(f,u,h=>g.push(h)),g.length&&console.error("[vdom2/audit] "+g.join(" | "))}catch(g){console.error("[vdom2/audit] \u6821\u9A8C\u5F02\u5E38:",g)}}}catch(d){e.onError?e.onError(d):console.error("[vdom2] render error:",d?.stack??d)}}function r(i){return i==null?Promise.resolve():Promise.all(i.map(s=>o(s))).then(()=>{})}return{render:r}}function yt(e){let{ctx:n,browser:t}=e,o=e.registry??pe(),r=e.renderer??Ye({registry:o,ctx:n,rootEl:e.root,onError:e.onError}),i=n.ui,s=null,l=null,d={ctx:n,registry:o,renderer:r,async mount(u){s=u;let a=await G(u,n,null,o);e.root.innerHTML="";let c=$(a,n,t);if(c!=null&&e.root.appendChild(c),l=a?._child??a,i&&(i._rootVNodeId=a?._id??null),Ce())try{let f=[];xe(e.root,a,p=>f.push(p)),f.length&&console.error("[vdom2/audit] "+f.join(" | "))}catch(f){console.error("[vdom2/audit] \u6821\u9A8C\u5F02\u5E38:",f)}},async rerender(){if(s==null)return;let u=[];for(let[,a]of o.idRegistry)S(a)&&typeof a._render=="function"&&a._id&&u.push(a._id);await r.render(u)},unmount(){for(let[,u]of o.idRegistry)try{O(u,o)}catch{}e.root.innerHTML=""}};return d.close=()=>d.unmount(),d}var gt=E();function ht(e,n="bottom",t=6,o=!0){switch(n){case"bottom":return{top:e.bottom+t,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-t,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-t};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+t}}}function Xe(e,n,t=8){if(!n)return e;let o=n.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let r=Number.parseFloat(n.style.top)||o.top,i=Number.parseFloat(n.style.left)||o.left,s=e.top-r,l=e.left-i,d={top:o.top+s,bottom:o.bottom+s,left:o.left+l,right:o.right+l},u=gt.viewportWidth(),a=gt.viewportHeight(),c=e.top,f=e.left;return d.bottom>a-t&&(c=Math.max(t,c-(d.bottom-(a-t)))),d.top<t&&(c=Math.max(t,c+(t-d.top))),d.right>u-t&&(f=Math.max(t,f-(d.right-(u-t)))),d.left<t&&(f=Math.max(t,f+(t-d.left))),{top:c,left:f,width:e.width}}var Ve=E();function Nt(e){let n=new Map,t=new Map,o=!1,r=0;function i(){r||(r=requestAnimationFrame(()=>{r=0;let a=[];for(let[c,f]of n){if(!f.isOpen())continue;let p=f.getEl();if(!p)continue;let m=p.getBoundingClientRect();if(m.width===0&&m.height===0)continue;let g=f.compute(m);Object.assign(f.pos,Xe(g,f.panel?.(),f.margin)),a.push(c)}for(let[c,f]of t){let p=f.getScroller(),m=p instanceof Window?Ve.scrollingElement()?.scrollTop??Ve.scrollTop():p.scrollTop??0;m!==f.handle.y&&(f.handle.y=m,a.push(c))}a.length>0&&e(a)}))}function s(){o||(o=!0,Ve.addEventListener("scroll",i,{capture:!0,passive:!0}),Ve.addEventListener("resize",i))}function l(){o&&(Ve.removeEventListener("scroll",i,{capture:!0}),Ve.removeEventListener("resize",i),o=!1)}function d(a){for(let c of[...n.keys()])(c.startsWith(`popup:${a}:`)||c===`popup:${a}`||c===a)&&n.delete(c);t.delete(a)}function u(){l(),r&&(cancelAnimationFrame(r),r=0),n.clear(),t.clear()}return{popupTrackers:n,scrollTrackers:t,schedulePopupRecompute:i,ensurePopupListeners:s,destroyPopupListeners:l,cleanupTrackers:d,destroy:u}}function Vn(e,n,t){return r=>{r?n(r):t?.()}}function Ae(e){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches}function Je(e){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function En(e,n,t){let o=null,r=()=>{n(),t?.once&&o&&o.removeEventListener("animationend",r)};return s=>{s?(o=s,s.addEventListener("animationend",r)):o&&(o.removeEventListener("animationend",r),o=null)}}function Tn(e,n){let{onLongPress:t,duration:o=500}=n,r,i=0,s=0,l=null,d=()=>{clearTimeout(r),r=void 0},u=e.selfId();if(u){let a=e.onUnmount(c=>{c===u&&(d(),a())})}return{onPointerDown:a=>{i=a.clientX??0,s=a.clientY??0,l=a,d(),r=setTimeout(()=>{r=void 0,l&&t(l)},o)},onPointerUp:d,onPointerLeave:d,onPointerMove:a=>{let c=Math.abs((a.clientX??0)-i),f=Math.abs((a.clientY??0)-s);(c>10||f>10)&&d()},onContextMenu:a=>{a.preventDefault(),t(a)}}}function Ie(e,n){let t=e.selfId(),o="closed",r,i=()=>{o="closed",t?e.render([t]):e.render()};return{get phase(){return o},ref:l=>{l?r||(r=()=>{o==="exit"&&i()},l.addEventListener("animationend",r)):r=void 0},sync:l=>(l?o="open":o==="open"&&(o="exit"),o)}}function _n(e,n,t){let o=e.selfId(),r=Je(e),i=t?.duration??400,s=t?.ease==="linear"?f=>f:f=>1-Math.pow(1-f,3),l,d=n,u={value:r?n:0,reset:()=>{}},a=()=>{o?e.render([o]):e.render()},c=f=>{if(d=f,r){u.value=f,a();return}if(f===u.value)return;l&&cancelAnimationFrame(l);let p=u.value,m=performance.now(),g=h=>{let v=Math.min(1,(h-m)/i);u.value=Math.round(p+(f-p)*s(v)),v<1?(l=requestAnimationFrame(g),a()):(l=void 0,a())};l=requestAnimationFrame(g)};if(u.reset=f=>{f===d&&l||c(f)},o){let f=e.onUnmount(p=>{p===o&&(l&&(cancelAnimationFrame(l),l=void 0),f())})}return queueMicrotask(()=>c(n)),u}function Pn(e,n,t){let o=e.selfId(),r=e.browser,i=`media:${o}:${n}`;if(!e.mediaRegistry.has(i)){let s=r.matchMedia(n);t(s.matches);let l=u=>t(u.matches);s.addEventListener("change",l),e.mediaRegistry.set(i,{mql:s,handler:l});let d=e.onUnmount(u=>{if(u!==o)return;let a=e.mediaRegistry.get(i);if(a?.mql&&a.handler)try{a.mql.removeEventListener("change",a.handler)}catch{}e.mediaRegistry.delete(i),d()})}}function kn(e,n,t){let o=e.browser,r=typeof n=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:n,i=typeof n=="function"?n:t,s=e.selfId(),l=`bp:${s}`;function d(){for(let[u,a]of Object.entries(r))if(o.matchMedia(a).matches)return u;return Object.keys(r)[0]??""}if(!e.mediaRegistry.has(l)){i(d());let u=[];for(let c of Object.values(r)){let f=o.matchMedia(c),p=()=>i(d());f.addEventListener("change",p),u.push({mql:f,handler:p})}e.mediaRegistry.set(l,{mqls:u});let a=e.onUnmount(c=>{if(c!==s)return;let f=e.mediaRegistry.get(l);if(f?.mqls)for(let p of f.mqls)try{p.mql.removeEventListener("change",p.handler)}catch{}e.mediaRegistry.delete(l),a()})}}function Sn(e){let n=e.selfId(),t=e.browser,o={height:t.viewportHeight(),offsetTop:0,keyboardOpen:!1},r=()=>{n?e.render([n]):e.render()},i=()=>{let l=t.visualViewport();o.height=l?.height??t.viewportHeight(),o.offsetTop=l?.offsetTop??0,o.keyboardOpen=o.height<t.viewportHeight()*.9,r()},s=t.visualViewport();if(s?.addEventListener?(s.addEventListener("resize",i),s.addEventListener("scroll",i)):t.addEventListener("resize",i),n){let l=e.onUnmount(d=>{d===n&&(s?.removeEventListener?(s.removeEventListener("resize",i),s.removeEventListener("scroll",i)):t.removeEventListener("resize",i),l())})}return o}function Rn(e,n){let t=e.selfId(),o={isIn:!1,ready:!1,observe:d,refresh:u,disconnect:a},r=null,i=null,s=()=>{t?e.render([t]):e.render()};function l(){if(i?.disconnect(),i=null,!r)return;let c=typeof n.rootMargin=="function"?n.rootMargin():n.rootMargin,f=typeof n.threshold=="function"?n.threshold():n.threshold;i=new IntersectionObserver(p=>{let m=p[p.length-1];if(!m)return;let g=m.isIntersecting,h=g!==o.isIn,v=!o.ready;o.isIn=g,o.ready=!0,n.onChange?.(m,g),(h||v)&&s()},{root:n.root?n.root():null,rootMargin:c??"0px",threshold:f??0}),i.observe(r)}function d(c){r=c,c?l():(i?.disconnect(),i=null,o.isIn=!1)}function u(){l()}function a(){i?.disconnect(),i=null}if(t){let c=e.onUnmount(f=>{f===t&&(a(),c())})}return o}function An(e,n){let t=e.selfId(),o=e.browser,r={y:0,refresh(){let l=i.getScroller();r.y=l instanceof Window?o.scrollingElement()?.scrollTop??o.scrollTop():l.scrollTop??0}},i={handle:r,getScroller:n.getScroller??(()=>window)};if(!t)return r.refresh(),r;e.scrollTrackers.set(t,i),e.ensurePopupListeners(),r.refresh();let s=e.onUnmount(l=>{l===t&&(e.scrollTrackers.delete(t),s())});return r}function Qe(e,n){let t=e.selfId(),o=n.value!==void 0;if(o&&!n.onChange&&n.name&&(e.warned.has(n.name)||(e.warned.add(n.name),console.warn(`[weifuwu/${n.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
4
|
-
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!o&&t&&!e.uncontrolledValues.has(t)){e.uncontrolledValues.set(t,n.value);let i=e.onUnmount(s=>{s===t&&(e.uncontrolledValues.delete(t),i())})}let r=i=>{if(o){n.onChange?.(i);return}t&&e.uncontrolledValues.set(t,i),t?e.render([t]):e.render()};return{value:o?n.value:t?e.uncontrolledValues.get(t):n.value,setValue:r,controlled:o}}function
|
|
5
|
-
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 open\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onOpenChange={(o) => setOpen(o)}`));let r=()=>o?!!n.open:t?e.openStates.get(t)??!1:!1,i=()=>{t?e.render([t]):e.render()},s=l=>{if(o){n.onOpenChange?.(l);return}t&&e.openStates.set(t,l),i()};return{get open(){return r()},setOpen:s,triggerProps:{onClick:()=>s(!0),onFocus:()=>{n.openOnFocus&&s(!0)}}}}var
|
|
1
|
+
function zt(e){let n=[],t=(e||"/").replace(/:(\w+)/g,(o,r)=>(n.push(r),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}var mn=class{_routes=[];_middlewares=[];_injections=[];_injected=!1;_mode;_notFound;constructor(n={}){this._mode=n.mode??"history"}get mode(){return this._mode}use(n,t){if(typeof n=="string"&&t){let o=this,r=n,i=async(s,l,d)=>{let u=l.__routePath??o.getPath(),a=null;return u===r?a="/":(r==="/"?u!=="/"&&u.startsWith("/"):u.startsWith(r+"/"))&&(a=u.slice(r.length)),a===null?d:async(c,f)=>{let p=await t._handle(a,c,f);return p===null?d(c,f):p}};return this._middlewares.push(i),this}return n.length<=1?(this._injections.push(n),this):(this._middlewares.push(n),this)}async _ensureInjected(n){if(!this._injected){this._injected=!0;for(let t of this._injections){let o=await t(n);o&&o!==n&&Object.assign(n,o)}}}get(n,t,o){return this._routes.push({path:n,handler:t,title:o?.title}),this}notFound(n){return this._notFound=n,this}getPath(){return this._getPath(void 0)}_getPath(n){let t=n?.location??(typeof window<"u"?window.location:null);return this._mode==="hash"?(t?.hash??"").replace(/^#/,"")||"/":t?.pathname??"/"}match(n){let t=null;for(let o of this._routes){let{re:r,keys:i}=zt(o.path),s=n.match(r);if(!s)continue;let l={};for(let d=0;d<i.length;d++)l[i[d]]=decodeURIComponent(s[d+1]);t={handler:o.handler,params:l,title:o.title};break}return t||(t={handler:this._notFound??(()=>null),params:{}}),t}async _handle(n,t,o){await this._ensureInjected(o);let r=this.match(n);r.title&&typeof document<"u"&&(document.title=r.title),o.params=r.params,o.route&&(o.route.params=r.params);let s=r.handler,l=o.__routePath;o.__routePath=n;try{for(let d=this._middlewares.length-1;d>=0;d--){let u=this._middlewares[d],a=s;s=await u(t,o,a)??a}return await s(t,o)}finally{o.__routePath=l}}async execute(n,t,o){await this._ensureInjected(t);let r=this.match(o);r.title&&typeof document<"u"&&(document.title=r.title),t.params=r.params,t.route&&(t.route.params=r.params);let s=r.handler;for(let l=this._middlewares.length-1;l>=0;l--){let d=this._middlewares[l],u=s;s=await d(n,t,u)??u}return await s(n,t)}};var J=Symbol("Fragment"),K=Symbol("Portal");function qe(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function ne(e){return e!=null&&typeof e=="object"&&e.type===J}function P(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function q(e){return e!=null&&typeof e=="object"&&e.type===K}function Ke(e,n,t=null){return{type:e,props:n,key:t,_child:null,_parentNode:null,_refNode:null,_id:null,_customId:null,_parentVNode:null,_ctxVersion:null,_lifecycle:"fresh"}}function Pe(e,n,t=null){return e===J?{...Ke(e,n,t),type:e}:e===K?{...Ke(e,n,t),type:e,_remoteEl:null,_placement:"remote"}:typeof e=="function"?{...Ke(e,n,t),type:e,_render:null,_outputChild:null}:{...Ke(e,n,t),type:e,el:null}}function ge(e,n,...t){let o=et(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),Pe(e,o,n?.key??null)}function yn(e,n,t){return Pe(e,et(n),t??null)}var Yt=yn;function Xt(e,n,t){return yn(e,n,t)}function et(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function A(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}function Ge(e,n){let t=Pe(K,{children:e,portalKey:n});return t.key=n??null,t}function V(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,queryAll:e=>typeof document<"u"?document.querySelectorAll(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,createElementNS:(e,n)=>typeof document<"u"?document.createElementNS(e,n):null,createDocumentFragment:()=>typeof document<"u"?document.createDocumentFragment():null,createComment:e=>typeof document<"u"?document.createComment(e):null,createTextNode:e=>typeof document<"u"?document.createTextNode(e):null,addEventListener:(e,n,t)=>{typeof window<"u"&&window.addEventListener(e,n,t)},removeEventListener:(e,n,t)=>{typeof window<"u"&&window.removeEventListener(e,n,t)},scrollTo:e=>{typeof window<"u"&&window.scrollTo(0,e)},matchMedia:e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e):null,visualViewport:()=>(typeof window<"u"?window:null)?.visualViewport??null,scrollingElement:()=>typeof document<"u"?document.scrollingElement:null,bodyElement:()=>typeof document<"u"?document.body:null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},clearBody:()=>{typeof document<"u"&&(document.body.innerHTML="")},event:(e,n)=>{let t=typeof window<"u"?window:null,o=n&&(n.key||n.code)?"KeyboardEvent":n&&(n.clientX!==void 0||n.clientY!==void 0||n.pointerId!==void 0)?"PointerEvent":"Event";try{return new t[o](e,n)}catch{return new t.Event(e,n)}},dispatchEvent:(e,n)=>typeof e<"u"?e.dispatchEvent(n):!1,navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,viewportWidth:()=>typeof window<"u"?window.innerWidth:0,pathname:()=>typeof window<"u"?window.location.pathname:"",createTreeWalker:(e,n)=>typeof document<"u"?document.createTreeWalker(e,n??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}function Jt(e,n,t=400){let o=!1,r=()=>{o||(o=!0,e.removeEventListener("animationend",r),clearTimeout(i),n())};e.addEventListener("animationend",r);let i=setTimeout(r,t)}function be(e,n){return Object.assign(Object.create(e),n)}function Qt(e){let n={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},t=e?.onRequest,o=e?.onResponse,r=e?.timeout??0;async function i(s,l,d,u,a=!1){let c=n.baseURL+l,f={method:s,headers:{...n.headers,...u?.headers}},p=e?.token?.();p&&!f.headers.Authorization&&(f.headers.Authorization=`Bearer ${p}`);let m=r>0,g=!!u?.signal,h=null,N=null;(m||g)&&(h=new AbortController,f.signal=h.signal,m&&(N=setTimeout(()=>h.abort(new Error("Request timed out")),r)),g&&u.signal.addEventListener("abort",()=>h.abort())),d!==void 0&&s!=="GET"&&s!=="HEAD"&&(f.body=JSON.stringify(d));let y={url:c,init:f};t&&(y=t(y));try{let v=await fetch(y.url,y.init);if(v.status===401&&await e?.onUnauthorized?.()&&!a)return i(s,l,d,u,!0);if(o)return o(v);if(!v.ok){let W=await v.text().catch(()=>"");throw new gn(v.status,W||v.statusText)}let b=v.headers.get("content-length");if(v.status===204||b==="0")return;let H=(v.headers.get("content-type")||"").toLowerCase();return H.includes("application/json")||H.includes("json")?v.json():v.text()}finally{N&&clearTimeout(N)}}return s=>be(s,{api:{get:(d,u)=>i("GET",d,void 0,u),post:(d,u,a)=>i("POST",d,u,a),put:(d,u,a)=>i("PUT",d,u,a),patch:(d,u,a)=>i("PATCH",d,u,a),delete:(d,u)=>i("DELETE",d,void 0,u)}})}var gn=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function Zt(e){try{let n=e.split(".");if(n.length!==3)return null;let t=n[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t))}catch{return null}}function eo(e){let n=Zt(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function no(e){let n=e?.storage??localStorage,t=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",r=e?.refreshTokenKey??"weifuwu_refresh",i=e?.refreshEndpoint??"/api/auth/refresh";return s=>{let l=n.getItem(t),d=n.getItem(o),u=null,a={token:l,user:d?JSON.parse(d):null,get isLoggedIn(){return this.token!==null},login(f,p,m){a.token=f,a.user=p,n.setItem(t,f),n.setItem(o,JSON.stringify(p)),m&&n.setItem(r,m)},logout(){a.token=null,a.user=null,n.removeItem(t),n.removeItem(o),n.removeItem(r)},setUser(f){a.user=f,n.setItem(o,JSON.stringify(f))},async refresh(){return u||(u=c().finally(()=>{u=null}),u)}};async function c(){let f=n.getItem(r);if(!f)return!1;let p=n.getItem(t);try{let m=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:f})});if(n.getItem(t)!==p)return!1;if(!m.ok)return a.logout(),!1;let g=await m.json();return n.getItem(t)!==p?!1:(a.token=g.token,n.setItem(t,g.token),g.refreshToken&&n.setItem(r,g.refreshToken),!0)}catch{return!1}}return l&&eo(l)&&a.refresh().catch(()=>{}),e?.onAuth?.(a),be(s,{auth:a})}}function to(e={}){let n=e.url??"/ws",t=e.reconnectInterval??3e3,o=e.maxReconnect??10,r=e.pingInterval??3e4,i=e.pingTimeout??1e4;return s=>{let l=new Set,d=null,u=0,a=null,c=null,f=null,p=!1,m=[],g={isConnected:!1,onMessage:b=>(l.add(b),()=>{l.delete(b)}),send:b=>{let H=JSON.stringify(b);d?.readyState===WebSocket.OPEN?d.send(H):m.push(H)},_connect:h,close:()=>{p=!0,v(),d?.close(),d=null,m=[],g.isConnected=!1}};async function h(){if(!p)try{d=new WebSocket(n),d.onopen=()=>{g.isConnected=!0,u=0;for(let b of m)d.send(b);m=[],N()},d.onmessage=b=>{try{let H=JSON.parse(b.data);for(let W of l)W(H)}catch{}y()},d.onclose=()=>{g.isConnected=!1,v(),!p&&u<o&&(u++,a=setTimeout(h,t*Math.min(u,5)))},d.onerror=()=>{d?.close()}}catch{p||(a=setTimeout(h,t))}}function N(){r<=0||(c=setInterval(()=>{d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"})),f=setTimeout(()=>{d?.close()},i)},r))}function y(){clearTimeout(f)}function v(){clearInterval(c),clearTimeout(f),clearTimeout(a)}return h(),be(s,{ws:g})}}var oo={route:"route",lifecycle:"lifecycle",x2y:"diff",keys:"diff",pos:"diff",render:"render",audit:"audit",build:"build",mount:"mount",diff:"diff"};function tt(e){return oo[e]}var Ce=new Set;function Ye(e){return Ce.add(e),()=>{Ce.delete(e)}}var ze=[],ro=0;function Xe(e){let n=`R${++ro}${e?":"+e:""}`;return ze.push(n),n}function Re(){ze.pop()}function io(){return ze[ze.length-1]??""}function S(e){if(Ce.size!==0){e.session||(e.session=io()),typeof e.payload=="function"&&(Ce.size>1||x(tt(e.machine),e.level??"debug"))&&(e.payload=e.payload());for(let n of Ce)try{n(e)}catch{}}}function ot(){return Ce.size>1}function so(e){if(e==null)return"";if(typeof e=="string")return` ${e}`;if(typeof e=="object"){let n=e,t=[];for(let o of["path","i","key","mode","kind","insertedBefore","after","depth"])if(n[o]!==void 0){let r=n[o];t.push(`${o}=${typeof r=="object"?JSON.stringify(r):String(r)}`)}return t.length?" "+t.join(" "):""}return` ${String(e)}`}function lo(e){let n=tt(e.machine);if(!x(n,e.level??"debug"))return;if(e.event==="TRACE"){console.log(`[vdom:${e.machine}] ${e.payload}`);return}let t=e.component?`${e.component}${e.nodeId?`(${e.nodeId})`:""}`:e.nodeId?`(${e.nodeId})`:"";console.log(`[vdom:${e.machine}] ${t?t+" ":""}${e.from} --${e.event}--> ${e.to}${so(e.payload)}`)}Ye(lo);var ao=500,Se=[],nt=!1;function uo(e){Se.push(e),Se.length>ao&&Se.shift()}function rt(){nt||(nt=!0,Ye(uo))}function it(){rt()}function st(e=50,n){return rt(),n?Se.filter(t=>Object.entries(n).every(([o,r])=>t[o]===r)).slice(-e):Se.slice(-e)}var co={fresh:{BUILD_START:"building",BUILD_DONE:"built",PRUNE:"pruned",DISPOSE:"disposed"},building:{BUILD_DONE:"built",DISPOSE:"disposed"},built:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},pruned:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},disposed:{BUILD_START:"building"}};function Q(e){let n=0,t=e._parentVNode??null;for(let o=0;o<10&&t;o++)n++,t=t._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:n}}var Je=new Map,fo=50;function po(e,n,t,o){if(!e?.id)return;let r=Je.get(e.id);r||(r={name:e.name??"?",events:[]},Je.set(e.id,r)),r.events.push(`${n}--${t}-->${o}`),r.events.length>fo&&r.events.shift()}function lt(e){if(e){let n=Je.get(e);return n?`${n.name}(${e}): ${n.events.join(" \u2192 ")}`:`no timeline for ${e}`}return[...Je.entries()].map(([n,t])=>`${t.name}(${n}): ${t.events.join(" \u2192 ")}`).join(`
|
|
2
|
+
`)}function Z(e,n,t){let o=co[e]?.[n]??null;return o==null?(S({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:"?",level:"warn",ts:Date.now()}),e):(po(t,e,n,o),S({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:o,payload:()=>({depth:t?.depth??0}),level:"debug",ts:Date.now()}),o)}function Ve(e){return!e||e._lifecycle==="disposed"||e._child==null?!1:!hn(e._child)}function hn(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e)){for(let t of e)if(hn(t))return!0;return!1}let n=e;return!!(n._lifecycle==="disposed"||n._child!=null&&hn(n._child))}var vn={error:0,warn:1,info:2,debug:3,trace:4},dt=["mount","build","render","diff","lifecycle","route","audit"],te={enabled:!1,stages:new Set,level:"info",filter:null},Nn=!1;function mo(e){return e&&e in vn?e:"info"}function at(e){let n=new Set;if(!e)return n;for(let t of e.split(",")){let o=t.trim().split(":")[0];dt.includes(o)&&n.add(o)}return n}function bn(){if(Nn)return te;Nn=!0;try{let e=globalThis,n=new URLSearchParams(typeof e.location?.search=="string"?e.location.search:""),t=n.get("vdom_trace"),o=n.get("vdom_debug"),r=e.__vdom_trace__,i=typeof e.localStorage?.getItem=="function"?e.localStorage.getItem("vdom_trace"):null;if(o==="1"||e?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")te={enabled:!0,stages:new Set(dt),level:"debug",filter:null};else if(t||r||i){let s=new Set;if(t)for(let l of at(t))s.add(l);if(r?.stages){let l=Array.isArray(r.stages)?r.stages:[...r.stages];for(let d of l)s.add(d)}if(i)for(let l of at(i))s.add(l);te={enabled:!0,stages:s,level:t?.includes(":")?mo(t.split(":")[1]):r?.level??"debug",filter:typeof r?.filter=="string"?r.filter:null}}}catch{}return te}function x(e,n="info"){return!te.enabled&&(Nn||bn(),!te.enabled)||te.stages.size&&!te.stages.has(e)?!1:vn[n]<=vn[te.level]}function k(e,n,t,...o){if(!x(e,n)&&!ot())return;let r=te.filter;r&&!t.includes(r)||S({session:"",machine:e,nodeId:null,component:null,from:"",event:"TRACE",to:"",payload:()=>o.length?`${t} ${o.join(" ")}`:t,level:n,ts:Date.now()})}var yo=0;function ut(e){return`R${++yo}${e?`:${e}`:""}`}function G(e,n=12){if(!e)return"\u2205";if(typeof e=="string"||typeof e=="number")return`"${e}"`;if(!Array.isArray(e))return he(e);let t=e.slice(0,n).map(he);return e.length>n&&t.push(`\u2026+${e.length-n}`),`[${t.join(" | ")}]`}function ct(e){return typeof e=="function"?"function":e===J?"fragment":typeof e=="string"?"string":"other"}var go={function:e=>e.name||"Comp",fragment:()=>"Frag",string:e=>String(e),other:e=>String(e)},ho={function:e=>e.name||"anonymous",fragment:()=>"Fragment",string:e=>String(e),other:e=>e===K?"Portal":String(e)};function he(e){if(e==null||typeof e=="boolean")return String(e);if(typeof e=="string")return`"${e.slice(0,16)}"`;if(typeof e=="number")return String(e);if(Array.isArray(e))return`ARR(${e.length})`;let n=e,t=n.type,o=go[ct(t)](t),r=n.props?.id?`#${n.props.id}`:n.key!=null?`@${n.key}`:"";return o+r}function z(e){if(!e)return"null";if(e.nodeType===1){let n=e;return`${n.tagName}${n.id?`#${n.id}`:""}${n.getAttribute?.("data-wf-key")?`@${n.getAttribute("data-wf-key")}`:""}`}return e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,40)}-->`:`#${e.nodeType}`}function se(e,n=12){if(!e)return"null";let o=Array.from(e.childNodes).slice(0,n).map(z);return e.childNodes.length>n&&o.push(`\u2026+${e.childNodes.length-n}`),`[${o.join(" | ")}]`}function wn(e,n=0){if(e==null||typeof e=="boolean")return[];if(typeof e=="string"||typeof e=="number")return[`${" ".repeat(n)}"${String(e).slice(0,20)}"`];if(Array.isArray(e))return e.flatMap(u=>wn(u,n));let t=e,o=t.type,r=ho[ct(o)](o),i=t._lifecycle?`[${t._lifecycle}]`:"",s=t._id?`(${t._id})`:"",l=[`${" ".repeat(n)}${r}${s}${i}`],d=t._child;return d!=null&&l.push(...wn(d,n+1)),l}function ft(e){let n=globalThis;if(n.__vdom_dump==null&&(n.__vdom_dump=()=>wn(e()??null).join(`
|
|
3
|
+
`)),n.__vdom_lc==null&&(n.__vdom_lc=t=>lt(t)),n.__vdom_events==null){let t=st;n.__vdom_events=(o,r)=>t(o,r)}}function I(e){return typeof e=="function"&&e.name||"anonymous"}function Qe(e){return e.ui?._ctxVersion??0}function Cn(e,n){e.ui?.setMounting?.(n)}var vo=0;function ye(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${vo++}`}}function Ze(e,n){return e.unmountHooks.push(n),()=>{let t=e.unmountHooks.indexOf(n);t>=0&&e.unmountHooks.splice(t,1)}}function pt(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function No(e,n,t,o){try{e(n)}catch(r){console.error(`[weifuwu] ref ${t} error in <${o??"anonymous"}>`,r)}}function U(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){let o=Q(t);if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let r=[...n.unmountHooks];for(let i of r)i(t._id);if(t._customId)for(let i of r)i(t._customId)}t._id=null,t._customId=null,P(t)&&(t._render=null),t._parentNode=null,t._refNode=null,t._lifecycle=Z(t._lifecycle,"DISPOSE",o)}else(P(t)||t._child!=null)&&(t._lifecycle=Z(t._lifecycle,"DISPOSE",Q(t)));if(t._child!=null){if(Array.isArray(t._child))for(let o of t._child)o&&typeof o=="object"&&U(o,n);else U(t._child,n);t._child=null}if(t.props?.children&&typeof t.type=="string"){let o=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let r of o)r&&typeof r=="object"&&U(r,n)}if(typeof t.props?.ref=="function"&&No(t.props.ref,null,"cleanup"),q(t)){let o=t._remoteEl;if(o){let r=t._child;if(r!=null)if(Array.isArray(r))for(let i of r)i&&typeof i=="object"&&U(i,n);else typeof r=="object"&&U(r,n);o.remove(),t._remoteEl=null}}}function L(e,n){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||ne(e)){let o=n;if(o&&o.nodeType===8&&o.nodeValue?.includes("type=fragment-start")){let r=[o],i=/fid=([^\s"]+)/.exec(o.nodeValue)?.[1]??"",s=o.nextSibling;for(;s&&(r.push(s),!(s.nodeType===8&&s.nodeValue?.includes("type=fragment-end")&&(/fid=([^\s"]+)/.exec(s.nodeValue)?.[1]??i)===i));)s=s.nextSibling;return r}return null}let t=e;return P(t)?L(t._outputChild??t._child,n):null}function $(e){if(e==null||typeof e=="boolean")return"hole";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"arr";let n=e;return ne(n)?"frag":q(n)?"portal":P(n)?"comp":"native"}function Vn(e){let n=!1,t=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){t=!0;continue}let r=o;q(r)||(r.key!=null?n=!0:t=!0)}return n&&t?"mixed":n?"keyed":"unkeyed"}function wo(e){if(e===!1)return"false";if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0)return"true";if(typeof e=="object")try{let n=JSON.stringify(e);return`object ${n!=null&&n.length>80?n.slice(0,80)+"\u2026":n??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function en(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function B(e){let n=[`type=${e.type}`];return e.value!==void 0&&n.push(`value=${en(wo(e.value))}`),e.key!=null&&n.push(`key=${en(e.key)}`),e.id!=null&&n.push(`id=${en(e.id)}`),e.fid!=null&&n.push(`fid=${en(e.fid)}`),`wf-hole: ${n.join(" ")}`}function yt(e){return typeof e!="string"&&typeof e!="function"&&e!==J&&e!==K}function gt(e){for(let n=0;n<e.length;n++){let t=e[n];if(t!=null&&typeof t=="object"&&!Array.isArray(t)){let o=t;o.key!==null&&(o.key=String(o.key))}}}var bo=/^on[A-Z]/,Co=/^on[A-Z].*Capture$/;function xn(e){let n=Co.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var En=new Set(["draggable","contenteditable","spellcheck","translate"]),Vo=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function Tn(e){return En.has(e)?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":bo.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function mt(e,n,t){if(t!==!1){if(t===!0){e.setAttribute(n,"");return}try{e[n]=t,e.getAttribute(n)!==String(t)&&e.setAttribute(n,String(t))}catch{e.setAttribute(n,String(t))}}}var xo={enumerated:(e,n,t)=>{e.setAttribute(n,t?"true":"false")},class:(e,n,t)=>{if(t!==!1)if(typeof t=="object")for(let[o,r]of Object.entries(t))r&&e.classList.add(o);else e.setAttribute("class",String(t))},style:(e,n,t)=>{if(t!==!1)if(typeof t=="string")e.setAttribute("style",t);else{let o=e.style;for(let[r,i]of Object.entries(t))i==null?o[r]="":r.startsWith("--")?o.setProperty(r,String(i)):typeof i=="number"&&!Vo.has(r)?o[r]=`${i}px`:o[r]=String(i)}},ref:(e,n,t)=>{if(typeof t=="function")try{t(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,n,t)=>{if(t===!1)return;let{type:o,capture:r}=xn(n);if(typeof t!="function"){console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof t} \u2014 ignored`);return}e.addEventListener(o,t,r?{capture:!0}:{})},value:(e,n,t)=>{t!==!1&&(e.value=t)},indeterminate:(e,n,t)=>{t!==!1&&(e.indeterminate=!!t)},innerHTML:(e,n,t)=>{t!==!1&&(e.innerHTML=String(t??""))},aria:(e,n,t)=>{if(t!==!1){if(typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}mt(e,n,t)}},default:mt};function oe(e,n,t){t!=null&&xo[Tn(n)](e,n,t)}function le(e,n){return e.createComment(B({type:"hole",value:n,key:null,id:null,fid:null}))}function ae(){return!!globalThis?.__WF_VDOM_AUDIT}var ht=!1;function vt(){ht||(ht=!0,Ye(e=>{e.machine!=="render"||e.event!=="PARENT"||ae()&&e.to==="SKIP_DETACHED"&&console.error(`[vdom2/audit] \u6302\u8F7D\u4E0D\u53D8\u91CF\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${e.component??"?"}${e.nodeId?`(${e.nodeId})`:""} \u72B6\u6001 ${String(e.payload?.lifecycle)} \u4F46\u65E0 _parentNode/_refNode\uFF08rootEl \u53EA\u5C5E\u4E8E\u6839\u7EC4\u4EF6\uFF09\u2014\u2014\u6302\u8F7D\u4FE1\u606F\u65AD\u88C2\uFF0C\u6E32\u67D3\u88AB\u8DF3\u8FC7\uFF0C\u72B6\u6001\u66F4\u65B0\u5C06\u4E22\u5931`)}))}function nn(e,n,t){if(n==null||n.length===0)return;let o=Array.from(e.childNodes);if(!n.some(i=>{if(i==null||typeof i!="object")return!1;if(Array.isArray(i))return!0;let s=i.type;return s===J||s===K}))for(let i=0;i<n.length;i++){let s=n[i];if(s==null||typeof s=="boolean"){let l=o[i];(!l||l.nodeType!==8||!l.nodeValue?.includes("type=hole"))&&t(`[audit] \u5360\u4F4D\u9519\u4F4D\uFF1A\u4F4D\u7F6E ${i} \u671F\u671B\u6CE8\u91CA(wf-hole)\uFF0C\u5B9E\u9645 ${l?.nodeName??"null"}\uFF08${e.nodeName}\uFF09`)}else if(typeof s=="string"||typeof s=="number"){let l=o[i];l&&l.nodeType!==3&&t(`[audit] \u6587\u672C\u9519\u4F4D\uFF1A\u4F4D\u7F6E ${i} \u671F\u671B\u6587\u672C\u8282\u70B9\uFF0C\u5B9E\u9645 ${l.nodeName}\uFF08${e.nodeName}\uFF09`)}}}function xe(e,n,t){Eo[$(n)](e,n,t)}var Eo={hole:()=>{},text:()=>{},arr:To,portal:()=>{},frag:_o,comp:ko,native:Po};function To(e,n,t){let o=n;nn(e,o,t);for(let r of o)if(r!=null&&typeof r=="object"&&Array.isArray(r))for(let i of r)xe(e,i,t);else r!=null&&typeof r=="object"&&!Array.isArray(r)&&ne(r)&&nn(e,A(r.props?.children),t)}function _o(e,n,t){nn(e,A(n.props?.children),t)}function ko(e,n,t){let o=n,r=o._refNode;r&&r.parentNode!==e&&t(`[audit] \u7EC4\u4EF6\u951A\u70B9\u9519\u4F4D\uFF1A${I(o.type)} _refNode \u4E0D\u5728\u7236\u8282\u70B9\u5185`),o._child!=null&&xe(e,o._child,t)}function Po(e,n,t){let o=n;if(yt(o.type))return;let r=o.el??o._refNode;if(r&&r.nodeType===1&&r.tagName.toLowerCase()!==String(o.type)&&t(`[audit] \u5143\u7D20\u7C7B\u578B\u9519\u4F4D\uFF1A\u671F\u671B <${String(o.type)}>\uFF0C\u5B9E\u9645 ${r.tagName}`),r&&r.nodeType===1&&!("innerHTML"in(o.props??{}))){nn(r,A(o.props?.children),t);for(let i of A(o.props?.children))i!=null&&typeof i=="object"&&!Array.isArray(i)&&P(i)&&xe(r,i,t)}}function So(e,n){if(e===n)return!0;let t=Object.keys(e),o=Object.keys(n);if(t.length!==o.length)return!1;for(let r of t)if(e[r]!==n[r])return!1;return!0}async function Ro(e,n,t,o){let r=e;r._id||(o?.reuse?._id?r._id=o.reuse._id:r._id=t.nextId(),t.idRegistry.set(r._id,r)),o?.reuse&&(o.reuse._parentNode&&(r._parentNode=o.reuse._parentNode),o.reuse._refNode&&(r._refNode=o.reuse._refNode),o.reuse._ctxVersion!=null&&(r._ctxVersion=o.reuse._ctxVersion));let i=Object.create(n);i.ui=Object.create(n.ui);let s=i.ui;if(s._selfId=r._id??null,s._selfVNode=r,s.render=function(l){let d=n.ui;return l==null&&r._id?d.render([r._id]):d.render(l)},typeof r._render!="function"&&P(o?.reuse)&&typeof o.reuse._render=="function"&&(r._render=o.reuse._render),typeof r._render!="function"){Cn(n,!0);let l;try{l=await r.type(r.props??{},i)}finally{Cn(n,!1)}if(typeof l!="function")throw new Error(`Component ${I(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);r._render=l}return{renderFn:r._render,childCtx:i}}function _n(e){return!!e&&typeof e.then=="function"}function Y(e,n,t,o,r){return Ao[$(e)](e,n,t,o,r)}function kn(e,n){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===n.type?e:null}var Ao={hole:e=>e,text:e=>e,arr:Io,comp:Lo,frag:Mo,native:Nt,portal:Nt};function Io(e,n,t,o,r){let i=e;x("build")&&k("build","debug","",`array in kids=${G(i)}`);for(let a of i)if(a!=null&&typeof a=="object"&&!Array.isArray(a)&&a._lifecycle==="disposed"){let c=a;S({session:"",machine:"audit",nodeId:c._id??null,component:I(c.type),from:"disposed",event:"CONTRACT_VIOLATION",to:"new-tree",level:"error",ts:Date.now()}),ae()&&console.error(`[vdom2/audit] \u4E24\u9636\u6BB5\u5951\u7EA6\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${I(c.type)} \u7684 renderFn \u8FD4\u56DE\u4E86 disposed \u65E7 vnode${c._id?`(${c._id})`:""}\u2014\u2014\u590D\u7528\u65E7\u6811\u5BF9\u8C61\uFF08\u5E94\u4E3A\u6BCF\u6B21\u6E32\u67D3\u751F\u6210\u65B0 vnode\uFF09\u3002\u540C\u4E00\u5BF9\u8C61\u65E2\u662F\u65E7\u6811\u53C8\u88AB dispose \u2192 diff \u81EA dispose \u2192 \u5361\u7247\u9519\u4F4D/\u6D88\u5931\uFF08demo \u641C\u7D22\u6062\u590D\u4E8B\u6545\uFF09`);break}for(let a=0;a<i.length;a++){let c=i[a];if(c!=null&&typeof c=="object"&&!Array.isArray(c)){let f=c;f.key!==null&&(f.key=String(f.key))}}let s=Array.isArray(t)?t:[],l=new Map;for(let a of s)a!=null&&typeof a=="object"&&!Array.isArray(a)&&a.key!=null&&l.set(a.key,a);let d=i.map((a,c)=>{let f=null;return a!=null&&typeof a=="object"&&!Array.isArray(a)&&a.key!=null&&(f=l.get(a.key)??null),f==null&&(f=s[c]??null),Y(a,n,f,o,r)});x("build")&&k("build","debug","",`array out kids=${G(i)}`);let u=!1;for(let a=0;a<d.length;a++)if(_n(d[a])){u=!0;break}return u?Promise.all(d).then(()=>i):i}function Lo(e,n,t,o,r){let i=e,s=o??n.__registry??ye(),l=kn(t,i);i._id||(i._id=l?._id??s.nextId(),s.idRegistry.set(i._id,i)),l&&(l._parentNode&&(i._parentNode=l._parentNode),l._refNode&&(i._refNode=l._refNode),l._ctxVersion!=null&&(i._ctxVersion=l._ctxVersion),P(i)&&P(l)&&typeof l._render=="function"&&(i._render=l._render));let d=So(l?.props??{},i.props??{}),u=Qe(n),a=(l?._ctxVersion??-1)===u;if(!r?.force&&d&&a&&Ve(l)&&typeof i._render=="function"){let c=l;return i._lifecycle=Z(i._lifecycle,"PRUNE",Q(i)),i._child=c._child,i._ctxVersion=c._ctxVersion,x("build")&&k("build","debug","",`prune comp=${he(i)} propsSame=${d} verSame=${a}`),i}return i._lifecycle=Z(i._lifecycle,"BUILD_START",Q(i)),x("build")&&k("build","debug","",`mount comp=${he(i)} propsSame=${d} verSame=${a} force=${!!r?.force}`),(async()=>{let{childCtx:c}=await Ro(i,n,s,{reuse:l??null}),f=await Y(await i._render(i.props),c,l?._child,s,r);return i._child=f??null,i._ctxVersion=u,i._lifecycle=Z(i._lifecycle,"BUILD_DONE",Q(i)),i})()}function Mo(e,n,t,o,r){let i=e,s=o??n.__registry??ye(),l=kn(t,i);x("build")&&k("build","debug","",`fragment kids=${G(A(i.props?.children))}`);let d=Y(i.props?.children??null,n,l?._child??l?.props?.children,s,r);return _n(d)?d.then(u=>(i._child=u??null,i._lifecycle=Z(i._lifecycle,"BUILD_DONE",Q(i)),i)):(i._child=d??null,i._lifecycle=Z(i._lifecycle,"BUILD_DONE",Q(i)),i)}function Nt(e,n,t,o,r){let i=e;if(typeof i.type!="string"&&typeof i.type!="symbol")return i;let s=o??n.__registry??ye(),l=kn(t,i);x("build")&&k("build","trace","",`native <${String(i.type)}> kids=${G(A(i.props?.children))}`);let d=Y(i.props?.children??null,n,l?.props?.children,s,r);return _n(d)?d.then(u=>(i._child=u??null,i._lifecycle=Z(i._lifecycle,"BUILD_DONE",Q(i)),i)):(i._child=d??null,i._lifecycle=Z(i._lifecycle,"BUILD_DONE",Q(i)),i)}var Ho=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function Ee(e,n){return le(e,n)}function D(e,n,t,o=null,r=null,i=null){let s=n?.browser??t;if(!s)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return Ko[$(e)](e,n,s,o,r,i)}function Oo(e,n,t){return null}function Uo(e,n,t){return t.createTextNode(String(e))}function Pn(e,n,t,o,r){if(e==null||typeof e=="boolean")return Ee(t,e);let i=D(e,n,t,String(o),null,r);return i??Ee(t,null)}function $o(e,n,t,o=null,r=null,i=null){let s=e,l=t.createDocumentFragment();if(!l)return null;x("render")&&k("render","debug","",`array kids=${G(s)} fid=${i??"-"} key=${o??"-"}`);let d=t.createComment(B({type:"fragment-start",key:o,id:r,fid:i})),u=t.createComment(B({type:"fragment-end",key:o,id:r,fid:i}));d&&l.appendChild(d);for(let a=0;a<s.length;a++){let c=s[a],f=i!=null?`${i}-${a}`:String(a),p=Pn(c,n,t,a,f);p!=null&&l.appendChild(p)}return u&&l.appendChild(u),l}function Do(e,n,t){let o=e,r=o,i=t.bodyElement();if(!i)return null;let s=i.querySelector("#__wf_portal");s||(s=t.createElement("div"),s&&(s.id="__wf_portal",i.appendChild(s)));let l=t.createElement("div");if(l){l.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let d=D(o.props?.children??null,n,t);d!=null&&l.appendChild(d),s&&s.appendChild(l),r._remoteEl=l;let u=A(o.props?.children);for(let a of u)a!=null&&typeof a=="object"&&!Array.isArray(a)&&(a._parentVNode=o)}return null}function jo(e,n,t,o=null,r=null,i=null){let s=e,l=s,d=t.createDocumentFragment();if(!d)return null;let u=A(s.props?.children);x("render")&&k("render","debug","",`fragment kids=${G(u)} fid=${i??"-"}`);let a=t.createComment(B({type:"fragment-start",key:o,id:r,fid:i})),c=t.createComment(B({type:"fragment-end",key:o,id:r,fid:i}));a&&d.appendChild(a),l._refNode=a;for(let f=0;f<u.length;f++){let p=u[f],m=i!=null?`${i}-${f}`:String(f),g=Pn(p,n,t,f,m);g!=null&&d.appendChild(g)}return c&&d.appendChild(c),d}function Wo(e,n,t){let o=e,r=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return Fo[r](o,n,t)}var Fo={fresh:(e,n,t)=>{throw new Error(`[vdom2] component ${I(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,n,t)=>{throw new Error(`[vdom2] component ${I(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,n,t)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${I(e.type)} \u5728\u6E32\u67D3\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`),Ee(t,null)),built:wt,pruned:wt};function wt(e,n,t){let o=e._child;if(o==null)return e._child=null,null;e._child=o,e._outputChild=o,typeof o=="object"&&!Array.isArray(o)&&(o._parentVNode=e);let r=D(o,n,t);if(r){if(e._refNode=r.nodeType===11?r.firstChild:r,e._id)if(r.nodeType===11)for(let i of Array.from(r.childNodes))i.nodeType===1&&i.setAttribute("data-wf-id",e._id);else r.nodeType===1&&r.setAttribute("data-wf-id",e._id);if(e.key!=null)if(r.nodeType===11)for(let i of Array.from(r.childNodes))i.nodeType===1&&i.setAttribute("data-wf-key",e.key);else r.nodeType===1&&r.setAttribute("data-wf-key",e.key)}return r}function Bo(e,n,t,o,r){let i=e,s=i,l=i.type,d=Ho.has(l)?t.createElementNS("http://www.w3.org/2000/svg",l):t.createElement(l);if(!d)return null;s.el=d,s._refNode=d,x("render")&&k("render","trace","",`native <${l}> key=${i.key??"-"} kids=${G(A(i.props?.children))}`),i.key!=null&&d.setAttribute("data-wf-key",i.key);let u=null;for(let[a,c]of Object.entries(i.props??{}))if(!(a==="children"||a==="key")){if(a==="value"&&d instanceof HTMLSelectElement){u=c;continue}oe(d,a,c)}if(!("innerHTML"in(i.props??{}))){let a=A(i.props?.children);for(let c=0;c<a.length;c++){let f=a[c],p=r!=null?`${r}-${c}`:String(c),m=Pn(f,n,t,c,p);if(m!=null&&(d.appendChild(m),f&&typeof f=="object"&&!Array.isArray(f)&&typeof f.type=="function")){let g=f;g._parentNode||(g._parentNode=d)}}x("render")&&k("render","trace","",`native <${l}> out=${se(d)}`)}return u!==null&&(d.value=String(u)),d}var Ko={hole:Oo,text:Uo,arr:$o,portal:Do,frag:jo,comp:Wo,native:Bo};function de(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=D(e.newInput,r,r.browser??V());if(i==null)return null;if(t?.parentNode){let s=Ae(o,t,n,r);return s&&s.parentNode===n?n.insertBefore(i,s):n.appendChild(i),i}return n.appendChild(i),i}function qo(e){return Ae(e.oldInput,e.oldNode,e.parent,e.ctx),null}function Go(e){let n=e.oldNode;if(n?.nodeType===8){let t=Ee(e.ctx.browser??V(),e.newInput);return t&&n.nodeValue!==t.nodeValue&&(n.nodeValue=t.nodeValue),n}return null}function Te(e){let{parent:n,oldNode:t,ctx:o}=e,r=D(e.newInput,o,o.browser??V());return r==null?null:(t?.parentNode?t.parentNode.replaceChild(r,t):t?n.insertBefore(r,t):n.appendChild(r),r)}function zo(e){let{parent:n,oldNode:t,oldInput:o}=e,r=String(e.newInput);if(String(o)!==r){if(t&&t.nodeType===3)return t.nodeValue=r,t;let i=n.ownerDocument.createTextNode(r);return t?.parentNode?t.parentNode.replaceChild(i,t):n.appendChild(i),i}return t}function Yo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=i.type;if(t&&t.nodeType===1&&(s?.type??null)===l&&qe(i)){let d=t;return i.el=d,i._refNode=d,Ct(d,s?.props??{},i.props??{}),"innerHTML"in(i.props??{})||Ie(d,s?._child??s?.props?.children??null,i._child??i.props?.children??null,r),d}return de(e)}function Xo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=ne(s)?L(s,t):null,d=Sn(n,s??o,i,r,l);return t?.parentNode?t:d[0]??null}function Jo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput;if(!P(i)||typeof i._render!="function")throw new Error(`[vdom2] component ${I(i.type)} not built in diff \u2014 buildVNode must run before patchValue`);let s=o&&typeof o=="object"&&!Array.isArray(o)?o:null;if(s?.type!=null&&s.type!==i.type)return de(e);let l=s?.type===i.type;if(!r.force&&s&&l&&Ve(s)&&i._child===s._child)return t;s?.type===i.type&&s._id&&(i._id=s._id,r.registry.idRegistry.set(i._id,i)),i._parentNode=n,t&&(i._refNode=t);let d=i._child;if(d===null){i._outputChild=null,i._refNode=null;let a=t?.parentNode!=null,c=Ae(s?._child??null,t,n,r);s&&(s._child=null);let f=Ee(r.browser??V(),null);return a&&f?(c&&c.parentNode===n?n.insertBefore(f,c):n.appendChild(f),f):ee(n,t,s?._child,null,r)}i._outputChild=d;let u=ee(n,t,s?._child,d,r);return u&&(i._refNode=u),u}function Qo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e;if(o===e.newInput&&t?.parentNode)return t;let i=n.ownerDocument.createDocumentFragment(),s=Ie(n,o,e.newInput,r,t?[t]:null);for(let l of s)l&&i.appendChild(l);return t?.parentNode?i.contains(t)?n.appendChild(i):t.parentNode.replaceChild(i,t):n.appendChild(i),i}function Zo(e){let{ctx:n,oldInput:t}=e,o=e.newInput,r=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(q(r)&&q(o)){let i=r._remoteEl;if(i){let s=r._child??r.props?.children??null,l=o._child??o.props?.children??null;Ie(i,s,l,n)}return o._remoteEl=r._remoteEl,null}return de(e)}function ve(e){return{text:de,native:de,frag:de,comp:de,arr:de,hole:qo,portal:de,...e}}var er={text:ve({text:zo}),hole:ve({text:Te,native:Te,frag:Te,comp:Te,arr:Te,portal:Te,hole:Go}),native:ve({native:Yo}),frag:ve({frag:Xo}),comp:ve({comp:Jo}),arr:ve({arr:Qo}),portal:ve({portal:Zo})};function bt(e){let n=$(e.oldInput),t=$(e.newInput);return S({session:"",machine:"x2y",nodeId:null,component:null,from:n,event:"X2Y",to:t,level:"trace",ts:Date.now()}),er[n][t](e)}function re(e,n){if(n&&typeof e.type=="function"&&e._id){try{U(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}pt(n,e._id)}}function Oe(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let n=e;return q(n)?typeof n.props?.portalKey=="string"?n.props.portalKey:null:n.key}function Rn(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)){let t=L(e,n);if(t&&t.length>1)return t}return[n]}function tn(e,n){let t=A(e.props?.children);for(let o of t){if(o==null||typeof o!="object"||Array.isArray(o))continue;let r=o;nr[$(r)](r,n)}}var nr={comp:(e,n)=>{re(e,n)},frag:(e,n)=>{tn(e,n)},native:(e,n)=>{tn(e,n)},portal:(e,n)=>{tn(e,n)},arr:()=>{},text:()=>{},hole:()=>{}};function Ae(e,n,t,o){return tr[$(e)](e,n,t,o)}var tr={arr:(e,n,t,o)=>{let r=L(e,n);if(r&&r.length){let i=(r[r.length-1]??n)?.nextSibling??null;for(let s of r)s.parentNode&&s.parentNode.removeChild(s);return i&&i.parentNode===t?i:null}return Le(e,n,t,o)},frag:(e,n,t,o)=>{let r=e,s=L(r,n)??[],l=(s[s.length-1]??n)?.nextSibling??null;for(let d of s)d.parentNode&&d.parentNode.removeChild(d);return tn(r,o.registry),l&&l.parentNode===t?l:null},portal:(e,n,t,o)=>{let r=e,i=r._remoteEl;try{U(r.props?.children,o.registry)}catch(s){console.error("[weifuwu] portal ref cleanup error",s)}return i?.parentNode?.removeChild(i),null},comp:(e,n,t,o)=>{let r=e,i=L(r,n);if(re(r,o.registry),i&&i.length>1){let s=(i[i.length-1]??n)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return s&&s.parentNode===t?s:null}return Le(e,n,t,o)},native:(e,n,t,o)=>{try{U(e,o.registry)}catch(r){console.error("[weifuwu] ref cleanup error",r)}return Le(e,n,t,o)},text:(e,n,t,o)=>Le(e,n,t,o),hole:(e,n,t,o)=>Le(e,n,t,o)};function Le(e,n,t,o){let r=n?.nextSibling??null;return n?.parentNode&&n.parentNode.removeChild(n),r&&r.parentNode===t?r:null}function ee(e,n,t,o,r){return bt({parent:e,oldNode:n,oldInput:t,newInput:o,ctx:r})}var or={event:(e,n,t,o)=>{let{type:r,capture:i}=xn(n);typeof t=="function"&&e.removeEventListener(r,t,i?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(r,o,i?{capture:!0}:{}))},class:(e,n,t,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",oe(e,n,o))},ref:(e,n,t,o)=>{if(o==null||o===!1){if(typeof t=="function")try{t(null)}catch(r){console.error("[weifuwu] ref cleanup error",r)}}else oe(e,n,o)},value:(e,n,t,o)=>{o==null||o===!1?e.value="":oe(e,n,o)},indeterminate:(e,n,t,o)=>{o==null||o===!1?e.indeterminate=!1:oe(e,n,o)},enumerated:Me,style:Me,innerHTML:Me,aria:Me,default:Me};function Me(e,n,t,o){if(o==null||o===!1){e.removeAttribute(n);try{delete e[n]}catch{}}else oe(e,n,o)}function Ct(e,n,t){let o=Object.keys(n),r=Object.keys(t);if(o.length===r.length){let s=!0;for(let l=0;l<o.length;l++)if(o[l]!==r[l]||n[o[l]]!==t[o[l]]){s=!1;break}if(s)return}let i=new Set([...o,...r]);for(let s of i){if(s==="children"||s==="key")continue;let l=n[s],d=t[s];l!==d&&or[Tn(s)](e,s,l,d)}}function Sn(e,n,t,o,r){let i=Array.isArray(n)?n:n?._child??n?.props?.children??null,s=Array.isArray(t)?t:t?._child??t?.props?.children??null;return Ie(e,i,s,o,r)}function Ie(e,n,t,o,r,i){let s=A(n),l=A(t),d=r??Array.from(e.childNodes);x("diff")&&k("diff","debug","",`patchChildren parent=${z(e)} old=${G(s)} new=${G(l)} dom=${se(e)}`);let u=l.some(p=>Array.isArray(p))||s.some(p=>Array.isArray(p)),a=u?"unkeyed":Vn(l);if(S({session:"",machine:"keys",nodeId:null,component:null,from:u?"unkeyed":Vn(l),event:"SELECT",to:a,payload:()=>({len:l.length}),level:"trace",ts:Date.now()}),ae()&&s.length!==l.length)for(let p=0;p<l.length;p++){let m=l[p];m!=null&&typeof m=="object"&&!Array.isArray(m)&&P(m)&&m.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${p} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\u2014\u2014\u5217\u8868\u589E\u5220/\u91CD\u6392\u4F1A\u9519\u4F4D\u7EC4\u4EF6\u5B9E\u4F8B\u72B6\u6001\u3002\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u8EAB\u4EFD key\uFF08\u5982 key={item.id}\uFF09\uFF1B\u65E0\u72B6\u6001 native \u9879\u8C41\u514D\u3002`)}let c=r&&r.length?r[r.length-1]:null;a==="mixed"&&(on(l),on(s));let f=(()=>{let p=d;p.length>=2&&p[0]?.nodeType===8&&p[0].nodeValue?.includes("fragment-start")&&p[p.length-1]?.nodeType===8&&p[p.length-1].nodeValue?.includes("fragment-end")&&(p=p.slice(1,-1));let m=[],g=0;for(let h=0;h<s.length;h++){let N=s[h];if(Array.isArray(N)){let v=p[g]??null;m.push(v);let b=L(N,v);g+=b?.length??1;continue}if(N==null||typeof N=="boolean"||typeof N=="string"||typeof N=="number"){m.push(p[g]??null),g++;continue}let y=N;if(q(y)){m.push(y._remoteEl??null);continue}if(m.push(y._refNode??p[g]??null),typeof y.type=="function"||ne(y)){let v=L(y,y._refNode??p[g]??null);g+=v?.length??1}else g++}return m})();return Vr[a]({parent:e,oldChildren:s,newChildren:l,oldNodes:f,ctx:o,arrEnd:c,anchorOut:i})}function He(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&ne(e)?"multi":"real"}function rr(e){let{parent:n,oldC:t,oldNode:o,oldNodes:r,i,ctx:s,out:l,pushA:d}=e;if(Array.isArray(t)){x("diff")&&k("diff","trace","",`remove-arr-item i=${i} range=[${(L(t,r[i])??[]).map(z).join(" | ")}] before=${se(n)}`);let u=L(t,o);for(let a of u??[])a.parentNode?.removeChild(a);x("diff")&&k("diff","trace","",`remove-arr-item after=${se(n)}`);for(let a of t)a!=null&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"&&re(a,s.registry)}else if(t&&typeof t=="object"&&!Array.isArray(t)){if(typeof t.type=="function")re(t,s.registry);else try{U(t,s.registry)}catch(u){console.error("[weifuwu] ref cleanup error",u)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);l.push(null),d(null)}function ir(e){let{parent:n,newC:t,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,u=le(d.browser??V(),t);if(o?.nodeType===8){u&&o.nodeValue!==u.nodeValue&&(o.nodeValue=u.nodeValue),s.push(o),l(o);return}if(u&&o?.parentNode)o.parentNode.replaceChild(u,o);else if(u){let a=null;for(let c=r+1;c<i.length;c++){let f=i[c];if(f&&f.parentNode===n){a=f;break}}if(!a){let c=null;for(let f=s.length-1;f>=0;f--)if(s[f]){c=s[f];break}c&&c.parentNode===n&&(a=c.nextSibling)}a&&a.parentNode===n?n.insertBefore(u,a):n.appendChild(u),s.push(u),l(u)}else s.push(u),l(u)}function Vt(e){let{parent:n,newC:t,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,u=D(t,d,d.browser??V(),String(r));if(u==null){s.push(null),l(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){S({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"HOLE_FILL",to:"real",payload:()=>({i:r,replaced:z(o)}),level:"trace",ts:Date.now()}),o.parentNode?.replaceChild(u,o),s.push(u),l(u);return}let a=null;for(let c=r+1;c<i.length;c++){let f=i[c];if(f&&f.parentNode===n){a=f;break}}if(a==null){let c=null;for(let f=s.length-1;f>=0;f--)if(s[f]){c=s[f];break}if(c&&c.parentNode===n)a=c.nextSibling;else{let f=i[i.length-1];f&&f.parentNode===n&&(a=f.nextSibling)}}a&&a.parentNode===n?n.insertBefore(u,a):n.appendChild(u),S({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"INSERT",to:"real",payload:()=>({i:r,insertedBefore:a?z(a):"END",node:z(u)}),level:"trace",ts:Date.now()}),s.push(u),l(u)}function sr(e){let{parent:n,oldC:t,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e;if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.type=="function"){let u=Tt(n,t,r,o,l);i.push(u),s(u);return}let d=_t(n,t,r,o,l);i.push(d),s(d)}function lr(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,out:s,pushA:l,ctx:d}=e,u=d.browser??V(),a=D(o,d,u,String(i));if(a==null){s.push(null),l(null);return}let c=t&&typeof t=="object"?L(t,r):null;if(c&&c.length>1){let p=(c[c.length-1]??r)?.nextSibling??null;for(let m of c)m.parentNode&&m.parentNode.removeChild(m);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")re(t,d.registry);else try{U(t,d.registry)}catch(m){console.error("[weifuwu] ref cleanup error",m)}p&&p.parentNode===n?n.insertBefore(a,p):n.appendChild(a)}else r?.parentNode?r.parentNode.replaceChild(a,r):n.appendChild(a);let f=a.nodeType===11?Array.from(a.childNodes):[a];s.push(...f),l(f[0]??a)}function ar(e){let{parent:n,oldC:t,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e,d=Et(n,t,r,o,l);i.push(d),s(d)}function dr(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,oldNodes:s,out:l,pushA:d,ctx:u}=e,a=u.browser??V(),c=L(t,r);x("diff")&&k("diff","debug","",`multi-remove i=${i} range=${c?c.map(z).join(" | "):"null"}`);for(let m of c??[])m.parentNode?.removeChild(m);for(let m of A(t?.props?.children))m!=null&&typeof m=="object"&&!Array.isArray(m)&&typeof m.type=="function"&&re(m,u.registry);let f=D(o,u,a,String(i));if(f==null){l.push(null),d(null);return}let p=s[i+1]??null;p?.parentNode?p.parentNode.insertBefore(f,p):n.appendChild(f),l.push(f),d(f)}function ur(e){let{parent:n,oldC:t,newC:o,oldNode:r,oldNodes:i,i:s,out:l,pushA:d,ctx:u}=e,a=L(t,r),c=Sn(n,t,o,u,a);l.push(...c),d(i[s]??c[0]??null)}function cr(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,out:s,pushA:l,ctx:d}=e;if(o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.type=="function"&&o._lifecycle==="disposed"){let c=Pt(n,r,d,I(o.type));s.push(c),l(c);return}let u=ee(n,r,t,o,d);x("diff")&&k("diff","trace","",`after-patch i=${i} new=${he(o)} node=${z(u)} dom=${se(n)}`);let a=Rn(o,u);s.push(...a),l(a[0]??u??null)}function Et(e,n,t,o,r){let i=le(r.browser??V(),o),s=L(n,t),l=((s??[])[s?.length?s.length-1:0]??t)?.nextSibling??null;for(let d of s??[])d.parentNode?.removeChild(d);for(let d of A(n?.props?.children))d!=null&&typeof d=="object"&&!Array.isArray(d)&&typeof d.type=="function"&&re(d,r.registry);return i&&l&&l.parentNode===e?e.insertBefore(i,l):i&&e.appendChild(i),i}function Tt(e,n,t,o,r){let i=le(r.browser??V(),o),s=Ae(n,t,e,r);return i&&s?e.insertBefore(i,s):i&&e.appendChild(i),i}function _t(e,n,t,o,r){let i=le(r.browser??V(),o);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")re(n,r.registry);else try{U(n,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}return i&&t?.parentNode?t.parentNode.replaceChild(i,t):i&&e.appendChild(i),i}var fr={hole:{hole:ir,real:Vt,multi:Vt},real:{hole:sr,real:cr,multi:lr},multi:{hole:ar,real:dr,multi:ur}};function pr(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,anchorOut:s}=e,l=Math.max(t.length,o.length),d=[],u=a=>{s&&s.push(a)};for(let a=0;a<l;a++){let c=a<t.length?t[a]:null,f=a<o.length?o[a]:null;if(a>=o.length){rr({parent:n,oldC:c,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:u,ctx:i});continue}if(c!=null&&typeof c=="object"&&!Array.isArray(c)&&f!=null&&typeof f=="object"&&!Array.isArray(f)&&f===c&&Ve(c)){d.push(r[a]),u(r[a]);continue}let p=fr[He(c)][He(f)];S({session:"",machine:"pos",nodeId:null,component:null,from:He(c),event:p.name,to:He(f),payload:()=>({i:a}),level:"trace",ts:Date.now()}),p({parent:n,oldC:c,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:u,ctx:i})}return d}function xt(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,anchorOut:s,arrEnd:l}=e,d=new Map;t.forEach((p,m)=>{let g=Oe(p);g!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&d.set(g,{vnode:p,nodes:[r[m]??null].filter(Boolean),index:m})});let u=[],a=new Set,c=p=>{s&&s.push(p)},f=null;return o.forEach((p,m)=>{let g=Oe(p),h=p;if(g!==null&&d.has(g)){let N=d.get(g),y=N.nodes[0]??null;if(a.add(g),h&&typeof h=="object"&&typeof h.type=="function"&&h._lifecycle==="disposed"){let C=Pt(n,y,i,I(h.type));u.push(C),c(C),C&&(f=C);return}let v=ee(n,y,N.vnode,h,i),b=Rn(h,v),H=b[0]??v,W=b[b.length-1]??v;if(H&&H.parentNode===n&&f&&H.previousSibling!==f){x("diff")&&k("diff","debug","",`keyed-correct i=${m} k=${g} move=[${b.map(z).join(" | ")}] after=${z(f)} before=${se(n)}`);let C=f.nextSibling;for(let E of b)E&&E.parentNode===n&&n.insertBefore(E,C);x("diff")&&k("diff","debug","",`keyed-correct after=${se(n)}`)}u.push(...b),c(b[0]??v??null),W&&(f=W)}else{let N={current:f};Nr[vr(p)]({parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,out:u,pushA:c,arrEnd:l,c:p,i:m},N),f=N.current}}),t.forEach((p,m)=>{yr[mr(Oe(p),a)](n,p,m,r,i,o.length)}),u}function mr(e,n){return e===null?"unkeyed":n.has(e)?"moved":"stale-keyed"}var yr={moved:()=>{},"stale-keyed":gr,unkeyed:hr};function gr(e,n,t,o,r){let i=n&&typeof n=="object"&&!Array.isArray(n)?L(n,o[t]):null;if(x("diff")&&k("diff","trace","",`keyed-delete i=${t} k=${Oe(n)} range=${i?.length??0} oldNode=${z(o[t])}`),n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")re(n,r.registry);else try{U(n,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}kt(i,o[t])}function hr(e,n,t,o,r,i){let s=o[t];if(s?.nodeType===8&&s.nodeValue?.includes("type=hole")&&t<i)return;if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")re(n,r.registry);else try{U(n,r.registry)}catch(u){console.error("[weifuwu] ref cleanup error",u)}let d=n&&typeof n=="object"&&!Array.isArray(n)?L(n,s):null;kt(d,s)}function kt(e,n){if(e&&e.length>1)for(let t of e)t.parentNode&&t.parentNode.removeChild(t);else n?.parentNode&&n.parentNode.removeChild(n)}function vr(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&q(e)?"portal":"real"}var Nr={hole:wr,portal:br,real:Cr};function wr(e,n){let{parent:t,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:u}=e,a=o[u]??null,c=r[u]??null,f=He(a);if(f==="hole"){let m=le(i.browser??V(),d);c?.nodeType===8?(m&&c.nodeValue!==m.nodeValue&&(c.nodeValue=m.nodeValue),s.push(c),l(c),c&&(n.current=c)):(m&&c?.parentNode?c.parentNode.replaceChild(m,c):m&&t.appendChild(m),s.push(m),l(m),m&&(n.current=m));return}let p=f==="multi"?Et(t,a,c,d,i):a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"?Tt(t,a,c,d,i):_t(t,a,c,d,i);s.push(p),l(p),p&&(n.current=p)}function br(e,n){let{parent:t,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:u}=e,a=d,c=o[u]??null,f=ee(t,r[u]??null,c,a,i),p=Rn(a,f);s.push(...p),l(p[0]??f??null);let m=p[p.length-1]??f;m&&(n.current=m)}function Cr(e,n){let{parent:t,oldNodes:o,ctx:r,out:i,pushA:s,arrEnd:l,c:d,i:u}=e,c=D(d,r,r.browser??V());if(i.push(c),s(c??null),c!=null){let f=o[u];f&&f.nodeType===8&&f.nodeValue?.includes("type=hole")?(f.parentNode?.replaceChild(c,f),n.current=c):(n.current?t.insertBefore(c,n.current.nextSibling):l&&l.parentNode===t?t.insertBefore(c,l):t.insertBefore(c,t.firstChild),n.current=c)}}function on(e){for(let n=0;n<e.length;n++){let t=e[n];t&&typeof t=="object"&&!Array.isArray(t)&&Oe(t)===null&&(t.key=`pos:${n}`)}}function Pt(e,n,t,o){ae()?console.error(`[vdom2/audit] I1 \u8FDD\u53CD\uFF1Adiff \u6536\u5230 disposed \u7EC4\u4EF6 ${o}\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\uFF08portal \u5185\u5BB9\u72EC\u7ACB dispose\uFF09\u2014\u2014\u7236\u6811\u5C06\u91CD\u5EFA`):console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${o} \u5728 diff\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`);let r=le(t.browser??V(),null);if(r==null)return null;let i=n;if(i){let s=i.parentNode;s?s.replaceChild(r,i):e.appendChild(r)}else e.appendChild(r);return r}var Vr={unkeyed:pr,keyed:xt,mixed:e=>(on(e.newChildren),on(e.oldChildren),xt(e))};function rn(e){let{registry:n,ctx:t}=e,o=new Map;async function r(s){let l=n.idRegistry.get(s);if(!l||!P(l)||typeof l._render!="function")return;let d=l,u=Xe("render");try{let a=await d._render(d.props),c=await Y(a,t,d._child,n)??null,f=d._child;if(d._child=c,d._lifecycle==="building"){S({session:u,machine:"render",nodeId:d._id??null,component:St(d),from:"IDLE",event:"PARENT",to:"SKIP_BUILDING",payload:()=>({lifecycle:d._lifecycle}),level:"debug",ts:Date.now()});return}let p=d._id!=null&&d._id===t.ui?._rootVNodeId,m=d._parentNode??d._refNode?.parentNode??null;m==null&&p&&(m=e.rootEl??null);let g=m?p&&!d._parentNode?"ROOT":"MOUNTED":"SKIP_DETACHED";if(S({session:u,machine:"render",nodeId:d._id??null,component:St(d),from:"IDLE",event:"PARENT",to:g,payload:()=>({lifecycle:d._lifecycle}),level:"debug",ts:Date.now()}),m){let h={browser:t.browser??V(),registry:n,ctxVersion:Qe(t)},N=ee(m,d._refNode??null,f,c,h);if(d._refNode=N,ae())try{let y=[];xe(m,c,v=>y.push(v)),y.length&&console.error("[vdom2/audit] "+y.join(" | "))}catch(y){console.error("[vdom2/audit] \u6821\u9A8C\u5F02\u5E38:",y)}}}catch(a){e.onError?e.onError(a):console.error("[vdom2] render error:",a?.stack??a)}finally{Re()}}function i(s){return s==null?Promise.resolve():Promise.all(s.map(l=>{let u=(o.get(l)??Promise.resolve()).then(()=>r(l));return o.set(l,u),u.finally(()=>{o.get(l)===u&&o.delete(l)})})).then(()=>{})}return{render:i}}function St(e){return typeof e.type=="function"&&e.type.name?e.type.name:"anonymous"}function Rt(e){let{ctx:n,browser:t}=e,o=e.registry??ye(),r=e.renderer??rn({registry:o,ctx:n,rootEl:e.root,onError:e.onError}),i=n.ui,s=null,l=null,d={ctx:n,registry:o,renderer:r,async mount(u){s=u;let a=await Y(u,n,null,o);e.root.innerHTML="";let c=D(a,n,t);if(c!=null&&e.root.appendChild(c),l=a?._child??a,i&&(i._rootVNodeId=a?._id??null),ae())try{let f=[];xe(e.root,a,p=>f.push(p)),f.length&&console.error("[vdom2/audit] "+f.join(" | "))}catch(f){console.error("[vdom2/audit] \u6821\u9A8C\u5F02\u5E38:",f)}},async rerender(){if(s==null)return;let u=[];for(let[,a]of o.idRegistry)P(a)&&typeof a._render=="function"&&a._id&&u.push(a._id);await r.render(u)},unmount(){for(let[,u]of o.idRegistry)try{U(u,o)}catch{}e.root.innerHTML=""}};return d.close=()=>d.unmount(),d}var At=V();function It(e,n="bottom",t=6,o=!0){switch(n){case"bottom":return{top:e.bottom+t,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-t,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-t};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+t}}}function sn(e,n,t=8){if(!n)return e;let o=n.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let r=Number.parseFloat(n.style.top)||o.top,i=Number.parseFloat(n.style.left)||o.left,s=e.top-r,l=e.left-i,d={top:o.top+s,bottom:o.bottom+s,left:o.left+l,right:o.right+l},u=At.viewportWidth(),a=At.viewportHeight(),c=e.top,f=e.left;return d.bottom>a-t&&(c=Math.max(t,c-(d.bottom-(a-t)))),d.top<t&&(c=Math.max(t,c+(t-d.top))),d.right>u-t&&(f=Math.max(t,f-(d.right-(u-t)))),d.left<t&&(f=Math.max(t,f+(t-d.left))),{top:c,left:f,width:e.width}}var _e=V();function Lt(e){let n=new Map,t=new Map,o=!1,r=0;function i(){r||(r=requestAnimationFrame(()=>{r=0;let a=[];for(let[c,f]of n){if(!f.isOpen())continue;let p=f.getEl();if(!p)continue;let m=p.getBoundingClientRect();if(m.width===0&&m.height===0)continue;let g=f.compute(m);Object.assign(f.pos,sn(g,f.panel?.(),f.margin)),a.push(c)}for(let[c,f]of t){let p=f.getScroller(),m=p instanceof Window?_e.scrollingElement()?.scrollTop??_e.scrollTop():p.scrollTop??0;m!==f.handle.y&&(f.handle.y=m,a.push(c))}a.length>0&&e(a)}))}function s(){o||(o=!0,_e.addEventListener("scroll",i,{capture:!0,passive:!0}),_e.addEventListener("resize",i))}function l(){o&&(_e.removeEventListener("scroll",i,{capture:!0}),_e.removeEventListener("resize",i),o=!1)}function d(a){for(let c of[...n.keys()])(c.startsWith(`popup:${a}:`)||c===`popup:${a}`||c===a)&&n.delete(c);t.delete(a)}function u(){l(),r&&(cancelAnimationFrame(r),r=0),n.clear(),t.clear()}return{popupTrackers:n,scrollTrackers:t,schedulePopupRecompute:i,ensurePopupListeners:s,destroyPopupListeners:l,cleanupTrackers:d,destroy:u}}function An(e,n,t){return r=>{r?n(r):t?.()}}function Ue(e){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches}function ln(e){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function In(e,n,t){let o=null,r=()=>{n(),t?.once&&o&&o.removeEventListener("animationend",r)};return s=>{s?(o=s,s.addEventListener("animationend",r)):o&&(o.removeEventListener("animationend",r),o=null)}}function Ln(e,n){let{onLongPress:t,duration:o=500}=n,r,i=0,s=0,l=null,d=()=>{clearTimeout(r),r=void 0},u=e.selfId();if(u){let a=e.onUnmount(c=>{c===u&&(d(),a())})}return{onPointerDown:a=>{i=a.clientX??0,s=a.clientY??0,l=a,d(),r=setTimeout(()=>{r=void 0,l&&t(l)},o)},onPointerUp:d,onPointerLeave:d,onPointerMove:a=>{let c=Math.abs((a.clientX??0)-i),f=Math.abs((a.clientY??0)-s);(c>10||f>10)&&d()},onContextMenu:a=>{a.preventDefault(),t(a)}}}function $e(e,n){let t=e.selfId(),o="closed",r,i=()=>{o="closed",t?e.render([t]):e.render()};return{get phase(){return o},ref:l=>{l?r||(r=()=>{o==="exit"&&i()},l.addEventListener("animationend",r)):r=void 0},sync:l=>(l?o="open":o==="open"&&(o="exit"),o)}}function Mn(e,n,t){let o=e.selfId(),r=ln(e),i=t?.duration??400,s=t?.ease==="linear"?f=>f:f=>1-Math.pow(1-f,3),l,d=n,u={value:r?n:0,reset:()=>{}},a=()=>{o?e.render([o]):e.render()},c=f=>{if(d=f,r){u.value=f,a();return}if(f===u.value)return;l&&cancelAnimationFrame(l);let p=u.value,m=performance.now(),g=h=>{let N=Math.min(1,(h-m)/i);u.value=Math.round(p+(f-p)*s(N)),N<1?(l=requestAnimationFrame(g),a()):(l=void 0,a())};l=requestAnimationFrame(g)};if(u.reset=f=>{f===d&&l||c(f)},o){let f=e.onUnmount(p=>{p===o&&(l&&(cancelAnimationFrame(l),l=void 0),f())})}return queueMicrotask(()=>c(n)),u}function Hn(e,n,t){let o=e.selfId(),r=e.browser,i=`media:${o}:${n}`;if(!e.mediaRegistry.has(i)){let s=r.matchMedia(n);t(s.matches);let l=u=>t(u.matches);s.addEventListener("change",l),e.mediaRegistry.set(i,{mql:s,handler:l});let d=e.onUnmount(u=>{if(u!==o)return;let a=e.mediaRegistry.get(i);if(a?.mql&&a.handler)try{a.mql.removeEventListener("change",a.handler)}catch{}e.mediaRegistry.delete(i),d()})}}function On(e,n,t){let o=e.browser,r=typeof n=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:n,i=typeof n=="function"?n:t,s=e.selfId(),l=`bp:${s}`;function d(){for(let[u,a]of Object.entries(r))if(o.matchMedia(a).matches)return u;return Object.keys(r)[0]??""}if(!e.mediaRegistry.has(l)){i(d());let u=[];for(let c of Object.values(r)){let f=o.matchMedia(c),p=()=>i(d());f.addEventListener("change",p),u.push({mql:f,handler:p})}e.mediaRegistry.set(l,{mqls:u});let a=e.onUnmount(c=>{if(c!==s)return;let f=e.mediaRegistry.get(l);if(f?.mqls)for(let p of f.mqls)try{p.mql.removeEventListener("change",p.handler)}catch{}e.mediaRegistry.delete(l),a()})}}function Un(e){let n=e.selfId(),t=e.browser,o={height:t.viewportHeight(),offsetTop:0,keyboardOpen:!1},r=()=>{n?e.render([n]):e.render()},i=()=>{let l=t.visualViewport();o.height=l?.height??t.viewportHeight(),o.offsetTop=l?.offsetTop??0,o.keyboardOpen=o.height<t.viewportHeight()*.9,r()},s=t.visualViewport();if(s?.addEventListener?(s.addEventListener("resize",i),s.addEventListener("scroll",i)):t.addEventListener("resize",i),n){let l=e.onUnmount(d=>{d===n&&(s?.removeEventListener?(s.removeEventListener("resize",i),s.removeEventListener("scroll",i)):t.removeEventListener("resize",i),l())})}return o}function $n(e,n){let t=e.selfId(),o={isIn:!1,ready:!1,observe:d,refresh:u,disconnect:a},r=null,i=null,s=()=>{t?e.render([t]):e.render()};function l(){if(i?.disconnect(),i=null,!r)return;let c=typeof n.rootMargin=="function"?n.rootMargin():n.rootMargin,f=typeof n.threshold=="function"?n.threshold():n.threshold;i=new IntersectionObserver(p=>{let m=p[p.length-1];if(!m)return;let g=m.isIntersecting,h=g!==o.isIn,N=!o.ready;o.isIn=g,o.ready=!0,n.onChange?.(m,g),(h||N)&&s()},{root:n.root?n.root():null,rootMargin:c??"0px",threshold:f??0}),i.observe(r)}function d(c){r=c,c?l():(i?.disconnect(),i=null,o.isIn=!1)}function u(){l()}function a(){i?.disconnect(),i=null}if(t){let c=e.onUnmount(f=>{f===t&&(a(),c())})}return o}function Dn(e,n){let t=e.selfId(),o=e.browser,r={y:0,refresh(){let l=i.getScroller();r.y=l instanceof Window?o.scrollingElement()?.scrollTop??o.scrollTop():l.scrollTop??0}},i={handle:r,getScroller:n.getScroller??(()=>window)};if(!t)return r.refresh(),r;e.scrollTrackers.set(t,i),e.ensurePopupListeners(),r.refresh();let s=e.onUnmount(l=>{l===t&&(e.scrollTrackers.delete(t),s())});return r}function an(e,n){let t=e.selfId(),o=n.value!==void 0;if(o&&!n.onChange&&n.name&&(e.warned.has(n.name)||(e.warned.add(n.name),console.warn(`[weifuwu/${n.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
4
|
+
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!o&&t&&!e.uncontrolledValues.has(t)){e.uncontrolledValues.set(t,n.value);let i=e.onUnmount(s=>{s===t&&(e.uncontrolledValues.delete(t),i())})}let r=i=>{if(o){n.onChange?.(i);return}t&&e.uncontrolledValues.set(t,i),t?e.render([t]):e.render()};return{value:o?n.value:t?e.uncontrolledValues.get(t):n.value,setValue:r,controlled:o}}function jn(e,n){let t=e.selfId(),o=an(e,{value:n.value,onChange:n.onChange,name:n.name});if(t&&!e.inputStates.has(t)){e.inputStates.set(t,{keyword:"",selectedLabel:""});let s=e.onUnmount(l=>{l===t&&(e.inputStates.delete(t),s())})}let r=t?e.inputStates.get(t):{keyword:"",selectedLabel:""},i=()=>{t?e.render([t]):e.render()};return{...o,get keyword(){return r.keyword},setKeyword(s){r.keyword=s,i()},get selectedLabel(){return r.selectedLabel},setSelectedLabel(s){r.selectedLabel=s,i()}}}function Wn(e,n){let t=e.selfId(),o=!1;if(t){let d=e.onUnmount(u=>{u===t&&(o=!0,d())})}let r=()=>{o||(t?e.render([t]):e.render())},i={data:void 0,loading:!1,error:void 0},s=0,l=()=>{let d=++s;i.loading=!0,i.error=null,r(),Promise.resolve().then(()=>n()).then(u=>{s===d&&(i.data=u,i.loading=!1,r())}).catch(u=>{s===d&&(i.error=u,i.loading=!1,r())})};return l(),i.reload=l,i}function Fn(e,n){let t=e.selfId(),o=e.browser;if(typeof window>"u")return()=>{};if(o.addEventListener("keydown",n),t){let r=e.onUnmount(i=>{i===t&&(o.removeEventListener("keydown",n),r())})}return()=>o.removeEventListener("keydown",n)}function Bn(e,n){let t=e.browser,o=0,r=0,i=!1,s=a=>{i&&n.onMove(a,{x:a.clientX-o,y:a.clientY-r})},l=a=>{i&&(i=!1,t.removeEventListener("pointermove",s),t.removeEventListener("pointerup",l),n.onEnd?.(a))},d=a=>{i||(a.preventDefault(),i=!0,o=a.clientX,r=a.clientY,t.addEventListener("pointermove",s),t.addEventListener("pointerup",l),n.onStart?.(a))},u=e.selfId();if(u){let a=e.onUnmount(c=>{c===u&&(i&&(t.removeEventListener("pointermove",s),t.removeEventListener("pointerup",l),i=!1),a())})}return{onPointerDown:d}}function Kn(e,n){let t={};n.onDrop&&(t.onDrop=r=>{r.preventDefault(),n.onDrop(r)}),n.onDragOver&&(t.onDragOver=r=>{r.preventDefault(),n.onDragOver(r)}),n.onDragLeave&&(t.onDragLeave=r=>n.onDragLeave(r));let o={draggable:!0};if(n.onDragStart){let r=n.onDragStart;o.onDragStart=i=>{typeof document<"u"&&document.body.classList.add("wf-dragging"),r(i)}}if(n.onDragEnd){let r=n.onDragEnd;o.onDragEnd=i=>{typeof document<"u"&&document.body.classList.remove("wf-dragging"),r(i)}}return{dropProps:t,dragProps:o}}function un(e,n){let t=e.selfId(),o={top:0,left:0,refresh:()=>{}};if(!t)return o;let r={pos:o,getEl:n.el,isOpen:n.isOpen,compute:n.compute,panel:n.panel,margin:n.margin??8};e.popupTrackers.set(t,r),e.ensurePopupListeners();let i=e.onUnmount(s=>{s===t&&(e.popupTrackers.delete(t),i())});return o.refresh=()=>{let s=r.getEl();if(!s)return;let l=s.getBoundingClientRect();if(l.width===0&&l.height===0)return;let d=r.compute(l);Object.assign(o,sn(d,r.panel?.(),r.margin))},o}function qn(e,n){let t=e.selfId(),o=e.browser,r=Ue(e),i=()=>typeof n.trigger=="function"?n.trigger():n.trigger??"manual",s=n.open!==void 0,l=()=>!!n.disabled?.(),d=()=>s?typeof n.open=="function"?!!n.open():!!n.open:n.isOpen(),u=n.presence?$e(e,{name:n.name}):null,a,c=!1,f=w=>{if(!u)return w?"open":"closed";let T=u.sync(w);return w&&n.lockScroll&&!c&&(xr(),c=!0),T},p=w=>{l()||(s?n.onOpenChange?.(w):u?w?f(!0):d()&&f(!1):n.setOpen(w))},m=()=>{let w=n.placement;return typeof w=="function"?w():w??"bottom"},g=null,h=!1,N=un(e,{el:n.el??(()=>null),isOpen:()=>d(),compute:w=>{if(n.position){let T=n.position();return{top:T.y,left:T.x,width:T.width}}return It(w,m(),n.gap??6,n.center!==!1)},panel:()=>g,margin:n.margin??8}),y=w=>{if(n.closeOnOutside===!1||n.mask||!d())return;let T=w.target;if(!(T instanceof Node))return;let X=n.el?.()??null;X&&X.contains(T)||g&&g.contains(T)||p(!1)},v=w=>{n.closeOnEscape!==!1&&(w.key!=="Escape"||!d()||p(!1))};if(o.addEventListener("mousedown",y),o.addEventListener("keydown",v),t){let w=e.onUnmount(T=>{T===t&&(o.removeEventListener("mousedown",y),o.removeEventListener("keydown",v),w())})}let b={},H=w=>typeof w=="function"?w():w??0,W=()=>H(n.openDelay),C=()=>H(n.closeDelay),E,_,ce=()=>{clearTimeout(E),clearTimeout(_),E=void 0,_=void 0},F=w=>{if(l())return;let T=w.currentTarget,X=w.relatedTarget;T.contains(X)||(clearTimeout(_),_=void 0,E=setTimeout(()=>{E=void 0,p(!0)},W()))},j=w=>{if(l())return;let T=w.currentTarget,X=w.relatedTarget;T.contains(X)||(clearTimeout(E),E=void 0,_=setTimeout(()=>{_=void 0,p(!1)},C()))},ie=()=>{l()||(clearTimeout(_),_=void 0,E=setTimeout(()=>{E=void 0,p(!0)},W()))},fe=()=>{l()||(clearTimeout(E),E=void 0,_=setTimeout(()=>{_=void 0,p(!1)},C()))},O=()=>i()==="hover";if(b.onMouseOver=w=>{O()&&F(w)},b.onMouseOut=w=>{O()&&j(w)},b.onClick=()=>{O()?r||p(!d()):i()==="click"&&p(!0)},b.onFocus=()=>{O()?ie():i()==="focus"&&(clearTimeout(_),_=void 0,p(!0))},b.onBlur=()=>{O()?fe():i()==="focus"&&(clearTimeout(E),E=void 0,_=setTimeout(()=>{_=void 0,p(!1)},C()))},i()==="longpress"){let w,T=0,X=0,me=()=>{clearTimeout(w),w=void 0};b.onPointerDown=M=>{l()||(T=M.clientX??0,X=M.clientY??0,me(),w=setTimeout(()=>{w=void 0,n.onTrigger?.({clientX:T,clientY:X}),p(!0)},n.longPressDuration??500))},b.onPointerUp=me,b.onPointerLeave=me,b.onPointerMove=M=>{let fn=Math.abs((M.clientX??0)-T),pn=Math.abs((M.clientY??0)-X);(fn>10||pn>10)&&me()},b.onContextMenu=M=>{M.preventDefault(),n.onTrigger?.({clientX:M.clientX??0,clientY:M.clientY??0}),p(!0)}}if(b.onKeyDown=w=>{w.key==="Escape"&&n.closeOnEscape!==!1&&p(!1)},t){let w=e.onUnmount(T=>{T===t&&(ce(),w())})}let R=w=>{if(w){g=w;let T=()=>N.refresh();w.addEventListener("animationend",T,{once:!0})}else g=null},pe=null,ke=null,Zn=w=>{R(w),ke&&ke(w),u?.ref(w),n.trapFocus&&(w?a=_r(w):(a?.(),a=void 0)),n.lockScroll&&!w&&c&&(Er(),c=!1)};return{get open(){return d()},setOpen:p,get phase(){return u?u.phase:d()?"open":"closed"},sync:f,wrapProps:b,portal:(w,T="popover")=>{if(l())return null;if(!(u?u.phase!=="closed":d()))return h=!1,pe=null,null;let me=n.el?.()??null;(!h||me!==pe)&&(me?N.refresh():queueMicrotask(()=>{d()&&N.refresh()}),h=!0,pe=me);let M=w.props??{};ke=M.ref??null;let fn=n.positioning==="none"?M.class??"":["wf-popup",M.class].filter(Boolean).join(" "),pn=n.positioning==="none"?{...M.style??{},position:"fixed"}:{...M.style??{},position:"fixed",top:`${N.top}px`,left:`${N.left}px`,...N.width!==void 0?{width:`${N.width}px`}:{},maxWidth:(()=>{let Be=typeof n.width=="function"?n.width():n.width;return Be!==void 0?`min(${Be}px, calc(100vw - 32px))`:"calc(100vw - 32px)"})()},we={...w,props:{...M,class:fn,style:pn,ref:Zn}};if(n.mask){let Be=typeof n.mask=="object"?n.mask:ge("div",{class:"wf-popup-mask","data-portal-mask":T,onClick:n.maskClosable===!1?void 0:()=>p(!1)}),Kt=n.maskCentered?ge("div",{class:"wf-cover",style:{"--wf-z":"var(--wf-z-popover)",pointerEvents:"none"}},{...we,props:{...we.props,style:{...M.style??{},pointerEvents:"auto"},ref:Zn}}):null,qt=n.maskCentered?void 0:{...we.props?.style??{},zIndex:"var(--wf-z-popover)"},Gt=n.maskCentered?Kt:{...we,props:{...we.props,style:qt}};return Ge([Be,Gt],T)}return Ge(we,T)},refresh:()=>N.refresh()}}function Gn(e,n){let t=e.selfId();if(t&&!e.openStates.has(t)){e.openStates.set(t,!1);let l=e.onUnmount(d=>{d===t&&(e.openStates.delete(t),l())})}let o=n.open!==void 0;o&&!n.onOpenChange&&n.name&&!e.warned.has(n.name)&&(e.warned.add(n.name),console.warn(`[weifuwu/${n.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08open \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onOpenChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
5
|
+
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 open\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onOpenChange={(o) => setOpen(o)}`));let r=()=>o?!!n.open:t?e.openStates.get(t)??!1:!1,i=()=>{t?e.render([t]):e.render()},s=l=>{if(o){n.onOpenChange?.(l);return}t&&e.openStates.set(t,l),i()};return{get open(){return r()},setOpen:s,triggerProps:{onClick:()=>s(!0),onFocus:()=>{n.openOnFocus&&s(!0)}}}}var Ne=V(),De=0,Mt="",Ht="",Ot="",Ut="",dn=0;function $t(){return typeof window<"u"&&typeof document<"u"}function xr(){if(De++,De>1||!$t())return;dn=Ne.scrollTop();let e=Ne.bodyElement();Mt=e.style.overflow,Ht=e.style.position,Ot=e.style.top,Ut=e.style.width,e.style.overflow="hidden",(/iPhone|iPad|iPod/.test(navigator.platform)||/Mac/.test(navigator.platform)&&"ontouchend"in document)&&(e.style.position="fixed",e.style.top=`-${dn}px`,e.style.width="100%")}function Er(){if(De===0||(De--,De>0)||!$t())return;let e=Ne.bodyElement();e.style.overflow=Mt,e.style.position=Ht,e.style.top=Ot,e.style.width=Ut,dn>0&&Ne.scrollTo(dn)}var Tr='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function _r(e){let n;return queueMicrotask(()=>{let t=e.querySelectorAll(Tr);if(t.length===0)return;let o=t[0],r=t[t.length-1],i=l=>{l.key==="Tab"&&(l.shiftKey&&Ne.activeElement()===o?(l.preventDefault(),r.focus()):!l.shiftKey&&Ne.activeElement()===r&&(l.preventDefault(),o.focus()))},s=Ne.activeElement();o.focus(),e.addEventListener("keydown",i),n=()=>{e.removeEventListener("keydown",i),s?.focus()}}),()=>n?.()}function kr(e){return e.map(n=>{let t={role:n.role,content:n.content};return n.reasoning&&(t.reasoning_content=n.reasoning),t})}function zn(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Dt(e,n,t,o){t.initialMessages?e.messages=structuredClone(t.initialMessages):e.messages===void 0&&(e.messages=[]),e.input===void 0&&(e.input=""),e.streaming===void 0&&(e.streaming=!1),e.error===void 0&&(e.error=null),e.usage===void 0&&(e.usage=null),e.step===void 0&&(e.step=null);let r=null;function i(){if(!e.streaming)return;let m=e.messages[e.messages.length-1];return m&&m.role==="assistant"&&m.status==="streaming"?m:void 0}function s(m,g,h){let N=i();switch(m){case"wf:token":N&&(N.content+=g.text);break;case"wf:tool_call":{N&&(N.toolCalls||(N.toolCalls=[]),N.toolCalls.push({call:g,status:"running"}));break}case"wf:tool_progress":{let y=g,v=N?.toolCalls?.find(b=>b.call.id===y.toolCallId);v&&(v.progress=y);break}case"wf:tool_result":{let y=g,v=N?.toolCalls?.find(b=>b.call.id===y.id);v&&(v.result=y,v.status=y.ok?"ok":"error");break}case"wf:approval_request":N&&(N.approval=g);break;case"wf:usage":N&&(N.usage=g);break;case"wf:step":e.step=g;break;case"wf:done":if(N){N.status="done",N.approval=void 0;let y=g;y.reasoning&&(N.reasoning=y.reasoning)}e.streaming=!1,e.step=null;break;case"wf:error":N&&(N.status="error",N.error=g,N.approval=void 0),e.error=g,e.streaming=!1,e.step=null;break;default:h?.(m,g);break}o?.()}function l(){let m=t.body?t.body(e.messages):{messages:kr(e.messages)};r=n(t.url,m,{onToken:h=>s("wf:token",{text:h}),onToolCall:h=>s("wf:tool_call",h),onToolProgress:h=>s("wf:tool_progress",h),onToolResult:h=>s("wf:tool_result",h),onApproval:h=>s("wf:approval_request",h),onUsage:h=>s("wf:usage",h),onStep:h=>s("wf:step",h),onDone:h=>s("wf:done",h),onError:h=>s("wf:error",h),onEvent:(h,N)=>s(h,N,t.onEvent)},{signal:t.signal,headers:t.headers}),e.streaming=!0;let g=i();g&&r?.traceId&&(g.id=r.traceId)}function d(){if(e.streaming)return;let m=String(e.input??"").trim();m&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:zn(),role:"user",content:m,status:"done"},{id:zn(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function u(){r?.abort(),e.streaming=!1,e.step=null;let m=e.messages[e.messages.length-1];m&&m.role==="assistant"&&m.status==="streaming"&&(!m.content&&(!m.toolCalls||m.toolCalls.length===0)?e.messages.pop():m.status="done"),o?.()}function a(){if(e.streaming)return;let m=-1;for(let g=e.messages.length-1;g>=0;g--)if(e.messages[g].role==="user"){m=g;break}m!==-1&&(e.messages.splice(m+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:zn(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function c(){r?.abort(),e.messages=[],e.input="",e.streaming=!1,e.error=null,e.usage=null,e.step=null,o?.()}async function f(m,g,h){let N=e.messages[e.messages.length-1],y=N?.role==="assistant"?N.approval:void 0;if(y&&(N.approval=void 0,o?.(),!!t.approveUrl))try{await fetch(t.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(h?{id:y.id,decision:m,note:g,modifiedArgs:h}:{id:y.id,decision:m,note:g}),signal:t.signal})}catch(v){if(t.signal?.aborted)return;e.error={code:"provider_error",message:v instanceof Error?v.message:String(v)},o?.()}}function p(){r?.abort(),r=null}return{send:d,stop:u,retry:a,clear:c,approve:f,dispose:p}}function jt(e,n,t){let o=new AbortController,r=t?.signal;r&&(r.aborted?o.abort():r.addEventListener("abort",()=>o.abort(),{once:!0}));let i=t?.traceId??Ir(),s=t?.record!==!1,l=[],d=(async()=>{let u;try{u=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":i,Accept:"text/event-stream",...t?.headers},body:JSON.stringify(n),signal:o.signal})}catch(a){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:a instanceof Error?a.message:String(a)});return}if(!u.ok){t?.onError?.({code:Ar(u.status),message:`HTTP ${u.status} ${u.statusText}`});return}try{for await(let{name:a,data:c}of Sr(u.body)){if(o.signal.aborted)return;Rr(l,{name:a,data:c},s),Pr(a,c,t??{})}}catch(a){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:a instanceof Error?a.message:String(a)})}})();return{abort:()=>o.abort(),done:d,traceId:i,events:l}}function Pr(e,n,t){switch(e){case"wf:token":return t.onToken?.(n.text);case"wf:tool_call":return t.onToolCall?.(n);case"wf:tool_result":return t.onToolResult?.(n);case"wf:tool_progress":return t.onToolProgress?.(n);case"wf:step":return t.onStep?.(n);case"wf:approval_request":return t.onApproval?.(n);case"wf:usage":return t.onUsage?.(n);case"wf:done":return t.onDone?.(n);case"wf:error":return t.onError?.(n);default:return t.onEvent?.(e,n)}}async function*Sr(e){let n=e.getReader(),t=new TextDecoder,o="";try{for(;;){let{done:r,value:i}=await n.read();if(r)break;o+=t.decode(i,{stream:!0});let s=o.split(`
|
|
6
6
|
|
|
7
7
|
`);o=s.pop()??"";for(let l of s){let d="message",u="";for(let a of l.split(`
|
|
8
|
-
`))a.startsWith("event: ")?d=a.slice(7):a.startsWith("data: ")&&(u+=a.slice(6));if(u)try{yield{name:d,data:JSON.parse(u)}}catch{}}}}finally{n.releaseLock()}}function
|
|
9
|
-
`).slice(2,5).map(
|
|
8
|
+
`))a.startsWith("event: ")?d=a.slice(7):a.startsWith("data: ")&&(u+=a.slice(6));if(u)try{yield{name:d,data:JSON.parse(u)}}catch{}}}}finally{n.releaseLock()}}function Rr(e,n,t){t&&(e.length>=1e3&&e.shift(),e.push(n))}function Ar(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Ir(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Yn(e,n){let t={messages:[],input:"",streaming:!1,error:null,usage:null,step:null},o=new Set,i=Dt(t,jt,n,()=>{for(let l of[...o])l()});Object.assign(t,i),t.subscribe=l=>(o.add(l),()=>{o.delete(l)});let s=e.selfId();if(s){let l=e.onUnmount(d=>{d===s&&(i.dispose(),l())})}return t}function Xn(e,n){let t=e.selfId(),o;return t&&(o=n.subscribe(()=>e.render([t])),e.onUnmount(()=>o?.())),n}function cn(e){let n=e.registry??ye(),t={_selfId:"_wf_root",_mounting:!1,_ctxVersion:0,_rootVNodeId:null},o={browser:e.browser,__registry:n};o.app={navigate:y=>e.browser.navigate(y)};let r=e.renderer??rn({registry:n,ctx:o,rootEl:e.root,onError:e.onError}),i=Lt(y=>{for(let v of y)r.render([v])}),s=new Map,{popupTrackers:l,scrollTrackers:d,ensurePopupListeners:u,destroyPopupListeners:a,cleanupTrackers:c}=i;Ze(n,y=>{c(y),l.has(y)&&l.delete(y)});let f=new Set,p=new Map,m=new Map,g=new Map,h=y=>({selfId:()=>{let v=y?._selfVNode?._id??y?._selfId;return typeof v=="string"?v:void 0},render:v=>r.render(v),browser:e.browser,onUnmount:v=>Ze(n,v),registry:n,mediaRegistry:s,popupTrackers:l,scrollTrackers:d,isMounting:()=>t._mounting===!0,warned:f,uncontrolledValues:p,inputStates:m,openStates:g,ensurePopupListeners:u}),N=!1;return t.render=function(y){if(y==null){let v=this._selfId!=="_wf_root"&&this._selfId?this._selfId:t._rootVNodeId;return v?r.render([v]):(N||(N=!0,console.warn("[weifuwu] render() \u65E0\u53C2\u4F46\u65E0\u6E32\u67D3\u76EE\u6807\uFF1A\u9875\u9762\u6839\u662F native vnode\uFF08UIHandler \u76F4\u63A5\u8FD4\u56DE vnode \u7684\u9875\u9762\u5F62\u6001\uFF09\u3002\u6539\u7528 async \u7EC4\u4EF6\u5F62\u6001\uFF08const Page: Component = async ... => (props) => ...\uFF09\u6216 createStore + useExternal \u5171\u4EAB\u72B6\u6001\u3002")),Promise.resolve())}return r.render(y)},t.setMounting=y=>{t._mounting=y},t.endMounting=()=>{t._mounting=!1},t.bumpCtxVersion=()=>{t._ctxVersion=(t._ctxVersion??0)+1},t.selfId=function(y){if(typeof y!="string"||!y)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof y}`);if(n.idRegistry.has(y))throw new Error(`[weifuwu] Duplicate component ID: "${y}". Each component must have a unique custom ID.`);let v=this._selfVNode;v&&(v._customId=y,n.idRegistry.set(y,v))},t.onUnmount=function(y){let v=this?._selfVNode?._id??this?._selfId;if(v)return Ze(n,b=>{b===v&&y()})},t.useChat=function(y){return Yn(h(this),y)},t.useMedia=function(y,v){return Hn(h(this),y,v)},t.useBreakpoint=function(y,v){return On(h(this),y,v)},t.usePopupPosition=function(y){return un(h(this),y)},t.useHoverCapable=function(){return Ue(h(this))},t.useStableRef=function(y,v){return An(h(this),y,v)},t.useVisualViewport=function(){return Un(h(this))},t.usePopup=function(y){return qn(h(this),y)},t.useLongPress=function(y){return Ln(h(this),y)},t.useInView=function(y){return $n(h(this),y)},t.useScrollPosition=function(y){return Dn(h(this),y)},t.useAsync=function(y){return Wn(h(this),y)},t.useControlled=function(y){return an(h(this),y)},t.useControlledInput=function(y){return jn(h(this),y)},t.useOpen=function(y){return Gn(h(this),y)},t.usePresence=function(y){return $e(h(this),y)},t.useGlobalKey=function(y){return Fn(h(this),y)},t.useDrag=function(y){return Bn(h(this),y)},t.useDragDrop=function(y){return Kn(h(this),y)},t.useExternal=function(y){return Xn(h(this),y)},t.useReducedMotion=function(){return ln(h(this))},t.useAnimationEnd=function(y,v){return In(h(this),y,v)},t.useTween=function(y,v){return Mn(h(this),y,v)},t.destroyPopupListeners=a,o.ui=t,{ctx:o,registry:n,renderer:r,rootUi:t,destroyPopupListeners:a}}function Lr(e){let{ctx:n,registry:t,renderer:o}=cn(e);return Rt({root:e.root,browser:e.browser,ctx:n,registry:t,renderer:o,onError:e.onError})}var Mr=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function je(e){e.node=e.node?e.node.nextSibling:null}function Hr(e,n){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(n,e.node):e.parent.appendChild(n)}function Or(e,n){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(n,e.node),je(e)):e.parent.appendChild(n)}function Ur(e,n){for(let[t,o]of Object.entries(n))t==="children"||t==="key"||t==="innerHTML"||oe(e,t,o)}function We(e,n,t){return $r[$(e)](e,n,t)}var $r={hole:()=>null,text:Dr,arr:jr,portal:Wt,frag:Wt,comp:Wr,native:Fr};function Dr(e,n,t){let o=n.browser??V(),r=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==r&&(t.node.textContent=r),je(t),t.node;let i=o.createTextNode(r);return Hr(t,i),i}function jr(e,n,t){let o=null;for(let r of e){let i=We(r,n,t);i!=null&&!o&&(o=i)}return o}function Wt(e,n,t){let r=e.props?.children,i=r==null?[]:Array.isArray(r)?r:[r],s=null;for(let l of i){let d=We(l,n,t);d!=null&&!s&&(s=d)}return s}function Wr(e,n,t){let o=e,r=o._child;if(r==null){if(typeof o._render!="function")throw new Error(`[vdom2] component ${I(o.type)} not built before hydration`);for(o._child=null;t.node&&t.node.nodeType===8&&t.node.nodeValue?.startsWith("wf-hole:");)je(t);return null}let i=We(r,n,t);return o._refNode||(o._refNode=i),i}function Fr(e,n,t){let o=n.browser??V(),r=e,i=r.type,s=r.props??{};for(;t.node&&t.node.nodeType===8&&t.node.nodeValue?.startsWith("wf-hole:");)je(t);let l;if(t.node&&t.node.nodeType===1&&t.node.tagName.toLowerCase()===i.toLowerCase()?(l=t.node,je(t)):(l=Mr.has(i)?o.createElementNS("http://www.w3.org/2000/svg",i):o.createElement(i),Or(t,l)),r.el=l,Ur(l,s),!("innerHTML"in s)){let d={parent:l,node:l.firstChild},u=(Array.isArray(s.children)?s.children:[s.children]).flat(1/0);for(let a of u){let c=We(a,n,d);if(c!=null&&c.parentNode!==l&&l.appendChild(c),a&&typeof a=="object"&&!Array.isArray(a)&&P(a)){let f=a;f._parentNode||(f._parentNode=l,f._refNode=c)}}for(;d.node;){let a=d.node;d.node=a.nextSibling,a.parentNode?.removeChild(a)}}return"value"in s&&l instanceof HTMLSelectElement&&(l.value=String(s.value??"")),l}async function Jn(e,n,t){let o=t.__registry;await Y(n,t,null,o);let r={parent:e,node:e.firstChild};for(We(n,t,r);r.node;){let i=r.node;r.node=i.nextSibling,i.parentNode?.removeChild(i)}}var Br={idle:{NAVIGATE_START:"navigating"},navigating:{NAVIGATE_DONE:"settled",NAVIGATE_ERROR:"idle"},settled:{NAVIGATE_START:"navigating"}};function Ft(){let e="idle",n=(t,o)=>{let r=Br[e]?.[t]??null;return r==null?(S({session:"",machine:"route",nodeId:null,component:null,from:e,event:t,to:"?",payload:{path:o},level:"debug",ts:Date.now()}),e):(S({session:"",machine:"route",nodeId:null,component:null,from:e,event:t,to:r,payload:{path:o},level:"debug",ts:Date.now()}),e=r,r)};return{get state(){return e},navigateStart:t=>{n("NAVIGATE_START",t)},navigateDone:t=>{n("NAVIGATE_DONE",t)},navigateError:(t,o)=>{n("NAVIGATE_ERROR",t)}}}function Kr(e,n){let t=V(),o=typeof n.root=="string"?t.query(n.root):n.root;if(!o)throw new Error(`uiServe: root not found: ${n.root}`);let r=o,i=!!n.hydrate;!i&&!n.loading&&(r.innerHTML="");try{(new URLSearchParams(globalThis?.location?.search??"").get("vdom_debug")==="1"||globalThis?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")&&(globalThis.__WF_VDOM_DEBUG=!0,console.log("[weifuwu] vdom debug \u5DF2\u5F00\u542F\uFF08?vdom_debug=1\uFF09")),bn()}catch{}try{if(new URLSearchParams(globalThis?.location?.search??"").get("wf_reflow")==="1"||globalThis?.localStorage?.getItem?.("__WF_REFLOW_DEBUG")==="1"){globalThis.__WF_REFLOW_DEBUG=!0,console.log("[weifuwu] reflow debug \u5DF2\u5F00\u542F\uFF08?wf_reflow=1\u2014\u2014\u5E03\u5C40\u8BFB\u53D6\u8FFD\u8E2A\uFF09");let _=(F,j)=>{let ie=typeof document<"u"?document.styleSheets?.length??0:-1,fe=j?.tagName?`<${j.tagName}${j.id?"#"+j.id:""}${j.className?"."+String(j.className).split(" ")[0]:""}>`:"",O=(new Error().stack||"").split(`
|
|
9
|
+
`).slice(2,5).map(R=>R.trim().split("/").pop()?.slice(0,80)).join(" \u2190 ");console.log(`[wf-reflow] ${F}${fe} styles=${ie}${ie===0?" \u26A0\uFE0F\u6837\u5F0F\u672A\u52A0\u8F7D\uFF08\u5F3A\u5236\u6392\u7248\u573A\u666F\uFF09":""} :: ${O}`)},ce=Element.prototype.getBoundingClientRect;Element.prototype.getBoundingClientRect=function(...F){return _("rect",this),ce.apply(this,F)};for(let F of["offsetWidth","offsetHeight","offsetTop","offsetLeft","clientWidth","clientHeight","scrollTop","scrollHeight"]){let j=Object.getOwnPropertyDescriptor(Element.prototype,F);if(j?.get){let ie=j.get;Object.defineProperty(Element.prototype,F,{configurable:!0,enumerable:!0,get(){return _(F,this),ie.call(this)}})}}}}catch{}let{ctx:s,registry:l,renderer:d,rootUi:u,destroyPopupListeners:a}=cn({browser:t,root:r}),c=new Map,f=globalThis.__DATA__??window.__DATA__;if(f&&typeof f=="object")for(let[C,E]of Object.entries(f))c.set(C,{value:E});s.data={async get(C,E){let _=c.get(C);if(_&&"value"in _)return _.value;if(_?.promise)return _.promise;if(!E)return;let ce=Promise.resolve().then(()=>E()).then(F=>(c.set(C,{value:F}),F));return c.set(C,{promise:ce}),ce},set(C,E){c.set(C,{value:E})},has(C){return c.has(C)}},s.route={params:{},query:{},path:""};let p=null,m="",g=0,h,N=new Promise(C=>{h=C}),y=!1,v=Ft();async function b(C,E){let _=++g,ce={pathname:C,search:""};s.route.path=C,v.navigateStart(C);let F=Xe(E?"initial":"nav"),j;try{j=await e.execute(ce,s,C)}catch(R){v.navigateError(C,R),j=ge("div",{class:"ui-dom-error"},`\u9875\u9762\u6E32\u67D3\u5931\u8D25: ${R?.message??String(R)}`)}if(y||_!==g){Re();return}let ie=x("mount"),fe=ie?ut("nav"):"";ie&&k("mount","info",fe,`route path=${C} initial=${E}`);let O;try{O=await Y(j,s,p,l)}catch(R){O=ge("div",{class:"ui-dom-error"},`\u7EC4\u4EF6\u6E32\u67D3\u5931\u8D25: ${R?.message??String(R)}`)}if(!(y||_!==g)){if(E)if(i)await Jn(r,O,s),x("mount")&&k("mount","debug",fe,`hydrate done=${r.childNodes.length}`);else{r.innerHTML="";let R=D(O,s,t);x("mount")&&k("mount","debug",fe,`first-render node=${R?.nodeName??"null"} fragKids=${R?.nodeType===11?Array.from(R.childNodes).length:"-"}`),R!=null&&r.appendChild(R),x("mount")&&k("mount","debug",fe,`root-fill done=${r.childNodes.length} first=${r.firstChild?.nodeName}`)}else if(p!==void 0){let R=p;p=O;let pe=R,ke=qe(pe)?pe.el??pe._refNode:pe._refNode;ee(r,ke,R,O,{browser:t,registry:l,ctxVersion:s?.ui?._ctxVersion??0})}p=O,m=C,u._rootVNodeId=O?._id,v.navigateDone(C),Re()}}let H=t.pathname();b(H,!0).finally(()=>{y||h()}),ft(()=>p),it(),vt();let W=()=>{let C=t.pathname();b(C,!1)};return t.addEventListener("popstate",W),{close(){y=!0,t.removeEventListener("popstate",W),a(),l.idRegistry.clear()},ready:N,ctx:s}}function Fe(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function qr(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,n])=>n).map(([n])=>n).join(" "):""}function Gr(e){return Object.entries(e).filter(([,n])=>n!=null&&n!==!1).map(([n,t])=>`${n}:${typeof t=="number"?t:String(t)}`).join(";")}var zr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Yr=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);async function ue(e,n){return ii[$(e)](e,n)}async function Xr(e,n){return""}async function Jr(e,n){return Fe(String(e))}function Qr(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)?"arr":"vnode"}var Zr={hole:e=>Promise.resolve(`<!--${B({type:"hole",value:e,key:null,id:null,fid:null})}-->`),arr:async(e,n,t,o)=>{let r=await ue(e,{...n,_fidPath:o});return`<!--${B({type:"fragment-start",key:String(t),id:null,fid:o})}-->${r}<!--${B({type:"fragment-end",key:String(t),id:null,fid:o})}-->`},vnode:async(e,n)=>{let t=await ue(e,n);return t===""?`<!--${B({type:"hole",value:null,key:null,id:null,fid:null})}-->`:t}};async function ei(e,n){let t=e;gt(t);let o=n._fidPath;return(await Promise.all(t.map(async(i,s)=>{let l=o!=null?`${o}-${s}`:String(s);return Zr[Qr(i)](i,n,s,l)}))).join("")}async function ni(e,n){let t=e,o=n._fidPath??null,r=await ue(t.props?.children,{...n,_fidPath:o??void 0});return`<!--${B({type:"fragment-start",key:null,id:null,fid:o})}-->${r}<!--${B({type:"fragment-end",key:null,id:null,fid:o})}-->`}async function ti(e,n){return ue(e.props?.children,n)}async function oi(e,n){let t=e,o=Object.create(n);delete o._fidPath;let r=await t.type(t.props??{},o);if(typeof r!="function")throw new Error(`Component ${I(t.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);let i=await r(t.props??{});if(t.key!=null&&i!=null&&typeof i=="object")if(Array.isArray(i))for(let s of i)s!=null&&typeof s=="object"&&!Array.isArray(s)&&(s.key=t.key);else i.key=t.key;return ue(i,o)}async function ri(e,n){let t=e,o=t.type,r=t.props??{},i=[],s=null;t.key!=null&&i.push(` data-wf-key="${Fe(String(t.key))}"`);for(let[a,c]of Object.entries(r))if(!(a==="children"||a==="key")&&a!=="ref"&&!(a.startsWith("on")&&typeof c=="function")){if(a==="innerHTML"){s=String(c??"");continue}if(a==="class"||a==="className"){let f=qr(c);f&&i.push(` class="${Fe(f)}"`);continue}if(a==="style"&&c&&typeof c=="object"){i.push(` style="${Fe(Gr(c))}"`);continue}if(En.has(a)){i.push(` ${a}="${c?"true":"false"}"`);continue}if(c===!0){i.push(` ${a}`);continue}c===!1||c==null||i.push(` ${a}="${Fe(String(c))}"`)}let l=i.join(""),d=Yr.has(o);if(zr.has(o))return`<${o}${l}>`;if(s!==null)return`<${o}${l}>${s}</${o}>`;let u=await ue(r.children,n);return d?`<${o}${l}>${u}</${o}>`:`<${o}${l}>${u}</${o}>`}var ii={hole:Xr,text:Jr,arr:ei,portal:ti,frag:ni,comp:oi,native:ri};function Bt(e){return`<script>window.__DATA__=${JSON.stringify(Object.fromEntries(e)).replace(/</g,"\\u003c")};<\/script>`}function Qn(e,n){let t={...e,browser:null,__registry:null,ui:{_rootVNodeId:null,render:()=>Promise.resolve(),setMounting:()=>{},endMounting:()=>{}}},o=new Map;return t.data={async get(r,i){let s=o.get(r);if(s&&"value"in s)return s.value;if(s?.promise)return s.promise;if(!i)return;let l=Promise.resolve().then(()=>i()).then(d=>(o.set(r,{value:d}),n.set(r,d),d));return o.set(r,{promise:l}),l},set(r,i){o.set(r,{value:i}),n.set(r,i)},has(r){return o.has(r)}},t}async function si(e,n,t,o={}){let r=o.data??new Map,i=Qn(t??{},r),s=Pe(e,n??{});return ue(s,i)}async function li(e,n){let t=new Map,r=Qn({params:{},query:{}},t),i=n.url.split("?")[0].split("#")[0],s=e.match(i);r.params=s.params,r.query=Object.fromEntries(new URLSearchParams(n.url.split("?")[1]??""));let l=new URL(n.url.startsWith("http")?n.url:`http://localhost${n.url.startsWith("/")?n.url:"/"+n.url}`),d=await e.execute(l,r,i),u=await ue(d,r),a=Bt(t),c=s.title??n.title??"",f=n.rootId??"root",p=(n.styles??[]).map(g=>` <link rel="stylesheet" href="${g}">`).join(`
|
|
10
10
|
`),m=`<!DOCTYPE html>
|
|
11
11
|
<html lang="${n.lang??"zh-CN"}">
|
|
12
12
|
<head>
|
|
@@ -20,4 +20,4 @@ function At(e){let n=[],t=(e||"/").replace(/:(\w+)/g,(o,r)=>(n.push(r),"([^/]+)"
|
|
|
20
20
|
${a}
|
|
21
21
|
<script src="/app.js"><\/script>
|
|
22
22
|
</body>
|
|
23
|
-
</html>`;return{html:u,dataScript:a,page:m}}function
|
|
23
|
+
</html>`;return{html:u,dataScript:a,page:m}}function ai(e){let n={...e},t=new Set,o=()=>{for(let r of[...t])r()};return{state:n,subscribe(r){return t.add(r),()=>{t.delete(r)}},set(r){Object.assign(n,r),o()},update(r){r(n),o()},notify:o}}export{J as Fragment,K as Portal,mn as UIRouter,Jt as animateOut,Qt as api,no as auth,Y as buildVNode,V as createClientBrowser,Ge as createPortal,rn as createRenderer,Qn as createSsrContext,ai as createStore,cn as createVdomContext,ge as h,Jn as hydrateVNode,yn as jsx,Xt as jsxDEV,Yt as jsxs,Lr as mountRoot,ee as patchValue,D as renderValue,Bt as serializeData,li as ssrPage,si as ssrToString,Kr as uiServe,to as ws};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var i=Symbol("Fragment"),d=Symbol("Portal");function
|
|
1
|
+
var i=Symbol("Fragment"),d=Symbol("Portal");function t(e,o,n=null){return{type:e,props:o,key:n,_child:null,_parentNode:null,_refNode:null,_id:null,_customId:null,_parentVNode:null,_ctxVersion:null,_lifecycle:"fresh"}}function u(e,o,n=null){return e===i?{...t(e,o,n),type:e}:e===d?{...t(e,o,n),type:e,_remoteEl:null,_placement:"remote"}:typeof e=="function"?{...t(e,o,n),type:e,_render:null,_outputChild:null}:{...t(e,o,n),type:e,el:null}}function r(e,o,n){return u(e,c(o),n??null)}var s=r;function a(e,o,n){return r(e,o,n)}function c(e){if(!e)return{};let o={};for(let n of Object.keys(e))n!=="key"&&(o[n]=e[n]);return o}export{i as Fragment,r as jsx,a as jsxDEV,s as jsxs};
|
package/dist/ui-dom/testing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Q=Symbol("Fragment"),ie=Symbol("Portal");function Ee(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function K(e){return e!=null&&typeof e=="object"&&e.type===Q}function C(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function v(e){return e!=null&&typeof e=="object"&&e.type===ie}function w(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}var fe={error:0,warn:1,info:2,debug:3,trace:4},Ae=["mount","build","render","diff","lifecycle","route","audit"],k={enabled:!1,stages:new Set,level:"info",filter:null},pe=!1;function qe(e){return e&&e in fe?e:"info"}function Se(e){let n=new Set;if(!e)return n;for(let t of e.split(",")){let o=t.trim().split(":")[0];Ae.includes(o)&&n.add(o)}return n}function ze(){if(pe)return k;pe=!0;try{let e=globalThis,n=new URLSearchParams(typeof e.location?.search=="string"?e.location.search:""),t=n.get("vdom_trace"),o=n.get("vdom_debug"),i=e.__vdom_trace__,r=typeof e.localStorage?.getItem=="function"?e.localStorage.getItem("vdom_trace"):null;if(o==="1"||e?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")k={enabled:!0,stages:new Set(Ae),level:"debug",filter:null};else if(t||i||r){let l=new Set;if(t)for(let d of Se(t))l.add(d);if(i?.stages){let d=Array.isArray(i.stages)?i.stages:[...i.stages];for(let u of d)l.add(u)}if(r)for(let d of Se(r))l.add(d);k={enabled:!0,stages:l,level:t?.includes(":")?qe(t.split(":")[1]):i?.level??"debug",filter:typeof i?.filter=="string"?i.filter:null}}}catch{}return k}function m(e,n="info"){return!k.enabled&&(pe||ze(),!k.enabled)||k.stages.size&&!k.stages.has(e)?!1:fe[n]<=fe[k.level]}function N(e,n,t,...o){if(!m(e,n))return;let i=k.filter;i&&!t.includes(i)||console.log(`[vdom:${e}] ${t}`,...o)}function E(e,n=12){if(!e)return"\u2205";if(typeof e=="string"||typeof e=="number")return`"${e}"`;if(!Array.isArray(e))return H(e);let t=e.slice(0,n).map(H);return e.length>n&&t.push(`\u2026+${e.length-n}`),`[${t.join(" | ")}]`}function Ge(e){return typeof e=="function"?"function":e===Q?"fragment":typeof e=="string"?"string":"other"}var Ye={function:e=>e.name||"Comp",fragment:()=>"Frag",string:e=>String(e),other:e=>String(e)};function H(e){if(e==null||typeof e=="boolean")return String(e);if(typeof e=="string")return`"${e.slice(0,16)}"`;if(typeof e=="number")return String(e);if(Array.isArray(e))return`ARR(${e.length})`;let n=e,t=n.type,o=Ye[Ge(t)](t),i=n.props?.id?`#${n.props.id}`:n.key!=null?`@${n.key}`:"";return o+i}function $(e){if(!e)return"null";if(e.nodeType===1){let n=e;return`${n.tagName}${n.id?`#${n.id}`:""}${n.getAttribute?.("data-wf-key")?`@${n.getAttribute("data-wf-key")}`:""}`}return e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,40)}-->`:`#${e.nodeType}`}function O(e,n=12){if(!e)return"null";let o=Array.from(e.childNodes).slice(0,n).map($);return e.childNodes.length>n&&o.push(`\u2026+${e.childNodes.length-n}`),`[${o.join(" | ")}]`}var Xe={fresh:{BUILD_START:"building",BUILD_DONE:"built",PRUNE:"pruned",DISPOSE:"disposed"},building:{BUILD_DONE:"built",DISPOSE:"disposed"},built:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},pruned:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},disposed:{BUILD_START:"building"}};function A(e){let n=0,t=e._parentVNode??null;for(let o=0;o<10&&t;o++)n++,t=t._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:n}}var Te=new Map,Je=50;function Ze(e,n,t,o){if(!e?.id)return;let i=Te.get(e.id);i||(i={name:e.name??"?",events:[]},Te.set(e.id,i)),i.events.push(`${n}--${t}-->${o}`),i.events.length>Je&&i.events.shift()}function T(e,n,t){let o=Xe[e]?.[n]??null,i=t?`${t.name??"?"}(${t.id??"?"})[d${t.depth??0}]`:"?";return o==null?(m("lifecycle")&&N("lifecycle","warn","",`illegal transition ${i} ${e} --${n}--> ?`),e):(Ze(t,e,n,o),m("lifecycle","debug")&&N("lifecycle","debug","",`${i} ${e} --${n}--> ${o}`),o)}function Y(e){return!e||e._lifecycle==="disposed"||e._child==null?!1:!ye(e._child)}function ye(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e)){for(let t of e)if(ye(t))return!0;return!1}let n=e;return!!(n._lifecycle==="disposed"||n._child!=null&&ye(n._child))}var Qe=0;function U(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${Qe++}`}}function Pe(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function en(e,n,t,o){try{e(n)}catch(i){console.error(`[weifuwu] ref ${t} error in <${o??"anonymous"}>`,i)}}function _(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let o=[...n.unmountHooks];for(let i of o)i(t._id);if(t._customId)for(let i of o)i(t._customId)}t._id=null,t._customId=null,C(t)&&(t._render=null),t._parentNode=null,t._refNode=null,t._lifecycle=T(t._lifecycle,"DISPOSE",A(t))}else(C(t)||t._child!=null)&&(t._lifecycle=T(t._lifecycle,"DISPOSE",A(t)));if(t._child!=null){if(Array.isArray(t._child))for(let o of t._child)o&&typeof o=="object"&&_(o,n);else _(t._child,n);t._child=null}if(t.props?.children&&typeof t.type=="string"){let o=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let i of o)i&&typeof i=="object"&&_(i,n)}if(typeof t.props?.ref=="function"&&en(t.props.ref,null,"cleanup"),v(t)){let o=t._remoteEl;if(o){let i=t._child;if(i!=null)if(Array.isArray(i))for(let r of i)r&&typeof r=="object"&&_(r,n);else typeof i=="object"&&_(i,n);o.remove(),t._remoteEl=null}}}function P(e){return typeof e=="function"&&e.name||"anonymous"}function Re(e){return e.ui?._ctxVersion??0}function me(e,n){e.ui?.setMounting?.(n)}function g(e,n){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||K(e)){let o=n;if(o&&o.nodeType===8&&o.nodeValue?.includes("type=fragment-start")){let i=[o],r=/fid=([^\s"]+)/.exec(o.nodeValue)?.[1]??"",l=o.nextSibling;for(;l&&(i.push(l),!(l.nodeType===8&&l.nodeValue?.includes("type=fragment-end")&&(/fid=([^\s"]+)/.exec(l.nodeValue)?.[1]??r)===r));)l=l.nextSibling;return i}return null}let t=e;return C(t)?g(t._outputChild??t._child,n):null}function L(e){if(e==null||typeof e=="boolean")return"hole";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"arr";let n=e;return K(n)?"frag":v(n)?"portal":C(n)?"comp":"native"}function ke(e){let n=!1,t=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){t=!0;continue}let i=o;v(i)||(i.key!=null?n=!0:t=!0)}return n&&t?"mixed":n?"keyed":"unkeyed"}function nn(e,n){if(e===n)return!0;let t=Object.keys(e),o=Object.keys(n);if(t.length!==o.length)return!1;for(let i of t)if(e[i]!==n[i])return!1;return!0}async function tn(e,n,t,o){let i=e;i._id||(o?.reuse?._id?i._id=o.reuse._id:i._id=t.nextId(),t.idRegistry.set(i._id,i)),o?.reuse&&(o.reuse._parentNode&&(i._parentNode=o.reuse._parentNode),o.reuse._refNode&&(i._refNode=o.reuse._refNode),o.reuse._ctxVersion!=null&&(i._ctxVersion=o.reuse._ctxVersion));let r=Object.create(n);r.ui=Object.create(n.ui);let l=r.ui;if(l._selfId=i._id??null,l._selfVNode=i,l.render=function(d){let u=n.ui;return d==null&&i._id?u.render([i._id]):u.render(d)},typeof i._render!="function"&&C(o?.reuse)&&typeof o.reuse._render=="function"&&(i._render=o.reuse._render),typeof i._render!="function"){me(n,!0);let d;try{d=await i.type(i.props??{},r)}finally{me(n,!1)}if(typeof d!="function")throw new Error(`Component ${P(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);i._render=d}return{renderFn:i._render,childCtx:r}}function Ne(e){return!!e&&typeof e.then=="function"}function B(e,n,t,o,i){return on[L(e)](e,n,t,o,i)}function he(e,n){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===n.type?e:null}var on={hole:e=>e,text:e=>e,arr:rn,comp:ln,frag:dn,native:$e,portal:$e};function rn(e,n,t,o,i){let r=e;m("build")&&N("build","debug","",`array in kids=${E(r)}`);for(let s=0;s<r.length;s++){let a=r[s];if(a!=null&&typeof a=="object"&&!Array.isArray(a)){let c=a;c.key!==null&&(c.key=String(c.key))}}let l=Array.isArray(t)?t:[],d=new Map;for(let s of l)s!=null&&typeof s=="object"&&!Array.isArray(s)&&s.key!=null&&d.set(s.key,s);let u=r.map((s,a)=>{let c=null;return s!=null&&typeof s=="object"&&!Array.isArray(s)&&s.key!=null&&(c=d.get(s.key)??null),c==null&&(c=l[a]??null),B(s,n,c,o,i)});m("build")&&N("build","debug","",`array out kids=${E(r)}`);let f=!1;for(let s=0;s<u.length;s++)if(Ne(u[s])){f=!0;break}return f?Promise.all(u).then(()=>r):r}function ln(e,n,t,o,i){let r=e,l=o??n.__registry??U(),d=he(t,r);r._id||(r._id=d?._id??l.nextId(),l.idRegistry.set(r._id,r)),d&&(d._parentNode&&(r._parentNode=d._parentNode),d._refNode&&(r._refNode=d._refNode),d._ctxVersion!=null&&(r._ctxVersion=d._ctxVersion),C(r)&&C(d)&&typeof d._render=="function"&&(r._render=d._render));let u=nn(d?.props??{},r.props??{}),f=Re(n),s=(d?._ctxVersion??-1)===f;if(!i?.force&&u&&s&&Y(d)&&typeof r._render=="function"){let a=d;return r._lifecycle=T(r._lifecycle,"PRUNE",A(r)),r._child=a._child,r._ctxVersion=a._ctxVersion,m("build")&&N("build","debug","",`prune comp=${H(r)} propsSame=${u} verSame=${s}`),r}return r._lifecycle=T(r._lifecycle,"BUILD_START",A(r)),m("build")&&N("build","debug","",`mount comp=${H(r)} propsSame=${u} verSame=${s} force=${!!i?.force}`),(async()=>{let{childCtx:a}=await tn(r,n,l,{reuse:d??null}),c=await B(await r._render(r.props),a,d?._child,l,i);return r._child=c??null,r._ctxVersion=f,r._lifecycle=T(r._lifecycle,"BUILD_DONE",A(r)),r})()}function dn(e,n,t,o,i){let r=e,l=o??n.__registry??U(),d=he(t,r);m("build")&&N("build","debug","",`fragment kids=${E(w(r.props?.children))}`);let u=B(r.props?.children??null,n,d?._child??d?.props?.children,l,i);return Ne(u)?u.then(f=>(r._child=f??null,r._lifecycle=T(r._lifecycle,"BUILD_DONE",A(r)),r)):(r._child=u??null,r._lifecycle=T(r._lifecycle,"BUILD_DONE",A(r)),r)}function $e(e,n,t,o,i){let r=e;if(typeof r.type!="string"&&typeof r.type!="symbol")return r;let l=o??n.__registry??U(),d=he(t,r);m("build")&&N("build","trace","",`native <${String(r.type)}> kids=${E(w(r.props?.children))}`);let u=B(r.props?.children??null,n,d?.props?.children,l,i);return Ne(u)?u.then(f=>(r._child=f??null,r._lifecycle=T(r._lifecycle,"BUILD_DONE",A(r)),r)):(r._child=u??null,r._lifecycle=T(r._lifecycle,"BUILD_DONE",A(r)),r)}function V(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,queryAll:e=>typeof document<"u"?document.querySelectorAll(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,createElementNS:(e,n)=>typeof document<"u"?document.createElementNS(e,n):null,createDocumentFragment:()=>typeof document<"u"?document.createDocumentFragment():null,createComment:e=>typeof document<"u"?document.createComment(e):null,createTextNode:e=>typeof document<"u"?document.createTextNode(e):null,addEventListener:(e,n,t)=>{typeof window<"u"&&window.addEventListener(e,n,t)},removeEventListener:(e,n,t)=>{typeof window<"u"&&window.removeEventListener(e,n,t)},scrollTo:e=>{typeof window<"u"&&window.scrollTo(0,e)},matchMedia:e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e):null,visualViewport:()=>(typeof window<"u"?window:null)?.visualViewport??null,scrollingElement:()=>typeof document<"u"?document.scrollingElement:null,bodyElement:()=>typeof document<"u"?document.body:null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},clearBody:()=>{typeof document<"u"&&(document.body.innerHTML="")},event:(e,n)=>{let t=typeof window<"u"?window:null,o=n&&(n.key||n.code)?"KeyboardEvent":n&&(n.clientX!==void 0||n.clientY!==void 0||n.pointerId!==void 0)?"PointerEvent":"Event";try{return new t[o](e,n)}catch{return new t.Event(e,n)}},dispatchEvent:(e,n)=>typeof e<"u"?e.dispatchEvent(n):!1,navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,viewportWidth:()=>typeof window<"u"?window.innerWidth:0,pathname:()=>typeof window<"u"?window.location.pathname:"",createTreeWalker:(e,n)=>typeof document<"u"?document.createTreeWalker(e,n??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}function sn(e){if(e===!1)return"false";if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0)return"true";if(typeof e=="object")try{let n=JSON.stringify(e);return`object ${n!=null&&n.length>80?n.slice(0,80)+"\u2026":n??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function le(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function X(e){let n=[`type=${e.type}`];return e.value!==void 0&&n.push(`value=${le(sn(e.value))}`),e.key!=null&&n.push(`key=${le(e.key)}`),e.id!=null&&n.push(`id=${le(e.id)}`),e.fid!=null&&n.push(`fid=${le(e.fid)}`),`wf-hole: ${n.join(" ")}`}var un=/^on[A-Z]/,an=/^on[A-Z].*Capture$/;function ge(e){let n=an.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var cn=new Set(["draggable","contenteditable","spellcheck","translate"]),fn=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function Ve(e){return cn.has(e)?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":un.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function Le(e,n,t){if(t!==!1){if(t===!0){e.setAttribute(n,"");return}try{e[n]=t,e.getAttribute(n)!==String(t)&&e.setAttribute(n,String(t))}catch{e.setAttribute(n,String(t))}}}var pn={enumerated:(e,n,t)=>{e.setAttribute(n,t?"true":"false")},class:(e,n,t)=>{if(t!==!1)if(typeof t=="object")for(let[o,i]of Object.entries(t))i&&e.classList.add(o);else e.setAttribute("class",String(t))},style:(e,n,t)=>{if(t!==!1)if(typeof t=="string")e.setAttribute("style",t);else{let o=e.style;for(let[i,r]of Object.entries(t))r==null?o[i]="":i.startsWith("--")?o.setProperty(i,String(r)):typeof r=="number"&&!fn.has(i)?o[i]=`${r}px`:o[i]=String(r)}},ref:(e,n,t)=>{if(typeof t=="function")try{t(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,n,t)=>{if(t===!1)return;let{type:o,capture:i}=ge(n);if(typeof t!="function"){console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof t} \u2014 ignored`);return}e.addEventListener(o,t,i?{capture:!0}:{})},value:(e,n,t)=>{t!==!1&&(e.value=t)},indeterminate:(e,n,t)=>{t!==!1&&(e.indeterminate=!!t)},innerHTML:(e,n,t)=>{t!==!1&&(e.innerHTML=String(t??""))},aria:(e,n,t)=>{if(t!==!1){if(typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}Le(e,n,t)}},default:Le};function W(e,n,t){t!=null&&pn[Ve(n)](e,n,t)}function D(e,n){return e.createComment(X({type:"hole",value:n,key:null,id:null,fid:null}))}var yn=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function J(e,n){return D(e,n)}function x(e,n,t,o=null,i=null,r=null){let l=n?.browser??t;if(!l)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return bn[L(e)](e,n,l,o,i,r)}function mn(e,n,t){return null}function Nn(e,n,t){return t.createTextNode(String(e))}function Ce(e,n,t,o,i){if(e==null||typeof e=="boolean")return J(t,e);let r=x(e,n,t,String(o),null,i);return r??J(t,null)}function hn(e,n,t,o=null,i=null,r=null){let l=e,d=t.createDocumentFragment();if(!d)return null;m("render")&&N("render","debug","",`array kids=${E(l)} fid=${r??"-"} key=${o??"-"}`);let u=t.createComment(X({type:"fragment-start",key:o,id:i,fid:r})),f=t.createComment(X({type:"fragment-end",key:o,id:i,fid:r}));u&&d.appendChild(u);for(let s=0;s<l.length;s++){let a=l[s],c=r!=null?`${r}-${s}`:String(s),p=Ce(a,n,t,s,c);p!=null&&d.appendChild(p)}return f&&d.appendChild(f),d}function gn(e,n,t){let o=e,i=o,r=t.bodyElement();if(!r)return null;let l=r.querySelector("#__wf_portal");l||(l=t.createElement("div"),l&&(l.id="__wf_portal",r.appendChild(l)));let d=t.createElement("div");if(d){d.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let u=x(o.props?.children??null,n,t);u!=null&&d.appendChild(u),l&&l.appendChild(d),i._remoteEl=d;let f=w(o.props?.children);for(let s of f)s!=null&&typeof s=="object"&&!Array.isArray(s)&&(s._parentVNode=o)}return null}function Vn(e,n,t,o=null,i=null,r=null){let l=e,d=l,u=t.createDocumentFragment();if(!u)return null;let f=w(l.props?.children);m("render")&&N("render","debug","",`fragment kids=${E(f)} fid=${r??"-"}`);let s=t.createComment(X({type:"fragment-start",key:o,id:i,fid:r})),a=t.createComment(X({type:"fragment-end",key:o,id:i,fid:r}));s&&u.appendChild(s),d._refNode=s;for(let c=0;c<f.length;c++){let p=f[c],y=r!=null?`${r}-${c}`:String(c),h=Ce(p,n,t,c,y);h!=null&&u.appendChild(h)}return a&&u.appendChild(a),u}function Cn(e,n,t){let o=e,i=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return wn[i](o,n,t)}var wn={fresh:(e,n,t)=>{throw new Error(`[vdom2] component ${P(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,n,t)=>{throw new Error(`[vdom2] component ${P(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,n,t)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${P(e.type)} \u5728\u6E32\u67D3\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`),J(t,null)),built:Ie,pruned:Ie};function Ie(e,n,t){let o=e._child;if(o==null)return e._child=null,null;e._child=o,e._outputChild=o,typeof o=="object"&&!Array.isArray(o)&&(o._parentVNode=e);let i=x(o,n,t);if(i){if(e._refNode=i.nodeType===11?i.firstChild:i,e._id)if(i.nodeType===11)for(let r of Array.from(i.childNodes))r.nodeType===1&&r.setAttribute("data-wf-id",e._id);else i.nodeType===1&&i.setAttribute("data-wf-id",e._id);if(e.key!=null)if(i.nodeType===11)for(let r of Array.from(i.childNodes))r.nodeType===1&&r.setAttribute("data-wf-key",e.key);else i.nodeType===1&&i.setAttribute("data-wf-key",e.key)}return i}function _n(e,n,t,o,i){let r=e,l=r,d=r.type,u=yn.has(d)?t.createElementNS("http://www.w3.org/2000/svg",d):t.createElement(d);if(!u)return null;l.el=u,l._refNode=u,m("render")&&N("render","trace","",`native <${d}> key=${r.key??"-"} kids=${E(w(r.props?.children))}`),r.key!=null&&u.setAttribute("data-wf-key",r.key);let f=null;for(let[s,a]of Object.entries(r.props??{}))if(!(s==="children"||s==="key")){if(s==="value"&&u instanceof HTMLSelectElement){f=a;continue}W(u,s,a)}if(!("innerHTML"in(r.props??{}))){let s=w(r.props?.children);for(let a=0;a<s.length;a++){let c=s[a],p=i!=null?`${i}-${a}`:String(a),y=Ce(c,n,t,a,p);if(y!=null&&(u.appendChild(y),c&&typeof c=="object"&&!Array.isArray(c)&&typeof c.type=="function")){let h=c;h._parentNode||(h._parentNode=u)}}m("render")&&N("render","trace","",`native <${d}> out=${O(u)}`)}return f!==null&&(u.value=String(f)),u}var bn={hole:mn,text:Nn,arr:hn,portal:gn,frag:Vn,comp:Cn,native:_n};function F(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=x(e.newInput,i,i.browser??V());if(r==null)return null;if(t?.parentNode){let l=ee(o,t,n,i);return l&&l.parentNode===n?n.insertBefore(r,l):n.appendChild(r),r}return n.appendChild(r),r}function xn(e){return ee(e.oldInput,e.oldNode,e.parent,e.ctx),null}function vn(e){let n=e.oldNode;if(n?.nodeType===8){let t=J(e.ctx.browser??V(),e.newInput);return t&&n.nodeValue!==t.nodeValue&&(n.nodeValue=t.nodeValue),n}return null}function Z(e){let{parent:n,oldNode:t,ctx:o}=e,i=x(e.newInput,o,o.browser??V());return i==null?null:(t?.parentNode?t.parentNode.replaceChild(i,t):t?n.insertBefore(i,t):n.appendChild(i),i)}function En(e){let{parent:n,oldNode:t,oldInput:o}=e,i=String(e.newInput);if(String(o)!==i){if(t&&t.nodeType===3)return t.nodeValue=i,t;let r=n.ownerDocument.createTextNode(i);return t?.parentNode?t.parentNode.replaceChild(r,t):n.appendChild(r),r}return t}function Sn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput,l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=r.type;if(t&&t.nodeType===1&&(l?.type??null)===d&&Ee(r)){let u=t;return r.el=u,r._refNode=u,Me(u,l?.props??{},r.props??{}),"innerHTML"in(r.props??{})||ne(u,l?._child??l?.props?.children??null,r._child??r.props?.children??null,i),u}return F(e)}function An(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput,l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=K(l)?g(l,t):null,u=we(n,l??o,r,i,d);return t?.parentNode?t:u[0]??null}function Tn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput;if(!C(r)||typeof r._render!="function")throw new Error(`[vdom2] component ${P(r.type)} not built in diff \u2014 buildVNode must run before patchValue`);let l=o&&typeof o=="object"&&!Array.isArray(o)?o:null;if(l?.type!=null&&l.type!==r.type)return F(e);let d=l?.type===r.type;if(!i.force&&l&&d&&Y(l)&&r._child===l._child)return t;l?.type===r.type&&l._id&&(r._id=l._id,i.registry.idRegistry.set(r._id,r)),r._parentNode=n,t&&(r._refNode=t);let u=r._child;if(u===null){r._outputChild=null,r._refNode=null;let s=t?.parentNode!=null,a=ee(l?._child??null,t,n,i);l&&(l._child=null);let c=J(i.browser??V(),null);return s&&c?(a&&a.parentNode===n?n.insertBefore(c,a):n.appendChild(c),c):q(n,t,l?._child,null,i)}r._outputChild=u;let f=q(n,t,l?._child,u,i);return f&&(r._refNode=f),f}function Pn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e;if(o===e.newInput&&t?.parentNode)return t;let r=n.ownerDocument.createDocumentFragment(),l=ne(n,o,e.newInput,i,t?[t]:null);for(let d of l)d&&r.appendChild(d);return t?.parentNode?r.contains(t)?n.appendChild(r):t.parentNode.replaceChild(r,t):n.appendChild(r),r}function Rn(e){let{ctx:n,oldInput:t}=e,o=e.newInput,i=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(v(i)&&v(o)){let r=i._remoteEl;if(r){let l=i._child??i.props?.children??null,d=o._child??o.props?.children??null;ne(r,l,d,n)}return o._remoteEl=i._remoteEl,null}return F(e)}function z(e){return{text:F,native:F,frag:F,comp:F,arr:F,hole:xn,portal:F,...e}}var kn={text:z({text:En}),hole:z({text:Z,native:Z,frag:Z,comp:Z,arr:Z,portal:Z,hole:vn}),native:z({native:Sn}),frag:z({frag:An}),comp:z({comp:Tn}),arr:z({arr:Pn}),portal:z({portal:Rn})};function je(e){let n=L(e.oldInput),t=L(e.newInput);return kn[n][t](e)}function _e(){return!!globalThis?.__WF_VDOM_AUDIT}function I(e,n){if(n&&typeof e.type=="function"&&e._id){try{_(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}Pe(n,e._id)}}function re(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let n=e;return v(n)?typeof n.props?.portalKey=="string"?n.props.portalKey:null:n.key}function xe(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)){let t=g(e,n);if(t&&t.length>1)return t}return[n]}function de(e,n){let t=w(e.props?.children);for(let o of t){if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o;$n[L(i)](i,n)}}var $n={comp:(e,n)=>{I(e,n)},frag:(e,n)=>{de(e,n)},native:(e,n)=>{de(e,n)},portal:(e,n)=>{de(e,n)},arr:()=>{},text:()=>{},hole:()=>{}};function ee(e,n,t,o){return Ln[L(e)](e,n,t,o)}var Ln={arr:(e,n,t,o)=>{let i=g(e,n);if(i&&i.length){let r=(i[i.length-1]??n)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return r&&r.parentNode===t?r:null}return te(e,n,t,o)},frag:(e,n,t,o)=>{let i=e,l=g(i,n)??[],d=(l[l.length-1]??n)?.nextSibling??null;for(let u of l)u.parentNode&&u.parentNode.removeChild(u);return de(i,o.registry),d&&d.parentNode===t?d:null},portal:(e,n,t,o)=>{let i=e,r=i._remoteEl;try{_(i.props?.children,o.registry)}catch(l){console.error("[weifuwu] portal ref cleanup error",l)}return r?.parentNode?.removeChild(r),null},comp:(e,n,t,o)=>{let i=e,r=g(i,n);if(I(i,o.registry),r&&r.length>1){let l=(r[r.length-1]??n)?.nextSibling??null;for(let d of r)d.parentNode&&d.parentNode.removeChild(d);return l&&l.parentNode===t?l:null}return te(e,n,t,o)},native:(e,n,t,o)=>{try{_(e,o.registry)}catch(i){console.error("[weifuwu] ref cleanup error",i)}return te(e,n,t,o)},text:(e,n,t,o)=>te(e,n,t,o),hole:(e,n,t,o)=>te(e,n,t,o)};function te(e,n,t,o){let i=n?.nextSibling??null;return n?.parentNode&&n.parentNode.removeChild(n),i&&i.parentNode===t?i:null}function q(e,n,t,o,i){return je({parent:e,oldNode:n,oldInput:t,newInput:o,ctx:i})}var In={event:(e,n,t,o)=>{let{type:i,capture:r}=ge(n);typeof t=="function"&&e.removeEventListener(i,t,r?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(i,o,r?{capture:!0}:{}))},class:(e,n,t,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",W(e,n,o))},ref:(e,n,t,o)=>{if(o==null||o===!1){if(typeof t=="function")try{t(null)}catch(i){console.error("[weifuwu] ref cleanup error",i)}}else W(e,n,o)},value:(e,n,t,o)=>{o==null||o===!1?e.value="":W(e,n,o)},indeterminate:(e,n,t,o)=>{o==null||o===!1?e.indeterminate=!1:W(e,n,o)},enumerated:oe,style:oe,innerHTML:oe,aria:oe,default:oe};function oe(e,n,t,o){if(o==null||o===!1){e.removeAttribute(n);try{delete e[n]}catch{}}else W(e,n,o)}function Me(e,n,t){let o=Object.keys(n),i=Object.keys(t);if(o.length===i.length){let l=!0;for(let d=0;d<o.length;d++)if(o[d]!==i[d]||n[o[d]]!==t[o[d]]){l=!1;break}if(l)return}let r=new Set([...o,...i]);for(let l of r){if(l==="children"||l==="key")continue;let d=n[l],u=t[l];d!==u&&In[Ve(l)](e,l,d,u)}}function we(e,n,t,o,i){let r=Array.isArray(n)?n:n?._child??n?.props?.children??null,l=Array.isArray(t)?t:t?._child??t?.props?.children??null;return ne(e,r,l,o,i)}function ne(e,n,t,o,i,r){let l=w(n),d=w(t),u=i??Array.from(e.childNodes);m("diff")&&N("diff","debug","",`patchChildren parent=${$(e)} old=${E(l)} new=${E(d)} dom=${O(e)}`);let s=d.some(p=>Array.isArray(p))||l.some(p=>Array.isArray(p))?"unkeyed":ke(d);if(m("diff")&&N("diff","debug","",`key-mode=${s}`),_e()&&l.length!==d.length)for(let p=0;p<d.length;p++){let y=d[p];y!=null&&typeof y=="object"&&!Array.isArray(y)&&C(y)&&y.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${p} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\u2014\u2014\u5217\u8868\u589E\u5220/\u91CD\u6392\u4F1A\u9519\u4F4D\u7EC4\u4EF6\u5B9E\u4F8B\u72B6\u6001\u3002\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u8EAB\u4EFD key\uFF08\u5982 key={item.id}\uFF09\uFF1B\u65E0\u72B6\u6001 native \u9879\u8C41\u514D\u3002`)}let a=i&&i.length?i[i.length-1]:null;s==="mixed"&&(se(d),se(l));let c=(()=>{let p=u;p.length>=2&&p[0]?.nodeType===8&&p[0].nodeValue?.includes("fragment-start")&&p[p.length-1]?.nodeType===8&&p[p.length-1].nodeValue?.includes("fragment-end")&&(p=p.slice(1,-1));let y=[],h=0;for(let S=0;S<l.length;S++){let b=l[S];if(Array.isArray(b)){let j=p[h]??null;y.push(j);let M=g(b,j);h+=M?.length??1;continue}if(b==null||typeof b=="boolean"||typeof b=="string"||typeof b=="number"){y.push(p[h]??null),h++;continue}let R=b;if(v(R)){y.push(R._remoteEl??null);continue}if(y.push(R._refNode??p[h]??null),typeof R.type=="function"||K(R)){let j=g(R,R._refNode??p[h]??null);h+=j?.length??1}else h++}return y})();return nt[s]({parent:e,oldChildren:l,newChildren:d,oldNodes:c,ctx:o,arrEnd:a,anchorOut:r})}function be(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&K(e)?"multi":"real"}function jn(e){let{parent:n,oldC:t,oldNode:o,oldNodes:i,i:r,ctx:l,out:d,pushA:u}=e;if(Array.isArray(t)){m("diff")&&N("diff","trace","",`remove-arr-item i=${r} range=[${(g(t,i[r])??[]).map($).join(" | ")}] before=${O(n)}`);let f=g(t,o);for(let s of f??[])s.parentNode?.removeChild(s);m("diff")&&N("diff","trace","",`remove-arr-item after=${O(n)}`);for(let s of t)s!=null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"&&I(s,l.registry)}else if(t&&typeof t=="object"&&!Array.isArray(t)){if(typeof t.type=="function")I(t,l.registry);else try{_(t,l.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);d.push(null),u(null)}function Mn(e){let{parent:n,newC:t,oldNode:o,i,oldNodes:r,out:l,pushA:d,ctx:u}=e,f=D(u.browser??V(),t);if(o?.nodeType===8){f&&o.nodeValue!==f.nodeValue&&(o.nodeValue=f.nodeValue),l.push(o),d(o);return}if(f&&o?.parentNode)o.parentNode.replaceChild(f,o);else if(f){let s=null;for(let a=i+1;a<r.length;a++){let c=r[a];if(c&&c.parentNode===n){s=c;break}}if(!s){let a=null;for(let c=l.length-1;c>=0;c--)if(l[c]){a=l[c];break}a&&a.parentNode===n&&(s=a.nextSibling)}s&&s.parentNode===n?n.insertBefore(f,s):n.appendChild(f),l.push(f),d(f)}else l.push(f),d(f)}function He(e){let{parent:n,newC:t,oldNode:o,i,oldNodes:r,out:l,pushA:d,ctx:u}=e,f=x(t,u,u.browser??V(),String(i));if(f==null){l.push(null),d(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){o.parentNode?.replaceChild(f,o),l.push(f),d(f);return}let s=null;for(let a=i+1;a<r.length;a++){let c=r[a];if(c&&c.parentNode===n){s=c;break}}if(s==null){let a=null;for(let c=l.length-1;c>=0;c--)if(l[c]){a=l[c];break}if(a&&a.parentNode===n)s=a.nextSibling;else{let c=r[r.length-1];c&&c.parentNode===n&&(s=c.nextSibling)}}s&&s.parentNode===n?n.insertBefore(f,s):n.appendChild(f),l.push(f),d(f)}function Hn(e){let{parent:n,oldC:t,newC:o,oldNode:i,out:r,pushA:l,ctx:d}=e;if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.type=="function"){let f=De(n,t,i,o,d);r.push(f),l(f);return}let u=Fe(n,t,i,o,d);r.push(u),l(u)}function On(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,out:l,pushA:d,ctx:u}=e,f=u.browser??V(),s=x(o,u,f,String(r));if(s==null){l.push(null),d(null);return}let a=t&&typeof t=="object"?g(t,i):null;if(a&&a.length>1){let p=(a[a.length-1]??i)?.nextSibling??null;for(let y of a)y.parentNode&&y.parentNode.removeChild(y);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")I(t,u.registry);else try{_(t,u.registry)}catch(y){console.error("[weifuwu] ref cleanup error",y)}p&&p.parentNode===n?n.insertBefore(s,p):n.appendChild(s)}else i?.parentNode?i.parentNode.replaceChild(s,i):n.appendChild(s);let c=s.nodeType===11?Array.from(s.childNodes):[s];l.push(...c),d(c[0]??s)}function Bn(e){let{parent:n,oldC:t,newC:o,oldNode:i,out:r,pushA:l,ctx:d}=e,u=Be(n,t,i,o,d);r.push(u),l(u)}function Dn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,oldNodes:l,out:d,pushA:u,ctx:f}=e,s=f.browser??V(),a=g(t,i);m("diff")&&N("diff","debug","",`multi-remove i=${r} range=${a?a.map($).join(" | "):"null"}`);for(let y of a??[])y.parentNode?.removeChild(y);for(let y of w(t?.props?.children))y!=null&&typeof y=="object"&&!Array.isArray(y)&&typeof y.type=="function"&&I(y,f.registry);let c=x(o,f,s,String(r));if(c==null){d.push(null),u(null);return}let p=l[r+1]??null;p?.parentNode?p.parentNode.insertBefore(c,p):n.appendChild(c),d.push(c),u(c)}function Fn(e){let{parent:n,oldC:t,newC:o,oldNode:i,oldNodes:r,i:l,out:d,pushA:u,ctx:f}=e,s=g(t,i),a=we(n,t,o,f,s);d.push(...a),u(r[l]??a[0]??null)}function Kn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,out:l,pushA:d,ctx:u}=e;if(o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.type=="function"&&o._lifecycle==="disposed"){let a=Ue(n,i,u,P(o.type));l.push(a),d(a);return}let f=q(n,i,t,o,u);m("diff")&&N("diff","trace","",`after-patch i=${r} new=${H(o)} node=${$(f)} dom=${O(n)}`);let s=xe(o,f);l.push(...s),d(s[0]??f??null)}function Be(e,n,t,o,i){let r=D(i.browser??V(),o),l=g(n,t),d=((l??[])[l?.length?l.length-1:0]??t)?.nextSibling??null;for(let u of l??[])u.parentNode?.removeChild(u);for(let u of w(n?.props?.children))u!=null&&typeof u=="object"&&!Array.isArray(u)&&typeof u.type=="function"&&I(u,i.registry);return r&&d&&d.parentNode===e?e.insertBefore(r,d):r&&e.appendChild(r),r}function De(e,n,t,o,i){let r=D(i.browser??V(),o),l=ee(n,t,e,i);return r&&l?e.insertBefore(r,l):r&&e.appendChild(r),r}function Fe(e,n,t,o,i){let r=D(i.browser??V(),o);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")I(n,i.registry);else try{_(n,i.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}return r&&t?.parentNode?t.parentNode.replaceChild(r,t):r&&e.appendChild(r),r}var Un={hole:{hole:Mn,real:He,multi:He},real:{hole:Hn,real:Kn,multi:On},multi:{hole:Bn,real:Dn,multi:Fn}};function Wn(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,anchorOut:l}=e,d=Math.max(t.length,o.length),u=[],f=s=>{l&&l.push(s)};for(let s=0;s<d;s++){let a=s<t.length?t[s]:null,c=s<o.length?o[s]:null;if(m("diff")&&N("diff","trace","",`pos ${s} old=${H(a)} new=${H(c)} oldNode=${$(i[s])}`),s>=o.length){jn({parent:n,oldC:a,newC:c,oldNode:i[s],i:s,oldNodes:i,newChildren:o,out:u,pushA:f,ctx:r});continue}if(a!=null&&typeof a=="object"&&!Array.isArray(a)&&c!=null&&typeof c=="object"&&!Array.isArray(c)&&c===a&&Y(a)){u.push(i[s]),f(i[s]);continue}Un[be(a)][be(c)]({parent:n,oldC:a,newC:c,oldNode:i[s],i:s,oldNodes:i,newChildren:o,out:u,pushA:f,ctx:r})}return u}function Oe(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,anchorOut:l,arrEnd:d}=e,u=new Map;t.forEach((p,y)=>{let h=re(p);h!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&u.set(h,{vnode:p,nodes:[i[y]??null].filter(Boolean),index:y})});let f=[],s=new Set,a=p=>{l&&l.push(p)},c=null;return o.forEach((p,y)=>{let h=re(p),S=p;if(h!==null&&u.has(h)){let b=u.get(h),R=b.nodes[0]??null;if(s.add(h),S&&typeof S=="object"&&typeof S.type=="function"&&S._lifecycle==="disposed"){let G=Ue(n,R,r,P(S.type));f.push(G),a(G),G&&(c=G);return}let j=q(n,R,b.vnode,S,r),M=xe(S,j),ae=M[0]??j,ve=M[M.length-1]??j;if(ae&&ae.parentNode===n&&c&&ae.previousSibling!==c){m("diff")&&N("diff","debug","",`keyed-correct i=${y} k=${h} move=[${M.map($).join(" | ")}] after=${$(c)} before=${O(n)}`);let G=c.nextSibling;for(let ce of M)ce&&ce.parentNode===n&&n.insertBefore(ce,G);m("diff")&&N("diff","debug","",`keyed-correct after=${O(n)}`)}f.push(...M),a(M[0]??j??null),ve&&(c=ve)}else{let b={current:c};Jn[Xn(p)]({parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,out:f,pushA:a,arrEnd:d,c:p,i:y},b),c=b.current}}),t.forEach((p,y)=>{zn[qn(re(p),s)](n,p,y,i,r,o.length)}),f}function qn(e,n){return e===null?"unkeyed":n.has(e)?"moved":"stale-keyed"}var zn={moved:()=>{},"stale-keyed":Gn,unkeyed:Yn};function Gn(e,n,t,o,i){let r=n&&typeof n=="object"&&!Array.isArray(n)?g(n,o[t]):null;if(m("diff")&&N("diff","trace","",`keyed-delete i=${t} k=${re(n)} range=${r?.length??0} oldNode=${$(o[t])}`),n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")I(n,i.registry);else try{_(n,i.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}Ke(r,o[t])}function Yn(e,n,t,o,i,r){let l=o[t];if(l?.nodeType===8&&l.nodeValue?.includes("type=hole")&&t<r)return;if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")I(n,i.registry);else try{_(n,i.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}let u=n&&typeof n=="object"&&!Array.isArray(n)?g(n,l):null;Ke(u,l)}function Ke(e,n){if(e&&e.length>1)for(let t of e)t.parentNode&&t.parentNode.removeChild(t);else n?.parentNode&&n.parentNode.removeChild(n)}function Xn(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&v(e)?"portal":"real"}var Jn={hole:Zn,portal:Qn,real:et};function Zn(e,n){let{parent:t,oldChildren:o,oldNodes:i,ctx:r,out:l,pushA:d,c:u,i:f}=e,s=o[f]??null,a=i[f]??null,c=be(s);if(c==="hole"){let y=D(r.browser??V(),u);a?.nodeType===8?(y&&a.nodeValue!==y.nodeValue&&(a.nodeValue=y.nodeValue),l.push(a),d(a),a&&(n.current=a)):(y&&a?.parentNode?a.parentNode.replaceChild(y,a):y&&t.appendChild(y),l.push(y),d(y),y&&(n.current=y));return}let p=c==="multi"?Be(t,s,a,u,r):s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"?De(t,s,a,u,r):Fe(t,s,a,u,r);l.push(p),d(p),p&&(n.current=p)}function Qn(e,n){let{parent:t,oldChildren:o,oldNodes:i,ctx:r,out:l,pushA:d,c:u,i:f}=e,s=u,a=o[f]??null,c=q(t,i[f]??null,a,s,r),p=xe(s,c);l.push(...p),d(p[0]??c??null);let y=p[p.length-1]??c;y&&(n.current=y)}function et(e,n){let{parent:t,oldNodes:o,ctx:i,out:r,pushA:l,arrEnd:d,c:u,i:f}=e,a=x(u,i,i.browser??V());if(r.push(a),l(a??null),a!=null){let c=o[f];c&&c.nodeType===8&&c.nodeValue?.includes("type=hole")?(c.parentNode?.replaceChild(a,c),n.current=a):(n.current?t.insertBefore(a,n.current.nextSibling):d&&d.parentNode===t?t.insertBefore(a,d):t.insertBefore(a,t.firstChild),n.current=a)}}function se(e){for(let n=0;n<e.length;n++){let t=e[n];t&&typeof t=="object"&&!Array.isArray(t)&&re(t)===null&&(t.key=`pos:${n}`)}}function Ue(e,n,t,o){_e()?console.error(`[vdom2/audit] I1 \u8FDD\u53CD\uFF1Adiff \u6536\u5230 disposed \u7EC4\u4EF6 ${o}\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\uFF08portal \u5185\u5BB9\u72EC\u7ACB dispose\uFF09\u2014\u2014\u7236\u6811\u5C06\u91CD\u5EFA`):console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${o} \u5728 diff\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`);let i=D(t.browser??V(),null);if(i==null)return null;let r=n;if(r){let l=r.parentNode;l?l.replaceChild(i,r):e.appendChild(i)}else e.appendChild(i);return i}var nt={unkeyed:Wn,keyed:Oe,mixed:e=>(se(e.newChildren),se(e.oldChildren),Oe(e))};function We(e,n,t,o){let i=t,r=i.__registry??U(),l=i.browser??V();return Promise.resolve(B(n,i,null,r)).then(()=>{let d=x(n,i,l);if(d!=null&&e.appendChild(d),n._id&&r){let u=r.idRegistry.get(n._id);u&&(u._parentNode=e)}o?.onMounted?.()}).catch(d=>console.error("[vdom2] command mount error",d)),{id:n._id??""}}function Vo(e,n,t){return new Promise(o=>{We(e,n,t,{onMounted:o})})}async function Co(e,n,t,o,i){return await B(o,i,t,i.__registry),q(e,n,t,o,{browser:i.browser??i.__browser,registry:i.__registry})}function wo(e,n){let t=n.__registry??(n.__registry=U());return Promise.resolve(B(e,n,void 0,t))}async function _o(e,n,t){let o=await e(n,t);return typeof o=="function"?o(n):o}async function bo(e,n,t){let o=await e(n,t);return()=>typeof o=="function"?o(n):o}function ue(e,n){if(e==null||typeof e!="object")return;if(Array.isArray(e)){for(let o of e)ue(o,n);return}n(e);let t=e?.props?.children;t!=null&&ue(t,n)}function xo(e,n){let t;return ue(e,o=>{!t&&n(o)&&(t=o)}),t}function vo(e,n){let t=[];return ue(e,o=>{typeof o?.props?.class=="string"&&o.props.class.split(" ").includes(n)&&t.push(o)}),t}function Eo(e){let n={ui:{render:()=>{},ready:!0,useExternal:()=>{}}};return e?{ui:{...n.ui,...e.ui??{}},...e.browser?{browser:e.browser}:{}}:n}function So(e=()=>!1,n){return{get open(){return e()},setOpen:n??(t=>{}),refresh:()=>{},portal:(t,o)=>e()?t:null,wrapProps:{}}}export{wo as buildToDom,So as createPopupMock,Eo as createTestCtx,vo as findByClass,xo as findVNode,bo as mountComponent,Vo as mountToDom,Co as patchToDom,_o as renderVNode,ue as walkVNode};
|
|
1
|
+
var ne=Symbol("Fragment"),ue=Symbol("Portal");function ke(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function K(e){return e!=null&&typeof e=="object"&&e.type===ne}function C(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function S(e){return e!=null&&typeof e=="object"&&e.type===ue}function _(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}var Ne={error:0,warn:1,info:2,debug:3,trace:4},Re=["mount","build","render","diff","lifecycle","route","audit"],I={enabled:!1,stages:new Set,level:"info",filter:null},he=!1;function Je(e){return e&&e in Ne?e:"info"}function Te(e){let n=new Set;if(!e)return n;for(let t of e.split(",")){let o=t.trim().split(":")[0];Re.includes(o)&&n.add(o)}return n}function Ze(){if(he)return I;he=!0;try{let e=globalThis,n=new URLSearchParams(typeof e.location?.search=="string"?e.location.search:""),t=n.get("vdom_trace"),o=n.get("vdom_debug"),i=e.__vdom_trace__,r=typeof e.localStorage?.getItem=="function"?e.localStorage.getItem("vdom_trace"):null;if(o==="1"||e?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")I={enabled:!0,stages:new Set(Re),level:"debug",filter:null};else if(t||i||r){let l=new Set;if(t)for(let d of Te(t))l.add(d);if(i?.stages){let d=Array.isArray(i.stages)?i.stages:[...i.stages];for(let u of d)l.add(u)}if(r)for(let d of Te(r))l.add(d);I={enabled:!0,stages:l,level:t?.includes(":")?Je(t.split(":")[1]):i?.level??"debug",filter:typeof i?.filter=="string"?i.filter:null}}}catch{}return I}function m(e,n="info"){return!I.enabled&&(he||Ze(),!I.enabled)||I.stages.size&&!I.stages.has(e)?!1:Ne[n]<=Ne[I.level]}function h(e,n,t,...o){if(!m(e,n)&&!Pe())return;let i=I.filter;i&&!t.includes(i)||w({session:"",machine:e,nodeId:null,component:null,from:"",event:"TRACE",to:"",payload:()=>o.length?`${t} ${o.join(" ")}`:t,level:n,ts:Date.now()})}function A(e,n=12){if(!e)return"\u2205";if(typeof e=="string"||typeof e=="number")return`"${e}"`;if(!Array.isArray(e))return z(e);let t=e.slice(0,n).map(z);return e.length>n&&t.push(`\u2026+${e.length-n}`),`[${t.join(" | ")}]`}function Qe(e){return typeof e=="function"?"function":e===ne?"fragment":typeof e=="string"?"string":"other"}var en={function:e=>e.name||"Comp",fragment:()=>"Frag",string:e=>String(e),other:e=>String(e)};function z(e){if(e==null||typeof e=="boolean")return String(e);if(typeof e=="string")return`"${e.slice(0,16)}"`;if(typeof e=="number")return String(e);if(Array.isArray(e))return`ARR(${e.length})`;let n=e,t=n.type,o=en[Qe(t)](t),i=n.props?.id?`#${n.props.id}`:n.key!=null?`@${n.key}`:"";return o+i}function k(e){if(!e)return"null";if(e.nodeType===1){let n=e;return`${n.tagName}${n.id?`#${n.id}`:""}${n.getAttribute?.("data-wf-key")?`@${n.getAttribute("data-wf-key")}`:""}`}return e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,40)}-->`:`#${e.nodeType}`}function O(e,n=12){if(!e)return"null";let o=Array.from(e.childNodes).slice(0,n).map(k);return e.childNodes.length>n&&o.push(`\u2026+${e.childNodes.length-n}`),`[${o.join(" | ")}]`}var nn={route:"route",lifecycle:"lifecycle",x2y:"diff",keys:"diff",pos:"diff",render:"render",audit:"audit",build:"build",mount:"mount",diff:"diff"};function Ie(e){return nn[e]}var Y=new Set;function tn(e){return Y.add(e),()=>{Y.delete(e)}}var $e=[];function on(){return $e[$e.length-1]??""}function w(e){if(Y.size!==0){e.session||(e.session=on()),typeof e.payload=="function"&&(Y.size>1||m(Ie(e.machine),e.level??"debug"))&&(e.payload=e.payload());for(let n of Y)try{n(e)}catch{}}}function Pe(){return Y.size>1}function rn(e){if(e==null)return"";if(typeof e=="string")return` ${e}`;if(typeof e=="object"){let n=e,t=[];for(let o of["path","i","key","mode","kind","insertedBefore","after","depth"])if(n[o]!==void 0){let i=n[o];t.push(`${o}=${typeof i=="object"?JSON.stringify(i):String(i)}`)}return t.length?" "+t.join(" "):""}return` ${String(e)}`}function ln(e){let n=Ie(e.machine);if(!m(n,e.level??"debug"))return;if(e.event==="TRACE"){console.log(`[vdom:${e.machine}] ${e.payload}`);return}let t=e.component?`${e.component}${e.nodeId?`(${e.nodeId})`:""}`:e.nodeId?`(${e.nodeId})`:"";console.log(`[vdom:${e.machine}] ${t?t+" ":""}${e.from} --${e.event}--> ${e.to}${rn(e.payload)}`)}tn(ln);var dn={fresh:{BUILD_START:"building",BUILD_DONE:"built",PRUNE:"pruned",DISPOSE:"disposed"},building:{BUILD_DONE:"built",DISPOSE:"disposed"},built:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},pruned:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},disposed:{BUILD_START:"building"}};function R(e){let n=0,t=e._parentVNode??null;for(let o=0;o<10&&t;o++)n++,t=t._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:n}}var Le=new Map,sn=50;function un(e,n,t,o){if(!e?.id)return;let i=Le.get(e.id);i||(i={name:e.name??"?",events:[]},Le.set(e.id,i)),i.events.push(`${n}--${t}-->${o}`),i.events.length>sn&&i.events.shift()}function P(e,n,t){let o=dn[e]?.[n]??null;return o==null?(w({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:"?",level:"warn",ts:Date.now()}),e):(un(t,e,n,o),w({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:o,payload:()=>({depth:t?.depth??0}),level:"debug",ts:Date.now()}),o)}function J(e){return!e||e._lifecycle==="disposed"||e._child==null?!1:!ge(e._child)}function ge(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e)){for(let t of e)if(ge(t))return!0;return!1}let n=e;return!!(n._lifecycle==="disposed"||n._child!=null&&ge(n._child))}var an=0;function U(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${an++}`}}function Me(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function cn(e,n,t,o){try{e(n)}catch(i){console.error(`[weifuwu] ref ${t} error in <${o??"anonymous"}>`,i)}}function b(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){let o=R(t);if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let i=[...n.unmountHooks];for(let r of i)r(t._id);if(t._customId)for(let r of i)r(t._customId)}t._id=null,t._customId=null,C(t)&&(t._render=null),t._parentNode=null,t._refNode=null,t._lifecycle=P(t._lifecycle,"DISPOSE",o)}else(C(t)||t._child!=null)&&(t._lifecycle=P(t._lifecycle,"DISPOSE",R(t)));if(t._child!=null){if(Array.isArray(t._child))for(let o of t._child)o&&typeof o=="object"&&b(o,n);else b(t._child,n);t._child=null}if(t.props?.children&&typeof t.type=="string"){let o=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let i of o)i&&typeof i=="object"&&b(i,n)}if(typeof t.props?.ref=="function"&&cn(t.props.ref,null,"cleanup"),S(t)){let o=t._remoteEl;if(o){let i=t._child;if(i!=null)if(Array.isArray(i))for(let r of i)r&&typeof r=="object"&&b(r,n);else typeof i=="object"&&b(i,n);o.remove(),t._remoteEl=null}}}function v(e){return typeof e=="function"&&e.name||"anonymous"}function je(e){return e.ui?._ctxVersion??0}function Ve(e,n){e.ui?.setMounting?.(n)}function g(e,n){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||K(e)){let o=n;if(o&&o.nodeType===8&&o.nodeValue?.includes("type=fragment-start")){let i=[o],r=/fid=([^\s"]+)/.exec(o.nodeValue)?.[1]??"",l=o.nextSibling;for(;l&&(i.push(l),!(l.nodeType===8&&l.nodeValue?.includes("type=fragment-end")&&(/fid=([^\s"]+)/.exec(l.nodeValue)?.[1]??r)===r));)l=l.nextSibling;return i}return null}let t=e;return C(t)?g(t._outputChild??t._child,n):null}function L(e){if(e==null||typeof e=="boolean")return"hole";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"arr";let n=e;return K(n)?"frag":S(n)?"portal":C(n)?"comp":"native"}function Ce(e){let n=!1,t=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){t=!0;continue}let i=o;S(i)||(i.key!=null?n=!0:t=!0)}return n&&t?"mixed":n?"keyed":"unkeyed"}function fn(e){if(e===!1)return"false";if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0)return"true";if(typeof e=="object")try{let n=JSON.stringify(e);return`object ${n!=null&&n.length>80?n.slice(0,80)+"\u2026":n??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function ae(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function Z(e){let n=[`type=${e.type}`];return e.value!==void 0&&n.push(`value=${ae(fn(e.value))}`),e.key!=null&&n.push(`key=${ae(e.key)}`),e.id!=null&&n.push(`id=${ae(e.id)}`),e.fid!=null&&n.push(`fid=${ae(e.fid)}`),`wf-hole: ${n.join(" ")}`}var pn=/^on[A-Z]/,yn=/^on[A-Z].*Capture$/;function _e(e){let n=yn.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var mn=new Set(["draggable","contenteditable","spellcheck","translate"]),Nn=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function we(e){return mn.has(e)?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":pn.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function De(e,n,t){if(t!==!1){if(t===!0){e.setAttribute(n,"");return}try{e[n]=t,e.getAttribute(n)!==String(t)&&e.setAttribute(n,String(t))}catch{e.setAttribute(n,String(t))}}}var hn={enumerated:(e,n,t)=>{e.setAttribute(n,t?"true":"false")},class:(e,n,t)=>{if(t!==!1)if(typeof t=="object")for(let[o,i]of Object.entries(t))i&&e.classList.add(o);else e.setAttribute("class",String(t))},style:(e,n,t)=>{if(t!==!1)if(typeof t=="string")e.setAttribute("style",t);else{let o=e.style;for(let[i,r]of Object.entries(t))r==null?o[i]="":i.startsWith("--")?o.setProperty(i,String(r)):typeof r=="number"&&!Nn.has(i)?o[i]=`${r}px`:o[i]=String(r)}},ref:(e,n,t)=>{if(typeof t=="function")try{t(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,n,t)=>{if(t===!1)return;let{type:o,capture:i}=_e(n);if(typeof t!="function"){console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof t} \u2014 ignored`);return}e.addEventListener(o,t,i?{capture:!0}:{})},value:(e,n,t)=>{t!==!1&&(e.value=t)},indeterminate:(e,n,t)=>{t!==!1&&(e.indeterminate=!!t)},innerHTML:(e,n,t)=>{t!==!1&&(e.innerHTML=String(t??""))},aria:(e,n,t)=>{if(t!==!1){if(typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}De(e,n,t)}},default:De};function q(e,n,t){t!=null&&hn[we(n)](e,n,t)}function H(e,n){return e.createComment(Z({type:"hole",value:n,key:null,id:null,fid:null}))}function te(){return!!globalThis?.__WF_VDOM_AUDIT}function gn(e,n){if(e===n)return!0;let t=Object.keys(e),o=Object.keys(n);if(t.length!==o.length)return!1;for(let i of t)if(e[i]!==n[i])return!1;return!0}async function Vn(e,n,t,o){let i=e;i._id||(o?.reuse?._id?i._id=o.reuse._id:i._id=t.nextId(),t.idRegistry.set(i._id,i)),o?.reuse&&(o.reuse._parentNode&&(i._parentNode=o.reuse._parentNode),o.reuse._refNode&&(i._refNode=o.reuse._refNode),o.reuse._ctxVersion!=null&&(i._ctxVersion=o.reuse._ctxVersion));let r=Object.create(n);r.ui=Object.create(n.ui);let l=r.ui;if(l._selfId=i._id??null,l._selfVNode=i,l.render=function(d){let u=n.ui;return d==null&&i._id?u.render([i._id]):u.render(d)},typeof i._render!="function"&&C(o?.reuse)&&typeof o.reuse._render=="function"&&(i._render=o.reuse._render),typeof i._render!="function"){Ve(n,!0);let d;try{d=await i.type(i.props??{},r)}finally{Ve(n,!1)}if(typeof d!="function")throw new Error(`Component ${v(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);i._render=d}return{renderFn:i._render,childCtx:r}}function be(e){return!!e&&typeof e.then=="function"}function B(e,n,t,o,i){return Cn[L(e)](e,n,t,o,i)}function xe(e,n){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===n.type?e:null}var Cn={hole:e=>e,text:e=>e,arr:_n,comp:wn,frag:bn,native:Oe,portal:Oe};function _n(e,n,t,o,i){let r=e;m("build")&&h("build","debug","",`array in kids=${A(r)}`);for(let s of r)if(s!=null&&typeof s=="object"&&!Array.isArray(s)&&s._lifecycle==="disposed"){let a=s;w({session:"",machine:"audit",nodeId:a._id??null,component:v(a.type),from:"disposed",event:"CONTRACT_VIOLATION",to:"new-tree",level:"error",ts:Date.now()}),te()&&console.error(`[vdom2/audit] \u4E24\u9636\u6BB5\u5951\u7EA6\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${v(a.type)} \u7684 renderFn \u8FD4\u56DE\u4E86 disposed \u65E7 vnode${a._id?`(${a._id})`:""}\u2014\u2014\u590D\u7528\u65E7\u6811\u5BF9\u8C61\uFF08\u5E94\u4E3A\u6BCF\u6B21\u6E32\u67D3\u751F\u6210\u65B0 vnode\uFF09\u3002\u540C\u4E00\u5BF9\u8C61\u65E2\u662F\u65E7\u6811\u53C8\u88AB dispose \u2192 diff \u81EA dispose \u2192 \u5361\u7247\u9519\u4F4D/\u6D88\u5931\uFF08demo \u641C\u7D22\u6062\u590D\u4E8B\u6545\uFF09`);break}for(let s=0;s<r.length;s++){let a=r[s];if(a!=null&&typeof a=="object"&&!Array.isArray(a)){let c=a;c.key!==null&&(c.key=String(c.key))}}let l=Array.isArray(t)?t:[],d=new Map;for(let s of l)s!=null&&typeof s=="object"&&!Array.isArray(s)&&s.key!=null&&d.set(s.key,s);let u=r.map((s,a)=>{let c=null;return s!=null&&typeof s=="object"&&!Array.isArray(s)&&s.key!=null&&(c=d.get(s.key)??null),c==null&&(c=l[a]??null),B(s,n,c,o,i)});m("build")&&h("build","debug","",`array out kids=${A(r)}`);let f=!1;for(let s=0;s<u.length;s++)if(be(u[s])){f=!0;break}return f?Promise.all(u).then(()=>r):r}function wn(e,n,t,o,i){let r=e,l=o??n.__registry??U(),d=xe(t,r);r._id||(r._id=d?._id??l.nextId(),l.idRegistry.set(r._id,r)),d&&(d._parentNode&&(r._parentNode=d._parentNode),d._refNode&&(r._refNode=d._refNode),d._ctxVersion!=null&&(r._ctxVersion=d._ctxVersion),C(r)&&C(d)&&typeof d._render=="function"&&(r._render=d._render));let u=gn(d?.props??{},r.props??{}),f=je(n),s=(d?._ctxVersion??-1)===f;if(!i?.force&&u&&s&&J(d)&&typeof r._render=="function"){let a=d;return r._lifecycle=P(r._lifecycle,"PRUNE",R(r)),r._child=a._child,r._ctxVersion=a._ctxVersion,m("build")&&h("build","debug","",`prune comp=${z(r)} propsSame=${u} verSame=${s}`),r}return r._lifecycle=P(r._lifecycle,"BUILD_START",R(r)),m("build")&&h("build","debug","",`mount comp=${z(r)} propsSame=${u} verSame=${s} force=${!!i?.force}`),(async()=>{let{childCtx:a}=await Vn(r,n,l,{reuse:d??null}),c=await B(await r._render(r.props),a,d?._child,l,i);return r._child=c??null,r._ctxVersion=f,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r})()}function bn(e,n,t,o,i){let r=e,l=o??n.__registry??U(),d=xe(t,r);m("build")&&h("build","debug","",`fragment kids=${A(_(r.props?.children))}`);let u=B(r.props?.children??null,n,d?._child??d?.props?.children,l,i);return be(u)?u.then(f=>(r._child=f??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)):(r._child=u??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)}function Oe(e,n,t,o,i){let r=e;if(typeof r.type!="string"&&typeof r.type!="symbol")return r;let l=o??n.__registry??U(),d=xe(t,r);m("build")&&h("build","trace","",`native <${String(r.type)}> kids=${A(_(r.props?.children))}`);let u=B(r.props?.children??null,n,d?.props?.children,l,i);return be(u)?u.then(f=>(r._child=f??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)):(r._child=u??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)}function V(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,queryAll:e=>typeof document<"u"?document.querySelectorAll(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,createElementNS:(e,n)=>typeof document<"u"?document.createElementNS(e,n):null,createDocumentFragment:()=>typeof document<"u"?document.createDocumentFragment():null,createComment:e=>typeof document<"u"?document.createComment(e):null,createTextNode:e=>typeof document<"u"?document.createTextNode(e):null,addEventListener:(e,n,t)=>{typeof window<"u"&&window.addEventListener(e,n,t)},removeEventListener:(e,n,t)=>{typeof window<"u"&&window.removeEventListener(e,n,t)},scrollTo:e=>{typeof window<"u"&&window.scrollTo(0,e)},matchMedia:e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e):null,visualViewport:()=>(typeof window<"u"?window:null)?.visualViewport??null,scrollingElement:()=>typeof document<"u"?document.scrollingElement:null,bodyElement:()=>typeof document<"u"?document.body:null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},clearBody:()=>{typeof document<"u"&&(document.body.innerHTML="")},event:(e,n)=>{let t=typeof window<"u"?window:null,o=n&&(n.key||n.code)?"KeyboardEvent":n&&(n.clientX!==void 0||n.clientY!==void 0||n.pointerId!==void 0)?"PointerEvent":"Event";try{return new t[o](e,n)}catch{return new t.Event(e,n)}},dispatchEvent:(e,n)=>typeof e<"u"?e.dispatchEvent(n):!1,navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,viewportWidth:()=>typeof window<"u"?window.innerWidth:0,pathname:()=>typeof window<"u"?window.location.pathname:"",createTreeWalker:(e,n)=>typeof document<"u"?document.createTreeWalker(e,n??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}var xn=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function Q(e,n){return H(e,n)}function E(e,n,t,o=null,i=null,r=null){let l=n?.browser??t;if(!l)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return $n[L(e)](e,n,l,o,i,r)}function vn(e,n,t){return null}function En(e,n,t){return t.createTextNode(String(e))}function ve(e,n,t,o,i){if(e==null||typeof e=="boolean")return Q(t,e);let r=E(e,n,t,String(o),null,i);return r??Q(t,null)}function Sn(e,n,t,o=null,i=null,r=null){let l=e,d=t.createDocumentFragment();if(!d)return null;m("render")&&h("render","debug","",`array kids=${A(l)} fid=${r??"-"} key=${o??"-"}`);let u=t.createComment(Z({type:"fragment-start",key:o,id:i,fid:r})),f=t.createComment(Z({type:"fragment-end",key:o,id:i,fid:r}));u&&d.appendChild(u);for(let s=0;s<l.length;s++){let a=l[s],c=r!=null?`${r}-${s}`:String(s),p=ve(a,n,t,s,c);p!=null&&d.appendChild(p)}return f&&d.appendChild(f),d}function An(e,n,t){let o=e,i=o,r=t.bodyElement();if(!r)return null;let l=r.querySelector("#__wf_portal");l||(l=t.createElement("div"),l&&(l.id="__wf_portal",r.appendChild(l)));let d=t.createElement("div");if(d){d.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let u=E(o.props?.children??null,n,t);u!=null&&d.appendChild(u),l&&l.appendChild(d),i._remoteEl=d;let f=_(o.props?.children);for(let s of f)s!=null&&typeof s=="object"&&!Array.isArray(s)&&(s._parentVNode=o)}return null}function kn(e,n,t,o=null,i=null,r=null){let l=e,d=l,u=t.createDocumentFragment();if(!u)return null;let f=_(l.props?.children);m("render")&&h("render","debug","",`fragment kids=${A(f)} fid=${r??"-"}`);let s=t.createComment(Z({type:"fragment-start",key:o,id:i,fid:r})),a=t.createComment(Z({type:"fragment-end",key:o,id:i,fid:r}));s&&u.appendChild(s),d._refNode=s;for(let c=0;c<f.length;c++){let p=f[c],y=r!=null?`${r}-${c}`:String(c),N=ve(p,n,t,c,y);N!=null&&u.appendChild(N)}return a&&u.appendChild(a),u}function Tn(e,n,t){let o=e,i=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return Rn[i](o,n,t)}var Rn={fresh:(e,n,t)=>{throw new Error(`[vdom2] component ${v(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,n,t)=>{throw new Error(`[vdom2] component ${v(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,n,t)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${v(e.type)} \u5728\u6E32\u67D3\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`),Q(t,null)),built:He,pruned:He};function He(e,n,t){let o=e._child;if(o==null)return e._child=null,null;e._child=o,e._outputChild=o,typeof o=="object"&&!Array.isArray(o)&&(o._parentVNode=e);let i=E(o,n,t);if(i){if(e._refNode=i.nodeType===11?i.firstChild:i,e._id)if(i.nodeType===11)for(let r of Array.from(i.childNodes))r.nodeType===1&&r.setAttribute("data-wf-id",e._id);else i.nodeType===1&&i.setAttribute("data-wf-id",e._id);if(e.key!=null)if(i.nodeType===11)for(let r of Array.from(i.childNodes))r.nodeType===1&&r.setAttribute("data-wf-key",e.key);else i.nodeType===1&&i.setAttribute("data-wf-key",e.key)}return i}function Pn(e,n,t,o,i){let r=e,l=r,d=r.type,u=xn.has(d)?t.createElementNS("http://www.w3.org/2000/svg",d):t.createElement(d);if(!u)return null;l.el=u,l._refNode=u,m("render")&&h("render","trace","",`native <${d}> key=${r.key??"-"} kids=${A(_(r.props?.children))}`),r.key!=null&&u.setAttribute("data-wf-key",r.key);let f=null;for(let[s,a]of Object.entries(r.props??{}))if(!(s==="children"||s==="key")){if(s==="value"&&u instanceof HTMLSelectElement){f=a;continue}q(u,s,a)}if(!("innerHTML"in(r.props??{}))){let s=_(r.props?.children);for(let a=0;a<s.length;a++){let c=s[a],p=i!=null?`${i}-${a}`:String(a),y=ve(c,n,t,a,p);if(y!=null&&(u.appendChild(y),c&&typeof c=="object"&&!Array.isArray(c)&&typeof c.type=="function")){let N=c;N._parentNode||(N._parentNode=u)}}m("render")&&h("render","trace","",`native <${d}> out=${O(u)}`)}return f!==null&&(u.value=String(f)),u}var $n={hole:vn,text:En,arr:Sn,portal:An,frag:kn,comp:Tn,native:Pn};function F(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=E(e.newInput,i,i.browser??V());if(r==null)return null;if(t?.parentNode){let l=oe(o,t,n,i);return l&&l.parentNode===n?n.insertBefore(r,l):n.appendChild(r),r}return n.appendChild(r),r}function In(e){return oe(e.oldInput,e.oldNode,e.parent,e.ctx),null}function Ln(e){let n=e.oldNode;if(n?.nodeType===8){let t=Q(e.ctx.browser??V(),e.newInput);return t&&n.nodeValue!==t.nodeValue&&(n.nodeValue=t.nodeValue),n}return null}function ee(e){let{parent:n,oldNode:t,ctx:o}=e,i=E(e.newInput,o,o.browser??V());return i==null?null:(t?.parentNode?t.parentNode.replaceChild(i,t):t?n.insertBefore(i,t):n.appendChild(i),i)}function Mn(e){let{parent:n,oldNode:t,oldInput:o}=e,i=String(e.newInput);if(String(o)!==i){if(t&&t.nodeType===3)return t.nodeValue=i,t;let r=n.ownerDocument.createTextNode(i);return t?.parentNode?t.parentNode.replaceChild(r,t):n.appendChild(r),r}return t}function jn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput,l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=r.type;if(t&&t.nodeType===1&&(l?.type??null)===d&&ke(r)){let u=t;return r.el=u,r._refNode=u,Fe(u,l?.props??{},r.props??{}),"innerHTML"in(r.props??{})||re(u,l?._child??l?.props?.children??null,r._child??r.props?.children??null,i),u}return F(e)}function Dn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput,l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=K(l)?g(l,t):null,u=Ee(n,l??o,r,i,d);return t?.parentNode?t:u[0]??null}function On(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput;if(!C(r)||typeof r._render!="function")throw new Error(`[vdom2] component ${v(r.type)} not built in diff \u2014 buildVNode must run before patchValue`);let l=o&&typeof o=="object"&&!Array.isArray(o)?o:null;if(l?.type!=null&&l.type!==r.type)return F(e);let d=l?.type===r.type;if(!i.force&&l&&d&&J(l)&&r._child===l._child)return t;l?.type===r.type&&l._id&&(r._id=l._id,i.registry.idRegistry.set(r._id,r)),r._parentNode=n,t&&(r._refNode=t);let u=r._child;if(u===null){r._outputChild=null,r._refNode=null;let s=t?.parentNode!=null,a=oe(l?._child??null,t,n,i);l&&(l._child=null);let c=Q(i.browser??V(),null);return s&&c?(a&&a.parentNode===n?n.insertBefore(c,a):n.appendChild(c),c):W(n,t,l?._child,null,i)}r._outputChild=u;let f=W(n,t,l?._child,u,i);return f&&(r._refNode=f),f}function Hn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e;if(o===e.newInput&&t?.parentNode)return t;let r=n.ownerDocument.createDocumentFragment(),l=re(n,o,e.newInput,i,t?[t]:null);for(let d of l)d&&r.appendChild(d);return t?.parentNode?r.contains(t)?n.appendChild(r):t.parentNode.replaceChild(r,t):n.appendChild(r),r}function Bn(e){let{ctx:n,oldInput:t}=e,o=e.newInput,i=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(S(i)&&S(o)){let r=i._remoteEl;if(r){let l=i._child??i.props?.children??null,d=o._child??o.props?.children??null;re(r,l,d,n)}return o._remoteEl=i._remoteEl,null}return F(e)}function G(e){return{text:F,native:F,frag:F,comp:F,arr:F,hole:In,portal:F,...e}}var Fn={text:G({text:Mn}),hole:G({text:ee,native:ee,frag:ee,comp:ee,arr:ee,portal:ee,hole:Ln}),native:G({native:jn}),frag:G({frag:Dn}),comp:G({comp:On}),arr:G({arr:Hn}),portal:G({portal:Bn})};function Be(e){let n=L(e.oldInput),t=L(e.newInput);return w({session:"",machine:"x2y",nodeId:null,component:null,from:n,event:"X2Y",to:t,level:"trace",ts:Date.now()}),Fn[n][t](e)}function M(e,n){if(n&&typeof e.type=="function"&&e._id){try{b(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}Me(n,e._id)}}function se(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let n=e;return S(n)?typeof n.props?.portalKey=="string"?n.props.portalKey:null:n.key}function Se(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)){let t=g(e,n);if(t&&t.length>1)return t}return[n]}function ce(e,n){let t=_(e.props?.children);for(let o of t){if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o;Kn[L(i)](i,n)}}var Kn={comp:(e,n)=>{M(e,n)},frag:(e,n)=>{ce(e,n)},native:(e,n)=>{ce(e,n)},portal:(e,n)=>{ce(e,n)},arr:()=>{},text:()=>{},hole:()=>{}};function oe(e,n,t,o){return Un[L(e)](e,n,t,o)}var Un={arr:(e,n,t,o)=>{let i=g(e,n);if(i&&i.length){let r=(i[i.length-1]??n)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return r&&r.parentNode===t?r:null}return ie(e,n,t,o)},frag:(e,n,t,o)=>{let i=e,l=g(i,n)??[],d=(l[l.length-1]??n)?.nextSibling??null;for(let u of l)u.parentNode&&u.parentNode.removeChild(u);return ce(i,o.registry),d&&d.parentNode===t?d:null},portal:(e,n,t,o)=>{let i=e,r=i._remoteEl;try{b(i.props?.children,o.registry)}catch(l){console.error("[weifuwu] portal ref cleanup error",l)}return r?.parentNode?.removeChild(r),null},comp:(e,n,t,o)=>{let i=e,r=g(i,n);if(M(i,o.registry),r&&r.length>1){let l=(r[r.length-1]??n)?.nextSibling??null;for(let d of r)d.parentNode&&d.parentNode.removeChild(d);return l&&l.parentNode===t?l:null}return ie(e,n,t,o)},native:(e,n,t,o)=>{try{b(e,o.registry)}catch(i){console.error("[weifuwu] ref cleanup error",i)}return ie(e,n,t,o)},text:(e,n,t,o)=>ie(e,n,t,o),hole:(e,n,t,o)=>ie(e,n,t,o)};function ie(e,n,t,o){let i=n?.nextSibling??null;return n?.parentNode&&n.parentNode.removeChild(n),i&&i.parentNode===t?i:null}function W(e,n,t,o,i){return Be({parent:e,oldNode:n,oldInput:t,newInput:o,ctx:i})}var qn={event:(e,n,t,o)=>{let{type:i,capture:r}=_e(n);typeof t=="function"&&e.removeEventListener(i,t,r?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(i,o,r?{capture:!0}:{}))},class:(e,n,t,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",q(e,n,o))},ref:(e,n,t,o)=>{if(o==null||o===!1){if(typeof t=="function")try{t(null)}catch(i){console.error("[weifuwu] ref cleanup error",i)}}else q(e,n,o)},value:(e,n,t,o)=>{o==null||o===!1?e.value="":q(e,n,o)},indeterminate:(e,n,t,o)=>{o==null||o===!1?e.indeterminate=!1:q(e,n,o)},enumerated:le,style:le,innerHTML:le,aria:le,default:le};function le(e,n,t,o){if(o==null||o===!1){e.removeAttribute(n);try{delete e[n]}catch{}}else q(e,n,o)}function Fe(e,n,t){let o=Object.keys(n),i=Object.keys(t);if(o.length===i.length){let l=!0;for(let d=0;d<o.length;d++)if(o[d]!==i[d]||n[o[d]]!==t[o[d]]){l=!1;break}if(l)return}let r=new Set([...o,...i]);for(let l of r){if(l==="children"||l==="key")continue;let d=n[l],u=t[l];d!==u&&qn[we(l)](e,l,d,u)}}function Ee(e,n,t,o,i){let r=Array.isArray(n)?n:n?._child??n?.props?.children??null,l=Array.isArray(t)?t:t?._child??t?.props?.children??null;return re(e,r,l,o,i)}function re(e,n,t,o,i,r){let l=_(n),d=_(t),u=i??Array.from(e.childNodes);m("diff")&&h("diff","debug","",`patchChildren parent=${k(e)} old=${A(l)} new=${A(d)} dom=${O(e)}`);let f=d.some(p=>Array.isArray(p))||l.some(p=>Array.isArray(p)),s=f?"unkeyed":Ce(d);if(w({session:"",machine:"keys",nodeId:null,component:null,from:f?"unkeyed":Ce(d),event:"SELECT",to:s,payload:()=>({len:d.length}),level:"trace",ts:Date.now()}),te()&&l.length!==d.length)for(let p=0;p<d.length;p++){let y=d[p];y!=null&&typeof y=="object"&&!Array.isArray(y)&&C(y)&&y.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${p} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\u2014\u2014\u5217\u8868\u589E\u5220/\u91CD\u6392\u4F1A\u9519\u4F4D\u7EC4\u4EF6\u5B9E\u4F8B\u72B6\u6001\u3002\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u8EAB\u4EFD key\uFF08\u5982 key={item.id}\uFF09\uFF1B\u65E0\u72B6\u6001 native \u9879\u8C41\u514D\u3002`)}let a=i&&i.length?i[i.length-1]:null;s==="mixed"&&(fe(d),fe(l));let c=(()=>{let p=u;p.length>=2&&p[0]?.nodeType===8&&p[0].nodeValue?.includes("fragment-start")&&p[p.length-1]?.nodeType===8&&p[p.length-1].nodeValue?.includes("fragment-end")&&(p=p.slice(1,-1));let y=[],N=0;for(let T=0;T<l.length;T++){let x=l[T];if(Array.isArray(x)){let j=p[N]??null;y.push(j);let D=g(x,j);N+=D?.length??1;continue}if(x==null||typeof x=="boolean"||typeof x=="string"||typeof x=="number"){y.push(p[N]??null),N++;continue}let $=x;if(S($)){y.push($._remoteEl??null);continue}if(y.push($._refNode??p[N]??null),typeof $.type=="function"||K($)){let j=g($,$._refNode??p[N]??null);N+=j?.length??1}else N++}return y})();return ct[s]({parent:e,oldChildren:l,newChildren:d,oldNodes:c,ctx:o,arrEnd:a,anchorOut:r})}function de(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&K(e)?"multi":"real"}function Wn(e){let{parent:n,oldC:t,oldNode:o,oldNodes:i,i:r,ctx:l,out:d,pushA:u}=e;if(Array.isArray(t)){m("diff")&&h("diff","trace","",`remove-arr-item i=${r} range=[${(g(t,i[r])??[]).map(k).join(" | ")}] before=${O(n)}`);let f=g(t,o);for(let s of f??[])s.parentNode?.removeChild(s);m("diff")&&h("diff","trace","",`remove-arr-item after=${O(n)}`);for(let s of t)s!=null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"&&M(s,l.registry)}else if(t&&typeof t=="object"&&!Array.isArray(t)){if(typeof t.type=="function")M(t,l.registry);else try{b(t,l.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);d.push(null),u(null)}function zn(e){let{parent:n,newC:t,oldNode:o,i,oldNodes:r,out:l,pushA:d,ctx:u}=e,f=H(u.browser??V(),t);if(o?.nodeType===8){f&&o.nodeValue!==f.nodeValue&&(o.nodeValue=f.nodeValue),l.push(o),d(o);return}if(f&&o?.parentNode)o.parentNode.replaceChild(f,o);else if(f){let s=null;for(let a=i+1;a<r.length;a++){let c=r[a];if(c&&c.parentNode===n){s=c;break}}if(!s){let a=null;for(let c=l.length-1;c>=0;c--)if(l[c]){a=l[c];break}a&&a.parentNode===n&&(s=a.nextSibling)}s&&s.parentNode===n?n.insertBefore(f,s):n.appendChild(f),l.push(f),d(f)}else l.push(f),d(f)}function Ke(e){let{parent:n,newC:t,oldNode:o,i,oldNodes:r,out:l,pushA:d,ctx:u}=e,f=E(t,u,u.browser??V(),String(i));if(f==null){l.push(null),d(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){w({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"HOLE_FILL",to:"real",payload:()=>({i,replaced:k(o)}),level:"trace",ts:Date.now()}),o.parentNode?.replaceChild(f,o),l.push(f),d(f);return}let s=null;for(let a=i+1;a<r.length;a++){let c=r[a];if(c&&c.parentNode===n){s=c;break}}if(s==null){let a=null;for(let c=l.length-1;c>=0;c--)if(l[c]){a=l[c];break}if(a&&a.parentNode===n)s=a.nextSibling;else{let c=r[r.length-1];c&&c.parentNode===n&&(s=c.nextSibling)}}s&&s.parentNode===n?n.insertBefore(f,s):n.appendChild(f),w({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"INSERT",to:"real",payload:()=>({i,insertedBefore:s?k(s):"END",node:k(f)}),level:"trace",ts:Date.now()}),l.push(f),d(f)}function Gn(e){let{parent:n,oldC:t,newC:o,oldNode:i,out:r,pushA:l,ctx:d}=e;if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.type=="function"){let f=We(n,t,i,o,d);r.push(f),l(f);return}let u=ze(n,t,i,o,d);r.push(u),l(u)}function Xn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,out:l,pushA:d,ctx:u}=e,f=u.browser??V(),s=E(o,u,f,String(r));if(s==null){l.push(null),d(null);return}let a=t&&typeof t=="object"?g(t,i):null;if(a&&a.length>1){let p=(a[a.length-1]??i)?.nextSibling??null;for(let y of a)y.parentNode&&y.parentNode.removeChild(y);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")M(t,u.registry);else try{b(t,u.registry)}catch(y){console.error("[weifuwu] ref cleanup error",y)}p&&p.parentNode===n?n.insertBefore(s,p):n.appendChild(s)}else i?.parentNode?i.parentNode.replaceChild(s,i):n.appendChild(s);let c=s.nodeType===11?Array.from(s.childNodes):[s];l.push(...c),d(c[0]??s)}function Yn(e){let{parent:n,oldC:t,newC:o,oldNode:i,out:r,pushA:l,ctx:d}=e,u=qe(n,t,i,o,d);r.push(u),l(u)}function Jn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,oldNodes:l,out:d,pushA:u,ctx:f}=e,s=f.browser??V(),a=g(t,i);m("diff")&&h("diff","debug","",`multi-remove i=${r} range=${a?a.map(k).join(" | "):"null"}`);for(let y of a??[])y.parentNode?.removeChild(y);for(let y of _(t?.props?.children))y!=null&&typeof y=="object"&&!Array.isArray(y)&&typeof y.type=="function"&&M(y,f.registry);let c=E(o,f,s,String(r));if(c==null){d.push(null),u(null);return}let p=l[r+1]??null;p?.parentNode?p.parentNode.insertBefore(c,p):n.appendChild(c),d.push(c),u(c)}function Zn(e){let{parent:n,oldC:t,newC:o,oldNode:i,oldNodes:r,i:l,out:d,pushA:u,ctx:f}=e,s=g(t,i),a=Ee(n,t,o,f,s);d.push(...a),u(r[l]??a[0]??null)}function Qn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,out:l,pushA:d,ctx:u}=e;if(o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.type=="function"&&o._lifecycle==="disposed"){let a=Xe(n,i,u,v(o.type));l.push(a),d(a);return}let f=W(n,i,t,o,u);m("diff")&&h("diff","trace","",`after-patch i=${r} new=${z(o)} node=${k(f)} dom=${O(n)}`);let s=Se(o,f);l.push(...s),d(s[0]??f??null)}function qe(e,n,t,o,i){let r=H(i.browser??V(),o),l=g(n,t),d=((l??[])[l?.length?l.length-1:0]??t)?.nextSibling??null;for(let u of l??[])u.parentNode?.removeChild(u);for(let u of _(n?.props?.children))u!=null&&typeof u=="object"&&!Array.isArray(u)&&typeof u.type=="function"&&M(u,i.registry);return r&&d&&d.parentNode===e?e.insertBefore(r,d):r&&e.appendChild(r),r}function We(e,n,t,o,i){let r=H(i.browser??V(),o),l=oe(n,t,e,i);return r&&l?e.insertBefore(r,l):r&&e.appendChild(r),r}function ze(e,n,t,o,i){let r=H(i.browser??V(),o);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")M(n,i.registry);else try{b(n,i.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}return r&&t?.parentNode?t.parentNode.replaceChild(r,t):r&&e.appendChild(r),r}var et={hole:{hole:zn,real:Ke,multi:Ke},real:{hole:Gn,real:Qn,multi:Xn},multi:{hole:Yn,real:Jn,multi:Zn}};function nt(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,anchorOut:l}=e,d=Math.max(t.length,o.length),u=[],f=s=>{l&&l.push(s)};for(let s=0;s<d;s++){let a=s<t.length?t[s]:null,c=s<o.length?o[s]:null;if(s>=o.length){Wn({parent:n,oldC:a,newC:c,oldNode:i[s],i:s,oldNodes:i,newChildren:o,out:u,pushA:f,ctx:r});continue}if(a!=null&&typeof a=="object"&&!Array.isArray(a)&&c!=null&&typeof c=="object"&&!Array.isArray(c)&&c===a&&J(a)){u.push(i[s]),f(i[s]);continue}let p=et[de(a)][de(c)];w({session:"",machine:"pos",nodeId:null,component:null,from:de(a),event:p.name,to:de(c),payload:()=>({i:s}),level:"trace",ts:Date.now()}),p({parent:n,oldC:a,newC:c,oldNode:i[s],i:s,oldNodes:i,newChildren:o,out:u,pushA:f,ctx:r})}return u}function Ue(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,anchorOut:l,arrEnd:d}=e,u=new Map;t.forEach((p,y)=>{let N=se(p);N!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&u.set(N,{vnode:p,nodes:[i[y]??null].filter(Boolean),index:y})});let f=[],s=new Set,a=p=>{l&&l.push(p)},c=null;return o.forEach((p,y)=>{let N=se(p),T=p;if(N!==null&&u.has(N)){let x=u.get(N),$=x.nodes[0]??null;if(s.add(N),T&&typeof T=="object"&&typeof T.type=="function"&&T._lifecycle==="disposed"){let X=Xe(n,$,r,v(T.type));f.push(X),a(X),X&&(c=X);return}let j=W(n,$,x.vnode,T,r),D=Se(T,j),ye=D[0]??j,Ae=D[D.length-1]??j;if(ye&&ye.parentNode===n&&c&&ye.previousSibling!==c){m("diff")&&h("diff","debug","",`keyed-correct i=${y} k=${N} move=[${D.map(k).join(" | ")}] after=${k(c)} before=${O(n)}`);let X=c.nextSibling;for(let me of D)me&&me.parentNode===n&&n.insertBefore(me,X);m("diff")&&h("diff","debug","",`keyed-correct after=${O(n)}`)}f.push(...D),a(D[0]??j??null),Ae&&(c=Ae)}else{let x={current:c};dt[lt(p)]({parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,out:f,pushA:a,arrEnd:d,c:p,i:y},x),c=x.current}}),t.forEach((p,y)=>{ot[tt(se(p),s)](n,p,y,i,r,o.length)}),f}function tt(e,n){return e===null?"unkeyed":n.has(e)?"moved":"stale-keyed"}var ot={moved:()=>{},"stale-keyed":rt,unkeyed:it};function rt(e,n,t,o,i){let r=n&&typeof n=="object"&&!Array.isArray(n)?g(n,o[t]):null;if(m("diff")&&h("diff","trace","",`keyed-delete i=${t} k=${se(n)} range=${r?.length??0} oldNode=${k(o[t])}`),n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")M(n,i.registry);else try{b(n,i.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}Ge(r,o[t])}function it(e,n,t,o,i,r){let l=o[t];if(l?.nodeType===8&&l.nodeValue?.includes("type=hole")&&t<r)return;if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")M(n,i.registry);else try{b(n,i.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}let u=n&&typeof n=="object"&&!Array.isArray(n)?g(n,l):null;Ge(u,l)}function Ge(e,n){if(e&&e.length>1)for(let t of e)t.parentNode&&t.parentNode.removeChild(t);else n?.parentNode&&n.parentNode.removeChild(n)}function lt(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&S(e)?"portal":"real"}var dt={hole:st,portal:ut,real:at};function st(e,n){let{parent:t,oldChildren:o,oldNodes:i,ctx:r,out:l,pushA:d,c:u,i:f}=e,s=o[f]??null,a=i[f]??null,c=de(s);if(c==="hole"){let y=H(r.browser??V(),u);a?.nodeType===8?(y&&a.nodeValue!==y.nodeValue&&(a.nodeValue=y.nodeValue),l.push(a),d(a),a&&(n.current=a)):(y&&a?.parentNode?a.parentNode.replaceChild(y,a):y&&t.appendChild(y),l.push(y),d(y),y&&(n.current=y));return}let p=c==="multi"?qe(t,s,a,u,r):s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"?We(t,s,a,u,r):ze(t,s,a,u,r);l.push(p),d(p),p&&(n.current=p)}function ut(e,n){let{parent:t,oldChildren:o,oldNodes:i,ctx:r,out:l,pushA:d,c:u,i:f}=e,s=u,a=o[f]??null,c=W(t,i[f]??null,a,s,r),p=Se(s,c);l.push(...p),d(p[0]??c??null);let y=p[p.length-1]??c;y&&(n.current=y)}function at(e,n){let{parent:t,oldNodes:o,ctx:i,out:r,pushA:l,arrEnd:d,c:u,i:f}=e,a=E(u,i,i.browser??V());if(r.push(a),l(a??null),a!=null){let c=o[f];c&&c.nodeType===8&&c.nodeValue?.includes("type=hole")?(c.parentNode?.replaceChild(a,c),n.current=a):(n.current?t.insertBefore(a,n.current.nextSibling):d&&d.parentNode===t?t.insertBefore(a,d):t.insertBefore(a,t.firstChild),n.current=a)}}function fe(e){for(let n=0;n<e.length;n++){let t=e[n];t&&typeof t=="object"&&!Array.isArray(t)&&se(t)===null&&(t.key=`pos:${n}`)}}function Xe(e,n,t,o){te()?console.error(`[vdom2/audit] I1 \u8FDD\u53CD\uFF1Adiff \u6536\u5230 disposed \u7EC4\u4EF6 ${o}\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\uFF08portal \u5185\u5BB9\u72EC\u7ACB dispose\uFF09\u2014\u2014\u7236\u6811\u5C06\u91CD\u5EFA`):console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${o} \u5728 diff\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`);let i=H(t.browser??V(),null);if(i==null)return null;let r=n;if(r){let l=r.parentNode;l?l.replaceChild(i,r):e.appendChild(i)}else e.appendChild(i);return i}var ct={unkeyed:nt,keyed:Ue,mixed:e=>(fe(e.newChildren),fe(e.oldChildren),Ue(e))};function Ye(e,n,t,o){let i=t,r=i.__registry??U(),l=i.browser??V();return Promise.resolve(B(n,i,null,r)).then(()=>{let d=E(n,i,l);if(d!=null&&e.appendChild(d),n._id&&r){let u=r.idRegistry.get(n._id);u&&(u._parentNode=e)}o?.onMounted?.()}).catch(d=>console.error("[vdom2] command mount error",d)),{id:n._id??""}}function jo(e,n,t){return new Promise(o=>{Ye(e,n,t,{onMounted:o})})}async function Do(e,n,t,o,i){return await B(o,i,t,i.__registry),W(e,n,t,o,{browser:i.browser??i.__browser,registry:i.__registry})}function Oo(e,n){let t=n.__registry??(n.__registry=U());return Promise.resolve(B(e,n,void 0,t))}async function Ho(e,n,t){let o=await e(n,t);return typeof o=="function"?o(n):o}async function Bo(e,n,t){let o=await e(n,t);return()=>typeof o=="function"?o(n):o}function pe(e,n){if(e==null||typeof e!="object")return;if(Array.isArray(e)){for(let o of e)pe(o,n);return}n(e);let t=e?.props?.children;t!=null&&pe(t,n)}function Fo(e,n){let t;return pe(e,o=>{!t&&n(o)&&(t=o)}),t}function Ko(e,n){let t=[];return pe(e,o=>{typeof o?.props?.class=="string"&&o.props.class.split(" ").includes(n)&&t.push(o)}),t}function Uo(e){let n={ui:{render:()=>{},ready:!0,useExternal:()=>{}}};return e?{ui:{...n.ui,...e.ui??{}},...e.browser?{browser:e.browser}:{}}:n}function qo(e=()=>!1,n){return{get open(){return e()},setOpen:n??(t=>{}),refresh:()=>{},portal:(t,o)=>e()?t:null,wrapProps:{}}}export{Oo as buildToDom,qo as createPopupMock,Uo as createTestCtx,Ko as findByClass,Fo as findVNode,Bo as mountComponent,jo as mountToDom,Do as patchToDom,Ho as renderVNode,pe as walkVNode};
|
|
@@ -15,6 +15,8 @@ import type { VNodeChild } from '../vnode.ts';
|
|
|
15
15
|
import { type VKind } from './kind.ts';
|
|
16
16
|
/** audit 开关(dev/测试注入;生产默认关) */
|
|
17
17
|
export declare function auditEnabled(): boolean;
|
|
18
|
+
/** 安装挂载不变量 audit(uiServe 初始化时调用一次——订阅事件流而非遍历 DOM) */
|
|
19
|
+
export declare function installMountInvariantAudit(): void;
|
|
18
20
|
/** 数组级校验:childNodes 与 children 数组对齐(A1/A2——占位错位/数量错位) */
|
|
19
21
|
export declare function auditChildren(parent: Node, children: VNodeChild[] | null, report: (msg: string) => void): void;
|
|
20
22
|
/** 树级校验:vnode 树 ↔ DOM 树递归对照(A3/A4)——入口分派 AUDITERS[classifyKind(child)] 查表 */
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom/events — 统一状态机事件总线
|
|
3
|
+
*
|
|
4
|
+
* 状态机管"转换"(route/lifecycle/x2y/keys/pos),事件总线管"观测":
|
|
5
|
+
* 所有状态转换统一发射结构化 VdomEvent,多路 sink 消费——
|
|
6
|
+
* - console sink:人类可读(复用 trace 阶段开关,格式兼容旧 trace 输出)
|
|
7
|
+
* - ring buffer sink:内存最近 N 条(__vdom_events(n) 查询——事故现场可追溯)
|
|
8
|
+
* - collect sink:测试断言(makeEventCollector——事件序列断言,过程级而非结果级)
|
|
9
|
+
* - audit sink:不变量校验器(订阅事件流而非事后遍历 DOM——阶段 2)
|
|
10
|
+
*
|
|
11
|
+
* 事件 = "决策记录"(同步、纯,不执行 DOM);执行层(appendChild/坐标计算)不进事件流。
|
|
12
|
+
* 性能:emit 首行检查——无观测者或 trace 关闭时仅一次布尔比较;payload 支持惰性函数
|
|
13
|
+
* (高频 diff 事件只在有消费者需要时才求值,避免 vnDesc/nodeDesc 的字符串成本)。
|
|
14
|
+
*/
|
|
15
|
+
import { type VdomLevel, type VdomStage } from './trace.ts';
|
|
16
|
+
/** 状态机名(事件来源)——含执行细节摘要通道(build/render/diff/mount——trace 包装) */
|
|
17
|
+
export type VdomMachine = 'route' | 'lifecycle' | 'x2y' | 'keys' | 'pos' | 'render' | 'audit' | 'build' | 'mount' | 'diff';
|
|
18
|
+
export declare function machineToStage(m: VdomMachine): VdomStage;
|
|
19
|
+
/** 统一状态机事件(一次渲染会话的全部转换通过 session 关联) */
|
|
20
|
+
export interface VdomEvent {
|
|
21
|
+
/** 渲染会话 id(R{n}——同一渲染的 build/render/diff 事件共享;阶段 2 接入贯穿) */
|
|
22
|
+
session: string;
|
|
23
|
+
machine: VdomMachine;
|
|
24
|
+
/** 关联 vnode id(_id——按实例过滤/追溯) */
|
|
25
|
+
nodeId: string | null;
|
|
26
|
+
/** 组件名/类型名(尽力) */
|
|
27
|
+
component: string | null;
|
|
28
|
+
from: string;
|
|
29
|
+
event: string;
|
|
30
|
+
to: string;
|
|
31
|
+
/** 附加数据(key/i/path 等)——可传函数惰性求值(高频路径零字符串成本) */
|
|
32
|
+
payload?: unknown;
|
|
33
|
+
/** 输出级别(console sink 门控;默认 debug) */
|
|
34
|
+
level?: VdomLevel;
|
|
35
|
+
ts: number;
|
|
36
|
+
}
|
|
37
|
+
export type EventSink = (ev: VdomEvent) => void;
|
|
38
|
+
/** 注册事件 sink(返回退订函数) */
|
|
39
|
+
export declare function onVdomEvent(sink: EventSink): () => void;
|
|
40
|
+
/** 开始渲染会话(renderOne/renderPath 入口调用)——期间所有 emit 共享 session */
|
|
41
|
+
export declare function beginSession(tag?: string): string;
|
|
42
|
+
/** 结束渲染会话(renderOne/renderPath 出口调用) */
|
|
43
|
+
export declare function endSession(): void;
|
|
44
|
+
/** 当前会话 id(空 = 无会话——事件流外直接 emit) */
|
|
45
|
+
export declare function currentSession(): string;
|
|
46
|
+
/** payload 惰性求值 + 分发(sink 错误隔离——不中断渲染管线)
|
|
47
|
+
* session:事件显式传入优先,否则继承当前渲染会话(一次渲染 = 一棵事件树) */
|
|
48
|
+
export declare function emit(ev: VdomEvent): void;
|
|
49
|
+
/** 是否存在「console 之外」的观测 sink(ring/collect)——trace() 包装的 emit 门槛:
|
|
50
|
+
* trace 关闭但测试收集/调试 ring 存在时,执行细节事件仍要发射(供断言/追溯) */
|
|
51
|
+
export declare function hasObservingSinks(): boolean;
|
|
52
|
+
/** 注册 ring buffer sink(uiServe 初始化时调用——页面生命周期内事件全程可追溯) */
|
|
53
|
+
export declare function installEventRing(): void;
|
|
54
|
+
/** 调试 API:查询最近事件(可按 machine/nodeId/event 过滤)——__vdom_events(50, { machine: 'lifecycle' }) */
|
|
55
|
+
export declare function __vdom_events(n?: number, filter?: Partial<VdomEvent>): VdomEvent[];
|
|
56
|
+
/** 重置 ring buffer(测试隔离用) */
|
|
57
|
+
export declare function __resetVdomEvents(): void;
|
|
58
|
+
export declare function makeEventCollector(): {
|
|
59
|
+
events: VdomEvent[];
|
|
60
|
+
unsubscribe: () => void;
|
|
61
|
+
};
|
|
@@ -34,8 +34,9 @@ export declare function vnodeTraceCtx(vnode: {
|
|
|
34
34
|
}): LifecycleTraceCtx;
|
|
35
35
|
/** 查询生命周期时间线(全组件或单组件)——__vdom_lc(id?) */
|
|
36
36
|
export declare function dumpTimeline(id?: string): string;
|
|
37
|
-
/** 状态转换执行(非法转换 → 保留原状态 + trace warn——不静默吞掉)
|
|
38
|
-
* tctx:trace 上下文(组件名/id
|
|
37
|
+
/** 状态转换执行(非法转换 → 保留原状态 + 事件/trace warn——不静默吞掉)
|
|
38
|
+
* tctx:trace 上下文(组件名/id/深度——事件携带结构化字段,trace 输出 `Name(id)[d0] from --event--> to`)
|
|
39
|
+
* 事件流:所有转换统一 emit(machine=lifecycle)——过程级可观测/可断言 */
|
|
39
40
|
export declare function transition(from: Lifecycle, event: LifecycleEvent, tctx?: LifecycleTraceCtx): Lifecycle;
|
|
40
41
|
/** 旧树复用有效性(I3——所有复用路径统一检查):
|
|
41
42
|
* - 生命周期非 disposed(dispose 显式标记——根治「引用还在但内容被掏空」的误判)
|
|
@@ -40,7 +40,8 @@ export interface VdomContext {
|
|
|
40
40
|
renderer: Renderer;
|
|
41
41
|
rootUi: any;
|
|
42
42
|
}
|
|
43
|
-
/** 渲染执行器(render-only
|
|
43
|
+
/** 渲染执行器(render-only 唯一渲染入口——per-id 串行链:并发触发排队补跑,
|
|
44
|
+
* 同一组件渲染中再次触发 → 排队等前一个完成后补跑最新状态(合并语义)) */
|
|
44
45
|
export declare function createRenderer(opts: {
|
|
45
46
|
registry: Registry;
|
|
46
47
|
ctx: any;
|
|
@@ -23,7 +23,7 @@ export interface RouteController {
|
|
|
23
23
|
/** 导航失败(router.execute 抛错——回退 idle) */
|
|
24
24
|
navigateError(path: string, err: unknown): void;
|
|
25
25
|
}
|
|
26
|
-
/** 创建路由生命周期协调器(查表分派——非法转换 trace warn 不静默) */
|
|
26
|
+
/** 创建路由生命周期协调器(查表分派——非法转换 emit/trace warn 不静默) */
|
|
27
27
|
export declare function createRouteController(): RouteController;
|
|
28
28
|
/** 重置(测试/清理用) */
|
|
29
29
|
export declare function __resetRouteState(): void;
|
|
@@ -37,7 +37,10 @@ export interface VdomTraceConfig {
|
|
|
37
37
|
export declare function initVdomTrace(): VdomTraceConfig;
|
|
38
38
|
/** 插桩点前置检查:阶段开启 + 级别满足(关闭时连参数求值都跳过) */
|
|
39
39
|
export declare function traceEnabled(stage: VdomStage, level?: VdomLevel): boolean;
|
|
40
|
-
/** 输出 trace 日志([vdom:{stage}] {traceId} {msg})
|
|
40
|
+
/** 输出 trace 日志([vdom:{stage}] {traceId} {msg})
|
|
41
|
+
* 统一事件流:trace = 执行细节摘要通道——内部发射 TRACE 事件(console sink 输出原格式;
|
|
42
|
+
* ring/collect sink 记录——执行细节可追溯/可断言)。
|
|
43
|
+
* gate:trace 开启 或 存在观测 sink(collect/ring)——否则零成本(调用点已有 traceEnabled 前置守卫保证 msg 惰性) */
|
|
41
44
|
export declare function trace(stage: VdomStage, level: VdomLevel, msg: string, ...args: unknown[]): void;
|
|
42
45
|
/** 手动配置(测试/调试用——不受 init 时序/缓存影响) */
|
|
43
46
|
export declare function configureVdomTrace(c: Partial<Omit<VdomTraceConfig, 'enabled'>>): void;
|
|
@@ -54,5 +57,6 @@ export declare function childNodesSeq(parent: Node | null, max?: number): string
|
|
|
54
57
|
export declare function dumpTree(vnode: VNodeChild, depth?: number): string[];
|
|
55
58
|
/** 安装全局调试 API(dev/调试——页面加载后可用):
|
|
56
59
|
* __vdom_dump() 全树生命周期快照(root 由调用方注入)
|
|
57
|
-
* __vdom_lc(id?) 生命周期时间线(全组件或单组件)
|
|
60
|
+
* __vdom_lc(id?) 生命周期时间线(全组件或单组件)
|
|
61
|
+
* __vdom_events(n?) 统一状态机事件流(最近 N 条——跨状态机关联/追溯) */
|
|
58
62
|
export declare function installVdomInspect(rootGetter: () => VNodeChild | null | undefined): void;
|
|
@@ -17,7 +17,8 @@ import { type PatchState, type VKind } from './kind.ts';
|
|
|
17
17
|
import { type PatchCtx } from './patch.ts';
|
|
18
18
|
type TransitionFn = (s: PatchState) => Node | null;
|
|
19
19
|
export declare const TRANSITIONS: Record<VKind, Record<VKind, TransitionFn>>;
|
|
20
|
-
/** x2y 状态机分派:由源类型(oldInput)与目标类型(newInput)查表调用转换函数
|
|
20
|
+
/** x2y 状态机分派:由源类型(oldInput)与目标类型(newInput)查表调用转换函数
|
|
21
|
+
* 转换事件:machine=x2y(from=旧 kind,to=新 kind)——过程级可观测 */
|
|
21
22
|
export declare function x2y(s: PatchState): Node | null;
|
|
22
23
|
export type { PatchCtx };
|
|
23
24
|
export { Fragment, Portal };
|
package/dist/ui-dom/vnode.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ interface VNodeBase {
|
|
|
37
37
|
_ctxVersion: number | null;
|
|
38
38
|
/** 生命周期状态(节点生命周期状态机——lifecycle.ts):fresh→building→built / pruned;dispose→disposed */
|
|
39
39
|
_lifecycle: Lifecycle;
|
|
40
|
+
/** 渲染调度状态(render 调度状态机:IDLE/RUNNING——渲染中再次触发跳过,防重入) */
|
|
41
|
+
_rendering?: boolean;
|
|
40
42
|
}
|
|
41
43
|
/** 原生元素——type: string;特有:el(元素引用——锚点统一用 _refNode) */
|
|
42
44
|
export interface NativeVNode extends VNodeBase {
|