@jonathanleelx/meddle 0.4.5 → 0.5.0-beta.1

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.
Files changed (29) hide show
  1. package/dist/core/remote-access.d.ts +1 -0
  2. package/dist/core/remote-access.d.ts.map +1 -1
  3. package/dist/core/remote-access.js +27 -2
  4. package/dist/core/remote-access.js.map +1 -1
  5. package/package.json +1 -1
  6. package/web/dist/assets/{checkbox-BQRlRJrm.js → checkbox-7NvTvLBs.js} +1 -1
  7. package/web/dist/assets/{code-fixer-Dlsw62Ke.js → code-fixer-DoYxwBWb.js} +1 -1
  8. package/web/dist/assets/{detail-panel-DElQDCRS.js → detail-panel-vwvLpmzz.js} +1 -1
  9. package/web/dist/assets/{global-panel-shell-CNR5hbEs.js → global-panel-shell-Dq8vMdMI.js} +1 -1
  10. package/web/dist/assets/{health-panel-BKOR7Y8q.js → health-panel-CVQcuI1d.js} +1 -1
  11. package/web/dist/assets/{index-otwkxfTB.js → index-DJ5BnqEk.js} +2 -2
  12. package/web/dist/assets/index-PcoCj3ST.css +2 -0
  13. package/web/dist/assets/mobile-proxy-panel-DMJRIDMK.js +8 -0
  14. package/web/dist/assets/{mock-config-COLWxz2R.js → mock-config-BTdHrudB.js} +1 -1
  15. package/web/dist/assets/{mock-editor-panel-Bbkaq85N.js → mock-editor-panel-ztb1w__0.js} +1 -1
  16. package/web/dist/assets/{monaco-editor-DYWjOxN7.js → monaco-editor-CHNSCVe0.js} +1 -1
  17. package/web/dist/assets/{plugin-code-editor-hGuv6MC3.js → plugin-code-editor-C_h_-lKr.js} +1 -1
  18. package/web/dist/assets/{plugin-config-DkZcWYNN.js → plugin-config-B5tDGCq-.js} +1 -1
  19. package/web/dist/assets/{plugin-generator-B217-RVa.js → plugin-generator-CojssHdE.js} +1 -1
  20. package/web/dist/assets/{plugin-test-dialog-oWz-o_XG.js → plugin-test-dialog-iWeHVCGW.js} +1 -1
  21. package/web/dist/assets/{route-preview-Dv6AYYUb.js → route-preview-BecifYSe.js} +1 -1
  22. package/web/dist/assets/{rule-ai-assistant-panel-DsJ1sdXd.js → rule-ai-assistant-panel-LWDaNQKt.js} +1 -1
  23. package/web/dist/assets/rule-config-CLte-qNZ.js +15 -0
  24. package/web/dist/assets/{select-DSwkV3cG.js → select-C5thwxXQ.js} +1 -1
  25. package/web/dist/assets/{settings-panel-DSSxRrV9.js → settings-panel-Bx_qz1RQ.js} +1 -1
  26. package/web/dist/index.html +2 -2
  27. package/web/dist/assets/index-DQtOwhpd.css +0 -2
  28. package/web/dist/assets/mobile-proxy-panel-m88i11PB.js +0 -8
  29. package/web/dist/assets/rule-config-DuUVPgbM.js +0 -15
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/global-panel-shell-CNR5hbEs.js","assets/button-BTToMaBW.js","assets/dist-C6eaYCUo.js","assets/dist-CxdY_A67.js","assets/es2015-CfXu88Y7.js","assets/dist-Bb9TeEub.js","assets/dist-C5nMErq8.js","assets/circle-alert-Q8cZk9Rv.js","assets/ai-config-store-DQXVJVn_.js","assets/rule-config-DuUVPgbM.js","assets/checkbox-BQRlRJrm.js","assets/dist-D5Dj17P8.js","assets/plus-tVxSydJ8.js","assets/table-DymgLlcc.js","assets/syntax-highlight-BHsSDUha.js","assets/file-system-access-DK7FI6pN.js","assets/rule-config-CHpVij2M.css","assets/mock-config-COLWxz2R.js","assets/monaco-editor-DYWjOxN7.js","assets/chevron-down-CPngAx4M.js","assets/chevron-right-V1DGIDbL.js","assets/code-5_eJ_XpJ.js","assets/wand-sparkles-wkul5vje.js","assets/code-fixer-Dlsw62Ke.js","assets/plugin-config-DkZcWYNN.js","assets/select-DSwkV3cG.js","assets/dist-DZJ9SMlJ.js","assets/dist-Cn0y0IRn.js","assets/switch-C-Xk56TK.js","assets/refresh-cw-CG3HaiQT.js","assets/zap-Djo4cgux.js","assets/detail-panel-DElQDCRS.js","assets/body-diff-view-D7dCWajG.js","assets/arrow-right-B4Mrlj2-.js","assets/circle-x-C9USji_R.js","assets/server-Cpj4KNwN.js","assets/copy-BYjq1hdN.js","assets/shield-check-OqUmVLQt.js","assets/clipboard-Dz6MgwV-.js","assets/settings-panel-DSSxRrV9.js","assets/rotate-ccw-CAYM6Vv0.js","assets/smartphone-DKeDuJTU.js","assets/alert-Bve02Ufr.js","assets/plugin-generator-B217-RVa.js","assets/textarea-vuxJwU0x.js","assets/plugin-code-editor-hGuv6MC3.js","assets/pencil-line-Cqe41E4h.js","assets/plugin-test-dialog-oWz-o_XG.js","assets/rule-ai-assistant-panel-DsJ1sdXd.js","assets/mock-editor-panel-Bbkaq85N.js","assets/route-preview-Dv6AYYUb.js","assets/mobile-proxy-panel-m88i11PB.js","assets/wifi-D9M35Ajj.js","assets/health-panel-BKOR7Y8q.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/global-panel-shell-Dq8vMdMI.js","assets/button-BTToMaBW.js","assets/dist-C6eaYCUo.js","assets/dist-CxdY_A67.js","assets/es2015-CfXu88Y7.js","assets/dist-Bb9TeEub.js","assets/dist-C5nMErq8.js","assets/circle-alert-Q8cZk9Rv.js","assets/ai-config-store-DQXVJVn_.js","assets/rule-config-CLte-qNZ.js","assets/checkbox-7NvTvLBs.js","assets/dist-D5Dj17P8.js","assets/plus-tVxSydJ8.js","assets/table-DymgLlcc.js","assets/syntax-highlight-BHsSDUha.js","assets/file-system-access-DK7FI6pN.js","assets/rule-config-CHpVij2M.css","assets/mock-config-BTdHrudB.js","assets/monaco-editor-CHNSCVe0.js","assets/chevron-down-CPngAx4M.js","assets/chevron-right-V1DGIDbL.js","assets/code-5_eJ_XpJ.js","assets/wand-sparkles-wkul5vje.js","assets/code-fixer-DoYxwBWb.js","assets/plugin-config-B5tDGCq-.js","assets/select-C5thwxXQ.js","assets/dist-DZJ9SMlJ.js","assets/dist-Cn0y0IRn.js","assets/switch-C-Xk56TK.js","assets/refresh-cw-CG3HaiQT.js","assets/zap-Djo4cgux.js","assets/detail-panel-vwvLpmzz.js","assets/body-diff-view-D7dCWajG.js","assets/arrow-right-B4Mrlj2-.js","assets/circle-x-C9USji_R.js","assets/server-Cpj4KNwN.js","assets/copy-BYjq1hdN.js","assets/shield-check-OqUmVLQt.js","assets/clipboard-Dz6MgwV-.js","assets/settings-panel-Bx_qz1RQ.js","assets/rotate-ccw-CAYM6Vv0.js","assets/smartphone-DKeDuJTU.js","assets/alert-Bve02Ufr.js","assets/plugin-generator-CojssHdE.js","assets/textarea-vuxJwU0x.js","assets/plugin-code-editor-C_h_-lKr.js","assets/pencil-line-Cqe41E4h.js","assets/plugin-test-dialog-iWeHVCGW.js","assets/rule-ai-assistant-panel-LWDaNQKt.js","assets/mock-editor-panel-ztb1w__0.js","assets/route-preview-BecifYSe.js","assets/mobile-proxy-panel-DMJRIDMK.js","assets/wifi-D9M35Ajj.js","assets/health-panel-CVQcuI1d.js"])))=>i.map(i=>d[i]);
2
2
  import{a as e,c as t,d as n,f as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./button-BTToMaBW.js";import{a as d,c as f,n as p,o as m,r as h,t as g}from"./dist-C6eaYCUo.js";import{a as _,c as v,i as y,n as b,o as x,r as S,s as C,t as ee}from"./dist-CxdY_A67.js";import{t as te}from"./dist-Cn0y0IRn.js";import{t as ne}from"./dist-C5nMErq8.js";import{n as re,t as w}from"./dist-Bb9TeEub.js";import"./es2015-CfXu88Y7.js";import{n as ie,r as ae,t as oe}from"./dist-B8XUKgXe.js";import{t as se}from"./dist-DZJ9SMlJ.js";import{c as ce,o as le,r as T}from"./ai-config-store-DQXVJVn_.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var E=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,w());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}var S=!1,C=-1,ee=5,te=-1;function ne(){return g?!0:!(e.unstable_now()-te<ee)}function re(){if(g=!1,S){var t=e.unstable_now();te=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ne());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&oe(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?w():S=!1}}}var w;if(typeof y==`function`)w=function(){y(re)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=re,w=function(){ae.postMessage(null)}}else w=function(){_(re,0)};function oe(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):ee=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,oe(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,w()))),r},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),ue=n(((e,t)=>{t.exports=E()})),de=n((e=>{var t=ue(),n=u(),r=f();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),ee=Symbol.for(`react.suspense`),te=Symbol.for(`react.suspense_list`),ne=Symbol.for(`react.memo`),re=Symbol.for(`react.lazy`),w=Symbol.for(`react.activity`),ie=Symbol.for(`react.memo_cache_sentinel`),ae=Symbol.iterator;function oe(e){return typeof e!=`object`||!e?null:(e=ae&&e[ae]||e[`@@iterator`],typeof e==`function`?e:null)}var se=Symbol.for(`react.client.reference`);function ce(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===se?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case ee:return`Suspense`;case te:return`SuspenseList`;case w:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ne:return t=e.displayName||null,t===null?ce(e.type)||`Memo`:t;case re:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var le=Array.isArray,T=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de={pending:!1,data:null,method:null,action:null},fe=[],pe=-1;function D(e){return{current:e}}function me(e){0>pe||(e.current=fe[pe],fe[pe]=null,pe--)}function O(e,t){pe++,fe[pe]=e.current,e.current=t}var he=D(null),k=D(null),ge=D(null),_e=D(null);function ve(e,t){switch(O(ge,t),O(k,e),O(he,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}me(he),O(he,e)}function A(){me(he),me(k),me(ge)}function j(e){e.memoizedState!==null&&O(_e,e);var t=he.current,n=Hd(t,e.type);t!==n&&(O(k,e),O(he,n))}function ye(e){k.current===e&&(me(he),me(k)),_e.current===e&&(me(_e),Qf._currentValue=de)}var be,xe;function Se(e){if(be===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);be=t&&t[1]||``,xe=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+be+e+xe}var Ce=!1;function we(e,t){if(!e||Ce)return``;Ce=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -15,4 +15,4 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
15
15
  color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function Ya(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var Xa=(e,t)=>Math.abs(e-t)<1.01,Za=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},Qa=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},$a=e=>e,eo=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},to=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Qa(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Qa(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},no={passive:!0},ro=typeof window>`u`?!0:`onscrollend`in window,io=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&ro?()=>void 0:Za(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,no);let l=e.options.useScrollendEvent&&ro;return l&&n.addEventListener(`scrollend`,c,no),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},ao=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},oo=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},so=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{this._measureElement(e.target,e)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:$a,rangeExtractor:eo,onChange:()=>{},measureElement:ao,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Ja(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=Ja(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=Ja(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Ja(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?lo({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Ja(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this._measureElement=(e,t)=>{let n=this.indexFromElement(e),r=this.measurementsCache[n];if(!r)return;let i=r.key,a=this.elementsCache.get(i);a!==e&&(a&&this.observer.unobserve(a),this.observer.observe(e),this.elementsCache.set(i,e)),e.isConnected&&this.resizeItem(n,this.options.measureElement(e,t,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}this._measureElement(e,void 0)},this.getVirtualItems=Ja(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return Ya(t[co(0,t.length-1,e=>Ya(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.measurementsCache[e];if(!n)return;let r=this.getSize(),i=this.getScrollOffset();if(t===`auto`)if(n.end>=i+r-this.options.scrollPaddingEnd)t=`end`;else if(n.start<=i+this.options.scrollPaddingStart)t=`start`;else return[i,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,n.size),t]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(e,{align:t=`start`,behavior:n}={})=>{n===`smooth`&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(e,t),{adjustments:void 0,behavior:n})},this.scrollToIndex=(e,{align:t=`auto`,behavior:n}={})=>{n===`smooth`&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),e=Math.max(0,Math.min(e,this.options.count-1)),this.currentScrollToIndex=e;let r=0,i=t=>{if(!this.targetWindow)return;let r=this.getOffsetForIndex(e,t);if(!r){console.warn(`Failed to get offset for index:`,e);return}let[i,o]=r;this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{let t=()=>{if(this.currentScrollToIndex!==e)return;let t=this.getScrollOffset(),n=this.getOffsetForIndex(e,o);if(!n){console.warn(`Failed to get offset for index:`,e);return}Xa(n[0],t)||a(o)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(t):t()})},a=t=>{this.targetWindow&&this.currentScrollToIndex===e&&(r++,r<10?this.targetWindow.requestAnimationFrame(()=>i(t)):console.warn(`Failed to scroll to index ${e} after 10 attempts.`))};i(t)},this.scrollBy=(e,{behavior:t}={})=>{t===`smooth`&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adjustments:void 0,behavior:t})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}},co=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function lo({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=co(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var uo=typeof document<`u`?D.useLayoutEffect:D.useEffect;function fo({useFlushSync:e=!0,...t}){let n=D.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,pe.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=D.useState(()=>new so(r));return i.setOptions(r),uo(()=>i._didMount(),[]),uo(()=>i._willUpdate()),i}function R(e){return fo({observeElementRect:to,observeElementOffset:io,scrollToFn:oo,...e})}function po({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`empty`,className:a(`flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-lg border-dashed p-6 text-center text-balance md:p-12`,e),...t})}function mo({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`empty-header`,className:a(`flex max-w-sm flex-col items-center gap-2 text-center`,e),...t})}var z=t(`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,icon:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-6`}},defaultVariants:{variant:`default`}});function B({className:e,variant:t=`default`,...n}){return(0,N.jsx)(`div`,{"data-slot":`empty-icon`,"data-variant":t,className:a(z({variant:t,className:e})),...n})}function V({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`empty-title`,className:a(`text-lg font-medium tracking-tight`,e),...t})}function ho({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`empty-description`,className:a(`text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function go({className:e,children:t,...n}){return(0,N.jsxs)(Ii,{"data-slot":`scroll-area`,className:a(`relative`,e),...n,children:[(0,N.jsx)(Li,{"data-slot":`scroll-area-viewport`,className:`focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1`,children:t}),(0,N.jsx)(_o,{}),(0,N.jsx)(Ri,{})]})}function _o({className:e,orientation:t=`vertical`,...n}){return(0,N.jsx)(ui,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:a(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,N.jsx)(xi,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}function vo(e){let t=`${e.applicationName||``} ${e.applicationProcess||``}`.toLowerCase();return t.includes(`chrome`)||t.includes(`chromium`)?{icon:fr,name:`chrome`,className:`bg-blue-500/12 text-blue-600 dark:text-blue-400`}:t.includes(`safari`)?{icon:vr,name:`safari`,className:`bg-sky-500/12 text-sky-600 dark:text-sky-400`}:t.includes(`edge`)?{icon:Pr,name:`edge`,className:`bg-teal-500/12 text-teal-600 dark:text-teal-400`}:t.includes(`firefox`)?{icon:Cr,name:`firefox`,className:`bg-orange-500/12 text-orange-600 dark:text-orange-400`}:t.includes(`opera`)?{icon:mr,name:`opera`,className:`bg-red-500/12 text-red-600 dark:text-red-400`}:t.includes(`duckduckgo`)?{icon:Wr,name:`duckduckgo`,className:`bg-orange-500/12 text-orange-600 dark:text-orange-400`}:t.includes(`webview`)?{icon:Fr,name:`webview`,className:`bg-violet-500/12 text-violet-600 dark:text-violet-400`}:t.includes(`samsung internet`)?{icon:yr,name:`samsung-internet`,className:`bg-indigo-500/12 text-indigo-600 dark:text-indigo-400`}:t.includes(`curl`)||t.includes(`wget`)||t.includes(`terminal`)?{icon:Yr,name:`terminal`,className:`bg-slate-500/12 text-slate-600 dark:text-slate-300`}:t.includes(`node`)?{icon:Er,name:`node`,className:`bg-green-500/12 text-green-600 dark:text-green-400`}:e.applicationIdentitySource===`user-agent`?{icon:yr,name:`browser`,className:`bg-cyan-500/12 text-cyan-600 dark:text-cyan-400`}:{icon:ar,name:`application`,className:`bg-muted text-muted-foreground`}}function yo({record:e,className:t,compact:n=!1}){let r=vo(e),i=r.icon;return(0,N.jsx)(`span`,{"aria-hidden":`true`,"data-application-icon":r.name,className:a(`inline-flex shrink-0 items-center justify-center rounded-md`,n?`size-5`:`size-6`,r.className,t),children:(0,N.jsx)(i,{className:n?`size-3.5`:`size-4`,strokeWidth:2})})}var bo=`h-[18px] px-[5px] py-0 font-mono text-[10px] leading-none`,xo=`flex h-9 shrink-0 items-center px-2 leading-none`,H=36,So=H;function Co(e){switch(e.toUpperCase()){case`POST`:return`default`;case`DELETE`:return`destructive`;case`GET`:return`secondary`;default:return`outline`}}function wo(e){return e>=400?`destructive`:e>=300?`secondary`:e>=200?`default`:`outline`}function To(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Eo(e){return e.clientType===`local`?e.clientName||`本机`:e.clientType===`plugin`?e.clientName||`插件`:e.clientType===`remote`?e.clientName||`远程`:`未标记`}function Do(e){return e.clientType===`plugin`?`default`:e.clientType===`remote`?`secondary`:`outline`}function Oo(e){return[e.applicationName,e.applicationIdentitySource===`local-process`?`识别方式: 本机进程`:e.applicationIdentitySource===`user-agent`?`识别方式: User-Agent 推断`:e.applicationIdentitySource===`client-reported`?`识别方式: 客户端上报`:void 0,e.applicationIdentityConfidence?`可信度: ${e.applicationIdentityConfidence===`high`?`高`:e.applicationIdentityConfidence===`medium`?`中`:`低`}`:void 0,e.applicationProcess&&e.applicationProcess!==e.applicationName?`进程: ${e.applicationProcess}`:void 0,e.applicationPid?`PID: ${e.applicationPid}`:void 0,e.applicationBundleId?`Bundle ID: ${e.applicationBundleId}`:void 0,e.applicationPath].filter(Boolean).join(`
16
16
  `)}function ko(e){return e.applicationIdentitySource===`user-agent`}function Ao({records:e,selectedRecordId:t,onSelect:n,autoScroll:r}){let i=(0,D.useRef)(null),o=(0,D.useRef)(e.length),s=(0,D.useRef)(!0),[c,u]=(0,D.useState)(`desc`),d=R({count:e.length,getScrollElement:()=>i.current?.querySelector(`[data-radix-scroll-area-viewport]`),estimateSize:()=>H,overscan:10}),f=d.getVirtualItems();return(0,D.useEffect)(()=>{let e=i.current?.querySelector(`[data-radix-scroll-area-viewport]`);if(!(e instanceof HTMLElement))return;let t=()=>{s.current=c===`desc`?e.scrollTop<=So:e.scrollHeight-e.scrollTop-e.clientHeight<=So};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[c]),(0,D.useEffect)(()=>{if(r&&s.current&&e.length>o.current){let e=i.current?.querySelector(`[data-radix-scroll-area-viewport]`);e&&requestAnimationFrame(()=>{e.scrollTop=c===`desc`?0:e.scrollHeight})}o.current=e.length},[e.length,r,c]),(0,N.jsx)(`div`,{className:`relative flex min-h-0 flex-1 overflow-x-auto`,children:(0,N.jsxs)(`div`,{className:`flex min-h-0 min-w-[1080px] flex-1 flex-col`,children:[(0,N.jsxs)(`div`,{className:`z-10 flex h-9 shrink-0 items-stretch border-b bg-muted/70 text-xs font-medium backdrop-blur supports-[backdrop-filter]:bg-muted/90`,children:[(0,N.jsx)(`div`,{className:a(xo,`w-16`),children:`方法`}),(0,N.jsx)(`div`,{className:a(xo,`w-14`),children:`状态`}),(0,N.jsx)(`div`,{className:a(xo,`w-24`),children:`来源`}),(0,N.jsx)(`div`,{className:a(xo,`w-44`),children:`应用`}),(0,N.jsx)(`div`,{className:a(xo,`min-w-[200px] flex-1`),children:`源地址`}),(0,N.jsx)(`div`,{className:a(xo,`min-w-[200px] flex-1`),children:`目标地址`}),(0,N.jsx)(`div`,{className:a(xo,`w-14`),children:`协议`}),(0,N.jsx)(`div`,{className:a(xo,`w-16`),children:`耗时`}),(0,N.jsx)(`div`,{className:a(xo,`w-28`),children:(0,N.jsxs)(l,{variant:`ghost`,size:`xs`,onClick:()=>{let e=c===`desc`?`asc`:`desc`;s.current=e===`desc`,u(e),d.scrollToOffset(0)},className:`-ml-2 h-7`,title:c===`desc`?`倒序(新→旧),点击切换为正序`:`正序(旧→新),点击切换为倒序`,children:[`时间`,c===`desc`?(0,N.jsx)(or,{"data-icon":`inline-end`}):(0,N.jsx)(sr,{"data-icon":`inline-end`})]})})]}),(0,N.jsx)(go,{className:`min-h-0 flex-1`,ref:i,children:(0,N.jsx)(`div`,{className:`min-w-full`,children:e.length===0?(0,N.jsx)(po,{className:`min-h-72 border-0`,children:(0,N.jsxs)(mo,{children:[(0,N.jsx)(B,{variant:`icon`,children:(0,N.jsx)(Dr,{})}),(0,N.jsx)(V,{children:`暂无请求记录`}),(0,N.jsx)(ho,{children:`打开需要调试的页面后,请求会实时显示在这里。`})]})}):(0,N.jsx)(`div`,{style:{height:`${d.getTotalSize()}px`,position:`relative`},children:f.map(r=>{let i=e[c===`desc`?r.index:e.length-1-r.index];return(0,N.jsxs)(`div`,{className:a(`absolute flex w-full items-center cursor-pointer border-b border-border/50 text-xs transition-colors`,t===i.id?`bg-accent`:`hover:bg-muted/50`),onClick:()=>i.id!=null&&n(i.id),style:{height:`${r.size}px`,transform:`translateY(${r.start}px)`},children:[(0,N.jsx)(`div`,{className:`flex h-full w-16 items-center px-2`,children:(0,N.jsx)(L,{variant:Co(i.method),className:bo,children:i.method})}),(0,N.jsx)(`div`,{className:`flex h-full w-14 items-center px-2`,children:i.statusCode!=null&&(0,N.jsx)(L,{variant:wo(i.statusCode),className:bo,children:i.statusCode})}),(0,N.jsx)(`div`,{className:`flex h-full w-24 items-center truncate px-2`,title:[i.clientName,i.clientIp].filter(Boolean).join(` · `)||`未标记来源`,children:(0,N.jsx)(L,{variant:Do(i),className:a(bo,`max-w-full`),children:(0,N.jsx)(`span`,{className:`truncate`,children:Eo(i)})})}),(0,N.jsx)(`div`,{className:`flex h-full w-44 items-center gap-1.5 truncate px-2`,title:Oo(i)||(i.clientType===`plugin`?``:`未识别到请求应用`),children:i.applicationName?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(yo,{record:i,compact:!0}),(0,N.jsx)(`span`,{className:`truncate`,children:i.applicationName}),ko(i)&&(0,N.jsx)(`span`,{className:`shrink-0 rounded border px-1 text-[9px] leading-4 text-muted-foreground`,children:`推断`})]}):(0,N.jsx)(`span`,{className:`truncate text-muted-foreground`,children:i.clientType===`plugin`?`—`:`未知应用`})}),(0,N.jsxs)(`div`,{className:`flex h-full min-w-[200px] flex-1 items-center truncate px-2 font-mono`,title:i.source,children:[i._fromPluginTest&&(0,N.jsx)(L,{variant:`secondary`,className:a(bo,`mr-1`),children:`插件测试`}),i.source]}),(0,N.jsxs)(`div`,{className:`flex h-full min-w-[200px] flex-1 items-center truncate px-2 font-mono`,title:i.target,children:[i.mock&&(0,N.jsx)(L,{className:a(bo,`mr-1`),children:`MOCK`}),i.target]}),(0,N.jsx)(`div`,{className:`flex h-full w-14 items-center px-2`,children:i.protocol&&(0,N.jsx)(L,{variant:i.protocol===`h2`?`secondary`:`outline`,className:bo,children:i.protocol})}),(0,N.jsx)(`div`,{className:`flex h-full w-16 items-center px-2 font-mono text-[10px] text-muted-foreground`,children:i.duration!=null&&To(i.duration)}),(0,N.jsx)(`div`,{className:`flex h-full w-28 items-center px-2 font-mono text-muted-foreground`,children:i.time})]},i.id??r.index)})})})})]})})}var U=Symbol.for(`react.lazy`),jo=D.use;function Mo(e){return typeof e==`object`&&!!e&&`then`in e}function No(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===U&&`_payload`in e&&Mo(e._payload)}function Po(e){let t=Fo(e),n=D.forwardRef((e,n)=>{let{children:r,...i}=e;No(r)&&typeof jo==`function`&&(r=jo(r._payload));let a=D.Children.toArray(r),o=a.find(Lo);if(o){let e=o.props.children,r=a.map(t=>t===o?D.Children.count(e)>1?D.Children.only(null):D.isValidElement(e)?e.props.children:null:t);return(0,N.jsx)(t,{...i,ref:n,children:D.isValidElement(e)?D.cloneElement(e,void 0,r):null})}return(0,N.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Fo(e){let t=D.forwardRef((e,t)=>{let{children:n,...r}=e;if(No(n)&&typeof jo==`function`&&(n=jo(n._payload)),D.isValidElement(n)){let e=zo(n),i=Ro(r,n.props);return n.type!==D.Fragment&&(i.ref=t?o(t,e):e),D.cloneElement(n,i)}return D.Children.count(n)>1?D.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Io=Symbol(`radix.slottable`);function Lo(e){return D.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Io}function Ro(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function zo(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Bo=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Po(`Primitive.${t}`),r=D.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,N.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Vo=`Label`,Ho=D.forwardRef((e,t)=>(0,N.jsx)(Bo.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Ho.displayName=Vo;var Uo=Ho,Wo=D.forwardRef(({className:e,...t},n)=>(0,N.jsx)(Uo,{ref:n,className:a(`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,e),...t}));Wo.displayName=Uo.displayName;var Go=400;function Ko({...e}){return(0,N.jsx)(x,{"data-slot":`sheet`,...e})}function qo({...e}){return(0,N.jsx)(_,{"data-slot":`sheet-portal`,...e})}function Jo({className:e,...t}){return(0,N.jsx)(y,{"data-slot":`sheet-overlay`,className:a(`sheet-glass-overlay data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[90]`,e),...t})}function Yo({className:e,children:t,side:n=`right`,showCloseButton:r=!0,resizable:i=!1,defaultWidth:o=700,minWidth:s=Go,maxWidth:c=1600,storageKey:l=`sheet-width`,...u}){let d=`sheet-w-${l}`,[f,p]=D.useState(()=>{if(typeof window>`u`||!i)return o;let e=localStorage.getItem(d);if(e){let t=parseInt(e,10);if(!isNaN(t))return Math.max(s,Math.min(c,t))}return o}),[m,h]=D.useState(!1),g=D.useRef(null);D.useEffect(()=>{if(!i||!m)return;let e=e=>{let t=window.innerWidth,r=n===`left`?e.clientX:t-e.clientX,i=Math.min(c,t*.92),a=Math.max(s,Math.min(i,r));p(a),localStorage.setItem(d,a.toString())},t=()=>{h(!1),document.body.style.cursor=``,document.body.style.userSelect=``};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),document.body.style.cursor=`ew-resize`,document.body.style.userSelect=`none`,()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[m,i,s,c,d,n]);let _=e=>{e.preventDefault(),h(!0)};return(0,N.jsxs)(qo,{children:[(0,N.jsx)(Jo,{}),(0,N.jsxs)(b,{ref:g,"data-slot":`sheet-content`,style:i&&(n===`right`||n===`left`)?{width:`${f}px`,maxWidth:`92vw`}:void 0,className:a(`sheet-glass-content data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-[91] flex flex-col gap-4 transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500`,n===`right`&&!i&&`data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm`,n===`right`&&i&&`data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full border-l`,n===`left`&&!i&&`data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm`,n===`left`&&i&&`data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full border-r`,n===`top`&&`data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b`,n===`bottom`&&`data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t`,e),...u,children:[i&&(n===`right`||n===`left`)&&(0,N.jsx)(`div`,{className:a(`absolute top-0 bottom-0 w-1 cursor-ew-resize transition-colors z-10`,n===`right`?`left-0`:`right-0`,m?`bg-blue-500 w-1`:`hover:bg-blue-400/60`),onMouseDown:_,children:(0,N.jsx)(`div`,{className:a(`absolute top-0 bottom-0 w-5`,n===`right`?`left-0 -translate-x-2`:`right-0 translate-x-2`)})}),t,r&&(0,N.jsxs)(ee,{className:`ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none`,children:[(0,N.jsx)(v,{className:`size-4`}),(0,N.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function Xo({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`sheet-header`,className:a(`sheet-glass-header flex flex-col gap-1.5 border-b p-4`,e),...t})}function Zo({className:e,...t}){return(0,N.jsx)(C,{"data-slot":`sheet-title`,className:a(`text-foreground font-semibold`,e),...t})}function Qo({className:e,...t}){return(0,N.jsx)(S,{"data-slot":`sheet-description`,className:a(`text-muted-foreground text-sm`,e),...t})}function $o({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,N.jsx)(Hi,{"data-slot":`separator`,decorative:n,orientation:t,className:a(`bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}function es(){return`⌘+S / Ctrl+S`}function ts({className:e}){return(0,N.jsx)(`kbd`,{"aria-hidden":`true`,"data-slot":`save-shortcut`,className:a(`pointer-events-none ml-1 rounded border border-current/20 px-1 py-0.5 font-mono text-[10px] font-normal leading-none opacity-70`,e),children:es()})}function ns({children:e,...t}){return(0,N.jsxs)(l,{"aria-keyshortcuts":`Meta+S Control+S`,...t,children:[e,(0,N.jsx)(ts,{})]})}var rs=(0,D.createContext)(null),is={page:100,panel:200,modal:300};function as(e){let t=(0,D.useContext)(rs),n=(0,D.useId)();(0,D.useEffect)(()=>{if(t)return t.register(n),()=>t.unregister(n)},[n,t]),(0,D.useEffect)(()=>{t&&t.update(n,e)},[n,e,t])}function os(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var ss=e=>{switch(e){case`success`:return us;case`info`:return fs;case`warning`:return ds;case`error`:return ps;default:return null}},cs=Array(12).fill(0),ls=({visible:e,className:t})=>D.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},D.createElement(`div`,{className:`sonner-spinner`},cs.map((e,t)=>D.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),us=D.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},D.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),ds=D.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},D.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),fs=D.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},D.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),ps=D.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},D.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),ms=D.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},D.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),D.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),hs=()=>{let[e,t]=D.useState(document.hidden);return D.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},gs=1,_s=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:gs++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],D.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(ys(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!D.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!D.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!D.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!D.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||gs++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},vs=(e,t)=>{let n=t?.id||gs++;return _s.addToast({title:e,...t,id:n}),n},ys=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,bs=vs,xs=Object.assign(bs,{success:_s.success,info:_s.info,warning:_s.warning,error:_s.error,custom:_s.custom,message:_s.message,promise:_s.promise,dismiss:_s.dismiss,loading:_s.loading},{getHistory:()=>_s.toasts,getToasts:()=>_s.getActiveToasts()});os(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function Ss(e){return e.label!==void 0}var Cs=3,ws=`24px`,Ts=`16px`,Es=4e3,Ds=356,Os=14,ks=45,As=200;function js(...e){return e.filter(Boolean).join(` `)}function Ms(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var Ns=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:ee,closeButtonAriaLabel:te=`Close toast`}=e,[ne,re]=D.useState(null),[w,ie]=D.useState(null),[ae,oe]=D.useState(!1),[se,ce]=D.useState(!1),[le,T]=D.useState(!1),[E,ue]=D.useState(!1),[de,fe]=D.useState(!1),[pe,me]=D.useState(0),[O,he]=D.useState(0),k=D.useRef(n.duration||y||Es),ge=D.useRef(null),_e=D.useRef(null),ve=c===0,A=c+1<=o,j=n.type,ye=n.dismissible!==!1,be=n.className||``,xe=n.descriptionClassName||``,Se=D.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),Ce=D.useMemo(()=>n.closeButton??p,[n.closeButton,p]),we=D.useMemo(()=>n.duration||y||Es,[n.duration,y]),Te=D.useRef(0),Ee=D.useRef(0),De=D.useRef(0),Oe=D.useRef(null),[ke,Ae]=b.split(`-`),je=D.useMemo(()=>s.reduce((e,t,n)=>n>=Se?e:e+t.height,0),[s,Se]),Me=hs(),Ne=n.invert||t,Pe=j===`loading`;Ee.current=D.useMemo(()=>Se*x+je,[Se,je]),D.useEffect(()=>{k.current=we},[we]),D.useEffect(()=>{oe(!0)},[]),D.useEffect(()=>{let e=_e.current;if(e){let t=e.getBoundingClientRect().height;return he(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),D.useLayoutEffect(()=>{if(!ae)return;let e=_e.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,he(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[ae,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let Fe=D.useCallback(()=>{ce(!0),me(Ee.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},As)},[n,d,a,Ee]);D.useEffect(()=>{if(n.promise&&j===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||Me?(()=>{if(De.current<Te.current){let e=new Date().getTime()-Te.current;k.current-=e}De.current=new Date().getTime()})():k.current!==1/0&&(Te.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),Fe()},k.current)),()=>clearTimeout(e)},[u,i,n,j,Me,Fe]),D.useEffect(()=>{n.delete&&(Fe(),n.onDismiss==null||n.onDismiss.call(n,n))},[Fe,n.delete]);function Ie(){return ee?.loading?D.createElement(`div`,{className:js(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":j===`loading`},ee.loading):D.createElement(ls,{className:js(C?.loader,n?.classNames?.loader),visible:j===`loading`})}let Le=n.icon||ee?.[j]||ss(j);return D.createElement(`li`,{tabIndex:0,ref:_e,className:js(_,be,C?.toast,n?.classNames?.toast,C?.default,C?.[j],n?.classNames?.[j]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":ae,"data-promise":!!n.promise,"data-swiped":de,"data-removed":se,"data-visible":A,"data-y-position":ke,"data-x-position":Ae,"data-index":c,"data-front":ve,"data-swiping":le,"data-dismissible":ye,"data-type":j,"data-invert":Ne,"data-swipe-out":E,"data-swipe-direction":w,"data-expanded":!!(u||S&&ae),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${se?pe:Ee.current}px`,"--initial-height":S?`auto`:`${O}px`,...m,...n.style},onDragEnd:()=>{T(!1),re(null),Oe.current=null},onPointerDown:e=>{e.button!==2&&(Pe||!ye||(ge.current=new Date,me(Ee.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(T(!0),Oe.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(E||!ye)return;Oe.current=null;let e=Number(_e.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(_e.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-ge.current?.getTime(),i=ne===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=ks||a>.11){me(Ee.current),n.onDismiss==null||n.onDismiss.call(n,n),ie(ne===`x`?e>0?`right`:`left`:t>0?`down`:`up`),Fe(),ue(!0);return}else{var o,s;(o=_e.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=_e.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}fe(!1),T(!1),re(null)},onPointerMove:t=>{var n,r;if(!Oe.current||!ye||window.getSelection()?.toString().length>0)return;let i=t.clientY-Oe.current.y,a=t.clientX-Oe.current.x,o=e.swipeDirections??Ms(b);!ne&&(Math.abs(a)>1||Math.abs(i)>1)&&re(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(ne===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(ne===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&fe(!0),(n=_e.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=_e.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},Ce&&!n.jsx&&j!==`loading`?D.createElement(`button`,{"aria-label":te,"data-disabled":Pe,"data-close-button":!0,onClick:Pe||!ye?()=>{}:()=>{Fe(),n.onDismiss==null||n.onDismiss.call(n,n)},className:js(C?.closeButton,n?.classNames?.closeButton)},ee?.close??ms):null,(j||n.icon||n.promise)&&n.icon!==null&&(ee?.[j]!==null||n.icon)?D.createElement(`div`,{"data-icon":``,className:js(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Ie():null,n.type===`loading`?null:Le):null,D.createElement(`div`,{"data-content":``,className:js(C?.content,n?.classNames?.content)},D.createElement(`div`,{"data-title":``,className:js(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?D.createElement(`div`,{"data-description":``,className:js(v,xe,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),D.isValidElement(n.cancel)?n.cancel:n.cancel&&Ss(n.cancel)?D.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{Ss(n.cancel)&&ye&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),Fe())},className:js(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,D.isValidElement(n.action)?n.action:n.action&&Ss(n.action)?D.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{Ss(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&Fe())},className:js(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function Ps(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function Fs(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?Ts:ws;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var Is=D.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=Cs,toastOptions:g,dir:_=Ps(),gap:v=Os,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=D.useState([]),C=D.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),ee=D.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[te,ne]=D.useState([]),[re,w]=D.useState(!1),[ie,ae]=D.useState(!1),[oe,se]=D.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),ce=D.useRef(null),le=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),T=D.useRef(null),E=D.useRef(!1),ue=D.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||_s.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return D.useEffect(()=>_s.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{pe.flushSync(()=>{S(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[x]),D.useEffect(()=>{if(d!==`system`){se(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?se(`dark`):se(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{se(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{se(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),D.useEffect(()=>{x.length<=1&&w(!1)},[x]),D.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;w(!0),(t=ce.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===ce.current||ce.current?.contains(document.activeElement))&&w(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),D.useEffect(()=>{if(ce.current)return()=>{T.current&&(T.current.focus({preventScroll:!0}),T.current=null,E.current=!1)}},[ce.current]),D.createElement(`section`,{ref:t,"aria-label":`${b} ${le}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},ee.map((t,n)=>{let[i,a]=t.split(`-`);return C.length?D.createElement(`ol`,{key:t,dir:_===`auto`?Ps():_,tabIndex:-1,ref:ce,className:c,"data-sonner-toaster":!0,"data-sonner-theme":oe,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${te[0]?.height||0}px`,"--width":`${Ds}px`,"--gap":`${v}px`,...m,...Fs(l,u)},onBlur:e=>{E.current&&!e.currentTarget.contains(e.relatedTarget)&&(E.current=!1,T.current&&=(T.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||E.current||(E.current=!0,T.current=e.relatedTarget)},onMouseEnter:()=>w(!0),onMouseMove:()=>w(!0),onMouseLeave:()=>{ie||w(!1)},onDragEnd:()=>w(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||ae(!0)},onPointerUp:()=>ae(!1)},C.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>D.createElement(Ns,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:ie,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:ue,toasts:C.filter(e=>e.position==n.position),heights:te.filter(e=>e.position==n.position),setHeights:ne,expandByDefault:o,gap:v,expanded:re,swipeDirections:e.swipeDirections}))):null}))}),Ls=3e3;function Rs(e){return{...e,duration:Ls}}var zs={success(e,t){return xs.success(e,Rs(t))},info(e,t){return xs.info(e,Rs(t))},warning(e,t){return xs.warning(e,Rs(t))},error(e,t){return xs.error(e,Rs(t))},dismiss:xs.dismiss};function Bs(){let e=T(),t=le(e);return e.enabled?t?(0,N.jsxs)(L,{variant:`outline`,children:[`AI: `,e.provider===`openai`?`OpenAI`:`Anthropic`]}):(0,N.jsx)(L,{variant:`secondary`,children:`AI: 未配置`}):(0,N.jsx)(L,{variant:`outline`,className:`text-xs`,children:`AI: 未启用`})}var Vs={theme:`system`,accentColor:`auto`,fontSize:`medium`,detailBodySizeKB:256,aiConfig:{enabled:!1,provider:`openai`,apiKey:``,baseUrl:``,model:``,models:[]},mocksFilePath:``,pluginMode:`off`,clientAliases:{}},Hs=null;async function Us(){try{let e=await fetch(`/api/settings`);if(e.ok){let t=await e.json(),n={...Vs,...t,accentColor:t.accentColor||Vs.accentColor,aiConfig:{...Vs.aiConfig,...t.aiConfig}};return Hs=n,ce(n.aiConfig),n}}catch(e){console.error(`加载设置失败:`,e)}let e=qs();return e?(Hs=e,Ws(e).catch(console.error),e):(Hs={...Vs},Hs)}async function Ws(e){try{if((await fetch(`/api/settings`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).ok)Hs=e;else throw Error(`保存设置失败`)}catch(e){throw console.error(`保存设置失败:`,e),e}}function Gs(){return Hs||{...Vs}}async function Ks(e){let t=Gs();(!t||!t.aiConfig?.apiKey)&&(t=await Us()),await Ws({...t,...e})}function qs(){try{let e=localStorage.getItem(`theme-storage`),t=localStorage.getItem(`font-size`),n=localStorage.getItem(`meddle-ai-config`);if(!e&&!t&&!n)return null;let r={...Vs};if(e)try{r.theme=JSON.parse(e).theme||`system`}catch{}if(t&&(r.fontSize=t),n)try{r.aiConfig=JSON.parse(n)}catch{}return console.log(`已从 localStorage 迁移设置`),r}catch(e){return console.error(`迁移设置失败:`,e),null}}var Js=D.createContext(void 0);function Ys(e){if(!e)return 1;let t={small:.9,medium:1,large:1.1};if(e in t)return t[e];let n=Number(e);return!Number.isFinite(n)||n<=0?1:n>10?n/100:n}function Xs(){return typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function Zs({children:e,defaultTheme:t=`system`}){let[n,r]=D.useState(()=>typeof window>`u`?t:Gs().theme||t),[i,a]=D.useState(()=>typeof window>`u`?`auto`:Gs().accentColor||`auto`),[o,s]=D.useState(!1),c=D.useCallback(e=>{window.document.documentElement.style.setProperty(`--app-scale`,String(e))},[]);D.useEffect(()=>{Us().then(e=>{r(e.theme||t),a(e.accentColor||`auto`),c(Ys(e.fontSize)),s(!0)}).catch(()=>{s(!0)})},[t,c]);let l=n===`system`?Xs():n;D.useEffect(()=>{if(!o)return;let e=window.document.documentElement;e.classList.remove(`light`,`dark`),e.classList.add(l),e.dataset.accent=i,Ks({theme:n,accentColor:i}).catch(console.error)},[n,l,i,o]),D.useEffect(()=>{if(n!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>{let e=window.document.documentElement;e.classList.remove(`light`,`dark`),e.classList.add(Xs())};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[n]);let u=D.useCallback(e=>{r(e)},[]),d=D.useCallback(e=>{a(e)},[]),f=D.useCallback(()=>{r(e=>e===`light`?`dark`:e===`dark`?`system`:`light`)},[]),p=D.useMemo(()=>({theme:n,resolvedTheme:l,accentColor:i,setTheme:u,setAccentColor:d,toggleTheme:f,setZoom:c}),[n,l,i,u,d,f,c]);return(0,N.jsx)(Js.Provider,{value:p,children:e})}function Qs(){let e=D.useContext(Js);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e}function $s(){let[e,t]=(0,D.useState)(!1),[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(null),[o,s]=(0,D.useState)(null),c=(0,D.useRef)(null),u=(0,D.useCallback)(async()=>{r(!0),s(null);try{let e=await fetch(`/api/sessions`,{cache:`no-store`});if(!e.ok)throw Error(`HTTP ${e.status}`);a(await e.json())}catch(e){s(e.message)}finally{r(!1)}},[]);(0,D.useEffect)(()=>{if(!e)return;u();let n=e=>{c.current&&!c.current.contains(e.target)&&t(!1)},r=e=>{e.key===`Escape`&&t(!1)};return document.addEventListener(`mousedown`,n),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,n),document.removeEventListener(`keydown`,r)}},[e,u]);let d=i?.current.isDefault?`Default`:i?.current.id??`Session`,f=e=>{window.open(`http://127.0.0.1:${e}/`,`_blank`,`noopener`)},p=i?.sessions.filter(e=>e.id!==i.current.id)??[];return(0,N.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,N.jsxs)(l,{variant:`outline`,size:`sm`,onClick:()=>t(e=>!e),title:`切换 session`,children:[(0,N.jsx)(lr,{"data-icon":`inline-start`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:d})]}),e&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-full z-50 mt-1 w-80 rounded-md border bg-popover p-1 text-popover-foreground shadow-md`,children:[(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-xs font-medium text-muted-foreground`,children:`当前 session`}),i&&(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm px-2 py-1.5`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(dr,{className:`size-3.5 text-primary shrink-0`}),(0,N.jsx)(`span`,{className:`truncate text-sm`,children:i.current.isDefault?`Default`:i.current.id})]}),(0,N.jsxs)(L,{variant:`secondary`,className:`shrink-0`,children:[`:`,i.current.port]})]}),(0,N.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-xs font-medium text-muted-foreground`,children:`其他 session`}),n&&(0,N.jsxs)(`div`,{className:`space-y-1 px-1 py-1`,children:[(0,N.jsx)(za,{className:`h-8 w-full`}),(0,N.jsx)(za,{className:`h-8 w-full`})]}),o&&(0,N.jsxs)(`div`,{className:`px-2 py-2 text-xs text-destructive`,children:[`加载失败: `,o]}),!n&&!o&&p.length===0&&(0,N.jsxs)(`div`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:[`暂无其他 session。用 `,(0,N.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`meddle session create`}),` 创建。`]}),!n&&!o&&p.map(e=>(0,N.jsxs)(`button`,{onClick:()=>f(e.port),className:`flex w-full items-center justify-between gap-2 rounded-sm px-2 py-1.5 text-left hover:bg-accent`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${e.alive?`bg-green-500`:`bg-red-500`}`,title:e.alive?`running`:`orphaned`}),(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`div`,{className:`truncate text-sm`,children:e.label||e.id}),(0,N.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.id})]})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,N.jsxs)(L,{variant:`secondary`,children:[`:`,e.port]}),(0,N.jsx)(br,{className:`size-3.5 text-muted-foreground`})]})]},e.id))]})]})}function ec({onSettingsClick:e,onCommandClick:t,onMobileProxyClick:n}){let{theme:r,toggleTheme:i}=Qs();return(0,N.jsx)(`header`,{className:`sticky top-0 z-40 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80`,children:(0,N.jsxs)(`div`,{className:`mx-auto flex h-14 w-full max-w-[1600px] items-center gap-3 px-4 lg:px-6`,children:[(0,N.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground shadow-sm`,children:(0,N.jsx)(Tr,{className:`size-4`})}),(0,N.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,N.jsx)(`h1`,{className:`truncate text-sm font-semibold tracking-tight`,children:`Meddle`}),(0,N.jsx)(`span`,{className:`hidden text-xs text-muted-foreground sm:inline`,children:`开发代理工具`})]}),(0,N.jsx)(`div`,{className:`flex-1`}),(0,N.jsx)(Bs,{}),(0,N.jsx)($s,{}),(0,N.jsxs)(l,{variant:`outline`,size:`sm`,onClick:n,title:`手机代理与二维码`,children:[(0,N.jsx)(Vr,{"data-icon":`inline-start`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`手机代理`})]}),(0,N.jsxs)(l,{variant:`outline`,size:`sm`,onClick:t,className:`hidden sm:inline-flex`,title:`打开全局操作面板`,children:[(0,N.jsx)(_r,{"data-icon":`inline-start`}),`操作`,(0,N.jsx)(L,{variant:`secondary`,children:`⌘K`})]}),(0,N.jsx)(l,{variant:`ghost`,size:`icon-sm`,onClick:e,"aria-label":`设置`,children:(0,N.jsx)(Gr,{})}),(0,N.jsx)(l,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":`当前主题: ${r},点击切换`,title:`主题: ${r===`system`?`跟随系统`:r===`light`?`浅色`:`深色`}`,children:r===`light`?(0,N.jsx)(Mr,{}):r===`dark`?(0,N.jsx)(Jr,{}):(0,N.jsx)(jr,{})})]})})}var tc=1e4;function nc(e,t,n){if(t.length===0)return e;let r=Math.max(0,n);if(r===0)return[];let i=Math.min(t.length,r),a=Math.min(e.length,r-i),o=Array(i+a);for(let e=0;e<i;e++)o[e]=t[t.length-1-e];for(let t=0;t<a;t++)o[i+t]=e[t];return o}function rc(e,t,n){let r=Math.max(0,n);if(r===0)return[];if(e.length===0)return t.length<=r?t:t.slice(0,r);let i=[],a=new Set,o=e=>{if(!(i.length>=r)){if(typeof e.id==`number`){if(a.has(e.id))return;a.add(e.id)}i.push(e)}};for(let t of e)o(t);for(let e of t)o(e);return i}function ic(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`number`&&typeof t.method==`string`&&typeof t.source==`string`&&typeof t.target==`string`&&typeof t.time==`string`}function ac(e=tc){let[t,n]=(0,D.useState)([]),[r,i]=(0,D.useState)(null),[a,o]=(0,D.useState)(null),[s,c]=(0,D.useState)(!1),[l,u]=(0,D.useState)(null),d=(0,D.useRef)(e),f=(0,D.useRef)(null),p=(0,D.useRef)([]);return(0,D.useEffect)(()=>{d.current=e},[e]),(0,D.useEffect)(()=>{let e=new AbortController;return fetch(`/api/logs`,{signal:e.signal}).then(e=>e.json()).then(e=>{n(t=>rc(t,e,d.current))}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||console.error(e)}),()=>e.abort()},[]),(0,D.useEffect)(()=>{let e=null,t=null,r=0,i=()=>{t=null;let e=p.current;e.length!==0&&(p.current=[],n(t=>nc(t,e,d.current)))},a=()=>{t||=setTimeout(i,50)},o=()=>{let t=location.protocol===`https:`?`wss://`:`ws://`,n=new WebSocket(t+location.host+`/ws`);n.addEventListener(`message`,e=>{try{let t=JSON.parse(e.data);if(t&&t.type===`mocksUpdated`){window.dispatchEvent(new CustomEvent(`mocksUpdated`,{detail:t.rules??[]}));return}if(!ic(t))return;p.current.push(t),a()}catch(e){console.error(`Failed to parse WebSocket message:`,e)}}),n.addEventListener(`error`,e=>{console.error(`WebSocket error:`,e)}),n.addEventListener(`close`,()=>{if(console.log(`WebSocket closed`),f.current=null,r<10){let t=Math.min(1e3*2**r,3e4);console.log(`Reconnecting in ${t}ms (attempt ${r+1}/10)`),e=setTimeout(()=>{r++,o()},t)}else console.error(`Max reconnection attempts reached`)}),n.addEventListener(`open`,()=>{console.log(`WebSocket connected`),r=0}),f.current=n};return o(),()=>{e&&clearTimeout(e),t&&clearTimeout(t),p.current=[],f.current&&=(f.current.close(),null)}},[]),{records:t,selectedRecordId:r,recordDetail:a,detailLoading:s,detailError:l,fetchDetail:(0,D.useCallback)(async e=>{i(e),c(!0),o(null),u(null);try{let t=await fetch(`/api/logs/${e}`),n=await t.json();if(!t.ok)throw Error(n?.error||`加载详情失败 (${t.status})`);o(n)}catch(e){u(e instanceof Error?e.message:`加载详情失败`),console.error(`Failed to fetch detail:`,e)}finally{c(!1)}},[]),closeDetail:(0,D.useCallback)(()=>{i(null),o(null)},[]),clearRecords:(0,D.useCallback)(()=>{p.current=[],n([])},[]),replayRequest:(0,D.useCallback)(async e=>{let t=await(await fetch(`/api/replay/${e}`,{method:`POST`})).json();if(t.status===`success`)return t;throw Error(t.error||`重放请求失败`)},[])}}var oc=/^(?:\d{1,3}\.){3}\d{1,3}$/,sc=/^(?:[0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}(?:%[\w.-]+)?$/,cc=/^[A-Za-z0-9_.-]+$/;function lc(e){return oc.test(e)||sc.test(e)}function uc(e){return e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function dc(e){let t=e.indexOf(`#`);return(t>=0?e.slice(0,t):e).trim()}function fc(e){let t=dc(e);if(!t)return null;let[n,...r]=t.split(/\s+/).filter(Boolean);return!n||r.length===0||!lc(n)||!r.every(e=>cc.test(e))?null:`${r.join(` `)} ${uc(n)}`}function pc(e){let t=!1,n=e.split(/\r?\n/).map(e=>{let n=fc(e);return n?(t=!0,n):e}).join(`
17
17
  `);return t?n:e}function mc(e){return e.split(/\r?\n/).flatMap((e,t)=>{let n=e.trim();return!n||n.startsWith(`#`)||(n.startsWith(`//`)?n.slice(2).trim():n).split(/\s+/).filter(Boolean).filter(e=>!e.startsWith(`!`)).length>=2?[]:[{line:t+1,content:e}]})}function hc(e){return e.split(/\r?\n/).filter(e=>e.trim()).flatMap(e=>{let t=e.trim();if(t.startsWith(`#`))return[];let n=!0;t.startsWith(`//`)?(n=!1,e=t.slice(2).trim()):e=t;let r=e.split(/\s+/).filter(Boolean);if(r.length<2)return[];let i=[],a=r.filter(e=>e.startsWith(`!`)?(i.push(e.slice(1)),!1):!0);if(a.length<2)return[];let o=a[a.length-1];return a.slice(0,-1).map(e=>({rule:e,target:o,enabled:n,exclusions:[...i]}))})}function gc(e){return e.map(e=>{let t=e.enabled?``:`//`,n=(e.exclusions||[]).map(e=>`!${e}`).join(` `);return`${t}${(n?[e.rule,n,e.target]:[e.rule,e.target]).join(` `)}`}).join(`
18
- `)}function _c(){let[e,t]=(0,D.useState)([]),[n,r]=(0,D.useState)([]),[i,a]=(0,D.useState)(null),o=(0,D.useCallback)(async()=>{try{let e=await(await fetch(`/api/rule-files`)).json(),t=Array.isArray(e)?e:[];return r(t),t}catch(e){return console.error(`Failed to fetch rule files:`,e),[]}},[]),s=(0,D.useCallback)(async e=>(await fetch(`/api/rule-files/${encodeURIComponent(e)}/content`)).text(),[]),c=(0,D.useCallback)(async e=>{try{t(hc(await s(e))),a(e)}catch(e){console.error(`Failed to fetch file content:`,e)}},[s]),l=(0,D.useCallback)(async(e,t)=>{try{return(await(await fetch(`/api/rule-files/${encodeURIComponent(e)}/content`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:t})})).json()).status===`success`}catch(e){return console.error(`Failed to save file content:`,e),!1}},[]);return{rules:e,setRules:t,ruleFiles:n,activeFileName:i,fetchRuleFiles:o,fetchFileContent:c,fetchRuleFileRawContent:s,saveRuleFileRawContent:l,saveFileContent:(0,D.useCallback)(async(e,t)=>l(e,gc(t)),[l]),createRuleFile:(0,D.useCallback)(async(e,t=``)=>{let n=e.trim();try{let e=await(await fetch(`/api/rule-files`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n,content:t,enabled:!0})})).json();return e.status===`success`?(await o(),{success:!0}):{success:!1,error:e.error}}catch(e){return(await o()).some(e=>e.name===n)?{success:!0}:{success:!1,error:e instanceof Error?e.message:`创建规则文件失败`}}},[o]),toggleRuleFile:(0,D.useCallback)(async(e,t)=>{try{return(await(await fetch(`/api/rule-files/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})})).json()).status===`success`?(await o(),!0):!1}catch(e){return console.error(`Failed to toggle rule file:`,e),!1}},[o]),renameRuleFile:(0,D.useCallback)(async(e,t)=>{let n=t.trim();if(!n)return{success:!1,error:`规则文件名称不能为空`};try{let t=await(await fetch(`/api/rule-files/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({newName:n})})).json();if(t.status!==`success`)return{success:!1,error:t.error||`重命名失败`};let r=typeof t.name==`string`?t.name:n;return i===e&&a(r),await o(),{success:!0,name:r}}catch(e){return{success:!1,error:e instanceof Error?e.message:`重命名失败`}}},[i,o]),deleteRuleFile:(0,D.useCallback)(async e=>{try{return(await(await fetch(`/api/rule-files/${encodeURIComponent(e)}`,{method:`DELETE`})).json()).status===`success`?(i===e&&(a(null),t([])),await o(),!0):!1}catch(e){return console.error(`Failed to delete rule file:`,e),!1}},[o,i])}}var vc=`mocksUpdated`;function yc(e){let t=new Map;for(let n of e)t.set(n.id,n);return Array.from(t.values()).sort((e,t)=>e.id-t.id)}function bc(e,t){return yc([...e.filter(e=>e.id!==t.id),t])}function xc(){let[e,t]=(0,D.useState)([]),n=(0,D.useCallback)(async()=>{try{let e=await(await fetch(`/api/mocks`,{cache:`no-store`})).json();t(yc(Array.isArray(e)?e:[]))}catch(e){console.error(`Failed to fetch mocks:`,e)}},[]);return(0,D.useEffect)(()=>{n()},[n]),(0,D.useEffect)(()=>{let e=e=>{let n=e;t(yc(Array.isArray(n.detail)?n.detail:[]))};return window.addEventListener(vc,e),()=>window.removeEventListener(vc,e)},[]),{mockRules:e,fetchMocks:n,createMock:(0,D.useCallback)(async e=>{try{let n=await(await fetch(`/api/mocks`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();return n.status===`success`?(t(e=>bc(e,n.rule)),n.rule):null}catch(e){return console.error(`Failed to create mock:`,e),null}},[]),updateMock:(0,D.useCallback)(async(e,n)=>{let r;t(t=>(r=t.find(t=>t.id===e),r?bc(t,{...r,...n}):t));try{let i=await(await fetch(`/api/mocks/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})).json();if(i.status===`success`)return t(e=>bc(e,i.rule)),!0;if(r){let e=r;t(t=>bc(t,e))}return!1}catch(e){if(console.error(`Failed to update mock:`,e),r){let e=r;t(t=>bc(t,e))}return!1}},[]),deleteMock:(0,D.useCallback)(async e=>{try{return(await(await fetch(`/api/mocks/${e}`,{method:`DELETE`})).json()).status===`success`?(t(t=>t.filter(t=>t.id!==e)),!0):!1}catch(e){return console.error(`Failed to delete mock:`,e),!1}},[])}}function Sc(){let[e,t]=(0,D.useState)([]),[n,r]=(0,D.useState)(`off`),[i,a]=(0,D.useState)([]),[o,s]=(0,D.useState)({allowAll:!1,trusted:[]}),c=(0,D.useCallback)(async()=>{try{let e=await(await fetch(`/api/plugins`)).json();r(e.mode||`off`),t(e.plugins||[])}catch(e){console.error(`Failed to fetch plugins:`,e)}},[]);return{plugins:e,pluginMode:n,switchPluginMode:(0,D.useCallback)(async e=>{try{(await fetch(`/api/pipeline/mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})})).ok&&r(e)}catch(e){console.error(`Failed to switch plugin mode:`,e)}},[]),thirdPartyPlugins:i,thirdPartySecurity:o,fetchPlugins:c,startPlugin:(0,D.useCallback)(async e=>{try{await fetch(`/api/plugins/${e}/start`,{method:`POST`})}catch(e){console.error(`Failed to start plugin:`,e)}},[]),stopPlugin:(0,D.useCallback)(async e=>{try{await fetch(`/api/plugins/${e}/stop`,{method:`POST`})}catch(e){console.error(`Failed to stop plugin:`,e)}},[]),togglePlugin:(0,D.useCallback)(async(e,n)=>{try{(await fetch(`/api/plugins/${encodeURIComponent(e)}/toggle`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n})})).ok&&t(t=>t.map(t=>t.id===e?{...t,state:n?`running`:`disabled`}:t))}catch(e){console.error(`Failed to toggle plugin:`,e)}},[]),fetchThirdPartyPlugins:(0,D.useCallback)(async()=>{try{let e=await fetch(`/api/plugins/third-party`),t=e.headers.get(`content-type`)||``;if(!e.ok||!t.includes(`application/json`)){a([]),s({allowAll:!1,trusted:[]});return}let n=await e.json();a(n.plugins||[]),s(n.security||{allowAll:!1,trusted:[]})}catch(e){console.error(`Failed to fetch third-party plugins:`,e)}},[]),loadThirdPartyPlugin:(0,D.useCallback)(async e=>{try{await fetch(`/api/plugins/third-party/load`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})})}catch(e){console.error(`Failed to load third-party plugin:`,e)}},[]),unloadThirdPartyPlugin:(0,D.useCallback)(async e=>{try{await fetch(`/api/plugins/third-party/${e}/unload`,{method:`POST`})}catch(e){console.error(`Failed to unload third-party plugin:`,e)}},[])}}function Cc(){let[e,t]=(0,D.useState)(tc),n=ac(e),r=_c(),i=xc(),a=Sc();return{records:n.records,selectedRecordId:n.selectedRecordId,recordDetail:n.recordDetail,detailLoading:n.detailLoading,detailError:n.detailError,fetchDetail:n.fetchDetail,closeDetail:n.closeDetail,clearRecords:n.clearRecords,replayRequest:n.replayRequest,maxRecords:e,setMaxRecords:t,rules:r.rules,setRules:r.setRules,ruleFiles:r.ruleFiles,activeFileName:r.activeFileName,fetchRuleFiles:r.fetchRuleFiles,fetchFileContent:r.fetchFileContent,fetchRuleFileRawContent:r.fetchRuleFileRawContent,saveRuleFileRawContent:r.saveRuleFileRawContent,saveFileContent:r.saveFileContent,createRuleFile:r.createRuleFile,toggleRuleFile:r.toggleRuleFile,renameRuleFile:r.renameRuleFile,deleteRuleFile:r.deleteRuleFile,mockRules:i.mockRules,fetchMocks:i.fetchMocks,createMock:i.createMock,updateMock:i.updateMock,deleteMock:i.deleteMock,plugins:a.plugins,pluginMode:a.pluginMode,switchPluginMode:a.switchPluginMode,thirdPartyPlugins:a.thirdPartyPlugins,thirdPartySecurity:a.thirdPartySecurity,fetchPlugins:a.fetchPlugins,startPlugin:a.startPlugin,stopPlugin:a.stopPlugin,togglePlugin:a.togglePlugin,fetchThirdPartyPlugins:a.fetchThirdPartyPlugins,loadThirdPartyPlugin:a.loadThirdPartyPlugin,unloadThirdPartyPlugin:a.unloadThirdPartyPlugin}}function wc(e){let t=typeof e.source==`string`?e.source:``,n=typeof e.method==`string`?e.method:``,r=t.toLowerCase(),i=n.toUpperCase();if(!r)return`other`;if(r.startsWith(`ws://`)||r.startsWith(`wss://`))return`websocket`;if(i!==`GET`||r.includes(`/api/`)||r.includes(`.json`))return`fetch`;let a=r.split(`?`)[0].split(`#`)[0].split(`/`),o=a[a.length-1]||``,s=o.includes(`.`)&&o.split(`.`).pop()||``;return[`html`,`htm`,`php`,`asp`,`aspx`,`jsp`].includes(s)||!s&&i===`GET`?`doc`:s===`css`?`css`:[`js`,`mjs`,`jsx`,`ts`,`tsx`].includes(s)?`js`:[`woff`,`woff2`,`ttf`,`otf`,`eot`].includes(s)?`font`:[`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`,`ico`,`bmp`].includes(s)?`img`:[`mp4`,`webm`,`ogg`,`mp3`,`wav`,`flac`,`aac`,`m4a`].includes(s)?`media`:[`manifest`,`webmanifest`].includes(s)?`manifest`:s===`wasm`?`wasm`:`other`}var Tc=new WeakMap;function Ec(e){let t=Tc.get(e);if(t)return t;let n=typeof e.method==`string`?e.method:``,r=typeof e.source==`string`?e.source:``,i=typeof e.target==`string`?e.target:``,a=typeof e.time==`string`?e.time:``,o=e.clientType||``,s=e.clientIp||``,c=e.clientName||``,l=e.applicationName||``,u=e.applicationProcess||``,d=e.applicationBundleId||``,f=e.applicationPid?.toString()||``,p=e.applicationIdentitySource||``,m=e.applicationIdentityConfidence||``,h=r;try{h=new URL(r).hostname}catch{}let g={methodUpper:n.toUpperCase(),statusCode:e.statusCode,statusText:e.statusCode?.toString()||``,sourceLower:r.toLowerCase(),domainLower:h.toLowerCase(),clientLower:`${o} ${c} ${s}`.toLowerCase(),clientIpLower:s.toLowerCase(),applicationLower:`${l} ${u} ${d} ${f} ${p} ${m}`.toLowerCase(),haystack:`${n} ${r} ${i} ${a} ${o} ${s} ${c} ${l} ${u} ${d} ${f} ${p} ${m}`.toLowerCase(),resourceType:wc(e)};return Tc.set(e,g),g}function Dc(e){let[t,n]=(0,D.useState)(``),[r,i]=(0,D.useState)(`all`),[a,o]=(0,D.useState)(`all`),s=(0,D.useDeferredValue)(t);return{filterText:t,setFilterText:n,resourceTypeFilter:r,setResourceTypeFilter:i,clientSourceFilter:a,setClientSourceFilter:o,filteredRecords:(0,D.useMemo)(()=>{let t=s.trim();if(!t&&r===`all`&&a===`all`)return e;let n=t.split(/\s+/).filter(Boolean),i=[];for(let t of e){if(a!==`all`&&t.clientType!==a)continue;let e=Ec(t);r!==`all`&&e.resourceType!==r||n.every(t=>{let n=t.startsWith(`-`)&&t.length>1,r=n?t.slice(1):t,i=r.toLowerCase(),a=!1;if(i.startsWith(`method:`))a=e.methodUpper===r.slice(7).toUpperCase();else if(i.startsWith(`status:`)){let t=i.slice(7);if(!e.statusCode)a=!1;else if(t.includes(`x`)){let n=t.replace(/x/gi,``);a=e.statusText.startsWith(n)}else a=e.statusText===t}else a=i.startsWith(`domain:`)?e.domainLower.includes(i.slice(7))||e.sourceLower.includes(i.slice(7)):i.startsWith(`client:`)?e.clientLower.includes(i.slice(7)):i.startsWith(`ip:`)?e.clientIpLower.includes(i.slice(3)):i.startsWith(`app:`)?e.applicationLower.includes(i.slice(4)):Oc(i,e.haystack);return n?!a:a})&&i.push(t)}return i},[e,s,r,a])}}function Oc(e,t){if(t.includes(e))return!0;let n=0;for(let r=0;r<t.length&&n<e.length;r++)e[n]===t[r]&&n++;return n===e.length}var kc=[`content-length`,`content-encoding`,`connection`,`date`,`etag`,`last-modified`,`server`];function Ac(e){if(!e)return{};let t={};return Object.entries(e).forEach(([e,n])=>{kc.includes(e.toLowerCase())||(t[e]=n)}),t}function jc(e){let t=e.match(/^\(truncated, \d+ bytes\)\n/);return t?e.substring(t[0].length):e}function Mc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Nc(e){let t=Ac(e.responseHeaders),n=jc(e.responseBody);return{urlPattern:Mc(e.source),body:n,statusCode:e.statusCode,headers:t,name:`从日志创建`,method:`*`,enabled:!0}}var Pc=(0,D.createContext)(null);function Fc(e){(0,D.useEffect)(()=>{let t=t=>{t.isComposing||t.key.toLowerCase()===`k`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e())};return window.addEventListener(`keydown`,t,{capture:!0}),()=>window.removeEventListener(`keydown`,t,{capture:!0})},[e])}var Ic=(0,D.lazy)(()=>k(()=>import(`./global-panel-shell-CNR5hbEs.js`).then(e=>({default:e.GlobalPanelShell})),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),Lc=class extends D.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`Global panel failed to render`,e,t)}render(){return this.state.error?(0,N.jsx)(`div`,{className:`fixed inset-0 z-[82] flex items-center justify-center bg-background/80 p-6 backdrop-blur-sm`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg border bg-card p-5 shadow-xl`,children:[(0,N.jsx)(`h2`,{className:`font-semibold`,children:`面板加载失败`}),(0,N.jsx)(`p`,{className:`mt-2 break-words text-sm text-destructive`,children:this.state.error.message}),(0,N.jsx)(`button`,{type:`button`,className:`mt-4 rounded-md border px-3 py-1.5 text-sm`,onClick:this.props.onClose,children:`关闭面板`})]})}):this.props.children}};function W({children:e,commands:t,renderPanel:n}){let[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)([]),s=(0,D.useCallback)(()=>{o([]),i(!0)},[]),c=(0,D.useCallback)(e=>{o([e]),i(!0)},[]),l=(0,D.useCallback)(e=>{o(t=>[...t,e]),i(!0)},[]),u=(0,D.useCallback)(()=>{o(e=>e.slice(0,-1))},[]),d=(0,D.useCallback)(()=>{i(!1),o([])},[]);Fc(s),(0,D.useEffect)(()=>{let e=()=>s(),t=e=>{let t=e.detail;t?.id&&c(t)};return window.addEventListener(`global-panel:open-command`,e),window.addEventListener(`global-panel:open-panel`,t),()=>{window.removeEventListener(`global-panel:open-command`,e),window.removeEventListener(`global-panel:open-panel`,t)}},[s,c]);let f=a.length>0?a[a.length-1]:null,p=(0,D.useMemo)(()=>({open:r,stack:a,currentRoute:f,openCommand:s,openPanel:c,pushPanel:l,back:u,close:d}),[u,d,f,r,s,c,l,a]),m=typeof t==`function`?t(p):t;return(0,N.jsxs)(Pc.Provider,{value:p,children:[e,r&&(0,N.jsx)(Lc,{onClose:d,children:(0,N.jsx)(D.Suspense,{fallback:null,children:(0,N.jsx)(Ic,{commands:m,renderPanel:e=>n(e,p)})})},f?.id||`command`)]})}var Rc=(0,D.lazy)(()=>k(()=>import(`./rule-config-DuUVPgbM.js`).then(e=>({default:e.RuleConfig})),__vite__mapDeps([9,1,2,10,6,11,3,4,5,12,13,14,15,16]))),zc=(0,D.lazy)(()=>k(()=>import(`./mock-config-COLWxz2R.js`).then(e=>({default:e.MockConfig})),__vite__mapDeps([17,1,18,2,10,6,11,4,5,19,20,21,12,22,13,8,23,14,15]))),Bc=(0,D.lazy)(()=>k(()=>import(`./plugin-config-DkZcWYNN.js`).then(e=>({default:e.PluginConfig})),__vite__mapDeps([24,1,25,26,2,27,4,5,11,19,28,29,30,13]))),Vc=(0,D.lazy)(()=>k(()=>import(`./detail-panel-DElQDCRS.js`).then(e=>({default:e.DetailPanel})),__vite__mapDeps([31,1,2,4,5,32,33,19,20,34,35,36,37,22,14,38]))),Hc=(0,D.lazy)(()=>k(()=>import(`./settings-panel-DSSxRrV9.js`).then(e=>({default:e.SettingsPanel})),__vite__mapDeps([39,1,25,26,2,27,4,5,11,19,28,7,34,12,29,40,41,42,8]))),Uc=(0,D.lazy)(()=>k(()=>import(`./plugin-generator-B217-RVa.js`).then(e=>({default:e.PluginGenerator})),__vite__mapDeps([43,1,2,4,5,34,21,36,22,44,8]))),Wc=(0,D.lazy)(()=>k(()=>import(`./plugin-code-editor-hGuv6MC3.js`).then(e=>({default:e.PluginCodeEditor})),__vite__mapDeps([45,1,18,2,4,5,46,40,30,44,8]))),Gc=(0,D.lazy)(()=>k(()=>import(`./plugin-test-dialog-oWz-o_XG.js`).then(e=>({default:e.PluginTestDialog})),__vite__mapDeps([47,1,18,2,4,5,32,33,7,34,46,29,22,44,8]))),Kc=(0,D.lazy)(()=>k(()=>import(`./rule-ai-assistant-panel-DsJ1sdXd.js`).then(e=>({default:e.RuleAiAssistantPanel})),__vite__mapDeps([48,1,22,42,44,8]))),qc=(0,D.lazy)(()=>k(()=>import(`./mock-editor-panel-Bbkaq85N.js`).then(e=>({default:e.MockEditorPanel})),__vite__mapDeps([49,1,18,2,10,6,11,21,22,44,8,23,14]))),Jc=(0,D.lazy)(()=>k(()=>import(`./route-preview-Dv6AYYUb.js`).then(e=>({default:e.RoutePreview})),__vite__mapDeps([50,1,33]))),Yc=(0,D.lazy)(()=>k(()=>import(`./mobile-proxy-panel-m88i11PB.js`).then(e=>({default:e.MobileProxyPanel})),__vite__mapDeps([51,1,2,36,29,37,41,52,42,38]))),Xc=(0,D.lazy)(()=>k(()=>import(`./health-panel-BKOR7Y8q.js`).then(e=>({default:e.HealthPanel})),__vite__mapDeps([53,1,2,28,11,34,35,29,37,52,42,13])));function Zc(){return(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 p-6`,"aria-label":`加载中`,children:[(0,N.jsx)(za,{className:`h-5 w-32`}),(0,N.jsx)(za,{className:`h-9 w-full`}),(0,N.jsx)(za,{className:`h-64 w-full`})]})}function Qc(){let e=Cc(),t=e.fetchPlugins,n=Dt(),r=wt(),{filterText:i,setFilterText:a,resourceTypeFilter:o,setResourceTypeFilter:s,clientSourceFilter:c,setClientSourceFilter:l,filteredRecords:u}=Dc(e.records),[d,f]=(0,D.useState)(!0),[p,m]=(0,D.useState)(!0),h=(e=>({"/":`logs`,"/logs":`logs`,"/config":`config`,"/mock":`mock`,"/plugins":`plugins`,"/health":`health`})[e]||`logs`)(r.pathname),g=e=>{n({logs:`/logs`,config:`/config`,mock:`/mock`,plugins:`/plugins`,health:`/health`}[e]||`/`)},_=(0,D.useCallback)(t=>{let r=Nc(t);e.closeDetail(),n(`/mock`),window.dispatchEvent(new CustomEvent(`global-panel:open-panel`,{detail:{id:`mock.create`,title:`新建 Mock 规则`,size:`lg`,params:{initialData:r}}}))},[n,e]),v=(0,D.useCallback)(async t=>{let n=await e.replayRequest(t);return e.fetchDetail(n.recordId),n},[e]),y=(0,D.useCallback)(()=>{window.dispatchEvent(new CustomEvent(`global-panel:open-command`))},[]),b=(0,D.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`global-panel:open-panel`,{detail:e}))},[]),x=(0,D.useCallback)(t=>{e.fetchDetail(t),b({id:`request.detail`,title:`请求详情`,size:`lg`})},[b,e]),S=(0,D.useCallback)(t=>[{id:`nav.logs`,title:`打开日志`,section:`导航`,icon:Tr,keywords:[`logs`,`请求`],run:()=>n(`/logs`)},{id:`nav.rules`,title:`打开路由规则`,section:`导航`,icon:Sr,keywords:[`rules`,`config`],run:()=>n(`/config`)},{id:`nav.mock`,title:`打开 Mock`,section:`导航`,icon:hr,keywords:[`mock`],run:()=>n(`/mock`)},{id:`nav.plugins`,title:`打开扩展插件`,section:`导航`,icon:zr,keywords:[`plugin`,`plugins`],run:()=>n(`/plugins`)},{id:`nav.health`,title:`打开运行健康`,section:`导航`,icon:ir,keywords:[`health`,`健康`,`watchdog`,`运行状态`],run:()=>n(`/health`)},{id:`panel.settings`,title:`打开系统设置`,description:`偏好、配置文件、AI 配置`,section:`全局`,icon:Gr,keywords:[`settings`,`配置`,`AI`],closeOnRun:!1,run:()=>t.openPanel({id:`settings`,title:`系统设置`,description:`管理系统偏好、配置和 AI 功能`,size:`lg`})},{id:`panel.mobile-proxy`,title:`打开手机代理二维码`,description:`扫码配置手机代理并安装 HTTPS 根证书`,section:`全局`,icon:Vr,keywords:[`手机`,`二维码`,`QR`,`remote`,`proxy`],closeOnRun:!1,run:()=>t.openPanel({id:`mobile-proxy`,title:`手机代理`,description:`扫描二维码,在手机上配置代理与 HTTPS 证书`,size:`md`})},{id:`logs.focus-filter`,title:`聚焦日志过滤器`,description:`输入 method:GET、domain:example.com 或关键词筛选请求`,section:`日志`,icon:Wr,run:()=>{n(`/logs`),window.setTimeout(()=>document.getElementById(`proxy-log-filter`)?.focus(),50)}},{id:`logs.toggle-recording`,title:d?`暂停记录日志`:`恢复记录日志`,section:`日志`,icon:d?Ir:Rr,run:()=>f(e=>!e)},{id:`logs.clear`,title:`清空日志`,section:`日志`,icon:Zr,danger:!0,confirm:`确定要清空当前日志列表吗?`,run:e.clearRecords},{id:`logs.toggle-auto-scroll`,title:p?`关闭自动滚动`:`开启自动滚动`,section:`日志`,icon:kr,run:()=>m(e=>!e)},...[{value:`all`,label:`全部资源`},{value:`fetch`,label:`Fetch/XHR`},{value:`doc`,label:`Doc`},{value:`css`,label:`CSS`},{value:`js`,label:`JS`},{value:`font`,label:`Font`},{value:`img`,label:`图片`},{value:`media`,label:`媒体`},{value:`manifest`,label:`Manifest`},{value:`websocket`,label:`WebSocket`},{value:`wasm`,label:`Wasm`},{value:`other`,label:`其他资源`}].map(e=>({id:`logs.resource.${e.value}`,title:`日志只看:${e.label}`,section:`日志`,icon:wr,keywords:[`资源类型`,e.value],run:()=>{n(`/logs`),s(e.value)}})),{id:`request.detail`,title:`打开当前请求详情`,section:`日志`,icon:Sr,disabled:e.selectedRecordId==null,disabledReason:`请先在日志表里选择一条请求`,closeOnRun:!1,run:()=>t.openPanel({id:`request.detail`,title:`请求详情`,size:`lg`})},{id:`request.replay`,title:`重放当前请求`,section:`日志`,icon:Hr,disabled:e.selectedRecordId==null,disabledReason:`请先在日志表里选择一条请求`,run:async()=>{e.selectedRecordId!=null&&await v(e.selectedRecordId)}},{id:`rules.ai`,title:`打开 AI 规则助手`,section:`路由规则`,icon:Kr,keywords:[`AI`,`生成规则`,`合并规则`],closeOnRun:!1,run:()=>t.openPanel({id:`rules.ai`,title:`AI 规则助手`,description:`用自然语言生成规则,或安全合并当前配置`,size:`md`})},{id:`rules.preview`,title:`预览 URL 转发结果`,description:`输入 URL,使用当前规则计算真实转发地址`,section:`路由规则`,icon:Wr,keywords:[`URL`,`preview`,`route`,`转发`,`预览`],closeOnRun:!1,run:()=>{t.openPanel({id:`rules.preview`,title:`URL 预览`,description:`使用当前编辑中的规则计算真实转发地址`,size:`md`})}},{id:`rules.add`,title:`添加路由规则`,section:`路由规则`,icon:xr,disabled:!e.activeFileName,disabledReason:`请先选择或创建一个规则文件`,run:()=>{n(`/config`),e.setRules(e=>[{enabled:!0,rule:``,target:``,exclusions:[]},...e])}},{id:`rules.save`,title:`保存当前规则文件`,description:e.activeFileName?`保存 ${e.activeFileName}`:void 0,section:`路由规则`,icon:Ur,disabled:!e.activeFileName,disabledReason:`请先选择一个规则文件`,run:async()=>{e.activeFileName&&(await e.saveFileContent(e.activeFileName,e.rules)?(await e.fetchRuleFiles(),zs.success(`规则保存成功`)):zs.error(`规则保存失败`))}},{id:`rules.create-file`,title:`创建规则文件`,section:`路由规则`,icon:xr,run:async()=>{let t=window.prompt(`请输入规则文件名称`);if(!t?.trim())return;let r=await e.createRuleFile(t.trim());r.success?(n(`/config`),await e.fetchFileContent(t.trim())):r.error&&window.alert(r.error)}},...e.ruleFiles.map(t=>({id:`rules.file.open.${t.name}`,title:`打开规则文件:${t.name}`,description:`${t.ruleCount} 条规则 · ${t.enabled?`已启用`:`未启用`}`,section:`规则文件`,icon:Sr,keywords:[`规则文件`,t.name],run:async()=>{n(`/config`),await e.fetchFileContent(t.name)}})),...e.ruleFiles.map(t=>({id:`rules.file.toggle.${t.name}`,title:`${t.enabled?`禁用`:`启用`}规则文件:${t.name}`,section:`规则文件`,icon:Br,keywords:[`规则文件`,t.name,`启用`,`禁用`],run:async()=>{await e.toggleRuleFile(t.name,!t.enabled)}})),...e.ruleFiles.map(t=>({id:`rules.file.delete.${t.name}`,title:`删除规则文件:${t.name}`,section:`规则文件`,icon:Zr,danger:!0,confirm:`确定要删除规则文件「${t.name}」吗?`,keywords:[`规则文件`,t.name,`删除`],run:async()=>{await e.deleteRuleFile(t.name)}})),{id:`mock.create`,title:`新建 Mock 规则`,section:`Mock`,icon:hr,keywords:[`mock`,`新增规则`],closeOnRun:!1,run:()=>t.openPanel({id:`mock.create`,title:`新建 Mock 规则`,size:`lg`})},...e.mockRules.map(e=>({id:`mock.edit.${e.id}`,title:`编辑 Mock:${e.name||e.urlPattern}`,description:`${e.method||`*`} ${e.urlPattern}`,section:`Mock`,icon:Lr,keywords:[`mock`,e.name,e.urlPattern],closeOnRun:!1,run:()=>t.openPanel({id:`mock.edit`,title:`编辑 Mock:${e.name||e.urlPattern}`,size:`lg`,params:{id:e.id}})})),...e.mockRules.map(t=>({id:`mock.toggle.${t.id}`,title:`${t.enabled?`禁用`:`启用`} Mock:${t.name||t.urlPattern}`,description:`${t.method||`*`} ${t.urlPattern}`,section:`Mock`,icon:Br,keywords:[`mock`,t.name,t.urlPattern,`启用`,`禁用`],run:async()=>{await e.updateMock(t.id,{enabled:!t.enabled}),await e.fetchMocks()}})),...e.mockRules.map(t=>({id:`mock.delete.${t.id}`,title:`删除 Mock:${t.name||t.urlPattern}`,description:`${t.method||`*`} ${t.urlPattern}`,section:`Mock`,icon:Zr,danger:!0,confirm:`确定要删除 Mock「${t.name||t.urlPattern}」吗?`,keywords:[`mock`,t.name,t.urlPattern,`删除`],run:async()=>{await e.deleteMock(t.id),await e.fetchMocks()}})),{id:`mock.refresh`,title:`刷新 Mock 列表`,section:`Mock`,icon:Hr,run:e.fetchMocks},{id:`plugins.mode.off`,title:`关闭插件模式`,section:`插件`,icon:Br,keywords:[`plugin`,`plugins`,`mode`,`off`,`插件模式`],run:()=>e.switchPluginMode(`off`)},{id:`plugins.mode.on`,title:`开启插件模式`,section:`插件`,icon:zr,keywords:[`plugin`,`plugins`,`mode`,`on`,`插件模式`],run:()=>e.switchPluginMode(`on`)},{id:`plugins.mode.shadow`,title:`切换到插件影子模式`,section:`插件`,icon:Kr,keywords:[`plugin`,`plugins`,`mode`,`shadow`,`插件模式`,`影子模式`],run:()=>e.switchPluginMode(`shadow`)},{id:`plugins.generate`,title:`AI 生成插件`,section:`插件`,icon:cr,keywords:[`plugin`,`plugins`,`generate`,`AI`,`插件生成`],closeOnRun:!1,run:()=>t.openPanel({id:`plugin.generate`,title:`AI 插件生成器`,size:`xl`})},{id:`plugins.reload`,title:`热加载插件`,section:`插件`,icon:Hr,keywords:[`plugin`,`plugins`,`reload`,`hot reload`,`热加载`],run:async()=>{await fetch(`/api/plugins/reload`,{method:`POST`}),await e.fetchPlugins()}},...e.plugins.map(t=>({id:`plugins.runtime.${t.state===`running`?`stop`:`start`}.${t.id}`,title:`${t.state===`running`?`停止`:`启动`}插件:${t.name}`,description:`${t.version} · ${t.hooks.join(`, `)||`无 hooks`}`,section:`插件`,icon:t.state===`running`?qr:Rr,keywords:[`插件`,t.name,t.id,...t.hooks],run:async()=>{t.state===`running`?await e.stopPlugin(t.id):await e.startPlugin(t.id),await e.fetchPlugins()}})),...e.plugins.filter(e=>e.id.startsWith(`local.`)).map(e=>{let n=`${e.id.replace(/^local\./,``)}.js`;return{id:`plugins.edit.${e.id}`,title:`编辑插件代码:${e.name}`,description:n,section:`插件`,icon:gr,keywords:[`插件`,`代码`,e.name,e.id,n],closeOnRun:!1,run:()=>t.openPanel({id:`plugin.code`,title:`编辑插件代码:${n}`,size:`xl`,params:{filename:n}})}}),...e.plugins.filter(e=>e.id.startsWith(`local.`)).map(e=>({id:`plugins.test.${e.id}`,title:`测试插件:${e.name}`,description:e.hooks.join(`, `)||`无 hooks`,section:`插件`,icon:Xr,keywords:[`插件`,`测试`,e.name,e.id,...e.hooks],closeOnRun:!1,run:()=>t.openPanel({id:`plugin.test`,title:`测试插件:${e.name}`,size:`xl`,params:{pluginId:e.id,pluginName:e.name,hooks:e.hooks}})})),...e.plugins.map(t=>({id:`plugins.toggle.${t.id}`,title:`${t.state===`disabled`?`启用`:`禁用`}插件:${t.name}`,description:t.id,section:`插件`,icon:Br,keywords:[`插件`,t.name,t.id,`启用`,`禁用`],run:async()=>{await e.togglePlugin(t.id,t.state===`disabled`),await e.fetchPlugins()}})),{id:`plugins.third-party.load`,title:`加载第三方插件`,section:`插件`,icon:$r,keywords:[`plugin`,`plugins`,`third party`,`load`,`第三方插件`],run:async()=>{let t=window.prompt(`请输入第三方插件路径`);t?.trim()&&(await e.loadThirdPartyPlugin(t.trim()),await e.fetchThirdPartyPlugins())}},...e.thirdPartyPlugins.map(t=>({id:`plugins.third-party.unload.${t.id}`,title:`卸载第三方插件:${t.name}`,description:t.id,section:`插件`,icon:Zr,danger:!0,confirm:`确定要卸载第三方插件「${t.name}」吗?`,keywords:[`第三方插件`,t.name,t.id,`卸载`],run:async()=>{await e.unloadThirdPartyPlugin(t.id),await e.fetchThirdPartyPlugins()}})),{id:`settings.theme`,title:`主题与缩放设置`,section:`设置`,icon:ur,keywords:[`settings`,`theme`,`zoom`,`主题`,`缩放`],closeOnRun:!1,run:()=>t.openPanel({id:`settings`,title:`系统设置`,description:`打开偏好设置`,size:`lg`})}],[p,v,n,d,s,e]),C=(0,D.useCallback)((t,r)=>{switch(t.id){case`settings`:return(0,N.jsx)(Hc,{embedded:!0});case`mobile-proxy`:return(0,N.jsx)(Yc,{});case`request.detail`:return(0,N.jsx)(Vc,{embedded:!0,detail:e.recordDetail,loading:e.detailLoading,error:e.detailError,selectedRecord:e.records.find(t=>t.id===e.selectedRecordId),onCreateMock:_,onReplay:v});case`plugin.generate`:return(0,N.jsx)(Uc,{embedded:!0,onOpenChange:e=>{e||r.close()},onPluginSaved:async()=>{await e.fetchPlugins()}});case`mock.create`:return(0,N.jsx)(qc,{initialData:t.params?.initialData,createMock:e.createMock,updateMock:e.updateMock,onSaved:()=>{e.fetchMocks(),r.close()}});case`mock.edit`:{let n=Number(t.params?.id),i=e.mockRules.find(e=>e.id===n);return i?(0,N.jsx)(qc,{rule:i,createMock:e.createMock,updateMock:e.updateMock,onSaved:()=>{e.fetchMocks(),r.close()}}):(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:`没有找到这条 Mock 规则`})}case`plugin.code`:return(0,N.jsx)(Wc,{embedded:!0,filename:String(t.params?.filename||``),onOpenChange:e=>{e||r.close()},onSaved:e.fetchPlugins});case`plugin.test`:return(0,N.jsx)(Gc,{embedded:!0,pluginId:String(t.params?.pluginId||``),pluginName:String(t.params?.pluginName||``),hooks:Array.isArray(t.params?.hooks)?t.params.hooks:[],onOpenChange:e=>{e||r.close()},onPluginFixed:e.fetchPlugins});case`rules.ai`:return(0,N.jsx)(Kc,{rules:e.rules,setRules:e.setRules,ruleFiles:e.ruleFiles,activeFileName:e.activeFileName,fetchRuleFileRawContent:e.fetchRuleFileRawContent});case`rules.preview`:return(0,N.jsx)(Jc,{embedded:!0,rules:e.rules,activeFileName:e.activeFileName,onRevealRule:e=>{r.close(),n(`/config`),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent(`route-rule:highlight`,{detail:{pattern:e.pattern,target:e.target}}))},120)}});default:return(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:`未找到这个面板`})}},[_,v,n,e]),ee=u;return(0,D.useEffect)(()=>{t()},[t]),(0,N.jsx)(W,{commands:S,renderPanel:(e,t)=>(0,N.jsx)(D.Suspense,{fallback:(0,N.jsx)(Zc,{}),children:C(e,t)}),children:(0,N.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-muted/20`,children:[(0,N.jsx)(ec,{onSettingsClick:()=>b({id:`settings`,title:`系统设置`,description:`管理系统偏好、配置和 AI 功能`,size:`lg`}),onCommandClick:y,onMobileProxyClick:()=>b({id:`mobile-proxy`,title:`手机代理`,description:`扫描二维码,在手机上配置代理与 HTTPS 证书`,size:`md`})}),(0,N.jsx)(`main`,{className:`mx-auto flex min-h-0 w-full max-w-[1600px] flex-1 px-4 pt-4 lg:px-6`,children:(0,N.jsx)(Ma,{className:`h-full min-h-0 w-full flex-1 gap-0 overflow-hidden rounded-b-none py-0`,children:(0,N.jsxs)(Ea,{value:h,onValueChange:g,className:`min-h-0 flex-1 gap-0`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b px-4 py-2`,children:[(0,N.jsxs)(Oa,{className:`!h-auto max-w-full justify-start gap-1 overflow-x-auto p-1`,children:[(0,N.jsxs)(ka,{value:`logs`,className:`h-8 flex-none px-3`,title:`查看经过代理的本机、远程设备和插件测试流量`,children:[(0,N.jsx)(Tr,{}),`日志`]}),(0,N.jsxs)(ka,{value:`config`,className:`h-8 flex-none px-3`,title:`管理代理转发规则,并在表格、文本和图表视图间切换`,children:[(0,N.jsx)(Sr,{}),`路由规则`]}),(0,N.jsxs)(ka,{value:`mock`,className:`h-8 flex-none px-3`,title:`匹配请求后返回本地响应,用于联调和异常场景测试`,children:[(0,N.jsx)(hr,{}),`Mock`,e.mockRules.filter(e=>e.enabled).length>0&&(0,N.jsx)(L,{variant:`secondary`,children:e.mockRules.filter(e=>e.enabled).length})]}),(0,N.jsxs)(ka,{value:`plugins`,className:`h-8 flex-none px-3`,title:`控制内置、自定义和第三方插件的运行状态`,children:[(0,N.jsx)(zr,{}),`扩展插件`]}),(0,N.jsxs)(ka,{value:`health`,className:`h-8 flex-none px-3`,title:`查看进程健康、连接、守护策略和日志限流状态`,children:[(0,N.jsx)(ir,{}),`健康`]})]}),h===`logs`&&(0,N.jsxs)(L,{variant:d?`default`:`secondary`,className:`ml-auto shrink-0`,children:[(0,N.jsx)(`span`,{className:d?`size-1.5 rounded-full bg-current opacity-70`:`size-1.5 rounded-full bg-current opacity-50`}),d?`记录中`:`已暂停`]})]}),(0,N.jsx)(Aa,{value:`logs`,className:`mt-0 flex min-h-0 flex-col p-[var(--ui-page-padding)]`,children:(0,N.jsxs)(Ma,{"data-testid":`log-panel-card`,className:`min-h-0 flex-1 gap-0 overflow-hidden py-0 shadow-none`,children:[(0,N.jsxs)(Na,{className:`block shrink-0 border-b px-3 py-3 [.border-b]:pb-3`,children:[(0,N.jsx)(Pa,{className:`sr-only`,children:`请求日志`}),(0,N.jsx)(qa,{filterText:i,setFilterText:a,resourceTypeFilter:o,setResourceTypeFilter:s,clientSourceFilter:c,setClientSourceFilter:l,totalCount:e.records.length,filteredCount:u.length,onClear:e.clearRecords,recording:d,onToggleRecording:()=>f(e=>!e)})]}),(0,N.jsx)(La,{className:`flex min-h-0 flex-1 flex-col p-0`,children:(0,N.jsx)(Ao,{records:ee,selectedRecordId:e.selectedRecordId,onSelect:x,autoScroll:p})})]})}),(0,N.jsx)(Aa,{value:`config`,className:`mt-0 flex min-h-0 flex-1 flex-col p-[var(--ui-page-padding)]`,children:(0,N.jsx)(D.Suspense,{fallback:(0,N.jsx)(Zc,{}),children:(0,N.jsx)(Rc,{rules:e.rules,setRules:e.setRules,ruleFiles:e.ruleFiles,activeFileName:e.activeFileName,fetchRuleFiles:e.fetchRuleFiles,fetchFileContent:e.fetchFileContent,fetchRuleFileRawContent:e.fetchRuleFileRawContent,saveRuleFileRawContent:e.saveRuleFileRawContent,saveFileContent:e.saveFileContent,createRuleFile:e.createRuleFile,toggleRuleFile:e.toggleRuleFile,renameRuleFile:e.renameRuleFile,deleteRuleFile:e.deleteRuleFile})})}),(0,N.jsx)(Aa,{value:`mock`,className:`mt-0 min-h-0 overflow-y-auto`,children:(0,N.jsx)(La,{className:`app-workspace-content`,children:(0,N.jsx)(D.Suspense,{fallback:(0,N.jsx)(Zc,{}),children:(0,N.jsx)(zc,{mockRules:e.mockRules,fetchMocks:e.fetchMocks,createMock:e.createMock,updateMock:e.updateMock,deleteMock:e.deleteMock})})})}),(0,N.jsx)(Aa,{value:`plugins`,className:`mt-0 min-h-0 overflow-y-auto`,children:(0,N.jsx)(La,{className:`app-workspace-content`,children:(0,N.jsx)(D.Suspense,{fallback:(0,N.jsx)(Zc,{}),children:(0,N.jsx)(Bc,{plugins:e.plugins,pluginMode:e.pluginMode,switchPluginMode:e.switchPluginMode,fetchPlugins:e.fetchPlugins,startPlugin:e.startPlugin,stopPlugin:e.stopPlugin,togglePlugin:e.togglePlugin,thirdPartyPlugins:e.thirdPartyPlugins,thirdPartySecurity:e.thirdPartySecurity,fetchThirdPartyPlugins:e.fetchThirdPartyPlugins,loadThirdPartyPlugin:e.loadThirdPartyPlugin,unloadThirdPartyPlugin:e.unloadThirdPartyPlugin})})})}),(0,N.jsx)(Aa,{value:`health`,className:`mt-0 min-h-0 overflow-y-auto`,children:(0,N.jsx)(D.Suspense,{fallback:(0,N.jsx)(Zc,{}),children:(0,N.jsx)(Xc,{})})})]})})})]})})}function $c({position:e=`bottom-right`,duration:t=Ls,...n}){let{resolvedTheme:r}=Qs();return(0,N.jsx)(Is,{theme:r,position:e,duration:t,expand:!0,closeButton:!0,gap:10,visibleToasts:4,offset:16,mobileOffset:12,swipeDirections:[`right`],className:`toaster group`,icons:{success:(0,N.jsx)(pr,{className:`size-4`}),info:(0,N.jsx)(Or,{className:`size-4`}),warning:(0,N.jsx)(Qr,{className:`size-4`}),error:(0,N.jsx)(Nr,{className:`size-4`}),loading:(0,N.jsx)(Ar,{className:`size-4 animate-spin`}),close:(0,N.jsx)(v,{className:`size-3`})},toastOptions:{unstyled:!0,closeButtonAriaLabel:`关闭通知`,style:{"--system-toast-duration":`${Ls}ms`},classNames:{toast:`system-toast`,content:`system-toast-content`,title:`system-toast-title`,description:`system-toast-description`,icon:`system-toast-icon`,closeButton:`system-toast-close`,actionButton:`system-toast-action`,cancelButton:`system-toast-cancel`,success:`system-toast-success`,info:`system-toast-info`,warning:`system-toast-warning`,error:`system-toast-error`,loading:`system-toast-loading`,default:`system-toast-default`}},...n})}function el({children:e}){let t=(0,D.useRef)(new Map),n=(0,D.useRef)(0),r=(0,D.useCallback)(e=>{t.current.set(e,{order:n.current++})},[]),i=(0,D.useCallback)((e,i)=>{t.current.get(e)||r(e);let a=t.current.get(e);a&&(!a.registration?.active&&i.active&&(a.order=n.current++),a.registration=i)},[r]),a=(0,D.useCallback)(e=>{t.current.delete(e)},[]);(0,D.useEffect)(()=>{let e=e=>{if(e.isComposing||e.repeat||!(e.metaKey||e.ctrlKey)||e.key.toLowerCase()!==`s`)return;let n=[...t.current.values()].filter(e=>!!e.registration?.active).sort((e,t)=>t.registration.priority-e.registration.priority||t.order-e.order)[0];n&&(e.preventDefault(),e.stopPropagation(),n.registration.enabled&&n.registration.onSave())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]);let o=(0,D.useMemo)(()=>({register:r,update:i,unregister:a}),[r,a,i]);return(0,N.jsx)(rs.Provider,{value:o,children:e})}(0,fe.createRoot)(document.getElementById(`root`)).render((0,N.jsx)(D.StrictMode,{children:(0,N.jsxs)(Zs,{defaultTheme:`light`,storageKey:`theme`,children:[(0,N.jsx)(el,{children:(0,N.jsx)(Ln,{children:(0,N.jsx)(Qc,{})})}),(0,N.jsx)($c,{})]})}));export{Ur as $,Ba as A,Ea as B,po as C,V as D,B as E,Fa as F,Zr as G,Oa as H,Ra as I,Jr as J,Xr as K,Na as L,Ma as M,Ia as N,Ua as O,La as P,Wr as Q,Pa as R,go as S,mo as T,ka as U,Aa as V,Qr as W,Kr as X,qr as Y,Gr as Z,Qo as _,ir as _t,gc as a,jr as at,Wo as b,Us as c,wr as ct,as as d,_r as dt,Hr as et,is as f,gr as ft,Yo as g,or as gt,Ko as h,cr as ht,hc as i,Mr as it,za as j,Wa as k,Ks as l,Sr as lt,$o as m,dr as mt,mc as n,Rr as nt,Qs as o,Ar as ot,ns as p,pr as pt,Yr as q,pc as r,Lr as rt,Gs as s,Tr as st,Pc as t,Vr as tt,zs as u,br as ut,Xo as v,k as vt,ho as w,yo as x,Zo as y,L as z};
18
+ `)}function _c(){let[e,t]=(0,D.useState)([]),[n,r]=(0,D.useState)([]),[i,a]=(0,D.useState)(null),o=(0,D.useCallback)(async()=>{try{let e=await(await fetch(`/api/rule-files`)).json(),t=Array.isArray(e)?e:[];return r(t),t}catch(e){return console.error(`Failed to fetch rule files:`,e),[]}},[]),s=(0,D.useCallback)(async e=>(await fetch(`/api/rule-files/${encodeURIComponent(e)}/content`)).text(),[]),c=(0,D.useCallback)(async e=>{try{t(hc(await s(e))),a(e)}catch(e){console.error(`Failed to fetch file content:`,e)}},[s]),l=(0,D.useCallback)(async(e,t)=>{try{return(await(await fetch(`/api/rule-files/${encodeURIComponent(e)}/content`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:t})})).json()).status===`success`}catch(e){return console.error(`Failed to save file content:`,e),!1}},[]);return{rules:e,setRules:t,ruleFiles:n,activeFileName:i,fetchRuleFiles:o,fetchFileContent:c,fetchRuleFileRawContent:s,saveRuleFileRawContent:l,saveFileContent:(0,D.useCallback)(async(e,t)=>l(e,gc(t)),[l]),createRuleFile:(0,D.useCallback)(async(e,t=``)=>{let n=e.trim();try{let e=await(await fetch(`/api/rule-files`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n,content:t,enabled:!0})})).json();return e.status===`success`?(await o(),{success:!0}):{success:!1,error:e.error}}catch(e){return(await o()).some(e=>e.name===n)?{success:!0}:{success:!1,error:e instanceof Error?e.message:`创建规则文件失败`}}},[o]),toggleRuleFile:(0,D.useCallback)(async(e,t)=>{try{return(await(await fetch(`/api/rule-files/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})})).json()).status===`success`?(await o(),!0):!1}catch(e){return console.error(`Failed to toggle rule file:`,e),!1}},[o]),renameRuleFile:(0,D.useCallback)(async(e,t)=>{let n=t.trim();if(!n)return{success:!1,error:`规则文件名称不能为空`};try{let t=await(await fetch(`/api/rule-files/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({newName:n})})).json();if(t.status!==`success`)return{success:!1,error:t.error||`重命名失败`};let r=typeof t.name==`string`?t.name:n;return i===e&&a(r),await o(),{success:!0,name:r}}catch(e){return{success:!1,error:e instanceof Error?e.message:`重命名失败`}}},[i,o]),deleteRuleFile:(0,D.useCallback)(async e=>{try{return(await(await fetch(`/api/rule-files/${encodeURIComponent(e)}`,{method:`DELETE`})).json()).status===`success`?(i===e&&(a(null),t([])),await o(),!0):!1}catch(e){return console.error(`Failed to delete rule file:`,e),!1}},[o,i])}}var vc=`mocksUpdated`;function yc(e){let t=new Map;for(let n of e)t.set(n.id,n);return Array.from(t.values()).sort((e,t)=>e.id-t.id)}function bc(e,t){return yc([...e.filter(e=>e.id!==t.id),t])}function xc(){let[e,t]=(0,D.useState)([]),n=(0,D.useCallback)(async()=>{try{let e=await(await fetch(`/api/mocks`,{cache:`no-store`})).json();t(yc(Array.isArray(e)?e:[]))}catch(e){console.error(`Failed to fetch mocks:`,e)}},[]);return(0,D.useEffect)(()=>{n()},[n]),(0,D.useEffect)(()=>{let e=e=>{let n=e;t(yc(Array.isArray(n.detail)?n.detail:[]))};return window.addEventListener(vc,e),()=>window.removeEventListener(vc,e)},[]),{mockRules:e,fetchMocks:n,createMock:(0,D.useCallback)(async e=>{try{let n=await(await fetch(`/api/mocks`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();return n.status===`success`?(t(e=>bc(e,n.rule)),n.rule):null}catch(e){return console.error(`Failed to create mock:`,e),null}},[]),updateMock:(0,D.useCallback)(async(e,n)=>{let r;t(t=>(r=t.find(t=>t.id===e),r?bc(t,{...r,...n}):t));try{let i=await(await fetch(`/api/mocks/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})).json();if(i.status===`success`)return t(e=>bc(e,i.rule)),!0;if(r){let e=r;t(t=>bc(t,e))}return!1}catch(e){if(console.error(`Failed to update mock:`,e),r){let e=r;t(t=>bc(t,e))}return!1}},[]),deleteMock:(0,D.useCallback)(async e=>{try{return(await(await fetch(`/api/mocks/${e}`,{method:`DELETE`})).json()).status===`success`?(t(t=>t.filter(t=>t.id!==e)),!0):!1}catch(e){return console.error(`Failed to delete mock:`,e),!1}},[])}}function Sc(){let[e,t]=(0,D.useState)([]),[n,r]=(0,D.useState)(`off`),[i,a]=(0,D.useState)([]),[o,s]=(0,D.useState)({allowAll:!1,trusted:[]}),c=(0,D.useCallback)(async()=>{try{let e=await(await fetch(`/api/plugins`)).json();r(e.mode||`off`),t(e.plugins||[])}catch(e){console.error(`Failed to fetch plugins:`,e)}},[]);return{plugins:e,pluginMode:n,switchPluginMode:(0,D.useCallback)(async e=>{try{(await fetch(`/api/pipeline/mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})})).ok&&r(e)}catch(e){console.error(`Failed to switch plugin mode:`,e)}},[]),thirdPartyPlugins:i,thirdPartySecurity:o,fetchPlugins:c,startPlugin:(0,D.useCallback)(async e=>{try{await fetch(`/api/plugins/${e}/start`,{method:`POST`})}catch(e){console.error(`Failed to start plugin:`,e)}},[]),stopPlugin:(0,D.useCallback)(async e=>{try{await fetch(`/api/plugins/${e}/stop`,{method:`POST`})}catch(e){console.error(`Failed to stop plugin:`,e)}},[]),togglePlugin:(0,D.useCallback)(async(e,n)=>{try{(await fetch(`/api/plugins/${encodeURIComponent(e)}/toggle`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n})})).ok&&t(t=>t.map(t=>t.id===e?{...t,state:n?`running`:`disabled`}:t))}catch(e){console.error(`Failed to toggle plugin:`,e)}},[]),fetchThirdPartyPlugins:(0,D.useCallback)(async()=>{try{let e=await fetch(`/api/plugins/third-party`),t=e.headers.get(`content-type`)||``;if(!e.ok||!t.includes(`application/json`)){a([]),s({allowAll:!1,trusted:[]});return}let n=await e.json();a(n.plugins||[]),s(n.security||{allowAll:!1,trusted:[]})}catch(e){console.error(`Failed to fetch third-party plugins:`,e)}},[]),loadThirdPartyPlugin:(0,D.useCallback)(async e=>{try{await fetch(`/api/plugins/third-party/load`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})})}catch(e){console.error(`Failed to load third-party plugin:`,e)}},[]),unloadThirdPartyPlugin:(0,D.useCallback)(async e=>{try{await fetch(`/api/plugins/third-party/${e}/unload`,{method:`POST`})}catch(e){console.error(`Failed to unload third-party plugin:`,e)}},[])}}function Cc(){let[e,t]=(0,D.useState)(tc),n=ac(e),r=_c(),i=xc(),a=Sc();return{records:n.records,selectedRecordId:n.selectedRecordId,recordDetail:n.recordDetail,detailLoading:n.detailLoading,detailError:n.detailError,fetchDetail:n.fetchDetail,closeDetail:n.closeDetail,clearRecords:n.clearRecords,replayRequest:n.replayRequest,maxRecords:e,setMaxRecords:t,rules:r.rules,setRules:r.setRules,ruleFiles:r.ruleFiles,activeFileName:r.activeFileName,fetchRuleFiles:r.fetchRuleFiles,fetchFileContent:r.fetchFileContent,fetchRuleFileRawContent:r.fetchRuleFileRawContent,saveRuleFileRawContent:r.saveRuleFileRawContent,saveFileContent:r.saveFileContent,createRuleFile:r.createRuleFile,toggleRuleFile:r.toggleRuleFile,renameRuleFile:r.renameRuleFile,deleteRuleFile:r.deleteRuleFile,mockRules:i.mockRules,fetchMocks:i.fetchMocks,createMock:i.createMock,updateMock:i.updateMock,deleteMock:i.deleteMock,plugins:a.plugins,pluginMode:a.pluginMode,switchPluginMode:a.switchPluginMode,thirdPartyPlugins:a.thirdPartyPlugins,thirdPartySecurity:a.thirdPartySecurity,fetchPlugins:a.fetchPlugins,startPlugin:a.startPlugin,stopPlugin:a.stopPlugin,togglePlugin:a.togglePlugin,fetchThirdPartyPlugins:a.fetchThirdPartyPlugins,loadThirdPartyPlugin:a.loadThirdPartyPlugin,unloadThirdPartyPlugin:a.unloadThirdPartyPlugin}}function wc(e){let t=typeof e.source==`string`?e.source:``,n=typeof e.method==`string`?e.method:``,r=t.toLowerCase(),i=n.toUpperCase();if(!r)return`other`;if(r.startsWith(`ws://`)||r.startsWith(`wss://`))return`websocket`;if(i!==`GET`||r.includes(`/api/`)||r.includes(`.json`))return`fetch`;let a=r.split(`?`)[0].split(`#`)[0].split(`/`),o=a[a.length-1]||``,s=o.includes(`.`)&&o.split(`.`).pop()||``;return[`html`,`htm`,`php`,`asp`,`aspx`,`jsp`].includes(s)||!s&&i===`GET`?`doc`:s===`css`?`css`:[`js`,`mjs`,`jsx`,`ts`,`tsx`].includes(s)?`js`:[`woff`,`woff2`,`ttf`,`otf`,`eot`].includes(s)?`font`:[`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`,`ico`,`bmp`].includes(s)?`img`:[`mp4`,`webm`,`ogg`,`mp3`,`wav`,`flac`,`aac`,`m4a`].includes(s)?`media`:[`manifest`,`webmanifest`].includes(s)?`manifest`:s===`wasm`?`wasm`:`other`}var Tc=new WeakMap;function Ec(e){let t=Tc.get(e);if(t)return t;let n=typeof e.method==`string`?e.method:``,r=typeof e.source==`string`?e.source:``,i=typeof e.target==`string`?e.target:``,a=typeof e.time==`string`?e.time:``,o=e.clientType||``,s=e.clientIp||``,c=e.clientName||``,l=e.applicationName||``,u=e.applicationProcess||``,d=e.applicationBundleId||``,f=e.applicationPid?.toString()||``,p=e.applicationIdentitySource||``,m=e.applicationIdentityConfidence||``,h=r;try{h=new URL(r).hostname}catch{}let g={methodUpper:n.toUpperCase(),statusCode:e.statusCode,statusText:e.statusCode?.toString()||``,sourceLower:r.toLowerCase(),domainLower:h.toLowerCase(),clientLower:`${o} ${c} ${s}`.toLowerCase(),clientIpLower:s.toLowerCase(),applicationLower:`${l} ${u} ${d} ${f} ${p} ${m}`.toLowerCase(),haystack:`${n} ${r} ${i} ${a} ${o} ${s} ${c} ${l} ${u} ${d} ${f} ${p} ${m}`.toLowerCase(),resourceType:wc(e)};return Tc.set(e,g),g}function Dc(e){let[t,n]=(0,D.useState)(``),[r,i]=(0,D.useState)(`all`),[a,o]=(0,D.useState)(`all`),s=(0,D.useDeferredValue)(t);return{filterText:t,setFilterText:n,resourceTypeFilter:r,setResourceTypeFilter:i,clientSourceFilter:a,setClientSourceFilter:o,filteredRecords:(0,D.useMemo)(()=>{let t=s.trim();if(!t&&r===`all`&&a===`all`)return e;let n=t.split(/\s+/).filter(Boolean),i=[];for(let t of e){if(a!==`all`&&t.clientType!==a)continue;let e=Ec(t);r!==`all`&&e.resourceType!==r||n.every(t=>{let n=t.startsWith(`-`)&&t.length>1,r=n?t.slice(1):t,i=r.toLowerCase(),a=!1;if(i.startsWith(`method:`))a=e.methodUpper===r.slice(7).toUpperCase();else if(i.startsWith(`status:`)){let t=i.slice(7);if(!e.statusCode)a=!1;else if(t.includes(`x`)){let n=t.replace(/x/gi,``);a=e.statusText.startsWith(n)}else a=e.statusText===t}else a=i.startsWith(`domain:`)?e.domainLower.includes(i.slice(7))||e.sourceLower.includes(i.slice(7)):i.startsWith(`client:`)?e.clientLower.includes(i.slice(7)):i.startsWith(`ip:`)?e.clientIpLower.includes(i.slice(3)):i.startsWith(`app:`)?e.applicationLower.includes(i.slice(4)):Oc(i,e.haystack);return n?!a:a})&&i.push(t)}return i},[e,s,r,a])}}function Oc(e,t){if(t.includes(e))return!0;let n=0;for(let r=0;r<t.length&&n<e.length;r++)e[n]===t[r]&&n++;return n===e.length}var kc=[`content-length`,`content-encoding`,`connection`,`date`,`etag`,`last-modified`,`server`];function Ac(e){if(!e)return{};let t={};return Object.entries(e).forEach(([e,n])=>{kc.includes(e.toLowerCase())||(t[e]=n)}),t}function jc(e){let t=e.match(/^\(truncated, \d+ bytes\)\n/);return t?e.substring(t[0].length):e}function Mc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Nc(e){let t=Ac(e.responseHeaders),n=jc(e.responseBody);return{urlPattern:Mc(e.source),body:n,statusCode:e.statusCode,headers:t,name:`从日志创建`,method:`*`,enabled:!0}}var Pc=(0,D.createContext)(null);function Fc(e){(0,D.useEffect)(()=>{let t=t=>{t.isComposing||t.key.toLowerCase()===`k`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e())};return window.addEventListener(`keydown`,t,{capture:!0}),()=>window.removeEventListener(`keydown`,t,{capture:!0})},[e])}var Ic=(0,D.lazy)(()=>k(()=>import(`./global-panel-shell-Dq8vMdMI.js`).then(e=>({default:e.GlobalPanelShell})),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),Lc=class extends D.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`Global panel failed to render`,e,t)}render(){return this.state.error?(0,N.jsx)(`div`,{className:`fixed inset-0 z-[82] flex items-center justify-center bg-background/80 p-6 backdrop-blur-sm`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg border bg-card p-5 shadow-xl`,children:[(0,N.jsx)(`h2`,{className:`font-semibold`,children:`面板加载失败`}),(0,N.jsx)(`p`,{className:`mt-2 break-words text-sm text-destructive`,children:this.state.error.message}),(0,N.jsx)(`button`,{type:`button`,className:`mt-4 rounded-md border px-3 py-1.5 text-sm`,onClick:this.props.onClose,children:`关闭面板`})]})}):this.props.children}};function W({children:e,commands:t,renderPanel:n}){let[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)([]),s=(0,D.useCallback)(()=>{o([]),i(!0)},[]),c=(0,D.useCallback)(e=>{o([e]),i(!0)},[]),l=(0,D.useCallback)(e=>{o(t=>[...t,e]),i(!0)},[]),u=(0,D.useCallback)(()=>{o(e=>e.slice(0,-1))},[]),d=(0,D.useCallback)(()=>{i(!1),o([])},[]);Fc(s),(0,D.useEffect)(()=>{let e=()=>s(),t=e=>{let t=e.detail;t?.id&&c(t)};return window.addEventListener(`global-panel:open-command`,e),window.addEventListener(`global-panel:open-panel`,t),()=>{window.removeEventListener(`global-panel:open-command`,e),window.removeEventListener(`global-panel:open-panel`,t)}},[s,c]);let f=a.length>0?a[a.length-1]:null,p=(0,D.useMemo)(()=>({open:r,stack:a,currentRoute:f,openCommand:s,openPanel:c,pushPanel:l,back:u,close:d}),[u,d,f,r,s,c,l,a]),m=typeof t==`function`?t(p):t;return(0,N.jsxs)(Pc.Provider,{value:p,children:[e,r&&(0,N.jsx)(Lc,{onClose:d,children:(0,N.jsx)(D.Suspense,{fallback:null,children:(0,N.jsx)(Ic,{commands:m,renderPanel:e=>n(e,p)})})},f?.id||`command`)]})}var Rc=(0,D.lazy)(()=>k(()=>import(`./rule-config-CLte-qNZ.js`).then(e=>({default:e.RuleConfig})),__vite__mapDeps([9,1,2,10,6,11,3,4,5,12,13,14,15,16]))),zc=(0,D.lazy)(()=>k(()=>import(`./mock-config-BTdHrudB.js`).then(e=>({default:e.MockConfig})),__vite__mapDeps([17,1,18,2,10,6,11,4,5,19,20,21,12,22,13,8,23,14,15]))),Bc=(0,D.lazy)(()=>k(()=>import(`./plugin-config-B5tDGCq-.js`).then(e=>({default:e.PluginConfig})),__vite__mapDeps([24,1,25,26,2,27,4,5,11,19,28,29,30,13]))),Vc=(0,D.lazy)(()=>k(()=>import(`./detail-panel-vwvLpmzz.js`).then(e=>({default:e.DetailPanel})),__vite__mapDeps([31,1,2,4,5,32,33,19,20,34,35,36,37,22,14,38]))),Hc=(0,D.lazy)(()=>k(()=>import(`./settings-panel-Bx_qz1RQ.js`).then(e=>({default:e.SettingsPanel})),__vite__mapDeps([39,1,25,26,2,27,4,5,11,19,28,7,34,12,29,40,41,42,8]))),Uc=(0,D.lazy)(()=>k(()=>import(`./plugin-generator-CojssHdE.js`).then(e=>({default:e.PluginGenerator})),__vite__mapDeps([43,1,2,4,5,34,21,36,22,44,8]))),Wc=(0,D.lazy)(()=>k(()=>import(`./plugin-code-editor-C_h_-lKr.js`).then(e=>({default:e.PluginCodeEditor})),__vite__mapDeps([45,1,18,2,4,5,46,40,30,44,8]))),Gc=(0,D.lazy)(()=>k(()=>import(`./plugin-test-dialog-iWeHVCGW.js`).then(e=>({default:e.PluginTestDialog})),__vite__mapDeps([47,1,18,2,4,5,32,33,7,34,46,29,22,44,8]))),Kc=(0,D.lazy)(()=>k(()=>import(`./rule-ai-assistant-panel-LWDaNQKt.js`).then(e=>({default:e.RuleAiAssistantPanel})),__vite__mapDeps([48,1,22,42,44,8]))),qc=(0,D.lazy)(()=>k(()=>import(`./mock-editor-panel-ztb1w__0.js`).then(e=>({default:e.MockEditorPanel})),__vite__mapDeps([49,1,18,2,10,6,11,21,22,44,8,23,14]))),Jc=(0,D.lazy)(()=>k(()=>import(`./route-preview-BecifYSe.js`).then(e=>({default:e.RoutePreview})),__vite__mapDeps([50,1,33]))),Yc=(0,D.lazy)(()=>k(()=>import(`./mobile-proxy-panel-DMJRIDMK.js`).then(e=>({default:e.MobileProxyPanel})),__vite__mapDeps([51,1,2,36,29,37,41,52,42,38]))),Xc=(0,D.lazy)(()=>k(()=>import(`./health-panel-CVQcuI1d.js`).then(e=>({default:e.HealthPanel})),__vite__mapDeps([53,1,2,28,11,34,35,29,37,52,42,13])));function Zc(){return(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 p-6`,"aria-label":`加载中`,children:[(0,N.jsx)(za,{className:`h-5 w-32`}),(0,N.jsx)(za,{className:`h-9 w-full`}),(0,N.jsx)(za,{className:`h-64 w-full`})]})}function Qc(){let e=Cc(),t=e.fetchPlugins,n=Dt(),r=wt(),{filterText:i,setFilterText:a,resourceTypeFilter:o,setResourceTypeFilter:s,clientSourceFilter:c,setClientSourceFilter:l,filteredRecords:u}=Dc(e.records),[d,f]=(0,D.useState)(!0),[p,m]=(0,D.useState)(!0),h=(e=>({"/":`logs`,"/logs":`logs`,"/config":`config`,"/mock":`mock`,"/plugins":`plugins`,"/health":`health`})[e]||`logs`)(r.pathname),g=e=>{n({logs:`/logs`,config:`/config`,mock:`/mock`,plugins:`/plugins`,health:`/health`}[e]||`/`)},_=(0,D.useCallback)(t=>{let r=Nc(t);e.closeDetail(),n(`/mock`),window.dispatchEvent(new CustomEvent(`global-panel:open-panel`,{detail:{id:`mock.create`,title:`新建 Mock 规则`,size:`lg`,params:{initialData:r}}}))},[n,e]),v=(0,D.useCallback)(async t=>{let n=await e.replayRequest(t);return e.fetchDetail(n.recordId),n},[e]),y=(0,D.useCallback)(()=>{window.dispatchEvent(new CustomEvent(`global-panel:open-command`))},[]),b=(0,D.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`global-panel:open-panel`,{detail:e}))},[]),x=(0,D.useCallback)(t=>{e.fetchDetail(t),b({id:`request.detail`,title:`请求详情`,size:`lg`})},[b,e]),S=(0,D.useCallback)(t=>[{id:`nav.logs`,title:`打开日志`,section:`导航`,icon:Tr,keywords:[`logs`,`请求`],run:()=>n(`/logs`)},{id:`nav.rules`,title:`打开路由规则`,section:`导航`,icon:Sr,keywords:[`rules`,`config`],run:()=>n(`/config`)},{id:`nav.mock`,title:`打开 Mock`,section:`导航`,icon:hr,keywords:[`mock`],run:()=>n(`/mock`)},{id:`nav.plugins`,title:`打开扩展插件`,section:`导航`,icon:zr,keywords:[`plugin`,`plugins`],run:()=>n(`/plugins`)},{id:`nav.health`,title:`打开运行健康`,section:`导航`,icon:ir,keywords:[`health`,`健康`,`watchdog`,`运行状态`],run:()=>n(`/health`)},{id:`panel.settings`,title:`打开系统设置`,description:`偏好、配置文件、AI 配置`,section:`全局`,icon:Gr,keywords:[`settings`,`配置`,`AI`],closeOnRun:!1,run:()=>t.openPanel({id:`settings`,title:`系统设置`,description:`管理系统偏好、配置和 AI 功能`,size:`lg`})},{id:`panel.mobile-proxy`,title:`打开手机代理二维码`,description:`扫码配置手机代理并安装 HTTPS 根证书`,section:`全局`,icon:Vr,keywords:[`手机`,`二维码`,`QR`,`remote`,`proxy`],closeOnRun:!1,run:()=>t.openPanel({id:`mobile-proxy`,title:`手机代理`,description:`扫描二维码,在手机上配置代理与 HTTPS 证书`,size:`md`})},{id:`logs.focus-filter`,title:`聚焦日志过滤器`,description:`输入 method:GET、domain:example.com 或关键词筛选请求`,section:`日志`,icon:Wr,run:()=>{n(`/logs`),window.setTimeout(()=>document.getElementById(`proxy-log-filter`)?.focus(),50)}},{id:`logs.toggle-recording`,title:d?`暂停记录日志`:`恢复记录日志`,section:`日志`,icon:d?Ir:Rr,run:()=>f(e=>!e)},{id:`logs.clear`,title:`清空日志`,section:`日志`,icon:Zr,danger:!0,confirm:`确定要清空当前日志列表吗?`,run:e.clearRecords},{id:`logs.toggle-auto-scroll`,title:p?`关闭自动滚动`:`开启自动滚动`,section:`日志`,icon:kr,run:()=>m(e=>!e)},...[{value:`all`,label:`全部资源`},{value:`fetch`,label:`Fetch/XHR`},{value:`doc`,label:`Doc`},{value:`css`,label:`CSS`},{value:`js`,label:`JS`},{value:`font`,label:`Font`},{value:`img`,label:`图片`},{value:`media`,label:`媒体`},{value:`manifest`,label:`Manifest`},{value:`websocket`,label:`WebSocket`},{value:`wasm`,label:`Wasm`},{value:`other`,label:`其他资源`}].map(e=>({id:`logs.resource.${e.value}`,title:`日志只看:${e.label}`,section:`日志`,icon:wr,keywords:[`资源类型`,e.value],run:()=>{n(`/logs`),s(e.value)}})),{id:`request.detail`,title:`打开当前请求详情`,section:`日志`,icon:Sr,disabled:e.selectedRecordId==null,disabledReason:`请先在日志表里选择一条请求`,closeOnRun:!1,run:()=>t.openPanel({id:`request.detail`,title:`请求详情`,size:`lg`})},{id:`request.replay`,title:`重放当前请求`,section:`日志`,icon:Hr,disabled:e.selectedRecordId==null,disabledReason:`请先在日志表里选择一条请求`,run:async()=>{e.selectedRecordId!=null&&await v(e.selectedRecordId)}},{id:`rules.ai`,title:`打开 AI 规则助手`,section:`路由规则`,icon:Kr,keywords:[`AI`,`生成规则`,`合并规则`],closeOnRun:!1,run:()=>t.openPanel({id:`rules.ai`,title:`AI 规则助手`,description:`用自然语言生成规则,或安全合并当前配置`,size:`md`})},{id:`rules.preview`,title:`预览 URL 转发结果`,description:`输入 URL,使用当前规则计算真实转发地址`,section:`路由规则`,icon:Wr,keywords:[`URL`,`preview`,`route`,`转发`,`预览`],closeOnRun:!1,run:()=>{t.openPanel({id:`rules.preview`,title:`URL 预览`,description:`使用当前编辑中的规则计算真实转发地址`,size:`md`})}},{id:`rules.add`,title:`添加路由规则`,section:`路由规则`,icon:xr,disabled:!e.activeFileName,disabledReason:`请先选择或创建一个规则文件`,run:()=>{n(`/config`),e.setRules(e=>[{enabled:!0,rule:``,target:``,exclusions:[]},...e])}},{id:`rules.save`,title:`保存当前规则文件`,description:e.activeFileName?`保存 ${e.activeFileName}`:void 0,section:`路由规则`,icon:Ur,disabled:!e.activeFileName,disabledReason:`请先选择一个规则文件`,run:async()=>{e.activeFileName&&(await e.saveFileContent(e.activeFileName,e.rules)?(await e.fetchRuleFiles(),zs.success(`规则保存成功`)):zs.error(`规则保存失败`))}},{id:`rules.create-file`,title:`创建规则文件`,section:`路由规则`,icon:xr,run:async()=>{let t=window.prompt(`请输入规则文件名称`);if(!t?.trim())return;let r=await e.createRuleFile(t.trim());r.success?(n(`/config`),await e.fetchFileContent(t.trim())):r.error&&window.alert(r.error)}},...e.ruleFiles.map(t=>({id:`rules.file.open.${t.name}`,title:`打开规则文件:${t.name}`,description:`${t.ruleCount} 条规则 · ${t.enabled?`已启用`:`未启用`}`,section:`规则文件`,icon:Sr,keywords:[`规则文件`,t.name],run:async()=>{n(`/config`),await e.fetchFileContent(t.name)}})),...e.ruleFiles.map(t=>({id:`rules.file.toggle.${t.name}`,title:`${t.enabled?`禁用`:`启用`}规则文件:${t.name}`,section:`规则文件`,icon:Br,keywords:[`规则文件`,t.name,`启用`,`禁用`],run:async()=>{await e.toggleRuleFile(t.name,!t.enabled)}})),...e.ruleFiles.map(t=>({id:`rules.file.delete.${t.name}`,title:`删除规则文件:${t.name}`,section:`规则文件`,icon:Zr,danger:!0,confirm:`确定要删除规则文件「${t.name}」吗?`,keywords:[`规则文件`,t.name,`删除`],run:async()=>{await e.deleteRuleFile(t.name)}})),{id:`mock.create`,title:`新建 Mock 规则`,section:`Mock`,icon:hr,keywords:[`mock`,`新增规则`],closeOnRun:!1,run:()=>t.openPanel({id:`mock.create`,title:`新建 Mock 规则`,size:`lg`})},...e.mockRules.map(e=>({id:`mock.edit.${e.id}`,title:`编辑 Mock:${e.name||e.urlPattern}`,description:`${e.method||`*`} ${e.urlPattern}`,section:`Mock`,icon:Lr,keywords:[`mock`,e.name,e.urlPattern],closeOnRun:!1,run:()=>t.openPanel({id:`mock.edit`,title:`编辑 Mock:${e.name||e.urlPattern}`,size:`lg`,params:{id:e.id}})})),...e.mockRules.map(t=>({id:`mock.toggle.${t.id}`,title:`${t.enabled?`禁用`:`启用`} Mock:${t.name||t.urlPattern}`,description:`${t.method||`*`} ${t.urlPattern}`,section:`Mock`,icon:Br,keywords:[`mock`,t.name,t.urlPattern,`启用`,`禁用`],run:async()=>{await e.updateMock(t.id,{enabled:!t.enabled}),await e.fetchMocks()}})),...e.mockRules.map(t=>({id:`mock.delete.${t.id}`,title:`删除 Mock:${t.name||t.urlPattern}`,description:`${t.method||`*`} ${t.urlPattern}`,section:`Mock`,icon:Zr,danger:!0,confirm:`确定要删除 Mock「${t.name||t.urlPattern}」吗?`,keywords:[`mock`,t.name,t.urlPattern,`删除`],run:async()=>{await e.deleteMock(t.id),await e.fetchMocks()}})),{id:`mock.refresh`,title:`刷新 Mock 列表`,section:`Mock`,icon:Hr,run:e.fetchMocks},{id:`plugins.mode.off`,title:`关闭插件模式`,section:`插件`,icon:Br,keywords:[`plugin`,`plugins`,`mode`,`off`,`插件模式`],run:()=>e.switchPluginMode(`off`)},{id:`plugins.mode.on`,title:`开启插件模式`,section:`插件`,icon:zr,keywords:[`plugin`,`plugins`,`mode`,`on`,`插件模式`],run:()=>e.switchPluginMode(`on`)},{id:`plugins.mode.shadow`,title:`切换到插件影子模式`,section:`插件`,icon:Kr,keywords:[`plugin`,`plugins`,`mode`,`shadow`,`插件模式`,`影子模式`],run:()=>e.switchPluginMode(`shadow`)},{id:`plugins.generate`,title:`AI 生成插件`,section:`插件`,icon:cr,keywords:[`plugin`,`plugins`,`generate`,`AI`,`插件生成`],closeOnRun:!1,run:()=>t.openPanel({id:`plugin.generate`,title:`AI 插件生成器`,size:`xl`})},{id:`plugins.reload`,title:`热加载插件`,section:`插件`,icon:Hr,keywords:[`plugin`,`plugins`,`reload`,`hot reload`,`热加载`],run:async()=>{await fetch(`/api/plugins/reload`,{method:`POST`}),await e.fetchPlugins()}},...e.plugins.map(t=>({id:`plugins.runtime.${t.state===`running`?`stop`:`start`}.${t.id}`,title:`${t.state===`running`?`停止`:`启动`}插件:${t.name}`,description:`${t.version} · ${t.hooks.join(`, `)||`无 hooks`}`,section:`插件`,icon:t.state===`running`?qr:Rr,keywords:[`插件`,t.name,t.id,...t.hooks],run:async()=>{t.state===`running`?await e.stopPlugin(t.id):await e.startPlugin(t.id),await e.fetchPlugins()}})),...e.plugins.filter(e=>e.id.startsWith(`local.`)).map(e=>{let n=`${e.id.replace(/^local\./,``)}.js`;return{id:`plugins.edit.${e.id}`,title:`编辑插件代码:${e.name}`,description:n,section:`插件`,icon:gr,keywords:[`插件`,`代码`,e.name,e.id,n],closeOnRun:!1,run:()=>t.openPanel({id:`plugin.code`,title:`编辑插件代码:${n}`,size:`xl`,params:{filename:n}})}}),...e.plugins.filter(e=>e.id.startsWith(`local.`)).map(e=>({id:`plugins.test.${e.id}`,title:`测试插件:${e.name}`,description:e.hooks.join(`, `)||`无 hooks`,section:`插件`,icon:Xr,keywords:[`插件`,`测试`,e.name,e.id,...e.hooks],closeOnRun:!1,run:()=>t.openPanel({id:`plugin.test`,title:`测试插件:${e.name}`,size:`xl`,params:{pluginId:e.id,pluginName:e.name,hooks:e.hooks}})})),...e.plugins.map(t=>({id:`plugins.toggle.${t.id}`,title:`${t.state===`disabled`?`启用`:`禁用`}插件:${t.name}`,description:t.id,section:`插件`,icon:Br,keywords:[`插件`,t.name,t.id,`启用`,`禁用`],run:async()=>{await e.togglePlugin(t.id,t.state===`disabled`),await e.fetchPlugins()}})),{id:`plugins.third-party.load`,title:`加载第三方插件`,section:`插件`,icon:$r,keywords:[`plugin`,`plugins`,`third party`,`load`,`第三方插件`],run:async()=>{let t=window.prompt(`请输入第三方插件路径`);t?.trim()&&(await e.loadThirdPartyPlugin(t.trim()),await e.fetchThirdPartyPlugins())}},...e.thirdPartyPlugins.map(t=>({id:`plugins.third-party.unload.${t.id}`,title:`卸载第三方插件:${t.name}`,description:t.id,section:`插件`,icon:Zr,danger:!0,confirm:`确定要卸载第三方插件「${t.name}」吗?`,keywords:[`第三方插件`,t.name,t.id,`卸载`],run:async()=>{await e.unloadThirdPartyPlugin(t.id),await e.fetchThirdPartyPlugins()}})),{id:`settings.theme`,title:`主题与缩放设置`,section:`设置`,icon:ur,keywords:[`settings`,`theme`,`zoom`,`主题`,`缩放`],closeOnRun:!1,run:()=>t.openPanel({id:`settings`,title:`系统设置`,description:`打开偏好设置`,size:`lg`})}],[p,v,n,d,s,e]),C=(0,D.useCallback)((t,r)=>{switch(t.id){case`settings`:return(0,N.jsx)(Hc,{embedded:!0});case`mobile-proxy`:return(0,N.jsx)(Yc,{});case`request.detail`:return(0,N.jsx)(Vc,{embedded:!0,detail:e.recordDetail,loading:e.detailLoading,error:e.detailError,selectedRecord:e.records.find(t=>t.id===e.selectedRecordId),onCreateMock:_,onReplay:v});case`plugin.generate`:return(0,N.jsx)(Uc,{embedded:!0,onOpenChange:e=>{e||r.close()},onPluginSaved:async()=>{await e.fetchPlugins()}});case`mock.create`:return(0,N.jsx)(qc,{initialData:t.params?.initialData,createMock:e.createMock,updateMock:e.updateMock,onSaved:()=>{e.fetchMocks(),r.close()}});case`mock.edit`:{let n=Number(t.params?.id),i=e.mockRules.find(e=>e.id===n);return i?(0,N.jsx)(qc,{rule:i,createMock:e.createMock,updateMock:e.updateMock,onSaved:()=>{e.fetchMocks(),r.close()}}):(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:`没有找到这条 Mock 规则`})}case`plugin.code`:return(0,N.jsx)(Wc,{embedded:!0,filename:String(t.params?.filename||``),onOpenChange:e=>{e||r.close()},onSaved:e.fetchPlugins});case`plugin.test`:return(0,N.jsx)(Gc,{embedded:!0,pluginId:String(t.params?.pluginId||``),pluginName:String(t.params?.pluginName||``),hooks:Array.isArray(t.params?.hooks)?t.params.hooks:[],onOpenChange:e=>{e||r.close()},onPluginFixed:e.fetchPlugins});case`rules.ai`:return(0,N.jsx)(Kc,{rules:e.rules,setRules:e.setRules,ruleFiles:e.ruleFiles,activeFileName:e.activeFileName,fetchRuleFileRawContent:e.fetchRuleFileRawContent});case`rules.preview`:return(0,N.jsx)(Jc,{embedded:!0,rules:e.rules,activeFileName:e.activeFileName,onRevealRule:e=>{r.close(),n(`/config`),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent(`route-rule:highlight`,{detail:{pattern:e.pattern,target:e.target}}))},120)}});default:return(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:`未找到这个面板`})}},[_,v,n,e]),ee=u;return(0,D.useEffect)(()=>{t()},[t]),(0,N.jsx)(W,{commands:S,renderPanel:(e,t)=>(0,N.jsx)(D.Suspense,{fallback:(0,N.jsx)(Zc,{}),children:C(e,t)}),children:(0,N.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-muted/20`,children:[(0,N.jsx)(ec,{onSettingsClick:()=>b({id:`settings`,title:`系统设置`,description:`管理系统偏好、配置和 AI 功能`,size:`lg`}),onCommandClick:y,onMobileProxyClick:()=>b({id:`mobile-proxy`,title:`手机代理`,description:`扫描二维码,在手机上配置代理与 HTTPS 证书`,size:`md`})}),(0,N.jsx)(`main`,{className:`mx-auto flex min-h-0 w-full max-w-[1600px] flex-1 px-4 pt-4 lg:px-6`,children:(0,N.jsx)(Ma,{className:`h-full min-h-0 w-full flex-1 gap-0 overflow-hidden rounded-b-none py-0`,children:(0,N.jsxs)(Ea,{value:h,onValueChange:g,className:`min-h-0 flex-1 gap-0`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b px-4 py-2`,children:[(0,N.jsxs)(Oa,{className:`!h-auto max-w-full justify-start gap-1 overflow-x-auto p-1`,children:[(0,N.jsxs)(ka,{value:`logs`,className:`h-8 flex-none px-3`,title:`查看经过代理的本机、远程设备和插件测试流量`,children:[(0,N.jsx)(Tr,{}),`日志`]}),(0,N.jsxs)(ka,{value:`config`,className:`h-8 flex-none px-3`,title:`管理代理转发规则,并在表格、文本和图表视图间切换`,children:[(0,N.jsx)(Sr,{}),`路由规则`]}),(0,N.jsxs)(ka,{value:`mock`,className:`h-8 flex-none px-3`,title:`匹配请求后返回本地响应,用于联调和异常场景测试`,children:[(0,N.jsx)(hr,{}),`Mock`,e.mockRules.filter(e=>e.enabled).length>0&&(0,N.jsx)(L,{variant:`secondary`,children:e.mockRules.filter(e=>e.enabled).length})]}),(0,N.jsxs)(ka,{value:`plugins`,className:`h-8 flex-none px-3`,title:`控制内置、自定义和第三方插件的运行状态`,children:[(0,N.jsx)(zr,{}),`扩展插件`]}),(0,N.jsxs)(ka,{value:`health`,className:`h-8 flex-none px-3`,title:`查看进程健康、连接、守护策略和日志限流状态`,children:[(0,N.jsx)(ir,{}),`健康`]})]}),h===`logs`&&(0,N.jsxs)(L,{variant:d?`default`:`secondary`,className:`ml-auto shrink-0`,children:[(0,N.jsx)(`span`,{className:d?`size-1.5 rounded-full bg-current opacity-70`:`size-1.5 rounded-full bg-current opacity-50`}),d?`记录中`:`已暂停`]})]}),(0,N.jsx)(Aa,{value:`logs`,className:`mt-0 flex min-h-0 flex-col p-[var(--ui-page-padding)]`,children:(0,N.jsxs)(Ma,{"data-testid":`log-panel-card`,className:`min-h-0 flex-1 gap-0 overflow-hidden py-0 shadow-none`,children:[(0,N.jsxs)(Na,{className:`block shrink-0 border-b px-3 py-3 [.border-b]:pb-3`,children:[(0,N.jsx)(Pa,{className:`sr-only`,children:`请求日志`}),(0,N.jsx)(qa,{filterText:i,setFilterText:a,resourceTypeFilter:o,setResourceTypeFilter:s,clientSourceFilter:c,setClientSourceFilter:l,totalCount:e.records.length,filteredCount:u.length,onClear:e.clearRecords,recording:d,onToggleRecording:()=>f(e=>!e)})]}),(0,N.jsx)(La,{className:`flex min-h-0 flex-1 flex-col p-0`,children:(0,N.jsx)(Ao,{records:ee,selectedRecordId:e.selectedRecordId,onSelect:x,autoScroll:p})})]})}),(0,N.jsx)(Aa,{value:`config`,className:`mt-0 flex min-h-0 flex-1 flex-col p-[var(--ui-page-padding)]`,children:(0,N.jsx)(D.Suspense,{fallback:(0,N.jsx)(Zc,{}),children:(0,N.jsx)(Rc,{rules:e.rules,setRules:e.setRules,ruleFiles:e.ruleFiles,activeFileName:e.activeFileName,fetchRuleFiles:e.fetchRuleFiles,fetchFileContent:e.fetchFileContent,fetchRuleFileRawContent:e.fetchRuleFileRawContent,saveRuleFileRawContent:e.saveRuleFileRawContent,saveFileContent:e.saveFileContent,createRuleFile:e.createRuleFile,toggleRuleFile:e.toggleRuleFile,renameRuleFile:e.renameRuleFile,deleteRuleFile:e.deleteRuleFile})})}),(0,N.jsx)(Aa,{value:`mock`,className:`mt-0 min-h-0 overflow-y-auto`,children:(0,N.jsx)(La,{className:`app-workspace-content`,children:(0,N.jsx)(D.Suspense,{fallback:(0,N.jsx)(Zc,{}),children:(0,N.jsx)(zc,{mockRules:e.mockRules,fetchMocks:e.fetchMocks,createMock:e.createMock,updateMock:e.updateMock,deleteMock:e.deleteMock})})})}),(0,N.jsx)(Aa,{value:`plugins`,className:`mt-0 min-h-0 overflow-y-auto`,children:(0,N.jsx)(La,{className:`app-workspace-content`,children:(0,N.jsx)(D.Suspense,{fallback:(0,N.jsx)(Zc,{}),children:(0,N.jsx)(Bc,{plugins:e.plugins,pluginMode:e.pluginMode,switchPluginMode:e.switchPluginMode,fetchPlugins:e.fetchPlugins,startPlugin:e.startPlugin,stopPlugin:e.stopPlugin,togglePlugin:e.togglePlugin,thirdPartyPlugins:e.thirdPartyPlugins,thirdPartySecurity:e.thirdPartySecurity,fetchThirdPartyPlugins:e.fetchThirdPartyPlugins,loadThirdPartyPlugin:e.loadThirdPartyPlugin,unloadThirdPartyPlugin:e.unloadThirdPartyPlugin})})})}),(0,N.jsx)(Aa,{value:`health`,className:`mt-0 min-h-0 overflow-y-auto`,children:(0,N.jsx)(D.Suspense,{fallback:(0,N.jsx)(Zc,{}),children:(0,N.jsx)(Xc,{})})})]})})})]})})}function $c({position:e=`bottom-right`,duration:t=Ls,...n}){let{resolvedTheme:r}=Qs();return(0,N.jsx)(Is,{theme:r,position:e,duration:t,expand:!0,closeButton:!0,gap:10,visibleToasts:4,offset:16,mobileOffset:12,swipeDirections:[`right`],className:`toaster group`,icons:{success:(0,N.jsx)(pr,{className:`size-4`}),info:(0,N.jsx)(Or,{className:`size-4`}),warning:(0,N.jsx)(Qr,{className:`size-4`}),error:(0,N.jsx)(Nr,{className:`size-4`}),loading:(0,N.jsx)(Ar,{className:`size-4 animate-spin`}),close:(0,N.jsx)(v,{className:`size-3`})},toastOptions:{unstyled:!0,closeButtonAriaLabel:`关闭通知`,style:{"--system-toast-duration":`${Ls}ms`},classNames:{toast:`system-toast`,content:`system-toast-content`,title:`system-toast-title`,description:`system-toast-description`,icon:`system-toast-icon`,closeButton:`system-toast-close`,actionButton:`system-toast-action`,cancelButton:`system-toast-cancel`,success:`system-toast-success`,info:`system-toast-info`,warning:`system-toast-warning`,error:`system-toast-error`,loading:`system-toast-loading`,default:`system-toast-default`}},...n})}function el({children:e}){let t=(0,D.useRef)(new Map),n=(0,D.useRef)(0),r=(0,D.useCallback)(e=>{t.current.set(e,{order:n.current++})},[]),i=(0,D.useCallback)((e,i)=>{t.current.get(e)||r(e);let a=t.current.get(e);a&&(!a.registration?.active&&i.active&&(a.order=n.current++),a.registration=i)},[r]),a=(0,D.useCallback)(e=>{t.current.delete(e)},[]);(0,D.useEffect)(()=>{let e=e=>{if(e.isComposing||e.repeat||!(e.metaKey||e.ctrlKey)||e.key.toLowerCase()!==`s`)return;let n=[...t.current.values()].filter(e=>!!e.registration?.active).sort((e,t)=>t.registration.priority-e.registration.priority||t.order-e.order)[0];n&&(e.preventDefault(),e.stopPropagation(),n.registration.enabled&&n.registration.onSave())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]);let o=(0,D.useMemo)(()=>({register:r,update:i,unregister:a}),[r,a,i]);return(0,N.jsx)(rs.Provider,{value:o,children:e})}(0,fe.createRoot)(document.getElementById(`root`)).render((0,N.jsx)(D.StrictMode,{children:(0,N.jsxs)(Zs,{defaultTheme:`light`,storageKey:`theme`,children:[(0,N.jsx)(el,{children:(0,N.jsx)(Ln,{children:(0,N.jsx)(Qc,{})})}),(0,N.jsx)($c,{})]})}));export{Ur as $,Ba as A,Ea as B,po as C,V as D,B as E,Fa as F,Zr as G,Oa as H,Ra as I,Jr as J,Xr as K,Na as L,Ma as M,Ia as N,Ua as O,La as P,Wr as Q,Pa as R,go as S,mo as T,ka as U,Aa as V,Qr as W,Kr as X,qr as Y,Gr as Z,Qo as _,ir as _t,gc as a,jr as at,Wo as b,Us as c,wr as ct,as as d,_r as dt,Hr as et,is as f,gr as ft,Yo as g,or as gt,Ko as h,cr as ht,hc as i,Mr as it,za as j,Wa as k,Ks as l,Sr as lt,$o as m,dr as mt,mc as n,Rr as nt,Qs as o,Ar as ot,ns as p,pr as pt,Yr as q,pc as r,Lr as rt,Gs as s,Tr as st,Pc as t,Vr as tt,zs as u,br as ut,Xo as v,k as vt,ho as w,yo as x,Zo as y,L as z};