@jonathanleelx/meddle 0.5.0-beta.1 → 0.5.0-beta.2

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 (27) hide show
  1. package/dist/core/remote-access.d.ts +11 -0
  2. package/dist/core/remote-access.d.ts.map +1 -1
  3. package/dist/core/remote-access.js +32 -0
  4. package/dist/core/remote-access.js.map +1 -1
  5. package/index.js +7 -8
  6. package/package.json +1 -1
  7. package/web/dist/assets/{checkbox-7NvTvLBs.js → checkbox-DK9f9Mxu.js} +1 -1
  8. package/web/dist/assets/{code-fixer-DoYxwBWb.js → code-fixer-IRTVs-a6.js} +1 -1
  9. package/web/dist/assets/{detail-panel-vwvLpmzz.js → detail-panel--2r_Fgpi.js} +1 -1
  10. package/web/dist/assets/{global-panel-shell-Dq8vMdMI.js → global-panel-shell-R-EZQRhs.js} +1 -1
  11. package/web/dist/assets/{health-panel-CVQcuI1d.js → health-panel-CKt2-Gkj.js} +1 -1
  12. package/web/dist/assets/{index-DJ5BnqEk.js → index-DhzkcDnh.js} +2 -2
  13. package/web/dist/assets/mobile-proxy-panel-Dxz-7iYx.js +8 -0
  14. package/web/dist/assets/{mock-config-BTdHrudB.js → mock-config-84LSNP6M.js} +1 -1
  15. package/web/dist/assets/{mock-editor-panel-ztb1w__0.js → mock-editor-panel-RJ1abekr.js} +1 -1
  16. package/web/dist/assets/{monaco-editor-CHNSCVe0.js → monaco-editor-CbL970eS.js} +1 -1
  17. package/web/dist/assets/{plugin-code-editor-C_h_-lKr.js → plugin-code-editor-DfLc4JdP.js} +1 -1
  18. package/web/dist/assets/{plugin-config-B5tDGCq-.js → plugin-config-CT-u4XYw.js} +1 -1
  19. package/web/dist/assets/{plugin-generator-CojssHdE.js → plugin-generator-CyBK9FuM.js} +1 -1
  20. package/web/dist/assets/{plugin-test-dialog-iWeHVCGW.js → plugin-test-dialog-B-NF0sGH.js} +1 -1
  21. package/web/dist/assets/{route-preview-BecifYSe.js → route-preview-C8nW9w7i.js} +1 -1
  22. package/web/dist/assets/{rule-ai-assistant-panel-LWDaNQKt.js → rule-ai-assistant-panel-CNL1O0GY.js} +1 -1
  23. package/web/dist/assets/{rule-config-CLte-qNZ.js → rule-config-DXfovZnm.js} +1 -1
  24. package/web/dist/assets/{select-C5thwxXQ.js → select-DQ6s7CL8.js} +1 -1
  25. package/web/dist/assets/{settings-panel-Bx_qz1RQ.js → settings-panel-BhXgMr_a.js} +1 -1
  26. package/web/dist/index.html +1 -1
  27. package/web/dist/assets/mobile-proxy-panel-DMJRIDMK.js +0 -8
