weifuwu 0.83.0 → 0.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -51
- package/dist/components/ChatInput/ChatInput.d.ts +2 -2
- package/dist/components/Confirm/Confirm.d.ts +2 -2
- package/dist/components/Notification/Notification.d.ts +0 -2
- package/dist/components/Toast/Toast.d.ts +0 -2
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +12 -12
- package/dist/components/style.css +17 -0
- package/dist/index.js +2408 -341
- package/dist/ui-dom/Confirm.d.ts +1 -1
- package/dist/ui-dom/Notification.d.ts +1 -1
- package/dist/ui-dom/Toast.d.ts +1 -1
- package/dist/ui-dom/hooks/index.d.ts +0 -1
- package/dist/ui-dom/hooks/popup.d.ts +2 -0
- package/dist/ui-dom/hooks/stable.d.ts +2 -6
- package/dist/ui-dom/index.d.ts +24 -19
- package/dist/ui-dom/index.js +40 -22
- package/dist/ui-dom/jsx-runtime.js +1 -1
- package/dist/ui-dom/middleware/ws.d.ts +8 -0
- package/dist/ui-dom/popup-tracker.d.ts +1 -1
- package/dist/ui-dom/testing.d.ts +3 -9
- package/dist/ui-dom/testing.js +7 -1
- package/dist/ui-dom/types.d.ts +7 -37
- package/dist/ui-dom/vdom3/README.d.ts +6 -3
- package/dist/ui-dom/vdom3/app.d.ts +20 -0
- package/dist/ui-dom/vdom3/audit.d.ts +13 -0
- package/dist/ui-dom/vdom3/build.d.ts +7 -3
- package/dist/ui-dom/vdom3/commands.d.ts +13 -3
- package/dist/ui-dom/vdom3/comp-index.d.ts +18 -0
- package/dist/ui-dom/vdom3/delegate.d.ts +48 -0
- package/dist/ui-dom/vdom3/events.d.ts +8 -2
- package/dist/ui-dom/vdom3/index.d.ts +5 -3
- package/dist/ui-dom/vdom3/jsx.d.ts +26 -4
- package/dist/ui-dom/vdom3/record.d.ts +3 -0
- package/dist/ui-dom/vdom3/render.d.ts +19 -6
- package/dist/ui-dom/vdom3/replay.d.ts +11 -8
- package/dist/ui-dom/vdom3/root.d.ts +3 -7
- package/dist/ui-dom/vdom3/types.d.ts +128 -70
- package/dist/ui-dom/vdom3/ui.d.ts +3 -30
- package/dist/ui-dom/vdom3.js +12 -10
- package/dist/ui-dom/vnode.d.ts +9 -89
- package/docs/compat-three-library.md +1 -1
- package/docs/components-map.md +1 -1
- package/docs/frontend-middleware.md +59 -53
- package/docs/frontend-ui-dom.md +115 -132
- package/docs/frontend.md +28 -24
- package/docs/realtime.md +21 -21
- package/package.json +1 -1
- package/dist/test/client/setup.d.ts +0 -12
- package/dist/ui-dom/context.d.ts +0 -32
- package/dist/ui-dom/hooks/test/hooks.test.d.ts +0 -1
- package/dist/ui-dom/middleware/serve.d.ts +0 -27
- package/dist/ui-dom/router.d.ts +0 -73
- package/dist/ui-dom/vdom2/audit.d.ts +0 -28
- package/dist/ui-dom/vdom2/build.d.ts +0 -53
- package/dist/ui-dom/vdom2/ctx.d.ts +0 -32
- package/dist/ui-dom/vdom2/dom-trace.d.ts +0 -4
- package/dist/ui-dom/vdom2/events.d.ts +0 -65
- package/dist/ui-dom/vdom2/hydrate.d.ts +0 -21
- package/dist/ui-dom/vdom2/index.d.ts +0 -13
- package/dist/ui-dom/vdom2/kind.d.ts +0 -44
- package/dist/ui-dom/vdom2/lifecycle.d.ts +0 -54
- package/dist/ui-dom/vdom2/mount.d.ts +0 -77
- package/dist/ui-dom/vdom2/patch.d.ts +0 -116
- package/dist/ui-dom/vdom2/registry.d.ts +0 -27
- package/dist/ui-dom/vdom2/render.d.ts +0 -21
- package/dist/ui-dom/vdom2/route.d.ts +0 -29
- package/dist/ui-dom/vdom2/ssr.d.ts +0 -32
- package/dist/ui-dom/vdom2/trace.d.ts +0 -62
- package/dist/ui-dom/vdom2/transform.d.ts +0 -76
- package/dist/ui-dom/vdom2/transitions.d.ts +0 -24
- package/dist/ui-dom/vdom2/x2html.d.ts +0 -26
- package/dist/ui-dom/vdom3/compat.d.ts +0 -20
package/dist/ui-dom/index.js
CHANGED
|
@@ -1,23 +1,41 @@
|
|
|
1
|
-
function uo(e){let t=[],n=(e||"/").replace(/:(\w+)/g,(o,r)=>(t.push(r),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${n}$`),keys:t}}function at(e,t){if(!t||t==="/")return e||"/";let n=e.endsWith("/")?e.slice(0,-1):e,o=t.startsWith("/")?t:"/"+t;return n+o}var bn=class{_routes=[];_middlewares=[];_injections=[];_injected=!1;_mode;_notFound;_children=[];constructor(t={}){this._mode=t.mode??"history"}get mode(){return this._mode}use(t,n){if(typeof t=="string"&&n){let o=this,r=t;this._children.push({prefix:t,sub:n});let i=async(s,l,d)=>{let c=l.__routePath??o.getPath(),a=null;return c===r?a="/":(r==="/"?c!=="/"&&c.startsWith("/"):c.startsWith(r+"/"))&&(a=c.slice(r.length)),a===null?d:async(u,f)=>{let p=await n._handle(a,u,f);return p===null?d(u,f):p}};return this._middlewares.push(i),this}return t.length<=1?(this._injections.push(t),this):(this._middlewares.push(t),this)}async _ensureInjected(t){if(!this._injected){this._injected=!0;for(let n of this._injections){let o=await n(t);o&&o!==t&&Object.assign(t,o)}}}get(t,n,o){return this._routes.push({path:t,handler:n,title:o?.title}),this}notFound(t){return this._notFound=t,this}getPath(){return this._getPath(void 0)}dumpRoutes(t=""){let n=this._routes.map(o=>({path:at(t,o.path),title:o.title}));for(let o of this._children)n.push(...o.sub.dumpRoutes(at(t,o.prefix)));return n}_getPath(t){let n=t?.location??(typeof window<"u"?window.location:null);return this._mode==="hash"?(n?.hash??"").replace(/^#/,"")||"/":n?.pathname??"/"}match(t){let n=null;for(let o of this._routes){let{re:r,keys:i}=uo(o.path),s=t.match(r);if(!s)continue;let l={};for(let d=0;d<i.length;d++)l[i[d]]=decodeURIComponent(s[d+1]);n={handler:o.handler,params:l,title:o.title};break}return n||(n={handler:this._notFound??(()=>null),params:{}}),n}async _handle(t,n,o){await this._ensureInjected(o);let r=this.match(t);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=t;try{for(let d=this._middlewares.length-1;d>=0;d--){let c=this._middlewares[d],a=s;s=await c(n,o,a)??a}return await s(n,o)}finally{o.__routePath=l}}async execute(t,n,o){await this._ensureInjected(n);let r=this.match(o);r.title&&typeof document<"u"&&(document.title=r.title),n.params=r.params,n.route&&(n.route.params=r.params);let s=r.handler;for(let l=this._middlewares.length-1;l>=0;l--){let d=this._middlewares[l],c=s;s=await d(t,n,c)??c}return await s(t,n)}};var Z=Symbol("Fragment"),z=Symbol("Portal");function Je(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function oe(e){return e!=null&&typeof e=="object"&&e.type===Z}function R(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function Y(e){return e!=null&&typeof e=="object"&&e.type===z}function Xe(e,t,n=null){return{type:e,props:t,key:n,_child:null,_parentNode:null,_refNode:null,_id:null,_customId:null,_parentVNode:null,_ctxVersion:null,_lifecycle:"fresh"}}function Le(e,t,n=null){return e===Z?{...Xe(e,t,n),type:e}:e===z?{...Xe(e,t,n),type:e,_remoteEl:null,_placement:"remote"}:typeof e=="function"?{...Xe(e,t,n),type:e,_render:null,_outputChild:null}:{...Xe(e,t,n),type:e,el:null}}function ve(e,t,...n){let o=dt(t??{});return n.length>0&&(o.children=n.length===1?n[0]:n),Le(e,o,t?.key??null)}function Cn(e,t,n){return Le(e,dt(t),n??null)}var co=Cn;function fo(e,t,n){return Cn(e,t,n)}function dt(e){if(!e)return{};let t={};for(let n of Object.keys(e))n!=="key"&&(t[n]=e[n]);return t}function A(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}function Qe(e,t){let n=Le(z,{children:e,portalKey:t});return n.key=t??null,n}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,t)=>typeof document<"u"?document.createElementNS(e,t):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,t,n)=>{typeof window<"u"&&window.addEventListener(e,t,n)},removeEventListener:(e,t,n)=>{typeof window<"u"&&window.removeEventListener(e,t,n)},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,t)=>{let n=typeof window<"u"?window:null,o=t&&(t.key||t.code)?"KeyboardEvent":t&&(t.clientX!==void 0||t.clientY!==void 0||t.pointerId!==void 0)?"PointerEvent":"Event";try{return new n[o](e,t)}catch{return new n.Event(e,t)}},dispatchEvent:(e,t)=>typeof e<"u"?e.dispatchEvent(t):!1,reload:()=>{typeof window<"u"&&window.location.reload()},navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},downloadFile:(e,t,n="text/plain")=>{try{if(typeof document>"u"||typeof URL>"u"||!URL.createObjectURL)return!1;let o=new Blob([t],{type:n}),r=URL.createObjectURL(o),i=document.createElement("a");return i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(r),1e3),!0}catch{return!1}},copyText:async e=>{let t=typeof window<"u"?window:null;if(t?.navigator?.clipboard?.writeText)try{return await t.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();let o=document.execCommand("copy");return document.body.removeChild(n),o}catch{return!1}},execCommand:(e,t)=>typeof document<"u"?document.execCommand(e,!1,t):!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,t)=>typeof document<"u"?document.createTreeWalker(e,t??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,t=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??t?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,t)=>typeof window<"u"?window.setTimeout(e,t):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,t)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,t)}catch{}}}}function po(e,t,n=400){let o=!1,r=()=>{o||(o=!0,e.removeEventListener("animationend",r),clearTimeout(i),t())};e.addEventListener("animationend",r);let i=setTimeout(r,n)}function Ee(e,t){return Object.assign(Object.create(e),t)}function mo(e){let t={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},n=e?.onRequest,o=e?.onResponse,r=e?.timeout??0;async function i(s,l,d,c,a=!1){let u=t.baseURL+l,f={method:s,headers:{...t.headers,...c?.headers}},p=e?.token?.();p&&!f.headers.Authorization&&(f.headers.Authorization=`Bearer ${p}`);let m=r>0,g=!!c?.signal,h=null,w=null;(m||g)&&(h=new AbortController,f.signal=h.signal,m&&(w=setTimeout(()=>h.abort(new Error("Request timed out")),r)),g&&c.signal.addEventListener("abort",()=>h.abort())),d!==void 0&&s!=="GET"&&s!=="HEAD"&&(f.body=JSON.stringify(d));let y={url:u,init:f};n&&(y=n(y));try{let N=await fetch(y.url,y.init);if(N.status===401&&await e?.onUnauthorized?.()&&!a)return i(s,l,d,c,!0);if(o)return o(N);if(!N.ok){let I=await N.text().catch(()=>"");throw new xn(N.status,I||N.statusText)}let b=N.headers.get("content-length");if(N.status===204||b==="0")return;let P=(N.headers.get("content-type")||"").toLowerCase();return P.includes("application/json")||P.includes("json")?N.json():N.text()}finally{w&&clearTimeout(w)}}return s=>Ee(s,{api:{get:(d,c)=>i("GET",d,void 0,c),post:(d,c,a)=>i("POST",d,c,a),put:(d,c,a)=>i("PUT",d,c,a),patch:(d,c,a)=>i("PATCH",d,c,a),delete:(d,c)=>i("DELETE",d,void 0,c)}})}var xn=class extends Error{status;body;constructor(t,n){super(`API Error ${t}: ${n}`),this.name="ApiError",this.status=t,this.body=n}};function yo(e){try{let t=e.split(".");if(t.length!==3)return null;let n=t[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(n))}catch{return null}}function go(e){let t=yo(e);return t?.exp?t.exp*1e3-3e4<Date.now():!0}function ho(e){let t=e?.storage??localStorage,n=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",r=e?.refreshTokenKey??"weifuwu_refresh",i=e?.refreshEndpoint??"/api/auth/refresh";return s=>{let l=t.getItem(n),d=t.getItem(o),c=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,t.setItem(n,f),t.setItem(o,JSON.stringify(p)),m&&t.setItem(r,m)},logout(){a.token=null,a.user=null,t.removeItem(n),t.removeItem(o),t.removeItem(r)},setUser(f){a.user=f,t.setItem(o,JSON.stringify(f))},async refresh(){return c||(c=u().finally(()=>{c=null}),c)}};async function u(){let f=t.getItem(r);if(!f)return!1;let p=t.getItem(n);try{let m=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:f})});if(t.getItem(n)!==p)return!1;if(!m.ok)return a.logout(),!1;let g=await m.json();return t.getItem(n)!==p?!1:(a.token=g.token,t.setItem(n,g.token),g.refreshToken&&t.setItem(r,g.refreshToken),!0)}catch{return!1}}return l&&go(l)&&a.refresh().catch(()=>{}),e?.onAuth?.(a),Ee(s,{auth:a})}}function vo(e={}){let t=e.url??"/ws",n=e.reconnectInterval??3e3,o=e.maxReconnect??10,r=e.pingInterval??3e4,i=e.pingTimeout??1e4;return s=>{let l=new Set,d=null,c=0,a=null,u=null,f=null,p=!1,m=[],g={isConnected:!1,onMessage:b=>(l.add(b),()=>{l.delete(b)}),send:b=>{let P=JSON.stringify(b);d?.readyState===WebSocket.OPEN?d.send(P):m.push(P)},_connect:h,close:()=>{p=!0,N(),d?.close(),d=null,m=[],g.isConnected=!1}};async function h(){if(!p)try{d=new WebSocket(t),d.onopen=()=>{g.isConnected=!0,c=0;for(let b of m)d.send(b);m=[],w()},d.onmessage=b=>{try{let P=JSON.parse(b.data);for(let I of l)I(P)}catch{}y()},d.onclose=()=>{g.isConnected=!1,N(),!p&&c<o&&(c++,a=setTimeout(h,n*Math.min(c,5)))},d.onerror=()=>{d?.close()}}catch{p||(a=setTimeout(h,n))}}function w(){r<=0||(u=setInterval(()=>{d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"})),f=setTimeout(()=>{d?.close()},i)},r))}function y(){clearTimeout(f)}function N(){clearInterval(u),clearTimeout(f),clearTimeout(a)}return h(),Ee(s,{ws:g})}}var ut={components:{Button:{loading:"\u52A0\u8F7D\u4E2D..."},FileUpload:{placeholder:"\u70B9\u51FB\u6216\u62D6\u62FD\u4E0A\u4F20\u6587\u4EF6",supportedFormats:"\u652F\u6301\u683C\u5F0F: ",maxSize:"\u6700\u5927 ",remove:"\u5220\u9664"},Pagination:{ariaLabel:"\u5206\u9875"},ProgressBar:{ariaLabel:"\u8FDB\u5EA6"},Switch:{ariaLabel:"\u5207\u6362"},Breadcrumb:{ariaLabel:"\u9762\u5305\u5C51"},Modal:{ariaLabel:"\u5F39\u7A97",closeAria:"\u5173\u95ED"},Confirm:{confirmText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},Drawer:{ariaLabel:"\u4FA7\u8FB9\u9762\u677F",closeAria:"\u5173\u95ED"},DatePicker:{w0:"\u65E5",w1:"\u4E00",w2:"\u4E8C",w3:"\u4E09",w4:"\u56DB",w5:"\u4E94",w6:"\u516D",hour:"\u65F6",minute:"\u5206",time:"\u65F6\u95F4",confirm:"\u786E\u5B9A",cancel:"\u53D6\u6D88",placeholder:"\u9009\u62E9\u65E5\u671F"}}};var ct={components:{Button:{loading:"Loading..."},FileUpload:{placeholder:"Click or drag to upload",supportedFormats:"Supported formats: ",maxSize:"Max size: ",remove:"Remove"},Pagination:{ariaLabel:"Pagination"},ProgressBar:{ariaLabel:"Progress"},Switch:{ariaLabel:"Toggle"},Breadcrumb:{ariaLabel:"Breadcrumb"},Modal:{ariaLabel:"Dialog",closeAria:"Close"},Confirm:{confirmText:"OK",cancelText:"Cancel"},Drawer:{ariaLabel:"Panel",closeAria:"Close"},DatePicker:{w0:"Su",w1:"Mo",w2:"Tu",w3:"We",w4:"Th",w5:"Fr",w6:"Sa",hour:"Hour",minute:"Min",time:"Time",confirm:"OK",cancel:"Cancel",placeholder:"Pick a date"}}};var Ze={"zh-CN":ut,"en-US":ct};function ft(e){if(Ze[e])return e;let t=e.split("-")[0];return Object.keys(Ze).find(o=>o.startsWith(t))??"zh-CN"}function No(e={}){let{locale:t="zh-CN",messages:n={},components:o={}}=e,r=ft(t),i=Ze[r],s=pt(i,n,o),l={locale:r,t:(d,c)=>s.messages?.[d]??c??d,setLocale:()=>{},components:s.components};return d=>{let c=d;return c.i18n=l,l.setLocale=a=>{let u=ft(a),f=Ze[u];f&&(s=pt(f,n,o),l.locale=u,l.components=s.components,c.ui?.bumpCtxVersion?.(),c.ui?.render())},d}}function pt(e,t,n){return{messages:{...e?.messages,...t},components:wo(e?.components??{},n)}}function wo(e,t){let n={...e};for(let o of Object.keys(t))typeof t[o]=="object"&&t[o]!==null&&typeof n[o]=="object"?n[o]={...n[o],...t[o]}:n[o]=t[o];return n}var bo={route:"route",lifecycle:"lifecycle",x2y:"diff",keys:"diff",pos:"diff",render:"render",audit:"audit",build:"build",mount:"mount",diff:"diff",dom:"diff"};function yt(e){return bo[e]}var _e=new Set;function nn(e){return _e.add(e),()=>{_e.delete(e)}}var en=[],Co=0;function tn(e){let t=`R${++Co}${e?":"+e:""}`;return en.push(t),t}function Me(){en.pop()}function He(){return en[en.length-1]??""}function T(e){if(on(),_e.size!==0){e.session||(e.session=He()),typeof e.payload=="function"&&(_e.size>1||E(yt(e.machine),e.level??"debug"))&&(e.payload=e.payload());for(let t of _e)try{t(e)}catch{}}}function gt(){return _e.size>1}function xo(e){if(e==null)return"";if(typeof e=="string")return` ${e}`;if(typeof e=="object"){let t=e,n=[];for(let o of["path","i","key","mode","kind","insertedBefore","after","depth"])if(t[o]!==void 0){let r=t[o];n.push(`${o}=${typeof r=="object"?JSON.stringify(r):String(r)}`)}return n.length?" "+n.join(" "):""}return` ${String(e)}`}function Vo(e){let t=yt(e.machine);if(!E(t,e.level??"debug"))return;if(e.event==="TRACE"){console.log(`[vdom:${e.machine}] ${e.payload}`);return}let n=e.component?`${e.component}${e.nodeId?`(${e.nodeId})`:""}`:e.nodeId?`(${e.nodeId})`:"";console.log(`[vdom:${e.machine}] ${n?n+" ":""}${e.from} --${e.event}--> ${e.to}${xo(e.payload)}`)}nn(Vo);var Eo=Number(globalThis?.__WF_RING_MAX)||5e3,Ne=[],mt=!1;function _o(e){Ne.push(e),Ne.length>Eo&&Ne.shift()}function on(){mt||(mt=!0,nn(_o))}function ht(){on()}function vt(e=50,t){return on(),t?Ne.filter(n=>Object.entries(t).every(([o,r])=>n[o]===r)).slice(-e):Ne.slice(-e)}function Nt(e=100){return on(),Ne.filter(t=>t.event==="RENDER_REQUEST").slice(-e).map(t=>{let n=t.payload??{},o=Ne[0]?.ts??0,r=n.ts!=null?n.ts-o:0,i=t.component?`${t.component}${t.nodeId?`(${t.nodeId})`:""}`:t.from,s=n.ids?.length?`[${n.ids.join(",")}]`:"(\u65E0\u53C2\u2192self)";return`[t=+${r}ms] ${i} \u2192 ${s} ${n.detail?`(${n.detail})`:""}`})}var To={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 ee(e){let t=0,n=e._parentVNode??null;for(let o=0;o<10&&n;o++)t++,n=n._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:t}}var rn=new Map,So=50;function ko(e,t,n,o){if(!e?.id)return;let r=rn.get(e.id);r||(r={name:e.name??"?",events:[]},rn.set(e.id,r)),r.events.push(`${t}--${n}-->${o}`),r.events.length>So&&r.events.shift()}function wt(e){if(e){let t=rn.get(e);return t?`${t.name}(${e}): ${t.events.join(" \u2192 ")}`:`no timeline for ${e}`}return[...rn.entries()].map(([t,n])=>`${n.name}(${t}): ${n.events.join(" \u2192 ")}`).join(`
|
|
2
|
-
|
|
3
|
-
`)),t.__vdom_lc==null&&(t.__vdom_lc=n=>wt(n)),t.__vdom_events==null){let n=vt;t.__vdom_events=(o,r)=>n(o,r)}t.__vdom_render_trace==null&&(t.__vdom_render_trace=n=>Nt(n))}function k(e){return typeof e=="function"&&e.name||"anonymous"}function sn(e){return e.ui?._ctxVersion??0}function Sn(e,t){e.ui?.setMounting?.(t)}var Lo=0;function fe(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${Lo++}`}}function ln(e,t){return e.unmountHooks.push(t),()=>{let n=e.unmountHooks.indexOf(t);n>=0&&e.unmountHooks.splice(n,1)}}function _t(e,t){for(let n of[...e.unmountHooks])n(t);e.idRegistry.delete(t),e.idRegistry.delete(`custom:${t}`)}function Mo(e,t,n,o){try{e(t)}catch(r){console.error(`[weifuwu] ref ${n} error in <${o??"anonymous"}>`,r)}}function O(e,t){if(e==null||typeof e!="object")return;let n=e;if(n._lifecycle!=="disposed"){if(n._id){let o=ee(n);if(n._customId&&t.idRegistry.delete(n._customId),t.idRegistry.delete(n._id),t.unmountHooks.length>0){let r=[...t.unmountHooks];for(let i of r)i(n._id);if(n._customId)for(let i of r)i(n._customId)}n._id=null,n._customId=null,R(n)&&(n._render=null),n._parentNode=null,n._refNode=null,n._lifecycle=ne(n._lifecycle,"DISPOSE",o)}else(R(n)||n._child!=null)&&(n._lifecycle=ne(n._lifecycle,"DISPOSE",ee(n)));if(n._child!=null){if(Array.isArray(n._child))for(let o of n._child)o&&typeof o=="object"&&O(o,t);else O(n._child,t);n._child=null}if(n.props?.children&&typeof n.type=="string"){let o=Array.isArray(n.props.children)?n.props.children:[n.props.children];for(let r of o)r&&typeof r=="object"&&O(r,t)}if(typeof n.props?.ref=="function"&&Mo(n.props.ref,null,"cleanup"),Y(n)){let o=n._remoteEl;if(o){let r=n._child;if(r!=null)if(Array.isArray(r))for(let i of r)i&&typeof i=="object"&&O(i,t);else typeof r=="object"&&O(r,t);o.remove(),n._remoteEl=null}}}}function L(e,t){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||oe(e)){let o=t;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 n=e;return R(n)?L(n._outputChild??n._child,t):null}function D(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 t=e;return oe(t)?"frag":Y(t)?"portal":R(t)?"comp":"native"}function kn(e){let t=!1,n=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){n=!0;continue}let r=o;Y(r)||(r.key!=null?t=!0:n=!0)}return t&&n?"mixed":t?"keyed":"unkeyed"}function Ho(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 t=JSON.stringify(e);return`object ${t!=null&&t.length>80?t.slice(0,80)+"\u2026":t??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function an(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function K(e){let t=[`type=${e.type}`];return e.value!==void 0&&t.push(`value=${an(Ho(e.value))}`),e.key!=null&&t.push(`key=${an(e.key)}`),e.id!=null&&t.push(`id=${an(e.id)}`),e.fid!=null&&t.push(`fid=${an(e.fid)}`),`wf-hole: ${t.join(" ")}`}function St(e){return typeof e!="string"&&typeof e!="function"&&e!==Z&&e!==z}function kt(e){for(let t=0;t<e.length;t++){let n=e[t];if(n!=null&&typeof n=="object"&&!Array.isArray(n)){let o=n;o.key!==null&&(o.key=String(o.key))}}}var Oo=/^on[A-Z]/,$o=/^on[A-Z].*Capture$/;function Pn(e){let t=$o.test(e);return{type:(t?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:t}}var Rn=new Set(["draggable","contenteditable","spellcheck","translate"]),Uo=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function An(e){return Rn.has(e.toLowerCase())?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":Oo.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function Tt(e,t,n){if(n!==!1){if(n===!0){e.setAttribute(t,"");return}try{e[t]=n,e.getAttribute(t)!==String(n)&&e.setAttribute(t,String(n))}catch{e.setAttribute(t,String(n))}}}var Do={enumerated:(e,t,n)=>{e.setAttribute(t,n?"true":"false")},class:(e,t,n)=>{if(n!==!1)if(typeof n=="object")for(let[o,r]of Object.entries(n))r&&e.classList.add(o);else e.setAttribute("class",String(n))},style:(e,t,n)=>{if(n!==!1)if(typeof n=="string")e.setAttribute("style",n);else{let o=e.style;for(let[r,i]of Object.entries(n))i==null?o[r]="":r.startsWith("--")?o.setProperty(r,String(i)):typeof i=="number"&&!Uo.has(r)?o[r]=`${i}px`:o[r]=String(i)}},ref:(e,t,n)=>{if(typeof n=="function")try{n(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,t,n)=>{if(n===!1)return;let{type:o,capture:r}=Pn(t);if(typeof n!="function"){console.warn(`[weifuwu] event prop ${t} expects a function, got ${typeof n} \u2014 ignored`);return}e.addEventListener(o,n,r?{capture:!0}:{})},value:(e,t,n)=>{n!==!1&&(e.value=n)},indeterminate:(e,t,n)=>{n!==!1&&(e.indeterminate=!!n)},innerHTML:(e,t,n)=>{n!==!1&&(e.innerHTML=String(n??""))},aria:(e,t,n)=>{if(n!==!1){if(typeof n=="boolean"){e.setAttribute(t,n?"true":"false");return}Tt(e,t,n)}},default:Tt};function ie(e,t,n){n!=null&&Do[An(t)](e,t,n)}function pe(e,t){return e.createComment(K({type:"hole",value:t,key:null,id:null,fid:null}))}function se(){let e=globalThis;return!(e.__WF_VDOM_AUDIT===0||e.__WF_VDOM_AUDIT==="0"||e.__WF_VDOM_AUDIT===!1)}var Pt=!1;function Rt(){Pt||(Pt=!0,nn(e=>{if(!(e.machine!=="render"||e.event!=="PARENT")&&se()&&e.to==="SKIP_DETACHED"){let t=e.payload;if(t.rendered===!1)return;console.error(`[vdom2/audit] \u6302\u8F7D\u4E0D\u53D8\u91CF\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${e.component??"?"}${e.nodeId?`(${e.nodeId})`:""} \u72B6\u6001 ${String(t?.lifecycle)} \u4F46\u65E0 _parentNode/_refNode\uFF08rootEl \u53EA\u5C5E\u4E8E\u6839\u7EC4\u4EF6\uFF09\u2014\u2014\u6302\u8F7D\u4FE1\u606F\u65AD\u88C2\uFF08\u66FE\u6E32\u67D3\u540E\u5B9A\u4F4D\u4E22\u5931\uFF09\uFF0C\u6E32\u67D3\u88AB\u8DF3\u8FC7\uFF0C\u72B6\u6001\u66F4\u65B0\u5C06\u4E22\u5931`)}}))}function dn(e,t,n){if(t==null||t.length===0)return;let o=Array.from(e.childNodes);if(!t.some(i=>{if(i==null||typeof i!="object")return!1;if(Array.isArray(i))return!0;let s=i.type;return s===Z||s===z}))for(let i=0;i<t.length;i++){let s=t[i];if(s==null||typeof s=="boolean"){let l=o[i];(!l||l.nodeType!==8||!l.nodeValue?.includes("type=hole"))&&n(`[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&&n(`[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 ke(e,t,n){jo[D(t)](e,t,n)}var jo={hole:()=>{},text:()=>{},arr:Wo,portal:()=>{},frag:Fo,comp:Bo,native:Ko};function Wo(e,t,n){let o=t;dn(e,o,n);for(let r of o)if(r!=null&&typeof r=="object"&&Array.isArray(r))for(let i of r)ke(e,i,n);else r!=null&&typeof r=="object"&&!Array.isArray(r)&&oe(r)&&dn(e,A(r.props?.children),n)}function Fo(e,t,n){dn(e,A(t.props?.children),n)}function Bo(e,t,n){let o=t,r=o._refNode;r&&r.parentNode!==e&&n(`[audit] \u7EC4\u4EF6\u951A\u70B9\u9519\u4F4D\uFF1A${k(o.type)} _refNode \u4E0D\u5728\u7236\u8282\u70B9\u5185`),o._child!=null&&ke(e,o._child,n)}function Ko(e,t,n){let o=t;if(St(o.type))return;let r=o.el??o._refNode;if(r&&r.nodeType===1&&r.tagName.toLowerCase()!==String(o.type)&&n(`[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??{}))){dn(r,A(o.props?.children),n);for(let i of A(o.props?.children))i!=null&&typeof i=="object"&&!Array.isArray(i)&&R(i)&&ke(r,i,n)}}function qo(e,t){if(e===t)return!0;let n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}async function Go(e,t,n,o){let r=e;r._id||(o?.reuse?._id?r._id=o.reuse._id:r._id=n.nextId(),n.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(t);i.ui=Object.create(t.ui);let s=i.ui;if(s._selfId=r._id??null,s._selfVNode=r,s.render=function(l){let d={source:"component",component:k(r.type),nodeId:r._id??null},c=i.ui,a=0;for(;c&&typeof c=="object"&&c._selfVNode&&a<10;)c=Object.getPrototypeOf(c),a++;return l==null&&r._id?c.render([r._id],d):c.render(l,d)},typeof r._render!="function"&&R(o?.reuse)&&typeof o.reuse._render=="function"&&(r._render=o.reuse._render),typeof r._render!="function"){Sn(t,!0);let l;try{l=await r.type(r.props??{},i)}finally{Sn(t,!1)}if(typeof l!="function")throw new Error(`Component ${k(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);r._render=l}return{renderFn:r._render,childCtx:i}}function In(e){return!!e&&typeof e.then=="function"}function q(e,t,n,o,r){return zo[D(e)](e,t,n,o,r)}function Ln(e,t){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===t.type?e:null}var zo={hole:e=>e,text:e=>e,arr:Yo,comp:Xo,frag:Jo,native:At,portal:At};function Yo(e,t,n,o,r){let i=e;E("build")&&S("build","debug","",`array in kids=${X(i)}`);for(let a of i)if(a!=null&&typeof a=="object"&&!Array.isArray(a)&&a._lifecycle==="disposed"){let u=a;T({session:"",machine:"audit",nodeId:u._id??null,component:k(u.type),from:"disposed",event:"CONTRACT_VIOLATION",to:"new-tree",level:"error",ts:Date.now()}),se()&&console.error(`[vdom2/audit] \u4E24\u9636\u6BB5\u5951\u7EA6\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${k(u.type)} \u7684 renderFn \u8FD4\u56DE\u4E86 disposed \u65E7 vnode${u._id?`(${u._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 u=i[a];if(u!=null&&typeof u=="object"&&!Array.isArray(u)){let f=u;f.key!==null&&(f.key=String(f.key))}}let s=Array.isArray(n)?n:[],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,u)=>{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[u]??null),q(a,t,f,o,r)});E("build")&&S("build","debug","",`array out kids=${X(i)}`);let c=!1;for(let a=0;a<d.length;a++)if(In(d[a])){c=!0;break}return c?Promise.all(d).then(()=>i):i}function Xo(e,t,n,o,r){let i=e,s=o??t.__registry??fe(),l=Ln(n,i);if(se()){let u=He(),f=i._sessionId;f!=null&&f!==u&&i._lifecycle==="building"&&console.error(`[vdom2/audit] I1 \u4F1A\u8BDD\u4E92\u65A5\u8FDD\u53CD\uFF1A${k(i.type)} \u88AB\u4F1A\u8BDD ${f} \u6784\u5EFA\u4E2D\u53C8\u88AB\u4F1A\u8BDD ${u} \u5904\u7406\u2014\u2014\u540C\u4E00 vnode \u591A\u4F1A\u8BDD\u5E76\u53D1\u6784\u5EFA\uFF08await \u70B9\u6E32\u67D3\u4EA4\u9519\u2014\u2014\u6784\u5EFA\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u9700\u6392\u67E5\u6E32\u67D3\u89E6\u53D1\u6E90\uFF09`),i._sessionId=u}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),R(i)&&R(l)&&typeof l._render=="function"&&(i._render=l._render));let d=qo(l?.props??{},i.props??{}),c=sn(t),a=(l?._ctxVersion??-1)===c;if(!r?.force&&d&&a&&Se(l)&&typeof i._render=="function"){let u=l;return i._lifecycle=ne(i._lifecycle,"PRUNE",ee(i)),i._child=u._child,i._ctxVersion=u._ctxVersion,E("build")&&S("build","debug","",`prune comp=${we(i)} propsSame=${d} verSame=${a}`),i}return i._lifecycle=ne(i._lifecycle,"BUILD_START",ee(i)),E("build")&&S("build","debug","",`mount comp=${we(i)} propsSame=${d} verSame=${a} force=${!!r?.force} oldV=${l?(typeof l.type=="function"?l.type.name:String(l.type))+"/"+(l._lifecycle??"?"):"null"}`),(async()=>{let{childCtx:u}=await Go(i,t,s,{reuse:l??null}),f=await q(await i._render(i.props),u,l?._child,s,r);return i._child=f??null,i._ctxVersion=c,i._lifecycle=ne(i._lifecycle,"BUILD_DONE",ee(i)),i})()}function Jo(e,t,n,o,r){let i=e,s=o??t.__registry??fe(),l=Ln(n,i);E("build")&&S("build","debug","",`fragment kids=${X(A(i.props?.children))}`);let d=q(i.props?.children??null,t,l?._child??l?.props?.children,s,r);return In(d)?d.then(c=>(i._child=c??null,i._lifecycle=ne(i._lifecycle,"BUILD_DONE",ee(i)),i)):(i._child=d??null,i._lifecycle=ne(i._lifecycle,"BUILD_DONE",ee(i)),i)}function At(e,t,n,o,r){let i=e;if(typeof i.type!="string"&&typeof i.type!="symbol")return i;let s=o??t.__registry??fe(),l=Ln(n,i);E("build")&&S("build","trace","",`native <${String(i.type)}> kids=${X(A(i.props?.children))}`);let d=q(i.props?.children??null,t,l?.props?.children,s,r);return In(d)?d.then(c=>(i._child=c??null,i._lifecycle=ne(i._lifecycle,"BUILD_DONE",ee(i)),i)):(i._child=d??null,i._lifecycle=ne(i._lifecycle,"BUILD_DONE",ee(i)),i)}var Qo=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function Pe(e,t){return pe(e,t)}function $(e,t,n,o=null,r=null,i=null){let s=t?.browser??n;if(!s)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return lr[D(e)](e,t,s,o,r,i)}function Zo(e,t,n){return null}function er(e,t,n){return n.createTextNode(String(e))}function Mn(e,t,n,o,r){if(e==null||typeof e=="boolean")return Pe(n,e);let i=$(e,t,n,String(o),null,r);return i??Pe(n,null)}function nr(e,t,n,o=null,r=null,i=null){let s=e,l=n.createDocumentFragment();if(!l)return null;E("render")&&S("render","debug","",`array kids=${X(s)} fid=${i??"-"} key=${o??"-"}`);let d=n.createComment(K({type:"fragment-start",key:o,id:r,fid:i})),c=n.createComment(K({type:"fragment-end",key:o,id:r,fid:i}));d&&l.appendChild(d);for(let a=0;a<s.length;a++){let u=s[a],f=i!=null?`${i}-${a}`:String(a),p=Mn(u,t,n,a,f);p!=null&&l.appendChild(p)}return c&&l.appendChild(c),l}function tr(e,t,n){let o=e,r=o,i=n.bodyElement();if(!i)return null;let s=i.querySelector("#__wf_portal");s||(s=n.createElement("div"),s&&(s.id="__wf_portal",i.appendChild(s)));let l=n.createElement("div");if(l){l.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let d=$(o.props?.children??null,t,n);d!=null&&l.appendChild(d),s&&s.appendChild(l),r._remoteEl=l;let c=A(o.props?.children);for(let a of c)a!=null&&typeof a=="object"&&!Array.isArray(a)&&(a._parentVNode=o)}return null}function or(e,t,n,o=null,r=null,i=null){let s=e,l=s,d=n.createDocumentFragment();if(!d)return null;let c=A(s.props?.children);E("render")&&S("render","debug","",`fragment kids=${X(c)} fid=${i??"-"}`);let a=n.createComment(K({type:"fragment-start",key:o,id:r,fid:i})),u=n.createComment(K({type:"fragment-end",key:o,id:r,fid:i}));a&&d.appendChild(a),l._refNode=a;for(let f=0;f<c.length;f++){let p=c[f],m=i!=null?`${i}-${f}`:String(f),g=Mn(p,t,n,f,m);g!=null&&d.appendChild(g)}return u&&d.appendChild(u),d}function rr(e,t,n){let o=e,r=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return ir[r](o,t,n)}var ir={fresh:(e,t,n)=>{throw new Error(`[vdom2] component ${k(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,t,n)=>{throw new Error(`[vdom2] component ${k(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,t,n)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${k(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`),Pe(n,null)),built:It,pruned:It};function It(e,t,n){let o=e._child;if(o==null)return e._child=null,null;e._child=o,e._outputChild=o,typeof o=="object"&&!Array.isArray(o)&&(o._parentVNode=e);let r=$(o,t,n);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 sr(e,t,n,o,r){let i=e,s=i,l=i.type,d=Qo.has(l)?n.createElementNS("http://www.w3.org/2000/svg",l):n.createElement(l);if(!d)return null;s.el=d,s._refNode=d,E("render")&&S("render","trace","",`native <${l}> key=${i.key??"-"} kids=${X(A(i.props?.children))}`),i.key!=null&&d.setAttribute("data-wf-key",i.key);let c=null;for(let[a,u]of Object.entries(i.props??{}))if(!(a==="children"||a==="key")){if(a==="value"&&(d instanceof HTMLSelectElement||d instanceof HTMLInputElement)){c=u;continue}ie(d,a,u)}if(!("innerHTML"in(i.props??{}))){let a=A(i.props?.children);for(let u=0;u<a.length;u++){let f=a[u],p=r!=null?`${r}-${u}`:String(u),m=Mn(f,t,n,u,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)}}E("render")&&S("render","trace","",`native <${l}> out=${ce(d)}`)}return c!==null&&(d.value=String(c)),d}var lr={hole:Zo,text:er,arr:nr,portal:tr,frag:or,comp:rr,native:sr};function me(e){let{parent:t,oldNode:n,oldInput:o,ctx:r}=e,i=$(e.newInput,r,r.browser??V());if(i==null)return null;if(n?.parentNode){let s=Oe(o,n,t,r);return s&&s.parentNode===t?t.insertBefore(i,s):t.appendChild(i),i}return t.appendChild(i),i}function ar(e){return Oe(e.oldInput,e.oldNode,e.parent,e.ctx),null}function dr(e){let t=e.oldNode;if(t?.nodeType===8){let n=Pe(e.ctx.browser??V(),e.newInput);return n&&t.nodeValue!==n.nodeValue&&(t.nodeValue=n.nodeValue),t}return null}function Re(e){let{parent:t,oldNode:n,ctx:o}=e,r=$(e.newInput,o,o.browser??V());return r==null?null:(n?.parentNode?n.parentNode.replaceChild(r,n):n?t.insertBefore(r,n):t.appendChild(r),r)}function ur(e){let{parent:t,oldNode:n,oldInput:o}=e,r=String(e.newInput);if(String(o)!==r){if(n&&n.nodeType===3)return n.nodeValue=r,n;let i=t.ownerDocument.createTextNode(r);return n?.parentNode?n.parentNode.replaceChild(i,n):t.appendChild(i),i}return n}function cr(e){let{parent:t,oldNode:n,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=i.type;if(n&&n.nodeType===1&&(s?.type??null)===l&&Je(i)){let d=n;return i.el=d,i._refNode=d,Mt(d,s?.props??{},i.props??{}),"innerHTML"in(i.props??{})||$e(d,s?._child??s?.props?.children??null,i._child??i.props?.children??null,r),d}return me(e)}function fr(e){let{parent:t,oldNode:n,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=oe(s)?L(s,n):null,d=Hn(t,s??o,i,r,l);return n?.parentNode?n:d[0]??null}function pr(e){let{parent:t,oldNode:n,oldInput:o,ctx:r}=e,i=e.newInput;if(!R(i)||typeof i._render!="function")throw new Error(`[vdom2] component ${k(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 me(e);let l=s?.type===i.type;if(!r.force&&s&&l&&Se(s)&&i._child===s._child)return n;s?.type===i.type&&s._id&&(i._id=s._id,r.registry.idRegistry.set(i._id,i)),i._parentNode=t,n&&(i._refNode=n);let d=i._child;if(d===null){i._outputChild=null,i._refNode=null;let a=n?.parentNode!=null,u=Oe(s?._child??null,n,t,r);s&&(s._child=null);let f=Pe(r.browser??V(),null);return a&&f?(u&&u.parentNode===t?t.insertBefore(f,u):t.appendChild(f),f):te(t,n,s?._child,null,r)}if(i._outputChild=d,d!=null&&Te(d)||s?._child!=null&&Te(s._child))return T({session:"",machine:"audit",nodeId:i._id??null,component:k(i.type),from:"PRUNED",event:"STALE_CACHE",to:"SKIP_DIFF",level:"warn",ts:Date.now()}),console.warn(`[vdom2] \u526A\u679D\u7F13\u5B58\u5931\u6548\uFF1A${k(i.type)} \u8F93\u51FA\u542B disposed \u7EC4\u4EF6\u2014\u2014\u5E76\u53D1\u6E32\u67D3\u4F1A\u8BDD dispose \u5171\u4EAB\u65E7\u6811\u2014\u2014\u8DF3\u8FC7 diff\uFF08\u4E0B\u4E00\u8F6E\u91CD\u5EFA\u6062\u590D\uFF09`),n;let c=te(t,n,s?._child,d,r);return c&&(i._refNode=c),c}function mr(e){let{parent:t,oldNode:n,oldInput:o,ctx:r}=e;if(o===e.newInput&&n?.parentNode)return n;let i=t.ownerDocument.createDocumentFragment(),s=$e(t,o,e.newInput,r,n?[n]:null);for(let l of s)l&&i.appendChild(l);return n?.parentNode?i.contains(n)?t.appendChild(i):n.parentNode.replaceChild(i,n):t.appendChild(i),i}function yr(e){let{ctx:t,oldInput:n}=e,o=e.newInput,r=n&&typeof n=="object"&&!Array.isArray(n)?n:null;if(Y(r)&&Y(o)){let i=r._remoteEl;if(i){let s=r._child??r.props?.children??null,l=o._child??o.props?.children??null;$e(i,s,l,t)}return o._remoteEl=r._remoteEl,null}return me(e)}function be(e){return{text:me,native:me,frag:me,comp:me,arr:me,hole:ar,portal:me,...e}}var gr={text:be({text:ur}),hole:be({text:Re,native:Re,frag:Re,comp:Re,arr:Re,portal:Re,hole:dr}),native:be({native:cr}),frag:be({frag:fr}),comp:be({comp:pr}),arr:be({arr:mr}),portal:be({portal:yr})};function Lt(e){let t=D(e.oldInput),n=D(e.newInput);return T({session:"",machine:"x2y",nodeId:null,component:null,from:t,event:"X2Y",to:n,level:"trace",ts:Date.now()}),gr[t][n](e)}function le(e,t){if(t&&typeof e.type=="function"&&e._id){try{O(e,t)}catch(n){console.error("[weifuwu] ref cleanup error",n)}_t(t,e._id)}}var Ht=new Set;function We(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let t=e;return Y(t)?typeof t.props?.portalKey=="string"?t.props.portalKey:null:t.key}function On(e,t){if(t&&e&&typeof e=="object"&&!Array.isArray(e)){let n=L(e,t);if(n&&n.length>1)return n}return[t]}function un(e,t){let n=A(e.props?.children);for(let o of n){if(o==null||typeof o!="object"||Array.isArray(o))continue;let r=o;hr[D(r)](r,t)}}var hr={comp:(e,t)=>{le(e,t)},frag:(e,t)=>{un(e,t)},native:(e,t)=>{un(e,t)},portal:(e,t)=>{un(e,t)},arr:()=>{},text:()=>{},hole:()=>{}};function Oe(e,t,n,o){return vr[D(e)](e,t,n,o)}var vr={arr:(e,t,n,o)=>{let r=L(e,t);if(r&&r.length){let i=(r[r.length-1]??t)?.nextSibling??null;for(let s of r)s.parentNode&&s.parentNode.removeChild(s);return i&&i.parentNode===n?i:null}return Ue(e,t,n,o)},frag:(e,t,n,o)=>{let r=e,s=L(r,t)??[],l=(s[s.length-1]??t)?.nextSibling??null;for(let d of s)d.parentNode&&d.parentNode.removeChild(d);return un(r,o.registry),l&&l.parentNode===n?l:null},portal:(e,t,n,o)=>{let r=e,i=r._remoteEl;try{O(r.props?.children,o.registry)}catch(s){console.error("[weifuwu] portal ref cleanup error",s)}return i?.parentNode?.removeChild(i),null},comp:(e,t,n,o)=>{let r=e,i=L(r,t);if(le(r,o.registry),i&&i.length>1){let s=(i[i.length-1]??t)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return s&&s.parentNode===n?s:null}return Ue(e,t,n,o)},native:(e,t,n,o)=>{try{O(e,o.registry)}catch(r){console.error("[weifuwu] ref cleanup error",r)}return Ue(e,t,n,o)},text:(e,t,n,o)=>Ue(e,t,n,o),hole:(e,t,n,o)=>Ue(e,t,n,o)};function Ue(e,t,n,o){let r=t?.nextSibling??null;return t?.parentNode&&t.parentNode.removeChild(t),r&&r.parentNode===n?r:null}function te(e,t,n,o,r){return Lt({parent:e,oldNode:t,oldInput:n,newInput:o,ctx:r})}var Ot={event:(e,t,n,o)=>{let{type:r,capture:i}=Pn(t);typeof n=="function"&&e.removeEventListener(r,n,i?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${t} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(r,o,i?{capture:!0}:{}))},class:(e,t,n,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",ie(e,t,o))},ref:(e,t,n,o)=>{if(o==null||o===!1){if(typeof n=="function")try{n(null)}catch(r){console.error("[weifuwu] ref cleanup error",r)}}else ie(e,t,o)},value:(e,t,n,o)=>{o==null||o===!1?e.value="":ie(e,t,o)},indeterminate:(e,t,n,o)=>{o==null||o===!1?e.indeterminate=!1:ie(e,t,o)},enumerated:De,style:De,innerHTML:De,aria:De,default:De};function De(e,t,n,o){if(o==null||o===!1){e.removeAttribute(t);try{delete e[t]}catch{}}else ie(e,t,o)}function Mt(e,t,n){let o=Object.keys(t),r=Object.keys(n);if(o.length===r.length){let l=!0;for(let d=0;d<o.length;d++)if(o[d]!==r[d]||t[o[d]]!==n[o[d]]){l=!1;break}if(l)return}let i=new Set([...o,...r]),s=null;for(let l of i){if(l==="children"||l==="key")continue;let d=t[l],c=n[l];if(d!==c){if(l==="value"&&(e instanceof HTMLSelectElement||e instanceof HTMLInputElement)){s={ov:d,nv:c};continue}Ot[An(l)](e,l,d,c)}}s&&Ot.value(e,"value",s.ov,s.nv)}function Hn(e,t,n,o,r){let i=Array.isArray(t)?t:t?._child??t?.props?.children??null,s=Array.isArray(n)?n:n?._child??n?.props?.children??null;return $e(e,i,s,o,r)}function $e(e,t,n,o,r,i){let s=A(t),l=A(n),d=r??Array.from(e.childNodes);E("diff")&&S("diff","debug","",`patchChildren parent=${J(e)} old=${X(s)} new=${X(l)} dom=${ce(e)}`);let c=l.some(p=>Array.isArray(p))||s.some(p=>Array.isArray(p)),a=c?"unkeyed":kn(l);if(T({session:"",machine:"keys",nodeId:null,component:null,from:c?"unkeyed":kn(l),event:"SELECT",to:a,payload:()=>({len:l.length}),level:"trace",ts:Date.now()}),se()&&s.length!==l.length){let p=`${l.length}:${s.length}`;if(!Ht.has(p)){Ht.add(p);for(let m=0;m<l.length;m++){let g=l[m];g!=null&&typeof g=="object"&&!Array.isArray(g)&&R(g)&&g.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${m} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\uFF08${k(g.type)}\uFF09\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 u=r&&r.length?r[r.length-1]:null;a==="mixed"&&(cn(l),cn(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 w=s[h];if(Array.isArray(w)){let N=p[g]??null;m.push(N);let b=L(w,N);g+=b?.length??1;continue}if(w==null||typeof w=="boolean"||typeof w=="string"||typeof w=="number"){m.push(p[g]??null),g++;continue}let y=w;if(Y(y)){m.push(y._remoteEl??null);continue}if(m.push(y._refNode??p[g]??null),typeof y.type=="function"||oe(y)){let N=L(y,y._refNode??p[g]??null);g+=N?.length??1}else g++}return m})();return $r[a]({parent:e,oldChildren:s,newChildren:l,oldNodes:f,ctx:o,arrEnd:u,anchorOut:i})}function je(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&oe(e)?"multi":"real"}function Nr(e){let{parent:t,oldC:n,oldNode:o,oldNodes:r,i,ctx:s,out:l,pushA:d}=e;if(Array.isArray(n)){E("diff")&&S("diff","trace","",`remove-arr-item i=${i} range=[${(L(n,r[i])??[]).map(J).join(" | ")}] before=${ce(t)}`);let c=L(n,o);for(let a of c??[])a.parentNode?.removeChild(a);E("diff")&&S("diff","trace","",`remove-arr-item after=${ce(t)}`);for(let a of n)a!=null&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"&&le(a,s.registry)}else if(n&&typeof n=="object"&&!Array.isArray(n)){if(typeof n.type=="function")le(n,s.registry);else try{O(n,s.registry)}catch(c){console.error("[weifuwu] ref cleanup error",c)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);l.push(null),d(null)}function wr(e){let{parent:t,newC:n,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,c=pe(d.browser??V(),n);if(o?.nodeType===8){c&&o.nodeValue!==c.nodeValue&&(o.nodeValue=c.nodeValue),s.push(o),l(o);return}if(c&&o?.parentNode)o.parentNode.replaceChild(c,o);else if(c){let a=null;for(let u=r+1;u<i.length;u++){let f=i[u];if(f&&f.parentNode===t){a=f;break}}if(!a){let u=null;for(let f=s.length-1;f>=0;f--)if(s[f]){u=s[f];break}u&&u.parentNode===t&&(a=u.nextSibling)}a&&a.parentNode===t?t.insertBefore(c,a):t.appendChild(c),s.push(c),l(c)}else s.push(c),l(c)}function $t(e){let{parent:t,newC:n,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,c=$(n,d,d.browser??V(),String(r));if(c==null){s.push(null),l(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){T({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"HOLE_FILL",to:"real",payload:()=>({i:r,replaced:J(o)}),level:"trace",ts:Date.now()}),o.parentNode?.replaceChild(c,o),s.push(c),l(c);return}let a=null;for(let u=r+1;u<i.length;u++){let f=i[u];if(f&&f.parentNode===t){a=f;break}}if(a==null){let u=null;for(let f=s.length-1;f>=0;f--)if(s[f]){u=s[f];break}if(u&&u.parentNode===t)a=u.nextSibling;else{let f=i[i.length-1];f&&f.parentNode===t&&(a=f.nextSibling)}}a&&a.parentNode===t?t.insertBefore(c,a):t.appendChild(c),T({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"INSERT",to:"real",payload:()=>({i:r,insertedBefore:a?J(a):"END",node:J(c)}),level:"trace",ts:Date.now()}),s.push(c),l(c)}function br(e){let{parent:t,oldC:n,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e;if(n&&typeof n=="object"&&!Array.isArray(n)&&typeof n.type=="function"){let c=jt(t,n,r,o,l);i.push(c),s(c);return}let d=Wt(t,n,r,o,l);i.push(d),s(d)}function Cr(e){let{parent:t,oldC:n,newC:o,oldNode:r,i,out:s,pushA:l,ctx:d}=e,c=d.browser??V(),a=$(o,d,c,String(i));if(a==null){s.push(null),l(null);return}let u=n&&typeof n=="object"?L(n,r):null;if(u&&u.length>1){let p=(u[u.length-1]??r)?.nextSibling??null;for(let m of u)m.parentNode&&m.parentNode.removeChild(m);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")le(n,d.registry);else try{O(n,d.registry)}catch(m){console.error("[weifuwu] ref cleanup error",m)}p&&p.parentNode===t?t.insertBefore(a,p):t.appendChild(a)}else r?.parentNode?r.parentNode.replaceChild(a,r):t.appendChild(a);let f=a.nodeType===11?Array.from(a.childNodes):[a];s.push(...f),l(f[0]??a)}function xr(e){let{parent:t,oldC:n,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e,d=Dt(t,n,r,o,l);i.push(d),s(d)}function Vr(e){let{parent:t,oldC:n,newC:o,oldNode:r,i,oldNodes:s,out:l,pushA:d,ctx:c}=e,a=c.browser??V(),u=L(n,r);E("diff")&&S("diff","debug","",`multi-remove i=${i} range=${u?u.map(J).join(" | "):"null"}`);for(let m of u??[])m.parentNode?.removeChild(m);for(let m of A(n?.props?.children))m!=null&&typeof m=="object"&&!Array.isArray(m)&&typeof m.type=="function"&&le(m,c.registry);let f=$(o,c,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):t.appendChild(f),l.push(f),d(f)}function Er(e){let{parent:t,oldC:n,newC:o,oldNode:r,oldNodes:i,i:s,out:l,pushA:d,ctx:c}=e,a=L(n,r),u=Hn(t,n,o,c,a);l.push(...u),d(i[s]??u[0]??null)}function _r(e){let{parent:t,oldC:n,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 u=Bt(t,r,d,k(o.type));s.push(u),l(u);return}let c=te(t,r,n,o,d);E("diff")&&S("diff","trace","",`after-patch i=${i} new=${we(o)} node=${J(c)} dom=${ce(t)}`);let a=On(o,c);s.push(...a),l(a[0]??c??null)}function Dt(e,t,n,o,r){let i=pe(r.browser??V(),o),s=L(t,n),l=((s??[])[s?.length?s.length-1:0]??n)?.nextSibling??null;for(let d of s??[])d.parentNode?.removeChild(d);for(let d of A(t?.props?.children))d!=null&&typeof d=="object"&&!Array.isArray(d)&&typeof d.type=="function"&&le(d,r.registry);return i&&l&&l.parentNode===e?e.insertBefore(i,l):i&&e.appendChild(i),i}function jt(e,t,n,o,r){let i=pe(r.browser??V(),o),s=Oe(t,n,e,r);return i&&s?e.insertBefore(i,s):i&&e.appendChild(i),i}function Wt(e,t,n,o,r){let i=pe(r.browser??V(),o);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")le(t,r.registry);else try{O(t,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}return i&&n?.parentNode?n.parentNode.replaceChild(i,n):i&&e.appendChild(i),i}var Tr={hole:{hole:wr,real:$t,multi:$t},real:{hole:br,real:_r,multi:Cr},multi:{hole:xr,real:Vr,multi:Er}};function Sr(e){let{parent:t,oldChildren:n,newChildren:o,oldNodes:r,ctx:i,anchorOut:s}=e,l=Math.max(n.length,o.length),d=[],c=a=>{s&&s.push(a)};for(let a=0;a<l;a++){let u=a<n.length?n[a]:null,f=a<o.length?o[a]:null;if(a>=o.length){Nr({parent:t,oldC:u,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:c,ctx:i});continue}if(u!=null&&typeof u=="object"&&!Array.isArray(u)&&f!=null&&typeof f=="object"&&!Array.isArray(f)&&f===u&&Se(u)){d.push(r[a]),c(r[a]);continue}let p=Tr[je(u)][je(f)];T({session:"",machine:"pos",nodeId:null,component:null,from:je(u),event:p.name,to:je(f),payload:()=>({i:a}),level:"trace",ts:Date.now()}),p({parent:t,oldC:u,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:c,ctx:i})}return d}function Ut(e){let{parent:t,oldChildren:n,newChildren:o,oldNodes:r,ctx:i,anchorOut:s,arrEnd:l}=e,d=new Map;n.forEach((p,m)=>{let g=We(p);g!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&d.set(g,{vnode:p,nodes:[r[m]??null].filter(Boolean),index:m})});let c=[],a=new Set,u=p=>{s&&s.push(p)},f=null;return o.forEach((p,m)=>{let g=We(p),h=p;if(g!==null&&d.has(g)){let w=d.get(g),y=w.nodes[0]??null;if(a.add(g),h&&typeof h=="object"&&typeof h.type=="function"&&h._lifecycle==="disposed"){let j=Bt(t,y,i,k(h.type));c.push(j),u(j),j&&(f=j);return}let N=te(t,y,w.vnode,h,i),b=On(h,N),P=b[0]??N,I=b[b.length-1]??N;if(P&&P.parentNode===t&&f&&P.previousSibling!==f){E("diff")&&S("diff","debug","",`keyed-correct i=${m} k=${g} move=[${b.map(J).join(" | ")}] after=${J(f)} before=${ce(t)}`);let j=f.nextSibling;for(let C of b)C&&C.parentNode===t&&t.insertBefore(C,j);E("diff")&&S("diff","debug","",`keyed-correct after=${ce(t)}`)}c.push(...b),u(b[0]??N??null),I&&(f=I)}else{let w={current:f};Lr[Ir(p)]({parent:t,oldChildren:n,newChildren:o,oldNodes:r,ctx:i,out:c,pushA:u,arrEnd:l,c:p,i:m},w),f=w.current}}),n.forEach((p,m)=>{Pr[kr(We(p),a)](t,p,m,r,i,o.length)}),c}function kr(e,t){return e===null?"unkeyed":t.has(e)?"moved":"stale-keyed"}var Pr={moved:()=>{},"stale-keyed":Rr,unkeyed:Ar};function Rr(e,t,n,o,r){let i=t&&typeof t=="object"&&!Array.isArray(t)?L(t,o[n]):null;if(E("diff")&&S("diff","trace","",`keyed-delete i=${n} k=${We(t)} range=${i?.length??0} oldNode=${J(o[n])}`),t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")le(t,r.registry);else try{O(t,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}Ft(i,o[n])}function Ar(e,t,n,o,r,i){let s=o[n];if(s?.nodeType===8&&s.nodeValue?.includes("type=hole")&&n<i)return;if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")le(t,r.registry);else try{O(t,r.registry)}catch(c){console.error("[weifuwu] ref cleanup error",c)}let d=t&&typeof t=="object"&&!Array.isArray(t)?L(t,s):null;Ft(d,s)}function Ft(e,t){if(e&&e.length>1)for(let n of e)n.parentNode&&n.parentNode.removeChild(n);else t?.parentNode&&t.parentNode.removeChild(t)}function Ir(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&Y(e)?"portal":"real"}var Lr={hole:Mr,portal:Hr,real:Or};function Mr(e,t){let{parent:n,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:c}=e,a=o[c]??null,u=r[c]??null,f=je(a);if(f==="hole"){let m=pe(i.browser??V(),d);u?.nodeType===8?(m&&u.nodeValue!==m.nodeValue&&(u.nodeValue=m.nodeValue),s.push(u),l(u),u&&(t.current=u)):(m&&u?.parentNode?u.parentNode.replaceChild(m,u):m&&n.appendChild(m),s.push(m),l(m),m&&(t.current=m));return}let p=f==="multi"?Dt(n,a,u,d,i):a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"?jt(n,a,u,d,i):Wt(n,a,u,d,i);s.push(p),l(p),p&&(t.current=p)}function Hr(e,t){let{parent:n,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:c}=e,a=d,u=o[c]??null,f=te(n,r[c]??null,u,a,i),p=On(a,f);s.push(...p),l(p[0]??f??null);let m=p[p.length-1]??f;m&&(t.current=m)}function Or(e,t){let{parent:n,oldNodes:o,ctx:r,out:i,pushA:s,arrEnd:l,c:d,i:c}=e,u=$(d,r,r.browser??V());if(i.push(u),s(u??null),u!=null){let f=o[c];f&&f.nodeType===8&&f.nodeValue?.includes("type=hole")?(f.parentNode?.replaceChild(u,f),t.current=u):(t.current?n.insertBefore(u,t.current.nextSibling):l&&l.parentNode===n?n.insertBefore(u,l):n.insertBefore(u,n.firstChild),t.current=u)}}function cn(e){for(let t=0;t<e.length;t++){let n=e[t];n&&typeof n=="object"&&!Array.isArray(n)&&We(n)===null&&(n.key=`pos:${t}`)}}function Bt(e,t,n,o){se()?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=pe(n.browser??V(),null);if(r==null)return null;let i=t;if(i){let s=i.parentNode;s?s.replaceChild(r,i):e.appendChild(r)}else e.appendChild(r);return r}var $r={unkeyed:Sr,keyed:Ut,mixed:e=>(cn(e.newChildren),cn(e.oldChildren),Ut(e))};function Ur(e,t,n,o){T({session:o,machine:"render",nodeId:e?.nodeId??null,component:e?.component??null,from:e?.source??"external",event:"RENDER_REQUEST",to:n,payload:()=>({ids:t,source:e?.source??"external",detail:e?.detail??null,ts:Date.now()}),level:"info",ts:Date.now()})}function fn(e){let{registry:t,ctx:n}=e,o=new Map;function r(c,a){if(c==null||typeof c!="object")return!1;if(c===a)return!0;if(Array.isArray(c)){for(let f of c)if(r(f,a))return!0;return!1}let u=c;return!!(u._child!=null&&r(u._child,a)||typeof u.type=="string"&&u.props?.children!=null&&r(u.props.children,a))}async function i(c){let a=t.idRegistry.get(c);if(!a||!R(a)||typeof a._render!="function")return;let u=a,f=tn("render");try{if(u._lifecycle==="building"){s.add(c),T({session:f,machine:"render",nodeId:u._id??null,component:$n(u),from:"IDLE",event:"PARENT",to:"SKIP_BUILDING",payload:()=>({lifecycle:u._lifecycle}),level:"debug",ts:Date.now()});return}let p=n.ui?._rootVNodeId;if(p){let b=t.idRegistry.get(p);if(b&&!r(b,u)){t.idRegistry.delete(c),t.idRegistry.delete(`custom:${c}`),T({session:f,machine:"render",nodeId:c,component:$n(u),from:"IDLE",event:"PARENT",to:"SKIP_ORPHAN",payload:()=>({reason:"not in render tree (stale instance)"}),level:"warn",ts:Date.now()});return}}let m=await u._render(u.props),g=await q(m,n,u._child,t)??null,h=u._child;u._child=g;let w=u._id!=null&&u._id===n.ui?._rootVNodeId,y=u._parentNode??u._refNode?.parentNode??null;y==null&&w&&(y=e.rootEl??null);let N=y?w&&!u._parentNode?"ROOT":"MOUNTED":"SKIP_DETACHED";if(T({session:f,machine:"render",nodeId:u._id??null,component:$n(u),from:"IDLE",event:"PARENT",to:N,payload:()=>({lifecycle:u._lifecycle,rendered:u._outputChild!=null}),level:"debug",ts:Date.now()}),!y)return;if(y){let b={browser:n.browser??V(),registry:t,ctxVersion:sn(n)},P=te(y,u._refNode??null,h,g,b);if(u._refNode=P,se())try{let I=[];ke(y,g,j=>I.push(j)),I.length&&console.error("[vdom2/audit] "+I.join(" | "))}catch(I){console.error("[vdom2/audit] \u6821\u9A8C\u5F02\u5E38:",I)}}}catch(p){e.onError?e.onError(p):console.error("[vdom2] render error:",p?.stack??p)}finally{Me()}}let s=new Set;function l(){if(s.size===0)return Promise.resolve();let c=[...s];s.clear();let a=c.filter(u=>{let f=t.idRegistry.get(u);return f&&R(f)&&typeof f._render=="function"&&f._lifecycle!=="building"&&f._lifecycle!=="disposed"});if(a.length)return d(a,{source:"external",component:null,nodeId:null,detail:"pending-flush"});for(let u of c)s.add(u);return Promise.resolve()}function d(c,a){return c==null?Promise.resolve():(Ur(a??{source:"external",component:null,nodeId:null},c,"dispatch",""),Promise.all(c.map(u=>{let p=(o.get(u)??Promise.resolve()).then(()=>i(u));return o.set(u,p),p.finally(()=>{o.get(u)===p&&o.delete(u)})})).then(()=>l()))}return{render:d,flushPending:l}}function $n(e){return typeof e.type=="function"&&e.type.name?e.type.name:"anonymous"}function Kt(e){let{ctx:t,browser:n}=e,o=e.registry??fe(),r=e.renderer??fn({registry:o,ctx:t,rootEl:e.root,onError:e.onError}),i=t.ui,s=null,l=null,d={ctx:t,registry:o,renderer:r,async mount(c){s=c;let a=await q(c,t,null,o);e.root.innerHTML="";let u=$(a,t,n);if(u!=null&&e.root.appendChild(u),l=a?._child??a,i&&(i._rootVNodeId=a?._id??null),se())try{let f=[];ke(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 c=[];for(let[,a]of o.idRegistry)R(a)&&typeof a._render=="function"&&a._id&&c.push(a._id);await r.render(c)},unmount(){for(let[,c]of o.idRegistry)try{O(c,o)}catch{}e.root.innerHTML=""}};return d.close=()=>d.unmount(),d}function Dr(e,t,n,o){let r=n,i=r.__registry??fe(),s=r.browser??V();return Promise.resolve(q(t,r,null,i)).then(()=>{let l=$(t,r,s);if(l!=null&&e.appendChild(l),t._id&&i){let d=i.idRegistry.get(t._id);d&&(d._parentNode=e)}o?.onMounted?.()}).catch(l=>console.error("[vdom2] command mount error",l)),{id:t._id??""}}function jr(e,t,n){let o=n.__registry;if(o)for(let[,r]of o.idRegistry)try{O(r,o)}catch{}e.remove()}var qt=V();function Gt(e,t="bottom",n=6,o=!0){switch(t){case"bottom":return{top:e.bottom+n,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-n,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-n};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+n}}}function pn(e,t,n=8){if(!t)return e;let o=t.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let r=Number.parseFloat(t.style.top)||o.top,i=Number.parseFloat(t.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},c=qt.viewportWidth(),a=qt.viewportHeight(),u=e.top,f=e.left;return d.bottom>a-n&&(u=Math.max(n,u-(d.bottom-(a-n)))),d.top<n&&(u=Math.max(n,u+(n-d.top))),d.right>c-n&&(f=Math.max(n,f-(d.right-(c-n)))),d.left<n&&(f=Math.max(n,f+(n-d.left))),{top:u,left:f,width:e.width}}var Ae=V();function zt(e){let t=new Map,n=new Map,o=!1,r=0;function i(){r||(r=requestAnimationFrame(()=>{r=0;let a=[];for(let[u,f]of t){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,pn(g,f.panel?.(),f.margin)),a.push(u)}for(let[u,f]of n){let p=f.getScroller(),m=p instanceof Window?Ae.scrollingElement()?.scrollTop??Ae.scrollTop():p.scrollTop??0;m!==f.handle.y&&(f.handle.y=m,a.push(u))}a.length>0&&e(a)}))}function s(){o||(o=!0,Ae.addEventListener("scroll",i,{capture:!0,passive:!0}),Ae.addEventListener("resize",i))}function l(){o&&(Ae.removeEventListener("scroll",i,{capture:!0}),Ae.removeEventListener("resize",i),o=!1)}function d(a){for(let u of[...t.keys()])(u.startsWith(`popup:${a}:`)||u===`popup:${a}`||u===a)&&t.delete(u);n.delete(a)}function c(){l(),r&&(cancelAnimationFrame(r),r=0),t.clear(),n.clear()}return{popupTrackers:t,scrollTrackers:n,schedulePopupRecompute:i,ensurePopupListeners:s,destroyPopupListeners:l,cleanupTrackers:d,destroy:c}}function Un(e,t,n){return r=>{r?t(r):n?.()}}function Fe(e){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches}function mn(e){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Dn(e,t,n){let o=null,r=()=>{t(),n?.once&&o&&o.removeEventListener("animationend",r)};return s=>{s?(o=s,s.addEventListener("animationend",r)):o&&(o.removeEventListener("animationend",r),o=null)}}function jn(e,t){let{onLongPress:n,duration:o=500}=t,r,i=0,s=0,l=null,d=()=>{clearTimeout(r),r=void 0},c=e.selfId();if(c){let a=e.onUnmount(u=>{u===c&&(d(),a())})}return{onPointerDown:a=>{i=a.clientX??0,s=a.clientY??0,l=a,d(),r=setTimeout(()=>{r=void 0,l&&n(l)},o)},onPointerUp:d,onPointerLeave:d,onPointerMove:a=>{let u=Math.abs((a.clientX??0)-i),f=Math.abs((a.clientY??0)-s);(u>10||f>10)&&d()},onContextMenu:a=>{a.preventDefault(),n(a)}}}function Be(e,t){let n=e.selfId(),o="closed",r,i=()=>{o="closed",n?e.render([n]):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 Wn(e,t,n){let o=e.selfId(),r=mn(e),i=n?.duration??400,s=n?.ease==="linear"?f=>f:f=>1-Math.pow(1-f,3),l,d=t,c={value:r?t:0,reset:()=>{}},a=()=>{o?e.render([o]):e.render()},u=f=>{if(d=f,r){c.value=f,a();return}if(f===c.value)return;l&&cancelAnimationFrame(l);let p=c.value,m=performance.now(),g=h=>{let w=Math.min(1,(h-m)/i);c.value=Math.round(p+(f-p)*s(w)),w<1?(l=requestAnimationFrame(g),a()):(l=void 0,a())};l=requestAnimationFrame(g)};if(c.reset=f=>{f===d&&l||u(f)},o){let f=e.onUnmount(p=>{p===o&&(l&&(cancelAnimationFrame(l),l=void 0),f())})}return queueMicrotask(()=>u(t)),c}function Fn(e,t,n){let o=e.selfId(),r=e.browser,i=`media:${o}:${t}`;if(!e.mediaRegistry.has(i)){let s=r.matchMedia(t);n(s.matches);let l=c=>n(c.matches);s.addEventListener("change",l),e.mediaRegistry.set(i,{mql:s,handler:l});let d=e.onUnmount(c=>{if(c!==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 Bn(e,t,n){let o=e.browser,r=typeof t=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:t,i=typeof t=="function"?t:n,s=e.selfId(),l=`bp:${s}`;function d(){for(let[c,a]of Object.entries(r))if(o.matchMedia(a).matches)return c;return Object.keys(r)[0]??""}if(!e.mediaRegistry.has(l)){i(d());let c=[];for(let u of Object.values(r)){let f=o.matchMedia(u),p=()=>i(d());f.addEventListener("change",p),c.push({mql:f,handler:p})}e.mediaRegistry.set(l,{mqls:c});let a=e.onUnmount(u=>{if(u!==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 Kn(e){let t=e.selfId(),n=e.browser,o={height:n.viewportHeight(),offsetTop:0,keyboardOpen:!1},r=()=>{t?e.render([t]):e.render()},i=()=>{let l=n.visualViewport();o.height=l?.height??n.viewportHeight(),o.offsetTop=l?.offsetTop??0,o.keyboardOpen=o.height<n.viewportHeight()*.9,r()},s=n.visualViewport();if(s?.addEventListener?(s.addEventListener("resize",i),s.addEventListener("scroll",i)):n.addEventListener("resize",i),t){let l=e.onUnmount(d=>{d===t&&(s?.removeEventListener?(s.removeEventListener("resize",i),s.removeEventListener("scroll",i)):n.removeEventListener("resize",i),l())})}return o}function qn(e,t){let n=e.selfId(),o={isIn:!1,ready:!1,observe:d,refresh:c,disconnect:a},r=null,i=null,s=()=>{n?e.render([n]):e.render()};function l(){if(i?.disconnect(),i=null,!r)return;let u=typeof t.rootMargin=="function"?t.rootMargin():t.rootMargin,f=typeof t.threshold=="function"?t.threshold():t.threshold;i=new IntersectionObserver(p=>{let m=p[p.length-1];if(!m)return;let g=m.isIntersecting,h=g!==o.isIn,w=!o.ready;o.isIn=g,o.ready=!0,t.onChange?.(m,g),(h||w)&&s()},{root:t.root?t.root():null,rootMargin:u??"0px",threshold:f??0}),i.observe(r)}function d(u){r=u,u?l():(i?.disconnect(),i=null,o.isIn=!1)}function c(){l()}function a(){i?.disconnect(),i=null}if(n){let u=e.onUnmount(f=>{f===n&&(a(),u())})}return o}function Gn(e,t){let n=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:t.getScroller??(()=>window)};if(!n)return r.refresh(),r;e.scrollTrackers.set(n,i),e.ensurePopupListeners(),r.refresh();let s=e.onUnmount(l=>{l===n&&(e.scrollTrackers.delete(n),s())});return r}function yn(e,t){let n=e.selfId(),o=t.value!==void 0;if(o&&!t.onChange&&t.name&&(e.warned.has(t.name)||(e.warned.add(t.name),console.warn(`[weifuwu/${t.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
4
|
-
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!o&&n&&!e.uncontrolledValues.has(n)){e.uncontrolledValues.set(n,t.value);let i=e.onUnmount(s=>{s===n&&(e.uncontrolledValues.delete(n),i())})}let r=i=>{if(o){t.onChange?.(i);return}n&&e.uncontrolledValues.set(n,i),n?e.render([n]):e.render()};return{value:o?t.value:n?e.uncontrolledValues.get(n):t.value,setValue:r,controlled:o}}function zn(e,t){let n=e.selfId(),o=yn(e,{value:t.value,onChange:t.onChange,name:t.name});if(n&&!e.inputStates.has(n)){e.inputStates.set(n,{keyword:"",selectedLabel:""});let s=e.onUnmount(l=>{l===n&&(e.inputStates.delete(n),s())})}let r=n?e.inputStates.get(n):{keyword:"",selectedLabel:""},i=()=>{n?e.render([n]):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 Yn(e,t){let n=e.selfId(),o=!1;if(n){let d=e.onUnmount(c=>{c===n&&(o=!0,d())})}let r=()=>{o||(n?e.render([n]):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(()=>t()).then(c=>{s===d&&(i.data=c,i.loading=!1,r())}).catch(c=>{s===d&&(i.error=c,i.loading=!1,r())})};return l(),i.reload=l,i}function Xn(e,t){let n=e.selfId(),o=e.browser;if(typeof window>"u")return()=>{};if(o.addEventListener("keydown",t),n){let r=e.onUnmount(i=>{i===n&&(o.removeEventListener("keydown",t),r())})}return()=>o.removeEventListener("keydown",t)}function Jn(e,t){let n=e.browser,o=0,r=0,i=!1,s=a=>{i&&t.onMove(a,{x:a.clientX-o,y:a.clientY-r})},l=a=>{i&&(i=!1,n.removeEventListener("pointermove",s),n.removeEventListener("pointerup",l),t.onEnd?.(a))},d=a=>{i||(a.preventDefault(),i=!0,o=a.clientX,r=a.clientY,n.addEventListener("pointermove",s),n.addEventListener("pointerup",l),t.onStart?.(a))},c=e.selfId();if(c){let a=e.onUnmount(u=>{u===c&&(i&&(n.removeEventListener("pointermove",s),n.removeEventListener("pointerup",l),i=!1),a())})}return{onPointerDown:d}}function Qn(e,t){let n={};t.onDrop&&(n.onDrop=r=>{r.preventDefault(),t.onDrop(r)}),t.onDragOver&&(n.onDragOver=r=>{r.preventDefault(),t.onDragOver(r)}),t.onDragLeave&&(n.onDragLeave=r=>t.onDragLeave(r));let o={draggable:!0};if(t.onDragStart){let r=t.onDragStart;o.onDragStart=i=>{typeof document<"u"&&document.body.classList.add("wf-dragging"),r(i)}}if(t.onDragEnd){let r=t.onDragEnd;o.onDragEnd=i=>{typeof document<"u"&&document.body.classList.remove("wf-dragging"),r(i)}}return{dropProps:n,dragProps:o}}function hn(e,t){let n=e.selfId(),o={top:0,left:0,refresh:()=>{}};if(!n)return o;let r={pos:o,getEl:t.el,isOpen:t.isOpen,compute:t.compute,panel:t.panel,margin:t.margin??8};e.popupTrackers.set(n,r),e.ensurePopupListeners();let i=e.onUnmount(s=>{s===n&&(e.popupTrackers.delete(n),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,pn(d,r.panel?.(),r.margin))},o}function Zn(e,t){let n=e.selfId(),o=e.browser,r=Fe(e),i=()=>typeof t.trigger=="function"?t.trigger():t.trigger??"manual",s=t.open!==void 0,l=()=>!!t.disabled?.(),d=()=>s?typeof t.open=="function"?!!t.open():!!t.open:t.isOpen(),c=t.presence?Be(e,{name:t.name}):null,a,u=!1,f=v=>{if(!c)return v?"open":"closed";let x=c.sync(v);return v&&t.lockScroll&&!u&&(Wr(),u=!0),x},p=v=>{l()||(s?t.onOpenChange?.(v):c?v?f(!0):d()&&f(!1):t.setOpen(v))},m=()=>{let v=t.placement;return typeof v=="function"?v():v??"bottom"},g=null,h=!1,w=hn(e,{el:t.el??(()=>null),isOpen:()=>d(),compute:v=>{if(t.position){let x=t.position();return{top:x.y,left:x.x,width:x.width}}return Gt(v,m(),t.gap??6,t.center!==!1)},panel:()=>g,margin:t.margin??8}),y=v=>{if(t.closeOnOutside===!1||t.mask||!d())return;let x=v.target;if(!(x instanceof Node))return;let B=t.el?.()??null;B&&B.contains(x)||g&&g.contains(x)||p(!1)},N=v=>{t.closeOnEscape!==!1&&(v.key!=="Escape"||!d()||p(!1))};if(o.addEventListener("mousedown",y),o.addEventListener("keydown",N),n){let v=e.onUnmount(x=>{x===n&&(o.removeEventListener("mousedown",y),o.removeEventListener("keydown",N),v())})}let b={},P=v=>typeof v=="function"?v():v??0,I=()=>P(t.openDelay),j=()=>P(t.closeDelay),C,_,U=()=>{clearTimeout(C),clearTimeout(_),C=void 0,_=void 0},W=v=>{if(l())return;let x=v.currentTarget,B=v.relatedTarget;x.contains(B)||(clearTimeout(_),_=void 0,C=setTimeout(()=>{C=void 0,p(!0)},I()))},M=v=>{if(l())return;let x=v.currentTarget,B=v.relatedTarget;x.contains(B)||(clearTimeout(C),C=void 0,_=setTimeout(()=>{_=void 0,p(!1)},j()))},F=()=>{l()||(clearTimeout(_),_=void 0,C=setTimeout(()=>{C=void 0,p(!0)},I()))},G=()=>{l()||(clearTimeout(C),C=void 0,_=setTimeout(()=>{_=void 0,p(!1)},j()))},ae=()=>i()==="hover";if(b.onMouseOver=v=>{ae()&&W(v)},b.onMouseOut=v=>{ae()&&M(v)},b.onClick=()=>{ae()?r||p(!d()):i()==="click"&&p(!0)},b.onFocus=()=>{ae()?F():i()==="focus"&&(clearTimeout(_),_=void 0,p(!0))},b.onBlur=()=>{ae()?G():i()==="focus"&&(clearTimeout(C),C=void 0,_=setTimeout(()=>{_=void 0,p(!1)},j()))},i()==="longpress"){let v,x=0,B=0,ge=()=>{clearTimeout(v),v=void 0};b.onPointerDown=H=>{l()||(x=H.clientX??0,B=H.clientY??0,ge(),v=setTimeout(()=>{v=void 0,t.onTrigger?.({clientX:x,clientY:B}),p(!0)},t.longPressDuration??500))},b.onPointerUp=ge,b.onPointerLeave=ge,b.onPointerMove=H=>{let Nn=Math.abs((H.clientX??0)-x),wn=Math.abs((H.clientY??0)-B);(Nn>10||wn>10)&&ge()},b.onContextMenu=H=>{H.preventDefault(),t.onTrigger?.({clientX:H.clientX??0,clientY:H.clientY??0}),p(!0)}}if(b.onKeyDown=v=>{v.key==="Escape"&&t.closeOnEscape!==!1&&p(!1)},n){let v=e.onUnmount(x=>{x===n&&(U(),v())})}let Ie=v=>{if(v){g=v;let x=()=>w.refresh();v.addEventListener("animationend",x,{once:!0})}else g=null},de=null,xe=null,he=v=>{Ie(v),xe&&xe(v),c?.ref(v),t.trapFocus&&(v?a=Kr(v):(a?.(),a=void 0)),t.lockScroll&&!v&&u&&(Fr(),u=!1)};return{get open(){return d()},setOpen:p,get phase(){return c?c.phase:d()?"open":"closed"},sync:f,wrapProps:b,portal:(v,x="popover")=>{if(l())return null;if(!(c?c.phase!=="closed":d()))return h=!1,de=null,null;let ge=t.el?.()??null;(!h||ge!==de)&&(ge?w.refresh():queueMicrotask(()=>{d()&&w.refresh()}),h=!0,de=ge);let H=v.props??{};xe=H.ref??null;let Nn=t.positioning==="none"?H.class??"":["wf-popup",H.class].filter(Boolean).join(" "),wn=t.positioning==="none"?{...H.style??{},position:"fixed"}:{...H.style??{},position:"fixed",top:`${w.top}px`,left:`${w.left}px`,...w.width!==void 0?{width:`${w.width}px`}:{},maxWidth:(()=>{let Ye=typeof t.width=="function"?t.width():t.width;return Ye!==void 0?`min(${Ye}px, calc(100vw - 32px))`:"calc(100vw - 32px)"})()},Ve={...v,props:{...H,class:Nn,style:wn,ref:he}};if(t.mask){let Ye=typeof t.mask=="object"?t.mask:ve("div",{class:"wf-popup-mask","data-portal-mask":x,onClick:t.maskClosable===!1?void 0:()=>p(!1)}),so=t.maskCentered?ve("div",{class:"wf-cover",style:{"--wf-z":"var(--wf-z-popover)",pointerEvents:"none"}},{...Ve,props:{...Ve.props,style:{...H.style??{},pointerEvents:"auto"},ref:he}}):null,lo=t.maskCentered?void 0:{...Ve.props?.style??{},zIndex:"var(--wf-z-popover)"},ao=t.maskCentered?so:{...Ve,props:{...Ve.props,style:lo}};return Qe([Ye,ao],x)}return Qe(Ve,x)},refresh:()=>w.refresh()}}function et(e,t){let n=e.selfId();if(n&&!e.openStates.has(n)){e.openStates.set(n,!1);let l=e.onUnmount(d=>{d===n&&(e.openStates.delete(n),l())})}let o=t.open!==void 0;o&&!t.onOpenChange&&t.name&&!e.warned.has(t.name)&&(e.warned.add(t.name),console.warn(`[weifuwu/${t.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08open \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onOpenChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
5
|
-
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 open\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onOpenChange={(o) => setOpen(o)}`));let r=()=>o?!!t.open:n?e.openStates.get(n)??!1:!1,i=()=>{n?e.render([n]):e.render()},s=l=>{if(o){t.onOpenChange?.(l);return}n&&e.openStates.set(n,l),i()};return{get open(){return r()},setOpen:s,triggerProps:{onClick:()=>s(!0),onFocus:()=>{t.openOnFocus&&s(!0)}}}}var Ce=V(),Ke=0,Yt="",Xt="",Jt="",Qt="",gn=0;function Zt(){return typeof window<"u"&&typeof document<"u"}function Wr(){if(Ke++,Ke>1||!Zt())return;gn=Ce.scrollTop();let e=Ce.bodyElement();Yt=e.style.overflow,Xt=e.style.position,Jt=e.style.top,Qt=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=`-${gn}px`,e.style.width="100%")}function Fr(){if(Ke===0||(Ke--,Ke>0)||!Zt())return;let e=Ce.bodyElement();e.style.overflow=Yt,e.style.position=Xt,e.style.top=Jt,e.style.width=Qt,gn>0&&Ce.scrollTo(gn)}var Br='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Kr(e){let t;return queueMicrotask(()=>{let n=e.querySelectorAll(Br);if(n.length===0)return;let o=n[0],r=n[n.length-1],i=l=>{l.key==="Tab"&&(l.shiftKey&&Ce.activeElement()===o?(l.preventDefault(),r.focus()):!l.shiftKey&&Ce.activeElement()===r&&(l.preventDefault(),o.focus()))},s=Ce.activeElement();o.focus(),e.addEventListener("keydown",i),t=()=>{e.removeEventListener("keydown",i),s?.focus()}}),()=>t?.()}function qr(e){return e.map(t=>{let n={role:t.role,content:t.content};return t.reasoning&&(n.reasoning_content=t.reasoning),n})}function nt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function eo(e,t,n,o){n.initialMessages?e.messages=structuredClone(n.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 w=i();switch(m){case"wf:token":w&&(w.content+=g.text);break;case"wf:tool_call":{w&&(w.toolCalls||(w.toolCalls=[]),w.toolCalls.push({call:g,status:"running"}));break}case"wf:tool_progress":{let y=g,N=w?.toolCalls?.find(b=>b.call.id===y.toolCallId);N&&(N.progress=y);break}case"wf:tool_result":{let y=g,N=w?.toolCalls?.find(b=>b.call.id===y.id);N&&(N.result=y,N.status=y.ok?"ok":"error");break}case"wf:approval_request":w&&(w.approval=g);break;case"wf:usage":w&&(w.usage=g);break;case"wf:step":e.step=g;break;case"wf:done":if(w){w.status="done",w.approval=void 0;let y=g;y.reasoning&&(w.reasoning=y.reasoning)}e.streaming=!1,e.step=null;break;case"wf:error":w&&(w.status="error",w.error=g,w.approval=void 0),e.error=g,e.streaming=!1,e.step=null;break;default:h?.(m,g);break}o?.()}function l(){let m=n.body?n.body(e.messages):{messages:qr(e.messages)};r=t(n.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,w)=>s(h,w,n.onEvent)},{signal:n.signal,headers:n.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:nt(),role:"user",content:m,status:"done"},{id:nt(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function c(){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:nt(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function u(){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 w=e.messages[e.messages.length-1],y=w?.role==="assistant"?w.approval:void 0;if(y&&(w.approval=void 0,o?.(),!!n.approveUrl))try{await fetch(n.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...n.headers},body:JSON.stringify(h?{id:y.id,decision:m,note:g,modifiedArgs:h}:{id:y.id,decision:m,note:g}),signal:n.signal})}catch(N){if(n.signal?.aborted)return;e.error={code:"provider_error",message:N instanceof Error?N.message:String(N)},o?.()}}function p(){r?.abort(),r=null}return{send:d,stop:c,retry:a,clear:u,approve:f,dispose:p}}function no(e,t,n){let o=new AbortController,r=n?.signal;r&&(r.aborted?o.abort():r.addEventListener("abort",()=>o.abort(),{once:!0}));let i=n?.traceId??Jr(),s=n?.record!==!1,l=[],d=(async()=>{let c;try{c=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":i,Accept:"text/event-stream",...n?.headers},body:JSON.stringify(t),signal:o.signal})}catch(a){if(o.signal.aborted)return;n?.onError?.({code:"provider_error",message:a instanceof Error?a.message:String(a)});return}if(!c.ok){n?.onError?.({code:Xr(c.status),message:`HTTP ${c.status} ${c.statusText}`});return}try{for await(let{name:a,data:u}of zr(c.body)){if(o.signal.aborted)return;Yr(l,{name:a,data:u},s),Gr(a,u,n??{})}}catch(a){if(o.signal.aborted)return;n?.onError?.({code:"provider_error",message:a instanceof Error?a.message:String(a)})}})();return{abort:()=>o.abort(),done:d,traceId:i,events:l}}function Gr(e,t,n){switch(e){case"wf:token":return n.onToken?.(t.text);case"wf:tool_call":return n.onToolCall?.(t);case"wf:tool_result":return n.onToolResult?.(t);case"wf:tool_progress":return n.onToolProgress?.(t);case"wf:step":return n.onStep?.(t);case"wf:approval_request":return n.onApproval?.(t);case"wf:usage":return n.onUsage?.(t);case"wf:done":return n.onDone?.(t);case"wf:error":return n.onError?.(t);default:return n.onEvent?.(e,t)}}async function*zr(e){let t=e.getReader(),n=new TextDecoder,o="";try{for(;;){let{done:r,value:i}=await t.read();if(r)break;o+=n.decode(i,{stream:!0});let s=o.split(`
|
|
1
|
+
function ie(e){if(e==null||typeof e=="boolean")return"null";if(typeof e=="string"||typeof e=="number")return"text";let t=e.type;return typeof t=="function"?"comp":typeof t=="symbol"?t===te?"app":e.props?.portalKey!=null?"portal":"frag":"native"}function $e(e){return Array.isArray(e)?e.flatMap(t=>$e(t)):[e]}function V(e){if(e.children!=null)return $e(e.children);let t=e.props?.children??[];return $e(t)}var F=Symbol("v3-fragment"),ee=Symbol("v3-portal"),te=Symbol("v3-app");function C(e,t,...n){let o=t?{...t}:{};return n.length>0&&(o.children=n.length===1?n[0]:n),{type:e,props:o,key:t?.key??null}}function we(e,t,n){let o=t?{...t}:{};return delete o.key,{type:e,props:o,key:n??t?.key??null}}var gt=we;function yt(e,t,n){return we(e,t,n)}function ve(e,t){return{type:ee,props:{children:Array.isArray(e)?e:[e],portalKey:t??"default"},key:t??null}}function D(){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,t)=>typeof document<"u"?document.createElementNS(e,t):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,t,n)=>{typeof window<"u"&&window.addEventListener(e,t,n)},removeEventListener:(e,t,n)=>{typeof window<"u"&&window.removeEventListener(e,t,n)},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,t)=>{let n=typeof window<"u"?window:null,o=t&&(t.key||t.code)?"KeyboardEvent":t&&(t.clientX!==void 0||t.clientY!==void 0||t.pointerId!==void 0)?"PointerEvent":"Event";try{return new n[o](e,t)}catch{return new n.Event(e,t)}},dispatchEvent:(e,t)=>typeof e<"u"?e.dispatchEvent(t):!1,reload:()=>{typeof window<"u"&&window.location.reload()},navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},downloadFile:(e,t,n="text/plain")=>{try{if(typeof document>"u"||typeof URL>"u"||!URL.createObjectURL)return!1;let o=new Blob([t],{type:n}),r=URL.createObjectURL(o),s=document.createElement("a");return s.href=r,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>URL.revokeObjectURL(r),1e3),!0}catch{return!1}},copyText:async e=>{let t=typeof window<"u"?window:null;if(t?.navigator?.clipboard?.writeText)try{return await t.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();let o=document.execCommand("copy");return document.body.removeChild(n),o}catch{return!1}},execCommand:(e,t)=>typeof document<"u"?document.execCommand(e,!1,t):!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,t)=>typeof document<"u"?document.createTreeWalker(e,t??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,t=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??t?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,t)=>typeof window<"u"?window.setTimeout(e,t):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,t)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,t)}catch{}}}}function y(e,t,n,o){let r={entity:e,action:t,ts:Date.now()};return n!=null&&(r.target=n),o!=null&&(r.payload=o),r}function Pn(e){return`${e.entity}:${e.action}`}function ht(e=2e4,t){let n=[],o=0,r=0,s=0,a=!1,l=t?.watermark??.8,u=new Set,i=p=>n[(o+p)%e],d=(p,g)=>{n[(o+p)%e]=g},c=(p,g)=>{r<e?(d(r,p),r++):(d(0,p),o=(o+1)%e,g||(s++,(s%64===1||s===1)&&c(y("stream","overflow",void 0,{capacity:e,count:s,dropped:`${p.entity}:${p.action}`,droppedTarget:p.target??null}),!0)))},f=null,m=0;return{setSession(){return f=`s${++m}`,f},currentSession(){return f},emit(p){f!=null&&p.session==null&&(p.session=f),c(p,!1),l>0&&!a&&r>=e*l&&(a=!0,c(y("stream","watermark",void 0,{usage:r,capacity:e,ratio:l}),!0));for(let g of u)try{g(p)}catch{}},subscribe(p,g){let w=typeof p=="function"?null:p,h=typeof p=="function"?p:g,E=b=>{if(w==null){h(b);return}(Array.isArray(w)?w:[w]).includes(b.entity)&&h(b)};return u.add(E),()=>{u.delete(E)}},size(){return r},capacity(){return e},overflowCount(){return s},events(){let p=new Array(r);for(let g=0;g<r;g++)p[g]=i(g);return p},eventsBySession(p){return this.events().filter(g=>g.session===p)},inverse(p){switch(p.entity+":"+p.action){case"node:insert":return y("node","remove",p.target,{parent:p.payload?.parent});case"node:remove":return null;case"prop:update":return y("prop","update",p.target,{key:p.payload?.key,value:p.payload?.prev,prev:p.payload?.value});case"text:update":return y("text","update",p.target,{value:p.payload?.prev,prev:p.payload?.value});case"node:move":return null;default:return null}},reset(){o=0,r=0,s=0,a=!1}}}var v=ht();if(typeof globalThis<"u"){let e=globalThis;e.__wf_tail||(e.__wf_tail=(t=200,n)=>{let o=v.events().slice(-t);return n?o.filter(r=>!(n.comp&&r.payload?.name!==n.comp||n.decision&&r.payload?.reason!==n.decision||n.causeId&&r.payload?.causeId!==n.causeId)):o},e.__wf_builds=t=>{let n=v.events().filter(o=>o.entity==="comp"&&o.action==="build");return t?n.filter(o=>o.payload?.name===t).map(o=>({name:o.payload?.name,reason:o.payload?.reason,changedKeys:o.payload?.changedKeys})):n.map(o=>({name:o.payload?.name,reason:o.payload?.reason,changedKeys:o.payload?.changedKeys}))},e.__wf_recent=(t=50)=>v.events().slice(-t),e.__wf_comp=t=>v.events().filter(o=>!!(o.target===t||o.payload?.name&&!t)).map(o=>({entity:o.entity,action:o.action,target:o.target,payload:o.payload,session:o.session})))}var Ln=0;function ne(){return`n${++Ln}`}function Be(e){if(!e)return 0;let t=0;for(let n of pe.values())n.has(e)&&t++;return t}var pe=new Map,Ge=new Set,Ke=new Map,xe=new Map,ze=new Map,Fe=new Map,wt={focus:"focusin",blur:"focusout"},An=new Set(["error","load","loadstart","loadend","abort","unload","resize","message"]),_n=new Set(["input","change","compositionstart","compositionend"]);function Et(e,t,n,o=!1){let r=pe.get(t);r||(r=new Map,pe.set(t,r)),r.set(e,{handler:n,once:o})}function xt(e,t){pe.get(t)?.delete(e)&&v.emit(y("event","unbind",e,{event:t}))}function ke(e){for(let[t,n]of pe)n.delete(e)&&v.emit(y("event","unbind",e,{event:t}))}function B(e,t,n,o=!1){let r=e.getAttribute("data-v3-id");if(!r)return()=>{};Et(r,t,n,o);let s=kt(e);return s&&Nt(s,t),()=>xt(r,t)}function oe(e){Ge.add(e),On()}var vt=!1,qe=0,Ee=[];function bt(){let e=document.getSelection?.(),t=e?.toString?.()??"",n=e?.anchorNode;return{target:n&&n.nodeType===1?n.getAttribute?.("data-v3-id")??null:n?.parentElement?.getAttribute?.("data-v3-id")??null,text:t}}function On(){if(vt||(vt=!0,typeof document>"u"))return;let e=()=>{qe||(qe=requestAnimationFrame(()=>{qe=0;try{let{target:o,text:r}=bt();if(!r)return;v.emit(y("text","select",void 0,{target:o,length:r.length,sample:r.slice(0,40)}))}catch{}}))};Ee.push(L(document,"selectionchange",e));let t=o=>{let{target:r,text:s}=bt(),a=s;return o.type==="paste"&&(a=o.clipboardData?.getData?.("text")??""),{target:r,sample:a.slice(0,40)}},n=o=>{if(!(o.type!=="copy"&&o.type!=="cut"&&o.type!=="paste"))try{let{target:r,sample:s}=t(o);if(!s)return;v.emit(y("text",o.type,void 0,{target:r,length:s.length,sample:s}))}catch{}};Ee.push(L(document,"copy",n)),Ee.push(L(document,"cut",n)),Ee.push(L(document,"paste",n))}function Rn(e){Ge.delete(e),Ke.delete(e);let t=xe.get(e);if(t){for(let[n,o]of t)e.removeEventListener(n,o);xe.delete(e)}}function kt(e){let t=e;for(;t;){if(t.nodeType===1&&Ge.has(t))return t;t=t.parentNode}return null}function Nt(e,t){let n=Ke.get(e)??new Set;if(n.has(t))return;n.add(t),Ke.set(e,n);let o=wt[t]??t,r=u=>Hn(u),s=An.has(o);e.addEventListener(o,r,s?{capture:!0}:void 0);let a=xe.get(e)??new Map;a.set(o,r),xe.set(e,a);let l=e.hasAttribute("data-wf-portal-key")?`portal:${e.getAttribute("data-wf-portal-key")}`:"root";v.emit(y("event","bind",l,{event:o,delegated:!0}))}function L(e,t,n,o){let r=wt[t]??t,s=ze.get(r);s||(s=new Set,ze.set(r,s)),s.add(n);let a=Fe.get(e)??new Map;if(!a.has(r)){let l=i=>{for(let d of ze.get(r)??[])try{d(i)}catch{}},u=o?.capture?{capture:!0,passive:o?.passive??!1}:void 0;e.addEventListener(r,l,u),a.set(r,l),Fe.set(e,a),v.emit(y("event","bind",e===window?"window":"document",{event:r,delegated:!0,capture:o?.capture??!1}))}return()=>{if(s.delete(n),s.size===0){let l=a.get(r);l&&e.removeEventListener(r,l,o?.capture?{capture:!0}:void 0),a.delete(r),a.size===0&&Fe.delete(e),v.emit(y("event","unbind",e===window?"window":"document",{event:r}))}}}function Ne(e,t,n,o){if(Et(e,t,n),o){let r=kt(o);r&&Nt(r,t)}}function Hn(e){let t=e.target;t&&t.nodeType===3&&(t=t.parentElement);let n=pe.get(e.type);if(n)for(;t;){if(!t.hasAttribute?.("data-v3-id")){let r=t.closest?.("[data-v3-id]");if(r&&r!==t){t=r;continue}}let o=t.getAttribute?.("data-v3-id");if(o){let r=n.get(o);if(r){try{Object.defineProperty(e,"currentTarget",{value:t,configurable:!0})}catch{}try{r.handler(e)}catch{}if(_n.has(e.type)){let s=t?.value??null;v.emit(y("text","input",o,{event:e.type,value:typeof s=="string"?s.slice(0,100):null}))}if(r.once&&(n.delete(o),v.emit(y("event","unbind",o,{event:e.type}))),e.cancelBubble)break}}t=t.parentElement}}function In(e,t,n=400){v.emit(y("effect","animate",void 0,{target:e.getAttribute?.("data-v3-id")??null,ms:n}));let o=!1,r=()=>{o||(o=!0,s(),clearTimeout(l),t())},s=()=>{};e.getAttribute?.("data-v3-id")?s=B(e,"animationend",r,!0):e.addEventListener("animationend",r);let l=setTimeout(r,n)}function fe(e,t){return Object.assign(Object.create(e),t)}function Un(e){let t={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},n=e?.onRequest,o=e?.onResponse,r=e?.timeout??0;async function s(a,l,u,i,d=!1){let c=t.baseURL+l,f={method:a,headers:{...t.headers,...i?.headers}},m=e?.token?.();m&&!f.headers.Authorization&&(f.headers.Authorization=`Bearer ${m}`);let p=r>0,g=!!i?.signal,w=null,h=null;(p||g)&&(w=new AbortController,f.signal=w.signal,p&&(h=setTimeout(()=>w.abort(new Error("Request timed out")),r)),g&&i.signal.addEventListener("abort",()=>w.abort())),u!==void 0&&a!=="GET"&&a!=="HEAD"&&(f.body=JSON.stringify(u));let E={url:c,init:f};n&&(E=n(E));try{let b=await fetch(E.url,E.init);if(b.status===401&&await e?.onUnauthorized?.()&&!d)return s(a,l,u,i,!0);if(o)return o(b);if(!b.ok){let N=await b.text().catch(()=>"");throw new Je(b.status,N||b.statusText)}let x=b.headers.get("content-length");if(b.status===204||x==="0")return;let P=(b.headers.get("content-type")||"").toLowerCase();return P.includes("application/json")||P.includes("json")?b.json():b.text()}finally{h&&clearTimeout(h)}}return a=>fe(a,{api:{get:(u,i)=>s("GET",u,void 0,i),post:(u,i,d)=>s("POST",u,i,d),put:(u,i,d)=>s("PUT",u,i,d),patch:(u,i,d)=>s("PATCH",u,i,d),delete:(u,i)=>s("DELETE",u,void 0,i)}})}var Je=class extends Error{status;body;constructor(t,n){super(`API Error ${t}: ${n}`),this.name="ApiError",this.status=t,this.body=n}};function Dn(e){try{let t=e.split(".");if(t.length!==3)return null;let n=t[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(n))}catch{return null}}function jn(e){let t=Dn(e);return t?.exp?t.exp*1e3-3e4<Date.now():!0}function Wn(e){let t=e?.storage??localStorage,n=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",r=e?.refreshTokenKey??"weifuwu_refresh",s=e?.refreshEndpoint??"/api/auth/refresh";return a=>{let l=t.getItem(n),u=t.getItem(o),i=null,d={token:l,user:u?JSON.parse(u):null,get isLoggedIn(){return this.token!==null},login(f,m,p){d.token=f,d.user=m,t.setItem(n,f),t.setItem(o,JSON.stringify(m)),p&&t.setItem(r,p)},logout(){d.token=null,d.user=null,t.removeItem(n),t.removeItem(o),t.removeItem(r)},setUser(f){d.user=f,t.setItem(o,JSON.stringify(f))},async refresh(){return i||(i=c().finally(()=>{i=null}),i)}};async function c(){let f=t.getItem(r);if(!f)return!1;let m=t.getItem(n);try{let p=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:f})});if(t.getItem(n)!==m)return!1;if(!p.ok)return d.logout(),!1;let g=await p.json();return t.getItem(n)!==m?!1:(d.token=g.token,t.setItem(n,g.token),g.refreshToken&&t.setItem(r,g.refreshToken),!0)}catch{return!1}}return l&&jn(l)&&d.refresh().catch(()=>{}),e?.onAuth?.(d),fe(a,{auth:d})}}function $n(e={}){let t=e.url??"/ws",n=e.reconnectInterval??3e3,o=e.maxReconnect??10,r=e.pingInterval??3e4,s=e.pingTimeout??1e4;return a=>{let l=new Set,u=null,i=0,d=null,c=null,f=null,m=!1,p=[],g=new Set,w=N=>{h.isConnected=N==="connected";let M=N==="disconnected"?{attempt:i+1,max:o}:void 0;for(let O of g)try{O(N,M)}catch{}},h={isConnected:!1,onMessage:N=>(l.add(N),()=>{l.delete(N)}),onStatusChange:N=>(g.add(N),queueMicrotask(()=>{try{N(h.isConnected?"connected":"connecting",{attempt:0,max:o})}catch{}}),()=>{g.delete(N)}),send:N=>{let M=JSON.stringify(N);try{u?.readyState===WebSocket.OPEN?u.send(M):p.push(M)}catch{p.push(M)}},_connect:E,close:()=>{m=!0,P(),u?.close(),u=null,p=[],h.isConnected=!1}};async function E(){if(!m)try{u=new WebSocket(t),u.onopen=()=>{h.isConnected=!0,i=0,w("connected");for(let N of p)u.send(N);p=[],b()},u.onmessage=N=>{try{let M=JSON.parse(N.data);for(let O of l)O(M)}catch{}x()},u.onclose=()=>{h.isConnected=!1,P(),w("disconnected"),!m&&i<o&&(i++,d=setTimeout(E,n*Math.min(i,5)))},u.onerror=()=>{u?.close()}}catch{m||(d=setTimeout(E,n))}}function b(){r<=0||(c=setInterval(()=>{u?.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"ping"})),f=setTimeout(()=>{u?.close()},s)},r))}function x(){clearTimeout(f)}function P(){clearInterval(c),clearTimeout(f),clearTimeout(d)}return E(),fe(a,{ws:h})}}var Tt={components:{Button:{loading:"\u52A0\u8F7D\u4E2D..."},FileUpload:{placeholder:"\u70B9\u51FB\u6216\u62D6\u62FD\u4E0A\u4F20\u6587\u4EF6",supportedFormats:"\u652F\u6301\u683C\u5F0F: ",maxSize:"\u6700\u5927 ",remove:"\u5220\u9664"},Pagination:{ariaLabel:"\u5206\u9875"},ProgressBar:{ariaLabel:"\u8FDB\u5EA6"},Switch:{ariaLabel:"\u5207\u6362"},Breadcrumb:{ariaLabel:"\u9762\u5305\u5C51"},Modal:{ariaLabel:"\u5F39\u7A97",closeAria:"\u5173\u95ED"},Confirm:{confirmText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},Drawer:{ariaLabel:"\u4FA7\u8FB9\u9762\u677F",closeAria:"\u5173\u95ED"},DatePicker:{w0:"\u65E5",w1:"\u4E00",w2:"\u4E8C",w3:"\u4E09",w4:"\u56DB",w5:"\u4E94",w6:"\u516D",hour:"\u65F6",minute:"\u5206",time:"\u65F6\u95F4",confirm:"\u786E\u5B9A",cancel:"\u53D6\u6D88",placeholder:"\u9009\u62E9\u65E5\u671F"}}};var Mt={components:{Button:{loading:"Loading..."},FileUpload:{placeholder:"Click or drag to upload",supportedFormats:"Supported formats: ",maxSize:"Max size: ",remove:"Remove"},Pagination:{ariaLabel:"Pagination"},ProgressBar:{ariaLabel:"Progress"},Switch:{ariaLabel:"Toggle"},Breadcrumb:{ariaLabel:"Breadcrumb"},Modal:{ariaLabel:"Dialog",closeAria:"Close"},Confirm:{confirmText:"OK",cancelText:"Cancel"},Drawer:{ariaLabel:"Panel",closeAria:"Close"},DatePicker:{w0:"Su",w1:"Mo",w2:"Tu",w3:"We",w4:"Th",w5:"Fr",w6:"Sa",hour:"Hour",minute:"Min",time:"Time",confirm:"OK",cancel:"Cancel",placeholder:"Pick a date"}}};var Te={"zh-CN":Tt,"en-US":Mt};function Ct(e){if(Te[e])return e;let t=e.split("-")[0];return Object.keys(Te).find(o=>o.startsWith(t))??"zh-CN"}function zn(e={}){let{locale:t="zh-CN",messages:n={},components:o={}}=e,r=Ct(t),s=Te[r],a=Vt(s,n,o),l={locale:r,t:(u,i)=>a.messages?.[u]??i??u,setLocale:()=>{},components:a.components};return u=>{let i=u;return i.i18n=l,l.setLocale=d=>{let c=Ct(d),f=Te[c];f&&(a=Vt(f,n,o),l.locale=c,l.components=a.components,i.render?.(),i.ui?.render?.())},u}}function Vt(e,t,n){return{messages:{...e?.messages,...t},components:Fn(e?.components??{},n)}}function Fn(e,t){let n={...e};for(let o of Object.keys(t))typeof t[o]=="object"&&t[o]!==null&&typeof n[o]=="object"?n[o]={...n[o],...t[o]}:n[o]=t[o];return n}function qn(e){let t={...e},n=new Set,o=()=>{for(let r of[...n])r()};return{state:t,subscribe(r){return n.add(r),()=>{n.delete(r)}},set(r){Object.assign(t,r),o()},update(r){r(t),o()},notify:o}}var Xe=new Map;function Ye(e){e._id&&Xe.set(e._id,e)}function St(e){Xe.delete(e)}function Pt(e){return Xe.get(e)??null}var Qe=new Map;function Kn(e,t){Qe.set(e,t)}function Ze(e){return Qe.get(e)??null}function Bn(){Qe.clear()}function Lt(e,t){let n=e.selfId(),o;return n&&(o=t.subscribe(()=>e.render([n])),e.onUnmount(()=>o?.())),t}function et(e,t){let n=e.selfId(),o=t.value!==void 0;if(o&&!t.onChange&&t.name&&(e.warned.has(t.name)||(e.warned.add(t.name),console.warn(`[weifuwu/${t.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
2
|
+
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!o&&n&&!e.uncontrolledValues.has(n)){e.uncontrolledValues.set(n,t.value);let s=e.onUnmount(a=>{a===n&&(e.uncontrolledValues.delete(n),s())})}let r=s=>{if(o){t.onChange?.(s);return}n&&e.uncontrolledValues.set(n,s),n?e.render([n]):e.render()};return{value:o?t.value:n?e.uncontrolledValues.get(n):t.value,setValue:r,controlled:o}}function At(e,t){let n=e.selfId(),o=et(e,{value:t.value,onChange:t.onChange,name:t.name});if(n&&!e.inputStates.has(n)){e.inputStates.set(n,{keyword:"",selectedLabel:""});let a=e.onUnmount(l=>{l===n&&(e.inputStates.delete(n),a())})}let r=n?e.inputStates.get(n):{keyword:"",selectedLabel:""},s=()=>{n?e.render([n]):e.render()};return{...o,get keyword(){return r.keyword},setKeyword(a){r.keyword=a,s()},get selectedLabel(){return r.selectedLabel},setSelectedLabel(a){r.selectedLabel=a,s()}}}function _t(e,t){let n=e.selfId(),o=!1;if(n){let u=e.onUnmount(i=>{i===n&&(o=!0,u())})}let r=()=>{o||(n?e.render([n]):e.render())},s={data:void 0,loading:!1,error:void 0},a=0,l=()=>{let u=++a;s.loading=!0,s.error=null,r(),Promise.resolve().then(()=>t()).then(i=>{a===u&&(s.data=i,s.loading=!1,r())}).catch(i=>{a===u&&(s.error=i,s.loading=!1,r())})};return l(),s.reload=l,s}function Ot(e,t,n){return r=>{r?t(r):n?.()}}function Me(e){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches}function tt(e){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Rt(e,t){let{onLongPress:n,duration:o=500}=t,r,s=0,a=0,l=null,u=()=>{clearTimeout(r),r=void 0},i=e.selfId();if(i){let d=e.onUnmount(c=>{c===i&&(u(),d())})}return{onPointerDown:d=>{s=d.clientX??0,a=d.clientY??0,l=d,u(),r=setTimeout(()=>{r=void 0,l&&n(l)},o)},onPointerUp:u,onPointerLeave:u,onPointerMove:d=>{let c=Math.abs((d.clientX??0)-s),f=Math.abs((d.clientY??0)-a);(c>10||f>10)&&u()},onContextMenu:d=>{d.preventDefault(),n(d)}}}function Ce(e,t){let n=e.selfId(),o="closed",r,s=()=>{o="closed",n?e.render([n]):e.render()},a=null;return{get phase(){return o},ref:u=>{u?a||(r=()=>{o==="exit"&&s()},a=B(u,"animationend",r)):(a?.(),a=null,r=void 0)},sync:u=>(u?o="open":o==="open"&&(o="exit"),o)}}function Ht(e,t,n){let o=e.selfId(),r=tt(e),s=n?.duration??400,a=n?.ease==="linear"?f=>f:f=>1-Math.pow(1-f,3),l,u=t,i={value:r?t:0,reset:()=>{}},d=()=>{o?e.render([o]):e.render()},c=f=>{if(u=f,r){i.value=f,d();return}if(f===i.value)return;l&&cancelAnimationFrame(l);let m=i.value,p=performance.now(),g=w=>{let h=Math.min(1,(w-p)/s);i.value=Math.round(m+(f-m)*a(h)),h<1?(l=requestAnimationFrame(g),d()):(l=void 0,d())};l=requestAnimationFrame(g)};if(i.reset=f=>{f===u&&l||c(f)},o){let f=e.onUnmount(m=>{m===o&&(l&&(cancelAnimationFrame(l),l=void 0),f())})}return queueMicrotask(()=>c(t)),i}var It=D();function Ut(e,t="bottom",n=6,o=!0){switch(t){case"bottom":return{top:e.bottom+n,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-n,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-n};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+n}}}function Ve(e,t,n=8){if(!t)return e;let o=t.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let r=Number.parseFloat(t.style.top)||o.top,s=Number.parseFloat(t.style.left)||o.left,a=e.top-r,l=e.left-s,u={top:o.top+a,bottom:o.bottom+a,left:o.left+l,right:o.right+l},i=It.viewportWidth(),d=It.viewportHeight(),c=e.top,f=e.left;return u.bottom>d-n&&(c=Math.max(n,c-(u.bottom-(d-n)))),u.top<n&&(c=Math.max(n,c+(n-u.top))),u.right>i-n&&(f=Math.max(n,f-(u.right-(i-n)))),u.left<n&&(f=Math.max(n,f+(n-u.left))),{top:c,left:f,width:e.width}}function nt(e,t){let n=e.selfId(),o={top:0,left:0,refresh:()=>{}};if(!n)return o;let r={pos:o,getEl:t.el,isOpen:t.isOpen,compute:t.compute,panel:t.panel,margin:t.margin??8};e.popupTrackers.set(n,r),e.ensurePopupListeners();let s=e.onUnmount(a=>{a===n&&(e.popupTrackers.delete(n),s())});return o.refresh=()=>{let a=r.getEl();if(!a)return;let l=a.getBoundingClientRect();if(l.width===0&&l.height===0)return;let u=r.compute(l);Object.assign(o,Ve(u,r.panel?.(),r.margin))},o}function Dt(e,t){let n=e.selfId(),o=e.browser,r=Me(e),s=()=>typeof t.trigger=="function"?t.trigger():t.trigger??"manual",a=t.open!==void 0,l=()=>!!t.disabled?.(),u=()=>a?typeof t.open=="function"?!!t.open():!!t.open:t.isOpen(),i=t.presence?Ce(e,{name:t.name}):null,d,c=!1,f=k=>{if(!i)return k?"open":"closed";let S=i.sync(k);return k&&t.lockScroll&&!c&&(Gn(),c=!0),S},m=k=>{l()||(a?t.onOpenChange?.(k):i?k?f(!0):u()&&f(!1):t.setOpen(k))},p=()=>{let k=t.placement;return typeof k=="function"?k():k??"bottom"},g=null,w=!1,h=nt(e,{el:t.el??(()=>null),isOpen:()=>u(),compute:k=>{if(t.position){let S=t.position();return{top:S.y,left:S.x,width:S.width}}return Ut(k,p(),t.gap??6,t.center!==!1)},panel:()=>g,margin:t.margin??8}),E=k=>{if(t.closeOnOutside===!1||t.mask||!u())return;let S=k.target;if(!(S instanceof Node))return;let j=t.el?.()??null;j&&j.contains(S)||g&&g.contains(S)||m(!1)},b=k=>{t.closeOnEscape!==!1&&(k.key!=="Escape"||!u()||m(!1))},x=L(o,"mousedown",E),P=L(o,"keydown",b);if(n){let k=e.onUnmount(S=>{S===n&&(x(),P(),k())})}let N={},M=k=>typeof k=="function"?k():k??0,O=()=>M(t.openDelay),R=()=>M(t.closeDelay),A,H,En=()=>{clearTimeout(A),clearTimeout(H),A=void 0,H=void 0},xn=k=>{if(l())return;let S=k.currentTarget,j=k.relatedTarget;S.contains(j)||(clearTimeout(H),H=void 0,A=setTimeout(()=>{A=void 0,m(!0)},O()))},kn=k=>{if(l())return;let S=k.currentTarget,j=k.relatedTarget;S.contains(j)||(clearTimeout(A),A=void 0,H=setTimeout(()=>{H=void 0,m(!1)},R()))},Nn=()=>{l()||(clearTimeout(H),H=void 0,A=setTimeout(()=>{A=void 0,m(!0)},O()))},Tn=()=>{l()||(clearTimeout(A),A=void 0,H=setTimeout(()=>{H=void 0,m(!1)},R()))},he=()=>s()==="hover";if(N.onMouseOver=k=>{he()&&xn(k)},N.onMouseOut=k=>{he()&&kn(k)},N.onClick=()=>{he()?r||m(!u()):s()==="click"&&m(!0)},N.onFocus=()=>{he()?Nn():s()==="focus"&&(clearTimeout(H),H=void 0,m(!0))},N.onBlur=()=>{he()?Tn():s()==="focus"&&(clearTimeout(A),A=void 0,H=setTimeout(()=>{H=void 0,m(!1)},R()))},s()==="longpress"){let k,S=0,j=0,Z=()=>{clearTimeout(k),k=void 0};N.onPointerDown=I=>{l()||(S=I.clientX??0,j=I.clientY??0,Z(),k=setTimeout(()=>{k=void 0,t.onTrigger?.({clientX:S,clientY:j}),m(!0)},t.longPressDuration??500))},N.onPointerUp=Z,N.onPointerLeave=Z,N.onPointerMove=I=>{let je=Math.abs((I.clientX??0)-S),We=Math.abs((I.clientY??0)-j);(je>10||We>10)&&Z()},N.onContextMenu=I=>{I.preventDefault(),t.onTrigger?.({clientX:I.clientX??0,clientY:I.clientY??0}),m(!0)}}if(N.onKeyDown=k=>{k.key==="Escape"&&t.closeOnEscape!==!1&&m(!1)},n){let k=e.onUnmount(S=>{S===n&&(En(),k())})}let Mn=k=>{k?(g=k,B(k,"animationend",()=>h.refresh(),!0)):g=null},Ue=null,De=null,mt=k=>{Mn(k),De&&De(k),i?.ref(k),t.trapFocus&&(k?d=Yn(k):(d?.(),d=void 0)),t.lockScroll&&!k&&c&&(Jn(),c=!1)};return{get open(){return u()},setOpen:m,get phase(){return i?i.phase:u()?"open":"closed"},sync:f,wrapProps:N,portal:(k,S="popover")=>{if(l())return null;if(!(i?i.phase!=="closed":u()))return w=!1,Ue=null,null;let Z=t.el?.()??null;(!w||Z!==Ue)&&(Z?h.refresh():queueMicrotask(()=>{u()&&h.refresh()}),w=!0,Ue=Z);let I=k.props??{};De=I.ref??null;let je=t.positioning==="none"?I.class??"":["wf-popup",I.class].filter(Boolean).join(" "),We=t.positioning==="none"?{...I.style??{},position:"fixed"}:{...I.style??{},position:"fixed",top:`${h.top}px`,left:`${h.left}px`,...h.width!==void 0?{width:`${h.width}px`}:{},maxWidth:(()=>{let be=typeof t.width=="function"?t.width():t.width;return be!==void 0?`min(${be}px, calc(100vw - 32px))`:"calc(100vw - 32px)"})()},ce={...k,props:{...I,class:je,style:We,ref:mt}};if(t.mask){let be=typeof t.mask=="object"?t.mask:C("div",{class:"wf-popup-mask","data-portal-mask":S,onClick:t.maskClosable===!1?void 0:()=>m(!1)}),Cn=t.maskCentered?C("div",{class:"wf-cover",style:{"--wf-z":"var(--wf-z-popover)",pointerEvents:"none"}},{...ce,props:{...ce.props,style:{...I.style??{},pointerEvents:"auto"},ref:mt}}):null,Vn=t.maskCentered?void 0:{...ce.props?.style??{},zIndex:"var(--wf-z-popover)"},Sn=t.maskCentered?Cn:{...ce,props:{...ce.props,style:Vn}};return ve([be,Sn],S)}return ve(ce,S)},refresh:()=>h.refresh()}}function jt(e,t){let n=e.selfId();if(n&&!e.openStates.has(n)){e.openStates.set(n,!1);let l=e.onUnmount(u=>{u===n&&(e.openStates.delete(n),l())})}let o=t.open!==void 0;o&&!t.onOpenChange&&t.name&&!e.warned.has(t.name)&&(e.warned.add(t.name),console.warn(`[weifuwu/${t.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08open \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onOpenChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
3
|
+
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 open\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onOpenChange={(o) => setOpen(o)}`));let r=()=>o?!!t.open:n?e.openStates.get(n)??!1:!1,s=()=>{n?e.render([n]):e.render()},a=l=>{if(o){t.onOpenChange?.(l);return}n&&e.openStates.set(n,l),s()};return{get open(){return r()},setOpen:a,triggerProps:{onClick:()=>a(!0),onFocus:()=>{t.openOnFocus&&a(!0)}}}}var le=D(),ae=0,Wt="",$t="",zt="",Ft="",Se=0;function qt(){return typeof window<"u"&&typeof document<"u"}function Gn(){if(ae++,v.emit(y("effect","lock",void 0,{depth:ae})),ae>1||!qt())return;Se=le.scrollTop();let e=le.bodyElement();Wt=e.style.overflow,$t=e.style.position,zt=e.style.top,Ft=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=`-${Se}px`,e.style.width="100%")}function Jn(){if(ae===0||(ae--,v.emit(y("effect","unlock",void 0,{depth:ae})),ae>0)||!qt())return;let e=le.bodyElement();e.style.overflow=Wt,e.style.position=$t,e.style.top=zt,e.style.width=Ft,Se>0&&le.scrollTo(Se)}var Xn='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Yn(e){let t;return queueMicrotask(()=>{let n=e.querySelectorAll(Xn);if(n.length===0)return;let o=n[0],r=n[n.length-1],s=u=>{u.key==="Tab"&&(u.shiftKey&&le.activeElement()===o?(u.preventDefault(),r.focus()):!u.shiftKey&&le.activeElement()===r&&(u.preventDefault(),o.focus()))},a=le.activeElement();v.emit(y("effect","focus",void 0,{mode:"trap-start"})),o.focus();let l=L(e,"keydown",s);t=()=>{l(),v.emit(y("effect","focus",void 0,{mode:"restore"})),a?.focus()}}),()=>t?.()}function Kt(e,t,n){let o=e.selfId(),r=e.browser,s=`media:${o}:${t}`;if(!e.mediaRegistry.has(s)){let a=r.matchMedia(t);n(a.matches);let l=i=>n(i.matches);L(a,"change",l),e.mediaRegistry.set(s,{mql:a,handler:l});let u=e.onUnmount(i=>{if(i!==o)return;let d=e.mediaRegistry.get(s);if(d?.mql&&d.handler)try{d.mql.removeEventListener("change",d.handler)}catch{}e.mediaRegistry.delete(s),u()})}}function Bt(e,t,n){let o=e.browser,r=typeof t=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:t,s=typeof t=="function"?t:n,a=e.selfId(),l=`bp:${a}`;function u(){for(let[i,d]of Object.entries(r))if(o.matchMedia(d).matches)return i;return Object.keys(r)[0]??""}if(!e.mediaRegistry.has(l)){s(u());let i=[];for(let c of Object.values(r)){let f=o.matchMedia(c),m=()=>s(u());L(f,"change",m),i.push({mql:f,handler:m})}e.mediaRegistry.set(l,{mqls:i});let d=e.onUnmount(c=>{if(c!==a)return;let f=e.mediaRegistry.get(l);if(f?.mqls)for(let m of f.mqls)try{m.mql.removeEventListener("change",m.handler)}catch{}e.mediaRegistry.delete(l),d()})}}function Gt(e){let t=e.selfId(),n=e.browser,o={height:n.viewportHeight(),offsetTop:0,keyboardOpen:!1},r=()=>{t?e.render([t]):e.render()},s=()=>{let i=n.visualViewport();o.height=i?.height??n.viewportHeight(),o.offsetTop=i?.offsetTop??0,o.keyboardOpen=o.height<n.viewportHeight()*.9,r()},a=n.visualViewport(),l=null,u=null;if(a?.addEventListener?(l=L(a,"resize",s),L(a,"scroll",s)):u=L(window,"resize",s),t){let i=e.onUnmount(d=>{d===t&&(l?.(),u?.(),i())})}return o}function Jt(e,t){let n=e.selfId(),o={isIn:!1,ready:!1,observe:u,refresh:i,disconnect:d},r=null,s=null,a=()=>{n?e.render([n]):e.render()};function l(){if(s?.disconnect(),s=null,!r)return;let c=typeof t.rootMargin=="function"?t.rootMargin():t.rootMargin,f=typeof t.threshold=="function"?t.threshold():t.threshold;s=new IntersectionObserver(m=>{let p=m[m.length-1];if(!p)return;let g=p.isIntersecting,w=g!==o.isIn,h=!o.ready;o.isIn=g,o.ready=!0,t.onChange?.(p,g),(w||h)&&a()},{root:t.root?t.root():null,rootMargin:c??"0px",threshold:f??0}),s.observe(r)}function u(c){r=c,c?l():(s?.disconnect(),s=null,o.isIn=!1)}function i(){l()}function d(){s?.disconnect(),s=null}if(n){let c=e.onUnmount(f=>{f===n&&(d(),c())})}return o}function Xt(e,t){let n=e.selfId(),o=e.browser,r={y:0,refresh(){let l=s.getScroller();r.y=l instanceof Window?o.scrollingElement()?.scrollTop??o.scrollTop():l.scrollTop??0}},s={handle:r,getScroller:t.getScroller??(()=>window)};if(!n)return r.refresh(),r;e.scrollTrackers.set(n,s),e.ensurePopupListeners(),r.refresh();let a=e.onUnmount(l=>{l===n&&(e.scrollTrackers.delete(n),a())});return r}function Yt(e,t){let n=e.selfId();if(typeof window>"u")return()=>{};let o=L(window,"keydown",t);if(n){let r=e.onUnmount(s=>{s===n&&(o(),r())})}return o}function Qt(e,t){let n=e.browser,o=0,r=0,s=!1,a=m=>{s&&t.onMove(m,{x:m.clientX-o,y:m.clientY-r})},l=null,u=null,i=()=>{l?.(),l=null,u?.(),u=null},d=m=>{s&&(s=!1,i(),t.onEnd?.(m))},c=m=>{s||(m.preventDefault(),s=!0,o=m.clientX,r=m.clientY,l=L(window,"pointermove",a),u=L(window,"pointerup",d),t.onStart?.(m))},f=e.selfId();if(f){let m=e.onUnmount(p=>{p===f&&(s&&(i(),s=!1),m())})}return{onPointerDown:c}}function Zt(e,t){let n={};t.onDrop&&(n.onDrop=r=>{r.preventDefault(),t.onDrop(r)}),t.onDragOver&&(n.onDragOver=r=>{r.preventDefault(),t.onDragOver(r)}),t.onDragLeave&&(n.onDragLeave=r=>t.onDragLeave(r));let o={draggable:!0};if(t.onDragStart){let r=t.onDragStart;o.onDragStart=s=>{typeof document<"u"&&document.body.classList.add("wf-dragging"),r(s)}}if(t.onDragEnd){let r=t.onDragEnd;o.onDragEnd=s=>{typeof document<"u"&&document.body.classList.remove("wf-dragging"),r(s)}}return{dropProps:n,dragProps:o}}function Qn(e){return e.map(t=>{let n={role:t.role,content:t.content};return t.reasoning&&(n.reasoning_content=t.reasoning),n})}function ot(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function en(e,t,n,o){n.initialMessages?e.messages=structuredClone(n.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 s(){if(!e.streaming)return;let p=e.messages[e.messages.length-1];return p&&p.role==="assistant"&&p.status==="streaming"?p:void 0}function a(p,g,w){let h=s();switch(p){case"wf:token":h&&(h.content+=g.text);break;case"wf:tool_call":{h&&(h.toolCalls||(h.toolCalls=[]),h.toolCalls.push({call:g,status:"running"}));break}case"wf:tool_progress":{let E=g,b=h?.toolCalls?.find(x=>x.call.id===E.toolCallId);b&&(b.progress=E);break}case"wf:tool_result":{let E=g,b=h?.toolCalls?.find(x=>x.call.id===E.id);b&&(b.result=E,b.status=E.ok?"ok":"error");break}case"wf:approval_request":h&&(h.approval=g);break;case"wf:usage":h&&(h.usage=g);break;case"wf:step":e.step=g;break;case"wf:done":if(h){h.status="done",h.approval=void 0;let E=g;E.reasoning&&(h.reasoning=E.reasoning)}e.streaming=!1,e.step=null;break;case"wf:error":h&&(h.status="error",h.error=g,h.approval=void 0),e.error=g,e.streaming=!1,e.step=null;break;default:w?.(p,g);break}o?.()}function l(){let p=n.body?n.body(e.messages):{messages:Qn(e.messages)};r=t(n.url,p,{onToken:w=>a("wf:token",{text:w}),onToolCall:w=>a("wf:tool_call",w),onToolProgress:w=>a("wf:tool_progress",w),onToolResult:w=>a("wf:tool_result",w),onApproval:w=>a("wf:approval_request",w),onUsage:w=>a("wf:usage",w),onStep:w=>a("wf:step",w),onDone:w=>a("wf:done",w),onError:w=>a("wf:error",w),onEvent:(w,h)=>a(w,h,n.onEvent)},{signal:n.signal,headers:n.headers}),e.streaming=!0;let g=s();g&&r?.traceId&&(g.id=r.traceId)}function u(){if(e.streaming)return;let p=String(e.input??"").trim();p&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:ot(),role:"user",content:p,status:"done"},{id:ot(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function i(){r?.abort(),e.streaming=!1,e.step=null;let p=e.messages[e.messages.length-1];p&&p.role==="assistant"&&p.status==="streaming"&&(!p.content&&(!p.toolCalls||p.toolCalls.length===0)?e.messages.pop():p.status="done"),o?.()}function d(){if(e.streaming)return;let p=-1;for(let g=e.messages.length-1;g>=0;g--)if(e.messages[g].role==="user"){p=g;break}p!==-1&&(e.messages.splice(p+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:ot(),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(p,g,w){let h=e.messages[e.messages.length-1],E=h?.role==="assistant"?h.approval:void 0;if(E&&(h.approval=void 0,o?.(),!!n.approveUrl))try{await fetch(n.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...n.headers},body:JSON.stringify(w?{id:E.id,decision:p,note:g,modifiedArgs:w}:{id:E.id,decision:p,note:g}),signal:n.signal})}catch(b){if(n.signal?.aborted)return;e.error={code:"provider_error",message:b instanceof Error?b.message:String(b)},o?.()}}function m(){r?.abort(),r=null}return{send:u,stop:i,retry:d,clear:c,approve:f,dispose:m}}function tn(e,t,n){let o=new AbortController,r=n?.signal;r&&(r.aborted?o.abort():r.addEventListener("abort",()=>o.abort(),{once:!0}));let s=n?.traceId??oo(),a=n?.record!==!1,l=[],u=(async()=>{let i;try{i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":s,Accept:"text/event-stream",...n?.headers},body:JSON.stringify(t),signal:o.signal})}catch(d){if(o.signal.aborted)return;n?.onError?.({code:"provider_error",message:d instanceof Error?d.message:String(d)});return}if(!i.ok){n?.onError?.({code:no(i.status),message:`HTTP ${i.status} ${i.statusText}`});return}try{for await(let{name:d,data:c}of eo(i.body)){if(o.signal.aborted)return;to(l,{name:d,data:c},a),Zn(d,c,n??{})}}catch(d){if(o.signal.aborted)return;n?.onError?.({code:"provider_error",message:d instanceof Error?d.message:String(d)})}})();return{abort:()=>o.abort(),done:u,traceId:s,events:l}}function Zn(e,t,n){switch(e){case"wf:token":return n.onToken?.(t.text);case"wf:tool_call":return n.onToolCall?.(t);case"wf:tool_result":return n.onToolResult?.(t);case"wf:tool_progress":return n.onToolProgress?.(t);case"wf:step":return n.onStep?.(t);case"wf:approval_request":return n.onApproval?.(t);case"wf:usage":return n.onUsage?.(t);case"wf:done":return n.onDone?.(t);case"wf:error":return n.onError?.(t);default:return n.onEvent?.(e,t)}}async function*eo(e){let t=e.getReader(),n=new TextDecoder,o="";try{for(;;){let{done:r,value:s}=await t.read();if(r)break;o+=n.decode(s,{stream:!0});let a=o.split(`
|
|
6
4
|
|
|
7
|
-
`);o=
|
|
8
|
-
`))a.startsWith("event: ")?d=a.slice(7):a.startsWith("data: ")&&(c+=a.slice(6));if(c)try{yield{name:d,data:JSON.parse(c)}}catch{}}}}finally{t.releaseLock()}}function Yr(e,t,n){n&&(e.length>=1e3&&e.shift(),e.push(t))}function Xr(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Jr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function tt(e,t){let n={messages:[],input:"",streaming:!1,error:null,usage:null,step:null},o=new Set,i=eo(n,no,t,()=>{for(let l of[...o])l()});Object.assign(n,i),n.subscribe=l=>(o.add(l),()=>{o.delete(l)});let s=e.selfId();if(s){let l=e.onUnmount(d=>{d===s&&(i.dispose(),l())})}return n}function ot(e,t){let n=e.selfId(),o;return n&&(o=t.subscribe(()=>e.render([n])),e.onUnmount(()=>o?.())),t}function vn(e){let t=e.registry??fe(),n={_selfId:"_wf_root",_mounting:!1,_ctxVersion:0,_rootVNodeId:null},o={browser:e.browser,__registry:t};o.app={navigate:y=>e.browser.navigate(y)};let r=e.renderer??fn({registry:t,ctx:o,rootEl:e.root,onError:e.onError}),i=zt(y=>{for(let N of y)r.render([N],{source:"external",component:null,nodeId:null,detail:"popup-tracker"})}),s=new Map,{popupTrackers:l,scrollTrackers:d,ensurePopupListeners:c,destroyPopupListeners:a,cleanupTrackers:u}=i;ln(t,y=>{u(y),l.has(y)&&l.delete(y)});let f=new Set,p=new Map,m=new Map,g=new Map,h=y=>({selfId:()=>{let N=y?._selfVNode?._id??y?._selfId;return typeof N=="string"?N:void 0},render:N=>{let b=y?._selfVNode;return r.render(N,{source:"component",component:b&&typeof b.type=="function"?b.type.name||"anonymous":null,nodeId:b?._id??null,detail:"hook"})},browser:e.browser,onUnmount:N=>ln(t,N),registry:t,mediaRegistry:s,popupTrackers:l,scrollTrackers:d,isMounting:()=>n._mounting===!0,warned:f,uncontrolledValues:p,inputStates:m,openStates:g,ensurePopupListeners:c}),w=!1;return n.render=function(y,N){let b=N??(this?._selfVNode?{source:"component",component:this._selfVNode&&typeof this._selfVNode.type=="function"?this._selfVNode.type.name||"anonymous":null,nodeId:this._selfVNode?._id??null}:{source:"root",component:null,nodeId:null});if(y==null){let P=this._selfId!=="_wf_root"&&this._selfId?this._selfId:n._rootVNodeId;return P?r.render([P],b):(w||(w=!0,console.warn("[weifuwu] render() \u65E0\u53C2\u4F46\u65E0\u6E32\u67D3\u76EE\u6807\uFF1A\u9875\u9762\u6839\u662F native vnode\uFF08UIHandler \u76F4\u63A5\u8FD4\u56DE vnode \u7684\u9875\u9762\u5F62\u6001\uFF09\u3002\u6539\u7528 async \u7EC4\u4EF6\u5F62\u6001\uFF08const Page: Component = async ... => (props) => ...\uFF09\u6216 createStore + useExternal \u5171\u4EAB\u72B6\u6001\u3002")),Promise.resolve())}return r.render(y,b)},n.setMounting=y=>{n._mounting=y},n.endMounting=()=>{n._mounting=!1},n.bumpCtxVersion=()=>{n._ctxVersion=(n._ctxVersion??0)+1},n.selfId=function(y){if(typeof y!="string"||!y)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof y}`);if(t.idRegistry.has(y))throw new Error(`[weifuwu] Duplicate component ID: "${y}". Each component must have a unique custom ID.`);let N=this._selfVNode;N&&(N._customId=y,t.idRegistry.set(y,N))},n.onUnmount=function(y){let N=this?._selfVNode?._id??this?._selfId;if(N)return ln(t,b=>{b===N&&y()})},n.useChat=function(y){return tt(h(this),y)},n.useMedia=function(y,N){return Fn(h(this),y,N)},n.useBreakpoint=function(y,N){return Bn(h(this),y,N)},n.usePopupPosition=function(y){return hn(h(this),y)},n.useHoverCapable=function(){return Fe(h(this))},n.useStableRef=function(y,N){return Un(h(this),y,N)},n.useVisualViewport=function(){return Kn(h(this))},n.usePopup=function(y){return Zn(h(this),y)},n.useLongPress=function(y){return jn(h(this),y)},n.useInView=function(y){return qn(h(this),y)},n.useScrollPosition=function(y){return Gn(h(this),y)},n.useAsync=function(y){return Yn(h(this),y)},n.useControlled=function(y){return yn(h(this),y)},n.useControlledInput=function(y){return zn(h(this),y)},n.useOpen=function(y){return et(h(this),y)},n.usePresence=function(y){return Be(h(this),y)},n.useGlobalKey=function(y){return Xn(h(this),y)},n.useDrag=function(y){return Jn(h(this),y)},n.useDragDrop=function(y){return Qn(h(this),y)},n.useExternal=function(y){return ot(h(this),y)},n.useReducedMotion=function(){return mn(h(this))},n.useAnimationEnd=function(y,N){return Dn(h(this),y,N)},n.useTween=function(y,N){return Wn(h(this),y,N)},n.destroyPopupListeners=a,o.ui=n,{ctx:o,registry:t,renderer:r,rootUi:n,destroyPopupListeners:a}}function Qr(e){let{ctx:t,registry:n,renderer:o}=vn(e);return Kt({root:e.root,browser:e.browser,ctx:t,registry:n,renderer:o,onError:e.onError})}var Zr=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function qe(e){e.node=e.node?e.node.nextSibling:null}function ei(e,t){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(t,e.node):e.parent.appendChild(t)}function ni(e,t){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(t,e.node),qe(e)):e.parent.appendChild(t)}function ti(e,t){for(let[n,o]of Object.entries(t))n==="children"||n==="key"||n==="innerHTML"||ie(e,n,o)}function Ge(e,t,n){return oi[D(e)](e,t,n)}var oi={hole:()=>null,text:ri,arr:ii,portal:to,frag:to,comp:si,native:li};function ri(e,t,n){let o=t.browser??V(),r=String(e);if(n.node&&n.node.nodeType===3)return n.node.textContent!==r&&(n.node.textContent=r),qe(n),n.node;let i=o.createTextNode(r);return ei(n,i),i}function ii(e,t,n){let o=null;for(let r of e){let i=Ge(r,t,n);i!=null&&!o&&(o=i)}return o}function to(e,t,n){let r=e.props?.children,i=r==null?[]:Array.isArray(r)?r:[r],s=null;for(let l of i){let d=Ge(l,t,n);d!=null&&!s&&(s=d)}return s}function si(e,t,n){let o=e,r=o._child;if(r==null){if(typeof o._render!="function")throw new Error(`[vdom2] component ${k(o.type)} not built before hydration`);for(o._child=null;n.node&&n.node.nodeType===8&&n.node.nodeValue?.startsWith("wf-hole:");)qe(n);return null}let i=Ge(r,t,n);return o._refNode||(o._refNode=i),i}function li(e,t,n){let o=t.browser??V(),r=e,i=r.type,s=r.props??{};for(;n.node&&n.node.nodeType===8&&n.node.nodeValue?.startsWith("wf-hole:");)qe(n);let l;if(n.node&&n.node.nodeType===1&&n.node.tagName.toLowerCase()===i.toLowerCase()?(l=n.node,qe(n)):(l=Zr.has(i)?o.createElementNS("http://www.w3.org/2000/svg",i):o.createElement(i),ni(n,l)),r.el=l,ti(l,s),!("innerHTML"in s)){let d={parent:l,node:l.firstChild},c=(Array.isArray(s.children)?s.children:[s.children]).flat(1/0);for(let a of c){let u=Ge(a,t,d);if(u!=null&&u.parentNode!==l&&l.appendChild(u),a&&typeof a=="object"&&!Array.isArray(a)&&R(a)){let f=a;f._parentNode||(f._parentNode=l,f._refNode=u)}}for(;d.node;){let a=d.node;d.node=a.nextSibling,a.parentNode?.removeChild(a)}}return"value"in s&&l instanceof HTMLSelectElement&&(l.value=String(s.value??"")),l}async function rt(e,t,n){let o=n.__registry;await q(t,n,null,o);let r={parent:e,node:e.firstChild};for(Ge(t,n,r);r.node;){let i=r.node;r.node=i.nextSibling,i.parentNode?.removeChild(i)}}var ai={idle:{NAVIGATE_START:"navigating"},navigating:{NAVIGATE_DONE:"settled",NAVIGATE_ERROR:"idle"},settled:{NAVIGATE_START:"navigating"}};function oo(){let e="idle",t=(n,o)=>{let r=ai[e]?.[n]??null;return r==null?(T({session:"",machine:"route",nodeId:null,component:null,from:e,event:n,to:"?",payload:{path:o},level:"debug",ts:Date.now()}),e):(T({session:"",machine:"route",nodeId:null,component:null,from:e,event:n,to:r,payload:{path:o},level:"debug",ts:Date.now()}),e=r,r)};return{get state(){return e},navigateStart:n=>{t("NAVIGATE_START",n)},navigateDone:n=>{t("NAVIGATE_DONE",n)},navigateError:(n,o)=>{t("NAVIGATE_ERROR",n)}}}function Q(e,t=40){if(!e)return"null";if(e.nodeType===1){let n=e,o=[n.tagName.toLowerCase()];n.id&&o.push("#"+n.id);let r=String(n.className||"").split(" ").filter(Boolean).slice(0,2);r.length&&o.push("."+r.join("."));let i=n.getAttribute?.("data-wf-key");i&&o.push(`@${i}`);let s=n.getAttribute?.("data-wf-id");return s&&o.push(`(${s})`),o.join("").slice(0,t)}return e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,20)}-->`:e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:`#${e.nodeType}`}function st(){return!!globalThis?.__WF_DOM_TRACE}var it=!1;function ro(){if(it)return()=>{};it=!0;let e=[{proto:Node.prototype,name:"appendChild",describe:(n,o)=>({parent:Q(n),target:Q(o)})},{proto:Node.prototype,name:"insertBefore",describe:(n,o,r)=>({parent:Q(n),target:Q(o),ref:Q(r)})},{proto:Node.prototype,name:"removeChild",describe:(n,o)=>({parent:Q(n),target:Q(o)})},{proto:Node.prototype,name:"replaceChild",describe:(n,o,r)=>({parent:Q(n),target:Q(o),ref:"replace "+Q(r)})},{proto:Element.prototype,name:"setAttribute",describe:(n,o,r)=>({parent:Q(n),target:o,ref:`=${String(r).slice(0,30)}`})},{proto:Element.prototype,name:"removeAttribute",describe:(n,o)=>({parent:Q(n),target:o})}],t=new Map;for(let n of e){let o=n.proto[n.name];typeof o=="function"&&(t.set(n.name,o),n.proto[n.name]=function(...r){if(st())try{let i=n.describe(this,...r);T({session:He(),machine:"dom",nodeId:null,component:null,from:n.name,event:"WRITE",to:"",payload:()=>({...i,ts:Date.now()}),level:"trace",ts:Date.now()})}catch{}return o.apply(this,r)})}return()=>{it=!1;for(let[n,o]of t){let r=n.startsWith("set")||n.startsWith("remove")?Element.prototype:Node.prototype;r[n]=o}t.clear()}}function di(e,t){let n=V(),o=typeof t.root=="string"?n.query(t.root):t.root;if(!o)throw new Error(`uiServe: root not found: ${t.root}`);let r=o,i=!!t.hydrate;!i&&!t.loading&&(r.innerHTML="");try{if(new URLSearchParams(globalThis?.location?.search??"").get("vdom_debug")==="1"||globalThis?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1"){globalThis.__WF_VDOM_DEBUG=!0,console.log("[weifuwu] vdom debug \u5DF2\u5F00\u542F\uFF08?vdom_debug=1\uFF09"),globalThis.__WF_DOM_TRACE=!0;try{let U=e.dumpRoutes?.()??[];console.log(`[weifuwu] routes (${U.length}):`);for(let W of U)console.log(`[weifuwu] ${W.path}${W.title?" \u2014 "+W.title:""}`)}catch{}}Tn()}catch{}try{st()&&ro()}catch{}try{if(new URLSearchParams(globalThis?.location?.search??"").get("wf_reflow")==="1"||globalThis?.localStorage?.getItem?.("__WF_REFLOW_DEBUG")==="1"){globalThis.__WF_REFLOW_DEBUG=!0,console.log("[weifuwu] reflow debug \u5DF2\u5F00\u542F\uFF08?wf_reflow=1\u2014\u2014\u5E03\u5C40\u8BFB\u53D6\u8FFD\u8E2A\uFF09");let U=(M,F)=>{let G=typeof document<"u"?document.styleSheets?.length??0:-1,ae=F?.tagName?`<${F.tagName}${F.id?"#"+F.id:""}${F.className?"."+String(F.className).split(" ")[0]:""}>`:"",Ie=(new Error().stack||"").split(`
|
|
9
|
-
`).slice(2,5).map(de=>de.trim().split("/").pop()?.slice(0,80)).join(" \u2190 ");console.log(`[wf-reflow] ${M}${ae} styles=${G}${G===0?" \u26A0\uFE0F\u6837\u5F0F\u672A\u52A0\u8F7D\uFF08\u5F3A\u5236\u6392\u7248\u573A\u666F\uFF09":""} :: ${Ie}`)},W=Element.prototype.getBoundingClientRect;Element.prototype.getBoundingClientRect=function(...M){return U("rect",this),W.apply(this,M)};for(let M of["offsetWidth","offsetHeight","offsetTop","offsetLeft","clientWidth","clientHeight","scrollTop","scrollHeight"]){let F=Object.getOwnPropertyDescriptor(Element.prototype,M);if(F?.get){let G=F.get;Object.defineProperty(Element.prototype,M,{configurable:!0,enumerable:!0,get(){return U(M,this),G.call(this)}})}}}}catch{}let{ctx:s,registry:l,renderer:d,rootUi:c,destroyPopupListeners:a}=vn({browser:n,root:r}),u=new Map,f=globalThis.__DATA__??window.__DATA__;if(f&&typeof f=="object")for(let[C,_]of Object.entries(f))u.set(C,{value:_});s.data={async get(C,_){let U=u.get(C);if(U&&"value"in U)return U.value;if(U?.promise)return U.promise;if(!_)return;let W=Promise.resolve().then(()=>_()).then(M=>(u.set(C,{value:M}),M));return u.set(C,{promise:W}),W},set(C,_){u.set(C,{value:_})},has(C){return u.has(C)}},s.route={params:{},query:{},path:""};let p=null,m="",g=0,h={},w,y=new Promise(C=>{w=C}),N=!1,b=oo();async function P(C,_){let U=++g,W=C.indexOf("?"),M=W>=0?C.slice(0,W):C,F=W>=0?C.slice(W):"",G={};if(F)for(let[v,x]of new URLSearchParams(F))G[v]=x;JSON.stringify(G)!==JSON.stringify(h)&&(s.ui.bumpCtxVersion?.(),h=G);let ae={pathname:M,search:F,query:G};s.route={params:{},query:G,path:M},b.navigateStart(M);let Ie=tn(_?"initial":"nav"),de;try{de=await e.execute(ae,s,M)}catch(v){b.navigateError(C,v),de=ve("div",{class:"ui-dom-error"},`\u9875\u9762\u6E32\u67D3\u5931\u8D25: ${v?.message??String(v)}`)}if(N||U!==g){Me();return}T({session:Ie,machine:"render",nodeId:null,component:null,from:"uiServe",event:"RENDER_REQUEST",to:_?"initial":"nav",payload:()=>({source:"uiServe",detail:_?"initial":"nav",path:C,ts:Date.now()}),level:"info",ts:Date.now()});let xe=E("mount"),he=xe?xt("nav"):"";xe&&S("mount","info",he,`route path=${C} initial=${_}`);let ue;try{ue=await q(de,s,p,l)}catch(v){ue=ve("div",{class:"ui-dom-error"},`\u7EC4\u4EF6\u6E32\u67D3\u5931\u8D25: ${v?.message??String(v)}`)}if(!(N||U!==g)){if(_)if(i)await rt(r,ue,s),E("mount")&&S("mount","debug",he,`hydrate done=${r.childNodes.length}`);else{r.innerHTML="";let v=$(ue,s,n);E("mount")&&S("mount","debug",he,`first-render node=${v?.nodeName??"null"} fragKids=${v?.nodeType===11?Array.from(v.childNodes).length:"-"}`),v!=null&&r.appendChild(v),E("mount")&&S("mount","debug",he,`root-fill done=${r.childNodes.length} first=${r.firstChild?.nodeName}`)}else if(p!==void 0){let v=p;p=ue;let x=v,B=Je(x)?x.el??x._refNode:x._refNode;te(r,B,v,ue,{browser:n,registry:l,ctxVersion:s?.ui?._ctxVersion??0})}p=ue,m=C,c._rootVNodeId=ue?._id,b.navigateDone(C),d.flushPending(),Me()}}let I=n.pathname();P(I,!0).finally(()=>{N||w()}),Et(()=>p),ht(),Rt();let j=()=>{let C=typeof window<"u"?window.location.pathname+window.location.search:n.pathname();P(C,!1)};return n.addEventListener("popstate",j),{close(){N=!0,n.removeEventListener("popstate",j),a(),l.idRegistry.clear()},ready:y,ctx:s}}function ze(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function ui(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" "):""}function ci(e){return Object.entries(e).filter(([,t])=>t!=null&&t!==!1).map(([t,n])=>`${t}:${typeof n=="number"?n:String(n)}`).join(";")}var fi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),pi=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);async function ye(e,t){return xi[D(e)](e,t)}async function mi(e,t){return""}async function yi(e,t){return ze(String(e))}function gi(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)?"arr":"vnode"}var hi={hole:e=>Promise.resolve(`<!--${K({type:"hole",value:e,key:null,id:null,fid:null})}-->`),arr:async(e,t,n,o)=>{let r=await ye(e,{...t,_fidPath:o});return`<!--${K({type:"fragment-start",key:String(n),id:null,fid:o})}-->${r}<!--${K({type:"fragment-end",key:String(n),id:null,fid:o})}-->`},vnode:async(e,t)=>{let n=await ye(e,t);return n===""?`<!--${K({type:"hole",value:null,key:null,id:null,fid:null})}-->`:n}};async function vi(e,t){let n=e;kt(n);let o=t._fidPath;return(await Promise.all(n.map(async(i,s)=>{let l=o!=null?`${o}-${s}`:String(s);return hi[gi(i)](i,t,s,l)}))).join("")}async function Ni(e,t){let n=e,o=t._fidPath??null,r=await ye(n.props?.children,{...t,_fidPath:o??void 0});return`<!--${K({type:"fragment-start",key:null,id:null,fid:o})}-->${r}<!--${K({type:"fragment-end",key:null,id:null,fid:o})}-->`}async function wi(e,t){return ye(e.props?.children,t)}async function bi(e,t){let n=e,o=Object.create(t);delete o._fidPath;let r=await n.type(n.props??{},o);if(typeof r!="function")throw new Error(`Component ${k(n.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);let i=await r(n.props??{});if(n.key!=null&&i!=null&&typeof i=="object")if(Array.isArray(i))for(let s of i)s!=null&&typeof s=="object"&&!Array.isArray(s)&&(s.key=n.key);else i.key=n.key;return ye(i,o)}async function Ci(e,t){let n=e,o=n.type,r=n.props??{},i=[],s=null;n.key!=null&&i.push(` data-wf-key="${ze(String(n.key))}"`);for(let[a,u]of Object.entries(r))if(!(a==="children"||a==="key")&&a!=="ref"&&!(a.startsWith("on")&&typeof u=="function")){if(a==="innerHTML"){s=String(u??"");continue}if(a==="class"||a==="className"){let f=ui(u);f&&i.push(` class="${ze(f)}"`);continue}if(a==="style"&&u&&typeof u=="object"){i.push(` style="${ze(ci(u))}"`);continue}if(Rn.has(a)){i.push(` ${a}="${u?"true":"false"}"`);continue}if(u===!0){i.push(` ${a}`);continue}u===!1||u==null||i.push(` ${a}="${ze(String(u))}"`)}let l=i.join(""),d=pi.has(o);if(fi.has(o))return`<${o}${l}>`;if(s!==null)return`<${o}${l}>${s}</${o}>`;let c=await ye(r.children,t);return d?`<${o}${l}>${c}</${o}>`:`<${o}${l}>${c}</${o}>`}var xi={hole:mi,text:yi,arr:vi,portal:wi,frag:Ni,comp:bi,native:Ci};function io(e){return`<script>window.__DATA__=${JSON.stringify(Object.fromEntries(e)).replace(/</g,"\\u003c")};<\/script>`}function lt(e,t){let n={...e,browser:null,__registry:null,ui:{_rootVNodeId:null,render:()=>Promise.resolve(),setMounting:()=>{},endMounting:()=>{}}},o=new Map;return n.data={async get(r,i){let s=o.get(r);if(s&&"value"in s)return s.value;if(s?.promise)return s.promise;if(!i)return;let l=Promise.resolve().then(()=>i()).then(d=>(o.set(r,{value:d}),t.set(r,d),d));return o.set(r,{promise:l}),l},set(r,i){o.set(r,{value:i}),t.set(r,i)},has(r){return o.has(r)}},n}async function Vi(e,t,n,o={}){let r=o.data??new Map,i=lt(n??{},r),s=Le(e,t??{});return ye(s,i)}async function Ei(e,t){let n=new Map,r=lt({params:{},query:{}},n),i=t.url.split("?")[0].split("#")[0],s=e.match(i);r.params=s.params,r.query=Object.fromEntries(new URLSearchParams(t.url.split("?")[1]??""));let l=new URL(t.url.startsWith("http")?t.url:`http://localhost${t.url.startsWith("/")?t.url:"/"+t.url}`),d=await e.execute(l,r,i),c=await ye(d,r),a=io(n),u=s.title??t.title??"",f=t.rootId??"root",p=(t.styles??[]).map(g=>` <link rel="stylesheet" href="${g}">`).join(`
|
|
10
|
-
`),m=`<!DOCTYPE html>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
`);o=a.pop()??"";for(let l of a){let u="message",i="";for(let d of l.split(`
|
|
6
|
+
`))d.startsWith("event: ")?u=d.slice(7):d.startsWith("data: ")&&(i+=d.slice(6));if(i)try{yield{name:u,data:JSON.parse(i)}}catch{}}}}finally{t.releaseLock()}}function to(e,t,n){n&&(e.length>=1e3&&e.shift(),e.push(t))}function no(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function oo(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function nn(e,t){let n={messages:[],input:"",streaming:!1,error:null,usage:null,step:null},o=new Set,s=en(n,tn,t,()=>{for(let l of[...o])l()});Object.assign(n,s),n.subscribe=l=>(o.add(l),()=>{o.delete(l)});let a=e.selfId();if(a){let l=e.onUnmount(u=>{u===a&&(s.dispose(),l())})}return n}var on=D();function rn(e){let t=new Map,n=new Map,o=!1,r=0;function s(){r||(r=requestAnimationFrame(()=>{r=0;let f=[];for(let[m,p]of t){if(!p.isOpen())continue;let g=p.getEl();if(!g)continue;let w=g.getBoundingClientRect();if(w.width===0&&w.height===0)continue;let h=p.compute(w);Object.assign(p.pos,Ve(h,p.panel?.(),p.margin)),f.push(m)}for(let[m,p]of n){let g=p.getScroller(),w=g instanceof Window?on.scrollingElement()?.scrollTop??on.scrollTop():g.scrollTop??0;w!==p.handle.y&&(p.handle.y=w,f.push(m))}f.length>0&&e(f)}))}let a=null,l=null;function u(){o||(o=!0,a=L(window,"scroll",s,{capture:!0,passive:!0}),l=L(window,"resize",s))}function i(){o&&(a?.(),l?.(),a=null,l=null,o=!1)}function d(f){for(let m of[...t.keys()])(m.startsWith(`popup:${f}:`)||m===`popup:${f}`||m===f)&&t.delete(m);n.delete(f)}function c(){i(),r&&(cancelAnimationFrame(r),r=0),t.clear(),n.clear()}return{popupTrackers:t,scrollTrackers:n,schedulePopupRecompute:s,ensurePopupListeners:u,destroyPopupListeners:i,cleanupTrackers:d,destroy:c}}var ro=new Map,so=new Set,io=new Map,ao=new Map,lo=new Map,rt=new Map,st=rn(e=>{for(let t of e){let n=rt.get(t);if(n)try{n()}catch{}}}),uo=st.popupTrackers,co=st.scrollTrackers,po=st.ensurePopupListeners;function it(e,t,n){rt.set(e,t);let o={selfId:()=>e,render:s=>{window.__chain="env.render",!s||s.length===0||s.includes(e)?t():console.warn(`[vdom3/ui] render([${s.join(",")}]) \u8DE8\u7EC4\u4EF6\u6E32\u67D3\u6682\u672A\u5B9E\u73B0\uFF08vdom3 \u5F53\u524D\u4EC5\u7EC4\u4EF6\u81EA\u8EAB render\uFF09`)},browser:D(),onUnmount:s=>(n(()=>{s(e),rt.delete(e)}),()=>{}),registry:{idRegistry:new Map},mediaRegistry:ro,popupTrackers:uo,scrollTrackers:co,isMounting:()=>!1,warned:so,uncontrolledValues:io,inputStates:ao,openStates:lo,ensurePopupListeners:po};return{__v3ui:!0,__compId:e,render:s=>o.render(s),onUnmount:s=>{n(s)},selfId:s=>{o.registry.idRegistry.set(s,e)},useExternal:s=>Lt(o,s),useControlled:s=>et(o,s),useControlledInput:s=>At(o,s),useOpen:s=>jt(o,s),usePopup:s=>Dt(o,s),usePopupPosition:s=>nt(o,s),useTween:(s,a)=>Ht(o,s,a),useInView:s=>Jt(o,s),useScrollPosition:s=>Xt(o,s),useGlobalKey:s=>Yt(o,s),useDrag:s=>Qt(o,s),useDragDrop:s=>Zt(o,s),useMedia:(s,a)=>{Kt(o,s,a)},useBreakpoint:(s,a)=>{Bt(o,s,a)},useReducedMotion:()=>tt(o),useStableRef:(s,a)=>Ot(o,s,a),usePresence:s=>Ce(o,s),useLongPress:s=>Rt(o,s),useHoverCapable:()=>Me(o),useVisualViewport:()=>Gt(o),useAsync:s=>_t(o,s),useChat:s=>nn(o,s)}}var Le=new Map;function at(e){let t=Le.get(e);if(t){try{t()}catch{}Le.delete(e)}}function W(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&"type"in e}function Pe(e){try{let t={};for(let[n,o]of Object.entries(e))if(o!=null&&typeof o=="object"){let r=JSON.stringify(o);r!=null&&r.length<=1e4&&(t[n]=r)}return Object.keys(t).length>0?JSON.stringify(t):null}catch{return null}}var sn=new Set;function an(e,t){let n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}async function U(e,t,n,o=!1){if(typeof e.type=="function"||e.type===te){let i={...e};if(e.type===te)return r(i,t,n);let d=n!=null&&typeof n=="object"&&n.type===e.type&&n.key===e.key&&n._render?n:null;if(d){if(i._render=d._render,i._id=d._id,Ye(i),!o&&an(d.props,i.props)){if(i._child=d._child,d.el!=null&&(i.el=d.el),globalThis.__WF_V3_AUDIT!=="0"&&d._propsSnap!=null){let p=Pe(i.props);if(p!=null&&p!==d._propsSnap){let g=`${q(i.type)}:${p.slice(0,40)}`;sn.has(g)||(sn.add(g),console.warn(`[vdom3/audit] \u7EC4\u4EF6 ${q(i.type)} \u7684 props \u5BF9\u8C61\u5185\u5BB9\u5DF2\u53D8\u4F46\u5F15\u7528\u672A\u53D8\uFF08\u539F\u5730\u4FEE\u6539\u5BF9\u8C61\uFF1F\uFF09\u2014\u2014\u526A\u679D\u5C06\u8DF3\u8FC7\u91CD\u6E32\u67D3\u2014\u2014\u8BF7\u65B0\u5EFA\u5BF9\u8C61\u4F20 props\uFF08props \u4E0D\u53EF\u53D8\u5951\u7EA6\uFF09`))}}return v.emit(y("comp","build",i._id,{name:q(i.type),reused:!0,index:!0,reason:"reuse-skip",propsKeys:Object.keys(i.props)})),i._propsSnap=Pe(i.props),i}let m=Object.keys({...d.props,...i.props}).filter(p=>d.props[p]!==i.props[p]);v.emit(y("props","update",i._id,{name:q(i.type),keys:m})),i._propsSnap=Pe(i.props),v.emit(y("comp","build",i._id,{name:q(i.type),reused:!0,index:!0,reason:o?"root-render":"props-changed",changedKeys:m}))}else{i._id=ne(),Ye(i),v.emit(y("comp","build",i._id,{name:q(i.type),reused:!1,index:!0,reason:"mount"})),v.emit(y("comp","mount",i._id,{name:q(i.type)}));let m=i._id,p=()=>{window.__chain="componentRender:"+m;let h=t._componentRender;h?(window.__chain="fn("+m+")",h(m)):(window.__chain="ctx.render("+m+")",t.render())},g=Object.assign(Object.create(t),{render:p,onUnmount:h=>{Le.set(m,h)},browser:D(),ui:it(m,p,h=>{Le.set(m,h)})}),w=null;try{w=await i.type(i.props,g)}catch(h){let E=h;throw v.emit(y("error","throw",i._id,{phase:"factory",name:q(i.type),message:E?.message??String(h)})),h}i._render=w,i._propsSnap=Pe(i.props)}v.emit(y("comp","render",i._id,{name:q(i.type)}));let c=null;try{c=await i._render(i.props)}catch(m){let p=m;throw v.emit(y("error","throw",i._id,{phase:"renderFn",name:q(i.type),message:p?.message??String(m)})),m}i._child=null;let f=d?._child??null;if(c){let m=await U(c,t,f!=null&&typeof f=="object"?f:null);i._child=m}return i}async function r(i,d,c){let f=String(i.props?.appId??""),m=Ze(f);if(!m)return v.emit(y("app","error",void 0,{appId:f,reason:"unknown-app"})),i;let p=c!=null&&c.type===te&&c.appId===f;if(!p||!c._appOutput){v.emit(y("app","mount",void 0,{appId:f}));let h=await m(i.props?.props??{},d);i._appOutput=h}else{i._appOutput=c._appOutput;let h=c.props?.props??{},E=i.props?.props??{},b=[...new Set([...Object.keys(h),...Object.keys(E)])].filter(x=>h[x]!==E[x]);b.length>0&&v.emit(y("app","update",void 0,{appId:f,keys:b}))}let g=p&&c._appOutput?await U(c._appOutput,d,null):null,w=i._appOutput?await U(i._appOutput,d,g):null;return i._child=w,i.appId=f,i}let s=V(n??{}),a=0,l=null;for(let i of V(e)){if(W(i)){let d=s[a],c=await U(i,t,d!=null&&typeof d=="object"?d:null);c!==i&&(l??=[...V(e)],l[a]=c)}a++}if(l==null&&n!=null&&typeof n=="object"&&!Array.isArray(n)){let i=V(n),d=V(e);if(an(n.props??{},e.props??{})&&i.length===d.length&&i.every((c,f)=>c===d[f]))return n}let u={...e};return l&&(u.children=l),u}function q(e){return typeof e=="function"?e.name||"anonymous":String(e)}function ue(e){let t=document.getElementById("__wf_portal");t||(t=document.createElement("div"),t.id="__wf_portal",document.body.appendChild(t));let n=t.querySelector(`[data-wf-portal-key="${e}"]`);return n||(n=document.createElement("div"),n.setAttribute("data-wf-portal-key",e),t.appendChild(n)),n}var _=class{byId=new Map;idByNode=new WeakMap;removed=new Map;static PORTAL=t=>`portal:${t}`;resolveParent(t){return t.startsWith("portal:")?ue(t.slice(7)):this.get(t)}get(t){return t.startsWith("portal:")?ue(t.slice(7)):this.byId.get(t)??null}register(t,n){this.byId.set(t,n),this.idByNode.set(n,t)}idOf(t){return t?t.nodeType===1?t.getAttribute("data-v3-id")??this.idByNode.get(t)??"el":this.idByNode.get(t)??"node":"null"}unregister(t,n){this.byId.delete(t),this.removed.set(t,n)}takeRemoved(t){let n=this.removed.get(t);return n&&this.removed.delete(t),n??null}static ROOT="root"};var fo=globalThis.__WF_V3_AUDIT!=="0";function ln(e,t){if(!fo)return;let n=V(t).filter(s=>s!=null&&typeof s=="object"&&s.el!=null);if(n.length<2)return;let o=n[0].el?.parentNode;if(!o)return;let r=-1;for(let s of n){let a=s.el;if(a.parentNode!==o)return;let l=[...o.childNodes].indexOf(a);if(l<0)return;if(l<r){let u=globalThis.__WF_V3_AUDIT_STACK?new Error().stack?.split(`
|
|
7
|
+
`).slice(2,5).map(c=>c.trim().slice(0,70)).join(" | "):"",i=n.map(c=>typeof c.type=="function"?"C":String(c.type).slice(0,8)),d=n.map(c=>[...o.childNodes].indexOf(c.el));console.warn(`[vdom3/audit] children \u987A\u5E8F\u9519\u4F4D idx=${l}<${r} tag=${String(s.type).slice(0,30)} kinds=[${i.join(",")}] idxs=[${d.join(",")}] kids=${n.length} domKids=${o.childNodes.length}${u?" || "+u:""}`);return}r=l}}function Ae(e,t){if(globalThis.__WF_VDOM_AUDIT!=="1")return()=>{};let n=new Set,o=(s,a)=>{let l=`${s}:${a??"?"}`;n.has(l)||(n.add(l),console.warn(`[vdom3/audit] DOM \u53D8\u5316\u65E0\u4E8B\u4EF6\u6D41\u5BF9\u5E94\uFF08\u7ED5\u8FC7\u70B9\uFF09\uFF1A${s} id=${a??"?"}\u2014\u2014\u65E0\u4E8B\u4EF6\u6D41\u4E0D\u6E32\u67D3\u4E0D\u53D8\u91CF\u88AB\u7834\u574F`))},r=new MutationObserver(s=>{for(let a of s)if(a.type==="childList"){for(let l of a.removedNodes){if(l.nodeType!==1)continue;let u=l.getAttribute?.("data-v3-id")??null;u&&!n.has(`remove:${u}`)&&(t().some(c=>c.entity==="node"&&c.action==="remove"&&c.target===u)||o("remove",u))}for(let l of a.addedNodes){if(l.nodeType!==1)continue;let u=l.getAttribute?.("data-v3-id")??null;if(!u||[...a.removedNodes].some(f=>f.getAttribute?.("data-v3-id")===u))continue;t().some(f=>f.entity==="node"&&f.action==="insert"&&f.target===u)||o("insert",u)}}});return r.observe(e,{childList:!0,subtree:!0}),()=>r.disconnect()}var mo=new Set(["svg","path","circle","rect","line","polyline","polygon","g","defs","use","text","tspan","ellipse","title","desc","marker","symbol","linearGradient","radialGradient","stop","mask","pattern","clipPath"]);function K(e){if(e==null||typeof e!="object")return!1;let t=e.type;return t===ee||typeof t=="symbol"&&e.props?.portalKey!=null}function go(e){if(e==null||typeof e!="object")return!1;let t=e.type;return(t===F||typeof t=="symbol")&&e.props?.portalKey==null}var T=new _;function se(e,t,n){let o=T;n&&(T=n);try{oe(t),t.innerHTML="",T.register(_.ROOT,t),J(e,t)}finally{T=o}}function J(e,t,n){if(typeof e.type=="function"||e.type===te){let l=e._child!==void 0?e._child:V(e)[0]??null;if(l==null)return null;if(e.el!=null&&(e.el.isConnected||e.el.parentNode===t))return e.el;let u=J(l,t,n);return e.el=u,e._outFirst=l._outFirst??u,e._outLast=l._outLast??u,u}if(go(e)){let l=null,u=null;for(let i of V(e)){let d=lt(i,t,n);d&&(l||(l=d),u=d)}return e._outFirst=l,e._outLast=u,l}if(K(e)){let u=String(e.props?.portalKey??"default"),i=ue(u);oe(i),T.register(_.PORTAL(u),i);let d=null,c=i.childNodes.length===0;for(let f of V(e)){let m=lt(f,i);m&&!d&&(d=m)}return c&&i.childNodes.length>0&&v.emit(y("portal","open",void 0,{portalKey:u})),e.el=i,d??i}let o=e.type,r=mo.has(o)?document.createElementNS("http://www.w3.org/2000/svg",o):document.createElement(o),s=ne();r.setAttribute("data-v3-id",s),T.register(s,r),e.el=r,v.emit(y("node","create",s,{tag:e.type}));for(let[l,u]of Object.entries(e.props??{}))if(!(l==="key"||l==="children"||l==="ref")){if(typeof u=="function"&&/^on[A-Z]/.test(l)){Ne(s,l.slice(2).toLowerCase(),u,t);continue}if(u!=null&&u!==!1){if(l==="value"&&r instanceof HTMLInputElement)r.value=String(u);else if(l==="style"&&typeof u=="object"&&!Array.isArray(u)){let i=Object.entries(u).filter(([,d])=>d!=null&&d!==!1).map(([d,c])=>`${d.replace(/[A-Z]/g,f=>"-"+f.toLowerCase())}:${c}`).join(";");r.setAttribute("style",i)}else r.setAttribute(l,String(u));v.emit(y("prop","update",s,{key:l,value:u,prev:""}))}}e._outFirst=r,e._outLast=r,n&&n.parentNode===t?t.insertBefore(r,n):t.appendChild(r),v.emit(y("node","insert",s,{parent:Y(t),ref:n?$(n):null,causeId:G??void 0}));let a=e.props?.ref;typeof a=="function"&&(v.emit(y("ref","mount",s,{})),a(r));for(let l of V(e))lt(l,r);return r}function yo(e,t,n,o){if(e!=null&&typeof e=="object"&&e._outFirst&&e._outLast&&e._outLast!==e._outFirst){let r=e._outFirst,s=e._outLast;typeof e.type=="function"&&e._id?fn(e,t,o):e.el&&e.el.parentNode===t?re(e.el,t,e):r.parentNode===t&&de(r,t);let a=r.nextSibling,l=64,u=0;for(;a&&a!==s&&u++<l;){let i=a.nextSibling;de(a,t),a=i}s.parentNode===t&&de(s,t);return}if(e!=null&&typeof e=="object"&&K(e)){X(e);return}if(e!=null&&typeof e=="object"&&e._child&&K(e._child)){X(e._child);return}if(e!=null&&typeof e=="object"&&typeof e.type=="function"&&e._id){fn(e,t,o);return}e!=null&&typeof e=="object"&&e.el?re(e.el,t,e):n&&de(n,t)}function de(e,t){let n=T.idOf(e);n&&(v.emit(y("node","remove",n,{parent:Y(t),causeId:G??void 0})),T.unregister(n,e)),e.parentNode?.removeChild(e)}function ut(e,t){let n=document.createComment("wf-hole"),o=ne();return T.register(o,n),v.emit(y("node","create",o,{kind:"hole"})),t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n),v.emit(y("node","insert",o,{parent:Y(e),ref:t?$(t):null,kind:"hole",causeId:G??void 0})),n}function lt(e,t,n){if(e==null||e===!1||e===!0)return ut(t,n);if(typeof e=="string"||typeof e=="number"){let o=document.createTextNode(String(e)),r=ne();return T.register(r,o),v.emit(y("text","create",r,{value:String(e)})),n&&n.parentNode===t?t.insertBefore(o,n):t.appendChild(o),v.emit(y("node","insert",r,{parent:Y(t),ref:n?$(n):null})),o}return J(e,t,n)}function z(e,t,n,o,r){let s=T;r&&(T=r);try{return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&e===t?e.el??null:vo(e,t,n,o)}finally{T=s}}var ho=0,G=null,gn=[];function un(){return gn.push(G),G=`c${++ho}`,G}function dn(){G=gn.pop()??null}function cn(e){if(e==null||typeof e=="boolean")return"hole";if(typeof e=="string"||typeof e=="number")return"text";if(typeof e=="object"&&!Array.isArray(e)){let t=e.type;return typeof t=="function"?"comp":t===F?"frag":t===ee?"portal":"native"}return"unknown"}function vo(e,t,n,o){let r=cn(e),s=cn(t);if(v.emit(y("diff","transition",void 0,{from:r,to:s,level:"trace"})),typeof t=="string"||typeof t=="number"){let i=String(t),d=e&&typeof e=="object"?e.el:n.childNodes[0]??null;if(d&&d.nodeType===3)return d.nodeValue!==i&&(v.emit(y("text","update",$(d),{value:i,prev:d.nodeValue??""})),d.nodeValue=i),d;let c=document.createTextNode(i),f=ne();return T.register(f,c),v.emit(y("text","create",f,{value:i})),o&&o.parentNode===n?n.insertBefore(c,o):n.appendChild(c),v.emit(y("node","insert",f,{parent:Y(n),ref:o?$(o):null})),c}if(t==null||t===!1||t===!0){if(e!=null&&typeof e=="object"&&!Array.isArray(e)){if(K(e))X(e);else if(e.el&&e.el.parentNode===n){let i=T.idOf(e.el);v.emit(y("node","remove",i,{parent:Y(n)})),e.el.parentNode?.removeChild(e.el),T.unregister(i,e.el)}}return null}let a=t,l=e!=null&&typeof e=="object"&&"type"in e;if(l&&e.type===a.type&&e.key===a.key){let i=e,d=ie(a);_e(l?ie(e):null,d,"reuse");let c=ko[d];return c?c(i,a,n,o):(_e(l?ie(e):null,d,"unhandled"),console.warn(`[vdom3/patch] kind=${d} \u65E0\u540C\u7C7B\u578B\u5904\u7406\u5668\u2014\u2014\u964D\u7EA7\u91CD\u5EFA\uFF08kind \u5206\u53D1\u5B8C\u6574\u6027\u7F3A\u5931\uFF09`),J(a,n,o))}if(_e(l?ie(e):null,ie(a),"rebuild"),l&&typeof e.type=="function"&&e._id&&(at(e._id),v.emit(y("comp","unmount",e._id,{name:ct(e.type)}))),l){let i=e.el;i&&i.parentNode===n?re(i,n,e):e&&K(e)&&X(e)}return J(a,n,o)}function bo(e,t,n){let o=$(e),r=new Set([...Object.keys(t??{}),...Object.keys(n??{})]),s=t?.ref,a=n?.ref;s!==a&&(typeof s=="function"&&s(null),typeof a=="function"&&a(e));for(let l of r){if(l==="key"||l==="children"||l==="ref")continue;let u=t?.[l],i=n?.[l];if(u!==i&&!(u!=null&&i!=null&&typeof u=="object"&&typeof i=="object"&&!Array.isArray(u)&&!Array.isArray(i)&&Co(u,i))){if(typeof i=="function"&&/^on[A-Z]/.test(l)){Ne(o,l.slice(2).toLowerCase(),i,e);continue}if(i==null||i===!1)l==="value"&&e instanceof HTMLInputElement?e.value="":e.removeAttribute(l);else if(l==="value"&&e instanceof HTMLInputElement)e.value=String(i);else if(l==="style"&&typeof i=="object"&&!Array.isArray(i)){let d=Object.entries(i).filter(([,c])=>c!=null&&c!==!1).map(([c,f])=>`${c.replace(/[A-Z]/g,m=>"-"+m.toLowerCase())}:${f}`).join(";");e.setAttribute("style",d)}else e.setAttribute(l,String(i));v.emit(y("prop","update",o,{key:l,value:i,prev:u??""}))}}}function _e(e,t,n){v.emit(y("vnode","patch",void 0,{oldKind:e,newKind:t,strategy:n}))}function wo(e,t,n,o){let r=e.el;return r==null?(_e(ie(e),"native","unhandled"),console.warn(`[vdom3/patch] native \u590D\u7528\u4F46 ov.el \u7F3A\u5931\uFF08tag=${String(e.type)}\u2014\u2014kind \u5206\u53D1\u6216\u6E32\u67D3\u65F6\u5E8F\u9519\u8BEF\uFF09\u2014\u2014\u964D\u7EA7\u91CD\u5EFA`),J(t,n,o)):(t.el=r,bo(r,e.props,t.props),dt(e,t,r),r)}function pn(e,t,n,o){t._render=e._render,t._id=e._id;let r=t._child!==void 0?t._child:V(t)[0]??null,s=e._child!==void 0?e._child:V(e)[0]??null;if(r==null||r===!1||r===!0){if(s&&K(s))X(s);else if(e.el){Oe(s);let a=e._outFirst??e.el,l=e._outLast??e.el;if(l!==a&&a.parentNode===n){let u=T.idOf(a);v.emit(y("node","remove",u,{parent:Y(n)})),a.parentNode?.removeChild(a),T.unregister(u,a);let i=a.nextSibling,d=64,c=0;for(;i&&i!==l&&c++<d;){let f=i.nextSibling;de(i,n),i=f}l.parentNode===n&&de(l,n)}else{let u=T.idOf(e.el);v.emit(y("node","remove",u,{parent:Y(n)})),e.el.parentNode?.removeChild(e.el),T.unregister(u,e.el)}e.el=null}return t.el=null,null}return e.el==null||!(e.el.isConnected||e.el.parentNode===n)?t.el=J(t,n,o):(z(s,r,n,o),t.el=e.el,t._outFirst=r._outFirst??t.el,t._outLast=r._outLast??t.el),t.el}function Eo(e,t,n,o){dt(e,t,n,No(e));let r=V(e).find(u=>u!=null&&typeof u=="object"&&!Array.isArray(u));t.el=e.el??r?.el??null;let s=V(t).filter(u=>u!=null&&typeof u=="object"&&!Array.isArray(u)),a=s[0],l=s[s.length-1];return t._outFirst=a?.el??t.el,t._outLast=l?._outLast??l?.el??t.el,t.el}function xo(e,t,n,o){let r=String(t.props?.portalKey??"default"),s=ue(r);return T.register(_.PORTAL(r),s),dt(e,t,s),t.el=s,s}var ko={native:wo,comp:pn,app:pn,frag:Eo,portal:xo,text:void 0,null:void 0};function No(e){let n=V(e).find(r=>r!=null&&typeof r=="object"&&!Array.isArray(r))?.el,o=n?.parentNode;if(o&&n){let r=0;for(let s of o.childNodes){if(s===n)return r;r++}}return 0}function To(e,t,n){let o=new Map;e.forEach((s,a)=>{W(s)&&s.key!=null&&o.set(s.key,a)});let r=null;for(let s=0;s<t.length;s++){let a=t[s];if(!W(a)||a.key==null){r=null;continue}let l=o.get(a.key),u=null;if(l!=null&&W(e[l])&&(u=e[l].el??null),u&&u.parentNode===n){let i=r?r.nextSibling:n.firstChild;if(i!==u){let d=u.previousSibling?T.idOf(u.previousSibling):null;n.insertBefore(u,i),v.emit(y("node","move",T.idOf(u),{parent:$(n),ref:i?T.idOf(i):null,prev:d,key:a.key,causeId:G??void 0}))}r=u}}}function Mo(e,t,n){let o=new Map;for(let a of e)W(a)&&a.key!=null&&o.set(a.key,a);To(e,t,n);let r=null;for(let a of t){let l=a,u=o.get(l.key??"")??null;u&&u!==l?(z(u,l,n),r=l.el??r):u||(J(l,n,r?r.nextSibling:n.firstChild),r=l.el??r)}let s=new Set(t.filter(a=>W(a)).map(a=>a.key));for(let a of e)if(W(a)&&a.key!=null&&!s.has(a.key)&&a.el?.parentNode===n){let l=T.idOf(a.el);v.emit(y("node","remove",l,{parent:$(n)})),a.el.parentNode?.removeChild(a.el),T.unregister(l,a.el)}}function Oe(e){if(e==null||typeof e!="object"||Array.isArray(e))return;let t=e.props?.ref;if(typeof t=="function"){let n=e.el;v.emit(y("ref","cleanup",n?T.idOf(n):"null")),t(null)}for(let n of V(e))n!=null&&typeof n=="object"&&!Array.isArray(n)&&Oe(n)}function fn(e,t,n){let o=e._id;if(o&&(at(o),v.emit(y("comp","unmount",o,{name:ct(e.type)})),St(o)),e.el)re(e.el,t,e);else{let r=t.childNodes[n];r&&r.parentNode?.removeChild(r)}}function re(e,t,n){let o=globalThis.__WF_V3_AUDIT!=="0"?Be(T.idOf(e)):0;if(ke(T.idOf(e)),o>0){let s=Be(T.idOf(e));s>0&&console.warn(`[vdom3/audit] \u8282\u70B9\u76D1\u542C\u6B8B\u7559\uFF1A${s}/${o} \u4E2A\u76D1\u542C\u672A\u6E05\u7406\uFF08${String(n?.type??e.nodeName).slice(0,20)}\uFF09\u2014\u2014\u4E8B\u4EF6\u4ECD\u4F1A\u54CD\u5E94\u2014\u2014\u6CC4\u6F0F`)}n&&Oe(n);let r=T.idOf(e);v.emit(y("node","remove",r,{parent:Y(t),causeId:G??void 0})),e.parentNode?.removeChild(e),T.unregister(r,e)}function Co(e,t){let n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}function X(e){let t=String(e.props?.portalKey??"default"),n=ue(t);Oe(e);for(let o of[...n.childNodes]){ke(T.idOf(o));let r=T.idOf(o);v.emit(y("node","remove",r,{parent:_.PORTAL(t)})),n.removeChild(o),T.unregister(r,o)}n.childNodes.length===0&&v.emit(y("portal","close",void 0,{portalKey:t}))}var mn=new Set;function dt(e,t,n,o=0){let r=V(e),s=V(t),a=s.length>1&&s.every(c=>W(c)&&c.key!=null)?"keyed":"unkeyed";if(v.emit(y("diff","mode",void 0,{mode:a,len:s.length,prevLen:r.length,level:"trace"})),globalThis.__WF_V3_AUDIT!=="0"&&r.length!==s.length){let c=`${s.length}:${r.length}`;if(!mn.has(c)){mn.add(c);for(let f=0;f<s.length;f++){let m=s[f];if(m!=null&&typeof m=="object"&&!Array.isArray(m)&&typeof m.type=="function"&&m.key==null){console.error(`[vdom3/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${f} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\uFF08${ct(m.type)}\uFF09\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`);break}}}}if(s.length>1&&s.every(c=>W(c)&&c.key!=null)){Mo(r,s,n);return}let l=c=>!!c&&c.nodeType===8&&(c.nodeValue??"").includes("wf-hole"),u=Math.max(r.length,s.length),i=o,d=(c,f)=>{if(c!=null&&typeof c=="object"&&!Array.isArray(c)){let m=c._outFirst,p=c._outLast;if(m&&p&&p!==m){let g=1,w=m,h=64,E=0;for(;w&&w!==p&&E++<h;)g++,w=w.nextSibling;return g}}return f?1:0};for(let c=0;c<u;c++){let f=c<r.length?r[c]:null,m=c<s.length?s[c]:null,p=n.childNodes[i]??null,g=()=>yo(f,n,p,c);if(c>=s.length){let h=f!=null&&typeof f=="object"&&f._outFirst&&f._outLast&&f._outLast!==f._outFirst?d(f,p):1;g(),i+=h;continue}if(typeof m=="string"||typeof m=="number"){let h=String(m);if(p&&p.nodeType===3)p.nodeValue!==h&&(v.emit(y("text","update",$(p),{value:h,prev:p.nodeValue??""})),p.nodeValue=h);else{let E=document.createTextNode(h),b=ne();if(T.register(b,E),v.emit(y("text","create",b,{value:h})),p&&p.parentNode===n){let x=T.idOf(p);x&&(v.emit(y("node","remove",x,{parent:$(n)})),T.unregister(x,p)),n.replaceChild(E,p)}else n.appendChild(E);v.emit(y("node","insert",b,{parent:$(n),ref:null}))}i+=1;continue}if(m==null||m===!1||m===!0){if(!l(p)){un();try{let h=p?p.nextSibling:null;g(),ut(n,h)}finally{dn()}}i+=1;continue}if(f!=null&&typeof f=="object"&&f.type===m.type)z(f,m,n,p??null);else{un();try{let h=J(m,n,p??null);p&&!l(p)?g():p&&l(p)&&de(p,n),h==null&&!p&&ut(n,null)}finally{dn()}}let w=d(m,p)||(f!=null&&typeof f=="object"&&!Array.isArray(f)&&f._outFirst&&f._outLast&&f._outLast!==f._outFirst?d(f,p):1);i+=w}ln(n,t)}function ct(e){return typeof e=="function"?e.name||"anonymous":String(e)}function $(e){return T.idOf(e)}function Y(e){return T.idOf(e)}var Re=class{queue=[];running=!1;iterations=0;schedule(t){this.queue.push(t),this.running||(this.running=!0,this.iterations=0,queueMicrotask(()=>this.flush()))}flush(){if(!(!this.running&&this.queue.length===0)){this.running=!0;do{if(++this.iterations>10){console.error("[vdom3/scheduler] \u6E32\u67D3\u5FAA\u73AF\u8D85\u9650\uFF08\u7591\u4F3C\u6B7B\u5FAA\u73AF\uFF09\u2014\u2014\u4E2D\u6B62\u672C\u8F6E flush"),this.queue=[];break}let t=this.queue;this.queue=[];for(let n of t)try{n()}catch(o){console.error("[vdom3/scheduler] render error:",o)}}while(this.queue.length>0);this.running=!1,this.iterations=0}}pending(){return this.queue.length}get isRunning(){return this.running}},me=new Re;function Vo(e){return typeof e.type=="function"&&e.type.name||"anonymous"}function ge(e,t){if(e==null||typeof e!="object"||Array.isArray(e))return null;if(e._id===t)return e;let n=e._child;if(n!=null&&typeof n=="object"&&!Array.isArray(n)){let o=ge(n,t);if(o)return o}for(let o of V(e))if(o!=null&&typeof o=="object"&&!Array.isArray(o)){let r=ge(o,t);if(r)return r}return null}function yn(e,t,n){let o=Math.round(t+n);v.emit(y("render","duration",e??void 0,{ms:o,buildMs:Math.round(t),patchMs:Math.round(n)}));let r=globalThis.__v3SlowMs??100;o>r&&console.warn(`[vdom3/audit] \u6E32\u67D3\u8017\u65F6 ${o}ms\uFF08build ${Math.round(t)}ms + patch ${Math.round(n)}ms\uFF09\u2014\u2014session ${e??"?"}\u2014\u2014${r}ms \u4EE5\u4E0A\u89C6\u4E3A\u6162\u6E32\u67D3\uFF08__v3SlowMs \u53EF\u8C03\uFF09`)}function He(e,t,n){let o=e,r=!1,s=!1,a=new Set,l=new Set;async function u(g){if(a.has(g)){l.add(g),v.emit(y("render","queued",g,{target:"comp",cause:"coalesced"}));return}a.add(g),v.emit(y("render","flushed",g,{target:"comp",cause:"manual"})),v.setSession();let w=v.currentSession(),h=performance.now();try{do{l.delete(g);let E=ge(o,g);if(!E||typeof E.type!="function"||!E._render)break;let b=globalThis.__WF_V3_STACK==="1";v.emit(y("comp","render",E._id,{name:Vo(E),...b?{stack:new Error().stack?.split(`
|
|
8
|
+
`).slice(2,5).map(R=>R.trim().slice(0,80)).join(" | ")}:{}}));let x=globalThis.__v3HangMs??3e3,P=await Promise.race([E._render(E.props),new Promise((R,A)=>setTimeout(()=>A(new Error(`renderFn \u6302\u8D77\u8D85\u65F6\uFF08${x}ms\uFF09\u2014\u2014\u7EC4\u4EF6 ${g} \u672A resolve`)),x))]),N=E._child??null,M=P?await Promise.race([U(P,d,N??void 0),new Promise((R,A)=>setTimeout(()=>A(new Error(`buildVNode \u6302\u8D77\u8D85\u65F6\uFF08${x}ms\uFF09\u2014\u2014\u7EC4\u4EF6 ${g} \u8F93\u51FA\u6784\u5EFA\u672A resolve`)),x))]):null;E._child=M;let O=E.el?.parentNode??t;if(N&&M)z(N,M,O);else if(M)se(M,O);else if(N||E.el)if(N&&K(N))X(N);else{let R=N&&N.el||E.el;R&&R.parentNode===O&&re(R,O,N)}E.el=M?.el??null}while(l.has(g))}catch(E){let b=E;v.emit(y("error","caught",g,{phase:"update",name:"component",message:b?.message??String(E)}))}finally{a.delete(g)}}async function i(){let g=v.setSession();if(r){s=!0,v.emit(y("render","queued",void 0,{target:"root",cause:"coalesced"}));return}r=!0,v.emit(y("render","flushed",void 0,{target:"root",cause:"manual"}));let w=performance.now(),h=0;try{do{s=!1;let E=await U(e,d,o,!0);h=performance.now()-w,o==null?se(E,t):z(o,E,t),o=E}while(s);yn(g,h,performance.now()-w-h)}finally{r=!1}}let d=Object.assign(Object.create(n?.ctx??null),{_vnode:e,_parent:t,render(){me.schedule(()=>{i()})}}),c=g=>{me.schedule(()=>{u(g)})};d._componentRender=c;let f,m=new Promise(g=>{f=g}),p={ctx:d,ready:m,rerender:()=>me.schedule(()=>{i()}),flush:()=>me.flush(),unmount(){o._id&&v.emit(y("comp","unmount",o._id,{name:"root"})),t.innerHTML=""}};return oe(t),Ae(t,()=>v.events().slice(-200)),(async()=>{v.setSession();let g=v.currentSession(),w=performance.now();try{let h=await U(e,d),E=performance.now()-w;se(h,t),o=h,yn(g,E,performance.now()-w-E)}catch(h){let E=h;v.emit(y("error","caught",e._id??"root",{phase:"mount",name:"root",message:E?.message??String(h)}))}finally{f()}})(),p}function So(e){let t=[],n=String(e).replace(/:(\w+)/g,(o,r)=>(t.push(r),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${n}$`),keys:t}}function Po(e,t){for(let n of e){let{re:o,keys:r}=So(n.path),s=t.match(o);if(!s)continue;let a={};for(let l=0;l<r.length;l++)a[r[l]]=decodeURIComponent(s[l+1]);return{def:n,params:a}}return null}function pt(e){return typeof e.type=="function"&&e.type.name||"anonymous"}function Lo(e,t,n){let o=null,r=null,s=!1,a=new Set,l=null;oe(t),Ae(t,()=>v.events().slice(-200));let u={},i={path:"",params:{}},d=()=>Object.assign(Object.create(n?.ctx??{}),{render:()=>{c()},_componentRender:b=>{m(b)},route:i});async function c(){if(s){l={type:"refresh"};return}if(!o||!r){v.emit(y("internal","skip","page",{reason:o?"no-page-vnode":"no-current"}));return}s=!0;try{let b=r;if(typeof b.type=="function"&&b._render){v.emit(y("comp","render",b._id,{name:pt(b)}));let x=3e3,P=await Promise.race([b._render(b.props),new Promise((O,R)=>setTimeout(()=>R(new Error(`\u9875\u9762 renderFn \u6302\u8D77\u8D85\u65F6\uFF08${x}ms\uFF09`)),x))]);if(P==null)return;let N=b._child??null,M=await U(P,u,N&&typeof N=="object"?N:null);b._child=M,z(N,M,t)}}catch(b){let x=b;v.emit(y("error","caught",r?._id??"page",{phase:"update",name:"page",message:x?.message??String(b)}))}finally{if(s=!1,l!=null){let b=l;l=null,p(b)}}}let f=()=>globalThis.__v3HangMs??3e3;async function m(b){if(s){v.emit(y("internal","queue",b,{reason:"busy"})),a.add(b);return}if(!o){v.emit(y("internal","skip",b,{reason:"no-current"}));return}s=!0;try{let x=Pt(b)??ge(o,b);if(!x||typeof x.type!="function"||!x._render){v.emit(y("internal","notfound",b,{reason:"comp-missing-or-render-absent"}));return}v.emit(y("comp","render",x._id,{name:pt(x)}));let P=f(),N=await Promise.race([x._render(x.props),new Promise((A,H)=>setTimeout(()=>H(new Error(`renderFn \u6302\u8D77\u8D85\u65F6\uFF08${P}ms\uFF09\u2014\u2014\u7EC4\u4EF6 ${b} \u672A resolve`)),P))]),M=x._child??null,O=N?await Promise.race([U(N,u,M??void 0),new Promise((A,H)=>setTimeout(()=>H(new Error(`buildVNode \u6302\u8D77\u8D85\u65F6\uFF08${P}ms\uFF09\u2014\u2014\u7EC4\u4EF6 ${b} \u8F93\u51FA\u6784\u5EFA\u672A resolve`)),P))]):null;x._child=O;let R=x.el?.parentNode??t;if(M&&O)z(M,O,R);else if(O)se(O,R);else if(M||x.el)if(M&&K(M))X(M);else{let A=M&&M.el||x.el;A&&A.parentNode===R&&re(A,R,M)}x.el=O?.el??null}catch(x){let P=x;v.emit(y("error","caught",b,{phase:"update",name:pt(ge(o,b)??{}),message:P?.message??String(x)}))}finally{if(s=!1,a.size>0){let x=a.values().next().value;a.delete(x),m(x)}else if(l!=null){let x=l;l=null,p(x)}}}function p(b){b.type==="nav"?g(b.path):b.type==="comp"?m(b.id):c()}async function g(b){if(s){l={type:"nav",path:b};return}s=!0;try{let x=Po(e,b);if(v.emit(y("route","change",void 0,{path:b,params:x?.params??{}})),!x){t.innerHTML="",o=null,r=null;return}u=d(),i.path=b,i.params=x.params;let P=x.def.render(x.params),N=x.def.layout?x.def.layout(P):P,M=await U(N,u,o,!0);o==null?se(M,t):z(o,M,t),o=M,r=M}finally{if(s=!1,l!=null){let x=l;l=null,p(x)}}}let h=L(window,"popstate",()=>{g(window.location.pathname)}),E=n?.initialPath??window.location.pathname;return g(E),{navigate(b){window.history.pushState(null,"",b),g(b)},path:()=>window.location.pathname,refresh:()=>{g(window.location.pathname)},close:()=>{h()}}}function Q(e){return`${e.entity}:${e.action}`}function Ie(e,t,n){switch(Q(e)){case"node:create":{let o=e.payload;if(o.kind==="hole"){let s=document.createComment("wf-hole");n.register(e.target,s);break}let r=document.createElement(o.tag);r.setAttribute("data-v3-id",e.target),n.register(e.target,r);break}case"text:create":{let o=e.payload,r=document.createTextNode(o.value);n.register(e.target,r);break}case"node:insert":{let o=e.payload,r=o.parent===_.ROOT?t:n.resolveParent(o.parent),s=n.get(e.target),a=o.ref?n.get(o.ref):null;r&&s&&(a&&a.parentNode===r?r.insertBefore(s,a):r.appendChild(s));break}case"node:remove":{let o=n.get(e.target);o?.parentNode&&o.parentNode.removeChild(o);break}case"node:move":{let o=e.payload,r=n.get(e.target),s=o.parent===_.ROOT?t:n.resolveParent(o.parent),a=o.ref?n.get(o.ref):null;r&&s&&r.parentNode===s&&(a&&a.parentNode===s?s.insertBefore(r,a):s.appendChild(r));break}case"prop:update":{let o=e.payload,r=n.get(e.target);r?.nodeType===1&&(o.value==null||o.value===!1?r.removeAttribute(o.key):r.setAttribute(o.key,String(o.value)));break}case"text:update":{let o=e.payload,r=n.get(e.target);r?.nodeType===3&&(r.nodeValue=o.value);break}default:break}}function Ao(e,t,n=new _){n.register(_.ROOT,t),t.innerHTML="";for(let o of e)Ie(o,t,n)}function _o(e,t,n=new _){let r=e.filter(s=>Q(s)==="node:insert"||Q(s)==="node:remove"||Q(s)==="prop:update"||Q(s)==="text:update"||Q(s)==="node:move").slice(-t);for(let s of[...r].reverse())switch(Q(s)){case"node:insert":{let a=n.get(s.target);a?.parentNode&&a.parentNode.removeChild(a);break}case"node:remove":{let a=s.payload,l=n.takeRemoved(s.target),u=a.parent===_.ROOT?null:n.get(a.parent);l&&u&&u.appendChild(l);break}case"prop:update":{let a=s.payload,l=n.get(s.target);l?.nodeType===1&&(a.prev==null||a.prev===""?l.removeAttribute(a.key):l.setAttribute(a.key,String(a.prev)));break}case"text:update":{let a=s.payload,l=n.get(s.target);l?.nodeType===3&&(l.nodeValue=a.prev);break}case"node:move":{let a=s.payload,l=n.get(s.target),u=a.parent===_.ROOT?null:n.get(a.parent);if(l&&u&&l.parentNode===u)if(a.prev){let i=n.get(a.prev);i&&i.parentNode===u&&u.insertBefore(l,i.nextSibling)}else u.insertBefore(l,u.firstChild);break}default:break}}function Oo(e,t){return e.filter(n=>Q(n)===t)}function Ro(e,t){return e.some(t)}function Ho(e,t){let n=e.map(Q);if(!t.map((r,s)=>n[s]===r).every(Boolean))throw new Error(`\u4E8B\u4EF6\u5E8F\u5217\u4E0D\u7B26\uFF1A\u671F\u671B [${t.join(",")}] \u5B9E\u9645 [${n.slice(0,t.length).join(",")}]`)}async function Io(e){let t=await U(e,{}),n=[],o=0,r=()=>`s${++o}`,s=Date.now(),a=(l,u)=>{if(typeof l.type=="function"){let d=l._child??V(l)[0]??null;d&&typeof d=="object"&&!Array.isArray(d)&&a(d,u);return}if(l.type===F){for(let d of V(l))d&&typeof d=="object"&&!Array.isArray(d)&&a(d,u);return}let i=r();n.push(y("node","create",i,{tag:l.type}));for(let[d,c]of Object.entries(l.props??{}))d==="key"||d==="children"||typeof c!="function"&&c!=null&&c!==!1&&n.push(y("prop","update",i,{key:d,value:c,prev:""}));n.push(y("node","insert",i,{parent:u,ref:null}));for(let d of V(l))if(d==null||d===!1||d===!0){let c=r();n.push(y("node","create",c,{kind:"hole"})),n.push(y("node","insert",c,{parent:i,ref:null}))}else if(typeof d=="string"||typeof d=="number"){let c=r();n.push(y("text","create",c,{value:String(d)})),n.push(y("node","insert",c,{parent:i,ref:null}))}else d&&typeof d=="object"&&!Array.isArray(d)&&a(d,i)};return a(t,"root"),n}async function*Uo(e){let t=await U(e,{}),n=0,o=()=>`s${++n}`,r=Date.now(),s=function*(a,l){if(typeof a.type=="function"){let i=a._child??V(a)[0]??null;i&&typeof i=="object"&&!Array.isArray(i)&&(yield*s(i,l));return}if(a.type===F){for(let i of a.children??[])i&&typeof i=="object"&&!Array.isArray(i)&&(yield*s(i,l));return}let u=o();yield y("node","create",u,{tag:a.type});for(let[i,d]of Object.entries(a.props??{}))i==="key"||i==="children"||typeof d!="function"&&d!=null&&d!==!1&&(yield y("prop","update",u,{key:i,value:d,prev:""}));yield y("node","insert",u,{parent:l,ref:null});for(let i of V(a))if(i==null||i===!1||i===!0){let d=o();yield y("node","create",d,{kind:"hole"}),yield y("node","insert",d,{parent:u,ref:null})}else if(typeof i=="string"||typeof i=="number"){let d=o();yield y("text","create",d,{value:String(i)}),yield y("node","insert",d,{parent:u,ref:null})}else i&&typeof i=="object"&&!Array.isArray(i)&&(yield*s(i,u))};yield*s(t,"root")}function Do(e){let t=new Map,n=new Map,o=new Map,r=new Set;for(let u of e)if(u.entity==="node"&&u.action==="create"){let i=u.payload;i.kind==="hole"?r.add(u.target):t.set(u.target,i.tag)}else if(u.entity==="prop"&&u.action==="update"){let i=u.payload,d=n.get(u.target)??new Map;i.value==null||i.value===!1?d.delete(i.key):d.set(i.key,i.value),n.set(u.target,d)}else u.entity==="text"&&u.action==="create"&&o.set(u.target,u.payload.value);let s=new Map;for(let u of e)if(u.entity==="node"&&u.action==="insert"){let i=u.payload,d=s.get(i.parent)??[];d.push(u.target),s.set(i.parent,d)}let a=u=>u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),l=u=>{if(r.has(u))return"<!--wf-hole-->";let i=t.get(u);if(i){let d=n.get(u),c=d?[...d.entries()].filter(([m,p])=>typeof p!="function"&&m!=="data-v3-id"&&m!=="key"&&m!=="ref").map(([m,p])=>` ${m}="${a(String(p))}"`).join(""):"",f=(s.get(u)??[]).map(l).join("");return`<${i}${c}>${f}</${i}>`}return a(o.get(u)??"")};return(s.get("root")??[]).map(l).join("")}function jo(e){return JSON.stringify(e)}function Wo(e){return JSON.parse(e)}function ye(e){return`${e.entity}:${e.action}`}function $o(e,t="recorded-render"){let n=[...new Set(e.map(ye))],o=new Map;for(let d of e)ye(d)==="node:create"&&o.set(d.target,d.payload.tag);let r=new Map;for(let d of e)if(ye(d)==="node:insert"){let c=d.payload,f=r.get(c.parent)??[];f.push(d.target),r.set(c.parent,f)}let s=new Set,a=d=>{s.add(d);for(let c of r.get(d)??[])a(c)};for(let d of e)ye(d)==="node:remove"&&a(d.target);let l=new Map;for(let[d,c]of o)s.has(d)||l.set(c,(l.get(c)??0)+1);let u=[...l.entries()].map(([d,c])=>` assert.equal(root.querySelectorAll('${d}').length, ${c}, '${d} \xD7 ${c}\uFF08\u4E8B\u4EF6\u6D41\u63A8\u5BFC\uFF09')`).join(`
|
|
9
|
+
`),i=JSON.stringify(e);return`/**
|
|
10
|
+
* \u81EA\u52A8\u751F\u6210\u6D4B\u8BD5\uFF08vdom3 recordToTest\uFF09\u2014\u2014\u4E8B\u4EF6\u6D41\u5F55\u5236\u8F6C\u56DE\u5F52
|
|
11
|
+
* \u6E32\u67D3\u8FC7\u7A0B\uFF1A${n.join(" \u2192 ")}
|
|
12
|
+
*/
|
|
13
|
+
import { test, before } from 'node:test'
|
|
14
|
+
import assert from 'node:assert'
|
|
15
|
+
import { setupJsdom } from './client/setup.ts'
|
|
16
|
+
import { replay, eventsOf } from '../ui-dom/vdom3/index.ts'
|
|
17
|
+
|
|
18
|
+
before(setupJsdom)
|
|
19
|
+
|
|
20
|
+
test('${t}\uFF1A\u4E8B\u4EF6\u6D41\u56DE\u653E\uFF08DOM = fold\uFF09+ \u6E32\u67D3\u5E8F\u5217\u65AD\u8A00', () => {
|
|
21
|
+
const events = ${i}
|
|
22
|
+
|
|
23
|
+
// \u56DE\u653E\uFF1A\u4E8B\u4EF6\u6D41 \u2192 DOM\uFF08\u96F6\u731C\u6D4B\u91CD\u5EFA\uFF09
|
|
24
|
+
const root = document.createElement('div')
|
|
25
|
+
document.body.appendChild(root)
|
|
26
|
+
replay(events, root)
|
|
27
|
+
assert.ok(root.childNodes.length > 0, '\u56DE\u653E\u6E32\u67D3\u975E\u7A7A')
|
|
28
|
+
|
|
29
|
+
// \u5185\u5BB9\u65AD\u8A00\uFF1Atag \u8BA1\u6570\u4E0E\u5F55\u5236\u4E00\u81F4\uFF08DOM = fold \u76F4\u63A5\u9A8C\u8BC1\uFF09
|
|
30
|
+
${u}
|
|
31
|
+
|
|
32
|
+
// \u6E32\u67D3\u7C7B\u578B\u65AD\u8A00\uFF1A\u6E32\u67D3\u8FC7\u7A0B\u5305\u542B\u7684\u5173\u952E\u4E8B\u4EF6\uFF08\u7CBE\u786E\u63CF\u8FF0\u6E32\u67D3\u505A\u4E86\u4EC0\u4E48\uFF09
|
|
33
|
+
const keyTypes = ['node:create', 'prop:update', 'node:insert']
|
|
34
|
+
for (const t of keyTypes) {
|
|
35
|
+
assert.ok(eventsOf(events, t).length > 0, '\u5305\u542B ' + t + ' \u4E8B\u4EF6')
|
|
36
|
+
}
|
|
37
|
+
assert.ok(eventsOf(events, 'text:create').length > 0, '\u5305\u542B\u6587\u672C\u521B\u5EFA\u4E8B\u4EF6\uFF08\u6709\u6587\u672C\u5185\u5BB9\uFF09')
|
|
38
|
+
|
|
39
|
+
document.body.removeChild(root)
|
|
40
|
+
})
|
|
41
|
+
`}function zo(e){let t={};for(let n of e)t[ye(n)]=(t[ye(n)]??0)+1;return Object.entries(t).map(([n,o])=>`${n}\xD7${o}`).join(" ")}function hn(e,t){let n=new _;n.register(_.ROOT,e),e.innerHTML="";let o=0,r=[];return{sync(){let s=t(),a=s.slice(o);r=a;for(let l of a)Ie(l,e,n);return o=s.length,a.length},applied(){return o},lastBatch(){return[...r]}}}function Fo(e,t,n){let o=hn(e,t);return o.sync(),n(()=>{o.sync()})}var qo={"chevron-down":["M6 9l6 6 6-6"],"chevron-up":["M6 15l6-6 6 6"],"chevron-left":["M15 18l-6-6 6-6"],"chevron-right":["M9 18l6-6-6-6"],"arrow-left":["M19 12H5","M12 19l-7-7 7-7"],"arrow-up":["M12 19V5","M5 12l7-7 7 7"],"arrow-down":["M12 5v14","M19 12l-7 7-7-7"],"arrow-right":["M5 12h14","M12 5l7 7-7 7"],sort:["M7 15l5 5 5-5","M7 9l5-5 5 5"],"sort-asc":["M12 19V5","M5 12l7-7 7 7"],"sort-desc":["M12 5v14","M19 12l-7 7-7-7"],check:["M20 6L9 17l-5-5"],close:["M18 6L6 18","M6 6l12 12"],alert:["M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z","M12 9v4","M12 17h.01"],info:["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M12 16v-4","M12 8h.01"],warning:["M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z","M12 9v4","M12 17h.01"],pause:["M6 4h4v16H6z","M14 4h4v16h-4z"],settings:["M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z","M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"],search:["M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z","M21 21l-4.35-4.35"],send:["M22 2L11 13","M22 2l-7 20-4-9-9-4 20-7z"],stop:["M6 6h12v12H6z"],retry:["M1 4v6h6","M23 20v-6h-6","M20.49 9A9 9 0 0 0 5.64 5.64L1 10","M3.51 15a9 9 0 0 0 14.85 3.36L23 14"],upload:["M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4","M17 8l-5-5-5 5","M12 3v12"],trash:["M3 6h18","M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2","M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6h14","M10 11v6","M14 11v6"],edit:["M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7","M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"],plus:["M12 5v14","M5 12h14"],copy:["M20 9h-9a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2z","M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"],eye:["M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z","M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"],"eye-off":["M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94","M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19","M14.12 14.12a3 3 0 1 1-4.24-4.24","M1 1l22 22"],star:["M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"],dashboard:["M3 13h8V3H3z","M21 13h-8V9h8z","M21 21h-8v-8h8z","M3 21h8v-8H3z"],grid:["M3 3h7v7H3z","M14 3h7v7h-7z","M14 14h7v7h-7z","M3 14h7v7H3z"],box:["M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z","M3.27 6.96L12 12.01l8.73-5.05","M12 22.08V12"],users:["M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2","M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z","M23 21v-2a4 4 0 0 0-3-3.87","M16 3.13a4 4 0 0 1 0 7.75"],user:["M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2","M12 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z"],home:["M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z","M9 22V12h6v10"],folder:["M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"],file:["M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z","M13 2v7h7"],"file-text":["M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z","M13 2v7h7","M9 13h6","M9 17h6"],calendar:["M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z","M16 3v4","M8 3v4","M3 11h18"],clock:["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M12 6v6l4 2"],bell:["M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9","M13.73 21a2 2 0 0 1-3.46 0"],menu:["M3 12h18","M3 6h18","M3 18h18"],activity:["M22 12h-4l-3 9L9 3l-3 9H2"],"trending-up":["M23 6l-9.5 9.5-5-5L1 18","M17 6h6v6"],"trending-down":["M23 18l-9.5-9.5-5 5L1 6","M17 18h6v-6"],database:["M12 8c4.97 0 9-1.34 9-3s-4.03-3-9-3-9 1.34-9 3 4.03 3 9 3z","M21 12c0 1.66-4.03 3-9 3s-9-1.34-9-3","M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"],server:["M20 4H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2z","M4 14h16","M20 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2","M7 18h.01","M12 18h.01"],heart:["M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"],refresh:["M23 4v6h-6","M1 20v-6h6","M3.51 9a9 9 0 0 1 14.85-3.36L23 10","M20.49 15a9 9 0 0 1-14.85 3.36L1 14"],message:["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"],inbox:["M22 12h-6l-2 3h-4l-2-3H2","M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"],shield:["M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"],zap:["M13 2L3 14h9l-1 8 10-12h-9l1-8z"],target:["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M12 18a6 6 0 1 0 0-12 6 6 0 0 0 0 12z","M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"],mail:["M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z","M22 6l-10 7L2 6"],"external-link":["M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6","M15 3h6v6","M10 14L21 3"],"log-out":["M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4","M16 17l5-5-5-5","M21 12H9"],lock:["M5 11h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2z","M7 11V7a5 5 0 0 1 10 0v4"],list:["M8 6h13","M8 12h13","M8 18h13","M3 6h.01","M3 12h.01","M3 18h.01"],"bar-chart":["M12 20V10","M18 20V4","M6 20v-4"],gauge:["M12 15l3.5-3.5","M20.39 18.39A10 10 0 1 0 3.61 18.39","M12 15a2 2 0 1 0 0 4 2 2 0 0 0 0-4z"],paperclip:["M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"],filter:["M22 3H2l8 9.46V19l4 2v-8.54L22 3z"],layers:["M12 2L2 7l10 5 10-5-10-5z","M2 17l10 5 10-5","M2 12l10 5 10-5"],"map-pin":["M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z","M15 10a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"],"book-open":["M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z","M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"],github:["M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"],tag:["M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z","M7 7h.01"],phone:["M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"],"more-vertical":["M12 7a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z","M12 13.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z","M12 20a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"],"check-circle":["M22 11.08V12a10 10 0 1 1-5.93-9.14","M22 4L12 14.01l-3-3"],"alert-circle":["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M12 8v4","M12 16h.01"],wifi:["M5 12.55a11 11 0 0 1 14.08 0","M1.42 9a16 16 0 0 1 21.16 0","M8.53 16.11a6 6 0 0 1 6.95 0","M12 20h.01"],cpu:["M9 9h6v6H9z","M9 1v4","M15 1v4","M9 19v4","M15 19v4","M1 9h4","M1 15h4","M19 9h4","M19 15h4","M5 5h14v14H5z"],"hard-drive":["M22 12H2","M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z","M6 16h.01","M10 16h.01"],globe:["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M2 12h20","M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"],briefcase:["M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16","M2 20h20","M4 4h16a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"],layout:["M3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z","M9 3v18","M3 9h18"]},vn=async(e,t)=>async n=>{let{name:o,size:r,className:s}=n;return C("svg",{class:`wf-icon${s?" "+s:""}`,width:r??"1em",height:r??"1em",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":1.8,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",focusable:"false"},qo[o].map(a=>C("path",{d:a})))};var bn=async(e,t)=>{let n=!1,o=t.ui.usePopup({presence:!0,trapFocus:!0,lockScroll:!0,positioning:"none",closeOnOutside:!1,closeOnEscape:!1,isOpen:()=>n,setOpen:()=>{}}),r;return t.ui.useGlobalKey(s=>{s.key==="Escape"&&o.phase==="open"&&r?.()}),async s=>{let{open:a,title:l,onClose:u,children:i,footer:d,width:c,closable:f=!0,maskClosable:m=!0}=s;r=u,n=!!a;let p=t?.i18n?.components?.Modal??{},g=o.sync(n);if(g==="closed")return null;let w=C("div",{class:"wf-modal-overlay",onClick:m?u:void 0}),h=f?C("button",{class:"wf-modal-close",onClick:u,type:"button","aria-label":p.closeAria??"\u5173\u95ED"},C(vn,{name:"close"})):null,E=l?C("div",{class:"wf-modal-header"},[l,h].filter(Boolean)):null,b=C("div",{class:"wf-modal-body"},i),x=d?C("div",{class:"wf-modal-footer"},d):null,P=C("div",{class:"wf-modal-content",onClick:M=>M.stopPropagation(),style:c?{minWidth:`min(${c}, calc(100vw - 32px))`,maxWidth:`min(${c}, calc(100vw - 32px))`}:void 0},[E,b,x].filter(Boolean)),N=C("div",{class:`wf-modal ${g==="exit"?"wf-modal--exit":"wf-modal--enter"}`,role:"dialog","aria-modal":"true","aria-label":l??p.ariaLabel??"\u5F39\u7A97"},[w,P]);return o.portal(N,"modal")}};var ft=async(e,t)=>async n=>{let{variant:o="primary",size:r="md",block:s,loading:a,disabled:l,type:u,onClick:i,children:d}=n,c=["wf-btn",`wf-btn--${o}`,`wf-btn--${r}`,s&&"wf-btn--block",a&&"wf-btn--loading"].filter(Boolean).join(" "),f=t?.i18n?.components?.Button??{};return C("button",{id:n.id,title:n.title,class:c,type:u??"button",disabled:l||a||void 0,"aria-busy":a||void 0,onClick:i},a?[C("span",{class:"wf-btn-spinner"}),f.loading??"\u52A0\u8F7D\u4E2D..."]:d)};var ci=D(),wn=async(e,t)=>async n=>{let{open:o=!1,title:r,message:s,confirmText:a,cancelText:l,variant:u="primary",width:i,maskClosable:d=!1,onConfirm:c,onCancel:f}=n,m=t?.i18n?.components?.Confirm??{},p=[C(ft,{variant:"secondary",size:"md",onClick:()=>f?.()},l??m.cancelText??"\u53D6\u6D88"),C(ft,{variant:u,size:"md",onClick:()=>c?.()},a??m.confirmText??"\u786E\u5B9A")];return C(bn,{open:o,title:r,onClose:f??n.onClose,maskClosable:d,footer:p,width:i,closable:!1},s)};function Ko(){return e=>(e.confirm=(t,n)=>Bo(t,n??{},e),e)}function Bo(e,t,n){return new Promise(o=>{let r=document.createElement("div");document.body.appendChild(r);let s=!1,a=!0,u=He(C(async(c,f)=>async()=>C("div",{class:"wf-confirm-host"},C(wn,{open:a,title:t.title,onCancel:()=>{s||(s=!0,a=!1,o(!1),f.ui.render())},onConfirm:()=>{s||(s=!0,a=!1,o(!0),f.ui.render())},message:e})),{}),r,{ctx:{...n}}),i=()=>{u.unmount(),r.remove()},d=document.querySelector("#__wf_portal .wf-modal");if(d&&typeof d.addEventListener=="function"){let c=!1,f=()=>{c||(c=!0,i())};B(d,"animationend",f,!0),setTimeout(f,600)}else i()})}function Go(){return e=>(e.toast=(t,n="info")=>Jo(t,n),e)}function Jo(e,t){let n=document.createElement("div");n.className="wf-toast-host",n.style.cssText="position:fixed;top:16px;right:16px;z-index:var(--wf-z-toast,9999)",document.body.appendChild(n);let r=He(C(async()=>async()=>C("div",{class:`wf-toast wf-toast--${t}`},C("span",{class:"wf-toast-msg"},e)),{}),n);setTimeout(()=>{r.unmount(),n.remove()},3e3)}export{te as App,F as Fragment,_ as NodeRegistry,ee as Portal,Re as Scheduler,L as addGlobalListener,In as animateOut,Un as api,Ie as applyEvent,Wn as auth,Fo as autoSync,Ne as bindDelegated,B as bindElementListener,U as buildVNode,D as createClientBrowser,ht as createEventStream,ve as createPortal,He as createRoot,Lo as createRouter,qn as createStore,hn as createSync,it as createV3Ui,Wo as deserializeEvents,oe as ensureDelegationRoot,ue as ensurePortalContainer,y as ev,Pn as evKey,Oo as eventsOf,Do as eventsToHtml,Ho as expectEventSequence,Ze as getAppFactory,C as h,Ro as hasEvent,zn as i18n,W as isVNode,we as jsx,yt as jsxDEV,gt as jsxs,se as mount,z as patch,$o as recordToTest,Kn as registerApp,Rn as removeDelegationRoot,Uo as renderToEventStream,Io as renderToEvents,Ao as replay,Bn as resetAppRegistry,me as scheduler,jo as serializeEvents,v as stream,zo as summarizeEvents,ke as unbindAll,xt as unbindEvent,_o as undo,Ko as v3Confirm,Go as v3Toast,$n as ws};
|