| 7 | `?(S.seenCR||S.line++,S.column=1,S.seenCR=!1):H==="\r"||H==="\u2028"||H==="\u2029"?(S.line++,S.column=1,S.seenCR=!0):(S.column++,S.seenCR=!1),A++;return he[b]=S,S}function Oe(b,S){var A=We(b),H=We(S);return{start:{offset:b,line:A.line,column:A.column},end:{offset:S,line:H.line,column:H.column}}}function ee(b){C<B||(C>B&&(B=C,oe=[]),oe.push(b))}function Me(b,S,A,H){function Tt(Ce){var De=1;for(Ce.sort(function(ut,Ke){return ut.description<Ke.description?-1:ut.description>Ke.description?1:0});De<Ce.length;)Ce[De-1]===Ce[De]?Ce.splice(De,1):De++}function es(Ce,De){function ut(At){function ft(Fe){return Fe.charCodeAt(0).toString(16).toUpperCase()}return At.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(Fe){return"\\x0"+ft(Fe)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(Fe){return"\\x"+ft(Fe)}).replace(/[\u0100-\u0FFF]/g,function(Fe){return"\\u0"+ft(Fe)}).replace(/[\u1000-\uFFFF]/g,function(Fe){return"\\u"+ft(Fe)})}var Ke=new Array(Ce.length),vt,Rt,it;for(it=0;it<Ce.length;it++)Ke[it]=Ce[it].description;return vt=Ce.length>1?Ke.slice(0,-1).join(", ")+" or "+Ke[Ce.length-1]:Ke[0],Rt=De?'"'+ut(De)+'"':"end of input","Expected "+vt+" but "+Rt+" found."}return S!==null&&Tt(S),new e(es(S,A),S,A,H)}function Re(){var b,S,A,H;if(b=C,S=re(),S!==n){if(A=[],H=Je(),H!==n)for(;H!==n;)A.push(H),H=Je();else A=n;A!==n?(H=Re(),H!==n?(S=d(S,H),b=S):(C=b,b=n)):(C=b,b=n)}else C=b,b=n;if(b===n&&(b=C,S=re(),S!==n&&(S=f(S)),b=S,b===n)){for(b=C,S=[],A=Je();A!==n;)S.push(A),A=Je();S!==n&&(S=p()),b=S}return b}function re(){var b,S,A,H;if(q++,b=C,i.charCodeAt(C)===34?(S=g,C++):(S=n,q===0&&ee(_)),S!==n){for(A=[],H=ue();H!==n;)A.push(H),H=ue();A!==n?(i.charCodeAt(C)===34?(H=g,C++):(H=n,q===0&&ee(_)),H!==n?(S=j(A),b=S):(C=b,b=n)):(C=b,b=n)}else C=b,b=n;if(b===n){if(b=C,i.charCodeAt(C)===39?(S=y,C++):(S=n,q===0&&ee(w)),S!==n){for(A=[],H=ge();H!==n;)A.push(H),H=ge();A!==n?(i.charCodeAt(C)===39?(H=y,C++):(H=n,q===0&&ee(w)),H!==n?(S=j(A),b=S):(C=b,b=n)):(C=b,b=n)}else C=b,b=n;if(b===n){if(b=C,S=C,q++,A=Zt(),q--,A===n?S=void 0:(C=S,S=n),S!==n){if(A=[],H=Ae(),H!==n)for(;H!==n;)A.push(H),H=Ae();else A=n;A!==n?(S=j(A),b=S):(C=b,b=n)}else C=b,b=n;if(b===n){if(b=C,i.charCodeAt(C)===34?(S=g,C++):(S=n,q===0&&ee(_)),S!==n){for(A=[],H=ue();H!==n;)A.push(H),H=ue();A!==n?(S=j(A),b=S):(C=b,b=n)}else C=b,b=n;if(b===n)if(b=C,i.charCodeAt(C)===39?(S=y,C++):(S=n,q===0&&ee(w)),S!==n){for(A=[],H=ge();H!==n;)A.push(H),H=ge();A!==n?(S=j(A),b=S):(C=b,b=n)}else C=b,b=n}}}return q--,b===n&&(S=n,q===0&&ee(h)),b}function ue(){var b,S,A;return b=C,S=C,q++,$.test(i.charAt(C))?(A=i.charAt(C),C++):(A=n,q===0&&ee(N)),q--,A===n?S=void 0:(C=S,S=n),S!==n?(i.length>C?(A=i.charAt(C),C++):(A=n,q===0&&ee(E)),A!==n?(S=T(A),b=S):(C=b,b=n)):(C=b,b=n),b===n&&(b=C,i.charCodeAt(C)===92?(S=P,C++):(S=n,q===0&&ee(L)),S!==n?(A=nt(),A!==n?(S=T(A),b=S):(C=b,b=n)):(C=b,b=n)),b}function ge(){var b,S,A;return b=C,S=C,q++,O.test(i.charAt(C))?(A=i.charAt(C),C++):(A=n,q===0&&ee(M)),q--,A===n?S=void 0:(C=S,S=n),S!==n?(i.length>C?(A=i.charAt(C),C++):(A=n,q===0&&ee(E)),A!==n?(S=T(A),b=S):(C=b,b=n)):(C=b,b=n),b===n&&(b=C,i.charCodeAt(C)===92?(S=P,C++):(S=n,q===0&&ee(L)),S!==n?(A=nt(),A!==n?(S=T(A),b=S):(C=b,b=n)):(C=b,b=n)),b}function Ae(){var b,S,A;return b=C,S=C,q++,A=Je(),q--,A===n?S=void 0:(C=S,S=n),S!==n?(i.length>C?(A=i.charAt(C),C++):(A=n,q===0&&ee(E)),A!==n?(S=T(A),b=S):(C=b,b=n)):(C=b,b=n),b}function nt(){var b,S;return U.test(i.charAt(C))?(b=i.charAt(C),C++):(b=n,q===0&&ee(V)),b===n&&(b=C,i.charCodeAt(C)===110?(S=W,C++):(S=n,q===0&&ee(J)),S!==n&&(S=z()),b=S,b===n&&(b=C,i.charCodeAt(C)===114?(S=te,C++):(S=n,q===0&&ee(Y)),S!==n&&(S=Q()),b=S,b===n&&(b=C,i.charCodeAt(C)===116?(S=X,C++):(S=n,q===0&&ee(Z)),S!==n&&(S=ae()),b=S))),b}function Je(){var b;return q++,de.test(i.charAt(C))?(b=i.charAt(C),C++):(b=n,q===0&&ee(ye)),q--,b===n&&q===0&&ee(le),b}function Zt(){var b;return q++,Se.test(i.charAt(C))?(b=i.charAt(C),C++):(b=n,q===0&&ee(Ee)),q--,b===n&&q===0&&ee(Pe),b}if($e=a(),$e!==n&&C===i.length)return $e;throw $e!==n&&C<i.length&&ee({type:"end",description:"end of input"}),Me(null,oe,B<i.length?i.charAt(B):null,B<i.length?Oe(B,B+1):Oe(B,B))}return{SyntaxError:e,parse:s}}();function us(t,e=""){if(!t)return[];const s=[];for(const i of Object.keys(t))i.startsWith(e)&&s.push(i);return s}function Bu(t){const e=k.c(6),{results:s}=t,i=I.useRef(null);let r,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{i&&i.current.addEventListener("DOMNodeInserted",Ku)},n=[],e[0]=r,e[1]=n):(r=e[0],n=e[1]),I.useEffect(r,n);let l;e[2]!==s?(l=s.map(Wu),e[2]=s,e[3]=l):l=e[3];let a;return e[4]!==l?(a=o.jsx("div",{className:"command-result",ref:i,children:l}),e[4]=l,e[5]=a):a=e[5],a}function Wu(t,e){return o.jsxs("div",{children:[o.jsx("div",{children:o.jsxs("strong",{children:["$ ",t.command]})}),t.result]},e)}function Ku(t){const e=t.currentTarget;e.scroll({top:e.scrollHeight,behavior:"auto"})}function zu(t){const e=k.c(20),{nextArgs:s,currentArg:i,help:r,description:n,availableCommands:l}=t;let a;if(e[0]!==i||e[1]!==s){a=[];for(let w=0;w<s.length;w++){if(w==i){a.push(o.jsx("mark",{children:s[w]},w));continue}a.push(o.jsxs("span",{children:[s[w]," "]},w))}e[0]=i,e[1]=s,e[2]=a}else a=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx("div",{className:"arrow"}),e[3]=d):d=e[3];let f;e[4]!==a?(f=a.length>0&&o.jsxs("div",{children:[o.jsx("strong",{children:"Argument suggestion:"})," ",a]}),e[4]=a,e[5]=f):f=e[5];let p;e[6]!==r?(p=r?.includes("->")&&o.jsxs("div",{children:[o.jsx("strong",{children:"Signature help: "}),r]}),e[6]=r,e[7]=p):p=e[7];let h;e[8]!==n?(h=n&&o.jsxs("div",{children:["# ",n]}),e[8]=n,e[9]=h):h=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("strong",{children:"Available Commands: "}),e[10]=g):g=e[10];let _;e[11]!==l?(_=JSON.stringify(l),e[11]=l,e[12]=_):_=e[12];let j;e[13]!==_?(j=o.jsxs("div",{children:[g,o.jsx("p",{className:"available-commands",children:_})]}),e[13]=_,e[14]=j):j=e[14];let y;return e[15]!==f||e[16]!==p||e[17]!==h||e[18]!==j?(y=o.jsxs("div",{className:"argument-suggestion popover top",children:[d,o.jsxs("div",{className:"popover-content",children:[f,p,h,j]})]}),e[15]=f,e[16]=p,e[17]=h,e[18]=j,e[19]=y):y=e[19],y}function Gu(){const t=k.c(45),[e,s]=I.useState(""),[i,r]=I.useState(""),[n,l]=I.useState(0);let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=[],t[0]=a):a=t[0];const[d,f]=I.useState(a);let p;t[1]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[1]=p):p=t[1];const[h,g]=I.useState(p);let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_={},t[2]=_):_=t[2];const[j,y]=I.useState(_);let w;t[3]===Symbol.for("react.memo_cache_sentinel")?(w=[],t[3]=w):w=t[3];const[$,N]=I.useState(w),[E,T]=I.useState(0),[P,L]=I.useState(""),[O,M]=I.useState("");let U;t[4]===Symbol.for("react.memo_cache_sentinel")?(U=[],t[4]=U):U=t[4];const[V,W]=I.useState(U);let J;t[5]===Symbol.for("react.memo_cache_sentinel")?(J=[],t[5]=J):J=t[5];const[z,te]=I.useState(J),[Y,Q]=I.useState(void 0);let X,Z;t[6]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{ne("/commands",{method:"GET"}).then(ef).then(re=>{y(re),f(us(re)),g(Object.keys(re))}).catch(Zu)},Z=[],t[6]=X,t[7]=Z):(X=t[6],Z=t[7]),I.useEffect(X,Z);let ae,le;t[8]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>{Bt("commands.history.get").then(re=>{te(re.value)}).catch(Xu)},le=[],t[8]=ae,t[9]=le):(ae=t[8],le=t[9]),I.useEffect(ae,le);let de;t[10]!==j?(de=(re,ue)=>{const ge=ds.parse(ue),Ae=ds.parse(re);L(j[ge[0]]?.signature_help),M(j[ge[0]]?.help||""),f(us(j,Ae[0])),g(us(j,ge[0]));const nt=j[ge[0]]?.parameters.map(Qu);nt&&(N([ge[0],...nt]),T(ge.length-1))},t[10]=j,t[11]=de):de=t[11];const ye=de;let Pe;t[12]===Symbol.for("react.memo_cache_sentinel")?(Pe=re=>{s(re.target.value),r(re.target.value),l(0)},t[12]=Pe):Pe=t[12];const Se=Pe;let Ee;t[13]!==h||t[14]!==d||t[15]!==n||t[16]!==Y||t[17]!==z||t[18]!==e||t[19]!==V?(Ee=re=>{if(re.key==="Enter"){const[ue,...ge]=ds.parse(e);te([...z,e]),Bt("commands.history.add",e).catch(Ju),ne.post(`/commands/${ue}`,{arguments:ge}).then(Yu).then(Ae=>{Q(void 0),N([]),W([...V,{command:e,result:JSON.stringify(Ae.value||Ae.error)}])}).catch(Ae=>{Q(void 0),N([]),W([...V,{command:e,result:Ae.toString()}])}),L(""),M(""),s(""),r(""),l(0),f(h)}if(re.key==="ArrowUp"){let ue;Y===void 0?ue=z.length-1:ue=Math.max(0,Y-1),s(z[ue]),r(z[ue]),Q(ue)}if(re.key==="ArrowDown"){if(Y===void 0)return;if(Y==z.length-1)s(""),r(""),Q(void 0);else{const ue=Y+1;s(z[ue]),r(z[ue]),Q(ue)}}re.key==="Tab"&&(s(d[n]),l((n+1)%d.length),re.preventDefault()),re.stopPropagation()},t[13]=h,t[14]=d,t[15]=n,t[16]=Y,t[17]=z,t[18]=e,t[19]=V,t[20]=Ee):Ee=t[20];const C=Ee;let he;t[21]!==j||t[22]!==e||t[23]!==i||t[24]!==ye?(he=re=>{if(!e){g(Object.keys(j));return}ye(i,e),re.stopPropagation()},t[21]=j,t[22]=e,t[23]=i,t[24]=ye,t[25]=he):he=t[25];const B=he;let oe;t[26]===Symbol.for("react.memo_cache_sentinel")?(oe=o.jsx("div",{className:"command-title",children:"Command Result"}),t[26]=oe):oe=t[26];let q;t[27]!==V?(q=o.jsx(Bu,{results:V}),t[27]=V,t[28]=q):q=t[28];let $e;t[29]!==h||t[30]!==E||t[31]!==O||t[32]!==$||t[33]!==P?($e=o.jsx(zu,{nextArgs:$,currentArg:E,help:P,description:O,availableCommands:h}),t[29]=h,t[30]=E,t[31]=O,t[32]=$,t[33]=P,t[34]=$e):$e=t[34];let We;t[35]===Symbol.for("react.memo_cache_sentinel")?(We=je("command-input input-group"),t[35]=We):We=t[35];let Oe;t[36]===Symbol.for("react.memo_cache_sentinel")?(Oe=o.jsx("span",{className:"input-group-addon",children:o.jsx("i",{className:"fa fa-fw fa-terminal"})}),t[36]=Oe):Oe=t[36];const ee=e||"";let Me;t[37]!==C||t[38]!==B||t[39]!==ee?(Me=o.jsxs("div",{className:We,children:[Oe,o.jsx("input",{type:"text",placeholder:"Enter command",className:"form-control",value:ee,onChange:Se,onKeyDown:C,onKeyUp:B})]}),t[37]=C,t[38]=B,t[39]=ee,t[40]=Me):Me=t[40];let Re;return t[41]!==q||t[42]!==$e||t[43]!==Me?(Re=o.jsxs("div",{className:"command",children:[oe,q,$e,Me]}),t[41]=q,t[42]=$e,t[43]=Me,t[44]=Re):Re=t[44],Re}function Yu(t){return t.json()}function Ju(){return 0}function Qu(t){return t.name}function Xu(t){return console.error(t)}function Zu(t){return console.error(t)}function ef(t){return t.json()}function tf(t){const e=k.c(7),{checked:s,onToggle:i,text:r}=t,n="btn btn-toggle "+(s?"btn-primary":"btn-default"),l="fa fa-fw "+(s?"fa-check-square-o":"fa-square-o");let a;e[0]!==l?(a=o.jsx("i",{className:l}),e[0]=l,e[1]=a):a=e[1];let d;return e[2]!==i||e[3]!==n||e[4]!==a||e[5]!==r?(d=o.jsxs("div",{className:n,onClick:i,children:[a," ",r]}),e[2]=i,e[3]=n,e[4]=a,e[5]=r,e[6]=d):d=e[6],d}class sf extends I.Component{static defaultProps={rowHeight:18};heights;viewport=Te.createRef();constructor(e){super(e),this.heights={},this.state={vScroll:kt()},this.onViewportUpdate=this.onViewportUpdate.bind(this)}componentDidMount(){window.addEventListener("resize",this.onViewportUpdate),this.onViewportUpdate()}componentWillUnmount(){window.removeEventListener("resize",this.onViewportUpdate)}getSnapshotBeforeUpdate(){return Es(this.viewport)}componentDidUpdate(e,s,i){i&&Jr(this.viewport),this.onViewportUpdate()}onViewportUpdate(){const e=this.viewport.current,s=kt({itemCount:this.props.events.length,rowHeight:this.props.rowHeight,viewportTop:e.scrollTop,viewportHeight:e.offsetHeight,itemHeights:this.props.events.map(i=>this.heights[i.id])});Kt(this.state.vScroll,s)||this.setState({vScroll:s})}setHeight(e,s){if(s&&!this.heights[e]){const i=s.offsetHeight;this.heights[e]!==i&&(this.heights[e]=i,this.onViewportUpdate())}}render(){const{vScroll:e}=this.state,{events:s}=this.props;return o.jsxs("pre",{ref:this.viewport,onScroll:this.onViewportUpdate,children:[o.jsx("div",{style:{height:e.paddingTop}}),s.slice(e.start,e.end).map(i=>o.jsxs("div",{ref:r=>{this.setHeight(i.id,r)},children:[o.jsx(nf,{event:i}),i.message]},i.id)),o.jsx("div",{style:{height:e.paddingBottom}})]})}}function nf(t){const e=k.c(4),{event:s}=t;let i;e[0]!==s.level?(i={web:"html5",debug:"bug",warn:"exclamation-triangle",error:"ban"}[s.level]||"info",e[0]=s.level,e[1]=i):i=e[1];const n=`fa fa-fw fa-${i}`;let l;return e[2]!==n?(l=o.jsx("i",{className:n}),e[2]=n,e[3]=l):l=e[3],l}class rf extends I.Component{static defaultProps={defaultHeight:200};dragStart;constructor(e,s){super(e,s),this.state={height:this.props.defaultHeight},this.onDragStart=this.onDragStart.bind(this),this.onDragMove=this.onDragMove.bind(this),this.onDragStop=this.onDragStop.bind(this)}onDragStart(e){e.preventDefault(),this.dragStart=this.state.height+e.pageY,window.addEventListener("mousemove",this.onDragMove),window.addEventListener("mouseup",this.onDragStop),window.addEventListener("dragend",this.onDragStop)}onDragMove(e){e.preventDefault(),this.setState({height:this.dragStart-e.pageY})}onDragStop(e){e.preventDefault(),window.removeEventListener("mousemove",this.onDragMove)}render(){const{height:e}=this.state,{filters:s,events:i,toggleFilter:r,close:n}=this.props;return o.jsxs("div",{className:"eventlog",style:{height:e},children:[o.jsxs("div",{onMouseDown:this.onDragStart,children:["Eventlog",o.jsxs("div",{className:"pull-right",children:[Object.values(Gi).map(l=>o.jsx(tf,{text:l,checked:s[l],onToggle:()=>r(l)},l)),o.jsx("i",{onClick:n,className:"fa fa-close"})]})]}),o.jsx(sf,{events:i})]})}}const of=zt(t=>({filters:t.eventLog.filters,events:t.eventLog.view}),{close:Gt,toggleFilter:zi})(rf);function lf(){const t=k.c(56),e=D(uf),{mode:s,intercept:i,showhost:r,upstream_cert:n,rawtcp:l,http2:a,websocket:d,anticache:f,anticomp:p,stickyauth:h,stickycookie:g,stream_large_bodies:_,listen_host:j,listen_port:y,server:w,ssl_insecure:$}=D(df),N=D(af),E=D(cf);let T;t[0]!==s?(T=s&&(s.length!==1||s[0]!=="regular")&&o.jsx("span",{className:"label label-success",children:s.join(",")}),t[0]=s,t[1]=T):T=t[1];let P;t[2]!==i?(P=i&&o.jsxs("span",{className:"label label-success",children:["Intercept: ",i]}),t[2]=i,t[3]=P):P=t[3];let L;t[4]!==$?(L=$&&o.jsx("span",{className:"label label-danger",children:"ssl_insecure"}),t[4]=$,t[5]=L):L=t[5];let O;t[6]!==r?(O=r&&o.jsx("span",{className:"label label-success",children:"showhost"}),t[6]=r,t[7]=O):O=t[7];let M;t[8]!==n?(M=!n&&o.jsx("span",{className:"label label-success",children:"no-upstream-cert"}),t[8]=n,t[9]=M):M=t[9];let U;t[10]!==l?(U=!l&&o.jsx("span",{className:"label label-success",children:"no-raw-tcp"}),t[10]=l,t[11]=U):U=t[11];let V;t[12]!==a?(V=!a&&o.jsx("span",{className:"label label-success",children:"no-http2"}),t[12]=a,t[13]=V):V=t[13];let W;t[14]!==d?(W=!d&&o.jsx("span",{className:"label label-success",children:"no-websocket"}),t[14]=d,t[15]=W):W=t[15];let J;t[16]!==f?(J=f&&o.jsx("span",{className:"label label-success",children:"anticache"}),t[16]=f,t[17]=J):J=t[17];let z;t[18]!==p?(z=p&&o.jsx("span",{className:"label label-success",children:"anticomp"}),t[18]=p,t[19]=z):z=t[19];let te;t[20]!==h?(te=h&&o.jsxs("span",{className:"label label-success",children:["stickyauth: ",h]}),t[20]=h,t[21]=te):te=t[21];let Y;t[22]!==g?(Y=g&&o.jsxs("span",{className:"label label-success",children:["stickycookie: ",g]}),t[22]=g,t[23]=Y):Y=t[23];let Q;t[24]!==_?(Q=_&&o.jsxs("span",{className:"label label-success",children:["stream: ",hi(_)]}),t[24]=_,t[25]=Q):Q=t[25];let X;t[26]!==N||t[27]!==E?(X=E>0&&o.jsxs("span",{className:"label label-default",children:[N," of ",E," flows selected"]}),t[26]=N,t[27]=E,t[28]=X):X=t[28];let Z;t[29]!==j||t[30]!==y||t[31]!==w?(Z=w&&o.jsxs("span",{className:"label label-primary",title:"HTTP Proxy Server Address",children:[j||"*",":",y||8080]}),t[29]=j,t[30]=y,t[31]=w,t[32]=Z):Z=t[32];let ae;t[33]!==Z?(ae=o.jsx(gt,{children:Z}),t[33]=Z,t[34]=ae):ae=t[34];let le;t[35]!==e?(le=o.jsxs("span",{className:"label label-default",title:"Mitmproxy Version",children:["mitmproxy ",e]}),t[35]=e,t[36]=le):le=t[36];let de;t[37]!==ae||t[38]!==le?(de=o.jsxs("div",{className:"pull-right",children:[ae,le]}),t[37]=ae,t[38]=le,t[39]=de):de=t[39];let ye;return t[40]!==T||t[41]!==P||t[42]!==te||t[43]!==Y||t[44]!==Q||t[45]!==X||t[46]!==de||t[47]!==L||t[48]!==O||t[49]!==M||t[50]!==U||t[51]!==V||t[52]!==W||t[53]!==J||t[54]!==z?(ye=o.jsxs("footer",{children:[T,P,L,O,M,U,V,W,J,z,te,Y,Q,X,de]}),t[40]=T,t[41]=P,t[42]=te,t[43]=Y,t[44]=Q,t[45]=X,t[46]=de,t[47]=L,t[48]=O,t[49]=M,t[50]=U,t[51]=V,t[52]=W,t[53]=J,t[54]=z,t[55]=ye):ye=t[55],ye}function cf(t){return t.flows.list.length}function af(t){return t.flows.selected.length}function df(t){return t.options}function uf(t){return t.backendState.version}function ff(t){const e=k.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"modal-backdrop fade in"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsxs("div",{children:[i,o.jsx("div",{className:"modal modal-visible",id:"optionsModal",tabIndex:-1,role:"dialog","aria-labelledby":"options",children:o.jsx("div",{className:"modal-dialog modal-lg",role:"document",children:o.jsx("div",{className:"modal-content",children:s})})})]}),e[1]=s,e[2]=r):r=e[2],r}const pf=t=>{t.key!=="Escape"&&t.stopPropagation()};function so(t){const e=k.c(10);let s,i,r;e[0]!==t?({value:r,onChange:s,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let n;e[4]!==s?(n=a=>s(a.target.checked),e[4]=s,e[5]=n):n=e[5];let l;return e[6]!==i||e[7]!==n||e[8]!==r?(l=o.jsx("div",{className:"checkbox",children:o.jsxs("label",{children:[o.jsx("input",{type:"checkbox",checked:r,onChange:n,...i}),"Enable"]})}),e[6]=i,e[7]=n,e[8]=r,e[9]=l):l=e[9],l}function ci(t){const e=k.c(10);let s,i,r;e[0]!==t?({value:r,onChange:s,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);const n=r||"";let l;e[4]!==s?(l=d=>s(d.target.value),e[4]=s,e[5]=l):l=e[5];let a;return e[6]!==i||e[7]!==n||e[8]!==l?(a=o.jsx("input",{type:"text",value:n,onChange:l,...i}),e[6]=i,e[7]=n,e[8]=l,e[9]=a):a=e[9],a}function ai(t){return function({onChange:s,...i}){return o.jsx(t,{onChange:r=>s(r||null),...i})}}function di(t){const e=k.c(10);let s,i,r;e[0]!==t?({value:r,onChange:s,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let n;e[4]!==s?(n=a=>s(parseInt(a.target.value)),e[4]=s,e[5]=n):n=e[5];let l;return e[6]!==i||e[7]!==n||e[8]!==r?(l=o.jsx("input",{type:"number",value:r,onChange:n,...i}),e[6]=i,e[7]=n,e[8]=r,e[9]=l):l=e[9],l}function hf(t){const e=k.c(12);let s,i,r,n;if(e[0]!==t){const{value:d,onChange:f,choices:p,...h}=t;n=d,s=p,i=h,r=g=>f(g.target.value),e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n}else s=e[1],i=e[2],r=e[3],n=e[4];let l;e[5]!==s?(l=s.map(mf),e[5]=s,e[6]=l):l=e[6];let a;return e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==n?(a=o.jsx("select",{onChange:r,value:n,...i,children:l}),e[7]=i,e[8]=r,e[9]=l,e[10]=n,e[11]=a):a=e[11],a}function mf(t){return o.jsx("option",{value:t,children:t},t)}function gf(t){const e=k.c(13);let s,i,r;e[0]!==t?({value:r,onChange:s,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);const n=Math.max(r.length,1);let l;e[4]!==r?(l=r.join(` |
| 9 | `).map(xf).filter(vf))},e[6]=s,e[7]=f):f=e[7];const p=f;let h;return e[8]!==p||e[9]!==n||e[10]!==i||e[11]!==a?(h=o.jsx("textarea",{rows:n,value:a,onChange:p,...i}),e[8]=p,e[9]=n,e[10]=i,e[11]=a,e[12]=h):h=e[12],h}function vf(t){return t!==""}function xf(t){return t.trim()}const _f={bool:so,str:ci,int:di,"optional str":ai(ci),"optional int":ai(di),"sequence of str":gf};function jf(t){const e=k.c(16),{choices:s,type:i,value:r,onChange:n,name:l,error:a}=t;let d,f;if(e[0]!==d||e[1]!==s||e[2]!==n||e[3]!==i||e[4]!==r){if(f={onChange:n,value:r},s)d=hf,f.choices=s;else if(d=_f[i],!d)throw`unknown option type ${i}`;d!==so&&(f.className="form-control"),e[0]=d,e[1]=s,e[2]=n,e[3]=i,e[4]=r,e[5]=f,e[6]=d}else f=e[5],d=e[6];let p;e[7]!==a?(p=je({"has-error":a}),e[7]=a,e[8]=p):p=e[8];let h;e[9]!==d||e[10]!==l||e[11]!==f?(h=o.jsx(d,{name:l,onKeyDown:pf,...f}),e[9]=d,e[10]=l,e[11]=f,e[12]=h):h=e[12];let g;return e[13]!==p||e[14]!==h?(g=o.jsx("div",{className:p,children:h}),e[13]=p,e[14]=h,e[15]=g):g=e[15],g}function yf(t){const e=k.c(18),{name:s}=t,i=G();let r;e[0]!==s?(r=j=>j.options_meta[s]?.choices,e[0]=s,e[1]=r):r=e[1];const n=D(r);let l;e[2]!==s?(l=j=>j.options_meta[s]?.type,e[2]=s,e[3]=l):l=e[3];const a=D(l);let d;e[4]!==s?(d=j=>{const y=j.ui.optionsEditor[s];return y?y.value:j.options_meta[s]?.value},e[4]=s,e[5]=d):d=e[5];const f=D(d);let p;e[6]!==s?(p=j=>j.ui.optionsEditor[s]?.error,e[6]=s,e[7]=p):p=e[7];const h=D(p);let g;e[8]!==i||e[9]!==s?(g=j=>i(Cs(s,j)),e[8]=i,e[9]=s,e[10]=g):g=e[10];let _;return e[11]!==n||e[12]!==h||e[13]!==s||e[14]!==g||e[15]!==a||e[16]!==f?(_=o.jsx(jf,{name:s,choices:n,type:a,value:f,error:h,onChange:g}),e[11]=n,e[12]=h,e[13]=s,e[14]=g,e[15]=a,e[16]=f,e[17]=_):_=e[17],_}function wf(t){const e=k.c(4),{name:s}=t;let i;e[0]!==s?(i=l=>l.options_meta[s]?.help,e[0]=s,e[1]=i):i=e[1];const r=D(i);let n;return e[2]!==r?(n=o.jsx("div",{className:"help-block small",children:r}),e[2]=r,e[3]=n):n=e[3],n}function bf(t){const e=k.c(4),{name:s}=t;let i;e[0]!==s?(i=l=>l.options_meta[s]?.error,e[0]=s,e[1]=i):i=e[1];const r=D(i);if(!r)return null;let n;return e[2]!==r?(n=o.jsx("div",{className:"small text-danger",children:r}),e[2]=r,e[3]=n):n=e[3],n}function Sf(t){const e=k.c(2);let{value:s,defaultVal:i}=t;if(s===i)return null;{if(typeof i=="boolean")i=i?"true":"false";else if(Array.isArray(i)){if(Ht.isEmpty(Ht.compact(s))&&Ht.isEmpty(i))return null;i="[ ]"}else i===""?i='""':i===null&&(i="null");let r;return e[0]!==i?(r=o.jsxs("div",{className:"small",children:["Default: ",o.jsxs("strong",{children:[" ",i," "]})," "]}),e[0]=i,e[1]=r):r=e[1],r}}const $f=zt((t,{name:e})=>({value:t.options[e],defaultVal:t.options_meta[e]?.default}))(Sf);function Cf(){const t=k.c(24),e=G(),s=D(kf,Kt);let i,r,n,l;if(t[0]!==e||t[1]!==s){const h=s.sort();let g;t[6]!==e?(g=()=>e(Wi()),t[6]=e,t[7]=g):g=t[7];let _;t[8]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("i",{className:"fa fa-fw fa-times"}),t[8]=_):_=t[8];let j;t[9]!==g?(j=o.jsx("button",{type:"button",className:"close","data-dismiss":"modal",onClick:g,children:_}),t[9]=g,t[10]=j):j=t[10];let y;t[11]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx("div",{className:"modal-title",children:o.jsx("h4",{children:"Options"})}),t[11]=y):y=t[11],t[12]!==j?(l=o.jsxs("div",{className:"modal-header",children:[j,y]}),t[12]=j,t[13]=l):l=t[13],n="modal-body",i="form-horizontal",r=h.map(Nf),t[0]=e,t[1]=s,t[2]=i,t[3]=r,t[4]=n,t[5]=l}else i=t[2],r=t[3],n=t[4],l=t[5];let a;t[14]!==i||t[15]!==r?(a=o.jsx("div",{className:i,children:r}),t[14]=i,t[15]=r,t[16]=a):a=t[16];let d;t[17]!==n||t[18]!==a?(d=o.jsx("div",{className:n,children:a}),t[17]=n,t[18]=a,t[19]=d):d=t[19];let f;t[20]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsx("div",{className:"modal-footer"}),t[20]=f):f=t[20];let p;return t[21]!==l||t[22]!==d?(p=o.jsxs("div",{children:[l,d,f]}),t[21]=l,t[22]=d,t[23]=p):p=t[23],p}function Nf(t){return o.jsxs("div",{className:"form-group",children:[o.jsxs("div",{className:"col-xs-6",children:[o.jsx("label",{htmlFor:t,children:t}),o.jsx(wf,{name:t})]}),o.jsxs("div",{className:"col-xs-6",children:[o.jsx(yf,{name:t}),o.jsx(bf,{name:t}),o.jsx($f,{name:t})]})]},t)}function kf(t){return Object.keys(t.options_meta)}function Ef(){const t=k.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(ff,{children:o.jsx(Cf,{})}),t[0]=e):e=t[0],e}const Tf={OptionModal:Ef};function Rf(){const t=k.c(3),e=D(Af),s=e?Tf[e]:void 0;if(s){let i;return t[0]!==s?(i=o.jsx(s,{}),t[0]=s,t[1]=i):i=t[1],i}else{let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(o.Fragment,{}),t[2]=i):i=t[2],i}}function Af(t){return t.ui.modal.activeModal}class Df extends I.Component{state={};render=()=>{const{showEventLog:e,showCommandBar:s}=this.props;return this.state.error?(console.log("ERR",this.state),o.jsxs("div",{className:"container",children:[o.jsx("h1",{children:"mitmproxy has crashed."}),o.jsxs("pre",{children:[this.state.error.stack,o.jsx("br",{}),o.jsx("br",{}),"Component Stack:",this.state.errorInfo?.componentStack]}),o.jsxs("p",{children:["Please lodge a bug report at"," ",o.jsx("a",{href:"https://github.com/mitmproxy/mitmproxy/issues",children:"https://github.com/mitmproxy/mitmproxy/issues"}),"."]})]})):o.jsxs("div",{id:"container",tabIndex:0,children:[o.jsx(Hu,{}),o.jsx(lu,{}),s&&o.jsx(Gu,{},"commandbar"),e&&o.jsx(of,{},"eventlog"),o.jsx(lf,{}),o.jsx(Rf,{})]})};componentDidMount(){window.addEventListener("keydown",this.props.onKeyDown)}componentWillUnmount(){window.removeEventListener("keydown",this.props.onKeyDown)}componentDidCatch(e,s){this.setState({error:e,errorInfo:s})}}const Ff=zt(t=>({showEventLog:t.eventLog.visible,showCommandBar:t.commandBar.visible}),{onKeyDown:od})(Df),Ze={SEARCH:"s",HIGHLIGHT:"h",SHOW_EVENTLOG:"e",SHOW_COMMANDBAR:"c"};function If(t){const[e,s]=window.location.hash.substr(1).split("?",2),i=e.substr(1).split("/");if(i[0]==="flows"){if(i.length==3){const[r,n]=i.slice(1);t.dispatch(Ut(n));const l=()=>{const d=t.getState().flows.byId.get(r);d!==void 0&&(a(),t.dispatch(Ve([d])))},a=t.subscribe(l);l()}}else i[0]==="capture"&&t.dispatch(Vt(xe.Capture));s&&s.split("&").forEach(r=>{const[n,l]=r.split("=",2),a=decodeURIComponent(l);switch(n){case Ze.SEARCH:t.dispatch(Ri(a));break;case Ze.HIGHLIGHT:t.dispatch(Ai(a));break;case Ze.SHOW_EVENTLOG:t.getState().eventLog.visible||t.dispatch(Gt());break;case Ze.SHOW_COMMANDBAR:t.getState().commandBar.visible||t.dispatch(Ji());break;default:console.error(`unimplemented query arg: ${r}`)}})}function Lf(t){const e=t.getState(),s={[Ze.SEARCH]:e.ui.filter[ve.Search],[Ze.HIGHLIGHT]:e.ui.filter[ve.Highlight],[Ze.SHOW_EVENTLOG]:e.eventLog.visible,[Ze.SHOW_COMMANDBAR]:e.commandBar.visible},i=Object.keys(s).filter(l=>s[l]).map(l=>`${l}=${encodeURIComponent(s[l])}`).join("&");let r;e.ui.tabs.current===xe.Capture?r="/capture":e.flows.selected.length>0?r=`/flows/${e.flows.selected[0].id}/${e.ui.flow.tab}`:r="/flows",i&&(r+="?"+i);let n=window.location.pathname;n==="blank"&&(n="/"),window.location.hash.substr(1)!==r&&history.replaceState(void 0,"",`${n}#${r}`)}function Pf(t){If(t),t.subscribe(()=>Lf(t))}var lt=(t=>(t.State="state",t.Flows="flows",t.Events="events",t.Options="options",t))(lt||{});class Of{activeFetches;store;filterState;socket;messageQueue;constructor(e){this.activeFetches={},this.store=e,this.filterState=Ti,this.messageQueue=[],this.connect(),this.store.subscribe(this.onStoreUpdate.bind(this))}connect(){this.socket=new WebSocket(location.origin.replace("http","ws")+location.pathname.replace(/\/$/,"")+"/updates"),this.socket.addEventListener("open",()=>this.onOpen()),this.socket.addEventListener("close",e=>this.onClose(e)),this.socket.addEventListener("message",e=>this.onMessage(JSON.parse(e.data))),this.socket.addEventListener("error",e=>this.onError(e))}async onOpen(){for(const e of this.messageQueue)this.socket.send(JSON.stringify(e));this.messageQueue=[],this.store.dispatch(Cc()),await Promise.all([this.fetchData("state"),this.fetchData("flows"),this.fetchData("events"),this.fetchData("options")]),this.store.dispatch(Nc())}onStoreUpdate(){const e=this.store.getState().ui.filter;if(e!==this.filterState){for(const s of Object.values(ve))this.filterState[s]!==e[s]&&this.sendMessage({type:"flows/updateFilter",payload:{name:s,expr:e[s]}});this.filterState=e}}fetchData(e){const s=[];return this.activeFetches[e]=s,ne(`./${e}`).then(i=>i.json()).then(i=>{this.activeFetches[e]===s&&this.receive(e,i)})}onMessage(e){switch(e.type){case"flows/add":return this.queueOrDispatch("flows",Mi(e.payload));case"flows/update":return this.queueOrDispatch("flows",qi(e.payload));case"flows/filterUpdate":return this.queueOrDispatch("flows",Vi(e.payload));case"flows/remove":return this.queueOrDispatch("flows",Hi(e.payload));case"events/add":return this.queueOrDispatch("events",Ss(e.payload));case"options/update":return this.queueOrDispatch("options",$s(e.payload));case"state/update":return this.queueOrDispatch("state",Be(e.payload));case"flows/reset":return this.fetchData("flows");case"events/reset":return this.fetchData("events");default:Ct(e.type)}}sendMessage(e){this.socket.readyState===WebSocket.OPEN?this.socket.send(JSON.stringify(e)):this.socket.readyState===WebSocket.CONNECTING?this.messageQueue.push(e):console.error("WebSocket is not open. Cannot send:",e)}queueOrDispatch(e,s){const i=this.activeFetches[e];i!==void 0?i.push(s):this.store.dispatch(s)}receive(e,s){switch(e){case"state":this.store.dispatch(Ue(s));break;case"options":this.store.dispatch(Yt(s));break;case"events":this.store.dispatch(Ki(s));break;case"flows":this.store.dispatch(bs(s));break;default:Ct(e)}const i=this.activeFetches[e];delete this.activeFetches[e],i.forEach(r=>this.store.dispatch(r))}onClose(e){this.store.dispatch(kc(`Connection closed at ${new Date().toUTCString()} with error code ${e.code}.`)),console.error("websocket connection closed",e)}onError(...e){console.error("websocket connection errored",e)}}class Mf{store;constructor(e){this.store=e,this.onOpen()}onOpen(){this.fetchData(lt.Flows),this.fetchData(lt.Options)}fetchData(e){ne(`./${e}`).then(s=>s.json()).then(s=>{this.receive(e,s)})}receive(e,s){switch(e){case lt.Flows:this.store.dispatch(bs(s));break;case lt.Options:this.store.dispatch(Yt(s));break;case lt.State:throw"unreachable";case lt.Events:throw"unreachable";default:Ct(e)}}}window.MITMWEB_STATIC?window.backend=new Mf(Nt):window.backend=new Of(Nt);Pf(Nt);window.addEventListener("error",t=>{Nt.dispatch(hc(`${t.message} |