@@ -1,4 +1,4 @@
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]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/global-panel-shell-R-EZQRhs.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-DXfovZnm.js","assets/checkbox-DK9f9Mxu.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-84LSNP6M.js","assets/monaco-editor-CbL970eS.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-IRTVs-a6.js","assets/plugin-config-CT-u4XYw.js","assets/select-DQ6s7CL8.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--2r_Fgpi.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-BhXgMr_a.js","assets/rotate-ccw-CAYM6Vv0.js","assets/smartphone-DKeDuJTU.js","assets/alert-Bve02Ufr.js","assets/plugin-generator-CyBK9FuM.js","assets/textarea-vuxJwU0x.js","assets/plugin-code-editor-DfLc4JdP.js","assets/pencil-line-Cqe41E4h.js","assets/plugin-test-dialog-B-NF0sGH.js","assets/rule-ai-assistant-panel-CNL1O0GY.js","assets/mock-editor-panel-RJ1abekr.js","assets/route-preview-C8nW9w7i.js","assets/mobile-proxy-panel-Dxz-7iYx.js","assets/wifi-D9M35Ajj.js","assets/health-panel-CKt2-Gkj.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-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};
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-R-EZQRhs.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-DXfovZnm.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-84LSNP6M.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-CT-u4XYw.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--2r_Fgpi.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-BhXgMr_a.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-CyBK9FuM.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-DfLc4JdP.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-B-NF0sGH.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-CNL1O0GY.js`).then(e=>({default:e.RuleAiAssistantPanel})),__vite__mapDeps([48,1,22,42,44,8]))),qc=(0,D.lazy)(()=>k(()=>import(`./mock-editor-panel-RJ1abekr.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-C8nW9w7i.js`).then(e=>({default:e.RoutePreview})),__vite__mapDeps([50,1,33]))),Yc=(0,D.lazy)(()=>k(()=>import(`./mobile-proxy-panel-Dxz-7iYx.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-CKt2-Gkj.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};
@@ -0,0 +1,8 @@
1
+ import{a as e,d as t,f as n,l as r,t as i,u as a}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as o}from"./copy-BYjq1hdN.js";import{t as s}from"./refresh-cw-CG3HaiQT.js";import{t as c}from"./shield-check-OqUmVLQt.js";import{t as l}from"./smartphone-DKeDuJTU.js";import{t as u}from"./wifi-D9M35Ajj.js";import{A as d,F as f,L as p,M as m,N as h,O as g,P as _,R as v,j as y,k as b,mt as x,ot as S,st as C,tt as w,u as T,ut as ee,z as E}from"./index-DhzkcDnh.js";import{t as te}from"./clipboard-Dz6MgwV-.js";import{n as D,r as O,t as k}from"./alert-Bve02Ufr.js";var A=r(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),j=r(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),M=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),N=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),P=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),F=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),I=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),L=t((e=>{var t=N().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),R=t((e=>{var t=N().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),z=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),B=t((e=>{var t=P(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),V=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),H=t((e=>{var t=V();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),U=t(((e,t)=>{var n=H();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),W=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),G=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
+ ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),K=t((e=>{var t=W(),n=G();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),ne=t((e=>{var t=N(),n=B(),r=P(),i=K(),a=W(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),re=t((e=>{var t=N(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),ie=t(((e,t)=>{var n=K();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),q=t(((e,t)=>{var n=K(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),J=t(((e,t)=>{var n=K();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),ae=t(((e,t)=>{var n=K(),r=N();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
+ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),oe=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),se=t((e=>{var t=K(),n=ie(),r=q(),i=J(),a=ae(),o=G(),s=N(),c=oe();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
+ Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),ce=t((e=>{var t=N(),n=P(),r=F(),i=I(),a=L(),o=R(),s=z(),c=B(),l=U(),u=ne(),d=re(),f=K(),p=se();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
5
+ The chosen QR Code version cannot contain this amount of data.
6
+ Minimum version required to store current data is: `+c+`.
7
+ `);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),Y=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[a[t*i+r]?1:0]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),le=t((e=>{var t=Y();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),ue=t((e=>{var t=Y();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
8
+ `;return typeof a==`function`&&a(null,p),p}})),de=n(t((e=>{var t=M(),n=ce(),r=le(),i=ue();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1),X=n(a(),1);async function fe(e,t){try{let n=await fetch(e,t),r=n.headers.get(`content-type`);return r&&r.includes(`application/json`)?await n.json():await n.text()}catch(t){throw console.error(`API request failed for ${e}:`,t),t}}async function pe(e){return fe(e)}var Z=e();function Q(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)}function me(e){return e===`localhost`||e===`127.0.0.1`||e===`::1`||Q(e)}function $(e){try{return new URL(e).protocol===`https:`?443:80}catch{return 0}}function he(e,t){if(!e.address)return``;if(Q(e.address))return`${e.address}:${t??``}`;let n=e.proxyPort??$(e.proxyUrl);return!n||n===$(e.proxyUrl)?e.address:`${e.address}:${n}`}function ge(){let{hostname:e,origin:t,protocol:n,port:r}=window.location;if(me(e))return null;let i=r?Number(r):n===`https:`?443:80;return{address:e,proxyUrl:t,setupUrl:`${t}/`,certificateUrl:`${t}/_meddle/ca.crt`,proxyPort:i}}function _e(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.enabled==`boolean`&&typeof t.interceptHttps==`boolean`&&typeof t.authenticationRequired==`boolean`&&Array.isArray(t.targets)}function ve(){let[e,t]=(0,X.useState)(null),[n,r]=(0,X.useState)(``),[a,M]=(0,X.useState)(``),[N,P]=(0,X.useState)(!0),[F,I]=(0,X.useState)(``),[L,R]=(0,X.useState)(!1),[z,B]=(0,X.useState)(``),V=(0,X.useRef)(null),H=async()=>{P(!0),I(``);try{let e=await pe(`/api/remote-access`);if(!_e(e))throw Error(`手机代理接口不可用,请重启 Meddle 服务后重试`);let n=ge(),i=n&&!e.targets.some(e=>e.address===n.address)?[n,...e.targets]:e.targets;t({...e,targets:i}),r(e=>i.some(t=>t.address===e)?e:i[0]?.address||``)}catch(e){I(e instanceof Error?e.message:`无法读取远程代理状态`)}finally{P(!1)}};(0,X.useEffect)(()=>{H()},[]),(0,X.useEffect)(()=>{z&&(V.current?.focus(),V.current?.select())},[z]);let U=(0,X.useMemo)(()=>e?.targets.find(e=>e.address===n)||e?.targets[0]||null,[e,n]),W=U?!Q(U.address):!1;(0,X.useEffect)(()=>{let e=!1;if(!U){M(``);return}return de.toDataURL(U.setupUrl,{width:320,margin:2,errorCorrectionLevel:`M`,color:{dark:`#111827`,light:`#ffffff`}}).then(t=>{e||M(t)}).catch(t=>{e||I(t instanceof Error?t.message:`二维码生成失败`)}),()=>{e=!0}},[U]);let G=async()=>{if(U)try{await te(U.setupUrl),R(!0),B(``),T.success(`手机配置地址已复制`),window.setTimeout(()=>R(!1),1500)}catch{B(U.setupUrl),T.info(`浏览器禁止自动复制,地址已选中`)}};return N?(0,Z.jsxs)(`div`,{className:`grid h-full gap-6 p-6 md:grid-cols-[340px_1fr]`,"aria-label":`正在读取手机代理状态`,children:[(0,Z.jsx)(y,{className:`min-h-[420px] w-full`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(y,{className:`h-8 w-40`}),(0,Z.jsx)(y,{className:`h-20 w-full`}),(0,Z.jsx)(y,{className:`h-10 w-full`})]})]}):F&&!e?(0,Z.jsx)(`div`,{className:`p-6`,children:(0,Z.jsxs)(k,{variant:`destructive`,children:[(0,Z.jsx)(O,{children:`加载失败`}),(0,Z.jsx)(D,{children:F})]})}):e?.enabled?U?(0,Z.jsx)(`div`,{className:`app-panel-content h-full`,children:(0,Z.jsxs)(`div`,{className:`mx-auto grid w-full max-w-3xl gap-6 md:grid-cols-[340px_1fr]`,children:[(0,Z.jsxs)(m,{className:`gap-0 overflow-hidden py-0 shadow-none`,children:[(0,Z.jsxs)(p,{className:`border-b py-4`,children:[(0,Z.jsxs)(v,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(w,{}),`扫码打开配置页`]}),(0,Z.jsx)(f,{children:`使用手机相机或 Safari 扫描。`}),(0,Z.jsx)(h,{children:W?(0,Z.jsx)(E,{variant:`secondary`,children:`公网入口`}):(0,Z.jsx)(E,{variant:`secondary`,children:`局域网`})})]}),(0,Z.jsx)(_,{className:`flex min-h-[340px] items-center justify-center bg-background p-4`,children:a?(0,Z.jsx)(`img`,{src:a,alt:`打开 ${U.setupUrl} 的二维码`,className:`size-[300px] rounded-lg`}):(0,Z.jsx)(S,{className:`size-6 animate-spin text-muted-foreground`})})]}),(0,Z.jsxs)(m,{className:`gap-0 py-0 shadow-none`,children:[(0,Z.jsxs)(p,{className:`border-b py-4`,children:[(0,Z.jsxs)(v,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(l,{}),`手机代理配置`]}),(0,Z.jsx)(f,{children:`手机与电脑连接同一局域网后,扫描二维码打开配置页并安装 HTTPS 根证书。`})]}),(0,Z.jsxs)(_,{className:`flex flex-col gap-5 p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsxs)(E,{variant:`outline`,className:`gap-1.5`,children:[W?(0,Z.jsx)(C,{}):(0,Z.jsx)(u,{}),he(U,e.proxyPort)]}),(0,Z.jsx)(i,{variant:`ghost`,size:`icon-sm`,onClick:()=>void G(),"aria-label":L?`地址已复制`:`复制手机配置地址`,title:L?`已复制`:`复制地址`,className:`size-6`,children:L?(0,Z.jsx)(x,{}):(0,Z.jsx)(o,{})})]}),(0,Z.jsxs)(E,{variant:e.interceptHttps?`default`:`secondary`,className:`gap-1.5`,children:[e.interceptHttps?(0,Z.jsx)(c,{}):(0,Z.jsx)(j,{}),`HTTPS `,e.interceptHttps?`解密开启`:`解密关闭`]}),e.authenticationRequired&&(0,Z.jsx)(E,{variant:`secondary`,children:`需要代理认证`})]}),z&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border bg-muted/40 p-3 text-xs text-muted-foreground`,role:`status`,children:[(0,Z.jsx)(`span`,{children:`浏览器禁止自动访问剪贴板,请按 Ctrl/Cmd+C 复制:`}),(0,Z.jsx)(d,{ref:V,value:z,readOnly:!0,"aria-label":`手动复制手机配置地址`,onFocus:e=>e.currentTarget.select(),onClick:e=>e.currentTarget.select()})]}),e.targets.length>1&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`选择局域网地址`}),(0,Z.jsx)(g,{type:`single`,value:U.address,onValueChange:e=>{e&&(r(e),B(``))},variant:`outline`,size:`sm`,spacing:1,className:`flex-wrap justify-start`,"aria-label":`局域网地址`,children:e.targets.map(e=>(0,Z.jsx)(b,{value:e.address,children:e.address},e.address))})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(i,{variant:`outline`,size:`sm`,asChild:!0,children:(0,Z.jsxs)(`a`,{href:U.setupUrl,target:`_blank`,rel:`noreferrer`,children:[(0,Z.jsx)(ee,{"data-icon":`inline-start`}),`浏览器打开`]})}),e.interceptHttps&&(0,Z.jsx)(i,{variant:`outline`,size:`sm`,asChild:!0,children:(0,Z.jsxs)(`a`,{href:U.certificateUrl,children:[(0,Z.jsx)(A,{"data-icon":`inline-start`}),`下载根证书`]})})]}),(0,Z.jsxs)(`ol`,{className:`flex flex-col gap-2 text-sm leading-6 text-muted-foreground`,children:[(0,Z.jsx)(`li`,{children:`1. 扫码打开手机配置页。`}),(0,Z.jsx)(`li`,{children:`2. 在手机 Wi-Fi 设置中填写页面显示的代理地址。`}),(0,Z.jsx)(`li`,{children:`3. 安装并完全信任根证书后,即可查看 HTTPS 请求。`})]}),F&&(0,Z.jsxs)(k,{variant:`destructive`,children:[(0,Z.jsx)(O,{children:`操作失败`}),(0,Z.jsx)(D,{children:F})]})]})]})]})}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 p-6`,children:[(0,Z.jsxs)(k,{variant:`destructive`,children:[(0,Z.jsx)(u,{}),(0,Z.jsx)(O,{children:`未发现局域网地址`}),(0,Z.jsx)(D,{children:`请确认电脑已连接 Wi-Fi 或有线局域网,然后重新检测。`})]}),(0,Z.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>void H(),children:[(0,Z.jsx)(s,{"data-icon":`inline-start`}),`重新检测`]})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 p-6`,children:[(0,Z.jsxs)(k,{children:[(0,Z.jsx)(j,{}),(0,Z.jsx)(O,{children:`远程代理尚未开启`}),(0,Z.jsxs)(D,{children:[`使用 `,(0,Z.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5`,children:`meddle --remote`}),` 重启代理后,即可显示手机扫码入口。`]})]}),(0,Z.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>void H(),children:[(0,Z.jsx)(s,{"data-icon":`inline-start`}),`重新检测`]})]})}export{ve as MobileProxyPanel};
@@ -1 +1 @@
1
- import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as ee}from"./chevron-down-CPngAx4M.js";import{t as te}from"./chevron-right-V1DGIDbL.js";import{t as a}from"./code-5_eJ_XpJ.js";import{n as ne,t as o}from"./checkbox-7NvTvLBs.js";import{t as s}from"./plus-tVxSydJ8.js";import{t as re}from"./wand-sparkles-wkul5vje.js";import"./es2015-CfXu88Y7.js";import{o as ie,r as ae}from"./ai-config-store-DQXVJVn_.js";import{A as c,G as l,d as oe,f as se,g as ce,h as le,lt as ue,m as u,p as de,rt as fe,u as d,v as pe,y as me,z as f}from"./index-DJ5BnqEk.js";import{i as p}from"./syntax-highlight-BHsSDUha.js";import{a as he,i as m,n as ge,o as h,r as g,t as _e}from"./table-DymgLlcc.js";import{n as ve}from"./monaco-editor-CHNSCVe0.js";import{n as _,t as ye}from"./code-fixer-DoYxwBWb.js";import{t as be}from"./file-system-access-DK7FI6pN.js";var v=n(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),y=t(i(),1),b=e();function xe(e){return e.trim().startsWith(`data:image/`)}var Se={name:``,urlPattern:``,method:`*`,statusCode:200,delay:0,bodyType:`inline`,headers:{},body:``,enabled:!0};function x({mockRules:e,fetchMocks:t,createMock:n,updateMock:i,deleteMock:x,initialEditData:S,onInitialEditConsumed:C}){let[w,T]=(0,y.useState)(!1),[E]=(0,y.useState)(null),[D,Ce]=(0,y.useState)(Se),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(!1),[M,we]=(0,y.useState)(300),Te=(0,y.useRef)(null),N=(0,y.useRef)(null),[P,F]=(0,y.useState)(``),[I,L]=(0,y.useState)(``),[R,z]=(0,y.useState)(null),[B,V]=(0,y.useState)(null),[H,U]=(0,y.useState)(!1),[W,G]=(0,y.useState)(!1),[K,q]=(0,y.useState)(null),Ee=e=>e.type.startsWith(`image/`),De=e=>({json:`application/json`,js:`application/javascript`,css:`text/css`,html:`text/html`,htm:`text/html`,xml:`application/xml`,txt:`text/plain`,csv:`text/csv`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,ico:`image/x-icon`,bmp:`image/bmp`})[e.toLowerCase().split(`.`).pop()||``]||`text/plain`,J=(0,y.useCallback)(e=>{let t=De(e);return(D.headers||{})[`Content-Type`]?null:t},[D.headers]),Y=(0,y.useCallback)(async e=>Ee(e)?new Promise(t=>{let n=new FileReader;n.onload=e=>{t(e.target?.result)},n.readAsDataURL(e)}):await e.text(),[]),X=(0,y.useCallback)(e=>{if(!e.trim()){V(null);return}let t=p(e);t.valid?V(null):V(t.error||`内容格式错误`)},[]),Z=(0,y.useCallback)((e,t)=>{Ce(n=>({...n,[e]:t})),e===`body`&&typeof t==`string`&&X(t)},[X]),Oe=(0,y.useCallback)(async()=>{if(be(window))try{let[e]=await window.showOpenFilePicker({types:[{description:`响应文件`,accept:{"application/json":[`.json`],"text/html":[`.html`,`.htm`],"text/plain":[`.txt`,`.js`,`.css`,`.xml`,`.csv`,`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`],"image/png":[`.png`],"image/jpeg":[`.jpg`,`.jpeg`],"image/gif":[`.gif`],"image/webp":[`.webp`]}}],multiple:!1}),t=await e.getFile();Z(`body`,await Y(t)),q(J(t.name));return}catch(e){console.log(`File System Access API not available or cancelled:`,e)}N.current?.click()},[J,Y,Z]),ke=(0,y.useCallback)(e=>{let t=e.target.files?.[0];t&&Y(t).then(e=>{Z(`body`,e),q(J(t.name))}),e.target.value=``},[J,Y,Z]);(0,y.useEffect)(()=>{t()},[t]),(0,y.useEffect)(()=>{S&&(window.dispatchEvent(new CustomEvent(`global-panel:open-panel`,{detail:{id:`mock.create`,title:`新建 Mock 规则`,size:`lg`,params:{initialData:S}}})),C?.())},[S,C]),(0,y.useEffect)(()=>{w||(F(``),L(``),j(!1),V(null),z(null))},[w]);let Ae=(0,y.useCallback)(()=>{window.dispatchEvent(new CustomEvent(`global-panel:open-panel`,{detail:{id:`mock.create`,title:`新建 Mock 规则`,size:`lg`}}))},[]),Q=(0,y.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`global-panel:open-panel`,{detail:{id:`mock.edit`,title:`编辑 Mock:${e.name||e.urlPattern}`,size:`lg`,params:{id:e.id}}}))},[]),je=(0,y.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=M,r=e=>{let r=e.clientY-t;we(Math.max(150,n+r))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[M]),$=(0,y.useCallback)(async()=>{if(D.bodyType===`inline`&&D.body.trim()){let e=p(D.body);if(!e.valid){let t=e.error||`内容格式错误`;V(t),d.error(t);return}}k(!0);try{if(!(E==null?await n(D):await i(E,D)))throw Error(`保存 Mock 规则失败`);d.success(`Mock 规则保存成功`),T(!1)}catch(e){d.error(e instanceof Error?e.message:`保存失败`)}finally{k(!1)}},[E,D,n,i]);oe({active:w,enabled:!O&&!!D.urlPattern,priority:se.modal,onSave:$});let Me=(0,y.useCallback)(async(e,t)=>{await i(e.id,{enabled:t})},[i]),Ne=(0,y.useCallback)(async e=>{await x(e)},[x]),Pe=(0,y.useCallback)(async()=>{G(!0);try{let{formatted:e,type:t}=await _(D.body);Z(`body`,e),z(null),console.log(`已格式化为 ${t}`)}catch(e){z(e instanceof Error?e.message:`格式化失败`),setTimeout(()=>z(null),3e3)}finally{G(!1)}},[D.body,Z]),Fe=(0,y.useCallback)(async()=>{U(!0);try{let e=await ye(D.body,!0);e.success?(Z(`body`,e.fixed),V(null),z(null),console.log(`代码已修复 (方法: ${e.method===`ai`?`AI`:`规则`})`)):(z(`自动修复失败,请手动修正语法错误`),setTimeout(()=>z(null),3e3))}catch(e){z(e instanceof Error?e.message:`修复失败`),setTimeout(()=>z(null),3e3)}finally{U(!1)}},[D.body,Z]);return(0,b.jsxs)(`div`,{className:`app-page-stack`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium`,children:`规则列表`}),(0,b.jsxs)(r,{variant:`outline`,size:`sm`,onClick:Ae,children:[(0,b.jsx)(s,{"data-icon":`inline-start`}),`新增规则`]})]}),(0,b.jsx)(`div`,{className:`rounded-md border`,children:(0,b.jsxs)(_e,{children:[(0,b.jsx)(he,{children:(0,b.jsxs)(h,{children:[(0,b.jsx)(m,{className:`w-12`,children:`启用`}),(0,b.jsx)(m,{className:`w-40`,children:`名称`}),(0,b.jsx)(m,{children:`URL 匹配`}),(0,b.jsx)(m,{className:`w-20`,children:`方法`}),(0,b.jsx)(m,{className:`w-20`,children:`状态码`}),(0,b.jsx)(m,{className:`w-16`,children:`类型`}),(0,b.jsx)(m,{className:`w-16`,children:`延迟`}),(0,b.jsx)(m,{className:`w-16`,children:`响应头`}),(0,b.jsx)(m,{className:`w-20`,children:`操作`})]})}),(0,b.jsx)(ge,{children:e.length===0?(0,b.jsx)(h,{children:(0,b.jsx)(g,{colSpan:9,className:`text-center text-muted-foreground py-8`,children:`暂无 Mock 规则,点击"新增规则"或从请求日志详情中创建`})}):e.map(e=>(0,b.jsxs)(h,{children:[(0,b.jsx)(g,{children:(0,b.jsx)(o,{checked:e.enabled,onCheckedChange:t=>Me(e,t===!0)})}),(0,b.jsx)(g,{className:`font-medium text-sm`,children:e.name||(0,b.jsx)(`span`,{className:`text-muted-foreground italic`,children:`未命名`})}),(0,b.jsx)(g,{className:`font-mono text-xs truncate max-w-[300px]`,title:e.urlPattern,children:e.urlPattern}),(0,b.jsx)(g,{children:(0,b.jsx)(f,{variant:`outline`,className:`text-xs`,children:e.method||`*`})}),(0,b.jsx)(g,{children:(0,b.jsx)(f,{variant:e.statusCode>=400?`destructive`:e.statusCode>=300?`secondary`:`default`,children:e.statusCode})}),(0,b.jsx)(g,{children:e.bodyType===`file`?(0,b.jsxs)(f,{variant:`secondary`,children:[(0,b.jsx)(ue,{}),`文件`]}):(0,b.jsxs)(f,{variant:`outline`,children:[(0,b.jsx)(a,{}),`内容`]})}),(0,b.jsx)(g,{className:`text-xs text-muted-foreground font-mono`,children:e.delay?`${e.delay}ms`:`-`}),(0,b.jsx)(g,{children:e.headers&&Object.keys(e.headers).length>0?(0,b.jsx)(f,{variant:`secondary`,className:`text-xs`,children:Object.keys(e.headers).length}):(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`-`})}),(0,b.jsx)(g,{children:(0,b.jsxs)(`div`,{className:`flex gap-1`,children:[(0,b.jsx)(r,{variant:`ghost`,size:`icon-sm`,onClick:()=>Q(e),className:`text-muted-foreground hover:text-primary`,"aria-label":`编辑 Mock 规则`,children:(0,b.jsx)(fe,{})}),(0,b.jsx)(r,{variant:`ghost`,size:`icon-sm`,onClick:()=>Ne(e.id),className:`text-muted-foreground hover:text-destructive`,"aria-label":`删除 Mock 规则`,children:(0,b.jsx)(l,{})})]})})]},e.id))})]})}),(0,b.jsx)(le,{open:w,onOpenChange:T,children:(0,b.jsxs)(ce,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:700,storageKey:`mock-config-editor`,children:[(0,b.jsx)(pe,{className:`px-4 pt-4 pb-2`,children:(0,b.jsx)(me,{className:`text-base`,children:E==null?`新建 Mock 规则`:`编辑 Mock 规则`})}),(0,b.jsx)(u,{}),(0,b.jsxs)(`div`,{className:`app-panel-content`,children:[(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`规则名称`}),(0,b.jsx)(c,{value:D.name,onChange:e=>Z(`name`,e.target.value),placeholder:`如:模拟欠费状态`,className:`h-8`})]}),(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`URL 匹配(支持正则)`}),(0,b.jsx)(c,{value:D.urlPattern,onChange:e=>Z(`urlPattern`,e.target.value),placeholder:`如:/api/console/user/corp/.*`,className:`h-8 font-mono text-sm`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`HTTP 方法`}),(0,b.jsxs)(`select`,{value:D.method,onChange:e=>Z(`method`,e.target.value),className:`flex h-8 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,children:[(0,b.jsx)(`option`,{value:`*`,children:`全部`}),(0,b.jsx)(`option`,{value:`GET`,children:`GET`}),(0,b.jsx)(`option`,{value:`POST`,children:`POST`}),(0,b.jsx)(`option`,{value:`PUT`,children:`PUT`}),(0,b.jsx)(`option`,{value:`DELETE`,children:`DELETE`}),(0,b.jsx)(`option`,{value:`PATCH`,children:`PATCH`})]})]}),(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`响应状态码`}),(0,b.jsx)(c,{type:`number`,value:D.statusCode,onChange:e=>Z(`statusCode`,parseInt(e.target.value)||200),className:`h-8`})]}),(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`响应延迟 (ms)`}),(0,b.jsx)(c,{type:`number`,value:D.delay,onChange:e=>Z(`delay`,parseInt(e.target.value)||0),placeholder:`0`,className:`h-8`})]})]}),(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`响应内容 (Body)`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-6 text-xs`,onClick:Oe,children:[(0,b.jsx)(v,{className:`h-3 w-3 mr-1`}),`从文件加载`]}),(0,b.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-6 text-xs`,onClick:async()=>{let e=window.prompt(`请输入文件 URL:`);if(e)try{let t=await fetch(e);if((t.headers.get(`content-type`)||``).startsWith(`image/`)||e.match(/\.(png|jpg|jpeg|gif|webp|svg|ico|bmp)$/i)){let e=await t.blob(),n=new FileReader;n.onload=()=>{Z(`body`,n.result)},n.readAsDataURL(e)}else Z(`body`,await t.text())}catch(e){alert(`无法加载文件: `+e.message)}},children:[(0,b.jsx)(v,{className:`h-3 w-3 mr-1`}),`从URL导入`]}),R&&(0,b.jsx)(`span`,{className:`text-xs text-red-500`,children:R}),D.body.trim()&&ie(ae())&&(0,b.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-6 text-xs`,onClick:Fe,disabled:H,children:[(0,b.jsx)(re,{className:`h-3 w-3 mr-1`}),H?`修复中...`:`AI修复`]}),(0,b.jsxs)(r,{variant:`ghost`,size:`sm`,className:`h-6 text-xs`,onClick:Pe,disabled:W,children:[(0,b.jsx)(a,{className:`h-3 w-3 mr-1`}),W?`格式化中...`:`智能格式化`]})]})]}),(0,b.jsx)(`input`,{ref:N,type:`file`,className:`hidden`,onChange:ke,accept:`image/*,.json,.html,.htm,.txt,.js,.css,.xml,.csv`}),D.body.trim()&&xe(D.body)?(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`div`,{className:`border rounded-md p-2 bg-muted/30`,children:(0,b.jsx)(`img`,{src:D.body,alt:`Preview`,className:`max-w-full max-h-96 object-contain`})}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(r,{variant:`outline`,size:`sm`,className:`h-6 text-xs`,onClick:()=>Z(`body`,``),children:`删除图片`}),(0,b.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-6 text-xs`,onClick:()=>{navigator.clipboard.writeText(D.body),alert(`图片内容已复制到剪贴板`)},children:`复制内容`})]})]}):(0,b.jsxs)(`div`,{ref:Te,className:`relative group`,children:[(0,b.jsx)(ve,{value:D.body,onChange:e=>Z(`body`,e),placeholder:`支持 JSON, HTML, JS, CSS 等格式,或从文件/URL导入`,height:`${M}px`}),(0,b.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-4 cursor-ns-resize flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-t from-border/50 to-transparent`,onMouseDown:je,children:(0,b.jsx)(ne,{className:`h-4 w-4 text-muted-foreground`})})]}),B&&(0,b.jsxs)(`div`,{className:`flex items-start gap-2 p-2 rounded-md bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-900`,children:[(0,b.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400 font-medium`,children:`语法错误:`}),(0,b.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400 flex-1`,children:B})]})]}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:()=>j(!A),children:[A?(0,b.jsx)(ee,{className:`h-3 w-3`}):(0,b.jsx)(te,{className:`h-3 w-3`}),`响应头 (Headers)`,Object.keys(D.headers||{}).length>0&&(0,b.jsx)(f,{variant:`secondary`,className:`ml-1 text-xs`,children:Object.keys(D.headers||{}).length})]}),K&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,b.jsxs)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:[`检测到内容类型变更,建议更新为 `,K,`?`]}),(0,b.jsx)(r,{variant:`outline`,size:`sm`,className:`h-6 text-xs`,onClick:()=>{Z(`headers`,{...D.headers||{},"Content-Type":K}),q(null)},children:`更新`}),(0,b.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-6 text-xs`,onClick:()=>q(null),children:`忽略`})]})]}),A&&(0,b.jsxs)(`div`,{className:`space-y-2 pl-4 border-l-2 border-muted`,children:[Object.entries(D.headers||{}).length>0?(0,b.jsx)(`div`,{className:`space-y-1`,children:Object.entries(D.headers||{}).map(([e,t])=>(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(c,{value:e,onChange:n=>{let r={...D.headers};delete r[e],n.target.value&&(r[n.target.value]=t),Z(`headers`,r)},placeholder:`Header 名称`,className:`h-7 font-mono text-xs flex-1`}),(0,b.jsx)(c,{value:t,onChange:t=>{Z(`headers`,{...D.headers,[e]:t.target.value})},placeholder:`Header 值`,className:`h-7 font-mono text-xs flex-1`}),(0,b.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>{let t={...D.headers};delete t[e],Z(`headers`,t)},children:(0,b.jsx)(l,{className:`h-3.5 w-3.5`})})]},e))}):(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`暂无自定义响应头`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(c,{value:P,onChange:e=>F(e.target.value),placeholder:`Header 名称`,className:`h-7 font-mono text-xs flex-1`}),(0,b.jsx)(c,{value:I,onChange:e=>L(e.target.value),placeholder:`Header 值`,className:`h-7 font-mono text-xs flex-1`}),(0,b.jsx)(r,{variant:`outline`,size:`sm`,className:`h-7`,onClick:()=>{P&&I&&(Z(`headers`,{...D.headers,[P]:I}),F(``),L(``))},disabled:!P||!I,children:(0,b.jsx)(s,{className:`h-3.5 w-3.5`})})]})]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(o,{checked:D.enabled,onCheckedChange:e=>Z(`enabled`,!!e)}),(0,b.jsx)(`label`,{className:`text-sm`,children:`启用此规则`})]})]}),(0,b.jsx)(u,{}),(0,b.jsxs)(`div`,{className:`px-4 py-3 flex justify-end gap-2`,children:[(0,b.jsx)(r,{variant:`outline`,size:`sm`,onClick:()=>T(!1),children:`取消`}),(0,b.jsx)(de,{size:`sm`,onClick:$,disabled:O||!D.urlPattern,children:O?`保存中...`:`保存`})]})]})})]})}export{x as MockConfig};
1
+ import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as ee}from"./chevron-down-CPngAx4M.js";import{t as te}from"./chevron-right-V1DGIDbL.js";import{t as a}from"./code-5_eJ_XpJ.js";import{n as ne,t as o}from"./checkbox-DK9f9Mxu.js";import{t as s}from"./plus-tVxSydJ8.js";import{t as re}from"./wand-sparkles-wkul5vje.js";import"./es2015-CfXu88Y7.js";import{o as ie,r as ae}from"./ai-config-store-DQXVJVn_.js";import{A as c,G as l,d as oe,f as se,g as ce,h as le,lt as ue,m as u,p as de,rt as fe,u as d,v as pe,y as me,z as f}from"./index-DhzkcDnh.js";import{i as p}from"./syntax-highlight-BHsSDUha.js";import{a as he,i as m,n as ge,o as h,r as g,t as _e}from"./table-DymgLlcc.js";import{n as ve}from"./monaco-editor-CbL970eS.js";import{n as _,t as ye}from"./code-fixer-IRTVs-a6.js";import{t as be}from"./file-system-access-DK7FI6pN.js";var v=n(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),y=t(i(),1),b=e();function xe(e){return e.trim().startsWith(`data:image/`)}var Se={name:``,urlPattern:``,method:`*`,statusCode:200,delay:0,bodyType:`inline`,headers:{},body:``,enabled:!0};function x({mockRules:e,fetchMocks:t,createMock:n,updateMock:i,deleteMock:x,initialEditData:S,onInitialEditConsumed:C}){let[w,T]=(0,y.useState)(!1),[E]=(0,y.useState)(null),[D,Ce]=(0,y.useState)(Se),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(!1),[M,we]=(0,y.useState)(300),Te=(0,y.useRef)(null),N=(0,y.useRef)(null),[P,F]=(0,y.useState)(``),[I,L]=(0,y.useState)(``),[R,z]=(0,y.useState)(null),[B,V]=(0,y.useState)(null),[H,U]=(0,y.useState)(!1),[W,G]=(0,y.useState)(!1),[K,q]=(0,y.useState)(null),Ee=e=>e.type.startsWith(`image/`),De=e=>({json:`application/json`,js:`application/javascript`,css:`text/css`,html:`text/html`,htm:`text/html`,xml:`application/xml`,txt:`text/plain`,csv:`text/csv`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,ico:`image/x-icon`,bmp:`image/bmp`})[e.toLowerCase().split(`.`).pop()||``]||`text/plain`,J=(0,y.useCallback)(e=>{let t=De(e);return(D.headers||{})[`Content-Type`]?null:t},[D.headers]),Y=(0,y.useCallback)(async e=>Ee(e)?new Promise(t=>{let n=new FileReader;n.onload=e=>{t(e.target?.result)},n.readAsDataURL(e)}):await e.text(),[]),X=(0,y.useCallback)(e=>{if(!e.trim()){V(null);return}let t=p(e);t.valid?V(null):V(t.error||`内容格式错误`)},[]),Z=(0,y.useCallback)((e,t)=>{Ce(n=>({...n,[e]:t})),e===`body`&&typeof t==`string`&&X(t)},[X]),Oe=(0,y.useCallback)(async()=>{if(be(window))try{let[e]=await window.showOpenFilePicker({types:[{description:`响应文件`,accept:{"application/json":[`.json`],"text/html":[`.html`,`.htm`],"text/plain":[`.txt`,`.js`,`.css`,`.xml`,`.csv`,`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`],"image/png":[`.png`],"image/jpeg":[`.jpg`,`.jpeg`],"image/gif":[`.gif`],"image/webp":[`.webp`]}}],multiple:!1}),t=await e.getFile();Z(`body`,await Y(t)),q(J(t.name));return}catch(e){console.log(`File System Access API not available or cancelled:`,e)}N.current?.click()},[J,Y,Z]),ke=(0,y.useCallback)(e=>{let t=e.target.files?.[0];t&&Y(t).then(e=>{Z(`body`,e),q(J(t.name))}),e.target.value=``},[J,Y,Z]);(0,y.useEffect)(()=>{t()},[t]),(0,y.useEffect)(()=>{S&&(window.dispatchEvent(new CustomEvent(`global-panel:open-panel`,{detail:{id:`mock.create`,title:`新建 Mock 规则`,size:`lg`,params:{initialData:S}}})),C?.())},[S,C]),(0,y.useEffect)(()=>{w||(F(``),L(``),j(!1),V(null),z(null))},[w]);let Ae=(0,y.useCallback)(()=>{window.dispatchEvent(new CustomEvent(`global-panel:open-panel`,{detail:{id:`mock.create`,title:`新建 Mock 规则`,size:`lg`}}))},[]),Q=(0,y.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`global-panel:open-panel`,{detail:{id:`mock.edit`,title:`编辑 Mock:${e.name||e.urlPattern}`,size:`lg`,params:{id:e.id}}}))},[]),je=(0,y.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=M,r=e=>{let r=e.clientY-t;we(Math.max(150,n+r))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[M]),$=(0,y.useCallback)(async()=>{if(D.bodyType===`inline`&&D.body.trim()){let e=p(D.body);if(!e.valid){let t=e.error||`内容格式错误`;V(t),d.error(t);return}}k(!0);try{if(!(E==null?await n(D):await i(E,D)))throw Error(`保存 Mock 规则失败`);d.success(`Mock 规则保存成功`),T(!1)}catch(e){d.error(e instanceof Error?e.message:`保存失败`)}finally{k(!1)}},[E,D,n,i]);oe({active:w,enabled:!O&&!!D.urlPattern,priority:se.modal,onSave:$});let Me=(0,y.useCallback)(async(e,t)=>{await i(e.id,{enabled:t})},[i]),Ne=(0,y.useCallback)(async e=>{await x(e)},[x]),Pe=(0,y.useCallback)(async()=>{G(!0);try{let{formatted:e,type:t}=await _(D.body);Z(`body`,e),z(null),console.log(`已格式化为 ${t}`)}catch(e){z(e instanceof Error?e.message:`格式化失败`),setTimeout(()=>z(null),3e3)}finally{G(!1)}},[D.body,Z]),Fe=(0,y.useCallback)(async()=>{U(!0);try{let e=await ye(D.body,!0);e.success?(Z(`body`,e.fixed),V(null),z(null),console.log(`代码已修复 (方法: ${e.method===`ai`?`AI`:`规则`})`)):(z(`自动修复失败,请手动修正语法错误`),setTimeout(()=>z(null),3e3))}catch(e){z(e instanceof Error?e.message:`修复失败`),setTimeout(()=>z(null),3e3)}finally{U(!1)}},[D.body,Z]);return(0,b.jsxs)(`div`,{className:`app-page-stack`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium`,children:`规则列表`}),(0,b.jsxs)(r,{variant:`outline`,size:`sm`,onClick:Ae,children:[(0,b.jsx)(s,{"data-icon":`inline-start`}),`新增规则`]})]}),(0,b.jsx)(`div`,{className:`rounded-md border`,children:(0,b.jsxs)(_e,{children:[(0,b.jsx)(he,{children:(0,b.jsxs)(h,{children:[(0,b.jsx)(m,{className:`w-12`,children:`启用`}),(0,b.jsx)(m,{className:`w-40`,children:`名称`}),(0,b.jsx)(m,{children:`URL 匹配`}),(0,b.jsx)(m,{className:`w-20`,children:`方法`}),(0,b.jsx)(m,{className:`w-20`,children:`状态码`}),(0,b.jsx)(m,{className:`w-16`,children:`类型`}),(0,b.jsx)(m,{className:`w-16`,children:`延迟`}),(0,b.jsx)(m,{className:`w-16`,children:`响应头`}),(0,b.jsx)(m,{className:`w-20`,children:`操作`})]})}),(0,b.jsx)(ge,{children:e.length===0?(0,b.jsx)(h,{children:(0,b.jsx)(g,{colSpan:9,className:`text-center text-muted-foreground py-8`,children:`暂无 Mock 规则,点击"新增规则"或从请求日志详情中创建`})}):e.map(e=>(0,b.jsxs)(h,{children:[(0,b.jsx)(g,{children:(0,b.jsx)(o,{checked:e.enabled,onCheckedChange:t=>Me(e,t===!0)})}),(0,b.jsx)(g,{className:`font-medium text-sm`,children:e.name||(0,b.jsx)(`span`,{className:`text-muted-foreground italic`,children:`未命名`})}),(0,b.jsx)(g,{className:`font-mono text-xs truncate max-w-[300px]`,title:e.urlPattern,children:e.urlPattern}),(0,b.jsx)(g,{children:(0,b.jsx)(f,{variant:`outline`,className:`text-xs`,children:e.method||`*`})}),(0,b.jsx)(g,{children:(0,b.jsx)(f,{variant:e.statusCode>=400?`destructive`:e.statusCode>=300?`secondary`:`default`,children:e.statusCode})}),(0,b.jsx)(g,{children:e.bodyType===`file`?(0,b.jsxs)(f,{variant:`secondary`,children:[(0,b.jsx)(ue,{}),`文件`]}):(0,b.jsxs)(f,{variant:`outline`,children:[(0,b.jsx)(a,{}),`内容`]})}),(0,b.jsx)(g,{className:`text-xs text-muted-foreground font-mono`,children:e.delay?`${e.delay}ms`:`-`}),(0,b.jsx)(g,{children:e.headers&&Object.keys(e.headers).length>0?(0,b.jsx)(f,{variant:`secondary`,className:`text-xs`,children:Object.keys(e.headers).length}):(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`-`})}),(0,b.jsx)(g,{children:(0,b.jsxs)(`div`,{className:`flex gap-1`,children:[(0,b.jsx)(r,{variant:`ghost`,size:`icon-sm`,onClick:()=>Q(e),className:`text-muted-foreground hover:text-primary`,"aria-label":`编辑 Mock 规则`,children:(0,b.jsx)(fe,{})}),(0,b.jsx)(r,{variant:`ghost`,size:`icon-sm`,onClick:()=>Ne(e.id),className:`text-muted-foreground hover:text-destructive`,"aria-label":`删除 Mock 规则`,children:(0,b.jsx)(l,{})})]})})]},e.id))})]})}),(0,b.jsx)(le,{open:w,onOpenChange:T,children:(0,b.jsxs)(ce,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:700,storageKey:`mock-config-editor`,children:[(0,b.jsx)(pe,{className:`px-4 pt-4 pb-2`,children:(0,b.jsx)(me,{className:`text-base`,children:E==null?`新建 Mock 规则`:`编辑 Mock 规则`})}),(0,b.jsx)(u,{}),(0,b.jsxs)(`div`,{className:`app-panel-content`,children:[(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`规则名称`}),(0,b.jsx)(c,{value:D.name,onChange:e=>Z(`name`,e.target.value),placeholder:`如:模拟欠费状态`,className:`h-8`})]}),(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`URL 匹配(支持正则)`}),(0,b.jsx)(c,{value:D.urlPattern,onChange:e=>Z(`urlPattern`,e.target.value),placeholder:`如:/api/console/user/corp/.*`,className:`h-8 font-mono text-sm`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`HTTP 方法`}),(0,b.jsxs)(`select`,{value:D.method,onChange:e=>Z(`method`,e.target.value),className:`flex h-8 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,children:[(0,b.jsx)(`option`,{value:`*`,children:`全部`}),(0,b.jsx)(`option`,{value:`GET`,children:`GET`}),(0,b.jsx)(`option`,{value:`POST`,children:`POST`}),(0,b.jsx)(`option`,{value:`PUT`,children:`PUT`}),(0,b.jsx)(`option`,{value:`DELETE`,children:`DELETE`}),(0,b.jsx)(`option`,{value:`PATCH`,children:`PATCH`})]})]}),(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`响应状态码`}),(0,b.jsx)(c,{type:`number`,value:D.statusCode,onChange:e=>Z(`statusCode`,parseInt(e.target.value)||200),className:`h-8`})]}),(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`响应延迟 (ms)`}),(0,b.jsx)(c,{type:`number`,value:D.delay,onChange:e=>Z(`delay`,parseInt(e.target.value)||0),placeholder:`0`,className:`h-8`})]})]}),(0,b.jsxs)(`div`,{className:`app-field-group`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`响应内容 (Body)`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-6 text-xs`,onClick:Oe,children:[(0,b.jsx)(v,{className:`h-3 w-3 mr-1`}),`从文件加载`]}),(0,b.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-6 text-xs`,onClick:async()=>{let e=window.prompt(`请输入文件 URL:`);if(e)try{let t=await fetch(e);if((t.headers.get(`content-type`)||``).startsWith(`image/`)||e.match(/\.(png|jpg|jpeg|gif|webp|svg|ico|bmp)$/i)){let e=await t.blob(),n=new FileReader;n.onload=()=>{Z(`body`,n.result)},n.readAsDataURL(e)}else Z(`body`,await t.text())}catch(e){alert(`无法加载文件: `+e.message)}},children:[(0,b.jsx)(v,{className:`h-3 w-3 mr-1`}),`从URL导入`]}),R&&(0,b.jsx)(`span`,{className:`text-xs text-red-500`,children:R}),D.body.trim()&&ie(ae())&&(0,b.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-6 text-xs`,onClick:Fe,disabled:H,children:[(0,b.jsx)(re,{className:`h-3 w-3 mr-1`}),H?`修复中...`:`AI修复`]}),(0,b.jsxs)(r,{variant:`ghost`,size:`sm`,className:`h-6 text-xs`,onClick:Pe,disabled:W,children:[(0,b.jsx)(a,{className:`h-3 w-3 mr-1`}),W?`格式化中...`:`智能格式化`]})]})]}),(0,b.jsx)(`input`,{ref:N,type:`file`,className:`hidden`,onChange:ke,accept:`image/*,.json,.html,.htm,.txt,.js,.css,.xml,.csv`}),D.body.trim()&&xe(D.body)?(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`div`,{className:`border rounded-md p-2 bg-muted/30`,children:(0,b.jsx)(`img`,{src:D.body,alt:`Preview`,className:`max-w-full max-h-96 object-contain`})}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(r,{variant:`outline`,size:`sm`,className:`h-6 text-xs`,onClick:()=>Z(`body`,``),children:`删除图片`}),(0,b.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-6 text-xs`,onClick:()=>{navigator.clipboard.writeText(D.body),alert(`图片内容已复制到剪贴板`)},children:`复制内容`})]})]}):(0,b.jsxs)(`div`,{ref:Te,className:`relative group`,children:[(0,b.jsx)(ve,{value:D.body,onChange:e=>Z(`body`,e),placeholder:`支持 JSON, HTML, JS, CSS 等格式,或从文件/URL导入`,height:`${M}px`}),(0,b.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-4 cursor-ns-resize flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-t from-border/50 to-transparent`,onMouseDown:je,children:(0,b.jsx)(ne,{className:`h-4 w-4 text-muted-foreground`})})]}),B&&(0,b.jsxs)(`div`,{className:`flex items-start gap-2 p-2 rounded-md bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-900`,children:[(0,b.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400 font-medium`,children:`语法错误:`}),(0,b.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400 flex-1`,children:B})]})]}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:()=>j(!A),children:[A?(0,b.jsx)(ee,{className:`h-3 w-3`}):(0,b.jsx)(te,{className:`h-3 w-3`}),`响应头 (Headers)`,Object.keys(D.headers||{}).length>0&&(0,b.jsx)(f,{variant:`secondary`,className:`ml-1 text-xs`,children:Object.keys(D.headers||{}).length})]}),K&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,b.jsxs)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:[`检测到内容类型变更,建议更新为 `,K,`?`]}),(0,b.jsx)(r,{variant:`outline`,size:`sm`,className:`h-6 text-xs`,onClick:()=>{Z(`headers`,{...D.headers||{},"Content-Type":K}),q(null)},children:`更新`}),(0,b.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-6 text-xs`,onClick:()=>q(null),children:`忽略`})]})]}),A&&(0,b.jsxs)(`div`,{className:`space-y-2 pl-4 border-l-2 border-muted`,children:[Object.entries(D.headers||{}).length>0?(0,b.jsx)(`div`,{className:`space-y-1`,children:Object.entries(D.headers||{}).map(([e,t])=>(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(c,{value:e,onChange:n=>{let r={...D.headers};delete r[e],n.target.value&&(r[n.target.value]=t),Z(`headers`,r)},placeholder:`Header 名称`,className:`h-7 font-mono text-xs flex-1`}),(0,b.jsx)(c,{value:t,onChange:t=>{Z(`headers`,{...D.headers,[e]:t.target.value})},placeholder:`Header 值`,className:`h-7 font-mono text-xs flex-1`}),(0,b.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>{let t={...D.headers};delete t[e],Z(`headers`,t)},children:(0,b.jsx)(l,{className:`h-3.5 w-3.5`})})]},e))}):(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`暂无自定义响应头`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(c,{value:P,onChange:e=>F(e.target.value),placeholder:`Header 名称`,className:`h-7 font-mono text-xs flex-1`}),(0,b.jsx)(c,{value:I,onChange:e=>L(e.target.value),placeholder:`Header 值`,className:`h-7 font-mono text-xs flex-1`}),(0,b.jsx)(r,{variant:`outline`,size:`sm`,className:`h-7`,onClick:()=>{P&&I&&(Z(`headers`,{...D.headers,[P]:I}),F(``),L(``))},disabled:!P||!I,children:(0,b.jsx)(s,{className:`h-3.5 w-3.5`})})]})]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(o,{checked:D.enabled,onCheckedChange:e=>Z(`enabled`,!!e)}),(0,b.jsx)(`label`,{className:`text-sm`,children:`启用此规则`})]})]}),(0,b.jsx)(u,{}),(0,b.jsxs)(`div`,{className:`px-4 py-3 flex justify-end gap-2`,children:[(0,b.jsx)(r,{variant:`outline`,size:`sm`,onClick:()=>T(!1),children:`取消`}),(0,b.jsx)(de,{size:`sm`,onClick:$,disabled:O||!D.urlPattern,children:O?`保存中...`:`保存`})]})]})})]})}export{x as MockConfig};