weifuwu 0.81.2 → 0.81.3
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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
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
|
|
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.toLowerCase())?"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
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
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
|
|
package/dist/ui-dom/testing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|
|
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 w(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)||_({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 _(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?(_({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),_({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 we(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 _e(e){return mn.has(e.toLowerCase())?"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}=we(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[_e(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:wn,comp:_n,frag:bn,native:Oe,portal:Oe};function wn(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;_({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 _n(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(w(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(w(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=w(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=w(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(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}q(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=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 _({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=w(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}=we(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[_e(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=w(n),d=w(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(_({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")){_({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),_({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 w(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 w(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)];_({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};
|
|
@@ -59,7 +59,10 @@ export declare const UNITLESS_PROPS: Set<string>;
|
|
|
59
59
|
* - aria :aria-* 语义属性(boolean 必须显式 'true'/'false')
|
|
60
60
|
* - default :其余——property + attribute 双写 */
|
|
61
61
|
export type PropChannel = 'enumerated' | 'class' | 'style' | 'ref' | 'event' | 'value' | 'indeterminate' | 'innerHTML' | 'aria' | 'default';
|
|
62
|
-
/** 属性通道判定(key 分类——值判断留在各通道处理函数内,规则表 §2)
|
|
62
|
+
/** 属性通道判定(key 分类——值判断留在各通道处理函数内,规则表 §2)
|
|
63
|
+
* enumerated 白名单小写匹配:JSX camelCase(contentEditable)与规范小写(contenteditable)
|
|
64
|
+
* 统一走显式 'true'/'false'——否则 camelCase 落入 boolean 通道输出空字符串(解析仍 true,
|
|
65
|
+
* 但违反 §6.2 显式协议且属性值不可预期) */
|
|
63
66
|
export declare function propChannelOf(key: string): PropChannel;
|
|
64
67
|
type SetPropFn = (el: Element, key: string, value: any) => void;
|
|
65
68
|
/** 属性设置状态机表(通道 → 设置行为——setProp 查表分派,无 if/else 通道链) */
|