You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-mitmproxy/web/client/build/static/js/main.dab9e469.chunk.js

2 lines
28 KiB
JavaScript

(this["webpackJsonpmitmproxy-client"]=this["webpackJsonpmitmproxy-client"]||[]).push([[0],{59:function(e,t,s){},65:function(e,t,s){"use strict";s.r(t);var n=s(1),i=s.n(n),r=s(20),o=s.n(r),a=(s(58),s(7)),c=s(8),l=s(15),h=s(14),d=s(52),u=s(10),p=s(13),j=(s(59),s(2)),v=s(22),b=s(16),y=s(43),f=s(30),w=s(0),O=function(e){Object(l.a)(s,e);var t=Object(h.a)(s);function s(e){var n;return Object(a.a)(this,s),(n=t.call(this,e)).state={show:!1,rule:{method:"ALL",url:"",action:1},haveRules:!1},n.handleClose=n.handleClose.bind(Object(v.a)(n)),n.handleShow=n.handleShow.bind(Object(v.a)(n)),n.handleSave=n.handleSave.bind(Object(v.a)(n)),n}return Object(c.a)(s,[{key:"handleClose",value:function(){this.setState({show:!1})}},{key:"handleShow",value:function(){this.setState({show:!0})}},{key:"handleSave",value:function(){var e=this.state.rule,t=[];e.url&&t.push({method:"ALL"===e.method?"":e.method,url:e.url,action:e.action}),this.props.onSave(t),this.handleClose(),this.setState({haveRules:!!t.length})}},{key:"render",value:function(){var e=this,t=this.state,s=t.rule,n=t.haveRules?"success":"primary";return Object(w.jsxs)("div",{children:[Object(w.jsx)(p.a,{variant:n,size:"sm",onClick:this.handleShow,children:"BreakPoint"}),Object(w.jsxs)(b.a,{show:this.state.show,onHide:this.handleClose,children:[Object(w.jsx)(b.a.Header,{closeButton:!0,children:Object(w.jsx)(b.a.Title,{children:"Set BreakPoint"})}),Object(w.jsxs)(b.a.Body,{children:[Object(w.jsxs)(u.a.Group,{as:y.a,children:[Object(w.jsx)(u.a.Label,{column:!0,sm:2,children:"Method"}),Object(w.jsx)(f.a,{sm:10,children:Object(w.jsxs)(u.a.Control,{as:"select",value:s.method,onChange:function(t){e.setState({rule:Object(j.a)(Object(j.a)({},s),{},{method:t.target.value})})},children:[Object(w.jsx)("option",{children:"ALL"}),Object(w.jsx)("option",{children:"GET"}),Object(w.jsx)("option",{children:"POST"}),Object(w.jsx)("option",{children:"PUT"}),Object(w.jsx)("option",{children:"DELETE"})]})})]}),Object(w.jsxs)(u.a.Group,{as:y.a,children:[Object(w.jsx)(u.a.Label,{column:!0,sm:2,children:"URL"}),Object(w.jsx)(f.a,{sm:10,children:Object(w.jsx)(u.a.Control,{value:s.url,onChange:function(t){e.setState({rule:Object(j.a)(Object(j.a)({},s),{},{url:t.target.value})})}})})]}),Object(w.jsxs)(u.a.Group,{as:y.a,children:[Object(w.jsx)(u.a.Label,{column:!0,sm:2,children:"Action"}),Object(w.jsx)(f.a,{sm:10,children:Object(w.jsxs)(u.a.Control,{as:"select",value:s.action,onChange:function(t){e.setState({rule:Object(j.a)(Object(j.a)({},s),{},{action:parseInt(t.target.value)})})},children:[Object(w.jsx)("option",{value:"1",children:"Request"}),Object(w.jsx)("option",{value:"2",children:"Response"}),Object(w.jsx)("option",{value:"3",children:"Both"})]})})]})]}),Object(w.jsxs)(b.a.Footer,{children:[Object(w.jsx)(p.a,{variant:"secondary",onClick:this.handleClose,children:"Close"}),Object(w.jsx)(p.a,{variant:"primary",onClick:this.handleSave,children:"Save"})]})]})]})}}]),s}(i.a.Component),x=function(e){return!!e&&(!!e.header&&(!!e.header["Content-Type"]&&/text|javascript|json|x-www-form-urlencoded|xml|form-data/.test(e.header["Content-Type"].join(""))))},m=function(e){return e?isNaN(e)||e<=0?"0":e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(2)," KB"):"".concat((e/1048576).toFixed(2)," MB"):"0"},R=function(e){for(var t="",s=new Uint8Array(e),n=s.byteLength,i=0;i<n;i++)t+=String.fromCharCode(s[i]);return btoa(t)},S=function(e){var t="",s=new Uint8Array(e),n=s.byteLength,i="";t+="00000000: ";for(var r=0;r<n;r++)t+=s[r].toString(16).padStart(2,"0")+" ",s[r]>=32&&s[r]<=126?i+=String.fromCharCode(s[r]):i+=".",(r+1)%16===0?(t+=" "+i,i="",t+="\n".concat((r+1).toString(16).padStart(8,"0"),": ")):(r+1)%8===0&&(t+=" ");if(i.length>0){for(var o=i.length;o<16;o++)t+=" ",(o+1)%8===0&&(t+=" ");t+=" "+i}return t};var g,E=function(e){Object(l.a)(s,e);var t=Object(h.a)(s);function s(){return Object(a.a)(this,s),t.apply(this,arguments)}return Object(c.a)(s,[{key:"shouldComponentUpdate",value:function(e){return e.isSelected!==this.props.isSelected||!function(e,t){if(e===t)return!0;var s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(var i=0;i<s.length;i++){var r=s[i];if(void 0===t[r]||e[r]!==t[r])return!1}return!0}(e.flow,this.props.flow)}},{key:"render",value:function(){var e=this,t=this.props.flow,s=[];return this.props.isSelected&&s.push("tr-selected"),t.waitIntercept&&s.push("tr-wait-intercept"),Object(w.jsxs)("tr",{className:s.length?s.join(" "):void 0,onClick:function(){e.props.onShowDetail()},children:[Object(w.jsx)("td",{children:t.no}),Object(w.jsx)("td",{children:t.method}),Object(w.jsx)("td",{children:t.host}),Object(w.jsx)("td",{children:t.path}),Object(w.jsx)("td",{children:t.contentType}),Object(w.jsx)("td",{children:t.statusCode}),Object(w.jsx)("td",{children:t.size}),Object(w.jsx)("td",{children:t.costTime})]})}}]),s}(i.a.Component),B=s(26),T=s(49),C=s.n(T),_=s(50),k=s.n(_),q=s(46),N=s.n(q),L=s(47),P=s(6),U=s(53),D=s(3);!function(e){e[e.REQUEST=1]="REQUEST",e[e.REQUEST_BODY=2]="REQUEST_BODY",e[e.RESPONSE=3]="RESPONSE",e[e.RESPONSE_BODY=4]="RESPONSE_BODY"}(g||(g={}));var A=function(){function e(t){Object(a.a)(this,e),this.no=void 0,this.id=void 0,this.waitIntercept=void 0,this.request=void 0,this.response=null,this.url=void 0,this.path=void 0,this._size=0,this.size="0",this.headerContentLengthExist=!1,this.contentType="",this.startTime=Date.now(),this.endTime=0,this.costTime="(pending)",this.status=g.REQUEST,this._isTextRequest=void 0,this._isTextResponse=void 0,this._requestBody=void 0,this._hexviewRequestBody=null,this._responseBody=void 0,this._previewResponseBody=null,this._previewRequestBody=null,this._hexviewResponseBody=null,this.no=++e.curNo,this.id=t.id,this.waitIntercept=t.waitIntercept,this.request=t.content,this.url=new URL(this.request.url),this.path=this.url.pathname+this.url.search,this._isTextRequest=null,this._isTextResponse=null,this._requestBody=null,this._responseBody=null}return Object(c.a)(e,[{key:"addRequestBody",value:function(e){return this.status=g.REQUEST_BODY,this.waitIntercept=e.waitIntercept,this.request.body=e.content,this}},{key:"addResponse",value:function(e){return this.status=g.RESPONSE,this.waitIntercept=e.waitIntercept,this.response=e.content,this.response&&this.response.header&&(null!=this.response.header["Content-Type"]&&(this.contentType=this.response.header["Content-Type"][0].split(";")[0],this.contentType.includes("javascript")&&(this.contentType="javascript")),null!=this.response.header["Content-Length"]&&(this.headerContentLengthExist=!0,this._size=parseInt(this.response.header["Content-Length"][0]),this.size=m(this._size))),this}},{key:"addResponseBody",value:function(e){return this.status=g.RESPONSE_BODY,this.waitIntercept=e.waitIntercept,this.response&&(this.response.body=e.content),this.endTime=Date.now(),this.costTime=String(this.endTime-this.startTime)+" ms",!this.headerContentLengthExist&&this.response&&this.response.body&&(this._size=this.response.body.byteLength,this.size=m(this._size)),this}},{key:"preview",value:function(){return{no:this.no,id:this.id,waitIntercept:this.waitIntercept,host:this.url.host,path:this.path,method:this.request.method,statusCode:this.response?String(this.response.statusCode):"(pending)",size:this.size,costTime:this.costTime,contentType:this.contentType}}},{key:"isTextRequest",value:function(){return null!==this._isTextRequest||(this._isTextRequest=x(this.request)),this._isTextRequest}},{key:"requestBody",value:function(){return null!==this._requestBody?this._requestBody:this.isTextRequest()?this.status<g.REQUEST_BODY?"":(this._requestBody=(new TextDecoder).decode(this.request.body),this._requestBody):(this._requestBody="",this._requestBody)}},{key:"hexviewRequestBody",value:function(){var e,t;return null!==this._hexviewRequestBody?this._hexviewRequestBody:this.status<g.REQUEST_BODY?null:(null===(e=this.request)||void 0===e||null===(t=e.body)||void 0===t?void 0:t.byteLength)?(this._hexviewRequestBody=S(this.request.body),this._hexviewRequestBody):null}},{key:"isTextResponse",value:function(){return this.status<g.RESPONSE?null:(null!==this._isTextResponse||(this._isTextResponse=x(this.response)),this._isTextResponse)}},{key:"responseBody",value:function(){var e;return null!==this._responseBody?this._responseBody:this.status<g.RESPONSE?"":this.isTextResponse()?this.status<g.RESPONSE_BODY?"":(this._responseBody=(new TextDecoder).decode(null===(e=this.response)||void 0===e?void 0:e.body),this._responseBody):(this._responseBody="",this._responseBody)}},{key:"previewResponseBody",value:function(){var e,t,s;return this._previewResponseBody?this._previewResponseBody:this.status<g.RESPONSE_BODY?null:(null===(e=this.response)||void 0===e||null===(t=e.body)||void 0===t?void 0:t.byteLength)?(this.response.header["Content-Type"]&&(s=this.response.header["Content-Type"][0]),s?(s.startsWith("image/")?this._previewResponseBody={type:"image",data:R(this.response.body)}:s.includes("application/json")&&(this._previewResponseBody={type:"json",data:this.responseBody()}),this._previewResponseBody):null):null}},{key:"previewRequestBody",value:function(){var e;return this._previewRequestBody?this._previewRequestBody:this.status<g.REQUEST_BODY?null:(null===(e=this.request.body)||void 0===e?void 0:e.byteLength)?(this.isTextRequest()?/json/.test(this.request.header["Content-Type"].join(""))&&(this._previewRequestBody={type:"json",data:this.requestBody()}):this._previewRequestBody={type:"binary",data:this.hexviewRequestBody()},this._previewRequestBody):null}},{key:"hexviewResponseBody",value:function(){var e,t;return null!==this._hexviewResponseBody?this._hexviewResponseBody:this.status<g.RESPONSE_BODY?null:(null===(e=this.response)||void 0===e||null===(t=e.body)||void 0===t?void 0:t.byteLength)?(this._hexviewResponseBody=S(this.response.body),this._hexviewResponseBody):null}}]),e}();A.curNo=0;var H,M=[g.REQUEST,g.REQUEST_BODY,g.RESPONSE,g.RESPONSE_BODY];!function(e){e[e.CHANGE_REQUEST=11]="CHANGE_REQUEST",e[e.CHANGE_RESPONSE=12]="CHANGE_RESPONSE",e[e.DROP_REQUEST=13]="DROP_REQUEST",e[e.DROP_RESPONSE=14]="DROP_RESPONSE",e[e.CHANGE_BREAK_POINT_RULES=21]="CHANGE_BREAK_POINT_RULES"}(H||(H={}));var I=function(e,t){if(e===H.DROP_REQUEST||e===H.DROP_RESPONSE){var s=new Uint8Array(38);return s[0]=1,s[1]=e,s.set((new TextEncoder).encode(t.id),2),s}var n,i;if(e===H.CHANGE_REQUEST){var r=t.request;i=r.body,n=Object(D.a)(r,["body"])}else{if(e!==H.CHANGE_RESPONSE)throw new Error("invalid message type");var o=t.response;i=o.body,n=Object(D.a)(o,["body"])}i instanceof ArrayBuffer&&(i=new Uint8Array(i));var a=i&&i.byteLength?i.byteLength:0;"Content-Encoding"in n.header&&delete n.header["Content-Encoding"],"Transfer-Encoding"in n.header&&delete n.header["Transfer-Encoding"],n.header["Content-Length"]=[String(a)];var c=(new TextEncoder).encode(JSON.stringify(n)),l=42+c.byteLength+4+a,h=new ArrayBuffer(l),d=new Uint8Array(h);d[0]=1,d[1]=e,d.set((new TextEncoder).encode(t.id),2),d.set(c,42),a&&d.set(i,42+c.byteLength+4);var u=new DataView(h);return u.setUint32(38,c.byteLength),u.setUint32(42+c.byteLength,a),d},z=function(e){Object(l.a)(s,e);var t=Object(h.a)(s);function s(e){var n;return Object(a.a)(this,s),(n=t.call(this,e)).state={show:!1,alertMsg:"",content:""},n.handleClose=n.handleClose.bind(Object(v.a)(n)),n.handleShow=n.handleShow.bind(Object(v.a)(n)),n.handleSave=n.handleSave.bind(Object(v.a)(n)),n}return Object(c.a)(s,[{key:"showAlert",value:function(e){this.setState({alertMsg:e})}},{key:"handleClose",value:function(){this.setState({show:!1})}},{key:"handleShow",value:function(){var e=this.props.flow,t="";t="request"===(e.response?"response":"request")?function(e){var t="".concat(e.method," ").concat(e.url),s=Object.keys(e.header).map((function(t){var s=e.header[t].join(" \t ");return"".concat(t,": ").concat(s)})).join("\n"),n="";return e.body&&x(e)&&(n=(new TextDecoder).decode(e.body)),"".concat(t,"\n\n").concat(s,"\n\n").concat(n)}(e.request):function(e){var t="".concat(e.statusCode),s=Object.keys(e.header).map((function(t){var s=e.header[t].join(" \t ");return"".concat(t,": ").concat(s)})).join("\n"),n="";return e.body&&x(e)&&(n=(new TextDecoder).decode(e.body)),"".concat(t,"\n\n").concat(s,"\n\n").concat(n)}(e.response),this.setState({show:!0,alertMsg:"",content:t})}},{key:"handleSave",value:function(){var e=this.props.flow.response?"response":"request",t=this.state.content;if("request"===e){var s=function(e){var t=e.indexOf("\n\n");if(!(t<=0)){var s=e.slice(0,t).split(" "),n=Object(P.a)(s,2),i=n[0],r=n[1];if(i&&r){var o=e.indexOf("\n\n",t+2);if(!(o<=0)){var a,c=e.slice(t+2,o),l={},h=Object(L.a)(c.split("\n"));try{for(h.s();!(a=h.n()).done;){var d=a.value.split(": "),u=Object(P.a)(d,2),p=u[0],j=u[1];if(!p||!j)return;l[p]=j.split(" \t ")}}catch(y){h.e(y)}finally{h.f()}var v,b=e.slice(o+2);return b&&(v=(new TextEncoder).encode(b)),{method:i,url:r,proto:"",header:l,body:v}}}}}(t);if(!s)return void this.showAlert("parse error");this.props.onChangeRequest(s),this.handleClose()}else{var n=function(e){var t=e.indexOf("\n\n");if(!(t<=0)){var s=e.slice(0,t),n=parseInt(s);if(!isNaN(n)){var i=e.indexOf("\n\n",t+2);if(!(i<=0)){var r,o=e.slice(t+2,i),a={},c=Object(L.a)(o.split("\n"));try{for(c.s();!(r=c.n()).done;){var l=r.value.split(": "),h=Object(P.a)(l,2),d=h[0],u=h[1];if(!d||!u)return;a[d]=u.split(" \t ")}}catch(v){c.e(v)}finally{c.f()}var p,j=e.slice(i+2);return j&&(p=(new TextEncoder).encode(j)),{statusCode:n,header:a,body:p}}}}}(t);if(!n)return void this.showAlert("parse error");this.props.onChangeResponse(n),this.handleClose()}}},{key:"render",value:function(){var e=this,t=this.props.flow;if(!t.waitIntercept)return null;var s=this.state.alertMsg,n=t.response?"response":"request";return Object(w.jsxs)("div",{className:"flow-wait-area",children:[Object(w.jsx)(p.a,{size:"sm",onClick:this.handleShow,children:"Edit"}),Object(w.jsx)(p.a,{size:"sm",onClick:function(){var s="response"===n?H.CHANGE_RESPONSE:H.CHANGE_REQUEST,i=I(s,t);e.props.onMessage(i)},children:"Continue"}),Object(w.jsx)(p.a,{size:"sm",onClick:function(){var s="response"===n?H.DROP_RESPONSE:H.DROP_REQUEST,i=I(s,t);e.props.onMessage(i)},children:"Drop"}),Object(w.jsxs)(b.a,{size:"lg",show:this.state.show,onHide:this.handleClose,children:[Object(w.jsx)(b.a.Header,{closeButton:!0,children:Object(w.jsxs)(b.a.Title,{children:["Edit ","request"===n?"Request":"Response"]})}),Object(w.jsxs)(b.a.Body,{children:[Object(w.jsx)(u.a.Group,{children:Object(w.jsx)(u.a.Control,{as:"textarea",rows:10,value:this.state.content,onChange:function(t){e.setState({content:t.target.value})}})}),s?Object(w.jsx)(U.a,{variant:"danger",children:s}):null]}),Object(w.jsxs)(b.a.Footer,{children:[Object(w.jsx)(p.a,{variant:"secondary",onClick:this.handleClose,children:"Close"}),Object(w.jsx)(p.a,{variant:"primary",onClick:this.handleSave,children:"Save"})]})]})]})}}]),s}(i.a.Component),Q=function(e){Object(l.a)(s,e);var t=Object(h.a)(s);function s(e){var n;return Object(a.a)(this,s),(n=t.call(this,e)).state={flowTab:"Headers",copied:!1,requestBodyViewTab:"Raw",responseBodyLineBreak:!1},n}return Object(c.a)(s,[{key:"preview",value:function(){var e=this.props.flow;if(!e)return null;var t=e.response;if(!t)return null;if(!t.body||!t.body.byteLength)return Object(w.jsx)("div",{style:{color:"gray"},children:"No response"});var s=e.previewResponseBody();return s?"image"===s.type?Object(w.jsx)("img",{src:"data:image/png;base64,".concat(s.data)}):"json"===s.type?Object(w.jsx)("div",{children:Object(w.jsx)(N.a,{data:s.data,keyStyle:"color: rgb(130,40,144);",stringStyle:"color: rgb(153,68,60);",valueStyle:"color: rgb(25,1,199);",booleanStyle:"color: rgb(94,105,192);"})}):Object(w.jsx)("div",{style:{color:"gray"},children:"Not support preview"}):Object(w.jsx)("div",{style:{color:"gray"},children:"Not support preview"})}},{key:"requestBodyPreview",value:function(){var e=this.props.flow;if(!e)return null;var t=e.previewRequestBody();return t?"json"===t.type?Object(w.jsx)("div",{children:Object(w.jsx)(N.a,{data:t.data,keyStyle:"color: rgb(130,40,144);",stringStyle:"color: rgb(153,68,60);",valueStyle:"color: rgb(25,1,199);",booleanStyle:"color: rgb(94,105,192);"})}):"binary"===t.type?Object(w.jsx)("div",{children:Object(w.jsx)("pre",{children:t.data})}):Object(w.jsx)("div",{style:{color:"gray"},children:"Not support preview"}):Object(w.jsx)("div",{style:{color:"gray"},children:"Not support preview"})}},{key:"hexview",value:function(){var e=this.props.flow;if(!e)return null;var t=e.response;return t?t.body&&t.body.byteLength?Object(w.jsx)("pre",{children:e.hexviewResponseBody()}):Object(w.jsx)("div",{style:{color:"gray"},children:"No response"}):null}},{key:"render",value:function(){var e=this;if(!this.props.flow)return null;var t=this.props.flow,s=this.state.flowTab,n=t.request,i=t.response||{},r=[];return t.url&&t.url.search&&t.url.searchParams.forEach((function(e,t){r.push({key:t,value:e})})),Object(w.jsxs)("div",{className:"flow-detail",children:[Object(w.jsxs)("div",{className:"header-tabs",children:[Object(w.jsx)("span",{onClick:function(){e.props.onClose()},children:"x"}),Object(w.jsx)("span",{className:"Headers"===s?"selected":void 0,onClick:function(){e.setState({flowTab:"Headers"})},children:"Headers"}),Object(w.jsx)("span",{className:"Preview"===s?"selected":void 0,onClick:function(){e.setState({flowTab:"Preview"})},children:"Preview"}),Object(w.jsx)("span",{className:"Response"===s?"selected":void 0,onClick:function(){e.setState({flowTab:"Response"})},children:"Response"}),Object(w.jsx)("span",{className:"Hexview"===s?"selected":void 0,onClick:function(){e.setState({flowTab:"Hexview"})},children:"Hexview"}),Object(w.jsx)(z,{flow:t,onChangeRequest:function(s){t.request.method=s.method,t.request.url=s.url,t.request.header=s.header,x(t.request)&&(t.request.body=s.body),e.props.onReRenderFlows()},onChangeResponse:function(s){t.response||(t.response={}),t.response.statusCode=s.statusCode,t.response.header=s.header,x(t.response)&&(t.response.body=s.body),e.props.onReRenderFlows()},onMessage:function(s){e.props.onMessage(s),t.waitIntercept=!1,e.props.onReRenderFlows()}})]}),Object(w.jsxs)("div",{style:{padding:"20px"},children:["Headers"!==s?null:Object(w.jsxs)("div",{children:[Object(w.jsx)("p",{children:Object(w.jsx)(p.a,{size:"sm",variant:this.state.copied?"success":"primary",disabled:this.state.copied,onClick:function(){var s=C()({url:t.request.url,method:t.request.method,headers:Object.keys(t.request.header).reduce((function(e,s){return e[s]=t.request.header[s][0],e}),{}),body:t.requestBody()});k()(s),e.setState({copied:!0},(function(){setTimeout((function(){e.setState({copied:!1})}),1e3)}))},children:this.state.copied?"Copied":"Copy as cURL"})}),Object(w.jsxs)("div",{className:"header-block",children:[Object(w.jsx)("p",{children:"General"}),Object(w.jsxs)("div",{className:"header-block-content",children:[Object(w.jsxs)("p",{children:["Request URL: ",n.url]}),Object(w.jsxs)("p",{children:["Request Method: ",n.method]}),Object(w.jsxs)("p",{children:["Status Code: ","".concat(i.statusCode||"(pending)")]})]})]}),i.header?Object(w.jsxs)("div",{className:"header-block",children:[Object(w.jsx)("p",{children:"Response Headers"}),Object(w.jsx)("div",{className:"header-block-content",children:Object.keys(i.header).map((function(e){return Object(w.jsxs)("p",{children:[e,": ",i.header[e].join(" ")]},e)}))})]}):null,Object(w.jsxs)("div",{className:"header-block",children:[Object(w.jsx)("p",{children:"Request Headers"}),Object(w.jsx)("div",{className:"header-block-content",children:n.header?Object.keys(n.header).map((function(e){return Object(w.jsxs)("p",{children:[e,": ",n.header[e].join(" ")]},e)})):null})]}),r.length?Object(w.jsxs)("div",{className:"header-block",children:[Object(w.jsx)("p",{children:"Query String Parameters"}),Object(w.jsx)("div",{className:"header-block-content",children:r.map((function(e){var t=e.key,s=e.value;return Object(w.jsxs)("p",{children:[t,": ",s]},t)}))})]}):null,n.body&&n.body.byteLength?Object(w.jsxs)("div",{className:"header-block",children:[Object(w.jsx)("p",{children:"Request Body"}),Object(w.jsx)("div",{className:"header-block-content",children:Object(w.jsxs)("div",{children:[Object(w.jsxs)("div",{className:"request-body-detail",style:{marginBottom:"15px"},children:[Object(w.jsx)("span",{className:"Raw"===this.state.requestBodyViewTab?"selected":void 0,onClick:function(){e.setState({requestBodyViewTab:"Raw"})},children:"Raw"}),Object(w.jsx)("span",{className:"Preview"===this.state.requestBodyViewTab?"selected":void 0,onClick:function(){e.setState({requestBodyViewTab:"Preview"})},children:"Preview"})]}),"Raw"!==this.state.requestBodyViewTab?null:Object(w.jsx)("div",{children:t.isTextRequest()?t.requestBody():Object(w.jsx)("span",{style:{color:"gray"},children:"Not text Request"})}),"Preview"!==this.state.requestBodyViewTab?null:Object(w.jsx)("div",{children:this.requestBodyPreview()})]})})]}):null]}),"Response"!==s?null:i.body&&i.body.byteLength?t.isTextResponse()?Object(w.jsxs)("div",{children:[Object(w.jsx)("div",{style:{marginBottom:"20px"},children:Object(w.jsx)(B.a,{inline:!0,type:"checkbox",checked:this.state.responseBodyLineBreak,onChange:function(t){e.setState({responseBodyLineBreak:t.target.checked})},label:"\u81ea\u52a8\u6362\u884c"})}),Object(w.jsx)("div",{style:{whiteSpace:this.state.responseBodyLineBreak?"pre-wrap":"pre"},children:t.responseBody()})]}):Object(w.jsx)("div",{style:{color:"gray"},children:"Not text response"}):Object(w.jsx)("div",{style:{color:"gray"},children:"No response"}),"Preview"!==s?null:Object(w.jsx)("div",{children:this.preview()}),"Hexview"!==s?null:Object(w.jsx)("div",{children:this.hexview()})]})]})}}]),s}(i.a.Component),G=function(){function e(){Object(a.a)(this,e),this.items=void 0,this._map=void 0,this.filterText=void 0,this.filterTimer=void 0,this.num=void 0,this.max=void 0,this.items=[],this._map=new Map,this.filterText="",this.filterTimer=null,this.num=0,this.max=1e3}return Object(c.a)(e,[{key:"showList",value:function(){var e=this.filterText;if(e&&(e=e.trim()),!e)return this.items;if(e.startsWith("/")&&e.endsWith("/")){if(!(e=e.slice(1,e.length-1).trim()))return this.items;try{var t=new RegExp(e);return this.items.filter((function(e){return t.test(e.request.url)}))}catch(s){return this.items}}return this.items.filter((function(t){return t.request.url.includes(e)}))}},{key:"add",value:function(e){if(e.no=++this.num,this.items.push(e),this._map.set(e.id,e),this.items.length>this.max){var t=this.items.shift();t&&this._map.delete(t.id)}}},{key:"get",value:function(e){return this._map.get(e)}},{key:"changeFilter",value:function(e){this.filterText=e}},{key:"changeFilterLazy",value:function(e,t){var s=this;this.filterTimer&&(clearTimeout(this.filterTimer),this.filterTimer=null),this.filterTimer=setTimeout((function(){s.filterText=e,t()}),300)}},{key:"clear",value:function(){this.items=[],this._map=new Map}}]),e}(),Y=[1,1,2,2,4,4,8,8,16,16,32,32],F=function(e){Object(l.a)(s,e);var t=Object(h.a)(s);function s(e){var n;return Object(a.a)(this,s),(n=t.call(this,e)).flowMgr=void 0,n.ws=void 0,n.wsUnmountClose=void 0,n.tableBottomRef=void 0,n.wsReconnCount=-1,n.flowMgr=new G,n.state={flows:n.flowMgr.showList(),flow:null,flowTab:"Headers",wsStatus:"close"},n.ws=null,n.wsUnmountClose=!1,n.tableBottomRef=i.a.createRef(),n}return Object(c.a)(s,[{key:"componentDidMount",value:function(){this.initWs()}},{key:"componentWillUnmount",value:function(){this.ws&&(this.wsUnmountClose=!0,this.ws.close(),this.ws=null)}},{key:"initWs",value:function(){var e,t=this;this.ws||(this.setState({wsStatus:"connecting"}),e=new URL(document.URL).host,this.ws=new WebSocket("ws://".concat(e,"/echo")),this.ws.binaryType="arraybuffer",this.ws.onopen=function(){t.wsReconnCount=-1,t.setState({wsStatus:"open"})},this.ws.onerror=function(e){var s;console.error("ERROR:",e),null===(s=t.ws)||void 0===s||s.close()},this.ws.onclose=function(){if(t.setState({wsStatus:"close"}),!t.wsUnmountClose){t.wsReconnCount++,t.ws=null;var e=Y[t.wsReconnCount]||Y[Y.length-1];console.info("will reconnect after ".concat(e," seconds")),setTimeout((function(){t.initWs()}),1e3*e)}},this.ws.onmessage=function(e){var s=function(e){if(e.byteLength<39)return null;var t=new Int8Array(e.slice(0,39));if(1!==t[0])return null;var s=t[1];if(!M.includes(s))return null;var n={type:s,id:(new TextDecoder).decode(e.slice(2,38)),waitIntercept:1===t[38]};if(39===e.byteLength)return n;if(s===g.REQUEST_BODY||s===g.RESPONSE_BODY)return n.content=e.slice(39),n;var i,r=(new TextDecoder).decode(e.slice(39));try{i=JSON.parse(r)}catch(o){return null}return n.content=i,n}(e.data);if(s){if(s.type===g.REQUEST){var n,i=new A(s);t.flowMgr.add(i);var r=!1;(null===(n=t.tableBottomRef)||void 0===n?void 0:n.current)&&function(e){var t=window.innerWidth||document.documentElement.clientWidth,s=window.innerHeight||document.documentElement.clientHeight,n=e.getBoundingClientRect(),i=n.top,r=n.right,o=n.bottom,a=n.left;return i>=0&&a>=0&&r<=t&&o<=s}(t.tableBottomRef.current)&&(r=!0),t.setState({flows:t.flowMgr.showList()},(function(){var e,s;r&&(null===(e=t.tableBottomRef)||void 0===e||null===(s=e.current)||void 0===s||s.scrollIntoView({behavior:"auto"}))}))}else if(s.type===g.REQUEST_BODY){var o=t.flowMgr.get(s.id);if(!o)return;o.addRequestBody(s),t.setState({flows:t.state.flows})}else if(s.type===g.RESPONSE){var a=t.flowMgr.get(s.id);if(!a)return;a.addResponse(s),t.setState({flows:t.state.flows})}else if(s.type===g.RESPONSE_BODY){var c=t.flowMgr.get(s.id);if(!c||!c.response)return;c.addResponseBody(s),t.setState({flows:t.state.flows})}}else console.error("parse error:",e.data)})}},{key:"render",value:function(){var e=this,t=this.state.flows;return Object(w.jsxs)("div",{className:"main-table-wrap",children:[Object(w.jsxs)("div",{className:"top-control",children:[Object(w.jsx)("div",{children:Object(w.jsx)(p.a,{size:"sm",onClick:function(){e.flowMgr.clear(),e.setState({flows:e.flowMgr.showList(),flow:null})},children:"Clear"})}),Object(w.jsx)("div",{children:Object(w.jsx)(u.a.Control,{size:"sm",placeholder:"Filter",onChange:function(t){var s=t.target.value;e.flowMgr.changeFilterLazy(s,(function(){e.setState({flows:e.flowMgr.showList()})}))}})}),Object(w.jsx)(O,{onSave:function(t){var s=function(e,t){if(e!==H.CHANGE_BREAK_POINT_RULES)throw new Error("invalid message type");var s=(new TextEncoder).encode(JSON.stringify(t)),n=new Uint8Array(2+s.byteLength);return n[0]=1,n[1]=e,n.set(s,2),n}(H.CHANGE_BREAK_POINT_RULES,t);e.ws&&e.ws.send(s)}}),Object(w.jsxs)("span",{children:["status: ",this.state.wsStatus]})]}),Object(w.jsxs)("div",{className:"table-wrap-div",children:[Object(w.jsxs)(d.a,{striped:!0,bordered:!0,size:"sm",style:{tableLayout:"fixed"},children:[Object(w.jsx)("thead",{children:Object(w.jsxs)("tr",{children:[Object(w.jsx)("th",{style:{width:"50px"},children:"No"}),Object(w.jsx)("th",{style:{width:"80px"},children:"Method"}),Object(w.jsx)("th",{style:{width:"200px"},children:"Host"}),Object(w.jsx)("th",{style:{width:"auto"},children:"Path"}),Object(w.jsx)("th",{style:{width:"150px"},children:"Type"}),Object(w.jsx)("th",{style:{width:"80px"},children:"Status"}),Object(w.jsx)("th",{style:{width:"90px"},children:"Size"}),Object(w.jsx)("th",{style:{width:"90px"},children:"Time"})]})}),Object(w.jsx)("tbody",{children:t.map((function(t){var s=t.preview();return Object(w.jsx)(E,{flow:s,isSelected:!(!e.state.flow||e.state.flow.id!==s.id),onShowDetail:function(){e.setState({flow:t})}},s.id)}))})]}),Object(w.jsx)("div",{ref:this.tableBottomRef,id:"hidden-bottom",style:{height:"0px",visibility:"hidden",marginBottom:"1px"}})]}),Object(w.jsx)(Q,{flow:this.state.flow,onClose:function(){e.setState({flow:null})},onReRenderFlows:function(){e.setState({flows:e.state.flows})},onMessage:function(t){e.ws&&e.ws.send(t)}})]})}}]),s}(i.a.Component),W=function(e){e&&e instanceof Function&&s.e(3).then(s.bind(null,67)).then((function(t){var s=t.getCLS,n=t.getFID,i=t.getFCP,r=t.getLCP,o=t.getTTFB;s(e),n(e),i(e),r(e),o(e)}))};o.a.render(Object(w.jsx)(i.a.StrictMode,{children:Object(w.jsx)(F,{})}),document.getElementById("root")),W()}},[[65,1,2]]]);
//# sourceMappingURL=main.dab9e469.chunk.js.map