weifuwu 0.67.1 → 0.67.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +4 -4
- package/dist/components/index.js +14 -14
- package/dist/components/style.css +6 -0
- package/dist/index.js +32 -4
- package/dist/layout/weifuwu-layout.css +6 -0
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var Ie="__wfAsyncComponent";function mn(e){let n=e;return n[Ie]=!0,n}function X(e){return typeof e=="function"&&e?.[Ie]===!0}var B=Symbol("Fragment"),q=Symbol("Portal");function we(e,n,t){return{type:e,props:De(n),key:t??void 0}}var yn=we;function gn(e,n,t){return we(e,n,t)}function hn(e,n,...t){let o=De(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),{type:e,props:o,key:n?.key??void 0}}function De(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function be(e,n){return{type:q,props:{children:e,portalKey:n},key:n??void 0,_placement:"remote"}}var vn=0,V=new Map,ie=[];function K(e){ie.push(e)}var se=new WeakMap;function J(){se=new WeakMap}function Ce(e,n){let t=se.get(e);if(t)return t;let o={promise:null};return o.promise=Promise.resolve().then(()=>e(n)).then(i=>{if(typeof i!="function")throw new Error(`asyncComponent factory <${e.name||"anonymous"}> must return a Component (initProps, ctx) => (props) => VNode.`);return o.resolved=i,i}),se.set(e,o),o}async function Ue(e,n){return Ce(e,n).promise}function je(e){return se.get(e)?.resolved}function wn(e){let n=e._child;if(n!=null)if(Array.isArray(n))for(let t of n)t&&typeof t=="object"&&O(t);else typeof n=="object"&&O(n)}function O(e){if(e==null||typeof e!="object")return;let n=e;if(n._id){if(n._customId&&V.delete(n._customId),V.delete(n._id),ie.length>0){for(let t of ie)t(n._id);if(n._customId)for(let t of ie)t(n._customId)}n._id=void 0,n._customId=void 0,n._render=void 0,n._parentNode=void 0,n._refNode=void 0}if(n._child!=null){if(Array.isArray(n._child))for(let t of n._child)t&&typeof t=="object"&&O(t);else O(n._child);n._child=void 0}if(n.props?.children&&typeof n.type=="string"){let t=Array.isArray(n.props.children)?n.props.children:[n.props.children];for(let o of t)o&&typeof o=="object"&&O(o)}typeof n.props?.ref=="function"&&n.props.ref(null),n._remoteEl&&(wn(n),n._remoteEl.remove(),n._remoteEl=void 0)}function Q(){return`_wf_${vn++}`}var qe=new WeakMap;function bn(e){let n=qe.get(e)??{count:0,warned:!1};n.count++,n.count>=3&&!n.warned&&(n.warned=!0,console.warn("[weifuwu] ref \u51FD\u6570\u6BCF\u6B21\u6E32\u67D3\u90FD\u53D8\u5316\uFF08\u5185\u8054 ref\uFF09\u2014\u2014ref \u56DE\u8C03\u5728\u6BCF\u6B21\u6E32\u67D3\u540E\u91CD\u65B0\u6267\u884C\uFF08\u6027\u80FD\u635F\u8017\uFF09\u3002\u628A ref \u5B9A\u4E49\u5230 mount \u4F5C\u7528\u57DF\uFF08\u7A33\u5B9A\u5F15\u7528\uFF09\uFF1Aconst listRef = (el) => {...}; return h('div', { ref: listRef })")),qe.set(e,n)}function z(e,n,t,o,i){if(t==null){if(o==null)return null;let c=D(o,i);return c==null?null:(n&&n.parentNode?n.parentNode.insertBefore(c,n):e.appendChild(c),c)}if(o==null)return n?(O(t),n.remove()):O(t),null;let s=Be(t),a=Be(o);if(s!==a){O(t);let c=D(o,i);return c==null?null:(n?.parentNode&&n.parentNode.replaceChild(c,n),c)}if(a==="text")return n&&n.textContent!==String(o)&&(n.textContent=String(o)),n;let u=o,l=t;if(typeof u.type=="function"){let c=u.type;l._render&&(u._render=l._render,u._id=l._id,u._id&&V.set(u._id,u)),u._parentNode=e,u._refNode=n;let m=Object.create(i);if(m.ui=Object.create(i.ui),m.ui._selfId=u._id,m.ui._selfVNode=u,u._ctxVersion=l._ctxVersion??m.ui._ctxVersion??0,l._render&&Tn(l.props,u.props)&&!m.ui._dirtySet?.has(l._id)&&u._ctxVersion===m.ui._ctxVersion)return u._child=l._child,n;m.ui._dirtySet?.delete(l._id);let g;try{typeof u._render=="function"?g=u._render(u.props):g=Ee(c,u.props,u,m)}catch(y){let v=i.ui?._errorHandler;v?(v(y),g=null):(console.error(`[weifuwu] Component render error in <${c?.name||"anonymous"}> (id: ${l._id??"?"}, phase: update)`,y),g=null)}let P=l._child;u._child=g;let C=z(e,n,P,g,m);return C||(u._refNode=null),C}if(u.type===B){let c=l._childNodes,m=$e(e,l,u,i,c);return u._childNodes=m,n}if(typeof u.type=="string"){if(n&&n.nodeType===1){let c=l.props?.ref,m=u.props?.ref;c!==m&&(typeof m=="function"&&m(n),typeof c=="function"&&typeof m=="function"&&bn(n)),Te(n,l.props,u.props),$e(n,l,u,i)}else if(n){O(t);let c=D(o,i);return c==null?null:(n.parentNode?.replaceChild(c,n),c)}return n}if(u.type===q)return ne(l,u,i),null;if(Array.isArray(o)){let c=Array.isArray(t)?t:[];ae(c,o);let m=Array.from(e.childNodes),g=n?m.indexOf(n):-1,P=g>=0?Z(m.slice(g),c):Z(m,c);return le(e,c,o,i,P,n),n}return n}var Fe=new Map;function Cn(e){let n=Fe.get(e);return n||(n=`fn:${e.name||"anon"}`,Fe.set(e,n)),n}function Be(e){if(e==null||typeof e=="boolean")return"null";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"array";let n=e;return typeof n.type=="function"?Cn(n.type):n.type===B?"fragment":n.type===q?"portal":typeof n.type=="string"?"tag:"+n.type:"unknown"}function Te(e,n,t){let o=n?Object.keys(n).filter(a=>a!=="children"&&a!=="key"&&a!=="innerHTML"):[],i=t?Object.keys(t).filter(a=>a!=="children"&&a!=="key"&&a!=="innerHTML"):[],s=new Set(i);for(let a of o)if(!s.has(a)){if(a==="ref")continue;a.startsWith("on")&&typeof n[a]=="function"?e.removeEventListener(a.slice(2).toLowerCase(),n[a]):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(a==="className"?"class":a)}for(let a of i){if(a==="ref")continue;let u=n?.[a],l=t?.[a];if(a==="innerHTML")l!==u&&(e.innerHTML=String(l??""));else if(l!==u)if(a==="class"||a==="className")e instanceof SVGElement?e.setAttribute("class",Ke(l)):e.className=Ke(l);else if(a==="style"&&typeof l=="object"){let c=e.style;for(let m of Object.keys(l)){let g=l[m];g!=null&&(c[m]=typeof g=="number"?g+"px":String(g))}}else if(a.startsWith("on")&&typeof l=="function"){let c=a.slice(2).toLowerCase();typeof u=="function"&&e.removeEventListener(c,u),e.addEventListener(c,l)}else a==="draggable"?e.setAttribute("draggable",l?"true":"false"):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(l??""):l===!0?e.setAttribute(a,""):l!=null&&l!==!1?e.setAttribute(a,String(l)):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(a)}}function Ke(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,n])=>n).map(([n])=>n).join(" "):""}function xe(e){if(!(e==null||typeof e!="object"))return e.key}function ae(e,n){if(!n.some(o=>o&&typeof o=="object"&&o.key!==void 0)){for(let o=0;o<n.length;o++){let i=n[o];i&&typeof i=="object"&&(i.key=o)}for(let o=0;o<e.length;o++){let i=e[o];i&&typeof i=="object"&&(i.key=o)}}}function Z(e,n){let t=[],o=0;for(let i of n){if(i==null||typeof i=="boolean"){t.push(null);continue}let s=i;if(s.type===q){t.push(null);continue}if(s.type===B){let a=s._childNodes;Array.isArray(a)&&a.length>0?(t.push(a.slice()),o+=a.length):(t.push(e[o]?[e[o]]:null),o+=1)}else typeof process<"u"&&process.env.DBG&&console.error("[map] idx=",o,"type=",s.type,"sourceLen=",e.length,"hit=",!!e[o]),t.push(e[o]?[e[o]]:null),o+=1}return t}function $e(e,n,t,o,i){let s=ee(n.props?.children),a=ee(t.props?.children);ae(s,a);let u=i??Array.from(e.childNodes),l=Z(u,s),c=le(e,s,a,o,l,i?.[0]??null),m=[];for(let g of c)g&&g.length>0&&m.push(...g);return m}function ee(e){if(e==null)return[];if(!Array.isArray(e))return[e];let n=[];for(let t of e)Array.isArray(t)?n.push(...t):n.push(t);return n}function ze(e){return e==null?[]:e instanceof DocumentFragment?Array.from(e.childNodes):[e]}function le(e,n,t,o,i=[],s=null){if(!t.some(y=>y&&typeof y=="object"&&y.key!==void 0)){let y=Math.max(n.length,t.length);for(let v=0;v<y;v++){let r=v<n.length?n[v]:null,d=v<t.length?t[v]:null;if(d==null){if(r!=null){O(r);for(let f of i[v]??[])f.remove()}}else if(r==null){let f=D(d,o);f!=null&&e.appendChild(f)}else{let f=i[v]?.[0]??null;z(e,f,r,d,o)}}return[]}for(let y=0;y<n.length;y++){let v=n[y];if(!(v==null||typeof v=="boolean")&&xe(v)===void 0)for(let r of i[y]??[])r.remove()}let u=new Map,l=0;for(let y=0;y<n.length;y++){let v=xe(n[y]);v!==void 0&&u.set(v,{vnode:n[y],nodes:i[y]??[],index:l++})}let c=t.map(y=>xe(y)),m=new Set(c);for(let y of[...u.keys()])if(!m.has(y)){let v=u.get(y);O(v.vnode);for(let r of v.nodes)r?.remove();u.delete(y)}let g=new Array(t.length).fill(null),P=-1,C=s&&s.parentNode===e?s:e.firstChild;for(let y=0;y<t.length;y++){let v=c[y],r=t[y],d=v!==void 0?u.get(v):void 0,f=r&&typeof r=="object"&&r._placement==="remote";if(d)if(d.nodes.length>0){if(d.index<P)for(let h of d.nodes)e.insertBefore(h,C);P=Math.max(P,d.index),z(e,d.nodes[0],d.vnode,r,o),g[y]=r._childNodes??d.nodes.filter(h=>h.parentNode===e),C=g[y][g[y].length-1]?.nextSibling??null}else if(f)ne(d.vnode,r,o),g[y]=[];else{let p=z(e,null,d.vnode,r,o);g[y]=ze(p);for(let b of g[y])e.insertBefore(b,C);C=g[y][g[y].length-1]?.nextSibling??null}else if(f)G(r,o),g[y]=[];else{let p=D(r,o);g[y]=ze(p);for(let b of g[y])e.insertBefore(b,C);C=g[y][g[y].length-1]?.nextSibling??null}}return g}function xn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}return e===n}function Tn(e,n){if(e===n)return!0;if(!e||!n)return!1;let t=new Set([...Object.keys(e),...Object.keys(n)]);for(let o of t)if(o!=="key"){if(o==="children"){if(!xn(e[o],n[o]))return!1}else if(e[o]!==n[o])return!1}return!0}var Pe="http://www.w3.org/2000/svg",_e=new Set(["svg","path","circle","line","rect","text","g","polyline","polygon","ellipse","defs","use","clipPath","mask","linearGradient","radialGradient","stop","tspan"]);function Ge(e,n){return D(e,n)}function D(e,n){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(Array.isArray(e))return _n(e,n);let t=e;if(t.type===q)return G(t,n),null;if(t.type===B){let a=document.createDocumentFragment(),u=t.props?.children==null?[]:Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let l of u){let c=D(l,n);c!=null&&a.appendChild(c)}return t._childNodes=Array.from(a.childNodes),a}if(typeof t.type=="function")return Pn(t.type,t.props,t,n);let o=t.type,i=_e.has(o)?document.createElementNS(Pe,o):document.createElement(o);t.el=i;let s;for(let[a,u]of Object.entries(t.props??{}))a==="children"||a==="key"||a==="value"||a==="innerHTML"||Ye(i,a,u);if("value"in(t.props??{})&&i instanceof HTMLSelectElement?s=t.props.value:"value"in(t.props??{})&&Ye(i,"value",t.props.value),"innerHTML"in(t.props??{}))i.innerHTML=String(t.props.innerHTML??"");else{let a=Ae(t.props?.children);for(let u of a){let l=D(u,n);if(l!=null&&(i.appendChild(l),u&&typeof u=="object"&&typeof u.type=="function")){let c=u;c._parentNode||(c._parentNode=i,c._refNode=l)}}}return s!==void 0&&(i.value=String(s)),typeof t.props?.ref=="function"&&t.props.ref(i),i}function En(e){let n=e.ui;n&&typeof n.render=="function"&&n.render(["_wf_root"])}function Ee(e,n,t,o){let i;if(X(e)){if(i=je(e),!i)return Ce(e,o).promise.then(()=>En(o),()=>{}),null}else i=e;o.ui?.setMounting?.(!0);let s;try{s=i(n,o)}finally{o.ui?.endMounting?.()}if(typeof s!="function")throw new Error(`Component ${e.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);return t._render=s,s(n)}function Pn(e,n,t,o){o.ui=o.ui??{},t._id||(t._id=Q(),V.set(t._id,t));let i=Object.create(o);i.ui=Object.create(o.ui),i.ui._selfId=t._id,i.ui._selfVNode=t,t._ctxVersion=i.ui._ctxVersion??0;let s;try{s=Ee(e,n,t,i)}catch(u){let l=o.ui?._errorHandler;l?(l(u),s=null):(console.error(`[weifuwu] Component render error in <${e.name||"anonymous"}> (id: ${t._id??"?"}, phase: mount)`,u),s=null)}if(s==null)return t._child=null,null;t._child=s;let a=D(s,i);return t._refNode||(t._refNode=a),a}function _n(e,n){let t=document.createDocumentFragment();for(let o of e){let i=D(o,n);i!=null&&t.appendChild(i)}return t}function An(){let e=document.getElementById("__wf_portal");return e||(e=document.createElement("div"),e.id="__wf_portal",e.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:9999",document.body.appendChild(e)),e}function G(e,n){let t=An(),o=document.createElement("div");o.style.pointerEvents="auto",t.appendChild(o),e._remoteEl=o;let i=ee(e.props?.children);e._child=i;for(let s of i){let a=D(s,n);a!=null&&o.appendChild(a)}}function ne(e,n,t){let o=e?._remoteEl;if(n._remoteEl=o,!o){G(n,t);return}let i=ee(n.props?.children),s=e._child||[];n._child=i,ae(s,i);let a=Z(Array.from(o.childNodes),s);le(o,s,i,t,a,a[0]?.[0]??null)}function Ae(e){if(e==null)return[];if(!Array.isArray(e))return[e];let n=[];for(let t of e)Array.isArray(t)?n.push(...t):n.push(t);return n}function Ye(e,n,t){if(n==="class"||n==="className")e instanceof SVGElement?e.setAttribute("class",String(t??"")):e.className=String(t??"");else if(n==="style"&&typeof t=="object"&&t!==null){let o=e.style;for(let i of Object.keys(t)){let s=t[i];s!=null&&(o[i]=typeof s=="number"?s+"px":String(s))}}else n.startsWith("on")&&typeof t=="function"?e.addEventListener(n.slice(2).toLowerCase(),t):n==="draggable"?e.setAttribute("draggable",t?"true":"false"):n==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(t??""):t===!0?e.setAttribute(n,""):t!=null&&t!==!1&&e.setAttribute(n,String(t))}function Sn(e,n,t){e.innerHTML="";let o=D(n,t);o instanceof Node?e.appendChild(o):Array.isArray(o)&&o.forEach(i=>e.appendChild(i))}function Se(e){e.node=e.node?e.node.nextSibling:null}function Rn(e,n){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(n,e.node):e.parent.appendChild(n)}function kn(e,n){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(n,e.node),Se(e)):e.parent.appendChild(n)}async function te(e,n,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let u=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==u&&(t.node.textContent=u),Se(t),t.node;let l=document.createTextNode(u);return Rn(t,l),l}if(Array.isArray(e)){let u=null;for(let l of e){let c=await te(l,n,t);c!=null&&!u&&(u=c)}return u}let o=e;if(o.type===q||o.type===B){let u=o.props?.children,l=u==null?[]:Array.isArray(u)?u:[u],c=null;for(let m of l){let g=await te(m,n,t);g!=null&&!c&&(c=g)}return c}if(typeof o.type=="function")return Nn(o,n,t);let i=o.type,s=o.props??{},a;if(t.node&&t.node.nodeType===1&&t.node.tagName.toLowerCase()===i.toLowerCase()?(a=t.node,Se(t)):(a=_e.has(i)?document.createElementNS(Pe,i):document.createElement(i),kn(t,a)),o.el=a,Te(a,null,s),!("innerHTML"in s)){let u={parent:a,node:a.firstChild},l=Ae(s.children);for(let c of l){let m=await te(c,n,u);if(m!=null&&m.parentNode!==a&&a.appendChild(m),c&&typeof c=="object"&&typeof c.type=="function"){let g=c;g._parentNode||(g._parentNode=a,g._refNode=m)}}for(;u.node;){let c=u.node;u.node=c.nextSibling,c.parentNode?.removeChild(c)}}return"value"in s&&a instanceof HTMLSelectElement&&(a.value=String(s.value??"")),typeof s.ref=="function"&&s.ref(a),a}async function Nn(e,n,t){n.ui=n.ui??{},e._id||(e._id=Q(),V.set(e._id,e));let o=Object.create(n);o.ui=Object.create(n.ui),o.ui._selfId=e._id,o.ui._selfVNode=e,e._ctxVersion=o.ui._ctxVersion??0;let i=e.type,s;try{let u;X(i)?u=await Ue(i,o):u=i;let l=u(e.props??{},o);if(typeof l!="function")throw new Error(`Component ${i.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);e._render=l,s=l(e.props??{})}catch(u){let l=n.ui?._errorHandler;l?(l(u),s=null):(console.error(`[weifuwu] Component hydration error in <${i.name||"anonymous"}> (id: ${e._id??"?"})`,u),s=null)}if(s==null)return e._child=null,null;e._child=s;let a=await te(s,o,t);return e._refNode||(e._refNode=a),a}async function Re(e,n,t){let o={parent:e,node:e.firstChild};for(await te(n,t,o);o.node;){let i=o.node;o.node=i.nextSibling,i.parentNode?.removeChild(i)}}var ue=0,Xe="",Je="",Qe="",Ze="",ce=0;function en(){return typeof window<"u"&&typeof document<"u"}function ke(){if(ue++,ue>1||!en())return;ce=window.scrollY;let e=document.body;Xe=e.style.overflow,Je=e.style.position,Qe=e.style.top,Ze=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=`-${ce}px`,e.style.width="100%")}function Ne(){if(ue--,ue>0||!en())return;let e=document.body;e.style.overflow=Xe,e.style.position=Je,e.style.top=Qe,e.style.width=Ze,ce>0&&window.scrollTo(0,ce)}var Mn='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function de(e){let n=e.querySelectorAll(Mn);if(n.length===0)return()=>{};let t=n[0],o=n[n.length-1],i=a=>{a.key==="Tab"&&(a.shiftKey&&document.activeElement===t?(a.preventDefault(),o.focus()):!a.shiftKey&&document.activeElement===o&&(a.preventDefault(),t.focus()))},s=document.activeElement;return queueMicrotask(()=>{t.focus()}),e.addEventListener("keydown",i),()=>{e.removeEventListener("keydown",i),s?.focus()}}function fe(e){let n=new WeakMap,t=new Set,o=s=>{if(s===null||typeof s!="object")return s;if(n.has(s))return n.get(s);let a=new Proxy(s,{set(u,l,c){if(Reflect.get(u,l)===c)return!0;Reflect.set(u,l,c),e();for(let g of t)g();return!0},get(u,l){let c=Reflect.get(u,l);return typeof c=="object"&&c!==null?o(c):c},deleteProperty(u,l){if(Reflect.has(u,l)){Reflect.deleteProperty(u,l),e();for(let c of t)c()}return!0}});return n.set(s,a),a},i=o({});return Object.defineProperty(i,"__watch",{value:s=>(t.add(s),()=>{t.delete(s)}),writable:!1,enumerable:!1}),i}function Me(e,n,t){let o=new AbortController,i=t?.signal;i&&(i.aborted?o.abort():i.addEventListener("abort",()=>o.abort(),{once:!0}));let s=t?.traceId??Hn(),a=t?.record!==!1,u=[],l=(async()=>{let c;try{c=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":s,Accept:"text/event-stream",...t?.headers},body:JSON.stringify(n),signal:o.signal})}catch(m){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:m instanceof Error?m.message:String(m)});return}if(!c.ok){t?.onError?.({code:Wn(c.status),message:`HTTP ${c.status} ${c.statusText}`});return}try{for await(let{name:m,data:g}of On(c.body)){if(o.signal.aborted)return;Vn(u,{name:m,data:g},a),Ln(m,g,t??{})}}catch(m){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:m instanceof Error?m.message:String(m)})}})();return{abort:()=>o.abort(),done:l,traceId:s,events:u}}function Ln(e,n,t){switch(e){case"wf:token":return t.onToken?.(n.text);case"wf:tool_call":return t.onToolCall?.(n);case"wf:tool_result":return t.onToolResult?.(n);case"wf:tool_progress":return t.onToolProgress?.(n);case"wf:step":return t.onStep?.(n);case"wf:approval_request":return t.onApproval?.(n);case"wf:usage":return t.onUsage?.(n);case"wf:done":return t.onDone?.(n);case"wf:error":return t.onError?.(n);default:return t.onEvent?.(e,n)}}async function*On(e){let n=e.getReader(),t=new TextDecoder,o="";try{for(;;){let{done:i,value:s}=await n.read();if(i)break;o+=t.decode(s,{stream:!0});let a=o.split(`
|
|
1
|
+
var Ie="__wfAsyncComponent";function mn(e){let n=e;return n[Ie]=!0,n}function X(e){return typeof e=="function"&&e?.[Ie]===!0}var B=Symbol("Fragment"),q=Symbol("Portal");function we(e,n,t){return{type:e,props:De(n),key:t??void 0}}var yn=we;function gn(e,n,t){return we(e,n,t)}function hn(e,n,...t){let o=De(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),{type:e,props:o,key:n?.key??void 0}}function De(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function be(e,n){return{type:q,props:{children:e,portalKey:n},key:n??void 0,_placement:"remote"}}var vn=0,V=new Map,ie=[];function K(e){ie.push(e)}var se=new WeakMap;function J(){se=new WeakMap}function Ce(e,n){let t=se.get(e);if(t)return t;let o={promise:null};return o.promise=Promise.resolve().then(()=>e(n)).then(i=>{if(typeof i!="function")throw new Error(`asyncComponent factory <${e.name||"anonymous"}> must return a Component (initProps, ctx) => (props) => VNode.`);return o.resolved=i,i}),se.set(e,o),o}async function Ue(e,n){return Ce(e,n).promise}function je(e){return se.get(e)?.resolved}function wn(e){let n=e._child;if(n!=null)if(Array.isArray(n))for(let t of n)t&&typeof t=="object"&&O(t);else typeof n=="object"&&O(n)}function O(e){if(e==null||typeof e!="object")return;let n=e;if(n._id){if(n._customId&&V.delete(n._customId),V.delete(n._id),ie.length>0){for(let t of ie)t(n._id);if(n._customId)for(let t of ie)t(n._customId)}n._id=void 0,n._customId=void 0,n._render=void 0,n._parentNode=void 0,n._refNode=void 0}if(n._child!=null){if(Array.isArray(n._child))for(let t of n._child)t&&typeof t=="object"&&O(t);else O(n._child);n._child=void 0}if(n.props?.children&&typeof n.type=="string"){let t=Array.isArray(n.props.children)?n.props.children:[n.props.children];for(let o of t)o&&typeof o=="object"&&O(o)}typeof n.props?.ref=="function"&&n.props.ref(null),n._remoteEl&&(wn(n),n._remoteEl.remove(),n._remoteEl=void 0)}function Q(){return`_wf_${vn++}`}var qe=new WeakMap;function bn(e){let n=qe.get(e)??{count:0,warned:!1};n.count++,n.count>=3&&!n.warned&&(n.warned=!0,console.warn("[weifuwu] ref \u51FD\u6570\u6BCF\u6B21\u6E32\u67D3\u90FD\u53D8\u5316\uFF08\u5185\u8054 ref\uFF09\u2014\u2014ref \u56DE\u8C03\u5728\u6BCF\u6B21\u6E32\u67D3\u540E\u91CD\u65B0\u6267\u884C\uFF08\u6027\u80FD\u635F\u8017\uFF09\u3002\u628A ref \u5B9A\u4E49\u5230 mount \u4F5C\u7528\u57DF\uFF08\u7A33\u5B9A\u5F15\u7528\uFF09\uFF1Aconst listRef = (el) => {...}; return h('div', { ref: listRef })")),qe.set(e,n)}function z(e,n,t,o,i){if(t==null){if(o==null)return null;let u=D(o,i);return u==null?null:(n&&n.parentNode?n.parentNode.insertBefore(u,n):e.appendChild(u),u)}if(o==null)return n?(O(t),n.remove()):O(t),null;let s=Be(t),a=Be(o);if(s!==a){O(t);let u=D(o,i);return u==null?null:(n?.parentNode&&n.parentNode.replaceChild(u,n),u)}if(a==="text")return n&&n.textContent!==String(o)&&(n.textContent=String(o)),n;let c=o,l=t;if(typeof c.type=="function"){let u=c.type;l._render&&(c._render=l._render,c._id=l._id,c._id&&V.set(c._id,c)),c._parentNode=e,c._refNode=n;let m=Object.create(i);if(m.ui=Object.create(i.ui),m.ui._selfId=c._id,m.ui._selfVNode=c,c._ctxVersion=l._ctxVersion??m.ui._ctxVersion??0,l._render&&Tn(l.props,c.props)&&!m.ui._dirtySet?.has(l._id)&&c._ctxVersion===m.ui._ctxVersion)return c._child=l._child,n;m.ui._dirtySet?.delete(l._id);let y;try{typeof c._render=="function"?y=c._render(c.props):y=Ee(u,c.props,c,m)}catch(g){let v=i.ui?._errorHandler;v?(v(g),y=null):(console.error(`[weifuwu] Component render error in <${u?.name||"anonymous"}> (id: ${l._id??"?"}, phase: update)`,g),y=null)}let T=l._child;c._child=y;let b=z(e,n,T,y,m);return b||(c._refNode=null),b}if(c.type===B){let u=l._childNodes,m=$e(e,l,c,i,u);return c._childNodes=m,n}if(typeof c.type=="string"){if(n&&n.nodeType===1){let u=l.props?.ref,m=c.props?.ref;u!==m&&(typeof m=="function"&&m(n),typeof u=="function"&&typeof m=="function"&&bn(n)),Te(n,l.props,c.props),$e(n,l,c,i)}else if(n){O(t);let u=D(o,i);return u==null?null:(n.parentNode?.replaceChild(u,n),u)}return n}if(c.type===q)return ne(l,c,i),null;if(Array.isArray(o)){let u=Array.isArray(t)?t:[];ae(u,o);let m=Array.from(e.childNodes),y=n?m.indexOf(n):-1,T=y>=0?Z(m.slice(y),u):Z(m,u);return le(e,u,o,i,T,n),n}return n}var Fe=new Map;function Cn(e){let n=Fe.get(e);return n||(n=`fn:${e.name||"anon"}`,Fe.set(e,n)),n}function Be(e){if(e==null||typeof e=="boolean")return"null";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"array";let n=e;return typeof n.type=="function"?Cn(n.type):n.type===B?"fragment":n.type===q?"portal":typeof n.type=="string"?"tag:"+n.type:"unknown"}function Te(e,n,t){let o=n?Object.keys(n).filter(a=>a!=="children"&&a!=="key"&&a!=="innerHTML"):[],i=t?Object.keys(t).filter(a=>a!=="children"&&a!=="key"&&a!=="innerHTML"):[],s=new Set(i);for(let a of o)if(!s.has(a)){if(a==="ref")continue;a.startsWith("on")&&typeof n[a]=="function"?e.removeEventListener(a.slice(2).toLowerCase(),n[a]):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(a==="className"?"class":a)}for(let a of i){if(a==="ref")continue;let c=n?.[a],l=t?.[a];if(a==="innerHTML")l!==c&&(e.innerHTML=String(l??""));else if(l!==c)if(a==="class"||a==="className")e instanceof SVGElement?e.setAttribute("class",Ke(l)):e.className=Ke(l);else if(a==="style"&&typeof l=="object"){let u=e.style;for(let m of Object.keys(l)){let y=l[m];y!=null&&(u[m]=typeof y=="number"?y+"px":String(y))}}else if(a.startsWith("on")&&typeof l=="function"){let u=a.slice(2).toLowerCase();typeof c=="function"&&e.removeEventListener(u,c),e.addEventListener(u,l)}else a==="draggable"?e.setAttribute("draggable",l?"true":"false"):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(l??""):l===!0?e.setAttribute(a,""):l!=null&&l!==!1?e.setAttribute(a,String(l)):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(a)}}function Ke(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,n])=>n).map(([n])=>n).join(" "):""}function xe(e){if(!(e==null||typeof e!="object"))return e.key}function ae(e,n){if(!n.some(o=>o&&typeof o=="object"&&o.key!==void 0)){for(let o=0;o<n.length;o++){let i=n[o];i&&typeof i=="object"&&(i.key=o)}for(let o=0;o<e.length;o++){let i=e[o];i&&typeof i=="object"&&(i.key=o)}}}function Z(e,n){let t=[],o=0;for(let i of n){if(i==null||typeof i=="boolean"){t.push(null);continue}let s=i;if(s.type===q){t.push(null);continue}if(s.type===B){let a=s._childNodes;Array.isArray(a)&&a.length>0?(t.push(a.slice()),o+=a.length):(t.push(e[o]?[e[o]]:null),o+=1)}else typeof process<"u"&&process.env.DBG&&console.error("[map] idx=",o,"type=",s.type,"sourceLen=",e.length,"hit=",!!e[o]),t.push(e[o]?[e[o]]:null),o+=1}return t}function $e(e,n,t,o,i){let s=ee(n.props?.children),a=ee(t.props?.children);ae(s,a);let c=i??Array.from(e.childNodes),l=Z(c,s),u=le(e,s,a,o,l,i?.[0]??null),m=[];for(let y of u)y&&y.length>0&&m.push(...y);return m}function ee(e){if(e==null)return[];if(!Array.isArray(e))return[e];let n=[];for(let t of e)Array.isArray(t)?n.push(...t):n.push(t);return n}function ze(e){return e==null?[]:e instanceof DocumentFragment?Array.from(e.childNodes):[e]}function le(e,n,t,o,i=[],s=null){if(!t.some(g=>g&&typeof g=="object"&&g.key!==void 0)){let g=Math.max(n.length,t.length);for(let v=0;v<g;v++){let r=v<n.length?n[v]:null,d=v<t.length?t[v]:null;if(d==null){if(r!=null){O(r);for(let f of i[v]??[])f.remove()}}else if(r==null){let f=D(d,o);f!=null&&e.appendChild(f)}else{let f=i[v]?.[0]??null;z(e,f,r,d,o)}}return[]}for(let g=0;g<n.length;g++){let v=n[g];if(!(v==null||typeof v=="boolean")&&xe(v)===void 0)for(let r of i[g]??[])r.remove()}let c=new Map,l=0;for(let g=0;g<n.length;g++){let v=xe(n[g]);v!==void 0&&c.set(v,{vnode:n[g],nodes:i[g]??[],index:l++})}let u=t.map(g=>xe(g)),m=new Set(u);for(let g of[...c.keys()])if(!m.has(g)){let v=c.get(g);O(v.vnode);for(let r of v.nodes)r?.remove();c.delete(g)}let y=new Array(t.length).fill(null),T=-1,b=s&&s.parentNode===e?s:e.firstChild;for(let g=0;g<t.length;g++){let v=u[g],r=t[g],d=v!==void 0?c.get(v):void 0,f=r&&typeof r=="object"&&r._placement==="remote";if(d)if(d.nodes.length>0){if(d.index<T)for(let h of d.nodes)e.insertBefore(h,b);T=Math.max(T,d.index),z(e,d.nodes[0],d.vnode,r,o),y[g]=r._childNodes??d.nodes.filter(h=>h.parentNode===e),b=y[g][y[g].length-1]?.nextSibling??null}else if(f)ne(d.vnode,r,o),y[g]=[];else{let p=z(e,null,d.vnode,r,o);y[g]=ze(p);for(let w of y[g])e.insertBefore(w,b);b=y[g][y[g].length-1]?.nextSibling??null}else if(f)Y(r,o),y[g]=[];else{let p=D(r,o);y[g]=ze(p);for(let w of y[g])e.insertBefore(w,b);b=y[g][y[g].length-1]?.nextSibling??null}}return y}function xn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}return e===n}function Tn(e,n){if(e===n)return!0;if(!e||!n)return!1;let t=new Set([...Object.keys(e),...Object.keys(n)]);for(let o of t)if(o!=="key"){if(o==="children"){if(!xn(e[o],n[o]))return!1}else if(e[o]!==n[o])return!1}return!0}var Pe="http://www.w3.org/2000/svg",_e=new Set(["svg","path","circle","line","rect","text","g","polyline","polygon","ellipse","defs","use","clipPath","mask","linearGradient","radialGradient","stop","tspan"]);function Ye(e,n){return D(e,n)}function D(e,n){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(Array.isArray(e))return _n(e,n);let t=e;if(t.type===q)return Y(t,n),null;if(t.type===B){let a=document.createDocumentFragment(),c=t.props?.children==null?[]:Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let l of c){let u=D(l,n);u!=null&&a.appendChild(u)}return t._childNodes=Array.from(a.childNodes),a}if(typeof t.type=="function")return Pn(t.type,t.props,t,n);let o=t.type,i=_e.has(o)?document.createElementNS(Pe,o):document.createElement(o);t.el=i;let s;for(let[a,c]of Object.entries(t.props??{}))a==="children"||a==="key"||a==="value"||a==="innerHTML"||Ge(i,a,c);if("value"in(t.props??{})&&i instanceof HTMLSelectElement?s=t.props.value:"value"in(t.props??{})&&Ge(i,"value",t.props.value),"innerHTML"in(t.props??{}))i.innerHTML=String(t.props.innerHTML??"");else{let a=Se(t.props?.children);for(let c of a){let l=D(c,n);if(l!=null&&(i.appendChild(l),c&&typeof c=="object"&&typeof c.type=="function")){let u=c;u._parentNode||(u._parentNode=i,u._refNode=l)}}}return s!==void 0&&(i.value=String(s)),typeof t.props?.ref=="function"&&t.props.ref(i),i}function En(e){let n=e.ui;n&&typeof n.render=="function"&&n.render(["_wf_root"])}function Ee(e,n,t,o){let i;if(X(e)){if(i=je(e),!i)return Ce(e,o).promise.then(()=>En(o),()=>{}),null}else i=e;o.ui?.setMounting?.(!0);let s;try{s=i(n,o)}finally{o.ui?.endMounting?.()}if(typeof s!="function")throw new Error(`Component ${e.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);return t._render=s,s(n)}function Pn(e,n,t,o){o.ui=o.ui??{},t._id||(t._id=Q(),V.set(t._id,t));let i=Object.create(o);i.ui=Object.create(o.ui),i.ui._selfId=t._id,i.ui._selfVNode=t,t._ctxVersion=i.ui._ctxVersion??0;let s;try{s=Ee(e,n,t,i)}catch(c){let l=o.ui?._errorHandler;l?(l(c),s=null):(console.error(`[weifuwu] Component render error in <${e.name||"anonymous"}> (id: ${t._id??"?"}, phase: mount)`,c),s=null)}if(s==null)return t._child=null,null;t._child=s;let a=D(s,i);return t._refNode||(t._refNode=a),a}function _n(e,n){let t=document.createDocumentFragment();for(let o of e){let i=D(o,n);i!=null&&t.appendChild(i)}return t}function Sn(){let e=document.getElementById("__wf_portal");return e||(e=document.createElement("div"),e.id="__wf_portal",e.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:9999",document.body.appendChild(e)),e}function Y(e,n){let t=Sn(),o=document.createElement("div");o.style.pointerEvents="auto",t.appendChild(o),e._remoteEl=o;let i=ee(e.props?.children);e._child=i;for(let s of i){let a=D(s,n);a!=null&&o.appendChild(a)}}function ne(e,n,t){let o=e?._remoteEl;if(n._remoteEl=o,!o){Y(n,t);return}let i=ee(n.props?.children),s=e._child||[];n._child=i,ae(s,i);let a=Z(Array.from(o.childNodes),s);le(o,s,i,t,a,a[0]?.[0]??null)}function Se(e){if(e==null)return[];if(!Array.isArray(e))return[e];let n=[];for(let t of e)Array.isArray(t)?n.push(...t):n.push(t);return n}function Ge(e,n,t){if(n!=="ref")if(n==="class"||n==="className")e instanceof SVGElement?e.setAttribute("class",String(t??"")):e.className=String(t??"");else if(n==="style"&&typeof t=="object"&&t!==null){let o=e.style;for(let i of Object.keys(t)){let s=t[i];s!=null&&(o[i]=typeof s=="number"?s+"px":String(s))}}else n.startsWith("on")&&typeof t=="function"?e.addEventListener(n.slice(2).toLowerCase(),t):n==="draggable"?e.setAttribute("draggable",t?"true":"false"):n==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(t??""):t===!0?e.setAttribute(n,""):t!=null&&t!==!1&&e.setAttribute(n,String(t))}function An(e,n,t){e.innerHTML="";let o=D(n,t);o instanceof Node?e.appendChild(o):Array.isArray(o)&&o.forEach(i=>e.appendChild(i))}function Ae(e){e.node=e.node?e.node.nextSibling:null}function Rn(e,n){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(n,e.node):e.parent.appendChild(n)}function kn(e,n){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(n,e.node),Ae(e)):e.parent.appendChild(n)}async function te(e,n,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let c=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==c&&(t.node.textContent=c),Ae(t),t.node;let l=document.createTextNode(c);return Rn(t,l),l}if(Array.isArray(e)){let c=null;for(let l of e){let u=await te(l,n,t);u!=null&&!c&&(c=u)}return c}let o=e;if(o.type===q||o.type===B){let c=o.props?.children,l=c==null?[]:Array.isArray(c)?c:[c],u=null;for(let m of l){let y=await te(m,n,t);y!=null&&!u&&(u=y)}return u}if(typeof o.type=="function")return Mn(o,n,t);let i=o.type,s=o.props??{},a;if(t.node&&t.node.nodeType===1&&t.node.tagName.toLowerCase()===i.toLowerCase()?(a=t.node,Ae(t)):(a=_e.has(i)?document.createElementNS(Pe,i):document.createElement(i),kn(t,a)),o.el=a,Te(a,null,s),!("innerHTML"in s)){let c={parent:a,node:a.firstChild},l=Se(s.children);for(let u of l){let m=await te(u,n,c);if(m!=null&&m.parentNode!==a&&a.appendChild(m),u&&typeof u=="object"&&typeof u.type=="function"){let y=u;y._parentNode||(y._parentNode=a,y._refNode=m)}}for(;c.node;){let u=c.node;c.node=u.nextSibling,u.parentNode?.removeChild(u)}}return"value"in s&&a instanceof HTMLSelectElement&&(a.value=String(s.value??"")),typeof s.ref=="function"&&s.ref(a),a}async function Mn(e,n,t){n.ui=n.ui??{},e._id||(e._id=Q(),V.set(e._id,e));let o=Object.create(n);o.ui=Object.create(n.ui),o.ui._selfId=e._id,o.ui._selfVNode=e,e._ctxVersion=o.ui._ctxVersion??0;let i=e.type,s;try{let c;X(i)?c=await Ue(i,o):c=i;let l=c(e.props??{},o);if(typeof l!="function")throw new Error(`Component ${i.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);e._render=l,s=l(e.props??{})}catch(c){let l=n.ui?._errorHandler;l?(l(c),s=null):(console.error(`[weifuwu] Component hydration error in <${i.name||"anonymous"}> (id: ${e._id??"?"})`,c),s=null)}if(s==null)return e._child=null,null;e._child=s;let a=await te(s,o,t);return e._refNode||(e._refNode=a),a}async function Re(e,n,t){let o={parent:e,node:e.firstChild};for(await te(n,t,o);o.node;){let i=o.node;o.node=i.nextSibling,i.parentNode?.removeChild(i)}}var ue=0,Xe="",Je="",Qe="",Ze="",ce=0;function en(){return typeof window<"u"&&typeof document<"u"}function ke(){if(ue++,ue>1||!en())return;ce=window.scrollY;let e=document.body;Xe=e.style.overflow,Je=e.style.position,Qe=e.style.top,Ze=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=`-${ce}px`,e.style.width="100%")}function Me(){if(ue--,ue>0||!en())return;let e=document.body;e.style.overflow=Xe,e.style.position=Je,e.style.top=Qe,e.style.width=Ze,ce>0&&window.scrollTo(0,ce)}var Nn='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function de(e){let n=e.querySelectorAll(Nn);if(n.length===0)return()=>{};let t=n[0],o=n[n.length-1],i=a=>{a.key==="Tab"&&(a.shiftKey&&document.activeElement===t?(a.preventDefault(),o.focus()):!a.shiftKey&&document.activeElement===o&&(a.preventDefault(),t.focus()))},s=document.activeElement;return queueMicrotask(()=>{t.focus()}),e.addEventListener("keydown",i),()=>{e.removeEventListener("keydown",i),s?.focus()}}function fe(e){let n=new WeakMap,t=new Set,o=s=>{if(s===null||typeof s!="object")return s;if(s instanceof Set||s instanceof Map){if(n.has(s))return n.get(s);let c=s instanceof Set?new Set(["add","delete","clear"]):new Set(["set","delete","clear"]),l=new Proxy(s,{get(u,m){let y=Reflect.get(u,m);return typeof y=="function"?c.has(String(m))?(...T)=>{let b=y.apply(u,T);e();for(let g of t)g();return b}:y.bind(u):y},set(u,m,y){Reflect.set(u,m,y),e();for(let T of t)T();return!0}});return n.set(s,l),l}if(s instanceof Date||s instanceof RegExp)return s;if(n.has(s))return n.get(s);let a=new Proxy(s,{set(c,l,u){if(Reflect.get(c,l)===u)return!0;Reflect.set(c,l,u),e();for(let y of t)y();return!0},get(c,l){let u=Reflect.get(c,l);return typeof u=="object"&&u!==null?o(u):u},deleteProperty(c,l){if(Reflect.has(c,l)){Reflect.deleteProperty(c,l),e();for(let u of t)u()}return!0}});return n.set(s,a),a},i=o({});return Object.defineProperty(i,"__watch",{value:s=>(t.add(s),()=>{t.delete(s)}),writable:!1,enumerable:!1}),i}function Ne(e,n,t){let o=new AbortController,i=t?.signal;i&&(i.aborted?o.abort():i.addEventListener("abort",()=>o.abort(),{once:!0}));let s=t?.traceId??Hn(),a=t?.record!==!1,c=[],l=(async()=>{let u;try{u=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":s,Accept:"text/event-stream",...t?.headers},body:JSON.stringify(n),signal:o.signal})}catch(m){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:m instanceof Error?m.message:String(m)});return}if(!u.ok){t?.onError?.({code:Wn(u.status),message:`HTTP ${u.status} ${u.statusText}`});return}try{for await(let{name:m,data:y}of On(u.body)){if(o.signal.aborted)return;Vn(c,{name:m,data:y},a),Ln(m,y,t??{})}}catch(m){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:m instanceof Error?m.message:String(m)})}})();return{abort:()=>o.abort(),done:l,traceId:s,events:c}}function Ln(e,n,t){switch(e){case"wf:token":return t.onToken?.(n.text);case"wf:tool_call":return t.onToolCall?.(n);case"wf:tool_result":return t.onToolResult?.(n);case"wf:tool_progress":return t.onToolProgress?.(n);case"wf:step":return t.onStep?.(n);case"wf:approval_request":return t.onApproval?.(n);case"wf:usage":return t.onUsage?.(n);case"wf:done":return t.onDone?.(n);case"wf:error":return t.onError?.(n);default:return t.onEvent?.(e,n)}}async function*On(e){let n=e.getReader(),t=new TextDecoder,o="";try{for(;;){let{done:i,value:s}=await n.read();if(i)break;o+=t.decode(s,{stream:!0});let a=o.split(`
|
|
2
2
|
|
|
3
|
-
`);o=a.pop()??"";for(let
|
|
4
|
-
`))m.startsWith("event: ")?l=m.slice(7):m.startsWith("data: ")&&(c+=m.slice(6));if(c)try{yield{name:l,data:JSON.parse(c)}}catch{}}}}finally{n.releaseLock()}}function Vn(e,n,t){t&&(e.length>=1e3&&e.shift(),e.push(n))}function Wn(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Hn(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function nn(e){return e.map(n=>({role:n.role,content:n.content}))}function Le(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function tn(e,n,t){t.initialMessages?e.messages=structuredClone(t.initialMessages):e.messages===void 0&&(e.messages=[]),e.input===void 0&&(e.input=""),e.streaming===void 0&&(e.streaming=!1),e.error===void 0&&(e.error=null),e.usage===void 0&&(e.usage=null),e.step===void 0&&(e.step=null);let o=null;function i(){if(!e.streaming)return;let C=e.messages[e.messages.length-1];return C&&C.role==="assistant"&&C.status==="streaming"?C:void 0}function s(C,y,v){let r=i();switch(C){case"wf:token":r&&(r.content+=y.text);break;case"wf:tool_call":{r&&(r.toolCalls||(r.toolCalls=[]),r.toolCalls.push({call:y,status:"running"}));break}case"wf:tool_progress":{let d=y,f=r?.toolCalls?.find(p=>p.call.id===d.toolCallId);f&&(f.progress=d);break}case"wf:tool_result":{let d=y,f=r?.toolCalls?.find(p=>p.call.id===d.id);f&&(f.result=d,f.status=d.ok?"ok":"error");break}case"wf:approval_request":r&&(r.approval=y);break;case"wf:usage":r&&(r.usage=y);break;case"wf:step":e.step=y;break;case"wf:done":r&&(r.status="done",r.approval=void 0),e.streaming=!1,e.step=null;break;case"wf:error":r&&(r.status="error",r.error=y,r.approval=void 0),e.error=y,e.streaming=!1,e.step=null;break;default:v?.(C,y);break}}function a(){let C=t.body?t.body(e.messages):{messages:nn(e.messages)};o=n(t.url,C,{onToken:v=>s("wf:token",{text:v}),onToolCall:v=>s("wf:tool_call",v),onToolProgress:v=>s("wf:tool_progress",v),onToolResult:v=>s("wf:tool_result",v),onApproval:v=>s("wf:approval_request",v),onUsage:v=>s("wf:usage",v),onStep:v=>s("wf:step",v),onDone:v=>s("wf:done",v),onError:v=>s("wf:error",v),onEvent:(v,r)=>s(v,r,t.onEvent)},{signal:t.signal,headers:t.headers}),e.streaming=!0;let y=i();y&&o?.traceId&&(y.id=o.traceId)}function u(){if(e.streaming)return;let C=String(e.input??"").trim();C&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"user",content:C,status:"done"},{id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function l(){o?.abort(),e.streaming=!1,e.step=null;let C=e.messages[e.messages.length-1];C&&C.role==="assistant"&&C.status==="streaming"&&(!C.content&&(!C.toolCalls||C.toolCalls.length===0)?e.messages.pop():C.status="done")}function c(){if(e.streaming)return;let C=-1;for(let y=e.messages.length-1;y>=0;y--)if(e.messages[y].role==="user"){C=y;break}C!==-1&&(e.messages.splice(C+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function m(){o?.abort(),e.messages=[],e.input="",e.streaming=!1,e.error=null,e.usage=null,e.step=null}async function g(C,y){let v=e.messages[e.messages.length-1],r=v?.role==="assistant"?v.approval:void 0;if(r&&(v.approval=void 0,!!t.approveUrl))try{await fetch(t.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify({id:r.id,decision:C,note:y}),signal:t.signal})}catch(d){if(t.signal?.aborted)return;e.error={code:"provider_error",message:d instanceof Error?d.message:String(d)}}}function P(){o?.abort(),o=null}return{send:u,stop:l,retry:c,clear:m,approve:g,dispose:P}}function pe(e,n="bottom",t=6,o=!0){switch(n){case"bottom":return{top:e.bottom+t,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-t,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-t};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+t}}}function In(e,n="bottom",t=6,o=!0){return pe(e.getBoundingClientRect(),n,t,o)}function me(e,n,t=8){if(!n)return e;let o=n.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let i=Number.parseFloat(n.style.top)||o.top,s=Number.parseFloat(n.style.left)||o.left,a=e.top-i,u=e.left-s,l={top:o.top+a,bottom:o.bottom+a,left:o.left+u,right:o.right+u},c=window.innerWidth,m=window.innerHeight,g=e.top,P=e.left;return l.bottom>m-t&&(g=Math.max(t,g-(l.bottom-(m-t)))),l.top<t&&(g=Math.max(t,g+(t-l.top))),l.right>c-t&&(P=Math.max(t,P-(l.right-(c-t)))),l.left<t&&(P=Math.max(t,P+(t-l.left))),{top:g,left:P,width:e.width}}var on=new Set,oe=new Map;function rn(e){let{ctx:n,renderByIds:t,getSelfId:o,dirtyBatch:i,dirtySet:s,mediaRegistry:a,popupTrackers:u,scrollTrackers:l,schedulePopupRecompute:c,ensurePopupListeners:m,isRendering:g,isMounting:P,setMounting:C,endMounting:y}=e;return{_selfId:"_wf_root",_ctxVersion:0,_dirtySet:s,setMounting:C,endMounting:y,bumpCtxVersion:function(){this._ctxVersion++},render:function(r){if(g()){if(P())return;this._pendingRender||(this._pendingRender=!0,queueMicrotask(()=>{this._pendingRender=!1,this.render(r)}));return}if(!r||r.length===0){let d=o(this);if(d)r=[d];else return}t(r)},dirty:function(r){if(!P()){if(g()){this._pendingDirty||(this._pendingDirty=!0,queueMicrotask(()=>{this._pendingDirty=!1,this.dirty(r)}));return}if(!r||r.length===0){let d=o(this);if(d)r=[d];else return}for(let d of r)d&&(i.add(d),s.add(d));this._dirtyScheduled||(this._dirtyScheduled=!0,queueMicrotask(()=>{this._dirtyScheduled=!1;let d=[...i];i.clear(),d.length>0&&t(d)}))}},$:function(){let r=this;return r._$cache||(r._$cache=fe(()=>{let d=r._selfVNode?._id??o(r);d&&n.ui.dirty([d])})),r._$cache},useChat:function(r){let d=this.$(),f=tn(d,Me,r);return Object.assign(d,{send:f.send,stop:f.stop,retry:f.retry,clear:f.clear,approve:f.approve,dispose:f.dispose}),d},useMedia:function(r,d){let p=`media:${o(this)}:${r}`;if(!a.has(p)){let h=window.matchMedia(r);d(h.matches);let b=E=>d(E.matches);h.addEventListener("change",b),a.set(p,{mql:h,handler:b})}},useBreakpoint:function(r,d){let f=typeof r=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:r,p=typeof r=="function"?r:d,b=`bp:${o(this)}`;function E(){for(let[x,k]of Object.entries(f))if(window.matchMedia(k).matches)return x;return Object.keys(f)[0]??""}if(!a.has(b)){p(E());let x=[];for(let k of Object.values(f)){let T=window.matchMedia(k),_=()=>p(E());T.addEventListener("change",_),x.push({mql:T,handler:_})}a.set(b,{mqls:x})}},usePopupPosition:function(r){let d=o(this),f={top:0,left:0,refresh:()=>{}};if(!d)return f;let p={pos:f,getEl:r.el,isOpen:r.isOpen,compute:r.compute,panel:r.panel,margin:r.margin??8};return u.set(d,p),m(),f.refresh=()=>{let h=p.getEl();if(!h)return;let b=p.compute(h.getBoundingClientRect());Object.assign(f,me(b,p.panel?.(),p.margin))},f},useHoverCapable:function(){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches},useStableRef:function(r,d){return p=>{p?r(p):d?.()}},useVisualViewport:function(){let r=o(this),d={height:window.innerHeight,offsetTop:0,keyboardOpen:!1},f=()=>{n.ui&&n.ui.dirty(r?[r]:void 0)},p=()=>{let b=window.visualViewport;d.height=b?.height??window.innerHeight,d.offsetTop=b?.offsetTop??0,d.keyboardOpen=d.height<window.innerHeight*.9,f()},h=window.visualViewport;return h?.addEventListener?(h.addEventListener("resize",p),h.addEventListener("scroll",p)):window.addEventListener("resize",p),r&&K(b=>{b===r&&(h?.removeEventListener?(h.removeEventListener("resize",p),h.removeEventListener("scroll",p)):window.removeEventListener("resize",p))}),d},usePopup:function(r){let d=o(this),f=this.useHoverCapable(),p=()=>typeof r.trigger=="function"?r.trigger():r.trigger,h=r.open!==void 0,b=()=>!!r.disabled?.(),E=()=>h?typeof r.open=="function"?!!r.open():!!r.open:r.isOpen(),x=A=>{b()||(h?r.onOpenChange?.(A):r.setOpen(A))},k=()=>{let A=r.placement;return typeof A=="function"?A():A??"bottom"},T=null,_=!1,w=n.ui.usePopupPosition({el:r.el,isOpen:()=>E(),compute:A=>{if(r.position){let W=r.position();return{top:W.y,left:W.x}}return pe(A,k(),r.gap??6,r.center!==!1)},panel:()=>T,margin:r.margin??8}),R=A=>{if(r.closeOnOutside===!1||!E())return;let W=A.target;if(!(W instanceof Node))return;let $=r.el();$&&$.contains(W)||T&&T.contains(W)||x(!1)},M=A=>{r.closeOnEscape!==!1&&(A.key!=="Escape"||!E()||x(!1))};document.addEventListener("mousedown",R),document.addEventListener("keydown",M),d&&K(A=>{A===d&&(document.removeEventListener("mousedown",R),document.removeEventListener("keydown",M))});let S={},j=A=>typeof A=="function"?A():A??0,N=()=>j(r.openDelay),H=()=>j(r.closeDelay),L,I,re=()=>{clearTimeout(L),clearTimeout(I),L=void 0,I=void 0};if(p()==="hover")f?(S.onMouseEnter=()=>{b()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onMouseLeave=()=>{b()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))}):S.onClick=()=>x(!E()),S.onFocus=()=>{b()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onBlur=()=>{b()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))};else if(p()==="click")S.onClick=()=>x(!E());else if(p()==="longpress"){let A,W=0,$=0,F=()=>{clearTimeout(A),A=void 0};S.onPointerDown=U=>{b()||(W=U.clientX??0,$=U.clientY??0,F(),A=setTimeout(()=>{A=void 0,r.onTrigger?.({clientX:W,clientY:$}),x(!0)},r.longPressDuration??500))},S.onPointerUp=F,S.onPointerLeave=F,S.onPointerMove=U=>{let he=Math.abs((U.clientX??0)-W),ve=Math.abs((U.clientY??0)-$);(he>10||ve>10)&&F()},S.onContextMenu=U=>{U.preventDefault(),r.onTrigger?.({clientX:U.clientX??0,clientY:U.clientY??0}),x(!0)}}S.onKeyDown=A=>{A.key==="Escape"&&r.closeOnEscape!==!1&&x(!1)},d&&K(A=>{A===d&&re()});let dn=A=>{if(A){T=A;let W=()=>w.refresh();A.addEventListener("animationend",W,{once:!0})}else T=null},fn=(A,W="popover")=>{if(b())return null;if(!E())return _=!1,null;_||(w.refresh(),_=!0);let F=A.props??{},U=F.ref,he=["wf-popup",F.class].filter(Boolean).join(" "),ve={...F.style??{},position:"fixed",top:`${w.top}px`,left:`${w.left}px`,maxWidth:r.width!==void 0?`min(${r.width}px, calc(100vw - 32px))`:"calc(100vw - 32px)"},pn={...A,props:{...F,class:he,style:ve,ref:He=>{dn(He),U&&U(He)}}};return be(pn,W)};return{open:E(),setOpen:x,wrapProps:S,portal:fn,refresh:()=>w.refresh()}},useLongPress:function(r){let{onLongPress:d,duration:f=500}=r,p,h=0,b=0,E=null,x=()=>{clearTimeout(p),p=void 0};return{onPointerDown:k=>{h=k.clientX??0,b=k.clientY??0,E=k,x(),p=setTimeout(()=>{p=void 0,d(E)},f)},onPointerUp:x,onPointerLeave:x,onPointerMove:k=>{let T=Math.abs((k.clientX??0)-h),_=Math.abs((k.clientY??0)-b);(T>10||_>10)&&x()},onContextMenu:k=>{k.preventDefault(),d(k)}}},useInView:function(r){let d=o(this),f={isIn:!1,ready:!1,observe:x,refresh:k,disconnect:T},p=null,h=null,b=()=>{n.ui&&n.ui.dirty(d?[d]:void 0)};function E(){if(h?.disconnect(),h=null,!p)return;let _=typeof r.rootMargin=="function"?r.rootMargin():r.rootMargin,w=typeof r.threshold=="function"?r.threshold():r.threshold;h=new IntersectionObserver(R=>{let M=R[R.length-1];if(!M)return;let S=M.isIntersecting,j=S!==f.isIn,N=!f.ready;f.isIn=S,f.ready=!0,r.onChange?.(M,S),(j||N)&&b()},{root:r.root?r.root():null,rootMargin:_??"0px",threshold:w??0}),h.observe(p)}function x(_){p=_,_?E():(h?.disconnect(),h=null,f.isIn=!1)}function k(){E()}function T(){h?.disconnect(),h=null}return f},useScrollPosition:function(r){let d=o(this),f={y:0,refresh(){let h=p.getScroller();f.y=h instanceof Window?document.scrollingElement?.scrollTop??h.scrollY??0:h.scrollTop??0}},p={handle:f,getScroller:r.getScroller??(()=>window)};return d?(l.set(d,p),m(),f.refresh(),f):(f.refresh(),f)},useAsync:function(r){let d=o(this),f=fe(()=>{n.ui&&n.ui.dirty(d?[d]:void 0)});f.loading=!0;let p=0,h=()=>{let b=++p;f.loading=!0,f.error=null,Promise.resolve().then(()=>r()).then(E=>{p===b&&(f.data=E,f.loading=!1)}).catch(E=>{p===b&&(f.error=E,f.loading=!1)})};return h(),f.reload=h,f},useControlled:function(r){let d=o(this),f=r.value!==void 0;f&&!r.onChange&&r.name&&(on.has(r.name)||(on.add(r.name),console.warn(`[weifuwu/${r.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
5
|
-
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!f&&d&&!oe.has(d)&&(oe.set(d,r.value),K(h=>{oe.delete(h)}));let p=h=>{if(f){r.onChange?.(h);return}d&&oe.set(d,h),n.ui&&(d?n.ui.dirty([d]):n.ui.render())};return{value:f?r.value:d?oe.get(d):r.value,setValue:p,controlled:f}},usePresence:function(r){let d=o(this),f="closed",p,h=()=>{f="closed",n.ui&&(d?n.ui.dirty([d]):n.ui.render())};return{get phase(){return f},ref:E=>{E?p||(p=()=>{f==="exit"&&h()},E.addEventListener("animationend",p)):(E?.removeEventListener("animationend",p),p=void 0)},sync:E=>(E?f="open":f==="open"&&(f="exit"),f)}},useDialog:function(r){let d=o(this),f,p=null,h=this.usePresence(r);return{get phase(){return h.phase},rootRef:x=>{x?(ke(),p&&(f=de(p)),h.ref(x)):(Ne(),f?.(),h.ref(null))},panelRef:x=>{p=x,x&&!f&&(f=de(x))},sync:x=>h.sync(x)}},useGlobalKey:function(r){let d=o(this);return typeof window>"u"?()=>{}:(window.addEventListener("keydown",r),d&&K(f=>{f===d&&window.removeEventListener("keydown",r)}),()=>window.removeEventListener("keydown",r))},useDrag:function(r){let d=0,f=0,p=!1,h=x=>{p&&r.onMove(x,{x:x.clientX-d,y:x.clientY-f})},b=x=>{p&&(p=!1,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",b),r.onEnd?.(x))};return{onPointerDown:x=>{p||(x.preventDefault(),p=!0,d=x.clientX,f=x.clientY,window.addEventListener("pointermove",h),window.addEventListener("pointerup",b),r.onStart?.(x))}}},useDragDrop:function(r){let d={};r.onDrop&&(d.onDrop=p=>{p.preventDefault(),r.onDrop(p)}),r.onDragOver&&(d.onDragOver=p=>{p.preventDefault(),r.onDragOver(p)}),r.onDragLeave&&(d.onDragLeave=p=>r.onDragLeave(p));let f={draggable:!0};return r.onDragStart&&(f.onDragStart=p=>r.onDragStart(p)),r.onDragEnd&&(f.onDragEnd=p=>r.onDragEnd(p)),{dropProps:d,dragProps:f}},useReducedMotion:function(){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches},useAnimationEnd:function(r,d){let f=null,p=()=>{r(),d?.once&&f&&f.removeEventListener("animationend",p)};return b=>{b?(f=b,b.addEventListener("animationend",p)):f&&(f.removeEventListener("animationend",p),f=null)}},useTween:function(r,d){let f=o(this),p=this.useReducedMotion(),h=d?.duration??400,b=d?.ease==="linear"?w=>w:w=>1-Math.pow(1-w,3),E,x=r,k={value:p?r:0,reset:()=>{}},T=()=>{n.ui&&(f?n.ui.dirty([f]):n.ui.render())},_=w=>{if(x=w,p){k.value=w,T();return}if(w===k.value)return;E&&cancelAnimationFrame(E);let R=k.value,M=performance.now(),S=j=>{let N=Math.min(1,(j-M)/h);k.value=Math.round(R+(w-R)*b(N)),N<1?(E=requestAnimationFrame(S),T()):(E=void 0,T())};E=requestAnimationFrame(S)};return k.reset=w=>{w===x&&E||_(w)},queueMicrotask(()=>_(r)),k},selfId:function(r){if(typeof r!="string"||!r)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof r}`);if(V.has(r))throw new Error(`[weifuwu] Duplicate component ID: "${r}". Each component must have a unique custom ID.`);let d=this._selfVNode;d&&(d._customId=r,V.set(r,d))}}}function sn(){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,createElement:e=>typeof document<"u"?document.createElement(e):null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}function Dn(){let e=[],n={},t=null,o=null,i=null,s=!1,a=!1,u=[];function l(T){u.push(a),a=T}function c(){a=u.pop()??!1}let m=new Set,g=!1,P=new Map;function C(T){let _=P.get(T);_&&(_.mql&&_.handler&&_.mql.removeEventListener("change",_.handler),_.mqls?.forEach(({mql:w,handler:R})=>w.removeEventListener("change",R)),P.delete(T))}let y=new Map,v=!1,r=0;function d(){v||(v=!0,window.addEventListener("scroll",h,{capture:!0,passive:!0}),window.addEventListener("resize",h))}function f(){v&&(window.removeEventListener("scroll",h,{capture:!0}),window.removeEventListener("resize",h),v=!1)}let p=new Map;function h(){r||(r=requestAnimationFrame(()=>{r=0;let T=[];for(let[_,w]of y){if(!w.isOpen())continue;let R=w.getEl();if(!R)continue;let M=w.compute(R.getBoundingClientRect());Object.assign(w.pos,me(M,w.panel?.(),w.margin)),T.push(_)}for(let[_,w]of p){let R=w.getScroller(),M=R instanceof Window?document.scrollingElement?.scrollTop??R.scrollY??0:R.scrollTop??0;M!==w.handle.y&&(w.handle.y=M,T.push(_))}T.length>0&&n.ui.render(T)}))}function b(T){if(!s){s=!0;for(let _ of T){let w=V.get(_);if(!w||!w._render)continue;n.ui._dirtySet?.delete(_);let R=w._child,M=w._render(w.props);if(w._child=M,R&&R._placement==="remote"||M&&M._placement==="remote"){R&&M?ne(R,M,n):M?G(M,n):R&&O(R);continue}if(!w._parentNode&&w._refNode&&(w._parentNode=w._refNode.parentNode),w._parentNode){let S=z(w._parentNode,w._refNode??null,R,M,n);S&&S!==w._refNode?w._refNode=S:S||(w._refNode=null)}}s=!1,E()}}function E(){let T=n.ui;m.size>0&&!T._dirtyScheduled&&(T._dirtyScheduled=!0,queueMicrotask(()=>{T._dirtyScheduled=!1;let _=[...m];m.clear(),_.length>0&&b(_)}))}function x(T){return T?._selfId??n.ui?._selfId}let k={get ctx(){return n},use(T){return e.push(T),k},async mount(T,_,w){o=_;for(let N of e)n=await N(n);let R=typeof T=="string"?document.querySelector(T):T;if(!R)throw new Error(`mount target not found: ${T}`);t=R;let M=!!w?.hydrate;M||(t.innerHTML="");let S=new Map,j=globalThis.__DATA__;if(j&&typeof j=="object")for(let[N,H]of Object.entries(j))S.set(N,{value:H});if(n.data={async get(N,H){let L=S.get(N);if(L&&"value"in L)return L.value;if(L?.promise)return L.promise;if(!H)return;let I=Promise.resolve().then(()=>H()).then(re=>(S.set(N,{value:re}),re));return S.set(N,{promise:I}),I},set(N,H){S.set(N,{value:H})},has(N){return S.has(N)}},K(N=>{for(let H of[...P.keys()])(H.startsWith(`media:${N}:`)||H===`bp:${N}`)&&C(H);y.delete(N),p.delete(N)}),n.browser=sn(),n.ui=rn({ctx:n,renderByIds:b,getSelfId:x,dirtyBatch:m,dirtySet:new Set,mediaRegistry:P,popupTrackers:y,scrollTrackers:p,schedulePopupRecompute:h,ensurePopupListeners:d,destroyPopupListeners:f,isRendering:()=>s,isMounting:()=>a,setMounting:l,endMounting:c}),s=!0,i=Un(_,n),i._id="_wf_root",i._parentNode=t,i._refNode=M?t.firstChild:null,V.set("_wf_root",i),M)await Re(t,i,n);else{let N=Ge(i,n);N instanceof Node&&t.appendChild(N)}i._refNode=t.firstChild,s=!1,E()},destroy(){f(),y.clear(),p.clear();for(let T of[...P.keys()])C(T);V.clear(),t&&(t.innerHTML=""),t=null,n={}}};return k}function Un(e,n){return{type:e,props:{},key:void 0}}function jn(e,n){if(!n||n==="/")return e||"/";let t=e.endsWith("/")?e.slice(0,-1):e,o=n.startsWith("/")?n:"/"+n;return t+o}function qn(e){let n=[],t=e.replace(/:(\w+)/g,(o,i)=>(n.push(i),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}function Oe(e,n="",t=[]){let o=[];for(let i of e){let s=jn(n,i.path),{re:a,keys:u}=qn(s),l=[...t,i];o.push({re:a,keys:u,def:i,chain:l}),i.children&&o.push(...Oe(i.children,s,l))}return o}function an(e,n){let t=null;for(let o of n)e.match(o.re)&&(!t||o.chain.length>t.chain.length)&&(t=o);return t}function ln(e,n){let t={},o=e.match(n.re);if(o)for(let i=0;i<n.keys.length;i++)t[n.keys[i]]=decodeURIComponent(o[i+1]);return t}function Fn(e){let n=Oe(e.routes),t=e.mode||"history";function o(){return t==="hash"?window.location.hash.replace(/^#/,"")||"/":window.location.pathname}function i(s){let a=an(s,n);if(a){let u=a.chain[a.chain.length-1];return{path:a.def.path,params:ln(s,a),query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:a.chain,title:u?.title??""}}return{path:s,params:{},query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:e.notFound?[{component:e.notFound,title:"Not Found"}]:[],title:""}}return s=>{let a=i(o());s.route=a,a.title&&(document.title=a.title),s.app||(s.app={}),s.app.navigate=l=>{if(J(),t==="hash"){window.location.hash="#"+l;let c=i(l);s.route=c}else{window.history.pushState({},"",l);let c=i(l);s.route=c}s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};let u=()=>{J();let l=i(o());s.route=l,s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};return window.addEventListener("popstate",u),t==="hash"&&window.addEventListener("hashchange",u),s}}function Bn(e,n){let t=n.route?._rvDepth??0;return()=>{let o=n.route;if(!o?.chain?.length||t>=o.chain.length)return null;let i=o.chain[t],s=i.layout??i.component;return s?(i.layout&&(o._rvDepth=t+1),{type:s,props:{},key:void 0}):null}}function Y(e,n){return Object.assign(Object.create(e),n)}function Kn(e={}){let n=e.url??"/ws",t=e.reconnectInterval??3e3,o=e.maxReconnect??10,i=e.pingInterval??3e4,s=e.pingTimeout??1e4;return a=>{let u=new Set,l=null,c=0,m=null,g=null,P=null,C=!1,y={isConnected:!1,onMessage:p=>(u.add(p),()=>{u.delete(p)}),send:p=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify(p))},_connect:v,close:()=>{C=!0,f(),l?.close(),l=null,y.isConnected=!1}};async function v(){if(!C)try{l=new WebSocket(n),l.onopen=()=>{y.isConnected=!0,c=0,r()},l.onmessage=p=>{try{let h=JSON.parse(p.data);for(let b of u)b(h)}catch{}d()},l.onclose=()=>{y.isConnected=!1,f(),!C&&c<o&&(c++,m=setTimeout(v,t*Math.min(c,5)))},l.onerror=()=>{l?.close()}}catch{C||(m=setTimeout(v,t))}}function r(){i<=0||(g=setInterval(()=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:"ping"})),P=setTimeout(()=>{l?.close()},s)},i))}function d(){clearTimeout(P)}function f(){clearInterval(g),clearTimeout(P),clearTimeout(m)}return v(),Y(a,{ws:y})}}function $n(e){let n={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},t=e?.onRequest,o=e?.onResponse,i=e?.timeout??0;async function s(a,u,l,c){let m=n.baseURL+u,g={method:a,headers:{...n.headers,...c?.headers}},P=e?.token?.();P&&!g.headers.Authorization&&(g.headers.Authorization=`Bearer ${P}`);let C=i>0,y=!!c?.signal,v=null,r=null;(C||y)&&(v=new AbortController,g.signal=v.signal,C&&(r=setTimeout(()=>v.abort(new Error("Request timed out")),i)),y&&c.signal.addEventListener("abort",()=>v.abort())),l!==void 0&&a!=="GET"&&a!=="HEAD"&&(g.body=JSON.stringify(l));let d={url:m,init:g};t&&(d=t(d));try{let f=await fetch(d.url,d.init);if(o)return o(f);if(!f.ok){let b=await f.text().catch(()=>"");throw new ye(f.status,b||f.statusText)}let p=f.headers.get("content-length");if(f.status===204||p==="0")return;let h=(f.headers.get("content-type")||"").toLowerCase();return h.includes("application/json")||h.includes("json")?f.json():f.text()}finally{r&&clearTimeout(r)}}return a=>Y(a,{api:{get:(l,c)=>s("GET",l,void 0,c),post:(l,c,m)=>s("POST",l,c,m),put:(l,c,m)=>s("PUT",l,c,m),patch:(l,c,m)=>s("PATCH",l,c,m),delete:(l,c)=>s("DELETE",l,void 0,c)}})}var ye=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function zn(e){try{let n=e.split(".");if(n.length!==3)return null;let t=n[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t))}catch{return null}}function Yn(e){let n=zn(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function Gn(e){let n=e?.storage??localStorage,t=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",i=e?.refreshTokenKey??"weifuwu_refresh",s=e?.refreshEndpoint??"/api/auth/refresh";return a=>{let u=n.getItem(t),l=n.getItem(o),c={token:u,user:l?JSON.parse(l):null,get isLoggedIn(){return this.token!==null},login(m,g,P){c.token=m,c.user=g,n.setItem(t,m),n.setItem(o,JSON.stringify(g)),P&&n.setItem(i,P)},logout(){c.token=null,c.user=null,n.removeItem(t),n.removeItem(o),n.removeItem(i)},setUser(m){c.user=m,n.setItem(o,JSON.stringify(m))},async refresh(){let m=n.getItem(i);if(!m)return!1;try{let g=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:m})});if(!g.ok)return c.logout(),!1;let P=await g.json();return c.token=P.token,n.setItem(t,P.token),P.refreshToken&&n.setItem(i,P.refreshToken),!0}catch{return!1}}};return u&&Yn(u)&&c.refresh().catch(()=>{}),Y(a,{auth:c})}}function Xn(e,n){let t=null;return o=>{if(t){let s=o.fallback;return typeof s=="function"?s({error:t}):s??null}n.ui._errorHandler=s=>{t=s,n.ui.render()};let i=o.children;try{return i??null}catch(s){t=s;let a=o.fallback;return typeof a=="function"?a({error:s}):a??null}}}var Ve={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 We={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 ge={"zh-CN":Ve,"en-US":We};function un(e){if(ge[e])return e;let n=e.split("-")[0];return Object.keys(ge).find(o=>o.startsWith(n))??"zh-CN"}function Jn(e={}){let{locale:n="zh-CN",messages:t={},components:o={}}=e,i=un(n),s=ge[i],a=cn(s,t,o),u={locale:i,t:(l,c)=>a.messages?.[l]??c??l,setLocale:()=>{},components:a.components};return l=>(l.i18n=u,u.setLocale=c=>{let m=un(c),g=ge[m];g&&(a=cn(g,t,o),u.locale=m,u.components=a.components,l?.ui?.bumpCtxVersion?.(),l?.ui?.render())},l)}function cn(e,n,t){return{messages:{...e?.messages,...n},components:Qn(e?.components??{},t)}}function Qn(e,n){let t={...e};for(let o of Object.keys(n))typeof n[o]=="object"&&n[o]!==null&&typeof t[o]=="object"?t[o]={...t[o],...n[o]}:t[o]=n[o];return t}function Zn(e,n,t=400){let o=!1,i=()=>{o||(o=!0,e.removeEventListener("animationend",i),clearTimeout(s),n())};e.addEventListener("animationend",i);let s=setTimeout(i,t)}export{ye as ApiError,Xn as ErrorBoundary,B as Fragment,q as Portal,Bn as RouteView,Me as aiStream,Zn as animateOut,$n as api,mn as asyncComponent,Gn as auth,O as callRefCleanup,J as clearAsyncComponentCache,In as computeFixedPos,pe as computeFixedPosRect,Dn as createApp,be as createPortal,fe as createReactiveState,We as enUS,Y as extendCtx,hn as h,Re as hydrateVNode,Jn as i18n,X as isAsyncComponent,we as jsx,gn as jsxDEV,yn as jsxs,ke as lockScroll,Sn as mountVNode,z as patchValue,Fn as router,nn as toChatMessages,de as trapFocus,Ne as unlockScroll,Kn as ws,Ve as zhCN};
|
|
3
|
+
`);o=a.pop()??"";for(let c of a){let l="message",u="";for(let m of c.split(`
|
|
4
|
+
`))m.startsWith("event: ")?l=m.slice(7):m.startsWith("data: ")&&(u+=m.slice(6));if(u)try{yield{name:l,data:JSON.parse(u)}}catch{}}}}finally{n.releaseLock()}}function Vn(e,n,t){t&&(e.length>=1e3&&e.shift(),e.push(n))}function Wn(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Hn(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function nn(e){return e.map(n=>({role:n.role,content:n.content}))}function Le(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function tn(e,n,t){t.initialMessages?e.messages=structuredClone(t.initialMessages):e.messages===void 0&&(e.messages=[]),e.input===void 0&&(e.input=""),e.streaming===void 0&&(e.streaming=!1),e.error===void 0&&(e.error=null),e.usage===void 0&&(e.usage=null),e.step===void 0&&(e.step=null);let o=null;function i(){if(!e.streaming)return;let b=e.messages[e.messages.length-1];return b&&b.role==="assistant"&&b.status==="streaming"?b:void 0}function s(b,g,v){let r=i();switch(b){case"wf:token":r&&(r.content+=g.text);break;case"wf:tool_call":{r&&(r.toolCalls||(r.toolCalls=[]),r.toolCalls.push({call:g,status:"running"}));break}case"wf:tool_progress":{let d=g,f=r?.toolCalls?.find(p=>p.call.id===d.toolCallId);f&&(f.progress=d);break}case"wf:tool_result":{let d=g,f=r?.toolCalls?.find(p=>p.call.id===d.id);f&&(f.result=d,f.status=d.ok?"ok":"error");break}case"wf:approval_request":r&&(r.approval=g);break;case"wf:usage":r&&(r.usage=g);break;case"wf:step":e.step=g;break;case"wf:done":r&&(r.status="done",r.approval=void 0),e.streaming=!1,e.step=null;break;case"wf:error":r&&(r.status="error",r.error=g,r.approval=void 0),e.error=g,e.streaming=!1,e.step=null;break;default:v?.(b,g);break}}function a(){let b=t.body?t.body(e.messages):{messages:nn(e.messages)};o=n(t.url,b,{onToken:v=>s("wf:token",{text:v}),onToolCall:v=>s("wf:tool_call",v),onToolProgress:v=>s("wf:tool_progress",v),onToolResult:v=>s("wf:tool_result",v),onApproval:v=>s("wf:approval_request",v),onUsage:v=>s("wf:usage",v),onStep:v=>s("wf:step",v),onDone:v=>s("wf:done",v),onError:v=>s("wf:error",v),onEvent:(v,r)=>s(v,r,t.onEvent)},{signal:t.signal,headers:t.headers}),e.streaming=!0;let g=i();g&&o?.traceId&&(g.id=o.traceId)}function c(){if(e.streaming)return;let b=String(e.input??"").trim();b&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"user",content:b,status:"done"},{id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function l(){o?.abort(),e.streaming=!1,e.step=null;let b=e.messages[e.messages.length-1];b&&b.role==="assistant"&&b.status==="streaming"&&(!b.content&&(!b.toolCalls||b.toolCalls.length===0)?e.messages.pop():b.status="done")}function u(){if(e.streaming)return;let b=-1;for(let g=e.messages.length-1;g>=0;g--)if(e.messages[g].role==="user"){b=g;break}b!==-1&&(e.messages.splice(b+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function m(){o?.abort(),e.messages=[],e.input="",e.streaming=!1,e.error=null,e.usage=null,e.step=null}async function y(b,g){let v=e.messages[e.messages.length-1],r=v?.role==="assistant"?v.approval:void 0;if(r&&(v.approval=void 0,!!t.approveUrl))try{await fetch(t.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify({id:r.id,decision:b,note:g}),signal:t.signal})}catch(d){if(t.signal?.aborted)return;e.error={code:"provider_error",message:d instanceof Error?d.message:String(d)}}}function T(){o?.abort(),o=null}return{send:c,stop:l,retry:u,clear:m,approve:y,dispose:T}}function pe(e,n="bottom",t=6,o=!0){switch(n){case"bottom":return{top:e.bottom+t,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-t,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-t};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+t}}}function In(e,n="bottom",t=6,o=!0){return pe(e.getBoundingClientRect(),n,t,o)}function me(e,n,t=8){if(!n)return e;let o=n.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let i=Number.parseFloat(n.style.top)||o.top,s=Number.parseFloat(n.style.left)||o.left,a=e.top-i,c=e.left-s,l={top:o.top+a,bottom:o.bottom+a,left:o.left+c,right:o.right+c},u=window.innerWidth,m=window.innerHeight,y=e.top,T=e.left;return l.bottom>m-t&&(y=Math.max(t,y-(l.bottom-(m-t)))),l.top<t&&(y=Math.max(t,y+(t-l.top))),l.right>u-t&&(T=Math.max(t,T-(l.right-(u-t)))),l.left<t&&(T=Math.max(t,T+(t-l.left))),{top:y,left:T,width:e.width}}var on=new Set,oe=new Map;function rn(e){let{ctx:n,renderByIds:t,getSelfId:o,dirtyBatch:i,dirtySet:s,mediaRegistry:a,popupTrackers:c,scrollTrackers:l,schedulePopupRecompute:u,ensurePopupListeners:m,isRendering:y,isMounting:T,setMounting:b,endMounting:g}=e;return{_selfId:"_wf_root",_ctxVersion:0,_dirtySet:s,setMounting:b,endMounting:g,bumpCtxVersion:function(){this._ctxVersion++},render:function(r){if(y()){if(T())return;this._pendingRender||(this._pendingRender=!0,queueMicrotask(()=>{this._pendingRender=!1,this.render(r)}));return}if(!r||r.length===0){let d=o(this);if(d)r=[d];else return}t(r)},dirty:function(r){if(!T()){if(y()){this._pendingDirty||(this._pendingDirty=!0,queueMicrotask(()=>{this._pendingDirty=!1,this.dirty(r)}));return}if(!r||r.length===0){let d=o(this);if(d)r=[d];else return}for(let d of r)d&&(i.add(d),s.add(d));this._dirtyScheduled||(this._dirtyScheduled=!0,queueMicrotask(()=>{this._dirtyScheduled=!1;let d=[...i];i.clear(),d.length>0&&t(d)}))}},$:function(){let r=this;return r._$cache||(r._$cache=fe(()=>{let d=r._selfVNode?._id??o(r);d&&n.ui.dirty([d])})),r._$cache},useChat:function(r){let d=this.$(),f=tn(d,Ne,r);return Object.assign(d,{send:f.send,stop:f.stop,retry:f.retry,clear:f.clear,approve:f.approve,dispose:f.dispose}),d},useMedia:function(r,d){let p=`media:${o(this)}:${r}`;if(!a.has(p)){let h=window.matchMedia(r);d(h.matches);let w=P=>d(P.matches);h.addEventListener("change",w),a.set(p,{mql:h,handler:w})}},useBreakpoint:function(r,d){let f=typeof r=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:r,p=typeof r=="function"?r:d,w=`bp:${o(this)}`;function P(){for(let[x,M]of Object.entries(f))if(window.matchMedia(M).matches)return x;return Object.keys(f)[0]??""}if(!a.has(w)){p(P());let x=[];for(let M of Object.values(f)){let E=window.matchMedia(M),_=()=>p(P());E.addEventListener("change",_),x.push({mql:E,handler:_})}a.set(w,{mqls:x})}},usePopupPosition:function(r){let d=o(this),f={top:0,left:0,refresh:()=>{}};if(!d)return f;let p={pos:f,getEl:r.el,isOpen:r.isOpen,compute:r.compute,panel:r.panel,margin:r.margin??8};return c.set(d,p),m(),f.refresh=()=>{let h=p.getEl();if(!h)return;let w=h.getBoundingClientRect();if(w.width===0&&w.height===0)return;let P=p.compute(w);Object.assign(f,me(P,p.panel?.(),p.margin))},f},useHoverCapable:function(){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches},useStableRef:function(r,d){return p=>{p?r(p):d?.()}},useVisualViewport:function(){let r=o(this),d={height:window.innerHeight,offsetTop:0,keyboardOpen:!1},f=()=>{n.ui&&n.ui.dirty(r?[r]:void 0)},p=()=>{let w=window.visualViewport;d.height=w?.height??window.innerHeight,d.offsetTop=w?.offsetTop??0,d.keyboardOpen=d.height<window.innerHeight*.9,f()},h=window.visualViewport;return h?.addEventListener?(h.addEventListener("resize",p),h.addEventListener("scroll",p)):window.addEventListener("resize",p),r&&K(w=>{w===r&&(h?.removeEventListener?(h.removeEventListener("resize",p),h.removeEventListener("scroll",p)):window.removeEventListener("resize",p))}),d},usePopup:function(r){let d=o(this),f=this.useHoverCapable(),p=()=>typeof r.trigger=="function"?r.trigger():r.trigger,h=r.open!==void 0,w=()=>!!r.disabled?.(),P=()=>h?typeof r.open=="function"?!!r.open():!!r.open:r.isOpen(),x=A=>{w()||(h?r.onOpenChange?.(A):r.setOpen(A))},M=()=>{let A=r.placement;return typeof A=="function"?A():A??"bottom"},E=null,_=!1,C=n.ui.usePopupPosition({el:r.el,isOpen:()=>P(),compute:A=>{if(r.position){let W=r.position();return{top:W.y,left:W.x}}return pe(A,M(),r.gap??6,r.center!==!1)},panel:()=>E,margin:r.margin??8}),R=A=>{if(r.closeOnOutside===!1||!P())return;let W=A.target;if(!(W instanceof Node))return;let $=r.el();$&&$.contains(W)||E&&E.contains(W)||x(!1)},k=A=>{r.closeOnEscape!==!1&&(A.key!=="Escape"||!P()||x(!1))};document.addEventListener("mousedown",R),document.addEventListener("keydown",k),d&&K(A=>{A===d&&(document.removeEventListener("mousedown",R),document.removeEventListener("keydown",k))});let S={},j=A=>typeof A=="function"?A():A??0,N=()=>j(r.openDelay),H=()=>j(r.closeDelay),L,I,re=()=>{clearTimeout(L),clearTimeout(I),L=void 0,I=void 0};if(p()==="hover")f?(S.onMouseEnter=()=>{w()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onMouseLeave=()=>{w()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))}):S.onClick=()=>x(!P()),S.onFocus=()=>{w()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onBlur=()=>{w()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))};else if(p()==="click")S.onClick=()=>x(!P());else if(p()==="longpress"){let A,W=0,$=0,F=()=>{clearTimeout(A),A=void 0};S.onPointerDown=U=>{w()||(W=U.clientX??0,$=U.clientY??0,F(),A=setTimeout(()=>{A=void 0,r.onTrigger?.({clientX:W,clientY:$}),x(!0)},r.longPressDuration??500))},S.onPointerUp=F,S.onPointerLeave=F,S.onPointerMove=U=>{let he=Math.abs((U.clientX??0)-W),ve=Math.abs((U.clientY??0)-$);(he>10||ve>10)&&F()},S.onContextMenu=U=>{U.preventDefault(),r.onTrigger?.({clientX:U.clientX??0,clientY:U.clientY??0}),x(!0)}}S.onKeyDown=A=>{A.key==="Escape"&&r.closeOnEscape!==!1&&x(!1)},d&&K(A=>{A===d&&re()});let dn=A=>{if(A){E=A;let W=()=>C.refresh();A.addEventListener("animationend",W,{once:!0})}else E=null},fn=(A,W="popover")=>{if(w())return null;if(!P())return _=!1,null;_||(C.refresh(),_=!0);let F=A.props??{},U=F.ref,he=["wf-popup",F.class].filter(Boolean).join(" "),ve={...F.style??{},position:"fixed",top:`${C.top}px`,left:`${C.left}px`,maxWidth:r.width!==void 0?`min(${r.width}px, calc(100vw - 32px))`:"calc(100vw - 32px)"},pn={...A,props:{...F,class:he,style:ve,ref:He=>{dn(He),U&&U(He)}}};return be(pn,W)};return{open:P(),setOpen:x,wrapProps:S,portal:fn,refresh:()=>C.refresh()}},useLongPress:function(r){let{onLongPress:d,duration:f=500}=r,p,h=0,w=0,P=null,x=()=>{clearTimeout(p),p=void 0};return{onPointerDown:M=>{h=M.clientX??0,w=M.clientY??0,P=M,x(),p=setTimeout(()=>{p=void 0,d(P)},f)},onPointerUp:x,onPointerLeave:x,onPointerMove:M=>{let E=Math.abs((M.clientX??0)-h),_=Math.abs((M.clientY??0)-w);(E>10||_>10)&&x()},onContextMenu:M=>{M.preventDefault(),d(M)}}},useInView:function(r){let d=o(this),f={isIn:!1,ready:!1,observe:x,refresh:M,disconnect:E},p=null,h=null,w=()=>{n.ui&&n.ui.dirty(d?[d]:void 0)};function P(){if(h?.disconnect(),h=null,!p)return;let _=typeof r.rootMargin=="function"?r.rootMargin():r.rootMargin,C=typeof r.threshold=="function"?r.threshold():r.threshold;h=new IntersectionObserver(R=>{let k=R[R.length-1];if(!k)return;let S=k.isIntersecting,j=S!==f.isIn,N=!f.ready;f.isIn=S,f.ready=!0,r.onChange?.(k,S),(j||N)&&w()},{root:r.root?r.root():null,rootMargin:_??"0px",threshold:C??0}),h.observe(p)}function x(_){p=_,_?P():(h?.disconnect(),h=null,f.isIn=!1)}function M(){P()}function E(){h?.disconnect(),h=null}return f},useScrollPosition:function(r){let d=o(this),f={y:0,refresh(){let h=p.getScroller();f.y=h instanceof Window?document.scrollingElement?.scrollTop??h.scrollY??0:h.scrollTop??0}},p={handle:f,getScroller:r.getScroller??(()=>window)};return d?(l.set(d,p),m(),f.refresh(),f):(f.refresh(),f)},useAsync:function(r){let d=o(this),f=fe(()=>{n.ui&&n.ui.dirty(d?[d]:void 0)});f.loading=!0;let p=0,h=()=>{let w=++p;f.loading=!0,f.error=null,Promise.resolve().then(()=>r()).then(P=>{p===w&&(f.data=P,f.loading=!1)}).catch(P=>{p===w&&(f.error=P,f.loading=!1)})};return h(),f.reload=h,f},useControlled:function(r){let d=o(this),f=r.value!==void 0;f&&!r.onChange&&r.name&&(on.has(r.name)||(on.add(r.name),console.warn(`[weifuwu/${r.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
5
|
+
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!f&&d&&!oe.has(d)&&(oe.set(d,r.value),K(h=>{oe.delete(h)}));let p=h=>{if(f){r.onChange?.(h);return}d&&oe.set(d,h),n.ui&&(d?n.ui.dirty([d]):n.ui.render())};return{value:f?r.value:d?oe.get(d):r.value,setValue:p,controlled:f}},usePresence:function(r){let d=o(this),f="closed",p,h=()=>{f="closed",n.ui&&(d?n.ui.dirty([d]):n.ui.render())};return{get phase(){return f},ref:P=>{P?p||(p=()=>{f==="exit"&&h()},P.addEventListener("animationend",p)):(P?.removeEventListener("animationend",p),p=void 0)},sync:P=>(P?f="open":f==="open"&&(f="exit"),f)}},useDialog:function(r){let d=o(this),f,p=null,h=this.usePresence(r);return{get phase(){return h.phase},rootRef:x=>{x?(ke(),p&&(f=de(p)),h.ref(x)):(Me(),f?.(),h.ref(null))},panelRef:x=>{p=x,x&&!f&&(f=de(x))},sync:x=>h.sync(x)}},useGlobalKey:function(r){let d=o(this);return typeof window>"u"?()=>{}:(window.addEventListener("keydown",r),d&&K(f=>{f===d&&window.removeEventListener("keydown",r)}),()=>window.removeEventListener("keydown",r))},useDrag:function(r){let d=0,f=0,p=!1,h=x=>{p&&r.onMove(x,{x:x.clientX-d,y:x.clientY-f})},w=x=>{p&&(p=!1,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",w),r.onEnd?.(x))};return{onPointerDown:x=>{p||(x.preventDefault(),p=!0,d=x.clientX,f=x.clientY,window.addEventListener("pointermove",h),window.addEventListener("pointerup",w),r.onStart?.(x))}}},useDragDrop:function(r){let d={};r.onDrop&&(d.onDrop=p=>{p.preventDefault(),r.onDrop(p)}),r.onDragOver&&(d.onDragOver=p=>{p.preventDefault(),r.onDragOver(p)}),r.onDragLeave&&(d.onDragLeave=p=>r.onDragLeave(p));let f={draggable:!0};if(r.onDragStart){let p=r.onDragStart;f.onDragStart=h=>{typeof document<"u"&&document.body.classList.add("wf-dragging"),p(h)}}if(r.onDragEnd){let p=r.onDragEnd;f.onDragEnd=h=>{typeof document<"u"&&document.body.classList.remove("wf-dragging"),p(h)}}return{dropProps:d,dragProps:f}},useReducedMotion:function(){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches},useAnimationEnd:function(r,d){let f=null,p=()=>{r(),d?.once&&f&&f.removeEventListener("animationend",p)};return w=>{w?(f=w,w.addEventListener("animationend",p)):f&&(f.removeEventListener("animationend",p),f=null)}},useTween:function(r,d){let f=o(this),p=this.useReducedMotion(),h=d?.duration??400,w=d?.ease==="linear"?C=>C:C=>1-Math.pow(1-C,3),P,x=r,M={value:p?r:0,reset:()=>{}},E=()=>{n.ui&&(f?n.ui.dirty([f]):n.ui.render())},_=C=>{if(x=C,p){M.value=C,E();return}if(C===M.value)return;P&&cancelAnimationFrame(P);let R=M.value,k=performance.now(),S=j=>{let N=Math.min(1,(j-k)/h);M.value=Math.round(R+(C-R)*w(N)),N<1?(P=requestAnimationFrame(S),E()):(P=void 0,E())};P=requestAnimationFrame(S)};return M.reset=C=>{C===x&&P||_(C)},queueMicrotask(()=>_(r)),M},selfId:function(r){if(typeof r!="string"||!r)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof r}`);if(V.has(r))throw new Error(`[weifuwu] Duplicate component ID: "${r}". Each component must have a unique custom ID.`);let d=this._selfVNode;d&&(d._customId=r,V.set(r,d))}}}function sn(){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,createElement:e=>typeof document<"u"?document.createElement(e):null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}function Dn(){let e=[],n={},t=null,o=null,i=null,s=!1,a=!1,c=[];function l(E){c.push(a),a=E}function u(){a=c.pop()??!1}let m=new Set,y=!1,T=new Map;function b(E){let _=T.get(E);_&&(_.mql&&_.handler&&_.mql.removeEventListener("change",_.handler),_.mqls?.forEach(({mql:C,handler:R})=>C.removeEventListener("change",R)),T.delete(E))}let g=new Map,v=!1,r=0;function d(){v||(v=!0,window.addEventListener("scroll",h,{capture:!0,passive:!0}),window.addEventListener("resize",h))}function f(){v&&(window.removeEventListener("scroll",h,{capture:!0}),window.removeEventListener("resize",h),v=!1)}let p=new Map;function h(){r||(r=requestAnimationFrame(()=>{r=0;let E=[];for(let[_,C]of g){if(!C.isOpen())continue;let R=C.getEl();if(!R)continue;let k=R.getBoundingClientRect();if(k.width===0&&k.height===0)continue;let S=C.compute(k);Object.assign(C.pos,me(S,C.panel?.(),C.margin)),E.push(_)}for(let[_,C]of p){let R=C.getScroller(),k=R instanceof Window?document.scrollingElement?.scrollTop??R.scrollY??0:R.scrollTop??0;k!==C.handle.y&&(C.handle.y=k,E.push(_))}E.length>0&&n.ui.render(E)}))}function w(E){if(!s){s=!0;for(let _ of E){let C=V.get(_);if(!C||!C._render)continue;n.ui._dirtySet?.delete(_);let R=C._child,k=C._render(C.props);if(C._child=k,R&&R._placement==="remote"||k&&k._placement==="remote"){R&&k?ne(R,k,n):k?Y(k,n):R&&O(R);continue}if(!C._parentNode&&C._refNode&&(C._parentNode=C._refNode.parentNode),C._parentNode){let S=z(C._parentNode,C._refNode??null,R,k,n);S&&S!==C._refNode?C._refNode=S:S||(C._refNode=null)}}s=!1,P()}}function P(){let E=n.ui;m.size>0&&!E._dirtyScheduled&&(E._dirtyScheduled=!0,queueMicrotask(()=>{E._dirtyScheduled=!1;let _=[...m];m.clear(),_.length>0&&w(_)}))}function x(E){return E?._selfId??n.ui?._selfId}let M={get ctx(){return n},use(E){return e.push(E),M},async mount(E,_,C){o=_;for(let N of e)n=await N(n);let R=typeof E=="string"?document.querySelector(E):E;if(!R)throw new Error(`mount target not found: ${E}`);t=R;let k=!!C?.hydrate;k||(t.innerHTML="");let S=new Map,j=globalThis.__DATA__;if(j&&typeof j=="object")for(let[N,H]of Object.entries(j))S.set(N,{value:H});if(n.data={async get(N,H){let L=S.get(N);if(L&&"value"in L)return L.value;if(L?.promise)return L.promise;if(!H)return;let I=Promise.resolve().then(()=>H()).then(re=>(S.set(N,{value:re}),re));return S.set(N,{promise:I}),I},set(N,H){S.set(N,{value:H})},has(N){return S.has(N)}},K(N=>{for(let H of[...T.keys()])(H.startsWith(`media:${N}:`)||H===`bp:${N}`)&&b(H);g.delete(N),p.delete(N)}),n.browser=sn(),n.ui=rn({ctx:n,renderByIds:w,getSelfId:x,dirtyBatch:m,dirtySet:new Set,mediaRegistry:T,popupTrackers:g,scrollTrackers:p,schedulePopupRecompute:h,ensurePopupListeners:d,destroyPopupListeners:f,isRendering:()=>s,isMounting:()=>a,setMounting:l,endMounting:u}),s=!0,i=Un(_,n),i._id="_wf_root",i._parentNode=t,i._refNode=k?t.firstChild:null,V.set("_wf_root",i),k)await Re(t,i,n);else{let N=Ye(i,n);N instanceof Node&&t.appendChild(N)}i._refNode=t.firstChild,s=!1,P()},destroy(){f(),g.clear(),p.clear();for(let E of[...T.keys()])b(E);V.clear(),t&&(t.innerHTML=""),t=null,n={}}};return M}function Un(e,n){return{type:e,props:{},key:void 0}}function jn(e,n){if(!n||n==="/")return e||"/";let t=e.endsWith("/")?e.slice(0,-1):e,o=n.startsWith("/")?n:"/"+n;return t+o}function qn(e){let n=[],t=e.replace(/:(\w+)/g,(o,i)=>(n.push(i),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}function Oe(e,n="",t=[]){let o=[];for(let i of e){let s=jn(n,i.path),{re:a,keys:c}=qn(s),l=[...t,i];o.push({re:a,keys:c,def:i,chain:l}),i.children&&o.push(...Oe(i.children,s,l))}return o}function an(e,n){let t=null;for(let o of n)e.match(o.re)&&(!t||o.chain.length>t.chain.length)&&(t=o);return t}function ln(e,n){let t={},o=e.match(n.re);if(o)for(let i=0;i<n.keys.length;i++)t[n.keys[i]]=decodeURIComponent(o[i+1]);return t}function Fn(e){let n=Oe(e.routes),t=e.mode||"history";function o(){return t==="hash"?window.location.hash.replace(/^#/,"")||"/":window.location.pathname}function i(s){let a=an(s,n);if(a){let c=a.chain[a.chain.length-1];return{path:a.def.path,params:ln(s,a),query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:a.chain,title:c?.title??""}}return{path:s,params:{},query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:e.notFound?[{component:e.notFound,title:"Not Found"}]:[],title:""}}return s=>{let a=i(o());s.route=a,a.title&&(document.title=a.title),s.app||(s.app={}),s.app.navigate=l=>{if(J(),t==="hash"){window.location.hash="#"+l;let u=i(l);s.route=u}else{window.history.pushState({},"",l);let u=i(l);s.route=u}s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};let c=()=>{J();let l=i(o());s.route=l,s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};return window.addEventListener("popstate",c),t==="hash"&&window.addEventListener("hashchange",c),s}}function Bn(e,n){let t=n.route?._rvDepth??0;return()=>{let o=n.route;if(!o?.chain?.length||t>=o.chain.length)return null;let i=o.chain[t],s=i.layout??i.component;return s?(i.layout&&(o._rvDepth=t+1),{type:s,props:{},key:void 0}):null}}function G(e,n){return Object.assign(Object.create(e),n)}function Kn(e={}){let n=e.url??"/ws",t=e.reconnectInterval??3e3,o=e.maxReconnect??10,i=e.pingInterval??3e4,s=e.pingTimeout??1e4;return a=>{let c=new Set,l=null,u=0,m=null,y=null,T=null,b=!1,g={isConnected:!1,onMessage:p=>(c.add(p),()=>{c.delete(p)}),send:p=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify(p))},_connect:v,close:()=>{b=!0,f(),l?.close(),l=null,g.isConnected=!1}};async function v(){if(!b)try{l=new WebSocket(n),l.onopen=()=>{g.isConnected=!0,u=0,r()},l.onmessage=p=>{try{let h=JSON.parse(p.data);for(let w of c)w(h)}catch{}d()},l.onclose=()=>{g.isConnected=!1,f(),!b&&u<o&&(u++,m=setTimeout(v,t*Math.min(u,5)))},l.onerror=()=>{l?.close()}}catch{b||(m=setTimeout(v,t))}}function r(){i<=0||(y=setInterval(()=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:"ping"})),T=setTimeout(()=>{l?.close()},s)},i))}function d(){clearTimeout(T)}function f(){clearInterval(y),clearTimeout(T),clearTimeout(m)}return v(),G(a,{ws:g})}}function $n(e){let n={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},t=e?.onRequest,o=e?.onResponse,i=e?.timeout??0;async function s(a,c,l,u){let m=n.baseURL+c,y={method:a,headers:{...n.headers,...u?.headers}},T=e?.token?.();T&&!y.headers.Authorization&&(y.headers.Authorization=`Bearer ${T}`);let b=i>0,g=!!u?.signal,v=null,r=null;(b||g)&&(v=new AbortController,y.signal=v.signal,b&&(r=setTimeout(()=>v.abort(new Error("Request timed out")),i)),g&&u.signal.addEventListener("abort",()=>v.abort())),l!==void 0&&a!=="GET"&&a!=="HEAD"&&(y.body=JSON.stringify(l));let d={url:m,init:y};t&&(d=t(d));try{let f=await fetch(d.url,d.init);if(o)return o(f);if(!f.ok){let w=await f.text().catch(()=>"");throw new ye(f.status,w||f.statusText)}let p=f.headers.get("content-length");if(f.status===204||p==="0")return;let h=(f.headers.get("content-type")||"").toLowerCase();return h.includes("application/json")||h.includes("json")?f.json():f.text()}finally{r&&clearTimeout(r)}}return a=>G(a,{api:{get:(l,u)=>s("GET",l,void 0,u),post:(l,u,m)=>s("POST",l,u,m),put:(l,u,m)=>s("PUT",l,u,m),patch:(l,u,m)=>s("PATCH",l,u,m),delete:(l,u)=>s("DELETE",l,void 0,u)}})}var ye=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function zn(e){try{let n=e.split(".");if(n.length!==3)return null;let t=n[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t))}catch{return null}}function Gn(e){let n=zn(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function Yn(e){let n=e?.storage??localStorage,t=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",i=e?.refreshTokenKey??"weifuwu_refresh",s=e?.refreshEndpoint??"/api/auth/refresh";return a=>{let c=n.getItem(t),l=n.getItem(o),u={token:c,user:l?JSON.parse(l):null,get isLoggedIn(){return this.token!==null},login(m,y,T){u.token=m,u.user=y,n.setItem(t,m),n.setItem(o,JSON.stringify(y)),T&&n.setItem(i,T)},logout(){u.token=null,u.user=null,n.removeItem(t),n.removeItem(o),n.removeItem(i)},setUser(m){u.user=m,n.setItem(o,JSON.stringify(m))},async refresh(){let m=n.getItem(i);if(!m)return!1;try{let y=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:m})});if(!y.ok)return u.logout(),!1;let T=await y.json();return u.token=T.token,n.setItem(t,T.token),T.refreshToken&&n.setItem(i,T.refreshToken),!0}catch{return!1}}};return c&&Gn(c)&&u.refresh().catch(()=>{}),G(a,{auth:u})}}function Xn(e,n){let t=null;return o=>{if(t){let s=o.fallback;return typeof s=="function"?s({error:t}):s??null}n.ui._errorHandler=s=>{t=s,n.ui.render()};let i=o.children;try{return i??null}catch(s){t=s;let a=o.fallback;return typeof a=="function"?a({error:s}):a??null}}}var Ve={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 We={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 ge={"zh-CN":Ve,"en-US":We};function un(e){if(ge[e])return e;let n=e.split("-")[0];return Object.keys(ge).find(o=>o.startsWith(n))??"zh-CN"}function Jn(e={}){let{locale:n="zh-CN",messages:t={},components:o={}}=e,i=un(n),s=ge[i],a=cn(s,t,o),c={locale:i,t:(l,u)=>a.messages?.[l]??u??l,setLocale:()=>{},components:a.components};return l=>(l.i18n=c,c.setLocale=u=>{let m=un(u),y=ge[m];y&&(a=cn(y,t,o),c.locale=m,c.components=a.components,l?.ui?.bumpCtxVersion?.(),l?.ui?.render())},l)}function cn(e,n,t){return{messages:{...e?.messages,...n},components:Qn(e?.components??{},t)}}function Qn(e,n){let t={...e};for(let o of Object.keys(n))typeof n[o]=="object"&&n[o]!==null&&typeof t[o]=="object"?t[o]={...t[o],...n[o]}:t[o]=n[o];return t}function Zn(e,n,t=400){let o=!1,i=()=>{o||(o=!0,e.removeEventListener("animationend",i),clearTimeout(s),n())};e.addEventListener("animationend",i);let s=setTimeout(i,t)}export{ye as ApiError,Xn as ErrorBoundary,B as Fragment,q as Portal,Bn as RouteView,Ne as aiStream,Zn as animateOut,$n as api,mn as asyncComponent,Yn as auth,O as callRefCleanup,J as clearAsyncComponentCache,In as computeFixedPos,pe as computeFixedPosRect,Dn as createApp,be as createPortal,fe as createReactiveState,We as enUS,G as extendCtx,hn as h,Re as hydrateVNode,Jn as i18n,X as isAsyncComponent,we as jsx,gn as jsxDEV,yn as jsxs,ke as lockScroll,An as mountVNode,z as patchValue,Fn as router,nn as toChatMessages,de as trapFocus,Me as unlockScroll,Kn as ws,Ve as zhCN};
|