@flowot/nx-pn-web 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ :root{--bg: #f6f7f9;--surface: #ffffff;--surface-soft: #fafbfc;--surface-hover: #f0f2f5;--surface-selected: #e9f0fa;--surface-section: #f8f9fd;--line: #e2e4e9;--line-strong: #d8d8d8;--line-muted: #dbe0e5;--line-input: #a7abb2;--text: #1f2430;--text-secondary: #4a5265;--text-muted: #7a8194;--text-faint: #999999;--text-disabled: #c2c4ca;--text-inverse: #ffffff;--brand: #3b6ef5;--brand-hover: #5a87f7;--brand-pressed: #2855d4;--brand-soft: #e2edff;--color-success: #18b681;--color-success-soft: #e3f7ee;--color-warning: #ffa600;--color-warning-soft: #fff7e8;--color-error: #ff0000;--color-error-soft: #fff5f5;--color-notify: #588ce9;--color-notify-soft: #e9f0fa;--link: #0033cc;--link-hover: #0066ff;--sidebar-bg: #1e2430;--sidebar-text: #dfe3ec;--sidebar-muted: #aeb6c4;--sidebar-faint: #6e7689;--sidebar-hover: rgba(255, 255, 255, .06);--radius-sm: 4px;--radius-md: 6px;--radius-lg: 10px;--shadow-drawer: 0 12px 40px rgba(15, 18, 25, .18);--shadow-modal: 0 20px 60px rgba(15, 18, 25, .24);--h-button: 28px;--h-input: 26px;--h-thead: 30px;--h-row: 35px;--fs-base: 12px;--fs-control: 14px;--fs-title: 16px;--fs-h1: 20px;--fs-h2: 15px;--fs-h3: 13px;--font-sans: system-ui, arial, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;--font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;--mask: rgba(15, 18, 25, .4)}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font-sans);font-size:var(--fs-base);line-height:1.5}#root{min-height:100vh}.layout{display:flex;min-height:100vh}.sidebar{width:200px;flex:0 0 200px;background:var(--sidebar-bg);color:var(--sidebar-text);display:flex;flex-direction:column;padding:16px 0}.brand{font-size:var(--fs-title);font-weight:700;padding:0 16px 18px;letter-spacing:.02em}.sidebar nav{flex:1}.nav-item{display:block;padding:10px 16px;color:var(--sidebar-muted);text-decoration:none;font-size:var(--fs-control);transition:background .12s,color .12s}.nav-item:hover{background:var(--sidebar-hover);color:var(--text-inverse)}.nav-item.active{background:var(--brand);color:var(--text-inverse)}.nav-sep{font-size:11px;letter-spacing:.05em;text-transform:uppercase;color:var(--sidebar-faint);padding:14px 16px 4px}.sidebar-foot{padding:12px 16px}.ws-badge{font-size:var(--fs-base);color:var(--sidebar-muted)}.ws-badge:before{content:"";display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--sidebar-muted);margin-right:6px}.ws-badge.on:before{background:var(--color-success)}.ws-badge.on{color:var(--sidebar-text)}.main{flex:1;padding:24px 32px;min-width:0;max-width:100%}.fullscreen-root{min-height:100vh;width:100%;display:flex;flex-direction:column}.fullscreen-root>*{width:100%}.fullscreen-root .page{padding:20px 28px}.page{max-width:1680px;width:100%}.page h1{font-size:var(--fs-h1);font-weight:600;margin:0 0 16px;color:var(--text)}.empty{padding:60px 0;text-align:center;color:var(--text-muted)}.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:16px 18px;margin-bottom:16px}.card h2{font-size:var(--fs-h2);font-weight:600;margin:0 0 14px;color:var(--text)}.muted{color:var(--text-muted);font-size:var(--fs-base)}.error-line{color:var(--color-error);margin:8px 0;font-size:var(--fs-base)}.ok-line{color:var(--color-success);margin:8px 0;font-size:var(--fs-base)}.error-box{background:var(--color-error-soft);border:1px solid #f2c6c6;color:var(--color-error);padding:24px;border-radius:var(--radius-md)}.error-box pre{white-space:pre-wrap;font-family:var(--font-mono);font-size:var(--fs-base)}.warn-box{background:var(--color-warning-soft);border:1px solid #f0d9a8;color:#8a5a00;padding:8px 12px;border-radius:var(--radius-md);margin:10px 0;font-size:var(--fs-base)}.table{width:100%;border-collapse:collapse;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);overflow:hidden;font-size:var(--fs-control)}.table th,.table td{text-align:left;padding:8px 12px;border-bottom:1px solid var(--line);vertical-align:middle;height:var(--h-row)}.table th{background:var(--surface-soft);font-weight:600;color:var(--text-secondary);font-size:var(--fs-base);text-transform:uppercase;letter-spacing:.03em;height:var(--h-thead)}.table tr:last-child td{border-bottom:none}.table.slim td{padding:4px 8px;border-bottom:1px dashed var(--line);font-size:var(--fs-base)}.mono{font-family:var(--font-mono);word-break:break-all}.key{color:var(--text-muted);width:180px;white-space:pre-wrap}.row-click{cursor:pointer;transition:background .12s}.row-click:hover{background:var(--surface-selected)}.empty-cell{text-align:center;color:var(--text-muted);padding:28px}.method{font-family:var(--font-mono);font-size:11px;font-weight:700;padding:2px 7px;border-radius:var(--radius-sm);background:var(--surface-hover);color:var(--text-secondary);display:inline-block}.method.POST{background:var(--color-warning-soft);color:#8a5a00}.method.PUT,.method.PATCH{background:var(--brand-soft);color:var(--brand-pressed)}.method.DELETE{background:var(--color-error-soft);color:#b0222f}.method.GET,.method.HEAD{background:var(--surface-hover);color:var(--text-secondary)}.status{font-family:var(--font-mono);font-weight:600}.status.ok{color:var(--color-success)}.status.warn{color:var(--color-warning)}.status.err{color:var(--color-error)}.tag{font-size:11px;padding:1px 5px;border-radius:3px;margin-left:6px;background:var(--brand-soft);color:var(--brand-pressed)}.tag.replay{background:var(--brand-soft);color:var(--brand-pressed)}.filters{display:flex;gap:8px;margin-bottom:12px;flex-wrap:wrap;align-items:center}.count{color:var(--text-muted);font-size:var(--fs-base);margin-left:auto}.sort-toggle,.th-sort{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:1px solid var(--line);background:var(--surface);color:var(--text);border-radius:var(--radius-md);padding:0 10px;height:var(--h-input);font-size:var(--fs-base);cursor:pointer;font-family:inherit;transition:border-color .12s,color .12s}.sort-toggle:hover,.th-sort:hover{border-color:var(--brand);color:var(--brand)}.th-sort{border:none;background:none;padding:0;height:auto;font-weight:600}input[type=text],input[type=search],input:not([type]),select,textarea{border:1px solid var(--line);border-radius:var(--radius-md);padding:0 10px;height:var(--h-input);font-size:var(--fs-control);background:var(--surface);color:var(--text);font-family:inherit;transition:border-color .12s,box-shadow .12s;outline:none}textarea{padding:6px 10px;height:auto;min-height:64px;resize:vertical;font-family:var(--font-mono)}input:hover:not(:disabled):not(:focus),select:hover:not(:disabled):not(:focus){border-color:var(--line-input)}input:focus,select:focus,textarea:focus{border-color:var(--brand);box-shadow:0 0 0 2px var(--brand-soft)}input:disabled,select:disabled,textarea:disabled{background:var(--surface-hover);color:var(--text-faint);cursor:not-allowed}input[type=file]{padding:3px 10px;height:auto}.filters input[type=text]{min-width:180px}.drawer-mask{position:fixed;top:0;right:0;bottom:0;left:0;background:var(--mask);display:flex;justify-content:flex-end;z-index:20}.drawer{background:var(--surface);width:min(720px,92vw);height:100%;overflow-y:auto;padding:20px 24px;box-shadow:var(--shadow-drawer)}.drawer-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}.drawer-head h3{margin:0 0 12px;word-break:break-all;font-size:var(--fs-title)}.drawer h4{margin:18px 0 6px;font-size:var(--fs-h3);color:var(--text-secondary);font-weight:600}.info-row{display:flex;gap:10px;margin:6px 0;font-size:var(--fs-base)}.info-label{color:var(--text-muted);width:64px;flex:0 0 64px}.body-view{background:#10131a;color:#d8dee9;padding:10px 12px;border-radius:var(--radius-md);font-family:var(--font-mono);font-size:var(--fs-base);overflow-x:auto;margin:4px 0}.body-view pre{margin:0;white-space:pre-wrap;word-break:break-word}button{border:1px solid var(--line);background:var(--surface);color:var(--text);border-radius:var(--radius-md);padding:0 14px;height:var(--h-button);min-width:60px;font-size:var(--fs-control);cursor:pointer;font-family:inherit;transition:border-color .12s,color .12s,background .12s}button:hover:not(:disabled){border-color:var(--brand);color:var(--brand)}button:active:not(:disabled){background:var(--brand-soft)}button:disabled{opacity:.5;cursor:not-allowed}button.ghost{padding:0 10px;height:var(--h-input);min-width:0;font-size:var(--fs-base)}button.danger:hover{border-color:var(--color-error);color:var(--color-error)}button.danger:active:not(:disabled){background:var(--color-error-soft)}.form-actions{margin-top:18px;display:flex;gap:8px}.replay-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}@media (max-width: 900px){.replay-grid{grid-template-columns:1fr}}.select{margin-bottom:14px}.form-row{display:flex;gap:8px;align-items:center}.form-row input.url{flex:1}.replay-grid textarea{min-width:480px}.replay-grid .select{margin-bottom:14px}.field-label{display:block;margin:14px 0 6px;color:var(--text-secondary);font-size:var(--fs-base);font-weight:500}.form-row+.field-label,textarea+.field-label{margin-top:14px}textarea+.muted{margin-top:12px}.hint{font-size:var(--fs-base);color:var(--text-muted);margin:6px 0 0;line-height:1.5}.actions{white-space:nowrap}.actions button{margin-right:6px}.confirm{background:var(--surface);border-radius:var(--radius-lg);padding:20px;width:min(560px,92vw);margin:auto;align-self:center;max-height:80vh;overflow-y:auto;box-shadow:var(--shadow-modal)}.confirm h3{margin:0 0 12px;font-size:var(--fs-title);font-weight:600}.confirm-detail{background:var(--surface-soft);border:1px solid var(--line);border-radius:var(--radius-md);padding:10px 12px;font-size:var(--fs-base);margin:12px 0}.confirm-detail pre{white-space:pre-wrap;margin:8px 0 0;font-family:var(--font-mono)}.compare{display:grid;grid-template-columns:1fr 1fr;gap:12px}@media (max-width: 720px){.compare{grid-template-columns:1fr}}.compare-col h3{font-size:var(--fs-h3);font-weight:600;margin:0 0 8px;color:var(--text-secondary)}.compare-item{display:flex;justify-content:space-between;font-size:var(--fs-base);margin:4px 0;padding:2px 0}.compare-item span{color:var(--text-muted)}.compare-item b{font-weight:600}.form>label{display:block;margin:16px 0;color:var(--text-secondary);font-size:var(--fs-base)}.form>label:first-child{margin-top:0}.form>label:last-child{margin-bottom:0}.form>label select,.form>label input,.form>label textarea{display:block;width:100%;margin-top:6px}
@@ -0,0 +1,16 @@
1
+ var ft=Object.defineProperty;var dt=(r,e,t)=>e in r?ft(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var l=(r,e,t)=>dt(r,typeof e!="symbol"?e+"":e,t);import{jsxs as g,jsx as c,Fragment as pt}from"react/jsx-runtime";import{useState as O,useCallback as se,useMemo as L,useEffect as U,useRef as gt,useSyncExternalStore as yt,Component as mt,StrictMode as bt}from"react";import{createRoot as wt}from"react-dom/client";import{useLocation as vt,Routes as Ve,Route as D,Navigate as xt,NavLink as te,useNavigate as St,BrowserRouter as Ot}from"react-router-dom";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();function fe(r){return r==null}function M(r,e,t){return Object.defineProperty(r,e,{writable:!0,value:t,enumerable:!1})}function ke(r,e){return arguments.length===1?t=>ke(r,t):r in globalThis&&e instanceof globalThis[r]||Object.prototype.toString.call(e).slice(8,-1)===r}function Ke(r){return ke("ArrayBuffer",r)||ke("SharedArrayBuffer",r)}function kt(r){return Ke(r)||ArrayBuffer.isView(r)}var Q;(r=>{r.is=Ke,r.isSource=kt;function e(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}r.fromSource=e;function t(o){if(o=e(o),typeof Buffer<"u")return Buffer.from(o).toString("base64");let a="";const u=new Uint8Array(o);for(let h=0;h<u.byteLength;h++)a+=String.fromCharCode(u[h]);return btoa(a)}r.toBase64=t;function n(o){return typeof Buffer<"u"?e(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}r.fromBase64=n;function s(o){return o=e(o),typeof Buffer<"u"?Buffer.from(o).toString("hex"):Array.from(new Uint8Array(o),a=>a.toString(16).padStart(2,"0")).join("")}r.toHex=s;function i(o){if(typeof Buffer<"u")return e(Buffer.from(o,"hex"));const a=o.length%2===0?o:o.slice(0,o.length-1),u=[];for(let h=0;h<a.length;h+=2)u.push(parseInt(`${a[h]}${a[h+1]}`,16));return Uint8Array.from(u).buffer}r.fromHex=i})(Q||(Q={}));Q.fromBase64;Q.toBase64;Q.fromHex;Q.toHex;function Et(r,e,t){const n=[];let s=0;for(let i=0;i<r.length;i++){const o=r.charCodeAt(i);if(o>=65&&o<=90){if(s===1){const a=r.charCodeAt(i+1);a>=97&&a<=122&&n.push(t),n.push(o+32)}else s!==0&&n.push(t),n.push(o+32);s=1}else o>=97&&o<=122?(n.push(o),s=2):e.includes(o)?(s!==0&&n.push(t),s=0):n.push(o)}return String.fromCharCode(...n)}function Rt(r){return Et(r,[45,95],45)}var Nt=Rt,Le;(r=>{r.millisecond=1,r.second=1e3,r.minute=r.second*60,r.hour=r.minute*60,r.day=r.hour*24,r.week=r.day*7;let e=new Date().getTimezoneOffset();function t(b){e=b}r.setTimezoneOffset=t;function n(){return e}r.getTimezoneOffset=n;function s(b=new Date,w){return typeof b=="number"&&(b=new Date(b)),w===void 0&&(w=e),Math.floor((b.valueOf()/r.minute-w)/1440)}r.getDateNumber=s;function i(b,w){const v=new Date(b*r.day);return w===void 0&&(w=e),new Date(+v+w*r.minute)}r.fromDateNumber=i;const o=/\d+(?:\.\d+)?/.source,a=new RegExp(`^${["w(?:eek(?:s)?)?","d(?:ay(?:s)?)?","h(?:our(?:s)?)?","m(?:in(?:ute)?(?:s)?)?","s(?:ec(?:ond)?(?:s)?)?"].map(b=>`(${o}${b})?`).join("")}$`);function u(b){const w=a.exec(b);return w?(parseFloat(w[1])*r.week||0)+(parseFloat(w[2])*r.day||0)+(parseFloat(w[3])*r.hour||0)+(parseFloat(w[4])*r.minute||0)+(parseFloat(w[5])*r.second||0):0}r.parseTime=u;function h(b){const w=u(b);return w?b=Date.now()+w:/^\d{1,2}(:\d{1,2}){1,2}$/.test(b)?b=`${new Date().toLocaleDateString()}-${b}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(b)&&(b=`${new Date().getFullYear()}-${b}`),b?new Date(b):new Date}r.parseDate=h;function y(b){const w=Math.abs(b);return w>=r.day-r.hour/2?Math.round(b/r.day)+"d":w>=r.hour-r.minute/2?Math.round(b/r.hour)+"h":w>=r.minute-r.second/2?Math.round(b/r.minute)+"m":w>=r.second?Math.round(b/r.second)+"s":b+"ms"}r.format=y;function f(b,w=2){return b.toString().padStart(w,"0")}r.toDigits=f;function x(b,w=new Date){return b.replace("yyyy",w.getFullYear().toString()).replace("yy",w.getFullYear().toString().slice(2)).replace("MM",f(w.getMonth()+1)).replace("dd",f(w.getDate())).replace("hh",f(w.getHours())).replace("mm",f(w.getMinutes())).replace("ss",f(w.getSeconds())).replace("SSS",f(w.getMilliseconds(),3))}r.template=x})(Le||(Le={}));var It=Object.defineProperty,p=(r,e)=>It(r,"name",{value:e,configurable:!0}),V,_e=(V=class{constructor(){l(this,"sn",0);l(this,"map",new Map);l(this,"weak",new WeakMap)}get length(){return this.map.size}push(e){const t=++this.sn;return this.map.set(t,e),this.weak.set(e,t),()=>this.map.delete(t)}delete(e){const t=this.weak.get(e);return t?this.map.delete(t):!1}clear(){const e=[...this.map.values()];return this.map.clear(),e.reverse()}[Symbol.iterator](){return this.map.values()}[Symbol.for("nodejs.util.inspect.custom")](){return[...this]}},p(V,"DisposableList"),V),d={shadow:Symbol.for("cordis.shadow"),caller:Symbol.for("cordis.caller"),receiver:Symbol.for("cordis.receiver"),original:Symbol.for("cordis.original"),metadata:Symbol.for("cordis.metadata"),initHooks:Symbol.for("cordis.initHooks"),checkProto:Symbol.for("cordis.checkProto"),effect:Symbol.for("cordis.effect"),filter:Symbol.for("cordis.filter"),isolate:Symbol.for("cordis.isolate"),intercept:Symbol.for("cordis.intercept"),init:Symbol.for("cordis.init"),check:Symbol.for("cordis.check"),config:Symbol.for("cordis.config"),invoke:Symbol.for("cordis.invoke"),extend:Symbol.for("cordis.extend"),tracker:Symbol.for("cordis.tracker"),resolveConfig:Symbol.for("cordis.resolveConfig")},Ct=(function*(){}).constructor,Be=(async function*(){}).constructor;function We(r){return!(!r.prototype||r instanceof Ct||Be!==Function&&r instanceof Be)}p(We,"isConstructor");function be(r,e){if(r===Object.prototype)return e;const t=Object.create(be(Object.getPrototypeOf(r),e));for(const n of Reflect.ownKeys(r))Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n));return t}p(be,"joinPrototype");function ie(r){return r&&(typeof r=="object"||typeof r=="function")}p(ie,"isObject");function je(r,e){let t=r;for(;t;){const n=Reflect.getOwnPropertyDescriptor(t,e);if(n)return n;t=Object.getPrototypeOf(t)}}p(je,"getPropertyDescriptor");function B(r,e){if(!ie(e))return e;if(Object.hasOwn(e,d.shadow))return Object.getPrototypeOf(e);const t=e[d.tracker];return t?we(r,e,t):e}p(B,"getTraceable");function oe(r,e){return e?new Proxy(r,{get:p((t,n,s)=>n in e&&n!=="constructor"?Reflect.get(e,n,s):Reflect.get(t,n,s),"get"),set:p((t,n,s,i)=>n in e&&n!=="constructor"?Reflect.set(e,n,s,i):Reflect.set(t,n,s,i),"set")}):r}p(oe,"withProps");function ge(r,e,t){return oe(r,Object.defineProperty(Object.create(null),e,{value:t,writable:!1}))}p(ge,"withProp");function re(r,e,t,n){var i;if(!t)return n;const s=(i=je(e,t))==null?void 0:i.value;return s?ge(n,t,r.extend({[d.shadow]:s})):n}p(re,"createShadow");function Ye(r,e,t,n){return new Proxy(e,{apply:p((s,i,o)=>(i===t&&(i=n),B(r,Reflect.apply(s,i,o))),"apply")})}p(Ye,"createShadowMethod");function we(r,e,t){const n=r[d.shadow]??r;r[d.shadow]&&(r=Object.getPrototypeOf(r));const s=new Proxy(e,{get:p((i,o,a)=>{if(o===d.original)return i;if(o===d.caller)return n;if(o===t.property)return r;if(typeof o=="symbol")return Reflect.get(i,o,a);if(t.associate&&r.reflect.props[`${t.associate}.${o}`])return Reflect.get(r,`${t.associate}.${o}`,ge(r,d.receiver,a));let u,h;const y=je(i,o);y&&"value"in y?h=y.value:(u=re(r,i,t.property,a),h=Reflect.get(i,o,u));const f=h==null?void 0:h[d.tracker];return f?we(r,h,f):!t.noShadow&&typeof h=="function"?(u??(u=re(r,i,t.property,a)),Ye(r,h,a,u)):h},"get"),set:p((i,o,a,u)=>{if(o===d.original||o===d.caller||o===t.property)return!1;if(typeof o=="symbol")return Reflect.set(i,o,a,u);if(t.associate&&r.reflect.props[`${t.associate}.${o}`])return Reflect.set(r,`${t.associate}.${o}`,a,ge(r,d.receiver,u));const h=re(r,i,t.property,u);return Reflect.set(i,o,a,h)},"set"),apply:p((i,o,a)=>{const u=t.noShadow?s:re(r,i,t.property,s);return Xe(u,i,o,a)},"apply")});return s}p(we,"createTraceable");function Xe(r,e,t,n){return e[d.invoke]?e[d.invoke].apply(r,n):Reflect.apply(e,t,n)}p(Xe,"applyTraceable");function ye(r,e,t){const n=p(function(...s){const i=we(n.ctx,n,t);return Reflect.apply(i,this,s)},"self");return M(n,"name",r),Object.setPrototypeOf(n,e)}p(ye,"createCallable");function Ee(r,e,t){const n=r.error.stack.split(`
2
+ `);if(typeof(e==null?void 0:e.stack)!="string"){const o=new Error(e),a=o.stack.split(`
3
+ `);throw a.splice(1,1/0,...t()),o.stack=a.join(`
4
+ `),o}const s=e.stack.split(`
5
+ `);let i=s.indexOf(n[2]);if(i===-1)throw e;for(i-=r.offset;i>0&&s[i-1].endsWith(" (<anonymous>)");)i-=1;throw s.splice(i,1/0,...t()),e.stack=s.join(`
6
+ `),e}p(Ee,"handleError");function Re(r,e=ve()){const t={offset:1,error:new Error};try{const n=r(t);return ie(n)&&"then"in n?n.then(void 0,s=>Ee(t,s,e)):n}catch(n){Ee(t,n,e)}}p(Re,"composeError");function ve(r=0){const e=new Error;return()=>e.stack.split(`
7
+ `).slice(3+r)}p(ve,"buildOuterStack");function Ne(r){return r!==null&&r!==!1&&r!==void 0}p(Ne,"isBailed");var K,Pt=(K=class{constructor(e){l(this,"ctx");l(this,"_hooks",Object.create(null));this.ctx=e,M(this,d.tracker,{property:"ctx",noShadow:!0}),this.on("internal/listener",function(t,n,s){var i;if(t==="internal/update"&&!s.global){const o=(i=this.fiber._hooks)["internal/update"]??(i["internal/update"]=new _e),a=s.prepend?"unshift":"push";return o[a](n)}}),this.on("internal/update",function(t,n,s){const i=[...this._hooks["internal/update"]||[]],o=p(()=>(i.shift()??s).call(this,t,n,o),"_next");return o()},{global:!0,prepend:!0})}_resolve(e,t){var o;const n=typeof t[0]=="object"||typeof t[0]=="function"?t.shift():null,s=t.shift();(typeof s!="string"||!s.startsWith("internal/"))&&((o=this._hooks["internal/dispatch"])!=null&&o.length)&&this.emit("internal/dispatch",e,s,t,n);const i=n==null?void 0:n[G.filter];return[n,(this._hooks[s]||[]).filter(a=>a.global||!i||i.call(n,a.ctx)).map(a=>a.callback)]}dispatch(e,t){const[n,s]=this._resolve(e,t);return s.map(i=>i.bind(n))}async parallel(...e){const[t,n]=this._resolve("emit",e),i=(await Promise.allSettled(n.map(async o=>Reflect.apply(o,t,e)))).filter(o=>o.status==="rejected");if(i.length)throw new AggregateError(i.map(o=>o.reason))}emit(...e){const[t,n]=this._resolve("emit",e);for(const s of n)Reflect.apply(s,t,e)}async serial(...e){const[t,n]=this._resolve("serial",e);for(const s of n){const i=await Reflect.apply(s,t,e);if(Ne(i))return i}}bail(...e){const[t,n]=this._resolve("bail",e);for(const s of n){const i=Reflect.apply(s,t,e);if(Ne(i))return i}}waterfall(...e){const[t,n]=this._resolve("waterfall",e),s=e.pop(),i=p(()=>{const o=n.shift();return o?Reflect.apply(o,t,e):s(...e)},"next");return e.push(i),i()}register(e,t,n,s){const i=s.prepend?"unshift":"push";return this.ctx.fiber.effect(()=>{var a;return((a=this._hooks)[t]??(a[t]=[]))[i]({ctx:this.ctx,callback:n,...s}),()=>this.unregister(t,n)},e)}unregister(e,t){const n=this._hooks[e];if(!n)return;const s=n.findIndex(i=>i.callback===t);if(s>=0)return n.splice(s,1),n.length||delete this._hooks[e],!0}on(e,t,n){typeof n!="object"&&(n={prepend:n}),this.ctx.fiber.assertActive(),t=this.ctx.reflect.bind(t);const s=this.bail(this.ctx,"internal/listener",e,t,n);if(s)return s;const i=`ctx.on(${typeof e=="string"?JSON.stringify(e):e.toString()})`;return this.register(i,e,t,n)}once(e,t,n){const s=this.on(e,function(...i){return s(),t.apply(this,i)},n);return s}},p(K,"EventsService"),K),Fe={s:p(r=>String(r),"s"),d:p(r=>Math.trunc(Number(r)),"d"),i:p(r=>Math.trunc(Number(r)),"i"),f:p(r=>Number(r),"f"),o:p(r=>JSON.stringify(r),"o"),O:p(r=>JSON.stringify(r),"O"),c:p(()=>"","c"),C:p((r,e,t)=>Ie.color(e,Ie.code(t.name,e.colors),r),"C")};function Ze(r){return r instanceof Error&&Array.isArray(r.errors)}p(Ze,"isAggregateError");var W,Ie=(W=class{constructor(e,t){l(this,"service");this.service=t,Object.assign(this,e),this.error=this._method("error",0),this.info=this._method("info",2),this.warn=this._method("warn",1),this.debug=this._method("debug",3)}static color(e,t,n,s=""){return e.colors?`\x1B[3${t<8?t:"8;5;"+t}${e.colors>=2?s:""}m${n}\x1B[0m`:""+n}static code(e,t){let n=0;for(let i=0;i<e.length;i++)n=(n<<3)-n+e.charCodeAt(i)+13,n|=0;const s=t?t>=2?jt:_t:[];return s[Math.abs(n)%s.length]}static format(e,t){var a;const n=t.args.slice();n[0]instanceof Error?(n[0]=n[0].stack||n[0].message,n.unshift("%s")):typeof n[0]!="string"&&n.unshift("%o");let s=n.shift();s=s.replace(/%([a-zA-Z%])/g,(u,h)=>{var f;if(u==="%%")return"%";const y=((f=e.formatters)==null?void 0:f[h])??Fe[h];if(typeof y=="function"){const x=n.shift();return y(x,e,t)}return u});const i=((a=e.formatters)==null?void 0:a.o)??Fe.o;for(let u of n)typeof u=="object"&&u&&(u=i(u,e,t)),s+=" "+u;const{maxLength:o=10240}=e;return s.split(/\r?\n/g).map(u=>u.slice(0,o)+(u.length>o?"...":"")).join(`
8
+ `)}_method(e,t){return(...n)=>{var o,a;if(n.length===1&&n[0]instanceof Error){if(n[0].cause)this[e](n[0].cause);else if(Ze(n[0])){n[0].errors.forEach(u=>this[e](u));return}}const s=++this.service._snMessage,i=Date.now();for(const u of this.service.exporters.values()){if((((o=u.levels)==null?void 0:o[this.name])??((a=u.levels)==null?void 0:a.default)??this.level??2)<t)continue;const y={sn:s,ts:i,type:e,level:t,name:this.name,...this.meta,args:n};u.export(y)}}}},p(W,"Logger"),W),_t=[6,2,3,4,5,1],jt=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221],H,$t=(H=class{constructor(e){l(this,"bufferSize",1e3);l(this,"buffer",[]);l(this,"ctx");l(this,"_snMessage",0);l(this,"_snExporter",0);l(this,"exporters",new Map);const t={property:"ctx",noShadow:!0},n=ye("logger",be(Object.getPrototypeOf(this),Function.prototype),t);return Object.assign(n,this),n.ctx=e,M(n,d.tracker,t),n.exporter({colors:3,export:p(s=>{n.buffer.push(s);const i=n.buffer.length-n.bufferSize;i===1?n.buffer.shift():i>1&&n.buffer.splice(0,i)},"export")}),n}exporter(e){return this.ctx.effect(()=>{const t=++this._snExporter;return this.exporters.set(t,e),()=>this.exporters.delete(t)},"ctx.logger.exporter()")}_resolveConfig(){let e=this.ctx[d.intercept];const t=[];for(;"logger"in e;)Object.hasOwn(e,"logger")&&t.unshift(e.logger),e=Object.getPrototypeOf(e);return Object.assign({},...t)}[d.invoke](e){const t=this._resolveConfig(),s=(this[d.caller]??this.ctx).fiber;return e??(e=t.name),e??(e=Nt(s.name)),new Ie({name:e,level:t.level,meta:{fiber:new WeakRef(s)}},this)}},p(H,"LoggerService"),(()=>{for(const e of["error","info","warn","debug"])H.prototype[e]=function(...t){return this()[e](...t)}})(),H),At=Symbol.for("ValidationError"),Y,Qe=(Y=class extends TypeError{constructor(t){super(`invalid config:
9
+ `+t.map(n=>n.path?` - ${n.message} (at ${n.path.join(".")})`:` - ${n.message}`).join(`
10
+ `));l(this,"name","ValidationError")}},p(Y,"ValidationError"),Y);Object.defineProperty(Qe.prototype,At,{value:!0});function Ce(r,e){if(!r.Config)return e;const t=r.Config["~standard"].validate(e);if("then"in t)throw new TypeError("Async config validation is not supported");if(t.issues)throw new Qe(t.issues);return t.value}p(Ce,"resolveConfig");var z,Pe=(z=class extends Error{constructor(t,n){super(n??z.Code[t]);l(this,"code");this.code=t}},p(z,"CordisError"),z);(r=>{r.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(Pe||(Pe={}));var T="__INACTIVE__",X,et=(X=class{constructor(e,t,n,s,i){l(this,"parent");l(this,"inject");l(this,"runtime");l(this,"uid");l(this,"ctx");l(this,"config");l(this,"state",0);l(this,"dispose");l(this,"store");l(this,"inertia");l(this,"_hooks",Object.create(null));l(this,"_disposables",new _e);l(this,"context");l(this,"_error");l(this,"_runner");l(this,"_store",Object.create(null));this.parent=e,this.inject=n,this.runtime=s;const o=p(a=>{this._disposables.push(a)},"collect");if(s){this.uid=e.registry.counter,this.ctx=this.context=e.extend({fiber:this});const a=Object.entries(this.inject);if(a.length){this.ctx[G.intercept]=Object.create(e[G.intercept]);for(const[u,h]of a)fe(h)||(this.ctx[G.intercept][u]=h)}this._runner={epoch:T,getOuterStack:i,execute:p(function(){var u;if(We(s.callback)){const h=new s.callback(this.ctx,this.config);for(const y of(h==null?void 0:h[d.initHooks])??[])y();return(u=h==null?void 0:h[d.init])==null?void 0:u.call(h)}else return s.callback(this.ctx,this.config)},"execute"),collect:o},this.context.emit("internal/plugin",this);for(const u of Object.keys(this.inject))this._checkImpl(u);this.dispose=e.fiber.effect(()=>{const u=s.fibers.push(this);try{this.config=Ce(s,t),this._refresh()}catch(h){this.ctx.logger.error(h),this._error=h}return async()=>{for(this.uid=null,this.context.emit("internal/plugin",this),this.ctx.registry.has(s.callback)&&(u(),s.fibers.length||this.ctx.registry.delete(s.callback)),this._setEpoch(T);this.inertia;)await this.inertia}},"ctx.plugin()")}else this.uid=0,this.ctx=this.context=e,this.state=2,this.store=Object.create(null),this._runner={epoch:"",getOuterStack:i,execute:p(()=>{},"execute"),collect:o},this.dispose=()=>this.restart()}get name(){var t;let e=this;do{if((t=e.runtime)!=null&&t.name)return e.runtime.name;e=e.parent.fiber}while(e!==e.parent.fiber);return"root"}assertActive(){if(this.uid===null)throw new Pe("INACTIVE_EFFECT")}_execute(e){const t=e.epoch;return Re(n=>{const s=p(o=>{if(typeof o=="function")e.collect(o);else if(!fe(o))throw new TypeError("Invalid effect")},"safeCollect"),i=e.execute.call(this);if(typeof i=="function")return e.collect(i);if(!fe(i))if(ie(i)){if("then"in i)return i.then(s);if(Symbol.iterator in i){n.error=new Error;const o=i[Symbol.iterator]();for(;;){const a=o.next();if(s(a.value),a.done)return}}else if(Symbol.asyncIterator in i){const o=i[Symbol.asyncIterator]();return(async()=>{for(await Promise.resolve(),n.error=new Error;;){if(e.epoch!==t)return;const a=await o.next();if(s(a.value),a.done)return}})()}else throw new TypeError("Invalid effect")}else throw new TypeError("Invalid effect")},e.getOuterStack)}effect(e,t="anonymous"){this.assertActive();const n=[],s=p(()=>{let y;for(const f of n.splice(0).reverse())if(y)y=y.then(f);else{const x=f();ie(x)&&"then"in x&&(y=x)}return y},"dispose"),i={label:t,children:[]},o={execute:e,epoch:!0,collect:p(y=>{n.push(y),this._disposables.delete(y),y[d.effect]&&i.children.push(y[d.effect])},"collect"),getOuterStack:ve()};let a;try{a=this._execute(o)}catch(y){throw s(),y}a==null||a.catch(s).catch(y=>this.ctx.logger.error(y));const u=M(()=>{if(o.epoch)return o.epoch=!1,a?a.then(s):s()},d.effect,i),h=p(()=>{if(o.epoch)return o.epoch=!1,s()},"disposeAsync");return u.then=async(y,f)=>Promise.resolve(a).then(()=>h).then(y,f),n.push(this._disposables.push(u)),u}getEffects(){return[...this._disposables].map(e=>e[d.effect]).filter(Boolean)}_getState(){return this.uid===null?4:this._error?3:this._runner.epoch!==T?2:0}_updateState(e){const t=this.state;if(this.state=e()??this._getState(),t!==this.state&&(this.context.emit("internal/status",this,t),!(t!==2&&this.state!==2)))for(const n of Reflect.ownKeys(this.ctx.reflect.store)){const s=this.ctx.reflect.store[n];s.fiber===this&&this.ctx.reflect.notify([s.name])}}_checkImpl(e){const t=this.ctx.reflect._getImpl(e,!0);if(!t)return delete this._store[e];try{if(t.check&&!t.check.call(B(this.ctx,t.value)))return delete this._store[e]}catch(n){return t.fiber.ctx.logger.error(n),delete this._store[e]}this._store[e]=t}_refresh(){let e=!1;e="";for(const t of Object.keys(this.inject)){const n=this._store[t];if(!n){e=T;break}e+=":"+n.fiber.uid}this._setEpoch(e)}_setEpoch(e){const t=this._runner.epoch;e!==t&&(this._error||(this._runner.epoch=e,!this.inertia&&this._updateState(()=>e!==T&&t===T?(this.inertia=this._reload(),1):(this.inertia=this._unload(),5))))}async _reload(){this.store={...this._store};const e=this._runner.epoch;try{await Promise.resolve(),await this._execute(this._runner)}catch(t){this.ctx.logger.error(t),this._error=t,this._runner.epoch=T}this._updateState(()=>{if(this._runner.epoch===e)this.inertia=void 0;else return this.inertia=this._unload(),5})}async _unload(){await Promise.all(this._disposables.clear().map(async e=>{try{await Re(async t=>{await Promise.resolve(),t.error=new Error,await e()},this._runner.getOuterStack)}catch(t){this.ctx.logger.error(t)}})),this.store=void 0,this._updateState(()=>{if(this._runner.epoch===T)this.inertia=void 0;else return this.inertia=this._reload(),1})}async await(){for(;this.inertia;)await this.inertia;if(this._error)throw this._error;return this}async restart(){const e=this.ctx.fiber;e.assertActive(),e._setEpoch(T),e._refresh(),await e.await()}update(e,t=!1){const n=this.ctx.fiber;n.assertActive(),e=Ce(n.runtime,e),n.context.waterfall(n,"internal/update",e,t,()=>(n.config=e,n._error=void 0,n.restart()))}},p(X,"Fiber"),X);function de(r){const e=r.stack.split(`
11
+ `);return e.splice(0,2,`Error: ${r.message}`),r.stack=e.join(`
12
+ `),r}p(de,"enhanceError");var Tt=["prototype","then"];function pe(r){return typeof r=="symbol"||Tt.includes(r)||parseInt(r).toString()===r||r.startsWith("_")}p(pe,"isSpecialProperty");var F,He=(F=class{constructor(e){l(this,"ctx");l(this,"store",Object.create(null));l(this,"props",Object.create(null));this.ctx=e,M(this,d.tracker,{property:"ctx",noShadow:!0}),this.mixin("reflect",["get","set","provide","accessor","mixin"]),this.mixin("fiber",["runtime","effect"]),this.mixin("registry",["inject","plugin"]),this.mixin("events",["on","once","parallel","emit","serial","bail","waterfall"])}get(e,t=!0){var n;return B(this.ctx,(n=this._getImpl(e,t))==null?void 0:n.value)}_getImpl(e,t=!0){const n=this.ctx[d.isolate][e],s=n&&this.store[n];if(s&&!(t&&s.fiber.state!==2))return s}set(e,t,n){const s=this.ctx[d.isolate][e],i=this.store[s];if(!i)throw new Error(`cannot set property "${e}" without provide`);if(i.fiber!==this.ctx.fiber)throw new Error(`cannot set property "${e}" in multiple fibers`);return i.value=t,!0}provide(e,t,n){return this.ctx.fiber.effect(()=>{var o,a;if(!this.props[e])(o=this.props)[e]??(o[e]={type:"service"});else if(this.props[e].type!=="service")throw new Error(`property "${e}" is already declared as ${this.props[e].type}`);this.props[e]={type:"service"},(a=this.ctx.root[d.isolate])[e]??(a[e]=Symbol(e));const s=this.ctx[d.isolate][e],i={name:e,value:t,fiber:this.ctx.fiber,check:n};if(this.store[s])throw new Error(`service "${e}" has been registered at <${this.store[s].fiber.name}>`);return this.store[s]=i,this.ctx.fiber.store[e]=i,this.ctx.fiber.state===2&&this.notify([e]),async()=>{delete this.store[s];const u=this.notify([e]);await Promise.allSettled(u.map(h=>h.await())),delete this.ctx.fiber.store[e]}},`ctx.provide(${JSON.stringify(e)})`)}notify(e,t=(n,s)=>n[d.isolate][s]===this.ctx[d.isolate][s]){var s;const n=[];for(const i of this.ctx.registry.values())for(const o of i.fibers){let a=!1;for(const u of e)u in o.inject&&t(o.ctx,u)&&(a=!0,o._checkImpl(u));a&&(o._refresh(),n.push(o))}for(const i of e){const o=Object.create(this.ctx);o[d.filter]=a=>t(a,i),this.ctx.events.emit(o,"internal/service",i,(s=this._getImpl(i,!1))==null?void 0:s.value)}return n}accessor(e,t){return this.ctx.fiber.effect(()=>{if(e in this.props)throw new Error(`property "${e}" is already declared as ${this.props[e].type}`);return this.props[e]={type:"accessor",...t},()=>delete this.props[e]},`ctx.accessor(${JSON.stringify(e)})`)}mixin(e,t){const n=this;return this.ctx.fiber.effect(function*(){const s=Array.isArray(t)?t.map(o=>[o,o]):Object.entries(t),i=p((o,a)=>o[e],"getTarget");for(const[o,a]of s)yield n.accessor(a,{get(u,h){const y=i(this,h);if(fe(y))return y;const f=u?oe(u,y):y,x=Reflect.get(y,o,f);return typeof x!="function"?x:x.bind(f??y)},set(u,h,y){const f=i(this,y),x=h?oe(h,f):f;return Reflect.set(f,o,u,x)}})},`ctx.mixin(${JSON.stringify(e)})`)}trace(e){return B(this.ctx,e)}bind(e){return new Proxy(e,{apply:p((t,n,s)=>Reflect.apply(t,this.trace(n),s.map(i=>this.trace(i))),"apply"),construct:p((t,n,s)=>Reflect.construct(t,n.map(i=>this.trace(i)),s),"construct")})}},p(F,"ReflectService"),l(F,"handler",{get:p((e,t,n)=>{if(pe(t))return Reflect.get(e,t,n);if(Reflect.has(e,t))return B(n,Reflect.get(e,t,n));const s=new Error(`cannot get property "${t}" without inject`);try{const i=e.reflect.props[t];return(i==null?void 0:i.type)==="accessor"?i.get.call(n,n[d.receiver],s):n.fiber.runtime?n.events.waterfall("internal/get",n,t,s,()=>{var u;const o=e[d.isolate][t];let a=(n[d.shadow]??n).fiber;for(;;){const h=(u=a.store)==null?void 0:u[t];if(h)return B(n,h.value);if(t in a.inject)throw s.message=`cannot get required service "${t}" in inactive context`,s;if(!a.runtime||a.parent[d.isolate][t]!==o)throw s;a=a.parent.fiber}}):n.reflect.get(t,!1)}catch(i){throw i===s?de(i):i}},"get"),set:p((e,t,n,s)=>{if(pe(t))return Reflect.set(e,t,n,s);const i=new Error(`cannot set property "${t}" without provide`),o=e.reflect.props[t];if(!o){if(!s.fiber.runtime)return Reflect.set(e,t,n,s);throw de(i)}try{return o.type==="accessor"?o.set?o.set.call(s,n,s[d.receiver],i):!1:s.events.waterfall("internal/set",s,t,n,i,()=>s.reflect.set(t,n,i))}catch(a){throw a===i?de(a):a}},"set"),has:p((e,t)=>pe(t)?Reflect.has(e,t):Reflect.has(e,t)?!0:!!e.reflect.props[t],"has")}),F);function tt(r){return r&&typeof r=="object"&&typeof r.apply=="function"}p(tt,"isApplicable");function me(r,e){return function(t,n){var s,i;if(n.kind==="class")Object.hasOwn(t,"inject")||(M(t,"inject",Object.create(Object.getPrototypeOf(t).inject??null)),M(t.inject,d.checkProto,!0)),t.inject[r]=e;else if(n.kind==="method"){const o=(i=t[s=d.metadata]??(t[s]={})).inject??(i.inject=Object.create(null));o[r]=e,n.addInitializer(function(){var u,h;const a=(u=this[d.tracker])==null?void 0:u.property;(this[h=d.initHooks]??(this[h]=[])).push(()=>{this.ctx.inject(o,y=>t.call(a?oe(this,{[a]:y}):this))})})}else throw new Error("@Inject() can only be used on class or class methods")}}p(me,"Inject");(r=>{function e(t,n=Object.create(null)){if(!t)return n;if(Array.isArray(t))for(const s of t)n[s]=null;else if(Reflect.has(t,d.checkProto)){Object.assign(n,e(Object.getPrototypeOf(t)));for(const s of Object.keys(t))n[s]=t[s]??null}else for(const s of Object.keys(t))n[s]=t[s]??null;return n}r.resolve=e,p(e,"resolve")})(me||(me={}));var Z,Dt=(Z=class{constructor(e){l(this,"ctx");l(this,"_counter",0);l(this,"_internal",new Map);this.ctx=e,M(this,d.tracker,{property:"ctx",noShadow:!0})}get counter(){return++this._counter}get size(){return this._internal.size}resolve(e){try{if(typeof e=="function")return e;if(tt(e))return e.apply}catch{}}get(e){const t=this.resolve(e);return t&&this._internal.get(t)}has(e){const t=this.resolve(e);return!!t&&this._internal.has(t)}delete(e){const t=this.resolve(e),n=t&&this._internal.get(t);if(n){this._internal.delete(t);for(const s of n.fibers)s.dispose();return n}}keys(){return this._internal.keys()}values(){return this._internal.values()}entries(){return this._internal.entries()}forEach(e){return this._internal.forEach(e)}inject(e,t){return this.plugin({inject:e,apply:t,name:t.name})}plugin(e,t,n=ve()){const s=this.resolve(e);if(!s)throw new Error('invalid plugin, expect function or object with an "apply" method, received '+typeof e);this.ctx.fiber.assertActive();let i=this._internal.get(s);if(!i){let u=e.name;u==="apply"&&(u=void 0),i={name:u,callback:s,fibers:new _e,Config:e.Config},this._internal.set(s,i)}const o=new et(this.ctx,t,me.resolve(e.inject),i,n),a=Object.create(o);return a.then=(u,h)=>o.await().then(u,h),a}},p(Z,"RegistryService"),Z),P,G=(P=class{static is(e){return!!(e!=null&&e[P.is])}constructor(){this[d.isolate]=Object.create(null),this[d.intercept]=Object.create(null);const e=new Proxy(this,He.handler);return this.root=e,this.baseUrl=void 0,this.fiber=new et(e,{},Object.create(null),null,()=>[]),this.reflect=new He(e),this.registry=new Dt(e),this.events=new Pt(e),this.logger=new $t(e),this.fiber._disposables.clear(),e}[Symbol.for("nodejs.util.inspect.custom")](){return`Context <${this.fiber.name}>`}extend(e={}){var s;const t=(s=Reflect.getOwnPropertyDescriptor(this,d.shadow))==null?void 0:s.value,n=Object.create(B(this,this));for(const i of Reflect.ownKeys(e))Object.defineProperty(n,i,Reflect.getOwnPropertyDescriptor(e,i));return t?Object.assign(Object.create(n),{[d.shadow]:t}):n}isolate(e,t){const n=Object.create(this[d.isolate]);return n[e]=t??Symbol(e),this.extend({[d.isolate]:n})}intercept(e,t){const n=Object.create(this[d.intercept]);return n[e]=t,this.extend({[d.intercept]:n})}},p(P,"Context"),l(P,"effect",d.effect),l(P,"filter",d.filter),l(P,"isolate",d.isolate),l(P,"intercept",d.intercept),P.is[Symbol.toPrimitive]=()=>Symbol.for("cordis.is"),P.prototype[P.is]=!0,P),C,Mt=(C=class{constructor(e,t){l(this,"ctx");l(this,"name");this.ctx=e,t??(t=this.constructor.provide);let n=this;const s={associate:t,property:"ctx"};return n[d.invoke]&&(n=ye(t,be(Object.getPrototypeOf(this),Function.prototype),s)),n.ctx=e,n.name=t,M(n,d.tracker,s),n.ctx.reflect.provide(t,n,this[d.check]),n}[d.filter](e){return e[d.isolate][this.name]===this.ctx[d.isolate][this.name]}[d.extend](e){let t;return this[C.invoke]?t=ye(this.name,this,this[d.tracker]):t=Object.create(this),Object.assign(t,e)}[d.resolveConfig](e,t){var i;let n=this.ctx[G.intercept];const s=[];for(;this.name in n;)Object.hasOwn(n,this.name)&&s.unshift(n[this.name]),n=Object.getPrototypeOf(n);return e&&s.unshift(e),t&&s.push(t),(i=this.Config)!=null&&i.merge?this.Config.merge(...s):Object.assign({},...s)}static[Symbol.hasInstance](e){var n;if(!e)return!1;let t=e.constructor;for(;t;){if(t=(n=t.prototype)==null?void 0:n.constructor,t===this)return!0;t&&(t=Object.getPrototypeOf(t))}return!1}},p(C,"Service"),l(C,"init",d.init),l(C,"check",d.check),l(C,"config",d.config),l(C,"invoke",d.invoke),l(C,"extend",d.extend),l(C,"tracker",d.tracker),l(C,"resolveConfig",d.resolveConfig),C);const Lt=G,$e=Mt;class Bt{constructor(){l(this,"entries",new Map);l(this,"byPlugin",new Map);l(this,"listeners",new Set);l(this,"snapshotCache",[]);l(this,"byKey",new Map)}keyOf(e,t){return`${e}\0${t}`}index(){this.entries.clear();const e=[...this.byPlugin.values()].flatMap(t=>[...t]).map(t=>this.byKey.get(t)).sort((t,n)=>{const s=t.order??100,i=n.order??100;return s!==i?s-i:t.pluginId!==n.pluginId?t.pluginId<n.pluginId?-1:1:t.path<n.path?-1:1});for(const t of e)this.entries.set(this.keyOf(t.pluginId,t.path),t);this.snapshotCache=[...this.entries.values()]}register(e){if(!e.path.startsWith("/"))throw new Error(`pages.register: path must start with "/" (got ${e.path})`);const t=this.keyOf(e.pluginId,e.path),n=this.byKey.has(t);if(this.byKey.set(t,{...e}),!n){const s=this.byPlugin.get(e.pluginId)??new Set;s.add(t),this.byPlugin.set(e.pluginId,s)}this.index(),this.notify()}unregister(e,t){const n=this.keyOf(e,t);if(!this.byKey.delete(n))return;const s=this.byPlugin.get(e);s&&(s.delete(n),s.size===0&&this.byPlugin.delete(e)),this.index(),this.notify()}unregisterAll(e){const t=this.byPlugin.get(e);if(!(!t||t.size===0)){for(const n of t)this.byKey.delete(n);this.byPlugin.delete(e),this.index(),this.notify()}}snapshot(){return this.snapshotCache}has(e){for(const t of this.entries.values())if(t.path===e)return!0;return!1}get size(){return this.entries.size}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of[...this.listeners])try{e()}catch{}}}class Ae extends $e{constructor(t){super(t,"pages");l(this,"registry",new Bt)}}l(Ae,"service","pages");const xe=Ae.prototype;xe.register=function(r){const e=this.ctx.effect;return e(()=>(this.registry.register(r),()=>this.registry.unregister(r.pluginId,r.path)),"pages.register")};xe.unregister=function(r){this.registry.unregisterAll(r)};xe.subscribe=function(r){return this.registry.subscribe(r)};xe.getSnapshot=function(){return this.registry.snapshot()};const Ft=1;class Ht{constructor(e){l(this,"state","connecting");l(this,"online");l(this,"onlineEvent");l(this,"offlineEvent");l(this,"socketEvents");l(this,"opener");l(this,"attempt",0);l(this,"timer");l(this,"disposed",!1);l(this,"addOnline");l(this,"addOffline");l(this,"removeOnline");l(this,"removeOffline");l(this,"scheduleTimer");l(this,"onOpened");l(this,"onDownNotify");l(this,"onStopped");this.online=e.online,this.opener=e.open,this.onlineEvent=()=>this.retry(0),this.offlineEvent=()=>this.goOffline(),this.socketEvents=()=>this.onDown(),this.addOnline=e.addOnlineListener,this.addOffline=e.addOfflineListener,this.removeOnline=e.removeOnlineListener,this.removeOffline=e.removeOfflineListener,this.scheduleTimer=e.schedule,this.onOpened=e.onOpen,this.onDownNotify=e.onDown,this.onStopped=e.onStopped,this.addOnline(this.onlineEvent),this.addOffline(this.offlineEvent)}attemptStart(){if(this.state!=="stopped"){if(!this.online()){this.state="offline";return}this.state="connecting",this.opener()}}onSocketOpen(){this.state!=="stopped"&&(this.attempt=0,this.state="connected",this.onOpened())}onDown(){if(this.state!=="stopped"){if(!this.online()){this.goOffline();return}this.state="connecting",this.onDownNotify(),this.retry(this.backoffMs())}}backoffMs(){return Math.min(1e3*2**this.attempt,1e4)}retry(e){if(this.state!=="stopped"){if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.attempt+=1,e===0){this.attemptStart();return}this.scheduleTimer(e)}}goOffline(){this.state!=="stopped"&&(this.state="offline",this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.onDownNotify())}onlineNow(){this.state!=="stopped"&&this.retry(0)}begin(){this.attemptStart()}down(){this.onDown()}open(){this.onSocketOpen()}stop(){var e;this.disposed||(this.disposed=!0,this.state="stopped",this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.removeOnline(this.onlineEvent),this.removeOffline(this.offlineEvent),(e=this.onStopped)==null||e.call(this))}}class zt{constructor(e){l(this,"controller");l(this,"url");l(this,"minDelayMs");l(this,"maxDelayMs");l(this,"handlers");l(this,"Impl");l(this,"socket",null);l(this,"generation",0);l(this,"stopped",!1);l(this,"onFrameBound",null);this.url=e.url,this.minDelayMs=e.minDelayMs??250,this.maxDelayMs=e.maxDelayMs??1e4,this.handlers=e.handlers??{},this.Impl=e.impl??globalThis.WebSocket??null,this.controller=new Ht({online:()=>e.online??!0,open:()=>this.openSocket(),onOpen:()=>this.handleOpen(),onDown:()=>this.handleDown(),schedule:t=>this.scheduleReconnect(t),addOnlineListener:t=>{typeof window<"u"&&window.addEventListener("online",t)},addOfflineListener:t=>{typeof window<"u"&&window.addEventListener("offline",t)},removeOnlineListener:t=>{typeof window<"u"&&window.removeEventListener("online",t)},removeOfflineListener:t=>{typeof window<"u"&&window.removeEventListener("offline",t)}})}connect(){this.controller.begin()}get currentGeneration(){return this.generation}send(e){const t=this.socket;if(!t||t.readyState!==Ft)return!1;try{return t.send(e),!0}catch{return this.controller.down(),!1}}close(){if(this.stopped)return;this.stopped=!0,this.controller.stop();const e=this.socket;if(this.socket=null,e)try{e.close(1e3,"client close")}catch{}}scheduleReconnect(e){this.stopped||setTimeout(()=>{this.stopped||this.controller.begin()},e)}openSocket(){if(!this.stopped)try{const e=new this.Impl(this.url);this.socket=e,e.addEventListener("open",()=>{this.socket===e&&(this.generation=Date.now(),this.controller.open())}),e.addEventListener("close",()=>{this.socket===e&&(this.socket=null,this.controller.down())}),e.addEventListener("error",()=>{});const t=n=>{var s,i;this.socket===e&&typeof n.data=="string"&&((i=(s=this.handlers).onMessage)==null||i.call(s,n.data))};this.onFrameBound=t,e.addEventListener("message",t)}catch{this.socket=null,this.controller.down()}}handleOpen(){var e,t;(t=(e=this.handlers).onOpen)==null||t.call(e,this.generation)}handleDown(){var e,t;this.socket=null,(t=(e=this.handlers).onClose)==null||t.call(e)}}const Ut=3e4,qt="payload/too-large",he="rpc/disconnected";let $=class extends Error{constructor(t,n){super(n??t);l(this,"code");this.code=t,this.name="RpcError"}};class Jt{constructor(e,t={}){l(this,"pending",new Map);l(this,"nextId",0);l(this,"generation",0);l(this,"defaultTimeoutMs");l(this,"onFrame");l(this,"closed",!1);l(this,"sendText");this.sendText=e,this.defaultTimeoutMs=t.defaultTimeoutMs??Ut,this.onFrame=t.onFrame??(()=>{})}reset(e){this.rejectAll(new $(he,"connection reset")),this.generation=e,this.closed=!1}disconnectAll(e){this.rejectAll(e??new $(he))}rejectAll(e){const t=[...this.pending.values()];this.pending.clear();for(const n of t){clearTimeout(n.timer);try{n.reject(e)}catch{}}}close(){this.closed=!0,this.disconnectAll()}sendNotification(e,t){if(this.closed)return!1;const n={v:1,generation:this.generation,requestId:`n:${this.nextId++}`,op:e,payload:t};let s;try{s=JSON.stringify(n)}catch{return!1}return s.length>ze()?!1:this.sendText(s)}request(e,t,n={}){if(this.closed)return Promise.reject(new $(he));const s=n.timeoutMs??this.defaultTimeoutMs,i=`c:${this.nextId++}`,o=this.generation,a={v:1,generation:o,requestId:i,op:e,payload:t};let u;try{u=JSON.stringify(a)}catch{return Promise.reject(new $("payload/serialize","payload not serializable"))}return u.length>ze()?Promise.reject(new $(qt,"frame exceeds MAX_FRAME_BYTES")):new Promise((h,y)=>{const f=setTimeout(()=>{this.pending.delete(i),y(new $("rpc/timeout","rpc timeout"))},s);this.pending.set(i,{op:e,generation:o,resolve:b=>{clearTimeout(f),h(b)},reject:b=>{clearTimeout(f),y(b)},timer:f}),this.sendText(u)||(this.pending.delete(i),clearTimeout(f),y(new $(he)))})}invokeTool(e,t,n){return this.request("tool.invoke",{event:e,payload:t,pluginRunId:n})}handleFrame(e){var n,s;if(e.op==="rpc.result"){const i=this.pending.get(e.requestId);if(!i)return;if(i.generation!==e.generation){this.pending.delete(e.requestId),clearTimeout(i.timer),i.reject(new $("rpc/protocol-mismatch","generation mismatch"));return}this.pending.delete(e.requestId),clearTimeout(i.timer);const o=e.payload;if(o&&o.ok===!1){i.reject(new $(((n=o.error)==null?void 0:n.code)??"rpc/error",(s=o.error)==null?void 0:s.message));return}i.resolve(o==null?void 0:o.data);return}const t=this.pending.get(e.requestId);if(t){this.pending.delete(e.requestId),clearTimeout(t.timer),t.generation!==e.generation?t.reject(new $("rpc/protocol-mismatch","generation mismatch")):t.reject(new $("rpc/protocol-mismatch",`unexpected op ${e.op} for pending request`));return}this.onFrame(e)}get pendingCount(){return this.pending.size}}function ze(){return 16*1024*1024}function Gt(r){if(!r||typeof r!="object")return!1;const e=r;return typeof e.id=="string"&&typeof e.pluginRunId=="string"&&typeof e.manifest=="object"}function Vt(r){if(!r||typeof r!="object")return;const e=r,t=typeof e.generation=="number"?e.generation:0,n=typeof e.auditLastId=="number"?e.auditLastId:0,s=Array.isArray(e.records)?e.records:[],i=Array.isArray(e.plugins)?e.plugins:[];return{generation:t,auditLastId:n,records:s,plugins:i.filter(Gt)}}class Kt extends Error{constructor(t,n){super(t);l(this,"code");this.code=n,this.name="RpcError"}}function Wt(r){if(!r||typeof r!="object")throw new Kt("malformed audit response");const e=r;return{status:e.status??0,statusText:e.statusText??"",headers:e.headers??{},bytes:e.bytes??0,truncated:e.truncated??!1,bodyText:e.bodyText??"",...e.bodyJson!==void 0?{bodyJson:e.bodyJson}:{}}}let rt;function Yt(r){rt=r}class Te extends $e{constructor(e){super(e,"auditClient")}}l(Te,"service","auditClient");function Xt(r){var n,s;const e=(n=r.ctx)==null?void 0:n.fiber,t=(s=e==null?void 0:e.config)==null?void 0:s.pluginRunId;return typeof t=="string"?t:""}function ce(r,e,t,n,s){const i=rt;return i?i.request("rpc.invoke",{method:e,url:t,...n!==void 0?{body:n}:{},...s?{config:s}:{},pluginRunId:Xt(r)}).then(o=>Wt(o)):Promise.reject(new Error("auditClient used before connectRpc wired the RPC bridge"))}const ae=Te.prototype;ae.get=function(r,e){return ce(this,"GET",r,void 0,e)};ae.post=function(r,e,t){return ce(this,"POST",r,e,t)};ae.put=function(r,e,t){return ce(this,"PUT",r,e,t)};ae.patch=function(r,e,t){return ce(this,"PATCH",r,e,t)};ae.delete=function(r,e){return ce(this,"DELETE",r,void 0,e)};let nt;function Zt(r){nt=r}class De extends $e{constructor(e){super(e,"hostCall")}}l(De,"service","hostCall");function Qt(r){var n,s;const e=(n=r.ctx)==null?void 0:n.fiber,t=(s=e==null?void 0:e.config)==null?void 0:s.pluginRunId;return typeof t=="string"?t:""}const er=De.prototype;er.hostCall=function(r,e){const t=nt;return t?typeof r!="string"||!r?Promise.reject(new Error("hostCall: event must be a non-empty string")):t.invokeTool(r,e,Qt(this)):Promise.reject(new Error("hostCall used before connectRpc wired the RPC bridge"))};async function tr(r,e,t){var i;const{ctx:n}=r;if(typeof((i=n.registry)==null?void 0:i.plugin)!="function")throw new Error(`browser-half ${e.id}: ctx lacks a cordis registry (no ctx.registry.plugin)`);const s=n.registry.plugin({inject:["pages","auditClient","hostCall"],apply:t},{name:e.id,pluginRunId:e.pluginRunId});return await s.await(),{id:e.id,pluginRunId:e.pluginRunId,fiber:s}}async function st(r,e){const t=new Blob([e.code],{type:"text/javascript"}),n=URL.createObjectURL(t);try{const s=await import(n),i=s.default??s.apply;if(typeof i!="function")throw new Error(`browser-half ${e.id} must default-export a function (ctx) => ...`);return await tr(r,{id:e.id,pluginRunId:e.pluginRunId},i)}finally{URL.revokeObjectURL(n)}}async function Ue(r,e){e.fiber&&(await e.fiber.dispose(),e.fiber=void 0)}class ne extends Error{constructor(t,n,s){super(n);l(this,"code");l(this,"status");this.code=t,this.status=s,this.name="ApiError"}}async function rr(r){var n,s;let e;try{e=await r.json()}catch{throw new ne("response/not-json",`host returned ${r.status} ${r.statusText}`)}if(!e||typeof e!="object")throw new ne("response/malformed","host returned a non-object payload");const t=e;if(t.ok===!1||!r.ok)throw new ne(((n=t.error)==null?void 0:n.code)??"http/error",((s=t.error)==null?void 0:s.message)??`HTTP ${r.status}`,r.status);return t.data}async function q(r,e){const t=await fetch(r,e);return rr(t)}function it(r,e){return q(`${r}/api/audit`)}function nr(r,e){return q(`${r}/api/replay`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)})}function Me(r){return q(`${r}/api/plugins`)}function sr(r,e){return q(`${r}/api/plugins/${encodeURIComponent(e)}/stop`,{method:"POST"})}function ir(r,e){return q(`${r}/api/plugins/${encodeURIComponent(e)}/remove`,{method:"POST"})}function or(r,e){return q(`${r}/api/plugins/install`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({spec:e})})}async function cr(r,e,t="plugin.zip"){const n=new FormData;return n.append("zip",e,t),q(`${r}/api/plugins`,{method:"POST",body:n})}async function ar(r,e=""){if(typeof fetch!="function")return;const t=await fetch(`${e}/api/plugins/${encodeURIComponent(r)}/browser-source`);if(t.ok)return await t.text()}async function ot(r,e,t=""){const n=await ar(e.pluginRunId,t);if(typeof n=="string")return st({ctx:r},{id:e.id,pluginRunId:e.pluginRunId,code:n})}async function lr(r,e){var i;const t=e.host??"";let n;try{n=await Me(t)}catch{return}const s=n.find(o=>o.id===e.id);if(s&&(i=s.manifest.halves.browser)!=null&&i.entry)return ot(r.ctx,{id:s.id,pluginRunId:s.pluginRunId},t)}class ur{constructor(e){l(this,"ctx");l(this,"rpc");l(this,"transport");l(this,"snapshotListeners",new Set);l(this,"currentSnapshot");l(this,"auditPushes");l(this,"halves",new Map);l(this,"loading",new Set);this.ctx=e.ctx,this.rpc=e.rpc,this.transport=e.transport,this.auditPushes=e.onAuditPush?[e.onAuditPush]:[]}get rpcClient(){return this.rpc}get status(){return this.transport.controller.state}snapshot(){return this.currentSnapshot}onSnapshot(e){return this.snapshotListeners.add(e),this.currentSnapshot&&e(this.currentSnapshot),()=>{this.snapshotListeners.delete(e)}}onAuditPush(e){return this.auditPushes.push(e),()=>{const t=this.auditPushes.indexOf(e);t>=0&&this.auditPushes.splice(t,1)}}applySnapshot(e){const t=Vt(e);if(t){this.currentSnapshot=t,this.reconcile(t);for(const n of[...this.snapshotListeners])try{n(t)}catch{}}}applyAuditPush(e){for(const t of[...this.auditPushes])try{t(e)}catch{}}async applyBrowserHalfLoad(e){const t=await st({ctx:this.ctx},e);this.halves.set(e.pluginRunId,t)}async applyBrowserHalfRetract(e){var n;const t=this.halves.get(e.pluginRunId);if(t&&(this.halves.delete(e.pluginRunId),await Ue({ctx:this.ctx},t)),e.id){const s=this.ctx.pages;try{(n=s==null?void 0:s.unregister)==null||n.call(s,e.id)}catch{}}}async reconcile(e){var n;const t=new Map;for(const s of e.plugins)(n=s.manifest.halves.browser)!=null&&n.entry&&t.set(s.pluginRunId,{id:s.id,pluginRunId:s.pluginRunId});for(const s of t.values())if(!(this.halves.has(s.pluginRunId)||this.loading.has(s.pluginRunId))){this.loading.add(s.pluginRunId);try{const i=await ot(this.ctx,s);i&&this.halves.set(s.pluginRunId,i)}catch{}finally{this.loading.delete(s.pluginRunId)}}for(const[s,i]of[...this.halves])if(!t.has(s)){this.halves.delete(s);try{await Ue({ctx:this.ctx},i)}catch{}}}close(){this.transport.close()}}async function hr(r={}){const e=r.ctx??new Lt,t=await dr(e),n=r.url??yr(),s=new zt({url:n,...r.minDelayMs!==void 0?{minDelayMs:r.minDelayMs}:{},...r.maxDelayMs!==void 0?{maxDelayMs:r.maxDelayMs}:{},...r.wsImpl!==void 0?{impl:r.wsImpl}:{},handlers:{onOpen:()=>{var u;i.reset(s.currentGeneration),i.sendNotification("snapshot.request",{sinceId:((u=a.snapshot())==null?void 0:u.auditLastId)??0})},onMessage:u=>{try{const h=JSON.parse(u);i.handleFrame(h)}catch{}},onClose:()=>{i.disconnectAll()}}}),i=new Jt(u=>s.send(u),{onFrame:u=>fr(a,u)});pr(e);const o=gr(e);Yt(i),Zt(i),await o;const a=new ur({ctx:e,transport:s,rpc:i});return s.connect(),{ctx:e,pages:t,onSnapshot:u=>a.onSnapshot(u),snapshot:()=>a.snapshot(),status:()=>a.status,close:()=>a.close()}}function fr(r,e){var t;switch(e.op){case"snapshot.respond":r.applySnapshot(e.payload);break;case"audit.append":r.applyAuditPush(e.payload);break;case"plugin.changed":r.rpcClient.sendNotification("snapshot.request",{sinceId:((t=r.snapshot())==null?void 0:t.auditLastId)??0});break;case"browser-half.load":r.applyBrowserHalfLoad(e.payload);break;case"browser-half.retract":r.applyBrowserHalfRetract(e.payload);break}}async function dr(r){let e=r.pages;return e||(await r.registry.plugin(Ae).await(),e=r.pages),e}function pr(r){var t,n;(n=(t=r.reflect)._getImpl)!=null&&n.call(t,"auditClient",!0)||new Te(r)}function gr(r){var t,n;return(n=(t=r.reflect)._getImpl)!=null&&n.call(t,"hostCall",!0)?Promise.resolve():r.registry.plugin(De,{}).await()}function yr(){return typeof location<"u"?`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/ws`:"ws://localhost:4560/ws"}const mr=["GET","POST","PUT","PATCH","DELETE"];function br(r){const[e,t]=O([]),[n,s]=O(null),i=se(async()=>{try{const o=await it("");t(o.records),s(null)}catch(o){s(o.message)}},[]);return U(()=>{i();let o;r&&(o=r.onSnapshot(()=>{i()}));const a=window.setInterval(()=>void i(),5e3);return()=>{window.clearInterval(a),o==null||o()}},[r,i]),{records:e,error:n,refresh:i}}function wr({runtime:r}){const{records:e,error:t}=br(r),[n,s]=O(""),[i,o]=O(""),[a,u]=O(""),[h,y]=O(null),[f,x]=O("desc"),b=se(()=>x(v=>v==="desc"?"asc":"desc"),[]),w=L(()=>{const v=a.trim().toLowerCase();return e.filter(k=>!(n&&k.method!==n||i&&!k.initiator.toLowerCase().includes(i.toLowerCase())||v&&!`${k.url} ${k.initiator} ${k.statusText}`.toLowerCase().includes(v))).sort((k,R)=>f==="desc"?R.ts-k.ts:k.ts-R.ts)},[e,n,i,a,f]);return g("div",{className:"page",children:[c("h1",{children:"审计记录"}),t&&g("div",{className:"error-line",children:["加载失败:",t]}),g("div",{className:"filters",children:[g("select",{value:n,onChange:v=>s(v.target.value),children:[c("option",{value:"",children:"全部方法"}),mr.map(v=>c("option",{value:v,children:v},v))]}),c("input",{placeholder:"发起方过滤",value:i,onChange:v=>o(v.target.value)}),c("input",{placeholder:"搜索 URL / 状态",value:a,onChange:v=>u(v.target.value)}),c("button",{type:"button",className:"sort-toggle",onClick:b,title:f==="desc"?"当前:最新在前,点击切换为时间正序":"当前:时间正序,点击切换为最新在前",children:f==="desc"?"最新在前 ↓":"时间顺序 ↑"}),g("span",{className:"count",children:["共 ",w.length," 条"]})]}),g("table",{className:"table",children:[c("thead",{children:g("tr",{children:[c("th",{children:g("button",{type:"button",className:"th-sort",onClick:b,children:["时间 ",f==="desc"?"↓":"↑"]})}),c("th",{children:"发起方"}),c("th",{children:"方法"}),c("th",{children:"URL"}),c("th",{children:"状态"}),c("th",{children:"耗时"})]})}),g("tbody",{children:[w.length===0&&c("tr",{children:c("td",{colSpan:6,className:"empty-cell",children:"暂无记录"})}),w.map(v=>g("tr",{onClick:()=>y(v),className:"row-click",children:[c("td",{children:ct(v.ts)}),g("td",{children:[v.initiator,v.replayOf!==void 0&&c("span",{className:"tag replay",children:"重放"})]}),c("td",{children:c("span",{className:`method ${v.method}`,children:v.method})}),c("td",{className:"mono",title:v.url,children:v.url}),c("td",{children:c("span",{className:`status ${xr(v.status)}`,children:v.status})}),g("td",{children:[v.durationMs," ms"]})]},v.id))]})]}),h&&c(vr,{record:h,onClose:()=>y(null)})]})}function vr({record:r,onClose:e}){return c("div",{className:"drawer-mask",onClick:e,children:g("div",{className:"drawer",onClick:t=>t.stopPropagation(),children:[g("div",{className:"drawer-head",children:[g("h3",{children:[r.method," ",r.url]}),c("button",{onClick:e,children:"关闭"})]}),g("div",{className:"drawer-body",children:[c(J,{label:"时间",value:ct(r.ts)}),c(J,{label:"发起方",value:r.initiator}),c(J,{label:"状态",value:`${r.status} ${r.statusText}`}),c(J,{label:"耗时",value:`${r.durationMs} ms`}),r.replayOf!==void 0&&c(J,{label:"重放自",value:`#${r.replayOf}`}),r.error&&c(J,{label:"错误",value:`${r.error.name}: ${r.error.message}`}),c("h4",{children:"请求头"}),c(qe,{headers:r.reqHeaders}),c("h4",{children:"请求体"}),c(Je,{body:r.reqBody}),c("h4",{children:"响应头"}),c(qe,{headers:r.resHeaders}),c("h4",{children:"响应体"}),c(Je,{body:r.resBody})]})]})})}function J({label:r,value:e}){return g("div",{className:"info-row",children:[c("span",{className:"info-label",children:r}),c("span",{children:e})]})}function qe({headers:r}){const e=Object.entries(r);return e.length===0?c("div",{className:"muted",children:"(无)"}):c("table",{className:"table slim",children:c("tbody",{children:e.map(([t,n])=>g("tr",{children:[c("td",{className:"mono key",children:t}),c("td",{className:"mono",children:n})]},t))})})}function Je({body:r}){return r.text?g("div",{className:"body-view",children:[c("pre",{children:r.text}),r.truncated&&g("div",{className:"muted",children:["已截断(",r.bytes," bytes)"]})]}):c("div",{className:"muted",children:"(空)"})}function xr(r){return r===0?"err":r<300||r<400?"ok":r<500?"warn":"err"}function ct(r){const e=new Date(r);return`${e.toLocaleDateString("zh-CN")} ${e.toLocaleTimeString("zh-CN",{hour12:!1})}`}const Sr=["POST","PUT","PATCH","DELETE"],Or=["GET","POST","PUT","PATCH","DELETE"];function kr({runtime:r}){const[e,t]=O([]),[n,s]=O(""),[i,o]=O("GET"),[a,u]=O(""),[h,y]=O(""),[f,x]=O(""),[b,w]=O(!1),[v,k]=O(!1),[R,N]=O(null),[_,le]=O(null);U(()=>{let S=!1;const ue=async()=>{try{const ht=await it("");S||t(ht.records)}catch{}};ue();const ut=window.setInterval(()=>void ue(),3e3);return()=>{S=!0,window.clearInterval(ut)}},[]);const I=L(()=>e.find(S=>S.id===n)??null,[e,n]);U(()=>{I&&(o(I.method),u(I.url),y(Rr(I.reqHeaders)),x(I.reqBody.text))},[I]);const m=L(()=>I?Object.keys(I.reqHeaders).some(ue=>/^(authorization|cookie|x-api-key|proxy-authorization|x-auth-token)$/i.test(ue)):!1,[I]),E=L(()=>Nr(h),[h]),j=n!==""&&a.trim().length>0,A=Sr.includes(i);async function ee(){if(n!==""){k(!0),le(null);try{const S=await nr("",{recordId:n,overrides:{method:i,url:a,headers:E,body:f}});N({original:I,replayed:{status:S.status,statusText:S.statusText,durationMs:0,bodyText:S.bodyText,headers:S.headers}}),w(!1)}catch(S){le(S.message)}finally{k(!1)}}}function Se(){if(A){w(!0);return}ee()}return g("div",{className:"page",children:[c("h1",{children:"API 重放"}),g("div",{className:"replay-grid",children:[g("section",{className:"card",children:[c("h2",{children:"1. 选择记录"}),g("div",{className:"select",children:[g("select",{value:n,onChange:S=>s(Number(S.target.value)||""),children:[c("option",{value:"",children:"请选择…"}),[...e].reverse().map(S=>g("option",{value:S.id,children:["#",S.id," ",S.method," ",S.url]},S.id))]}),m&&c("div",{className:"warn-box",children:"此请求包含凭证,重放将使用当前凭证服务的值。"})]}),c("h2",{children:"2. 编辑请求"}),g("div",{className:"form-row",children:[c("select",{value:i,onChange:S=>o(S.target.value),children:Or.map(S=>c("option",{value:S,children:S},S))}),c("input",{className:"url",value:a,onChange:S=>u(S.target.value),placeholder:"URL"})]}),c("label",{className:"field-label",children:"请求头 (每行 `Key: value`)"}),c("textarea",{value:h,onChange:S=>y(S.target.value),rows:4,className:"mono"}),c("label",{className:"field-label",children:"请求体"}),c("textarea",{value:f,onChange:S=>x(S.target.value),rows:6,className:"mono",disabled:Oe(i),placeholder:Oe(i)?"GET/HEAD 请求不携带请求体":""}),Oe(i)&&c("div",{className:"muted",children:"GET/HEAD 请求不携带请求体;上方内容仅作为编辑参考,重放时不会发送。"}),(I==null?void 0:I.reqBody.truncated)&&c("div",{className:"muted",children:"原始请求体已截断,重放将使用截断版本。"}),c("div",{className:"form-actions",children:c("button",{onClick:Se,disabled:!j||v,children:v?"重放中…":"重放"})}),_&&c("div",{className:"error-line",children:_})]}),g("section",{className:"card",children:[c("h2",{children:"3. 对比"}),!R&&c("div",{className:"muted",children:"选择记录并点击“重放”后在此对比。"}),R&&c(Er,{outcome:R})]})]}),b&&I&&c("div",{className:"drawer-mask",onClick:()=>w(!1),children:g("div",{className:"confirm",onClick:S=>S.stopPropagation(),children:[c("h3",{children:"确认重放非幂等请求"}),g("div",{className:"mono confirm-detail",children:[g("div",{children:[i," ",a]}),g("div",{children:["发起方:",I.initiator]}),c("pre",{children:f.slice(0,1e3)})]}),g("div",{className:"form-actions",children:[c("button",{className:"ghost",onClick:()=>w(!1),children:"取消"}),c("button",{onClick:()=>void ee(),disabled:v,children:"确认重放"})]})]})})]})}function Er({outcome:r}){const{original:e,replayed:t}=r;return g("div",{className:"compare",children:[g("div",{className:"compare-col",children:[c("h3",{children:"原始记录"}),g("div",{className:"compare-item",children:[c("span",{children:"状态"}),g("b",{children:[e.status," ",e.statusText]})]}),g("div",{className:"compare-item",children:[c("span",{children:"耗时"}),g("b",{children:[e.durationMs," ms"]})]}),c("pre",{className:"body-view",children:e.resBody.text||"(空)"})]}),g("div",{className:"compare-col",children:[c("h3",{children:"重放结果"}),g("div",{className:"compare-item",children:[c("span",{children:"状态"}),g("b",{children:[t.status," ",t.statusText]})]}),g("div",{className:"compare-item",children:[c("span",{children:"耗时"}),c("b",{children:t.durationMs?`${t.durationMs} ms`:"—"})]}),c("pre",{className:"body-view",children:t.bodyText||"(空)"})]})]})}function Rr(r){return Object.entries(r).map(([e,t])=>`${e}: ${t}`).join(`
13
+ `)}function Nr(r){const e={};for(const t of r.split(`
14
+ `)){const n=t.indexOf(":");if(n<0)continue;const s=t.slice(0,n).trim(),i=t.slice(n+1).trim();s&&(e[s]=i)}return e}function Oe(r){return r==="GET"||r==="HEAD"}const Ir={running:"运行中",stopping:"停止中…",removing:"移除中…",error:"错误"};function Cr(){const[r,e]=O([]),[t,n]=O(""),[s,i]=O(!1),[o,a]=O(null),[u,h]=O(null),[y,f]=O(!1),[x,b]=O(null),[w,v]=O(null),k=se(async()=>{try{const m=await Me("");e(E=>m.map(j=>{const A=E.find(Se=>Se.pluginRunId===j.pluginRunId);if(!A)return{...j,localState:"running"};const ee={...j,localState:A.localState};return A.message!==void 0&&(ee.message=A.message),ee}))}catch(m){v(m.message)}},[]);U(()=>{k();const m=window.setInterval(()=>void k(),3e3);return()=>window.clearInterval(m)},[k]);async function R(){const m=t.trim();if(m){i(!0),a(null),v(null);try{const E=await or("",m);a(`已安装 ${m} → ${E.id}@${E.version}(${E.pluginRunId})`),n(""),await k()}catch(E){const j=E instanceof ne?`${E.code}: ${E.message}`:E.message;v(`安装失败:${j}`)}finally{i(!1)}}}async function N(){if(u){f(!0),b(null),v(null);try{const m=await cr("",u,u.name);b(`上传成功:${m.id}@${m.manifest.version}(${m.pluginRunId})`),h(null),await k()}catch(m){const E=m instanceof ne?`${m.code}: ${m.message}`:m.message;v(`上传失败:${E}`)}finally{f(!1)}}}function _(m,E){e(j=>j.map(A=>A.pluginRunId===m?{...A,...E}:A))}async function le(m){_(m.pluginRunId,{localState:"stopping"});try{await sr("",m.pluginRunId),_(m.pluginRunId,{localState:"error",message:"已停止"})}catch(E){_(m.pluginRunId,{localState:"error",message:E.message})}}async function I(m){_(m.pluginRunId,{localState:"removing"});try{await ir("",m.pluginRunId),e(E=>E.filter(j=>j.pluginRunId!==m.pluginRunId))}catch(E){_(m.pluginRunId,{localState:"error",message:E.message})}}return g("div",{className:"page",children:[c("h1",{children:"插件管理"}),w&&c("div",{className:"error-line",children:w}),g("section",{className:"card",children:[c("h2",{children:"按包名安装"}),g("div",{className:"upload-row",children:[c("input",{type:"text",placeholder:"@scope/my-audit-plugin",value:t,onChange:m=>n(m.target.value),onKeyDown:m=>{m.key==="Enter"&&R()}}),c("button",{onClick:()=>void R(),disabled:!t.trim()||s,children:s?"安装中…":"安装"})]}),o&&c("div",{className:"ok-line",children:o}),g("div",{className:"muted",children:["npm 包名(如需指定版本:",c("span",{className:"mono",children:"pkg@1.2.3"}),"),或本地 ",c("span",{className:"mono",children:"file:./插件文件夹"})]})]}),g("section",{className:"card",children:[c("h2",{children:"或上传 zip"}),g("div",{className:"upload-row",children:[c("input",{type:"file",accept:".zip,application/zip",onChange:m=>{var E;return h(((E=m.target.files)==null?void 0:E[0])??null)}}),c("button",{onClick:()=>void N(),disabled:!u||y,children:y?"上传中…":"上传"})]}),x&&c("div",{className:"ok-line",children:x})]}),g("section",{className:"card",children:[c("h2",{children:"插件列表"}),r.length===0&&c("div",{className:"muted",children:"暂无插件"}),g("table",{className:"table",children:[c("thead",{children:g("tr",{children:[c("th",{children:"ID"}),c("th",{children:"版本"}),c("th",{children:"标题"}),c("th",{children:"状态"}),c("th",{children:"pluginRunId"}),c("th",{children:"操作"})]})}),c("tbody",{children:r.map(m=>g("tr",{children:[c("td",{className:"mono",children:m.id}),c("td",{children:m.manifest.version}),c("td",{children:m.manifest.title}),g("td",{children:[c("span",{className:`status ${m.localState==="running"?"ok":"warn"}`,children:Ir[m.localState]}),m.message&&c("div",{className:"muted",children:m.message})]}),c("td",{className:"mono",children:m.pluginRunId}),g("td",{className:"actions",children:[c("button",{className:"ghost",disabled:m.localState==="stopping"||m.localState==="removing",onClick:()=>void le(m),children:"停止"}),c("button",{className:"ghost danger",disabled:m.localState==="stopping"||m.localState==="removing",onClick:()=>void I(m),children:"移除"})]})]},m.pluginRunId))})]})]})]})}const Pr="";function _r(){const[r,e]=O(null);U(()=>{let f=!1,x;return hr({url:`${window.location.origin}/ws`}).then(b=>{if(f){b.close();return}x=b,e(b)}).catch(()=>{}),()=>{f=!0,x==null||x.close()}},[]);const t=gt(new Set);U(()=>{if(!r)return;const f=r;let x=!1;async function b(k,R){try{if(x||t.current.has(R))return;if(f.pages.getSnapshot().find(_=>_.pluginId===k)){t.current.add(R);return}await lr(f,{id:k}),t.current.add(R)}catch(N){const _=N instanceof Error?`${N.message}
15
+ ${N.stack}`:String(N);console.warn(`[plugin-sync] failed to install browser half for ${k} (${R}): ${_}`)}}async function w(){var R;let k;try{k=await Me(Pr)}catch{return}if(!x)for(const N of k)(R=N.manifest.halves.browser)!=null&&R.entry&&b(N.id,N.pluginRunId)}w();const v=f.onSnapshot(k=>{var R;for(const N of k.plugins)(R=N.manifest.halves.browser)!=null&&R.entry&&b(N.id,N.pluginRunId)});return()=>{x=!0,v()}},[r]);const n=se(f=>{const x=r==null?void 0:r.pages;return x?x.subscribe(f):()=>{}},[r]),s=se(()=>{const f=r==null?void 0:r.pages;return f?f.getSnapshot():Dr},[r]),i=yt(n,s),o=L(()=>i.filter(f=>typeof f.Component=="function"),[i]),a=L(()=>o.filter(f=>f.layout!=="fullscreen"),[o]),u=L(()=>o.filter(f=>f.layout==="fullscreen"),[o]),h=vt(),y=L(()=>u.some(f=>Tr(h.pathname,f.path)),[u,h.pathname]);return c(jr,{fullscreenActive:y,shellPages:a,fullscreenPages:u,runtime:r,children:g(Ve,{children:[c(D,{path:"/",element:c(xt,{to:"/audit",replace:!0})}),c(D,{path:"/audit",element:c(wr,{runtime:r})}),c(D,{path:"/replay",element:c(kr,{runtime:r})}),c(D,{path:"/plugins",element:c(Cr,{})}),a.map(f=>c(D,{path:f.path,element:c(at,{title:f.title,children:c(f.Component,{})})},`${f.pluginId}:${f.path}`)),u.map(f=>c(D,{path:`${f.path}/*`,element:c($r,{page:f})},`${f.pluginId}:${f.path}`)),c(D,{path:"*",element:c(Br,{})})]})})}function jr({fullscreenActive:r,shellPages:e,fullscreenPages:t,runtime:n,children:s}){return r?c(pt,{children:s}):g("div",{className:"layout",children:[g("aside",{className:"sidebar",children:[c("div",{className:"brand",children:"API Audit"}),g("nav",{children:[c(te,{to:"/audit",className:"nav-item",children:"审计记录"}),c(te,{to:"/replay",className:"nav-item",children:"API 重放"}),c(te,{to:"/plugins",className:"nav-item",children:"插件管理"}),t.length>0&&c("div",{className:"nav-sep",children:"插件页面(全屏)"}),t.map(i=>c(te,{to:i.path,className:"nav-item",children:i.title},`${i.pluginId}:${i.path}`)),e.length>0&&c("div",{className:"nav-sep",children:"插件页面"}),e.map(i=>c(te,{to:i.path,className:"nav-item",children:i.title},`${i.pluginId}:${i.path}`))]}),c("div",{className:"sidebar-foot",children:c(Lr,{runtime:n})})]}),c("main",{className:"main",children:s})]})}function $r({page:r}){return c("div",{className:"fullscreen-root",children:c(at,{title:r.title,fullscreen:!0,children:c(Ar,{routes:r.routes??[],fallback:r.Component})})})}function Ar({routes:r,fallback:e}){return g(Ve,{children:[r.map((t,n)=>{const s=t.path==="/"?"":t.path.replace(/^\//,"");return c(D,{path:s,element:c(Ge,{Component:t.Component})},`${t.path}:${n}`)}),e!==void 0&&c(D,{path:"*",element:c(Ge,{Component:e})})]})}function Ge({Component:r}){return typeof r=="function"?c(r,{}):null}function Tr(r,e){return e==="/"||e===""?!0:r===e||r.startsWith(`${e}/`)}const Dr=Object.freeze([]);class at extends mt{constructor(){super(...arguments);l(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}render(){var t;if(this.state.error){const n=g("div",{className:"error-box",children:[g("h2",{children:["插件页面出错:",this.props.title]}),c("pre",{children:String(((t=this.state.error)==null?void 0:t.message)??this.state.error)}),c("button",{onClick:()=>this.setState({error:null}),children:"重试"}),this.props.fullscreen?c(Mr,{}):null]});return this.props.fullscreen?c("div",{className:"fullscreen-root",children:n}):n}return this.props.children}}function Mr(){const r=St();return c("button",{onClick:()=>r("/audit"),children:"返回壳"})}function Lr({runtime:r}){const[e,t]=O("connecting");U(()=>{if(!r)return;const s=()=>t(r.status());s();const i=window.setInterval(s,500);return()=>window.clearInterval(i)},[r]);const n=e==="connected";return c("span",{className:`ws-badge ${n?"on":""}`,children:n?"已连接":"连接中…"})}function Br(){return g("div",{className:"empty",children:[c("h2",{children:"404"}),c("p",{children:"页面不存在。"})]})}const lt=document.getElementById("root");if(!lt)throw new Error("missing #root");wt(lt).render(c(bt,{children:c(Ot,{children:c(_r,{})})}));
16
+ //# sourceMappingURL=index-Dyef-KqU.js.map
package/dist/index.html CHANGED
@@ -16,8 +16,8 @@
16
16
  }
17
17
  }
18
18
  </script>
19
- <script type="module" crossorigin src="/assets/index-DfSekBjO.js"></script>
20
- <link rel="stylesheet" crossorigin href="/assets/index-B66FH-w5.css">
19
+ <script type="module" crossorigin src="/assets/index-Dyef-KqU.js"></script>
20
+ <link rel="stylesheet" crossorigin href="/assets/index-CuAKEX9m.css">
21
21
  </head>
22
22
  <body>
23
23
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowot/nx-pn-web",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Web shell frontend for the nx-pn plugin platform — vite build; dist/ served by the host",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -34,8 +34,8 @@
34
34
  "typescript": "5.6.3",
35
35
  "vite": "^5.4.8",
36
36
  "vitest": "2.1.5",
37
- "@flowot/nx-pn-client": "^0.2.1",
38
- "@flowot/nx-pn-core": "^0.2.1"
37
+ "@flowot/nx-pn-client": "^0.3.0",
38
+ "@flowot/nx-pn-core": "^0.3.0"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "node scripts/build-vendor.mjs && vite build",
@@ -1 +0,0 @@
1
- :root{--bg: #f6f7f9;--surface: #ffffff;--surface-soft: #fafbfc;--surface-hover: #f0f2f5;--surface-selected: #e9f0fa;--surface-section: #f8f9fd;--line: #e2e4e9;--line-strong: #d8d8d8;--line-muted: #dbe0e5;--line-input: #a7abb2;--text: #1f2430;--text-secondary: #4a5265;--text-muted: #7a8194;--text-faint: #999999;--text-disabled: #c2c4ca;--text-inverse: #ffffff;--brand: #3b6ef5;--brand-hover: #5a87f7;--brand-pressed: #2855d4;--brand-soft: #e2edff;--color-success: #18b681;--color-success-soft: #e3f7ee;--color-warning: #ffa600;--color-warning-soft: #fff7e8;--color-error: #ff0000;--color-error-soft: #fff5f5;--color-notify: #588ce9;--color-notify-soft: #e9f0fa;--link: #0033cc;--link-hover: #0066ff;--sidebar-bg: #1e2430;--sidebar-text: #dfe3ec;--sidebar-muted: #aeb6c4;--sidebar-faint: #6e7689;--sidebar-hover: rgba(255, 255, 255, .06);--radius-sm: 4px;--radius-md: 6px;--radius-lg: 10px;--shadow-drawer: 0 12px 40px rgba(15, 18, 25, .18);--shadow-modal: 0 20px 60px rgba(15, 18, 25, .24);--h-button: 28px;--h-input: 26px;--h-thead: 30px;--h-row: 35px;--fs-base: 12px;--fs-control: 14px;--fs-title: 16px;--fs-h1: 20px;--fs-h2: 15px;--fs-h3: 13px;--font-sans: system-ui, arial, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;--font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;--mask: rgba(15, 18, 25, .4)}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font-sans);font-size:var(--fs-base);line-height:1.5}#root{min-height:100vh}.layout{display:flex;min-height:100vh}.sidebar{width:200px;flex:0 0 200px;background:var(--sidebar-bg);color:var(--sidebar-text);display:flex;flex-direction:column;padding:16px 0}.brand{font-size:var(--fs-title);font-weight:700;padding:0 16px 18px;letter-spacing:.02em}.sidebar nav{flex:1}.nav-item{display:block;padding:10px 16px;color:var(--sidebar-muted);text-decoration:none;font-size:var(--fs-control);transition:background .12s,color .12s}.nav-item:hover{background:var(--sidebar-hover);color:var(--text-inverse)}.nav-item.active{background:var(--brand);color:var(--text-inverse)}.nav-sep{font-size:11px;letter-spacing:.05em;text-transform:uppercase;color:var(--sidebar-faint);padding:14px 16px 4px}.sidebar-foot{padding:12px 16px}.ws-badge{font-size:var(--fs-base);color:var(--sidebar-muted)}.ws-badge:before{content:"";display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--sidebar-muted);margin-right:6px}.ws-badge.on:before{background:var(--color-success)}.ws-badge.on{color:var(--sidebar-text)}.main{flex:1;padding:24px 32px;min-width:0;max-width:100%}.page{max-width:1680px;width:100%}.page h1{font-size:var(--fs-h1);font-weight:600;margin:0 0 16px;color:var(--text)}.empty{padding:60px 0;text-align:center;color:var(--text-muted)}.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:16px 18px;margin-bottom:16px}.card h2{font-size:var(--fs-h2);font-weight:600;margin:0 0 14px;color:var(--text)}.muted{color:var(--text-muted);font-size:var(--fs-base)}.error-line{color:var(--color-error);margin:8px 0;font-size:var(--fs-base)}.ok-line{color:var(--color-success);margin:8px 0;font-size:var(--fs-base)}.error-box{background:var(--color-error-soft);border:1px solid #f2c6c6;color:var(--color-error);padding:24px;border-radius:var(--radius-md)}.error-box pre{white-space:pre-wrap;font-family:var(--font-mono);font-size:var(--fs-base)}.warn-box{background:var(--color-warning-soft);border:1px solid #f0d9a8;color:#8a5a00;padding:8px 12px;border-radius:var(--radius-md);margin:10px 0;font-size:var(--fs-base)}.table{width:100%;border-collapse:collapse;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);overflow:hidden;font-size:var(--fs-control)}.table th,.table td{text-align:left;padding:8px 12px;border-bottom:1px solid var(--line);vertical-align:middle;height:var(--h-row)}.table th{background:var(--surface-soft);font-weight:600;color:var(--text-secondary);font-size:var(--fs-base);text-transform:uppercase;letter-spacing:.03em;height:var(--h-thead)}.table tr:last-child td{border-bottom:none}.table.slim td{padding:4px 8px;border-bottom:1px dashed var(--line);font-size:var(--fs-base)}.mono{font-family:var(--font-mono);word-break:break-all}.key{color:var(--text-muted);width:180px;white-space:pre-wrap}.row-click{cursor:pointer;transition:background .12s}.row-click:hover{background:var(--surface-selected)}.empty-cell{text-align:center;color:var(--text-muted);padding:28px}.method{font-family:var(--font-mono);font-size:11px;font-weight:700;padding:2px 7px;border-radius:var(--radius-sm);background:var(--surface-hover);color:var(--text-secondary);display:inline-block}.method.POST{background:var(--color-warning-soft);color:#8a5a00}.method.PUT,.method.PATCH{background:var(--brand-soft);color:var(--brand-pressed)}.method.DELETE{background:var(--color-error-soft);color:#b0222f}.method.GET,.method.HEAD{background:var(--surface-hover);color:var(--text-secondary)}.status{font-family:var(--font-mono);font-weight:600}.status.ok{color:var(--color-success)}.status.warn{color:var(--color-warning)}.status.err{color:var(--color-error)}.tag{font-size:11px;padding:1px 5px;border-radius:3px;margin-left:6px;background:var(--brand-soft);color:var(--brand-pressed)}.tag.replay{background:var(--brand-soft);color:var(--brand-pressed)}.filters{display:flex;gap:8px;margin-bottom:12px;flex-wrap:wrap;align-items:center}.count{color:var(--text-muted);font-size:var(--fs-base);margin-left:auto}.sort-toggle,.th-sort{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:1px solid var(--line);background:var(--surface);color:var(--text);border-radius:var(--radius-md);padding:0 10px;height:var(--h-input);font-size:var(--fs-base);cursor:pointer;font-family:inherit;transition:border-color .12s,color .12s}.sort-toggle:hover,.th-sort:hover{border-color:var(--brand);color:var(--brand)}.th-sort{border:none;background:none;padding:0;height:auto;font-weight:600}input[type=text],input[type=search],input:not([type]),select,textarea{border:1px solid var(--line);border-radius:var(--radius-md);padding:0 10px;height:var(--h-input);font-size:var(--fs-control);background:var(--surface);color:var(--text);font-family:inherit;transition:border-color .12s,box-shadow .12s;outline:none}textarea{padding:6px 10px;height:auto;min-height:64px;resize:vertical;font-family:var(--font-mono)}input:hover:not(:disabled):not(:focus),select:hover:not(:disabled):not(:focus){border-color:var(--line-input)}input:focus,select:focus,textarea:focus{border-color:var(--brand);box-shadow:0 0 0 2px var(--brand-soft)}input:disabled,select:disabled,textarea:disabled{background:var(--surface-hover);color:var(--text-faint);cursor:not-allowed}input[type=file]{padding:3px 10px;height:auto}.filters input[type=text]{min-width:180px}.drawer-mask{position:fixed;top:0;right:0;bottom:0;left:0;background:var(--mask);display:flex;justify-content:flex-end;z-index:20}.drawer{background:var(--surface);width:min(720px,92vw);height:100%;overflow-y:auto;padding:20px 24px;box-shadow:var(--shadow-drawer)}.drawer-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}.drawer-head h3{margin:0 0 12px;word-break:break-all;font-size:var(--fs-title)}.drawer h4{margin:18px 0 6px;font-size:var(--fs-h3);color:var(--text-secondary);font-weight:600}.info-row{display:flex;gap:10px;margin:6px 0;font-size:var(--fs-base)}.info-label{color:var(--text-muted);width:64px;flex:0 0 64px}.body-view{background:#10131a;color:#d8dee9;padding:10px 12px;border-radius:var(--radius-md);font-family:var(--font-mono);font-size:var(--fs-base);overflow-x:auto;margin:4px 0}.body-view pre{margin:0;white-space:pre-wrap;word-break:break-word}button{border:1px solid var(--line);background:var(--surface);color:var(--text);border-radius:var(--radius-md);padding:0 14px;height:var(--h-button);min-width:60px;font-size:var(--fs-control);cursor:pointer;font-family:inherit;transition:border-color .12s,color .12s,background .12s}button:hover:not(:disabled){border-color:var(--brand);color:var(--brand)}button:active:not(:disabled){background:var(--brand-soft)}button:disabled{opacity:.5;cursor:not-allowed}button.ghost{padding:0 10px;height:var(--h-input);min-width:0;font-size:var(--fs-base)}button.danger:hover{border-color:var(--color-error);color:var(--color-error)}button.danger:active:not(:disabled){background:var(--color-error-soft)}.form-actions{margin-top:18px;display:flex;gap:8px}.replay-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}@media (max-width: 900px){.replay-grid{grid-template-columns:1fr}}.select{margin-bottom:14px}.form-row{display:flex;gap:8px;align-items:center}.form-row input.url{flex:1}.replay-grid textarea{min-width:480px}.replay-grid .select{margin-bottom:14px}.field-label{display:block;margin:14px 0 6px;color:var(--text-secondary);font-size:var(--fs-base);font-weight:500}.form-row+.field-label,textarea+.field-label{margin-top:14px}textarea+.muted{margin-top:12px}.hint{font-size:var(--fs-base);color:var(--text-muted);margin:6px 0 0;line-height:1.5}.actions{white-space:nowrap}.actions button{margin-right:6px}.confirm{background:var(--surface);border-radius:var(--radius-lg);padding:20px;width:min(560px,92vw);margin:auto;align-self:center;max-height:80vh;overflow-y:auto;box-shadow:var(--shadow-modal)}.confirm h3{margin:0 0 12px;font-size:var(--fs-title);font-weight:600}.confirm-detail{background:var(--surface-soft);border:1px solid var(--line);border-radius:var(--radius-md);padding:10px 12px;font-size:var(--fs-base);margin:12px 0}.confirm-detail pre{white-space:pre-wrap;margin:8px 0 0;font-family:var(--font-mono)}.compare{display:grid;grid-template-columns:1fr 1fr;gap:12px}@media (max-width: 720px){.compare{grid-template-columns:1fr}}.compare-col h3{font-size:var(--fs-h3);font-weight:600;margin:0 0 8px;color:var(--text-secondary)}.compare-item{display:flex;justify-content:space-between;font-size:var(--fs-base);margin:4px 0;padding:2px 0}.compare-item span{color:var(--text-muted)}.compare-item b{font-weight:600}.form>label{display:block;margin:16px 0;color:var(--text-secondary);font-size:var(--fs-base)}.form>label:first-child{margin-top:0}.form>label:last-child{margin-bottom:0}.form>label select,.form>label input,.form>label textarea{display:block;width:100%;margin-top:6px}
@@ -1,16 +0,0 @@
1
- var at=Object.defineProperty;var lt=(r,e,t)=>e in r?at(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var l=(r,e,t)=>lt(r,typeof e!="symbol"?e+"":e,t);import{jsxs as p,jsx as c}from"react/jsx-runtime";import{useState as O,useCallback as re,useMemo as ee,useEffect as F,Component as qe,useRef as ut,useSyncExternalStore as ht,Suspense as ft,StrictMode as dt}from"react";import{createRoot as pt}from"react-dom/client";import{NavLink as le,Routes as gt,Route as z,Navigate as yt,BrowserRouter as mt}from"react-router-dom";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();function he(r){return r==null}function A(r,e,t){return Object.defineProperty(r,e,{writable:!0,value:t,enumerable:!1})}function ke(r,e){return arguments.length===1?t=>ke(r,t):r in globalThis&&e instanceof globalThis[r]||Object.prototype.toString.call(e).slice(8,-1)===r}function Je(r){return ke("ArrayBuffer",r)||ke("SharedArrayBuffer",r)}function bt(r){return Je(r)||ArrayBuffer.isView(r)}var X;(r=>{r.is=Je,r.isSource=bt;function e(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}r.fromSource=e;function t(o){if(o=e(o),typeof Buffer<"u")return Buffer.from(o).toString("base64");let a="";const u=new Uint8Array(o);for(let h=0;h<u.byteLength;h++)a+=String.fromCharCode(u[h]);return btoa(a)}r.toBase64=t;function n(o){return typeof Buffer<"u"?e(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}r.fromBase64=n;function s(o){return o=e(o),typeof Buffer<"u"?Buffer.from(o).toString("hex"):Array.from(new Uint8Array(o),a=>a.toString(16).padStart(2,"0")).join("")}r.toHex=s;function i(o){if(typeof Buffer<"u")return e(Buffer.from(o,"hex"));const a=o.length%2===0?o:o.slice(0,o.length-1),u=[];for(let h=0;h<a.length;h+=2)u.push(parseInt(`${a[h]}${a[h+1]}`,16));return Uint8Array.from(u).buffer}r.fromHex=i})(X||(X={}));X.fromBase64;X.toBase64;X.fromHex;X.toHex;function wt(r,e,t){const n=[];let s=0;for(let i=0;i<r.length;i++){const o=r.charCodeAt(i);if(o>=65&&o<=90){if(s===1){const a=r.charCodeAt(i+1);a>=97&&a<=122&&n.push(t),n.push(o+32)}else s!==0&&n.push(t),n.push(o+32);s=1}else o>=97&&o<=122?(n.push(o),s=2):e.includes(o)?(s!==0&&n.push(t),s=0):n.push(o)}return String.fromCharCode(...n)}function vt(r){return wt(r,[45,95],45)}var xt=vt,De;(r=>{r.millisecond=1,r.second=1e3,r.minute=r.second*60,r.hour=r.minute*60,r.day=r.hour*24,r.week=r.day*7;let e=new Date().getTimezoneOffset();function t(y){e=y}r.setTimezoneOffset=t;function n(){return e}r.getTimezoneOffset=n;function s(y=new Date,g){return typeof y=="number"&&(y=new Date(y)),g===void 0&&(g=e),Math.floor((y.valueOf()/r.minute-g)/1440)}r.getDateNumber=s;function i(y,g){const v=new Date(y*r.day);return g===void 0&&(g=e),new Date(+v+g*r.minute)}r.fromDateNumber=i;const o=/\d+(?:\.\d+)?/.source,a=new RegExp(`^${["w(?:eek(?:s)?)?","d(?:ay(?:s)?)?","h(?:our(?:s)?)?","m(?:in(?:ute)?(?:s)?)?","s(?:ec(?:ond)?(?:s)?)?"].map(y=>`(${o}${y})?`).join("")}$`);function u(y){const g=a.exec(y);return g?(parseFloat(g[1])*r.week||0)+(parseFloat(g[2])*r.day||0)+(parseFloat(g[3])*r.hour||0)+(parseFloat(g[4])*r.minute||0)+(parseFloat(g[5])*r.second||0):0}r.parseTime=u;function h(y){const g=u(y);return g?y=Date.now()+g:/^\d{1,2}(:\d{1,2}){1,2}$/.test(y)?y=`${new Date().toLocaleDateString()}-${y}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(y)&&(y=`${new Date().getFullYear()}-${y}`),y?new Date(y):new Date}r.parseDate=h;function m(y){const g=Math.abs(y);return g>=r.day-r.hour/2?Math.round(y/r.day)+"d":g>=r.hour-r.minute/2?Math.round(y/r.hour)+"h":g>=r.minute-r.second/2?Math.round(y/r.minute)+"m":g>=r.second?Math.round(y/r.second)+"s":y+"ms"}r.format=m;function w(y,g=2){return y.toString().padStart(g,"0")}r.toDigits=w;function S(y,g=new Date){return y.replace("yyyy",g.getFullYear().toString()).replace("yy",g.getFullYear().toString().slice(2)).replace("MM",w(g.getMonth()+1)).replace("dd",w(g.getDate())).replace("hh",w(g.getHours())).replace("mm",w(g.getMinutes())).replace("ss",w(g.getSeconds())).replace("SSS",w(g.getMilliseconds(),3))}r.template=S})(De||(De={}));var St=Object.defineProperty,d=(r,e)=>St(r,"name",{value:e,configurable:!0}),J,je=(J=class{constructor(){l(this,"sn",0);l(this,"map",new Map);l(this,"weak",new WeakMap)}get length(){return this.map.size}push(e){const t=++this.sn;return this.map.set(t,e),this.weak.set(e,t),()=>this.map.delete(t)}delete(e){const t=this.weak.get(e);return t?this.map.delete(t):!1}clear(){const e=[...this.map.values()];return this.map.clear(),e.reverse()}[Symbol.iterator](){return this.map.values()}[Symbol.for("nodejs.util.inspect.custom")](){return[...this]}},d(J,"DisposableList"),J),f={shadow:Symbol.for("cordis.shadow"),caller:Symbol.for("cordis.caller"),receiver:Symbol.for("cordis.receiver"),original:Symbol.for("cordis.original"),metadata:Symbol.for("cordis.metadata"),initHooks:Symbol.for("cordis.initHooks"),checkProto:Symbol.for("cordis.checkProto"),effect:Symbol.for("cordis.effect"),filter:Symbol.for("cordis.filter"),isolate:Symbol.for("cordis.isolate"),intercept:Symbol.for("cordis.intercept"),init:Symbol.for("cordis.init"),check:Symbol.for("cordis.check"),config:Symbol.for("cordis.config"),invoke:Symbol.for("cordis.invoke"),extend:Symbol.for("cordis.extend"),tracker:Symbol.for("cordis.tracker"),resolveConfig:Symbol.for("cordis.resolveConfig")},Ot=(function*(){}).constructor,Me=(async function*(){}).constructor;function Ge(r){return!(!r.prototype||r instanceof Ot||Me!==Function&&r instanceof Me)}d(Ge,"isConstructor");function me(r,e){if(r===Object.prototype)return e;const t=Object.create(me(Object.getPrototypeOf(r),e));for(const n of Reflect.ownKeys(r))Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n));return t}d(me,"joinPrototype");function ne(r){return r&&(typeof r=="object"||typeof r=="function")}d(ne,"isObject");function Ce(r,e){let t=r;for(;t;){const n=Reflect.getOwnPropertyDescriptor(t,e);if(n)return n;t=Object.getPrototypeOf(t)}}d(Ce,"getPropertyDescriptor");function D(r,e){if(!ne(e))return e;if(Object.hasOwn(e,f.shadow))return Object.getPrototypeOf(e);const t=e[f.tracker];return t?be(r,e,t):e}d(D,"getTraceable");function se(r,e){return e?new Proxy(r,{get:d((t,n,s)=>n in e&&n!=="constructor"?Reflect.get(e,n,s):Reflect.get(t,n,s),"get"),set:d((t,n,s,i)=>n in e&&n!=="constructor"?Reflect.set(e,n,s,i):Reflect.set(t,n,s,i),"set")}):r}d(se,"withProps");function pe(r,e,t){return se(r,Object.defineProperty(Object.create(null),e,{value:t,writable:!1}))}d(pe,"withProp");function Q(r,e,t,n){var i;if(!t)return n;const s=(i=Ce(e,t))==null?void 0:i.value;return s?pe(n,t,r.extend({[f.shadow]:s})):n}d(Q,"createShadow");function Ve(r,e,t,n){return new Proxy(e,{apply:d((s,i,o)=>(i===t&&(i=n),D(r,Reflect.apply(s,i,o))),"apply")})}d(Ve,"createShadowMethod");function be(r,e,t){const n=r[f.shadow]??r;r[f.shadow]&&(r=Object.getPrototypeOf(r));const s=new Proxy(e,{get:d((i,o,a)=>{if(o===f.original)return i;if(o===f.caller)return n;if(o===t.property)return r;if(typeof o=="symbol")return Reflect.get(i,o,a);if(t.associate&&r.reflect.props[`${t.associate}.${o}`])return Reflect.get(r,`${t.associate}.${o}`,pe(r,f.receiver,a));let u,h;const m=Ce(i,o);m&&"value"in m?h=m.value:(u=Q(r,i,t.property,a),h=Reflect.get(i,o,u));const w=h==null?void 0:h[f.tracker];return w?be(r,h,w):!t.noShadow&&typeof h=="function"?(u??(u=Q(r,i,t.property,a)),Ve(r,h,a,u)):h},"get"),set:d((i,o,a,u)=>{if(o===f.original||o===f.caller||o===t.property)return!1;if(typeof o=="symbol")return Reflect.set(i,o,a,u);if(t.associate&&r.reflect.props[`${t.associate}.${o}`])return Reflect.set(r,`${t.associate}.${o}`,a,pe(r,f.receiver,u));const h=Q(r,i,t.property,u);return Reflect.set(i,o,a,h)},"set"),apply:d((i,o,a)=>{const u=t.noShadow?s:Q(r,i,t.property,s);return Ke(u,i,o,a)},"apply")});return s}d(be,"createTraceable");function Ke(r,e,t,n){return e[f.invoke]?e[f.invoke].apply(r,n):Reflect.apply(e,t,n)}d(Ke,"applyTraceable");function ge(r,e,t){const n=d(function(...s){const i=be(n.ctx,n,t);return Reflect.apply(i,this,s)},"self");return A(n,"name",r),Object.setPrototypeOf(n,e)}d(ge,"createCallable");function Ee(r,e,t){const n=r.error.stack.split(`
2
- `);if(typeof(e==null?void 0:e.stack)!="string"){const o=new Error(e),a=o.stack.split(`
3
- `);throw a.splice(1,1/0,...t()),o.stack=a.join(`
4
- `),o}const s=e.stack.split(`
5
- `);let i=s.indexOf(n[2]);if(i===-1)throw e;for(i-=r.offset;i>0&&s[i-1].endsWith(" (<anonymous>)");)i-=1;throw s.splice(i,1/0,...t()),e.stack=s.join(`
6
- `),e}d(Ee,"handleError");function Re(r,e=we()){const t={offset:1,error:new Error};try{const n=r(t);return ne(n)&&"then"in n?n.then(void 0,s=>Ee(t,s,e)):n}catch(n){Ee(t,n,e)}}d(Re,"composeError");function we(r=0){const e=new Error;return()=>e.stack.split(`
7
- `).slice(3+r)}d(we,"buildOuterStack");function Ne(r){return r!==null&&r!==!1&&r!==void 0}d(Ne,"isBailed");var G,kt=(G=class{constructor(e){l(this,"ctx");l(this,"_hooks",Object.create(null));this.ctx=e,A(this,f.tracker,{property:"ctx",noShadow:!0}),this.on("internal/listener",function(t,n,s){var i;if(t==="internal/update"&&!s.global){const o=(i=this.fiber._hooks)["internal/update"]??(i["internal/update"]=new je),a=s.prepend?"unshift":"push";return o[a](n)}}),this.on("internal/update",function(t,n,s){const i=[...this._hooks["internal/update"]||[]],o=d(()=>(i.shift()??s).call(this,t,n,o),"_next");return o()},{global:!0,prepend:!0})}_resolve(e,t){var o;const n=typeof t[0]=="object"||typeof t[0]=="function"?t.shift():null,s=t.shift();(typeof s!="string"||!s.startsWith("internal/"))&&((o=this._hooks["internal/dispatch"])!=null&&o.length)&&this.emit("internal/dispatch",e,s,t,n);const i=n==null?void 0:n[q.filter];return[n,(this._hooks[s]||[]).filter(a=>a.global||!i||i.call(n,a.ctx)).map(a=>a.callback)]}dispatch(e,t){const[n,s]=this._resolve(e,t);return s.map(i=>i.bind(n))}async parallel(...e){const[t,n]=this._resolve("emit",e),i=(await Promise.allSettled(n.map(async o=>Reflect.apply(o,t,e)))).filter(o=>o.status==="rejected");if(i.length)throw new AggregateError(i.map(o=>o.reason))}emit(...e){const[t,n]=this._resolve("emit",e);for(const s of n)Reflect.apply(s,t,e)}async serial(...e){const[t,n]=this._resolve("serial",e);for(const s of n){const i=await Reflect.apply(s,t,e);if(Ne(i))return i}}bail(...e){const[t,n]=this._resolve("bail",e);for(const s of n){const i=Reflect.apply(s,t,e);if(Ne(i))return i}}waterfall(...e){const[t,n]=this._resolve("waterfall",e),s=e.pop(),i=d(()=>{const o=n.shift();return o?Reflect.apply(o,t,e):s(...e)},"next");return e.push(i),i()}register(e,t,n,s){const i=s.prepend?"unshift":"push";return this.ctx.fiber.effect(()=>{var a;return((a=this._hooks)[t]??(a[t]=[]))[i]({ctx:this.ctx,callback:n,...s}),()=>this.unregister(t,n)},e)}unregister(e,t){const n=this._hooks[e];if(!n)return;const s=n.findIndex(i=>i.callback===t);if(s>=0)return n.splice(s,1),n.length||delete this._hooks[e],!0}on(e,t,n){typeof n!="object"&&(n={prepend:n}),this.ctx.fiber.assertActive(),t=this.ctx.reflect.bind(t);const s=this.bail(this.ctx,"internal/listener",e,t,n);if(s)return s;const i=`ctx.on(${typeof e=="string"?JSON.stringify(e):e.toString()})`;return this.register(i,e,t,n)}once(e,t,n){const s=this.on(e,function(...i){return s(),t.apply(this,i)},n);return s}},d(G,"EventsService"),G),Le={s:d(r=>String(r),"s"),d:d(r=>Math.trunc(Number(r)),"d"),i:d(r=>Math.trunc(Number(r)),"i"),f:d(r=>Number(r),"f"),o:d(r=>JSON.stringify(r),"o"),O:d(r=>JSON.stringify(r),"O"),c:d(()=>"","c"),C:d((r,e,t)=>Ie.color(e,Ie.code(t.name,e.colors),r),"C")};function We(r){return r instanceof Error&&Array.isArray(r.errors)}d(We,"isAggregateError");var V,Ie=(V=class{constructor(e,t){l(this,"service");this.service=t,Object.assign(this,e),this.error=this._method("error",0),this.info=this._method("info",2),this.warn=this._method("warn",1),this.debug=this._method("debug",3)}static color(e,t,n,s=""){return e.colors?`\x1B[3${t<8?t:"8;5;"+t}${e.colors>=2?s:""}m${n}\x1B[0m`:""+n}static code(e,t){let n=0;for(let i=0;i<e.length;i++)n=(n<<3)-n+e.charCodeAt(i)+13,n|=0;const s=t?t>=2?Rt:Et:[];return s[Math.abs(n)%s.length]}static format(e,t){var a;const n=t.args.slice();n[0]instanceof Error?(n[0]=n[0].stack||n[0].message,n.unshift("%s")):typeof n[0]!="string"&&n.unshift("%o");let s=n.shift();s=s.replace(/%([a-zA-Z%])/g,(u,h)=>{var w;if(u==="%%")return"%";const m=((w=e.formatters)==null?void 0:w[h])??Le[h];if(typeof m=="function"){const S=n.shift();return m(S,e,t)}return u});const i=((a=e.formatters)==null?void 0:a.o)??Le.o;for(let u of n)typeof u=="object"&&u&&(u=i(u,e,t)),s+=" "+u;const{maxLength:o=10240}=e;return s.split(/\r?\n/g).map(u=>u.slice(0,o)+(u.length>o?"...":"")).join(`
8
- `)}_method(e,t){return(...n)=>{var o,a;if(n.length===1&&n[0]instanceof Error){if(n[0].cause)this[e](n[0].cause);else if(We(n[0])){n[0].errors.forEach(u=>this[e](u));return}}const s=++this.service._snMessage,i=Date.now();for(const u of this.service.exporters.values()){if((((o=u.levels)==null?void 0:o[this.name])??((a=u.levels)==null?void 0:a.default)??this.level??2)<t)continue;const m={sn:s,ts:i,type:e,level:t,name:this.name,...this.meta,args:n};u.export(m)}}}},d(V,"Logger"),V),Et=[6,2,3,4,5,1],Rt=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221],L,Nt=(L=class{constructor(e){l(this,"bufferSize",1e3);l(this,"buffer",[]);l(this,"ctx");l(this,"_snMessage",0);l(this,"_snExporter",0);l(this,"exporters",new Map);const t={property:"ctx",noShadow:!0},n=ge("logger",me(Object.getPrototypeOf(this),Function.prototype),t);return Object.assign(n,this),n.ctx=e,A(n,f.tracker,t),n.exporter({colors:3,export:d(s=>{n.buffer.push(s);const i=n.buffer.length-n.bufferSize;i===1?n.buffer.shift():i>1&&n.buffer.splice(0,i)},"export")}),n}exporter(e){return this.ctx.effect(()=>{const t=++this._snExporter;return this.exporters.set(t,e),()=>this.exporters.delete(t)},"ctx.logger.exporter()")}_resolveConfig(){let e=this.ctx[f.intercept];const t=[];for(;"logger"in e;)Object.hasOwn(e,"logger")&&t.unshift(e.logger),e=Object.getPrototypeOf(e);return Object.assign({},...t)}[f.invoke](e){const t=this._resolveConfig(),s=(this[f.caller]??this.ctx).fiber;return e??(e=t.name),e??(e=xt(s.name)),new Ie({name:e,level:t.level,meta:{fiber:new WeakRef(s)}},this)}},d(L,"LoggerService"),(()=>{for(const e of["error","info","warn","debug"])L.prototype[e]=function(...t){return this()[e](...t)}})(),L),It=Symbol.for("ValidationError"),K,Ye=(K=class extends TypeError{constructor(t){super(`invalid config:
9
- `+t.map(n=>n.path?` - ${n.message} (at ${n.path.join(".")})`:` - ${n.message}`).join(`
10
- `));l(this,"name","ValidationError")}},d(K,"ValidationError"),K);Object.defineProperty(Ye.prototype,It,{value:!0});function _e(r,e){if(!r.Config)return e;const t=r.Config["~standard"].validate(e);if("then"in t)throw new TypeError("Async config validation is not supported");if(t.issues)throw new Ye(t.issues);return t.value}d(_e,"resolveConfig");var B,Pe=(B=class extends Error{constructor(t,n){super(n??B.Code[t]);l(this,"code");this.code=t}},d(B,"CordisError"),B);(r=>{r.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(Pe||(Pe={}));var $="__INACTIVE__",W,Xe=(W=class{constructor(e,t,n,s,i){l(this,"parent");l(this,"inject");l(this,"runtime");l(this,"uid");l(this,"ctx");l(this,"config");l(this,"state",0);l(this,"dispose");l(this,"store");l(this,"inertia");l(this,"_hooks",Object.create(null));l(this,"_disposables",new je);l(this,"context");l(this,"_error");l(this,"_runner");l(this,"_store",Object.create(null));this.parent=e,this.inject=n,this.runtime=s;const o=d(a=>{this._disposables.push(a)},"collect");if(s){this.uid=e.registry.counter,this.ctx=this.context=e.extend({fiber:this});const a=Object.entries(this.inject);if(a.length){this.ctx[q.intercept]=Object.create(e[q.intercept]);for(const[u,h]of a)he(h)||(this.ctx[q.intercept][u]=h)}this._runner={epoch:$,getOuterStack:i,execute:d(function(){var u;if(Ge(s.callback)){const h=new s.callback(this.ctx,this.config);for(const m of(h==null?void 0:h[f.initHooks])??[])m();return(u=h==null?void 0:h[f.init])==null?void 0:u.call(h)}else return s.callback(this.ctx,this.config)},"execute"),collect:o},this.context.emit("internal/plugin",this);for(const u of Object.keys(this.inject))this._checkImpl(u);this.dispose=e.fiber.effect(()=>{const u=s.fibers.push(this);try{this.config=_e(s,t),this._refresh()}catch(h){this.ctx.logger.error(h),this._error=h}return async()=>{for(this.uid=null,this.context.emit("internal/plugin",this),this.ctx.registry.has(s.callback)&&(u(),s.fibers.length||this.ctx.registry.delete(s.callback)),this._setEpoch($);this.inertia;)await this.inertia}},"ctx.plugin()")}else this.uid=0,this.ctx=this.context=e,this.state=2,this.store=Object.create(null),this._runner={epoch:"",getOuterStack:i,execute:d(()=>{},"execute"),collect:o},this.dispose=()=>this.restart()}get name(){var t;let e=this;do{if((t=e.runtime)!=null&&t.name)return e.runtime.name;e=e.parent.fiber}while(e!==e.parent.fiber);return"root"}assertActive(){if(this.uid===null)throw new Pe("INACTIVE_EFFECT")}_execute(e){const t=e.epoch;return Re(n=>{const s=d(o=>{if(typeof o=="function")e.collect(o);else if(!he(o))throw new TypeError("Invalid effect")},"safeCollect"),i=e.execute.call(this);if(typeof i=="function")return e.collect(i);if(!he(i))if(ne(i)){if("then"in i)return i.then(s);if(Symbol.iterator in i){n.error=new Error;const o=i[Symbol.iterator]();for(;;){const a=o.next();if(s(a.value),a.done)return}}else if(Symbol.asyncIterator in i){const o=i[Symbol.asyncIterator]();return(async()=>{for(await Promise.resolve(),n.error=new Error;;){if(e.epoch!==t)return;const a=await o.next();if(s(a.value),a.done)return}})()}else throw new TypeError("Invalid effect")}else throw new TypeError("Invalid effect")},e.getOuterStack)}effect(e,t="anonymous"){this.assertActive();const n=[],s=d(()=>{let m;for(const w of n.splice(0).reverse())if(m)m=m.then(w);else{const S=w();ne(S)&&"then"in S&&(m=S)}return m},"dispose"),i={label:t,children:[]},o={execute:e,epoch:!0,collect:d(m=>{n.push(m),this._disposables.delete(m),m[f.effect]&&i.children.push(m[f.effect])},"collect"),getOuterStack:we()};let a;try{a=this._execute(o)}catch(m){throw s(),m}a==null||a.catch(s).catch(m=>this.ctx.logger.error(m));const u=A(()=>{if(o.epoch)return o.epoch=!1,a?a.then(s):s()},f.effect,i),h=d(()=>{if(o.epoch)return o.epoch=!1,s()},"disposeAsync");return u.then=async(m,w)=>Promise.resolve(a).then(()=>h).then(m,w),n.push(this._disposables.push(u)),u}getEffects(){return[...this._disposables].map(e=>e[f.effect]).filter(Boolean)}_getState(){return this.uid===null?4:this._error?3:this._runner.epoch!==$?2:0}_updateState(e){const t=this.state;if(this.state=e()??this._getState(),t!==this.state&&(this.context.emit("internal/status",this,t),!(t!==2&&this.state!==2)))for(const n of Reflect.ownKeys(this.ctx.reflect.store)){const s=this.ctx.reflect.store[n];s.fiber===this&&this.ctx.reflect.notify([s.name])}}_checkImpl(e){const t=this.ctx.reflect._getImpl(e,!0);if(!t)return delete this._store[e];try{if(t.check&&!t.check.call(D(this.ctx,t.value)))return delete this._store[e]}catch(n){return t.fiber.ctx.logger.error(n),delete this._store[e]}this._store[e]=t}_refresh(){let e=!1;e="";for(const t of Object.keys(this.inject)){const n=this._store[t];if(!n){e=$;break}e+=":"+n.fiber.uid}this._setEpoch(e)}_setEpoch(e){const t=this._runner.epoch;e!==t&&(this._error||(this._runner.epoch=e,!this.inertia&&this._updateState(()=>e!==$&&t===$?(this.inertia=this._reload(),1):(this.inertia=this._unload(),5))))}async _reload(){this.store={...this._store};const e=this._runner.epoch;try{await Promise.resolve(),await this._execute(this._runner)}catch(t){this.ctx.logger.error(t),this._error=t,this._runner.epoch=$}this._updateState(()=>{if(this._runner.epoch===e)this.inertia=void 0;else return this.inertia=this._unload(),5})}async _unload(){await Promise.all(this._disposables.clear().map(async e=>{try{await Re(async t=>{await Promise.resolve(),t.error=new Error,await e()},this._runner.getOuterStack)}catch(t){this.ctx.logger.error(t)}})),this.store=void 0,this._updateState(()=>{if(this._runner.epoch===$)this.inertia=void 0;else return this.inertia=this._reload(),1})}async await(){for(;this.inertia;)await this.inertia;if(this._error)throw this._error;return this}async restart(){const e=this.ctx.fiber;e.assertActive(),e._setEpoch($),e._refresh(),await e.await()}update(e,t=!1){const n=this.ctx.fiber;n.assertActive(),e=_e(n.runtime,e),n.context.waterfall(n,"internal/update",e,t,()=>(n.config=e,n._error=void 0,n.restart()))}},d(W,"Fiber"),W);function fe(r){const e=r.stack.split(`
11
- `);return e.splice(0,2,`Error: ${r.message}`),r.stack=e.join(`
12
- `),r}d(fe,"enhanceError");var _t=["prototype","then"];function de(r){return typeof r=="symbol"||_t.includes(r)||parseInt(r).toString()===r||r.startsWith("_")}d(de,"isSpecialProperty");var M,Be=(M=class{constructor(e){l(this,"ctx");l(this,"store",Object.create(null));l(this,"props",Object.create(null));this.ctx=e,A(this,f.tracker,{property:"ctx",noShadow:!0}),this.mixin("reflect",["get","set","provide","accessor","mixin"]),this.mixin("fiber",["runtime","effect"]),this.mixin("registry",["inject","plugin"]),this.mixin("events",["on","once","parallel","emit","serial","bail","waterfall"])}get(e,t=!0){var n;return D(this.ctx,(n=this._getImpl(e,t))==null?void 0:n.value)}_getImpl(e,t=!0){const n=this.ctx[f.isolate][e],s=n&&this.store[n];if(s&&!(t&&s.fiber.state!==2))return s}set(e,t,n){const s=this.ctx[f.isolate][e],i=this.store[s];if(!i)throw new Error(`cannot set property "${e}" without provide`);if(i.fiber!==this.ctx.fiber)throw new Error(`cannot set property "${e}" in multiple fibers`);return i.value=t,!0}provide(e,t,n){return this.ctx.fiber.effect(()=>{var o,a;if(!this.props[e])(o=this.props)[e]??(o[e]={type:"service"});else if(this.props[e].type!=="service")throw new Error(`property "${e}" is already declared as ${this.props[e].type}`);this.props[e]={type:"service"},(a=this.ctx.root[f.isolate])[e]??(a[e]=Symbol(e));const s=this.ctx[f.isolate][e],i={name:e,value:t,fiber:this.ctx.fiber,check:n};if(this.store[s])throw new Error(`service "${e}" has been registered at <${this.store[s].fiber.name}>`);return this.store[s]=i,this.ctx.fiber.store[e]=i,this.ctx.fiber.state===2&&this.notify([e]),async()=>{delete this.store[s];const u=this.notify([e]);await Promise.allSettled(u.map(h=>h.await())),delete this.ctx.fiber.store[e]}},`ctx.provide(${JSON.stringify(e)})`)}notify(e,t=(n,s)=>n[f.isolate][s]===this.ctx[f.isolate][s]){var s;const n=[];for(const i of this.ctx.registry.values())for(const o of i.fibers){let a=!1;for(const u of e)u in o.inject&&t(o.ctx,u)&&(a=!0,o._checkImpl(u));a&&(o._refresh(),n.push(o))}for(const i of e){const o=Object.create(this.ctx);o[f.filter]=a=>t(a,i),this.ctx.events.emit(o,"internal/service",i,(s=this._getImpl(i,!1))==null?void 0:s.value)}return n}accessor(e,t){return this.ctx.fiber.effect(()=>{if(e in this.props)throw new Error(`property "${e}" is already declared as ${this.props[e].type}`);return this.props[e]={type:"accessor",...t},()=>delete this.props[e]},`ctx.accessor(${JSON.stringify(e)})`)}mixin(e,t){const n=this;return this.ctx.fiber.effect(function*(){const s=Array.isArray(t)?t.map(o=>[o,o]):Object.entries(t),i=d((o,a)=>o[e],"getTarget");for(const[o,a]of s)yield n.accessor(a,{get(u,h){const m=i(this,h);if(he(m))return m;const w=u?se(u,m):m,S=Reflect.get(m,o,w);return typeof S!="function"?S:S.bind(w??m)},set(u,h,m){const w=i(this,m),S=h?se(h,w):w;return Reflect.set(w,o,u,S)}})},`ctx.mixin(${JSON.stringify(e)})`)}trace(e){return D(this.ctx,e)}bind(e){return new Proxy(e,{apply:d((t,n,s)=>Reflect.apply(t,this.trace(n),s.map(i=>this.trace(i))),"apply"),construct:d((t,n,s)=>Reflect.construct(t,n.map(i=>this.trace(i)),s),"construct")})}},d(M,"ReflectService"),l(M,"handler",{get:d((e,t,n)=>{if(de(t))return Reflect.get(e,t,n);if(Reflect.has(e,t))return D(n,Reflect.get(e,t,n));const s=new Error(`cannot get property "${t}" without inject`);try{const i=e.reflect.props[t];return(i==null?void 0:i.type)==="accessor"?i.get.call(n,n[f.receiver],s):n.fiber.runtime?n.events.waterfall("internal/get",n,t,s,()=>{var u;const o=e[f.isolate][t];let a=(n[f.shadow]??n).fiber;for(;;){const h=(u=a.store)==null?void 0:u[t];if(h)return D(n,h.value);if(t in a.inject)throw s.message=`cannot get required service "${t}" in inactive context`,s;if(!a.runtime||a.parent[f.isolate][t]!==o)throw s;a=a.parent.fiber}}):n.reflect.get(t,!1)}catch(i){throw i===s?fe(i):i}},"get"),set:d((e,t,n,s)=>{if(de(t))return Reflect.set(e,t,n,s);const i=new Error(`cannot set property "${t}" without provide`),o=e.reflect.props[t];if(!o){if(!s.fiber.runtime)return Reflect.set(e,t,n,s);throw fe(i)}try{return o.type==="accessor"?o.set?o.set.call(s,n,s[f.receiver],i):!1:s.events.waterfall("internal/set",s,t,n,i,()=>s.reflect.set(t,n,i))}catch(a){throw a===i?fe(a):a}},"set"),has:d((e,t)=>de(t)?Reflect.has(e,t):Reflect.has(e,t)?!0:!!e.reflect.props[t],"has")}),M);function Ze(r){return r&&typeof r=="object"&&typeof r.apply=="function"}d(Ze,"isApplicable");function ye(r,e){return function(t,n){var s,i;if(n.kind==="class")Object.hasOwn(t,"inject")||(A(t,"inject",Object.create(Object.getPrototypeOf(t).inject??null)),A(t.inject,f.checkProto,!0)),t.inject[r]=e;else if(n.kind==="method"){const o=(i=t[s=f.metadata]??(t[s]={})).inject??(i.inject=Object.create(null));o[r]=e,n.addInitializer(function(){var u,h;const a=(u=this[f.tracker])==null?void 0:u.property;(this[h=f.initHooks]??(this[h]=[])).push(()=>{this.ctx.inject(o,m=>t.call(a?se(this,{[a]:m}):this))})})}else throw new Error("@Inject() can only be used on class or class methods")}}d(ye,"Inject");(r=>{function e(t,n=Object.create(null)){if(!t)return n;if(Array.isArray(t))for(const s of t)n[s]=null;else if(Reflect.has(t,f.checkProto)){Object.assign(n,e(Object.getPrototypeOf(t)));for(const s of Object.keys(t))n[s]=t[s]??null}else for(const s of Object.keys(t))n[s]=t[s]??null;return n}r.resolve=e,d(e,"resolve")})(ye||(ye={}));var Y,Pt=(Y=class{constructor(e){l(this,"ctx");l(this,"_counter",0);l(this,"_internal",new Map);this.ctx=e,A(this,f.tracker,{property:"ctx",noShadow:!0})}get counter(){return++this._counter}get size(){return this._internal.size}resolve(e){try{if(typeof e=="function")return e;if(Ze(e))return e.apply}catch{}}get(e){const t=this.resolve(e);return t&&this._internal.get(t)}has(e){const t=this.resolve(e);return!!t&&this._internal.has(t)}delete(e){const t=this.resolve(e),n=t&&this._internal.get(t);if(n){this._internal.delete(t);for(const s of n.fibers)s.dispose();return n}}keys(){return this._internal.keys()}values(){return this._internal.values()}entries(){return this._internal.entries()}forEach(e){return this._internal.forEach(e)}inject(e,t){return this.plugin({inject:e,apply:t,name:t.name})}plugin(e,t,n=we()){const s=this.resolve(e);if(!s)throw new Error('invalid plugin, expect function or object with an "apply" method, received '+typeof e);this.ctx.fiber.assertActive();let i=this._internal.get(s);if(!i){let u=e.name;u==="apply"&&(u=void 0),i={name:u,callback:s,fibers:new je,Config:e.Config},this._internal.set(s,i)}const o=new Xe(this.ctx,t,ye.resolve(e.inject),i,n),a=Object.create(o);return a.then=(u,h)=>o.await().then(u,h),a}},d(Y,"RegistryService"),Y),I,q=(I=class{static is(e){return!!(e!=null&&e[I.is])}constructor(){this[f.isolate]=Object.create(null),this[f.intercept]=Object.create(null);const e=new Proxy(this,Be.handler);return this.root=e,this.baseUrl=void 0,this.fiber=new Xe(e,{},Object.create(null),null,()=>[]),this.reflect=new Be(e),this.registry=new Pt(e),this.events=new kt(e),this.logger=new Nt(e),this.fiber._disposables.clear(),e}[Symbol.for("nodejs.util.inspect.custom")](){return`Context <${this.fiber.name}>`}extend(e={}){var s;const t=(s=Reflect.getOwnPropertyDescriptor(this,f.shadow))==null?void 0:s.value,n=Object.create(D(this,this));for(const i of Reflect.ownKeys(e))Object.defineProperty(n,i,Reflect.getOwnPropertyDescriptor(e,i));return t?Object.assign(Object.create(n),{[f.shadow]:t}):n}isolate(e,t){const n=Object.create(this[f.isolate]);return n[e]=t??Symbol(e),this.extend({[f.isolate]:n})}intercept(e,t){const n=Object.create(this[f.intercept]);return n[e]=t,this.extend({[f.intercept]:n})}},d(I,"Context"),l(I,"effect",f.effect),l(I,"filter",f.filter),l(I,"isolate",f.isolate),l(I,"intercept",f.intercept),I.is[Symbol.toPrimitive]=()=>Symbol.for("cordis.is"),I.prototype[I.is]=!0,I),N,jt=(N=class{constructor(e,t){l(this,"ctx");l(this,"name");this.ctx=e,t??(t=this.constructor.provide);let n=this;const s={associate:t,property:"ctx"};return n[f.invoke]&&(n=ge(t,me(Object.getPrototypeOf(this),Function.prototype),s)),n.ctx=e,n.name=t,A(n,f.tracker,s),n.ctx.reflect.provide(t,n,this[f.check]),n}[f.filter](e){return e[f.isolate][this.name]===this.ctx[f.isolate][this.name]}[f.extend](e){let t;return this[N.invoke]?t=ge(this.name,this,this[f.tracker]):t=Object.create(this),Object.assign(t,e)}[f.resolveConfig](e,t){var i;let n=this.ctx[q.intercept];const s=[];for(;this.name in n;)Object.hasOwn(n,this.name)&&s.unshift(n[this.name]),n=Object.getPrototypeOf(n);return e&&s.unshift(e),t&&s.push(t),(i=this.Config)!=null&&i.merge?this.Config.merge(...s):Object.assign({},...s)}static[Symbol.hasInstance](e){var n;if(!e)return!1;let t=e.constructor;for(;t;){if(t=(n=t.prototype)==null?void 0:n.constructor,t===this)return!0;t&&(t=Object.getPrototypeOf(t))}return!1}},d(N,"Service"),l(N,"init",f.init),l(N,"check",f.check),l(N,"config",f.config),l(N,"invoke",f.invoke),l(N,"extend",f.extend),l(N,"tracker",f.tracker),l(N,"resolveConfig",f.resolveConfig),N);const Ct=q,Qe=jt;class $t{constructor(){l(this,"entries",new Map);l(this,"byPlugin",new Map);l(this,"listeners",new Set);l(this,"snapshotCache",[]);l(this,"byKey",new Map)}keyOf(e,t){return`${e}\0${t}`}index(){this.entries.clear();const e=[...this.byPlugin.values()].flatMap(t=>[...t]).map(t=>this.byKey.get(t)).sort((t,n)=>{const s=t.order??100,i=n.order??100;return s!==i?s-i:t.pluginId!==n.pluginId?t.pluginId<n.pluginId?-1:1:t.path<n.path?-1:1});for(const t of e)this.entries.set(this.keyOf(t.pluginId,t.path),t);this.snapshotCache=[...this.entries.values()]}register(e){if(!e.path.startsWith("/"))throw new Error(`pages.register: path must start with "/" (got ${e.path})`);const t=this.keyOf(e.pluginId,e.path),n=this.byKey.has(t);if(this.byKey.set(t,{...e}),!n){const s=this.byPlugin.get(e.pluginId)??new Set;s.add(t),this.byPlugin.set(e.pluginId,s)}this.index(),this.notify()}unregister(e,t){const n=this.keyOf(e,t);if(!this.byKey.delete(n))return;const s=this.byPlugin.get(e);s&&(s.delete(n),s.size===0&&this.byPlugin.delete(e)),this.index(),this.notify()}unregisterAll(e){const t=this.byPlugin.get(e);if(!(!t||t.size===0)){for(const n of t)this.byKey.delete(n);this.byPlugin.delete(e),this.index(),this.notify()}}snapshot(){return this.snapshotCache}has(e){for(const t of this.entries.values())if(t.path===e)return!0;return!1}get size(){return this.entries.size}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of[...this.listeners])try{e()}catch{}}}class $e extends Qe{constructor(t){super(t,"pages");l(this,"registry",new $t)}}l($e,"service","pages");const ve=$e.prototype;ve.register=function(r){const e=this.ctx.effect;return e(()=>(this.registry.register(r),()=>this.registry.unregister(r.pluginId,r.path)),"pages.register")};ve.unregister=function(r){this.registry.unregisterAll(r)};ve.subscribe=function(r){return this.registry.subscribe(r)};ve.getSnapshot=function(){return this.registry.snapshot()};const At=1;class Tt{constructor(e){l(this,"state","connecting");l(this,"online");l(this,"onlineEvent");l(this,"offlineEvent");l(this,"socketEvents");l(this,"opener");l(this,"attempt",0);l(this,"timer");l(this,"disposed",!1);l(this,"addOnline");l(this,"addOffline");l(this,"removeOnline");l(this,"removeOffline");l(this,"scheduleTimer");l(this,"onOpened");l(this,"onDownNotify");l(this,"onStopped");this.online=e.online,this.opener=e.open,this.onlineEvent=()=>this.retry(0),this.offlineEvent=()=>this.goOffline(),this.socketEvents=()=>this.onDown(),this.addOnline=e.addOnlineListener,this.addOffline=e.addOfflineListener,this.removeOnline=e.removeOnlineListener,this.removeOffline=e.removeOfflineListener,this.scheduleTimer=e.schedule,this.onOpened=e.onOpen,this.onDownNotify=e.onDown,this.onStopped=e.onStopped,this.addOnline(this.onlineEvent),this.addOffline(this.offlineEvent)}attemptStart(){if(this.state!=="stopped"){if(!this.online()){this.state="offline";return}this.state="connecting",this.opener()}}onSocketOpen(){this.state!=="stopped"&&(this.attempt=0,this.state="connected",this.onOpened())}onDown(){if(this.state!=="stopped"){if(!this.online()){this.goOffline();return}this.state="connecting",this.onDownNotify(),this.retry(this.backoffMs())}}backoffMs(){return Math.min(1e3*2**this.attempt,1e4)}retry(e){if(this.state!=="stopped"){if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.attempt+=1,e===0){this.attemptStart();return}this.scheduleTimer(e)}}goOffline(){this.state!=="stopped"&&(this.state="offline",this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.onDownNotify())}onlineNow(){this.state!=="stopped"&&this.retry(0)}begin(){this.attemptStart()}down(){this.onDown()}open(){this.onSocketOpen()}stop(){var e;this.disposed||(this.disposed=!0,this.state="stopped",this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.removeOnline(this.onlineEvent),this.removeOffline(this.offlineEvent),(e=this.onStopped)==null||e.call(this))}}class Dt{constructor(e){l(this,"controller");l(this,"url");l(this,"minDelayMs");l(this,"maxDelayMs");l(this,"handlers");l(this,"Impl");l(this,"socket",null);l(this,"generation",0);l(this,"stopped",!1);l(this,"onFrameBound",null);this.url=e.url,this.minDelayMs=e.minDelayMs??250,this.maxDelayMs=e.maxDelayMs??1e4,this.handlers=e.handlers??{},this.Impl=e.impl??globalThis.WebSocket??null,this.controller=new Tt({online:()=>e.online??!0,open:()=>this.openSocket(),onOpen:()=>this.handleOpen(),onDown:()=>this.handleDown(),schedule:t=>this.scheduleReconnect(t),addOnlineListener:t=>{typeof window<"u"&&window.addEventListener("online",t)},addOfflineListener:t=>{typeof window<"u"&&window.addEventListener("offline",t)},removeOnlineListener:t=>{typeof window<"u"&&window.removeEventListener("online",t)},removeOfflineListener:t=>{typeof window<"u"&&window.removeEventListener("offline",t)}})}connect(){this.controller.begin()}get currentGeneration(){return this.generation}send(e){const t=this.socket;if(!t||t.readyState!==At)return!1;try{return t.send(e),!0}catch{return this.controller.down(),!1}}close(){if(this.stopped)return;this.stopped=!0,this.controller.stop();const e=this.socket;if(this.socket=null,e)try{e.close(1e3,"client close")}catch{}}scheduleReconnect(e){this.stopped||setTimeout(()=>{this.stopped||this.controller.begin()},e)}openSocket(){if(!this.stopped)try{const e=new this.Impl(this.url);this.socket=e,e.addEventListener("open",()=>{this.socket===e&&(this.generation=Date.now(),this.controller.open())}),e.addEventListener("close",()=>{this.socket===e&&(this.socket=null,this.controller.down())}),e.addEventListener("error",()=>{});const t=n=>{var s,i;this.socket===e&&typeof n.data=="string"&&((i=(s=this.handlers).onMessage)==null||i.call(s,n.data))};this.onFrameBound=t,e.addEventListener("message",t)}catch{this.socket=null,this.controller.down()}}handleOpen(){var e,t;(t=(e=this.handlers).onOpen)==null||t.call(e,this.generation)}handleDown(){var e,t;this.socket=null,(t=(e=this.handlers).onClose)==null||t.call(e)}}const Mt=3e4,Lt="payload/too-large",ue="rpc/disconnected";let P=class extends Error{constructor(t,n){super(n??t);l(this,"code");this.code=t,this.name="RpcError"}};class Bt{constructor(e,t={}){l(this,"pending",new Map);l(this,"nextId",0);l(this,"generation",0);l(this,"defaultTimeoutMs");l(this,"onFrame");l(this,"closed",!1);l(this,"sendText");this.sendText=e,this.defaultTimeoutMs=t.defaultTimeoutMs??Mt,this.onFrame=t.onFrame??(()=>{})}reset(e){this.rejectAll(new P(ue,"connection reset")),this.generation=e,this.closed=!1}disconnectAll(e){this.rejectAll(e??new P(ue))}rejectAll(e){const t=[...this.pending.values()];this.pending.clear();for(const n of t){clearTimeout(n.timer);try{n.reject(e)}catch{}}}close(){this.closed=!0,this.disconnectAll()}sendNotification(e,t){if(this.closed)return!1;const n={v:1,generation:this.generation,requestId:`n:${this.nextId++}`,op:e,payload:t};let s;try{s=JSON.stringify(n)}catch{return!1}return s.length>Fe()?!1:this.sendText(s)}request(e,t,n={}){if(this.closed)return Promise.reject(new P(ue));const s=n.timeoutMs??this.defaultTimeoutMs,i=`c:${this.nextId++}`,o=this.generation,a={v:1,generation:o,requestId:i,op:e,payload:t};let u;try{u=JSON.stringify(a)}catch{return Promise.reject(new P("payload/serialize","payload not serializable"))}return u.length>Fe()?Promise.reject(new P(Lt,"frame exceeds MAX_FRAME_BYTES")):new Promise((h,m)=>{const w=setTimeout(()=>{this.pending.delete(i),m(new P("rpc/timeout","rpc timeout"))},s);this.pending.set(i,{op:e,generation:o,resolve:y=>{clearTimeout(w),h(y)},reject:y=>{clearTimeout(w),m(y)},timer:w}),this.sendText(u)||(this.pending.delete(i),clearTimeout(w),m(new P(ue)))})}handleFrame(e){var n,s;if(e.op==="rpc.result"){const i=this.pending.get(e.requestId);if(!i)return;if(i.generation!==e.generation){this.pending.delete(e.requestId),clearTimeout(i.timer),i.reject(new P("rpc/protocol-mismatch","generation mismatch"));return}this.pending.delete(e.requestId),clearTimeout(i.timer);const o=e.payload;if(o&&o.ok===!1){i.reject(new P(((n=o.error)==null?void 0:n.code)??"rpc/error",(s=o.error)==null?void 0:s.message));return}i.resolve(o==null?void 0:o.data);return}const t=this.pending.get(e.requestId);if(t){this.pending.delete(e.requestId),clearTimeout(t.timer),t.generation!==e.generation?t.reject(new P("rpc/protocol-mismatch","generation mismatch")):t.reject(new P("rpc/protocol-mismatch",`unexpected op ${e.op} for pending request`));return}this.onFrame(e)}get pendingCount(){return this.pending.size}}function Fe(){return 16*1024*1024}function Ft(r){if(!r||typeof r!="object")return!1;const e=r;return typeof e.id=="string"&&typeof e.pluginRunId=="string"&&typeof e.manifest=="object"}function Ht(r){if(!r||typeof r!="object")return;const e=r,t=typeof e.generation=="number"?e.generation:0,n=typeof e.auditLastId=="number"?e.auditLastId:0,s=Array.isArray(e.records)?e.records:[],i=Array.isArray(e.plugins)?e.plugins:[];return{generation:t,auditLastId:n,records:s,plugins:i.filter(Ft)}}class zt extends Error{constructor(t,n){super(t);l(this,"code");this.code=n,this.name="RpcError"}}function Ut(r){if(!r||typeof r!="object")throw new zt("malformed audit response");const e=r;return{status:e.status??0,statusText:e.statusText??"",headers:e.headers??{},bytes:e.bytes??0,truncated:e.truncated??!1,bodyText:e.bodyText??"",...e.bodyJson!==void 0?{bodyJson:e.bodyJson}:{}}}let et;function qt(r){et=r}class Ae extends Qe{constructor(e){super(e,"auditClient")}}l(Ae,"service","auditClient");function Jt(r){var n,s;const e=(n=r.ctx)==null?void 0:n.fiber,t=(s=e==null?void 0:e.config)==null?void 0:s.pluginRunId;return typeof t=="string"?t:""}function ie(r,e,t,n,s){const i=et;return i?i.request("rpc.invoke",{method:e,url:t,...n!==void 0?{body:n}:{},...s?{config:s}:{},pluginRunId:Jt(r)}).then(o=>Ut(o)):Promise.reject(new Error("auditClient used before connectRpc wired the RPC bridge"))}const oe=Ae.prototype;oe.get=function(r,e){return ie(this,"GET",r,void 0,e)};oe.post=function(r,e,t){return ie(this,"POST",r,e,t)};oe.put=function(r,e,t){return ie(this,"PUT",r,e,t)};oe.patch=function(r,e,t){return ie(this,"PATCH",r,e,t)};oe.delete=function(r,e){return ie(this,"DELETE",r,void 0,e)};async function Gt(r,e,t){var i;const{ctx:n}=r;if(typeof((i=n.registry)==null?void 0:i.plugin)!="function")throw new Error(`browser-half ${e.id}: ctx lacks a cordis registry (no ctx.registry.plugin)`);const s=n.registry.plugin({inject:["pages","auditClient"],apply:t},{name:e.id,pluginRunId:e.pluginRunId});return await s.await(),{id:e.id,pluginRunId:e.pluginRunId,fiber:s}}async function tt(r,e){const t=new Blob([e.code],{type:"text/javascript"}),n=URL.createObjectURL(t);try{const s=await import(n),i=s.default??s.apply;if(typeof i!="function")throw new Error(`browser-half ${e.id} must default-export a function (ctx) => ...`);return await Gt(r,{id:e.id,pluginRunId:e.pluginRunId},i)}finally{URL.revokeObjectURL(n)}}async function He(r,e){e.fiber&&(await e.fiber.dispose(),e.fiber=void 0)}class te extends Error{constructor(t,n,s){super(n);l(this,"code");l(this,"status");this.code=t,this.status=s,this.name="ApiError"}}async function Vt(r){var n,s;let e;try{e=await r.json()}catch{throw new te("response/not-json",`host returned ${r.status} ${r.statusText}`)}if(!e||typeof e!="object")throw new te("response/malformed","host returned a non-object payload");const t=e;if(t.ok===!1||!r.ok)throw new te(((n=t.error)==null?void 0:n.code)??"http/error",((s=t.error)==null?void 0:s.message)??`HTTP ${r.status}`,r.status);return t.data}async function H(r,e){const t=await fetch(r,e);return Vt(t)}function rt(r,e){return H(`${r}/api/audit`)}function Kt(r,e){return H(`${r}/api/replay`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)})}function Te(r){return H(`${r}/api/plugins`)}function Wt(r,e){return H(`${r}/api/plugins/${encodeURIComponent(e)}/stop`,{method:"POST"})}function Yt(r,e){return H(`${r}/api/plugins/${encodeURIComponent(e)}/remove`,{method:"POST"})}function Xt(r,e){return H(`${r}/api/plugins/install`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({spec:e})})}async function Zt(r,e,t="plugin.zip"){const n=new FormData;return n.append("zip",e,t),H(`${r}/api/plugins`,{method:"POST",body:n})}async function Qt(r,e=""){if(typeof fetch!="function")return;const t=await fetch(`${e}/api/plugins/${encodeURIComponent(r)}/browser-source`);if(t.ok)return await t.text()}async function nt(r,e,t=""){const n=await Qt(e.pluginRunId,t);if(typeof n=="string")return tt({ctx:r},{id:e.id,pluginRunId:e.pluginRunId,code:n})}async function er(r,e){var i;const t=e.host??"";let n;try{n=await Te(t)}catch{return}const s=n.find(o=>o.id===e.id);if(s&&(i=s.manifest.halves.browser)!=null&&i.entry)return nt(r.ctx,{id:s.id,pluginRunId:s.pluginRunId},t)}class tr{constructor(e){l(this,"ctx");l(this,"rpc");l(this,"transport");l(this,"snapshotListeners",new Set);l(this,"currentSnapshot");l(this,"auditPushes");l(this,"halves",new Map);l(this,"loading",new Set);this.ctx=e.ctx,this.rpc=e.rpc,this.transport=e.transport,this.auditPushes=e.onAuditPush?[e.onAuditPush]:[]}get rpcClient(){return this.rpc}get status(){return this.transport.controller.state}snapshot(){return this.currentSnapshot}onSnapshot(e){return this.snapshotListeners.add(e),this.currentSnapshot&&e(this.currentSnapshot),()=>{this.snapshotListeners.delete(e)}}onAuditPush(e){return this.auditPushes.push(e),()=>{const t=this.auditPushes.indexOf(e);t>=0&&this.auditPushes.splice(t,1)}}applySnapshot(e){const t=Ht(e);if(t){this.currentSnapshot=t,this.reconcile(t);for(const n of[...this.snapshotListeners])try{n(t)}catch{}}}applyAuditPush(e){for(const t of[...this.auditPushes])try{t(e)}catch{}}async applyBrowserHalfLoad(e){const t=await tt({ctx:this.ctx},e);this.halves.set(e.pluginRunId,t)}async applyBrowserHalfRetract(e){const t=this.halves.get(e.pluginRunId);t&&(this.halves.delete(e.pluginRunId),await He({ctx:this.ctx},t))}async reconcile(e){var n;const t=new Map;for(const s of e.plugins)(n=s.manifest.halves.browser)!=null&&n.entry&&t.set(s.pluginRunId,{id:s.id,pluginRunId:s.pluginRunId});for(const s of t.values())if(!(this.halves.has(s.pluginRunId)||this.loading.has(s.pluginRunId))){this.loading.add(s.pluginRunId);try{const i=await nt(this.ctx,s);i&&this.halves.set(s.pluginRunId,i)}catch{}finally{this.loading.delete(s.pluginRunId)}}for(const[s,i]of[...this.halves])if(!t.has(s)){this.halves.delete(s);try{await He({ctx:this.ctx},i)}catch{}}}close(){this.transport.close()}}async function rr(r={}){const e=r.ctx??new Ct,t=await sr(e),n=r.url??or(),s=new Dt({url:n,...r.minDelayMs!==void 0?{minDelayMs:r.minDelayMs}:{},...r.maxDelayMs!==void 0?{maxDelayMs:r.maxDelayMs}:{},...r.wsImpl!==void 0?{impl:r.wsImpl}:{},handlers:{onOpen:()=>{var a;i.reset(s.currentGeneration),i.sendNotification("snapshot.request",{sinceId:((a=o.snapshot())==null?void 0:a.auditLastId)??0})},onMessage:a=>{try{const u=JSON.parse(a);i.handleFrame(u)}catch{}},onClose:()=>{i.disconnectAll()}}}),i=new Bt(a=>s.send(a),{onFrame:a=>nr(o,a)});ir(e),qt(i);const o=new tr({ctx:e,transport:s,rpc:i});return s.connect(),{ctx:e,pages:t,onSnapshot:a=>o.onSnapshot(a),snapshot:()=>o.snapshot(),status:()=>o.status,close:()=>o.close()}}function nr(r,e){var t;switch(e.op){case"snapshot.respond":r.applySnapshot(e.payload);break;case"audit.append":r.applyAuditPush(e.payload);break;case"plugin.changed":r.rpcClient.sendNotification("snapshot.request",{sinceId:((t=r.snapshot())==null?void 0:t.auditLastId)??0});break;case"browser-half.load":r.applyBrowserHalfLoad(e.payload);break;case"browser-half.retract":r.applyBrowserHalfRetract(e.payload);break}}async function sr(r){let e=r.pages;return e||(await r.registry.plugin($e).await(),e=r.pages),e}function ir(r){var t,n;(n=(t=r.reflect)._getImpl)!=null&&n.call(t,"auditClient",!0)||new Ae(r)}function or(){return typeof location<"u"?`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/ws`:"ws://localhost:4560/ws"}const cr=["GET","POST","PUT","PATCH","DELETE"];function ar(r){const[e,t]=O([]),[n,s]=O(null),i=re(async()=>{try{const o=await rt("");t(o.records),s(null)}catch(o){s(o.message)}},[]);return F(()=>{i();let o;r&&(o=r.onSnapshot(()=>{i()}));const a=window.setInterval(()=>void i(),2e3);return()=>{window.clearInterval(a),o==null||o()}},[r,i]),{records:e,error:n,refresh:i}}function lr({runtime:r}){const{records:e,error:t}=ar(r),[n,s]=O(""),[i,o]=O(""),[a,u]=O(""),[h,m]=O(null),[w,S]=O("desc"),y=re(()=>S(v=>v==="desc"?"asc":"desc"),[]),g=ee(()=>{const v=a.trim().toLowerCase();return e.filter(E=>!(n&&E.method!==n||i&&!E.initiator.toLowerCase().includes(i.toLowerCase())||v&&!`${E.url} ${E.initiator} ${E.statusText}`.toLowerCase().includes(v))).sort((E,j)=>w==="desc"?j.ts-E.ts:E.ts-j.ts)},[e,n,i,a,w]);return p("div",{className:"page",children:[c("h1",{children:"审计记录"}),t&&p("div",{className:"error-line",children:["加载失败:",t]}),p("div",{className:"filters",children:[p("select",{value:n,onChange:v=>s(v.target.value),children:[c("option",{value:"",children:"全部方法"}),cr.map(v=>c("option",{value:v,children:v},v))]}),c("input",{placeholder:"发起方过滤",value:i,onChange:v=>o(v.target.value)}),c("input",{placeholder:"搜索 URL / 状态",value:a,onChange:v=>u(v.target.value)}),c("button",{type:"button",className:"sort-toggle",onClick:y,title:w==="desc"?"当前:最新在前,点击切换为时间正序":"当前:时间正序,点击切换为最新在前",children:w==="desc"?"最新在前 ↓":"时间顺序 ↑"}),p("span",{className:"count",children:["共 ",g.length," 条"]})]}),p("table",{className:"table",children:[c("thead",{children:p("tr",{children:[c("th",{children:p("button",{type:"button",className:"th-sort",onClick:y,children:["时间 ",w==="desc"?"↓":"↑"]})}),c("th",{children:"发起方"}),c("th",{children:"方法"}),c("th",{children:"URL"}),c("th",{children:"状态"}),c("th",{children:"耗时"})]})}),p("tbody",{children:[g.length===0&&c("tr",{children:c("td",{colSpan:6,className:"empty-cell",children:"暂无记录"})}),g.map(v=>p("tr",{onClick:()=>m(v),className:"row-click",children:[c("td",{children:st(v.ts)}),p("td",{children:[v.initiator,v.replayOf!==void 0&&c("span",{className:"tag replay",children:"重放"})]}),c("td",{children:c("span",{className:`method ${v.method}`,children:v.method})}),c("td",{className:"mono",title:v.url,children:v.url}),c("td",{children:c("span",{className:`status ${hr(v.status)}`,children:v.status})}),p("td",{children:[v.durationMs," ms"]})]},v.id))]})]}),h&&c(ur,{record:h,onClose:()=>m(null)})]})}function ur({record:r,onClose:e}){return c("div",{className:"drawer-mask",onClick:e,children:p("div",{className:"drawer",onClick:t=>t.stopPropagation(),children:[p("div",{className:"drawer-head",children:[p("h3",{children:[r.method," ",r.url]}),c("button",{onClick:e,children:"关闭"})]}),p("div",{className:"drawer-body",children:[c(U,{label:"时间",value:st(r.ts)}),c(U,{label:"发起方",value:r.initiator}),c(U,{label:"状态",value:`${r.status} ${r.statusText}`}),c(U,{label:"耗时",value:`${r.durationMs} ms`}),r.replayOf!==void 0&&c(U,{label:"重放自",value:`#${r.replayOf}`}),r.error&&c(U,{label:"错误",value:`${r.error.name}: ${r.error.message}`}),c("h4",{children:"请求头"}),c(ze,{headers:r.reqHeaders}),c("h4",{children:"请求体"}),c(Ue,{body:r.reqBody}),c("h4",{children:"响应头"}),c(ze,{headers:r.resHeaders}),c("h4",{children:"响应体"}),c(Ue,{body:r.resBody})]})]})})}function U({label:r,value:e}){return p("div",{className:"info-row",children:[c("span",{className:"info-label",children:r}),c("span",{children:e})]})}function ze({headers:r}){const e=Object.entries(r);return e.length===0?c("div",{className:"muted",children:"(无)"}):c("table",{className:"table slim",children:c("tbody",{children:e.map(([t,n])=>p("tr",{children:[c("td",{className:"mono key",children:t}),c("td",{className:"mono",children:n})]},t))})})}function Ue({body:r}){return r.text?p("div",{className:"body-view",children:[c("pre",{children:r.text}),r.truncated&&p("div",{className:"muted",children:["已截断(",r.bytes," bytes)"]})]}):c("div",{className:"muted",children:"(空)"})}function hr(r){return r===0?"err":r<300||r<400?"ok":r<500?"warn":"err"}function st(r){const e=new Date(r);return`${e.toLocaleDateString("zh-CN")} ${e.toLocaleTimeString("zh-CN",{hour12:!1})}`}const fr=["POST","PUT","PATCH","DELETE"],dr=["GET","POST","PUT","PATCH","DELETE"];function pr({runtime:r}){const[e,t]=O([]),[n,s]=O(""),[i,o]=O("GET"),[a,u]=O(""),[h,m]=O(""),[w,S]=O(""),[y,g]=O(!1),[v,E]=O(!1),[j,xe]=O(null),[T,ce]=O(null);F(()=>{let x=!1;const ae=async()=>{try{const ct=await rt("");x||t(ct.records)}catch{}};ae();const ot=window.setInterval(()=>void ae(),3e3);return()=>{x=!0,window.clearInterval(ot)}},[]);const R=ee(()=>e.find(x=>x.id===n)??null,[e,n]);F(()=>{R&&(o(R.method),u(R.url),m(yr(R.reqHeaders)),S(R.reqBody.text))},[R]);const b=ee(()=>R?Object.keys(R.reqHeaders).some(ae=>/^(authorization|cookie|x-api-key|proxy-authorization|x-auth-token)$/i.test(ae)):!1,[R]),k=ee(()=>mr(h),[h]),_=n!==""&&a.trim().length>0,C=fr.includes(i);async function Z(){if(n!==""){E(!0),ce(null);try{const x=await Kt("",{recordId:n,overrides:{method:i,url:a,headers:k,body:w}});xe({original:R,replayed:{status:x.status,statusText:x.statusText,durationMs:0,bodyText:x.bodyText,headers:x.headers}}),g(!1)}catch(x){ce(x.message)}finally{E(!1)}}}function Se(){if(C){g(!0);return}Z()}return p("div",{className:"page",children:[c("h1",{children:"API 重放"}),p("div",{className:"replay-grid",children:[p("section",{className:"card",children:[c("h2",{children:"1. 选择记录"}),p("div",{className:"select",children:[p("select",{value:n,onChange:x=>s(Number(x.target.value)||""),children:[c("option",{value:"",children:"请选择…"}),[...e].reverse().map(x=>p("option",{value:x.id,children:["#",x.id," ",x.method," ",x.url]},x.id))]}),b&&c("div",{className:"warn-box",children:"此请求包含凭证,重放将使用当前凭证服务的值。"})]}),c("h2",{children:"2. 编辑请求"}),p("div",{className:"form-row",children:[c("select",{value:i,onChange:x=>o(x.target.value),children:dr.map(x=>c("option",{value:x,children:x},x))}),c("input",{className:"url",value:a,onChange:x=>u(x.target.value),placeholder:"URL"})]}),c("label",{className:"field-label",children:"请求头 (每行 `Key: value`)"}),c("textarea",{value:h,onChange:x=>m(x.target.value),rows:4,className:"mono"}),c("label",{className:"field-label",children:"请求体"}),c("textarea",{value:w,onChange:x=>S(x.target.value),rows:6,className:"mono",disabled:Oe(i),placeholder:Oe(i)?"GET/HEAD 请求不携带请求体":""}),Oe(i)&&c("div",{className:"muted",children:"GET/HEAD 请求不携带请求体;上方内容仅作为编辑参考,重放时不会发送。"}),(R==null?void 0:R.reqBody.truncated)&&c("div",{className:"muted",children:"原始请求体已截断,重放将使用截断版本。"}),c("div",{className:"form-actions",children:c("button",{onClick:Se,disabled:!_||v,children:v?"重放中…":"重放"})}),T&&c("div",{className:"error-line",children:T})]}),p("section",{className:"card",children:[c("h2",{children:"3. 对比"}),!j&&c("div",{className:"muted",children:"选择记录并点击“重放”后在此对比。"}),j&&c(gr,{outcome:j})]})]}),y&&R&&c("div",{className:"drawer-mask",onClick:()=>g(!1),children:p("div",{className:"confirm",onClick:x=>x.stopPropagation(),children:[c("h3",{children:"确认重放非幂等请求"}),p("div",{className:"mono confirm-detail",children:[p("div",{children:[i," ",a]}),p("div",{children:["发起方:",R.initiator]}),c("pre",{children:w.slice(0,1e3)})]}),p("div",{className:"form-actions",children:[c("button",{className:"ghost",onClick:()=>g(!1),children:"取消"}),c("button",{onClick:()=>void Z(),disabled:v,children:"确认重放"})]})]})})]})}function gr({outcome:r}){const{original:e,replayed:t}=r;return p("div",{className:"compare",children:[p("div",{className:"compare-col",children:[c("h3",{children:"原始记录"}),p("div",{className:"compare-item",children:[c("span",{children:"状态"}),p("b",{children:[e.status," ",e.statusText]})]}),p("div",{className:"compare-item",children:[c("span",{children:"耗时"}),p("b",{children:[e.durationMs," ms"]})]}),c("pre",{className:"body-view",children:e.resBody.text||"(空)"})]}),p("div",{className:"compare-col",children:[c("h3",{children:"重放结果"}),p("div",{className:"compare-item",children:[c("span",{children:"状态"}),p("b",{children:[t.status," ",t.statusText]})]}),p("div",{className:"compare-item",children:[c("span",{children:"耗时"}),c("b",{children:t.durationMs?`${t.durationMs} ms`:"—"})]}),c("pre",{className:"body-view",children:t.bodyText||"(空)"})]})]})}function yr(r){return Object.entries(r).map(([e,t])=>`${e}: ${t}`).join(`
13
- `)}function mr(r){const e={};for(const t of r.split(`
14
- `)){const n=t.indexOf(":");if(n<0)continue;const s=t.slice(0,n).trim(),i=t.slice(n+1).trim();s&&(e[s]=i)}return e}function Oe(r){return r==="GET"||r==="HEAD"}const br={running:"运行中",stopping:"停止中…",removing:"移除中…",error:"错误"};function wr(){const[r,e]=O([]),[t,n]=O(""),[s,i]=O(!1),[o,a]=O(null),[u,h]=O(null),[m,w]=O(!1),[S,y]=O(null),[g,v]=O(null),E=re(async()=>{try{const b=await Te("");e(k=>b.map(_=>{const C=k.find(Se=>Se.pluginRunId===_.pluginRunId);if(!C)return{..._,localState:"running"};const Z={..._,localState:C.localState};return C.message!==void 0&&(Z.message=C.message),Z}))}catch(b){v(b.message)}},[]);F(()=>{E();const b=window.setInterval(()=>void E(),3e3);return()=>window.clearInterval(b)},[E]);async function j(){const b=t.trim();if(b){i(!0),a(null),v(null);try{const k=await Xt("",b);a(`已安装 ${b} → ${k.id}@${k.version}(${k.pluginRunId})`),n(""),await E()}catch(k){const _=k instanceof te?`${k.code}: ${k.message}`:k.message;v(`安装失败:${_}`)}finally{i(!1)}}}async function xe(){if(u){w(!0),y(null),v(null);try{const b=await Zt("",u,u.name);y(`上传成功:${b.id}@${b.manifest.version}(${b.pluginRunId})`),h(null),await E()}catch(b){const k=b instanceof te?`${b.code}: ${b.message}`:b.message;v(`上传失败:${k}`)}finally{w(!1)}}}function T(b,k){e(_=>_.map(C=>C.pluginRunId===b?{...C,...k}:C))}async function ce(b){T(b.pluginRunId,{localState:"stopping"});try{await Wt("",b.pluginRunId),T(b.pluginRunId,{localState:"error",message:"已停止"})}catch(k){T(b.pluginRunId,{localState:"error",message:k.message})}}async function R(b){T(b.pluginRunId,{localState:"removing"});try{await Yt("",b.pluginRunId),e(k=>k.filter(_=>_.pluginRunId!==b.pluginRunId))}catch(k){T(b.pluginRunId,{localState:"error",message:k.message})}}return p("div",{className:"page",children:[c("h1",{children:"插件管理"}),g&&c("div",{className:"error-line",children:g}),p("section",{className:"card",children:[c("h2",{children:"按包名安装"}),p("div",{className:"upload-row",children:[c("input",{type:"text",placeholder:"@scope/my-audit-plugin",value:t,onChange:b=>n(b.target.value),onKeyDown:b=>{b.key==="Enter"&&j()}}),c("button",{onClick:()=>void j(),disabled:!t.trim()||s,children:s?"安装中…":"安装"})]}),o&&c("div",{className:"ok-line",children:o}),p("div",{className:"muted",children:["npm 包名(如需指定版本:",c("span",{className:"mono",children:"pkg@1.2.3"}),"),或本地 ",c("span",{className:"mono",children:"file:./插件文件夹"})]})]}),p("section",{className:"card",children:[c("h2",{children:"或上传 zip"}),p("div",{className:"upload-row",children:[c("input",{type:"file",accept:".zip,application/zip",onChange:b=>{var k;return h(((k=b.target.files)==null?void 0:k[0])??null)}}),c("button",{onClick:()=>void xe(),disabled:!u||m,children:m?"上传中…":"上传"})]}),S&&c("div",{className:"ok-line",children:S})]}),p("section",{className:"card",children:[c("h2",{children:"插件列表"}),r.length===0&&c("div",{className:"muted",children:"暂无插件"}),p("table",{className:"table",children:[c("thead",{children:p("tr",{children:[c("th",{children:"ID"}),c("th",{children:"版本"}),c("th",{children:"标题"}),c("th",{children:"状态"}),c("th",{children:"pluginRunId"}),c("th",{children:"操作"})]})}),c("tbody",{children:r.map(b=>p("tr",{children:[c("td",{className:"mono",children:b.id}),c("td",{children:b.manifest.version}),c("td",{children:b.manifest.title}),p("td",{children:[c("span",{className:`status ${b.localState==="running"?"ok":"warn"}`,children:br[b.localState]}),b.message&&c("div",{className:"muted",children:b.message})]}),c("td",{className:"mono",children:b.pluginRunId}),p("td",{className:"actions",children:[c("button",{className:"ghost",disabled:b.localState==="stopping"||b.localState==="removing",onClick:()=>void ce(b),children:"停止"}),c("button",{className:"ghost danger",disabled:b.localState==="stopping"||b.localState==="removing",onClick:()=>void R(b),children:"移除"})]})]},b.pluginRunId))})]})]})]})}class vr extends qe{constructor(){super(...arguments);l(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}render(){var t;return this.state.error?p("div",{className:"error-box",children:[c("h2",{children:"页面出错了"}),c("pre",{children:String(((t=this.state.error)==null?void 0:t.message)??this.state.error)}),c("button",{onClick:()=>this.setState({error:null}),children:"重试"})]}):this.props.children}}const xr="";function Sr(){const[r,e]=O(null);F(()=>{let a=!1,u;return rr({url:`${location.origin}/ws`}).then(h=>{if(a){h.close();return}u=h,e(h)}).catch(()=>{}),()=>{a=!0,u==null||u.close()}},[]);const t=ut(new Set);F(()=>{if(!r)return;const a=r;let u=!1;async function h(S,y){try{if(u||t.current.has(y))return;if(a.pages.getSnapshot().find(v=>v.pluginId===S)){t.current.add(y);return}await er(a,{id:S}),t.current.add(y)}catch(g){const v=g instanceof Error?`${g.message}
15
- ${g.stack}`:String(g);console.warn(`[plugin-sync] failed to install browser half for ${S} (${y}): ${v}`)}}async function m(){var y;let S;try{S=await Te(xr)}catch{return}if(!u)for(const g of S)(y=g.manifest.halves.browser)!=null&&y.entry&&h(g.id,g.pluginRunId)}m();const w=a.onSnapshot(S=>{var y;for(const g of S.plugins)(y=g.manifest.halves.browser)!=null&&y.entry&&h(g.id,g.pluginRunId)});return()=>{u=!0,w()}},[r]);const n=re(a=>{const u=r==null?void 0:r.pages;return u?u.subscribe(a):()=>{}},[r]),s=re(()=>{const a=r==null?void 0:r.pages;return a?a.getSnapshot():Or},[r]),i=ht(n,s),o=ee(()=>i.filter(a=>typeof a.Component=="function"),[i]);return p("div",{className:"layout",children:[p("aside",{className:"sidebar",children:[c("div",{className:"brand",children:"API Audit"}),p("nav",{children:[c(le,{to:"/audit",className:"nav-item",children:"审计记录"}),c(le,{to:"/replay",className:"nav-item",children:"API 重放"}),c(le,{to:"/plugins",className:"nav-item",children:"插件管理"}),o.length>0&&c("div",{className:"nav-sep",children:"插件页面"}),o.map(a=>c(le,{to:a.path,className:"nav-item",children:a.title},`${a.pluginId}:${a.path}`))]}),c("div",{className:"sidebar-foot",children:c(Er,{runtime:r})})]}),c("main",{className:"main",children:c(vr,{children:c(ft,{fallback:c("div",{className:"empty",children:"加载中…"}),children:p(gt,{children:[c(z,{path:"/",element:c(yt,{to:"/audit",replace:!0})}),c(z,{path:"/audit",element:c(lr,{runtime:r})}),c(z,{path:"/replay",element:c(pr,{runtime:r})}),c(z,{path:"/plugins",element:c(wr,{})}),o.map(a=>c(z,{path:a.path,element:c(kr,{title:a.title,children:c(a.Component,{})})},`${a.pluginId}:${a.path}`)),c(z,{path:"*",element:c(Rr,{})})]})})})})]})}const Or=Object.freeze([]);class kr extends qe{constructor(){super(...arguments);l(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}render(){var t;return this.state.error?p("div",{className:"error-box",children:[p("h2",{children:["插件页面出错:",this.props.title]}),c("pre",{children:String(((t=this.state.error)==null?void 0:t.message)??this.state.error)}),c("button",{onClick:()=>this.setState({error:null}),children:"重试"})]}):this.props.children}}function Er({runtime:r}){const[e,t]=O("connecting");F(()=>{if(!r)return;const s=()=>t(r.status());s();const i=window.setInterval(s,500);return()=>window.clearInterval(i)},[r]);const n=e==="connected";return c("span",{className:`ws-badge ${n?"on":""}`,children:n?"已连接":"连接中…"})}function Rr(){return p("div",{className:"empty",children:[c("h2",{children:"404"}),c("p",{children:"页面不存在。"})]})}const it=document.getElementById("root");if(!it)throw new Error("missing #root");pt(it).render(c(dt,{children:c(mt,{children:c(Sr,{})})}));
16
- //# sourceMappingURL=index-DfSekBjO.js.map