(this["webpackJsonpmitmproxy-client"]=this["webpackJsonpmitmproxy-client"]||[]).push([[0],{49:function(e,t,s){},54:function(e,t,s){"use strict";s.r(t);var n,i=s(0),r=s.n(i),o=s(20),a=s.n(o),c=(s(48),s(9)),l=s(10),h=s(19),d=s(18),u=s(42),j=s(7),p=s(11),b=s(41),f=s.n(b),O=(s(49),s(21)),v=s(16),w=s(12),x=s(33),y=s(23),S=s(1),E=function(e){Object(h.a)(s,e);var t=Object(d.a)(s);function s(e){var n;return Object(c.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(l.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(S.jsxs)("div",{children:[Object(S.jsx)(p.a,{variant:n,size:"sm",onClick:this.handleShow,children:"BreakPoint"}),Object(S.jsxs)(w.a,{show:this.state.show,onHide:this.handleClose,children:[Object(S.jsx)(w.a.Header,{closeButton:!0,children:Object(S.jsx)(w.a.Title,{children:"Set BreakPoint"})}),Object(S.jsxs)(w.a.Body,{children:[Object(S.jsxs)(j.a.Group,{as:x.a,children:[Object(S.jsx)(j.a.Label,{column:!0,sm:2,children:"Method"}),Object(S.jsx)(y.a,{sm:10,children:Object(S.jsxs)(j.a.Control,{as:"select",value:s.method,onChange:function(t){e.setState({rule:Object(O.a)(Object(O.a)({},s),{},{method:t.target.value})})},children:[Object(S.jsx)("option",{children:"ALL"}),Object(S.jsx)("option",{children:"GET"}),Object(S.jsx)("option",{children:"POST"}),Object(S.jsx)("option",{children:"PUT"}),Object(S.jsx)("option",{children:"DELETE"})]})})]}),Object(S.jsxs)(j.a.Group,{as:x.a,children:[Object(S.jsx)(j.a.Label,{column:!0,sm:2,children:"URL"}),Object(S.jsx)(y.a,{sm:10,children:Object(S.jsx)(j.a.Control,{value:s.url,onChange:function(t){e.setState({rule:Object(O.a)(Object(O.a)({},s),{},{url:t.target.value})})}})})]}),Object(S.jsxs)(j.a.Group,{as:x.a,children:[Object(S.jsx)(j.a.Label,{column:!0,sm:2,children:"Action"}),Object(S.jsx)(y.a,{sm:10,children:Object(S.jsxs)(j.a.Control,{as:"select",value:s.action,onChange:function(t){e.setState({rule:Object(O.a)(Object(O.a)({},s),{},{action:parseInt(t.target.value)})})},children:[Object(S.jsx)("option",{value:"1",children:"Request"}),Object(S.jsx)("option",{value:"2",children:"Response"}),Object(S.jsx)("option",{value:"3",children:"Both"})]})})]})]}),Object(S.jsxs)(w.a.Footer,{children:[Object(S.jsx)(p.a,{variant:"secondary",onClick:this.handleClose,children:"Close"}),Object(S.jsx)(p.a,{variant:"primary",onClick:this.handleSave,children:"Save"})]})]})]})}}]),s}(r.a.Component),m=s(39),R=s(34),g=s(43),T=s(40),C=function(e){return!!e&&(!!e.header&&(!!e.header["Content-Type"]&&/text|javascript|json|x-www-form-urlencoded/.test(e.header["Content-Type"].join(""))))},_=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"};!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"}(n||(n={}));var N=function(){function e(t){Object(c.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.startTime=Date.now(),this.endTime=0,this.costTime="(pending)",this.status=n.REQUEST,this._isTextRequest=void 0,this._isTextResponse=void 0,this._requestBody=void 0,this._responseBody=void 0,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(l.a)(e,[{key:"addRequestBody",value:function(e){return this.status=n.REQUEST_BODY,this.waitIntercept=e.waitIntercept,this.request.body=e.content,this}},{key:"addResponse",value:function(e){return this.status=n.RESPONSE,this.waitIntercept=e.waitIntercept,this.response=e.content,this.response&&this.response.header&&null!=this.response.header["Content-Length"]&&(this.headerContentLengthExist=!0,this._size=parseInt(this.response.header["Content-Length"][0]),this.size=_(this._size)),this}},{key:"addResponseBody",value:function(e){return this.status=n.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=_(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}}},{key:"isTextRequest",value:function(){return null!==this._isTextRequest||(this._isTextRequest=C(this.request)),this._isTextRequest}},{key:"requestBody",value:function(){return null!==this._requestBody?this._requestBody:this.isTextRequest()?this.statusthis.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}(),D=function(e){Object(h.a)(s,e);var t=Object(d.a)(s);function s(e){var n;return Object(c.a)(this,s),(n=t.call(this,e)).flowMgr=void 0,n.ws=void 0,n.pageBottom=void 0,n.autoScore=!1,n.flowMgr=new U,n.state={flows:n.flowMgr.showList(),flow:null,flowTab:"Headers"},n.ws=null,n.pageBottom=null,n}return Object(l.a)(s,[{key:"componentDidMount",value:function(){this.initWs()}},{key:"componentWillUnmount",value:function(){this.ws&&this.ws.close()}},{key:"initWs",value:function(){var e,t=this;this.ws||(e=new URL(document.URL).host,this.ws=new WebSocket("ws://".concat(e,"/echo")),this.ws.binaryType="arraybuffer",this.ws.onopen=function(){console.log("OPEN")},this.ws.onclose=function(){console.log("CLOSE")},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(!k.includes(s))return null;var i={type:s,id:(new TextDecoder).decode(e.slice(2,38)),waitIntercept:1===t[38]};if(39===e.byteLength)return i;if(s===n.REQUEST_BODY||s===n.RESPONSE_BODY)return i.content=e.slice(39),i;var r,o=(new TextDecoder).decode(e.slice(39));try{r=JSON.parse(o)}catch(a){return null}return i.content=r,i}(e.data);if(s){if(s.type===n.REQUEST){var i=new N(s);t.flowMgr.add(i),t.setState({flows:t.flowMgr.showList()},(function(){t.pageBottom&&t.autoScore&&t.pageBottom.scrollIntoView({behavior:"auto"})}))}else if(s.type===n.REQUEST_BODY){var r=t.flowMgr.get(s.id);if(!r)return;r.addRequestBody(s),t.setState({flows:t.state.flows})}else if(s.type===n.RESPONSE){var o=t.flowMgr.get(s.id);if(!o)return;o.addResponse(s),t.setState({flows:t.state.flows})}else if(s.type===n.RESPONSE_BODY){var a=t.flowMgr.get(s.id);if(!a||!a.response)return;a.addResponseBody(s),t.setState({flows:t.state.flows})}}else console.error("parse error:",e.data)},this.ws.onerror=function(e){console.log("ERROR:",e)})}},{key:"initScrollMonitor",value:function(){var e=this;if(this.pageBottom){var t=f.a.create(this.pageBottom);t.enterViewport((function(){e.autoScore=!0})),t.exitViewport((function(){e.autoScore=!1}))}}},{key:"renderFlow",value:function(){var e=this,t=this.state,s=t.flow,n=t.flowTab;if(!s)return null;var i=s.request,r=s.response||{};return Object(S.jsxs)("div",{className:"flow-detail",children:[Object(S.jsxs)("div",{className:"header-tabs",children:[Object(S.jsx)("span",{onClick:function(){e.setState({flow:null})},children:"x"}),Object(S.jsx)("span",{className:"Headers"===n?"selected":void 0,onClick:function(){e.setState({flowTab:"Headers"})},children:"Headers"}),Object(S.jsx)("span",{className:"Preview"===n?"selected":void 0,onClick:function(){e.setState({flowTab:"Preview"})},children:"Preview"}),Object(S.jsx)("span",{className:"Response"===n?"selected":void 0,onClick:function(){e.setState({flowTab:"Response"})},children:"Response"}),Object(S.jsx)(L,{flow:s,onChangeRequest:function(t){s.request.method=t.method,s.request.url=t.url,s.request.header=t.header,C(s.request)&&(s.request.body=t.body),e.setState({flows:e.state.flows})},onChangeResponse:function(t){s.response||(s.response={}),s.response.statusCode=t.statusCode,s.response.header=t.header,C(s.response)&&(s.response.body=t.body),e.setState({flows:e.state.flows})},onMessage:function(t){e.ws&&e.ws.send(t),s.waitIntercept=!1,e.setState({flows:e.state.flows})}})]}),Object(S.jsxs)("div",{style:{padding:"20px"},children:["Headers"!==n?null:Object(S.jsxs)("div",{children:[Object(S.jsxs)("div",{className:"header-block",children:[Object(S.jsx)("p",{children:"General"}),Object(S.jsxs)("div",{className:"header-block-content",children:[Object(S.jsxs)("p",{children:["Request URL: ",i.url]}),Object(S.jsxs)("p",{children:["Request Method: ",i.method]}),Object(S.jsxs)("p",{children:["Status Code: ","".concat(r.statusCode||"(pending)")]})]})]}),r.header?Object(S.jsxs)("div",{className:"header-block",children:[Object(S.jsx)("p",{children:"Response Headers"}),Object(S.jsx)("div",{className:"header-block-content",children:Object.keys(r.header).map((function(e){return Object(S.jsxs)("p",{children:[e,": ",r.header[e].join(" ")]},e)}))})]}):null,Object(S.jsxs)("div",{className:"header-block",children:[Object(S.jsx)("p",{children:"Request Headers"}),Object(S.jsx)("div",{className:"header-block-content",children:i.header?Object.keys(i.header).map((function(e){return Object(S.jsxs)("p",{children:[e,": ",i.header[e].join(" ")]},e)})):null})]}),i.body&&i.body.byteLength?Object(S.jsxs)("div",{className:"header-block",children:[Object(S.jsx)("p",{children:"Request Body"}),Object(S.jsx)("div",{className:"header-block-content",children:Object(S.jsx)("p",{children:s.isTextRequest()?s.requestBody():Object(S.jsx)("span",{style:{color:"gray"},children:"Not text"})})})]}):null]}),"Response"!==n?null:r.body&&r.body.byteLength?s.isTextResponse()?Object(S.jsx)("div",{children:s.responseBody()}):Object(S.jsx)("div",{style:{color:"gray"},children:"Not text response"}):Object(S.jsx)("div",{style:{color:"gray"},children:"No response"})]})]})}},{key:"render",value:function(){var e=this,t=this.state.flows;return Object(S.jsxs)("div",{className:"main-table-wrap",children:[Object(S.jsxs)("div",{className:"top-control",children:[Object(S.jsx)("div",{children:Object(S.jsx)(p.a,{size:"sm",onClick:function(){e.flowMgr.clear(),e.setState({flows:e.flowMgr.showList(),flow:null})},children:"Clear"})}),Object(S.jsx)("div",{children:Object(S.jsx)(j.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(S.jsx)(E,{onSave:function(t){var s=function(e,t){if(e!==B.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}(B.CHANGE_BREAK_POINT_RULES,t);e.ws&&e.ws.send(s)}})]}),Object(S.jsxs)(u.a,{striped:!0,bordered:!0,size:"sm",style:{tableLayout:"fixed"},children:[Object(S.jsx)("thead",{children:Object(S.jsxs)("tr",{children:[Object(S.jsx)("th",{style:{width:"50px"},children:"No"}),Object(S.jsx)("th",{style:{width:"80px"},children:"Method"}),Object(S.jsx)("th",{style:{width:"200px"},children:"Host"}),Object(S.jsx)("th",{style:{width:"600px"},children:"Path"}),Object(S.jsx)("th",{style:{width:"80px"},children:"Status"}),Object(S.jsx)("th",{style:{width:"90px"},children:"Size"}),Object(S.jsx)("th",{style:{width:"90px"},children:"Time"})]})}),Object(S.jsx)("tbody",{children:t.map((function(t){var s=t.preview();return Object(S.jsx)(P,{flow:s,isSelected:!(!e.state.flow||e.state.flow.id!==s.id),onShowDetail:function(){e.setState({flow:t})}},s.id)}))})]}),this.renderFlow(),Object(S.jsx)("div",{ref:function(t){e.pageBottom||(e.pageBottom=t,e.initScrollMonitor())},style:{height:"0px",visibility:"hidden"},children:"bottom"})]})}}]),s}(r.a.Component),A=function(e){e&&e instanceof Function&&s.e(3).then(s.bind(null,56)).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)}))};a.a.render(Object(S.jsx)(r.a.StrictMode,{children:Object(S.jsx)(D,{})}),document.getElementById("root")),A()}},[[54,1,2]]]); //# sourceMappingURL=main.01aeb3c5.chunk.js.map