From 1fcd0335d59c301d73d1b1ef676ecafcf520ab79 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Tue, 12 Dec 2023 11:24:29 -0600 Subject: [PATCH 001/283] Fix response `content-length` when reading from HAR files (#6548) #### Description Closes https://github.com/mitmproxy/mitmproxy/issues/6547 Responses in flows constructed from HAR files were using the `Response.make` utility which resulted in the injection of `content-length` headers. When a `content-length` header existed already, this could cause failures during replay. #### Checklist - [x] I have updated tests where applicable. - [x] I have added an entry to the CHANGELOG. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- CHANGELOG.md | 2 + mitmproxy/http.py | 40 +--- mitmproxy/io/har.py | 43 +++- mitmproxy/net/http/headers.py | 37 ++++ test/mitmproxy/data/har_files/charles.json | 2 +- test/mitmproxy/data/har_files/chrome.json | 11 +- test/mitmproxy/data/har_files/firefox.json | 67 +----- .../data/har_files/head-content-length.har | 179 ++++++++++++++++ .../data/har_files/head-content-length.json | 193 ++++++++++++++++++ test/mitmproxy/data/har_files/safari.json | 46 +---- test/mitmproxy/net/http/test_headers.py | 34 +++ 11 files changed, 492 insertions(+), 162 deletions(-) create mode 100644 test/mitmproxy/data/har_files/head-content-length.har create mode 100644 test/mitmproxy/data/har_files/head-content-length.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 7db955d1f3..4aaab21f41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ## Unreleased: mitmproxy next +* Fix bug where response flows from HAR files had incorrect `content-length` headers + ([#6548](https://github.com/mitmproxy/mitmproxy/pull/6548), @zanieb) * Improved handling for `--allow-hosts`/`--ignore-hosts` options in WireGuard mode (#5930). ([#6513](https://github.com/mitmproxy/mitmproxy/pull/6513), @dsphper) * DNS resolution is now exempted from `--ignore-hosts` in WireGuard Mode. diff --git a/mitmproxy/http.py b/mitmproxy/http.py index 986e6b8983..bfffac567c 100644 --- a/mitmproxy/http.py +++ b/mitmproxy/http.py @@ -1,7 +1,6 @@ import binascii import json import os -import re import time import urllib.parse import warnings @@ -27,6 +26,7 @@ from mitmproxy.net.http import status_codes from mitmproxy.net.http import url from mitmproxy.net.http.headers import assemble_content_type +from mitmproxy.net.http.headers import infer_content_encoding from mitmproxy.net.http.headers import parse_content_type from mitmproxy.utils import human from mitmproxy.utils import strutils @@ -402,45 +402,11 @@ def get_content(self, strict: bool = True) -> bytes | None: else: return self.raw_content - def _get_content_type_charset(self) -> str | None: - ct = parse_content_type(self.headers.get("content-type", "")) - if ct: - return ct[2].get("charset") - return None - - def _guess_encoding(self, content: bytes = b"") -> str: - enc = self._get_content_type_charset() - if not enc: - if "json" in self.headers.get("content-type", ""): - enc = "utf8" - if not enc: - if "html" in self.headers.get("content-type", ""): - meta_charset = re.search( - rb"""]+charset=['"]?([^'">]+)""", content, re.IGNORECASE - ) - if meta_charset: - enc = meta_charset.group(1).decode("ascii", "ignore") - if not enc: - if "text/css" in self.headers.get("content-type", ""): - # @charset rule must be the very first thing. - css_charset = re.match( - rb"""@charset "([^"]+)";""", content, re.IGNORECASE - ) - if css_charset: - enc = css_charset.group(1).decode("ascii", "ignore") - if not enc: - enc = "latin-1" - # Use GB 18030 as the superset of GB2312 and GBK to fix common encoding problems on Chinese websites. - if enc.lower() in ("gb2312", "gbk"): - enc = "gb18030" - - return enc - def set_text(self, text: str | None) -> None: if text is None: self.content = None return - enc = self._guess_encoding() + enc = infer_content_encoding(self.headers.get("content-type", "")) try: self.content = cast(bytes, encoding.encode(text, enc)) @@ -464,7 +430,7 @@ def get_text(self, strict: bool = True) -> str | None: content = self.get_content(strict) if content is None: return None - enc = self._guess_encoding(content) + enc = infer_content_encoding(self.headers.get("content-type", ""), content) try: return cast(str, encoding.decode(content, enc)) except ValueError: diff --git a/mitmproxy/io/har.py b/mitmproxy/io/har.py index cf2dc0ce3a..c3178214bc 100644 --- a/mitmproxy/io/har.py +++ b/mitmproxy/io/har.py @@ -7,6 +7,7 @@ from mitmproxy import connection from mitmproxy import exceptions from mitmproxy import http +from mitmproxy.net.http.headers import infer_content_encoding logger = logging.getLogger(__name__) @@ -85,24 +86,52 @@ def request_to_flow(request_json: dict) -> http.HTTPFlow: # In Firefox HAR files images don't include response bodies response_content = request_json["response"]["content"].get("text", "") content_encoding = request_json["response"]["content"].get("encoding", None) + response_headers = fix_headers(request_json["response"]["headers"]) + if content_encoding == "base64": response_content = base64.b64decode(response_content) - response_headers = fix_headers(request_json["response"]["headers"]) + elif isinstance(response_content, str): + # Convert text to bytes, as in `Response.set_text` + try: + response_content = http.encoding.encode( + response_content, + ( + content_encoding + or infer_content_encoding(response_headers.get("content-type", "")) + ), + ) + except ValueError: + # Fallback to UTF-8 + response_content = response_content.encode( + "utf-8", errors="surrogateescape" + ) + + # Then encode the content, as in `Response.set_content` + response_content = http.encoding.encode( + response_content, response_headers.get("content-encoding") or "identity" + ) - new_flow.response = http.Response.make( - response_code, response_content, response_headers + new_flow.response = http.Response( + b"HTTP/1.1", + response_code, + http.status_codes.RESPONSES.get(response_code, "").encode(), + response_headers, + response_content, + None, + timestamp_start, + timestamp_end, ) - # Change time to match HAR file + # Update timestamps + new_flow.request.timestamp_start = timestamp_start new_flow.request.timestamp_end = timestamp_end - new_flow.response.timestamp_start = timestamp_start - new_flow.response.timestamp_end = timestamp_end - new_flow.client_conn.timestamp_start = timestamp_start new_flow.client_conn.timestamp_end = timestamp_end + # Update HTTP version + match http_version_req: case "http/2.0": new_flow.request.http_version = "HTTP/2" diff --git a/mitmproxy/net/http/headers.py b/mitmproxy/net/http/headers.py index e87efc5032..7e14b2a77c 100644 --- a/mitmproxy/net/http/headers.py +++ b/mitmproxy/net/http/headers.py @@ -1,4 +1,5 @@ import collections +import re def parse_content_type(c: str) -> tuple[str, str, dict[str, str]] | None: @@ -33,3 +34,39 @@ def assemble_content_type(type, subtype, parameters): return f"{type}/{subtype}" params = "; ".join(f"{k}={v}" for k, v in parameters.items()) return f"{type}/{subtype}; {params}" + + +def infer_content_encoding(content_type: str, content: bytes = b"") -> str: + """ + Infer the encoding of content from the content-type header. + """ + # Use the charset from the header if possible + parsed_content_type = parse_content_type(content_type) + enc = parsed_content_type[2].get("charset") if parsed_content_type else None + + # Otherwise, infer the encoding + if not enc and "json" in content_type: + enc = "utf8" + + if not enc and "html" in content_type: + meta_charset = re.search( + rb"""]+charset=['"]?([^'">]+)""", content, re.IGNORECASE + ) + if meta_charset: + enc = meta_charset.group(1).decode("ascii", "ignore") + + if not enc and "text/css" in content_type: + # @charset rule must be the very first thing. + css_charset = re.match(rb"""@charset "([^"]+)";""", content, re.IGNORECASE) + if css_charset: + enc = css_charset.group(1).decode("ascii", "ignore") + + # Fallback to latin-1 + if not enc: + enc = "latin-1" + + # Use GB 18030 as the superset of GB2312 and GBK to fix common encoding problems on Chinese websites. + if enc.lower() in ("gb2312", "gbk"): + enc = "gb18030" + + return enc diff --git a/test/mitmproxy/data/har_files/charles.json b/test/mitmproxy/data/har_files/charles.json index d38a849a9a..c4e5de8226 100644 --- a/test/mitmproxy/data/har_files/charles.json +++ b/test/mitmproxy/data/har_files/charles.json @@ -81,7 +81,7 @@ "headers": [ [ "Content-Type", - "text/html; charset=utf-8" + "text/html" ], [ "Content-Length", diff --git a/test/mitmproxy/data/har_files/chrome.json b/test/mitmproxy/data/har_files/chrome.json index d7fdc4035d..7fbf26aa17 100644 --- a/test/mitmproxy/data/har_files/chrome.json +++ b/test/mitmproxy/data/har_files/chrome.json @@ -194,10 +194,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "23866" ] ], "contentLength": 23866, @@ -326,12 +322,7 @@ "http_version": "HTTP/1.1", "status_code": 0, "reason": "", - "headers": [ - [ - "content-length", - "0" - ] - ], + "headers": [], "contentLength": 0, "contentHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "timestamp_start": 1689251552.676, diff --git a/test/mitmproxy/data/har_files/firefox.json b/test/mitmproxy/data/har_files/firefox.json index 849cb79edc..fc7a4771b1 100644 --- a/test/mitmproxy/data/har_files/firefox.json +++ b/test/mitmproxy/data/har_files/firefox.json @@ -174,14 +174,6 @@ [ "x-amz-cf-id", "DPEkuUbeK1ZXMsRuUHqgk6iE4l7ShgyrJntkqIbLaSJ5646Ptc2Xew==" - ], - [ - "content-type", - "text/plain; charset=utf-8" - ], - [ - "content-length", - "23866" ] ], "contentLength": 23866, @@ -282,12 +274,7 @@ "http_version": "HTTP/1.1", "status_code": 200, "reason": "OK", - "headers": [ - [ - "content-length", - "0" - ] - ], + "headers": [], "contentLength": 0, "contentHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "timestamp_start": 1680134339.418, @@ -386,12 +373,7 @@ "http_version": "HTTP/1.1", "status_code": 200, "reason": "OK", - "headers": [ - [ - "content-length", - "0" - ] - ], + "headers": [], "contentLength": 0, "contentHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "timestamp_start": 1680134339.456, @@ -490,12 +472,7 @@ "http_version": "HTTP/1.1", "status_code": 200, "reason": "OK", - "headers": [ - [ - "content-length", - "0" - ] - ], + "headers": [], "contentLength": 0, "contentHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "timestamp_start": 1680134339.457, @@ -594,12 +571,7 @@ "http_version": "HTTP/1.1", "status_code": 200, "reason": "OK", - "headers": [ - [ - "content-length", - "0" - ] - ], + "headers": [], "contentLength": 0, "contentHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "timestamp_start": 1680134339.457, @@ -698,12 +670,7 @@ "http_version": "HTTP/1.1", "status_code": 200, "reason": "OK", - "headers": [ - [ - "content-length", - "0" - ] - ], + "headers": [], "contentLength": 0, "contentHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "timestamp_start": 1680134339.458, @@ -878,10 +845,6 @@ [ "x-amz-cf-id", "EufbwzXQheESUTNil_OCjKK8cvVL51cQpYfmF7iZSHloCTvVhfZ8yQ==" - ], - [ - "content-length", - "3969" ] ], "contentLength": 3969, @@ -1058,10 +1021,6 @@ [ "x-amz-cf-id", "UuHHTyGhTqqTO07G_oZCw7rxjb9RJUGTN3OW0EUS77RH4GiQ-LkAvw==" - ], - [ - "content-length", - "3346" ] ], "contentLength": 3346, @@ -1238,10 +1197,6 @@ [ "x-amz-cf-id", "TOLqHpQWMFHQDWnv2yHHFWI5xkA3R13TTJQDJe1ARViKrgihxZdhxA==" - ], - [ - "content-length", - "794" ] ], "contentLength": 794, @@ -1425,10 +1380,6 @@ [ "x-amz-cf-id", "nnIrWtgAMt42ua4HYBtNAao6m_iD9WjIzLAFyURb8mjOr5MriSQXRA==" - ], - [ - "content-length", - "9689" ] ], "contentLength": 9689, @@ -1612,10 +1563,6 @@ [ "x-amz-cf-id", "PMTLvP_yUCVocnhd1i1ir7_FRAJRw0ayMhK3KaZKELDO3pxxoqLWjg==" - ], - [ - "content-length", - "9689" ] ], "contentLength": 9689, @@ -1958,10 +1905,6 @@ [ "x-amz-cf-id", "0okGWJw6nYo7R-4egQWE-WfonThN2EXyRSLO9MlCNKyMfD-2v1AU0Q==" - ], - [ - "content-length", - "6986" ] ], "contentLength": 6986, diff --git a/test/mitmproxy/data/har_files/head-content-length.har b/test/mitmproxy/data/har_files/head-content-length.har new file mode 100644 index 0000000000..ec549cbe9d --- /dev/null +++ b/test/mitmproxy/data/har_files/head-content-length.har @@ -0,0 +1,179 @@ +{ + "log": { + "version": "1.2", + "creator": { + "name": "Firefox", + "version": "111.0.1" + }, + "browser": { + "name": "Firefox", + "version": "111.0.1" + }, + "pages": [ + { + "startedDateTime": "2023-03-29T16:58:59.303-07:00", + "id": "page_1", + "title": "mitmproxy - an interactive HTTPS proxy", + "pageTimings": { + "onContentLoad": 208, + "onLoad": 270 + } + } + ], + "entries": [ + { + "startedDateTime": "2023-12-12T16:23:16.067544+00:00", + "time": 101.56393051147461, + "request": { + "method": "HEAD", + "url": "https://files.pythonhosted.org/packages/00/e5/f12a80907d0884e6dff9c16d0c0114d81b8cd07dc3ae54c5e962cc83037e/tqdm-4.66.1-py3-none-any.whl", + "httpVersion": "HTTP/2.0", + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "*/*" + }, + { + "name": "user-agent", + "value": "puffin" + }, + { + "name": "accept-encoding", + "value": "gzip, br" + } + ], + "queryString": [], + "headersSize": 91, + "bodySize": 0 + }, + "response": { + "status": 200, + "statusText": "", + "httpVersion": "HTTP/2.0", + "cookies": [], + "headers": [ + { + "name": "last-modified", + "value": "Thu, 10 Aug 2023 11:39:00 GMT" + }, + { + "name": "etag", + "value": "\"a296c6e224c118b0d08cd77e8c08f4b1\"" + }, + { + "name": "x-amz-request-id", + "value": "aeb4d3335548af85" + }, + { + "name": "x-amz-id-2", + "value": "aN65jxTFgNrlm8zEJMNdk7mYLYwUwTzh0" + }, + { + "name": "x-amz-version-id", + "value": "4_z179c51e67f11a0ad8f6c0018_f10789ff3151435c8_d20230810_m113900_c005_v0501001_t0045_u01691667540984" + }, + { + "name": "content-type", + "value": "application/octet-stream" + }, + { + "name": "cache-control", + "value": "max-age=365000000, immutable, public" + }, + { + "name": "accept-ranges", + "value": "bytes" + }, + { + "name": "date", + "value": "Tue, 12 Dec 2023 16:23:16 GMT" + }, + { + "name": "age", + "value": "2335275" + }, + { + "name": "x-served-by", + "value": "cache-iad-kcgs7200038-IAD, cache-lck10926-LCK" + }, + { + "name": "x-cache", + "value": "HIT, HIT" + }, + { + "name": "x-cache-hits", + "value": "21459, 139679" + }, + { + "name": "x-timer", + "value": "S1702398196.107663,VS0,VE0" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "x-frame-options", + "value": "deny" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-robots-header", + "value": "noindex" + }, + { + "name": "x-pypi-file-python-version", + "value": "py3" + }, + { + "name": "x-pypi-file-version", + "value": "4.66.1" + }, + { + "name": "x-pypi-file-package-type", + "value": "bdist_wheel" + }, + { + "name": "x-pypi-file-project", + "value": "tqdm" + }, + { + "name": "content-length", + "value": "78258" + } + ], + "content": { + "size": 0, + "compression": 0, + "mimeType": "application/octet-stream", + "text": "" + }, + "redirectURL": "", + "headersSize": 1188, + "bodySize": 0 + }, + "cache": {}, + "timings": { + "connect": 31.686782836914062, + "ssl": 35.33315658569336, + "send": 0.2961158752441406, + "receive": 0.6310939788818359, + "wait": 33.61678123474121 + }, + "serverIPAddress": "199.232.96.223" + } + ] + } +} \ No newline at end of file diff --git a/test/mitmproxy/data/har_files/head-content-length.json b/test/mitmproxy/data/har_files/head-content-length.json new file mode 100644 index 0000000000..b28343587f --- /dev/null +++ b/test/mitmproxy/data/har_files/head-content-length.json @@ -0,0 +1,193 @@ +[ + { + "id": "hardcoded_for_test", + "intercepted": false, + "is_replay": null, + "type": "http", + "modified": false, + "marked": "", + "comment": "", + "timestamp_created": 0, + "client_conn": { + "id": "hardcoded_for_test", + "peername": [ + "127.0.0.1", + 0 + ], + "sockname": [ + "127.0.0.1", + 0 + ], + "tls_established": false, + "cert": null, + "sni": null, + "cipher": null, + "alpn": null, + "tls_version": null, + "timestamp_start": 1702398196.067544, + "timestamp_tls_setup": null, + "timestamp_end": 1702398297.6314745 + }, + "server_conn": { + "id": "hardcoded_for_test", + "peername": null, + "sockname": null, + "address": [ + "199.232.96.223", + 443 + ], + "tls_established": false, + "cert": null, + "sni": null, + "cipher": null, + "alpn": null, + "tls_version": null, + "timestamp_start": null, + "timestamp_tcp_setup": null, + "timestamp_tls_setup": null, + "timestamp_end": null + }, + "request": { + "method": "HEAD", + "scheme": "https", + "host": "files.pythonhosted.org", + "port": 443, + "path": "/packages/00/e5/f12a80907d0884e6dff9c16d0c0114d81b8cd07dc3ae54c5e962cc83037e/tqdm-4.66.1-py3-none-any.whl", + "http_version": "HTTP/1.1", + "headers": [ + [ + "accept", + "*/*" + ], + [ + "user-agent", + "puffin" + ], + [ + "accept-encoding", + "gzip, br" + ], + [ + "content-length", + "0" + ] + ], + "contentLength": 0, + "contentHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "timestamp_start": 1702398196.067544, + "timestamp_end": 1702398297.6314745, + "pretty_host": "files.pythonhosted.org" + }, + "response": { + "http_version": "HTTP/1.1", + "status_code": 200, + "reason": "OK", + "headers": [ + [ + "last-modified", + "Thu, 10 Aug 2023 11:39:00 GMT" + ], + [ + "etag", + "\"a296c6e224c118b0d08cd77e8c08f4b1\"" + ], + [ + "x-amz-request-id", + "aeb4d3335548af85" + ], + [ + "x-amz-id-2", + "aN65jxTFgNrlm8zEJMNdk7mYLYwUwTzh0" + ], + [ + "x-amz-version-id", + "4_z179c51e67f11a0ad8f6c0018_f10789ff3151435c8_d20230810_m113900_c005_v0501001_t0045_u01691667540984" + ], + [ + "content-type", + "application/octet-stream" + ], + [ + "cache-control", + "max-age=365000000, immutable, public" + ], + [ + "accept-ranges", + "bytes" + ], + [ + "date", + "Tue, 12 Dec 2023 16:23:16 GMT" + ], + [ + "age", + "2335275" + ], + [ + "x-served-by", + "cache-iad-kcgs7200038-IAD, cache-lck10926-LCK" + ], + [ + "x-cache", + "HIT, HIT" + ], + [ + "x-cache-hits", + "21459, 139679" + ], + [ + "x-timer", + "S1702398196.107663,VS0,VE0" + ], + [ + "strict-transport-security", + "max-age=31536000; includeSubDomains; preload" + ], + [ + "x-frame-options", + "deny" + ], + [ + "x-xss-protection", + "1; mode=block" + ], + [ + "x-content-type-options", + "nosniff" + ], + [ + "x-permitted-cross-domain-policies", + "none" + ], + [ + "x-robots-header", + "noindex" + ], + [ + "x-pypi-file-python-version", + "py3" + ], + [ + "x-pypi-file-version", + "4.66.1" + ], + [ + "x-pypi-file-package-type", + "bdist_wheel" + ], + [ + "x-pypi-file-project", + "tqdm" + ], + [ + "content-length", + "78258" + ] + ], + "contentLength": 0, + "contentHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "timestamp_start": 1702398196.067544, + "timestamp_end": 1702398297.6314745 + } + } +] \ No newline at end of file diff --git a/test/mitmproxy/data/har_files/safari.json b/test/mitmproxy/data/har_files/safari.json index f1a9b01898..299689158b 100644 --- a/test/mitmproxy/data/har_files/safari.json +++ b/test/mitmproxy/data/har_files/safari.json @@ -101,7 +101,7 @@ "headers": [ [ "Content-Type", - "text/html; charset=utf-8" + "text/html" ], [ "Last-Modified", @@ -150,10 +150,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "4946" ] ], "contentLength": 4946, @@ -282,10 +278,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "36819" ] ], "contentLength": 36819, @@ -926,10 +918,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "5167" ] ], "contentLength": 5167, @@ -1058,10 +1046,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "3346" ] ], "contentLength": 3346, @@ -1190,10 +1174,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "794" ] ], "contentLength": 794, @@ -1334,10 +1314,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "3346" ] ], "contentLength": 3346, @@ -1478,10 +1454,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "3346" ] ], "contentLength": 3346, @@ -1622,10 +1594,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "3346" ] ], "contentLength": 3346, @@ -1766,10 +1734,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "3346" ] ], "contentLength": 3346, @@ -2282,10 +2246,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "3969" ] ], "contentLength": 3969, @@ -2596,10 +2556,6 @@ [ "x-cache", "Hit from cloudfront" - ], - [ - "content-length", - "1421" ] ], "contentLength": 1421, diff --git a/test/mitmproxy/net/http/test_headers.py b/test/mitmproxy/net/http/test_headers.py index 473b930f84..d7fb1999a3 100644 --- a/test/mitmproxy/net/http/test_headers.py +++ b/test/mitmproxy/net/http/test_headers.py @@ -1,6 +1,9 @@ import collections +import pytest + from mitmproxy.net.http.headers import assemble_content_type +from mitmproxy.net.http.headers import infer_content_encoding from mitmproxy.net.http.headers import parse_content_type @@ -25,3 +28,34 @@ def test_assemble_content_type(): ) == "text/html; charset=utf8; foo=bar" ) + + +@pytest.mark.parametrize( + "content_type,content,expected", + [ + ("", b"", "latin-1"), + ("", b"foo", "latin-1"), + ("", b"\xfc", "latin-1"), + ("", b"\xF0\xE2", "latin-1"), + ("text/html; charset=latin1", b"\xc3\xbc", "latin1"), + ("text/html; charset=utf8", b"\xc3\xbc", "utf8"), + # json + ("application/json", b'"\xc3\xbc"', "utf8"), + # meta charset + ( + "text/html", + b'\xe6\x98\x8e\xe4\xbc\xaf', + "gb18030", + ), + # css charset + ( + "text/css", + b'@charset "gb2312";' b'#foo::before {content: "\xe6\x98\x8e\xe4\xbc\xaf"}', + "gb18030", + ), + ], +) +def test_infer_content_encoding(content_type, content, expected): + # Additional test coverage in `test_http::TestMessageText` + assert infer_content_encoding(content_type, content) == expected From 0a3e016d394609e81fce0d05722418c701c45d39 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 12 Dec 2023 19:15:19 +0100 Subject: [PATCH 002/283] fix a bug where connections would not be fully closed (#6543) --- CHANGELOG.md | 2 + mitmproxy/addons/clientplayback.py | 6 +- mitmproxy/optmanager.py | 2 +- mitmproxy/proxy/mode_servers.py | 1 + mitmproxy/proxy/server.py | 18 +++-- pyproject.toml | 2 + test/mitmproxy/addons/test_asgiapp.py | 73 +++++++++++-------- test/mitmproxy/addons/test_clientplayback.py | 75 +++++++++++++------- test/mitmproxy/addons/test_proxyserver.py | 26 ++++--- test/mitmproxy/addons/test_script.py | 3 +- test/mitmproxy/proxy/test_mode_servers.py | 5 +- test/mitmproxy/tools/web/test_master.py | 9 ++- 12 files changed, 144 insertions(+), 78 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4aaab21f41..2ea648305b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ ([#6548](https://github.com/mitmproxy/mitmproxy/pull/6548), @zanieb) * Improved handling for `--allow-hosts`/`--ignore-hosts` options in WireGuard mode (#5930). ([#6513](https://github.com/mitmproxy/mitmproxy/pull/6513), @dsphper) +* Fix a bug where TCP connections were not closed properly. + ([#6543](https://github.com/mitmproxy/mitmproxy/pull/6543), @mhils) * DNS resolution is now exempted from `--ignore-hosts` in WireGuard Mode. ([#6513](https://github.com/mitmproxy/mitmproxy/pull/6513), @dsphper) * Fix a bug where logging was stopped prematurely during shutdown. diff --git a/mitmproxy/addons/clientplayback.py b/mitmproxy/addons/clientplayback.py index 53b202505a..d24548c39f 100644 --- a/mitmproxy/addons/clientplayback.py +++ b/mitmproxy/addons/clientplayback.py @@ -161,9 +161,13 @@ def running(self): ) self.options = ctx.options - def done(self): + async def done(self): if self.playback_task: self.playback_task.cancel() + try: + await self.playback_task + except asyncio.CancelledError: + pass async def playback(self): while True: diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index b116f31d13..3dbc215c51 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -523,7 +523,7 @@ def parse(text): if not text: return {} try: - yaml = ruamel.yaml.YAML(typ="unsafe", pure=True) + yaml = ruamel.yaml.YAML(typ="safe", pure=True) data = yaml.load(text) except ruamel.yaml.error.YAMLError as v: if hasattr(v, "problem_mark"): diff --git a/mitmproxy/proxy/mode_servers.py b/mitmproxy/proxy/mode_servers.py index 5ada94ed11..f051a9f45e 100644 --- a/mitmproxy/proxy/mode_servers.py +++ b/mitmproxy/proxy/mode_servers.py @@ -199,6 +199,7 @@ async def handle_tcp_connection( original_dst = platform.original_addr(s) except Exception as e: logger.error(f"Transparent mode failure: {e!r}") + writer.close() return else: handler.layer.context.client.sockname = original_dst diff --git a/mitmproxy/proxy/server.py b/mitmproxy/proxy/server.py index c990261924..58068fa80f 100644 --- a/mitmproxy/proxy/server.py +++ b/mitmproxy/proxy/server.py @@ -308,7 +308,10 @@ async def handle_connection(self, connection: Connection) -> None: # we may still use this connection to *send* stuff, # even though the remote has closed their side of the connection. # to make this work we keep this task running and wait for cancellation. - await asyncio.Event().wait() + try: + await asyncio.Event().wait() + except asyncio.CancelledError as e: + cancelled = e try: writer = self.transports[connection].writer @@ -336,10 +339,15 @@ async def drain_writers(self): transport.handler.cancel(f"Error sending data: {e}") async def on_timeout(self) -> None: - self.log(f"Closing connection due to inactivity: {self.client}") - handler = self.transports[self.client].handler - assert handler - handler.cancel("timeout") + try: + handler = self.transports[self.client].handler + except KeyError: # pragma: no cover + # there is a super short window between connection close and watchdog cancellation + pass + else: + self.log(f"Closing connection due to inactivity: {self.client}") + assert handler + handler.cancel("timeout") async def hook_task(self, hook: commands.StartHook) -> None: await self.handle_hook(hook) diff --git a/pyproject.toml b/pyproject.toml index 19b952e3dd..6844a316f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -130,6 +130,8 @@ testpaths = "test" addopts = "--capture=no --color=yes" filterwarnings = [ "ignore::DeprecationWarning:tornado.*:", + "error::RuntimeWarning", + "error::pytest.PytestUnraisableExceptionWarning", ] [tool.mypy] diff --git a/test/mitmproxy/addons/test_asgiapp.py b/test/mitmproxy/addons/test_asgiapp.py index 0926f091e1..233188b39a 100644 --- a/test/mitmproxy/addons/test_asgiapp.py +++ b/test/mitmproxy/addons/test_asgiapp.py @@ -57,57 +57,70 @@ async def test_asgi_full(caplog): assert await ps.setup_servers() proxy_addr = ("127.0.0.1", ps.listen_addrs()[0][1]) - reader, writer = await asyncio.open_connection(*proxy_addr) + # We parallelize connection establishment/closure because those operations tend to be slow. + [ + (r1, w1), + (r2, w2), + (r3, w3), + (r4, w4), + (r5, w5), + ] = await asyncio.gather( + asyncio.open_connection(*proxy_addr), + asyncio.open_connection(*proxy_addr), + asyncio.open_connection(*proxy_addr), + asyncio.open_connection(*proxy_addr), + asyncio.open_connection(*proxy_addr), + ) + req = f"GET http://testapp:80/ HTTP/1.1\r\n\r\n" - writer.write(req.encode()) - header = await reader.readuntil(b"\r\n\r\n") + w1.write(req.encode()) + header = await r1.readuntil(b"\r\n\r\n") assert header.startswith(b"HTTP/1.1 200 OK") - body = await reader.readuntil(b"testapp") + body = await r1.readuntil(b"testapp") assert body == b"testapp" - writer.close() - await writer.wait_closed() - reader, writer = await asyncio.open_connection(*proxy_addr) req = f"GET http://testapp:80/parameters?param1=1¶m2=2 HTTP/1.1\r\n\r\n" - writer.write(req.encode()) - header = await reader.readuntil(b"\r\n\r\n") + w2.write(req.encode()) + header = await r2.readuntil(b"\r\n\r\n") assert header.startswith(b"HTTP/1.1 200 OK") - body = await reader.readuntil(b"}") + body = await r2.readuntil(b"}") assert body == b'{"param1": "1", "param2": "2"}' - writer.close() - await writer.wait_closed() - reader, writer = await asyncio.open_connection(*proxy_addr) req = f"POST http://testapp:80/requestbody HTTP/1.1\r\nContent-Length: 6\r\n\r\nHello!" - writer.write(req.encode()) - header = await reader.readuntil(b"\r\n\r\n") + w3.write(req.encode()) + header = await r3.readuntil(b"\r\n\r\n") assert header.startswith(b"HTTP/1.1 200 OK") - body = await reader.readuntil(b"}") + body = await r3.readuntil(b"}") assert body == b'{"body": "Hello!"}' - writer.close() - await writer.wait_closed() - reader, writer = await asyncio.open_connection(*proxy_addr) req = f"GET http://errapp:80/?foo=bar HTTP/1.1\r\n\r\n" - writer.write(req.encode()) - header = await reader.readuntil(b"\r\n\r\n") + w4.write(req.encode()) + header = await r4.readuntil(b"\r\n\r\n") assert header.startswith(b"HTTP/1.1 500") - body = await reader.readuntil(b"ASGI Error") + body = await r4.readuntil(b"ASGI Error") assert body == b"ASGI Error" - writer.close() - await writer.wait_closed() assert "ValueError" in caplog.text - reader, writer = await asyncio.open_connection(*proxy_addr) req = f"GET http://noresponseapp:80/ HTTP/1.1\r\n\r\n" - writer.write(req.encode()) - header = await reader.readuntil(b"\r\n\r\n") + w5.write(req.encode()) + header = await r5.readuntil(b"\r\n\r\n") assert header.startswith(b"HTTP/1.1 500") - body = await reader.readuntil(b"ASGI Error") + body = await r5.readuntil(b"ASGI Error") assert body == b"ASGI Error" - writer.close() - await writer.wait_closed() assert "no response sent" in caplog.text + w1.close() + w2.close() + w3.close() + w4.close() + w5.close() + await asyncio.gather( + w1.wait_closed(), + w2.wait_closed(), + w3.wait_closed(), + w4.wait_closed(), + w5.wait_closed(), + ) + tctx.configure(ps, server=False) assert await ps.setup_servers() diff --git a/test/mitmproxy/addons/test_clientplayback.py b/test/mitmproxy/addons/test_clientplayback.py index f9f889e42f..f9fc32ae9f 100644 --- a/test/mitmproxy/addons/test_clientplayback.py +++ b/test/mitmproxy/addons/test_clientplayback.py @@ -17,23 +17,48 @@ @asynccontextmanager async def tcp_server(handle_conn, **server_args) -> Address: - server = await asyncio.start_server(handle_conn, "127.0.0.1", 0, **server_args) + """TCP server context manager that... + + 1. Exits only after all handlers have returned. + 2. Ensures that all handlers are closed properly. If we don't do that, + we get ghost errors in others tests from StreamWriter.__del__. + + Spawning a TCP server is relatively slow. Consider using in-memory networking for faster tests. + """ + if not hasattr(asyncio, "TaskGroup"): + pytest.skip("Skipped because asyncio.TaskGroup is unavailable.") + + tasks = asyncio.TaskGroup() + + async def handle_conn_wrapper( + reader: asyncio.StreamReader, + writer: asyncio.StreamWriter, + ) -> None: + try: + await handle_conn(reader, writer) + except Exception as e: + print(f"!!! TCP handler failed: {e}") + raise + finally: + if not writer.is_closing(): + writer.close() + await writer.wait_closed() + + async def _handle(r, w): + tasks.create_task(handle_conn_wrapper(r, w)) + + server = await asyncio.start_server(_handle, "127.0.0.1", 0, **server_args) await server.start_serving() - try: - yield server.sockets[0].getsockname() - finally: - server.close() + async with server: + async with tasks: + yield server.sockets[0].getsockname() @pytest.mark.parametrize("mode", ["http", "https", "upstream", "err"]) @pytest.mark.parametrize("concurrency", [-1, 1]) async def test_playback(tdata, mode, concurrency): - handler_ok = asyncio.Event() - async def handler(reader: asyncio.StreamReader, writer: asyncio.StreamWriter): if mode == "err": - writer.close() - handler_ok.set() return req = await reader.readline() if mode == "upstream": @@ -49,7 +74,6 @@ async def handler(reader: asyncio.StreamReader, writer: asyncio.StreamWriter): writer.write(b"HTTP/1.1 204 No Content\r\n\r\n") await writer.drain() assert not await reader.read() - handler_ok.set() cp = ClientPlayback() ps = Proxyserver() @@ -92,22 +116,20 @@ async def handler(reader: asyncio.StreamReader, writer: asyncio.StreamWriter): cp.start_replay([flow]) assert cp.count() == 1 await asyncio.wait_for(cp.queue.join(), 5) - await asyncio.wait_for(handler_ok.wait(), 5) - cp.done() - if mode != "err": - assert flow.response.status_code == 204 + while cp.replay_tasks: + await asyncio.sleep(0.001) + if mode != "err": + assert flow.response.status_code == 204 + await cp.done() async def test_playback_https_upstream(): - handler_ok = asyncio.Event() - async def handler(reader: asyncio.StreamReader, writer: asyncio.StreamWriter): conn_req = await reader.readuntil(b"\r\n\r\n") assert conn_req == b"CONNECT address:22 HTTP/1.1\r\n\r\n" writer.write(b"HTTP/1.1 502 Bad Gateway\r\n\r\n") await writer.drain() assert not await reader.read() - handler_ok.set() cp = ClientPlayback() ps = Proxyserver() @@ -122,17 +144,17 @@ async def handler(reader: asyncio.StreamReader, writer: asyncio.StreamWriter): cp.start_replay([flow]) assert cp.count() == 1 await asyncio.wait_for(cp.queue.join(), 5) - await asyncio.wait_for(handler_ok.wait(), 5) - cp.done() - assert flow.response is None - assert ( - str(flow.error) - == f"Upstream proxy {addr[0]}:{addr[1]} refused HTTP CONNECT request: 502 Bad Gateway" - ) + + assert flow.response is None + assert ( + str(flow.error) + == f"Upstream proxy {addr[0]}:{addr[1]} refused HTTP CONNECT request: 502 Bad Gateway" + ) + await cp.done() async def test_playback_crash(monkeypatch, caplog_async): - async def raise_err(): + async def raise_err(*_, **__): raise ValueError("oops") monkeypatch.setattr(ReplayHandler, "replay", raise_err) @@ -141,8 +163,9 @@ async def raise_err(): cp.running() cp.start_replay([tflow.tflow(live=False)]) await caplog_async.await_log("Client replay has crashed!") + assert "oops" in caplog_async.caplog.text assert cp.count() == 0 - cp.done() + await cp.done() def test_check(): diff --git a/test/mitmproxy/addons/test_proxyserver.py b/test/mitmproxy/addons/test_proxyserver.py index 341bfbe091..00f959fb2b 100644 --- a/test/mitmproxy/addons/test_proxyserver.py +++ b/test/mitmproxy/addons/test_proxyserver.py @@ -23,6 +23,7 @@ from aioquic.quic.connection import QuicConnection from aioquic.quic.connection import QuicConnectionError +from .test_clientplayback import tcp_server import mitmproxy.platform from mitmproxy import dns from mitmproxy import exceptions @@ -55,16 +56,6 @@ def tcp_start(self, f): self.flows.append(f) -@asynccontextmanager -async def tcp_server(handle_conn) -> Address: - server = await asyncio.start_server(handle_conn, "127.0.0.1", 0) - await server.start_serving() - try: - yield server.sockets[0].getsockname() - finally: - server.close() - - async def test_start_stop(caplog_async): caplog_async.set_level("INFO") @@ -74,7 +65,6 @@ async def server_handler( assert await reader.readuntil(b"\r\n\r\n") == b"GET /hello HTTP/1.1\r\n\r\n" writer.write(b"HTTP/1.1 204 No Content\r\n\r\n") await writer.drain() - writer.close() ps = Proxyserver() nl = NextLayer() @@ -160,6 +150,9 @@ async def server_handler( ps.inject_tcp(state.flows[0], True, b"c") assert await reader.read(1) == b"c" + writer.close() + await writer.wait_closed() + async def test_inject_fail(caplog) -> None: ps = Proxyserver() @@ -311,6 +304,9 @@ async def test_dns(caplog_async) -> None: tctx.configure(ps, server=False) await caplog_async.await_log("stopped") + w.close() + await w.wait_closed() + def test_validation_no_transparent(monkeypatch): monkeypatch.setattr(mitmproxy.platform, "original_addr", None) @@ -373,6 +369,9 @@ def server_handler( tctx.configure(ps, server=False) await caplog_async.await_log("stopped") + w.close() + await w.wait_closed() + class H3EchoServer(QuicConnectionProtocol): def __init__(self, *args, **kwargs) -> None: @@ -779,6 +778,11 @@ async def test_reverse_http3_and_quic_stream( await _test_echo(client, strict=scheme == "http3") assert len(ps.connections) == 1 + # dirty hack: forcibly close all connections so that there are no unexpected asyncio tasks + # that may cause test failures because they have not been run. + for conn in ps.servers[mode].manager.connections.values(): + await conn.on_timeout() + tctx.configure(ps, server=False) await caplog_async.await_log(f"stopped") diff --git a/test/mitmproxy/addons/test_script.py b/test/mitmproxy/addons/test_script.py index add0801fbe..c36279cb4d 100644 --- a/test/mitmproxy/addons/test_script.py +++ b/test/mitmproxy/addons/test_script.py @@ -328,6 +328,7 @@ def test_order(tdata, capsys): ] ) time = r"\[[\d:.]+\] " + out = capsys.readouterr().out assert re.match( rf"{time}Loading script.+recorder.py\n" rf"{time}\('recorder', 'load', .+\n" @@ -335,5 +336,5 @@ def test_order(tdata, capsys): rf"{time}Loading script.+shutdown.py\n" rf"{time}\('recorder', 'running', .+\n" rf"{time}\('recorder', 'done', .+\n$", - capsys.readouterr().out, + out, ) diff --git a/test/mitmproxy/proxy/test_mode_servers.py b/test/mitmproxy/proxy/test_mode_servers.py index 274eabe425..9071e28c71 100644 --- a/test/mitmproxy/proxy/test_mode_servers.py +++ b/test/mitmproxy/proxy/test_mode_servers.py @@ -269,6 +269,7 @@ async def test_udp_start_stop(caplog_async): assert await caplog_async.await_log("sent an invalid message") writer.close() + await writer.wait_closed() await inst.stop() assert await caplog_async.await_log("stopped") @@ -324,6 +325,7 @@ async def test_udp_dual_stack(caplog_async): writer.write(b"\x00\x00\x01") assert await caplog_async.await_log("sent an invalid message") writer.close() + await writer.wait_closed() if "listening on IPv4 only" not in caplog_async.caplog.text: caplog_async.clear() @@ -331,6 +333,7 @@ async def test_udp_dual_stack(caplog_async): writer.write(b"\x00\x00\x01") assert await caplog_async.await_log("sent an invalid message") writer.close() + await writer.wait_closed() await inst.stop() assert await caplog_async.await_log("stopped") @@ -338,7 +341,7 @@ async def test_udp_dual_stack(caplog_async): @pytest.fixture() def patched_local_redirector(monkeypatch): - start_local_redirector = AsyncMock() + start_local_redirector = AsyncMock(return_value=Mock()) monkeypatch.setattr(mitmproxy_rs, "start_local_redirector", start_local_redirector) # make sure _server and _instance are restored after this test monkeypatch.setattr(LocalRedirectorInstance, "_server", None) diff --git a/test/mitmproxy/tools/web/test_master.py b/test/mitmproxy/tools/web/test_master.py index ee0225754a..e956b73d4c 100644 --- a/test/mitmproxy/tools/web/test_master.py +++ b/test/mitmproxy/tools/web/test_master.py @@ -1,5 +1,4 @@ import asyncio -from unittest.mock import MagicMock import pytest @@ -8,8 +7,11 @@ async def test_reuse(): + async def handler(r, w): + pass + server = await asyncio.start_server( - MagicMock(), host="127.0.0.1", port=0, reuse_address=False + handler, host="127.0.0.1", port=0, reuse_address=False ) port = server.sockets[0].getsockname()[1] master = WebMaster(Options(), with_termlog=False) @@ -18,3 +20,6 @@ async def test_reuse(): with pytest.raises(OSError, match=f"--set web_port={port + 2}"): await master.running() server.close() + # tornado registers some callbacks, + # we want to run them to avoid fatal warnings. + await asyncio.sleep(0) From 9787871e6cadf397f94447c32dd4d397d937a954 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 12 Dec 2023 19:19:29 +0100 Subject: [PATCH 003/283] do not include subject key identifier in leaf certificates (#6549) This fixes #6494: if CA and leaf share the same Subject Key Identifier, SChannel gets confused. So we just skip the SKI for leafs, which is still fine with OpenSSL 3.x (this was previously fixed by @mmaxim) and RFC 5280. Co-authored-by: Andrius Andrikonis --- CHANGELOG.md | 3 +++ mitmproxy/certs.py | 12 +++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ea648305b..bdac343e75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ ## Unreleased: mitmproxy next +* Fix compatibility with Windows Schannel clients, which previously got + confused by CA and leaf certificate sharing the same Subject Key Identifier. + ([#6549](https://github.com/mitmproxy/mitmproxy/pull/6549), @driuba and @mhils) * Fix bug where response flows from HAR files had incorrect `content-length` headers ([#6548](https://github.com/mitmproxy/mitmproxy/pull/6548), @zanieb) * Improved handling for `--allow-hosts`/`--ignore-hosts` options in WireGuard mode (#5930). diff --git a/mitmproxy/certs.py b/mitmproxy/certs.py index d994fbb6b6..30b2213ece 100644 --- a/mitmproxy/certs.py +++ b/mitmproxy/certs.py @@ -279,17 +279,15 @@ def dummy_cert( x509.SubjectAlternativeName(ss), critical=not is_valid_commonname ) - # we just use the same key as the CA for these certs, so put that in the SKI extension - builder = builder.add_extension( - x509.SubjectKeyIdentifier.from_public_key(privkey.public_key()), - critical=False, - ) - # add authority key identifier for the cacert issuing cert for greater acceptance by - # client TLS libraries (such as OpenSSL 3.x) + # https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.1 builder = builder.add_extension( x509.AuthorityKeyIdentifier.from_issuer_public_key(cacert.public_key()), critical=False, ) + # If CA and leaf cert have the same Subject Key Identifier, SChannel breaks in funny ways, + # see https://github.com/mitmproxy/mitmproxy/issues/6494. + # https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.2 states + # that SKI is optional for the leaf cert, so we skip that. cert = builder.sign(private_key=privkey, algorithm=hashes.SHA256()) # type: ignore return Cert(cert) From 13c976de0d3ee54947dfa66d28f61b22e17d7831 Mon Sep 17 00:00:00 2001 From: xBZZZZ <91378413+xBZZZZ@users.noreply.github.com> Date: Tue, 12 Dec 2023 20:23:32 +0200 Subject: [PATCH 004/283] fix `mitmweb` splitter becoming drag and drop (#6492) --- CHANGELOG.md | 2 + .../components/common/SplitterSpec.tsx | 183 ++++++++++++------ .../__snapshots__/SplitterSpec.tsx.snap | 12 -- web/src/js/components/common/Splitter.tsx | 88 ++++----- 4 files changed, 168 insertions(+), 117 deletions(-) delete mode 100644 web/src/js/__tests__/components/common/__snapshots__/SplitterSpec.tsx.snap diff --git a/CHANGELOG.md b/CHANGELOG.md index bdac343e75..b47e55ff05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ ([#5084](https://github.com/mitmproxy/mitmproxy/pull/5084), @Speedlulu) * Scripts with relative paths are now loaded relative to the config file and not where the command is ran ([#4860](https://github.com/mitmproxy/mitmproxy/pull/4860), @Speedlulu) +* Fix `mitmweb` splitter becoming drag and drop. + ([#6492](https://github.com/mitmproxy/mitmproxy/pull/6492), @xBZZZZ) * Enhance documentation and add alert log messages when stream_large_bodies and modify_body are set ([#6514](https://github.com/mitmproxy/mitmproxy/pull/6514), @rosydawn6) diff --git a/web/src/js/__tests__/components/common/SplitterSpec.tsx b/web/src/js/__tests__/components/common/SplitterSpec.tsx index 488656d91e..fff51c7be6 100644 --- a/web/src/js/__tests__/components/common/SplitterSpec.tsx +++ b/web/src/js/__tests__/components/common/SplitterSpec.tsx @@ -4,87 +4,155 @@ import renderer from "react-test-renderer"; import Splitter from "../../../components/common/Splitter"; import TestUtils from "react-dom/test-utils"; -describe("Splitter Component", () => { - it("should render correctly", () => { - let splitter = renderer.create(), +describe.each([ + ["", ""], + ["x", "X"], + ["y", "Y"], +])("Splitter Component", (axisLower, axisUpper) => { + if (axisLower === "") { + it("should render correctly with default (x) axis", () => { + const splitter = renderer.create(), + tree = splitter.toJSON(); + expect(tree).toMatchInlineSnapshot(` +
+
+
+`); + }); + return; + } + + it("should render correctly with specified axis", () => { + const splitter = renderer.create(), tree = splitter.toJSON(); - expect(tree).toMatchSnapshot(); + expect(tree).toMatchInlineSnapshot(` +
+
+
+`); }); - let splitter = TestUtils.renderIntoDocument(), + const splitter = TestUtils.renderIntoDocument( + + ), dom = ReactDOM.findDOMNode(splitter), previousElementSibling = { - offsetHeight: 0, - offsetWidth: 0, + offsetWidth: 300, + offsetHeight: 500, style: { flex: "" }, }, nextElementSibling = { style: { flex: "" }, }; - it("should handle mouseDown ", () => { - window.addEventListener = jest.fn(); - splitter.onMouseDown({ pageX: 1, pageY: 2 }); - expect(splitter.state.startX).toEqual(1); - expect(splitter.state.startY).toEqual(2); - expect(window.addEventListener).toBeCalledWith( - "mousemove", - splitter.onMouseMove - ); - expect(window.addEventListener).toBeCalledWith( - "mouseup", - splitter.onMouseUp - ); - expect(window.addEventListener).toBeCalledWith( - "dragend", - splitter.onDragEnd - ); + Object.defineProperties(dom, { + previousElementSibling: { value: previousElementSibling }, + nextElementSibling: { value: nextElementSibling }, }); + dom.firstElementChild.setPointerCapture = jest.fn(); - it("should handle dragEnd", () => { - window.removeEventListener = jest.fn(); - splitter.onDragEnd(); - expect(dom.style.transform).toEqual(""); - expect(window.removeEventListener).toBeCalledWith( - "dragend", - splitter.onDragEnd - ); - expect(window.removeEventListener).toBeCalledWith( - "mouseup", - splitter.onMouseUp - ); - expect(window.removeEventListener).toBeCalledWith( - "mousemove", - splitter.onMouseMove + it("should handle pointerdown", () => { + const e = { + pageX: 13, + pageY: 22, + pointerId: -4618, + target: dom.firstElementChild, + }; + expect(splitter.state.dragPointer).toEqual(0.1); + splitter.onPointerDown(e); + expect(e.target.setPointerCapture).toBeCalledWith(-4618); + expect(splitter.state.dragPointer).toEqual(-4618); + expect(splitter.state.startPos).toEqual(e[`page${axisUpper}`]); + }); + + it("should handle pointermove", () => { + const e = { + pageX: 62, + pageY: 21, + pointerId: -4618, + target: dom.firstElementChild, + }; + splitter.onPointerMove(e); + expect(dom.style.transform).toEqual( + axisLower === "x" + ? `translateX(${62 - 13}px)` + : `translateY(${21 - 22}px)` ); }); - it("should handle mouseUp", () => { - Object.defineProperty(dom, "previousElementSibling", { - value: previousElementSibling, - }); - Object.defineProperty(dom, "nextElementSibling", { - value: nextElementSibling, - }); - splitter.onMouseUp({ pageX: 3, pageY: 4 }); - expect(splitter.state.applied).toBeTruthy(); + it("should handle lostpointercapture", () => { + const e = { + pageX: 56, + pageY: 82, + pointerId: -4618, + target: dom.firstElementChild, + }; + splitter.onLostPointerCapture(e); + expect(splitter.state.dragPointer).toEqual(0.1); + expect(dom.style.transform).toEqual(""); + expect(previousElementSibling.style.flex).toEqual( + `0 0 ${axisLower === "x" ? 300 + 56 - 13 : 500 + 82 - 22}px` + ); expect(nextElementSibling.style.flex).toEqual("1 1 auto"); - expect(previousElementSibling.style.flex).toEqual("0 0 2px"); }); - it("should handle mouseMove", () => { - splitter.onMouseMove({ pageX: 10, pageY: 10 }); - expect(dom.style.transform).toEqual("translate(9px, 0px)"); + it("should not resize previousElementSibling negative", () => { + const e = { + pageX: 56, + pageY: 82, + pointerId: 47, + target: dom.firstElementChild, + }; + splitter.onPointerDown(e); + e[`page${axisUpper}`] = -1234; + splitter.onLostPointerCapture(e); + expect(previousElementSibling.style.flex).toEqual("0 0 0px"); + }); - let splitterY = TestUtils.renderIntoDocument(); - splitterY.onMouseMove({ pageX: 10, pageY: 10 }); - expect(ReactDOM.findDOMNode(splitterY).style.transform).toEqual( - "translate(0px, 10px)" + it("should ignore other pointers", () => { + splitter.onPointerDown({ + pageX: 70, + pageY: 60, + pointerId: 47, + target: dom.firstElementChild, + }); + splitter.onPointerDown({ + pageX: 70, + pageY: 60, + pointerId: 46, + target: dom.firstElementChild, + }); + expect(splitter.state.dragPointer).toEqual(47); + splitter.onPointerMove({ pageX: 75, pageY: 55, pointerId: 46 }); + expect(dom.style.transform).toEqual(""); + splitter.onPointerMove({ + pageX: 74, + pageY: 54, + pointerId: 47, + target: dom.firstElementChild, + }); + splitter.onLostPointerCapture({ pageX: 76, pageY: 56, pointerId: 46 }); + expect(dom.style.transform).toEqual( + axisLower === "x" + ? `translateX(${74 - 70}px)` + : `translateY(${54 - 60}px)` ); }); it("should handle resize", () => { - let x = jest.spyOn(window, "setTimeout"); + const x = jest.spyOn(window, "setTimeout"); splitter.onResize(); expect(x).toHaveBeenCalled(); }); @@ -99,7 +167,6 @@ describe("Splitter Component", () => { it("should handle reset", () => { splitter.reset(false); expect(splitter.state.applied).toBeFalsy(); - expect(splitter.reset(true)).toEqual(undefined); }); }); diff --git a/web/src/js/__tests__/components/common/__snapshots__/SplitterSpec.tsx.snap b/web/src/js/__tests__/components/common/__snapshots__/SplitterSpec.tsx.snap deleted file mode 100644 index dd70ed7a7d..0000000000 --- a/web/src/js/__tests__/components/common/__snapshots__/SplitterSpec.tsx.snap +++ /dev/null @@ -1,12 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Splitter Component should render correctly 1`] = ` -
-
-
-`; diff --git a/web/src/js/components/common/Splitter.tsx b/web/src/js/components/common/Splitter.tsx index fd07f43b35..1db0d6a3ce 100644 --- a/web/src/js/components/common/Splitter.tsx +++ b/web/src/js/components/common/Splitter.tsx @@ -4,8 +4,9 @@ import classnames from "classnames"; type SplitterState = { applied: boolean; - startX: number; - startY: number; + startPos: number; + // .dragPointer === 0.1 means not dragging + dragPointer: number; }; type SplitterProps = { @@ -17,62 +18,51 @@ export default class Splitter extends Component { constructor(props, context) { super(props, context); - - this.state = { applied: false, startX: 0, startY: 0 }; - - this.onMouseMove = this.onMouseMove.bind(this); - this.onMouseDown = this.onMouseDown.bind(this); - this.onMouseUp = this.onMouseUp.bind(this); - this.onDragEnd = this.onDragEnd.bind(this); - } - - onMouseDown(e) { - this.setState({ startX: e.pageX, startY: e.pageY }); - - window.addEventListener("mousemove", this.onMouseMove); - window.addEventListener("mouseup", this.onMouseUp); - // Occasionally, only a dragEnd event is triggered, but no mouseUp. - window.addEventListener("dragend", this.onDragEnd); + this.state = { applied: false, startPos: 0, dragPointer: 0.1 }; + this.onLostPointerCapture = this.onLostPointerCapture.bind(this); + this.onPointerDown = this.onPointerDown.bind(this); + this.onPointerMove = this.onPointerMove.bind(this); } - onDragEnd() { - ReactDOM.findDOMNode(this).style.transform = ""; - - window.removeEventListener("dragend", this.onDragEnd); - window.removeEventListener("mouseup", this.onMouseUp); - window.removeEventListener("mousemove", this.onMouseMove); + onPointerDown(e) { + if (this.state.dragPointer !== 0.1) { + return; + } + e.target.setPointerCapture(e.pointerId); + this.setState({ + startPos: this.props.axis === "x" ? e.pageX : e.pageY, + dragPointer: e.pointerId, + }); } - onMouseUp(e) { - this.onDragEnd(); - - const node = ReactDOM.findDOMNode(this); - const prev = node.previousElementSibling; - - let flexBasis = prev.offsetHeight + e.pageY - this.state.startY; - - if (this.props.axis === "x") { - flexBasis = prev.offsetWidth + e.pageX - this.state.startX; + onLostPointerCapture(e) { + if (this.state.dragPointer !== e.pointerId) { + return; } + const node = e.target.parentNode; + const prev = node.previousElementSibling; - prev.style.flex = `0 0 ${Math.max(0, flexBasis)}px`; + node.style.transform = ""; + prev.style.flex = `0 0 ${Math.max( + 0, + (this.props.axis === "x" + ? prev.offsetWidth + e.pageX + : prev.offsetHeight + e.pageY) - this.state.startPos + )}px`; node.nextElementSibling.style.flex = "1 1 auto"; - this.setState({ applied: true }); + this.setState({ applied: true, dragPointer: 0.1 }); this.onResize(); } - onMouseMove(e) { - let dX = 0; - let dY = 0; - if (this.props.axis === "x") { - dX = e.pageX - this.state.startX; - } else { - dY = e.pageY - this.state.startY; + onPointerMove(e) { + if (this.state.dragPointer !== e.pointerId) { + return; } - ReactDOM.findDOMNode( - this - ).style.transform = `translate(${dX}px, ${dY}px)`; + e.target.parentNode.style.transform = + this.props.axis === "x" + ? `translateX(${e.pageX - this.state.startPos}px)` + : `translateY(${e.pageY - this.state.startPos}px)`; } onResize() { @@ -116,7 +106,11 @@ export default class Splitter extends Component { this.props.axis === "x" ? "splitter-x" : "splitter-y" )} > -
+
); } From b84a821fd88ab427b4548c99d6230bc5bfe7a496 Mon Sep 17 00:00:00 2001 From: Emanuele Micheletti Date: Tue, 12 Dec 2023 19:33:19 +0100 Subject: [PATCH 005/283] make url filters case-insensitive (#6493) fix #6329 --- CHANGELOG.md | 2 ++ mitmproxy/flowfilter.py | 1 + test/mitmproxy/addons/test_blocklist.py | 15 ++++++++------- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b47e55ff05..30713bb066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ ([#6543](https://github.com/mitmproxy/mitmproxy/pull/6543), @mhils) * DNS resolution is now exempted from `--ignore-hosts` in WireGuard Mode. ([#6513](https://github.com/mitmproxy/mitmproxy/pull/6513), @dsphper) +* Fix case sensitivity of URL added to blocklist + ([#6493](https://github.com/mitmproxy/mitmproxy/pull/6493), @emanuele-em) * Fix a bug where logging was stopped prematurely during shutdown. ([#6541](https://github.com/mitmproxy/mitmproxy/pull/6541), @mhils) * For plaintext traffic, `--ignore-hosts` now also takes HTTP/1 host headers into account. diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index 52db22be03..840583f3d1 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -402,6 +402,7 @@ class FUrl(_Rex): code = "u" help = "URL" is_binary = False + flags = re.IGNORECASE # FUrl is special, because it can be "naked". diff --git a/test/mitmproxy/addons/test_blocklist.py b/test/mitmproxy/addons/test_blocklist.py index 9187443b28..b7c7e536d3 100644 --- a/test/mitmproxy/addons/test_blocklist.py +++ b/test/mitmproxy/addons/test_blocklist.py @@ -22,20 +22,21 @@ def test_parse_spec_err(filter, err): class TestBlockList: @pytest.mark.parametrize( - "filter,status_code", + "filter,request_url,status_code", [ - (":~u example.org:404", 404), - (":~u example.com:404", None), - ("/!jpg/418", None), - ("/!png/418", 418), + (":~u example.org:404", b"https://example.org/images/test.jpg", 404), + (":~u example.com:404", b"https://example.org/images/test.jpg", None), + (":~u test:404", b"https://example.org/images/TEST.jpg", 404), + ("/!jpg/418", b"https://example.org/images/test.jpg", None), + ("/!png/418", b"https://example.org/images/test.jpg", 418), ], ) - def test_block(self, filter, status_code): + def test_block(self, filter, request_url, status_code): bl = blocklist.BlockList() with taddons.context(bl) as tctx: tctx.configure(bl, block_list=[filter]) f = tflow.tflow() - f.request.url = b"https://example.org/images/test.jpg" + f.request.url = request_url bl.request(f) if status_code is not None: assert f.response.status_code == status_code From 0b5e310881f0116c9e8e2ca5b9da98e258de0a11 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 13 Dec 2023 07:59:17 +0100 Subject: [PATCH 006/283] simplify cert loading with new cryptography APIs (#6550) /cc @driuba - does that look good? --------- Co-authored-by: Andrius Andrikonis Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- mitmproxy/certs.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/mitmproxy/certs.py b/mitmproxy/certs.py index 30b2213ece..c5bba3ebc6 100644 --- a/mitmproxy/certs.py +++ b/mitmproxy/certs.py @@ -2,7 +2,6 @@ import datetime import ipaddress import os -import re import sys from dataclasses import dataclass from pathlib import Path @@ -328,14 +327,7 @@ def __init__( self.default_ca = default_ca self.default_chain_file = default_chain_file self.default_chain_certs = ( - [ - Cert.from_pem(chunk) - for chunk in re.split( - rb"(?=-----BEGIN( [A-Z]+)+-----)", - self.default_chain_file.read_bytes(), - ) - if chunk.startswith(b"-----BEGIN CERTIFICATE-----") - ] + x509.load_pem_x509_certificates(self.default_chain_file.read_bytes()) if self.default_chain_file else [default_ca] ) @@ -395,9 +387,9 @@ def from_files( raw = ca_file.read_bytes() key = load_pem_private_key(raw, passphrase) dh = cls.load_dhparam(dhparam_file) - certs = re.split(rb"(?=-----BEGIN CERTIFICATE-----)", raw) - ca = Cert.from_pem(certs[1]) - if len(certs) > 2: + certs = x509.load_pem_x509_certificates(raw) + ca = Cert(certs[-1]) + if len(certs) > 1: chain_file: Path | None = ca_file else: chain_file = None From ba9f74b248e06405bcbcf42f0733d60d4242f4ef Mon Sep 17 00:00:00 2001 From: Thanush19 <110150744+Thanush19@users.noreply.github.com> Date: Wed, 13 Dec 2023 13:50:03 +0530 Subject: [PATCH 007/283] add svg image preview support (#6551) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- web/src/js/components/contentviews/HttpMessage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/src/js/components/contentviews/HttpMessage.tsx b/web/src/js/components/contentviews/HttpMessage.tsx index 66bdcdcf85..daf23bebfe 100644 --- a/web/src/js/components/contentviews/HttpMessage.tsx +++ b/web/src/js/components/contentviews/HttpMessage.tsx @@ -133,7 +133,8 @@ export default function HttpMessage({ flow, message }: HttpMessageProps) { } } -const isImage = /^image\/(png|jpe?g|gif|webp|vnc.microsoft.icon|x-icon)$/i; +const isImage = + /^image\/(png|jpe?g|gif|webp|vnc.microsoft.icon|x-icon|svg\+xml)$/i; ViewImage.matches = (msg) => isImage.test(MessageUtils.getContentType(msg) || ""); From c2f1aa16007bc6ae1f9dc72d613cd87abfa0eee7 Mon Sep 17 00:00:00 2001 From: Llama Date: Wed, 13 Dec 2023 15:45:27 +0000 Subject: [PATCH 008/283] Change default keybind to export flow to "x" (#6305) Co-authored-by: Maximilian Hils --- CHANGELOG.md | 2 ++ mitmproxy/tools/console/consoleaddons.py | 4 +++- mitmproxy/tools/console/defaultkeys.py | 4 ++-- mitmproxy/tools/console/quickhelp.py | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30713bb066..8c8af83cbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ * Fix compatibility with Windows Schannel clients, which previously got confused by CA and leaf certificate sharing the same Subject Key Identifier. ([#6549](https://github.com/mitmproxy/mitmproxy/pull/6549), @driuba and @mhils) +* Change keybinding for exporting flow from "e" to "x" to avoid conflict with "edit" keybinding. + ([#6225](https://github.com/mitmproxy/mitmproxy/issues/6225), @Llama1412) * Fix bug where response flows from HAR files had incorrect `content-length` headers ([#6548](https://github.com/mitmproxy/mitmproxy/pull/6548), @zanieb) * Improved handling for `--allow-hosts`/`--ignore-hosts` options in WireGuard mode (#5930). diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py index 6810bc42a5..e0c3aaf953 100644 --- a/mitmproxy/tools/console/consoleaddons.py +++ b/mitmproxy/tools/console/consoleaddons.py @@ -375,7 +375,9 @@ def edit_focus_options(self) -> Sequence[str]: flow = self.master.view.focus.flow focus_options = [] - if isinstance(flow, tcp.TCPFlow): + if flow is None: + raise exceptions.CommandError("No flow selected.") + elif isinstance(flow, tcp.TCPFlow): focus_options = ["tcp-message"] elif isinstance(flow, udp.UDPFlow): focus_options = ["udp-message"] diff --git a/mitmproxy/tools/console/defaultkeys.py b/mitmproxy/tools/console/defaultkeys.py index 41ac65bc56..2294538c35 100644 --- a/mitmproxy/tools/console/defaultkeys.py +++ b/mitmproxy/tools/console/defaultkeys.py @@ -74,7 +74,7 @@ def map(km: Keymap) -> None: "D", "view.flows.duplicate @focus", ["flowlist", "flowview"], "Duplicate flow" ) km.add( - "e", + "x", """ console.choose.cmd Format export.formats console.command export.file {choice} @focus @@ -156,7 +156,7 @@ def map(km: Keymap) -> None: console.choose.cmd Part console.edit.focus.options console.edit.focus {choice} """, - ["flowview"], + ["flowlist", "flowview"], "Edit a flow component", ) km.add( diff --git a/mitmproxy/tools/console/quickhelp.py b/mitmproxy/tools/console/quickhelp.py index d6c959ad9a..080bf503ca 100644 --- a/mitmproxy/tools/console/quickhelp.py +++ b/mitmproxy/tools/console/quickhelp.py @@ -73,6 +73,7 @@ def make( top_items["Unmark"] = "Toggle mark on this flow" else: top_items["Mark"] = "Toggle mark on this flow" + top_items["Edit"] = "Edit a flow component" if focused_flow.intercepted: top_items["Resume"] = "Resume this intercepted flow" if focused_flow.modified(): From b659ea0101ed6af8dc5dc227d8e71aafcda12d75 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 14 Dec 2023 10:26:23 +0100 Subject: [PATCH 009/283] represent SubjectAltNames as cryptography.x509.GeneralName objects, not strings. (#6537) This fixes #6536 --- CHANGELOG.md | 3 + mitmproxy/addons/tlsconfig.py | 24 +++++-- mitmproxy/certs.py | 87 +++++++++++++++-------- mitmproxy/tools/console/flowdetailview.py | 2 +- mitmproxy/tools/web/app.py | 2 +- test/mitmproxy/addons/test_tlsconfig.py | 25 ++++--- test/mitmproxy/test_certs.py | 74 ++++++++++++------- 7 files changed, 146 insertions(+), 71 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c8af83cbf..bbf47091ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,9 @@ ([#6492](https://github.com/mitmproxy/mitmproxy/pull/6492), @xBZZZZ) * Enhance documentation and add alert log messages when stream_large_bodies and modify_body are set ([#6514](https://github.com/mitmproxy/mitmproxy/pull/6514), @rosydawn6) +* Subject Alternative Names are now represented as `cryptography.x509.GeneralNames` instead of `list[str]` + across the codebase. This fixes a regression introduced in mitmproxy 10.1.1 related to punycode domain encoding. + ([#6537](https://github.com/mitmproxy/mitmproxy/pull/6537), @mhils) ## 14 November 2023: mitmproxy 10.1.5 diff --git a/mitmproxy/addons/tlsconfig.py b/mitmproxy/addons/tlsconfig.py index e044d1d1c8..63f876a0da 100644 --- a/mitmproxy/addons/tlsconfig.py +++ b/mitmproxy/addons/tlsconfig.py @@ -8,6 +8,7 @@ from aioquic.h3.connection import H3_ALPN from aioquic.tls import CipherSuite +from cryptography import x509 from OpenSSL import crypto from OpenSSL import SSL @@ -488,31 +489,42 @@ def get_cert(self, conn_context: context.Context) -> certs.CertStoreEntry: This function determines the Common Name (CN), Subject Alternative Names (SANs) and Organization Name our certificate should have and then fetches a matching cert from the certstore. """ - altnames: list[str] = [] + altnames: list[x509.GeneralName] = [] organization: str | None = None # Use upstream certificate if available. if ctx.options.upstream_cert and conn_context.server.certificate_list: upstream_cert = conn_context.server.certificate_list[0] if upstream_cert.cn: - altnames.append(upstream_cert.cn) + altnames.append(_ip_or_dns_name(upstream_cert.cn)) altnames.extend(upstream_cert.altnames) if upstream_cert.organization: organization = upstream_cert.organization # Add SNI or our local IP address. if conn_context.client.sni: - altnames.append(conn_context.client.sni) + altnames.append(_ip_or_dns_name(conn_context.client.sni)) else: - altnames.append(conn_context.client.sockname[0]) + altnames.append(_ip_or_dns_name(conn_context.client.sockname[0])) # If we already know of a server address, include that in the SANs as well. if conn_context.server.address: - altnames.append(conn_context.server.address[0]) + altnames.append(_ip_or_dns_name(conn_context.server.address[0])) # only keep first occurrence of each hostname altnames = list(dict.fromkeys(altnames)) # RFC 2818: If a subjectAltName extension of type dNSName is present, that MUST be used as the identity. # In other words, the Common Name is irrelevant then. - return self.certstore.get_cert(altnames[0], altnames, organization) + cn = next((str(x.value) for x in altnames), None) + return self.certstore.get_cert(cn, altnames, organization) + + +def _ip_or_dns_name(val: str) -> x509.GeneralName: + """Convert a string into either an x509.IPAddress or x509.DNSName object.""" + try: + ip = ipaddress.ip_address(val) + except ValueError: + return x509.DNSName(val) + else: + return x509.IPAddress(ip) diff --git a/mitmproxy/certs.py b/mitmproxy/certs.py index c5bba3ebc6..858b46de4e 100644 --- a/mitmproxy/certs.py +++ b/mitmproxy/certs.py @@ -3,6 +3,8 @@ import ipaddress import os import sys +import warnings +from collections.abc import Iterable from dataclasses import dataclass from pathlib import Path from typing import cast @@ -58,7 +60,8 @@ def __eq__(self, other): return self.fingerprint() == other.fingerprint() def __repr__(self): - return f"" + altnames = [str(x.value) for x in self.altnames] + return f"" def __hash__(self): return self._cert.__hash__() @@ -147,20 +150,18 @@ def organization(self) -> str | None: return None @property - def altnames(self) -> list[str]: + def altnames(self) -> x509.GeneralNames: """ Get all SubjectAlternativeName DNS altnames. """ try: - ext = self._cert.extensions.get_extension_for_class( + sans = self._cert.extensions.get_extension_for_class( x509.SubjectAlternativeName ).value except x509.ExtensionNotFound: - return [] + return x509.GeneralNames([]) else: - return ext.get_values_for_type(x509.DNSName) + [ - str(x) for x in ext.get_values_for_type(x509.IPAddress) - ] + return x509.GeneralNames(sans) def _name_to_keyval(name: x509.Name) -> list[tuple[str, str]]: @@ -224,11 +225,41 @@ def create_ca( return private_key, cert +def _fix_legacy_sans(sans: Iterable[x509.GeneralName] | list[str]) -> x509.GeneralNames: + """ + SANs used to be a list of strings in mitmproxy 10.1 and below, but now they're a list of GeneralNames. + This function converts the old format to the new one. + """ + if isinstance(sans, x509.GeneralNames): + return sans + elif ( + isinstance(sans, list) and len(sans) > 0 and isinstance(sans[0], str) + ): # pragma: no cover + warnings.warn( + "Passing SANs as a list of strings is deprecated.", + DeprecationWarning, + stacklevel=2, + ) + + ss: list[x509.GeneralName] = [] + for x in cast(list[str], sans): + try: + ip = ipaddress.ip_address(x) + except ValueError: + x = x.encode("idna").decode() + ss.append(x509.DNSName(x)) + else: + ss.append(x509.IPAddress(ip)) + return x509.GeneralNames(ss) + else: + return x509.GeneralNames(sans) + + def dummy_cert( privkey: rsa.RSAPrivateKey, cacert: x509.Certificate, commonname: str | None, - sans: list[str], + sans: Iterable[x509.GeneralName], organization: str | None = None, ) -> Cert: """ @@ -264,18 +295,10 @@ def dummy_cert( builder = builder.subject_name(x509.Name(subject)) builder = builder.serial_number(x509.random_serial_number()) - ss: list[x509.GeneralName] = [] - for x in sans: - try: - ip = ipaddress.ip_address(x) - except ValueError: - x = x.encode("idna").decode() - ss.append(x509.DNSName(x)) - else: - ss.append(x509.IPAddress(ip)) # RFC 5280 §4.2.1.6: subjectAltName is critical if subject is empty. builder = builder.add_extension( - x509.SubjectAlternativeName(ss), critical=not is_valid_commonname + x509.SubjectAlternativeName(_fix_legacy_sans(sans)), + critical=not is_valid_commonname, ) # https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.1 @@ -301,7 +324,7 @@ class CertStoreEntry: TCustomCertId = str # manually provided certs (e.g. mitmproxy's --certs) -TGeneratedCertId = tuple[Optional[str], tuple[str, ...]] # (common_name, sans) +TGeneratedCertId = tuple[Optional[str], x509.GeneralNames] # (common_name, sans) TCertId = Union[TCustomCertId, TGeneratedCertId] DHParams = NewType("DHParams", bytes) @@ -485,26 +508,31 @@ def add_cert(self, entry: CertStoreEntry, *names: str) -> None: if entry.cert.cn: self.certs[entry.cert.cn] = entry for i in entry.cert.altnames: - self.certs[i] = entry + self.certs[str(i.value)] = entry for i in names: self.certs[i] = entry @staticmethod - def asterisk_forms(dn: str) -> list[str]: + def asterisk_forms(dn: str | x509.GeneralName) -> list[str]: """ Return all asterisk forms for a domain. For example, for www.example.com this will return [b"www.example.com", b"*.example.com", b"*.com"]. The single wildcard "*" is omitted. """ - parts = dn.split(".") - ret = [dn] - for i in range(1, len(parts)): - ret.append("*." + ".".join(parts[i:])) - return ret + if isinstance(dn, str): + parts = dn.split(".") + ret = [dn] + for i in range(1, len(parts)): + ret.append("*." + ".".join(parts[i:])) + return ret + elif isinstance(dn, x509.DNSName): + return CertStore.asterisk_forms(dn.value) + else: + return [str(dn.value)] def get_cert( self, commonname: str | None, - sans: list[str], + sans: Iterable[x509.GeneralName], organization: str | None = None, ) -> CertStoreEntry: """ @@ -515,6 +543,7 @@ def get_cert( organization: Organization name for the generated certificate. """ + sans = _fix_legacy_sans(sans) potential_keys: list[TCertId] = [] if commonname: @@ -522,7 +551,7 @@ def get_cert( for s in sans: potential_keys.extend(self.asterisk_forms(s)) potential_keys.append("*") - potential_keys.append((commonname, tuple(sans))) + potential_keys.append((commonname, sans)) name = next(filter(lambda key: key in self.certs, potential_keys), None) if name: @@ -540,7 +569,7 @@ def get_cert( chain_file=self.default_chain_file, chain_certs=self.default_chain_certs, ) - self.certs[(commonname, tuple(sans))] = entry + self.certs[(commonname, sans)] = entry self.expire(entry) return entry diff --git a/mitmproxy/tools/console/flowdetailview.py b/mitmproxy/tools/console/flowdetailview.py index b8b2745549..e3a28b91a6 100644 --- a/mitmproxy/tools/console/flowdetailview.py +++ b/mitmproxy/tools/console/flowdetailview.py @@ -80,7 +80,7 @@ def flowdetails(state, flow: mitmproxy.flow.Flow): ] if c.altnames: - parts.append(("Alt names", ", ".join(c.altnames))) + parts.append(("Alt names", ", ".join(str(x.value) for x in c.altnames))) text.extend(common.format_keyvals(parts, indent=4)) if cc is not None: diff --git a/mitmproxy/tools/web/app.py b/mitmproxy/tools/web/app.py index f031d6787f..db68b866ad 100644 --- a/mitmproxy/tools/web/app.py +++ b/mitmproxy/tools/web/app.py @@ -50,7 +50,7 @@ def cert_to_json(certs: Sequence[certs.Cert]) -> dict | None: "serial": str(cert.serial), "subject": cert.subject, "issuer": cert.issuer, - "altnames": cert.altnames, + "altnames": [str(x.value) for x in cert.altnames], } diff --git a/test/mitmproxy/addons/test_tlsconfig.py b/test/mitmproxy/addons/test_tlsconfig.py index 64144e12e5..d209fd91eb 100644 --- a/test/mitmproxy/addons/test_tlsconfig.py +++ b/test/mitmproxy/addons/test_tlsconfig.py @@ -1,3 +1,4 @@ +import ipaddress import ssl import time from pathlib import Path @@ -128,20 +129,24 @@ def test_get_cert(self, tdata): ctx.server.certificate_list = [certs.Cert.from_pem(f.read())] entry = ta.get_cert(ctx) assert entry.cert.cn == "example.mitmproxy.org" - assert entry.cert.altnames == [ - "example.mitmproxy.org", - "server-address.example", - "127.0.0.1", - ] + assert entry.cert.altnames == x509.GeneralNames( + [ + x509.DNSName("example.mitmproxy.org"), + x509.IPAddress(ipaddress.ip_address("127.0.0.1")), + x509.DNSName("server-address.example"), + ] + ) # And now we also incorporate SNI. ctx.client.sni = "sni.example" entry = ta.get_cert(ctx) - assert entry.cert.altnames == [ - "example.mitmproxy.org", - "sni.example", - "server-address.example", - ] + assert entry.cert.altnames == x509.GeneralNames( + [ + x509.DNSName("example.mitmproxy.org"), + x509.DNSName("sni.example"), + x509.DNSName("server-address.example"), + ] + ) with open(tdata.path("mitmproxy/data/invalid-subject.pem"), "rb") as f: ctx.server.certificate_list = [certs.Cert.from_pem(f.read())] diff --git a/test/mitmproxy/test_certs.py b/test/mitmproxy/test_certs.py index d3c33727cb..d3850fdaf5 100644 --- a/test/mitmproxy/test_certs.py +++ b/test/mitmproxy/test_certs.py @@ -1,3 +1,4 @@ +import ipaddress import os from datetime import datetime from datetime import timezone @@ -73,16 +74,16 @@ def test_chain_file(self, tdata, tmp_path): assert len(ca.default_chain_certs) == 2 def test_sans(self, tstore): - c1 = tstore.get_cert("foo.com", ["*.bar.com"]) + c1 = tstore.get_cert("foo.com", [x509.DNSName("*.bar.com")]) tstore.get_cert("foo.bar.com", []) # assert c1 == c2 c3 = tstore.get_cert("bar.com", []) assert not c1 == c3 def test_sans_change(self, tstore): - tstore.get_cert("foo.com", ["*.bar.com"]) - entry = tstore.get_cert("foo.bar.com", ["*.baz.com"]) - assert "*.baz.com" in entry.cert.altnames + tstore.get_cert("foo.com", [x509.DNSName("*.bar.com")]) + entry = tstore.get_cert("foo.bar.com", [x509.DNSName("*.baz.com")]) + assert x509.DNSName("*.baz.com") in entry.cert.altnames def test_expire(self, tstore): tstore.STORE_CAP = 3 @@ -90,29 +91,29 @@ def test_expire(self, tstore): tstore.get_cert("two.com", []) tstore.get_cert("three.com", []) - assert ("one.com", ()) in tstore.certs - assert ("two.com", ()) in tstore.certs - assert ("three.com", ()) in tstore.certs + assert ("one.com", x509.GeneralNames([])) in tstore.certs + assert ("two.com", x509.GeneralNames([])) in tstore.certs + assert ("three.com", x509.GeneralNames([])) in tstore.certs tstore.get_cert("one.com", []) - assert ("one.com", ()) in tstore.certs - assert ("two.com", ()) in tstore.certs - assert ("three.com", ()) in tstore.certs + assert ("one.com", x509.GeneralNames([])) in tstore.certs + assert ("two.com", x509.GeneralNames([])) in tstore.certs + assert ("three.com", x509.GeneralNames([])) in tstore.certs tstore.get_cert("four.com", []) - assert ("one.com", ()) not in tstore.certs - assert ("two.com", ()) in tstore.certs - assert ("three.com", ()) in tstore.certs - assert ("four.com", ()) in tstore.certs + assert ("one.com", x509.GeneralNames([])) not in tstore.certs + assert ("two.com", x509.GeneralNames([])) in tstore.certs + assert ("three.com", x509.GeneralNames([])) in tstore.certs + assert ("four.com", x509.GeneralNames([])) in tstore.certs def test_overrides(self, tmp_path): ca1 = certs.CertStore.from_store(tmp_path / "ca1", "test", 2048) ca2 = certs.CertStore.from_store(tmp_path / "ca2", "test", 2048) assert not ca1.default_ca.serial == ca2.default_ca.serial - dc = ca2.get_cert("foo.com", ["sans.example.com"]) + dc = ca2.get_cert("foo.com", [x509.DNSName("sans.example.com")]) dcp = tmp_path / "dc" dcp.write_bytes(dc.cert.to_pem()) ca1.add_cert_file("foo.com", dcp) @@ -133,6 +134,23 @@ def test_umask_secret(self, tmpdir): # TODO: How do we actually attempt to read that file as another user? assert os.stat(filename).st_mode & 0o77 == 0 + @pytest.mark.parametrize( + "input,output", + [ + ( + "subdomain.example.com", + ["subdomain.example.com", "*.example.com", "*.com"], + ), + ( + x509.DNSName("subdomain.example.com"), + ["subdomain.example.com", "*.example.com", "*.com"], + ), + (x509.IPAddress(ipaddress.ip_address("127.0.0.1")), ["127.0.0.1"]), + ], + ) + def test_asterisk_forms(self, input, output): + assert certs.CertStore.asterisk_forms(input) == output + class TestDummyCert: def test_with_ca(self, tstore): @@ -140,17 +158,25 @@ def test_with_ca(self, tstore): tstore.default_privatekey, tstore.default_ca._cert, "foo.com", - ["one.com", "two.com", "*.three.com", "127.0.0.1", "bücher.example"], + [ + x509.DNSName("one.com"), + x509.DNSName("two.com"), + x509.DNSName("*.three.com"), + x509.IPAddress(ipaddress.ip_address("127.0.0.1")), + x509.DNSName("bücher.example".encode("idna").decode("ascii")), + ], "Foo Ltd.", ) assert r.cn == "foo.com" - assert r.altnames == [ - "one.com", - "two.com", - "*.three.com", - "xn--bcher-kva.example", - "127.0.0.1", - ] + assert r.altnames == x509.GeneralNames( + [ + x509.DNSName("one.com"), + x509.DNSName("two.com"), + x509.DNSName("*.three.com"), + x509.IPAddress(ipaddress.ip_address("127.0.0.1")), + x509.DNSName("xn--bcher-kva.example"), + ] + ) assert r.organization == "Foo Ltd." r = certs.dummy_cert( @@ -158,7 +184,7 @@ def test_with_ca(self, tstore): ) assert r.cn is None assert r.organization is None - assert r.altnames == [] + assert r.altnames == x509.GeneralNames([]) class TestCert: From e992d82f7d88e4cf3a9ed5479ebb4b8c0170b90d Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 14 Dec 2023 10:27:42 +0100 Subject: [PATCH 010/283] unify download filenames (#6487) refs https://github.com/mitmproxy/www/issues/57 --- release/build.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/release/build.py b/release/build.py index 9d6bdf6dad..2a2e69a235 100755 --- a/release/build.py +++ b/release/build.py @@ -89,17 +89,25 @@ def version() -> str: def operating_system() -> str: - match (platform.system(), platform.machine()): - case ("Windows", _): - return "windows" - case ("Linux", _): - return "linux" - case ("Darwin", "x86_64"): - return "macos-x86_64" - case ("Darwin", "arm64"): - return "macos-arm64" - warnings.warn("Unexpected platform.") - return f"{platform.system()}-{platform.machine()}" + match platform.system(): + case "Windows": + system = "windows" + case "Linux": + system = "linux" + case "Darwin": + system = "macos" + case other: + warnings.warn("Unexpected system.") + system = other + match platform.machine(): + case "AMD64" | "x86_64": + machine = "x86_64" + case "arm64": + machine = "arm64" + case other: + warnings.warn("Unexpected platform.") + machine = other + return f"{system}-{machine}" def _pyinstaller(specfile: str) -> None: @@ -350,6 +358,11 @@ def report(block, blocksize, total): installer = DIST_DIR / f"mitmproxy-{version()}-windows-x64-installer.exe" assert installer.exists() + # unify filenames + installer = installer.rename( + installer.with_name(installer.name.replace("x64", "x86_64")) + ) + print("Run installer...") subprocess.run( [installer, "--mode", "unattended", "--unattendedmodeui", "none"], check=True From d79862c8bb09eaaef4cac281d52dd102e6ce1b7f Mon Sep 17 00:00:00 2001 From: mitmproxy release bot Date: Thu, 14 Dec 2023 09:39:20 +0000 Subject: [PATCH 011/283] mitmproxy 10.1.6 --- CHANGELOG.md | 4 ++ mitmproxy/tools/web/static/app.js | 70 +++++++++++++++---------------- mitmproxy/version.py | 2 +- 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbf47091ee..f133bde91d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ ## Unreleased: mitmproxy next + + +## 14 December 2023: mitmproxy 10.1.6 + * Fix compatibility with Windows Schannel clients, which previously got confused by CA and leaf certificate sharing the same Subject Key Identifier. ([#6549](https://github.com/mitmproxy/mitmproxy/pull/6549), @driuba and @mhils) diff --git a/mitmproxy/tools/web/static/app.js b/mitmproxy/tools/web/static/app.js index 11a11b85eb..f67ebb1098 100644 --- a/mitmproxy/tools/web/static/app.js +++ b/mitmproxy/tools/web/static/app.js @@ -1,15 +1,15 @@ -(()=>{var cD=Object.create;var qc=Object.defineProperty,pD=Object.defineProperties,dD=Object.getOwnPropertyDescriptor,hD=Object.getOwnPropertyDescriptors,mD=Object.getOwnPropertyNames,Dg=Object.getOwnPropertySymbols,gD=Object.getPrototypeOf,Sw=Object.prototype.hasOwnProperty,Bb=Object.prototype.propertyIsEnumerable;var Cw=(e,t,n)=>t in e?qc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ke=(e,t)=>{for(var n in t||(t={}))Sw.call(t,n)&&Cw(e,n,t[n]);if(Dg)for(var n of Dg(t))Bb.call(t,n)&&Cw(e,n,t[n]);return e},Pt=(e,t)=>pD(e,hD(t)),Hb=e=>qc(e,"__esModule",{value:!0}),o=(e,t)=>qc(e,"name",{value:t,configurable:!0});var Ws=(e,t)=>{var n={};for(var l in e)Sw.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(e!=null&&Dg)for(var l of Dg(e))t.indexOf(l)<0&&Bb.call(e,l)&&(n[l]=e[l]);return n};var Ue=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Wb=(e,t)=>{Hb(e);for(var n in t)qc(e,n,{get:t[n],enumerable:!0})},vD=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of mD(t))!Sw.call(e,l)&&l!=="default"&&qc(e,l,{get:()=>t[l],enumerable:!(n=dD(t,l))||n.enumerable});return e},fe=e=>vD(Hb(qc(e!=null?cD(gD(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Vc=(e,t,n)=>(Cw(e,typeof t!="symbol"?t+"":t,n),n);var Ia=(e,t,n)=>new Promise((l,d)=>{var h=C=>{try{v(n.next(C))}catch(k){d(k)}},c=C=>{try{v(n.throw(C))}catch(k){d(k)}},v=C=>C.done?l(C.value):Promise.resolve(C.value).then(h,c);v((n=n.apply(e,t)).next())});var bw=Ue((cH,zb)=>{"use strict";var Ub=Object.getOwnPropertySymbols,yD=Object.prototype.hasOwnProperty,wD=Object.prototype.propertyIsEnumerable;function xD(e){if(e==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}o(xD,"toObject");function SD(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de",Object.getOwnPropertyNames(e)[0]==="5")return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var l=Object.getOwnPropertyNames(t).map(function(h){return t[h]});if(l.join("")!=="0123456789")return!1;var d={};return"abcdefghijklmnopqrst".split("").forEach(function(h){d[h]=h}),Object.keys(Object.assign({},d)).join("")==="abcdefghijklmnopqrst"}catch(h){return!1}}o(SD,"shouldUseNative");zb.exports=SD()?Object.assign:function(e,t){for(var n,l=xD(e),d,h=1;h{"use strict";var Ew=bw(),Kc=60103,$b=60106;Et.Fragment=60107;Et.StrictMode=60108;Et.Profiler=60114;var jb=60109,qb=60110,Vb=60112;Et.Suspense=60113;var Kb=60115,Gb=60116;typeof Symbol=="function"&&Symbol.for&&(Co=Symbol.for,Kc=Co("react.element"),$b=Co("react.portal"),Et.Fragment=Co("react.fragment"),Et.StrictMode=Co("react.strict_mode"),Et.Profiler=Co("react.profiler"),jb=Co("react.provider"),qb=Co("react.context"),Vb=Co("react.forward_ref"),Et.Suspense=Co("react.suspense"),Kb=Co("react.memo"),Gb=Co("react.lazy"));var Co,Yb=typeof Symbol=="function"&&Symbol.iterator;function CD(e){return e===null||typeof e!="object"?null:(e=Yb&&e[Yb]||e["@@iterator"],typeof e=="function"?e:null)}o(CD,"y");function Yd(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n{"use strict";oE.exports=iE()});var cE=Ue(Rt=>{"use strict";var Yc,Xd,Fg,Pw;typeof performance=="object"&&typeof performance.now=="function"?(sE=performance,Rt.unstable_now=function(){return sE.now()}):(Ow=Date,lE=Ow.now(),Rt.unstable_now=function(){return Ow.now()-lE});var sE,Ow,lE;typeof window=="undefined"||typeof MessageChannel!="function"?(Xc=null,Mw=null,Aw=o(function(){if(Xc!==null)try{var e=Rt.unstable_now();Xc(!0,e),Xc=null}catch(t){throw setTimeout(Aw,0),t}},"w"),Yc=o(function(e){Xc!==null?setTimeout(Yc,0,e):(Xc=e,setTimeout(Aw,0))},"f"),Xd=o(function(e,t){Mw=setTimeout(e,t)},"g"),Fg=o(function(){clearTimeout(Mw)},"h"),Rt.unstable_shouldYield=function(){return!1},Pw=Rt.unstable_forceFrameRate=function(){}):(aE=window.setTimeout,uE=window.clearTimeout,typeof console!="undefined"&&(fE=window.cancelAnimationFrame,typeof window.requestAnimationFrame!="function"&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),typeof fE!="function"&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")),Qd=!1,Zd=null,Bg=-1,Dw=5,Rw=0,Rt.unstable_shouldYield=function(){return Rt.unstable_now()>=Rw},Pw=o(function(){},"k"),Rt.unstable_forceFrameRate=function(e){0>e||125>>1,d=e[l];if(d!==void 0&&0Ug(c,n))C!==void 0&&0>Ug(C,c)?(e[l]=C,e[v]=n,l=v):(e[l]=c,e[h]=n,l=h);else if(C!==void 0&&0>Ug(C,n))e[l]=C,e[v]=n,l=v;else break e}}return t}return null}o(Wg,"K");function Ug(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}o(Ug,"I");var Us=[],Fa=[],kD=1,bo=null,Yn=3,zg=!1,df=!1,Jd=!1;function Bw(e){for(var t=os(Fa);t!==null;){if(t.callback===null)Wg(Fa);else if(t.startTime<=e)Wg(Fa),t.sortIndex=t.expirationTime,Fw(Us,t);else break;t=os(Fa)}}o(Bw,"T");function Hw(e){if(Jd=!1,Bw(e),!df)if(os(Us)!==null)df=!0,Yc(Ww);else{var t=os(Fa);t!==null&&Xd(Hw,t.startTime-e)}}o(Hw,"U");function Ww(e,t){df=!1,Jd&&(Jd=!1,Fg()),zg=!0;var n=Yn;try{for(Bw(t),bo=os(Us);bo!==null&&(!(bo.expirationTime>t)||e&&!Rt.unstable_shouldYield());){var l=bo.callback;if(typeof l=="function"){bo.callback=null,Yn=bo.priorityLevel;var d=l(bo.expirationTime<=t);t=Rt.unstable_now(),typeof d=="function"?bo.callback=d:bo===os(Us)&&Wg(Us),Bw(t)}else Wg(Us);bo=os(Us)}if(bo!==null)var h=!0;else{var c=os(Fa);c!==null&&Xd(Hw,c.startTime-t),h=!1}return h}finally{bo=null,Yn=n,zg=!1}}o(Ww,"V");var ND=Pw;Rt.unstable_IdlePriority=5;Rt.unstable_ImmediatePriority=1;Rt.unstable_LowPriority=4;Rt.unstable_NormalPriority=3;Rt.unstable_Profiling=null;Rt.unstable_UserBlockingPriority=2;Rt.unstable_cancelCallback=function(e){e.callback=null};Rt.unstable_continueExecution=function(){df||zg||(df=!0,Yc(Ww))};Rt.unstable_getCurrentPriorityLevel=function(){return Yn};Rt.unstable_getFirstCallbackNode=function(){return os(Us)};Rt.unstable_next=function(e){switch(Yn){case 1:case 2:case 3:var t=3;break;default:t=Yn}var n=Yn;Yn=t;try{return e()}finally{Yn=n}};Rt.unstable_pauseExecution=function(){};Rt.unstable_requestPaint=ND;Rt.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=Yn;Yn=e;try{return t()}finally{Yn=n}};Rt.unstable_scheduleCallback=function(e,t,n){var l=Rt.unstable_now();switch(typeof n=="object"&&n!==null?(n=n.delay,n=typeof n=="number"&&0l?(e.sortIndex=n,Fw(Fa,e),os(Us)===null&&e===os(Fa)&&(Jd?Fg():Jd=!0,Xd(Hw,n-l))):(e.sortIndex=d,Fw(Us,e),df||zg||(df=!0,Yc(Ww))),e};Rt.unstable_wrapCallback=function(e){var t=Yn;return function(){var n=Yn;Yn=t;try{return e.apply(this,arguments)}finally{Yn=n}}}});var dE=Ue((mH,pE)=>{"use strict";pE.exports=cE()});var JT=Ue(Lo=>{"use strict";var $g=Oe(),hr=bw(),Tn=dE();function we(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;nt}return!1}o(MD,"na");function vi(e,t,n,l,d,h,c){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=h,this.removeEmptyString=c}o(vi,"B");var Rn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Rn[e]=new vi(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Rn[t]=new vi(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Rn[e]=new vi(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Rn[e]=new vi(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Rn[e]=new vi(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Rn[e]=new vi(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Rn[e]=new vi(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Rn[e]=new vi(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Rn[e]=new vi(e,5,!1,e.toLowerCase(),null,!1,!1)});var Uw=/[\-:]([a-z])/g;function zw(e){return e[1].toUpperCase()}o(zw,"pa");"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Uw,zw);Rn[t]=new vi(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Uw,zw);Rn[t]=new vi(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Uw,zw);Rn[t]=new vi(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Rn[e]=new vi(e,1,!1,e.toLowerCase(),null,!1,!1)});Rn.xlinkHref=new vi("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Rn[e]=new vi(e,1,!1,e.toLowerCase(),null,!0,!0)});function $w(e,t,n,l){var d=Rn.hasOwnProperty(t)?Rn[t]:null,h=d!==null?d.type===0:l?!1:!(!(2{var cD=Object.create;var qc=Object.defineProperty,pD=Object.defineProperties,dD=Object.getOwnPropertyDescriptor,hD=Object.getOwnPropertyDescriptors,mD=Object.getOwnPropertyNames,Ag=Object.getOwnPropertySymbols,gD=Object.getPrototypeOf,xw=Object.prototype.hasOwnProperty,Fb=Object.prototype.propertyIsEnumerable;var Sw=(e,t,n)=>t in e?qc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ke=(e,t)=>{for(var n in t||(t={}))xw.call(t,n)&&Sw(e,n,t[n]);if(Ag)for(var n of Ag(t))Fb.call(t,n)&&Sw(e,n,t[n]);return e},Lt=(e,t)=>pD(e,hD(t)),Bb=e=>qc(e,"__esModule",{value:!0}),o=(e,t)=>qc(e,"name",{value:t,configurable:!0});var Ws=(e,t)=>{var n={};for(var l in e)xw.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(e!=null&&Ag)for(var l of Ag(e))t.indexOf(l)<0&&Fb.call(e,l)&&(n[l]=e[l]);return n};var Ue=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Hb=(e,t)=>{Bb(e);for(var n in t)qc(e,n,{get:t[n],enumerable:!0})},vD=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of mD(t))!xw.call(e,l)&&l!=="default"&&qc(e,l,{get:()=>t[l],enumerable:!(n=dD(t,l))||n.enumerable});return e},fe=e=>vD(Bb(qc(e!=null?cD(gD(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Vc=(e,t,n)=>(Sw(e,typeof t!="symbol"?t+"":t,n),n);var Ia=(e,t,n)=>new Promise((l,d)=>{var h=C=>{try{v(n.next(C))}catch(k){d(k)}},c=C=>{try{v(n.throw(C))}catch(k){d(k)}},v=C=>C.done?l(C.value):Promise.resolve(C.value).then(h,c);v((n=n.apply(e,t)).next())});var Cw=Ue((cH,Ub)=>{"use strict";var Wb=Object.getOwnPropertySymbols,yD=Object.prototype.hasOwnProperty,wD=Object.prototype.propertyIsEnumerable;function xD(e){if(e==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}o(xD,"toObject");function SD(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de",Object.getOwnPropertyNames(e)[0]==="5")return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var l=Object.getOwnPropertyNames(t).map(function(h){return t[h]});if(l.join("")!=="0123456789")return!1;var d={};return"abcdefghijklmnopqrst".split("").forEach(function(h){d[h]=h}),Object.keys(Object.assign({},d)).join("")==="abcdefghijklmnopqrst"}catch(h){return!1}}o(SD,"shouldUseNative");Ub.exports=SD()?Object.assign:function(e,t){for(var n,l=xD(e),d,h=1;h{"use strict";var bw=Cw(),Kc=60103,zb=60106;_t.Fragment=60107;_t.StrictMode=60108;_t.Profiler=60114;var $b=60109,jb=60110,qb=60112;_t.Suspense=60113;var Vb=60115,Kb=60116;typeof Symbol=="function"&&Symbol.for&&(Co=Symbol.for,Kc=Co("react.element"),zb=Co("react.portal"),_t.Fragment=Co("react.fragment"),_t.StrictMode=Co("react.strict_mode"),_t.Profiler=Co("react.profiler"),$b=Co("react.provider"),jb=Co("react.context"),qb=Co("react.forward_ref"),_t.Suspense=Co("react.suspense"),Vb=Co("react.memo"),Kb=Co("react.lazy"));var Co,Gb=typeof Symbol=="function"&&Symbol.iterator;function CD(e){return e===null||typeof e!="object"?null:(e=Gb&&e[Gb]||e["@@iterator"],typeof e=="function"?e:null)}o(CD,"y");function Yd(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n{"use strict";i_.exports=n_()});var f_=Ue(Rt=>{"use strict";var Yc,Xd,Ig,Pw;typeof performance=="object"&&typeof performance.now=="function"?(o_=performance,Rt.unstable_now=function(){return o_.now()}):(Lw=Date,s_=Lw.now(),Rt.unstable_now=function(){return Lw.now()-s_});var o_,Lw,s_;typeof window=="undefined"||typeof MessageChannel!="function"?(Xc=null,Ow=null,Mw=o(function(){if(Xc!==null)try{var e=Rt.unstable_now();Xc(!0,e),Xc=null}catch(t){throw setTimeout(Mw,0),t}},"w"),Yc=o(function(e){Xc!==null?setTimeout(Yc,0,e):(Xc=e,setTimeout(Mw,0))},"f"),Xd=o(function(e,t){Ow=setTimeout(e,t)},"g"),Ig=o(function(){clearTimeout(Ow)},"h"),Rt.unstable_shouldYield=function(){return!1},Pw=Rt.unstable_forceFrameRate=function(){}):(l_=window.setTimeout,a_=window.clearTimeout,typeof console!="undefined"&&(u_=window.cancelAnimationFrame,typeof window.requestAnimationFrame!="function"&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),typeof u_!="function"&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")),Qd=!1,Zd=null,Fg=-1,Aw=5,Dw=0,Rt.unstable_shouldYield=function(){return Rt.unstable_now()>=Dw},Pw=o(function(){},"k"),Rt.unstable_forceFrameRate=function(e){0>e||125>>1,d=e[l];if(d!==void 0&&0Wg(c,n))C!==void 0&&0>Wg(C,c)?(e[l]=C,e[v]=n,l=v):(e[l]=c,e[h]=n,l=h);else if(C!==void 0&&0>Wg(C,n))e[l]=C,e[v]=n,l=v;else break e}}return t}return null}o(Hg,"K");function Wg(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}o(Wg,"I");var Us=[],Fa=[],kD=1,bo=null,Yn=3,Ug=!1,df=!1,Jd=!1;function Fw(e){for(var t=os(Fa);t!==null;){if(t.callback===null)Hg(Fa);else if(t.startTime<=e)Hg(Fa),t.sortIndex=t.expirationTime,Iw(Us,t);else break;t=os(Fa)}}o(Fw,"T");function Bw(e){if(Jd=!1,Fw(e),!df)if(os(Us)!==null)df=!0,Yc(Hw);else{var t=os(Fa);t!==null&&Xd(Bw,t.startTime-e)}}o(Bw,"U");function Hw(e,t){df=!1,Jd&&(Jd=!1,Ig()),Ug=!0;var n=Yn;try{for(Fw(t),bo=os(Us);bo!==null&&(!(bo.expirationTime>t)||e&&!Rt.unstable_shouldYield());){var l=bo.callback;if(typeof l=="function"){bo.callback=null,Yn=bo.priorityLevel;var d=l(bo.expirationTime<=t);t=Rt.unstable_now(),typeof d=="function"?bo.callback=d:bo===os(Us)&&Hg(Us),Fw(t)}else Hg(Us);bo=os(Us)}if(bo!==null)var h=!0;else{var c=os(Fa);c!==null&&Xd(Bw,c.startTime-t),h=!1}return h}finally{bo=null,Yn=n,Ug=!1}}o(Hw,"V");var ND=Pw;Rt.unstable_IdlePriority=5;Rt.unstable_ImmediatePriority=1;Rt.unstable_LowPriority=4;Rt.unstable_NormalPriority=3;Rt.unstable_Profiling=null;Rt.unstable_UserBlockingPriority=2;Rt.unstable_cancelCallback=function(e){e.callback=null};Rt.unstable_continueExecution=function(){df||Ug||(df=!0,Yc(Hw))};Rt.unstable_getCurrentPriorityLevel=function(){return Yn};Rt.unstable_getFirstCallbackNode=function(){return os(Us)};Rt.unstable_next=function(e){switch(Yn){case 1:case 2:case 3:var t=3;break;default:t=Yn}var n=Yn;Yn=t;try{return e()}finally{Yn=n}};Rt.unstable_pauseExecution=function(){};Rt.unstable_requestPaint=ND;Rt.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=Yn;Yn=e;try{return t()}finally{Yn=n}};Rt.unstable_scheduleCallback=function(e,t,n){var l=Rt.unstable_now();switch(typeof n=="object"&&n!==null?(n=n.delay,n=typeof n=="number"&&0l?(e.sortIndex=n,Iw(Fa,e),os(Us)===null&&e===os(Fa)&&(Jd?Ig():Jd=!0,Xd(Bw,n-l))):(e.sortIndex=d,Iw(Us,e),df||Ug||(df=!0,Yc(Hw))),e};Rt.unstable_wrapCallback=function(e){var t=Yn;return function(){var n=Yn;Yn=t;try{return e.apply(this,arguments)}finally{Yn=n}}}});var p_=Ue((mH,c_)=>{"use strict";c_.exports=f_()});var ZT=Ue(Po=>{"use strict";var zg=Oe(),hr=Cw(),Tn=p_();function we(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;nt}return!1}o(MD,"na");function vi(e,t,n,l,d,h,c){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=h,this.removeEmptyString=c}o(vi,"B");var Rn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Rn[e]=new vi(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Rn[t]=new vi(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Rn[e]=new vi(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Rn[e]=new vi(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Rn[e]=new vi(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Rn[e]=new vi(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Rn[e]=new vi(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Rn[e]=new vi(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Rn[e]=new vi(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ww=/[\-:]([a-z])/g;function Uw(e){return e[1].toUpperCase()}o(Uw,"pa");"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ww,Uw);Rn[t]=new vi(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ww,Uw);Rn[t]=new vi(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ww,Uw);Rn[t]=new vi(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Rn[e]=new vi(e,1,!1,e.toLowerCase(),null,!1,!1)});Rn.xlinkHref=new vi("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Rn[e]=new vi(e,1,!1,e.toLowerCase(),null,!0,!0)});function zw(e,t,n,l){var d=Rn.hasOwnProperty(t)?Rn[t]:null,h=d!==null?d.type===0:l?!1:!(!(2v||d[c]!==h[v])return` -`+d[c].replace(" at new "," at ");while(1<=c&&0<=v);break}}}finally{Jw=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?oh(e):""}o(Kg,"Pa");function AD(e){switch(e.tag){case 5:return oh(e.type);case 16:return oh("Lazy");case 13:return oh("Suspense");case 19:return oh("SuspenseList");case 0:case 2:case 15:return e=Kg(e.type,!1),e;case 11:return e=Kg(e.type.render,!1),e;case 22:return e=Kg(e.type._render,!1),e;case 1:return e=Kg(e.type,!0),e;default:return""}}o(AD,"Qa");function Zc(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ba:return"Fragment";case gf:return"Portal";case rh:return"Profiler";case jw:return"StrictMode";case nh:return"Suspense";case qg:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Vw:return(e.displayName||"Context")+".Consumer";case qw:return(e._context.displayName||"Context")+".Provider";case jg:var t=e.render;return t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case Vg:return Zc(e.type);case Gw:return Zc(e._render);case Kw:t=e._payload,e=e._init;try{return Zc(e(t))}catch(n){}}return null}o(Zc,"Ra");function Ha(e){switch(typeof e){case"boolean":case"number":case"object":case"string":case"undefined":return e;default:return""}}o(Ha,"Sa");function xE(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}o(xE,"Ta");function DD(e){var t=xE(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),l=""+e[t];if(!e.hasOwnProperty(t)&&typeof n!="undefined"&&typeof n.get=="function"&&typeof n.set=="function"){var d=n.get,h=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return d.call(this)},set:function(c){l=""+c,h.call(this,c)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return l},setValue:function(c){l=""+c},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}o(DD,"Ua");function Gg(e){e._valueTracker||(e._valueTracker=DD(e))}o(Gg,"Va");function SE(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),l="";return e&&(l=xE(e)?e.checked?"true":"false":e.value),e=l,e!==n?(t.setValue(e),!0):!1}o(SE,"Wa");function Yg(e){if(e=e||(typeof document!="undefined"?document:void 0),typeof e=="undefined")return null;try{return e.activeElement||e.body}catch(t){return e.body}}o(Yg,"Xa");function e1(e,t){var n=t.checked;return hr({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}o(e1,"Ya");function CE(e,t){var n=t.defaultValue==null?"":t.defaultValue,l=t.checked!=null?t.checked:t.defaultChecked;n=Ha(t.value!=null?t.value:n),e._wrapperState={initialChecked:l,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}o(CE,"Za");function bE(e,t){t=t.checked,t!=null&&$w(e,"checked",t,!1)}o(bE,"$a");function t1(e,t){bE(e,t);var n=Ha(t.value),l=t.type;if(n!=null)l==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?r1(e,t.type,n):t.hasOwnProperty("defaultValue")&&r1(e,t.type,Ha(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}o(t1,"ab");function EE(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var l=t.type;if(!(l!=="submit"&&l!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}o(EE,"cb");function r1(e,t,n){(t!=="number"||Yg(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}o(r1,"bb");function RD(e){var t="";return $g.Children.forEach(e,function(n){n!=null&&(t+=n)}),t}o(RD,"db");function n1(e,t){return e=hr({children:void 0},t),(t=RD(t.children))&&(e.children=t),e}o(n1,"eb");function Jc(e,t,n,l){if(e=e.options,t){t={};for(var d=0;d=n.length))throw Error(we(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Ha(n)}}o(_E,"hb");function TE(e,t){var n=Ha(t.value),l=Ha(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),l!=null&&(e.defaultValue=""+l)}o(TE,"ib");function kE(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}o(kE,"jb");var o1={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};function NE(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}o(NE,"lb");function s1(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?NE(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}o(s1,"mb");var Xg,LE=function(e){return typeof MSApp!="undefined"&&MSApp.execUnsafeLocalFunction?function(t,n,l,d){MSApp.execUnsafeLocalFunction(function(){return e(t,n,l,d)})}:e}(function(e,t){if(e.namespaceURI!==o1.svg||"innerHTML"in e)e.innerHTML=t;else{for(Xg=Xg||document.createElement("div"),Xg.innerHTML=""+t.valueOf().toString()+"",t=Xg.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function sh(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}o(sh,"pb");var lh={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ID=["Webkit","ms","Moz","O"];Object.keys(lh).forEach(function(e){ID.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),lh[t]=lh[e]})});function PE(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||lh.hasOwnProperty(e)&&lh[e]?(""+t).trim():t+"px"}o(PE,"sb");function OE(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var l=n.indexOf("--")===0,d=PE(n,t[n],l);n==="float"&&(n="cssFloat"),l?e.setProperty(n,d):e[n]=d}}o(OE,"tb");var FD=hr({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function l1(e,t){if(t){if(FD[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(we(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(we(60));if(!(typeof t.dangerouslySetInnerHTML=="object"&&"__html"in t.dangerouslySetInnerHTML))throw Error(we(61))}if(t.style!=null&&typeof t.style!="object")throw Error(we(62))}}o(l1,"vb");function a1(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}o(a1,"wb");function u1(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}o(u1,"xb");var f1=null,ep=null,tp=null;function ME(e){if(e=_h(e)){if(typeof f1!="function")throw Error(we(280));var t=e.stateNode;t&&(t=vv(t),f1(e.stateNode,e.type,t))}}o(ME,"Bb");function AE(e){ep?tp?tp.push(e):tp=[e]:ep=e}o(AE,"Eb");function DE(){if(ep){var e=ep,t=tp;if(tp=ep=null,ME(e),t)for(e=0;el?0:1<n;n++)t.push(e);return t}o(b1,"Zc");function nv(e,t,n){e.pendingLanes|=t;var l=t-1;e.suspendedLanes&=l,e.pingedLanes&=l,e=e.eventTimes,t=31-$a(t),e[t]=n}o(nv,"$c");var $a=Math.clz32?Math.clz32:JD,QD=Math.log,ZD=Math.LN2;function JD(e){return e===0?32:31-(QD(e)/ZD|0)|0}o(JD,"ad");var eR=Tn.unstable_UserBlockingPriority,tR=Tn.unstable_runWithPriority,iv=!0;function rR(e,t,n,l){vf||p1();var d=E1,h=vf;vf=!0;try{RE(d,e,t,n,l)}finally{(vf=h)||h1()}}o(rR,"gd");function nR(e,t,n,l){tR(eR,E1.bind(null,e,t,n,l))}o(nR,"id");function E1(e,t,n,l){if(iv){var d;if((d=(t&4)==0)&&0=yh),l_=String.fromCharCode(32),a_=!1;function u_(e,t){switch(e){case"keyup":return TR.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}o(u_,"ge");function f_(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}o(f_,"he");var lp=!1;function NR(e,t){switch(e){case"compositionend":return f_(t);case"keypress":return t.which!==32?null:(a_=!0,l_);case"textInput":return e=t.data,e===l_&&a_?null:e;default:return null}}o(NR,"je");function LR(e,t){if(lp)return e==="compositionend"||!M1&&u_(e,t)?(e=t_(),ov=T1=ja=null,lp=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=l}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=g_(n)}}o(v_,"Le");function y_(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?y_(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}o(y_,"Me");function w_(){for(var e=window,t=Yg();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch(l){n=!1}if(n)e=t.contentWindow;else break;t=Yg(e.document)}return t}o(w_,"Ne");function D1(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}o(D1,"Oe");var HR=Ll&&"documentMode"in document&&11>=document.documentMode,ap=null,R1=null,Ch=null,I1=!1;function x_(e,t,n){var l=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;I1||ap==null||ap!==Yg(l)||(l=ap,"selectionStart"in l&&D1(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Ch&&Sh(Ch,l)||(Ch=l,l=dv(R1,"onSelect"),0dp||(e.current=$1[dp],$1[dp]=null,dp--)}o(fr,"H");function _r(e,t){dp++,$1[dp]=e.current,e.current=t}o(_r,"I");var Ka={},Xn=Va(Ka),Ri=Va(!1),xf=Ka;function hp(e,t){var n=e.type.contextTypes;if(!n)return Ka;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===t)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in n)d[h]=t[h];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=d),d}o(hp,"Ef");function Ii(e){return e=e.childContextTypes,e!=null}o(Ii,"Ff");function yv(){fr(Ri),fr(Xn)}o(yv,"Gf");function R_(e,t,n){if(Xn.current!==Ka)throw Error(we(168));_r(Xn,t),_r(Ri,n)}o(R_,"Hf");function I_(e,t,n){var l=e.stateNode;if(e=t.childContextTypes,typeof l.getChildContext!="function")return n;l=l.getChildContext();for(var d in l)if(!(d in e))throw Error(we(108,Zc(t)||"Unknown",d));return hr({},n,l)}o(I_,"If");function wv(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ka,xf=Xn.current,_r(Xn,e),_r(Ri,Ri.current),!0}o(wv,"Jf");function F_(e,t,n){var l=e.stateNode;if(!l)throw Error(we(169));n?(e=I_(e,t,xf),l.__reactInternalMemoizedMergedChildContext=e,fr(Ri),fr(Xn),_r(Xn,e)):fr(Ri),_r(Ri,n)}o(F_,"Kf");var j1=null,Sf=null,zR=Tn.unstable_runWithPriority,q1=Tn.unstable_scheduleCallback,V1=Tn.unstable_cancelCallback,$R=Tn.unstable_shouldYield,B_=Tn.unstable_requestPaint,K1=Tn.unstable_now,jR=Tn.unstable_getCurrentPriorityLevel,xv=Tn.unstable_ImmediatePriority,H_=Tn.unstable_UserBlockingPriority,W_=Tn.unstable_NormalPriority,U_=Tn.unstable_LowPriority,z_=Tn.unstable_IdlePriority,G1={},qR=B_!==void 0?B_:function(){},Pl=null,Sv=null,Y1=!1,$_=K1(),Qn=1e4>$_?K1:function(){return K1()-$_};function mp(){switch(jR()){case xv:return 99;case H_:return 98;case W_:return 97;case U_:return 96;case z_:return 95;default:throw Error(we(332))}}o(mp,"eg");function j_(e){switch(e){case 99:return xv;case 98:return H_;case 97:return W_;case 96:return U_;case 95:return z_;default:throw Error(we(332))}}o(j_,"fg");function Cf(e,t){return e=j_(e),zR(e,t)}o(Cf,"gg");function Th(e,t,n){return e=j_(e),q1(e,t,n)}o(Th,"hg");function $s(){if(Sv!==null){var e=Sv;Sv=null,V1(e)}q_()}o($s,"ig");function q_(){if(!Y1&&Pl!==null){Y1=!0;var e=0;try{var t=Pl;Cf(99,function(){for(;epe?(me=ne,ne=null):me=ne.sibling;var xe=B(R,ne,I[pe],G);if(xe===null){ne===null&&(ne=me);break}e&&ne&&xe.alternate===null&&t(R,ne),A=h(xe,A,pe),se===null?K=xe:se.sibling=xe,se=xe,ne=me}if(pe===I.length)return n(R,ne),K;if(ne===null){for(;pepe?(me=ne,ne=null):me=ne.sibling;var Ve=B(R,ne,xe.value,G);if(Ve===null){ne===null&&(ne=me);break}e&&ne&&Ve.alternate===null&&t(R,ne),A=h(Ve,A,pe),se===null?K=Ve:se.sibling=Ve,se=Ve,ne=me}if(xe.done)return n(R,ne),K;if(ne===null){for(;!xe.done;pe++,xe=I.next())xe=j(R,xe.value,G),xe!==null&&(A=h(xe,A,pe),se===null?K=xe:se.sibling=xe,se=xe);return K}for(ne=l(R,ne);!xe.done;pe++,xe=I.next())xe=X(ne,R,pe,xe.value,G),xe!==null&&(e&&xe.alternate!==null&&ne.delete(xe.key===null?pe:xe.key),A=h(xe,A,pe),se===null?K=xe:se.sibling=xe,se=xe);return e&&ne.forEach(function(tt){return t(R,tt)}),K}return o(Z,"w"),function(R,A,I,G){var K=typeof I=="object"&&I!==null&&I.type===Ba&&I.key===null;K&&(I=I.props.children);var se=typeof I=="object"&&I!==null;if(se)switch(I.$$typeof){case th:e:{for(se=I.key,K=A;K!==null;){if(K.key===se){switch(K.tag){case 7:if(I.type===Ba){n(R,K.sibling),A=d(K,I.props.children),A.return=R,R=A;break e}break;default:if(K.elementType===I.type){n(R,K.sibling),A=d(K,I.props),A.ref=Nh(R,K,I),A.return=R,R=A;break e}}n(R,K);break}else t(R,K);K=K.sibling}I.type===Ba?(A=_p(I.props.children,R.mode,G,I.key),A.return=R,R=A):(G=Vv(I.type,I.key,I.props,null,R.mode,G),G.ref=Nh(R,A,I),G.return=R,R=G)}return c(R);case gf:e:{for(K=I.key;A!==null;){if(A.key===K)if(A.tag===4&&A.stateNode.containerInfo===I.containerInfo&&A.stateNode.implementation===I.implementation){n(R,A.sibling),A=d(A,I.children||[]),A.return=R,R=A;break e}else{n(R,A);break}else t(R,A);A=A.sibling}A=Ix(I,R.mode,G),A.return=R,R=A}return c(R)}if(typeof I=="string"||typeof I=="number")return I=""+I,A!==null&&A.tag===6?(n(R,A.sibling),A=d(A,I),A.return=R,R=A):(n(R,A),A=Rx(I,R.mode,G),A.return=R,R=A),c(R);if(kv(I))return J(R,A,I,G);if(ih(I))return Z(R,A,I,G);if(se&&Nv(R,I),typeof I=="undefined"&&!K)switch(R.tag){case 1:case 22:case 0:case 11:case 15:throw Error(we(152,Zc(R.type)||"Component"))}return n(R,A)}}o(eT,"Sg");var Lv=eT(!0),tT=eT(!1),Lh={},js=Va(Lh),Ph=Va(Lh),Oh=Va(Lh);function bf(e){if(e===Lh)throw Error(we(174));return e}o(bf,"dh");function ex(e,t){switch(_r(Oh,t),_r(Ph,e),_r(js,Lh),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:s1(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=s1(t,e)}fr(js),_r(js,t)}o(ex,"eh");function yp(){fr(js),fr(Ph),fr(Oh)}o(yp,"fh");function rT(e){bf(Oh.current);var t=bf(js.current),n=s1(t,e.type);t!==n&&(_r(Ph,e),_r(js,n))}o(rT,"gh");function tx(e){Ph.current===e&&(fr(js),fr(Ph))}o(tx,"hh");var Tr=Va(0);function Pv(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if((t.flags&64)!=0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}o(Pv,"ih");var Ol=null,Qa=null,qs=!1;function nT(e,t){var n=No(5,null,null,0);n.elementType="DELETED",n.type="DELETED",n.stateNode=t,n.return=e,n.flags=8,e.lastEffect!==null?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}o(nT,"mh");function iT(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,!0):!1;case 13:return!1;default:return!1}}o(iT,"oh");function rx(e){if(qs){var t=Qa;if(t){var n=t;if(!iT(e,t)){if(t=fp(n.nextSibling),!t||!iT(e,t)){e.flags=e.flags&-1025|2,qs=!1,Ol=e;return}nT(Ol,n)}Ol=e,Qa=fp(t.firstChild)}else e.flags=e.flags&-1025|2,qs=!1,Ol=e}}o(rx,"ph");function oT(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Ol=e}o(oT,"qh");function Ov(e){if(e!==Ol)return!1;if(!qs)return oT(e),qs=!0,!1;var t=e.type;if(e.tag!==5||t!=="head"&&t!=="body"&&!W1(t,e.memoizedProps))for(t=Qa;t;)nT(e,t),t=fp(t.nextSibling);if(oT(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(we(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Qa=fp(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Qa=null}}else Qa=Ol?fp(e.stateNode.nextSibling):null;return!0}o(Ov,"rh");function nx(){Qa=Ol=null,qs=!1}o(nx,"sh");var wp=[];function ix(){for(var e=0;eh))throw Error(we(301));h+=1,In=Zn=null,t.updateQueue=null,Mh.current=XR,e=n(l,d)}while(Dh)}if(Mh.current=Iv,t=Zn!==null&&Zn.next!==null,Ah=0,In=Zn=Fr=null,Mv=!1,t)throw Error(we(300));return e}o(sx,"Ch");function Ef(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return In===null?Fr.memoizedState=In=e:In=In.next=e,In}o(Ef,"Hh");function _f(){if(Zn===null){var e=Fr.alternate;e=e!==null?e.memoizedState:null}else e=Zn.next;var t=In===null?Fr.memoizedState:In.next;if(t!==null)In=t,Zn=e;else{if(e===null)throw Error(we(310));Zn=e,e={memoizedState:Zn.memoizedState,baseState:Zn.baseState,baseQueue:Zn.baseQueue,queue:Zn.queue,next:null},In===null?Fr.memoizedState=In=e:In=In.next=e}return In}o(_f,"Ih");function Vs(e,t){return typeof t=="function"?t(e):t}o(Vs,"Jh");function Rh(e){var t=_f(),n=t.queue;if(n===null)throw Error(we(311));n.lastRenderedReducer=e;var l=Zn,d=l.baseQueue,h=n.pending;if(h!==null){if(d!==null){var c=d.next;d.next=h.next,h.next=c}l.baseQueue=d=h,n.pending=null}if(d!==null){d=d.next,l=l.baseState;var v=c=h=null,C=d;do{var k=C.lane;if((Ah&k)===k)v!==null&&(v=v.next={lane:0,action:C.action,eagerReducer:C.eagerReducer,eagerState:C.eagerState,next:null}),l=C.eagerReducer===e?C.eagerState:e(l,C.action);else{var O={lane:k,action:C.action,eagerReducer:C.eagerReducer,eagerState:C.eagerState,next:null};v===null?(c=v=O,h=l):v=v.next=O,Fr.lanes|=k,Hh|=k}C=C.next}while(C!==null&&C!==d);v===null?h=l:v.next=c,Eo(l,t.memoizedState)||(ls=!0),t.memoizedState=l,t.baseState=h,t.baseQueue=v,n.lastRenderedState=l}return[t.memoizedState,n.dispatch]}o(Rh,"Kh");function Ih(e){var t=_f(),n=t.queue;if(n===null)throw Error(we(311));n.lastRenderedReducer=e;var l=n.dispatch,d=n.pending,h=t.memoizedState;if(d!==null){n.pending=null;var c=d=d.next;do h=e(h,c.action),c=c.next;while(c!==d);Eo(h,t.memoizedState)||(ls=!0),t.memoizedState=h,t.baseQueue===null&&(t.baseState=h),n.lastRenderedState=h}return[h,l]}o(Ih,"Lh");function sT(e,t,n){var l=t._getVersion;l=l(t._source);var d=t._workInProgressVersionPrimary;if(d!==null?e=d===l:(e=e.mutableReadLanes,(e=(Ah&e)===e)&&(t._workInProgressVersionPrimary=l,wp.push(t))),e)return n(t._source);throw wp.push(t),Error(we(350))}o(sT,"Mh");function lT(e,t,n,l){var d=yi;if(d===null)throw Error(we(349));var h=t._getVersion,c=h(t._source),v=Mh.current,C=v.useState(function(){return sT(d,t,n)}),k=C[1],O=C[0];C=In;var j=e.memoizedState,B=j.refs,X=B.getSnapshot,J=j.source;j=j.subscribe;var Z=Fr;return e.memoizedState={refs:B,source:t,subscribe:l},v.useEffect(function(){B.getSnapshot=n,B.setSnapshot=k;var R=h(t._source);if(!Eo(c,R)){R=n(t._source),Eo(O,R)||(k(R),R=Ja(Z),d.mutableReadLanes|=R&d.pendingLanes),R=d.mutableReadLanes,d.entangledLanes|=R;for(var A=d.entanglements,I=R;0n?98:n,function(){e(!0)}),Cf(97<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=c.createElement(n,{is:l.is}):(e=c.createElement(n),n==="select"&&(c=e,l.multiple?c.multiple=!0:l.size&&(c.size=l.size))):e=c.createElementNS(e,n),e[qa]=t,e[gv]=l,NT(e,t,!1,!1),t.stateNode=e,c=a1(n,l),n){case"dialog":ur("cancel",e),ur("close",e),d=l;break;case"iframe":case"object":case"embed":ur("load",e),d=l;break;case"video":case"audio":for(d=0;dTx&&(t.flags|=64,h=!0,Bh(l,!1),t.lanes=33554432)}else{if(!h)if(e=Pv(c),e!==null){if(t.flags|=64,h=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Bh(l,!0),l.tail===null&&l.tailMode==="hidden"&&!c.alternate&&!qs)return t=t.lastEffect=l.lastEffect,t!==null&&(t.nextEffect=null),null}else 2*Qn()-l.renderingStartTime>Tx&&n!==1073741824&&(t.flags|=64,h=!0,Bh(l,!1),t.lanes=33554432);l.isBackwards?(c.sibling=t.child,t.child=c):(n=l.last,n!==null?n.sibling=c:t.child=c,l.last=c)}return l.tail!==null?(n=l.tail,l.rendering=n,l.tail=n.sibling,l.lastEffect=t.lastEffect,l.renderingStartTime=Qn(),n.sibling=null,t=Tr.current,_r(Tr,h?t&1|2:t&1),n):null;case 23:case 24:return Mx(),e!==null&&e.memoizedState!==null!=(t.memoizedState!==null)&&l.mode!=="unstable-defer-without-hiding"&&(t.flags|=4),null}throw Error(we(156,t.tag))}o(ZR,"Gi");function JR(e){switch(e.tag){case 1:Ii(e.type)&&yv();var t=e.flags;return t&4096?(e.flags=t&-4097|64,e):null;case 3:if(yp(),fr(Ri),fr(Xn),ix(),t=e.flags,(t&64)!=0)throw Error(we(285));return e.flags=t&-4097|64,e;case 5:return tx(e),null;case 13:return fr(Tr),t=e.flags,t&4096?(e.flags=t&-4097|64,e):null;case 19:return fr(Tr),null;case 4:return yp(),null;case 10:return Q1(e),null;case 23:case 24:return Mx(),null;default:return null}}o(JR,"Li");function gx(e,t){try{var n="",l=t;do n+=AD(l),l=l.return;while(l);var d=n}catch(h){d=` +`+d[c].replace(" at new "," at ");while(1<=c&&0<=v);break}}}finally{Zw=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?oh(e):""}o(Vg,"Pa");function AD(e){switch(e.tag){case 5:return oh(e.type);case 16:return oh("Lazy");case 13:return oh("Suspense");case 19:return oh("SuspenseList");case 0:case 2:case 15:return e=Vg(e.type,!1),e;case 11:return e=Vg(e.type.render,!1),e;case 22:return e=Vg(e.type._render,!1),e;case 1:return e=Vg(e.type,!0),e;default:return""}}o(AD,"Qa");function Zc(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ba:return"Fragment";case gf:return"Portal";case rh:return"Profiler";case $w:return"StrictMode";case nh:return"Suspense";case jg:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case qw:return(e.displayName||"Context")+".Consumer";case jw:return(e._context.displayName||"Context")+".Provider";case $g:var t=e.render;return t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case qg:return Zc(e.type);case Kw:return Zc(e._render);case Vw:t=e._payload,e=e._init;try{return Zc(e(t))}catch(n){}}return null}o(Zc,"Ra");function Ha(e){switch(typeof e){case"boolean":case"number":case"object":case"string":case"undefined":return e;default:return""}}o(Ha,"Sa");function w_(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}o(w_,"Ta");function DD(e){var t=w_(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),l=""+e[t];if(!e.hasOwnProperty(t)&&typeof n!="undefined"&&typeof n.get=="function"&&typeof n.set=="function"){var d=n.get,h=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return d.call(this)},set:function(c){l=""+c,h.call(this,c)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return l},setValue:function(c){l=""+c},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}o(DD,"Ua");function Kg(e){e._valueTracker||(e._valueTracker=DD(e))}o(Kg,"Va");function x_(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),l="";return e&&(l=w_(e)?e.checked?"true":"false":e.value),e=l,e!==n?(t.setValue(e),!0):!1}o(x_,"Wa");function Gg(e){if(e=e||(typeof document!="undefined"?document:void 0),typeof e=="undefined")return null;try{return e.activeElement||e.body}catch(t){return e.body}}o(Gg,"Xa");function Jw(e,t){var n=t.checked;return hr({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}o(Jw,"Ya");function S_(e,t){var n=t.defaultValue==null?"":t.defaultValue,l=t.checked!=null?t.checked:t.defaultChecked;n=Ha(t.value!=null?t.value:n),e._wrapperState={initialChecked:l,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}o(S_,"Za");function C_(e,t){t=t.checked,t!=null&&zw(e,"checked",t,!1)}o(C_,"$a");function e1(e,t){C_(e,t);var n=Ha(t.value),l=t.type;if(n!=null)l==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?t1(e,t.type,n):t.hasOwnProperty("defaultValue")&&t1(e,t.type,Ha(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}o(e1,"ab");function b_(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var l=t.type;if(!(l!=="submit"&&l!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}o(b_,"cb");function t1(e,t,n){(t!=="number"||Gg(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}o(t1,"bb");function RD(e){var t="";return zg.Children.forEach(e,function(n){n!=null&&(t+=n)}),t}o(RD,"db");function r1(e,t){return e=hr({children:void 0},t),(t=RD(t.children))&&(e.children=t),e}o(r1,"eb");function Jc(e,t,n,l){if(e=e.options,t){t={};for(var d=0;d=n.length))throw Error(we(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Ha(n)}}o(__,"hb");function E_(e,t){var n=Ha(t.value),l=Ha(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),l!=null&&(e.defaultValue=""+l)}o(E_,"ib");function T_(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}o(T_,"jb");var i1={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};function k_(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}o(k_,"lb");function o1(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?k_(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}o(o1,"mb");var Yg,N_=function(e){return typeof MSApp!="undefined"&&MSApp.execUnsafeLocalFunction?function(t,n,l,d){MSApp.execUnsafeLocalFunction(function(){return e(t,n,l,d)})}:e}(function(e,t){if(e.namespaceURI!==i1.svg||"innerHTML"in e)e.innerHTML=t;else{for(Yg=Yg||document.createElement("div"),Yg.innerHTML=""+t.valueOf().toString()+"",t=Yg.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function sh(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}o(sh,"pb");var lh={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ID=["Webkit","ms","Moz","O"];Object.keys(lh).forEach(function(e){ID.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),lh[t]=lh[e]})});function P_(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||lh.hasOwnProperty(e)&&lh[e]?(""+t).trim():t+"px"}o(P_,"sb");function L_(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var l=n.indexOf("--")===0,d=P_(n,t[n],l);n==="float"&&(n="cssFloat"),l?e.setProperty(n,d):e[n]=d}}o(L_,"tb");var FD=hr({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function s1(e,t){if(t){if(FD[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(we(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(we(60));if(!(typeof t.dangerouslySetInnerHTML=="object"&&"__html"in t.dangerouslySetInnerHTML))throw Error(we(61))}if(t.style!=null&&typeof t.style!="object")throw Error(we(62))}}o(s1,"vb");function l1(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}o(l1,"wb");function a1(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}o(a1,"xb");var u1=null,ep=null,tp=null;function O_(e){if(e=Eh(e)){if(typeof u1!="function")throw Error(we(280));var t=e.stateNode;t&&(t=gv(t),u1(e.stateNode,e.type,t))}}o(O_,"Bb");function M_(e){ep?tp?tp.push(e):tp=[e]:ep=e}o(M_,"Eb");function A_(){if(ep){var e=ep,t=tp;if(tp=ep=null,O_(e),t)for(e=0;el?0:1<n;n++)t.push(e);return t}o(C1,"Zc");function rv(e,t,n){e.pendingLanes|=t;var l=t-1;e.suspendedLanes&=l,e.pingedLanes&=l,e=e.eventTimes,t=31-$a(t),e[t]=n}o(rv,"$c");var $a=Math.clz32?Math.clz32:JD,QD=Math.log,ZD=Math.LN2;function JD(e){return e===0?32:31-(QD(e)/ZD|0)|0}o(JD,"ad");var eR=Tn.unstable_UserBlockingPriority,tR=Tn.unstable_runWithPriority,nv=!0;function rR(e,t,n,l){vf||c1();var d=b1,h=vf;vf=!0;try{D_(d,e,t,n,l)}finally{(vf=h)||d1()}}o(rR,"gd");function nR(e,t,n,l){tR(eR,b1.bind(null,e,t,n,l))}o(nR,"id");function b1(e,t,n,l){if(nv){var d;if((d=(t&4)==0)&&0=yh),sE=String.fromCharCode(32),lE=!1;function aE(e,t){switch(e){case"keyup":return TR.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}o(aE,"ge");function uE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}o(uE,"he");var lp=!1;function NR(e,t){switch(e){case"compositionend":return uE(t);case"keypress":return t.which!==32?null:(lE=!0,sE);case"textInput":return e=t.data,e===sE&&lE?null:e;default:return null}}o(NR,"je");function PR(e,t){if(lp)return e==="compositionend"||!O1&&aE(e,t)?(e=eE(),iv=E1=ja=null,lp=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=l}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=mE(n)}}o(gE,"Le");function vE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?vE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}o(vE,"Me");function yE(){for(var e=window,t=Gg();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch(l){n=!1}if(n)e=t.contentWindow;else break;t=Gg(e.document)}return t}o(yE,"Ne");function A1(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}o(A1,"Oe");var HR=Pl&&"documentMode"in document&&11>=document.documentMode,ap=null,D1=null,Ch=null,R1=!1;function wE(e,t,n){var l=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;R1||ap==null||ap!==Gg(l)||(l=ap,"selectionStart"in l&&A1(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Ch&&Sh(Ch,l)||(Ch=l,l=pv(D1,"onSelect"),0dp||(e.current=z1[dp],z1[dp]=null,dp--)}o(fr,"H");function Er(e,t){dp++,z1[dp]=e.current,e.current=t}o(Er,"I");var Ka={},Xn=Va(Ka),Ri=Va(!1),xf=Ka;function hp(e,t){var n=e.type.contextTypes;if(!n)return Ka;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===t)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in n)d[h]=t[h];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=d),d}o(hp,"Ef");function Ii(e){return e=e.childContextTypes,e!=null}o(Ii,"Ff");function vv(){fr(Ri),fr(Xn)}o(vv,"Gf");function DE(e,t,n){if(Xn.current!==Ka)throw Error(we(168));Er(Xn,t),Er(Ri,n)}o(DE,"Hf");function RE(e,t,n){var l=e.stateNode;if(e=t.childContextTypes,typeof l.getChildContext!="function")return n;l=l.getChildContext();for(var d in l)if(!(d in e))throw Error(we(108,Zc(t)||"Unknown",d));return hr({},n,l)}o(RE,"If");function yv(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ka,xf=Xn.current,Er(Xn,e),Er(Ri,Ri.current),!0}o(yv,"Jf");function IE(e,t,n){var l=e.stateNode;if(!l)throw Error(we(169));n?(e=RE(e,t,xf),l.__reactInternalMemoizedMergedChildContext=e,fr(Ri),fr(Xn),Er(Xn,e)):fr(Ri),Er(Ri,n)}o(IE,"Kf");var $1=null,Sf=null,zR=Tn.unstable_runWithPriority,j1=Tn.unstable_scheduleCallback,q1=Tn.unstable_cancelCallback,$R=Tn.unstable_shouldYield,FE=Tn.unstable_requestPaint,V1=Tn.unstable_now,jR=Tn.unstable_getCurrentPriorityLevel,wv=Tn.unstable_ImmediatePriority,BE=Tn.unstable_UserBlockingPriority,HE=Tn.unstable_NormalPriority,WE=Tn.unstable_LowPriority,UE=Tn.unstable_IdlePriority,K1={},qR=FE!==void 0?FE:function(){},Ll=null,xv=null,G1=!1,zE=V1(),Qn=1e4>zE?V1:function(){return V1()-zE};function mp(){switch(jR()){case wv:return 99;case BE:return 98;case HE:return 97;case WE:return 96;case UE:return 95;default:throw Error(we(332))}}o(mp,"eg");function $E(e){switch(e){case 99:return wv;case 98:return BE;case 97:return HE;case 96:return WE;case 95:return UE;default:throw Error(we(332))}}o($E,"fg");function Cf(e,t){return e=$E(e),zR(e,t)}o(Cf,"gg");function Th(e,t,n){return e=$E(e),j1(e,t,n)}o(Th,"hg");function $s(){if(xv!==null){var e=xv;xv=null,q1(e)}jE()}o($s,"ig");function jE(){if(!G1&&Ll!==null){G1=!0;var e=0;try{var t=Ll;Cf(99,function(){for(;epe?(me=ne,ne=null):me=ne.sibling;var xe=B(R,ne,I[pe],G);if(xe===null){ne===null&&(ne=me);break}e&&ne&&xe.alternate===null&&t(R,ne),A=h(xe,A,pe),se===null?K=xe:se.sibling=xe,se=xe,ne=me}if(pe===I.length)return n(R,ne),K;if(ne===null){for(;pepe?(me=ne,ne=null):me=ne.sibling;var Ve=B(R,ne,xe.value,G);if(Ve===null){ne===null&&(ne=me);break}e&&ne&&Ve.alternate===null&&t(R,ne),A=h(Ve,A,pe),se===null?K=Ve:se.sibling=Ve,se=Ve,ne=me}if(xe.done)return n(R,ne),K;if(ne===null){for(;!xe.done;pe++,xe=I.next())xe=j(R,xe.value,G),xe!==null&&(A=h(xe,A,pe),se===null?K=xe:se.sibling=xe,se=xe);return K}for(ne=l(R,ne);!xe.done;pe++,xe=I.next())xe=X(ne,R,pe,xe.value,G),xe!==null&&(e&&xe.alternate!==null&&ne.delete(xe.key===null?pe:xe.key),A=h(xe,A,pe),se===null?K=xe:se.sibling=xe,se=xe);return e&&ne.forEach(function(tt){return t(R,tt)}),K}return o(Z,"w"),function(R,A,I,G){var K=typeof I=="object"&&I!==null&&I.type===Ba&&I.key===null;K&&(I=I.props.children);var se=typeof I=="object"&&I!==null;if(se)switch(I.$$typeof){case th:e:{for(se=I.key,K=A;K!==null;){if(K.key===se){switch(K.tag){case 7:if(I.type===Ba){n(R,K.sibling),A=d(K,I.props.children),A.return=R,R=A;break e}break;default:if(K.elementType===I.type){n(R,K.sibling),A=d(K,I.props),A.ref=Nh(R,K,I),A.return=R,R=A;break e}}n(R,K);break}else t(R,K);K=K.sibling}I.type===Ba?(A=Ep(I.props.children,R.mode,G,I.key),A.return=R,R=A):(G=qv(I.type,I.key,I.props,null,R.mode,G),G.ref=Nh(R,A,I),G.return=R,R=G)}return c(R);case gf:e:{for(K=I.key;A!==null;){if(A.key===K)if(A.tag===4&&A.stateNode.containerInfo===I.containerInfo&&A.stateNode.implementation===I.implementation){n(R,A.sibling),A=d(A,I.children||[]),A.return=R,R=A;break e}else{n(R,A);break}else t(R,A);A=A.sibling}A=Rx(I,R.mode,G),A.return=R,R=A}return c(R)}if(typeof I=="string"||typeof I=="number")return I=""+I,A!==null&&A.tag===6?(n(R,A.sibling),A=d(A,I),A.return=R,R=A):(n(R,A),A=Dx(I,R.mode,G),A.return=R,R=A),c(R);if(Tv(I))return J(R,A,I,G);if(ih(I))return Z(R,A,I,G);if(se&&kv(R,I),typeof I=="undefined"&&!K)switch(R.tag){case 1:case 22:case 0:case 11:case 15:throw Error(we(152,Zc(R.type)||"Component"))}return n(R,A)}}o(JE,"Sg");var Nv=JE(!0),eT=JE(!1),Ph={},js=Va(Ph),Lh=Va(Ph),Oh=Va(Ph);function bf(e){if(e===Ph)throw Error(we(174));return e}o(bf,"dh");function J1(e,t){switch(Er(Oh,t),Er(Lh,e),Er(js,Ph),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:o1(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=o1(t,e)}fr(js),Er(js,t)}o(J1,"eh");function yp(){fr(js),fr(Lh),fr(Oh)}o(yp,"fh");function tT(e){bf(Oh.current);var t=bf(js.current),n=o1(t,e.type);t!==n&&(Er(Lh,e),Er(js,n))}o(tT,"gh");function ex(e){Lh.current===e&&(fr(js),fr(Lh))}o(ex,"hh");var Tr=Va(0);function Pv(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if((t.flags&64)!=0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}o(Pv,"ih");var Ol=null,Qa=null,qs=!1;function rT(e,t){var n=No(5,null,null,0);n.elementType="DELETED",n.type="DELETED",n.stateNode=t,n.return=e,n.flags=8,e.lastEffect!==null?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}o(rT,"mh");function nT(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,!0):!1;case 13:return!1;default:return!1}}o(nT,"oh");function tx(e){if(qs){var t=Qa;if(t){var n=t;if(!nT(e,t)){if(t=fp(n.nextSibling),!t||!nT(e,t)){e.flags=e.flags&-1025|2,qs=!1,Ol=e;return}rT(Ol,n)}Ol=e,Qa=fp(t.firstChild)}else e.flags=e.flags&-1025|2,qs=!1,Ol=e}}o(tx,"ph");function iT(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Ol=e}o(iT,"qh");function Lv(e){if(e!==Ol)return!1;if(!qs)return iT(e),qs=!0,!1;var t=e.type;if(e.tag!==5||t!=="head"&&t!=="body"&&!H1(t,e.memoizedProps))for(t=Qa;t;)rT(e,t),t=fp(t.nextSibling);if(iT(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(we(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Qa=fp(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Qa=null}}else Qa=Ol?fp(e.stateNode.nextSibling):null;return!0}o(Lv,"rh");function rx(){Qa=Ol=null,qs=!1}o(rx,"sh");var wp=[];function nx(){for(var e=0;eh))throw Error(we(301));h+=1,In=Zn=null,t.updateQueue=null,Mh.current=XR,e=n(l,d)}while(Dh)}if(Mh.current=Rv,t=Zn!==null&&Zn.next!==null,Ah=0,In=Zn=Fr=null,Ov=!1,t)throw Error(we(300));return e}o(ox,"Ch");function _f(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return In===null?Fr.memoizedState=In=e:In=In.next=e,In}o(_f,"Hh");function Ef(){if(Zn===null){var e=Fr.alternate;e=e!==null?e.memoizedState:null}else e=Zn.next;var t=In===null?Fr.memoizedState:In.next;if(t!==null)In=t,Zn=e;else{if(e===null)throw Error(we(310));Zn=e,e={memoizedState:Zn.memoizedState,baseState:Zn.baseState,baseQueue:Zn.baseQueue,queue:Zn.queue,next:null},In===null?Fr.memoizedState=In=e:In=In.next=e}return In}o(Ef,"Ih");function Vs(e,t){return typeof t=="function"?t(e):t}o(Vs,"Jh");function Rh(e){var t=Ef(),n=t.queue;if(n===null)throw Error(we(311));n.lastRenderedReducer=e;var l=Zn,d=l.baseQueue,h=n.pending;if(h!==null){if(d!==null){var c=d.next;d.next=h.next,h.next=c}l.baseQueue=d=h,n.pending=null}if(d!==null){d=d.next,l=l.baseState;var v=c=h=null,C=d;do{var k=C.lane;if((Ah&k)===k)v!==null&&(v=v.next={lane:0,action:C.action,eagerReducer:C.eagerReducer,eagerState:C.eagerState,next:null}),l=C.eagerReducer===e?C.eagerState:e(l,C.action);else{var O={lane:k,action:C.action,eagerReducer:C.eagerReducer,eagerState:C.eagerState,next:null};v===null?(c=v=O,h=l):v=v.next=O,Fr.lanes|=k,Hh|=k}C=C.next}while(C!==null&&C!==d);v===null?h=l:v.next=c,_o(l,t.memoizedState)||(ls=!0),t.memoizedState=l,t.baseState=h,t.baseQueue=v,n.lastRenderedState=l}return[t.memoizedState,n.dispatch]}o(Rh,"Kh");function Ih(e){var t=Ef(),n=t.queue;if(n===null)throw Error(we(311));n.lastRenderedReducer=e;var l=n.dispatch,d=n.pending,h=t.memoizedState;if(d!==null){n.pending=null;var c=d=d.next;do h=e(h,c.action),c=c.next;while(c!==d);_o(h,t.memoizedState)||(ls=!0),t.memoizedState=h,t.baseQueue===null&&(t.baseState=h),n.lastRenderedState=h}return[h,l]}o(Ih,"Lh");function oT(e,t,n){var l=t._getVersion;l=l(t._source);var d=t._workInProgressVersionPrimary;if(d!==null?e=d===l:(e=e.mutableReadLanes,(e=(Ah&e)===e)&&(t._workInProgressVersionPrimary=l,wp.push(t))),e)return n(t._source);throw wp.push(t),Error(we(350))}o(oT,"Mh");function sT(e,t,n,l){var d=yi;if(d===null)throw Error(we(349));var h=t._getVersion,c=h(t._source),v=Mh.current,C=v.useState(function(){return oT(d,t,n)}),k=C[1],O=C[0];C=In;var j=e.memoizedState,B=j.refs,X=B.getSnapshot,J=j.source;j=j.subscribe;var Z=Fr;return e.memoizedState={refs:B,source:t,subscribe:l},v.useEffect(function(){B.getSnapshot=n,B.setSnapshot=k;var R=h(t._source);if(!_o(c,R)){R=n(t._source),_o(O,R)||(k(R),R=Ja(Z),d.mutableReadLanes|=R&d.pendingLanes),R=d.mutableReadLanes,d.entangledLanes|=R;for(var A=d.entanglements,I=R;0n?98:n,function(){e(!0)}),Cf(97<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=c.createElement(n,{is:l.is}):(e=c.createElement(n),n==="select"&&(c=e,l.multiple?c.multiple=!0:l.size&&(c.size=l.size))):e=c.createElementNS(e,n),e[qa]=t,e[mv]=l,kT(e,t,!1,!1),t.stateNode=e,c=l1(n,l),n){case"dialog":ur("cancel",e),ur("close",e),d=l;break;case"iframe":case"object":case"embed":ur("load",e),d=l;break;case"video":case"audio":for(d=0;dEx&&(t.flags|=64,h=!0,Bh(l,!1),t.lanes=33554432)}else{if(!h)if(e=Pv(c),e!==null){if(t.flags|=64,h=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Bh(l,!0),l.tail===null&&l.tailMode==="hidden"&&!c.alternate&&!qs)return t=t.lastEffect=l.lastEffect,t!==null&&(t.nextEffect=null),null}else 2*Qn()-l.renderingStartTime>Ex&&n!==1073741824&&(t.flags|=64,h=!0,Bh(l,!1),t.lanes=33554432);l.isBackwards?(c.sibling=t.child,t.child=c):(n=l.last,n!==null?n.sibling=c:t.child=c,l.last=c)}return l.tail!==null?(n=l.tail,l.rendering=n,l.tail=n.sibling,l.lastEffect=t.lastEffect,l.renderingStartTime=Qn(),n.sibling=null,t=Tr.current,Er(Tr,h?t&1|2:t&1),n):null;case 23:case 24:return Ox(),e!==null&&e.memoizedState!==null!=(t.memoizedState!==null)&&l.mode!=="unstable-defer-without-hiding"&&(t.flags|=4),null}throw Error(we(156,t.tag))}o(ZR,"Gi");function JR(e){switch(e.tag){case 1:Ii(e.type)&&vv();var t=e.flags;return t&4096?(e.flags=t&-4097|64,e):null;case 3:if(yp(),fr(Ri),fr(Xn),nx(),t=e.flags,(t&64)!=0)throw Error(we(285));return e.flags=t&-4097|64,e;case 5:return ex(e),null;case 13:return fr(Tr),t=e.flags,t&4096?(e.flags=t&-4097|64,e):null;case 19:return fr(Tr),null;case 4:return yp(),null;case 10:return X1(e),null;case 23:case 24:return Ox(),null;default:return null}}o(JR,"Li");function mx(e,t){try{var n="",l=t;do n+=AD(l),l=l.return;while(l);var d=n}catch(h){d=` Error generating stack: `+h.message+` -`+h.stack}return{value:e,source:t,stack:d}}o(gx,"Mi");function vx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}o(vx,"Ni");var eI=typeof WeakMap=="function"?WeakMap:Map;function OT(e,t,n){n=Ya(-1,n),n.tag=3,n.payload={element:null};var l=t.value;return n.callback=function(){Wv||(Wv=!0,kx=l),vx(e,t)},n}o(OT,"Pi");function MT(e,t,n){n=Ya(-1,n),n.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var d=t.value;n.payload=function(){return vx(e,t),l(d)}}var h=e.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(n.callback=function(){typeof l!="function"&&(Ks===null?Ks=new Set([this]):Ks.add(this),vx(e,t));var c=t.stack;this.componentDidCatch(t.value,{componentStack:c!==null?c:""})}),n}o(MT,"Si");var tI=typeof WeakSet=="function"?WeakSet:Set;function AT(e){var t=e.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(n){ru(e,n)}else t.current=null}o(AT,"Vi");function rI(e,t){switch(t.tag){case 0:case 11:case 15:case 22:return;case 1:if(t.flags&256&&e!==null){var n=e.memoizedProps,l=e.memoizedState;e=t.stateNode,t=e.getSnapshotBeforeUpdate(t.elementType===t.type?n:ss(t.type,n),l),e.__reactInternalSnapshotBeforeUpdate=t}return;case 3:t.flags&256&&U1(t.stateNode.containerInfo);return;case 5:case 6:case 4:case 17:return}throw Error(we(163))}o(rI,"Xi");function nI(e,t,n){switch(n.tag){case 0:case 11:case 15:case 22:if(t=n.updateQueue,t=t!==null?t.lastEffect:null,t!==null){e=t=t.next;do{if((e.tag&3)==3){var l=e.create;e.destroy=l()}e=e.next}while(e!==t)}if(t=n.updateQueue,t=t!==null?t.lastEffect:null,t!==null){e=t=t.next;do{var d=e;l=d.next,d=d.tag,(d&4)!=0&&(d&1)!=0&&(GT(n,e),cI(n,e)),e=l}while(e!==t)}return;case 1:e=n.stateNode,n.flags&4&&(t===null?e.componentDidMount():(l=n.elementType===n.type?t.memoizedProps:ss(n.type,t.memoizedProps),e.componentDidUpdate(l,t.memoizedState,e.__reactInternalSnapshotBeforeUpdate))),t=n.updateQueue,t!==null&&Y_(n,t,e);return;case 3:if(t=n.updateQueue,t!==null){if(e=null,n.child!==null)switch(n.child.tag){case 5:e=n.child.stateNode;break;case 1:e=n.child.stateNode}Y_(n,t,e)}return;case 5:e=n.stateNode,t===null&&n.flags&4&&P_(n.type,n.memoizedProps)&&e.focus();return;case 6:return;case 4:return;case 12:return;case 13:n.memoizedState===null&&(n=n.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&KE(n))));return;case 19:case 17:case 20:case 21:case 23:case 24:return}throw Error(we(163))}o(nI,"Yi");function DT(e,t){for(var n=e;;){if(n.tag===5){var l=n.stateNode;if(t)l=l.style,typeof l.setProperty=="function"?l.setProperty("display","none","important"):l.display="none";else{l=n.stateNode;var d=n.memoizedProps.style;d=d!=null&&d.hasOwnProperty("display")?d.display:null,l.style.display=PE("display",d)}}else if(n.tag===6)n.stateNode.nodeValue=t?"":n.memoizedProps;else if((n.tag!==23&&n.tag!==24||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}}o(DT,"aj");function RT(e,t){if(Sf&&typeof Sf.onCommitFiberUnmount=="function")try{Sf.onCommitFiberUnmount(j1,t)}catch(h){}switch(t.tag){case 0:case 11:case 14:case 15:case 22:if(e=t.updateQueue,e!==null&&(e=e.lastEffect,e!==null)){var n=e=e.next;do{var l=n,d=l.destroy;if(l=l.tag,d!==void 0)if((l&4)!=0)GT(t,n);else{l=t;try{d()}catch(h){ru(l,h)}}n=n.next}while(n!==e)}break;case 1:if(AT(t),e=t.stateNode,typeof e.componentWillUnmount=="function")try{e.props=t.memoizedProps,e.state=t.memoizedState,e.componentWillUnmount()}catch(h){ru(t,h)}break;case 5:AT(t);break;case 4:HT(e,t)}}o(RT,"bj");function IT(e){e.alternate=null,e.child=null,e.dependencies=null,e.firstEffect=null,e.lastEffect=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.return=null,e.updateQueue=null}o(IT,"dj");function FT(e){return e.tag===5||e.tag===3||e.tag===4}o(FT,"ej");function BT(e){e:{for(var t=e.return;t!==null;){if(FT(t))break e;t=t.return}throw Error(we(160))}var n=t;switch(t=n.stateNode,n.tag){case 5:var l=!1;break;case 3:t=t.containerInfo,l=!0;break;case 4:t=t.containerInfo,l=!0;break;default:throw Error(we(161))}n.flags&16&&(sh(t,""),n.flags&=-17);e:t:for(n=e;;){for(;n.sibling===null;){if(n.return===null||FT(n.return)){n=null;break e}n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue t;n.child.return=n,n=n.child}if(!(n.flags&2)){n=n.stateNode;break e}}l?yx(e,n,t):wx(e,n,t)}o(BT,"fj");function yx(e,t,n){var l=e.tag,d=l===5||l===6;if(d)e=d?e.stateNode:e.stateNode.instance,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=hv));else if(l!==4&&(e=e.child,e!==null))for(yx(e,t,n),e=e.sibling;e!==null;)yx(e,t,n),e=e.sibling}o(yx,"gj");function wx(e,t,n){var l=e.tag,d=l===5||l===6;if(d)e=d?e.stateNode:e.stateNode.instance,t?n.insertBefore(e,t):n.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(wx(e,t,n),e=e.sibling;e!==null;)wx(e,t,n),e=e.sibling}o(wx,"hj");function HT(e,t){for(var n=t,l=!1,d,h;;){if(!l){l=n.return;e:for(;;){if(l===null)throw Error(we(160));switch(d=l.stateNode,l.tag){case 5:h=!1;break e;case 3:d=d.containerInfo,h=!0;break e;case 4:d=d.containerInfo,h=!0;break e}l=l.return}l=!0}if(n.tag===5||n.tag===6){e:for(var c=e,v=n,C=v;;)if(RT(c,C),C.child!==null&&C.tag!==4)C.child.return=C,C=C.child;else{if(C===v)break e;for(;C.sibling===null;){if(C.return===null||C.return===v)break e;C=C.return}C.sibling.return=C.return,C=C.sibling}h?(c=d,v=n.stateNode,c.nodeType===8?c.parentNode.removeChild(v):c.removeChild(v)):d.removeChild(n.stateNode)}else if(n.tag===4){if(n.child!==null){d=n.stateNode.containerInfo,h=!0,n.child.return=n,n=n.child;continue}}else if(RT(e,n),n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return,n.tag===4&&(l=!1)}n.sibling.return=n.return,n=n.sibling}}o(HT,"cj");function xx(e,t){switch(t.tag){case 0:case 11:case 14:case 15:case 22:var n=t.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var l=n=n.next;do(l.tag&3)==3&&(e=l.destroy,l.destroy=void 0,e!==void 0&&e()),l=l.next;while(l!==n)}return;case 1:return;case 5:if(n=t.stateNode,n!=null){l=t.memoizedProps;var d=e!==null?e.memoizedProps:l;e=t.type;var h=t.updateQueue;if(t.updateQueue=null,h!==null){for(n[gv]=l,e==="input"&&l.type==="radio"&&l.name!=null&&bE(n,l),a1(e,d),t=a1(e,l),d=0;dd&&(d=c),n&=~h}if(n=d,n=Qn()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*oI(n/1960))-n,10d&&(d=c),n&=~h}if(n=d,n=Qn()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*oI(n/1960))-n,10 component higher in the tree to provide a loading indicator or placeholder to display.`)}Fn!==5&&(Fn=2),C=gx(C,v),B=c;do{switch(B.tag){case 3:h=C,B.flags|=4096,t&=-t,B.lanes|=t;var se=OT(B,h,t);G_(B,se);break e;case 1:h=C;var ne=B.type,pe=B.stateNode;if((B.flags&64)==0&&(typeof ne.getDerivedStateFromError=="function"||pe!==null&&typeof pe.componentDidCatch=="function"&&(Ks===null||!Ks.has(pe)))){B.flags|=4096,t&=-t,B.lanes|=t;var me=MT(B,h,t);G_(B,me);break e}}B=B.return}while(B!==null)}KT(n)}catch(xe){t=xe,sn===n&&n!==null&&(sn=n=n.return);continue}break}while(1)}o(jT,"Sj");function qT(){var e=Bv.current;return Bv.current=Iv,e===null?Iv:e}o(qT,"Pj");function jh(e,t){var n=Ze;Ze|=16;var l=qT();yi===e&&Jn===t||Ep(e,t);do try{lI();break}catch(d){jT(e,d)}while(1);if(X1(),Ze=n,Bv.current=l,sn!==null)throw Error(we(261));return yi=null,Jn=0,Fn}o(jh,"Tj");function lI(){for(;sn!==null;)VT(sn)}o(lI,"ak");function aI(){for(;sn!==null&&!$R();)VT(sn)}o(aI,"Rj");function VT(e){var t=XT(e.alternate,e,Tf);e.memoizedProps=e.pendingProps,t===null?KT(e):sn=t,Sx.current=null}o(VT,"bk");function KT(e){var t=e;do{var n=t.alternate;if(e=t.return,(t.flags&2048)==0){if(n=ZR(n,t,Tf),n!==null){sn=n;return}if(n=t,n.tag!==24&&n.tag!==23||n.memoizedState===null||(Tf&1073741824)!=0||(n.mode&4)==0){for(var l=0,d=n.child;d!==null;)l|=d.lanes|d.childLanes,d=d.sibling;n.childLanes=l}e!==null&&(e.flags&2048)==0&&(e.firstEffect===null&&(e.firstEffect=t.firstEffect),t.lastEffect!==null&&(e.lastEffect!==null&&(e.lastEffect.nextEffect=t.firstEffect),e.lastEffect=t.lastEffect),1c&&(v=c,c=se,se=v),v=v_(I,se),h=v_(I,c),v&&h&&(K.rangeCount!==1||K.anchorNode!==v.node||K.anchorOffset!==v.offset||K.focusNode!==h.node||K.focusOffset!==h.offset)&&(G=G.createRange(),G.setStart(v.node,v.offset),K.removeAllRanges(),se>c?(K.addRange(G),K.extend(h.node,h.offset)):(G.setEnd(h.node,h.offset),K.addRange(G)))))),G=[],K=I;K=K.parentNode;)K.nodeType===1&&G.push({element:K,left:K.scrollLeft,top:K.scrollTop});for(typeof I.focus=="function"&&I.focus(),I=0;IQn()-_x?Ep(e,0):bx|=n),ko(e,t)}o(dI,"Yj");function hI(e,t){var n=e.stateNode;n!==null&&n.delete(t),t=0,t===0&&(t=e.mode,(t&2)==0?t=1:(t&4)==0?t=mp()===99?1:2:(Dl===0&&(Dl=xp),t=op(62914560&~Dl),t===0&&(t=4194304))),n=Ji(),e=jv(e,t),e!==null&&(nv(e,t,n),ko(e,n))}o(hI,"lj");var XT;XT=o(function(e,t,n){var l=t.lanes;if(e!==null)if(e.memoizedProps!==t.pendingProps||Ri.current)ls=!0;else if((n&l)!=0)ls=(e.flags&16384)!=0;else{switch(ls=!1,t.tag){case 3:ST(t),nx();break;case 5:rT(t);break;case 1:Ii(t.type)&&wv(t);break;case 4:ex(t,t.stateNode.containerInfo);break;case 10:l=t.memoizedProps.value;var d=t.type._context;_r(Cv,d._currentValue),d._currentValue=l;break;case 13:if(t.memoizedState!==null)return(n&t.child.childLanes)!=0?CT(e,t,n):(_r(Tr,Tr.current&1),t=Ml(e,t,n),t!==null?t.sibling:null);_r(Tr,Tr.current&1);break;case 19:if(l=(n&t.childLanes)!=0,(e.flags&64)!=0){if(l)return kT(e,t,n);t.flags|=64}if(d=t.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),_r(Tr,Tr.current),l)break;return null;case 23:case 24:return t.lanes=0,cx(e,t,n)}return Ml(e,t,n)}else ls=!1;switch(t.lanes=0,t.tag){case 2:if(l=t.type,e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2),e=t.pendingProps,d=hp(t,Xn.current),vp(t,n),d=sx(null,t,l,e,d,n),t.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ii(l)){var h=!0;wv(t)}else h=!1;t.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Z1(t);var c=l.getDerivedStateFromProps;typeof c=="function"&&_v(t,l,c,e),d.updater=Tv,t.stateNode=d,d._reactInternals=t,J1(t,l,e,n),t=dx(null,t,l,!0,h,n)}else t.tag=0,Bi(null,t,d,n),t=t.child;return t;case 16:d=t.elementType;e:{switch(e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2),e=t.pendingProps,h=d._init,d=h(d._payload),t.type=d,h=t.tag=gI(d),e=ss(d,e),h){case 0:t=px(null,t,d,e,n);break e;case 1:t=xT(null,t,d,e,n);break e;case 11:t=gT(null,t,d,e,n);break e;case 14:t=vT(null,t,d,ss(d.type,e),l,n);break e}throw Error(we(306,d,""))}return t;case 0:return l=t.type,d=t.pendingProps,d=t.elementType===l?d:ss(l,d),px(e,t,l,d,n);case 1:return l=t.type,d=t.pendingProps,d=t.elementType===l?d:ss(l,d),xT(e,t,l,d,n);case 3:if(ST(t),l=t.updateQueue,e===null||l===null)throw Error(we(282));if(l=t.pendingProps,d=t.memoizedState,d=d!==null?d.element:null,K_(e,t),kh(t,l,null,n),l=t.memoizedState.element,l===d)nx(),t=Ml(e,t,n);else{if(d=t.stateNode,(h=d.hydrate)&&(Qa=fp(t.stateNode.containerInfo.firstChild),Ol=t,h=qs=!0),h){if(e=d.mutableSourceEagerHydrationData,e!=null)for(d=0;d{"use strict";function ek(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(ek)}catch(e){console.error(e)}}o(ek,"checkDCE");ek(),tk.exports=JT()});var nk=Ue((yH,rk)=>{"use strict";var bI="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";rk.exports=bI});var lk=Ue((wH,sk)=>{"use strict";var EI=nk();function ik(){}o(ik,"emptyFunction");function ok(){}o(ok,"emptyFunctionWithReset");ok.resetWarningCache=ik;sk.exports=function(){function e(l,d,h,c,v,C){if(C!==EI){var k=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw k.name="Invariant Violation",k}}o(e,"shim"),e.isRequired=e;function t(){return e}o(t,"getShim");var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:ok,resetWarningCache:ik};return n.PropTypes=n,n}});var uk=Ue((CH,ak)=>{ak.exports=lk()();var xH,SH});var gk=Ue(Ht=>{"use strict";var kn=typeof Symbol=="function"&&Symbol.for,Ux=kn?Symbol.for("react.element"):60103,zx=kn?Symbol.for("react.portal"):60106,Xv=kn?Symbol.for("react.fragment"):60107,Qv=kn?Symbol.for("react.strict_mode"):60108,Zv=kn?Symbol.for("react.profiler"):60114,Jv=kn?Symbol.for("react.provider"):60109,e0=kn?Symbol.for("react.context"):60110,$x=kn?Symbol.for("react.async_mode"):60111,t0=kn?Symbol.for("react.concurrent_mode"):60111,r0=kn?Symbol.for("react.forward_ref"):60112,n0=kn?Symbol.for("react.suspense"):60113,NI=kn?Symbol.for("react.suspense_list"):60120,i0=kn?Symbol.for("react.memo"):60115,o0=kn?Symbol.for("react.lazy"):60116,LI=kn?Symbol.for("react.block"):60121,PI=kn?Symbol.for("react.fundamental"):60117,OI=kn?Symbol.for("react.responder"):60118,MI=kn?Symbol.for("react.scope"):60119;function eo(e){if(typeof e=="object"&&e!==null){var t=e.$$typeof;switch(t){case Ux:switch(e=e.type,e){case $x:case t0:case Xv:case Zv:case Qv:case n0:return e;default:switch(e=e&&e.$$typeof,e){case e0:case r0:case o0:case i0:case Jv:return e;default:return t}}case zx:return t}}}o(eo,"z");function mk(e){return eo(e)===t0}o(mk,"A");Ht.AsyncMode=$x;Ht.ConcurrentMode=t0;Ht.ContextConsumer=e0;Ht.ContextProvider=Jv;Ht.Element=Ux;Ht.ForwardRef=r0;Ht.Fragment=Xv;Ht.Lazy=o0;Ht.Memo=i0;Ht.Portal=zx;Ht.Profiler=Zv;Ht.StrictMode=Qv;Ht.Suspense=n0;Ht.isAsyncMode=function(e){return mk(e)||eo(e)===$x};Ht.isConcurrentMode=mk;Ht.isContextConsumer=function(e){return eo(e)===e0};Ht.isContextProvider=function(e){return eo(e)===Jv};Ht.isElement=function(e){return typeof e=="object"&&e!==null&&e.$$typeof===Ux};Ht.isForwardRef=function(e){return eo(e)===r0};Ht.isFragment=function(e){return eo(e)===Xv};Ht.isLazy=function(e){return eo(e)===o0};Ht.isMemo=function(e){return eo(e)===i0};Ht.isPortal=function(e){return eo(e)===zx};Ht.isProfiler=function(e){return eo(e)===Zv};Ht.isStrictMode=function(e){return eo(e)===Qv};Ht.isSuspense=function(e){return eo(e)===n0};Ht.isValidElementType=function(e){return typeof e=="string"||typeof e=="function"||e===Xv||e===t0||e===Zv||e===Qv||e===n0||e===NI||typeof e=="object"&&e!==null&&(e.$$typeof===o0||e.$$typeof===i0||e.$$typeof===Jv||e.$$typeof===e0||e.$$typeof===r0||e.$$typeof===PI||e.$$typeof===OI||e.$$typeof===MI||e.$$typeof===LI)};Ht.typeOf=eo});var yk=Ue((FH,vk)=>{"use strict";vk.exports=gk()});var _k=Ue((BH,Ek)=>{"use strict";var jx=yk(),AI={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},DI={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},RI={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},wk={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},qx={};qx[jx.ForwardRef]=RI;qx[jx.Memo]=wk;function xk(e){return jx.isMemo(e)?wk:qx[e.$$typeof]||AI}o(xk,"getStatics");var II=Object.defineProperty,FI=Object.getOwnPropertyNames,Sk=Object.getOwnPropertySymbols,BI=Object.getOwnPropertyDescriptor,HI=Object.getPrototypeOf,Ck=Object.prototype;function bk(e,t,n){if(typeof t!="string"){if(Ck){var l=HI(t);l&&l!==Ck&&bk(e,l,n)}var d=FI(t);Sk&&(d=d.concat(Sk(t)));for(var h=xk(e),c=xk(t),v=0;v{"use strict";var Nn=typeof Symbol=="function"&&Symbol.for,Vx=Nn?Symbol.for("react.element"):60103,Kx=Nn?Symbol.for("react.portal"):60106,s0=Nn?Symbol.for("react.fragment"):60107,l0=Nn?Symbol.for("react.strict_mode"):60108,a0=Nn?Symbol.for("react.profiler"):60114,u0=Nn?Symbol.for("react.provider"):60109,f0=Nn?Symbol.for("react.context"):60110,Gx=Nn?Symbol.for("react.async_mode"):60111,c0=Nn?Symbol.for("react.concurrent_mode"):60111,p0=Nn?Symbol.for("react.forward_ref"):60112,d0=Nn?Symbol.for("react.suspense"):60113,WI=Nn?Symbol.for("react.suspense_list"):60120,h0=Nn?Symbol.for("react.memo"):60115,m0=Nn?Symbol.for("react.lazy"):60116,UI=Nn?Symbol.for("react.block"):60121,zI=Nn?Symbol.for("react.fundamental"):60117,$I=Nn?Symbol.for("react.responder"):60118,jI=Nn?Symbol.for("react.scope"):60119;function to(e){if(typeof e=="object"&&e!==null){var t=e.$$typeof;switch(t){case Vx:switch(e=e.type,e){case Gx:case c0:case s0:case a0:case l0:case d0:return e;default:switch(e=e&&e.$$typeof,e){case f0:case p0:case m0:case h0:case u0:return e;default:return t}}case Kx:return t}}}o(to,"z");function Tk(e){return to(e)===c0}o(Tk,"A");Wt.AsyncMode=Gx;Wt.ConcurrentMode=c0;Wt.ContextConsumer=f0;Wt.ContextProvider=u0;Wt.Element=Vx;Wt.ForwardRef=p0;Wt.Fragment=s0;Wt.Lazy=m0;Wt.Memo=h0;Wt.Portal=Kx;Wt.Profiler=a0;Wt.StrictMode=l0;Wt.Suspense=d0;Wt.isAsyncMode=function(e){return Tk(e)||to(e)===Gx};Wt.isConcurrentMode=Tk;Wt.isContextConsumer=function(e){return to(e)===f0};Wt.isContextProvider=function(e){return to(e)===u0};Wt.isElement=function(e){return typeof e=="object"&&e!==null&&e.$$typeof===Vx};Wt.isForwardRef=function(e){return to(e)===p0};Wt.isFragment=function(e){return to(e)===s0};Wt.isLazy=function(e){return to(e)===m0};Wt.isMemo=function(e){return to(e)===h0};Wt.isPortal=function(e){return to(e)===Kx};Wt.isProfiler=function(e){return to(e)===a0};Wt.isStrictMode=function(e){return to(e)===l0};Wt.isSuspense=function(e){return to(e)===d0};Wt.isValidElementType=function(e){return typeof e=="string"||typeof e=="function"||e===s0||e===c0||e===a0||e===l0||e===d0||e===WI||typeof e=="object"&&e!==null&&(e.$$typeof===m0||e.$$typeof===h0||e.$$typeof===u0||e.$$typeof===f0||e.$$typeof===p0||e.$$typeof===zI||e.$$typeof===$I||e.$$typeof===jI||e.$$typeof===UI)};Wt.typeOf=to});var Lk=Ue((WH,Nk)=>{"use strict";Nk.exports=kk()});var Qh=Ue((Np,Xh)=>{(function(){var e,t="4.17.21",n=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",d="Expected a function",h="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",v=500,C="__lodash_placeholder__",k=1,O=2,j=4,B=1,X=2,J=1,Z=2,R=4,A=8,I=16,G=32,K=64,se=128,ne=256,pe=512,me=30,xe="...",Ve=800,tt=16,_e=1,St=2,We=3,Ke=1/0,Ge=9007199254740991,Xe=17976931348623157e292,nr=0/0,ct=4294967295,Hr=ct-1,Zt=ct>>>1,_t=[["ary",se],["bind",J],["bindKey",Z],["curry",A],["curryRight",I],["flip",pe],["partial",G],["partialRight",K],["rearg",ne]],Ct="[object Arguments]",ut="[object Array]",Lr="[object AsyncFunction]",zt="[object Boolean]",$t="[object Date]",ie="[object DOMException]",rt="[object Error]",Pr="[object Function]",Gt="[object GeneratorFunction]",Yt="[object Map]",Se="[object Number]",Or="[object Null]",fn="[object Object]",Un="[object Promise]",si="[object Proxy]",cn="[object RegExp]",Jt="[object Set]",gr="[object String]",pt="[object Symbol]",Ho="[object Undefined]",Cr="[object WeakMap]",Ui="[object WeakSet]",pn="[object ArrayBuffer]",zn="[object DataView]",Si="[object Float32Array]",Ci="[object Float64Array]",$n="[object Int8Array]",Mn="[object Int16Array]",Js="[object Int32Array]",H="[object Uint8Array]",ee="[object Uint8ClampedArray]",he="[object Uint16Array]",Te="[object Uint32Array]",ir=/\b__p \+= '';/g,Ul=/\b(__p \+=) '' \+/g,Ft=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Wr=/&(?:amp|lt|gt|quot|#39);/g,or=/[&<>"']/g,li=RegExp(Wr.source),ds=RegExp(or.source),lo=/<%-([\s\S]+?)%>/g,bi=/<%([\s\S]+?)%>/g,el=/<%=([\s\S]+?)%>/g,hs=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dn=/^\w*$/,id=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,tl=/[\\^$.*+?()[\]{}|]/g,Qf=RegExp(tl.source),rl=/^\s+/,od=/\s/,Zf=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,wu=/\{\n\/\* \[wrapped with (.+)\] \*/,sd=/,? & /,zl=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ms=/[()=,{}\[\]\/\s]/,ld=/\\(\\)?/g,Jf=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,nl=/\w*$/,xu=/^[-+]0x[0-9a-f]+$/i,Wo=/^0b[01]+$/i,ad=/^\[object .+?Constructor\]$/,Uo=/^0o[0-7]+$/i,$l=/^(?:0|[1-9]\d*)$/,ec=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,jt=/($^)/,Me=/['\n\r\u2028\u2029\\]/g,Ei="\\ud800-\\udfff",Su="\\u0300-\\u036f",ai="\\ufe20-\\ufe2f",vt="\\u20d0-\\u20ff",ao=Su+ai+vt,zo="\\u2700-\\u27bf",jl="a-z\\xdf-\\xf6\\xf8-\\xff",ue="\\xac\\xb1\\xd7\\xf7",ze="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Cu="\\u2000-\\u206f",bu=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",gs="A-Z\\xc0-\\xd6\\xd8-\\xde",il="\\ufe0e\\ufe0f",Eu=ue+ze+Cu+bu,He="['\u2019]",ud="["+Ei+"]",ql="["+Eu+"]",uo="["+ao+"]",ui="\\d+",tc="["+zo+"]",_u="["+jl+"]",$o="[^"+Ei+Eu+ui+zo+jl+gs+"]",vs="\\ud83c[\\udffb-\\udfff]",Tu="(?:"+uo+"|"+vs+")",ol="[^"+Ei+"]",Vl="(?:\\ud83c[\\udde6-\\uddff]){2}",Kl="[\\ud800-\\udbff][\\udc00-\\udfff]",fo="["+gs+"]",Gl="\\u200d",Yl="(?:"+_u+"|"+$o+")",rc="(?:"+fo+"|"+$o+")",Xl="(?:"+He+"(?:d|ll|m|re|s|t|ve))?",_i="(?:"+He+"(?:D|LL|M|RE|S|T|VE))?",nc=Tu+"?",Ql="["+il+"]?",co="(?:"+Gl+"(?:"+[ol,Vl,Kl].join("|")+")"+Ql+nc+")*",ys="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ic="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",oc=Ql+nc+co,fd="(?:"+[tc,Vl,Kl].join("|")+")"+oc,cd="(?:"+[ol+uo+"?",uo,Vl,Kl,ud].join("|")+")",ku=RegExp(He,"g"),sc=RegExp(uo,"g"),Nu=RegExp(vs+"(?="+vs+")|"+cd+oc,"g"),lc=RegExp([fo+"?"+_u+"+"+Xl+"(?="+[ql,fo,"$"].join("|")+")",rc+"+"+_i+"(?="+[ql,fo+Yl,"$"].join("|")+")",fo+"?"+Yl+"+"+Xl,fo+"+"+_i,ic,ys,ui,fd].join("|"),"g"),ac=RegExp("["+Gl+Ei+ao+il+"]"),Zl=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Jl=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Lu=-1,Ot={};Ot[Si]=Ot[Ci]=Ot[$n]=Ot[Mn]=Ot[Js]=Ot[H]=Ot[ee]=Ot[he]=Ot[Te]=!0,Ot[Ct]=Ot[ut]=Ot[pn]=Ot[zt]=Ot[zn]=Ot[$t]=Ot[rt]=Ot[Pr]=Ot[Yt]=Ot[Se]=Ot[fn]=Ot[cn]=Ot[Jt]=Ot[gr]=Ot[Cr]=!1;var Nt={};Nt[Ct]=Nt[ut]=Nt[pn]=Nt[zn]=Nt[zt]=Nt[$t]=Nt[Si]=Nt[Ci]=Nt[$n]=Nt[Mn]=Nt[Js]=Nt[Yt]=Nt[Se]=Nt[fn]=Nt[cn]=Nt[Jt]=Nt[gr]=Nt[pt]=Nt[H]=Nt[ee]=Nt[he]=Nt[Te]=!0,Nt[rt]=Nt[Pr]=Nt[Cr]=!1;var P={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Re={"&":"&","<":"<",">":">",'"':""","'":"'"},sl={"&":"&","<":"<",">":">",""":'"',"'":"'"},vr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Pu=parseFloat,ye=parseInt,jo=typeof global=="object"&&global&&global.Object===Object&&global,pd=typeof self=="object"&&self&&self.Object===Object&&self,qt=jo||pd||Function("return this")(),ea=typeof Np=="object"&&Np&&!Np.nodeType&&Np,hn=ea&&typeof Xh=="object"&&Xh&&!Xh.nodeType&&Xh,ws=hn&&hn.exports===ea,zi=ws&&jo.process,Ce=function(){try{var q=hn&&hn.require&&hn.require("util").types;return q||zi&&zi.binding&&zi.binding("util")}catch(re){}}(),ta=Ce&&Ce.isArrayBuffer,Ou=Ce&&Ce.isDate,nt=Ce&&Ce.isMap,uc=Ce&&Ce.isRegExp,fi=Ce&&Ce.isSet,ll=Ce&&Ce.isTypedArray;function Ur(q,re,Q){switch(Q.length){case 0:return q.call(re);case 1:return q.call(re,Q[0]);case 2:return q.call(re,Q[0],Q[1]);case 3:return q.call(re,Q[0],Q[1],Q[2])}return q.apply(re,Q)}o(Ur,"apply");function ra(q,re,Q,Pe){for(var Qe=-1,bt=q==null?0:q.length;++Qe-1}o(xs,"arrayIncludes");function qo(q,re,Q){for(var Pe=-1,Qe=q==null?0:q.length;++Pe-1;);return Q}o(qi,"charsStartIndex");function al(q,re){for(var Q=q.length;Q--&&Go(re,q[Q],0)>-1;);return Q}o(al,"charsEndIndex");function cc(q,re){for(var Q=q.length,Pe=0;Q--;)q[Q]===re&&++Pe;return Pe}o(cc,"countHolders");var Wu=oa(P),gd=oa(Re);function Uu(q){return"\\"+vr[q]}o(Uu,"escapeStringChar");function la(q,re){return q==null?e:q[re]}o(la,"getValue");function qn(q){return ac.test(q)}o(qn,"hasUnicode");function Ti(q){return Zl.test(q)}o(Ti,"hasUnicodeWord");function pc(q){for(var re,Q=[];!(re=q.next()).done;)Q.push(re.value);return Q}o(pc,"iteratorToArray");function aa(q){var re=-1,Q=Array(q.size);return q.forEach(function(Pe,Qe){Q[++re]=[Qe,Pe]}),Q}o(aa,"mapToArray");function dc(q,re){return function(Q){return q(re(Q))}}o(dc,"overArg");function Vi(q,re){for(var Q=-1,Pe=q.length,Qe=0,bt=[];++Q-1}o(Ky,"listCacheHas");function yc(s,f){var m=this.__data__,x=gl(m,s);return x<0?(++this.size,m.push([s,f])):m[x][1]=f,this}o(yc,"listCacheSet"),vo.prototype.clear=Cd,vo.prototype.delete=jm,vo.prototype.get=Yu,vo.prototype.has=Ky,vo.prototype.set=yc;function xr(s){var f=-1,m=s==null?0:s.length;for(this.clear();++f=f?s:f)),s}o(vl,"baseClamp");function Dn(s,f,m,x,_,L){var F,z=f&k,Y=f&O,le=f&j;if(m&&(F=_?m(s,x,_,L):m(s)),F!==e)return F;if(!Sr(s))return s;var ae=ot(s);if(ae){if(F=u(s),!z)return qr(s,F)}else{var ce=xn(s),Le=ce==Pr||ce==Gt;if(Ra(s))return Hd(s,z);if(ce==fn||ce==Ct||Le&&!_){if(F=Y||Le?{}:a(s),!z)return Y?hg(s,Xy(F,s)):iw(s,kd(F,s))}else{if(!Nt[ce])return _?s:{};F=p(s,ce,z)}}L||(L=new Ni);var Fe=L.get(s);if(Fe)return Fe;L.set(s,F),bb(s)?s.forEach(function(je){F.add(Dn(je,f,m,je,s,L))}):Sb(s)&&s.forEach(function(je,ht){F.set(ht,Dn(je,f,m,ht,s,L))});var $e=le?Y?Hc:ff:Y?Ai:_n,ft=ae?e:$e(s);return jn(ft||s,function(je,ht){ft&&(ht=je,je=s[ht]),Qu(F,ht,Dn(je,f,m,ht,s,L))}),F}o(Dn,"baseClone");function Ym(s){var f=_n(s);return function(m){return Xm(m,s,f)}}o(Ym,"baseConforms");function Xm(s,f,m){var x=m.length;if(s==null)return!x;for(s=mt(s);x--;){var _=m[x],L=f[_],F=s[_];if(F===e&&!(_ in s)||!L(F))return!1}return!0}o(Xm,"baseConformsTo");function Qm(s,f,m){if(typeof s!="function")throw new Kn(d);return At(function(){s.apply(e,m)},f)}o(Qm,"baseDelay");function va(s,f,m,x){var _=-1,L=xs,F=!0,z=s.length,Y=[],le=f.length;if(!z)return Y;m&&(f=yt(f,zr(m))),x?(L=qo,F=!1):f.length>=n&&(L=mn,F=!1,f=new tn(f));e:for(;++__?0:_+m),x=x===e||x>_?_:lt(x),x<0&&(x+=_),x=m>x?0:_b(x);m0&&m(z)?f>1?rn(z,f-1,m,x,_):$i(_,z):x||(_[_.length]=z)}return _}o(rn,"baseFlatten");var bc=gg(),$r=gg(!0);function hi(s,f){return s&&bc(s,f,_n)}o(hi,"baseForOwn");function Ec(s,f){return s&&$r(s,f,_n)}o(Ec,"baseForOwnRight");function Ju(s,f){return Vt(f,function(m){return _l(s[m])})}o(Ju,"baseFunctions");function Ds(s,f){f=Gi(f,s);for(var m=0,x=f.length;s!=null&&mf}o(_c,"baseGt");function Zm(s,f){return s!=null&&et.call(s,f)}o(Zm,"baseHas");function Jm(s,f){return s!=null&&f in mt(s)}o(Jm,"baseHasIn");function ya(s,f,m){return s>=Zr(f,m)&&s=120&&ae.length>=120)?new tn(F&&ae):e}ae=s[0];var ce=-1,Le=z[0];e:for(;++ce<_&&le.length-1;)z!==s&&pa.call(z,Y,1),pa.call(s,Y,1);return s}o(Md,"basePullAll");function Ad(s,f){for(var m=s?f.length:0,x=m-1;m--;){var _=f[m];if(m==x||_!==L){var L=_;S(_)?pa.call(s,_,1):of(s,_)}}return s}o(Ad,"basePullAt");function Pc(s,f){return s+ha(Ns()*(f-s+1))}o(Pc,"baseRandom");function ag(s,f,m,x){for(var _=-1,L=sr(da((f-s)/(m||1)),0),F=Q(L);L--;)F[x?L:++_]=s,s+=m;return F}o(ag,"baseRange");function Dd(s,f){var m="";if(!s||f<1||f>Ge)return m;do f%2&&(m+=s),f=ha(f/2),f&&(s+=s);while(f);return m}o(Dd,"baseRepeat");function st(s,f){return Sn(Ie(s,f,Di),s+"")}o(st,"baseRest");function ew(s){return wc(jc(s))}o(ew,"baseSample");function Fs(s,f){var m=jc(s);return Vr(m,vl(f,0,m.length))}o(Fs,"baseSampleSize");function Zo(s,f,m,x){if(!Sr(s))return s;f=Gi(f,s);for(var _=-1,L=f.length,F=L-1,z=s;z!=null&&++__?0:_+f),m=m>_?_:m,m<0&&(m+=_),_=f>m?0:m-f>>>0,f>>>=0;for(var L=Q(_);++x<_;)L[x]=s[x+f];return L}o(Li,"baseSlice");function tw(s,f){var m;return di(s,function(x,_,L){return m=f(x,_,L),!m}),!!m}o(tw,"baseSome");function es(s,f,m){var x=0,_=s==null?x:s.length;if(typeof f=="number"&&f===f&&_<=Zt){for(;x<_;){var L=x+_>>>1,F=s[L];F!==null&&!Yi(F)&&(m?F<=f:F=n){var le=f?null:uf(s);if(le)return w(le);F=!1,_=mn,Y=new tn}else Y=f?[]:z;e:for(;++x=x?s:Li(s,f,m)}o(Bs,"castSlice");var Ta=Iy||function(s){return qt.clearTimeout(s)};function Hd(s,f){if(f)return s.slice();var m=s.length,x=Wm?Wm(m):new s.constructor(m);return s.copy(x),x}o(Hd,"cloneBuffer");function Dc(s){var f=new s.constructor(s.byteLength);return new cl(f).set(new cl(s)),f}o(Dc,"cloneArrayBuffer");function nw(s,f){var m=f?Dc(s.buffer):s.buffer;return new s.constructor(m,s.byteOffset,s.byteLength)}o(nw,"cloneDataView");function Wd(s){var f=new s.constructor(s.source,nl.exec(s));return f.lastIndex=s.lastIndex,f}o(Wd,"cloneRegExp");function fg(s){return lr?mt(lr.call(s)):{}}o(fg,"cloneSymbol");function cg(s,f){var m=f?Dc(s.buffer):s.buffer;return new s.constructor(m,s.byteOffset,s.length)}o(cg,"cloneTypedArray");function Ud(s,f){if(s!==f){var m=s!==e,x=s===null,_=s===s,L=Yi(s),F=f!==e,z=f===null,Y=f===f,le=Yi(f);if(!z&&!le&&!L&&s>f||L&&F&&Y&&!z&&!le||x&&F&&Y||!m&&Y||!_)return 1;if(!x&&!L&&!le&&s=z)return Y;var le=m[x];return Y*(le=="desc"?-1:1)}}return s.index-f.index}o(pg,"compareMultiple");function dg(s,f,m,x){for(var _=-1,L=s.length,F=m.length,z=-1,Y=f.length,le=sr(L-F,0),ae=Q(Y+le),ce=!x;++z1?m[_-1]:e,F=_>2?m[2]:e;for(L=s.length>3&&typeof L=="function"?(_--,L):e,F&&b(m[0],m[1],F)&&(L=_<3?e:L,_=1),f=mt(f);++x<_;){var z=m[x];z&&s(f,z,x,L)}return f})}o(ka,"createAssigner");function mg(s,f){return function(m,x){if(m==null)return m;if(!Mi(m))return s(m,x);for(var _=m.length,L=f?_:-1,F=mt(m);(f?L--:++L<_)&&x(F[L],L,F)!==!1;);return m}}o(mg,"createBaseEach");function gg(s){return function(f,m,x){for(var _=-1,L=mt(f),F=x(f),z=F.length;z--;){var Y=F[s?z:++_];if(m(L[Y],Y,L)===!1)break}return f}}o(gg,"createBaseFor");function vg(s,f,m){var x=f&J,_=La(s);function L(){var F=this&&this!==qt&&this instanceof L?_:s;return F.apply(x?m:this,arguments)}return o(L,"wrapper"),L}o(vg,"createBind");function yg(s){return function(f){f=Dt(f);var m=qn(f)?Kt(f):e,x=m?m[0]:f.charAt(0),_=m?Bs(m,1).join(""):f.slice(1);return x[s]()+_}}o(yg,"createCaseFirst");function Na(s){return function(f){return Au(Db(Ab(f).replace(ku,"")),s,"")}}o(Na,"createCompounder");function La(s){return function(){var f=arguments;switch(f.length){case 0:return new s;case 1:return new s(f[0]);case 2:return new s(f[0],f[1]);case 3:return new s(f[0],f[1],f[2]);case 4:return new s(f[0],f[1],f[2],f[3]);case 5:return new s(f[0],f[1],f[2],f[3],f[4]);case 6:return new s(f[0],f[1],f[2],f[3],f[4],f[5]);case 7:return new s(f[0],f[1],f[2],f[3],f[4],f[5],f[6])}var m=go(s.prototype),x=s.apply(m,f);return Sr(x)?x:m}}o(La,"createCtor");function zd(s,f,m){var x=La(s);function _(){for(var L=arguments.length,F=Q(L),z=L,Y=Oa(_);z--;)F[z]=arguments[z];var le=L<3&&F[0]!==Y&&F[L-1]!==Y?[]:Vi(F,Y);if(L-=le.length,L-1?_[L?f[F]:F]:e}}o($d,"createFind");function wg(s){return ts(function(f){var m=f.length,x=m,_=An.prototype.thru;for(s&&f.reverse();x--;){var L=f[x];if(typeof L!="function")throw new Kn(d);if(_&&!F&&cf(L)=="wrapper")var F=new An([],!0)}for(x=F?x:m;++x1&>.reverse(),ae&&Yz))return!1;var le=L.get(s),ae=L.get(f);if(le&&ae)return le==f&&ae==s;var ce=-1,Le=!0,Fe=m&X?new tn:e;for(L.set(s,f),L.set(f,s);++ce1?"& ":"")+f[x],f=f.join(m>2?", ":" "),s.replace(Zf,`{ +Add a component higher in the tree to provide a loading indicator or placeholder to display.`)}Fn!==5&&(Fn=2),C=mx(C,v),B=c;do{switch(B.tag){case 3:h=C,B.flags|=4096,t&=-t,B.lanes|=t;var se=LT(B,h,t);KE(B,se);break e;case 1:h=C;var ne=B.type,pe=B.stateNode;if((B.flags&64)==0&&(typeof ne.getDerivedStateFromError=="function"||pe!==null&&typeof pe.componentDidCatch=="function"&&(Ks===null||!Ks.has(pe)))){B.flags|=4096,t&=-t,B.lanes|=t;var me=OT(B,h,t);KE(B,me);break e}}B=B.return}while(B!==null)}VT(n)}catch(xe){t=xe,sn===n&&n!==null&&(sn=n=n.return);continue}break}while(1)}o($T,"Sj");function jT(){var e=Fv.current;return Fv.current=Rv,e===null?Rv:e}o(jT,"Pj");function jh(e,t){var n=Ze;Ze|=16;var l=jT();yi===e&&Jn===t||_p(e,t);do try{lI();break}catch(d){$T(e,d)}while(1);if(Y1(),Ze=n,Fv.current=l,sn!==null)throw Error(we(261));return yi=null,Jn=0,Fn}o(jh,"Tj");function lI(){for(;sn!==null;)qT(sn)}o(lI,"ak");function aI(){for(;sn!==null&&!$R();)qT(sn)}o(aI,"Rj");function qT(e){var t=YT(e.alternate,e,Tf);e.memoizedProps=e.pendingProps,t===null?VT(e):sn=t,xx.current=null}o(qT,"bk");function VT(e){var t=e;do{var n=t.alternate;if(e=t.return,(t.flags&2048)==0){if(n=ZR(n,t,Tf),n!==null){sn=n;return}if(n=t,n.tag!==24&&n.tag!==23||n.memoizedState===null||(Tf&1073741824)!=0||(n.mode&4)==0){for(var l=0,d=n.child;d!==null;)l|=d.lanes|d.childLanes,d=d.sibling;n.childLanes=l}e!==null&&(e.flags&2048)==0&&(e.firstEffect===null&&(e.firstEffect=t.firstEffect),t.lastEffect!==null&&(e.lastEffect!==null&&(e.lastEffect.nextEffect=t.firstEffect),e.lastEffect=t.lastEffect),1c&&(v=c,c=se,se=v),v=gE(I,se),h=gE(I,c),v&&h&&(K.rangeCount!==1||K.anchorNode!==v.node||K.anchorOffset!==v.offset||K.focusNode!==h.node||K.focusOffset!==h.offset)&&(G=G.createRange(),G.setStart(v.node,v.offset),K.removeAllRanges(),se>c?(K.addRange(G),K.extend(h.node,h.offset)):(G.setEnd(h.node,h.offset),K.addRange(G)))))),G=[],K=I;K=K.parentNode;)K.nodeType===1&&G.push({element:K,left:K.scrollLeft,top:K.scrollTop});for(typeof I.focus=="function"&&I.focus(),I=0;IQn()-_x?_p(e,0):Cx|=n),ko(e,t)}o(dI,"Yj");function hI(e,t){var n=e.stateNode;n!==null&&n.delete(t),t=0,t===0&&(t=e.mode,(t&2)==0?t=1:(t&4)==0?t=mp()===99?1:2:(Dl===0&&(Dl=xp),t=op(62914560&~Dl),t===0&&(t=4194304))),n=Ji(),e=$v(e,t),e!==null&&(rv(e,t,n),ko(e,n))}o(hI,"lj");var YT;YT=o(function(e,t,n){var l=t.lanes;if(e!==null)if(e.memoizedProps!==t.pendingProps||Ri.current)ls=!0;else if((n&l)!=0)ls=(e.flags&16384)!=0;else{switch(ls=!1,t.tag){case 3:xT(t),rx();break;case 5:tT(t);break;case 1:Ii(t.type)&&yv(t);break;case 4:J1(t,t.stateNode.containerInfo);break;case 10:l=t.memoizedProps.value;var d=t.type._context;Er(Sv,d._currentValue),d._currentValue=l;break;case 13:if(t.memoizedState!==null)return(n&t.child.childLanes)!=0?ST(e,t,n):(Er(Tr,Tr.current&1),t=Ml(e,t,n),t!==null?t.sibling:null);Er(Tr,Tr.current&1);break;case 19:if(l=(n&t.childLanes)!=0,(e.flags&64)!=0){if(l)return TT(e,t,n);t.flags|=64}if(d=t.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),Er(Tr,Tr.current),l)break;return null;case 23:case 24:return t.lanes=0,fx(e,t,n)}return Ml(e,t,n)}else ls=!1;switch(t.lanes=0,t.tag){case 2:if(l=t.type,e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2),e=t.pendingProps,d=hp(t,Xn.current),vp(t,n),d=ox(null,t,l,e,d,n),t.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ii(l)){var h=!0;yv(t)}else h=!1;t.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Q1(t);var c=l.getDerivedStateFromProps;typeof c=="function"&&_v(t,l,c,e),d.updater=Ev,t.stateNode=d,d._reactInternals=t,Z1(t,l,e,n),t=px(null,t,l,!0,h,n)}else t.tag=0,Bi(null,t,d,n),t=t.child;return t;case 16:d=t.elementType;e:{switch(e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2),e=t.pendingProps,h=d._init,d=h(d._payload),t.type=d,h=t.tag=gI(d),e=ss(d,e),h){case 0:t=cx(null,t,d,e,n);break e;case 1:t=wT(null,t,d,e,n);break e;case 11:t=mT(null,t,d,e,n);break e;case 14:t=gT(null,t,d,ss(d.type,e),l,n);break e}throw Error(we(306,d,""))}return t;case 0:return l=t.type,d=t.pendingProps,d=t.elementType===l?d:ss(l,d),cx(e,t,l,d,n);case 1:return l=t.type,d=t.pendingProps,d=t.elementType===l?d:ss(l,d),wT(e,t,l,d,n);case 3:if(xT(t),l=t.updateQueue,e===null||l===null)throw Error(we(282));if(l=t.pendingProps,d=t.memoizedState,d=d!==null?d.element:null,VE(e,t),kh(t,l,null,n),l=t.memoizedState.element,l===d)rx(),t=Ml(e,t,n);else{if(d=t.stateNode,(h=d.hydrate)&&(Qa=fp(t.stateNode.containerInfo.firstChild),Ol=t,h=qs=!0),h){if(e=d.mutableSourceEagerHydrationData,e!=null)for(d=0;d{"use strict";function JT(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(JT)}catch(e){console.error(e)}}o(JT,"checkDCE");JT(),ek.exports=ZT()});var rk=Ue((yH,tk)=>{"use strict";var bI="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";tk.exports=bI});var sk=Ue((wH,ok)=>{"use strict";var _I=rk();function nk(){}o(nk,"emptyFunction");function ik(){}o(ik,"emptyFunctionWithReset");ik.resetWarningCache=nk;ok.exports=function(){function e(l,d,h,c,v,C){if(C!==_I){var k=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw k.name="Invariant Violation",k}}o(e,"shim"),e.isRequired=e;function t(){return e}o(t,"getShim");var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:ik,resetWarningCache:nk};return n.PropTypes=n,n}});var ak=Ue((CH,lk)=>{lk.exports=sk()();var xH,SH});var mk=Ue(Ht=>{"use strict";var kn=typeof Symbol=="function"&&Symbol.for,Wx=kn?Symbol.for("react.element"):60103,Ux=kn?Symbol.for("react.portal"):60106,Yv=kn?Symbol.for("react.fragment"):60107,Xv=kn?Symbol.for("react.strict_mode"):60108,Qv=kn?Symbol.for("react.profiler"):60114,Zv=kn?Symbol.for("react.provider"):60109,Jv=kn?Symbol.for("react.context"):60110,zx=kn?Symbol.for("react.async_mode"):60111,e0=kn?Symbol.for("react.concurrent_mode"):60111,t0=kn?Symbol.for("react.forward_ref"):60112,r0=kn?Symbol.for("react.suspense"):60113,NI=kn?Symbol.for("react.suspense_list"):60120,n0=kn?Symbol.for("react.memo"):60115,i0=kn?Symbol.for("react.lazy"):60116,PI=kn?Symbol.for("react.block"):60121,LI=kn?Symbol.for("react.fundamental"):60117,OI=kn?Symbol.for("react.responder"):60118,MI=kn?Symbol.for("react.scope"):60119;function eo(e){if(typeof e=="object"&&e!==null){var t=e.$$typeof;switch(t){case Wx:switch(e=e.type,e){case zx:case e0:case Yv:case Qv:case Xv:case r0:return e;default:switch(e=e&&e.$$typeof,e){case Jv:case t0:case i0:case n0:case Zv:return e;default:return t}}case Ux:return t}}}o(eo,"z");function hk(e){return eo(e)===e0}o(hk,"A");Ht.AsyncMode=zx;Ht.ConcurrentMode=e0;Ht.ContextConsumer=Jv;Ht.ContextProvider=Zv;Ht.Element=Wx;Ht.ForwardRef=t0;Ht.Fragment=Yv;Ht.Lazy=i0;Ht.Memo=n0;Ht.Portal=Ux;Ht.Profiler=Qv;Ht.StrictMode=Xv;Ht.Suspense=r0;Ht.isAsyncMode=function(e){return hk(e)||eo(e)===zx};Ht.isConcurrentMode=hk;Ht.isContextConsumer=function(e){return eo(e)===Jv};Ht.isContextProvider=function(e){return eo(e)===Zv};Ht.isElement=function(e){return typeof e=="object"&&e!==null&&e.$$typeof===Wx};Ht.isForwardRef=function(e){return eo(e)===t0};Ht.isFragment=function(e){return eo(e)===Yv};Ht.isLazy=function(e){return eo(e)===i0};Ht.isMemo=function(e){return eo(e)===n0};Ht.isPortal=function(e){return eo(e)===Ux};Ht.isProfiler=function(e){return eo(e)===Qv};Ht.isStrictMode=function(e){return eo(e)===Xv};Ht.isSuspense=function(e){return eo(e)===r0};Ht.isValidElementType=function(e){return typeof e=="string"||typeof e=="function"||e===Yv||e===e0||e===Qv||e===Xv||e===r0||e===NI||typeof e=="object"&&e!==null&&(e.$$typeof===i0||e.$$typeof===n0||e.$$typeof===Zv||e.$$typeof===Jv||e.$$typeof===t0||e.$$typeof===LI||e.$$typeof===OI||e.$$typeof===MI||e.$$typeof===PI)};Ht.typeOf=eo});var vk=Ue((FH,gk)=>{"use strict";gk.exports=mk()});var _k=Ue((BH,bk)=>{"use strict";var $x=vk(),AI={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},DI={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},RI={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},yk={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},jx={};jx[$x.ForwardRef]=RI;jx[$x.Memo]=yk;function wk(e){return $x.isMemo(e)?yk:jx[e.$$typeof]||AI}o(wk,"getStatics");var II=Object.defineProperty,FI=Object.getOwnPropertyNames,xk=Object.getOwnPropertySymbols,BI=Object.getOwnPropertyDescriptor,HI=Object.getPrototypeOf,Sk=Object.prototype;function Ck(e,t,n){if(typeof t!="string"){if(Sk){var l=HI(t);l&&l!==Sk&&Ck(e,l,n)}var d=FI(t);xk&&(d=d.concat(xk(t)));for(var h=wk(e),c=wk(t),v=0;v{"use strict";var Nn=typeof Symbol=="function"&&Symbol.for,qx=Nn?Symbol.for("react.element"):60103,Vx=Nn?Symbol.for("react.portal"):60106,o0=Nn?Symbol.for("react.fragment"):60107,s0=Nn?Symbol.for("react.strict_mode"):60108,l0=Nn?Symbol.for("react.profiler"):60114,a0=Nn?Symbol.for("react.provider"):60109,u0=Nn?Symbol.for("react.context"):60110,Kx=Nn?Symbol.for("react.async_mode"):60111,f0=Nn?Symbol.for("react.concurrent_mode"):60111,c0=Nn?Symbol.for("react.forward_ref"):60112,p0=Nn?Symbol.for("react.suspense"):60113,WI=Nn?Symbol.for("react.suspense_list"):60120,d0=Nn?Symbol.for("react.memo"):60115,h0=Nn?Symbol.for("react.lazy"):60116,UI=Nn?Symbol.for("react.block"):60121,zI=Nn?Symbol.for("react.fundamental"):60117,$I=Nn?Symbol.for("react.responder"):60118,jI=Nn?Symbol.for("react.scope"):60119;function to(e){if(typeof e=="object"&&e!==null){var t=e.$$typeof;switch(t){case qx:switch(e=e.type,e){case Kx:case f0:case o0:case l0:case s0:case p0:return e;default:switch(e=e&&e.$$typeof,e){case u0:case c0:case h0:case d0:case a0:return e;default:return t}}case Vx:return t}}}o(to,"z");function Ek(e){return to(e)===f0}o(Ek,"A");Wt.AsyncMode=Kx;Wt.ConcurrentMode=f0;Wt.ContextConsumer=u0;Wt.ContextProvider=a0;Wt.Element=qx;Wt.ForwardRef=c0;Wt.Fragment=o0;Wt.Lazy=h0;Wt.Memo=d0;Wt.Portal=Vx;Wt.Profiler=l0;Wt.StrictMode=s0;Wt.Suspense=p0;Wt.isAsyncMode=function(e){return Ek(e)||to(e)===Kx};Wt.isConcurrentMode=Ek;Wt.isContextConsumer=function(e){return to(e)===u0};Wt.isContextProvider=function(e){return to(e)===a0};Wt.isElement=function(e){return typeof e=="object"&&e!==null&&e.$$typeof===qx};Wt.isForwardRef=function(e){return to(e)===c0};Wt.isFragment=function(e){return to(e)===o0};Wt.isLazy=function(e){return to(e)===h0};Wt.isMemo=function(e){return to(e)===d0};Wt.isPortal=function(e){return to(e)===Vx};Wt.isProfiler=function(e){return to(e)===l0};Wt.isStrictMode=function(e){return to(e)===s0};Wt.isSuspense=function(e){return to(e)===p0};Wt.isValidElementType=function(e){return typeof e=="string"||typeof e=="function"||e===o0||e===f0||e===l0||e===s0||e===p0||e===WI||typeof e=="object"&&e!==null&&(e.$$typeof===h0||e.$$typeof===d0||e.$$typeof===a0||e.$$typeof===u0||e.$$typeof===c0||e.$$typeof===zI||e.$$typeof===$I||e.$$typeof===jI||e.$$typeof===UI)};Wt.typeOf=to});var Nk=Ue((WH,kk)=>{"use strict";kk.exports=Tk()});var Qh=Ue((Np,Xh)=>{(function(){var e,t="4.17.21",n=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",d="Expected a function",h="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",v=500,C="__lodash_placeholder__",k=1,O=2,j=4,B=1,X=2,J=1,Z=2,R=4,A=8,I=16,G=32,K=64,se=128,ne=256,pe=512,me=30,xe="...",Ve=800,tt=16,Ee=1,St=2,We=3,Ke=1/0,Ge=9007199254740991,Xe=17976931348623157e292,nr=0/0,ct=4294967295,Hr=ct-1,Zt=ct>>>1,Et=[["ary",se],["bind",J],["bindKey",Z],["curry",A],["curryRight",I],["flip",pe],["partial",G],["partialRight",K],["rearg",ne]],Ct="[object Arguments]",ut="[object Array]",Pr="[object AsyncFunction]",zt="[object Boolean]",$t="[object Date]",ie="[object DOMException]",rt="[object Error]",Lr="[object Function]",Gt="[object GeneratorFunction]",Yt="[object Map]",Se="[object Number]",Or="[object Null]",fn="[object Object]",Un="[object Promise]",si="[object Proxy]",cn="[object RegExp]",Jt="[object Set]",gr="[object String]",pt="[object Symbol]",Ho="[object Undefined]",Cr="[object WeakMap]",Ui="[object WeakSet]",pn="[object ArrayBuffer]",zn="[object DataView]",Si="[object Float32Array]",Ci="[object Float64Array]",$n="[object Int8Array]",Mn="[object Int16Array]",Js="[object Int32Array]",H="[object Uint8Array]",ee="[object Uint8ClampedArray]",he="[object Uint16Array]",Te="[object Uint32Array]",ir=/\b__p \+= '';/g,Ul=/\b(__p \+=) '' \+/g,Ft=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Wr=/&(?:amp|lt|gt|quot|#39);/g,or=/[&<>"']/g,li=RegExp(Wr.source),ds=RegExp(or.source),lo=/<%-([\s\S]+?)%>/g,bi=/<%([\s\S]+?)%>/g,el=/<%=([\s\S]+?)%>/g,hs=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dn=/^\w*$/,id=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,tl=/[\\^$.*+?()[\]{}|]/g,Qf=RegExp(tl.source),rl=/^\s+/,od=/\s/,Zf=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,wu=/\{\n\/\* \[wrapped with (.+)\] \*/,sd=/,? & /,zl=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ms=/[()=,{}\[\]\/\s]/,ld=/\\(\\)?/g,Jf=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,nl=/\w*$/,xu=/^[-+]0x[0-9a-f]+$/i,Wo=/^0b[01]+$/i,ad=/^\[object .+?Constructor\]$/,Uo=/^0o[0-7]+$/i,$l=/^(?:0|[1-9]\d*)$/,ec=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,jt=/($^)/,Me=/['\n\r\u2028\u2029\\]/g,_i="\\ud800-\\udfff",Su="\\u0300-\\u036f",ai="\\ufe20-\\ufe2f",vt="\\u20d0-\\u20ff",ao=Su+ai+vt,zo="\\u2700-\\u27bf",jl="a-z\\xdf-\\xf6\\xf8-\\xff",ue="\\xac\\xb1\\xd7\\xf7",ze="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Cu="\\u2000-\\u206f",bu=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",gs="A-Z\\xc0-\\xd6\\xd8-\\xde",il="\\ufe0e\\ufe0f",_u=ue+ze+Cu+bu,He="['\u2019]",ud="["+_i+"]",ql="["+_u+"]",uo="["+ao+"]",ui="\\d+",tc="["+zo+"]",Eu="["+jl+"]",$o="[^"+_i+_u+ui+zo+jl+gs+"]",vs="\\ud83c[\\udffb-\\udfff]",Tu="(?:"+uo+"|"+vs+")",ol="[^"+_i+"]",Vl="(?:\\ud83c[\\udde6-\\uddff]){2}",Kl="[\\ud800-\\udbff][\\udc00-\\udfff]",fo="["+gs+"]",Gl="\\u200d",Yl="(?:"+Eu+"|"+$o+")",rc="(?:"+fo+"|"+$o+")",Xl="(?:"+He+"(?:d|ll|m|re|s|t|ve))?",Ei="(?:"+He+"(?:D|LL|M|RE|S|T|VE))?",nc=Tu+"?",Ql="["+il+"]?",co="(?:"+Gl+"(?:"+[ol,Vl,Kl].join("|")+")"+Ql+nc+")*",ys="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ic="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",oc=Ql+nc+co,fd="(?:"+[tc,Vl,Kl].join("|")+")"+oc,cd="(?:"+[ol+uo+"?",uo,Vl,Kl,ud].join("|")+")",ku=RegExp(He,"g"),sc=RegExp(uo,"g"),Nu=RegExp(vs+"(?="+vs+")|"+cd+oc,"g"),lc=RegExp([fo+"?"+Eu+"+"+Xl+"(?="+[ql,fo,"$"].join("|")+")",rc+"+"+Ei+"(?="+[ql,fo+Yl,"$"].join("|")+")",fo+"?"+Yl+"+"+Xl,fo+"+"+Ei,ic,ys,ui,fd].join("|"),"g"),ac=RegExp("["+Gl+_i+ao+il+"]"),Zl=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Jl=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Pu=-1,Ot={};Ot[Si]=Ot[Ci]=Ot[$n]=Ot[Mn]=Ot[Js]=Ot[H]=Ot[ee]=Ot[he]=Ot[Te]=!0,Ot[Ct]=Ot[ut]=Ot[pn]=Ot[zt]=Ot[zn]=Ot[$t]=Ot[rt]=Ot[Lr]=Ot[Yt]=Ot[Se]=Ot[fn]=Ot[cn]=Ot[Jt]=Ot[gr]=Ot[Cr]=!1;var Nt={};Nt[Ct]=Nt[ut]=Nt[pn]=Nt[zn]=Nt[zt]=Nt[$t]=Nt[Si]=Nt[Ci]=Nt[$n]=Nt[Mn]=Nt[Js]=Nt[Yt]=Nt[Se]=Nt[fn]=Nt[cn]=Nt[Jt]=Nt[gr]=Nt[pt]=Nt[H]=Nt[ee]=Nt[he]=Nt[Te]=!0,Nt[rt]=Nt[Lr]=Nt[Cr]=!1;var L={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Re={"&":"&","<":"<",">":">",'"':""","'":"'"},sl={"&":"&","<":"<",">":">",""":'"',"'":"'"},vr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Lu=parseFloat,ye=parseInt,jo=typeof global=="object"&&global&&global.Object===Object&&global,pd=typeof self=="object"&&self&&self.Object===Object&&self,qt=jo||pd||Function("return this")(),ea=typeof Np=="object"&&Np&&!Np.nodeType&&Np,hn=ea&&typeof Xh=="object"&&Xh&&!Xh.nodeType&&Xh,ws=hn&&hn.exports===ea,zi=ws&&jo.process,Ce=function(){try{var q=hn&&hn.require&&hn.require("util").types;return q||zi&&zi.binding&&zi.binding("util")}catch(re){}}(),ta=Ce&&Ce.isArrayBuffer,Ou=Ce&&Ce.isDate,nt=Ce&&Ce.isMap,uc=Ce&&Ce.isRegExp,fi=Ce&&Ce.isSet,ll=Ce&&Ce.isTypedArray;function Ur(q,re,Q){switch(Q.length){case 0:return q.call(re);case 1:return q.call(re,Q[0]);case 2:return q.call(re,Q[0],Q[1]);case 3:return q.call(re,Q[0],Q[1],Q[2])}return q.apply(re,Q)}o(Ur,"apply");function ra(q,re,Q,Le){for(var Qe=-1,bt=q==null?0:q.length;++Qe-1}o(xs,"arrayIncludes");function qo(q,re,Q){for(var Le=-1,Qe=q==null?0:q.length;++Le-1;);return Q}o(qi,"charsStartIndex");function al(q,re){for(var Q=q.length;Q--&&Go(re,q[Q],0)>-1;);return Q}o(al,"charsEndIndex");function cc(q,re){for(var Q=q.length,Le=0;Q--;)q[Q]===re&&++Le;return Le}o(cc,"countHolders");var Wu=oa(L),gd=oa(Re);function Uu(q){return"\\"+vr[q]}o(Uu,"escapeStringChar");function la(q,re){return q==null?e:q[re]}o(la,"getValue");function qn(q){return ac.test(q)}o(qn,"hasUnicode");function Ti(q){return Zl.test(q)}o(Ti,"hasUnicodeWord");function pc(q){for(var re,Q=[];!(re=q.next()).done;)Q.push(re.value);return Q}o(pc,"iteratorToArray");function aa(q){var re=-1,Q=Array(q.size);return q.forEach(function(Le,Qe){Q[++re]=[Qe,Le]}),Q}o(aa,"mapToArray");function dc(q,re){return function(Q){return q(re(Q))}}o(dc,"overArg");function Vi(q,re){for(var Q=-1,Le=q.length,Qe=0,bt=[];++Q-1}o(Vy,"listCacheHas");function yc(s,f){var m=this.__data__,x=gl(m,s);return x<0?(++this.size,m.push([s,f])):m[x][1]=f,this}o(yc,"listCacheSet"),vo.prototype.clear=Cd,vo.prototype.delete=$m,vo.prototype.get=Yu,vo.prototype.has=Vy,vo.prototype.set=yc;function xr(s){var f=-1,m=s==null?0:s.length;for(this.clear();++f=f?s:f)),s}o(vl,"baseClamp");function Dn(s,f,m,x,E,P){var F,z=f&k,Y=f&O,le=f&j;if(m&&(F=E?m(s,x,E,P):m(s)),F!==e)return F;if(!Sr(s))return s;var ae=ot(s);if(ae){if(F=u(s),!z)return qr(s,F)}else{var ce=xn(s),Pe=ce==Lr||ce==Gt;if(Ra(s))return Hd(s,z);if(ce==fn||ce==Ct||Pe&&!E){if(F=Y||Pe?{}:a(s),!z)return Y?dg(s,Yy(F,s)):nw(s,kd(F,s))}else{if(!Nt[ce])return E?s:{};F=p(s,ce,z)}}P||(P=new Ni);var Fe=P.get(s);if(Fe)return Fe;P.set(s,F),Cb(s)?s.forEach(function(je){F.add(Dn(je,f,m,je,s,P))}):xb(s)&&s.forEach(function(je,ht){F.set(ht,Dn(je,f,m,ht,s,P))});var $e=le?Y?Hc:ff:Y?Ai:En,ft=ae?e:$e(s);return jn(ft||s,function(je,ht){ft&&(ht=je,je=s[ht]),Qu(F,ht,Dn(je,f,m,ht,s,P))}),F}o(Dn,"baseClone");function Gm(s){var f=En(s);return function(m){return Ym(m,s,f)}}o(Gm,"baseConforms");function Ym(s,f,m){var x=m.length;if(s==null)return!x;for(s=mt(s);x--;){var E=m[x],P=f[E],F=s[E];if(F===e&&!(E in s)||!P(F))return!1}return!0}o(Ym,"baseConformsTo");function Xm(s,f,m){if(typeof s!="function")throw new Kn(d);return At(function(){s.apply(e,m)},f)}o(Xm,"baseDelay");function va(s,f,m,x){var E=-1,P=xs,F=!0,z=s.length,Y=[],le=f.length;if(!z)return Y;m&&(f=yt(f,zr(m))),x?(P=qo,F=!1):f.length>=n&&(P=mn,F=!1,f=new tn(f));e:for(;++EE?0:E+m),x=x===e||x>E?E:lt(x),x<0&&(x+=E),x=m>x?0:_b(x);m0&&m(z)?f>1?rn(z,f-1,m,x,E):$i(E,z):x||(E[E.length]=z)}return E}o(rn,"baseFlatten");var bc=mg(),$r=mg(!0);function hi(s,f){return s&&bc(s,f,En)}o(hi,"baseForOwn");function _c(s,f){return s&&$r(s,f,En)}o(_c,"baseForOwnRight");function Ju(s,f){return Vt(f,function(m){return El(s[m])})}o(Ju,"baseFunctions");function Ds(s,f){f=Gi(f,s);for(var m=0,x=f.length;s!=null&&mf}o(Ec,"baseGt");function Qm(s,f){return s!=null&&et.call(s,f)}o(Qm,"baseHas");function Zm(s,f){return s!=null&&f in mt(s)}o(Zm,"baseHasIn");function ya(s,f,m){return s>=Zr(f,m)&&s=120&&ae.length>=120)?new tn(F&&ae):e}ae=s[0];var ce=-1,Pe=z[0];e:for(;++ce-1;)z!==s&&pa.call(z,Y,1),pa.call(s,Y,1);return s}o(Md,"basePullAll");function Ad(s,f){for(var m=s?f.length:0,x=m-1;m--;){var E=f[m];if(m==x||E!==P){var P=E;S(E)?pa.call(s,E,1):of(s,E)}}return s}o(Ad,"basePullAt");function Lc(s,f){return s+ha(Ns()*(f-s+1))}o(Lc,"baseRandom");function lg(s,f,m,x){for(var E=-1,P=sr(da((f-s)/(m||1)),0),F=Q(P);P--;)F[x?P:++E]=s,s+=m;return F}o(lg,"baseRange");function Dd(s,f){var m="";if(!s||f<1||f>Ge)return m;do f%2&&(m+=s),f=ha(f/2),f&&(s+=s);while(f);return m}o(Dd,"baseRepeat");function st(s,f){return Sn(Ie(s,f,Di),s+"")}o(st,"baseRest");function Jy(s){return wc(jc(s))}o(Jy,"baseSample");function Fs(s,f){var m=jc(s);return Vr(m,vl(f,0,m.length))}o(Fs,"baseSampleSize");function Zo(s,f,m,x){if(!Sr(s))return s;f=Gi(f,s);for(var E=-1,P=f.length,F=P-1,z=s;z!=null&&++EE?0:E+f),m=m>E?E:m,m<0&&(m+=E),E=f>m?0:m-f>>>0,f>>>=0;for(var P=Q(E);++x>>1,F=s[P];F!==null&&!Yi(F)&&(m?F<=f:F=n){var le=f?null:uf(s);if(le)return w(le);F=!1,E=mn,Y=new tn}else Y=f?[]:z;e:for(;++x=x?s:Pi(s,f,m)}o(Bs,"castSlice");var Ta=Ry||function(s){return qt.clearTimeout(s)};function Hd(s,f){if(f)return s.slice();var m=s.length,x=Hm?Hm(m):new s.constructor(m);return s.copy(x),x}o(Hd,"cloneBuffer");function Dc(s){var f=new s.constructor(s.byteLength);return new cl(f).set(new cl(s)),f}o(Dc,"cloneArrayBuffer");function rw(s,f){var m=f?Dc(s.buffer):s.buffer;return new s.constructor(m,s.byteOffset,s.byteLength)}o(rw,"cloneDataView");function Wd(s){var f=new s.constructor(s.source,nl.exec(s));return f.lastIndex=s.lastIndex,f}o(Wd,"cloneRegExp");function ug(s){return lr?mt(lr.call(s)):{}}o(ug,"cloneSymbol");function fg(s,f){var m=f?Dc(s.buffer):s.buffer;return new s.constructor(m,s.byteOffset,s.length)}o(fg,"cloneTypedArray");function Ud(s,f){if(s!==f){var m=s!==e,x=s===null,E=s===s,P=Yi(s),F=f!==e,z=f===null,Y=f===f,le=Yi(f);if(!z&&!le&&!P&&s>f||P&&F&&Y&&!z&&!le||x&&F&&Y||!m&&Y||!E)return 1;if(!x&&!P&&!le&&s=z)return Y;var le=m[x];return Y*(le=="desc"?-1:1)}}return s.index-f.index}o(cg,"compareMultiple");function pg(s,f,m,x){for(var E=-1,P=s.length,F=m.length,z=-1,Y=f.length,le=sr(P-F,0),ae=Q(Y+le),ce=!x;++z1?m[E-1]:e,F=E>2?m[2]:e;for(P=s.length>3&&typeof P=="function"?(E--,P):e,F&&b(m[0],m[1],F)&&(P=E<3?e:P,E=1),f=mt(f);++x-1?E[P?f[F]:F]:e}}o($d,"createFind");function yg(s){return ts(function(f){var m=f.length,x=m,E=An.prototype.thru;for(s&&f.reverse();x--;){var P=f[x];if(typeof P!="function")throw new Kn(d);if(E&&!F&&cf(P)=="wrapper")var F=new An([],!0)}for(x=F?x:m;++x1&>.reverse(),ae&&Yz))return!1;var le=P.get(s),ae=P.get(f);if(le&&ae)return le==f&&ae==s;var ce=-1,Pe=!0,Fe=m&X?new tn:e;for(P.set(s,f),P.set(f,s);++ce1?"& ":"")+f[x],f=f.join(m>2?", ":" "),s.replace(Zf,`{ /* [wrapped with `+f+`] */ -`)}o(g,"insertWrapDetails");function y(s){return ot(s)||pf(s)||!!(pl&&s&&s[pl])}o(y,"isFlattenable");function S(s,f){var m=typeof s;return f=f??Ge,!!f&&(m=="number"||m!="symbol"&&$l.test(s))&&s>-1&&s%1==0&&s0){if(++f>=Ve)return arguments[0]}else f=0;return s.apply(e,arguments)}}o(dr,"shortOut");function Vr(s,f){var m=-1,x=s.length,_=x-1;for(f=f===e?x:f;++m1?s[f-1]:e;return m=typeof m=="function"?(s.pop(),m):e,ub(s,m)});function fb(s){var f=N(s);return f.__chain__=!0,f}o(fb,"chain");function eM(s,f){return f(s),s}o(eM,"tap");function Tg(s,f){return f(s)}o(Tg,"thru");var tM=ts(function(s){var f=s.length,m=f?s[0]:0,x=this.__wrapped__,_=o(function(L){return Nd(L,s)},"interceptor");return f>1||this.__actions__.length||!(x instanceof dt)||!S(m)?this.thru(_):(x=x.slice(m,+m+(f?1:0)),x.__actions__.push({func:Tg,args:[_],thisArg:e}),new An(x,this.__chain__).thru(function(L){return f&&!L.length&&L.push(e),L}))});function rM(){return fb(this)}o(rM,"wrapperChain");function nM(){return new An(this.value(),this.__chain__)}o(nM,"wrapperCommit");function iM(){this.__values__===e&&(this.__values__=Eb(this.value()));var s=this.__index__>=this.__values__.length,f=s?e:this.__values__[this.__index__++];return{done:s,value:f}}o(iM,"wrapperNext");function oM(){return this}o(oM,"wrapperToIterator");function sM(s){for(var f,m=this;m instanceof vc;){var x=bn(m);x.__index__=0,x.__values__=e,f?_.__wrapped__=x:f=x;var _=x;m=m.__wrapped__}return _.__wrapped__=s,f}o(sM,"wrapperPlant");function lM(){var s=this.__wrapped__;if(s instanceof dt){var f=s;return this.__actions__.length&&(f=new dt(this)),f=f.reverse(),f.__actions__.push({func:Tg,args:[sw],thisArg:e}),new An(f,this.__chain__)}return this.thru(sw)}o(lM,"wrapperReverse");function aM(){return ug(this.__wrapped__,this.__actions__)}o(aM,"wrapperValue");var uM=Ic(function(s,f,m){et.call(s,m)?++s[m]:yo(s,m,1)});function fM(s,f,m){var x=ot(s)?Mu:Cc;return m&&b(s,f,m)&&(f=e),x(s,Be(f,3))}o(fM,"every");function cM(s,f){var m=ot(s)?Vt:Pd;return m(s,Be(f,3))}o(cM,"filter");var pM=$d(zc),dM=$d(ob);function hM(s,f){return rn(kg(s,f),1)}o(hM,"flatMap");function mM(s,f){return rn(kg(s,f),Ke)}o(mM,"flatMapDeep");function gM(s,f,m){return m=m===e?1:lt(m),rn(kg(s,f),m)}o(gM,"flatMapDepth");function cb(s,f){var m=ot(s)?jn:di;return m(s,Be(f,3))}o(cb,"forEach");function pb(s,f){var m=ot(s)?dd:Sc;return m(s,Be(f,3))}o(pb,"forEachRight");var vM=Ic(function(s,f,m){et.call(s,m)?s[m].push(f):yo(s,m,[f])});function yM(s,f,m,x){s=Mi(s)?s:jc(s),m=m&&!x?lt(m):0;var _=s.length;return m<0&&(m=sr(_+m,0)),Mg(s)?m<=_&&s.indexOf(f,m)>-1:!!_&&Go(s,f,m)>-1}o(yM,"includes");var wM=st(function(s,f,m){var x=-1,_=typeof f=="function",L=Mi(s)?Q(s.length):[];return di(s,function(F){L[++x]=_?Ur(f,F,m):wa(F,f,m)}),L}),xM=Ic(function(s,f,m){yo(s,m,f)});function kg(s,f){var m=ot(s)?yt:Ea;return m(s,Be(f,3))}o(kg,"map");function SM(s,f,m,x){return s==null?[]:(ot(f)||(f=f==null?[]:[f]),m=x?e:m,ot(m)||(m=m==null?[]:[m]),yn(s,f,m))}o(SM,"orderBy");var CM=Ic(function(s,f,m){s[m?0:1].push(f)},function(){return[[],[]]});function bM(s,f,m){var x=ot(s)?Au:Fu,_=arguments.length<3;return x(s,Be(f,4),m,_,di)}o(bM,"reduce");function EM(s,f,m){var x=ot(s)?hd:Fu,_=arguments.length<3;return x(s,Be(f,4),m,_,Sc)}o(EM,"reduceRight");function _M(s,f){var m=ot(s)?Vt:Pd;return m(s,Pg(Be(f,3)))}o(_M,"reject");function TM(s){var f=ot(s)?wc:ew;return f(s)}o(TM,"sample");function kM(s,f,m){(m?b(s,f,m):f===e)?f=1:f=lt(f);var x=ot(s)?As:Fs;return x(s,f)}o(kM,"sampleSize");function NM(s){var f=ot(s)?Gm:Jo;return f(s)}o(NM,"shuffle");function LM(s){if(s==null)return 0;if(Mi(s))return Mg(s)?wr(s):s.length;var f=xn(s);return f==Yt||f==Jt?s.size:Nc(s).length}o(LM,"size");function PM(s,f,m){var x=ot(s)?Vo:tw;return m&&b(s,f,m)&&(f=e),x(s,Be(f,3))}o(PM,"some");var OM=st(function(s,f){if(s==null)return[];var m=f.length;return m>1&&b(s,f[0],f[1])?f=[]:m>2&&b(f[0],f[1],f[2])&&(f=[f[0]]),yn(s,rn(f,1),[])}),Ng=Fy||function(){return qt.Date.now()};function MM(s,f){if(typeof f!="function")throw new Kn(d);return s=lt(s),function(){if(--s<1)return f.apply(this,arguments)}}o(MM,"after");function db(s,f,m){return f=m?e:f,f=s&&f==null?s.length:f,Oi(s,se,e,e,e,e,f)}o(db,"ary");function hb(s,f){var m;if(typeof f!="function")throw new Kn(d);return s=lt(s),function(){return--s>0&&(m=f.apply(this,arguments)),s<=1&&(f=e),m}}o(hb,"before");var aw=st(function(s,f,m){var x=J;if(m.length){var _=Vi(m,Oa(aw));x|=G}return Oi(s,x,f,m,_)}),mb=st(function(s,f,m){var x=J|Z;if(m.length){var _=Vi(m,Oa(mb));x|=G}return Oi(f,x,s,m,_)});function gb(s,f,m){f=m?e:f;var x=Oi(s,A,e,e,e,e,e,f);return x.placeholder=gb.placeholder,x}o(gb,"curry");function vb(s,f,m){f=m?e:f;var x=Oi(s,I,e,e,e,e,e,f);return x.placeholder=vb.placeholder,x}o(vb,"curryRight");function yb(s,f,m){var x,_,L,F,z,Y,le=0,ae=!1,ce=!1,Le=!0;if(typeof s!="function")throw new Kn(d);f=So(f)||0,Sr(m)&&(ae=!!m.leading,ce="maxWait"in m,L=ce?sr(So(m.maxWait)||0,f):L,Le="trailing"in m?!!m.trailing:Le);function Fe(Ir){var is=x,kl=_;return x=_=e,le=Ir,F=s.apply(kl,is),F}o(Fe,"invokeFunc");function $e(Ir){return le=Ir,z=At(ht,f),ae?Fe(Ir):F}o($e,"leadingEdge");function ft(Ir){var is=Ir-Y,kl=Ir-le,Fb=f-is;return ce?Zr(Fb,L-kl):Fb}o(ft,"remainingWait");function je(Ir){var is=Ir-Y,kl=Ir-le;return Y===e||is>=f||is<0||ce&&kl>=L}o(je,"shouldInvoke");function ht(){var Ir=Ng();if(je(Ir))return gt(Ir);z=At(ht,ft(Ir))}o(ht,"timerExpired");function gt(Ir){return z=e,Le&&x?Fe(Ir):(x=_=e,F)}o(gt,"trailingEdge");function Xi(){z!==e&&Ta(z),le=0,x=Y=_=z=e}o(Xi,"cancel");function gi(){return z===e?F:gt(Ng())}o(gi,"flush");function Qi(){var Ir=Ng(),is=je(Ir);if(x=arguments,_=this,Y=Ir,is){if(z===e)return $e(Y);if(ce)return Ta(z),z=At(ht,f),Fe(Y)}return z===e&&(z=At(ht,f)),F}return o(Qi,"debounced"),Qi.cancel=Xi,Qi.flush=gi,Qi}o(yb,"debounce");var AM=st(function(s,f){return Qm(s,1,f)}),DM=st(function(s,f,m){return Qm(s,So(f)||0,m)});function RM(s){return Oi(s,pe)}o(RM,"flip");function Lg(s,f){if(typeof s!="function"||f!=null&&typeof f!="function")throw new Kn(d);var m=o(function(){var x=arguments,_=f?f.apply(this,x):x[0],L=m.cache;if(L.has(_))return L.get(_);var F=s.apply(this,x);return m.cache=L.set(_,F)||L,F},"memoized");return m.cache=new(Lg.Cache||xr),m}o(Lg,"memoize"),Lg.Cache=xr;function Pg(s){if(typeof s!="function")throw new Kn(d);return function(){var f=arguments;switch(f.length){case 0:return!s.call(this);case 1:return!s.call(this,f[0]);case 2:return!s.call(this,f[0],f[1]);case 3:return!s.call(this,f[0],f[1],f[2])}return!s.apply(this,f)}}o(Pg,"negate");function IM(s){return hb(2,s)}o(IM,"once");var FM=rw(function(s,f){f=f.length==1&&ot(f[0])?yt(f[0],zr(Be())):yt(rn(f,1),zr(Be()));var m=f.length;return st(function(x){for(var _=-1,L=Zr(x.length,m);++_=f}),pf=xa(function(){return arguments}())?xa:function(s){return Er(s)&&et.call(s,"callee")&&!hc.call(s,"callee")},ot=Q.isArray,ZM=ta?zr(ta):Qy;function Mi(s){return s!=null&&Og(s.length)&&!_l(s)}o(Mi,"isArrayLike");function Rr(s){return Er(s)&&Mi(s)}o(Rr,"isArrayLikeObject");function JM(s){return s===!0||s===!1||Er(s)&&jr(s)==zt}o(JM,"isBoolean");var Ra=qu||xw,eA=Ou?zr(Ou):Sa;function tA(s){return Er(s)&&s.nodeType===1&&!Gd(s)}o(tA,"isElement");function rA(s){if(s==null)return!0;if(Mi(s)&&(ot(s)||typeof s=="string"||typeof s.splice=="function"||Ra(s)||$c(s)||pf(s)))return!s.length;var f=xn(s);if(f==Yt||f==Jt)return!s.size;if(te(s))return!Nc(s).length;for(var m in s)if(et.call(s,m))return!1;return!0}o(rA,"isEmpty");function nA(s,f){return Ca(s,f)}o(nA,"isEqual");function iA(s,f,m){m=typeof m=="function"?m:e;var x=m?m(s,f):e;return x===e?Ca(s,f,e,m):!!x}o(iA,"isEqualWith");function fw(s){if(!Er(s))return!1;var f=jr(s);return f==rt||f==ie||typeof s.message=="string"&&typeof s.name=="string"&&!Gd(s)}o(fw,"isError");function oA(s){return typeof s=="number"&&Um(s)}o(oA,"isFinite");function _l(s){if(!Sr(s))return!1;var f=jr(s);return f==Pr||f==Gt||f==Lr||f==si}o(_l,"isFunction");function xb(s){return typeof s=="number"&&s==lt(s)}o(xb,"isInteger");function Og(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=Ge}o(Og,"isLength");function Sr(s){var f=typeof s;return s!=null&&(f=="object"||f=="function")}o(Sr,"isObject");function Er(s){return s!=null&&typeof s=="object"}o(Er,"isObjectLike");var Sb=nt?zr(nt):tg;function sA(s,f){return s===f||wl(s,f,Ma(f))}o(sA,"isMatch");function lA(s,f,m){return m=typeof m=="function"?m:e,wl(s,f,Ma(f),m)}o(lA,"isMatchWith");function aA(s){return Cb(s)&&s!=+s}o(aA,"isNaN");function uA(s){if($(s))throw new Qe(l);return ba(s)}o(uA,"isNative");function fA(s){return s===null}o(fA,"isNull");function cA(s){return s==null}o(cA,"isNil");function Cb(s){return typeof s=="number"||Er(s)&&jr(s)==Se}o(Cb,"isNumber");function Gd(s){if(!Er(s)||jr(s)!=fn)return!1;var f=ca(s);if(f===null)return!0;var m=et.call(f,"constructor")&&f.constructor;return typeof m=="function"&&m instanceof m&&ho.call(m)==Ry}o(Gd,"isPlainObject");var cw=uc?zr(uc):ef;function pA(s){return xb(s)&&s>=-Ge&&s<=Ge}o(pA,"isSafeInteger");var bb=fi?zr(fi):tf;function Mg(s){return typeof s=="string"||!ot(s)&&Er(s)&&jr(s)==gr}o(Mg,"isString");function Yi(s){return typeof s=="symbol"||Er(s)&&jr(s)==pt}o(Yi,"isSymbol");var $c=ll?zr(ll):rg;function dA(s){return s===e}o(dA,"isUndefined");function hA(s){return Er(s)&&xn(s)==Cr}o(hA,"isWeakMap");function mA(s){return Er(s)&&jr(s)==Ui}o(mA,"isWeakSet");var gA=Mt(Is),vA=Mt(function(s,f){return s<=f});function Eb(s){if(!s)return[];if(Mi(s))return Mg(s)?Kt(s):qr(s);if(_s&&s[_s])return pc(s[_s]());var f=xn(s),m=f==Yt?aa:f==Jt?w:jc;return m(s)}o(Eb,"toArray");function Tl(s){if(!s)return s===0?s:0;if(s=So(s),s===Ke||s===-Ke){var f=s<0?-1:1;return f*Xe}return s===s?s:0}o(Tl,"toFinite");function lt(s){var f=Tl(s),m=f%1;return f===f?m?f-m:f:0}o(lt,"toInteger");function _b(s){return s?vl(lt(s),0,ct):0}o(_b,"toLength");function So(s){if(typeof s=="number")return s;if(Yi(s))return nr;if(Sr(s)){var f=typeof s.valueOf=="function"?s.valueOf():s;s=Sr(f)?f+"":f}if(typeof s!="string")return s===0?s:+s;s=Ss(s);var m=Wo.test(s);return m||Uo.test(s)?ye(s.slice(2),m?2:8):xu.test(s)?nr:+s}o(So,"toNumber");function Tb(s){return Gn(s,Ai(s))}o(Tb,"toPlainObject");function yA(s){return s?vl(lt(s),-Ge,Ge):s===0?s:0}o(yA,"toSafeInteger");function Dt(s){return s==null?"":wn(s)}o(Dt,"toString");var wA=ka(function(s,f){if(te(f)||Mi(f)){Gn(f,_n(f),s);return}for(var m in f)et.call(f,m)&&Qu(s,m,f[m])}),kb=ka(function(s,f){Gn(f,Ai(f),s)}),Ag=ka(function(s,f,m,x){Gn(f,Ai(f),s,x)}),xA=ka(function(s,f,m,x){Gn(f,_n(f),s,x)}),SA=ts(Nd);function CA(s,f){var m=go(s);return f==null?m:kd(m,f)}o(CA,"create");var bA=st(function(s,f){s=mt(s);var m=-1,x=f.length,_=x>2?f[2]:e;for(_&&b(f[0],f[1],_)&&(x=1);++m1),L}),Gn(s,Hc(s),m),x&&(m=Dn(m,k|O|j,Cg));for(var _=f.length;_--;)of(m,f[_]);return m});function UA(s,f){return Lb(s,Pg(Be(f)))}o(UA,"omitBy");var zA=ts(function(s,f){return s==null?{}:sg(s,f)});function Lb(s,f){if(s==null)return{};var m=yt(Hc(s),function(x){return[x]});return f=Be(f),lg(s,m,function(x,_){return f(x,_[0])})}o(Lb,"pickBy");function $A(s,f,m){f=Gi(f,s);var x=-1,_=f.length;for(_||(_=1,s=e);++x<_;){var L=s==null?e:s[Lt(f[x])];L===e&&(x=_,L=m),s=_l(L)?L.call(s):L}return s}o($A,"result");function jA(s,f,m){return s==null?s:Zo(s,f,m)}o(jA,"set");function qA(s,f,m,x){return x=typeof x=="function"?x:e,s==null?s:Zo(s,f,m,x)}o(qA,"setWith");var Pb=Pi(_n),Ob=Pi(Ai);function VA(s,f,m){var x=ot(s),_=x||Ra(s)||$c(s);if(f=Be(f,4),m==null){var L=s&&s.constructor;_?m=x?new L:[]:Sr(s)?m=_l(L)?go(ca(s)):{}:m={}}return(_?jn:hi)(s,function(F,z,Y){return f(m,F,z,Y)}),m}o(VA,"transform");function KA(s,f){return s==null?!0:of(s,f)}o(KA,"unset");function GA(s,f,m){return s==null?s:Mc(s,f,Ac(m))}o(GA,"update");function YA(s,f,m,x){return x=typeof x=="function"?x:e,s==null?s:Mc(s,f,Ac(m),x)}o(YA,"updateWith");function jc(s){return s==null?[]:sa(s,_n(s))}o(jc,"values");function XA(s){return s==null?[]:sa(s,Ai(s))}o(XA,"valuesIn");function QA(s,f,m){return m===e&&(m=f,f=e),m!==e&&(m=So(m),m=m===m?m:0),f!==e&&(f=So(f),f=f===f?f:0),vl(So(s),f,m)}o(QA,"clamp");function ZA(s,f,m){return f=Tl(f),m===e?(m=f,f=0):m=Tl(m),s=So(s),ya(s,f,m)}o(ZA,"inRange");function JA(s,f,m){if(m&&typeof m!="boolean"&&b(s,f,m)&&(f=m=e),m===e&&(typeof f=="boolean"?(m=f,f=e):typeof s=="boolean"&&(m=s,s=e)),s===e&&f===e?(s=0,f=1):(s=Tl(s),f===e?(f=s,s=0):f=Tl(f)),s>f){var x=s;s=f,f=x}if(m||s%1||f%1){var _=Ns();return Zr(s+_*(f-s+Pu("1e-"+((_+"").length-1))),f)}return Pc(s,f)}o(JA,"random");var e2=Na(function(s,f,m){return f=f.toLowerCase(),s+(m?Mb(f):f)});function Mb(s){return hw(Dt(s).toLowerCase())}o(Mb,"capitalize");function Ab(s){return s=Dt(s),s&&s.replace(ec,Wu).replace(sc,"")}o(Ab,"deburr");function t2(s,f,m){s=Dt(s),f=wn(f);var x=s.length;m=m===e?x:vl(lt(m),0,x);var _=m;return m-=f.length,m>=0&&s.slice(m,_)==f}o(t2,"endsWith");function r2(s){return s=Dt(s),s&&ds.test(s)?s.replace(or,gd):s}o(r2,"escape");function n2(s){return s=Dt(s),s&&Qf.test(s)?s.replace(tl,"\\$&"):s}o(n2,"escapeRegExp");var i2=Na(function(s,f,m){return s+(m?"-":"")+f.toLowerCase()}),o2=Na(function(s,f,m){return s+(m?" ":"")+f.toLowerCase()}),s2=yg("toLowerCase");function l2(s,f,m){s=Dt(s),f=lt(f);var x=f?wr(s):0;if(!f||x>=f)return s;var _=(f-x)/2;return Fc(ha(_),m)+s+Fc(da(_),m)}o(l2,"pad");function a2(s,f,m){s=Dt(s),f=lt(f);var x=f?wr(s):0;return f&&x>>0,m?(s=Dt(s),s&&(typeof f=="string"||f!=null&&!cw(f))&&(f=wn(f),!f&&qn(s))?Bs(Kt(s),0,m):s.split(f,m)):[]}o(h2,"split");var m2=Na(function(s,f,m){return s+(m?" ":"")+hw(f)});function g2(s,f,m){return s=Dt(s),m=m==null?0:vl(lt(m),0,s.length),f=wn(f),s.slice(m,m+f.length)==f}o(g2,"startsWith");function v2(s,f,m){var x=N.templateSettings;m&&b(s,f,m)&&(f=e),s=Dt(s),f=Ag({},f,x,Bc);var _=Ag({},f.imports,x.imports,Bc),L=_n(_),F=sa(_,L),z,Y,le=0,ae=f.interpolate||jt,ce="__p += '",Le=Cs((f.escape||jt).source+"|"+ae.source+"|"+(ae===el?Jf:jt).source+"|"+(f.evaluate||jt).source+"|$","g"),Fe="//# sourceURL="+(et.call(f,"sourceURL")?(f.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Lu+"]")+` -`;s.replace(Le,function(je,ht,gt,Xi,gi,Qi){return gt||(gt=Xi),ce+=s.slice(le,Qi).replace(Me,Uu),ht&&(z=!0,ce+=`' + +`)}o(g,"insertWrapDetails");function y(s){return ot(s)||pf(s)||!!(pl&&s&&s[pl])}o(y,"isFlattenable");function S(s,f){var m=typeof s;return f=f??Ge,!!f&&(m=="number"||m!="symbol"&&$l.test(s))&&s>-1&&s%1==0&&s0){if(++f>=Ve)return arguments[0]}else f=0;return s.apply(e,arguments)}}o(dr,"shortOut");function Vr(s,f){var m=-1,x=s.length,E=x-1;for(f=f===e?x:f;++m1?s[f-1]:e;return m=typeof m=="function"?(s.pop(),m):e,ab(s,m)});function ub(s){var f=N(s);return f.__chain__=!0,f}o(ub,"chain");function eM(s,f){return f(s),s}o(eM,"tap");function Eg(s,f){return f(s)}o(Eg,"thru");var tM=ts(function(s){var f=s.length,m=f?s[0]:0,x=this.__wrapped__,E=o(function(P){return Nd(P,s)},"interceptor");return f>1||this.__actions__.length||!(x instanceof dt)||!S(m)?this.thru(E):(x=x.slice(m,+m+(f?1:0)),x.__actions__.push({func:Eg,args:[E],thisArg:e}),new An(x,this.__chain__).thru(function(P){return f&&!P.length&&P.push(e),P}))});function rM(){return ub(this)}o(rM,"wrapperChain");function nM(){return new An(this.value(),this.__chain__)}o(nM,"wrapperCommit");function iM(){this.__values__===e&&(this.__values__=bb(this.value()));var s=this.__index__>=this.__values__.length,f=s?e:this.__values__[this.__index__++];return{done:s,value:f}}o(iM,"wrapperNext");function oM(){return this}o(oM,"wrapperToIterator");function sM(s){for(var f,m=this;m instanceof vc;){var x=bn(m);x.__index__=0,x.__values__=e,f?E.__wrapped__=x:f=x;var E=x;m=m.__wrapped__}return E.__wrapped__=s,f}o(sM,"wrapperPlant");function lM(){var s=this.__wrapped__;if(s instanceof dt){var f=s;return this.__actions__.length&&(f=new dt(this)),f=f.reverse(),f.__actions__.push({func:Eg,args:[ow],thisArg:e}),new An(f,this.__chain__)}return this.thru(ow)}o(lM,"wrapperReverse");function aM(){return ag(this.__wrapped__,this.__actions__)}o(aM,"wrapperValue");var uM=Ic(function(s,f,m){et.call(s,m)?++s[m]:yo(s,m,1)});function fM(s,f,m){var x=ot(s)?Mu:Cc;return m&&b(s,f,m)&&(f=e),x(s,Be(f,3))}o(fM,"every");function cM(s,f){var m=ot(s)?Vt:Ld;return m(s,Be(f,3))}o(cM,"filter");var pM=$d(zc),dM=$d(ib);function hM(s,f){return rn(Tg(s,f),1)}o(hM,"flatMap");function mM(s,f){return rn(Tg(s,f),Ke)}o(mM,"flatMapDeep");function gM(s,f,m){return m=m===e?1:lt(m),rn(Tg(s,f),m)}o(gM,"flatMapDepth");function fb(s,f){var m=ot(s)?jn:di;return m(s,Be(f,3))}o(fb,"forEach");function cb(s,f){var m=ot(s)?dd:Sc;return m(s,Be(f,3))}o(cb,"forEachRight");var vM=Ic(function(s,f,m){et.call(s,m)?s[m].push(f):yo(s,m,[f])});function yM(s,f,m,x){s=Mi(s)?s:jc(s),m=m&&!x?lt(m):0;var E=s.length;return m<0&&(m=sr(E+m,0)),Og(s)?m<=E&&s.indexOf(f,m)>-1:!!E&&Go(s,f,m)>-1}o(yM,"includes");var wM=st(function(s,f,m){var x=-1,E=typeof f=="function",P=Mi(s)?Q(s.length):[];return di(s,function(F){P[++x]=E?Ur(f,F,m):wa(F,f,m)}),P}),xM=Ic(function(s,f,m){yo(s,m,f)});function Tg(s,f){var m=ot(s)?yt:_a;return m(s,Be(f,3))}o(Tg,"map");function SM(s,f,m,x){return s==null?[]:(ot(f)||(f=f==null?[]:[f]),m=x?e:m,ot(m)||(m=m==null?[]:[m]),yn(s,f,m))}o(SM,"orderBy");var CM=Ic(function(s,f,m){s[m?0:1].push(f)},function(){return[[],[]]});function bM(s,f,m){var x=ot(s)?Au:Fu,E=arguments.length<3;return x(s,Be(f,4),m,E,di)}o(bM,"reduce");function _M(s,f,m){var x=ot(s)?hd:Fu,E=arguments.length<3;return x(s,Be(f,4),m,E,Sc)}o(_M,"reduceRight");function EM(s,f){var m=ot(s)?Vt:Ld;return m(s,Pg(Be(f,3)))}o(EM,"reject");function TM(s){var f=ot(s)?wc:Jy;return f(s)}o(TM,"sample");function kM(s,f,m){(m?b(s,f,m):f===e)?f=1:f=lt(f);var x=ot(s)?As:Fs;return x(s,f)}o(kM,"sampleSize");function NM(s){var f=ot(s)?Km:Jo;return f(s)}o(NM,"shuffle");function PM(s){if(s==null)return 0;if(Mi(s))return Og(s)?wr(s):s.length;var f=xn(s);return f==Yt||f==Jt?s.size:Nc(s).length}o(PM,"size");function LM(s,f,m){var x=ot(s)?Vo:ew;return m&&b(s,f,m)&&(f=e),x(s,Be(f,3))}o(LM,"some");var OM=st(function(s,f){if(s==null)return[];var m=f.length;return m>1&&b(s,f[0],f[1])?f=[]:m>2&&b(f[0],f[1],f[2])&&(f=[f[0]]),yn(s,rn(f,1),[])}),kg=Iy||function(){return qt.Date.now()};function MM(s,f){if(typeof f!="function")throw new Kn(d);return s=lt(s),function(){if(--s<1)return f.apply(this,arguments)}}o(MM,"after");function pb(s,f,m){return f=m?e:f,f=s&&f==null?s.length:f,Oi(s,se,e,e,e,e,f)}o(pb,"ary");function db(s,f){var m;if(typeof f!="function")throw new Kn(d);return s=lt(s),function(){return--s>0&&(m=f.apply(this,arguments)),s<=1&&(f=e),m}}o(db,"before");var lw=st(function(s,f,m){var x=J;if(m.length){var E=Vi(m,Oa(lw));x|=G}return Oi(s,x,f,m,E)}),hb=st(function(s,f,m){var x=J|Z;if(m.length){var E=Vi(m,Oa(hb));x|=G}return Oi(f,x,s,m,E)});function mb(s,f,m){f=m?e:f;var x=Oi(s,A,e,e,e,e,e,f);return x.placeholder=mb.placeholder,x}o(mb,"curry");function gb(s,f,m){f=m?e:f;var x=Oi(s,I,e,e,e,e,e,f);return x.placeholder=gb.placeholder,x}o(gb,"curryRight");function vb(s,f,m){var x,E,P,F,z,Y,le=0,ae=!1,ce=!1,Pe=!0;if(typeof s!="function")throw new Kn(d);f=So(f)||0,Sr(m)&&(ae=!!m.leading,ce="maxWait"in m,P=ce?sr(So(m.maxWait)||0,f):P,Pe="trailing"in m?!!m.trailing:Pe);function Fe(Ir){var is=x,kl=E;return x=E=e,le=Ir,F=s.apply(kl,is),F}o(Fe,"invokeFunc");function $e(Ir){return le=Ir,z=At(ht,f),ae?Fe(Ir):F}o($e,"leadingEdge");function ft(Ir){var is=Ir-Y,kl=Ir-le,Ib=f-is;return ce?Zr(Ib,P-kl):Ib}o(ft,"remainingWait");function je(Ir){var is=Ir-Y,kl=Ir-le;return Y===e||is>=f||is<0||ce&&kl>=P}o(je,"shouldInvoke");function ht(){var Ir=kg();if(je(Ir))return gt(Ir);z=At(ht,ft(Ir))}o(ht,"timerExpired");function gt(Ir){return z=e,Pe&&x?Fe(Ir):(x=E=e,F)}o(gt,"trailingEdge");function Xi(){z!==e&&Ta(z),le=0,x=Y=E=z=e}o(Xi,"cancel");function gi(){return z===e?F:gt(kg())}o(gi,"flush");function Qi(){var Ir=kg(),is=je(Ir);if(x=arguments,E=this,Y=Ir,is){if(z===e)return $e(Y);if(ce)return Ta(z),z=At(ht,f),Fe(Y)}return z===e&&(z=At(ht,f)),F}return o(Qi,"debounced"),Qi.cancel=Xi,Qi.flush=gi,Qi}o(vb,"debounce");var AM=st(function(s,f){return Xm(s,1,f)}),DM=st(function(s,f,m){return Xm(s,So(f)||0,m)});function RM(s){return Oi(s,pe)}o(RM,"flip");function Ng(s,f){if(typeof s!="function"||f!=null&&typeof f!="function")throw new Kn(d);var m=o(function(){var x=arguments,E=f?f.apply(this,x):x[0],P=m.cache;if(P.has(E))return P.get(E);var F=s.apply(this,x);return m.cache=P.set(E,F)||P,F},"memoized");return m.cache=new(Ng.Cache||xr),m}o(Ng,"memoize"),Ng.Cache=xr;function Pg(s){if(typeof s!="function")throw new Kn(d);return function(){var f=arguments;switch(f.length){case 0:return!s.call(this);case 1:return!s.call(this,f[0]);case 2:return!s.call(this,f[0],f[1]);case 3:return!s.call(this,f[0],f[1],f[2])}return!s.apply(this,f)}}o(Pg,"negate");function IM(s){return db(2,s)}o(IM,"once");var FM=tw(function(s,f){f=f.length==1&&ot(f[0])?yt(f[0],zr(Be())):yt(rn(f,1),zr(Be()));var m=f.length;return st(function(x){for(var E=-1,P=Zr(x.length,m);++E=f}),pf=xa(function(){return arguments}())?xa:function(s){return _r(s)&&et.call(s,"callee")&&!hc.call(s,"callee")},ot=Q.isArray,ZM=ta?zr(ta):Xy;function Mi(s){return s!=null&&Lg(s.length)&&!El(s)}o(Mi,"isArrayLike");function Rr(s){return _r(s)&&Mi(s)}o(Rr,"isArrayLikeObject");function JM(s){return s===!0||s===!1||_r(s)&&jr(s)==zt}o(JM,"isBoolean");var Ra=qu||ww,eA=Ou?zr(Ou):Sa;function tA(s){return _r(s)&&s.nodeType===1&&!Gd(s)}o(tA,"isElement");function rA(s){if(s==null)return!0;if(Mi(s)&&(ot(s)||typeof s=="string"||typeof s.splice=="function"||Ra(s)||$c(s)||pf(s)))return!s.length;var f=xn(s);if(f==Yt||f==Jt)return!s.size;if(te(s))return!Nc(s).length;for(var m in s)if(et.call(s,m))return!1;return!0}o(rA,"isEmpty");function nA(s,f){return Ca(s,f)}o(nA,"isEqual");function iA(s,f,m){m=typeof m=="function"?m:e;var x=m?m(s,f):e;return x===e?Ca(s,f,e,m):!!x}o(iA,"isEqualWith");function uw(s){if(!_r(s))return!1;var f=jr(s);return f==rt||f==ie||typeof s.message=="string"&&typeof s.name=="string"&&!Gd(s)}o(uw,"isError");function oA(s){return typeof s=="number"&&Wm(s)}o(oA,"isFinite");function El(s){if(!Sr(s))return!1;var f=jr(s);return f==Lr||f==Gt||f==Pr||f==si}o(El,"isFunction");function wb(s){return typeof s=="number"&&s==lt(s)}o(wb,"isInteger");function Lg(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=Ge}o(Lg,"isLength");function Sr(s){var f=typeof s;return s!=null&&(f=="object"||f=="function")}o(Sr,"isObject");function _r(s){return s!=null&&typeof s=="object"}o(_r,"isObjectLike");var xb=nt?zr(nt):eg;function sA(s,f){return s===f||wl(s,f,Ma(f))}o(sA,"isMatch");function lA(s,f,m){return m=typeof m=="function"?m:e,wl(s,f,Ma(f),m)}o(lA,"isMatchWith");function aA(s){return Sb(s)&&s!=+s}o(aA,"isNaN");function uA(s){if($(s))throw new Qe(l);return ba(s)}o(uA,"isNative");function fA(s){return s===null}o(fA,"isNull");function cA(s){return s==null}o(cA,"isNil");function Sb(s){return typeof s=="number"||_r(s)&&jr(s)==Se}o(Sb,"isNumber");function Gd(s){if(!_r(s)||jr(s)!=fn)return!1;var f=ca(s);if(f===null)return!0;var m=et.call(f,"constructor")&&f.constructor;return typeof m=="function"&&m instanceof m&&ho.call(m)==Dy}o(Gd,"isPlainObject");var fw=uc?zr(uc):ef;function pA(s){return wb(s)&&s>=-Ge&&s<=Ge}o(pA,"isSafeInteger");var Cb=fi?zr(fi):tf;function Og(s){return typeof s=="string"||!ot(s)&&_r(s)&&jr(s)==gr}o(Og,"isString");function Yi(s){return typeof s=="symbol"||_r(s)&&jr(s)==pt}o(Yi,"isSymbol");var $c=ll?zr(ll):tg;function dA(s){return s===e}o(dA,"isUndefined");function hA(s){return _r(s)&&xn(s)==Cr}o(hA,"isWeakMap");function mA(s){return _r(s)&&jr(s)==Ui}o(mA,"isWeakSet");var gA=Mt(Is),vA=Mt(function(s,f){return s<=f});function bb(s){if(!s)return[];if(Mi(s))return Og(s)?Kt(s):qr(s);if(Es&&s[Es])return pc(s[Es]());var f=xn(s),m=f==Yt?aa:f==Jt?w:jc;return m(s)}o(bb,"toArray");function Tl(s){if(!s)return s===0?s:0;if(s=So(s),s===Ke||s===-Ke){var f=s<0?-1:1;return f*Xe}return s===s?s:0}o(Tl,"toFinite");function lt(s){var f=Tl(s),m=f%1;return f===f?m?f-m:f:0}o(lt,"toInteger");function _b(s){return s?vl(lt(s),0,ct):0}o(_b,"toLength");function So(s){if(typeof s=="number")return s;if(Yi(s))return nr;if(Sr(s)){var f=typeof s.valueOf=="function"?s.valueOf():s;s=Sr(f)?f+"":f}if(typeof s!="string")return s===0?s:+s;s=Ss(s);var m=Wo.test(s);return m||Uo.test(s)?ye(s.slice(2),m?2:8):xu.test(s)?nr:+s}o(So,"toNumber");function Eb(s){return Gn(s,Ai(s))}o(Eb,"toPlainObject");function yA(s){return s?vl(lt(s),-Ge,Ge):s===0?s:0}o(yA,"toSafeInteger");function Dt(s){return s==null?"":wn(s)}o(Dt,"toString");var wA=ka(function(s,f){if(te(f)||Mi(f)){Gn(f,En(f),s);return}for(var m in f)et.call(f,m)&&Qu(s,m,f[m])}),Tb=ka(function(s,f){Gn(f,Ai(f),s)}),Mg=ka(function(s,f,m,x){Gn(f,Ai(f),s,x)}),xA=ka(function(s,f,m,x){Gn(f,En(f),s,x)}),SA=ts(Nd);function CA(s,f){var m=go(s);return f==null?m:kd(m,f)}o(CA,"create");var bA=st(function(s,f){s=mt(s);var m=-1,x=f.length,E=x>2?f[2]:e;for(E&&b(f[0],f[1],E)&&(x=1);++m1),P}),Gn(s,Hc(s),m),x&&(m=Dn(m,k|O|j,Sg));for(var E=f.length;E--;)of(m,f[E]);return m});function UA(s,f){return Nb(s,Pg(Be(f)))}o(UA,"omitBy");var zA=ts(function(s,f){return s==null?{}:og(s,f)});function Nb(s,f){if(s==null)return{};var m=yt(Hc(s),function(x){return[x]});return f=Be(f),sg(s,m,function(x,E){return f(x,E[0])})}o(Nb,"pickBy");function $A(s,f,m){f=Gi(f,s);var x=-1,E=f.length;for(E||(E=1,s=e);++xf){var x=s;s=f,f=x}if(m||s%1||f%1){var E=Ns();return Zr(s+E*(f-s+Lu("1e-"+((E+"").length-1))),f)}return Lc(s,f)}o(JA,"random");var e2=Na(function(s,f,m){return f=f.toLowerCase(),s+(m?Ob(f):f)});function Ob(s){return dw(Dt(s).toLowerCase())}o(Ob,"capitalize");function Mb(s){return s=Dt(s),s&&s.replace(ec,Wu).replace(sc,"")}o(Mb,"deburr");function t2(s,f,m){s=Dt(s),f=wn(f);var x=s.length;m=m===e?x:vl(lt(m),0,x);var E=m;return m-=f.length,m>=0&&s.slice(m,E)==f}o(t2,"endsWith");function r2(s){return s=Dt(s),s&&ds.test(s)?s.replace(or,gd):s}o(r2,"escape");function n2(s){return s=Dt(s),s&&Qf.test(s)?s.replace(tl,"\\$&"):s}o(n2,"escapeRegExp");var i2=Na(function(s,f,m){return s+(m?"-":"")+f.toLowerCase()}),o2=Na(function(s,f,m){return s+(m?" ":"")+f.toLowerCase()}),s2=vg("toLowerCase");function l2(s,f,m){s=Dt(s),f=lt(f);var x=f?wr(s):0;if(!f||x>=f)return s;var E=(f-x)/2;return Fc(ha(E),m)+s+Fc(da(E),m)}o(l2,"pad");function a2(s,f,m){s=Dt(s),f=lt(f);var x=f?wr(s):0;return f&&x>>0,m?(s=Dt(s),s&&(typeof f=="string"||f!=null&&!fw(f))&&(f=wn(f),!f&&qn(s))?Bs(Kt(s),0,m):s.split(f,m)):[]}o(h2,"split");var m2=Na(function(s,f,m){return s+(m?" ":"")+dw(f)});function g2(s,f,m){return s=Dt(s),m=m==null?0:vl(lt(m),0,s.length),f=wn(f),s.slice(m,m+f.length)==f}o(g2,"startsWith");function v2(s,f,m){var x=N.templateSettings;m&&b(s,f,m)&&(f=e),s=Dt(s),f=Mg({},f,x,Bc);var E=Mg({},f.imports,x.imports,Bc),P=En(E),F=sa(E,P),z,Y,le=0,ae=f.interpolate||jt,ce="__p += '",Pe=Cs((f.escape||jt).source+"|"+ae.source+"|"+(ae===el?Jf:jt).source+"|"+(f.evaluate||jt).source+"|$","g"),Fe="//# sourceURL="+(et.call(f,"sourceURL")?(f.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Pu+"]")+` +`;s.replace(Pe,function(je,ht,gt,Xi,gi,Qi){return gt||(gt=Xi),ce+=s.slice(le,Qi).replace(Me,Uu),ht&&(z=!0,ce+=`' + __e(`+ht+`) + '`),gi&&(Y=!0,ce+=`'; `+gi+`; @@ -25,49 +25,49 @@ __p += '`),gt&&(ce+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+ce+`return __p -}`;var ft=Rb(function(){return bt(L,Fe+"return "+ce).apply(e,F)});if(ft.source=ce,fw(ft))throw ft;return ft}o(v2,"template");function y2(s){return Dt(s).toLowerCase()}o(y2,"toLower");function w2(s){return Dt(s).toUpperCase()}o(w2,"toUpper");function x2(s,f,m){if(s=Dt(s),s&&(m||f===e))return Ss(s);if(!s||!(f=wn(f)))return s;var x=Kt(s),_=Kt(f),L=qi(x,_),F=al(x,_)+1;return Bs(x,L,F).join("")}o(x2,"trim");function S2(s,f,m){if(s=Dt(s),s&&(m||f===e))return s.slice(0,gn(s)+1);if(!s||!(f=wn(f)))return s;var x=Kt(s),_=al(x,Kt(f))+1;return Bs(x,0,_).join("")}o(S2,"trimEnd");function C2(s,f,m){if(s=Dt(s),s&&(m||f===e))return s.replace(rl,"");if(!s||!(f=wn(f)))return s;var x=Kt(s),_=qi(x,Kt(f));return Bs(x,_).join("")}o(C2,"trimStart");function b2(s,f){var m=me,x=xe;if(Sr(f)){var _="separator"in f?f.separator:_;m="length"in f?lt(f.length):m,x="omission"in f?wn(f.omission):x}s=Dt(s);var L=s.length;if(qn(s)){var F=Kt(s);L=F.length}if(m>=L)return s;var z=m-wr(x);if(z<1)return x;var Y=F?Bs(F,0,z).join(""):s.slice(0,z);if(_===e)return Y+x;if(F&&(z+=Y.length-z),cw(_)){if(s.slice(z).search(_)){var le,ae=Y;for(_.global||(_=Cs(_.source,Dt(nl.exec(_))+"g")),_.lastIndex=0;le=_.exec(ae);)var ce=le.index;Y=Y.slice(0,ce===e?z:ce)}}else if(s.indexOf(wn(_),z)!=z){var Le=Y.lastIndexOf(_);Le>-1&&(Y=Y.slice(0,Le))}return Y+x}o(b2,"truncate");function E2(s){return s=Dt(s),s&&li.test(s)?s.replace(Wr,ci):s}o(E2,"unescape");var _2=Na(function(s,f,m){return s+(m?" ":"")+f.toUpperCase()}),hw=yg("toUpperCase");function Db(s,f,m){return s=Dt(s),f=m?e:f,f===e?Ti(s)?Vn(s):Du(s):s.match(f)||[]}o(Db,"words");var Rb=st(function(s,f){try{return Ur(s,e,f)}catch(m){return fw(m)?m:new Qe(m)}}),T2=ts(function(s,f){return jn(f,function(m){m=Lt(m),yo(s,m,aw(s[m],s))}),s});function k2(s){var f=s==null?0:s.length,m=Be();return s=f?yt(s,function(x){if(typeof x[1]!="function")throw new Kn(d);return[m(x[0]),x[1]]}):[],st(function(x){for(var _=-1;++_Ge)return[];var m=ct,x=Zr(s,ct);f=Be(f),s-=ct;for(var _=Yo(x,f);++m0||f<0)?new dt(m):(s<0?m=m.takeRight(-s):s&&(m=m.drop(s)),f!==e&&(f=lt(f),m=f<0?m.dropRight(-f):m.take(f-s)),m)},dt.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},dt.prototype.toArray=function(){return this.take(ct)},hi(dt.prototype,function(s,f){var m=/^(?:filter|find|map|reject)|While$/.test(f),x=/^(?:head|last)$/.test(f),_=N[x?"take"+(f=="last"?"Right":""):f],L=x||/^find/.test(f);!_||(N.prototype[f]=function(){var F=this.__wrapped__,z=x?[1]:arguments,Y=F instanceof dt,le=z[0],ae=Y||ot(F),ce=o(function(ht){var gt=_.apply(N,$i([ht],z));return x&&Le?gt[0]:gt},"interceptor");ae&&m&&typeof le=="function"&&le.length!=1&&(Y=ae=!1);var Le=this.__chain__,Fe=!!this.__actions__.length,$e=L&&!Le,ft=Y&&!Fe;if(!L&&ae){F=ft?F:new dt(this);var je=s.apply(F,z);return je.__actions__.push({func:Tg,args:[ce],thisArg:e}),new An(je,Le)}return $e&&ft?s.apply(this,z):(je=this.thru(ce),$e?x?je.value()[0]:je.value():je)})}),jn(["pop","push","shift","sort","splice","unshift"],function(s){var f=fa[s],m=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",x=/^(?:pop|shift)$/.test(s);N.prototype[s]=function(){var _=arguments;if(x&&!this.__chain__){var L=this.value();return f.apply(ot(L)?L:[],_)}return this[m](function(F){return f.apply(ot(F)?F:[],_)})}}),hi(dt.prototype,function(s,f){var m=N[f];if(m){var x=m.name+"";et.call(ga,x)||(ga[x]=[]),ga[x].push({name:f,func:m})}}),ga[sf(e,Z).name]=[{name:"wrapper",func:e}],dt.prototype.clone=jy,dt.prototype.reverse=qy,dt.prototype.value=yd,N.prototype.at=tM,N.prototype.chain=rM,N.prototype.commit=nM,N.prototype.next=iM,N.prototype.plant=sM,N.prototype.reverse=lM,N.prototype.toJSON=N.prototype.valueOf=N.prototype.value=aM,N.prototype.first=N.prototype.head,_s&&(N.prototype[_s]=oM),N},"runInContext"),vn=zu();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(qt._=vn,define(function(){return vn})):hn?((hn.exports=vn)._=vn,ea._=vn):qt._=vn}).call(Np)});var jk=Ue((iS,oS)=>{(function(e,t){typeof iS=="object"&&typeof oS!="undefined"?oS.exports=t():typeof define=="function"&&define.amd?define(t):e.stable=t()})(iS,function(){"use strict";var e=o(function(l,d){return t(l.slice(),d)},"stable");e.inplace=function(l,d){var h=t(l,d);return h!==l&&n(h,null,l.length,l),l};function t(l,d){typeof d!="function"&&(d=o(function(k,O){return String(k).localeCompare(O)},"comp"));var h=l.length;if(h<=1)return l;for(var c=new Array(h),v=1;vv&&(j=v),B>v&&(B=v),X=O,J=j;;)if(X{(function(){"use strict";var e={}.hasOwnProperty;function t(){for(var n=[],l=0;l{(function(e,t){typeof IS=="object"&&typeof FS!="undefined"?FS.exports=t():typeof define=="function"&&define.amd?define(t):(e=e||self,e.CodeMirror=t())})(IS,function(){"use strict";var e=navigator.userAgent,t=navigator.platform,n=/gecko\/\d/i.test(e),l=/MSIE \d/.test(e),d=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),h=/Edge\/(\d+)/.exec(e),c=l||d||h,v=c&&(l?document.documentMode||6:+(h||d)[1]),C=!h&&/WebKit\//.test(e),k=C&&/Qt\/\d+\.\d+/.test(e),O=!h&&/Chrome\//.test(e),j=/Opera\//.test(e),B=/Apple Computer/.test(navigator.vendor),X=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),J=/PhantomJS/.test(e),Z=B&&(/Mobile\/\w+/.test(e)||navigator.maxTouchPoints>2),R=/Android/.test(e),A=Z||R||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),I=Z||/Mac/.test(t),G=/\bCrOS\b/.test(e),K=/win/i.test(t),se=j&&e.match(/Version\/(\d*\.\d*)/);se&&(se=Number(se[1])),se&&se>=15&&(j=!1,C=!0);var ne=I&&(k||j&&(se==null||se<12.11)),pe=n||c&&v>=9;function me(r){return new RegExp("(^|\\s)"+r+"(?:$|\\s)\\s*")}o(me,"classTest");var xe=o(function(r,i){var u=r.className,a=me(i).exec(u);if(a){var p=u.slice(a.index+a[0].length);r.className=u.slice(0,a.index)+(p?a[1]+p:"")}},"rmClass");function Ve(r){for(var i=r.childNodes.length;i>0;--i)r.removeChild(r.firstChild);return r}o(Ve,"removeChildren");function tt(r,i){return Ve(r).appendChild(i)}o(tt,"removeChildrenAndAdd");function _e(r,i,u,a){var p=document.createElement(r);if(u&&(p.className=u),a&&(p.style.cssText=a),typeof i=="string")p.appendChild(document.createTextNode(i));else if(i)for(var g=0;g=i)return y+(i-g);y+=S-g,y+=u-y%u,g=S+1}}o(_t,"countColumn");var Ct=o(function(){this.id=null,this.f=null,this.time=0,this.handler=Hr(this.onTimeout,this)},"Delayed");Ct.prototype.onTimeout=function(r){r.id=0,r.time<=+new Date?r.f():setTimeout(r.handler,r.time-+new Date)},Ct.prototype.set=function(r,i){this.f=i;var u=+new Date+r;(!this.id||u=i)return a+Math.min(y,i-p);if(p+=g-a,p+=u-p%u,a=g+1,p>=i)return a}}o(Pr,"findColumn");var Gt=[""];function Yt(r){for(;Gt.length<=r;)Gt.push(Se(Gt)+" ");return Gt[r]}o(Yt,"spaceStr");function Se(r){return r[r.length-1]}o(Se,"lst");function Or(r,i){for(var u=[],a=0;a"\x80"&&(r.toUpperCase()!=r.toLowerCase()||cn.test(r))}o(Jt,"isWordCharBasic");function gr(r,i){return i?i.source.indexOf("\\w")>-1&&Jt(r)?!0:i.test(r):Jt(r)}o(gr,"isWordChar");function pt(r){for(var i in r)if(r.hasOwnProperty(i)&&r[i])return!1;return!0}o(pt,"isEmpty");var Ho=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function Cr(r){return r.charCodeAt(0)>=768&&Ho.test(r)}o(Cr,"isExtendingChar");function Ui(r,i,u){for(;(u<0?i>0:iu?-1:1;;){if(i==u)return i;var p=(i+u)/2,g=a<0?Math.ceil(p):Math.floor(p);if(g==i)return r(g)?i:u;r(g)?u=g:i=g+a}}o(pn,"findFirst");function zn(r,i,u,a){if(!r)return a(i,u,"ltr",0);for(var p=!1,g=0;gi||i==u&&y.to==i)&&(a(Math.max(y.from,i),Math.min(y.to,u),y.level==1?"rtl":"ltr",g),p=!0)}p||a(i,u,"ltr")}o(zn,"iterateBidiSections");var Si=null;function Ci(r,i,u){var a;Si=null;for(var p=0;pi)return p;g.to==i&&(g.from!=g.to&&u=="before"?a=p:Si=p),g.from==i&&(g.from!=g.to&&u!="before"?a=p:Si=p)}return a??Si}o(Ci,"getBidiPartAt");var $n=function(){var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",i="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function u(E){return E<=247?r.charAt(E):1424<=E&&E<=1524?"R":1536<=E&&E<=1785?i.charAt(E-1536):1774<=E&&E<=2220?"r":8192<=E&&E<=8203?"w":E==8204?"b":"L"}o(u,"charType");var a=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,p=/[stwN]/,g=/[LRr]/,y=/[Lb1n]/,S=/[1n]/;function b(E,M,D){this.level=E,this.from=M,this.to=D}return o(b,"BidiSpan"),function(E,M){var D=M=="ltr"?"L":"R";if(E.length==0||M=="ltr"&&!a.test(E))return!1;for(var V=E.length,$=[],te=0;te-1&&(a[i]=p.slice(0,g).concat(p.slice(g+1)))}}}o(he,"off");function Te(r,i){var u=ee(r,i);if(!!u.length)for(var a=Array.prototype.slice.call(arguments,2),p=0;p0}o(Ft,"hasHandler");function Wr(r){r.prototype.on=function(i,u){H(this,i,u)},r.prototype.off=function(i,u){he(this,i,u)}}o(Wr,"eventMixin");function or(r){r.preventDefault?r.preventDefault():r.returnValue=!1}o(or,"e_preventDefault");function li(r){r.stopPropagation?r.stopPropagation():r.cancelBubble=!0}o(li,"e_stopPropagation");function ds(r){return r.defaultPrevented!=null?r.defaultPrevented:r.returnValue==!1}o(ds,"e_defaultPrevented");function lo(r){or(r),li(r)}o(lo,"e_stop");function bi(r){return r.target||r.srcElement}o(bi,"e_target");function el(r){var i=r.which;return i==null&&(r.button&1?i=1:r.button&2?i=3:r.button&4&&(i=2)),I&&r.ctrlKey&&i==1&&(i=3),i}o(el,"e_button");var hs=function(){if(c&&v<9)return!1;var r=_e("div");return"draggable"in r||"dragDrop"in r}(),dn;function id(r){if(dn==null){var i=_e("span","\u200B");tt(r,_e("span",[i,document.createTextNode("x")])),r.firstChild.offsetHeight!=0&&(dn=i.offsetWidth<=1&&i.offsetHeight>2&&!(c&&v<8))}var u=dn?_e("span","\u200B"):_e("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return u.setAttribute("cm-text",""),u}o(id,"zeroWidthElement");var tl;function Qf(r){if(tl!=null)return tl;var i=tt(r,document.createTextNode("A\u062EA")),u=We(i,0,1).getBoundingClientRect(),a=We(i,1,2).getBoundingClientRect();return Ve(r),!u||u.left==u.right?!1:tl=a.right-u.right<3}o(Qf,"hasBadBidiRects");var rl=` +}`;var ft=Db(function(){return bt(P,Fe+"return "+ce).apply(e,F)});if(ft.source=ce,uw(ft))throw ft;return ft}o(v2,"template");function y2(s){return Dt(s).toLowerCase()}o(y2,"toLower");function w2(s){return Dt(s).toUpperCase()}o(w2,"toUpper");function x2(s,f,m){if(s=Dt(s),s&&(m||f===e))return Ss(s);if(!s||!(f=wn(f)))return s;var x=Kt(s),E=Kt(f),P=qi(x,E),F=al(x,E)+1;return Bs(x,P,F).join("")}o(x2,"trim");function S2(s,f,m){if(s=Dt(s),s&&(m||f===e))return s.slice(0,gn(s)+1);if(!s||!(f=wn(f)))return s;var x=Kt(s),E=al(x,Kt(f))+1;return Bs(x,0,E).join("")}o(S2,"trimEnd");function C2(s,f,m){if(s=Dt(s),s&&(m||f===e))return s.replace(rl,"");if(!s||!(f=wn(f)))return s;var x=Kt(s),E=qi(x,Kt(f));return Bs(x,E).join("")}o(C2,"trimStart");function b2(s,f){var m=me,x=xe;if(Sr(f)){var E="separator"in f?f.separator:E;m="length"in f?lt(f.length):m,x="omission"in f?wn(f.omission):x}s=Dt(s);var P=s.length;if(qn(s)){var F=Kt(s);P=F.length}if(m>=P)return s;var z=m-wr(x);if(z<1)return x;var Y=F?Bs(F,0,z).join(""):s.slice(0,z);if(E===e)return Y+x;if(F&&(z+=Y.length-z),fw(E)){if(s.slice(z).search(E)){var le,ae=Y;for(E.global||(E=Cs(E.source,Dt(nl.exec(E))+"g")),E.lastIndex=0;le=E.exec(ae);)var ce=le.index;Y=Y.slice(0,ce===e?z:ce)}}else if(s.indexOf(wn(E),z)!=z){var Pe=Y.lastIndexOf(E);Pe>-1&&(Y=Y.slice(0,Pe))}return Y+x}o(b2,"truncate");function _2(s){return s=Dt(s),s&&li.test(s)?s.replace(Wr,ci):s}o(_2,"unescape");var E2=Na(function(s,f,m){return s+(m?" ":"")+f.toUpperCase()}),dw=vg("toUpperCase");function Ab(s,f,m){return s=Dt(s),f=m?e:f,f===e?Ti(s)?Vn(s):Du(s):s.match(f)||[]}o(Ab,"words");var Db=st(function(s,f){try{return Ur(s,e,f)}catch(m){return uw(m)?m:new Qe(m)}}),T2=ts(function(s,f){return jn(f,function(m){m=Pt(m),yo(s,m,lw(s[m],s))}),s});function k2(s){var f=s==null?0:s.length,m=Be();return s=f?yt(s,function(x){if(typeof x[1]!="function")throw new Kn(d);return[m(x[0]),x[1]]}):[],st(function(x){for(var E=-1;++EGe)return[];var m=ct,x=Zr(s,ct);f=Be(f),s-=ct;for(var E=Yo(x,f);++m0||f<0)?new dt(m):(s<0?m=m.takeRight(-s):s&&(m=m.drop(s)),f!==e&&(f=lt(f),m=f<0?m.dropRight(-f):m.take(f-s)),m)},dt.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},dt.prototype.toArray=function(){return this.take(ct)},hi(dt.prototype,function(s,f){var m=/^(?:filter|find|map|reject)|While$/.test(f),x=/^(?:head|last)$/.test(f),E=N[x?"take"+(f=="last"?"Right":""):f],P=x||/^find/.test(f);!E||(N.prototype[f]=function(){var F=this.__wrapped__,z=x?[1]:arguments,Y=F instanceof dt,le=z[0],ae=Y||ot(F),ce=o(function(ht){var gt=E.apply(N,$i([ht],z));return x&&Pe?gt[0]:gt},"interceptor");ae&&m&&typeof le=="function"&&le.length!=1&&(Y=ae=!1);var Pe=this.__chain__,Fe=!!this.__actions__.length,$e=P&&!Pe,ft=Y&&!Fe;if(!P&&ae){F=ft?F:new dt(this);var je=s.apply(F,z);return je.__actions__.push({func:Eg,args:[ce],thisArg:e}),new An(je,Pe)}return $e&&ft?s.apply(this,z):(je=this.thru(ce),$e?x?je.value()[0]:je.value():je)})}),jn(["pop","push","shift","sort","splice","unshift"],function(s){var f=fa[s],m=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",x=/^(?:pop|shift)$/.test(s);N.prototype[s]=function(){var E=arguments;if(x&&!this.__chain__){var P=this.value();return f.apply(ot(P)?P:[],E)}return this[m](function(F){return f.apply(ot(F)?F:[],E)})}}),hi(dt.prototype,function(s,f){var m=N[f];if(m){var x=m.name+"";et.call(ga,x)||(ga[x]=[]),ga[x].push({name:f,func:m})}}),ga[sf(e,Z).name]=[{name:"wrapper",func:e}],dt.prototype.clone=$y,dt.prototype.reverse=jy,dt.prototype.value=yd,N.prototype.at=tM,N.prototype.chain=rM,N.prototype.commit=nM,N.prototype.next=iM,N.prototype.plant=sM,N.prototype.reverse=lM,N.prototype.toJSON=N.prototype.valueOf=N.prototype.value=aM,N.prototype.first=N.prototype.head,Es&&(N.prototype[Es]=oM),N},"runInContext"),vn=zu();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(qt._=vn,define(function(){return vn})):hn?((hn.exports=vn)._=vn,ea._=vn):qt._=vn}).call(Np)});var $k=Ue((nS,iS)=>{(function(e,t){typeof nS=="object"&&typeof iS!="undefined"?iS.exports=t():typeof define=="function"&&define.amd?define(t):e.stable=t()})(nS,function(){"use strict";var e=o(function(l,d){return t(l.slice(),d)},"stable");e.inplace=function(l,d){var h=t(l,d);return h!==l&&n(h,null,l.length,l),l};function t(l,d){typeof d!="function"&&(d=o(function(k,O){return String(k).localeCompare(O)},"comp"));var h=l.length;if(h<=1)return l;for(var c=new Array(h),v=1;vv&&(j=v),B>v&&(B=v),X=O,J=j;;)if(X{(function(){"use strict";var e={}.hasOwnProperty;function t(){for(var n=[],l=0;l{(function(e,t){typeof RS=="object"&&typeof IS!="undefined"?IS.exports=t():typeof define=="function"&&define.amd?define(t):(e=e||self,e.CodeMirror=t())})(RS,function(){"use strict";var e=navigator.userAgent,t=navigator.platform,n=/gecko\/\d/i.test(e),l=/MSIE \d/.test(e),d=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),h=/Edge\/(\d+)/.exec(e),c=l||d||h,v=c&&(l?document.documentMode||6:+(h||d)[1]),C=!h&&/WebKit\//.test(e),k=C&&/Qt\/\d+\.\d+/.test(e),O=!h&&/Chrome\//.test(e),j=/Opera\//.test(e),B=/Apple Computer/.test(navigator.vendor),X=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),J=/PhantomJS/.test(e),Z=B&&(/Mobile\/\w+/.test(e)||navigator.maxTouchPoints>2),R=/Android/.test(e),A=Z||R||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),I=Z||/Mac/.test(t),G=/\bCrOS\b/.test(e),K=/win/i.test(t),se=j&&e.match(/Version\/(\d*\.\d*)/);se&&(se=Number(se[1])),se&&se>=15&&(j=!1,C=!0);var ne=I&&(k||j&&(se==null||se<12.11)),pe=n||c&&v>=9;function me(r){return new RegExp("(^|\\s)"+r+"(?:$|\\s)\\s*")}o(me,"classTest");var xe=o(function(r,i){var u=r.className,a=me(i).exec(u);if(a){var p=u.slice(a.index+a[0].length);r.className=u.slice(0,a.index)+(p?a[1]+p:"")}},"rmClass");function Ve(r){for(var i=r.childNodes.length;i>0;--i)r.removeChild(r.firstChild);return r}o(Ve,"removeChildren");function tt(r,i){return Ve(r).appendChild(i)}o(tt,"removeChildrenAndAdd");function Ee(r,i,u,a){var p=document.createElement(r);if(u&&(p.className=u),a&&(p.style.cssText=a),typeof i=="string")p.appendChild(document.createTextNode(i));else if(i)for(var g=0;g=i)return y+(i-g);y+=S-g,y+=u-y%u,g=S+1}}o(Et,"countColumn");var Ct=o(function(){this.id=null,this.f=null,this.time=0,this.handler=Hr(this.onTimeout,this)},"Delayed");Ct.prototype.onTimeout=function(r){r.id=0,r.time<=+new Date?r.f():setTimeout(r.handler,r.time-+new Date)},Ct.prototype.set=function(r,i){this.f=i;var u=+new Date+r;(!this.id||u=i)return a+Math.min(y,i-p);if(p+=g-a,p+=u-p%u,a=g+1,p>=i)return a}}o(Lr,"findColumn");var Gt=[""];function Yt(r){for(;Gt.length<=r;)Gt.push(Se(Gt)+" ");return Gt[r]}o(Yt,"spaceStr");function Se(r){return r[r.length-1]}o(Se,"lst");function Or(r,i){for(var u=[],a=0;a"\x80"&&(r.toUpperCase()!=r.toLowerCase()||cn.test(r))}o(Jt,"isWordCharBasic");function gr(r,i){return i?i.source.indexOf("\\w")>-1&&Jt(r)?!0:i.test(r):Jt(r)}o(gr,"isWordChar");function pt(r){for(var i in r)if(r.hasOwnProperty(i)&&r[i])return!1;return!0}o(pt,"isEmpty");var Ho=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function Cr(r){return r.charCodeAt(0)>=768&&Ho.test(r)}o(Cr,"isExtendingChar");function Ui(r,i,u){for(;(u<0?i>0:iu?-1:1;;){if(i==u)return i;var p=(i+u)/2,g=a<0?Math.ceil(p):Math.floor(p);if(g==i)return r(g)?i:u;r(g)?u=g:i=g+a}}o(pn,"findFirst");function zn(r,i,u,a){if(!r)return a(i,u,"ltr",0);for(var p=!1,g=0;gi||i==u&&y.to==i)&&(a(Math.max(y.from,i),Math.min(y.to,u),y.level==1?"rtl":"ltr",g),p=!0)}p||a(i,u,"ltr")}o(zn,"iterateBidiSections");var Si=null;function Ci(r,i,u){var a;Si=null;for(var p=0;pi)return p;g.to==i&&(g.from!=g.to&&u=="before"?a=p:Si=p),g.from==i&&(g.from!=g.to&&u!="before"?a=p:Si=p)}return a??Si}o(Ci,"getBidiPartAt");var $n=function(){var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",i="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function u(_){return _<=247?r.charAt(_):1424<=_&&_<=1524?"R":1536<=_&&_<=1785?i.charAt(_-1536):1774<=_&&_<=2220?"r":8192<=_&&_<=8203?"w":_==8204?"b":"L"}o(u,"charType");var a=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,p=/[stwN]/,g=/[LRr]/,y=/[Lb1n]/,S=/[1n]/;function b(_,M,D){this.level=_,this.from=M,this.to=D}return o(b,"BidiSpan"),function(_,M){var D=M=="ltr"?"L":"R";if(_.length==0||M=="ltr"&&!a.test(_))return!1;for(var V=_.length,$=[],te=0;te-1&&(a[i]=p.slice(0,g).concat(p.slice(g+1)))}}}o(he,"off");function Te(r,i){var u=ee(r,i);if(!!u.length)for(var a=Array.prototype.slice.call(arguments,2),p=0;p0}o(Ft,"hasHandler");function Wr(r){r.prototype.on=function(i,u){H(this,i,u)},r.prototype.off=function(i,u){he(this,i,u)}}o(Wr,"eventMixin");function or(r){r.preventDefault?r.preventDefault():r.returnValue=!1}o(or,"e_preventDefault");function li(r){r.stopPropagation?r.stopPropagation():r.cancelBubble=!0}o(li,"e_stopPropagation");function ds(r){return r.defaultPrevented!=null?r.defaultPrevented:r.returnValue==!1}o(ds,"e_defaultPrevented");function lo(r){or(r),li(r)}o(lo,"e_stop");function bi(r){return r.target||r.srcElement}o(bi,"e_target");function el(r){var i=r.which;return i==null&&(r.button&1?i=1:r.button&2?i=3:r.button&4&&(i=2)),I&&r.ctrlKey&&i==1&&(i=3),i}o(el,"e_button");var hs=function(){if(c&&v<9)return!1;var r=Ee("div");return"draggable"in r||"dragDrop"in r}(),dn;function id(r){if(dn==null){var i=Ee("span","\u200B");tt(r,Ee("span",[i,document.createTextNode("x")])),r.firstChild.offsetHeight!=0&&(dn=i.offsetWidth<=1&&i.offsetHeight>2&&!(c&&v<8))}var u=dn?Ee("span","\u200B"):Ee("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return u.setAttribute("cm-text",""),u}o(id,"zeroWidthElement");var tl;function Qf(r){if(tl!=null)return tl;var i=tt(r,document.createTextNode("A\u062EA")),u=We(i,0,1).getBoundingClientRect(),a=We(i,1,2).getBoundingClientRect();return Ve(r),!u||u.left==u.right?!1:tl=a.right-u.right<3}o(Qf,"hasBadBidiRects");var rl=` b`.split(/\n/).length!=3?function(r){for(var i=0,u=[],a=r.length;i<=a;){var p=r.indexOf(` -`,i);p==-1&&(p=r.length);var g=r.slice(i,r.charAt(p-1)=="\r"?p-1:p),y=g.indexOf("\r");y!=-1?(u.push(g.slice(0,y)),i+=y+1):(u.push(g),i=p+1)}return u}:function(r){return r.split(/\r\n?|\n/)},od=window.getSelection?function(r){try{return r.selectionStart!=r.selectionEnd}catch(i){return!1}}:function(r){var i;try{i=r.ownerDocument.selection.createRange()}catch(u){}return!i||i.parentElement()!=r?!1:i.compareEndPoints("StartToEnd",i)!=0},Zf=function(){var r=_e("div");return"oncopy"in r?!0:(r.setAttribute("oncopy","return;"),typeof r.oncopy=="function")}(),wu=null;function sd(r){if(wu!=null)return wu;var i=tt(r,_e("span","x")),u=i.getBoundingClientRect(),a=We(i,0,1).getBoundingClientRect();return wu=Math.abs(u.left-a.left)>1}o(sd,"hasBadZoomedRects");var zl={},ms={};function ld(r,i){arguments.length>2&&(i.dependencies=Array.prototype.slice.call(arguments,2)),zl[r]=i}o(ld,"defineMode");function Jf(r,i){ms[r]=i}o(Jf,"defineMIME");function nl(r){if(typeof r=="string"&&ms.hasOwnProperty(r))r=ms[r];else if(r&&typeof r.name=="string"&&ms.hasOwnProperty(r.name)){var i=ms[r.name];typeof i=="string"&&(i={name:i}),r=si(i,r),r.name=i.name}else{if(typeof r=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(r))return nl("application/xml");if(typeof r=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(r))return nl("application/json")}return typeof r=="string"?{name:r}:r||{name:"null"}}o(nl,"resolveMode");function xu(r,i){i=nl(i);var u=zl[i.name];if(!u)return xu(r,"text/plain");var a=u(r,i);if(Wo.hasOwnProperty(i.name)){var p=Wo[i.name];for(var g in p)!p.hasOwnProperty(g)||(a.hasOwnProperty(g)&&(a["_"+g]=a[g]),a[g]=p[g])}if(a.name=i.name,i.helperType&&(a.helperType=i.helperType),i.modeProps)for(var y in i.modeProps)a[y]=i.modeProps[y];return a}o(xu,"getMode");var Wo={};function ad(r,i){var u=Wo.hasOwnProperty(r)?Wo[r]:Wo[r]={};Zt(i,u)}o(ad,"extendMode");function Uo(r,i){if(i===!0)return i;if(r.copyState)return r.copyState(i);var u={};for(var a in i){var p=i[a];p instanceof Array&&(p=p.concat([])),u[a]=p}return u}o(Uo,"copyState");function $l(r,i){for(var u;r.innerMode&&(u=r.innerMode(i),!(!u||u.mode==r));)i=u.state,r=u.mode;return u||{mode:r,state:i}}o($l,"innerMode");function ec(r,i,u){return r.startState?r.startState(i,u):!0}o(ec,"startState");var jt=o(function(r,i,u){this.pos=this.start=0,this.string=r,this.tabSize=i||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=u},"StringStream");jt.prototype.eol=function(){return this.pos>=this.string.length},jt.prototype.sol=function(){return this.pos==this.lineStart},jt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},jt.prototype.next=function(){if(this.posi},jt.prototype.eatSpace=function(){for(var r=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>r},jt.prototype.skipToEnd=function(){this.pos=this.string.length},jt.prototype.skipTo=function(r){var i=this.string.indexOf(r,this.pos);if(i>-1)return this.pos=i,!0},jt.prototype.backUp=function(r){this.pos-=r},jt.prototype.column=function(){return this.lastColumnPos0?null:(g&&i!==!1&&(this.pos+=g[0].length),g)}},jt.prototype.current=function(){return this.string.slice(this.start,this.pos)},jt.prototype.hideFirstChars=function(r,i){this.lineStart+=r;try{return i()}finally{this.lineStart-=r}},jt.prototype.lookAhead=function(r){var i=this.lineOracle;return i&&i.lookAhead(r)},jt.prototype.baseToken=function(){var r=this.lineOracle;return r&&r.baseToken(this.pos)};function Me(r,i){if(i-=r.first,i<0||i>=r.size)throw new Error("There is no line "+(i+r.first)+" in the document.");for(var u=r;!u.lines;)for(var a=0;;++a){var p=u.children[a],g=p.chunkSize();if(i=r.first&&iu?ue(u,Me(r,u).text.length):ud(i,Me(r,i.line).text.length)}o(He,"clipPos");function ud(r,i){var u=r.ch;return u==null||u>i?ue(r.line,i):u<0?ue(r.line,0):r}o(ud,"clipToLen");function ql(r,i){for(var u=[],a=0;athis.maxLookAhead&&(this.maxLookAhead=r),i},ui.prototype.baseToken=function(r){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=r;)this.baseTokenPos+=2;var i=this.baseTokens[this.baseTokenPos+1];return{type:i&&i.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-r}},ui.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ui.fromSaved=function(r,i,u){return i instanceof uo?new ui(r,Uo(r.mode,i.state),u,i.lookAhead):new ui(r,Uo(r.mode,i),u)},ui.prototype.save=function(r){var i=r!==!1?Uo(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new uo(i,this.maxLookAhead):i};function tc(r,i,u,a){var p=[r.state.modeGen],g={};Gl(r,i.text,r.doc.mode,u,function(E,M){return p.push(E,M)},g,a);for(var y=u.state,S=o(function(E){u.baseTokens=p;var M=r.state.overlays[E],D=1,V=0;u.state=!0,Gl(r,i.text,M.mode,u,function($,te){for(var oe=D;V<$;){var de=p[D];de>$&&p.splice(D,1,$,p[D+1],de),D+=2,V=Math.min($,de)}if(!!te)if(M.opaque)p.splice(oe,D-oe,$,"overlay "+te),D=oe+2;else for(;oer.options.maxHighlightLength&&Uo(r.doc.mode,a.state),g=tc(r,i,a);p&&(a.state=p),i.stateAfter=a.save(!p),i.styles=g.styles,g.classes?i.styleClasses=g.classes:i.styleClasses&&(i.styleClasses=null),u===r.doc.highlightFrontier&&(r.doc.modeFrontier=Math.max(r.doc.modeFrontier,++r.doc.highlightFrontier))}return i.styles}o(_u,"getLineStyles");function $o(r,i,u){var a=r.doc,p=r.display;if(!a.mode.startState)return new ui(a,!0,i);var g=Yl(r,i,u),y=g>a.first&&Me(a,g-1).stateAfter,S=y?ui.fromSaved(a,y,g):new ui(a,ec(a.mode),g);return a.iter(g,i,function(b){vs(r,b.text,S);var E=S.line;b.stateAfter=E==i-1||E%5==0||E>=p.viewFrom&&Ei.start)return g}throw new Error("Mode "+r.name+" failed to advance stream.")}o(ol,"readToken");var Vl=o(function(r,i,u){this.start=r.start,this.end=r.pos,this.string=r.current(),this.type=i||null,this.state=u},"Token");function Kl(r,i,u,a){var p=r.doc,g=p.mode,y;i=He(p,i);var S=Me(p,i.line),b=$o(r,i.line,u),E=new jt(S.text,r.options.tabSize,b),M;for(a&&(M=[]);(a||E.posr.options.maxHighlightLength?(S=!1,y&&vs(r,i,a,M.pos),M.pos=i.length,D=null):D=fo(ol(u,M,a.state,V),g),V){var $=V[0].name;$&&(D="m-"+(D?$+" "+D:$))}if(!S||E!=D){for(;by;--S){if(S<=g.first)return g.first;var b=Me(g,S-1),E=b.stateAfter;if(E&&(!u||S+(E instanceof uo?E.lookAhead:0)<=g.modeFrontier))return S;var M=_t(b.text,null,r.options.tabSize);(p==null||a>M)&&(p=S-1,a=M)}return p}o(Yl,"findStartLine");function rc(r,i){if(r.modeFrontier=Math.min(r.modeFrontier,i),!(r.highlightFrontieru;a--){var p=Me(r,a).stateAfter;if(p&&(!(p instanceof uo)||a+p.lookAhead=i:g.to>i);(a||(a=[])).push(new co(y,g.from,b?null:g.to))}}return a}o(fd,"markedSpansBefore");function cd(r,i,u){var a;if(r)for(var p=0;p=i:g.to>i);if(S||g.from==i&&y.type=="bookmark"&&(!u||g.marker.insertLeft)){var b=g.from==null||(y.inclusiveLeft?g.from<=i:g.from0&&S)for(var Ne=0;Ne0)){var M=[b,1],D=ze(E.from,S.from),V=ze(E.to,S.to);(D<0||!y.inclusiveLeft&&!D)&&M.push({from:E.from,to:S.from}),(V>0||!y.inclusiveRight&&!V)&&M.push({from:S.to,to:E.to}),p.splice.apply(p,M),b+=M.length-3}}return p}o(Nu,"removeReadOnlyRanges");function lc(r){var i=r.markedSpans;if(!!i){for(var u=0;ui)&&(!a||Lu(a,g.marker)<0)&&(a=g.marker)}return a}o(Re,"collapsedSpanAround");function sl(r,i,u,a,p){var g=Me(r,i),y=_i&&g.markedSpans;if(y)for(var S=0;S=0&&D<=0||M<=0&&D>=0)&&(M<=0&&(b.marker.inclusiveRight&&p.inclusiveLeft?ze(E.to,u)>=0:ze(E.to,u)>0)||M>=0&&(b.marker.inclusiveRight&&p.inclusiveLeft?ze(E.from,a)<=0:ze(E.from,a)<0)))return!0}}}o(sl,"conflictingCollapsedRange");function vr(r){for(var i;i=Nt(r);)r=i.find(-1,!0).line;return r}o(vr,"visualLine");function Pu(r){for(var i;i=P(r);)r=i.find(1,!0).line;return r}o(Pu,"visualLineEnd");function ye(r){for(var i,u;i=P(r);)r=i.find(1,!0).line,(u||(u=[])).push(r);return u}o(ye,"visualLineContinued");function jo(r,i){var u=Me(r,i),a=vr(u);return u==a?i:vt(a)}o(jo,"visualLineNo");function pd(r,i){if(i>r.lastLine())return i;var u=Me(r,i),a;if(!qt(r,u))return i;for(;a=P(u);)u=a.find(1,!0).line;return vt(u)+1}o(pd,"visualLineEndNo");function qt(r,i){var u=_i&&i.markedSpans;if(u){for(var a=void 0,p=0;pi.maxLineLength&&(i.maxLineLength=p,i.maxLine=a)})}o(zi,"findMaxLine");var Ce=o(function(r,i,u){this.text=r,ac(this,i),this.height=u?u(this):1},"Line");Ce.prototype.lineNo=function(){return vt(this)},Wr(Ce);function ta(r,i,u,a){r.text=i,r.stateAfter&&(r.stateAfter=null),r.styles&&(r.styles=null),r.order!=null&&(r.order=null),lc(r),ac(r,u);var p=a?a(r):1;p!=r.height&&ai(r,p)}o(ta,"updateLine");function Ou(r){r.parent=null,lc(r)}o(Ou,"cleanUpLine");var nt={},uc={};function fi(r,i){if(!r||/^\s*$/.test(r))return null;var u=i.addModeClass?uc:nt;return u[r]||(u[r]=r.replace(/\S+/g,"cm-$&"))}o(fi,"interpretTokenStyle");function ll(r,i){var u=St("span",null,null,C?"padding-right: .1px":null),a={pre:St("pre",[u],"CodeMirror-line"),content:u,col:0,pos:0,cm:r,trailingSpace:!1,splitSpaces:r.getOption("lineWrapping")};i.measure={};for(var p=0;p<=(i.rest?i.rest.length:0);p++){var g=p?i.rest[p-1]:i.line,y=void 0;a.pos=0,a.addToken=ra,Qf(r.display.measure)&&(y=Mn(g,r.doc.direction))&&(a.addToken=dd(a.addToken,y)),a.map=[];var S=i!=r.display.externalMeasured&&vt(g);Vt(g,a,_u(r,g,S)),g.styleClasses&&(g.styleClasses.bgClass&&(a.bgClass=nr(g.styleClasses.bgClass,a.bgClass||"")),g.styleClasses.textClass&&(a.textClass=nr(g.styleClasses.textClass,a.textClass||""))),a.map.length==0&&a.map.push(0,0,a.content.appendChild(id(r.display.measure))),p==0?(i.measure.map=a.map,i.measure.cache={}):((i.measure.maps||(i.measure.maps=[])).push(a.map),(i.measure.caches||(i.measure.caches=[])).push({}))}if(C){var b=a.content.lastChild;(/\bcm-tab\b/.test(b.className)||b.querySelector&&b.querySelector(".cm-tab"))&&(a.content.className="cm-tab-wrap-hack")}return Te(r,"renderLine",r,i.line,a.pre),a.pre.className&&(a.textClass=nr(a.pre.className,a.textClass||"")),a}o(ll,"buildLineContent");function Ur(r){var i=_e("span","\u2022","cm-invalidchar");return i.title="\\u"+r.charCodeAt(0).toString(16),i.setAttribute("aria-label",i.title),i}o(Ur,"defaultSpecialCharPlaceholder");function ra(r,i,u,a,p,g,y){if(!!i){var S=r.splitSpaces?jn(i,r.trailingSpace):i,b=r.cm.state.specialChars,E=!1,M;if(!b.test(i))r.col+=i.length,M=document.createTextNode(S),r.map.push(r.pos,r.pos+i.length,M),c&&v<9&&(E=!0),r.pos+=i.length;else{M=document.createDocumentFragment();for(var D=0;;){b.lastIndex=D;var V=b.exec(i),$=V?V.index-D:i.length-D;if($){var te=document.createTextNode(S.slice(D,D+$));c&&v<9?M.appendChild(_e("span",[te])):M.appendChild(te),r.map.push(r.pos,r.pos+$,te),r.col+=$,r.pos+=$}if(!V)break;D+=$+1;var oe=void 0;if(V[0]==" "){var de=r.cm.options.tabSize,ge=de-r.col%de;oe=M.appendChild(_e("span",Yt(ge),"cm-tab")),oe.setAttribute("role","presentation"),oe.setAttribute("cm-text"," "),r.col+=ge}else V[0]=="\r"||V[0]==` -`?(oe=M.appendChild(_e("span",V[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),oe.setAttribute("cm-text",V[0]),r.col+=1):(oe=r.cm.options.specialCharPlaceholder(V[0]),oe.setAttribute("cm-text",V[0]),c&&v<9?M.appendChild(_e("span",[oe])):M.appendChild(oe),r.col+=1);r.map.push(r.pos,r.pos+1,oe),r.pos++}}if(r.trailingSpace=S.charCodeAt(i.length-1)==32,u||a||p||E||g||y){var be=u||"";a&&(be+=a),p&&(be+=p);var ve=_e("span",[M],be,g);if(y)for(var Ne in y)y.hasOwnProperty(Ne)&&Ne!="style"&&Ne!="class"&&ve.setAttribute(Ne,y[Ne]);return r.content.appendChild(ve)}r.content.appendChild(M)}}o(ra,"buildToken");function jn(r,i){if(r.length>1&&!/ /.test(r))return r;for(var u=i,a="",p=0;pE&&D.from<=E));V++);if(D.to>=M)return r(u,a,p,g,y,S,b);r(u,a.slice(0,D.to-E),p,g,null,S,b),g=null,a=a.slice(D.to-E),E=D.to}}}o(dd,"buildTokenBadBidi");function Mu(r,i,u,a){var p=!a&&u.widgetNode;p&&r.map.push(r.pos,r.pos+i,p),!a&&r.cm.display.input.needsContentAttribute&&(p||(p=r.content.appendChild(document.createElement("span"))),p.setAttribute("cm-marker",u.id)),p&&(r.cm.display.input.setUneditable(p),r.content.appendChild(p)),r.pos+=i,r.trailingSpace=!1}o(Mu,"buildCollapsedSpan");function Vt(r,i,u){var a=r.markedSpans,p=r.text,g=0;if(!a){for(var y=1;yb||it.collapsed&&De.to==b&&De.from==b)){if(De.to!=null&&De.to!=b&&$>De.to&&($=De.to,oe=""),it.className&&(te+=" "+it.className),it.css&&(V=(V?V+";":"")+it.css),it.startStyle&&De.from==b&&(de+=" "+it.startStyle),it.endStyle&&De.to==$&&(Ne||(Ne=[])).push(it.endStyle,De.to),it.title&&((be||(be={})).title=it.title),it.attributes)for(var Tt in it.attributes)(be||(be={}))[Tt]=it.attributes[Tt];it.collapsed&&(!ge||Lu(ge.marker,it)<0)&&(ge=De)}else De.from>b&&$>De.from&&($=De.from)}if(Ne)for(var br=0;br=S)break;for(var Sn=Math.min(S,$);;){if(M){var Cn=b+M.length;if(!ge){var dr=Cn>Sn?M.slice(0,Sn-b):M;i.addToken(i,dr,D?D+te:te,de,b+dr.length==$?oe:"",V,be)}if(Cn>=Sn){M=M.slice(Sn-b),b=Sn;break}b=Cn,de=""}M=p.slice(g,g=u[E++]),D=fi(u[E++],i.cm.options)}}}o(Vt,"insertLineContent");function xs(r,i,u){this.line=i,this.rest=ye(i),this.size=this.rest?vt(Se(this.rest))-u+1:1,this.node=this.text=null,this.hidden=qt(r,i)}o(xs,"LineView");function qo(r,i,u){for(var a=[],p,g=i;g2&&g.push((b.bottom+E.top)/2-u.top)}}g.push(u.bottom-u.top)}}o(cc,"ensureLineHeights");function Wu(r,i,u){if(r.line==i)return{map:r.measure.map,cache:r.measure.cache};for(var a=0;au)return{map:r.measure.maps[p],cache:r.measure.caches[p],before:!0}}o(Wu,"mapFromLineView");function gd(r,i){i=vr(i);var u=vt(i),a=r.display.externalMeasured=new xs(r.doc,i,u);a.lineN=u;var p=a.built=ll(r,a);return a.text=p.pre,tt(r.display.lineMeasure,p.pre),a}o(gd,"updateExternalMeasurement");function Uu(r,i,u,a){return Ti(r,qn(r,i),u,a)}o(Uu,"measureChar");function la(r,i){if(i>=r.display.viewFrom&&i=u.lineN&&ii)&&(g=b-S,p=g-1,i>=b&&(y="right")),p!=null){if(a=r[E+2],S==b&&u==(a.insertLeft?"left":"right")&&(y=u),u=="left"&&p==0)for(;E&&r[E-2]==r[E-3]&&r[E-1].insertLeft;)a=r[(E-=3)+2],y="left";if(u=="right"&&p==b-S)for(;E=0&&(u=r[p]).left==u.right;p--);return u}o(dc,"getUsefulRect");function Vi(r,i,u,a){var p=aa(i.map,u,a),g=p.node,y=p.start,S=p.end,b=p.collapse,E;if(g.nodeType==3){for(var M=0;M<4;M++){for(;y&&Cr(i.line.text.charAt(p.coverStart+y));)--y;for(;p.coverStart+S0&&(b=a="right");var D;r.options.lineWrapping&&(D=g.getClientRects()).length>1?E=D[a=="right"?D.length-1:0]:E=g.getBoundingClientRect()}if(c&&v<9&&!y&&(!E||!E.left&&!E.right)){var V=g.parentNode.getClientRects()[0];V?E={left:V.left,right:V.left+ua(r.display),top:V.top,bottom:V.bottom}:E=pc}for(var $=E.top-i.rect.top,te=E.bottom-i.rect.top,oe=($+te)/2,de=i.view.measure.heights,ge=0;ge=a.text.length?(b=a.text.length,E="before"):b<=0&&(b=0,E="after"),!S)return y(E=="before"?b-1:b,E=="before");function M(te,oe,de){var ge=S[oe],be=ge.level==1;return y(de?te-1:te,be!=de)}o(M,"getBidi");var D=Ci(S,b,E),V=Si,$=M(b,D,E=="before");return V!=null&&($.other=M(b,V,E!="before")),$}o(Vn,"cursorCoords");function zu(r,i){var u=0;i=He(r.doc,i),r.options.lineWrapping||(u=ua(r.display)*i.ch);var a=Me(r.doc,i.line),p=hn(a)+Ss(r.display);return{left:u,right:u,top:p,bottom:p+a.height}}o(zu,"estimateCoords");function vn(r,i,u,a,p){var g=ue(r,i,u);return g.xRel=p,a&&(g.outside=a),g}o(vn,"PosWithInfo");function q(r,i,u){var a=r.doc;if(u+=r.display.viewOffset,u<0)return vn(a.first,0,null,-1,-1);var p=ao(a,u),g=a.first+a.size-1;if(p>g)return vn(a.first+a.size-1,Me(a,g).text.length,null,1,1);i<0&&(i=0);for(var y=Me(a,p);;){var S=Qe(r,y,p,i,u),b=Re(y,S.ch+(S.xRel>0||S.outside>0?1:0));if(!b)return S;var E=b.find(1);if(E.line==p)return E;y=Me(a,p=E.line)}}o(q,"coordsChar");function re(r,i,u,a){a-=gn(i);var p=i.text.length,g=pn(function(y){return Ti(r,u,y-1).bottom<=a},p,0);return p=pn(function(y){return Ti(r,u,y).top>a},g,p),{begin:g,end:p}}o(re,"wrappedLineExtent");function Q(r,i,u,a){u||(u=qn(r,i));var p=ci(r,i,Ti(r,u,a),"line").top;return re(r,i,u,p)}o(Q,"wrappedLineExtentChar");function Pe(r,i,u,a){return r.bottom<=u?!1:r.top>u?!0:(a?r.left:r.right)>i}o(Pe,"boxIsAfter");function Qe(r,i,u,a,p){p-=hn(i);var g=qn(r,i),y=gn(i),S=0,b=i.text.length,E=!0,M=Mn(i,r.doc.direction);if(M){var D=(r.options.lineWrapping?Mr:bt)(r,i,u,g,M,a,p);E=D.level!=1,S=E?D.from:D.to-1,b=E?D.to:D.from-1}var V=null,$=null,te=pn(function(Ie){var De=Ti(r,g,Ie);return De.top+=y,De.bottom+=y,Pe(De,a,p,!1)?(De.top<=p&&De.left<=a&&(V=Ie,$=De),!0):!1},S,b),oe,de,ge=!1;if($){var be=a-$.left<$.right-a,ve=be==E;te=V+(ve?0:1),de=ve?"after":"before",oe=be?$.left:$.right}else{!E&&(te==b||te==S)&&te++,de=te==0?"after":te==i.text.length?"before":Ti(r,g,te-(E?1:0)).bottom+y<=p==E?"after":"before";var Ne=Vn(r,ue(u,te,de),"line",i,g);oe=Ne.left,ge=p=Ne.bottom?1:0}return te=Ui(i.text,te,1),vn(u,te,de,ge,a-oe)}o(Qe,"coordsCharInner");function bt(r,i,u,a,p,g,y){var S=pn(function(D){var V=p[D],$=V.level!=1;return Pe(Vn(r,ue(u,$?V.to:V.from,$?"before":"after"),"line",i,a),g,y,!0)},0,p.length-1),b=p[S];if(S>0){var E=b.level!=1,M=Vn(r,ue(u,E?b.from:b.to,E?"after":"before"),"line",i,a);Pe(M,g,y,!0)&&M.top>y&&(b=p[S-1])}return b}o(bt,"coordsBidiPart");function Mr(r,i,u,a,p,g,y){var S=re(r,i,a,y),b=S.begin,E=S.end;/\s/.test(i.text.charAt(E-1))&&E--;for(var M=null,D=null,V=0;V=E||$.to<=b)){var te=$.level!=1,oe=Ti(r,a,te?Math.min(E,$.to)-1:Math.max(b,$.from)).right,de=oede)&&(M=$,D=de)}}return M||(M=p[p.length-1]),M.fromE&&(M={from:M.from,to:E,level:M.level}),M}o(Mr,"coordsBidiPartWrapped");var mt;function Cs(r){if(r.cachedTextHeight!=null)return r.cachedTextHeight;if(mt==null){mt=_e("pre",null,"CodeMirror-line-like");for(var i=0;i<49;++i)mt.appendChild(document.createTextNode("x")),mt.appendChild(_e("br"));mt.appendChild(document.createTextNode("x"))}tt(r.measure,mt);var u=mt.offsetHeight/50;return u>3&&(r.cachedTextHeight=u),Ve(r.measure),u||1}o(Cs,"textHeight");function ua(r){if(r.cachedCharWidth!=null)return r.cachedCharWidth;var i=_e("span","xxxxxxxxxx"),u=_e("pre",[i],"CodeMirror-line-like");tt(r.measure,u);var a=i.getBoundingClientRect(),p=(a.right-a.left)/10;return p>2&&(r.cachedCharWidth=p),p||10}o(ua,"charWidth");function Kn(r){for(var i=r.display,u={},a={},p=i.gutters.clientLeft,g=i.gutters.firstChild,y=0;g;g=g.nextSibling,++y){var S=r.display.gutterSpecs[y].className;u[S]=g.offsetLeft+g.clientLeft+p,a[S]=g.clientWidth}return{fixedPos:fa(i),gutterTotalWidth:i.gutters.offsetWidth,gutterLeft:u,gutterWidth:a,wrapperWidth:i.wrapper.clientWidth}}o(Kn,"getDimensions");function fa(r){return r.scroller.getBoundingClientRect().left-r.sizer.getBoundingClientRect().left}o(fa,"compensateForHScroll");function Bm(r){var i=Cs(r.display),u=r.options.lineWrapping,a=u&&Math.max(5,r.display.scroller.clientWidth/ua(r.display)-3);return function(p){if(qt(r.doc,p))return 0;var g=0;if(p.widgets)for(var y=0;y0&&(E=Me(r.doc,b.line).text).length==b.ch){var M=_t(E,E.length,r.options.tabSize)-E.length;b=ue(b.line,Math.max(0,Math.round((g-sa(r.display).left)/ua(r.display))-M))}return b}o(po,"posFromMouse");function ho(r,i){if(i>=r.display.viewTo||(i-=r.display.viewFrom,i<0))return null;for(var u=r.display.view,a=0;ai)&&(p.updateLineNumbers=i),r.curOp.viewChanged=!0,i>=p.viewTo)_i&&jo(r.doc,i)p.viewFrom?Xo(r):(p.viewFrom+=a,p.viewTo+=a);else if(i<=p.viewFrom&&u>=p.viewTo)Xo(r);else if(i<=p.viewFrom){var g=fl(r,u,u+a,1);g?(p.view=p.view.slice(g.index),p.viewFrom=g.lineN,p.viewTo+=a):Xo(r)}else if(u>=p.viewTo){var y=fl(r,i,i,-1);y?(p.view=p.view.slice(0,y.index),p.viewTo=y.lineN):Xo(r)}else{var S=fl(r,i,i,-1),b=fl(r,u,u+a,1);S&&b?(p.view=p.view.slice(0,S.index).concat(qo(r,S.lineN,b.lineN)).concat(p.view.slice(b.index)),p.viewTo+=a):Xo(r)}var E=p.externalMeasured;E&&(u=p.lineN&&i=a.viewTo)){var g=a.view[ho(r,i)];if(g.node!=null){var y=g.changes||(g.changes=[]);ut(y,u)==-1&&y.push(u)}}}o(Es,"regLineChange");function Xo(r){r.display.viewFrom=r.display.viewTo=r.doc.first,r.display.view=[],r.display.viewOffset=0}o(Xo,"resetView");function fl(r,i,u,a){var p=ho(r,i),g,y=r.display.view;if(!_i||u==r.doc.first+r.doc.size)return{index:p,lineN:u};for(var S=r.display.viewFrom,b=0;b0){if(p==y.length-1)return null;g=S+y[p].size-i,p++}else g=S-i;i+=g,u+=g}for(;jo(r.doc,u)!=u;){if(p==(a<0?0:y.length-1))return null;u+=a*y[p-(a<0?1:0)].size,p+=a}return{index:p,lineN:u}}o(fl,"viewCuttingPoint");function Ry(r,i,u){var a=r.display,p=a.view;p.length==0||i>=a.viewTo||u<=a.viewFrom?(a.view=qo(r,i,u),a.viewFrom=i):(a.viewFrom>i?a.view=qo(r,i,a.viewFrom).concat(a.view):a.viewFromu&&(a.view=a.view.slice(0,ho(r,u)))),a.viewTo=u}o(Ry,"adjustView");function Hm(r){for(var i=r.display.view,u=0,a=0;a=r.display.viewTo||S.to().line1}o(sd,"hasBadZoomedRects");var zl={},ms={};function ld(r,i){arguments.length>2&&(i.dependencies=Array.prototype.slice.call(arguments,2)),zl[r]=i}o(ld,"defineMode");function Jf(r,i){ms[r]=i}o(Jf,"defineMIME");function nl(r){if(typeof r=="string"&&ms.hasOwnProperty(r))r=ms[r];else if(r&&typeof r.name=="string"&&ms.hasOwnProperty(r.name)){var i=ms[r.name];typeof i=="string"&&(i={name:i}),r=si(i,r),r.name=i.name}else{if(typeof r=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(r))return nl("application/xml");if(typeof r=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(r))return nl("application/json")}return typeof r=="string"?{name:r}:r||{name:"null"}}o(nl,"resolveMode");function xu(r,i){i=nl(i);var u=zl[i.name];if(!u)return xu(r,"text/plain");var a=u(r,i);if(Wo.hasOwnProperty(i.name)){var p=Wo[i.name];for(var g in p)!p.hasOwnProperty(g)||(a.hasOwnProperty(g)&&(a["_"+g]=a[g]),a[g]=p[g])}if(a.name=i.name,i.helperType&&(a.helperType=i.helperType),i.modeProps)for(var y in i.modeProps)a[y]=i.modeProps[y];return a}o(xu,"getMode");var Wo={};function ad(r,i){var u=Wo.hasOwnProperty(r)?Wo[r]:Wo[r]={};Zt(i,u)}o(ad,"extendMode");function Uo(r,i){if(i===!0)return i;if(r.copyState)return r.copyState(i);var u={};for(var a in i){var p=i[a];p instanceof Array&&(p=p.concat([])),u[a]=p}return u}o(Uo,"copyState");function $l(r,i){for(var u;r.innerMode&&(u=r.innerMode(i),!(!u||u.mode==r));)i=u.state,r=u.mode;return u||{mode:r,state:i}}o($l,"innerMode");function ec(r,i,u){return r.startState?r.startState(i,u):!0}o(ec,"startState");var jt=o(function(r,i,u){this.pos=this.start=0,this.string=r,this.tabSize=i||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=u},"StringStream");jt.prototype.eol=function(){return this.pos>=this.string.length},jt.prototype.sol=function(){return this.pos==this.lineStart},jt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},jt.prototype.next=function(){if(this.posi},jt.prototype.eatSpace=function(){for(var r=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>r},jt.prototype.skipToEnd=function(){this.pos=this.string.length},jt.prototype.skipTo=function(r){var i=this.string.indexOf(r,this.pos);if(i>-1)return this.pos=i,!0},jt.prototype.backUp=function(r){this.pos-=r},jt.prototype.column=function(){return this.lastColumnPos0?null:(g&&i!==!1&&(this.pos+=g[0].length),g)}},jt.prototype.current=function(){return this.string.slice(this.start,this.pos)},jt.prototype.hideFirstChars=function(r,i){this.lineStart+=r;try{return i()}finally{this.lineStart-=r}},jt.prototype.lookAhead=function(r){var i=this.lineOracle;return i&&i.lookAhead(r)},jt.prototype.baseToken=function(){var r=this.lineOracle;return r&&r.baseToken(this.pos)};function Me(r,i){if(i-=r.first,i<0||i>=r.size)throw new Error("There is no line "+(i+r.first)+" in the document.");for(var u=r;!u.lines;)for(var a=0;;++a){var p=u.children[a],g=p.chunkSize();if(i=r.first&&iu?ue(u,Me(r,u).text.length):ud(i,Me(r,i.line).text.length)}o(He,"clipPos");function ud(r,i){var u=r.ch;return u==null||u>i?ue(r.line,i):u<0?ue(r.line,0):r}o(ud,"clipToLen");function ql(r,i){for(var u=[],a=0;athis.maxLookAhead&&(this.maxLookAhead=r),i},ui.prototype.baseToken=function(r){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=r;)this.baseTokenPos+=2;var i=this.baseTokens[this.baseTokenPos+1];return{type:i&&i.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-r}},ui.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ui.fromSaved=function(r,i,u){return i instanceof uo?new ui(r,Uo(r.mode,i.state),u,i.lookAhead):new ui(r,Uo(r.mode,i),u)},ui.prototype.save=function(r){var i=r!==!1?Uo(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new uo(i,this.maxLookAhead):i};function tc(r,i,u,a){var p=[r.state.modeGen],g={};Gl(r,i.text,r.doc.mode,u,function(_,M){return p.push(_,M)},g,a);for(var y=u.state,S=o(function(_){u.baseTokens=p;var M=r.state.overlays[_],D=1,V=0;u.state=!0,Gl(r,i.text,M.mode,u,function($,te){for(var oe=D;V<$;){var de=p[D];de>$&&p.splice(D,1,$,p[D+1],de),D+=2,V=Math.min($,de)}if(!!te)if(M.opaque)p.splice(oe,D-oe,$,"overlay "+te),D=oe+2;else for(;oer.options.maxHighlightLength&&Uo(r.doc.mode,a.state),g=tc(r,i,a);p&&(a.state=p),i.stateAfter=a.save(!p),i.styles=g.styles,g.classes?i.styleClasses=g.classes:i.styleClasses&&(i.styleClasses=null),u===r.doc.highlightFrontier&&(r.doc.modeFrontier=Math.max(r.doc.modeFrontier,++r.doc.highlightFrontier))}return i.styles}o(Eu,"getLineStyles");function $o(r,i,u){var a=r.doc,p=r.display;if(!a.mode.startState)return new ui(a,!0,i);var g=Yl(r,i,u),y=g>a.first&&Me(a,g-1).stateAfter,S=y?ui.fromSaved(a,y,g):new ui(a,ec(a.mode),g);return a.iter(g,i,function(b){vs(r,b.text,S);var _=S.line;b.stateAfter=_==i-1||_%5==0||_>=p.viewFrom&&_i.start)return g}throw new Error("Mode "+r.name+" failed to advance stream.")}o(ol,"readToken");var Vl=o(function(r,i,u){this.start=r.start,this.end=r.pos,this.string=r.current(),this.type=i||null,this.state=u},"Token");function Kl(r,i,u,a){var p=r.doc,g=p.mode,y;i=He(p,i);var S=Me(p,i.line),b=$o(r,i.line,u),_=new jt(S.text,r.options.tabSize,b),M;for(a&&(M=[]);(a||_.posr.options.maxHighlightLength?(S=!1,y&&vs(r,i,a,M.pos),M.pos=i.length,D=null):D=fo(ol(u,M,a.state,V),g),V){var $=V[0].name;$&&(D="m-"+(D?$+" "+D:$))}if(!S||_!=D){for(;by;--S){if(S<=g.first)return g.first;var b=Me(g,S-1),_=b.stateAfter;if(_&&(!u||S+(_ instanceof uo?_.lookAhead:0)<=g.modeFrontier))return S;var M=Et(b.text,null,r.options.tabSize);(p==null||a>M)&&(p=S-1,a=M)}return p}o(Yl,"findStartLine");function rc(r,i){if(r.modeFrontier=Math.min(r.modeFrontier,i),!(r.highlightFrontieru;a--){var p=Me(r,a).stateAfter;if(p&&(!(p instanceof uo)||a+p.lookAhead=i:g.to>i);(a||(a=[])).push(new co(y,g.from,b?null:g.to))}}return a}o(fd,"markedSpansBefore");function cd(r,i,u){var a;if(r)for(var p=0;p=i:g.to>i);if(S||g.from==i&&y.type=="bookmark"&&(!u||g.marker.insertLeft)){var b=g.from==null||(y.inclusiveLeft?g.from<=i:g.from0&&S)for(var Ne=0;Ne0)){var M=[b,1],D=ze(_.from,S.from),V=ze(_.to,S.to);(D<0||!y.inclusiveLeft&&!D)&&M.push({from:_.from,to:S.from}),(V>0||!y.inclusiveRight&&!V)&&M.push({from:S.to,to:_.to}),p.splice.apply(p,M),b+=M.length-3}}return p}o(Nu,"removeReadOnlyRanges");function lc(r){var i=r.markedSpans;if(!!i){for(var u=0;ui)&&(!a||Pu(a,g.marker)<0)&&(a=g.marker)}return a}o(Re,"collapsedSpanAround");function sl(r,i,u,a,p){var g=Me(r,i),y=Ei&&g.markedSpans;if(y)for(var S=0;S=0&&D<=0||M<=0&&D>=0)&&(M<=0&&(b.marker.inclusiveRight&&p.inclusiveLeft?ze(_.to,u)>=0:ze(_.to,u)>0)||M>=0&&(b.marker.inclusiveRight&&p.inclusiveLeft?ze(_.from,a)<=0:ze(_.from,a)<0)))return!0}}}o(sl,"conflictingCollapsedRange");function vr(r){for(var i;i=Nt(r);)r=i.find(-1,!0).line;return r}o(vr,"visualLine");function Lu(r){for(var i;i=L(r);)r=i.find(1,!0).line;return r}o(Lu,"visualLineEnd");function ye(r){for(var i,u;i=L(r);)r=i.find(1,!0).line,(u||(u=[])).push(r);return u}o(ye,"visualLineContinued");function jo(r,i){var u=Me(r,i),a=vr(u);return u==a?i:vt(a)}o(jo,"visualLineNo");function pd(r,i){if(i>r.lastLine())return i;var u=Me(r,i),a;if(!qt(r,u))return i;for(;a=L(u);)u=a.find(1,!0).line;return vt(u)+1}o(pd,"visualLineEndNo");function qt(r,i){var u=Ei&&i.markedSpans;if(u){for(var a=void 0,p=0;pi.maxLineLength&&(i.maxLineLength=p,i.maxLine=a)})}o(zi,"findMaxLine");var Ce=o(function(r,i,u){this.text=r,ac(this,i),this.height=u?u(this):1},"Line");Ce.prototype.lineNo=function(){return vt(this)},Wr(Ce);function ta(r,i,u,a){r.text=i,r.stateAfter&&(r.stateAfter=null),r.styles&&(r.styles=null),r.order!=null&&(r.order=null),lc(r),ac(r,u);var p=a?a(r):1;p!=r.height&&ai(r,p)}o(ta,"updateLine");function Ou(r){r.parent=null,lc(r)}o(Ou,"cleanUpLine");var nt={},uc={};function fi(r,i){if(!r||/^\s*$/.test(r))return null;var u=i.addModeClass?uc:nt;return u[r]||(u[r]=r.replace(/\S+/g,"cm-$&"))}o(fi,"interpretTokenStyle");function ll(r,i){var u=St("span",null,null,C?"padding-right: .1px":null),a={pre:St("pre",[u],"CodeMirror-line"),content:u,col:0,pos:0,cm:r,trailingSpace:!1,splitSpaces:r.getOption("lineWrapping")};i.measure={};for(var p=0;p<=(i.rest?i.rest.length:0);p++){var g=p?i.rest[p-1]:i.line,y=void 0;a.pos=0,a.addToken=ra,Qf(r.display.measure)&&(y=Mn(g,r.doc.direction))&&(a.addToken=dd(a.addToken,y)),a.map=[];var S=i!=r.display.externalMeasured&&vt(g);Vt(g,a,Eu(r,g,S)),g.styleClasses&&(g.styleClasses.bgClass&&(a.bgClass=nr(g.styleClasses.bgClass,a.bgClass||"")),g.styleClasses.textClass&&(a.textClass=nr(g.styleClasses.textClass,a.textClass||""))),a.map.length==0&&a.map.push(0,0,a.content.appendChild(id(r.display.measure))),p==0?(i.measure.map=a.map,i.measure.cache={}):((i.measure.maps||(i.measure.maps=[])).push(a.map),(i.measure.caches||(i.measure.caches=[])).push({}))}if(C){var b=a.content.lastChild;(/\bcm-tab\b/.test(b.className)||b.querySelector&&b.querySelector(".cm-tab"))&&(a.content.className="cm-tab-wrap-hack")}return Te(r,"renderLine",r,i.line,a.pre),a.pre.className&&(a.textClass=nr(a.pre.className,a.textClass||"")),a}o(ll,"buildLineContent");function Ur(r){var i=Ee("span","\u2022","cm-invalidchar");return i.title="\\u"+r.charCodeAt(0).toString(16),i.setAttribute("aria-label",i.title),i}o(Ur,"defaultSpecialCharPlaceholder");function ra(r,i,u,a,p,g,y){if(!!i){var S=r.splitSpaces?jn(i,r.trailingSpace):i,b=r.cm.state.specialChars,_=!1,M;if(!b.test(i))r.col+=i.length,M=document.createTextNode(S),r.map.push(r.pos,r.pos+i.length,M),c&&v<9&&(_=!0),r.pos+=i.length;else{M=document.createDocumentFragment();for(var D=0;;){b.lastIndex=D;var V=b.exec(i),$=V?V.index-D:i.length-D;if($){var te=document.createTextNode(S.slice(D,D+$));c&&v<9?M.appendChild(Ee("span",[te])):M.appendChild(te),r.map.push(r.pos,r.pos+$,te),r.col+=$,r.pos+=$}if(!V)break;D+=$+1;var oe=void 0;if(V[0]==" "){var de=r.cm.options.tabSize,ge=de-r.col%de;oe=M.appendChild(Ee("span",Yt(ge),"cm-tab")),oe.setAttribute("role","presentation"),oe.setAttribute("cm-text"," "),r.col+=ge}else V[0]=="\r"||V[0]==` +`?(oe=M.appendChild(Ee("span",V[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),oe.setAttribute("cm-text",V[0]),r.col+=1):(oe=r.cm.options.specialCharPlaceholder(V[0]),oe.setAttribute("cm-text",V[0]),c&&v<9?M.appendChild(Ee("span",[oe])):M.appendChild(oe),r.col+=1);r.map.push(r.pos,r.pos+1,oe),r.pos++}}if(r.trailingSpace=S.charCodeAt(i.length-1)==32,u||a||p||_||g||y){var be=u||"";a&&(be+=a),p&&(be+=p);var ve=Ee("span",[M],be,g);if(y)for(var Ne in y)y.hasOwnProperty(Ne)&&Ne!="style"&&Ne!="class"&&ve.setAttribute(Ne,y[Ne]);return r.content.appendChild(ve)}r.content.appendChild(M)}}o(ra,"buildToken");function jn(r,i){if(r.length>1&&!/ /.test(r))return r;for(var u=i,a="",p=0;p_&&D.from<=_));V++);if(D.to>=M)return r(u,a,p,g,y,S,b);r(u,a.slice(0,D.to-_),p,g,null,S,b),g=null,a=a.slice(D.to-_),_=D.to}}}o(dd,"buildTokenBadBidi");function Mu(r,i,u,a){var p=!a&&u.widgetNode;p&&r.map.push(r.pos,r.pos+i,p),!a&&r.cm.display.input.needsContentAttribute&&(p||(p=r.content.appendChild(document.createElement("span"))),p.setAttribute("cm-marker",u.id)),p&&(r.cm.display.input.setUneditable(p),r.content.appendChild(p)),r.pos+=i,r.trailingSpace=!1}o(Mu,"buildCollapsedSpan");function Vt(r,i,u){var a=r.markedSpans,p=r.text,g=0;if(!a){for(var y=1;yb||it.collapsed&&De.to==b&&De.from==b)){if(De.to!=null&&De.to!=b&&$>De.to&&($=De.to,oe=""),it.className&&(te+=" "+it.className),it.css&&(V=(V?V+";":"")+it.css),it.startStyle&&De.from==b&&(de+=" "+it.startStyle),it.endStyle&&De.to==$&&(Ne||(Ne=[])).push(it.endStyle,De.to),it.title&&((be||(be={})).title=it.title),it.attributes)for(var Tt in it.attributes)(be||(be={}))[Tt]=it.attributes[Tt];it.collapsed&&(!ge||Pu(ge.marker,it)<0)&&(ge=De)}else De.from>b&&$>De.from&&($=De.from)}if(Ne)for(var br=0;br=S)break;for(var Sn=Math.min(S,$);;){if(M){var Cn=b+M.length;if(!ge){var dr=Cn>Sn?M.slice(0,Sn-b):M;i.addToken(i,dr,D?D+te:te,de,b+dr.length==$?oe:"",V,be)}if(Cn>=Sn){M=M.slice(Sn-b),b=Sn;break}b=Cn,de=""}M=p.slice(g,g=u[_++]),D=fi(u[_++],i.cm.options)}}}o(Vt,"insertLineContent");function xs(r,i,u){this.line=i,this.rest=ye(i),this.size=this.rest?vt(Se(this.rest))-u+1:1,this.node=this.text=null,this.hidden=qt(r,i)}o(xs,"LineView");function qo(r,i,u){for(var a=[],p,g=i;g2&&g.push((b.bottom+_.top)/2-u.top)}}g.push(u.bottom-u.top)}}o(cc,"ensureLineHeights");function Wu(r,i,u){if(r.line==i)return{map:r.measure.map,cache:r.measure.cache};for(var a=0;au)return{map:r.measure.maps[p],cache:r.measure.caches[p],before:!0}}o(Wu,"mapFromLineView");function gd(r,i){i=vr(i);var u=vt(i),a=r.display.externalMeasured=new xs(r.doc,i,u);a.lineN=u;var p=a.built=ll(r,a);return a.text=p.pre,tt(r.display.lineMeasure,p.pre),a}o(gd,"updateExternalMeasurement");function Uu(r,i,u,a){return Ti(r,qn(r,i),u,a)}o(Uu,"measureChar");function la(r,i){if(i>=r.display.viewFrom&&i=u.lineN&&ii)&&(g=b-S,p=g-1,i>=b&&(y="right")),p!=null){if(a=r[_+2],S==b&&u==(a.insertLeft?"left":"right")&&(y=u),u=="left"&&p==0)for(;_&&r[_-2]==r[_-3]&&r[_-1].insertLeft;)a=r[(_-=3)+2],y="left";if(u=="right"&&p==b-S)for(;_=0&&(u=r[p]).left==u.right;p--);return u}o(dc,"getUsefulRect");function Vi(r,i,u,a){var p=aa(i.map,u,a),g=p.node,y=p.start,S=p.end,b=p.collapse,_;if(g.nodeType==3){for(var M=0;M<4;M++){for(;y&&Cr(i.line.text.charAt(p.coverStart+y));)--y;for(;p.coverStart+S0&&(b=a="right");var D;r.options.lineWrapping&&(D=g.getClientRects()).length>1?_=D[a=="right"?D.length-1:0]:_=g.getBoundingClientRect()}if(c&&v<9&&!y&&(!_||!_.left&&!_.right)){var V=g.parentNode.getClientRects()[0];V?_={left:V.left,right:V.left+ua(r.display),top:V.top,bottom:V.bottom}:_=pc}for(var $=_.top-i.rect.top,te=_.bottom-i.rect.top,oe=($+te)/2,de=i.view.measure.heights,ge=0;ge=a.text.length?(b=a.text.length,_="before"):b<=0&&(b=0,_="after"),!S)return y(_=="before"?b-1:b,_=="before");function M(te,oe,de){var ge=S[oe],be=ge.level==1;return y(de?te-1:te,be!=de)}o(M,"getBidi");var D=Ci(S,b,_),V=Si,$=M(b,D,_=="before");return V!=null&&($.other=M(b,V,_!="before")),$}o(Vn,"cursorCoords");function zu(r,i){var u=0;i=He(r.doc,i),r.options.lineWrapping||(u=ua(r.display)*i.ch);var a=Me(r.doc,i.line),p=hn(a)+Ss(r.display);return{left:u,right:u,top:p,bottom:p+a.height}}o(zu,"estimateCoords");function vn(r,i,u,a,p){var g=ue(r,i,u);return g.xRel=p,a&&(g.outside=a),g}o(vn,"PosWithInfo");function q(r,i,u){var a=r.doc;if(u+=r.display.viewOffset,u<0)return vn(a.first,0,null,-1,-1);var p=ao(a,u),g=a.first+a.size-1;if(p>g)return vn(a.first+a.size-1,Me(a,g).text.length,null,1,1);i<0&&(i=0);for(var y=Me(a,p);;){var S=Qe(r,y,p,i,u),b=Re(y,S.ch+(S.xRel>0||S.outside>0?1:0));if(!b)return S;var _=b.find(1);if(_.line==p)return _;y=Me(a,p=_.line)}}o(q,"coordsChar");function re(r,i,u,a){a-=gn(i);var p=i.text.length,g=pn(function(y){return Ti(r,u,y-1).bottom<=a},p,0);return p=pn(function(y){return Ti(r,u,y).top>a},g,p),{begin:g,end:p}}o(re,"wrappedLineExtent");function Q(r,i,u,a){u||(u=qn(r,i));var p=ci(r,i,Ti(r,u,a),"line").top;return re(r,i,u,p)}o(Q,"wrappedLineExtentChar");function Le(r,i,u,a){return r.bottom<=u?!1:r.top>u?!0:(a?r.left:r.right)>i}o(Le,"boxIsAfter");function Qe(r,i,u,a,p){p-=hn(i);var g=qn(r,i),y=gn(i),S=0,b=i.text.length,_=!0,M=Mn(i,r.doc.direction);if(M){var D=(r.options.lineWrapping?Mr:bt)(r,i,u,g,M,a,p);_=D.level!=1,S=_?D.from:D.to-1,b=_?D.to:D.from-1}var V=null,$=null,te=pn(function(Ie){var De=Ti(r,g,Ie);return De.top+=y,De.bottom+=y,Le(De,a,p,!1)?(De.top<=p&&De.left<=a&&(V=Ie,$=De),!0):!1},S,b),oe,de,ge=!1;if($){var be=a-$.left<$.right-a,ve=be==_;te=V+(ve?0:1),de=ve?"after":"before",oe=be?$.left:$.right}else{!_&&(te==b||te==S)&&te++,de=te==0?"after":te==i.text.length?"before":Ti(r,g,te-(_?1:0)).bottom+y<=p==_?"after":"before";var Ne=Vn(r,ue(u,te,de),"line",i,g);oe=Ne.left,ge=p=Ne.bottom?1:0}return te=Ui(i.text,te,1),vn(u,te,de,ge,a-oe)}o(Qe,"coordsCharInner");function bt(r,i,u,a,p,g,y){var S=pn(function(D){var V=p[D],$=V.level!=1;return Le(Vn(r,ue(u,$?V.to:V.from,$?"before":"after"),"line",i,a),g,y,!0)},0,p.length-1),b=p[S];if(S>0){var _=b.level!=1,M=Vn(r,ue(u,_?b.from:b.to,_?"after":"before"),"line",i,a);Le(M,g,y,!0)&&M.top>y&&(b=p[S-1])}return b}o(bt,"coordsBidiPart");function Mr(r,i,u,a,p,g,y){var S=re(r,i,a,y),b=S.begin,_=S.end;/\s/.test(i.text.charAt(_-1))&&_--;for(var M=null,D=null,V=0;V=_||$.to<=b)){var te=$.level!=1,oe=Ti(r,a,te?Math.min(_,$.to)-1:Math.max(b,$.from)).right,de=oede)&&(M=$,D=de)}}return M||(M=p[p.length-1]),M.from_&&(M={from:M.from,to:_,level:M.level}),M}o(Mr,"coordsBidiPartWrapped");var mt;function Cs(r){if(r.cachedTextHeight!=null)return r.cachedTextHeight;if(mt==null){mt=Ee("pre",null,"CodeMirror-line-like");for(var i=0;i<49;++i)mt.appendChild(document.createTextNode("x")),mt.appendChild(Ee("br"));mt.appendChild(document.createTextNode("x"))}tt(r.measure,mt);var u=mt.offsetHeight/50;return u>3&&(r.cachedTextHeight=u),Ve(r.measure),u||1}o(Cs,"textHeight");function ua(r){if(r.cachedCharWidth!=null)return r.cachedCharWidth;var i=Ee("span","xxxxxxxxxx"),u=Ee("pre",[i],"CodeMirror-line-like");tt(r.measure,u);var a=i.getBoundingClientRect(),p=(a.right-a.left)/10;return p>2&&(r.cachedCharWidth=p),p||10}o(ua,"charWidth");function Kn(r){for(var i=r.display,u={},a={},p=i.gutters.clientLeft,g=i.gutters.firstChild,y=0;g;g=g.nextSibling,++y){var S=r.display.gutterSpecs[y].className;u[S]=g.offsetLeft+g.clientLeft+p,a[S]=g.clientWidth}return{fixedPos:fa(i),gutterTotalWidth:i.gutters.offsetWidth,gutterLeft:u,gutterWidth:a,wrapperWidth:i.wrapper.clientWidth}}o(Kn,"getDimensions");function fa(r){return r.scroller.getBoundingClientRect().left-r.sizer.getBoundingClientRect().left}o(fa,"compensateForHScroll");function Fm(r){var i=Cs(r.display),u=r.options.lineWrapping,a=u&&Math.max(5,r.display.scroller.clientWidth/ua(r.display)-3);return function(p){if(qt(r.doc,p))return 0;var g=0;if(p.widgets)for(var y=0;y0&&(_=Me(r.doc,b.line).text).length==b.ch){var M=Et(_,_.length,r.options.tabSize)-_.length;b=ue(b.line,Math.max(0,Math.round((g-sa(r.display).left)/ua(r.display))-M))}return b}o(po,"posFromMouse");function ho(r,i){if(i>=r.display.viewTo||(i-=r.display.viewFrom,i<0))return null;for(var u=r.display.view,a=0;ai)&&(p.updateLineNumbers=i),r.curOp.viewChanged=!0,i>=p.viewTo)Ei&&jo(r.doc,i)p.viewFrom?Xo(r):(p.viewFrom+=a,p.viewTo+=a);else if(i<=p.viewFrom&&u>=p.viewTo)Xo(r);else if(i<=p.viewFrom){var g=fl(r,u,u+a,1);g?(p.view=p.view.slice(g.index),p.viewFrom=g.lineN,p.viewTo+=a):Xo(r)}else if(u>=p.viewTo){var y=fl(r,i,i,-1);y?(p.view=p.view.slice(0,y.index),p.viewTo=y.lineN):Xo(r)}else{var S=fl(r,i,i,-1),b=fl(r,u,u+a,1);S&&b?(p.view=p.view.slice(0,S.index).concat(qo(r,S.lineN,b.lineN)).concat(p.view.slice(b.index)),p.viewTo+=a):Xo(r)}var _=p.externalMeasured;_&&(u<_.lineN?_.lineN+=a:i<_.lineN+_.size&&(p.externalMeasured=null))}o(et,"regChange");function _s(r,i,u){r.curOp.viewChanged=!0;var a=r.display,p=r.display.externalMeasured;if(p&&i>=p.lineN&&i=a.viewTo)){var g=a.view[ho(r,i)];if(g.node!=null){var y=g.changes||(g.changes=[]);ut(y,u)==-1&&y.push(u)}}}o(_s,"regLineChange");function Xo(r){r.display.viewFrom=r.display.viewTo=r.doc.first,r.display.view=[],r.display.viewOffset=0}o(Xo,"resetView");function fl(r,i,u,a){var p=ho(r,i),g,y=r.display.view;if(!Ei||u==r.doc.first+r.doc.size)return{index:p,lineN:u};for(var S=r.display.viewFrom,b=0;b0){if(p==y.length-1)return null;g=S+y[p].size-i,p++}else g=S-i;i+=g,u+=g}for(;jo(r.doc,u)!=u;){if(p==(a<0?0:y.length-1))return null;u+=a*y[p-(a<0?1:0)].size,p+=a}return{index:p,lineN:u}}o(fl,"viewCuttingPoint");function Dy(r,i,u){var a=r.display,p=a.view;p.length==0||i>=a.viewTo||u<=a.viewFrom?(a.view=qo(r,i,u),a.viewFrom=i):(a.viewFrom>i?a.view=qo(r,i,a.viewFrom).concat(a.view):a.viewFromu&&(a.view=a.view.slice(0,ho(r,u)))),a.viewTo=u}o(Dy,"adjustView");function Bm(r){for(var i=r.display.view,u=0,a=0;a=r.display.viewTo||S.to().line0?i.blinker=setInterval(function(){r.hasFocus()||pl(r),i.cursorDiv.style.visibility=(u=!u)?"":"hidden"},r.options.cursorBlinkRate):r.options.cursorBlinkRate<0&&(i.cursorDiv.style.visibility="hidden")}}o(ca,"restartBlink");function vd(r){r.hasFocus()||(r.display.input.focus(),r.state.focused||pa(r))}o(vd,"ensureFocus");function hc(r){r.state.delayingBlurEvent=!0,setTimeout(function(){r.state.delayingBlurEvent&&(r.state.delayingBlurEvent=!1,r.state.focused&&pl(r))},100)}o(hc,"delayBlurEvent");function pa(r,i){r.state.delayingBlurEvent&&!r.state.draggingText&&(r.state.delayingBlurEvent=!1),r.options.readOnly!="nocursor"&&(r.state.focused||(Te(r,"focus",r,i),r.state.focused=!0,Xe(r.display.wrapper,"CodeMirror-focused"),!r.curOp&&r.display.selForContextMenu!=r.doc.sel&&(r.display.input.reset(),C&&setTimeout(function(){return r.display.input.reset(!0)},20)),r.display.input.receivedFocus()),ca(r))}o(pa,"onFocus");function pl(r,i){r.state.delayingBlurEvent||(r.state.focused&&(Te(r,"blur",r,i),r.state.focused=!1,xe(r.display.wrapper,"CodeMirror-focused")),clearInterval(r.display.blinker),setTimeout(function(){r.state.focused||(r.display.shift=!1)},150))}o(pl,"onBlur");function _s(r){for(var i=r.display,u=i.lineDiv.offsetTop,a=0;a.005||M<-.005)&&(ai(p.line,y),Ts(p.line),p.rest))for(var D=0;Dr.display.sizerWidth){var V=Math.ceil(S/ua(r.display));V>r.display.maxLineLength&&(r.display.maxLineLength=V,r.display.maxLine=p.line,r.display.maxLineChanged=!0)}}}}o(_s,"updateHeightsInViewport");function Ts(r){if(r.widgets)for(var i=0;i=y&&(g=ao(i,hn(Me(i,b))-r.wrapper.clientHeight),y=b)}return{from:g,to:Math.max(y,g+1)}}o(dl,"visibleLines");function Iy(r,i){if(!ir(r,"scrollCursorIntoView")){var u=r.display,a=u.sizer.getBoundingClientRect(),p=null;if(i.top+a.top<0?p=!0:i.bottom+a.top>(window.innerHeight||document.documentElement.clientHeight)&&(p=!1),p!=null&&!J){var g=_e("div","\u200B",null,`position: absolute; + height: `+(De-Ne)+"px"))}o(M,"add");function D(ve,Ne,Ie){var De=Me(p,ve),it=De.text.length,Tt,br;function At(dr,Vr){return ki(r,ue(ve,dr),"div",De,Vr)}o(At,"coords");function Sn(dr,Vr,Ar){var Pt=Q(r,De,null,dr),Bt=Vr=="ltr"==(Ar=="after")?"left":"right",ar=Ar=="after"?Pt.begin:Pt.end-(/\s/.test(De.text.charAt(Pt.end-1))?2:1);return At(ar,Bt)[Bt]}o(Sn,"wrapX");var Cn=Mn(De,p.direction);return zn(Cn,Ne||0,Ie??it,function(dr,Vr,Ar,Pt){var Bt=Ar=="ltr",ar=At(dr,Bt?"left":"right"),bn=At(Vr-1,Bt?"right":"left"),Aa=Ne==null&&dr==0,Hs=Ie==null&&Vr==it,nn=Pt==0,wo=!Cn||Pt==Cn.length-1;if(bn.top-ar.top<=3){var Dr=(_?Aa:Hs)&&nn,Kd=(_?Hs:Aa)&&wo,rs=Dr?S:(Bt?ar:bn).left,bl=Kd?b:(Bt?bn:ar).right;M(rs,ar.top,bl-rs,ar.bottom)}else{var _l,_n,Da,zc;Bt?(_l=_&&Aa&&nn?S:ar.left,_n=_?b:Sn(dr,Ar,"before"),Da=_?S:Sn(Vr,Ar,"after"),zc=_&&Hs&&wo?b:bn.right):(_l=_?Sn(dr,Ar,"before"):S,_n=!_&&Aa&&nn?b:ar.right,Da=!_&&Hs&&wo?S:bn.left,zc=_?Sn(Vr,Ar,"after"):b),M(_l,ar.top,_n-_l,ar.bottom),ar.bottom0?i.blinker=setInterval(function(){r.hasFocus()||pl(r),i.cursorDiv.style.visibility=(u=!u)?"":"hidden"},r.options.cursorBlinkRate):r.options.cursorBlinkRate<0&&(i.cursorDiv.style.visibility="hidden")}}o(ca,"restartBlink");function vd(r){r.hasFocus()||(r.display.input.focus(),r.state.focused||pa(r))}o(vd,"ensureFocus");function hc(r){r.state.delayingBlurEvent=!0,setTimeout(function(){r.state.delayingBlurEvent&&(r.state.delayingBlurEvent=!1,r.state.focused&&pl(r))},100)}o(hc,"delayBlurEvent");function pa(r,i){r.state.delayingBlurEvent&&!r.state.draggingText&&(r.state.delayingBlurEvent=!1),r.options.readOnly!="nocursor"&&(r.state.focused||(Te(r,"focus",r,i),r.state.focused=!0,Xe(r.display.wrapper,"CodeMirror-focused"),!r.curOp&&r.display.selForContextMenu!=r.doc.sel&&(r.display.input.reset(),C&&setTimeout(function(){return r.display.input.reset(!0)},20)),r.display.input.receivedFocus()),ca(r))}o(pa,"onFocus");function pl(r,i){r.state.delayingBlurEvent||(r.state.focused&&(Te(r,"blur",r,i),r.state.focused=!1,xe(r.display.wrapper,"CodeMirror-focused")),clearInterval(r.display.blinker),setTimeout(function(){r.state.focused||(r.display.shift=!1)},150))}o(pl,"onBlur");function Es(r){for(var i=r.display,u=i.lineDiv.offsetTop,a=0;a.005||M<-.005)&&(ai(p.line,y),Ts(p.line),p.rest))for(var D=0;Dr.display.sizerWidth){var V=Math.ceil(S/ua(r.display));V>r.display.maxLineLength&&(r.display.maxLineLength=V,r.display.maxLine=p.line,r.display.maxLineChanged=!0)}}}}o(Es,"updateHeightsInViewport");function Ts(r){if(r.widgets)for(var i=0;i=y&&(g=ao(i,hn(Me(i,b))-r.wrapper.clientHeight),y=b)}return{from:g,to:Math.max(y,g+1)}}o(dl,"visibleLines");function Ry(r,i){if(!ir(r,"scrollCursorIntoView")){var u=r.display,a=u.sizer.getBoundingClientRect(),p=null;if(i.top+a.top<0?p=!0:i.bottom+a.top>(window.innerHeight||document.documentElement.clientHeight)&&(p=!1),p!=null&&!J){var g=Ee("div","\u200B",null,`position: absolute; top: `+(i.top-u.viewOffset-Ss(r.display))+`px; height: `+(i.bottom-i.top+mn(r)+u.barHeight)+`px; - left: `+i.left+"px; width: "+Math.max(2,i.right-i.left)+"px;");r.display.lineSpace.appendChild(g),g.scrollIntoView(p),r.display.lineSpace.removeChild(g)}}}o(Iy,"maybeScrollWindow");function Fy(r,i,u,a){a==null&&(a=0);var p;!r.options.lineWrapping&&i==u&&(u=i.sticky=="before"?ue(i.line,i.ch+1,"before"):i,i=i.ch?ue(i.line,i.sticky=="before"?i.ch-1:i.ch,"after"):i);for(var g=0;g<5;g++){var y=!1,S=Vn(r,i),b=!u||u==i?S:Vn(r,u);p={left:Math.min(S.left,b.left),top:Math.min(S.top,b.top)-a,right:Math.max(S.left,b.left),bottom:Math.max(S.bottom,b.bottom)+a};var E=da(r,p),M=r.doc.scrollTop,D=r.doc.scrollLeft;if(E.scrollTop!=null&&(sr(r,E.scrollTop),Math.abs(r.doc.scrollTop-M)>1&&(y=!0)),E.scrollLeft!=null&&(hl(r,E.scrollLeft),Math.abs(r.doc.scrollLeft-D)>1&&(y=!0)),!y)break}return p}o(Fy,"scrollPosIntoView");function By(r,i){var u=da(r,i);u.scrollTop!=null&&sr(r,u.scrollTop),u.scrollLeft!=null&&hl(r,u.scrollLeft)}o(By,"scrollIntoView");function da(r,i){var u=r.display,a=Cs(r.display);i.top<0&&(i.top=0);var p=r.curOp&&r.curOp.scrollTop!=null?r.curOp.scrollTop:u.scroller.scrollTop,g=al(r),y={};i.bottom-i.top>g&&(i.bottom=i.top+g);var S=r.doc.height+zr(u),b=i.topS-a;if(i.topp+g){var M=Math.min(i.top,(E?S:i.bottom)-g);M!=p&&(y.scrollTop=M)}var D=r.options.fixedGutter?0:u.gutters.offsetWidth,V=r.curOp&&r.curOp.scrollLeft!=null?r.curOp.scrollLeft:u.scroller.scrollLeft-D,$=qi(r)-u.gutters.offsetWidth,te=i.right-i.left>$;return te&&(i.right=i.left+$),i.left<10?y.scrollLeft=0:i.left$+V-3&&(y.scrollLeft=i.right+(te?0:10)-$),y}o(da,"calculateScrollPos");function ha(r,i){i!=null&&(mc(r),r.curOp.scrollTop=(r.curOp.scrollTop==null?r.doc.scrollTop:r.curOp.scrollTop)+i)}o(ha,"addToScrollTop");function ks(r){mc(r);var i=r.getCursor();r.curOp.scrollToPos={from:i,to:i,margin:r.options.cursorScrollMargin}}o(ks,"ensureCursorVisible");function qu(r,i,u){(i!=null||u!=null)&&mc(r),i!=null&&(r.curOp.scrollLeft=i),u!=null&&(r.curOp.scrollTop=u)}o(qu,"scrollToCoords");function Um(r,i){mc(r),r.curOp.scrollToPos=i}o(Um,"scrollToRange");function mc(r){var i=r.curOp.scrollToPos;if(i){r.curOp.scrollToPos=null;var u=zu(r,i.from),a=zu(r,i.to);zm(r,u,a,i.margin)}}o(mc,"resolveScrollToPos");function zm(r,i,u,a){var p=da(r,{left:Math.min(i.left,u.left),top:Math.min(i.top,u.top)-a,right:Math.max(i.right,u.right),bottom:Math.max(i.bottom,u.bottom)+a});qu(r,p.scrollLeft,p.scrollTop)}o(zm,"scrollToCoordsRange");function sr(r,i){Math.abs(r.doc.scrollTop-i)<2||(n||wd(r,{top:i}),Zr(r,i,!0),n&&wd(r),go(r,100))}o(sr,"updateScrollTop");function Zr(r,i,u){i=Math.max(0,Math.min(r.display.scroller.scrollHeight-r.display.scroller.clientHeight,i)),!(r.display.scroller.scrollTop==i&&!u)&&(r.doc.scrollTop=i,r.display.scrollbars.setScrollTop(i),r.display.scroller.scrollTop!=i&&(r.display.scroller.scrollTop=i))}o(Zr,"setScrollTop");function hl(r,i,u,a){i=Math.max(0,Math.min(i,r.display.scroller.scrollWidth-r.display.scroller.clientWidth)),!((u?i==r.doc.scrollLeft:Math.abs(r.doc.scrollLeft-i)<2)&&!a)&&(r.doc.scrollLeft=i,$m(r),r.display.scroller.scrollLeft!=i&&(r.display.scroller.scrollLeft=i),r.display.scrollbars.setScrollLeft(i))}o(hl,"setScrollLeft");function Vu(r){var i=r.display,u=i.gutters.offsetWidth,a=Math.round(r.doc.height+zr(r.display));return{clientHeight:i.scroller.clientHeight,viewHeight:i.wrapper.clientHeight,scrollWidth:i.scroller.scrollWidth,clientWidth:i.scroller.clientWidth,viewWidth:i.wrapper.clientWidth,barLeft:r.options.fixedGutter?u:0,docHeight:a,scrollHeight:a+mn(r)+i.barHeight,nativeBarWidth:i.nativeBarWidth,gutterWidth:u}}o(Vu,"measureForScrollbars");var Ns=o(function(r,i,u){this.cm=u;var a=this.vert=_e("div",[_e("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),p=this.horiz=_e("div",[_e("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");a.tabIndex=p.tabIndex=-1,r(a),r(p),H(a,"scroll",function(){a.clientHeight&&i(a.scrollTop,"vertical")}),H(p,"scroll",function(){p.clientWidth&&i(p.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,c&&v<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")},"NativeScrollbars");Ns.prototype.update=function(r){var i=r.scrollWidth>r.clientWidth+1,u=r.scrollHeight>r.clientHeight+1,a=r.nativeBarWidth;if(u){this.vert.style.display="block",this.vert.style.bottom=i?a+"px":"0";var p=r.viewHeight-(i?a:0);this.vert.firstChild.style.height=Math.max(0,r.scrollHeight-r.clientHeight+p)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(i){this.horiz.style.display="block",this.horiz.style.right=u?a+"px":"0",this.horiz.style.left=r.barLeft+"px";var g=r.viewWidth-r.barLeft-(u?a:0);this.horiz.firstChild.style.width=Math.max(0,r.scrollWidth-r.clientWidth+g)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&r.clientHeight>0&&(a==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:u?a:0,bottom:i?a:0}},Ns.prototype.setScrollLeft=function(r){this.horiz.scrollLeft!=r&&(this.horiz.scrollLeft=r),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ns.prototype.setScrollTop=function(r){this.vert.scrollTop!=r&&(this.vert.scrollTop=r),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ns.prototype.zeroWidthHack=function(){var r=I&&!X?"12px":"18px";this.horiz.style.height=this.vert.style.width=r,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Ct,this.disableVert=new Ct},Ns.prototype.enableZeroWidthBar=function(r,i,u){r.style.pointerEvents="auto";function a(){var p=r.getBoundingClientRect(),g=u=="vert"?document.elementFromPoint(p.right-1,(p.top+p.bottom)/2):document.elementFromPoint((p.right+p.left)/2,p.bottom-1);g!=r?r.style.pointerEvents="none":i.set(1e3,a)}o(a,"maybeDisable"),i.set(1e3,a)},Ns.prototype.clear=function(){var r=this.horiz.parentNode;r.removeChild(this.horiz),r.removeChild(this.vert)};var Ku=o(function(){},"NullScrollbars");Ku.prototype.update=function(){return{bottom:0,right:0}},Ku.prototype.setScrollLeft=function(){},Ku.prototype.setScrollTop=function(){},Ku.prototype.clear=function(){};function Ls(r,i){i||(i=Vu(r));var u=r.display.barWidth,a=r.display.barHeight;ma(r,i);for(var p=0;p<4&&u!=r.display.barWidth||a!=r.display.barHeight;p++)u!=r.display.barWidth&&r.options.lineWrapping&&_s(r),ma(r,Vu(r)),u=r.display.barWidth,a=r.display.barHeight}o(Ls,"updateScrollbars");function ma(r,i){var u=r.display,a=u.scrollbars.update(i);u.sizer.style.paddingRight=(u.barWidth=a.right)+"px",u.sizer.style.paddingBottom=(u.barHeight=a.bottom)+"px",u.heightForcer.style.borderBottom=a.bottom+"px solid transparent",a.right&&a.bottom?(u.scrollbarFiller.style.display="block",u.scrollbarFiller.style.height=a.bottom+"px",u.scrollbarFiller.style.width=a.right+"px"):u.scrollbarFiller.style.display="",a.bottom&&r.options.coverGutterNextToScrollbar&&r.options.fixedGutter?(u.gutterFiller.style.display="block",u.gutterFiller.style.height=a.bottom+"px",u.gutterFiller.style.width=i.gutterWidth+"px"):u.gutterFiller.style.display=""}o(ma,"updateScrollbarsInner");var gc={native:Ns,null:Ku};function ml(r){r.display.scrollbars&&(r.display.scrollbars.clear(),r.display.scrollbars.addClass&&xe(r.display.wrapper,r.display.scrollbars.addClass)),r.display.scrollbars=new gc[r.options.scrollbarStyle](function(i){r.display.wrapper.insertBefore(i,r.display.scrollbarFiller),H(i,"mousedown",function(){r.state.focused&&setTimeout(function(){return r.display.input.focus()},0)}),i.setAttribute("cm-not-content","true")},function(i,u){u=="horizontal"?hl(r,i):sr(r,i)},r),r.display.scrollbars.addClass&&Xe(r.display.wrapper,r.display.scrollbars.addClass)}o(ml,"initScrollbars");var Gu=0;function Ki(r){r.curOp={cm:r,viewChanged:!1,startHeight:r.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Gu,markArrays:null},$i(r.curOp)}o(Ki,"startOperation");function mo(r){var i=r.curOp;i&&hd(i,function(u){for(var a=0;a=u.viewTo)||u.maxLineChanged&&i.options.lineWrapping,r.update=r.mustUpdate&&new An(i,r.mustUpdate&&{top:r.scrollTop,ensure:r.scrollToPos},r.forceUpdate)}o(Hy,"endOperation_R1");function Wy(r){r.updatedDisplay=r.mustUpdate&&yd(r.cm,r.update)}o(Wy,"endOperation_W1");function Uy(r){var i=r.cm,u=i.display;r.updatedDisplay&&_s(i),r.barMeasure=Vu(i),u.maxLineChanged&&!i.options.lineWrapping&&(r.adjustWidthTo=Uu(i,u.maxLine,u.maxLine.text.length).left+3,i.display.sizerWidth=r.adjustWidthTo,r.barMeasure.scrollWidth=Math.max(u.scroller.clientWidth,u.sizer.offsetLeft+r.adjustWidthTo+mn(i)+i.display.barWidth),r.maxScrollLeft=Math.max(0,u.sizer.offsetLeft+r.adjustWidthTo-qi(i))),(r.updatedDisplay||r.selectionChanged)&&(r.preparedSelection=u.input.prepareSelection())}o(Uy,"endOperation_R2");function zy(r){var i=r.cm;r.adjustWidthTo!=null&&(i.display.sizer.style.minWidth=r.adjustWidthTo+"px",r.maxScrollLeft=r.display.viewTo)){var u=+new Date+r.options.workTime,a=$o(r,i.highlightFrontier),p=[];i.iter(a.line,Math.min(i.first+i.size,r.display.viewTo+500),function(g){if(a.line>=r.display.viewFrom){var y=g.styles,S=g.text.length>r.options.maxHighlightLength?Uo(i.mode,a.state):null,b=tc(r,g,a,!0);S&&(a.state=S),g.styles=b.styles;var E=g.styleClasses,M=b.classes;M?g.styleClasses=M:E&&(g.styleClasses=null);for(var D=!y||y.length!=g.styles.length||E!=M&&(!E||!M||E.bgClass!=M.bgClass||E.textClass!=M.textClass),V=0;!D&&Vu)return go(r,r.options.workDelay),!0}),i.highlightFrontier=a.line,i.modeFrontier=Math.max(i.modeFrontier,a.line),p.length&&Jr(r,function(){for(var g=0;g=u.viewFrom&&i.visible.to<=u.viewTo&&(u.updateLineNumbers==null||u.updateLineNumbers>=u.viewTo)&&u.renderedView==u.view&&Hm(r)==0)return!1;vo(r)&&(Xo(r),i.dims=Kn(r));var p=a.first+a.size,g=Math.max(i.visible.from-r.options.viewportMargin,a.first),y=Math.min(p,i.visible.to+r.options.viewportMargin);u.viewFromy&&u.viewTo-y<20&&(y=Math.min(p,u.viewTo)),_i&&(g=jo(r.doc,g),y=pd(r.doc,y));var S=g!=u.viewFrom||y!=u.viewTo||u.lastWrapHeight!=i.wrapperHeight||u.lastWrapWidth!=i.wrapperWidth;Ry(r,g,y),u.viewOffset=hn(Me(r.doc,u.viewFrom)),r.display.mover.style.top=u.viewOffset+"px";var b=Hm(r);if(!S&&b==0&&!i.force&&u.renderedView==u.view&&(u.updateLineNumbers==null||u.updateLineNumbers>=u.viewTo))return!1;var E=jy(r);return b>4&&(u.lineDiv.style.display="none"),Vy(r,u.updateLineNumbers,i.dims),b>4&&(u.lineDiv.style.display=""),u.renderedView=u.view,qy(E),Ve(u.cursorDiv),Ve(u.selectionDiv),u.gutters.style.height=u.sizer.style.minHeight=0,S&&(u.lastWrapHeight=i.wrapperHeight,u.lastWrapWidth=i.wrapperWidth,go(r,400)),u.updateLineNumbers=null,!0}o(yd,"updateDisplayIfNeeded");function Ps(r,i){for(var u=i.viewport,a=!0;;a=!1){if(!a||!r.options.lineWrapping||i.oldDisplayWidth==qi(r)){if(u&&u.top!=null&&(u={top:Math.min(r.doc.height+zr(r.display)-al(r),u.top)}),i.visible=dl(r.display,r.doc,u),i.visible.from>=r.display.viewFrom&&i.visible.to<=r.display.viewTo)break}else a&&(i.visible=dl(r.display,r.doc,u));if(!yd(r,i))break;_s(r);var p=Vu(r);$u(r),Ls(r,p),Sd(r,p),i.force=!1}i.signal(r,"update",r),(r.display.viewFrom!=r.display.reportedViewFrom||r.display.viewTo!=r.display.reportedViewTo)&&(i.signal(r,"viewportChange",r,r.display.viewFrom,r.display.viewTo),r.display.reportedViewFrom=r.display.viewFrom,r.display.reportedViewTo=r.display.viewTo)}o(Ps,"postUpdateDisplay");function wd(r,i){var u=new An(r,i);if(yd(r,u)){_s(r),Ps(r,u);var a=Vu(r);$u(r),Ls(r,a),Sd(r,a),u.finish()}}o(wd,"updateDisplaySimple");function Vy(r,i,u){var a=r.display,p=r.options.lineNumbers,g=a.lineDiv,y=g.firstChild;function S(te){var oe=te.nextSibling;return C&&I&&r.display.currentWheelTarget==te?te.style.display="none":te.parentNode.removeChild(te),oe}o(S,"rm");for(var b=a.view,E=a.viewFrom,M=0;M-1&&($=!1),Du(r,D,E,u)),$&&(Ve(D.lineNumber),D.lineNumber.appendChild(document.createTextNode(jl(r.options,E)))),y=D.node.nextSibling}E+=D.size}for(;y;)y=S(y)}o(Vy,"patchDisplay");function xd(r){var i=r.gutters.offsetWidth;r.sizer.style.marginLeft=i+"px",yr(r,"gutterChanged",r)}o(xd,"updateGutterSpace");function Sd(r,i){r.display.sizer.style.minHeight=i.docHeight+"px",r.display.heightForcer.style.top=i.docHeight+"px",r.display.gutters.style.height=i.docHeight+r.display.barHeight+mn(r)+"px"}o(Sd,"setDocumentHeight");function $m(r){var i=r.display,u=i.view;if(!(!i.alignWidgets&&(!i.gutters.firstChild||!r.options.fixedGutter))){for(var a=fa(i)-i.scroller.scrollLeft+r.doc.scrollLeft,p=i.gutters.offsetWidth,g=a+"px",y=0;yy.clientWidth,b=y.scrollHeight>y.clientHeight;if(!!(a&&S||p&&b)){if(p&&I&&C){e:for(var E=i.target,M=g.view;E!=y;E=E.parentNode)for(var D=0;D=0&&ze(r,a.to())<=0)return u}return-1};var wt=o(function(r,i){this.anchor=r,this.head=i},"Range");wt.prototype.from=function(){return il(this.anchor,this.head)},wt.prototype.to=function(){return gs(this.anchor,this.head)},wt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function tn(r,i,u){var a=r&&r.options.selectionsMayTouch,p=i[u];i.sort(function(V,$){return ze(V.from(),$.from())}),u=ut(i,p);for(var g=1;g0:b>=0){var E=il(S.from(),y.from()),M=gs(S.to(),y.to()),D=S.empty()?y.from()==y.head:S.from()==S.head;g<=u&&--u,i.splice(--g,2,new wt(D?M:E,D?E:M))}}return new pi(i,u)}o(tn,"normalizeSelection");function Os(r,i){return new pi([new wt(r,i||r)],0)}o(Os,"simpleSelection");function Ms(r){return r.text?ue(r.from.line+r.text.length-1,Se(r.text).length+(r.text.length==1?r.from.ch:0)):r.to}o(Ms,"changeEnd");function Ni(r,i){if(ze(r,i.from)<0)return r;if(ze(r,i.to)<=0)return Ms(i);var u=r.line+i.text.length-(i.to.line-i.from.line)-1,a=r.ch;return r.line==i.to.line&&(a+=Ms(i).ch-i.to.ch),ue(u,a)}o(Ni,"adjustForChange");function bd(r,i){for(var u=[],a=0;a1&&r.remove(S.line+1,te-1),r.insert(S.line+1,ge)}yr(r,"change",r,i)}o(wc,"updateDoc");function As(r,i,u){function a(p,g,y){if(p.linked)for(var S=0;S1&&!r.done[r.done.length-2].ranges)return r.done.pop(),Se(r.done)}o(Xy,"lastChangeEvent");function yo(r,i,u,a){var p=r.history;p.undone.length=0;var g=+new Date,y,S;if((p.lastOp==a||p.lastOrigin==i.origin&&i.origin&&(i.origin.charAt(0)=="+"&&p.lastModTime>g-(r.cm?r.cm.options.historyEventDelay:500)||i.origin.charAt(0)=="*"))&&(y=Xy(p,p.lastOp==a)))S=Se(y.changes),ze(i.from,i.to)==0&&ze(i.from,S.to)==0?S.to=Ms(i):y.changes.push(Td(r,i));else{var b=Se(p.done);for((!b||!b.ranges)&&Dn(r.sel,p.done),y={changes:[Td(r,i)],generation:p.generation},p.done.push(y);p.done.length>p.undoDepth;)p.done.shift(),p.done[0].ranges||p.done.shift()}p.done.push(u),p.generation=++p.maxGeneration,p.lastModTime=p.lastSelTime=g,p.lastOp=p.lastSelOp=a,p.lastOrigin=p.lastSelOrigin=i.origin,S||Te(r,"historyAdded")}o(yo,"addChangeToHistory");function Nd(r,i,u,a){var p=i.charAt(0);return p=="*"||p=="+"&&u.ranges.length==a.ranges.length&&u.somethingSelected()==a.somethingSelected()&&new Date-r.history.lastSelTime<=(r.cm?r.cm.options.historyEventDelay:500)}o(Nd,"selectionEventCanBeMerged");function vl(r,i,u,a){var p=r.history,g=a&&a.origin;u==p.lastSelOp||g&&p.lastSelOrigin==g&&(p.lastModTime==p.lastSelTime&&p.lastOrigin==g||Nd(r,g,Se(p.done),i))?p.done[p.done.length-1]=i:Dn(i,p.done),p.lastSelTime=+new Date,p.lastSelOrigin=g,p.lastSelOp=u,a&&a.clearRedo!==!1&&kd(p.undone)}o(vl,"addSelectionToHistory");function Dn(r,i){var u=Se(i);u&&u.ranges&&u.equals(r)||i.push(r)}o(Dn,"pushSelectionToHistory");function Ym(r,i,u,a){var p=i["spans_"+r.id],g=0;r.iter(Math.max(r.first,u),Math.min(r.first+r.size,a),function(y){y.markedSpans&&((p||(p=i["spans_"+r.id]={}))[g]=y.markedSpans),++g})}o(Ym,"attachLocalSpans");function Xm(r){if(!r)return null;for(var i,u=0;u-1&&(Se(S)[D]=E[D],delete E[D])}}return a}o(di,"copyHistoryArray");function Sc(r,i,u,a){if(a){var p=r.anchor;if(u){var g=ze(i,p)<0;g!=ze(u,p)<0?(p=i,i=u):g!=ze(i,u)<0&&(i=u)}return new wt(p,i)}else return new wt(u||i,i)}o(Sc,"extendRange");function Cc(r,i,u,a,p){p==null&&(p=r.cm&&(r.cm.display.shift||r.extend)),$r(r,new pi([Sc(r.sel.primary(),i,u,p)],0),a)}o(Cc,"extendSelection");function Zu(r,i,u){for(var a=[],p=r.cm&&(r.cm.display.shift||r.extend),g=0;g=i.ch:S.to>i.ch))){if(p&&(Te(b,"beforeCursorEnter"),b.explicitlyCleared))if(g.markedSpans){--y;continue}else break;if(!b.atomic)continue;if(u){var D=b.find(a<0?1:-1),V=void 0;if((a<0?M:E)&&(D=_c(r,D,-a,D&&D.line==i.line?g:null)),D&&D.line==i.line&&(V=ze(D,u))&&(a<0?V<0:V>0))return yl(r,D,i,a,p)}var $=b.find(a<0?-1:1);return(a<0?E:M)&&($=_c(r,$,a,$.line==i.line?g:null)),$?yl(r,$,i,a,p):null}}return i}o(yl,"skipAtomicInner");function jr(r,i,u,a,p){var g=a||1,y=yl(r,i,u,g,p)||!p&&yl(r,i,u,g,!0)||yl(r,i,u,-g,p)||!p&&yl(r,i,u,-g,!0);return y||(r.cantEdit=!0,ue(r.first,0))}o(jr,"skipAtomic");function _c(r,i,u,a){return u<0&&i.ch==0?i.line>r.first?He(r,ue(i.line-1)):null:u>0&&i.ch==(a||Me(r,i.line)).text.length?i.line=0;--p)Tc(r,{from:a[p].from,to:a[p].to,text:p?[""]:i.text,origin:i.origin});else Tc(r,i)}}o(ya,"makeChange");function Tc(r,i){if(!(i.text.length==1&&i.text[0]==""&&ze(i.from,i.to)==0)){var u=bd(r,i);yo(r,i,u,r.cm?r.cm.curOp.id:NaN),xa(r,i,u,ku(r,i));var a=[];As(r,function(p,g){!g&&ut(a,p.history)==-1&&(tg(p.history,i),a.push(p.history)),xa(p,i,null,ku(p,i))})}}o(Tc,"makeChangeInner");function kc(r,i,u){var a=r.cm&&r.cm.state.suppressEdits;if(!(a&&!u)){for(var p=r.history,g,y=r.sel,S=i=="undo"?p.done:p.undone,b=i=="undo"?p.undone:p.done,E=0;E=0;--$){var te=V($);if(te)return te.v}}}}o(kc,"makeChangeFromHistory");function wa(r,i){if(i!=0&&(r.first+=i,r.sel=new pi(Or(r.sel.ranges,function(p){return new wt(ue(p.anchor.line+i,p.anchor.ch),ue(p.head.line+i,p.head.ch))}),r.sel.primIndex),r.cm)){et(r.cm,r.first,r.first-i,i);for(var u=r.cm.display,a=u.viewFrom;ar.lastLine())){if(i.from.lineg&&(i={from:i.from,to:ue(g,Me(r,g).text.length),text:[i.text[0]],origin:i.origin}),i.removed=Ei(r,i.from,i.to),u||(u=bd(r,i)),r.cm?Qy(r.cm,i,a):wc(r,i,a),hi(r,u,$t),r.cantEdit&&jr(r,ue(r.firstLine(),0))&&(r.cantEdit=!1)}}o(xa,"makeChangeSingleDoc");function Qy(r,i,u){var a=r.doc,p=r.display,g=i.from,y=i.to,S=!1,b=g.line;r.options.lineWrapping||(b=vt(vr(Me(a,g.line))),a.iter(b,y.line+1,function($){if($==p.maxLine)return S=!0,!0})),a.sel.contains(i.from,i.to)>-1&&Ul(r),wc(a,i,u,Bm(r)),r.options.lineWrapping||(a.iter(b,g.line+i.text.length,function($){var te=ws($);te>p.maxLineLength&&(p.maxLine=$,p.maxLineLength=te,p.maxLineChanged=!0,S=!1)}),S&&(r.curOp.updateMaxLine=!0)),rc(a,g.line),go(r,400);var E=i.text.length-(y.line-g.line)-1;i.full?et(r):g.line==y.line&&i.text.length==1&&!_d(r.doc,i)?Es(r,g.line,"text"):et(r,g.line,y.line+1,E);var M=Ft(r,"changes"),D=Ft(r,"change");if(D||M){var V={from:g,to:y,text:i.text,removed:i.removed,origin:i.origin};D&&yr(r,"change",r,V),M&&(r.curOp.changeObjs||(r.curOp.changeObjs=[])).push(V)}r.display.selForContextMenu=null}o(Qy,"makeChangeSingleDocInEditor");function Sa(r,i,u,a,p){var g;a||(a=u),ze(a,u)<0&&(g=[a,u],u=g[0],a=g[1]),typeof i=="string"&&(i=r.splitLines(i)),ya(r,{from:u,to:a,text:i,origin:p})}o(Sa,"replaceRange");function Ca(r,i,u,a){u1||!(this.children[0]instanceof ba))){var S=[];this.collapse(S),this.children=[new ba(S)],this.children[0].parent=this}},collapse:function(r){for(var i=0;i50){for(var y=p.lines.length%25+25,S=y;S10);r.parent.maybeSpill()}},iterN:function(r,i,u){for(var a=0;ar.display.maxLineLength&&(r.display.maxLine=E,r.display.maxLineLength=M,r.display.maxLineChanged=!0)}a!=null&&r&&this.collapsed&&et(r,a,p+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,r&&Ju(r.doc)),r&&yr(r,"markerCleared",r,this,a,p),i&&mo(r),this.parent&&this.parent.clear()}},Rs.prototype.find=function(r,i){r==null&&this.type=="bookmark"&&(r=1);for(var u,a,p=0;p0||y==0&&g.clearWhenEmpty!==!1)return g;if(g.replacedWith&&(g.collapsed=!0,g.widgetNode=St("span",[g.replacedWith],"CodeMirror-widget"),a.handleMouseEvents||g.widgetNode.setAttribute("cm-ignore-events","true"),a.insertLeft&&(g.widgetNode.insertLeft=!0)),g.collapsed){if(sl(r,i.line,i,u,g)||i.line!=u.line&&sl(r,u.line,i,u,g))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ql()}g.addToHistory&&yo(r,{from:i,to:u,origin:"markText"},r.sel,NaN);var S=i.line,b=r.cm,E;if(r.iter(S,u.line+1,function(D){b&&g.collapsed&&!b.options.lineWrapping&&vr(D)==b.display.maxLine&&(E=!0),g.collapsed&&S!=i.line&&ai(D,0),oc(D,new co(g,S==i.line?i.ch:null,S==u.line?u.ch:null),r.cm&&r.cm.curOp),++S}),g.collapsed&&r.iter(i.line,u.line+1,function(D){qt(r,D)&&ai(D,0)}),g.clearOnEnter&&H(g,"beforeCursorEnter",function(){return g.clear()}),g.readOnly&&(nc(),(r.history.done.length||r.history.undone.length)&&r.clearHistory()),g.collapsed&&(g.id=++Nc,g.atomic=!0),b){if(E&&(b.curOp.updateMaxLine=!0),g.collapsed)et(b,i.line,u.line+1);else if(g.className||g.startStyle||g.endStyle||g.css||g.attributes||g.title)for(var M=i.line;M<=u.line;M++)Es(b,M,"text");g.atomic&&Ju(b.doc),yr(b,"markerAdded",b,g)}return g}o(Is,"markText");var Ea=o(function(r,i){this.markers=r,this.primary=i;for(var u=0;u=0;b--)ya(this,a[b]);S?bc(this,S):this.cm&&ks(this.cm)}),undo:N(function(){kc(this,"undo")}),redo:N(function(){kc(this,"redo")}),undoSelection:N(function(){kc(this,"undo",!0)}),redoSelection:N(function(){kc(this,"redo",!0)}),setExtending:function(r){this.extend=r},getExtending:function(){return this.extend},historySize:function(){for(var r=this.history,i=0,u=0,a=0;a=r.ch)&&i.push(p.marker.parent||p.marker)}return i},findMarks:function(r,i,u){r=He(this,r),i=He(this,i);var a=[],p=r.line;return this.iter(r.line,i.line+1,function(g){var y=g.markedSpans;if(y)for(var S=0;S=b.to||b.from==null&&p!=r.line||b.from!=null&&p==i.line&&b.from>=i.ch)&&(!u||u(b.marker))&&a.push(b.marker.parent||b.marker)}++p}),a},getAllMarks:function(){var r=[];return this.iter(function(i){var u=i.markedSpans;if(u)for(var a=0;ar)return i=r,!0;r-=g,++u}),He(this,ue(u,i))},indexFromPos:function(r){r=He(this,r);var i=r.ch;if(r.linei&&(i=r.from),r.to!=null&&r.to-1){i.state.draggingText(r),setTimeout(function(){return i.display.input.focus()},20);return}try{var M=r.dataTransfer.getData("Text");if(M){var D;if(i.state.draggingText&&!i.state.draggingText.copy&&(D=i.listSelections()),hi(i.doc,Os(u,u)),D)for(var V=0;V=0;S--)Sa(r.doc,"",a[S].from,a[S].to,"+delete");ks(r)})}o(mi,"deleteNearSelection");function of(r,i,u){var a=Ui(r.text,i+u,u);return a<0||a>r.text.length?null:a}o(of,"moveCharLogically");function Mc(r,i,u){var a=of(r,i.ch,u);return a==null?null:new ue(i.line,a,u<0?"after":"before")}o(Mc,"moveLogically");function _a(r,i,u,a,p){if(r){i.doc.direction=="rtl"&&(p=-p);var g=Mn(u,i.doc.direction);if(g){var y=p<0?Se(g):g[0],S=p<0==(y.level==1),b=S?"after":"before",E;if(y.level>0||i.doc.direction=="rtl"){var M=qn(i,u);E=p<0?u.text.length-1:0;var D=Ti(i,M,E).top;E=pn(function(V){return Ti(i,M,V).top==D},p<0==(y.level==1)?y.from:y.to-1,E),b=="before"&&(E=of(u,E,1))}else E=p<0?y.to:y.from;return new ue(a,E,b)}}return new ue(a,p<0?u.text.length:0,p<0?"before":"after")}o(_a,"endOfLine");function ug(r,i,u,a){var p=Mn(i,r.doc.direction);if(!p)return Mc(i,u,a);u.ch>=i.text.length?(u.ch=i.text.length,u.sticky="before"):u.ch<=0&&(u.ch=0,u.sticky="after");var g=Ci(p,u.ch,u.sticky),y=p[g];if(r.doc.direction=="ltr"&&y.level%2==0&&(a>0?y.to>u.ch:y.from=y.from&&V>=M.begin)){var $=D?"before":"after";return new ue(u.line,V,$)}}var te=o(function(ge,be,ve){for(var Ne=o(function(Tt,br){return br?new ue(u.line,S(Tt,1),"before"):new ue(u.line,Tt,"after")},"getRes");ge>=0&&ge0==(Ie.level!=1),it=De?ve.begin:S(ve.end,-1);if(Ie.from<=it&&it0?M.end:S(M.begin,-1);return de!=null&&!(a>0&&de==i.text.length)&&(oe=te(a>0?0:p.length-1,a,E(de)),oe)?oe:null}o(ug,"moveVisually");var xl={selectAll:Zm,singleSelection:function(r){return r.setSelection(r.getCursor("anchor"),r.getCursor("head"),$t)},killLine:function(r){return mi(r,function(i){if(i.empty()){var u=Me(r.doc,i.head.line).text.length;return i.head.ch==u&&i.head.line0)p=new ue(p.line,p.ch+1),r.replaceRange(g.charAt(p.ch-1)+g.charAt(p.ch-2),ue(p.line,p.ch-2),p,"+transpose");else if(p.line>r.doc.first){var y=Me(r.doc,p.line-1).text;y&&(p=new ue(p.line,1),r.replaceRange(g.charAt(0)+r.doc.lineSeparator()+y.charAt(y.length-1),ue(p.line-1,y.length-1),p,"+transpose"))}}u.push(new wt(p,p))}r.setSelections(u)})},newlineAndIndent:function(r){return Jr(r,function(){for(var i=r.listSelections(),u=i.length-1;u>=0;u--)r.replaceRange(r.doc.lineSeparator(),i[u].anchor,i[u].head,"+input");i=r.listSelections();for(var a=0;ar&&ze(i,this.pos)==0&&u==this.button};var qr,Gn;function iw(r,i){var u=+new Date;return Gn&&Gn.compare(u,r,i)?(qr=Gn=null,"triple"):qr&&qr.compare(u,r,i)?(Gn=new Rc(u,r,i),qr=null,"double"):(qr=new Rc(u,r,i),Gn=null,"single")}o(iw,"clickRepeat");function hg(r){var i=this,u=i.display;if(!(ir(i,r)||u.activeTouch&&u.input.supportsTouch())){if(u.input.ensurePolled(),u.shift=r.shiftKey,ji(u,r)){C||(u.scroller.draggable=!1,setTimeout(function(){return u.scroller.draggable=!0},100));return}if(!zd(i,r)){var a=po(i,r),p=el(r),g=a?iw(a,p):"single";window.focus(),p==1&&i.state.selectingText&&i.state.selectingText(r),!(a&&Ic(i,p,a,g,r))&&(p==1?a?mg(i,a,g,r):bi(r)==u.scroller&&or(r):p==2?(a&&Cc(i.doc,a),setTimeout(function(){return u.input.focus()},20)):p==3&&(pe?i.display.input.onContextMenu(r):hc(i)))}}}o(hg,"onMouseDown");function Ic(r,i,u,a,p){var g="Click";return a=="double"?g="Double"+g:a=="triple"&&(g="Triple"+g),g=(i==1?"Left":i==2?"Middle":"Right")+g,Ta(r,Rd(g,p),p,function(y){if(typeof y=="string"&&(y=xl[y]),!y)return!1;var S=!1;try{r.isReadOnly()&&(r.state.suppressEdits=!0),S=y(r,u)!=zt}finally{r.state.suppressEdits=!1}return S})}o(Ic,"handleMappedButton");function ka(r,i,u){var a=r.getOption("configureMouse"),p=a?a(r,i,u):{};if(p.unit==null){var g=G?u.shiftKey&&u.metaKey:u.altKey;p.unit=g?"rectangle":i=="single"?"char":i=="double"?"word":"line"}return(p.extend==null||r.doc.extend)&&(p.extend=r.doc.extend||u.shiftKey),p.addNew==null&&(p.addNew=I?u.metaKey:u.ctrlKey),p.moveOnDrag==null&&(p.moveOnDrag=!(I?u.altKey:u.ctrlKey)),p}o(ka,"configureMouse");function mg(r,i,u,a){c?setTimeout(Hr(vd,r),0):r.curOp.focus=Ge();var p=ka(r,u,a),g=r.doc.sel,y;r.options.dragDrop&&hs&&!r.isReadOnly()&&u=="single"&&(y=g.contains(i))>-1&&(ze((y=g.ranges[y]).from(),i)<0||i.xRel>0)&&(ze(y.to(),i)>0||i.xRel<0)?gg(r,a,i,p):yg(r,a,i,p)}o(mg,"leftButtonDown");function gg(r,i,u,a){var p=r.display,g=!1,y=lr(r,function(E){C&&(p.scroller.draggable=!1),r.state.draggingText=!1,r.state.delayingBlurEvent&&(r.hasFocus()?r.state.delayingBlurEvent=!1:hc(r)),he(p.wrapper.ownerDocument,"mouseup",y),he(p.wrapper.ownerDocument,"mousemove",S),he(p.scroller,"dragstart",b),he(p.scroller,"drop",y),g||(or(E),a.addNew||Cc(r.doc,u,null,null,a.extend),C&&!B||c&&v==9?setTimeout(function(){p.wrapper.ownerDocument.body.focus({preventScroll:!0}),p.input.focus()},20):p.input.focus())}),S=o(function(E){g=g||Math.abs(i.clientX-E.clientX)+Math.abs(i.clientY-E.clientY)>=10},"mouseMove"),b=o(function(){return g=!0},"dragStart");C&&(p.scroller.draggable=!0),r.state.draggingText=y,y.copy=!a.moveOnDrag,H(p.wrapper.ownerDocument,"mouseup",y),H(p.wrapper.ownerDocument,"mousemove",S),H(p.scroller,"dragstart",b),H(p.scroller,"drop",y),r.state.delayingBlurEvent=!0,setTimeout(function(){return p.input.focus()},20),p.scroller.dragDrop&&p.scroller.dragDrop()}o(gg,"leftButtonStartDrag");function vg(r,i,u){if(u=="char")return new wt(i,i);if(u=="word")return r.findWordAt(i);if(u=="line")return new wt(ue(i.line,0),He(r.doc,ue(i.line+1,0)));var a=u(r,i);return new wt(a.from,a.to)}o(vg,"rangeForUnit");function yg(r,i,u,a){c&&hc(r);var p=r.display,g=r.doc;or(i);var y,S,b=g.sel,E=b.ranges;if(a.addNew&&!a.extend?(S=g.sel.contains(u),S>-1?y=E[S]:y=new wt(u,u)):(y=g.sel.primary(),S=g.sel.primIndex),a.unit=="rectangle")a.addNew||(y=new wt(u,u)),u=po(r,i,!0,!0),S=-1;else{var M=vg(r,u,a.unit);a.extend?y=Sc(y,M.anchor,M.head,a.extend):y=M}a.addNew?S==-1?(S=E.length,$r(g,tn(r,E.concat([y]),S),{scroll:!1,origin:"*mouse"})):E.length>1&&E[S].empty()&&a.unit=="char"&&!a.extend?($r(g,tn(r,E.slice(0,S).concat(E.slice(S+1)),0),{scroll:!1,origin:"*mouse"}),b=g.sel):Ld(g,S,y,ie):(S=0,$r(g,new pi([y],0),ie),b=g.sel);var D=u;function V(ve){if(ze(D,ve)!=0)if(D=ve,a.unit=="rectangle"){for(var Ne=[],Ie=r.options.tabSize,De=_t(Me(g,u.line).text,u.ch,Ie),it=_t(Me(g,ve.line).text,ve.ch,Ie),Tt=Math.min(De,it),br=Math.max(De,it),At=Math.min(u.line,ve.line),Sn=Math.min(r.lastLine(),Math.max(u.line,ve.line));At<=Sn;At++){var Cn=Me(g,At).text,dr=Pr(Cn,Tt,Ie);Tt==br?Ne.push(new wt(ue(At,dr),ue(At,dr))):Cn.length>dr&&Ne.push(new wt(ue(At,dr),ue(At,Pr(Cn,br,Ie))))}Ne.length||Ne.push(new wt(u,u)),$r(g,tn(r,b.ranges.slice(0,S).concat(Ne),S),{origin:"*mouse",scroll:!1}),r.scrollIntoView(ve)}else{var Vr=y,Ar=vg(r,ve,a.unit),Lt=Vr.anchor,Bt;ze(Ar.anchor,Lt)>0?(Bt=Ar.head,Lt=il(Vr.from(),Ar.anchor)):(Bt=Ar.anchor,Lt=gs(Vr.to(),Ar.head));var ar=b.ranges.slice(0);ar[S]=Na(r,new wt(He(g,Lt),Bt)),$r(g,tn(r,ar,S),ie)}}o(V,"extendTo");var $=p.wrapper.getBoundingClientRect(),te=0;function oe(ve){var Ne=++te,Ie=po(r,ve,!0,a.unit=="rectangle");if(!!Ie)if(ze(Ie,D)!=0){r.curOp.focus=Ge(),V(Ie);var De=dl(p,g);(Ie.line>=De.to||Ie.line$.bottom?20:0;it&&setTimeout(lr(r,function(){te==Ne&&(p.scroller.scrollTop+=it,oe(ve))}),50)}}o(oe,"extend");function de(ve){r.state.selectingText=!1,te=1/0,ve&&(or(ve),p.input.focus()),he(p.wrapper.ownerDocument,"mousemove",ge),he(p.wrapper.ownerDocument,"mouseup",be),g.history.lastSelOrigin=null}o(de,"done");var ge=lr(r,function(ve){ve.buttons===0||!el(ve)?de(ve):oe(ve)}),be=lr(r,de);r.state.selectingText=be,H(p.wrapper.ownerDocument,"mousemove",ge),H(p.wrapper.ownerDocument,"mouseup",be)}o(yg,"leftButtonSelect");function Na(r,i){var u=i.anchor,a=i.head,p=Me(r.doc,u.line);if(ze(u,a)==0&&u.sticky==a.sticky)return i;var g=Mn(p);if(!g)return i;var y=Ci(g,u.ch,u.sticky),S=g[y];if(S.from!=u.ch&&S.to!=u.ch)return i;var b=y+(S.from==u.ch==(S.level!=1)?0:1);if(b==0||b==g.length)return i;var E;if(a.line!=u.line)E=(a.line-u.line)*(r.doc.direction=="ltr"?1:-1)>0;else{var M=Ci(g,a.ch,a.sticky),D=M-y||(a.ch-u.ch)*(S.level==1?-1:1);M==b-1||M==b?E=D<0:E=D>0}var V=g[b+(E?-1:0)],$=E==(V.level==1),te=$?V.from:V.to,oe=$?"after":"before";return u.ch==te&&u.sticky==oe?i:new wt(new ue(u.line,te,oe),a)}o(Na,"bidiSimplify");function La(r,i,u,a){var p,g;if(i.touches)p=i.touches[0].clientX,g=i.touches[0].clientY;else try{p=i.clientX,g=i.clientY}catch(V){return!1}if(p>=Math.floor(r.display.gutters.getBoundingClientRect().right))return!1;a&&or(i);var y=r.display,S=y.lineDiv.getBoundingClientRect();if(g>S.bottom||!Ft(r,u))return ds(i);g-=S.top-y.viewOffset;for(var b=0;b=p){var M=ao(r.doc,g),D=r.display.gutterSpecs[b];return Te(r,u,r,M,D.className,i),ds(i)}}}o(La,"gutterEvent");function zd(r,i){return La(r,i,"gutterClick",!0)}o(zd,"clickInGutter");function $d(r,i){ji(r.display,i)||wg(r,i)||ir(r,i,"contextmenu")||pe||r.display.input.onContextMenu(i)}o($d,"onContextMenu");function wg(r,i){return Ft(r,"gutterContextMenu")?La(r,i,"gutterContextMenu",!1):!1}o(wg,"contextMenuInGutter");function sf(r){r.display.wrapper.className=r.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+r.options.theme.replace(/(^|\s)\s*/g," cm-s-"),U(r)}o(sf,"themeChanged");var Sl={toString:function(){return"CodeMirror.Init"}},lf={},Pa={};function Fc(r){var i=r.optionHandlers;function u(a,p,g,y){r.defaults[a]=p,g&&(i[a]=y?function(S,b,E){E!=Sl&&g(S,b,E)}:g)}o(u,"option"),r.defineOption=u,r.Init=Sl,u("value","",function(a,p){return a.setValue(p)},!0),u("mode",null,function(a,p){a.doc.modeOption=p,Ed(a)},!0),u("indentUnit",2,Ed,!0),u("indentWithTabs",!1),u("smartIndent",!0),u("tabSize",4,function(a){Xu(a),U(a),et(a)},!0),u("lineSeparator",null,function(a,p){if(a.doc.lineSep=p,!!p){var g=[],y=a.doc.first;a.doc.iter(function(b){for(var E=0;;){var M=b.text.indexOf(p,E);if(M==-1)break;E=M+p.length,g.push(ue(y,M))}y++});for(var S=g.length-1;S>=0;S--)Sa(a.doc,p,g[S],ue(g[S].line,g[S].ch+p.length))}}),u("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(a,p,g){a.state.specialChars=new RegExp(p.source+(p.test(" ")?"":"| "),"g"),g!=Sl&&a.refresh()}),u("specialCharPlaceholder",Ur,function(a){return a.refresh()},!0),u("electricChars",!0),u("inputStyle",A?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),u("spellcheck",!1,function(a,p){return a.getInputField().spellcheck=p},!0),u("autocorrect",!1,function(a,p){return a.getInputField().autocorrect=p},!0),u("autocapitalize",!1,function(a,p){return a.getInputField().autocapitalize=p},!0),u("rtlMoveVisually",!K),u("wholeLineUpdateBefore",!0),u("theme","default",function(a){sf(a),Yu(a)},!0),u("keyMap","default",function(a,p,g){var y=wn(p),S=g!=Sl&&wn(g);S&&S.detach&&S.detach(a,y),y.attach&&y.attach(a,S||null)}),u("extraKeys",null),u("configureMouse",null),u("lineWrapping",!1,xg,!0),u("gutters",[],function(a,p){a.display.gutterSpecs=Cd(p,a.options.lineNumbers),Yu(a)},!0),u("fixedGutter",!0,function(a,p){a.display.gutters.style.left=p?fa(a.display)+"px":"0",a.refresh()},!0),u("coverGutterNextToScrollbar",!1,function(a){return Ls(a)},!0),u("scrollbarStyle","native",function(a){ml(a),Ls(a),a.display.scrollbars.setScrollTop(a.doc.scrollTop),a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},!0),u("lineNumbers",!1,function(a,p){a.display.gutterSpecs=Cd(a.options.gutters,p),Yu(a)},!0),u("firstLineNumber",1,Yu,!0),u("lineNumberFormatter",function(a){return a},Yu,!0),u("showCursorWhenSelecting",!1,$u,!0),u("resetSelectionOnContextMenu",!0),u("lineWiseCopyCut",!0),u("pasteLinesPerSelection",!0),u("selectionsMayTouch",!1),u("readOnly",!1,function(a,p){p=="nocursor"&&(pl(a),a.display.input.blur()),a.display.input.readOnlyChanged(p)}),u("screenReaderLabel",null,function(a,p){p=p===""?null:p,a.display.input.screenReaderLabelChanged(p)}),u("disableInput",!1,function(a,p){p||a.display.input.reset()},!0),u("dragDrop",!0,ow),u("allowDropFileTypes",null),u("cursorBlinkRate",530),u("cursorScrollMargin",0),u("cursorHeight",1,$u,!0),u("singleCursorHeightPerLine",!0,$u,!0),u("workTime",100),u("workDelay",100),u("flattenSpans",!0,Xu,!0),u("addModeClass",!1,Xu,!0),u("pollInterval",100),u("undoDepth",200,function(a,p){return a.doc.history.undoDepth=p}),u("historyEventDelay",1250),u("viewportMargin",10,function(a){return a.refresh()},!0),u("maxHighlightLength",1e4,Xu,!0),u("moveInputWithCursor",!0,function(a,p){p||a.display.input.resetPosition()}),u("tabindex",null,function(a,p){return a.display.input.getField().tabIndex=p||""}),u("autofocus",null),u("direction","ltr",function(a,p){return a.doc.setDirection(p)},!0),u("phrases",null)}o(Fc,"defineOptions");function ow(r,i,u){var a=u&&u!=Sl;if(!i!=!a){var p=r.display.dragFunctions,g=i?H:he;g(r.display.scroller,"dragstart",p.start),g(r.display.scroller,"dragenter",p.enter),g(r.display.scroller,"dragover",p.over),g(r.display.scroller,"dragleave",p.leave),g(r.display.scroller,"drop",p.drop)}}o(ow,"dragDropChanged");function xg(r){r.options.lineWrapping?(Xe(r.display.wrapper,"CodeMirror-wrap"),r.display.sizer.style.minWidth="",r.display.sizerWidth=null):(xe(r.display.wrapper,"CodeMirror-wrap"),zi(r)),bs(r),et(r),U(r),setTimeout(function(){return Ls(r)},100)}o(xg,"wrappingChanged");function Mt(r,i){var u=this;if(!(this instanceof Mt))return new Mt(r,i);this.options=i=i?Zt(i):{},Zt(lf,i,!1);var a=i.value;typeof a=="string"?a=new yn(a,i.mode,null,i.lineSeparator,i.direction):i.mode&&(a.modeOption=i.mode),this.doc=a;var p=new Mt.inputStyles[i.inputStyle](this),g=this.display=new Ky(r,a,p,i);g.wrapper.CodeMirror=this,sf(this),i.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),ml(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new Ct,keySeq:null,specialChars:null},i.autofocus&&!A&&g.input.focus(),c&&v<11&&setTimeout(function(){return u.display.input.reset(!0)},20),Sg(this),Dd(),Ki(this),this.curOp.forceUpdate=!0,Gm(this,a),i.autofocus&&!A||this.hasFocus()?setTimeout(function(){u.hasFocus()&&!u.state.focused&&pa(u)},20):pl(this);for(var y in Pa)Pa.hasOwnProperty(y)&&Pa[y](this,i[y],Sl);vo(this),i.finishInit&&i.finishInit(this);for(var S=0;S20*20}o(y,"farAway"),H(i.scroller,"touchstart",function(b){if(!ir(r,b)&&!g(b)&&!zd(r,b)){i.input.ensurePolled(),clearTimeout(u);var E=+new Date;i.activeTouch={start:E,moved:!1,prev:E-a.end<=300?a:null},b.touches.length==1&&(i.activeTouch.left=b.touches[0].pageX,i.activeTouch.top=b.touches[0].pageY)}}),H(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),H(i.scroller,"touchend",function(b){var E=i.activeTouch;if(E&&!ji(i,b)&&E.left!=null&&!E.moved&&new Date-E.start<300){var M=r.coordsChar(i.activeTouch,"page"),D;!E.prev||y(E,E.prev)?D=new wt(M,M):!E.prev.prev||y(E,E.prev.prev)?D=r.findWordAt(M):D=new wt(ue(M.line,0),He(r.doc,ue(M.line+1,0))),r.setSelection(D.anchor,D.head),r.focus(),or(b)}p()}),H(i.scroller,"touchcancel",p),H(i.scroller,"scroll",function(){i.scroller.clientHeight&&(sr(r,i.scroller.scrollTop),hl(r,i.scroller.scrollLeft,!0),Te(r,"scroll",r))}),H(i.scroller,"mousewheel",function(b){return Vm(r,b)}),H(i.scroller,"DOMMouseScroll",function(b){return Vm(r,b)}),H(i.wrapper,"scroll",function(){return i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(b){ir(r,b)||lo(b)},over:function(b){ir(r,b)||(Md(r,b),lo(b))},start:function(b){return Jy(r,b)},drop:lr(r,lg),leave:function(b){ir(r,b)||Ad(r)}};var S=i.input.getField();H(S,"keyup",function(b){return Ud.call(r,b)}),H(S,"keydown",lr(r,fg)),H(S,"keypress",lr(r,pg)),H(S,"focus",function(b){return pa(r,b)}),H(S,"blur",function(b){return pl(r,b)})}o(Sg,"registerEventHandlers");var af=[];Mt.defineInitHook=function(r){return af.push(r)};function uf(r,i,u,a){var p=r.doc,g;u==null&&(u="add"),u=="smart"&&(p.mode.indent?g=$o(r,i).state:u="prev");var y=r.options.tabSize,S=Me(p,i),b=_t(S.text,null,y);S.stateAfter&&(S.stateAfter=null);var E=S.text.match(/^\s*/)[0],M;if(!a&&!/\S/.test(S.text))M=0,u="not";else if(u=="smart"&&(M=p.mode.indent(g,S.text.slice(E.length),S.text),M==zt||M>150)){if(!a)return;u="prev"}u=="prev"?i>p.first?M=_t(Me(p,i-1).text,null,y):M=0:u=="add"?M=b+r.options.indentUnit:u=="subtract"?M=b-r.options.indentUnit:typeof u=="number"&&(M=b+u),M=Math.max(0,M);var D="",V=0;if(r.options.indentWithTabs)for(var $=Math.floor(M/y);$;--$)V+=y,D+=" ";if(Vy,b=rl(i),E=null;if(S&&a.ranges.length>1)if(Pi&&Pi.text.join(` -`)==i){if(a.ranges.length%Pi.text.length==0){E=[];for(var M=0;M=0;V--){var $=a.ranges[V],te=$.from(),oe=$.to();$.empty()&&(u&&u>0?te=ue(te.line,te.ch-u):r.state.overwrite&&!S?oe=ue(oe.line,Math.min(Me(g,oe.line).text.length,oe.ch+Se(b).length)):S&&Pi&&Pi.lineWise&&Pi.text.join(` + left: `+i.left+"px; width: "+Math.max(2,i.right-i.left)+"px;");r.display.lineSpace.appendChild(g),g.scrollIntoView(p),r.display.lineSpace.removeChild(g)}}}o(Ry,"maybeScrollWindow");function Iy(r,i,u,a){a==null&&(a=0);var p;!r.options.lineWrapping&&i==u&&(u=i.sticky=="before"?ue(i.line,i.ch+1,"before"):i,i=i.ch?ue(i.line,i.sticky=="before"?i.ch-1:i.ch,"after"):i);for(var g=0;g<5;g++){var y=!1,S=Vn(r,i),b=!u||u==i?S:Vn(r,u);p={left:Math.min(S.left,b.left),top:Math.min(S.top,b.top)-a,right:Math.max(S.left,b.left),bottom:Math.max(S.bottom,b.bottom)+a};var _=da(r,p),M=r.doc.scrollTop,D=r.doc.scrollLeft;if(_.scrollTop!=null&&(sr(r,_.scrollTop),Math.abs(r.doc.scrollTop-M)>1&&(y=!0)),_.scrollLeft!=null&&(hl(r,_.scrollLeft),Math.abs(r.doc.scrollLeft-D)>1&&(y=!0)),!y)break}return p}o(Iy,"scrollPosIntoView");function Fy(r,i){var u=da(r,i);u.scrollTop!=null&&sr(r,u.scrollTop),u.scrollLeft!=null&&hl(r,u.scrollLeft)}o(Fy,"scrollIntoView");function da(r,i){var u=r.display,a=Cs(r.display);i.top<0&&(i.top=0);var p=r.curOp&&r.curOp.scrollTop!=null?r.curOp.scrollTop:u.scroller.scrollTop,g=al(r),y={};i.bottom-i.top>g&&(i.bottom=i.top+g);var S=r.doc.height+zr(u),b=i.topS-a;if(i.topp+g){var M=Math.min(i.top,(_?S:i.bottom)-g);M!=p&&(y.scrollTop=M)}var D=r.options.fixedGutter?0:u.gutters.offsetWidth,V=r.curOp&&r.curOp.scrollLeft!=null?r.curOp.scrollLeft:u.scroller.scrollLeft-D,$=qi(r)-u.gutters.offsetWidth,te=i.right-i.left>$;return te&&(i.right=i.left+$),i.left<10?y.scrollLeft=0:i.left$+V-3&&(y.scrollLeft=i.right+(te?0:10)-$),y}o(da,"calculateScrollPos");function ha(r,i){i!=null&&(mc(r),r.curOp.scrollTop=(r.curOp.scrollTop==null?r.doc.scrollTop:r.curOp.scrollTop)+i)}o(ha,"addToScrollTop");function ks(r){mc(r);var i=r.getCursor();r.curOp.scrollToPos={from:i,to:i,margin:r.options.cursorScrollMargin}}o(ks,"ensureCursorVisible");function qu(r,i,u){(i!=null||u!=null)&&mc(r),i!=null&&(r.curOp.scrollLeft=i),u!=null&&(r.curOp.scrollTop=u)}o(qu,"scrollToCoords");function Wm(r,i){mc(r),r.curOp.scrollToPos=i}o(Wm,"scrollToRange");function mc(r){var i=r.curOp.scrollToPos;if(i){r.curOp.scrollToPos=null;var u=zu(r,i.from),a=zu(r,i.to);Um(r,u,a,i.margin)}}o(mc,"resolveScrollToPos");function Um(r,i,u,a){var p=da(r,{left:Math.min(i.left,u.left),top:Math.min(i.top,u.top)-a,right:Math.max(i.right,u.right),bottom:Math.max(i.bottom,u.bottom)+a});qu(r,p.scrollLeft,p.scrollTop)}o(Um,"scrollToCoordsRange");function sr(r,i){Math.abs(r.doc.scrollTop-i)<2||(n||wd(r,{top:i}),Zr(r,i,!0),n&&wd(r),go(r,100))}o(sr,"updateScrollTop");function Zr(r,i,u){i=Math.max(0,Math.min(r.display.scroller.scrollHeight-r.display.scroller.clientHeight,i)),!(r.display.scroller.scrollTop==i&&!u)&&(r.doc.scrollTop=i,r.display.scrollbars.setScrollTop(i),r.display.scroller.scrollTop!=i&&(r.display.scroller.scrollTop=i))}o(Zr,"setScrollTop");function hl(r,i,u,a){i=Math.max(0,Math.min(i,r.display.scroller.scrollWidth-r.display.scroller.clientWidth)),!((u?i==r.doc.scrollLeft:Math.abs(r.doc.scrollLeft-i)<2)&&!a)&&(r.doc.scrollLeft=i,zm(r),r.display.scroller.scrollLeft!=i&&(r.display.scroller.scrollLeft=i),r.display.scrollbars.setScrollLeft(i))}o(hl,"setScrollLeft");function Vu(r){var i=r.display,u=i.gutters.offsetWidth,a=Math.round(r.doc.height+zr(r.display));return{clientHeight:i.scroller.clientHeight,viewHeight:i.wrapper.clientHeight,scrollWidth:i.scroller.scrollWidth,clientWidth:i.scroller.clientWidth,viewWidth:i.wrapper.clientWidth,barLeft:r.options.fixedGutter?u:0,docHeight:a,scrollHeight:a+mn(r)+i.barHeight,nativeBarWidth:i.nativeBarWidth,gutterWidth:u}}o(Vu,"measureForScrollbars");var Ns=o(function(r,i,u){this.cm=u;var a=this.vert=Ee("div",[Ee("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),p=this.horiz=Ee("div",[Ee("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");a.tabIndex=p.tabIndex=-1,r(a),r(p),H(a,"scroll",function(){a.clientHeight&&i(a.scrollTop,"vertical")}),H(p,"scroll",function(){p.clientWidth&&i(p.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,c&&v<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")},"NativeScrollbars");Ns.prototype.update=function(r){var i=r.scrollWidth>r.clientWidth+1,u=r.scrollHeight>r.clientHeight+1,a=r.nativeBarWidth;if(u){this.vert.style.display="block",this.vert.style.bottom=i?a+"px":"0";var p=r.viewHeight-(i?a:0);this.vert.firstChild.style.height=Math.max(0,r.scrollHeight-r.clientHeight+p)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(i){this.horiz.style.display="block",this.horiz.style.right=u?a+"px":"0",this.horiz.style.left=r.barLeft+"px";var g=r.viewWidth-r.barLeft-(u?a:0);this.horiz.firstChild.style.width=Math.max(0,r.scrollWidth-r.clientWidth+g)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&r.clientHeight>0&&(a==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:u?a:0,bottom:i?a:0}},Ns.prototype.setScrollLeft=function(r){this.horiz.scrollLeft!=r&&(this.horiz.scrollLeft=r),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ns.prototype.setScrollTop=function(r){this.vert.scrollTop!=r&&(this.vert.scrollTop=r),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ns.prototype.zeroWidthHack=function(){var r=I&&!X?"12px":"18px";this.horiz.style.height=this.vert.style.width=r,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Ct,this.disableVert=new Ct},Ns.prototype.enableZeroWidthBar=function(r,i,u){r.style.pointerEvents="auto";function a(){var p=r.getBoundingClientRect(),g=u=="vert"?document.elementFromPoint(p.right-1,(p.top+p.bottom)/2):document.elementFromPoint((p.right+p.left)/2,p.bottom-1);g!=r?r.style.pointerEvents="none":i.set(1e3,a)}o(a,"maybeDisable"),i.set(1e3,a)},Ns.prototype.clear=function(){var r=this.horiz.parentNode;r.removeChild(this.horiz),r.removeChild(this.vert)};var Ku=o(function(){},"NullScrollbars");Ku.prototype.update=function(){return{bottom:0,right:0}},Ku.prototype.setScrollLeft=function(){},Ku.prototype.setScrollTop=function(){},Ku.prototype.clear=function(){};function Ps(r,i){i||(i=Vu(r));var u=r.display.barWidth,a=r.display.barHeight;ma(r,i);for(var p=0;p<4&&u!=r.display.barWidth||a!=r.display.barHeight;p++)u!=r.display.barWidth&&r.options.lineWrapping&&Es(r),ma(r,Vu(r)),u=r.display.barWidth,a=r.display.barHeight}o(Ps,"updateScrollbars");function ma(r,i){var u=r.display,a=u.scrollbars.update(i);u.sizer.style.paddingRight=(u.barWidth=a.right)+"px",u.sizer.style.paddingBottom=(u.barHeight=a.bottom)+"px",u.heightForcer.style.borderBottom=a.bottom+"px solid transparent",a.right&&a.bottom?(u.scrollbarFiller.style.display="block",u.scrollbarFiller.style.height=a.bottom+"px",u.scrollbarFiller.style.width=a.right+"px"):u.scrollbarFiller.style.display="",a.bottom&&r.options.coverGutterNextToScrollbar&&r.options.fixedGutter?(u.gutterFiller.style.display="block",u.gutterFiller.style.height=a.bottom+"px",u.gutterFiller.style.width=i.gutterWidth+"px"):u.gutterFiller.style.display=""}o(ma,"updateScrollbarsInner");var gc={native:Ns,null:Ku};function ml(r){r.display.scrollbars&&(r.display.scrollbars.clear(),r.display.scrollbars.addClass&&xe(r.display.wrapper,r.display.scrollbars.addClass)),r.display.scrollbars=new gc[r.options.scrollbarStyle](function(i){r.display.wrapper.insertBefore(i,r.display.scrollbarFiller),H(i,"mousedown",function(){r.state.focused&&setTimeout(function(){return r.display.input.focus()},0)}),i.setAttribute("cm-not-content","true")},function(i,u){u=="horizontal"?hl(r,i):sr(r,i)},r),r.display.scrollbars.addClass&&Xe(r.display.wrapper,r.display.scrollbars.addClass)}o(ml,"initScrollbars");var Gu=0;function Ki(r){r.curOp={cm:r,viewChanged:!1,startHeight:r.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Gu,markArrays:null},$i(r.curOp)}o(Ki,"startOperation");function mo(r){var i=r.curOp;i&&hd(i,function(u){for(var a=0;a=u.viewTo)||u.maxLineChanged&&i.options.lineWrapping,r.update=r.mustUpdate&&new An(i,r.mustUpdate&&{top:r.scrollTop,ensure:r.scrollToPos},r.forceUpdate)}o(By,"endOperation_R1");function Hy(r){r.updatedDisplay=r.mustUpdate&&yd(r.cm,r.update)}o(Hy,"endOperation_W1");function Wy(r){var i=r.cm,u=i.display;r.updatedDisplay&&Es(i),r.barMeasure=Vu(i),u.maxLineChanged&&!i.options.lineWrapping&&(r.adjustWidthTo=Uu(i,u.maxLine,u.maxLine.text.length).left+3,i.display.sizerWidth=r.adjustWidthTo,r.barMeasure.scrollWidth=Math.max(u.scroller.clientWidth,u.sizer.offsetLeft+r.adjustWidthTo+mn(i)+i.display.barWidth),r.maxScrollLeft=Math.max(0,u.sizer.offsetLeft+r.adjustWidthTo-qi(i))),(r.updatedDisplay||r.selectionChanged)&&(r.preparedSelection=u.input.prepareSelection())}o(Wy,"endOperation_R2");function Uy(r){var i=r.cm;r.adjustWidthTo!=null&&(i.display.sizer.style.minWidth=r.adjustWidthTo+"px",r.maxScrollLeft=r.display.viewTo)){var u=+new Date+r.options.workTime,a=$o(r,i.highlightFrontier),p=[];i.iter(a.line,Math.min(i.first+i.size,r.display.viewTo+500),function(g){if(a.line>=r.display.viewFrom){var y=g.styles,S=g.text.length>r.options.maxHighlightLength?Uo(i.mode,a.state):null,b=tc(r,g,a,!0);S&&(a.state=S),g.styles=b.styles;var _=g.styleClasses,M=b.classes;M?g.styleClasses=M:_&&(g.styleClasses=null);for(var D=!y||y.length!=g.styles.length||_!=M&&(!_||!M||_.bgClass!=M.bgClass||_.textClass!=M.textClass),V=0;!D&&Vu)return go(r,r.options.workDelay),!0}),i.highlightFrontier=a.line,i.modeFrontier=Math.max(i.modeFrontier,a.line),p.length&&Jr(r,function(){for(var g=0;g=u.viewFrom&&i.visible.to<=u.viewTo&&(u.updateLineNumbers==null||u.updateLineNumbers>=u.viewTo)&&u.renderedView==u.view&&Bm(r)==0)return!1;vo(r)&&(Xo(r),i.dims=Kn(r));var p=a.first+a.size,g=Math.max(i.visible.from-r.options.viewportMargin,a.first),y=Math.min(p,i.visible.to+r.options.viewportMargin);u.viewFromy&&u.viewTo-y<20&&(y=Math.min(p,u.viewTo)),Ei&&(g=jo(r.doc,g),y=pd(r.doc,y));var S=g!=u.viewFrom||y!=u.viewTo||u.lastWrapHeight!=i.wrapperHeight||u.lastWrapWidth!=i.wrapperWidth;Dy(r,g,y),u.viewOffset=hn(Me(r.doc,u.viewFrom)),r.display.mover.style.top=u.viewOffset+"px";var b=Bm(r);if(!S&&b==0&&!i.force&&u.renderedView==u.view&&(u.updateLineNumbers==null||u.updateLineNumbers>=u.viewTo))return!1;var _=$y(r);return b>4&&(u.lineDiv.style.display="none"),qy(r,u.updateLineNumbers,i.dims),b>4&&(u.lineDiv.style.display=""),u.renderedView=u.view,jy(_),Ve(u.cursorDiv),Ve(u.selectionDiv),u.gutters.style.height=u.sizer.style.minHeight=0,S&&(u.lastWrapHeight=i.wrapperHeight,u.lastWrapWidth=i.wrapperWidth,go(r,400)),u.updateLineNumbers=null,!0}o(yd,"updateDisplayIfNeeded");function Ls(r,i){for(var u=i.viewport,a=!0;;a=!1){if(!a||!r.options.lineWrapping||i.oldDisplayWidth==qi(r)){if(u&&u.top!=null&&(u={top:Math.min(r.doc.height+zr(r.display)-al(r),u.top)}),i.visible=dl(r.display,r.doc,u),i.visible.from>=r.display.viewFrom&&i.visible.to<=r.display.viewTo)break}else a&&(i.visible=dl(r.display,r.doc,u));if(!yd(r,i))break;Es(r);var p=Vu(r);$u(r),Ps(r,p),Sd(r,p),i.force=!1}i.signal(r,"update",r),(r.display.viewFrom!=r.display.reportedViewFrom||r.display.viewTo!=r.display.reportedViewTo)&&(i.signal(r,"viewportChange",r,r.display.viewFrom,r.display.viewTo),r.display.reportedViewFrom=r.display.viewFrom,r.display.reportedViewTo=r.display.viewTo)}o(Ls,"postUpdateDisplay");function wd(r,i){var u=new An(r,i);if(yd(r,u)){Es(r),Ls(r,u);var a=Vu(r);$u(r),Ps(r,a),Sd(r,a),u.finish()}}o(wd,"updateDisplaySimple");function qy(r,i,u){var a=r.display,p=r.options.lineNumbers,g=a.lineDiv,y=g.firstChild;function S(te){var oe=te.nextSibling;return C&&I&&r.display.currentWheelTarget==te?te.style.display="none":te.parentNode.removeChild(te),oe}o(S,"rm");for(var b=a.view,_=a.viewFrom,M=0;M-1&&($=!1),Du(r,D,_,u)),$&&(Ve(D.lineNumber),D.lineNumber.appendChild(document.createTextNode(jl(r.options,_)))),y=D.node.nextSibling}_+=D.size}for(;y;)y=S(y)}o(qy,"patchDisplay");function xd(r){var i=r.gutters.offsetWidth;r.sizer.style.marginLeft=i+"px",yr(r,"gutterChanged",r)}o(xd,"updateGutterSpace");function Sd(r,i){r.display.sizer.style.minHeight=i.docHeight+"px",r.display.heightForcer.style.top=i.docHeight+"px",r.display.gutters.style.height=i.docHeight+r.display.barHeight+mn(r)+"px"}o(Sd,"setDocumentHeight");function zm(r){var i=r.display,u=i.view;if(!(!i.alignWidgets&&(!i.gutters.firstChild||!r.options.fixedGutter))){for(var a=fa(i)-i.scroller.scrollLeft+r.doc.scrollLeft,p=i.gutters.offsetWidth,g=a+"px",y=0;yy.clientWidth,b=y.scrollHeight>y.clientHeight;if(!!(a&&S||p&&b)){if(p&&I&&C){e:for(var _=i.target,M=g.view;_!=y;_=_.parentNode)for(var D=0;D=0&&ze(r,a.to())<=0)return u}return-1};var wt=o(function(r,i){this.anchor=r,this.head=i},"Range");wt.prototype.from=function(){return il(this.anchor,this.head)},wt.prototype.to=function(){return gs(this.anchor,this.head)},wt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function tn(r,i,u){var a=r&&r.options.selectionsMayTouch,p=i[u];i.sort(function(V,$){return ze(V.from(),$.from())}),u=ut(i,p);for(var g=1;g0:b>=0){var _=il(S.from(),y.from()),M=gs(S.to(),y.to()),D=S.empty()?y.from()==y.head:S.from()==S.head;g<=u&&--u,i.splice(--g,2,new wt(D?M:_,D?_:M))}}return new pi(i,u)}o(tn,"normalizeSelection");function Os(r,i){return new pi([new wt(r,i||r)],0)}o(Os,"simpleSelection");function Ms(r){return r.text?ue(r.from.line+r.text.length-1,Se(r.text).length+(r.text.length==1?r.from.ch:0)):r.to}o(Ms,"changeEnd");function Ni(r,i){if(ze(r,i.from)<0)return r;if(ze(r,i.to)<=0)return Ms(i);var u=r.line+i.text.length-(i.to.line-i.from.line)-1,a=r.ch;return r.line==i.to.line&&(a+=Ms(i).ch-i.to.ch),ue(u,a)}o(Ni,"adjustForChange");function bd(r,i){for(var u=[],a=0;a1&&r.remove(S.line+1,te-1),r.insert(S.line+1,ge)}yr(r,"change",r,i)}o(wc,"updateDoc");function As(r,i,u){function a(p,g,y){if(p.linked)for(var S=0;S1&&!r.done[r.done.length-2].ranges)return r.done.pop(),Se(r.done)}o(Yy,"lastChangeEvent");function yo(r,i,u,a){var p=r.history;p.undone.length=0;var g=+new Date,y,S;if((p.lastOp==a||p.lastOrigin==i.origin&&i.origin&&(i.origin.charAt(0)=="+"&&p.lastModTime>g-(r.cm?r.cm.options.historyEventDelay:500)||i.origin.charAt(0)=="*"))&&(y=Yy(p,p.lastOp==a)))S=Se(y.changes),ze(i.from,i.to)==0&&ze(i.from,S.to)==0?S.to=Ms(i):y.changes.push(Td(r,i));else{var b=Se(p.done);for((!b||!b.ranges)&&Dn(r.sel,p.done),y={changes:[Td(r,i)],generation:p.generation},p.done.push(y);p.done.length>p.undoDepth;)p.done.shift(),p.done[0].ranges||p.done.shift()}p.done.push(u),p.generation=++p.maxGeneration,p.lastModTime=p.lastSelTime=g,p.lastOp=p.lastSelOp=a,p.lastOrigin=p.lastSelOrigin=i.origin,S||Te(r,"historyAdded")}o(yo,"addChangeToHistory");function Nd(r,i,u,a){var p=i.charAt(0);return p=="*"||p=="+"&&u.ranges.length==a.ranges.length&&u.somethingSelected()==a.somethingSelected()&&new Date-r.history.lastSelTime<=(r.cm?r.cm.options.historyEventDelay:500)}o(Nd,"selectionEventCanBeMerged");function vl(r,i,u,a){var p=r.history,g=a&&a.origin;u==p.lastSelOp||g&&p.lastSelOrigin==g&&(p.lastModTime==p.lastSelTime&&p.lastOrigin==g||Nd(r,g,Se(p.done),i))?p.done[p.done.length-1]=i:Dn(i,p.done),p.lastSelTime=+new Date,p.lastSelOrigin=g,p.lastSelOp=u,a&&a.clearRedo!==!1&&kd(p.undone)}o(vl,"addSelectionToHistory");function Dn(r,i){var u=Se(i);u&&u.ranges&&u.equals(r)||i.push(r)}o(Dn,"pushSelectionToHistory");function Gm(r,i,u,a){var p=i["spans_"+r.id],g=0;r.iter(Math.max(r.first,u),Math.min(r.first+r.size,a),function(y){y.markedSpans&&((p||(p=i["spans_"+r.id]={}))[g]=y.markedSpans),++g})}o(Gm,"attachLocalSpans");function Ym(r){if(!r)return null;for(var i,u=0;u-1&&(Se(S)[D]=_[D],delete _[D])}}return a}o(di,"copyHistoryArray");function Sc(r,i,u,a){if(a){var p=r.anchor;if(u){var g=ze(i,p)<0;g!=ze(u,p)<0?(p=i,i=u):g!=ze(i,u)<0&&(i=u)}return new wt(p,i)}else return new wt(u||i,i)}o(Sc,"extendRange");function Cc(r,i,u,a,p){p==null&&(p=r.cm&&(r.cm.display.shift||r.extend)),$r(r,new pi([Sc(r.sel.primary(),i,u,p)],0),a)}o(Cc,"extendSelection");function Zu(r,i,u){for(var a=[],p=r.cm&&(r.cm.display.shift||r.extend),g=0;g=i.ch:S.to>i.ch))){if(p&&(Te(b,"beforeCursorEnter"),b.explicitlyCleared))if(g.markedSpans){--y;continue}else break;if(!b.atomic)continue;if(u){var D=b.find(a<0?1:-1),V=void 0;if((a<0?M:_)&&(D=Ec(r,D,-a,D&&D.line==i.line?g:null)),D&&D.line==i.line&&(V=ze(D,u))&&(a<0?V<0:V>0))return yl(r,D,i,a,p)}var $=b.find(a<0?-1:1);return(a<0?_:M)&&($=Ec(r,$,a,$.line==i.line?g:null)),$?yl(r,$,i,a,p):null}}return i}o(yl,"skipAtomicInner");function jr(r,i,u,a,p){var g=a||1,y=yl(r,i,u,g,p)||!p&&yl(r,i,u,g,!0)||yl(r,i,u,-g,p)||!p&&yl(r,i,u,-g,!0);return y||(r.cantEdit=!0,ue(r.first,0))}o(jr,"skipAtomic");function Ec(r,i,u,a){return u<0&&i.ch==0?i.line>r.first?He(r,ue(i.line-1)):null:u>0&&i.ch==(a||Me(r,i.line)).text.length?i.line=0;--p)Tc(r,{from:a[p].from,to:a[p].to,text:p?[""]:i.text,origin:i.origin});else Tc(r,i)}}o(ya,"makeChange");function Tc(r,i){if(!(i.text.length==1&&i.text[0]==""&&ze(i.from,i.to)==0)){var u=bd(r,i);yo(r,i,u,r.cm?r.cm.curOp.id:NaN),xa(r,i,u,ku(r,i));var a=[];As(r,function(p,g){!g&&ut(a,p.history)==-1&&(eg(p.history,i),a.push(p.history)),xa(p,i,null,ku(p,i))})}}o(Tc,"makeChangeInner");function kc(r,i,u){var a=r.cm&&r.cm.state.suppressEdits;if(!(a&&!u)){for(var p=r.history,g,y=r.sel,S=i=="undo"?p.done:p.undone,b=i=="undo"?p.undone:p.done,_=0;_=0;--$){var te=V($);if(te)return te.v}}}}o(kc,"makeChangeFromHistory");function wa(r,i){if(i!=0&&(r.first+=i,r.sel=new pi(Or(r.sel.ranges,function(p){return new wt(ue(p.anchor.line+i,p.anchor.ch),ue(p.head.line+i,p.head.ch))}),r.sel.primIndex),r.cm)){et(r.cm,r.first,r.first-i,i);for(var u=r.cm.display,a=u.viewFrom;ar.lastLine())){if(i.from.lineg&&(i={from:i.from,to:ue(g,Me(r,g).text.length),text:[i.text[0]],origin:i.origin}),i.removed=_i(r,i.from,i.to),u||(u=bd(r,i)),r.cm?Xy(r.cm,i,a):wc(r,i,a),hi(r,u,$t),r.cantEdit&&jr(r,ue(r.firstLine(),0))&&(r.cantEdit=!1)}}o(xa,"makeChangeSingleDoc");function Xy(r,i,u){var a=r.doc,p=r.display,g=i.from,y=i.to,S=!1,b=g.line;r.options.lineWrapping||(b=vt(vr(Me(a,g.line))),a.iter(b,y.line+1,function($){if($==p.maxLine)return S=!0,!0})),a.sel.contains(i.from,i.to)>-1&&Ul(r),wc(a,i,u,Fm(r)),r.options.lineWrapping||(a.iter(b,g.line+i.text.length,function($){var te=ws($);te>p.maxLineLength&&(p.maxLine=$,p.maxLineLength=te,p.maxLineChanged=!0,S=!1)}),S&&(r.curOp.updateMaxLine=!0)),rc(a,g.line),go(r,400);var _=i.text.length-(y.line-g.line)-1;i.full?et(r):g.line==y.line&&i.text.length==1&&!Ed(r.doc,i)?_s(r,g.line,"text"):et(r,g.line,y.line+1,_);var M=Ft(r,"changes"),D=Ft(r,"change");if(D||M){var V={from:g,to:y,text:i.text,removed:i.removed,origin:i.origin};D&&yr(r,"change",r,V),M&&(r.curOp.changeObjs||(r.curOp.changeObjs=[])).push(V)}r.display.selForContextMenu=null}o(Xy,"makeChangeSingleDocInEditor");function Sa(r,i,u,a,p){var g;a||(a=u),ze(a,u)<0&&(g=[a,u],u=g[0],a=g[1]),typeof i=="string"&&(i=r.splitLines(i)),ya(r,{from:u,to:a,text:i,origin:p})}o(Sa,"replaceRange");function Ca(r,i,u,a){u1||!(this.children[0]instanceof ba))){var S=[];this.collapse(S),this.children=[new ba(S)],this.children[0].parent=this}},collapse:function(r){for(var i=0;i50){for(var y=p.lines.length%25+25,S=y;S10);r.parent.maybeSpill()}},iterN:function(r,i,u){for(var a=0;ar.display.maxLineLength&&(r.display.maxLine=_,r.display.maxLineLength=M,r.display.maxLineChanged=!0)}a!=null&&r&&this.collapsed&&et(r,a,p+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,r&&Ju(r.doc)),r&&yr(r,"markerCleared",r,this,a,p),i&&mo(r),this.parent&&this.parent.clear()}},Rs.prototype.find=function(r,i){r==null&&this.type=="bookmark"&&(r=1);for(var u,a,p=0;p0||y==0&&g.clearWhenEmpty!==!1)return g;if(g.replacedWith&&(g.collapsed=!0,g.widgetNode=St("span",[g.replacedWith],"CodeMirror-widget"),a.handleMouseEvents||g.widgetNode.setAttribute("cm-ignore-events","true"),a.insertLeft&&(g.widgetNode.insertLeft=!0)),g.collapsed){if(sl(r,i.line,i,u,g)||i.line!=u.line&&sl(r,u.line,i,u,g))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ql()}g.addToHistory&&yo(r,{from:i,to:u,origin:"markText"},r.sel,NaN);var S=i.line,b=r.cm,_;if(r.iter(S,u.line+1,function(D){b&&g.collapsed&&!b.options.lineWrapping&&vr(D)==b.display.maxLine&&(_=!0),g.collapsed&&S!=i.line&&ai(D,0),oc(D,new co(g,S==i.line?i.ch:null,S==u.line?u.ch:null),r.cm&&r.cm.curOp),++S}),g.collapsed&&r.iter(i.line,u.line+1,function(D){qt(r,D)&&ai(D,0)}),g.clearOnEnter&&H(g,"beforeCursorEnter",function(){return g.clear()}),g.readOnly&&(nc(),(r.history.done.length||r.history.undone.length)&&r.clearHistory()),g.collapsed&&(g.id=++Nc,g.atomic=!0),b){if(_&&(b.curOp.updateMaxLine=!0),g.collapsed)et(b,i.line,u.line+1);else if(g.className||g.startStyle||g.endStyle||g.css||g.attributes||g.title)for(var M=i.line;M<=u.line;M++)_s(b,M,"text");g.atomic&&Ju(b.doc),yr(b,"markerAdded",b,g)}return g}o(Is,"markText");var _a=o(function(r,i){this.markers=r,this.primary=i;for(var u=0;u=0;b--)ya(this,a[b]);S?bc(this,S):this.cm&&ks(this.cm)}),undo:N(function(){kc(this,"undo")}),redo:N(function(){kc(this,"redo")}),undoSelection:N(function(){kc(this,"undo",!0)}),redoSelection:N(function(){kc(this,"redo",!0)}),setExtending:function(r){this.extend=r},getExtending:function(){return this.extend},historySize:function(){for(var r=this.history,i=0,u=0,a=0;a=r.ch)&&i.push(p.marker.parent||p.marker)}return i},findMarks:function(r,i,u){r=He(this,r),i=He(this,i);var a=[],p=r.line;return this.iter(r.line,i.line+1,function(g){var y=g.markedSpans;if(y)for(var S=0;S=b.to||b.from==null&&p!=r.line||b.from!=null&&p==i.line&&b.from>=i.ch)&&(!u||u(b.marker))&&a.push(b.marker.parent||b.marker)}++p}),a},getAllMarks:function(){var r=[];return this.iter(function(i){var u=i.markedSpans;if(u)for(var a=0;ar)return i=r,!0;r-=g,++u}),He(this,ue(u,i))},indexFromPos:function(r){r=He(this,r);var i=r.ch;if(r.linei&&(i=r.from),r.to!=null&&r.to-1){i.state.draggingText(r),setTimeout(function(){return i.display.input.focus()},20);return}try{var M=r.dataTransfer.getData("Text");if(M){var D;if(i.state.draggingText&&!i.state.draggingText.copy&&(D=i.listSelections()),hi(i.doc,Os(u,u)),D)for(var V=0;V=0;S--)Sa(r.doc,"",a[S].from,a[S].to,"+delete");ks(r)})}o(mi,"deleteNearSelection");function of(r,i,u){var a=Ui(r.text,i+u,u);return a<0||a>r.text.length?null:a}o(of,"moveCharLogically");function Mc(r,i,u){var a=of(r,i.ch,u);return a==null?null:new ue(i.line,a,u<0?"after":"before")}o(Mc,"moveLogically");function Ea(r,i,u,a,p){if(r){i.doc.direction=="rtl"&&(p=-p);var g=Mn(u,i.doc.direction);if(g){var y=p<0?Se(g):g[0],S=p<0==(y.level==1),b=S?"after":"before",_;if(y.level>0||i.doc.direction=="rtl"){var M=qn(i,u);_=p<0?u.text.length-1:0;var D=Ti(i,M,_).top;_=pn(function(V){return Ti(i,M,V).top==D},p<0==(y.level==1)?y.from:y.to-1,_),b=="before"&&(_=of(u,_,1))}else _=p<0?y.to:y.from;return new ue(a,_,b)}}return new ue(a,p<0?u.text.length:0,p<0?"before":"after")}o(Ea,"endOfLine");function ag(r,i,u,a){var p=Mn(i,r.doc.direction);if(!p)return Mc(i,u,a);u.ch>=i.text.length?(u.ch=i.text.length,u.sticky="before"):u.ch<=0&&(u.ch=0,u.sticky="after");var g=Ci(p,u.ch,u.sticky),y=p[g];if(r.doc.direction=="ltr"&&y.level%2==0&&(a>0?y.to>u.ch:y.from=y.from&&V>=M.begin)){var $=D?"before":"after";return new ue(u.line,V,$)}}var te=o(function(ge,be,ve){for(var Ne=o(function(Tt,br){return br?new ue(u.line,S(Tt,1),"before"):new ue(u.line,Tt,"after")},"getRes");ge>=0&&ge0==(Ie.level!=1),it=De?ve.begin:S(ve.end,-1);if(Ie.from<=it&&it0?M.end:S(M.begin,-1);return de!=null&&!(a>0&&de==i.text.length)&&(oe=te(a>0?0:p.length-1,a,_(de)),oe)?oe:null}o(ag,"moveVisually");var xl={selectAll:Qm,singleSelection:function(r){return r.setSelection(r.getCursor("anchor"),r.getCursor("head"),$t)},killLine:function(r){return mi(r,function(i){if(i.empty()){var u=Me(r.doc,i.head.line).text.length;return i.head.ch==u&&i.head.line0)p=new ue(p.line,p.ch+1),r.replaceRange(g.charAt(p.ch-1)+g.charAt(p.ch-2),ue(p.line,p.ch-2),p,"+transpose");else if(p.line>r.doc.first){var y=Me(r.doc,p.line-1).text;y&&(p=new ue(p.line,1),r.replaceRange(g.charAt(0)+r.doc.lineSeparator()+y.charAt(y.length-1),ue(p.line-1,y.length-1),p,"+transpose"))}}u.push(new wt(p,p))}r.setSelections(u)})},newlineAndIndent:function(r){return Jr(r,function(){for(var i=r.listSelections(),u=i.length-1;u>=0;u--)r.replaceRange(r.doc.lineSeparator(),i[u].anchor,i[u].head,"+input");i=r.listSelections();for(var a=0;ar&&ze(i,this.pos)==0&&u==this.button};var qr,Gn;function nw(r,i){var u=+new Date;return Gn&&Gn.compare(u,r,i)?(qr=Gn=null,"triple"):qr&&qr.compare(u,r,i)?(Gn=new Rc(u,r,i),qr=null,"double"):(qr=new Rc(u,r,i),Gn=null,"single")}o(nw,"clickRepeat");function dg(r){var i=this,u=i.display;if(!(ir(i,r)||u.activeTouch&&u.input.supportsTouch())){if(u.input.ensurePolled(),u.shift=r.shiftKey,ji(u,r)){C||(u.scroller.draggable=!1,setTimeout(function(){return u.scroller.draggable=!0},100));return}if(!zd(i,r)){var a=po(i,r),p=el(r),g=a?nw(a,p):"single";window.focus(),p==1&&i.state.selectingText&&i.state.selectingText(r),!(a&&Ic(i,p,a,g,r))&&(p==1?a?hg(i,a,g,r):bi(r)==u.scroller&&or(r):p==2?(a&&Cc(i.doc,a),setTimeout(function(){return u.input.focus()},20)):p==3&&(pe?i.display.input.onContextMenu(r):hc(i)))}}}o(dg,"onMouseDown");function Ic(r,i,u,a,p){var g="Click";return a=="double"?g="Double"+g:a=="triple"&&(g="Triple"+g),g=(i==1?"Left":i==2?"Middle":"Right")+g,Ta(r,Rd(g,p),p,function(y){if(typeof y=="string"&&(y=xl[y]),!y)return!1;var S=!1;try{r.isReadOnly()&&(r.state.suppressEdits=!0),S=y(r,u)!=zt}finally{r.state.suppressEdits=!1}return S})}o(Ic,"handleMappedButton");function ka(r,i,u){var a=r.getOption("configureMouse"),p=a?a(r,i,u):{};if(p.unit==null){var g=G?u.shiftKey&&u.metaKey:u.altKey;p.unit=g?"rectangle":i=="single"?"char":i=="double"?"word":"line"}return(p.extend==null||r.doc.extend)&&(p.extend=r.doc.extend||u.shiftKey),p.addNew==null&&(p.addNew=I?u.metaKey:u.ctrlKey),p.moveOnDrag==null&&(p.moveOnDrag=!(I?u.altKey:u.ctrlKey)),p}o(ka,"configureMouse");function hg(r,i,u,a){c?setTimeout(Hr(vd,r),0):r.curOp.focus=Ge();var p=ka(r,u,a),g=r.doc.sel,y;r.options.dragDrop&&hs&&!r.isReadOnly()&&u=="single"&&(y=g.contains(i))>-1&&(ze((y=g.ranges[y]).from(),i)<0||i.xRel>0)&&(ze(y.to(),i)>0||i.xRel<0)?mg(r,a,i,p):vg(r,a,i,p)}o(hg,"leftButtonDown");function mg(r,i,u,a){var p=r.display,g=!1,y=lr(r,function(_){C&&(p.scroller.draggable=!1),r.state.draggingText=!1,r.state.delayingBlurEvent&&(r.hasFocus()?r.state.delayingBlurEvent=!1:hc(r)),he(p.wrapper.ownerDocument,"mouseup",y),he(p.wrapper.ownerDocument,"mousemove",S),he(p.scroller,"dragstart",b),he(p.scroller,"drop",y),g||(or(_),a.addNew||Cc(r.doc,u,null,null,a.extend),C&&!B||c&&v==9?setTimeout(function(){p.wrapper.ownerDocument.body.focus({preventScroll:!0}),p.input.focus()},20):p.input.focus())}),S=o(function(_){g=g||Math.abs(i.clientX-_.clientX)+Math.abs(i.clientY-_.clientY)>=10},"mouseMove"),b=o(function(){return g=!0},"dragStart");C&&(p.scroller.draggable=!0),r.state.draggingText=y,y.copy=!a.moveOnDrag,H(p.wrapper.ownerDocument,"mouseup",y),H(p.wrapper.ownerDocument,"mousemove",S),H(p.scroller,"dragstart",b),H(p.scroller,"drop",y),r.state.delayingBlurEvent=!0,setTimeout(function(){return p.input.focus()},20),p.scroller.dragDrop&&p.scroller.dragDrop()}o(mg,"leftButtonStartDrag");function gg(r,i,u){if(u=="char")return new wt(i,i);if(u=="word")return r.findWordAt(i);if(u=="line")return new wt(ue(i.line,0),He(r.doc,ue(i.line+1,0)));var a=u(r,i);return new wt(a.from,a.to)}o(gg,"rangeForUnit");function vg(r,i,u,a){c&&hc(r);var p=r.display,g=r.doc;or(i);var y,S,b=g.sel,_=b.ranges;if(a.addNew&&!a.extend?(S=g.sel.contains(u),S>-1?y=_[S]:y=new wt(u,u)):(y=g.sel.primary(),S=g.sel.primIndex),a.unit=="rectangle")a.addNew||(y=new wt(u,u)),u=po(r,i,!0,!0),S=-1;else{var M=gg(r,u,a.unit);a.extend?y=Sc(y,M.anchor,M.head,a.extend):y=M}a.addNew?S==-1?(S=_.length,$r(g,tn(r,_.concat([y]),S),{scroll:!1,origin:"*mouse"})):_.length>1&&_[S].empty()&&a.unit=="char"&&!a.extend?($r(g,tn(r,_.slice(0,S).concat(_.slice(S+1)),0),{scroll:!1,origin:"*mouse"}),b=g.sel):Pd(g,S,y,ie):(S=0,$r(g,new pi([y],0),ie),b=g.sel);var D=u;function V(ve){if(ze(D,ve)!=0)if(D=ve,a.unit=="rectangle"){for(var Ne=[],Ie=r.options.tabSize,De=Et(Me(g,u.line).text,u.ch,Ie),it=Et(Me(g,ve.line).text,ve.ch,Ie),Tt=Math.min(De,it),br=Math.max(De,it),At=Math.min(u.line,ve.line),Sn=Math.min(r.lastLine(),Math.max(u.line,ve.line));At<=Sn;At++){var Cn=Me(g,At).text,dr=Lr(Cn,Tt,Ie);Tt==br?Ne.push(new wt(ue(At,dr),ue(At,dr))):Cn.length>dr&&Ne.push(new wt(ue(At,dr),ue(At,Lr(Cn,br,Ie))))}Ne.length||Ne.push(new wt(u,u)),$r(g,tn(r,b.ranges.slice(0,S).concat(Ne),S),{origin:"*mouse",scroll:!1}),r.scrollIntoView(ve)}else{var Vr=y,Ar=gg(r,ve,a.unit),Pt=Vr.anchor,Bt;ze(Ar.anchor,Pt)>0?(Bt=Ar.head,Pt=il(Vr.from(),Ar.anchor)):(Bt=Ar.anchor,Pt=gs(Vr.to(),Ar.head));var ar=b.ranges.slice(0);ar[S]=Na(r,new wt(He(g,Pt),Bt)),$r(g,tn(r,ar,S),ie)}}o(V,"extendTo");var $=p.wrapper.getBoundingClientRect(),te=0;function oe(ve){var Ne=++te,Ie=po(r,ve,!0,a.unit=="rectangle");if(!!Ie)if(ze(Ie,D)!=0){r.curOp.focus=Ge(),V(Ie);var De=dl(p,g);(Ie.line>=De.to||Ie.line$.bottom?20:0;it&&setTimeout(lr(r,function(){te==Ne&&(p.scroller.scrollTop+=it,oe(ve))}),50)}}o(oe,"extend");function de(ve){r.state.selectingText=!1,te=1/0,ve&&(or(ve),p.input.focus()),he(p.wrapper.ownerDocument,"mousemove",ge),he(p.wrapper.ownerDocument,"mouseup",be),g.history.lastSelOrigin=null}o(de,"done");var ge=lr(r,function(ve){ve.buttons===0||!el(ve)?de(ve):oe(ve)}),be=lr(r,de);r.state.selectingText=be,H(p.wrapper.ownerDocument,"mousemove",ge),H(p.wrapper.ownerDocument,"mouseup",be)}o(vg,"leftButtonSelect");function Na(r,i){var u=i.anchor,a=i.head,p=Me(r.doc,u.line);if(ze(u,a)==0&&u.sticky==a.sticky)return i;var g=Mn(p);if(!g)return i;var y=Ci(g,u.ch,u.sticky),S=g[y];if(S.from!=u.ch&&S.to!=u.ch)return i;var b=y+(S.from==u.ch==(S.level!=1)?0:1);if(b==0||b==g.length)return i;var _;if(a.line!=u.line)_=(a.line-u.line)*(r.doc.direction=="ltr"?1:-1)>0;else{var M=Ci(g,a.ch,a.sticky),D=M-y||(a.ch-u.ch)*(S.level==1?-1:1);M==b-1||M==b?_=D<0:_=D>0}var V=g[b+(_?-1:0)],$=_==(V.level==1),te=$?V.from:V.to,oe=$?"after":"before";return u.ch==te&&u.sticky==oe?i:new wt(new ue(u.line,te,oe),a)}o(Na,"bidiSimplify");function Pa(r,i,u,a){var p,g;if(i.touches)p=i.touches[0].clientX,g=i.touches[0].clientY;else try{p=i.clientX,g=i.clientY}catch(V){return!1}if(p>=Math.floor(r.display.gutters.getBoundingClientRect().right))return!1;a&&or(i);var y=r.display,S=y.lineDiv.getBoundingClientRect();if(g>S.bottom||!Ft(r,u))return ds(i);g-=S.top-y.viewOffset;for(var b=0;b=p){var M=ao(r.doc,g),D=r.display.gutterSpecs[b];return Te(r,u,r,M,D.className,i),ds(i)}}}o(Pa,"gutterEvent");function zd(r,i){return Pa(r,i,"gutterClick",!0)}o(zd,"clickInGutter");function $d(r,i){ji(r.display,i)||yg(r,i)||ir(r,i,"contextmenu")||pe||r.display.input.onContextMenu(i)}o($d,"onContextMenu");function yg(r,i){return Ft(r,"gutterContextMenu")?Pa(r,i,"gutterContextMenu",!1):!1}o(yg,"contextMenuInGutter");function sf(r){r.display.wrapper.className=r.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+r.options.theme.replace(/(^|\s)\s*/g," cm-s-"),U(r)}o(sf,"themeChanged");var Sl={toString:function(){return"CodeMirror.Init"}},lf={},La={};function Fc(r){var i=r.optionHandlers;function u(a,p,g,y){r.defaults[a]=p,g&&(i[a]=y?function(S,b,_){_!=Sl&&g(S,b,_)}:g)}o(u,"option"),r.defineOption=u,r.Init=Sl,u("value","",function(a,p){return a.setValue(p)},!0),u("mode",null,function(a,p){a.doc.modeOption=p,_d(a)},!0),u("indentUnit",2,_d,!0),u("indentWithTabs",!1),u("smartIndent",!0),u("tabSize",4,function(a){Xu(a),U(a),et(a)},!0),u("lineSeparator",null,function(a,p){if(a.doc.lineSep=p,!!p){var g=[],y=a.doc.first;a.doc.iter(function(b){for(var _=0;;){var M=b.text.indexOf(p,_);if(M==-1)break;_=M+p.length,g.push(ue(y,M))}y++});for(var S=g.length-1;S>=0;S--)Sa(a.doc,p,g[S],ue(g[S].line,g[S].ch+p.length))}}),u("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(a,p,g){a.state.specialChars=new RegExp(p.source+(p.test(" ")?"":"| "),"g"),g!=Sl&&a.refresh()}),u("specialCharPlaceholder",Ur,function(a){return a.refresh()},!0),u("electricChars",!0),u("inputStyle",A?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),u("spellcheck",!1,function(a,p){return a.getInputField().spellcheck=p},!0),u("autocorrect",!1,function(a,p){return a.getInputField().autocorrect=p},!0),u("autocapitalize",!1,function(a,p){return a.getInputField().autocapitalize=p},!0),u("rtlMoveVisually",!K),u("wholeLineUpdateBefore",!0),u("theme","default",function(a){sf(a),Yu(a)},!0),u("keyMap","default",function(a,p,g){var y=wn(p),S=g!=Sl&&wn(g);S&&S.detach&&S.detach(a,y),y.attach&&y.attach(a,S||null)}),u("extraKeys",null),u("configureMouse",null),u("lineWrapping",!1,wg,!0),u("gutters",[],function(a,p){a.display.gutterSpecs=Cd(p,a.options.lineNumbers),Yu(a)},!0),u("fixedGutter",!0,function(a,p){a.display.gutters.style.left=p?fa(a.display)+"px":"0",a.refresh()},!0),u("coverGutterNextToScrollbar",!1,function(a){return Ps(a)},!0),u("scrollbarStyle","native",function(a){ml(a),Ps(a),a.display.scrollbars.setScrollTop(a.doc.scrollTop),a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},!0),u("lineNumbers",!1,function(a,p){a.display.gutterSpecs=Cd(a.options.gutters,p),Yu(a)},!0),u("firstLineNumber",1,Yu,!0),u("lineNumberFormatter",function(a){return a},Yu,!0),u("showCursorWhenSelecting",!1,$u,!0),u("resetSelectionOnContextMenu",!0),u("lineWiseCopyCut",!0),u("pasteLinesPerSelection",!0),u("selectionsMayTouch",!1),u("readOnly",!1,function(a,p){p=="nocursor"&&(pl(a),a.display.input.blur()),a.display.input.readOnlyChanged(p)}),u("screenReaderLabel",null,function(a,p){p=p===""?null:p,a.display.input.screenReaderLabelChanged(p)}),u("disableInput",!1,function(a,p){p||a.display.input.reset()},!0),u("dragDrop",!0,iw),u("allowDropFileTypes",null),u("cursorBlinkRate",530),u("cursorScrollMargin",0),u("cursorHeight",1,$u,!0),u("singleCursorHeightPerLine",!0,$u,!0),u("workTime",100),u("workDelay",100),u("flattenSpans",!0,Xu,!0),u("addModeClass",!1,Xu,!0),u("pollInterval",100),u("undoDepth",200,function(a,p){return a.doc.history.undoDepth=p}),u("historyEventDelay",1250),u("viewportMargin",10,function(a){return a.refresh()},!0),u("maxHighlightLength",1e4,Xu,!0),u("moveInputWithCursor",!0,function(a,p){p||a.display.input.resetPosition()}),u("tabindex",null,function(a,p){return a.display.input.getField().tabIndex=p||""}),u("autofocus",null),u("direction","ltr",function(a,p){return a.doc.setDirection(p)},!0),u("phrases",null)}o(Fc,"defineOptions");function iw(r,i,u){var a=u&&u!=Sl;if(!i!=!a){var p=r.display.dragFunctions,g=i?H:he;g(r.display.scroller,"dragstart",p.start),g(r.display.scroller,"dragenter",p.enter),g(r.display.scroller,"dragover",p.over),g(r.display.scroller,"dragleave",p.leave),g(r.display.scroller,"drop",p.drop)}}o(iw,"dragDropChanged");function wg(r){r.options.lineWrapping?(Xe(r.display.wrapper,"CodeMirror-wrap"),r.display.sizer.style.minWidth="",r.display.sizerWidth=null):(xe(r.display.wrapper,"CodeMirror-wrap"),zi(r)),bs(r),et(r),U(r),setTimeout(function(){return Ps(r)},100)}o(wg,"wrappingChanged");function Mt(r,i){var u=this;if(!(this instanceof Mt))return new Mt(r,i);this.options=i=i?Zt(i):{},Zt(lf,i,!1);var a=i.value;typeof a=="string"?a=new yn(a,i.mode,null,i.lineSeparator,i.direction):i.mode&&(a.modeOption=i.mode),this.doc=a;var p=new Mt.inputStyles[i.inputStyle](this),g=this.display=new Vy(r,a,p,i);g.wrapper.CodeMirror=this,sf(this),i.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),ml(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new Ct,keySeq:null,specialChars:null},i.autofocus&&!A&&g.input.focus(),c&&v<11&&setTimeout(function(){return u.display.input.reset(!0)},20),xg(this),Dd(),Ki(this),this.curOp.forceUpdate=!0,Km(this,a),i.autofocus&&!A||this.hasFocus()?setTimeout(function(){u.hasFocus()&&!u.state.focused&&pa(u)},20):pl(this);for(var y in La)La.hasOwnProperty(y)&&La[y](this,i[y],Sl);vo(this),i.finishInit&&i.finishInit(this);for(var S=0;S20*20}o(y,"farAway"),H(i.scroller,"touchstart",function(b){if(!ir(r,b)&&!g(b)&&!zd(r,b)){i.input.ensurePolled(),clearTimeout(u);var _=+new Date;i.activeTouch={start:_,moved:!1,prev:_-a.end<=300?a:null},b.touches.length==1&&(i.activeTouch.left=b.touches[0].pageX,i.activeTouch.top=b.touches[0].pageY)}}),H(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),H(i.scroller,"touchend",function(b){var _=i.activeTouch;if(_&&!ji(i,b)&&_.left!=null&&!_.moved&&new Date-_.start<300){var M=r.coordsChar(i.activeTouch,"page"),D;!_.prev||y(_,_.prev)?D=new wt(M,M):!_.prev.prev||y(_,_.prev.prev)?D=r.findWordAt(M):D=new wt(ue(M.line,0),He(r.doc,ue(M.line+1,0))),r.setSelection(D.anchor,D.head),r.focus(),or(b)}p()}),H(i.scroller,"touchcancel",p),H(i.scroller,"scroll",function(){i.scroller.clientHeight&&(sr(r,i.scroller.scrollTop),hl(r,i.scroller.scrollLeft,!0),Te(r,"scroll",r))}),H(i.scroller,"mousewheel",function(b){return qm(r,b)}),H(i.scroller,"DOMMouseScroll",function(b){return qm(r,b)}),H(i.wrapper,"scroll",function(){return i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(b){ir(r,b)||lo(b)},over:function(b){ir(r,b)||(Md(r,b),lo(b))},start:function(b){return Zy(r,b)},drop:lr(r,sg),leave:function(b){ir(r,b)||Ad(r)}};var S=i.input.getField();H(S,"keyup",function(b){return Ud.call(r,b)}),H(S,"keydown",lr(r,ug)),H(S,"keypress",lr(r,cg)),H(S,"focus",function(b){return pa(r,b)}),H(S,"blur",function(b){return pl(r,b)})}o(xg,"registerEventHandlers");var af=[];Mt.defineInitHook=function(r){return af.push(r)};function uf(r,i,u,a){var p=r.doc,g;u==null&&(u="add"),u=="smart"&&(p.mode.indent?g=$o(r,i).state:u="prev");var y=r.options.tabSize,S=Me(p,i),b=Et(S.text,null,y);S.stateAfter&&(S.stateAfter=null);var _=S.text.match(/^\s*/)[0],M;if(!a&&!/\S/.test(S.text))M=0,u="not";else if(u=="smart"&&(M=p.mode.indent(g,S.text.slice(_.length),S.text),M==zt||M>150)){if(!a)return;u="prev"}u=="prev"?i>p.first?M=Et(Me(p,i-1).text,null,y):M=0:u=="add"?M=b+r.options.indentUnit:u=="subtract"?M=b-r.options.indentUnit:typeof u=="number"&&(M=b+u),M=Math.max(0,M);var D="",V=0;if(r.options.indentWithTabs)for(var $=Math.floor(M/y);$;--$)V+=y,D+=" ";if(Vy,b=rl(i),_=null;if(S&&a.ranges.length>1)if(Li&&Li.text.join(` +`)==i){if(a.ranges.length%Li.text.length==0){_=[];for(var M=0;M=0;V--){var $=a.ranges[V],te=$.from(),oe=$.to();$.empty()&&(u&&u>0?te=ue(te.line,te.ch-u):r.state.overwrite&&!S?oe=ue(oe.line,Math.min(Me(g,oe.line).text.length,oe.ch+Se(b).length)):S&&Li&&Li.lineWise&&Li.text.join(` `)==b.join(` -`)&&(te=oe=ue(te.line,0)));var de={from:te,to:oe,text:E?E[V%E.length]:b,origin:p||(S?"paste":r.state.cutIncoming>y?"cut":"+input")};ya(r.doc,de),yr(r,"inputRead",r,de)}i&&!S&&Cg(r,i),ks(r),r.curOp.updateInput<2&&(r.curOp.updateInput=D),r.curOp.typing=!0,r.state.pasteIncoming=r.state.cutIncoming=-1}o(Bc,"applyTextInput");function jd(r,i){var u=r.clipboardData&&r.clipboardData.getData("Text");if(u)return r.preventDefault(),!i.isReadOnly()&&!i.options.disableInput&&Jr(i,function(){return Bc(i,u,0,null,"paste")}),!0}o(jd,"handlePaste");function Cg(r,i){if(!(!r.options.electricChars||!r.options.smartIndent))for(var u=r.doc.sel,a=u.ranges.length-1;a>=0;a--){var p=u.ranges[a];if(!(p.head.ch>100||a&&u.ranges[a-1].head.line==p.head.line)){var g=r.getModeAt(p.head),y=!1;if(g.electricChars){for(var S=0;S-1){y=uf(r,p.head.line,"smart");break}}else g.electricInput&&g.electricInput.test(Me(r.doc,p.head.line).text.slice(0,p.head.ch))&&(y=uf(r,p.head.line,"smart"));y&&yr(r,"electricInput",r,p.head.line)}}}o(Cg,"triggerElectric");function qd(r){for(var i=[],u=[],a=0;ag&&(uf(this,S.head.line,a,!0),g=S.head.line,y==this.doc.sel.primIndex&&ks(this));else{var b=S.from(),E=S.to(),M=Math.max(g,b.line);g=Math.min(this.lastLine(),E.line-(E.ch?0:1))+1;for(var D=M;D0&&Ld(this.doc,y,new wt(b,V[y].to()),$t)}}}),getTokenAt:function(a,p){return Kl(this,a,p)},getLineTokens:function(a,p){return Kl(this,ue(a),p,!0)},getTokenTypeAt:function(a){a=He(this.doc,a);var p=_u(this,Me(this.doc,a.line)),g=0,y=(p.length-1)/2,S=a.ch,b;if(S==0)b=p[2];else for(;;){var E=g+y>>1;if((E?p[E*2-1]:0)>=S)y=E;else if(p[E*2+1]b&&(a=b,y=!0),S=Me(this.doc,a)}else S=a;return ci(this,S,{top:0,left:0},p||"page",g||y).top+(y?this.doc.height-hn(S):0)},defaultTextHeight:function(){return Cs(this.display)},defaultCharWidth:function(){return ua(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,p,g,y,S){var b=this.display;a=Vn(this,He(this.doc,a));var E=a.bottom,M=a.left;if(p.style.position="absolute",p.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(p),b.sizer.appendChild(p),y=="over")E=a.top;else if(y=="above"||y=="near"){var D=Math.max(b.wrapper.clientHeight,this.doc.height),V=Math.max(b.sizer.clientWidth,b.lineSpace.clientWidth);(y=="above"||a.bottom+p.offsetHeight>D)&&a.top>p.offsetHeight?E=a.top-p.offsetHeight:a.bottom+p.offsetHeight<=D&&(E=a.bottom),M+p.offsetWidth>V&&(M=V-p.offsetWidth)}p.style.top=E+"px",p.style.left=p.style.right="",S=="right"?(M=b.sizer.clientWidth-p.offsetWidth,p.style.right="0px"):(S=="left"?M=0:S=="middle"&&(M=(b.sizer.clientWidth-p.offsetWidth)/2),p.style.left=M+"px"),g&&By(this,{left:M,top:E,right:M+p.offsetWidth,bottom:E+p.offsetHeight})},triggerOnKeyDown:en(fg),triggerOnKeyPress:en(pg),triggerOnKeyUp:Ud,triggerOnMouseDown:en(hg),execCommand:function(a){if(xl.hasOwnProperty(a))return xl[a].call(null,this)},triggerElectric:en(function(a){Cg(this,a)}),findPosH:function(a,p,g,y){var S=1;p<0&&(S=-1,p=-p);for(var b=He(this.doc,a),E=0;E0&&M(g.charAt(y-1));)--y;for(;S.5||this.options.lineWrapping)&&bs(this),Te(this,"refresh",this)}),swapDoc:en(function(a){var p=this.doc;return p.cm=null,this.state.selectingText&&this.state.selectingText(),Gm(this,a),U(this),this.display.input.reset(),qu(this,a.scrollLeft,a.scrollTop),this.curOp.forceScroll=!0,yr(this,"swapDoc",this,p),p}),phrase:function(a){var p=this.options.phrases;return p&&Object.prototype.hasOwnProperty.call(p,a)?p[a]:a},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Wr(r),r.registerHelper=function(a,p,g){u.hasOwnProperty(a)||(u[a]=r[a]={_global:[]}),u[a][p]=g},r.registerGlobalHelper=function(a,p,g,y){r.registerHelper(a,p,y),u[a]._global.push({pred:g,val:y})}}o(ts,"addEditorMethods");function ff(r,i,u,a,p){var g=i,y=u,S=Me(r,i.line),b=p&&r.direction=="rtl"?-u:u;function E(){var be=i.line+b;return be=r.first+r.size?!1:(i=new ue(be,i.ch,i.sticky),S=Me(r,be))}o(E,"findNextLine");function M(be){var ve;if(a=="codepoint"){var Ne=S.text.charCodeAt(i.ch+(u>0?0:-1));if(isNaN(Ne))ve=null;else{var Ie=u>0?Ne>=55296&&Ne<56320:Ne>=56320&&Ne<57343;ve=new ue(i.line,Math.max(0,Math.min(S.text.length,i.ch+u*(Ie?2:1))),-u)}}else p?ve=ug(r.cm,S,i,u):ve=Mc(S,i,u);if(ve==null)if(!be&&E())i=_a(p,r.cm,S,i.line,b);else return!1;else i=ve;return!0}if(o(M,"moveOnce"),a=="char"||a=="codepoint")M();else if(a=="column")M(!0);else if(a=="word"||a=="group")for(var D=null,V=a=="group",$=r.cm&&r.cm.getHelper(i,"wordChars"),te=!0;!(u<0&&!M(!te));te=!1){var oe=S.text.charAt(i.ch)||` +`)&&(te=oe=ue(te.line,0)));var de={from:te,to:oe,text:_?_[V%_.length]:b,origin:p||(S?"paste":r.state.cutIncoming>y?"cut":"+input")};ya(r.doc,de),yr(r,"inputRead",r,de)}i&&!S&&Sg(r,i),ks(r),r.curOp.updateInput<2&&(r.curOp.updateInput=D),r.curOp.typing=!0,r.state.pasteIncoming=r.state.cutIncoming=-1}o(Bc,"applyTextInput");function jd(r,i){var u=r.clipboardData&&r.clipboardData.getData("Text");if(u)return r.preventDefault(),!i.isReadOnly()&&!i.options.disableInput&&Jr(i,function(){return Bc(i,u,0,null,"paste")}),!0}o(jd,"handlePaste");function Sg(r,i){if(!(!r.options.electricChars||!r.options.smartIndent))for(var u=r.doc.sel,a=u.ranges.length-1;a>=0;a--){var p=u.ranges[a];if(!(p.head.ch>100||a&&u.ranges[a-1].head.line==p.head.line)){var g=r.getModeAt(p.head),y=!1;if(g.electricChars){for(var S=0;S-1){y=uf(r,p.head.line,"smart");break}}else g.electricInput&&g.electricInput.test(Me(r.doc,p.head.line).text.slice(0,p.head.ch))&&(y=uf(r,p.head.line,"smart"));y&&yr(r,"electricInput",r,p.head.line)}}}o(Sg,"triggerElectric");function qd(r){for(var i=[],u=[],a=0;ag&&(uf(this,S.head.line,a,!0),g=S.head.line,y==this.doc.sel.primIndex&&ks(this));else{var b=S.from(),_=S.to(),M=Math.max(g,b.line);g=Math.min(this.lastLine(),_.line-(_.ch?0:1))+1;for(var D=M;D0&&Pd(this.doc,y,new wt(b,V[y].to()),$t)}}}),getTokenAt:function(a,p){return Kl(this,a,p)},getLineTokens:function(a,p){return Kl(this,ue(a),p,!0)},getTokenTypeAt:function(a){a=He(this.doc,a);var p=Eu(this,Me(this.doc,a.line)),g=0,y=(p.length-1)/2,S=a.ch,b;if(S==0)b=p[2];else for(;;){var _=g+y>>1;if((_?p[_*2-1]:0)>=S)y=_;else if(p[_*2+1]b&&(a=b,y=!0),S=Me(this.doc,a)}else S=a;return ci(this,S,{top:0,left:0},p||"page",g||y).top+(y?this.doc.height-hn(S):0)},defaultTextHeight:function(){return Cs(this.display)},defaultCharWidth:function(){return ua(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,p,g,y,S){var b=this.display;a=Vn(this,He(this.doc,a));var _=a.bottom,M=a.left;if(p.style.position="absolute",p.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(p),b.sizer.appendChild(p),y=="over")_=a.top;else if(y=="above"||y=="near"){var D=Math.max(b.wrapper.clientHeight,this.doc.height),V=Math.max(b.sizer.clientWidth,b.lineSpace.clientWidth);(y=="above"||a.bottom+p.offsetHeight>D)&&a.top>p.offsetHeight?_=a.top-p.offsetHeight:a.bottom+p.offsetHeight<=D&&(_=a.bottom),M+p.offsetWidth>V&&(M=V-p.offsetWidth)}p.style.top=_+"px",p.style.left=p.style.right="",S=="right"?(M=b.sizer.clientWidth-p.offsetWidth,p.style.right="0px"):(S=="left"?M=0:S=="middle"&&(M=(b.sizer.clientWidth-p.offsetWidth)/2),p.style.left=M+"px"),g&&Fy(this,{left:M,top:_,right:M+p.offsetWidth,bottom:_+p.offsetHeight})},triggerOnKeyDown:en(ug),triggerOnKeyPress:en(cg),triggerOnKeyUp:Ud,triggerOnMouseDown:en(dg),execCommand:function(a){if(xl.hasOwnProperty(a))return xl[a].call(null,this)},triggerElectric:en(function(a){Sg(this,a)}),findPosH:function(a,p,g,y){var S=1;p<0&&(S=-1,p=-p);for(var b=He(this.doc,a),_=0;_0&&M(g.charAt(y-1));)--y;for(;S.5||this.options.lineWrapping)&&bs(this),Te(this,"refresh",this)}),swapDoc:en(function(a){var p=this.doc;return p.cm=null,this.state.selectingText&&this.state.selectingText(),Km(this,a),U(this),this.display.input.reset(),qu(this,a.scrollLeft,a.scrollTop),this.curOp.forceScroll=!0,yr(this,"swapDoc",this,p),p}),phrase:function(a){var p=this.options.phrases;return p&&Object.prototype.hasOwnProperty.call(p,a)?p[a]:a},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Wr(r),r.registerHelper=function(a,p,g){u.hasOwnProperty(a)||(u[a]=r[a]={_global:[]}),u[a][p]=g},r.registerGlobalHelper=function(a,p,g,y){r.registerHelper(a,p,y),u[a]._global.push({pred:g,val:y})}}o(ts,"addEditorMethods");function ff(r,i,u,a,p){var g=i,y=u,S=Me(r,i.line),b=p&&r.direction=="rtl"?-u:u;function _(){var be=i.line+b;return be=r.first+r.size?!1:(i=new ue(be,i.ch,i.sticky),S=Me(r,be))}o(_,"findNextLine");function M(be){var ve;if(a=="codepoint"){var Ne=S.text.charCodeAt(i.ch+(u>0?0:-1));if(isNaN(Ne))ve=null;else{var Ie=u>0?Ne>=55296&&Ne<56320:Ne>=56320&&Ne<57343;ve=new ue(i.line,Math.max(0,Math.min(S.text.length,i.ch+u*(Ie?2:1))),-u)}}else p?ve=ag(r.cm,S,i,u):ve=Mc(S,i,u);if(ve==null)if(!be&&_())i=Ea(p,r.cm,S,i.line,b);else return!1;else i=ve;return!0}if(o(M,"moveOnce"),a=="char"||a=="codepoint")M();else if(a=="column")M(!0);else if(a=="word"||a=="group")for(var D=null,V=a=="group",$=r.cm&&r.cm.getHelper(i,"wordChars"),te=!0;!(u<0&&!M(!te));te=!1){var oe=S.text.charAt(i.ch)||` `,de=gr(oe,$)?"w":V&&oe==` -`?"n":!V||/\s/.test(oe)?null:"p";if(V&&!te&&!de&&(de="s"),D&&D!=de){u<0&&(u=1,M(),i.sticky="after");break}if(de&&(D=de),u>0&&!M(!te))break}var ge=jr(r,i,g,y,!0);return Cu(g,ge)&&(ge.hitSide=!0),ge}o(ff,"findPosH");function Hc(r,i,u,a){var p=r.doc,g=i.left,y;if(a=="page"){var S=Math.min(r.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),b=Math.max(S-.5*Cs(r.display),3);y=(u>0?i.bottom:i.top)+u*b}else a=="line"&&(y=u>0?i.bottom+3:i.top-3);for(var E;E=q(r,g,y),!!E.outside;){if(u<0?y<=0:y>=p.height){E.hitSide=!0;break}y+=u*5}return E}o(Hc,"findPosV");var xt=o(function(r){this.cm=r,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Ct,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null},"ContentEditableInput");xt.prototype.init=function(r){var i=this,u=this,a=u.cm,p=u.div=r.lineDiv;p.contentEditable=!0,bg(p,a.options.spellcheck,a.options.autocorrect,a.options.autocapitalize);function g(S){for(var b=S.target;b;b=b.parentNode){if(b==p)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(b.className))break}return!1}o(g,"belongsToInput"),H(p,"paste",function(S){!g(S)||ir(a,S)||jd(S,a)||v<=11&&setTimeout(lr(a,function(){return i.updateFromDOM()}),20)}),H(p,"compositionstart",function(S){i.composing={data:S.data,done:!1}}),H(p,"compositionupdate",function(S){i.composing||(i.composing={data:S.data,done:!1})}),H(p,"compositionend",function(S){i.composing&&(S.data!=i.composing.data&&i.readFromDOMSoon(),i.composing.done=!0)}),H(p,"touchstart",function(){return u.forceCompositionEnd()}),H(p,"input",function(){i.composing||i.readFromDOMSoon()});function y(S){if(!(!g(S)||ir(a,S))){if(a.somethingSelected())Oi({lineWise:!1,text:a.getSelections()}),S.type=="cut"&&a.replaceSelection("",null,"cut");else if(a.options.lineWiseCopyCut){var b=qd(a);Oi({lineWise:!0,text:b.text}),S.type=="cut"&&a.operation(function(){a.setSelections(b.ranges,0,$t),a.replaceSelection("",null,"cut")})}else return;if(S.clipboardData){S.clipboardData.clearData();var E=Pi.text.join(` -`);if(S.clipboardData.setData("Text",E),S.clipboardData.getData("Text")==E){S.preventDefault();return}}var M=Eg(),D=M.firstChild;a.display.lineSpace.insertBefore(M,a.display.lineSpace.firstChild),D.value=Pi.text.join(` -`);var V=Ge();ct(D),setTimeout(function(){a.display.lineSpace.removeChild(M),V.focus(),V==p&&u.showPrimarySelection()},50)}}o(y,"onCopyCut"),H(p,"copy",y),H(p,"cut",y)},xt.prototype.screenReaderLabelChanged=function(r){r?this.div.setAttribute("aria-label",r):this.div.removeAttribute("aria-label")},xt.prototype.prepareSelection=function(){var r=ju(this.cm,!1);return r.focus=Ge()==this.div,r},xt.prototype.showSelection=function(r,i){!r||!this.cm.display.view.length||((r.focus||i)&&this.showPrimarySelection(),this.showMultipleSelections(r))},xt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},xt.prototype.showPrimarySelection=function(){var r=this.getSelection(),i=this.cm,u=i.doc.sel.primary(),a=u.from(),p=u.to();if(i.display.viewTo==i.display.viewFrom||a.line>=i.display.viewTo||p.line=i.display.viewFrom&&cf(i,a)||{node:S[0].measure.map[2],offset:0},E=p.liner.firstLine()&&(a=ue(a.line-1,Me(r.doc,a.line-1).length)),p.ch==Me(r.doc,p.line).text.length&&p.linei.viewTo-1)return!1;var g,y,S;a.line==i.viewFrom||(g=ho(r,a.line))==0?(y=vt(i.view[0].line),S=i.view[0].node):(y=vt(i.view[g].line),S=i.view[g-1].node.nextSibling);var b=ho(r,p.line),E,M;if(b==i.view.length-1?(E=i.viewTo-1,M=i.lineDiv.lastChild):(E=vt(i.view[b+1].line)-1,M=i.view[b+1].node.previousSibling),!S)return!1;for(var D=r.doc.splitLines(Wc(r,S,M,y,E)),V=Ei(r.doc,ue(y,0),ue(E,Me(r.doc,E).text.length));D.length>1&&V.length>1;)if(Se(D)==Se(V))D.pop(),V.pop(),E--;else if(D[0]==V[0])D.shift(),V.shift(),y++;else break;for(var $=0,te=0,oe=D[0],de=V[0],ge=Math.min(oe.length,de.length);$a.ch&&be.charCodeAt(be.length-te-1)==ve.charCodeAt(ve.length-te-1);)$--,te++;D[D.length-1]=be.slice(0,be.length-te).replace(/^\u200b+/,""),D[0]=D[0].slice($).replace(/\u200b+$/,"");var Ie=ue(y,$),De=ue(E,V.length?Se(V).length-te:0);if(D.length>1||D[0]||ze(Ie,De))return Sa(r.doc,D,Ie,De,"+input"),!0},xt.prototype.ensurePolled=function(){this.forceCompositionEnd()},xt.prototype.reset=function(){this.forceCompositionEnd()},xt.prototype.forceCompositionEnd=function(){!this.composing||(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},xt.prototype.readFromDOMSoon=function(){var r=this;this.readDOMTimeout==null&&(this.readDOMTimeout=setTimeout(function(){if(r.readDOMTimeout=null,r.composing)if(r.composing.done)r.composing=null;else return;r.updateFromDOM()},80))},xt.prototype.updateFromDOM=function(){var r=this;(this.cm.isReadOnly()||!this.pollContent())&&Jr(this.cm,function(){return et(r.cm)})},xt.prototype.setUneditable=function(r){r.contentEditable="false"},xt.prototype.onKeyPress=function(r){r.charCode==0||this.composing||(r.preventDefault(),this.cm.isReadOnly()||lr(this.cm,Bc)(this.cm,String.fromCharCode(r.charCode==null?r.keyCode:r.charCode),0))},xt.prototype.readOnlyChanged=function(r){this.div.contentEditable=String(r!="nocursor")},xt.prototype.onContextMenu=function(){},xt.prototype.resetPosition=function(){},xt.prototype.needsContentAttribute=!0;function cf(r,i){var u=la(r,i.line);if(!u||u.hidden)return null;var a=Me(r.doc,i.line),p=Wu(u,a,i.line),g=Mn(a,r.doc.direction),y="left";if(g){var S=Ci(g,i.ch);y=S%2?"right":"left"}var b=aa(p.map,i.ch,y);return b.offset=b.collapse=="right"?b.end:b.start,b}o(cf,"posToDOM");function Oa(r){for(var i=r;i;i=i.parentNode)if(/CodeMirror-gutter-wrapper/.test(i.className))return!0;return!1}o(Oa,"isInGutter");function Be(r,i){return i&&(r.bad=!0),r}o(Be,"badPos");function Wc(r,i,u,a,p){var g="",y=!1,S=r.doc.lineSeparator(),b=!1;function E($){return function(te){return te.id==$}}o(E,"recognizeMarker");function M(){y&&(g+=S,b&&(g+=S),y=b=!1)}o(M,"close");function D($){$&&(M(),g+=$)}o(D,"addText");function V($){if($.nodeType==1){var te=$.getAttribute("cm-text");if(te){D(te);return}var oe=$.getAttribute("cm-marker"),de;if(oe){var ge=r.findMarks(ue(a,0),ue(p+1,0),E(+oe));ge.length&&(de=ge[0].find(0))&&D(Ei(r.doc,de.from,de.to).join(S));return}if($.getAttribute("contenteditable")=="false")return;var be=/^(pre|div|p|li|table|br)$/i.test($.nodeName);if(!/^br$/i.test($.nodeName)&&$.textContent.length==0)return;be&&M();for(var ve=0;ve<$.childNodes.length;ve++)V($.childNodes[ve]);/^(pre|p)$/i.test($.nodeName)&&(b=!0),be&&(y=!0)}else $.nodeType==3&&D($.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(o(V,"walk");V(i),i!=u;)i=i.nextSibling,b=!1;return g}o(Wc,"domTextBetween");function Ma(r,i,u){var a;if(i==r.display.lineDiv){if(a=r.display.lineDiv.childNodes[u],!a)return Be(r.clipPos(ue(r.display.viewTo-1)),!0);i=null,u=0}else for(a=i;;a=a.parentNode){if(!a||a==r.display.lineDiv)return null;if(a.parentNode&&a.parentNode==r.display.lineDiv)break}for(var p=0;p=9&&i.hasSelection&&(i.hasSelection=null),u.poll()}),H(p,"paste",function(y){ir(a,y)||jd(y,a)||(a.state.pasteIncoming=+new Date,u.fastPoll())});function g(y){if(!ir(a,y)){if(a.somethingSelected())Oi({lineWise:!1,text:a.getSelections()});else if(a.options.lineWiseCopyCut){var S=qd(a);Oi({lineWise:!0,text:S.text}),y.type=="cut"?a.setSelections(S.ranges,null,$t):(u.prevInput="",p.value=S.text.join(` -`),ct(p))}else return;y.type=="cut"&&(a.state.cutIncoming=+new Date)}}o(g,"prepareCopyCut"),H(p,"cut",g),H(p,"copy",g),H(r.scroller,"paste",function(y){if(!(ji(r,y)||ir(a,y))){if(!p.dispatchEvent){a.state.pasteIncoming=+new Date,u.focus();return}var S=new Event("paste");S.clipboardData=y.clipboardData,p.dispatchEvent(S)}}),H(r.lineSpace,"selectstart",function(y){ji(r,y)||or(y)}),H(p,"compositionstart",function(){var y=a.getCursor("from");u.composing&&u.composing.range.clear(),u.composing={start:y,range:a.markText(y,a.getCursor("to"),{className:"CodeMirror-composing"})}}),H(p,"compositionend",function(){u.composing&&(u.poll(),u.composing.range.clear(),u.composing=null)})},pr.prototype.createField=function(r){this.wrapper=Eg(),this.textarea=this.wrapper.firstChild},pr.prototype.screenReaderLabelChanged=function(r){r?this.textarea.setAttribute("aria-label",r):this.textarea.removeAttribute("aria-label")},pr.prototype.prepareSelection=function(){var r=this.cm,i=r.display,u=r.doc,a=ju(r);if(r.options.moveInputWithCursor){var p=Vn(r,u.sel.primary().head,"div"),g=i.wrapper.getBoundingClientRect(),y=i.lineDiv.getBoundingClientRect();a.teTop=Math.max(0,Math.min(i.wrapper.clientHeight-10,p.top+y.top-g.top)),a.teLeft=Math.max(0,Math.min(i.wrapper.clientWidth-10,p.left+y.left-g.left))}return a},pr.prototype.showSelection=function(r){var i=this.cm,u=i.display;tt(u.cursorDiv,r.cursors),tt(u.selectionDiv,r.selection),r.teTop!=null&&(this.wrapper.style.top=r.teTop+"px",this.wrapper.style.left=r.teLeft+"px")},pr.prototype.reset=function(r){if(!(this.contextMenuPending||this.composing)){var i=this.cm;if(i.somethingSelected()){this.prevInput="";var u=i.getSelection();this.textarea.value=u,i.state.focused&&ct(this.textarea),c&&v>=9&&(this.hasSelection=u)}else r||(this.prevInput=this.textarea.value="",c&&v>=9&&(this.hasSelection=null))}},pr.prototype.getField=function(){return this.textarea},pr.prototype.supportsTouch=function(){return!1},pr.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!A||Ge()!=this.textarea))try{this.textarea.focus()}catch(r){}},pr.prototype.blur=function(){this.textarea.blur()},pr.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},pr.prototype.receivedFocus=function(){this.slowPoll()},pr.prototype.slowPoll=function(){var r=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){r.poll(),r.cm.state.focused&&r.slowPoll()})},pr.prototype.fastPoll=function(){var r=!1,i=this;i.pollingFast=!0;function u(){var a=i.poll();!a&&!r?(r=!0,i.polling.set(60,u)):(i.pollingFast=!1,i.slowPoll())}o(u,"p"),i.polling.set(20,u)},pr.prototype.poll=function(){var r=this,i=this.cm,u=this.textarea,a=this.prevInput;if(this.contextMenuPending||!i.state.focused||od(u)&&!a&&!this.composing||i.isReadOnly()||i.options.disableInput||i.state.keySeq)return!1;var p=u.value;if(p==a&&!i.somethingSelected())return!1;if(c&&v>=9&&this.hasSelection===p||I&&/[\uf700-\uf7ff]/.test(p))return i.display.input.reset(),!1;if(i.doc.sel==i.display.selForContextMenu){var g=p.charCodeAt(0);if(g==8203&&!a&&(a="\u200B"),g==8666)return this.reset(),this.cm.execCommand("undo")}for(var y=0,S=Math.min(a.length,p.length);y1e3||p.indexOf(` -`)>-1?u.value=r.prevInput="":r.prevInput=p,r.composing&&(r.composing.range.clear(),r.composing.range=i.markText(r.composing.start,i.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},pr.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},pr.prototype.onKeyPress=function(){c&&v>=9&&(this.hasSelection=null),this.fastPoll()},pr.prototype.onContextMenu=function(r){var i=this,u=i.cm,a=u.display,p=i.textarea;i.contextMenuPending&&i.contextMenuPending();var g=po(u,r),y=a.scroller.scrollTop;if(!g||j)return;var S=u.options.resetSelectionOnContextMenu;S&&u.doc.sel.contains(g)==-1&&lr(u,$r)(u.doc,Os(g),$t);var b=p.style.cssText,E=i.wrapper.style.cssText,M=i.wrapper.offsetParent.getBoundingClientRect();i.wrapper.style.cssText="position: static",p.style.cssText=`position: absolute; width: 30px; height: 30px; +`?"n":!V||/\s/.test(oe)?null:"p";if(V&&!te&&!de&&(de="s"),D&&D!=de){u<0&&(u=1,M(),i.sticky="after");break}if(de&&(D=de),u>0&&!M(!te))break}var ge=jr(r,i,g,y,!0);return Cu(g,ge)&&(ge.hitSide=!0),ge}o(ff,"findPosH");function Hc(r,i,u,a){var p=r.doc,g=i.left,y;if(a=="page"){var S=Math.min(r.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),b=Math.max(S-.5*Cs(r.display),3);y=(u>0?i.bottom:i.top)+u*b}else a=="line"&&(y=u>0?i.bottom+3:i.top-3);for(var _;_=q(r,g,y),!!_.outside;){if(u<0?y<=0:y>=p.height){_.hitSide=!0;break}y+=u*5}return _}o(Hc,"findPosV");var xt=o(function(r){this.cm=r,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Ct,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null},"ContentEditableInput");xt.prototype.init=function(r){var i=this,u=this,a=u.cm,p=u.div=r.lineDiv;p.contentEditable=!0,Cg(p,a.options.spellcheck,a.options.autocorrect,a.options.autocapitalize);function g(S){for(var b=S.target;b;b=b.parentNode){if(b==p)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(b.className))break}return!1}o(g,"belongsToInput"),H(p,"paste",function(S){!g(S)||ir(a,S)||jd(S,a)||v<=11&&setTimeout(lr(a,function(){return i.updateFromDOM()}),20)}),H(p,"compositionstart",function(S){i.composing={data:S.data,done:!1}}),H(p,"compositionupdate",function(S){i.composing||(i.composing={data:S.data,done:!1})}),H(p,"compositionend",function(S){i.composing&&(S.data!=i.composing.data&&i.readFromDOMSoon(),i.composing.done=!0)}),H(p,"touchstart",function(){return u.forceCompositionEnd()}),H(p,"input",function(){i.composing||i.readFromDOMSoon()});function y(S){if(!(!g(S)||ir(a,S))){if(a.somethingSelected())Oi({lineWise:!1,text:a.getSelections()}),S.type=="cut"&&a.replaceSelection("",null,"cut");else if(a.options.lineWiseCopyCut){var b=qd(a);Oi({lineWise:!0,text:b.text}),S.type=="cut"&&a.operation(function(){a.setSelections(b.ranges,0,$t),a.replaceSelection("",null,"cut")})}else return;if(S.clipboardData){S.clipboardData.clearData();var _=Li.text.join(` +`);if(S.clipboardData.setData("Text",_),S.clipboardData.getData("Text")==_){S.preventDefault();return}}var M=bg(),D=M.firstChild;a.display.lineSpace.insertBefore(M,a.display.lineSpace.firstChild),D.value=Li.text.join(` +`);var V=Ge();ct(D),setTimeout(function(){a.display.lineSpace.removeChild(M),V.focus(),V==p&&u.showPrimarySelection()},50)}}o(y,"onCopyCut"),H(p,"copy",y),H(p,"cut",y)},xt.prototype.screenReaderLabelChanged=function(r){r?this.div.setAttribute("aria-label",r):this.div.removeAttribute("aria-label")},xt.prototype.prepareSelection=function(){var r=ju(this.cm,!1);return r.focus=Ge()==this.div,r},xt.prototype.showSelection=function(r,i){!r||!this.cm.display.view.length||((r.focus||i)&&this.showPrimarySelection(),this.showMultipleSelections(r))},xt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},xt.prototype.showPrimarySelection=function(){var r=this.getSelection(),i=this.cm,u=i.doc.sel.primary(),a=u.from(),p=u.to();if(i.display.viewTo==i.display.viewFrom||a.line>=i.display.viewTo||p.line=i.display.viewFrom&&cf(i,a)||{node:S[0].measure.map[2],offset:0},_=p.liner.firstLine()&&(a=ue(a.line-1,Me(r.doc,a.line-1).length)),p.ch==Me(r.doc,p.line).text.length&&p.linei.viewTo-1)return!1;var g,y,S;a.line==i.viewFrom||(g=ho(r,a.line))==0?(y=vt(i.view[0].line),S=i.view[0].node):(y=vt(i.view[g].line),S=i.view[g-1].node.nextSibling);var b=ho(r,p.line),_,M;if(b==i.view.length-1?(_=i.viewTo-1,M=i.lineDiv.lastChild):(_=vt(i.view[b+1].line)-1,M=i.view[b+1].node.previousSibling),!S)return!1;for(var D=r.doc.splitLines(Wc(r,S,M,y,_)),V=_i(r.doc,ue(y,0),ue(_,Me(r.doc,_).text.length));D.length>1&&V.length>1;)if(Se(D)==Se(V))D.pop(),V.pop(),_--;else if(D[0]==V[0])D.shift(),V.shift(),y++;else break;for(var $=0,te=0,oe=D[0],de=V[0],ge=Math.min(oe.length,de.length);$a.ch&&be.charCodeAt(be.length-te-1)==ve.charCodeAt(ve.length-te-1);)$--,te++;D[D.length-1]=be.slice(0,be.length-te).replace(/^\u200b+/,""),D[0]=D[0].slice($).replace(/\u200b+$/,"");var Ie=ue(y,$),De=ue(_,V.length?Se(V).length-te:0);if(D.length>1||D[0]||ze(Ie,De))return Sa(r.doc,D,Ie,De,"+input"),!0},xt.prototype.ensurePolled=function(){this.forceCompositionEnd()},xt.prototype.reset=function(){this.forceCompositionEnd()},xt.prototype.forceCompositionEnd=function(){!this.composing||(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},xt.prototype.readFromDOMSoon=function(){var r=this;this.readDOMTimeout==null&&(this.readDOMTimeout=setTimeout(function(){if(r.readDOMTimeout=null,r.composing)if(r.composing.done)r.composing=null;else return;r.updateFromDOM()},80))},xt.prototype.updateFromDOM=function(){var r=this;(this.cm.isReadOnly()||!this.pollContent())&&Jr(this.cm,function(){return et(r.cm)})},xt.prototype.setUneditable=function(r){r.contentEditable="false"},xt.prototype.onKeyPress=function(r){r.charCode==0||this.composing||(r.preventDefault(),this.cm.isReadOnly()||lr(this.cm,Bc)(this.cm,String.fromCharCode(r.charCode==null?r.keyCode:r.charCode),0))},xt.prototype.readOnlyChanged=function(r){this.div.contentEditable=String(r!="nocursor")},xt.prototype.onContextMenu=function(){},xt.prototype.resetPosition=function(){},xt.prototype.needsContentAttribute=!0;function cf(r,i){var u=la(r,i.line);if(!u||u.hidden)return null;var a=Me(r.doc,i.line),p=Wu(u,a,i.line),g=Mn(a,r.doc.direction),y="left";if(g){var S=Ci(g,i.ch);y=S%2?"right":"left"}var b=aa(p.map,i.ch,y);return b.offset=b.collapse=="right"?b.end:b.start,b}o(cf,"posToDOM");function Oa(r){for(var i=r;i;i=i.parentNode)if(/CodeMirror-gutter-wrapper/.test(i.className))return!0;return!1}o(Oa,"isInGutter");function Be(r,i){return i&&(r.bad=!0),r}o(Be,"badPos");function Wc(r,i,u,a,p){var g="",y=!1,S=r.doc.lineSeparator(),b=!1;function _($){return function(te){return te.id==$}}o(_,"recognizeMarker");function M(){y&&(g+=S,b&&(g+=S),y=b=!1)}o(M,"close");function D($){$&&(M(),g+=$)}o(D,"addText");function V($){if($.nodeType==1){var te=$.getAttribute("cm-text");if(te){D(te);return}var oe=$.getAttribute("cm-marker"),de;if(oe){var ge=r.findMarks(ue(a,0),ue(p+1,0),_(+oe));ge.length&&(de=ge[0].find(0))&&D(_i(r.doc,de.from,de.to).join(S));return}if($.getAttribute("contenteditable")=="false")return;var be=/^(pre|div|p|li|table|br)$/i.test($.nodeName);if(!/^br$/i.test($.nodeName)&&$.textContent.length==0)return;be&&M();for(var ve=0;ve<$.childNodes.length;ve++)V($.childNodes[ve]);/^(pre|p)$/i.test($.nodeName)&&(b=!0),be&&(y=!0)}else $.nodeType==3&&D($.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(o(V,"walk");V(i),i!=u;)i=i.nextSibling,b=!1;return g}o(Wc,"domTextBetween");function Ma(r,i,u){var a;if(i==r.display.lineDiv){if(a=r.display.lineDiv.childNodes[u],!a)return Be(r.clipPos(ue(r.display.viewTo-1)),!0);i=null,u=0}else for(a=i;;a=a.parentNode){if(!a||a==r.display.lineDiv)return null;if(a.parentNode&&a.parentNode==r.display.lineDiv)break}for(var p=0;p=9&&i.hasSelection&&(i.hasSelection=null),u.poll()}),H(p,"paste",function(y){ir(a,y)||jd(y,a)||(a.state.pasteIncoming=+new Date,u.fastPoll())});function g(y){if(!ir(a,y)){if(a.somethingSelected())Oi({lineWise:!1,text:a.getSelections()});else if(a.options.lineWiseCopyCut){var S=qd(a);Oi({lineWise:!0,text:S.text}),y.type=="cut"?a.setSelections(S.ranges,null,$t):(u.prevInput="",p.value=S.text.join(` +`),ct(p))}else return;y.type=="cut"&&(a.state.cutIncoming=+new Date)}}o(g,"prepareCopyCut"),H(p,"cut",g),H(p,"copy",g),H(r.scroller,"paste",function(y){if(!(ji(r,y)||ir(a,y))){if(!p.dispatchEvent){a.state.pasteIncoming=+new Date,u.focus();return}var S=new Event("paste");S.clipboardData=y.clipboardData,p.dispatchEvent(S)}}),H(r.lineSpace,"selectstart",function(y){ji(r,y)||or(y)}),H(p,"compositionstart",function(){var y=a.getCursor("from");u.composing&&u.composing.range.clear(),u.composing={start:y,range:a.markText(y,a.getCursor("to"),{className:"CodeMirror-composing"})}}),H(p,"compositionend",function(){u.composing&&(u.poll(),u.composing.range.clear(),u.composing=null)})},pr.prototype.createField=function(r){this.wrapper=bg(),this.textarea=this.wrapper.firstChild},pr.prototype.screenReaderLabelChanged=function(r){r?this.textarea.setAttribute("aria-label",r):this.textarea.removeAttribute("aria-label")},pr.prototype.prepareSelection=function(){var r=this.cm,i=r.display,u=r.doc,a=ju(r);if(r.options.moveInputWithCursor){var p=Vn(r,u.sel.primary().head,"div"),g=i.wrapper.getBoundingClientRect(),y=i.lineDiv.getBoundingClientRect();a.teTop=Math.max(0,Math.min(i.wrapper.clientHeight-10,p.top+y.top-g.top)),a.teLeft=Math.max(0,Math.min(i.wrapper.clientWidth-10,p.left+y.left-g.left))}return a},pr.prototype.showSelection=function(r){var i=this.cm,u=i.display;tt(u.cursorDiv,r.cursors),tt(u.selectionDiv,r.selection),r.teTop!=null&&(this.wrapper.style.top=r.teTop+"px",this.wrapper.style.left=r.teLeft+"px")},pr.prototype.reset=function(r){if(!(this.contextMenuPending||this.composing)){var i=this.cm;if(i.somethingSelected()){this.prevInput="";var u=i.getSelection();this.textarea.value=u,i.state.focused&&ct(this.textarea),c&&v>=9&&(this.hasSelection=u)}else r||(this.prevInput=this.textarea.value="",c&&v>=9&&(this.hasSelection=null))}},pr.prototype.getField=function(){return this.textarea},pr.prototype.supportsTouch=function(){return!1},pr.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!A||Ge()!=this.textarea))try{this.textarea.focus()}catch(r){}},pr.prototype.blur=function(){this.textarea.blur()},pr.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},pr.prototype.receivedFocus=function(){this.slowPoll()},pr.prototype.slowPoll=function(){var r=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){r.poll(),r.cm.state.focused&&r.slowPoll()})},pr.prototype.fastPoll=function(){var r=!1,i=this;i.pollingFast=!0;function u(){var a=i.poll();!a&&!r?(r=!0,i.polling.set(60,u)):(i.pollingFast=!1,i.slowPoll())}o(u,"p"),i.polling.set(20,u)},pr.prototype.poll=function(){var r=this,i=this.cm,u=this.textarea,a=this.prevInput;if(this.contextMenuPending||!i.state.focused||od(u)&&!a&&!this.composing||i.isReadOnly()||i.options.disableInput||i.state.keySeq)return!1;var p=u.value;if(p==a&&!i.somethingSelected())return!1;if(c&&v>=9&&this.hasSelection===p||I&&/[\uf700-\uf7ff]/.test(p))return i.display.input.reset(),!1;if(i.doc.sel==i.display.selForContextMenu){var g=p.charCodeAt(0);if(g==8203&&!a&&(a="\u200B"),g==8666)return this.reset(),this.cm.execCommand("undo")}for(var y=0,S=Math.min(a.length,p.length);y1e3||p.indexOf(` +`)>-1?u.value=r.prevInput="":r.prevInput=p,r.composing&&(r.composing.range.clear(),r.composing.range=i.markText(r.composing.start,i.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},pr.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},pr.prototype.onKeyPress=function(){c&&v>=9&&(this.hasSelection=null),this.fastPoll()},pr.prototype.onContextMenu=function(r){var i=this,u=i.cm,a=u.display,p=i.textarea;i.contextMenuPending&&i.contextMenuPending();var g=po(u,r),y=a.scroller.scrollTop;if(!g||j)return;var S=u.options.resetSelectionOnContextMenu;S&&u.doc.sel.contains(g)==-1&&lr(u,$r)(u.doc,Os(g),$t);var b=p.style.cssText,_=i.wrapper.style.cssText,M=i.wrapper.offsetParent.getBoundingClientRect();i.wrapper.style.cssText="position: static",p.style.cssText=`position: absolute; width: 30px; height: 30px; top: `+(r.clientY-M.top-5)+"px; left: "+(r.clientX-M.left-5)+`px; z-index: 1000; background: `+(c?"rgba(255, 255, 255, .05)":"transparent")+`; - outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var D;C&&(D=window.scrollY),a.input.focus(),C&&window.scrollTo(null,D),a.input.reset(),u.somethingSelected()||(p.value=i.prevInput=" "),i.contextMenuPending=$,a.selForContextMenu=u.doc.sel,clearTimeout(a.detectingSelectAll);function V(){if(p.selectionStart!=null){var oe=u.somethingSelected(),de="\u200B"+(oe?p.value:"");p.value="\u21DA",p.value=de,i.prevInput=oe?"":"\u200B",p.selectionStart=1,p.selectionEnd=de.length,a.selForContextMenu=u.doc.sel}}o(V,"prepareSelectAllHack");function $(){if(i.contextMenuPending==$&&(i.contextMenuPending=!1,i.wrapper.style.cssText=E,p.style.cssText=b,c&&v<9&&a.scrollbars.setScrollTop(a.scroller.scrollTop=y),p.selectionStart!=null)){(!c||c&&v<9)&&V();var oe=0,de=o(function(){a.selForContextMenu==u.doc.sel&&p.selectionStart==0&&p.selectionEnd>0&&i.prevInput=="\u200B"?lr(u,Zm)(u):oe++<10?a.detectingSelectAll=setTimeout(de,500):(a.selForContextMenu=null,a.input.reset())},"poll");a.detectingSelectAll=setTimeout(de,200)}}if(o($,"rehide"),c&&v>=9&&V(),pe){lo(r);var te=o(function(){he(window,"mouseup",te),setTimeout($,20)},"mouseup");H(window,"mouseup",te)}else setTimeout($,50)},pr.prototype.readOnlyChanged=function(r){r||this.reset(),this.textarea.disabled=r=="nocursor",this.textarea.readOnly=!!r},pr.prototype.setUneditable=function(){},pr.prototype.needsContentAttribute=!1;function Vd(r,i){if(i=i?Zt(i):{},i.value=r.value,!i.tabindex&&r.tabIndex&&(i.tabindex=r.tabIndex),!i.placeholder&&r.placeholder&&(i.placeholder=r.placeholder),i.autofocus==null){var u=Ge();i.autofocus=u==r||r.getAttribute("autofocus")!=null&&u==document.body}function a(){r.value=S.getValue()}o(a,"save");var p;if(r.form&&(H(r.form,"submit",a),!i.leaveSubmitMethodAlone)){var g=r.form;p=g.submit;try{var y=g.submit=function(){a(),g.submit=p,g.submit(),g.submit=y}}catch(b){}}i.finishInit=function(b){b.save=a,b.getTextArea=function(){return r},b.toTextArea=function(){b.toTextArea=isNaN,a(),r.parentNode.removeChild(b.getWrapperElement()),r.style.display="",r.form&&(he(r.form,"submit",a),!i.leaveSubmitMethodAlone&&typeof r.form.submit=="function"&&(r.form.submit=p))}},r.style.display="none";var S=Mt(function(b){return r.parentNode.insertBefore(b,r.nextSibling)},i);return S}o(Vd,"fromTextArea");function _g(r){r.off=he,r.on=H,r.wheelEventPixels=Gy,r.Doc=yn,r.splitLines=rl,r.countColumn=_t,r.findColumn=Pr,r.isWordChar=Jt,r.Pass=zt,r.signal=Te,r.Line=Ce,r.changeEnd=Ms,r.scrollbarModel=gc,r.Pos=ue,r.cmpPos=ze,r.modes=zl,r.mimeModes=ms,r.resolveMode=nl,r.getMode=xu,r.modeExtensions=Wo,r.extendMode=ad,r.copyState=Uo,r.startState=ec,r.innerMode=$l,r.commands=xl,r.keyMap=Jo,r.keyName=Id,r.isModifierKey=Oc,r.lookupKey=es,r.normalizeKeyMap=tw,r.StringStream=jt,r.SharedTextMarker=Ea,r.TextMarker=Rs,r.LineWidget=tf,r.e_preventDefault=or,r.e_stopPropagation=li,r.e_stop=lo,r.addClass=Xe,r.contains=Ke,r.rmClass=xe,r.keyNames=Fs}o(_g,"addLegacyProps"),Fc(Mt),ts(Mt);var xn="iter insert remove copy getEditor constructor".split(" ");for(var Uc in yn.prototype)yn.prototype.hasOwnProperty(Uc)&&ut(xn,Uc)<0&&(Mt.prototype[Uc]=function(r){return function(){return r.apply(this.doc,arguments)}}(yn.prototype[Uc]));return Wr(yn),Mt.inputStyles={textarea:pr,contenteditable:xt},Mt.defineMode=function(r){!Mt.defaults.mode&&r!="null"&&(Mt.defaults.mode=r),ld.apply(this,arguments)},Mt.defineMIME=Jf,Mt.defineMode("null",function(){return{token:function(r){return r.skipToEnd()}}}),Mt.defineMIME("text/plain","null"),Mt.defineExtension=function(r,i){Mt.prototype[r]=i},Mt.defineDocExtension=function(r,i){yn.prototype[r]=i},Mt.fromTextArea=Vd,_g(Mt),Mt.version="5.62.3",Mt})});var pL=Ue((sz,cL)=>{var k3=typeof Element!="undefined",N3=typeof Map=="function",L3=typeof Set=="function",P3=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function sy(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var n,l,d;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(l=n;l--!=0;)if(!sy(e[l],t[l]))return!1;return!0}var h;if(N3&&e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(h=e.entries();!(l=h.next()).done;)if(!t.has(l.value[0]))return!1;for(h=e.entries();!(l=h.next()).done;)if(!sy(l.value[1],t.get(l.value[0])))return!1;return!0}if(L3&&e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(h=e.entries();!(l=h.next()).done;)if(!t.has(l.value[0]))return!1;return!0}if(P3&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(l=n;l--!=0;)if(e[l]!==t[l])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(d=Object.keys(e),n=d.length,n!==Object.keys(t).length)return!1;for(l=n;l--!=0;)if(!Object.prototype.hasOwnProperty.call(t,d[l]))return!1;if(k3&&e instanceof Element)return!1;for(l=n;l--!=0;)if(!((d[l]==="_owner"||d[l]==="__v"||d[l]==="__o")&&e.$$typeof)&&!sy(e[d[l]],t[d[l]]))return!1;return!0}return e!==e&&t!==t}o(sy,"equal");cL.exports=o(function(t,n){try{return sy(t,n)}catch(l){if((l.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw l}},"isEqual")});var _L=Ue((T9,EL)=>{"use strict";var z3="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";EL.exports=z3});var LL=Ue((k9,NL)=>{"use strict";var $3=_L();function TL(){}o(TL,"emptyFunction");function kL(){}o(kL,"emptyFunctionWithReset");kL.resetWarningCache=TL;NL.exports=function(){function e(l,d,h,c,v,C){if(C!==$3){var k=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw k.name="Invariant Violation",k}}o(e,"shim"),e.isRequired=e;function t(){return e}o(t,"getShim");var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:kL,resetWarningCache:TL};return n.PropTypes=n,n}});var Cm=Ue((P9,PL)=>{PL.exports=LL()();var N9,L9});var cC=Ue((O9,OL)=>{OL.exports=o(function(t,n,l,d){var h=l?l.call(d,t,n):void 0;if(h!==void 0)return!!h;if(t===n)return!0;if(typeof t!="object"||!t||typeof n!="object"||!n)return!1;var c=Object.keys(t),v=Object.keys(n);if(c.length!==v.length)return!1;for(var C=Object.prototype.hasOwnProperty.bind(n),k=0;k{WL.exports=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}});var du=Ue(qf=>{var dC,q3=[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];qf.getSymbolSize=o(function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17},"getSymbolSize");qf.getSymbolTotalCodewords=o(function(t){return q3[t]},"getSymbolTotalCodewords");qf.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};qf.setToSJISFunction=o(function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');dC=t},"setToSJISFunction");qf.isKanjiModeEnabled=function(){return typeof dC!="undefined"};qf.toSJIS=o(function(t){return dC(t)},"toSJIS")});var gy=Ue(Do=>{Do.L={bit:1};Do.M={bit:0};Do.Q={bit:3};Do.H={bit:2};function V3(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return Do.L;case"m":case"medium":return Do.M;case"q":case"quartile":return Do.Q;case"h":case"high":return Do.H;default:throw new Error("Unknown EC Level: "+e)}}o(V3,"fromString");Do.isValid=o(function(t){return t&&typeof t.bit!="undefined"&&t.bit>=0&&t.bit<4},"isValid");Do.from=o(function(t,n){if(Do.isValid(t))return t;try{return V3(t)}catch(l){return n}},"from")});var jL=Ue((Q9,$L)=>{function zL(){this.buffer=[],this.length=0}o(zL,"BitBuffer");zL.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-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++}};$L.exports=zL});var VL=Ue((Z9,qL)=>{function Tm(e){if(!e||e<1)throw new 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)}o(Tm,"BitMatrix");Tm.prototype.set=function(e,t,n,l){let d=e*this.size+t;this.data[d]=n,l&&(this.reservedBit[d]=!0)};Tm.prototype.get=function(e,t){return this.data[e*this.size+t]};Tm.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Tm.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};qL.exports=Tm});var KL=Ue(vy=>{var K3=du().getSymbolSize;vy.getRowColCoords=o(function(t){if(t===1)return[];let n=Math.floor(t/7)+2,l=K3(t),d=l===145?26:Math.ceil((l-13)/(2*n-2))*2,h=[l-7];for(let c=1;c{var G3=du().getSymbolSize,GL=7;YL.getPositions=o(function(t){let n=G3(t);return[[0,0],[n-GL,0],[0,n-GL]]},"getPositions")});var QL=Ue(rr=>{rr.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var Vf={N1:3,N2:3,N3:40,N4:10};rr.isValid=o(function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7},"isValid");rr.from=o(function(t){return rr.isValid(t)?parseInt(t,10):void 0},"from");rr.getPenaltyN1=o(function(t){let n=t.size,l=0,d=0,h=0,c=null,v=null;for(let C=0;C=5&&(l+=Vf.N1+(d-5)),c=O,d=1),O=t.get(k,C),O===v?h++:(h>=5&&(l+=Vf.N1+(h-5)),v=O,h=1)}d>=5&&(l+=Vf.N1+(d-5)),h>=5&&(l+=Vf.N1+(h-5))}return l},"getPenaltyN1");rr.getPenaltyN2=o(function(t){let n=t.size,l=0;for(let d=0;d=10&&(d===1488||d===93)&&l++,h=h<<1&2047|t.get(v,c),v>=10&&(h===1488||h===93)&&l++}return l*Vf.N3},"getPenaltyN3");rr.getPenaltyN4=o(function(t){let n=0,l=t.data.length;for(let h=0;h{var hu=gy(),yy=[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],wy=[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];hC.getBlocksCount=o(function(t,n){switch(n){case hu.L:return yy[(t-1)*4+0];case hu.M:return yy[(t-1)*4+1];case hu.Q:return yy[(t-1)*4+2];case hu.H:return yy[(t-1)*4+3];default:return}},"getBlocksCount");hC.getTotalCodewordsCount=o(function(t,n){switch(n){case hu.L:return wy[(t-1)*4+0];case hu.M:return wy[(t-1)*4+1];case hu.Q:return wy[(t-1)*4+2];case hu.H:return wy[(t-1)*4+3];default:return}},"getTotalCodewordsCount")});var ZL=Ue(Sy=>{var km=new Uint8Array(512),xy=new Uint8Array(256);o(function(){let t=1;for(let n=0;n<255;n++)km[n]=t,xy[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)km[n]=km[n-255]},"initTables")();Sy.log=o(function(t){if(t<1)throw new Error("log("+t+")");return xy[t]},"log");Sy.exp=o(function(t){return km[t]},"exp");Sy.mul=o(function(t,n){return t===0||n===0?0:km[xy[t]+xy[n]]},"mul")});var JL=Ue(Nm=>{var gC=ZL();Nm.mul=o(function(t,n){let l=new Uint8Array(t.length+n.length-1);for(let d=0;d=0;){let d=l[0];for(let c=0;c{var eP=JL();function vC(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}o(vC,"ReedSolomonEncoder");vC.prototype.initialize=o(function(t){this.degree=t,this.genPoly=eP.generateECPolynomial(this.degree)},"initialize");vC.prototype.encode=o(function(t){if(!this.genPoly)throw new Error("Encoder not initialized");let n=new Uint8Array(t.length+this.degree);n.set(t);let l=eP.mod(n,this.genPoly),d=this.degree-l.length;if(d>0){let h=new Uint8Array(this.degree);return h.set(l,d),h}return l},"encode");tP.exports=vC});var yC=Ue(nP=>{nP.isValid=o(function(t){return!isNaN(t)&&t>=1&&t<=40},"isValid")});var wC=Ue(Bl=>{var iP="[0-9]+",X3="[A-Z $%*+\\-./:]+",Lm="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Lm=Lm.replace(/u/g,"\\u");var Q3="(?:(?![A-Z0-9 $%*+\\-./:]|"+Lm+`)(?:.|[\r -]))+`;Bl.KANJI=new RegExp(Lm,"g");Bl.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Bl.BYTE=new RegExp(Q3,"g");Bl.NUMERIC=new RegExp(iP,"g");Bl.ALPHANUMERIC=new RegExp(X3,"g");var Z3=new RegExp("^"+Lm+"$"),J3=new RegExp("^"+iP+"$"),eB=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Bl.testKanji=o(function(t){return Z3.test(t)},"testKanji");Bl.testNumeric=o(function(t){return J3.test(t)},"testNumeric");Bl.testAlphanumeric=o(function(t){return eB.test(t)},"testAlphanumeric")});var mu=Ue(Xr=>{var tB=yC(),xC=wC();Xr.NUMERIC={id:"Numeric",bit:1<<0,ccBits:[10,12,14]};Xr.ALPHANUMERIC={id:"Alphanumeric",bit:1<<1,ccBits:[9,11,13]};Xr.BYTE={id:"Byte",bit:1<<2,ccBits:[8,16,16]};Xr.KANJI={id:"Kanji",bit:1<<3,ccBits:[8,10,12]};Xr.MIXED={bit:-1};Xr.getCharCountIndicator=o(function(t,n){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!tB.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?t.ccBits[0]:n<27?t.ccBits[1]:t.ccBits[2]},"getCharCountIndicator");Xr.getBestModeForData=o(function(t){return xC.testNumeric(t)?Xr.NUMERIC:xC.testAlphanumeric(t)?Xr.ALPHANUMERIC:xC.testKanji(t)?Xr.KANJI:Xr.BYTE},"getBestModeForData");Xr.toString=o(function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},"toString");Xr.isValid=o(function(t){return t&&t.bit&&t.ccBits},"isValid");function rB(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return Xr.NUMERIC;case"alphanumeric":return Xr.ALPHANUMERIC;case"kanji":return Xr.KANJI;case"byte":return Xr.BYTE;default:throw new Error("Unknown mode: "+e)}}o(rB,"fromString");Xr.from=o(function(t,n){if(Xr.isValid(t))return t;try{return rB(t)}catch(l){return n}},"from")});var uP=Ue(Kf=>{var Cy=du(),nB=mC(),oP=gy(),gu=mu(),SC=yC(),sP=1<<12|1<<11|1<<10|1<<9|1<<8|1<<5|1<<2|1<<0,lP=Cy.getBCHDigit(sP);function iB(e,t,n){for(let l=1;l<=40;l++)if(t<=Kf.getCapacity(l,n,e))return l}o(iB,"getBestVersionForDataLength");function aP(e,t){return gu.getCharCountIndicator(e,t)+4}o(aP,"getReservedBitsCount");function oB(e,t){let n=0;return e.forEach(function(l){n+=aP(l.mode,t)+l.getBitsLength()}),n}o(oB,"getTotalBitsFromDataArray");function sB(e,t){for(let n=1;n<=40;n++)if(oB(e,n)<=Kf.getCapacity(n,t,gu.MIXED))return n}o(sB,"getBestVersionForMixedData");Kf.from=o(function(t,n){return SC.isValid(t)?parseInt(t,10):n},"from");Kf.getCapacity=o(function(t,n,l){if(!SC.isValid(t))throw new Error("Invalid QR Code version");typeof l=="undefined"&&(l=gu.BYTE);let d=Cy.getSymbolTotalCodewords(t),h=nB.getTotalCodewordsCount(t,n),c=(d-h)*8;if(l===gu.MIXED)return c;let v=c-aP(l,t);switch(l){case gu.NUMERIC:return Math.floor(v/10*3);case gu.ALPHANUMERIC:return Math.floor(v/11*2);case gu.KANJI:return Math.floor(v/13);case gu.BYTE:default:return Math.floor(v/8)}},"getCapacity");Kf.getBestVersionForData=o(function(t,n){let l,d=oP.from(n,oP.M);if(Array.isArray(t)){if(t.length>1)return sB(t,d);if(t.length===0)return 1;l=t[0]}else l=t;return iB(l.mode,l.getLength(),d)},"getBestVersionForData");Kf.getEncodedBits=o(function(t){if(!SC.isValid(t)||t<7)throw new Error("Invalid QR Code version");let n=t<<12;for(;Cy.getBCHDigit(n)-lP>=0;)n^=sP<{var CC=du(),fP=1<<10|1<<8|1<<5|1<<4|1<<2|1<<1|1<<0,lB=1<<14|1<<12|1<<10|1<<4|1<<1,cP=CC.getBCHDigit(fP);pP.getEncodedBits=o(function(t,n){let l=t.bit<<3|n,d=l<<10;for(;CC.getBCHDigit(d)-cP>=0;)d^=fP<{var aB=mu();function Kp(e){this.mode=aB.NUMERIC,this.data=e.toString()}o(Kp,"NumericData");Kp.getBitsLength=o(function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},"getBitsLength");Kp.prototype.getLength=o(function(){return this.data.length},"getLength");Kp.prototype.getBitsLength=o(function(){return Kp.getBitsLength(this.data.length)},"getBitsLength");Kp.prototype.write=o(function(t){let n,l,d;for(n=0;n+3<=this.data.length;n+=3)l=this.data.substr(n,3),d=parseInt(l,10),t.put(d,10);let h=this.data.length-n;h>0&&(l=this.data.substr(n),d=parseInt(l,10),t.put(d,h*3+1))},"write");hP.exports=Kp});var vP=Ue((p$,gP)=>{var uB=mu(),bC=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Gp(e){this.mode=uB.ALPHANUMERIC,this.data=e}o(Gp,"AlphanumericData");Gp.getBitsLength=o(function(t){return 11*Math.floor(t/2)+6*(t%2)},"getBitsLength");Gp.prototype.getLength=o(function(){return this.data.length},"getLength");Gp.prototype.getBitsLength=o(function(){return Gp.getBitsLength(this.data.length)},"getBitsLength");Gp.prototype.write=o(function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let l=bC.indexOf(this.data[n])*45;l+=bC.indexOf(this.data[n+1]),t.put(l,11)}this.data.length%2&&t.put(bC.indexOf(this.data[n]),6)},"write");gP.exports=Gp});var wP=Ue((d$,yP)=>{"use strict";yP.exports=o(function(t){for(var n=[],l=t.length,d=0;d=55296&&h<=56319&&l>d+1){var c=t.charCodeAt(d+1);c>=56320&&c<=57343&&(h=(h-55296)*1024+c-56320+65536,d+=1)}if(h<128){n.push(h);continue}if(h<2048){n.push(h>>6|192),n.push(h&63|128);continue}if(h<55296||h>=57344&&h<65536){n.push(h>>12|224),n.push(h>>6&63|128),n.push(h&63|128);continue}if(h>=65536&&h<=1114111){n.push(h>>18|240),n.push(h>>12&63|128),n.push(h>>6&63|128),n.push(h&63|128);continue}n.push(239,191,189)}return new Uint8Array(n).buffer},"encodeUtf8")});var SP=Ue((h$,xP)=>{var fB=wP(),cB=mu();function Yp(e){this.mode=cB.BYTE,typeof e=="string"&&(e=fB(e)),this.data=new Uint8Array(e)}o(Yp,"ByteData");Yp.getBitsLength=o(function(t){return t*8},"getBitsLength");Yp.prototype.getLength=o(function(){return this.data.length},"getLength");Yp.prototype.getBitsLength=o(function(){return Yp.getBitsLength(this.data.length)},"getBitsLength");Yp.prototype.write=function(e){for(let t=0,n=this.data.length;t{var pB=mu(),dB=du();function Xp(e){this.mode=pB.KANJI,this.data=e}o(Xp,"KanjiData");Xp.getBitsLength=o(function(t){return t*13},"getBitsLength");Xp.prototype.getLength=o(function(){return this.data.length},"getLength");Xp.prototype.getBitsLength=o(function(){return Xp.getBitsLength(this.data.length)},"getBitsLength");Xp.prototype.write=function(e){let t;for(t=0;t=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+` -Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};CP.exports=Xp});var EP=Ue((g$,EC)=>{"use strict";var Pm={single_source_shortest_paths:function(e,t,n){var l={},d={};d[t]=0;var h=Pm.PriorityQueue.make();h.push(t,0);for(var c,v,C,k,O,j,B,X,J;!h.empty();){c=h.pop(),v=c.value,k=c.cost,O=e[v]||{};for(C in O)O.hasOwnProperty(C)&&(j=O[C],B=k+j,X=d[C],J=typeof d[C]=="undefined",(J||X>B)&&(d[C]=B,h.push(C,B),l[C]=v))}if(typeof n!="undefined"&&typeof d[n]=="undefined"){var Z=["Could not find a path from ",t," to ",n,"."].join("");throw new Error(Z)}return l},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],l=t,d;l;)n.push(l),d=e[l],l=e[l];return n.reverse(),n},find_path:function(e,t,n){var l=Pm.single_source_shortest_paths(e,t,n);return Pm.extract_shortest_path_from_predecessor_list(l,n)},PriorityQueue:{make:function(e){var t=Pm.PriorityQueue,n={},l;e=e||{};for(l in t)t.hasOwnProperty(l)&&(n[l]=t[l]);return n.queue=[],n.sorter=e.sorter||t.default_sorter,n},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}}};typeof EC!="undefined"&&(EC.exports=Pm)});var MP=Ue(Qp=>{var It=mu(),_P=mP(),TP=vP(),kP=SP(),NP=bP(),Om=wC(),by=du(),hB=EP();function LP(e){return unescape(encodeURIComponent(e)).length}o(LP,"getStringByteLength");function Mm(e,t,n){let l=[],d;for(;(d=e.exec(n))!==null;)l.push({data:d[0],index:d.index,mode:t,length:d[0].length});return l}o(Mm,"getSegments");function PP(e){let t=Mm(Om.NUMERIC,It.NUMERIC,e),n=Mm(Om.ALPHANUMERIC,It.ALPHANUMERIC,e),l,d;return by.isKanjiModeEnabled()?(l=Mm(Om.BYTE,It.BYTE,e),d=Mm(Om.KANJI,It.KANJI,e)):(l=Mm(Om.BYTE_KANJI,It.BYTE,e),d=[]),t.concat(n,l,d).sort(function(c,v){return c.index-v.index}).map(function(c){return{data:c.data,mode:c.mode,length:c.length}})}o(PP,"getSegmentsFromString");function _C(e,t){switch(t){case It.NUMERIC:return _P.getBitsLength(e);case It.ALPHANUMERIC:return TP.getBitsLength(e);case It.KANJI:return NP.getBitsLength(e);case It.BYTE:return kP.getBitsLength(e)}}o(_C,"getSegmentBitsLength");function mB(e){return e.reduce(function(t,n){let l=t.length-1>=0?t[t.length-1]:null;return l&&l.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}o(mB,"mergeSegments");function gB(e){let t=[];for(let n=0;n{var Ey=du(),TC=gy(),yB=jL(),wB=VL(),xB=KL(),SB=XL(),kC=QL(),NC=mC(),CB=rP(),_y=uP(),bB=dP(),EB=mu(),LC=MP();function _B(e,t){let n=e.size,l=SB.getPositions(t);for(let d=0;d=0&&v<=6&&(C===0||C===6)||C>=0&&C<=6&&(v===0||v===6)||v>=2&&v<=4&&C>=2&&C<=4?e.set(h+v,c+C,!0,!0):e.set(h+v,c+C,!1,!0))}}o(_B,"setupFinderPattern");function TB(e){let t=e.size;for(let n=8;n>v&1)==1,e.set(d,h,c,!0),e.set(h,d,c,!0)}o(NB,"setupVersionInfo");function PC(e,t,n){let l=e.size,d=bB.getEncodedBits(t,n),h,c;for(h=0;h<15;h++)c=(d>>h&1)==1,h<6?e.set(h,8,c,!0):h<8?e.set(h+1,8,c,!0):e.set(l-15+h,8,c,!0),h<8?e.set(8,l-h-1,c,!0):h<9?e.set(8,15-h-1+1,c,!0):e.set(8,15-h-1,c,!0);e.set(l-8,8,1,!0)}o(PC,"setupFormatInfo");function LB(e,t){let n=e.size,l=-1,d=n-1,h=7,c=0;for(let v=n-1;v>0;v-=2)for(v===6&&v--;;){for(let C=0;C<2;C++)if(!e.isReserved(d,v-C)){let k=!1;c>>h&1)==1),e.set(d,v-C,k),h--,h===-1&&(c++,h=7)}if(d+=l,d<0||n<=d){d-=l,l=-l;break}}}o(LB,"setupData");function PB(e,t,n){let l=new yB;n.forEach(function(C){l.put(C.mode.bit,4),l.put(C.getLength(),EB.getCharCountIndicator(C.mode,e)),C.write(l)});let d=Ey.getSymbolTotalCodewords(e),h=NC.getTotalCodewordsCount(e,t),c=(d-h)*8;for(l.getLengthInBits()+4<=c&&l.put(0,4);l.getLengthInBits()%8!=0;)l.putBit(0);let v=(c-l.getLengthInBits())/8;for(let C=0;C0&&i.prevInput=="\u200B"?lr(u,Qm)(u):oe++<10?a.detectingSelectAll=setTimeout(de,500):(a.selForContextMenu=null,a.input.reset())},"poll");a.detectingSelectAll=setTimeout(de,200)}}if(o($,"rehide"),c&&v>=9&&V(),pe){lo(r);var te=o(function(){he(window,"mouseup",te),setTimeout($,20)},"mouseup");H(window,"mouseup",te)}else setTimeout($,50)},pr.prototype.readOnlyChanged=function(r){r||this.reset(),this.textarea.disabled=r=="nocursor",this.textarea.readOnly=!!r},pr.prototype.setUneditable=function(){},pr.prototype.needsContentAttribute=!1;function Vd(r,i){if(i=i?Zt(i):{},i.value=r.value,!i.tabindex&&r.tabIndex&&(i.tabindex=r.tabIndex),!i.placeholder&&r.placeholder&&(i.placeholder=r.placeholder),i.autofocus==null){var u=Ge();i.autofocus=u==r||r.getAttribute("autofocus")!=null&&u==document.body}function a(){r.value=S.getValue()}o(a,"save");var p;if(r.form&&(H(r.form,"submit",a),!i.leaveSubmitMethodAlone)){var g=r.form;p=g.submit;try{var y=g.submit=function(){a(),g.submit=p,g.submit(),g.submit=y}}catch(b){}}i.finishInit=function(b){b.save=a,b.getTextArea=function(){return r},b.toTextArea=function(){b.toTextArea=isNaN,a(),r.parentNode.removeChild(b.getWrapperElement()),r.style.display="",r.form&&(he(r.form,"submit",a),!i.leaveSubmitMethodAlone&&typeof r.form.submit=="function"&&(r.form.submit=p))}},r.style.display="none";var S=Mt(function(b){return r.parentNode.insertBefore(b,r.nextSibling)},i);return S}o(Vd,"fromTextArea");function _g(r){r.off=he,r.on=H,r.wheelEventPixels=Ky,r.Doc=yn,r.splitLines=rl,r.countColumn=Et,r.findColumn=Lr,r.isWordChar=Jt,r.Pass=zt,r.signal=Te,r.Line=Ce,r.changeEnd=Ms,r.scrollbarModel=gc,r.Pos=ue,r.cmpPos=ze,r.modes=zl,r.mimeModes=ms,r.resolveMode=nl,r.getMode=xu,r.modeExtensions=Wo,r.extendMode=ad,r.copyState=Uo,r.startState=ec,r.innerMode=$l,r.commands=xl,r.keyMap=Jo,r.keyName=Id,r.isModifierKey=Oc,r.lookupKey=es,r.normalizeKeyMap=ew,r.StringStream=jt,r.SharedTextMarker=_a,r.TextMarker=Rs,r.LineWidget=tf,r.e_preventDefault=or,r.e_stopPropagation=li,r.e_stop=lo,r.addClass=Xe,r.contains=Ke,r.rmClass=xe,r.keyNames=Fs}o(_g,"addLegacyProps"),Fc(Mt),ts(Mt);var xn="iter insert remove copy getEditor constructor".split(" ");for(var Uc in yn.prototype)yn.prototype.hasOwnProperty(Uc)&&ut(xn,Uc)<0&&(Mt.prototype[Uc]=function(r){return function(){return r.apply(this.doc,arguments)}}(yn.prototype[Uc]));return Wr(yn),Mt.inputStyles={textarea:pr,contenteditable:xt},Mt.defineMode=function(r){!Mt.defaults.mode&&r!="null"&&(Mt.defaults.mode=r),ld.apply(this,arguments)},Mt.defineMIME=Jf,Mt.defineMode("null",function(){return{token:function(r){return r.skipToEnd()}}}),Mt.defineMIME("text/plain","null"),Mt.defineExtension=function(r,i){Mt.prototype[r]=i},Mt.defineDocExtension=function(r,i){yn.prototype[r]=i},Mt.fromTextArea=Vd,_g(Mt),Mt.version="5.62.3",Mt})});var cP=Ue((sz,fP)=>{var k3=typeof Element!="undefined",N3=typeof Map=="function",P3=typeof Set=="function",L3=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function oy(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var n,l,d;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(l=n;l--!=0;)if(!oy(e[l],t[l]))return!1;return!0}var h;if(N3&&e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(h=e.entries();!(l=h.next()).done;)if(!t.has(l.value[0]))return!1;for(h=e.entries();!(l=h.next()).done;)if(!oy(l.value[1],t.get(l.value[0])))return!1;return!0}if(P3&&e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(h=e.entries();!(l=h.next()).done;)if(!t.has(l.value[0]))return!1;return!0}if(L3&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(l=n;l--!=0;)if(e[l]!==t[l])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(d=Object.keys(e),n=d.length,n!==Object.keys(t).length)return!1;for(l=n;l--!=0;)if(!Object.prototype.hasOwnProperty.call(t,d[l]))return!1;if(k3&&e instanceof Element)return!1;for(l=n;l--!=0;)if(!((d[l]==="_owner"||d[l]==="__v"||d[l]==="__o")&&e.$$typeof)&&!oy(e[d[l]],t[d[l]]))return!1;return!0}return e!==e&&t!==t}o(oy,"equal");fP.exports=o(function(t,n){try{return oy(t,n)}catch(l){if((l.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw l}},"isEqual")});var EP=Ue((T9,_P)=>{"use strict";var z3="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";_P.exports=z3});var PP=Ue((k9,NP)=>{"use strict";var $3=EP();function TP(){}o(TP,"emptyFunction");function kP(){}o(kP,"emptyFunctionWithReset");kP.resetWarningCache=TP;NP.exports=function(){function e(l,d,h,c,v,C){if(C!==$3){var k=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw k.name="Invariant Violation",k}}o(e,"shim"),e.isRequired=e;function t(){return e}o(t,"getShim");var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:kP,resetWarningCache:TP};return n.PropTypes=n,n}});var Sm=Ue((L9,LP)=>{LP.exports=PP()();var N9,P9});var fC=Ue((O9,OP)=>{OP.exports=o(function(t,n,l,d){var h=l?l.call(d,t,n):void 0;if(h!==void 0)return!!h;if(t===n)return!0;if(typeof t!="object"||!t||typeof n!="object"||!n)return!1;var c=Object.keys(t),v=Object.keys(n);if(c.length!==v.length)return!1;for(var C=Object.prototype.hasOwnProperty.bind(n),k=0;k{WP.exports=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}});var du=Ue(qf=>{var pC,q3=[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];qf.getSymbolSize=o(function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17},"getSymbolSize");qf.getSymbolTotalCodewords=o(function(t){return q3[t]},"getSymbolTotalCodewords");qf.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};qf.setToSJISFunction=o(function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');pC=t},"setToSJISFunction");qf.isKanjiModeEnabled=function(){return typeof pC!="undefined"};qf.toSJIS=o(function(t){return pC(t)},"toSJIS")});var my=Ue(Do=>{Do.L={bit:1};Do.M={bit:0};Do.Q={bit:3};Do.H={bit:2};function V3(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return Do.L;case"m":case"medium":return Do.M;case"q":case"quartile":return Do.Q;case"h":case"high":return Do.H;default:throw new Error("Unknown EC Level: "+e)}}o(V3,"fromString");Do.isValid=o(function(t){return t&&typeof t.bit!="undefined"&&t.bit>=0&&t.bit<4},"isValid");Do.from=o(function(t,n){if(Do.isValid(t))return t;try{return V3(t)}catch(l){return n}},"from")});var jP=Ue((Q9,$P)=>{function zP(){this.buffer=[],this.length=0}o(zP,"BitBuffer");zP.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-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++}};$P.exports=zP});var VP=Ue((Z9,qP)=>{function Em(e){if(!e||e<1)throw new 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)}o(Em,"BitMatrix");Em.prototype.set=function(e,t,n,l){let d=e*this.size+t;this.data[d]=n,l&&(this.reservedBit[d]=!0)};Em.prototype.get=function(e,t){return this.data[e*this.size+t]};Em.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Em.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};qP.exports=Em});var KP=Ue(gy=>{var K3=du().getSymbolSize;gy.getRowColCoords=o(function(t){if(t===1)return[];let n=Math.floor(t/7)+2,l=K3(t),d=l===145?26:Math.ceil((l-13)/(2*n-2))*2,h=[l-7];for(let c=1;c{var G3=du().getSymbolSize,GP=7;YP.getPositions=o(function(t){let n=G3(t);return[[0,0],[n-GP,0],[0,n-GP]]},"getPositions")});var QP=Ue(rr=>{rr.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var Vf={N1:3,N2:3,N3:40,N4:10};rr.isValid=o(function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7},"isValid");rr.from=o(function(t){return rr.isValid(t)?parseInt(t,10):void 0},"from");rr.getPenaltyN1=o(function(t){let n=t.size,l=0,d=0,h=0,c=null,v=null;for(let C=0;C=5&&(l+=Vf.N1+(d-5)),c=O,d=1),O=t.get(k,C),O===v?h++:(h>=5&&(l+=Vf.N1+(h-5)),v=O,h=1)}d>=5&&(l+=Vf.N1+(d-5)),h>=5&&(l+=Vf.N1+(h-5))}return l},"getPenaltyN1");rr.getPenaltyN2=o(function(t){let n=t.size,l=0;for(let d=0;d=10&&(d===1488||d===93)&&l++,h=h<<1&2047|t.get(v,c),v>=10&&(h===1488||h===93)&&l++}return l*Vf.N3},"getPenaltyN3");rr.getPenaltyN4=o(function(t){let n=0,l=t.data.length;for(let h=0;h{var hu=my(),vy=[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],yy=[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];dC.getBlocksCount=o(function(t,n){switch(n){case hu.L:return vy[(t-1)*4+0];case hu.M:return vy[(t-1)*4+1];case hu.Q:return vy[(t-1)*4+2];case hu.H:return vy[(t-1)*4+3];default:return}},"getBlocksCount");dC.getTotalCodewordsCount=o(function(t,n){switch(n){case hu.L:return yy[(t-1)*4+0];case hu.M:return yy[(t-1)*4+1];case hu.Q:return yy[(t-1)*4+2];case hu.H:return yy[(t-1)*4+3];default:return}},"getTotalCodewordsCount")});var ZP=Ue(xy=>{var Tm=new Uint8Array(512),wy=new Uint8Array(256);o(function(){let t=1;for(let n=0;n<255;n++)Tm[n]=t,wy[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Tm[n]=Tm[n-255]},"initTables")();xy.log=o(function(t){if(t<1)throw new Error("log("+t+")");return wy[t]},"log");xy.exp=o(function(t){return Tm[t]},"exp");xy.mul=o(function(t,n){return t===0||n===0?0:Tm[wy[t]+wy[n]]},"mul")});var JP=Ue(km=>{var mC=ZP();km.mul=o(function(t,n){let l=new Uint8Array(t.length+n.length-1);for(let d=0;d=0;){let d=l[0];for(let c=0;c{var eL=JP();function gC(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}o(gC,"ReedSolomonEncoder");gC.prototype.initialize=o(function(t){this.degree=t,this.genPoly=eL.generateECPolynomial(this.degree)},"initialize");gC.prototype.encode=o(function(t){if(!this.genPoly)throw new Error("Encoder not initialized");let n=new Uint8Array(t.length+this.degree);n.set(t);let l=eL.mod(n,this.genPoly),d=this.degree-l.length;if(d>0){let h=new Uint8Array(this.degree);return h.set(l,d),h}return l},"encode");tL.exports=gC});var vC=Ue(nL=>{nL.isValid=o(function(t){return!isNaN(t)&&t>=1&&t<=40},"isValid")});var yC=Ue(Bl=>{var iL="[0-9]+",X3="[A-Z $%*+\\-./:]+",Nm="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Nm=Nm.replace(/u/g,"\\u");var Q3="(?:(?![A-Z0-9 $%*+\\-./:]|"+Nm+`)(?:.|[\r +]))+`;Bl.KANJI=new RegExp(Nm,"g");Bl.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Bl.BYTE=new RegExp(Q3,"g");Bl.NUMERIC=new RegExp(iL,"g");Bl.ALPHANUMERIC=new RegExp(X3,"g");var Z3=new RegExp("^"+Nm+"$"),J3=new RegExp("^"+iL+"$"),eB=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Bl.testKanji=o(function(t){return Z3.test(t)},"testKanji");Bl.testNumeric=o(function(t){return J3.test(t)},"testNumeric");Bl.testAlphanumeric=o(function(t){return eB.test(t)},"testAlphanumeric")});var mu=Ue(Xr=>{var tB=vC(),wC=yC();Xr.NUMERIC={id:"Numeric",bit:1<<0,ccBits:[10,12,14]};Xr.ALPHANUMERIC={id:"Alphanumeric",bit:1<<1,ccBits:[9,11,13]};Xr.BYTE={id:"Byte",bit:1<<2,ccBits:[8,16,16]};Xr.KANJI={id:"Kanji",bit:1<<3,ccBits:[8,10,12]};Xr.MIXED={bit:-1};Xr.getCharCountIndicator=o(function(t,n){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!tB.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?t.ccBits[0]:n<27?t.ccBits[1]:t.ccBits[2]},"getCharCountIndicator");Xr.getBestModeForData=o(function(t){return wC.testNumeric(t)?Xr.NUMERIC:wC.testAlphanumeric(t)?Xr.ALPHANUMERIC:wC.testKanji(t)?Xr.KANJI:Xr.BYTE},"getBestModeForData");Xr.toString=o(function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},"toString");Xr.isValid=o(function(t){return t&&t.bit&&t.ccBits},"isValid");function rB(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return Xr.NUMERIC;case"alphanumeric":return Xr.ALPHANUMERIC;case"kanji":return Xr.KANJI;case"byte":return Xr.BYTE;default:throw new Error("Unknown mode: "+e)}}o(rB,"fromString");Xr.from=o(function(t,n){if(Xr.isValid(t))return t;try{return rB(t)}catch(l){return n}},"from")});var uL=Ue(Kf=>{var Sy=du(),nB=hC(),oL=my(),gu=mu(),xC=vC(),sL=1<<12|1<<11|1<<10|1<<9|1<<8|1<<5|1<<2|1<<0,lL=Sy.getBCHDigit(sL);function iB(e,t,n){for(let l=1;l<=40;l++)if(t<=Kf.getCapacity(l,n,e))return l}o(iB,"getBestVersionForDataLength");function aL(e,t){return gu.getCharCountIndicator(e,t)+4}o(aL,"getReservedBitsCount");function oB(e,t){let n=0;return e.forEach(function(l){n+=aL(l.mode,t)+l.getBitsLength()}),n}o(oB,"getTotalBitsFromDataArray");function sB(e,t){for(let n=1;n<=40;n++)if(oB(e,n)<=Kf.getCapacity(n,t,gu.MIXED))return n}o(sB,"getBestVersionForMixedData");Kf.from=o(function(t,n){return xC.isValid(t)?parseInt(t,10):n},"from");Kf.getCapacity=o(function(t,n,l){if(!xC.isValid(t))throw new Error("Invalid QR Code version");typeof l=="undefined"&&(l=gu.BYTE);let d=Sy.getSymbolTotalCodewords(t),h=nB.getTotalCodewordsCount(t,n),c=(d-h)*8;if(l===gu.MIXED)return c;let v=c-aL(l,t);switch(l){case gu.NUMERIC:return Math.floor(v/10*3);case gu.ALPHANUMERIC:return Math.floor(v/11*2);case gu.KANJI:return Math.floor(v/13);case gu.BYTE:default:return Math.floor(v/8)}},"getCapacity");Kf.getBestVersionForData=o(function(t,n){let l,d=oL.from(n,oL.M);if(Array.isArray(t)){if(t.length>1)return sB(t,d);if(t.length===0)return 1;l=t[0]}else l=t;return iB(l.mode,l.getLength(),d)},"getBestVersionForData");Kf.getEncodedBits=o(function(t){if(!xC.isValid(t)||t<7)throw new Error("Invalid QR Code version");let n=t<<12;for(;Sy.getBCHDigit(n)-lL>=0;)n^=sL<{var SC=du(),fL=1<<10|1<<8|1<<5|1<<4|1<<2|1<<1|1<<0,lB=1<<14|1<<12|1<<10|1<<4|1<<1,cL=SC.getBCHDigit(fL);pL.getEncodedBits=o(function(t,n){let l=t.bit<<3|n,d=l<<10;for(;SC.getBCHDigit(d)-cL>=0;)d^=fL<{var aB=mu();function Kp(e){this.mode=aB.NUMERIC,this.data=e.toString()}o(Kp,"NumericData");Kp.getBitsLength=o(function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},"getBitsLength");Kp.prototype.getLength=o(function(){return this.data.length},"getLength");Kp.prototype.getBitsLength=o(function(){return Kp.getBitsLength(this.data.length)},"getBitsLength");Kp.prototype.write=o(function(t){let n,l,d;for(n=0;n+3<=this.data.length;n+=3)l=this.data.substr(n,3),d=parseInt(l,10),t.put(d,10);let h=this.data.length-n;h>0&&(l=this.data.substr(n),d=parseInt(l,10),t.put(d,h*3+1))},"write");hL.exports=Kp});var vL=Ue((p$,gL)=>{var uB=mu(),CC=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Gp(e){this.mode=uB.ALPHANUMERIC,this.data=e}o(Gp,"AlphanumericData");Gp.getBitsLength=o(function(t){return 11*Math.floor(t/2)+6*(t%2)},"getBitsLength");Gp.prototype.getLength=o(function(){return this.data.length},"getLength");Gp.prototype.getBitsLength=o(function(){return Gp.getBitsLength(this.data.length)},"getBitsLength");Gp.prototype.write=o(function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let l=CC.indexOf(this.data[n])*45;l+=CC.indexOf(this.data[n+1]),t.put(l,11)}this.data.length%2&&t.put(CC.indexOf(this.data[n]),6)},"write");gL.exports=Gp});var wL=Ue((d$,yL)=>{"use strict";yL.exports=o(function(t){for(var n=[],l=t.length,d=0;d=55296&&h<=56319&&l>d+1){var c=t.charCodeAt(d+1);c>=56320&&c<=57343&&(h=(h-55296)*1024+c-56320+65536,d+=1)}if(h<128){n.push(h);continue}if(h<2048){n.push(h>>6|192),n.push(h&63|128);continue}if(h<55296||h>=57344&&h<65536){n.push(h>>12|224),n.push(h>>6&63|128),n.push(h&63|128);continue}if(h>=65536&&h<=1114111){n.push(h>>18|240),n.push(h>>12&63|128),n.push(h>>6&63|128),n.push(h&63|128);continue}n.push(239,191,189)}return new Uint8Array(n).buffer},"encodeUtf8")});var SL=Ue((h$,xL)=>{var fB=wL(),cB=mu();function Yp(e){this.mode=cB.BYTE,typeof e=="string"&&(e=fB(e)),this.data=new Uint8Array(e)}o(Yp,"ByteData");Yp.getBitsLength=o(function(t){return t*8},"getBitsLength");Yp.prototype.getLength=o(function(){return this.data.length},"getLength");Yp.prototype.getBitsLength=o(function(){return Yp.getBitsLength(this.data.length)},"getBitsLength");Yp.prototype.write=function(e){for(let t=0,n=this.data.length;t{var pB=mu(),dB=du();function Xp(e){this.mode=pB.KANJI,this.data=e}o(Xp,"KanjiData");Xp.getBitsLength=o(function(t){return t*13},"getBitsLength");Xp.prototype.getLength=o(function(){return this.data.length},"getLength");Xp.prototype.getBitsLength=o(function(){return Xp.getBitsLength(this.data.length)},"getBitsLength");Xp.prototype.write=function(e){let t;for(t=0;t=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+` +Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};CL.exports=Xp});var _L=Ue((g$,bC)=>{"use strict";var Pm={single_source_shortest_paths:function(e,t,n){var l={},d={};d[t]=0;var h=Pm.PriorityQueue.make();h.push(t,0);for(var c,v,C,k,O,j,B,X,J;!h.empty();){c=h.pop(),v=c.value,k=c.cost,O=e[v]||{};for(C in O)O.hasOwnProperty(C)&&(j=O[C],B=k+j,X=d[C],J=typeof d[C]=="undefined",(J||X>B)&&(d[C]=B,h.push(C,B),l[C]=v))}if(typeof n!="undefined"&&typeof d[n]=="undefined"){var Z=["Could not find a path from ",t," to ",n,"."].join("");throw new Error(Z)}return l},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],l=t,d;l;)n.push(l),d=e[l],l=e[l];return n.reverse(),n},find_path:function(e,t,n){var l=Pm.single_source_shortest_paths(e,t,n);return Pm.extract_shortest_path_from_predecessor_list(l,n)},PriorityQueue:{make:function(e){var t=Pm.PriorityQueue,n={},l;e=e||{};for(l in t)t.hasOwnProperty(l)&&(n[l]=t[l]);return n.queue=[],n.sorter=e.sorter||t.default_sorter,n},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}}};typeof bC!="undefined"&&(bC.exports=Pm)});var ML=Ue(Qp=>{var It=mu(),EL=mL(),TL=vL(),kL=SL(),NL=bL(),Lm=yC(),Cy=du(),hB=_L();function PL(e){return unescape(encodeURIComponent(e)).length}o(PL,"getStringByteLength");function Om(e,t,n){let l=[],d;for(;(d=e.exec(n))!==null;)l.push({data:d[0],index:d.index,mode:t,length:d[0].length});return l}o(Om,"getSegments");function LL(e){let t=Om(Lm.NUMERIC,It.NUMERIC,e),n=Om(Lm.ALPHANUMERIC,It.ALPHANUMERIC,e),l,d;return Cy.isKanjiModeEnabled()?(l=Om(Lm.BYTE,It.BYTE,e),d=Om(Lm.KANJI,It.KANJI,e)):(l=Om(Lm.BYTE_KANJI,It.BYTE,e),d=[]),t.concat(n,l,d).sort(function(c,v){return c.index-v.index}).map(function(c){return{data:c.data,mode:c.mode,length:c.length}})}o(LL,"getSegmentsFromString");function _C(e,t){switch(t){case It.NUMERIC:return EL.getBitsLength(e);case It.ALPHANUMERIC:return TL.getBitsLength(e);case It.KANJI:return NL.getBitsLength(e);case It.BYTE:return kL.getBitsLength(e)}}o(_C,"getSegmentBitsLength");function mB(e){return e.reduce(function(t,n){let l=t.length-1>=0?t[t.length-1]:null;return l&&l.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}o(mB,"mergeSegments");function gB(e){let t=[];for(let n=0;n{var by=du(),EC=my(),yB=jP(),wB=VP(),xB=KP(),SB=XP(),TC=QP(),kC=hC(),CB=rL(),_y=uL(),bB=dL(),_B=mu(),NC=ML();function EB(e,t){let n=e.size,l=SB.getPositions(t);for(let d=0;d=0&&v<=6&&(C===0||C===6)||C>=0&&C<=6&&(v===0||v===6)||v>=2&&v<=4&&C>=2&&C<=4?e.set(h+v,c+C,!0,!0):e.set(h+v,c+C,!1,!0))}}o(EB,"setupFinderPattern");function TB(e){let t=e.size;for(let n=8;n>v&1)==1,e.set(d,h,c,!0),e.set(h,d,c,!0)}o(NB,"setupVersionInfo");function PC(e,t,n){let l=e.size,d=bB.getEncodedBits(t,n),h,c;for(h=0;h<15;h++)c=(d>>h&1)==1,h<6?e.set(h,8,c,!0):h<8?e.set(h+1,8,c,!0):e.set(l-15+h,8,c,!0),h<8?e.set(8,l-h-1,c,!0):h<9?e.set(8,15-h-1+1,c,!0):e.set(8,15-h-1,c,!0);e.set(l-8,8,1,!0)}o(PC,"setupFormatInfo");function PB(e,t){let n=e.size,l=-1,d=n-1,h=7,c=0;for(let v=n-1;v>0;v-=2)for(v===6&&v--;;){for(let C=0;C<2;C++)if(!e.isReserved(d,v-C)){let k=!1;c>>h&1)==1),e.set(d,v-C,k),h--,h===-1&&(c++,h=7)}if(d+=l,d<0||n<=d){d-=l,l=-l;break}}}o(PB,"setupData");function LB(e,t,n){let l=new yB;n.forEach(function(C){l.put(C.mode.bit,4),l.put(C.getLength(),_B.getCharCountIndicator(C.mode,e)),C.write(l)});let d=by.getSymbolTotalCodewords(e),h=kC.getTotalCodewordsCount(e,t),c=(d-h)*8;for(l.getLengthInBits()+4<=c&&l.put(0,4);l.getLengthInBits()%8!=0;)l.putBit(0);let v=(c-l.getLengthInBits())/8;for(let C=0;C=7&&NB(C,t),LB(C,c),isNaN(l)&&(l=kC.getBestMask(C,PC.bind(null,C,n))),kC.applyMask(l,C),PC(C,n,l),{modules:C,version:t,errorCorrectionLevel:n,maskPattern:l,segments:d}}o(MB,"createSymbol");AP.create=o(function(t,n){if(typeof t=="undefined"||t==="")throw new Error("No input text");let l=TC.M,d,h;return typeof n!="undefined"&&(l=TC.from(n.errorCorrectionLevel,TC.M),d=_y.from(n.version),h=kC.from(n.maskPattern),n.toSJISFunc&&Ey.setToSJISFunction(n.toSJISFunc)),MB(t,d,l,h)},"create")});var OC=Ue(Gf=>{function RP(e){if(typeof e=="number"&&(e=e.toString()),typeof e!="string")throw new 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 new Error("Invalid hex color: "+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(l){return[l,l]}))),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("")}}o(RP,"hex2rgba");Gf.getOptions=o(function(t){t||(t={}),t.color||(t.color={});let n=typeof t.margin=="undefined"||t.margin===null||t.margin<0?4:t.margin,l=t.width&&t.width>=21?t.width:void 0,d=t.scale||4;return{width:l,scale:l?4:d,margin:n,color:{dark:RP(t.color.dark||"#000000ff"),light:RP(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},"getOptions");Gf.getScale=o(function(t,n){return n.width&&n.width>=t+n.margin*2?n.width/(t+n.margin*2):n.scale},"getScale");Gf.getImageWidth=o(function(t,n){let l=Gf.getScale(t,n);return Math.floor((t+n.margin*2)*l)},"getImageWidth");Gf.qrToImageData=o(function(t,n,l){let d=n.modules.size,h=n.modules.data,c=Gf.getScale(d,l),v=Math.floor((d+l.margin*2)*c),C=l.margin*c,k=[l.color.light,l.color.dark];for(let O=0;O=C&&j>=C&&O{var MC=OC();function AB(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=n,t.width=n,t.style.height=n+"px",t.style.width=n+"px"}o(AB,"clearCanvas");function DB(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}o(DB,"getCanvasElement");Ty.render=o(function(t,n,l){let d=l,h=n;typeof d=="undefined"&&(!n||!n.getContext)&&(d=n,n=void 0),n||(h=DB()),d=MC.getOptions(d);let c=MC.getImageWidth(t.modules.size,d),v=h.getContext("2d"),C=v.createImageData(c,c);return MC.qrToImageData(C.data,t,d),AB(v,h,c),v.putImageData(C,0,0),h},"render");Ty.renderToDataURL=o(function(t,n,l){let d=l;typeof d=="undefined"&&(!n||!n.getContext)&&(d=n,n=void 0),d||(d={});let h=Ty.render(t,n,d),c=d.type||"image/png",v=d.rendererOpts||{};return h.toDataURL(c,v.quality)},"renderToDataURL")});var HP=Ue(BP=>{var RB=OC();function FP(e,t){let n=e.a/255,l=t+'="'+e.hex+'"';return n<1?l+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':l}o(FP,"getColorAttrib");function AC(e,t,n){let l=e+t;return typeof n!="undefined"&&(l+=" "+n),l}o(AC,"svgCmd");function IB(e,t,n){let l="",d=0,h=!1,c=0;for(let v=0;v0&&C>0&&e[v-1]||(l+=h?AC("M",C+n,.5+k+n):AC("m",d,0),d=0,h=!1),C+1':"",k="',O='viewBox="0 0 '+v+" "+v+'"',j=d.width?'width="'+d.width+'" height="'+d.width+'" ':"",B=''+C+k+` -`;return typeof l=="function"&&l(null,B),B},"render")});var UP=Ue(Am=>{var FB=UL(),DC=DP(),WP=IP(),BB=HP();function RC(e,t,n,l,d){let h=[].slice.call(arguments,1),c=h.length,v=typeof h[c-1]=="function";if(!v&&!FB())throw new Error("Callback required as last argument");if(v){if(c<2)throw new Error("Too few arguments provided");c===2?(d=n,n=t,t=l=void 0):c===3&&(t.getContext&&typeof d=="undefined"?(d=l,l=void 0):(d=l,l=n,n=t,t=void 0))}else{if(c<1)throw new Error("Too few arguments provided");return c===1?(n=t,t=l=void 0):c===2&&!t.getContext&&(l=n,n=t,t=void 0),new Promise(function(C,k){try{let O=DC.create(n,l);C(e(O,t,l))}catch(O){k(O)}})}try{let C=DC.create(n,l);d(null,e(C,t,l))}catch(C){d(C)}}o(RC,"renderCanvas");Am.create=DC.create;Am.toCanvas=RC.bind(null,WP.render);Am.toDataURL=RC.bind(null,WP.renderToDataURL);Am.toString=RC.bind(null,function(e,t,n){return BB.render(e,n)})});var ib=fe(Oe()),uO=fe(iu());var Gh=fe(Oe()),NH=fe(uk());var fk=fe(Oe()),ei=fk.default.createContext(null);function _I(e){e()}o(_I,"defaultNoopBatch");var ck=_I,pk=o(function(t){return ck=t},"setBatch"),dk=o(function(){return ck},"getBatch");var hk={notify:o(function(){},"notify")};function TI(){var e=dk(),t=null,n=null;return{clear:o(function(){t=null,n=null},"clear"),notify:o(function(){e(function(){for(var d=t;d;)d.callback(),d=d.next})},"notify"),get:o(function(){for(var d=[],h=t;h;)d.push(h),h=h.next;return d},"get"),subscribe:o(function(d){var h=!0,c=n={callback:d,next:null,prev:n};return c.prev?c.prev.next=c:t=c,o(function(){!h||t===null||(h=!1,c.next?c.next.prev=c.prev:n=c.prev,c.prev?c.prev.next=c.next:t=c.next)},"unsubscribe")},"subscribe")}}o(TI,"createListenerCollection");var Tp=function(){function e(n,l){this.store=n,this.parentSub=l,this.unsubscribe=null,this.listeners=hk,this.handleChangeWrapper=this.handleChangeWrapper.bind(this)}o(e,"Subscription");var t=e.prototype;return t.addNestedSub=o(function(l){return this.trySubscribe(),this.listeners.subscribe(l)},"addNestedSub"),t.notifyNestedSubs=o(function(){this.listeners.notify()},"notifyNestedSubs"),t.handleChangeWrapper=o(function(){this.onStateChange&&this.onStateChange()},"handleChangeWrapper"),t.isSubscribed=o(function(){return Boolean(this.unsubscribe)},"isSubscribed"),t.trySubscribe=o(function(){this.unsubscribe||(this.unsubscribe=this.parentSub?this.parentSub.addNestedSub(this.handleChangeWrapper):this.store.subscribe(this.handleChangeWrapper),this.listeners=TI())},"trySubscribe"),t.tryUnsubscribe=o(function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null,this.listeners.clear(),this.listeners=hk)},"tryUnsubscribe"),e}();var Yv=fe(Oe()),Nf=typeof window!="undefined"&&typeof window.document!="undefined"&&typeof window.document.createElement!="undefined"?Yv.useLayoutEffect:Yv.useEffect;function kI(e){var t=e.store,n=e.context,l=e.children,d=(0,Gh.useMemo)(function(){var v=new Tp(t);return v.onStateChange=v.notifyNestedSubs,{store:t,subscription:v}},[t]),h=(0,Gh.useMemo)(function(){return t.getState()},[t]);Nf(function(){var v=d.subscription;return v.trySubscribe(),h!==t.getState()&&v.notifyNestedSubs(),function(){v.tryUnsubscribe(),v.onStateChange=null}},[d,h]);var c=n||ei;return Gh.default.createElement(c.Provider,{value:d},l)}o(kI,"Provider");var Wx=kI;function Po(){return Po=Object.assign||function(e){for(var t=1;t=0)&&(n[d]=e[d]);return n}o(ou,"_objectWithoutPropertiesLoose");var Yx=fe(_k()),cr=fe(Oe()),Pk=fe(Lk());var qI=[],VI=[null,null];function KI(e,t){var n=e[1];return[t.payload,n+1]}o(KI,"storeStateUpdatesReducer");function Ok(e,t,n){Nf(function(){return e.apply(void 0,t)},n)}o(Ok,"useIsomorphicLayoutEffectWithArgs");function GI(e,t,n,l,d,h,c){e.current=l,t.current=d,n.current=!1,h.current&&(h.current=null,c())}o(GI,"captureWrapperProps");function YI(e,t,n,l,d,h,c,v,C,k){if(!!e){var O=!1,j=null,B=o(function(){if(!O){var Z=t.getState(),R,A;try{R=l(Z,d.current)}catch(I){A=I,j=I}A||(j=null),R===h.current?c.current||C():(h.current=R,v.current=R,c.current=!0,k({type:"STORE_UPDATED",payload:{error:A}}))}},"checkForUpdates");n.onStateChange=B,n.trySubscribe(),B();var X=o(function(){if(O=!0,n.tryUnsubscribe(),n.onStateChange=null,j)throw j},"unsubscribeWrapper");return X}}o(YI,"subscribeUpdates");var XI=o(function(){return[null,0]},"initStateUpdates");function g0(e,t){t===void 0&&(t={});var n=t,l=n.getDisplayName,d=l===void 0?function(ne){return"ConnectAdvanced("+ne+")"}:l,h=n.methodName,c=h===void 0?"connectAdvanced":h,v=n.renderCountProp,C=v===void 0?void 0:v,k=n.shouldHandleStateChanges,O=k===void 0?!0:k,j=n.storeKey,B=j===void 0?"store":j,X=n.withRef,J=X===void 0?!1:X,Z=n.forwardRef,R=Z===void 0?!1:Z,A=n.context,I=A===void 0?ei:A,G=ou(n,["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef","forwardRef","context"]);if(!1)var K;var se=I;return o(function(pe){var me=pe.displayName||pe.name||"Component",xe=d(me),Ve=Po({},G,{getDisplayName:d,methodName:c,renderCountProp:C,shouldHandleStateChanges:O,storeKey:B,displayName:xe,wrappedComponentName:me,WrappedComponent:pe}),tt=G.pure;function _e(Xe){return e(Xe.dispatch,Ve)}o(_e,"createChildSelector");var St=tt?cr.useMemo:function(Xe){return Xe()};function We(Xe){var nr=(0,cr.useMemo)(function(){var Cr=Xe.reactReduxForwardedRef,Ui=ou(Xe,["reactReduxForwardedRef"]);return[Xe.context,Cr,Ui]},[Xe]),ct=nr[0],Hr=nr[1],Zt=nr[2],_t=(0,cr.useMemo)(function(){return ct&&ct.Consumer&&(0,Pk.isContextConsumer)(cr.default.createElement(ct.Consumer,null))?ct:se},[ct,se]),Ct=(0,cr.useContext)(_t),ut=Boolean(Xe.store)&&Boolean(Xe.store.getState)&&Boolean(Xe.store.dispatch),Lr=Boolean(Ct)&&Boolean(Ct.store),zt=ut?Xe.store:Ct.store,$t=(0,cr.useMemo)(function(){return _e(zt)},[zt]),ie=(0,cr.useMemo)(function(){if(!O)return VI;var Cr=new Tp(zt,ut?null:Ct.subscription),Ui=Cr.notifyNestedSubs.bind(Cr);return[Cr,Ui]},[zt,ut,Ct]),rt=ie[0],Pr=ie[1],Gt=(0,cr.useMemo)(function(){return ut?Ct:Po({},Ct,{subscription:rt})},[ut,Ct,rt]),Yt=(0,cr.useReducer)(KI,qI,XI),Se=Yt[0],Or=Se[0],fn=Yt[1];if(Or&&Or.error)throw Or.error;var Un=(0,cr.useRef)(),si=(0,cr.useRef)(Zt),cn=(0,cr.useRef)(),Jt=(0,cr.useRef)(!1),gr=St(function(){return cn.current&&Zt===si.current?cn.current:$t(zt.getState(),Zt)},[zt,Or,Zt]);Ok(GI,[si,Un,Jt,Zt,gr,cn,Pr]),Ok(YI,[O,zt,rt,$t,si,Un,Jt,cn,Pr,fn],[zt,rt,$t]);var pt=(0,cr.useMemo)(function(){return cr.default.createElement(pe,Po({},gr,{ref:Hr}))},[Hr,pe,gr]),Ho=(0,cr.useMemo)(function(){return O?cr.default.createElement(_t.Provider,{value:Gt},pt):pt},[_t,pt,Gt]);return Ho}o(We,"ConnectFunction");var Ke=tt?cr.default.memo(We):We;if(Ke.WrappedComponent=pe,Ke.displayName=We.displayName=xe,R){var Ge=cr.default.forwardRef(o(function(nr,ct){return cr.default.createElement(Ke,Po({},nr,{reactReduxForwardedRef:ct}))},"forwardConnectRef"));return Ge.displayName=xe,Ge.WrappedComponent=pe,(0,Yx.default)(Ge,pe)}return(0,Yx.default)(Ke,pe)},"wrapWithConnect")}o(g0,"connectAdvanced");function Mk(e,t){return e===t?e!==0||t!==0||1/e==1/t:e!==e&&t!==t}o(Mk,"is");function kp(e,t){if(Mk(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),l=Object.keys(t);if(n.length!==l.length)return!1;for(var d=0;d=0;l--){var d=t[l](e);if(d)return d}return function(h,c){throw new Error("Invalid value of type "+typeof e+" for "+n+" argument when connecting component "+c.wrappedComponentName+".")}}o(Zx,"match");function uF(e,t){return e===t}o(uF,"strictEqual");function fF(e){var t=e===void 0?{}:e,n=t.connectHOC,l=n===void 0?g0:n,d=t.mapStateToPropsFactories,h=d===void 0?Rk:d,c=t.mapDispatchToPropsFactories,v=c===void 0?Dk:c,C=t.mergePropsFactories,k=C===void 0?Ik:C,O=t.selectorFactory,j=O===void 0?Qx:O;return o(function(X,J,Z,R){R===void 0&&(R={});var A=R,I=A.pure,G=I===void 0?!0:I,K=A.areStatesEqual,se=K===void 0?uF:K,ne=A.areOwnPropsEqual,pe=ne===void 0?kp:ne,me=A.areStatePropsEqual,xe=me===void 0?kp:me,Ve=A.areMergedPropsEqual,tt=Ve===void 0?kp:Ve,_e=ou(A,["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"]),St=Zx(X,h,"mapStateToProps"),We=Zx(J,v,"mapDispatchToProps"),Ke=Zx(Z,k,"mergeProps");return l(j,Po({methodName:"connect",getDisplayName:o(function(Xe){return"Connect("+Xe+")"},"getDisplayName"),shouldHandleStateChanges:Boolean(X),initMapStateToProps:St,initMapDispatchToProps:We,initMergeProps:Ke,pure:G,areStatesEqual:se,areOwnPropsEqual:pe,areStatePropsEqual:xe,areMergedPropsEqual:tt},_e))},"connect")}o(fF,"createConnect");var Hi=fF();var Bk=fe(Oe());var Fk=fe(Oe());function y0(){var e=(0,Fk.useContext)(ei);return e}o(y0,"useReduxContext");function w0(e){e===void 0&&(e=ei);var t=e===ei?y0:function(){return(0,Bk.useContext)(e)};return o(function(){var l=t(),d=l.store;return d},"useStore")}o(w0,"createStoreHook");var Jx=w0();function Hk(e){e===void 0&&(e=ei);var t=e===ei?Jx:w0(e);return o(function(){var l=t();return l.dispatch},"useDispatch")}o(Hk,"createDispatchHook");var Gs=Hk();var ro=fe(Oe());var cF=o(function(t,n){return t===n},"refEquality");function pF(e,t,n,l){var d=(0,ro.useReducer)(function(J){return J+1},0),h=d[1],c=(0,ro.useMemo)(function(){return new Tp(n,l)},[n,l]),v=(0,ro.useRef)(),C=(0,ro.useRef)(),k=(0,ro.useRef)(),O=(0,ro.useRef)(),j=n.getState(),B;try{if(e!==C.current||j!==k.current||v.current){var X=e(j);O.current===void 0||!t(X,O.current)?B=X:B=O.current}else B=O.current}catch(J){throw v.current&&(J.message+=` +`);let c=LB(t,n,d),v=by.getSymbolSize(t),C=new wB(v);return EB(C,t),TB(C),kB(C,t),PC(C,n,0),t>=7&&NB(C,t),PB(C,c),isNaN(l)&&(l=TC.getBestMask(C,PC.bind(null,C,n))),TC.applyMask(l,C),PC(C,n,l),{modules:C,version:t,errorCorrectionLevel:n,maskPattern:l,segments:d}}o(MB,"createSymbol");AL.create=o(function(t,n){if(typeof t=="undefined"||t==="")throw new Error("No input text");let l=EC.M,d,h;return typeof n!="undefined"&&(l=EC.from(n.errorCorrectionLevel,EC.M),d=_y.from(n.version),h=TC.from(n.maskPattern),n.toSJISFunc&&by.setToSJISFunction(n.toSJISFunc)),MB(t,d,l,h)},"create")});var LC=Ue(Gf=>{function RL(e){if(typeof e=="number"&&(e=e.toString()),typeof e!="string")throw new 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 new Error("Invalid hex color: "+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(l){return[l,l]}))),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("")}}o(RL,"hex2rgba");Gf.getOptions=o(function(t){t||(t={}),t.color||(t.color={});let n=typeof t.margin=="undefined"||t.margin===null||t.margin<0?4:t.margin,l=t.width&&t.width>=21?t.width:void 0,d=t.scale||4;return{width:l,scale:l?4:d,margin:n,color:{dark:RL(t.color.dark||"#000000ff"),light:RL(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},"getOptions");Gf.getScale=o(function(t,n){return n.width&&n.width>=t+n.margin*2?n.width/(t+n.margin*2):n.scale},"getScale");Gf.getImageWidth=o(function(t,n){let l=Gf.getScale(t,n);return Math.floor((t+n.margin*2)*l)},"getImageWidth");Gf.qrToImageData=o(function(t,n,l){let d=n.modules.size,h=n.modules.data,c=Gf.getScale(d,l),v=Math.floor((d+l.margin*2)*c),C=l.margin*c,k=[l.color.light,l.color.dark];for(let O=0;O=C&&j>=C&&O{var OC=LC();function AB(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=n,t.width=n,t.style.height=n+"px",t.style.width=n+"px"}o(AB,"clearCanvas");function DB(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}o(DB,"getCanvasElement");Ey.render=o(function(t,n,l){let d=l,h=n;typeof d=="undefined"&&(!n||!n.getContext)&&(d=n,n=void 0),n||(h=DB()),d=OC.getOptions(d);let c=OC.getImageWidth(t.modules.size,d),v=h.getContext("2d"),C=v.createImageData(c,c);return OC.qrToImageData(C.data,t,d),AB(v,h,c),v.putImageData(C,0,0),h},"render");Ey.renderToDataURL=o(function(t,n,l){let d=l;typeof d=="undefined"&&(!n||!n.getContext)&&(d=n,n=void 0),d||(d={});let h=Ey.render(t,n,d),c=d.type||"image/png",v=d.rendererOpts||{};return h.toDataURL(c,v.quality)},"renderToDataURL")});var HL=Ue(BL=>{var RB=LC();function FL(e,t){let n=e.a/255,l=t+'="'+e.hex+'"';return n<1?l+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':l}o(FL,"getColorAttrib");function MC(e,t,n){let l=e+t;return typeof n!="undefined"&&(l+=" "+n),l}o(MC,"svgCmd");function IB(e,t,n){let l="",d=0,h=!1,c=0;for(let v=0;v0&&C>0&&e[v-1]||(l+=h?MC("M",C+n,.5+k+n):MC("m",d,0),d=0,h=!1),C+1':"",k="',O='viewBox="0 0 '+v+" "+v+'"',j=d.width?'width="'+d.width+'" height="'+d.width+'" ':"",B=''+C+k+` +`;return typeof l=="function"&&l(null,B),B},"render")});var UL=Ue(Mm=>{var FB=UP(),AC=DL(),WL=IL(),BB=HL();function DC(e,t,n,l,d){let h=[].slice.call(arguments,1),c=h.length,v=typeof h[c-1]=="function";if(!v&&!FB())throw new Error("Callback required as last argument");if(v){if(c<2)throw new Error("Too few arguments provided");c===2?(d=n,n=t,t=l=void 0):c===3&&(t.getContext&&typeof d=="undefined"?(d=l,l=void 0):(d=l,l=n,n=t,t=void 0))}else{if(c<1)throw new Error("Too few arguments provided");return c===1?(n=t,t=l=void 0):c===2&&!t.getContext&&(l=n,n=t,t=void 0),new Promise(function(C,k){try{let O=AC.create(n,l);C(e(O,t,l))}catch(O){k(O)}})}try{let C=AC.create(n,l);d(null,e(C,t,l))}catch(C){d(C)}}o(DC,"renderCanvas");Mm.create=AC.create;Mm.toCanvas=DC.bind(null,WL.render);Mm.toDataURL=DC.bind(null,WL.renderToDataURL);Mm.toString=DC.bind(null,function(e,t,n){return BB.render(e,n)})});var nb=fe(Oe()),uO=fe(iu());var Gh=fe(Oe()),NH=fe(ak());var uk=fe(Oe()),ei=uk.default.createContext(null);function EI(e){e()}o(EI,"defaultNoopBatch");var fk=EI,ck=o(function(t){return fk=t},"setBatch"),pk=o(function(){return fk},"getBatch");var dk={notify:o(function(){},"notify")};function TI(){var e=pk(),t=null,n=null;return{clear:o(function(){t=null,n=null},"clear"),notify:o(function(){e(function(){for(var d=t;d;)d.callback(),d=d.next})},"notify"),get:o(function(){for(var d=[],h=t;h;)d.push(h),h=h.next;return d},"get"),subscribe:o(function(d){var h=!0,c=n={callback:d,next:null,prev:n};return c.prev?c.prev.next=c:t=c,o(function(){!h||t===null||(h=!1,c.next?c.next.prev=c.prev:n=c.prev,c.prev?c.prev.next=c.next:t=c.next)},"unsubscribe")},"subscribe")}}o(TI,"createListenerCollection");var Tp=function(){function e(n,l){this.store=n,this.parentSub=l,this.unsubscribe=null,this.listeners=dk,this.handleChangeWrapper=this.handleChangeWrapper.bind(this)}o(e,"Subscription");var t=e.prototype;return t.addNestedSub=o(function(l){return this.trySubscribe(),this.listeners.subscribe(l)},"addNestedSub"),t.notifyNestedSubs=o(function(){this.listeners.notify()},"notifyNestedSubs"),t.handleChangeWrapper=o(function(){this.onStateChange&&this.onStateChange()},"handleChangeWrapper"),t.isSubscribed=o(function(){return Boolean(this.unsubscribe)},"isSubscribed"),t.trySubscribe=o(function(){this.unsubscribe||(this.unsubscribe=this.parentSub?this.parentSub.addNestedSub(this.handleChangeWrapper):this.store.subscribe(this.handleChangeWrapper),this.listeners=TI())},"trySubscribe"),t.tryUnsubscribe=o(function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null,this.listeners.clear(),this.listeners=dk)},"tryUnsubscribe"),e}();var Gv=fe(Oe()),Nf=typeof window!="undefined"&&typeof window.document!="undefined"&&typeof window.document.createElement!="undefined"?Gv.useLayoutEffect:Gv.useEffect;function kI(e){var t=e.store,n=e.context,l=e.children,d=(0,Gh.useMemo)(function(){var v=new Tp(t);return v.onStateChange=v.notifyNestedSubs,{store:t,subscription:v}},[t]),h=(0,Gh.useMemo)(function(){return t.getState()},[t]);Nf(function(){var v=d.subscription;return v.trySubscribe(),h!==t.getState()&&v.notifyNestedSubs(),function(){v.tryUnsubscribe(),v.onStateChange=null}},[d,h]);var c=n||ei;return Gh.default.createElement(c.Provider,{value:d},l)}o(kI,"Provider");var Hx=kI;function Lo(){return Lo=Object.assign||function(e){for(var t=1;t=0)&&(n[d]=e[d]);return n}o(ou,"_objectWithoutPropertiesLoose");var Gx=fe(_k()),cr=fe(Oe()),Pk=fe(Nk());var qI=[],VI=[null,null];function KI(e,t){var n=e[1];return[t.payload,n+1]}o(KI,"storeStateUpdatesReducer");function Lk(e,t,n){Nf(function(){return e.apply(void 0,t)},n)}o(Lk,"useIsomorphicLayoutEffectWithArgs");function GI(e,t,n,l,d,h,c){e.current=l,t.current=d,n.current=!1,h.current&&(h.current=null,c())}o(GI,"captureWrapperProps");function YI(e,t,n,l,d,h,c,v,C,k){if(!!e){var O=!1,j=null,B=o(function(){if(!O){var Z=t.getState(),R,A;try{R=l(Z,d.current)}catch(I){A=I,j=I}A||(j=null),R===h.current?c.current||C():(h.current=R,v.current=R,c.current=!0,k({type:"STORE_UPDATED",payload:{error:A}}))}},"checkForUpdates");n.onStateChange=B,n.trySubscribe(),B();var X=o(function(){if(O=!0,n.tryUnsubscribe(),n.onStateChange=null,j)throw j},"unsubscribeWrapper");return X}}o(YI,"subscribeUpdates");var XI=o(function(){return[null,0]},"initStateUpdates");function m0(e,t){t===void 0&&(t={});var n=t,l=n.getDisplayName,d=l===void 0?function(ne){return"ConnectAdvanced("+ne+")"}:l,h=n.methodName,c=h===void 0?"connectAdvanced":h,v=n.renderCountProp,C=v===void 0?void 0:v,k=n.shouldHandleStateChanges,O=k===void 0?!0:k,j=n.storeKey,B=j===void 0?"store":j,X=n.withRef,J=X===void 0?!1:X,Z=n.forwardRef,R=Z===void 0?!1:Z,A=n.context,I=A===void 0?ei:A,G=ou(n,["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef","forwardRef","context"]);if(!1)var K;var se=I;return o(function(pe){var me=pe.displayName||pe.name||"Component",xe=d(me),Ve=Lo({},G,{getDisplayName:d,methodName:c,renderCountProp:C,shouldHandleStateChanges:O,storeKey:B,displayName:xe,wrappedComponentName:me,WrappedComponent:pe}),tt=G.pure;function Ee(Xe){return e(Xe.dispatch,Ve)}o(Ee,"createChildSelector");var St=tt?cr.useMemo:function(Xe){return Xe()};function We(Xe){var nr=(0,cr.useMemo)(function(){var Cr=Xe.reactReduxForwardedRef,Ui=ou(Xe,["reactReduxForwardedRef"]);return[Xe.context,Cr,Ui]},[Xe]),ct=nr[0],Hr=nr[1],Zt=nr[2],Et=(0,cr.useMemo)(function(){return ct&&ct.Consumer&&(0,Pk.isContextConsumer)(cr.default.createElement(ct.Consumer,null))?ct:se},[ct,se]),Ct=(0,cr.useContext)(Et),ut=Boolean(Xe.store)&&Boolean(Xe.store.getState)&&Boolean(Xe.store.dispatch),Pr=Boolean(Ct)&&Boolean(Ct.store),zt=ut?Xe.store:Ct.store,$t=(0,cr.useMemo)(function(){return Ee(zt)},[zt]),ie=(0,cr.useMemo)(function(){if(!O)return VI;var Cr=new Tp(zt,ut?null:Ct.subscription),Ui=Cr.notifyNestedSubs.bind(Cr);return[Cr,Ui]},[zt,ut,Ct]),rt=ie[0],Lr=ie[1],Gt=(0,cr.useMemo)(function(){return ut?Ct:Lo({},Ct,{subscription:rt})},[ut,Ct,rt]),Yt=(0,cr.useReducer)(KI,qI,XI),Se=Yt[0],Or=Se[0],fn=Yt[1];if(Or&&Or.error)throw Or.error;var Un=(0,cr.useRef)(),si=(0,cr.useRef)(Zt),cn=(0,cr.useRef)(),Jt=(0,cr.useRef)(!1),gr=St(function(){return cn.current&&Zt===si.current?cn.current:$t(zt.getState(),Zt)},[zt,Or,Zt]);Lk(GI,[si,Un,Jt,Zt,gr,cn,Lr]),Lk(YI,[O,zt,rt,$t,si,Un,Jt,cn,Lr,fn],[zt,rt,$t]);var pt=(0,cr.useMemo)(function(){return cr.default.createElement(pe,Lo({},gr,{ref:Hr}))},[Hr,pe,gr]),Ho=(0,cr.useMemo)(function(){return O?cr.default.createElement(Et.Provider,{value:Gt},pt):pt},[Et,pt,Gt]);return Ho}o(We,"ConnectFunction");var Ke=tt?cr.default.memo(We):We;if(Ke.WrappedComponent=pe,Ke.displayName=We.displayName=xe,R){var Ge=cr.default.forwardRef(o(function(nr,ct){return cr.default.createElement(Ke,Lo({},nr,{reactReduxForwardedRef:ct}))},"forwardConnectRef"));return Ge.displayName=xe,Ge.WrappedComponent=pe,(0,Gx.default)(Ge,pe)}return(0,Gx.default)(Ke,pe)},"wrapWithConnect")}o(m0,"connectAdvanced");function Ok(e,t){return e===t?e!==0||t!==0||1/e==1/t:e!==e&&t!==t}o(Ok,"is");function kp(e,t){if(Ok(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),l=Object.keys(t);if(n.length!==l.length)return!1;for(var d=0;d=0;l--){var d=t[l](e);if(d)return d}return function(h,c){throw new Error("Invalid value of type "+typeof e+" for "+n+" argument when connecting component "+c.wrappedComponentName+".")}}o(Qx,"match");function uF(e,t){return e===t}o(uF,"strictEqual");function fF(e){var t=e===void 0?{}:e,n=t.connectHOC,l=n===void 0?m0:n,d=t.mapStateToPropsFactories,h=d===void 0?Dk:d,c=t.mapDispatchToPropsFactories,v=c===void 0?Ak:c,C=t.mergePropsFactories,k=C===void 0?Rk:C,O=t.selectorFactory,j=O===void 0?Xx:O;return o(function(X,J,Z,R){R===void 0&&(R={});var A=R,I=A.pure,G=I===void 0?!0:I,K=A.areStatesEqual,se=K===void 0?uF:K,ne=A.areOwnPropsEqual,pe=ne===void 0?kp:ne,me=A.areStatePropsEqual,xe=me===void 0?kp:me,Ve=A.areMergedPropsEqual,tt=Ve===void 0?kp:Ve,Ee=ou(A,["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"]),St=Qx(X,h,"mapStateToProps"),We=Qx(J,v,"mapDispatchToProps"),Ke=Qx(Z,k,"mergeProps");return l(j,Lo({methodName:"connect",getDisplayName:o(function(Xe){return"Connect("+Xe+")"},"getDisplayName"),shouldHandleStateChanges:Boolean(X),initMapStateToProps:St,initMapDispatchToProps:We,initMergeProps:Ke,pure:G,areStatesEqual:se,areOwnPropsEqual:pe,areStatePropsEqual:xe,areMergedPropsEqual:tt},Ee))},"connect")}o(fF,"createConnect");var Hi=fF();var Fk=fe(Oe());var Ik=fe(Oe());function v0(){var e=(0,Ik.useContext)(ei);return e}o(v0,"useReduxContext");function y0(e){e===void 0&&(e=ei);var t=e===ei?v0:function(){return(0,Fk.useContext)(e)};return o(function(){var l=t(),d=l.store;return d},"useStore")}o(y0,"createStoreHook");var Zx=y0();function Bk(e){e===void 0&&(e=ei);var t=e===ei?Zx:y0(e);return o(function(){var l=t();return l.dispatch},"useDispatch")}o(Bk,"createDispatchHook");var Gs=Bk();var ro=fe(Oe());var cF=o(function(t,n){return t===n},"refEquality");function pF(e,t,n,l){var d=(0,ro.useReducer)(function(J){return J+1},0),h=d[1],c=(0,ro.useMemo)(function(){return new Tp(n,l)},[n,l]),v=(0,ro.useRef)(),C=(0,ro.useRef)(),k=(0,ro.useRef)(),O=(0,ro.useRef)(),j=n.getState(),B;try{if(e!==C.current||j!==k.current||v.current){var X=e(j);O.current===void 0||!t(X,O.current)?B=X:B=O.current}else B=O.current}catch(J){throw v.current&&(J.message+=` The error may be correlated with this previous error: `+v.current.stack+` -`),J}return Nf(function(){C.current=e,k.current=j,O.current=B,v.current=void 0}),Nf(function(){function J(){try{var Z=n.getState(),R=C.current(Z);if(t(R,O.current))return;O.current=R,k.current=Z}catch(A){v.current=A}h()}return o(J,"checkForUpdates"),c.onStateChange=J,c.trySubscribe(),J(),function(){return c.tryUnsubscribe()}},[n,c]),B}o(pF,"useSelectorWithStoreAndSubscription");function Wk(e){e===void 0&&(e=ei);var t=e===ei?y0:function(){return(0,ro.useContext)(e)};return o(function(l,d){d===void 0&&(d=cF);var h=t(),c=h.store,v=h.subscription,C=pF(l,d,c,v);return(0,ro.useDebugValue)(C),C},"useSelector")}o(Wk,"createSelectorHook");var eS=Wk();var tS=fe(iu());pk(tS.unstable_batchedUpdates);var Wn=fe(Oe());var Uk="UI_FLOWVIEW_SET_TAB",zk="SET_CONTENT_VIEW_FOR",dF={tab:"request",contentViewFor:{}};function rS(e=dF,t){switch(t.type){case zk:return Pt(ke({},e),{contentViewFor:Pt(ke({},e.contentViewFor),{[t.messageId]:t.contentView})});case Uk:return Pt(ke({},e),{tab:t.tab?t.tab:"request"});default:return e}}o(rS,"reducer");function Lf(e){return{type:Uk,tab:e}}o(Lf,"selectTab");function x0(e,t){return{type:zk,messageId:e,contentView:t}}o(x0,"setContentViewFor");var $k=fe(Qh()),hF=fe(Oe());window._=$k.default;window.React=hF;var S0=o(function(e){if(e===0)return"0";for(var t=["b","kb","mb","gb","tb"],n=0;ne);n++);var l;return e%Math.pow(1024,n)==0?l=0:l=1,(e/Math.pow(1024,n)).toFixed(l)+t[n]},"formatSize"),C0=o(function(e){for(var t=e,n=["ms","s","min","h"],l=[1e3,60,60],d=0;Math.abs(t)>=l[d]&&dkt(e,ke({method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},n));kt.post=(e,t,n={})=>kt(e,ke({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},n));function Pf(e,...t){return Ia(this,null,function*(){return yield(yield kt(`/commands/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({arguments:t})})).json()})}o(Pf,"runCommand");var Jh={};Wb(Jh,{ADD:()=>uS,RECEIVE:()=>pS,REMOVE:()=>cS,SET_FILTER:()=>lS,SET_SORT:()=>aS,UPDATE:()=>fS,add:()=>vF,defaultState:()=>b0,receive:()=>xF,reduce:()=>Lp,remove:()=>wF,setFilter:()=>dS,setSort:()=>qk,update:()=>yF});var sS=fe(jk()),lS="LIST_SET_FILTER",aS="LIST_SET_SORT",uS="LIST_ADD",fS="LIST_UPDATE",cS="LIST_REMOVE",pS="LIST_RECEIVE",b0={byId:{},list:[],listIndex:{},view:[],viewIndex:{}};function Lp(e=b0,t){let{byId:n,list:l,listIndex:d,view:h,viewIndex:c}=e;switch(t.type){case lS:h=(0,sS.default)(l.filter(t.filter),t.sort),c={},h.forEach((k,O)=>{c[k.id]=O});break;case aS:h=(0,sS.default)([...h],t.sort),c={},h.forEach((k,O)=>{c[k.id]=O});break;case uS:if(t.item.id in n)break;n=Pt(ke({},n),{[t.item.id]:t.item}),d=Pt(ke({},d),{[t.item.id]:l.length}),l=[...l,t.item],t.filter(t.item)&&({view:h,viewIndex:c}=Vk(e,t.item,t.sort));break;case fS:n=Pt(ke({},n),{[t.item.id]:t.item}),l=[...l],l[d[t.item.id]]=t.item;let v=t.item.id in c,C=t.filter(t.item);C&&!v?{view:h,viewIndex:c}=Vk(e,t.item,t.sort):!C&&v?{data:h,dataIndex:c}=hS(h,c,t.item.id):C&&v&&({view:h,viewIndex:c}=SF(e,t.item,t.sort));break;case cS:if(!(t.id in n))break;n=ke({},n),delete n[t.id],{data:l,dataIndex:d}=hS(l,d,t.id),t.id in c&&({data:h,dataIndex:c}=hS(h,c,t.id));break;case pS:l=t.list,d={},n={},l.forEach((k,O)=>{n[k.id]=k,d[k.id]=O}),h=l.filter(t.filter).sort(t.sort),c={},h.forEach((k,O)=>{c[k.id]=O});break}return{byId:n,list:l,listIndex:d,view:h,viewIndex:c}}o(Lp,"reduce");function dS(e=E0,t=Zh){return{type:lS,filter:e,sort:t}}o(dS,"setFilter");function qk(e=Zh){return{type:aS,sort:e}}o(qk,"setSort");function vF(e,t=E0,n=Zh){return{type:uS,item:e,filter:t,sort:n}}o(vF,"add");function yF(e,t=E0,n=Zh){return{type:fS,item:e,filter:t,sort:n}}o(yF,"update");function wF(e){return{type:cS,id:e}}o(wF,"remove");function xF(e,t=E0,n=Zh){return{type:pS,list:e,filter:t,sort:n}}o(xF,"receive");function Vk(e,t,n){let l=CF(e.view,t,n),d=[...e.view],h=ke({},e.viewIndex);d.splice(l,0,t);for(let c=d.length-1;c>=l;c--)h[d[c].id]=c;return{view:d,viewIndex:h}}o(Vk,"sortedInsert");function hS(e,t,n){let l=t[n],d=[...e],h=ke({},t);delete h[n],d.splice(l,1);for(let c=d.length-1;c>=l;c--)h[d[c].id]=c;return{data:d,dataIndex:h}}o(hS,"removeData");function SF(e,t,n){let l=[...e.view],d=ke({},e.viewIndex),h=d[t.id];for(l[h]=t;h+10;)l[h]=l[h+1],l[h+1]=t,d[t.id]=h+1,d[l[h].id]=h,++h;for(;h>0&&n(l[h],l[h-1])<0;)l[h]=l[h-1],l[h-1]=t,d[t.id]=h-1,d[l[h].id]=h,--h;return{view:l,viewIndex:d}}o(SF,"sortedUpdate");function CF(e,t,n){let l=0,d=e.length;for(;l>>1;n(t,e[h])>=0?l=h+1:d=h}return l}o(CF,"sortedIndex");function E0(){return!0}o(E0,"defaultFilter");function Zh(e,t){return 0}o(Zh,"defaultSort");var Kk={http:80,https:443},Kr=class{static getContentType(t){var n=Kr.get_first_header(t,/^Content-Type$/i);if(n)return n.split(";")[0].trim()}static get_first_header(t,n){let l=t;l._headerLookups||Object.defineProperty(l,"_headerLookups",{value:{},configurable:!1,enumerable:!1,writable:!1});let d=n.toString();if(!(d in l._headerLookups)){let h;for(let c=0;c{var t,n;switch(e.type){case"http":let l=e.request.contentLength||0;return e.response&&(l+=e.response.contentLength||0),e.websocket&&(l+=e.websocket.messages_meta.contentLength||0),l;case"tcp":case"udp":return e.messages_meta.contentLength||0;case"dns":return(n=(t=e.response)==null?void 0:t.size)!=null?n:0}},"getTotalSize"),_0=o(e=>e.type==="http"&&!e.websocket,"canReplay");var Of=function(){"use strict";function e(l,d){function h(){this.constructor=l}o(h,"ctor"),h.prototype=d.prototype,l.prototype=new h}o(e,"peg$subclass");function t(l,d,h,c){this.message=l,this.expected=d,this.found=h,this.location=c,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t)}o(t,"peg$SyntaxError"),e(t,Error);function n(l){var d=arguments.length>1?arguments[1]:{},h=this,c={},v={start:Ou},C=Ou,k={type:"other",description:"filter expression"},O=o(function(w){return w},"peg$c1"),j={type:"other",description:"whitespace"},B=/^[ \t\n\r]/,X={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},J={type:"other",description:"control character"},Z=/^[|&!()~"]/,R={type:"class",value:'[|&!()~"]',description:'[|&!()~"]'},A={type:"other",description:"optional whitespace"},I="|",G={type:"literal",value:"|",description:'"|"'},K=o(function(w,T){return Au(w,T)},"peg$c11"),se="&",ne={type:"literal",value:"&",description:'"&"'},pe=o(function(w,T){return hd(w,T)},"peg$c14"),me="!",xe={type:"literal",value:"!",description:'"!"'},Ve=o(function(w){return Vo(w)},"peg$c17"),tt="(",_e={type:"literal",value:"(",description:'"("'},St=")",We={type:"literal",value:")",description:'")"'},Ke=o(function(w){return yr(w)},"peg$c22"),Ge="~all",Xe={type:"literal",value:"~all",description:'"~all"'},nr=o(function(){return fc},"peg$c25"),ct="~a",Hr={type:"literal",value:"~a",description:'"~a"'},Zt=o(function(){return Ko},"peg$c28"),_t="~b",Ct={type:"literal",value:"~b",description:'"~b"'},ut=o(function(w){return na(w)},"peg$c31"),Lr="~bq",zt={type:"literal",value:"~bq",description:'"~bq"'},$t=o(function(w){return Go(w)},"peg$c34"),ie="~bs",rt={type:"literal",value:"~bs",description:'"~bs"'},Pr=o(function(w){return md(w)},"peg$c37"),Gt="~c",Yt={type:"literal",value:"~c",description:'"~c"'},Se=o(function(w){return ia(w)},"peg$c40"),Or="~comment",fn={type:"literal",value:"~comment",description:'"~comment"'},Un=o(function(w){return Ru(w)},"peg$c43"),si="~d",cn={type:"literal",value:"~d",description:'"~d"'},Jt=o(function(w){return Iu(w)},"peg$c46"),gr="~dns",pt={type:"literal",value:"~dns",description:'"~dns"'},Ho=o(function(){return oa},"peg$c49"),Cr="~dst",Ui={type:"literal",value:"~dst",description:'"~dst"'},pn=o(function(w){return Fu(w)},"peg$c52"),zn="~e",Si={type:"literal",value:"~e",description:'"~e"'},Ci=o(function(){return Bu},"peg$c55"),$n="~h",Mn={type:"literal",value:"~h",description:'"~h"'},Js=o(function(w){return Hu(w)},"peg$c58"),H="~hq",ee={type:"literal",value:"~hq",description:'"~hq"'},he=o(function(w){return Yo(w)},"peg$c61"),Te="~hs",ir={type:"literal",value:"~hs",description:'"~hs"'},Ul=o(function(w){return ji(w)},"peg$c64"),Ft="~http",Wr={type:"literal",value:"~http",description:'"~http"'},or=o(function(){return Ss},"peg$c67"),li="~marked",ds={type:"literal",value:"~marked",description:'"~marked"'},lo=o(function(){return zr},"peg$c70"),bi="~marker",el={type:"literal",value:"~marker",description:'"~marker"'},hs=o(function(w){return sa(w)},"peg$c73"),dn="~m",id={type:"literal",value:"~m",description:'"~m"'},tl=o(function(w){return mn(w)},"peg$c76"),Qf="~q",rl={type:"literal",value:"~q",description:'"~q"'},od=o(function(){return qi},"peg$c79"),Zf="~replayq",wu={type:"literal",value:"~replayq",description:'"~replayq"'},sd=o(function(){return al},"peg$c82"),zl="~replays",ms={type:"literal",value:"~replays",description:'"~replays"'},ld=o(function(){return cc},"peg$c85"),Jf="~replay",nl={type:"literal",value:"~replay",description:'"~replay"'},xu=o(function(){return Wu},"peg$c88"),Wo="~src",ad={type:"literal",value:"~src",description:'"~src"'},Uo=o(function(w){return gd(w)},"peg$c91"),$l="~s",ec={type:"literal",value:"~s",description:'"~s"'},jt=o(function(){return Uu},"peg$c94"),Me="~tcp",Ei={type:"literal",value:"~tcp",description:'"~tcp"'},Su=o(function(){return la},"peg$c97"),ai="~udp",vt={type:"literal",value:"~udp",description:'"~udp"'},ao=o(function(){return qn},"peg$c100"),zo="~tq",jl={type:"literal",value:"~tq",description:'"~tq"'},ue=o(function(w){return Ti(w)},"peg$c103"),ze="~ts",Cu={type:"literal",value:"~ts",description:'"~ts"'},bu=o(function(w){return pc(w)},"peg$c106"),gs="~t",il={type:"literal",value:"~t",description:'"~t"'},Eu=o(function(w){return aa(w)},"peg$c109"),He="~u",ud={type:"literal",value:"~u",description:'"~u"'},ql=o(function(w){return dc(w)},"peg$c112"),uo="~websocket",ui={type:"literal",value:"~websocket",description:'"~websocket"'},tc=o(function(){return Vi},"peg$c115"),_u={type:"other",description:"integer"},$o=/^['"]/,vs={type:"class",value:`['"]`,description:`['"]`},Tu=/^[0-9]/,ol={type:"class",value:"[0-9]",description:"[0-9]"},Vl=o(function(w){return parseInt(w.join(""),10)},"peg$c121"),Kl={type:"other",description:"string"},fo='"',Gl={type:"literal",value:'"',description:'"\\""'},Yl=o(function(w){return w.join("")},"peg$c125"),rc="'",Xl={type:"literal",value:"'",description:`"'"`},_i=/^["\\]/,nc={type:"class",value:'["\\\\]',description:'["\\\\]'},Ql={type:"any",description:"any character"},co=o(function(w){return w},"peg$c131"),ys="\\",ic={type:"literal",value:"\\",description:'"\\\\"'},oc=/^['\\]/,fd={type:"class",value:"['\\\\]",description:"['\\\\]"},cd=/^['"\\]/,ku={type:"class",value:`['"\\\\]`,description:`['"\\\\]`},sc="n",Nu={type:"literal",value:"n",description:'"n"'},lc=o(function(){return` -`},"peg$c140"),ac="r",Zl={type:"literal",value:"r",description:'"r"'},Jl=o(function(){return"\r"},"peg$c143"),Lu="t",Ot={type:"literal",value:"t",description:'"t"'},Nt=o(function(){return" "},"peg$c146"),P=0,Re=0,sl=[{line:1,column:1,seenCR:!1}],vr=0,Pu=[],ye=0,jo;if("startRule"in d){if(!(d.startRule in v))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');C=v[d.startRule]}function pd(){return l.substring(Re,P)}o(pd,"text");function qt(){return zi(Re,P)}o(qt,"location");function ea(w){throw ta(null,[{type:"other",description:w}],l.substring(Re,P),zi(Re,P))}o(ea,"expected");function hn(w){throw ta(w,null,l.substring(Re,P),zi(Re,P))}o(hn,"error");function ws(w){var T=sl[w],W,U;if(T)return T;for(W=w-1;!sl[W];)W--;for(T=sl[W],T={line:T.line,column:T.column,seenCR:T.seenCR};Wvr&&(vr=P,Pu=[]),Pu.push(w))}o(Ce,"peg$fail");function ta(w,T,W,U){function wr(gn){var ci=1;for(gn.sort(function(ul,ki){return ul.descriptionki.description?1:0});ci1?ki.slice(0,-1).join(", ")+" or "+ki[gn.length-1]:ki[0],zu=ci?'"'+ul(ci)+'"':"end of input","Expected "+Vn+" but "+zu+" found."}return o(Kt,"buildMessage"),T!==null&&wr(T),new t(w!==null?w:Kt(T,W),T,W,U)}o(ta,"peg$buildException");function Ou(){var w,T,W,U;return ye++,w=P,T=fi(),T!==c?(W=ll(),W!==c?(U=fi(),U!==c?(Re=w,T=O(W),w=T):(P=w,w=c)):(P=w,w=c)):(P=w,w=c),ye--,w===c&&(T=c,ye===0&&Ce(k)),w}o(Ou,"peg$parsestart");function nt(){var w,T;return ye++,B.test(l.charAt(P))?(w=l.charAt(P),P++):(w=c,ye===0&&Ce(X)),ye--,w===c&&(T=c,ye===0&&Ce(j)),w}o(nt,"peg$parsews");function uc(){var w,T;return ye++,Z.test(l.charAt(P))?(w=l.charAt(P),P++):(w=c,ye===0&&Ce(R)),ye--,w===c&&(T=c,ye===0&&Ce(J)),w}o(uc,"peg$parsecc");function fi(){var w,T;for(ye++,w=[],T=nt();T!==c;)w.push(T),T=nt();return ye--,w===c&&(T=c,ye===0&&Ce(A)),w}o(fi,"peg$parse__");function ll(){var w,T,W,U,wr,Kt;return w=P,T=Ur(),T!==c?(W=fi(),W!==c?(l.charCodeAt(P)===124?(U=I,P++):(U=c,ye===0&&Ce(G)),U!==c?(wr=fi(),wr!==c?(Kt=ll(),Kt!==c?(Re=w,T=K(T,Kt),w=T):(P=w,w=c)):(P=w,w=c)):(P=w,w=c)):(P=w,w=c)):(P=w,w=c),w===c&&(w=Ur()),w}o(ll,"peg$parseOrExpr");function Ur(){var w,T,W,U,wr,Kt;if(w=P,T=ra(),T!==c?(W=fi(),W!==c?(l.charCodeAt(P)===38?(U=se,P++):(U=c,ye===0&&Ce(ne)),U!==c?(wr=fi(),wr!==c?(Kt=Ur(),Kt!==c?(Re=w,T=pe(T,Kt),w=T):(P=w,w=c)):(P=w,w=c)):(P=w,w=c)):(P=w,w=c)):(P=w,w=c),w===c){if(w=P,T=ra(),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Ur(),U!==c?(Re=w,T=pe(T,U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;w===c&&(w=ra())}return w}o(Ur,"peg$parseAndExpr");function ra(){var w,T,W,U;return w=P,l.charCodeAt(P)===33?(T=me,P++):(T=c,ye===0&&Ce(xe)),T!==c?(W=fi(),W!==c?(U=ra(),U!==c?(Re=w,T=Ve(U),w=T):(P=w,w=c)):(P=w,w=c)):(P=w,w=c),w===c&&(w=jn()),w}o(ra,"peg$parseNotExpr");function jn(){var w,T,W,U,wr,Kt;return w=P,l.charCodeAt(P)===40?(T=tt,P++):(T=c,ye===0&&Ce(_e)),T!==c?(W=fi(),W!==c?(U=ll(),U!==c?(wr=fi(),wr!==c?(l.charCodeAt(P)===41?(Kt=St,P++):(Kt=c,ye===0&&Ce(We)),Kt!==c?(Re=w,T=Ke(U),w=T):(P=w,w=c)):(P=w,w=c)):(P=w,w=c)):(P=w,w=c)):(P=w,w=c),w===c&&(w=dd()),w}o(jn,"peg$parseBindingExpr");function dd(){var w,T,W,U;if(w=P,l.substr(P,4)===Ge?(T=Ge,P+=4):(T=c,ye===0&&Ce(Xe)),T!==c&&(Re=w,T=nr()),w=T,w===c&&(w=P,l.substr(P,2)===ct?(T=ct,P+=2):(T=c,ye===0&&Ce(Hr)),T!==c&&(Re=w,T=Zt()),w=T,w===c)){if(w=P,l.substr(P,2)===_t?(T=_t,P+=2):(T=c,ye===0&&Ce(Ct)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=ut(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,3)===Lr?(T=Lr,P+=3):(T=c,ye===0&&Ce(zt)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=$t(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,3)===ie?(T=ie,P+=3):(T=c,ye===0&&Ce(rt)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Pr(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,2)===Gt?(T=Gt,P+=2):(T=c,ye===0&&Ce(Yt)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Mu(),U!==c?(Re=w,T=Se(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,8)===Or?(T=Or,P+=8):(T=c,ye===0&&Ce(fn)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Un(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,2)===si?(T=si,P+=2):(T=c,ye===0&&Ce(cn)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Jt(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c&&(w=P,l.substr(P,4)===gr?(T=gr,P+=4):(T=c,ye===0&&Ce(pt)),T!==c&&(Re=w,T=Ho()),w=T,w===c)){if(w=P,l.substr(P,4)===Cr?(T=Cr,P+=4):(T=c,ye===0&&Ce(Ui)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=pn(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c&&(w=P,l.substr(P,2)===zn?(T=zn,P+=2):(T=c,ye===0&&Ce(Si)),T!==c&&(Re=w,T=Ci()),w=T,w===c)){if(w=P,l.substr(P,2)===$n?(T=$n,P+=2):(T=c,ye===0&&Ce(Mn)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Js(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,3)===H?(T=H,P+=3):(T=c,ye===0&&Ce(ee)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=he(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,3)===Te?(T=Te,P+=3):(T=c,ye===0&&Ce(ir)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Ul(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c&&(w=P,l.substr(P,5)===Ft?(T=Ft,P+=5):(T=c,ye===0&&Ce(Wr)),T!==c&&(Re=w,T=or()),w=T,w===c&&(w=P,l.substr(P,7)===li?(T=li,P+=7):(T=c,ye===0&&Ce(ds)),T!==c&&(Re=w,T=lo()),w=T,w===c))){if(w=P,l.substr(P,7)===bi?(T=bi,P+=7):(T=c,ye===0&&Ce(el)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=hs(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,2)===dn?(T=dn,P+=2):(T=c,ye===0&&Ce(id)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=tl(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c&&(w=P,l.substr(P,2)===Qf?(T=Qf,P+=2):(T=c,ye===0&&Ce(rl)),T!==c&&(Re=w,T=od()),w=T,w===c&&(w=P,l.substr(P,8)===Zf?(T=Zf,P+=8):(T=c,ye===0&&Ce(wu)),T!==c&&(Re=w,T=sd()),w=T,w===c&&(w=P,l.substr(P,8)===zl?(T=zl,P+=8):(T=c,ye===0&&Ce(ms)),T!==c&&(Re=w,T=ld()),w=T,w===c&&(w=P,l.substr(P,7)===Jf?(T=Jf,P+=7):(T=c,ye===0&&Ce(nl)),T!==c&&(Re=w,T=xu()),w=T,w===c))))){if(w=P,l.substr(P,4)===Wo?(T=Wo,P+=4):(T=c,ye===0&&Ce(ad)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Uo(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c&&(w=P,l.substr(P,2)===$l?(T=$l,P+=2):(T=c,ye===0&&Ce(ec)),T!==c&&(Re=w,T=jt()),w=T,w===c&&(w=P,l.substr(P,4)===Me?(T=Me,P+=4):(T=c,ye===0&&Ce(Ei)),T!==c&&(Re=w,T=Su()),w=T,w===c&&(w=P,l.substr(P,4)===ai?(T=ai,P+=4):(T=c,ye===0&&Ce(vt)),T!==c&&(Re=w,T=ao()),w=T,w===c)))){if(w=P,l.substr(P,3)===zo?(T=zo,P+=3):(T=c,ye===0&&Ce(jl)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=ue(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,3)===ze?(T=ze,P+=3):(T=c,ye===0&&Ce(Cu)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=bu(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,2)===gs?(T=gs,P+=2):(T=c,ye===0&&Ce(il)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Eu(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.substr(P,2)===He?(T=He,P+=2):(T=c,ye===0&&Ce(ud)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=ql(U),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;w===c&&(w=P,l.substr(P,10)===uo?(T=uo,P+=10):(T=c,ye===0&&Ce(ui)),T!==c&&(Re=w,T=tc()),w=T,w===c&&(w=P,T=Vt(),T!==c&&(Re=w,T=ql(T)),w=T))}}}}}}}}}}}}}}}}}return w}o(dd,"peg$parseExpr");function Mu(){var w,T,W,U;if(ye++,w=P,$o.test(l.charAt(P))?(T=l.charAt(P),P++):(T=c,ye===0&&Ce(vs)),T===c&&(T=null),T!==c){if(W=[],Tu.test(l.charAt(P))?(U=l.charAt(P),P++):(U=c,ye===0&&Ce(ol)),U!==c)for(;U!==c;)W.push(U),Tu.test(l.charAt(P))?(U=l.charAt(P),P++):(U=c,ye===0&&Ce(ol));else W=c;W!==c?($o.test(l.charAt(P))?(U=l.charAt(P),P++):(U=c,ye===0&&Ce(vs)),U===c&&(U=null),U!==c?(Re=w,T=Vl(W),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;return ye--,w===c&&(T=c,ye===0&&Ce(_u)),w}o(Mu,"peg$parseIntegerLiteral");function Vt(){var w,T,W,U;if(ye++,w=P,l.charCodeAt(P)===34?(T=fo,P++):(T=c,ye===0&&Ce(Gl)),T!==c){for(W=[],U=xs();U!==c;)W.push(U),U=xs();W!==c?(l.charCodeAt(P)===34?(U=fo,P++):(U=c,ye===0&&Ce(Gl)),U!==c?(Re=w,T=Yl(W),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c){if(w=P,l.charCodeAt(P)===39?(T=rc,P++):(T=c,ye===0&&Ce(Xl)),T!==c){for(W=[],U=qo();U!==c;)W.push(U),U=qo();W!==c?(l.charCodeAt(P)===39?(U=rc,P++):(U=c,ye===0&&Ce(Xl)),U!==c?(Re=w,T=Yl(W),w=T):(P=w,w=c)):(P=w,w=c)}else P=w,w=c;if(w===c)if(w=P,T=P,ye++,W=uc(),ye--,W===c?T=void 0:(P=T,T=c),T!==c){if(W=[],U=yt(),U!==c)for(;U!==c;)W.push(U),U=yt();else W=c;W!==c?(Re=w,T=Yl(W),w=T):(P=w,w=c)}else P=w,w=c}return ye--,w===c&&(T=c,ye===0&&Ce(Kl)),w}o(Vt,"peg$parseStringLiteral");function xs(){var w,T,W;return w=P,T=P,ye++,_i.test(l.charAt(P))?(W=l.charAt(P),P++):(W=c,ye===0&&Ce(nc)),ye--,W===c?T=void 0:(P=T,T=c),T!==c?(l.length>P?(W=l.charAt(P),P++):(W=c,ye===0&&Ce(Ql)),W!==c?(Re=w,T=co(W),w=T):(P=w,w=c)):(P=w,w=c),w===c&&(w=P,l.charCodeAt(P)===92?(T=ys,P++):(T=c,ye===0&&Ce(ic)),T!==c?(W=$i(),W!==c?(Re=w,T=co(W),w=T):(P=w,w=c)):(P=w,w=c)),w}o(xs,"peg$parseDoubleStringChar");function qo(){var w,T,W;return w=P,T=P,ye++,oc.test(l.charAt(P))?(W=l.charAt(P),P++):(W=c,ye===0&&Ce(fd)),ye--,W===c?T=void 0:(P=T,T=c),T!==c?(l.length>P?(W=l.charAt(P),P++):(W=c,ye===0&&Ce(Ql)),W!==c?(Re=w,T=co(W),w=T):(P=w,w=c)):(P=w,w=c),w===c&&(w=P,l.charCodeAt(P)===92?(T=ys,P++):(T=c,ye===0&&Ce(ic)),T!==c?(W=$i(),W!==c?(Re=w,T=co(W),w=T):(P=w,w=c)):(P=w,w=c)),w}o(qo,"peg$parseSingleStringChar");function yt(){var w,T,W;return w=P,T=P,ye++,W=nt(),ye--,W===c?T=void 0:(P=T,T=c),T!==c?(l.length>P?(W=l.charAt(P),P++):(W=c,ye===0&&Ce(Ql)),W!==c?(Re=w,T=co(W),w=T):(P=w,w=c)):(P=w,w=c),w}o(yt,"peg$parseUnquotedStringChar");function $i(){var w,T;return cd.test(l.charAt(P))?(w=l.charAt(P),P++):(w=c,ye===0&&Ce(ku)),w===c&&(w=P,l.charCodeAt(P)===110?(T=sc,P++):(T=c,ye===0&&Ce(Nu)),T!==c&&(Re=w,T=lc()),w=T,w===c&&(w=P,l.charCodeAt(P)===114?(T=ac,P++):(T=c,ye===0&&Ce(Zl)),T!==c&&(Re=w,T=Jl()),w=T,w===c&&(w=P,l.charCodeAt(P)===116?(T=Lu,P++):(T=c,ye===0&&Ce(Ot)),T!==c&&(Re=w,T=Nt()),w=T))),w}o($i,"peg$parseEscapeSequence");function Au(w,T){function W(){return w.apply(this,arguments)||T.apply(this,arguments)}return o(W,"orFilter"),W.desc=w.desc+" or "+T.desc,W}o(Au,"or");function hd(w,T){function W(){return w.apply(this,arguments)&&T.apply(this,arguments)}return o(W,"andFilter"),W.desc=w.desc+" and "+T.desc,W}o(hd,"and");function Vo(w){function T(){return!w.apply(this,arguments)}return o(T,"notFilter"),T.desc="not "+w.desc,T}o(Vo,"not");function yr(w){function T(){return w.apply(this,arguments)}return o(T,"bindingFilter"),T.desc="("+w.desc+")",T}o(yr,"binding");function fc(w){return!0}o(fc,"allFilter"),fc.desc="all flows";var Du=[new RegExp("text/javascript"),new RegExp("application/x-javascript"),new RegExp("application/javascript"),new RegExp("text/css"),new RegExp("image/.*"),new RegExp("font/.*"),new RegExp("application/font.*")];function Ko(w){if(w.response){for(var T=Ys.getContentType(w.response),W=Du.length;W--;)if(Du[W].test(T))return!0}return!1}o(Ko,"assetFilter"),Ko.desc="is asset";function na(w){w=new RegExp(w,"i");function T(W){return!0}return o(T,"bodyFilter"),T.desc="body filters are not implemented yet, see https://github.com/mitmproxy/mitmproxy/issues/3609",T}o(na,"body");function Go(w){w=new RegExp(w,"i");function T(W){return!0}return o(T,"requestBodyFilter"),T.desc="body filters are not implemented yet, see https://github.com/mitmproxy/mitmproxy/issues/3609",T}o(Go,"requestBody");function md(w){w=new RegExp(w,"i");function T(W){return!0}return o(T,"responseBodyFilter"),T.desc="body filters are not implemented yet, see https://github.com/mitmproxy/mitmproxy/issues/3609",T}o(md,"responseBody");function ia(w){function T(W){return W.response&&W.response.status_code===w}return o(T,"responseCodeFilter"),T.desc="resp. code is "+w,T}o(ia,"responseCode");function Ru(w){w=new RegExp(w,"i");function T(W){return w.test(W.comment)}return o(T,"commentFilter"),T.desc="comment matches "+w,T}o(Ru,"comment");function Iu(w){w=new RegExp(w,"i");function T(W){return W.request&&(w.test(W.request.host)||w.test(W.request.pretty_host))}return o(T,"domainFilter"),T.desc="domain matches "+w,T}o(Iu,"domain");function oa(w){return w.type==="dns"}o(oa,"dnsFilter"),oa.desc="is a DNS Flow";function Fu(w){w=new RegExp(w,"i");function T(W){return!!W.server_conn.address&&w.test(W.server_conn.address[0]+":"+W.server_conn.address[1])}return o(T,"destinationFilter"),T.desc="destination address matches "+w,T}o(Fu,"destination");function Bu(w){return!!w.error}o(Bu,"errorFilter"),Bu.desc="has error";function Hu(w){w=new RegExp(w,"i");function T(W){return W.request&&Oo.match_header(W.request,w)||W.response&&Ys.match_header(W.response,w)}return o(T,"headerFilter"),T.desc="header matches "+w,T}o(Hu,"header");function Yo(w){w=new RegExp(w,"i");function T(W){return W.request&&Oo.match_header(W.request,w)}return o(T,"requestHeaderFilter"),T.desc="req. header matches "+w,T}o(Yo,"requestHeader");function ji(w){w=new RegExp(w,"i");function T(W){return W.response&&Ys.match_header(W.response,w)}return o(T,"responseHeaderFilter"),T.desc="resp. header matches "+w,T}o(ji,"responseHeader");function Ss(w){return w.type==="http"}o(Ss,"httpFilter"),Ss.desc="is an HTTP Flow";function zr(w){return w.marked}o(zr,"markedFilter"),zr.desc="is marked";function sa(w){w=new RegExp(w,"i");function T(W){return w.test(W.marked)}return o(T,"markerFilter"),T.desc="marker matches "+w,T}o(sa,"marker");function mn(w){w=new RegExp(w,"i");function T(W){return W.request&&w.test(W.request.method)}return o(T,"methodFilter"),T.desc="method matches "+w,T}o(mn,"method");function qi(w){return w.request&&!w.response}o(qi,"noResponseFilter"),qi.desc="has no response";function al(w){return w.is_replay==="request"}o(al,"clientReplayFilter"),al.desc="request has been replayed";function cc(w){return w.is_replay==="response"}o(cc,"serverReplayFilter"),cc.desc="response has been replayed";function Wu(w){return!!w.is_replay}o(Wu,"replayFilter"),Wu.desc="flow has been replayed";function gd(w){w=new RegExp(w,"i");function T(W){return!!W.client_conn.peername&&w.test(W.client_conn.peername[0]+":"+W.client_conn.peername[1])}return o(T,"sourceFilter"),T.desc="source address matches "+w,T}o(gd,"source");function Uu(w){return!!w.response}o(Uu,"responseFilter"),Uu.desc="has response";function la(w){return w.type==="tcp"}o(la,"tcpFilter"),la.desc="is a TCP Flow";function qn(w){return w.type==="udp"}o(qn,"udpFilter"),qn.desc="is a UDP Flow";function Ti(w){w=new RegExp(w,"i");function T(W){return W.request&&w.test(Oo.getContentType(W.request))}return o(T,"requestContentTypeFilter"),T.desc="req. content type matches "+w,T}o(Ti,"requestContentType");function pc(w){w=new RegExp(w,"i");function T(W){return W.response&&w.test(Ys.getContentType(W.response))}return o(T,"responseContentTypeFilter"),T.desc="resp. content type matches "+w,T}o(pc,"responseContentType");function aa(w){w=new RegExp(w,"i");function T(W){return W.request&&w.test(Oo.getContentType(W.request))||W.response&&w.test(Ys.getContentType(W.response))}return o(T,"contentTypeFilter"),T.desc="content type matches "+w,T}o(aa,"contentType");function dc(w){w=new RegExp(w,"i");function T(W){var U;if(W.type==="dns"){let wr=(U=W.request)==null?void 0:U.questions[0];return wr&&w.test(wr.name)}return W.request&&w.test(Oo.pretty_url(W.request))}return o(T,"urlFilter"),T.desc="url matches "+w,T}o(dc,"url");function Vi(w){return!!w.websocket}if(o(Vi,"websocketFilter"),Vi.desc="is a Websocket Flow",jo=C(),jo!==c&&P===l.length)return jo;throw jo!==c&&PwS,icon:()=>L0,method:()=>tm,path:()=>P0,quickactions:()=>Pp,size:()=>O0,status:()=>nm,time:()=>M0,timestamp:()=>A0,tls:()=>N0,version:()=>rm});var Xt=fe(Oe());var k0=fe(ti());var N0=o(({flow:e})=>Xt.default.createElement("td",{className:(0,k0.default)("col-tls",e.client_conn.tls_established?"col-tls-https":"col-tls-http")}),"tls");N0.headerName="";N0.sortKey=e=>e.type==="http"&&e.request.scheme;var L0=o(({flow:e})=>Xt.default.createElement("td",{className:"col-icon"},Xt.default.createElement("div",{className:(0,k0.default)("resource-icon",Gk(e))})),"icon");L0.headerName="";L0.sortKey=e=>Gk(e);var Gk=o(e=>{if(e.type!=="http")return e.client_conn.tls_version==="QUIC"?"resource-icon-quic":`resource-icon-${e.type}`;if(e.websocket)return"resource-icon-websocket";if(!e.response)return"resource-icon-plain";var t=Ys.getContentType(e.response)||"";return e.response.status_code===304?"resource-icon-not-modified":300<=e.response.status_code&&e.response.status_code<400?"resource-icon-redirect":t.indexOf("image")>=0?"resource-icon-image":t.indexOf("javascript")>=0?"resource-icon-js":t.indexOf("css")>=0?"resource-icon-css":t.indexOf("html")>=0?"resource-icon-document":"resource-icon-plain"},"getIcon"),Yk=o(e=>{var t,n,l,d;switch(e.type){case"http":return Oo.pretty_url(e.request);case"tcp":case"udp":return`${e.client_conn.peername.join(":")} \u2194 ${(n=(t=e.server_conn)==null?void 0:t.address)==null?void 0:n.join(":")}`;case"dns":return`${e.request.questions.map(h=>`${h.name} ${h.type}`).join(", ")} = ${((d=(l=e.response)==null?void 0:l.answers.map(h=>h.data).join(", "))!=null?d:"...")||"?"}`}},"mainPath"),P0=o(({flow:e})=>{let t;return e.error&&(e.error.msg==="Connection killed."?t=Xt.default.createElement("i",{className:"fa fa-fw fa-times pull-right"}):t=Xt.default.createElement("i",{className:"fa fa-fw fa-exclamation pull-right"})),Xt.default.createElement("td",{className:"col-path"},e.is_replay==="request"&&Xt.default.createElement("i",{className:"fa fa-fw fa-repeat pull-right"}),e.intercepted&&Xt.default.createElement("i",{className:"fa fa-fw fa-pause pull-right"}),t,Xt.default.createElement("span",{className:"marker pull-right"},e.marked),Yk(e))},"path");P0.headerName="Path";P0.sortKey=e=>Yk(e);var tm=o(({flow:e})=>Xt.default.createElement("td",{className:"col-method"},tm.sortKey(e)),"method");tm.headerName="Method";tm.sortKey=e=>{switch(e.type){case"http":return e.websocket?e.client_conn.tls_established?"WSS":"WS":e.request.method;case"dns":return e.request.op_code;default:return e.type.toUpperCase()}};var rm=o(({flow:e})=>Xt.default.createElement("td",{className:"col-http-version"},rm.sortKey(e)),"version");rm.headerName="Version";rm.sortKey=e=>{switch(e.type){case"http":return e.request.http_version;default:return""}};var nm=o(({flow:e})=>{let t="darkred";return e.type!=="http"&&e.type!="dns"||!e.response?Xt.default.createElement("td",{className:"col-status"}):(100<=e.response.status_code&&e.response.status_code<200?t="green":200<=e.response.status_code&&e.response.status_code<300?t="darkgreen":300<=e.response.status_code&&e.response.status_code<400?t="lightblue":(400<=e.response.status_code&&e.response.status_code<500||500<=e.response.status_code&&e.response.status_code<600)&&(t="red"),Xt.default.createElement("td",{className:"col-status",style:{color:t}},nm.sortKey(e)))},"status");nm.headerName="Status";nm.sortKey=e=>{var t,n;switch(e.type){case"http":return(t=e.response)==null?void 0:t.status_code;case"dns":return(n=e.response)==null?void 0:n.response_code;default:return}};var O0=o(({flow:e})=>Xt.default.createElement("td",{className:"col-size"},S0(yS(e))),"size");O0.headerName="Size";O0.sortKey=e=>yS(e);var M0=o(({flow:e})=>{let t=em(e),n=vS(e);return Xt.default.createElement("td",{className:"col-time"},t&&n?C0(1e3*(n-t)):"...")},"time");M0.headerName="Time";M0.sortKey=e=>{let t=em(e),n=vS(e);return t&&n&&n-t};var A0=o(({flow:e})=>{let t=em(e);return Xt.default.createElement("td",{className:"col-timestamp"},t?no(t):"...")},"timestamp");A0.headerName="Start time";A0.sortKey=e=>em(e);var Pp=o(({flow:e})=>{let t=Gs(),[n,l]=(0,Xt.useState)(!1),d=null;return e.intercepted?d=Xt.default.createElement("a",{href:"#",className:"quickaction",onClick:()=>t(Op(e))},Xt.default.createElement("i",{className:"fa fa-fw fa-play text-success"})):_0(e)&&(d=Xt.default.createElement("a",{href:"#",className:"quickaction",onClick:()=>t(Mp(e))},Xt.default.createElement("i",{className:"fa fa-fw fa-repeat text-primary"}))),Xt.default.createElement("td",{className:(0,k0.default)("col-quickactions",{hover:n}),onClick:()=>0},d?Xt.default.createElement("div",null,d):Xt.default.createElement(Xt.default.Fragment,null))},"quickactions");Pp.headerName="";Pp.sortKey=e=>0;var wS={icon:L0,method:tm,version:rm,path:P0,quickactions:Pp,size:O0,status:nm,time:M0,timestamp:A0,tls:N0};var _F="FLOWS_ADD",TF="FLOWS_UPDATE",Xk="FLOWS_REMOVE",kF="FLOWS_RECEIVE",Qk="FLOWS_SELECT",Zk="FLOWS_SET_FILTER",Jk="FLOWS_SET_SORT",eN="FLOWS_SET_HIGHLIGHT",NF=ke({highlight:void 0,filter:void 0,sort:{column:void 0,desc:!1},selected:[]},b0);function xS(e=NF,t){switch(t.type){case _F:case TF:case Xk:case kF:let n=Jh[t.cmd](t.data,tN(e.filter),SS(e.sort)),l=e.selected;if(t.type===Xk&&e.selected.includes(t.data)){if(e.selected.length>1)l=l.filter(d=>d!==t.data);else if(l=[],t.data in e.viewIndex&&e.view.length>1){let d=e.viewIndex[t.data],h;d===e.view.length-1?h=e.view[d-1]:h=e.view[d+1],l.push(h.id)}}return ke(Pt(ke({},e),{selected:l}),Lp(e,n));case Zk:return ke(Pt(ke({},e),{filter:t.filter}),Lp(e,dS(tN(t.filter),SS(e.sort))));case eN:return Pt(ke({},e),{highlight:t.highlight});case Jk:return ke(Pt(ke({},e),{sort:t.sort}),Lp(e,qk(SS(t.sort))));case Qk:return Pt(ke({},e),{selected:t.flowIds});default:return e}}o(xS,"reducer");function tN(e){if(!!e)return Of.parse(e)}o(tN,"makeFilter");function SS({column:e,desc:t}){if(!e)return(l,d)=>0;let n=wS[e].sortKey;return(l,d)=>{let h=n(l),c=n(d);return h>c?t?-1:1:hkt(`/flows/${e.id}/resume`,{method:"POST"})}o(Op,"resume");function I0(){return e=>kt("/flows/resume",{method:"POST"})}o(I0,"resumeAll");function F0(e){return t=>kt(`/flows/${e.id}/kill`,{method:"POST"})}o(F0,"kill");function nN(){return e=>kt("/flows/kill",{method:"POST"})}o(nN,"killAll");function B0(e){return t=>kt(`/flows/${e.id}`,{method:"DELETE"})}o(B0,"remove");function H0(e){return t=>kt(`/flows/${e.id}/duplicate`,{method:"POST"})}o(H0,"duplicate");function Mp(e){return t=>kt(`/flows/${e.id}/replay`,{method:"POST"})}o(Mp,"replay");function W0(e){return t=>kt(`/flows/${e.id}/revert`,{method:"POST"})}o(W0,"revert");function Wi(e,t){return n=>kt.put(`/flows/${e.id}`,t)}o(Wi,"update");function iN(e,t,n){let l=new FormData;return t=new window.Blob([t],{type:"plain/text"}),l.append("file",t),d=>kt(`/flows/${e.id}/${n}/content.data`,{method:"POST",body:l})}o(iN,"uploadContent");function U0(){return e=>kt("/clear",{method:"POST"})}o(U0,"clear");function oN(e){let t=new FormData;return t.append("file",e),n=>kt("/flows/dump",{method:"POST",body:t})}o(oN,"upload");function Af(e){return{type:Qk,flowIds:e?[e]:[]}}o(Af,"select");var z0="UI_HIDE_MODAL",sN="UI_SET_ACTIVE_MODAL",LF={activeModal:void 0};function CS(e=LF,t){switch(t.type){case sN:return Pt(ke({},e),{activeModal:t.activeModal});case z0:return Pt(ke({},e),{activeModal:void 0});default:return e}}o(CS,"reducer");function lN(e){return{type:sN,activeModal:e}}o(lN,"setActiveModal");function $0(){return{type:z0}}o($0,"hideModal");var wm=fe(Oe());var Ut=fe(Oe());var Dp=fe(Oe());var om=fe(Oe()),aN=fe(ti()),uN=(()=>{let e=document.createElement("div");return e.setAttribute("contenteditable","PLAINTEXT-ONLY"),e.contentEditable==="plaintext-only"?"plaintext-only":"true"})(),Ap=!1,Xs=class extends om.Component{constructor(){super(...arguments);this.input=om.default.createRef();this.isEditing=o(()=>{var t;return((t=this.input.current)==null?void 0:t.contentEditable)===uN},"isEditing");this.startEditing=o(()=>{if(!this.input.current)return console.error("unreachable");this.isEditing()||(this.suppress_events=!0,this.input.current.blur(),this.input.current.contentEditable=uN,window.requestAnimationFrame(()=>{var l,d;if(!this.input.current)return;this.input.current.focus(),this.suppress_events=!1;let t=document.createRange();t.selectNodeContents(this.input.current);let n=window.getSelection();n==null||n.removeAllRanges(),n==null||n.addRange(t),(d=(l=this.props).onEditStart)==null||d.call(l)}))},"startEditing");this.resetValue=o(()=>{var t,n;if(!this.input.current)return console.error("unreachable");this.input.current.textContent=this.props.content,(n=(t=this.props).onInput)==null||n.call(t,this.props.content)},"resetValue");this.finishEditing=o(()=>{if(!this.input.current)return console.error("unreachable");this.props.onEditDone(this.input.current.textContent||""),this.input.current.blur(),this.input.current.contentEditable="inherit"},"finishEditing");this.onPaste=o(t=>{t.preventDefault();let n=t.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,n)},"onPaste");this.suppress_events=!1;this.onMouseDown=o(t=>{Ap&&console.debug("onMouseDown",this.suppress_events),this.suppress_events=!0,window.addEventListener("mouseup",this.onMouseUp,{once:!0})},"onMouseDown");this.onMouseUp=o(t=>{var d;let n=t.target===this.input.current,l=!((d=window.getSelection())==null?void 0:d.toString());Ap&&console.warn("mouseUp",this.suppress_events,n,l),n&&l&&this.startEditing(),this.suppress_events=!1},"onMouseUp");this.onClick=o(t=>{Ap&&console.debug("onClick",this.suppress_events)},"onClick");this.onFocus=o(t=>{if(Ap&&console.debug("onFocus",this.props.content,this.suppress_events),!this.input.current)throw"unreachable";this.suppress_events||this.startEditing()},"onFocus");this.onInput=o(t=>{var n,l,d;(d=(l=this.props).onInput)==null||d.call(l,((n=this.input.current)==null?void 0:n.textContent)||"")},"onInput");this.onBlur=o(t=>{Ap&&console.debug("onBlur",this.props.content,this.suppress_events),!this.suppress_events&&this.finishEditing()},"onBlur");this.onKeyDown=o(t=>{var n,l;switch(Ap&&console.debug("keydown",t),t.stopPropagation(),t.key){case"Escape":t.preventDefault(),this.resetValue(),this.finishEditing();break;case"Enter":t.shiftKey||(t.preventDefault(),this.finishEditing());break;default:break}(l=(n=this.props).onKeyDown)==null||l.call(n,t)},"onKeyDown")}render(){let t=(0,aN.default)("inline-input",this.props.className);return om.default.createElement("span",{ref:this.input,tabIndex:0,className:t,placeholder:this.props.placeholder,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onInput:this.onInput,onPaste:this.onPaste,onMouseDown:this.onMouseDown,onClick:this.onClick},this.props.content)}componentDidUpdate(t){var n,l;t.content!==this.props.content&&((l=(n=this.props).onInput)==null||l.call(n,this.props.content))}};o(Xs,"ValueEditor");var fN=fe(ti());function Df(e){let[t,n]=(0,Dp.useState)(e.isValid(e.content)),l=(0,Dp.useRef)(null),d=o(c=>{var v;e.isValid(c)?e.onEditDone(c):(v=l.current)==null||v.resetValue()},"onEditDone"),h=(0,fN.default)(e.className,t?"has-success":"has-warning");return Dp.default.createElement(Xs,Pt(ke({},e),{className:h,onInput:c=>n(e.isValid(c)),onEditDone:d,ref:l}))}o(Df,"ValidateEditor");function bS(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}o(bS,"_defineProperty");function cN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(d){return Object.getOwnPropertyDescriptor(e,d).enumerable})),n.push.apply(n,l)}return n}o(cN,"ownKeys");function j0(e){for(var t=1;tn[l.level])));case hN:case MF:return ke(ke({},e),Lp(e,Jh[t.cmd](t.data,l=>e.filters[l.level])));default:return e}}o(kS,"reduce");function vN(e){return{type:gN,filter:e}}o(vN,"toggleFilter");function Rp(){return{type:mN}}o(Rp,"toggleVisibility");function yN(e,t="web"){let n={id:Math.random().toString(),message:e,level:t};return{type:hN,cmd:"add",data:n}}o(yN,"add");var wN="UI_OPTION_UPDATE_START",xN="UI_OPTION_UPDATE_SUCCESS",SN="UI_OPTION_UPDATE_ERROR",DF={};function NS(e=DF,t){switch(t.type){case wN:return Pt(ke({},e),{[t.option]:{isUpdating:!0,value:t.value,error:!1}});case xN:return Pt(ke({},e),{[t.option]:void 0});case SN:let n=e[t.option].value;return typeof n=="boolean"&&(n=!n),Pt(ke({},e),{[t.option]:{value:n,isUpdating:!1,error:t.error}});case z0:return{};default:return e}}o(NS,"reducer");function CN(e,t){return{type:wN,option:e,value:t}}o(CN,"startUpdate");function bN(e){return{type:xN,option:e}}o(bN,"updateSuccess");function EN(e,t){return{type:SN,option:e,error:t}}o(EN,"updateError");var _N=V0({flow:rS,modal:CS,optionsEditor:NS});var ni;(function(h){h.INIT="CONNECTION_INIT",h.FETCHING="CONNECTION_FETCHING",h.ESTABLISHED="CONNECTION_ESTABLISHED",h.ERROR="CONNECTION_ERROR",h.OFFLINE="CONNECTION_OFFLINE"})(ni||(ni={}));var RF={state:ni.INIT,message:void 0};function LS(e=RF,t){switch(t.type){case ni.ESTABLISHED:case ni.FETCHING:case ni.ERROR:case ni.OFFLINE:return{state:t.type,message:t.message};default:return e}}o(LS,"reducer");function TN(){return{type:ni.FETCHING}}o(TN,"startFetching");function kN(){return{type:ni.ESTABLISHED}}o(kN,"connectionEstablished");function NN(e){return{type:ni.ERROR,message:e}}o(NN,"connectionError");var LN={add_upstream_certs_to_client_chain:!1,allow_hosts:[],anticache:!1,anticomp:!1,block_global:!0,block_list:[],block_private:!1,body_size_limit:void 0,cert_passphrase:void 0,certs:[],ciphers_client:void 0,ciphers_server:void 0,client_certs:void 0,client_replay:[],client_replay_concurrency:1,command_history:!0,confdir:"~/.mitmproxy",connect_addr:void 0,connection_strategy:"eager",console_focus_follow:!1,content_view_lines_cutoff:512,export_preserve_original_ip:!1,hardump:"",http2:!0,http2_ping_keepalive:58,http3:!0,ignore_hosts:[],intercept:void 0,intercept_active:!1,keep_host_header:!1,key_size:2048,listen_host:"",listen_port:void 0,map_local:[],map_remote:[],mode:["regular"],modify_body:[],modify_headers:[],normalize_outbound_headers:!0,onboarding:!0,onboarding_host:"mitm.it",proxy_debug:!1,proxyauth:void 0,rawtcp:!0,readfile_filter:void 0,rfile:void 0,save_stream_file:void 0,save_stream_filter:void 0,scripts:[],server:!0,server_replay:[],server_replay_extra:"forward",server_replay_ignore_content:!1,server_replay_ignore_host:!1,server_replay_ignore_params:[],server_replay_ignore_payload_params:[],server_replay_ignore_port:!1,server_replay_kill_extra:!1,server_replay_nopop:!1,server_replay_refresh:!0,server_replay_reuse:!1,server_replay_use_headers:[],showhost:!1,ssl_insecure:!1,ssl_verify_upstream_trusted_ca:void 0,ssl_verify_upstream_trusted_confdir:void 0,stickyauth:void 0,stickycookie:void 0,stream_large_bodies:void 0,tcp_hosts:[],termlog_verbosity:"info",tls_ecdh_curve_client:void 0,tls_ecdh_curve_server:void 0,tls_version_client_max:"UNBOUNDED",tls_version_client_min:"TLS1_2",tls_version_server_max:"UNBOUNDED",tls_version_server_min:"TLS1_2",udp_hosts:[],upstream_auth:void 0,upstream_cert:!0,validate_inbound_headers:!0,view_filter:void 0,view_order:"time",view_order_reversed:!1,web_columns:["tls","icon","path","method","status","size","time"],web_debug:!1,web_host:"127.0.0.1",web_open_browser:!0,web_port:8081,web_static_viewer:"",websocket:!0};var PS="OPTIONS_RECEIVE",OS="OPTIONS_UPDATE";function MS(e=LN,t){switch(t.type){case PS:let n={};for(let[d,{value:h}]of Object.entries(t.data))n[d]=h;return n;case OS:let l=ke({},e);for(let[d,{value:h}]of Object.entries(t.data))l[d]=h;return l;default:return e}}o(MS,"reducer");function IF(e,t,n){return Ia(this,null,function*(){try{let l=yield kt.put("/options",{[e]:t});if(l.status===200)n(bN(e));else throw yield l.text()}catch(l){n(EN(e,l))}})}o(IF,"pureSendUpdate");var FF=IF;function Ip(e,t){return n=>{n(CN(e,t)),FF(e,t,n)}}o(Ip,"update");function PN(){return e=>kt("/options/save",{method:"POST"})}o(PN,"save");var ON="COMMANDBAR_TOGGLE_VISIBILITY",BF={visible:!1};function AS(e=BF,t){switch(t.type){case ON:return Pt(ke({},e),{visible:!e.visible});default:return e}}o(AS,"reducer");function K0(){return{type:ON}}o(K0,"toggleVisibility");function MN(e){return function(t){var n=t.dispatch,l=t.getState;return function(d){return function(h){return typeof h=="function"?h(n,l,e):d(h)}}}}o(MN,"createThunkMiddleware");var AN=MN();AN.withExtraArgument=MN;var DN=AN;var HF="STATE_RECEIVE",WF="STATE_UPDATE",UF={available:!1,version:"",contentViews:[],servers:[]};function DS(e=UF,t){switch(t.type){case HF:case WF:return ke(Pt(ke({},e),{available:!0}),t.data);default:return e}}o(DS,"reducer");var zF={},$F=o((e=zF,t)=>{switch(t.type){case PS:return t.data;case OS:return ke(ke({},e),t.data);default:return e}},"reducer"),RN=$F;var jF=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__||TS,qF=V0({commandBar:AS,eventLog:kS,flows:xS,connection:LS,ui:_N,options:MS,options_meta:RN,backendState:DS}),VF=o(e=>_S(qF,e,jF(dN(DN))),"createAppStore"),Fp=VF(void 0),Qt=o(()=>Gs(),"useAppDispatch"),qe=eS;var io=fe(Oe());var IN=fe(Qh()),FN=fe(ti()),RS=class extends io.Component{constructor(){super(...arguments);this.container=io.default.createRef();this.nameInput=io.default.createRef();this.valueInput=io.default.createRef();this.render=o(()=>{let[t,n]=this.props.item;return io.default.createElement("div",{ref:this.container,className:"kv-row",onClick:this.onClick,onKeyDownCapture:this.onKeyDown},io.default.createElement(Xs,{ref:this.nameInput,className:"kv-key",content:t,onEditStart:this.props.onEditStart,onEditDone:l=>this.props.onEditDone([l,n])}),":\xA0",io.default.createElement(Xs,{ref:this.valueInput,className:"kv-value",content:n,onEditStart:this.props.onEditStart,onEditDone:l=>this.props.onEditDone([t,l]),placeholder:"empty"}))},"render");this.onClick=o(t=>{t.target===this.container.current&&this.props.onClickEmptyArea()},"onClick");this.onKeyDown=o(t=>{var n;t.target===((n=this.valueInput.current)==null?void 0:n.input.current)&&t.key==="Tab"&&this.props.onTabNext()},"onKeyDown")}};o(RS,"Row");var Bp=class extends io.Component{constructor(){super(...arguments);this.rowRefs={};this.state={currentList:this.props.data||[],initialList:this.props.data};this.render=o(()=>{this.rowRefs={};let t=this.state.currentList.map((n,l)=>io.default.createElement(RS,{key:l,item:n,onEditStart:()=>this.currentlyEditing=l,onEditDone:d=>this.onEditDone(l,d),onClickEmptyArea:()=>this.onClickEmptyArea(l),onTabNext:()=>this.onTabNext(l),ref:d=>this.rowRefs[l]=d}));return io.default.createElement("div",{className:(0,FN.default)("kv-editor",this.props.className),onMouseDown:this.onMouseDown},t,io.default.createElement("div",{onClick:n=>{n.preventDefault(),this.onClickEmptyArea(this.state.currentList.length-1)},className:"kv-add-row fa fa-plus-square-o",role:"button","aria-label":"Add"}))},"render");this.onEditDone=o((t,n)=>{let l=[...this.state.currentList];n[0]?l[t]=n:l.splice(t,1),this.currentlyEditing=void 0,(0,IN.isEqual)(this.state.currentList,l)||this.props.onChange(l),this.setState({currentList:l})},"onEditDone");this.onClickEmptyArea=o(t=>{if(this.justFinishedEditing)return;let n=[...this.state.currentList];n.splice(t+1,0,["",""]),this.setState({currentList:n},()=>{var l,d;return(d=(l=this.rowRefs[t+1])==null?void 0:l.nameInput.current)==null?void 0:d.startEditing()})},"onClickEmptyArea");this.onTabNext=o(t=>{t==this.state.currentList.length-1&&this.onClickEmptyArea(t)},"onTabNext");this.onMouseDown=o(t=>{this.justFinishedEditing=this.currentlyEditing},"onMouseDown")}static getDerivedStateFromProps(t,n){return t.data!==n.initialList?{currentList:t.data||[],initialList:t.data}:null}};o(Bp,"KeyValueListEditor");var tr=fe(Oe());var sm=fe(Oe());function G0(e,t){let[n,l]=(0,sm.useState)(),[d,h]=(0,sm.useState)();return(0,sm.useEffect)(()=>{d&&d.abort();let c=new AbortController;return kt(e,{signal:c.signal}).then(v=>{if(!v.ok)throw`${v.status} ${v.statusText}`.trim();return v.text()}).then(v=>{l(v)}).catch(v=>{c.signal.aborted||l(`Error getting content: ${v}.`)}),h(c),()=>{c.signal.aborted||c.abort()}},[e,t]),n}o(G0,"useContent");var lm=fe(Oe()),Y0=lm.default.memo(o(function({icon:t,text:n,className:l,title:d,onOpenFile:h,onClick:c}){let v;return lm.default.createElement("a",{href:"#",onClick:C=>{v.click(),c&&c(C)},className:l,title:d},lm.default.createElement("i",{className:"fa fa-fw "+t}),n,lm.default.createElement("input",{ref:C=>v=C,className:"hidden",type:"file",onChange:C=>{C.preventDefault(),C.target.files&&C.target.files.length>0&&h(C.target.files[0]),v.value=""}}))},"FileChooser"));var Hp=fe(Oe()),BN=fe(ti());function kr({onClick:e,children:t,icon:n,disabled:l,className:d,title:h}){return Hp.createElement("button",{className:(0,BN.default)(d,"btn btn-default"),onClick:l?void 0:e,disabled:l,title:h},n&&Hp.createElement(Hp.Fragment,null,Hp.createElement("i",{className:"fa "+n}),"\xA0"),t)}o(kr,"Button");var um=fe(Oe()),jN=fe(Oe());var am=fe(Oe()),WN=fe(ti()),UN=fe(HN()),zN=fe(Qh());function $N(e){return e&&e.replace(/\r\n|\r/g,` -`)}o($N,"normalizeLineEndings");var Wp=class extends am.Component{constructor(t){super(t);this.state={isFocused:!1}}getCodeMirrorInstance(){return this.props.codeMirrorInstance||UN.default}UNSAFE_componentWillMount(){this.props.path&&console.error("Warning: react-codemirror: the `path` prop has been changed to `name`")}componentDidMount(){let t=this.getCodeMirrorInstance();this.codeMirror=t.fromTextArea(this.textareaNode,this.props.options),this.codeMirror.on("change",this.codemirrorValueChanged.bind(this)),this.codeMirror.on("cursorActivity",this.cursorActivity.bind(this)),this.codeMirror.on("focus",this.focusChanged.bind(this,!0)),this.codeMirror.on("blur",this.focusChanged.bind(this,!1)),this.codeMirror.on("scroll",this.scrollChanged.bind(this)),this.codeMirror.setValue(this.props.defaultValue||this.props.value||"")}componentWillUnmount(){this.codeMirror&&this.codeMirror.toTextArea()}UNSAFE_componentWillReceiveProps(t){if(this.codeMirror&&t.value!==void 0&&t.value!==this.props.value&&$N(this.codeMirror.getValue())!==$N(t.value))if(this.props.preserveScrollPosition){var n=this.codeMirror.getScrollInfo();this.codeMirror.setValue(t.value),this.codeMirror.scrollTo(n.left,n.top)}else this.codeMirror.setValue(t.value);if(typeof t.options=="object")for(let l in t.options)t.options.hasOwnProperty(l)&&this.setOptionIfChanged(l,t.options[l])}setOptionIfChanged(t,n){let l=this.codeMirror.getOption(t);zN.default.isEqual(l,n)||this.codeMirror.setOption(t,n)}getCodeMirror(){return this.codeMirror}focus(){this.codeMirror&&this.codeMirror.focus()}focusChanged(t){this.setState({isFocused:t}),this.props.onFocusChange&&this.props.onFocusChange(t)}cursorActivity(t){this.props.onCursorActivity&&this.props.onCursorActivity(t)}scrollChanged(t){this.props.onScroll&&this.props.onScroll(t.getScrollInfo())}codemirrorValueChanged(t,n){this.props.onChange&&n.origin!=="setValue"&&this.props.onChange(t.getValue(),n)}render(){let t=(0,WN.default)("ReactCodeMirror",this.state.isFocused?"ReactCodeMirror--focused":null,this.props.className);return am.createElement("div",{className:t},am.createElement("textarea",{ref:n=>this.textareaNode=n,name:this.props.name||this.props.path,defaultValue:this.props.value,autoComplete:"off",autoFocus:this.props.autoFocus}))}};o(Wp,"CodeMirror"),Wp.defaultProps={preserveScrollPosition:!1};var fm=class extends jN.Component{constructor(){super(...arguments);this.editor=um.createRef();this.getContent=o(()=>{var t;return(t=this.editor.current)==null?void 0:t.codeMirror.getValue()},"getContent");this.render=o(()=>{let t={lineNumbers:!0};return um.createElement("div",{className:"codeeditor",onKeyDown:n=>n.stopPropagation()},um.createElement(Wp,{ref:this.editor,value:this.props.initialContent,onChange:()=>0,options:t}))},"render")}};o(fm,"CodeEditor");var Rf=fe(Oe()),KF=Rf.default.memo(o(function({lines:t,maxLines:n,showMore:l}){return t.length===0?null:Rf.default.createElement("pre",null,t.map((d,h)=>h===n?Rf.default.createElement("button",{key:"showmore",onClick:l,className:"btn btn-xs btn-info"},Rf.default.createElement("i",{className:"fa fa-angle-double-down","aria-hidden":"true"})," ","Show more"):Rf.default.createElement("div",{key:h},d.map(([c,v],C)=>Rf.default.createElement("span",{key:C,className:c},v)))))},"LineRenderer")),X0=KF;var zf=fe(Oe());var xi=fe(Oe());var Q0=fe(Oe());var BS=o(function(t){return t.reduce(function(n,l){var d=l[0],h=l[1];return n[d]=h,n},{})},"fromEntries"),HS=typeof window!="undefined"&&window.document&&window.document.createElement?Q0.useLayoutEffect:Q0.useEffect;var fu=fe(Oe());var Gr="top",Ln="bottom",ln="right",an="left",Z0="auto",su=[Gr,Ln,ln,an],Rl="start",J0="end",qN="clippingParents",ey="viewport",Up="popper",VN="reference",WS=su.reduce(function(e,t){return e.concat([t+"-"+Rl,t+"-"+J0])},[]),ty=[].concat(su,[Z0]).reduce(function(e,t){return e.concat([t,t+"-"+Rl,t+"-"+J0])},[]),GF="beforeRead",YF="read",XF="afterRead",QF="beforeMain",ZF="main",JF="afterMain",e3="beforeWrite",t3="write",r3="afterWrite",KN=[GF,YF,XF,QF,ZF,JF,e3,t3,r3];function Pn(e){return e?(e.nodeName||"").toLowerCase():null}o(Pn,"getNodeName");function Br(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}o(Br,"getWindow");function Il(e){var t=Br(e).Element;return e instanceof t||e instanceof Element}o(Il,"isElement");function Yr(e){var t=Br(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}o(Yr,"isHTMLElement");function ry(e){if(typeof ShadowRoot=="undefined")return!1;var t=Br(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}o(ry,"isShadowRoot");function n3(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var l=t.styles[n]||{},d=t.attributes[n]||{},h=t.elements[n];!Yr(h)||!Pn(h)||(Object.assign(h.style,l),Object.keys(d).forEach(function(c){var v=d[c];v===!1?h.removeAttribute(c):h.setAttribute(c,v===!0?"":v)}))})}o(n3,"applyStyles");function i3(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(l){var d=t.elements[l],h=t.attributes[l]||{},c=Object.keys(t.styles.hasOwnProperty(l)?t.styles[l]:n[l]),v=c.reduce(function(C,k){return C[k]="",C},{});!Yr(d)||!Pn(d)||(Object.assign(d.style,v),Object.keys(h).forEach(function(C){d.removeAttribute(C)}))})}}o(i3,"effect");var GN={name:"applyStyles",enabled:!0,phase:"write",fn:n3,effect:i3,requires:["computeStyles"]};function On(e){return e.split("-")[0]}o(On,"getBasePlacement");var lu=Math.round;function Mo(e,t){t===void 0&&(t=!1);var n=e.getBoundingClientRect(),l=1,d=1;return Yr(e)&&t&&(l=n.width/e.offsetWidth||1,d=n.height/e.offsetHeight||1),{width:lu(n.width/l),height:lu(n.height/d),top:lu(n.top/d),right:lu(n.right/l),bottom:lu(n.bottom/d),left:lu(n.left/l),x:lu(n.left/l),y:lu(n.top/d)}}o(Mo,"getBoundingClientRect");function If(e){var t=Mo(e),n=e.offsetWidth,l=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-l)<=1&&(l=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:l}}o(If,"getLayoutRect");function cm(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&ry(n)){var l=t;do{if(l&&e.isSameNode(l))return!0;l=l.parentNode||l.host}while(l)}return!1}o(cm,"contains");function wi(e){return Br(e).getComputedStyle(e)}o(wi,"getComputedStyle");function US(e){return["table","td","th"].indexOf(Pn(e))>=0}o(US,"isTableElement");function Bn(e){return((Il(e)?e.ownerDocument:e.document)||window.document).documentElement}o(Bn,"getDocumentElement");function Fl(e){return Pn(e)==="html"?e:e.assignedSlot||e.parentNode||(ry(e)?e.host:null)||Bn(e)}o(Fl,"getParentNode");function YN(e){return!Yr(e)||wi(e).position==="fixed"?null:e.offsetParent}o(YN,"getTrueOffsetParent");function o3(e){var t=navigator.userAgent.toLowerCase().indexOf("firefox")!==-1,n=navigator.userAgent.indexOf("Trident")!==-1;if(n&&Yr(e)){var l=wi(e);if(l.position==="fixed")return null}for(var d=Fl(e);Yr(d)&&["html","body"].indexOf(Pn(d))<0;){var h=wi(d);if(h.transform!=="none"||h.perspective!=="none"||h.contain==="paint"||["transform","perspective"].indexOf(h.willChange)!==-1||t&&h.willChange==="filter"||t&&h.filter&&h.filter!=="none")return d;d=d.parentNode}return null}o(o3,"getContainingBlock");function as(e){for(var t=Br(e),n=YN(e);n&&US(n)&&wi(n).position==="static";)n=YN(n);return n&&(Pn(n)==="html"||Pn(n)==="body"&&wi(n).position==="static")?t:n||o3(e)||t}o(as,"getOffsetParent");function Ff(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}o(Ff,"getMainAxisFromPlacement");var Ao=Math.max,au=Math.min,pm=Math.round;function Bf(e,t,n){return Ao(e,au(t,n))}o(Bf,"within");function dm(){return{top:0,right:0,bottom:0,left:0}}o(dm,"getFreshSideObject");function hm(e){return Object.assign({},dm(),e)}o(hm,"mergePaddingObject");function mm(e,t){return t.reduce(function(n,l){return n[l]=e,n},{})}o(mm,"expandToHashMap");var s3=o(function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,hm(typeof t!="number"?t:mm(t,su))},"toPaddingObject");function l3(e){var t,n=e.state,l=e.name,d=e.options,h=n.elements.arrow,c=n.modifiersData.popperOffsets,v=On(n.placement),C=Ff(v),k=[an,ln].indexOf(v)>=0,O=k?"height":"width";if(!(!h||!c)){var j=s3(d.padding,n),B=If(h),X=C==="y"?Gr:an,J=C==="y"?Ln:ln,Z=n.rects.reference[O]+n.rects.reference[C]-c[C]-n.rects.popper[O],R=c[C]-n.rects.reference[C],A=as(h),I=A?C==="y"?A.clientHeight||0:A.clientWidth||0:0,G=Z/2-R/2,K=j[X],se=I-B[O]-j[J],ne=I/2-B[O]/2+G,pe=Bf(K,ne,se),me=C;n.modifiersData[l]=(t={},t[me]=pe,t.centerOffset=pe-ne,t)}}o(l3,"arrow");function a3(e){var t=e.state,n=e.options,l=n.element,d=l===void 0?"[data-popper-arrow]":l;d!=null&&(typeof d=="string"&&(d=t.elements.popper.querySelector(d),!d)||!cm(t.elements.popper,d)||(t.elements.arrow=d))}o(a3,"effect");var XN={name:"arrow",enabled:!0,phase:"main",fn:l3,effect:a3,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};var u3={top:"auto",right:"auto",bottom:"auto",left:"auto"};function f3(e){var t=e.x,n=e.y,l=window,d=l.devicePixelRatio||1;return{x:pm(pm(t*d)/d)||0,y:pm(pm(n*d)/d)||0}}o(f3,"roundOffsetsByDPR");function QN(e){var t,n=e.popper,l=e.popperRect,d=e.placement,h=e.offsets,c=e.position,v=e.gpuAcceleration,C=e.adaptive,k=e.roundOffsets,O=k===!0?f3(h):typeof k=="function"?k(h):h,j=O.x,B=j===void 0?0:j,X=O.y,J=X===void 0?0:X,Z=h.hasOwnProperty("x"),R=h.hasOwnProperty("y"),A=an,I=Gr,G=window;if(C){var K=as(n),se="clientHeight",ne="clientWidth";K===Br(n)&&(K=Bn(n),wi(K).position!=="static"&&(se="scrollHeight",ne="scrollWidth")),K=K,d===Gr&&(I=Ln,J-=K[se]-l.height,J*=v?1:-1),d===an&&(A=ln,B-=K[ne]-l.width,B*=v?1:-1)}var pe=Object.assign({position:c},C&&u3);if(v){var me;return Object.assign({},pe,(me={},me[I]=R?"0":"",me[A]=Z?"0":"",me.transform=(G.devicePixelRatio||1)<2?"translate("+B+"px, "+J+"px)":"translate3d("+B+"px, "+J+"px, 0)",me))}return Object.assign({},pe,(t={},t[I]=R?J+"px":"",t[A]=Z?B+"px":"",t.transform="",t))}o(QN,"mapToStyles");function c3(e){var t=e.state,n=e.options,l=n.gpuAcceleration,d=l===void 0?!0:l,h=n.adaptive,c=h===void 0?!0:h,v=n.roundOffsets,C=v===void 0?!0:v;if(!1)var k;var O={placement:On(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:d};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,QN(Object.assign({},O,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:c,roundOffsets:C})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,QN(Object.assign({},O,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:C})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}o(c3,"computeStyles");var ZN={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:c3,data:{}};var ny={passive:!0};function p3(e){var t=e.state,n=e.instance,l=e.options,d=l.scroll,h=d===void 0?!0:d,c=l.resize,v=c===void 0?!0:c,C=Br(t.elements.popper),k=[].concat(t.scrollParents.reference,t.scrollParents.popper);return h&&k.forEach(function(O){O.addEventListener("scroll",n.update,ny)}),v&&C.addEventListener("resize",n.update,ny),function(){h&&k.forEach(function(O){O.removeEventListener("scroll",n.update,ny)}),v&&C.removeEventListener("resize",n.update,ny)}}o(p3,"effect");var JN={name:"eventListeners",enabled:!0,phase:"write",fn:o(function(){},"fn"),effect:p3,data:{}};var d3={left:"right",right:"left",bottom:"top",top:"bottom"};function zp(e){return e.replace(/left|right|bottom|top/g,function(t){return d3[t]})}o(zp,"getOppositePlacement");var h3={start:"end",end:"start"};function iy(e){return e.replace(/start|end/g,function(t){return h3[t]})}o(iy,"getOppositeVariationPlacement");function Hf(e){var t=Br(e),n=t.pageXOffset,l=t.pageYOffset;return{scrollLeft:n,scrollTop:l}}o(Hf,"getWindowScroll");function Wf(e){return Mo(Bn(e)).left+Hf(e).scrollLeft}o(Wf,"getWindowScrollBarX");function zS(e){var t=Br(e),n=Bn(e),l=t.visualViewport,d=n.clientWidth,h=n.clientHeight,c=0,v=0;return l&&(d=l.width,h=l.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(c=l.offsetLeft,v=l.offsetTop)),{width:d,height:h,x:c+Wf(e),y:v}}o(zS,"getViewportRect");function $S(e){var t,n=Bn(e),l=Hf(e),d=(t=e.ownerDocument)==null?void 0:t.body,h=Ao(n.scrollWidth,n.clientWidth,d?d.scrollWidth:0,d?d.clientWidth:0),c=Ao(n.scrollHeight,n.clientHeight,d?d.scrollHeight:0,d?d.clientHeight:0),v=-l.scrollLeft+Wf(e),C=-l.scrollTop;return wi(d||n).direction==="rtl"&&(v+=Ao(n.clientWidth,d?d.clientWidth:0)-h),{width:h,height:c,x:v,y:C}}o($S,"getDocumentRect");function Uf(e){var t=wi(e),n=t.overflow,l=t.overflowX,d=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+d+l)}o(Uf,"isScrollParent");function oy(e){return["html","body","#document"].indexOf(Pn(e))>=0?e.ownerDocument.body:Yr(e)&&Uf(e)?e:oy(Fl(e))}o(oy,"getScrollParent");function uu(e,t){var n;t===void 0&&(t=[]);var l=oy(e),d=l===((n=e.ownerDocument)==null?void 0:n.body),h=Br(l),c=d?[h].concat(h.visualViewport||[],Uf(l)?l:[]):l,v=t.concat(c);return d?v:v.concat(uu(Fl(c)))}o(uu,"listScrollParents");function $p(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}o($p,"rectToClientRect");function m3(e){var t=Mo(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}o(m3,"getInnerBoundingClientRect");function eL(e,t){return t===ey?$p(zS(e)):Yr(t)?m3(t):$p($S(Bn(e)))}o(eL,"getClientRectFromMixedType");function g3(e){var t=uu(Fl(e)),n=["absolute","fixed"].indexOf(wi(e).position)>=0,l=n&&Yr(e)?as(e):e;return Il(l)?t.filter(function(d){return Il(d)&&cm(d,l)&&Pn(d)!=="body"}):[]}o(g3,"getClippingParents");function jS(e,t,n){var l=t==="clippingParents"?g3(e):[].concat(t),d=[].concat(l,[n]),h=d[0],c=d.reduce(function(v,C){var k=eL(e,C);return v.top=Ao(k.top,v.top),v.right=au(k.right,v.right),v.bottom=au(k.bottom,v.bottom),v.left=Ao(k.left,v.left),v},eL(e,h));return c.width=c.right-c.left,c.height=c.bottom-c.top,c.x=c.left,c.y=c.top,c}o(jS,"getClippingRect");function Qs(e){return e.split("-")[1]}o(Qs,"getVariation");function gm(e){var t=e.reference,n=e.element,l=e.placement,d=l?On(l):null,h=l?Qs(l):null,c=t.x+t.width/2-n.width/2,v=t.y+t.height/2-n.height/2,C;switch(d){case Gr:C={x:c,y:t.y-n.height};break;case Ln:C={x:c,y:t.y+t.height};break;case ln:C={x:t.x+t.width,y:v};break;case an:C={x:t.x-n.width,y:v};break;default:C={x:t.x,y:t.y}}var k=d?Ff(d):null;if(k!=null){var O=k==="y"?"height":"width";switch(h){case Rl:C[k]=C[k]-(t[O]/2-n[O]/2);break;case J0:C[k]=C[k]+(t[O]/2-n[O]/2);break;default:}}return C}o(gm,"computeOffsets");function us(e,t){t===void 0&&(t={});var n=t,l=n.placement,d=l===void 0?e.placement:l,h=n.boundary,c=h===void 0?qN:h,v=n.rootBoundary,C=v===void 0?ey:v,k=n.elementContext,O=k===void 0?Up:k,j=n.altBoundary,B=j===void 0?!1:j,X=n.padding,J=X===void 0?0:X,Z=hm(typeof J!="number"?J:mm(J,su)),R=O===Up?VN:Up,A=e.elements.reference,I=e.rects.popper,G=e.elements[B?R:O],K=jS(Il(G)?G:G.contextElement||Bn(e.elements.popper),c,C),se=Mo(A),ne=gm({reference:se,element:I,strategy:"absolute",placement:d}),pe=$p(Object.assign({},I,ne)),me=O===Up?pe:se,xe={top:K.top-me.top+Z.top,bottom:me.bottom-K.bottom+Z.bottom,left:K.left-me.left+Z.left,right:me.right-K.right+Z.right},Ve=e.modifiersData.offset;if(O===Up&&Ve){var tt=Ve[d];Object.keys(xe).forEach(function(_e){var St=[ln,Ln].indexOf(_e)>=0?1:-1,We=[Gr,Ln].indexOf(_e)>=0?"y":"x";xe[_e]+=tt[We]*St})}return xe}o(us,"detectOverflow");function qS(e,t){t===void 0&&(t={});var n=t,l=n.placement,d=n.boundary,h=n.rootBoundary,c=n.padding,v=n.flipVariations,C=n.allowedAutoPlacements,k=C===void 0?ty:C,O=Qs(l),j=O?v?WS:WS.filter(function(J){return Qs(J)===O}):su,B=j.filter(function(J){return k.indexOf(J)>=0});B.length===0&&(B=j);var X=B.reduce(function(J,Z){return J[Z]=us(e,{placement:Z,boundary:d,rootBoundary:h,padding:c})[On(Z)],J},{});return Object.keys(X).sort(function(J,Z){return X[J]-X[Z]})}o(qS,"computeAutoPlacement");function v3(e){if(On(e)===Z0)return[];var t=zp(e);return[iy(e),t,iy(t)]}o(v3,"getExpandedFallbackPlacements");function y3(e){var t=e.state,n=e.options,l=e.name;if(!t.modifiersData[l]._skip){for(var d=n.mainAxis,h=d===void 0?!0:d,c=n.altAxis,v=c===void 0?!0:c,C=n.fallbackPlacements,k=n.padding,O=n.boundary,j=n.rootBoundary,B=n.altBoundary,X=n.flipVariations,J=X===void 0?!0:X,Z=n.allowedAutoPlacements,R=t.options.placement,A=On(R),I=A===R,G=C||(I||!J?[zp(R)]:v3(R)),K=[R].concat(G).reduce(function(ut,Lr){return ut.concat(On(Lr)===Z0?qS(t,{placement:Lr,boundary:O,rootBoundary:j,padding:k,flipVariations:J,allowedAutoPlacements:Z}):Lr)},[]),se=t.rects.reference,ne=t.rects.popper,pe=new Map,me=!0,xe=K[0],Ve=0;Ve=0,Ke=We?"width":"height",Ge=us(t,{placement:tt,boundary:O,rootBoundary:j,altBoundary:B,padding:k}),Xe=We?St?ln:an:St?Ln:Gr;se[Ke]>ne[Ke]&&(Xe=zp(Xe));var nr=zp(Xe),ct=[];if(h&&ct.push(Ge[_e]<=0),v&&ct.push(Ge[Xe]<=0,Ge[nr]<=0),ct.every(function(ut){return ut})){xe=tt,me=!1;break}pe.set(tt,ct)}if(me)for(var Hr=J?3:1,Zt=o(function(Lr){var zt=K.find(function($t){var ie=pe.get($t);if(ie)return ie.slice(0,Lr).every(function(rt){return rt})});if(zt)return xe=zt,"break"},"_loop"),_t=Hr;_t>0;_t--){var Ct=Zt(_t);if(Ct==="break")break}t.placement!==xe&&(t.modifiersData[l]._skip=!0,t.placement=xe,t.reset=!0)}}o(y3,"flip");var tL={name:"flip",enabled:!0,phase:"main",fn:y3,requiresIfExists:["offset"],data:{_skip:!1}};function rL(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}o(rL,"getSideOffsets");function nL(e){return[Gr,ln,Ln,an].some(function(t){return e[t]>=0})}o(nL,"isAnySideFullyClipped");function w3(e){var t=e.state,n=e.name,l=t.rects.reference,d=t.rects.popper,h=t.modifiersData.preventOverflow,c=us(t,{elementContext:"reference"}),v=us(t,{altBoundary:!0}),C=rL(c,l),k=rL(v,d,h),O=nL(C),j=nL(k);t.modifiersData[n]={referenceClippingOffsets:C,popperEscapeOffsets:k,isReferenceHidden:O,hasPopperEscaped:j},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":O,"data-popper-escaped":j})}o(w3,"hide");var iL={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:w3};function x3(e,t,n){var l=On(e),d=[an,Gr].indexOf(l)>=0?-1:1,h=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,c=h[0],v=h[1];return c=c||0,v=(v||0)*d,[an,ln].indexOf(l)>=0?{x:v,y:c}:{x:c,y:v}}o(x3,"distanceAndSkiddingToXY");function S3(e){var t=e.state,n=e.options,l=e.name,d=n.offset,h=d===void 0?[0,0]:d,c=ty.reduce(function(O,j){return O[j]=x3(j,t.rects,h),O},{}),v=c[t.placement],C=v.x,k=v.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=C,t.modifiersData.popperOffsets.y+=k),t.modifiersData[l]=c}o(S3,"offset");var oL={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:S3};function C3(e){var t=e.state,n=e.name;t.modifiersData[n]=gm({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}o(C3,"popperOffsets");var sL={name:"popperOffsets",enabled:!0,phase:"read",fn:C3,data:{}};function VS(e){return e==="x"?"y":"x"}o(VS,"getAltAxis");function b3(e){var t=e.state,n=e.options,l=e.name,d=n.mainAxis,h=d===void 0?!0:d,c=n.altAxis,v=c===void 0?!1:c,C=n.boundary,k=n.rootBoundary,O=n.altBoundary,j=n.padding,B=n.tether,X=B===void 0?!0:B,J=n.tetherOffset,Z=J===void 0?0:J,R=us(t,{boundary:C,rootBoundary:k,padding:j,altBoundary:O}),A=On(t.placement),I=Qs(t.placement),G=!I,K=Ff(A),se=VS(K),ne=t.modifiersData.popperOffsets,pe=t.rects.reference,me=t.rects.popper,xe=typeof Z=="function"?Z(Object.assign({},t.rects,{placement:t.placement})):Z,Ve={x:0,y:0};if(!!ne){if(h||v){var tt=K==="y"?Gr:an,_e=K==="y"?Ln:ln,St=K==="y"?"height":"width",We=ne[K],Ke=ne[K]+R[tt],Ge=ne[K]-R[_e],Xe=X?-me[St]/2:0,nr=I===Rl?pe[St]:me[St],ct=I===Rl?-me[St]:-pe[St],Hr=t.elements.arrow,Zt=X&&Hr?If(Hr):{width:0,height:0},_t=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:dm(),Ct=_t[tt],ut=_t[_e],Lr=Bf(0,pe[St],Zt[St]),zt=G?pe[St]/2-Xe-Lr-Ct-xe:nr-Lr-Ct-xe,$t=G?-pe[St]/2+Xe+Lr+ut+xe:ct+Lr+ut+xe,ie=t.elements.arrow&&as(t.elements.arrow),rt=ie?K==="y"?ie.clientTop||0:ie.clientLeft||0:0,Pr=t.modifiersData.offset?t.modifiersData.offset[t.placement][K]:0,Gt=ne[K]+zt-Pr-rt,Yt=ne[K]+$t-Pr;if(h){var Se=Bf(X?au(Ke,Gt):Ke,We,X?Ao(Ge,Yt):Ge);ne[K]=Se,Ve[K]=Se-We}if(v){var Or=K==="x"?Gr:an,fn=K==="x"?Ln:ln,Un=ne[se],si=Un+R[Or],cn=Un-R[fn],Jt=Bf(X?au(si,Gt):si,Un,X?Ao(cn,Yt):cn);ne[se]=Jt,Ve[se]=Jt-Un}}t.modifiersData[l]=Ve}}o(b3,"preventOverflow");var lL={name:"preventOverflow",enabled:!0,phase:"main",fn:b3,requiresIfExists:["offset"]};function KS(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}o(KS,"getHTMLElementScroll");function GS(e){return e===Br(e)||!Yr(e)?Hf(e):KS(e)}o(GS,"getNodeScroll");function E3(e){var t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,l=t.height/e.offsetHeight||1;return n!==1||l!==1}o(E3,"isElementScaled");function YS(e,t,n){n===void 0&&(n=!1);var l=Yr(t),d=Yr(t)&&E3(t),h=Bn(t),c=Mo(e,d),v={scrollLeft:0,scrollTop:0},C={x:0,y:0};return(l||!l&&!n)&&((Pn(t)!=="body"||Uf(h))&&(v=GS(t)),Yr(t)?(C=Mo(t,!0),C.x+=t.clientLeft,C.y+=t.clientTop):h&&(C.x=Wf(h))),{x:c.left+v.scrollLeft-C.x,y:c.top+v.scrollTop-C.y,width:c.width,height:c.height}}o(YS,"getCompositeRect");function _3(e){var t=new Map,n=new Set,l=[];e.forEach(function(h){t.set(h.name,h)});function d(h){n.add(h.name);var c=[].concat(h.requires||[],h.requiresIfExists||[]);c.forEach(function(v){if(!n.has(v)){var C=t.get(v);C&&d(C)}}),l.push(h)}return o(d,"sort"),e.forEach(function(h){n.has(h.name)||d(h)}),l}o(_3,"order");function XS(e){var t=_3(e);return KN.reduce(function(n,l){return n.concat(t.filter(function(d){return d.phase===l}))},[])}o(XS,"orderModifiers");function QS(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}o(QS,"debounce");function ZS(e){var t=e.reduce(function(n,l){var d=n[l.name];return n[l.name]=d?Object.assign({},d,l,{options:Object.assign({},d.options,l.options),data:Object.assign({},d.data,l.data)}):l,n},{});return Object.keys(t).map(function(n){return t[n]})}o(ZS,"mergeByName");var aL={placement:"bottom",modifiers:[],strategy:"absolute"};function uL(){for(var e=arguments.length,t=new Array(e),n=0;nxi.default.createElement("li",{role:"separator",className:"divider"}),"Divider");function ii(l){var d=l,{onClick:e,children:t}=d,n=Ws(d,["onClick","children"]);return xi.default.createElement("li",null,xi.default.createElement("a",ke({href:"#",onClick:o(c=>{c.preventDefault(),e()},"click")},n),t))}o(ii,"MenuItem");var cu=xi.default.memo(o(function(v){var C=v,{text:t,children:n,options:l,className:d,onOpen:h}=C,c=Ws(C,["text","children","options","className","onOpen"]);let[k,O]=(0,xi.useState)(null),[j,B]=(0,xi.useState)(!1),[X,J]=(0,xi.useState)(null),{styles:Z,attributes:R}=eC(k,X,ke({},l)),A=o(G=>{B(G),h&&h(G)},"setOpen");(0,xi.useEffect)(()=>{!X||document.addEventListener("click",G=>{X.contains(G.target)?document.addEventListener("click",()=>A(!1),{once:!0}):(G.preventDefault(),G.stopPropagation(),A(!1))},{once:!0,capture:!0})},[X]);let I;return j?I=xi.default.createElement("ul",ke({className:"dropdown-menu show",ref:J,style:Z.popper},R.popper),n):I=null,xi.default.createElement(xi.default.Fragment,null,xi.default.createElement("a",ke({href:"#",ref:O,className:(0,hL.default)(d,{open:j}),onClick:G=>{G.preventDefault(),A(!0)}},c),t),I)},"Dropdown"));function vm({value:e,onChange:t}){let n=qe(d=>d.backendState.contentViews||[]),l=zf.default.createElement("span",null,zf.default.createElement("i",{className:"fa fa-fw fa-files-o"}),"\xA0",zf.default.createElement("b",null,"View:")," ",e.toLowerCase()," ",zf.default.createElement("span",{className:"caret"}));return zf.default.createElement(cu,{text:l,className:"btn btn-default btn-xs",options:{placement:"top-start"}},n.map(d=>zf.default.createElement(ii,{key:d,onClick:()=>t(d)},d.toLowerCase().replace("_"," "))))}o(vm,"ViewSelector");function tC({flow:e,message:t}){let n=Qt(),l=e.request===t?"request":"response",d=qe(J=>J.ui.flow.contentViewFor[e.id+l]||"Auto"),h=(0,tr.useRef)(null),[c,v]=(0,tr.useState)(qe(J=>J.options.content_view_lines_cutoff)),C=(0,tr.useCallback)(()=>v(Math.max(1024,c*2)),[c]),[k,O]=(0,tr.useState)(!1),j;k?j=Kr.getContentURL(e,t):j=Kr.getContentURL(e,t,d,c+1);let B=G0(j,t.contentHash),X=(0,tr.useMemo)(()=>{if(B&&!k)try{return JSON.parse(B)}catch(J){return{description:"Network Error",lines:[[["error",`${B}`]]]}}else return},[B]);if(k)return tr.default.createElement("div",{className:"contentview",key:"edit"},tr.default.createElement("div",{className:"controls"},tr.default.createElement("h5",null,"[Editing]"),tr.default.createElement(kr,{onClick:o(()=>Ia(this,null,function*(){var R;let Z=(R=h.current)==null?void 0:R.getContent();yield n(Wi(e,{[l]:{content:Z}})),O(!1)}),"save"),icon:"fa-check text-success",className:"btn-xs"},"Done"),"\xA0",tr.default.createElement(kr,{onClick:()=>O(!1),icon:"fa-times text-danger",className:"btn-xs"},"Cancel")),tr.default.createElement(fm,{ref:h,initialContent:B||""}));{let J=X?X.description:"Loading...";return tr.default.createElement("div",{className:"contentview",key:"view"},tr.default.createElement("div",{className:"controls"},tr.default.createElement("h5",null,J),tr.default.createElement(kr,{onClick:()=>O(!0),icon:"fa-edit",className:"btn-xs"},"Edit"),"\xA0",tr.default.createElement(Y0,{icon:"fa-upload",text:"Replace",title:"Upload a file to replace the content.",onOpenFile:Z=>n(iN(e,Z,l)),className:"btn btn-default btn-xs"}),"\xA0",tr.default.createElement(vm,{value:d,onChange:Z=>n(x0(e.id+l,Z))})),rC.matches(t)&&tr.default.createElement(rC,{flow:e,message:t}),tr.default.createElement(X0,{lines:(X==null?void 0:X.lines)||[],maxLines:c,showMore:C}))}}o(tC,"HttpMessage");var M3=/^image\/(png|jpe?g|gif|webp|vnc.microsoft.icon|x-icon)$/i;rC.matches=e=>M3.test(Kr.getContentType(e)||"");function rC({flow:e,message:t}){return tr.default.createElement("div",{className:"flowview-image"},tr.default.createElement("img",{src:Kr.getContentURL(e,t),alt:"preview",className:"img-thumbnail"}))}o(rC,"ViewImage");function A3({flow:e}){let t=Qt();return Ut.createElement("div",{className:"first-line request-line"},Ut.createElement("div",null,Ut.createElement(Df,{content:e.request.method,onEditDone:n=>t(Wi(e,{request:{method:n}})),isValid:n=>n.length>0}),"\xA0",Ut.createElement(Df,{content:Oo.pretty_url(e.request),onEditDone:n=>t(Wi(e,{request:ke({path:""},mS(n))})),isValid:n=>{var l;return!!((l=mS(n))==null?void 0:l.host)}}),"\xA0",Ut.createElement(Df,{content:e.request.http_version,onEditDone:n=>t(Wi(e,{request:{http_version:n}})),isValid:gS})))}o(A3,"RequestLine");function D3({flow:e}){let t=Qt();return Ut.createElement("div",{className:"first-line response-line"},Ut.createElement(Df,{content:e.response.http_version,onEditDone:n=>t(Wi(e,{response:{http_version:n}})),isValid:gS}),"\xA0",Ut.createElement(Df,{content:e.response.status_code+"",onEditDone:n=>t(Wi(e,{response:{code:parseInt(n)}})),isValid:n=>/^\d+$/.test(n)}),e.response.http_version!=="HTTP/2.0"&&Ut.createElement(Ut.Fragment,null,"\xA0",Ut.createElement(Xs,{content:e.response.reason,onEditDone:n=>t(Wi(e,{response:{msg:n}}))})))}o(D3,"ResponseLine");function R3({flow:e,message:t}){let n=Qt(),l=e.request===t?"request":"response";return Ut.createElement(Bp,{className:"headers",data:t.headers,onChange:d=>n(Wi(e,{[l]:{headers:d}}))})}o(R3,"Headers");function I3({flow:e,message:t}){let n=Qt(),l=e.request===t?"request":"response";return!Kr.get_first_header(t,/^trailer$/i)?null:Ut.createElement(Ut.Fragment,null,Ut.createElement("hr",null),Ut.createElement("h5",null,"HTTP Trailers"),Ut.createElement(Bp,{className:"trailers",data:t.trailers,onChange:h=>n(Wi(e,{[l]:{trailers:h}}))}))}o(I3,"Trailers");var gL=Ut.memo(o(function({flow:t,message:n}){let l=t.request===n?"request":"response",d=t.request===n?A3:D3;return Ut.createElement("section",{className:l},Ut.createElement(d,{flow:t}),Ut.createElement(R3,{flow:t,message:n}),Ut.createElement("hr",null),Ut.createElement(tC,{key:t.id+l,flow:t,message:n}),Ut.createElement(I3,{flow:t,message:n}))},"Message"));function nC(){let e=qe(t=>t.flows.byId[t.flows.selected[0]]);return Ut.createElement(gL,{flow:e,message:e.request})}o(nC,"Request");nC.displayName="Request";function iC(){let e=qe(t=>t.flows.byId[t.flows.selected[0]]);return Ut.createElement(gL,{flow:e,message:e.response})}o(iC,"Response");iC.displayName="Response";var Ye=fe(Oe());var F3=o(({message:e})=>Ye.createElement("div",null,e.query?e.op_code:e.response_code,"\xA0",e.truncation?"(Truncated)":""),"Summary"),B3=o(({message:e})=>Ye.createElement(Ye.Fragment,null,Ye.createElement("h5",null,e.recursion_desired?"Recursive ":"","Question"),Ye.createElement("table",null,Ye.createElement("thead",null,Ye.createElement("tr",null,Ye.createElement("th",null,"Name"),Ye.createElement("th",null,"Type"),Ye.createElement("th",null,"Class"))),Ye.createElement("tbody",null,e.questions.map((t,n)=>Ye.createElement("tr",{key:n},Ye.createElement("td",null,t.name),Ye.createElement("td",null,t.type),Ye.createElement("td",null,t.class)))))),"Questions"),oC=o(({name:e,values:t})=>Ye.createElement(Ye.Fragment,null,Ye.createElement("h5",null,e),t.length>0?Ye.createElement("table",null,Ye.createElement("thead",null,Ye.createElement("tr",null,Ye.createElement("th",null,"Name"),Ye.createElement("th",null,"Type"),Ye.createElement("th",null,"Class"),Ye.createElement("th",null,"TTL"),Ye.createElement("th",null,"Data"))),Ye.createElement("tbody",null,t.map((n,l)=>Ye.createElement("tr",{key:l},Ye.createElement("td",null,n.name),Ye.createElement("td",null,n.type),Ye.createElement("td",null,n.class),Ye.createElement("td",null,n.ttl),Ye.createElement("td",null,n.data))))):"\u2014"),"ResourceRecords"),vL=o(({type:e,message:t})=>Ye.createElement("section",{className:"dns-"+e},Ye.createElement("div",{className:`first-line ${e}-line`},Ye.createElement(F3,{message:t})),Ye.createElement(B3,{message:t}),Ye.createElement("hr",null),Ye.createElement(oC,{name:`${t.authoritative_answer?"Authoritative ":""}${t.recursion_available?"Recursive ":""}Answer`,values:t.answers}),Ye.createElement("hr",null),Ye.createElement(oC,{name:"Authority",values:t.authorities}),Ye.createElement("hr",null),Ye.createElement(oC,{name:"Additional",values:t.additionals})),"Message");function sC(){let e=qe(t=>t.flows.byId[t.flows.selected[0]]);return Ye.createElement(vL,{type:"request",message:e.request})}o(sC,"Request");sC.displayName="Request";function lC(){let e=qe(t=>t.flows.byId[t.flows.selected[0]]);return Ye.createElement(vL,{type:"response",message:e.response})}o(lC,"Response");lC.displayName="Response";var Ee=fe(Oe());function yL({conn:e}){var n,l,d;let t=null;return"address"in e?t=Ee.createElement(Ee.Fragment,null,Ee.createElement("tr",null,Ee.createElement("td",null,"Address:"),Ee.createElement("td",null,(n=e.address)==null?void 0:n.join(":"))),e.peername&&Ee.createElement("tr",null,Ee.createElement("td",null,"Resolved address:"),Ee.createElement("td",null,e.peername.join(":"))),e.sockname&&Ee.createElement("tr",null,Ee.createElement("td",null,"Source address:"),Ee.createElement("td",null,e.sockname.join(":")))):((l=e.peername)==null?void 0:l[0])&&(t=Ee.createElement(Ee.Fragment,null,Ee.createElement("tr",null,Ee.createElement("td",null,"Address:"),Ee.createElement("td",null,(d=e.peername)==null?void 0:d.join(":"))))),Ee.createElement("table",{className:"connection-table"},Ee.createElement("tbody",null,t,e.sni?Ee.createElement("tr",null,Ee.createElement("td",null,Ee.createElement("abbr",{title:"TLS Server Name Indication"},"SNI"),":"),Ee.createElement("td",null,e.sni)):null,e.alpn?Ee.createElement("tr",null,Ee.createElement("td",null,Ee.createElement("abbr",{title:"ALPN protocol negotiated"},"ALPN"),":"),Ee.createElement("td",null,e.alpn)):null,e.tls_version?Ee.createElement("tr",null,Ee.createElement("td",null,"TLS Version:"),Ee.createElement("td",null,e.tls_version)):null,e.cipher?Ee.createElement("tr",null,Ee.createElement("td",null,"TLS Cipher:"),Ee.createElement("td",null,e.cipher)):null))}o(yL,"ConnectionInfo");function wL(e){return Ee.createElement("dl",{className:"cert-attributes"},e.map(([t,n])=>Ee.createElement(Ee.Fragment,{key:t},Ee.createElement("dt",null,t),Ee.createElement("dd",null,n))))}o(wL,"attrList");function H3({flow:e}){var n;let t=(n=e.server_conn)==null?void 0:n.cert;return t?Ee.createElement(Ee.Fragment,null,Ee.createElement("h4",{key:"name"},"Server Certificate"),Ee.createElement("table",{className:"certificate-table"},Ee.createElement("tbody",null,Ee.createElement("tr",null,Ee.createElement("td",null,"Type"),Ee.createElement("td",null,t.keyinfo[0],", ",t.keyinfo[1]," bits")),Ee.createElement("tr",null,Ee.createElement("td",null,"SHA256 digest"),Ee.createElement("td",null,t.sha256)),Ee.createElement("tr",null,Ee.createElement("td",null,"Valid from"),Ee.createElement("td",null,no(t.notbefore,{milliseconds:!1}))),Ee.createElement("tr",null,Ee.createElement("td",null,"Valid to"),Ee.createElement("td",null,no(t.notafter,{milliseconds:!1}))),Ee.createElement("tr",null,Ee.createElement("td",null,"Subject Alternative Names"),Ee.createElement("td",null,t.altnames.join(", "))),Ee.createElement("tr",null,Ee.createElement("td",null,"Subject"),Ee.createElement("td",null,wL(t.subject))),Ee.createElement("tr",null,Ee.createElement("td",null,"Issuer"),Ee.createElement("td",null,wL(t.issuer))),Ee.createElement("tr",null,Ee.createElement("td",null,"Serial"),Ee.createElement("td",null,t.serial))))):Ee.createElement(Ee.Fragment,null)}o(H3,"CertificateInfo");function ly({flow:e}){var t;return Ee.createElement("section",{className:"detail"},Ee.createElement("h4",null,"Client Connection"),Ee.createElement(yL,{conn:e.client_conn}),((t=e.server_conn)==null?void 0:t.address)&&Ee.createElement(Ee.Fragment,null,Ee.createElement("h4",null,"Server Connection"),Ee.createElement(yL,{conn:e.server_conn})),Ee.createElement(H3,{flow:e}))}o(ly,"Connection");ly.displayName="Connection";var ym=fe(Oe());function ay({flow:e}){return ym.createElement("section",{className:"error"},ym.createElement("div",{className:"alert alert-warning"},e.error.msg,ym.createElement("div",null,ym.createElement("small",null,no(e.error.timestamp)))))}o(ay,"Error");ay.displayName="Error";var fs=fe(Oe());function W3({t:e,deltaTo:t,title:n}){return e?fs.createElement("tr",null,fs.createElement("td",null,n,":"),fs.createElement("td",null,no(e),t&&fs.createElement("span",{className:"text-muted"},"(",C0(1e3*(e-t)),")"))):fs.createElement("tr",null)}o(W3,"TimeStamp");function uy({flow:e}){var l,d,h,c,v,C;let t;e.type==="http"?t=e.request.timestamp_start:t=e.client_conn.timestamp_start;let n=[{title:"Server conn. initiated",t:(l=e.server_conn)==null?void 0:l.timestamp_start,deltaTo:t},{title:"Server conn. TCP handshake",t:(d=e.server_conn)==null?void 0:d.timestamp_tcp_setup,deltaTo:t},{title:"Server conn. TLS handshake",t:(h=e.server_conn)==null?void 0:h.timestamp_tls_setup,deltaTo:t},{title:"Server conn. closed",t:(c=e.server_conn)==null?void 0:c.timestamp_end,deltaTo:t},{title:"Client conn. established",t:e.client_conn.timestamp_start,deltaTo:e.type==="http"?t:void 0},{title:"Client conn. TLS handshake",t:e.client_conn.timestamp_tls_setup,deltaTo:t},{title:"Client conn. closed",t:e.client_conn.timestamp_end,deltaTo:t}];return e.type==="http"&&n.push({title:"First request byte",t:e.request.timestamp_start},{title:"Request complete",t:e.request.timestamp_end,deltaTo:t},{title:"First response byte",t:(v=e.response)==null?void 0:v.timestamp_start,deltaTo:t},{title:"Response complete",t:(C=e.response)==null?void 0:C.timestamp_end,deltaTo:t}),fs.createElement("section",{className:"timing"},fs.createElement("h4",null,"Timing"),fs.createElement("table",{className:"timing-table"},fs.createElement("tbody",null,n.filter(k=>!!k.t).sort((k,O)=>k.t-O.t).map(k=>fs.createElement(W3,ke({key:k.title},k))))))}o(uy,"Timing");uy.displayName="Timing";var pu=fe(Oe());var Zs=fe(Oe()),jp=fe(Oe());function $f({flow:e,messages_meta:t}){let n=Qt(),l=qe(k=>k.ui.flow.contentViewFor[e.id+"messages"]||"Auto"),[d,h]=(0,jp.useState)(qe(k=>k.options.content_view_lines_cutoff)),c=(0,jp.useCallback)(()=>h(Math.max(1024,d*2)),[d]),v=G0(Kr.getContentURL(e,"messages",l,d+1),e.id+t.count),C=(0,jp.useMemo)(()=>{if(v)try{return JSON.parse(v)}catch(k){return[{description:"Network Error",lines:[[["error",`${v}`]]]}]}},[v])||[];return Zs.createElement("div",{className:"contentview"},Zs.createElement("div",{className:"controls"},Zs.createElement("h5",null,t.count," Messages"),Zs.createElement(vm,{value:l,onChange:k=>n(x0(e.id+"messages",k))})),C.map((k,O)=>{let j=`fa fa-fw fa-arrow-${k.from_client?"right text-primary":"left text-danger"}`,B=Zs.createElement("div",{key:O},Zs.createElement("small",null,Zs.createElement("i",{className:j}),Zs.createElement("span",{className:"pull-right"},k.timestamp&&no(k.timestamp))),Zs.createElement(X0,{lines:k.lines,maxLines:d,showMore:c}));return d-=k.lines.length,B}))}o($f,"Messages");function fy({flow:e}){return pu.createElement("section",{className:"websocket"},pu.createElement("h4",null,"WebSocket"),pu.createElement($f,{flow:e,messages_meta:e.websocket.messages_meta}),pu.createElement(U3,{websocket:e.websocket}))}o(fy,"WebSocket");fy.displayName="WebSocket";function U3({websocket:e}){if(!e.timestamp_end)return null;let t=e.close_reason?`(${e.close_reason})`:"";return pu.createElement("div",null,pu.createElement("i",{className:"fa fa-fw fa-window-close text-muted"}),"\xA0 Closed by ",e.closed_by_client?"client":"server"," ","with code ",e.close_code," ",t,".",pu.createElement("small",{className:"pull-right"},no(e.timestamp_end)))}o(U3,"CloseSummary");var xL=fe(ti());var aC=fe(Oe());function cy({flow:e}){return aC.createElement("section",{className:"tcp"},aC.createElement($f,{flow:e,messages_meta:e.messages_meta}))}o(cy,"TcpMessages");cy.displayName="Stream Data";var uC=fe(Oe());function py({flow:e}){return uC.createElement("section",{className:"udp"},uC.createElement($f,{flow:e,messages_meta:e.messages_meta}))}o(py,"UdpMessages");py.displayName="Datagrams";var SL={request:nC,response:iC,error:ay,connection:ly,timing:uy,websocket:fy,tcpmessages:cy,udpmessages:py,dnsrequest:sC,dnsresponse:lC};function dy(e){let t;switch(e.type){case"http":t=["request","response","websocket"].filter(n=>e[n]);break;case"tcp":t=["tcpmessages"];break;case"udp":t=["udpmessages"];break;case"dns":t=["request","response"].filter(n=>e[n]).map(n=>"dns"+n);break}return e.error&&t.push("error"),t.push("connection"),t.push("timing"),t}o(dy,"tabsForFlow");function fC(){let e=Qt(),t=qe(h=>h.flows.byId[h.flows.selected[0]]),n=dy(t),l=qe(h=>h.ui.flow.tab);n.indexOf(l)<0&&(l==="response"&&t.error?l="error":l==="error"&&"response"in t?l="response":l=n[0]);let d=SL[l];return wm.createElement("div",{className:"flow-detail"},wm.createElement("nav",{className:"nav-tabs nav-tabs-sm"},n.map(h=>wm.createElement("a",{key:h,href:"#",className:(0,xL.default)({active:l===h}),onClick:c=>{c.preventDefault(),e(Lf(h))}},SL[h].displayName))),wm.createElement(d,{flow:t}))}o(fC,"FlowView");function CL(e){if(e.ctrlKey||e.metaKey)return()=>{};let t=e.key;return e.preventDefault(),(n,l)=>{let d=l().flows,h=d.byId[l().flows.selected[0]];switch(t){case"k":case"ArrowUp":n(Mf(d,-1));break;case"j":case"ArrowDown":n(Mf(d,1));break;case" ":case"PageDown":n(Mf(d,10));break;case"PageUp":n(Mf(d,-10));break;case"End":n(Mf(d,1e10));break;case"Home":n(Mf(d,-1e10));break;case"Escape":l().ui.modal.activeModal?n($0()):n(Af(void 0));break;case"ArrowLeft":{if(!h)break;let c=dy(h),v=l().ui.flow.tab,C=c[(Math.max(0,c.indexOf(v))-1+c.length)%c.length];n(Lf(C));break}case"Tab":case"ArrowRight":{if(!h)break;let c=dy(h),v=l().ui.flow.tab,C=c[(Math.max(0,c.indexOf(v))+1)%c.length];n(Lf(C));break}case"Delete":case"d":{if(!h)return;n(B0(h));break}case"n":{Pf("view.flows.create","get","https://example.com/");break}case"D":{if(!h)return;n(H0(h));break}case"a":{h&&h.intercepted&&n(Op(h));break}case"A":{n(I0());break}case"r":{h&&n(Mp(h));break}case"v":{h&&h.modified&&n(W0(h));break}case"x":{h&&h.intercepted&&n(F0(h));break}case"X":{n(nN());break}case"z":{n(U0());break}default:return}}}o(CL,"onKeyDown");var Zp=fe(Oe());var xm=fe(Oe()),Sm=fe(iu()),bL=fe(ti()),qp=class extends xm.Component{constructor(t,n){super(t,n);this.state={applied:!1,startX:0,startY:0},this.onMouseMove=this.onMouseMove.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onDragEnd=this.onDragEnd.bind(this)}onMouseDown(t){this.setState({startX:t.pageX,startY:t.pageY}),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp),window.addEventListener("dragend",this.onDragEnd)}onDragEnd(){Sm.default.findDOMNode(this).style.transform="",window.removeEventListener("dragend",this.onDragEnd),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove)}onMouseUp(t){this.onDragEnd();let n=Sm.default.findDOMNode(this),l=n.previousElementSibling,d=l.offsetHeight+t.pageY-this.state.startY;this.props.axis==="x"&&(d=l.offsetWidth+t.pageX-this.state.startX),l.style.flex=`0 0 ${Math.max(0,d)}px`,n.nextElementSibling.style.flex="1 1 auto",this.setState({applied:!0}),this.onResize()}onMouseMove(t){let n=0,l=0;this.props.axis==="x"?n=t.pageX-this.state.startX:l=t.pageY-this.state.startY,Sm.default.findDOMNode(this).style.transform=`translate(${n}px, ${l}px)`}onResize(){window.setTimeout(()=>window.dispatchEvent(new CustomEvent("resize")),1)}reset(t){if(!this.state.applied)return;let n=Sm.default.findDOMNode(this);n.previousElementSibling&&(n.previousElementSibling.style.flex=""),n.nextElementSibling&&(n.nextElementSibling.style.flex=""),t||this.setState({applied:!1}),this.onResize()}componentWillUnmount(){this.reset(!0)}render(){return xm.default.createElement("div",{className:(0,bL.default)("splitter",this.props.axis==="x"?"splitter-x":"splitter-y")},xm.default.createElement("div",{onMouseDown:this.onMouseDown,draggable:"true"}))}};o(qp,"Splitter"),qp.defaultProps={axis:"x"};var cs=fe(Oe()),Em=fe(Cm()),my=fe(iu());var BL=fe(cC());var pC=fe(iu()),ML=Symbol("shouldStick"),AL=o(e=>Math.round(e.scrollTop)+e.clientHeight===e.scrollHeight,"isAtBottom"),hy=o(e=>{var t;return Object.assign((o(t=class extends e{UNSAFE_componentWillUpdate(){let l=pC.default.findDOMNode(this);this[ML]=l.scrollTop&&AL(l),super.UNSAFE_componentWillUpdate&&super.UNSAFE_componentWillUpdate(),super.componentWillUpdate&&super.componentWillUpdate()}componentDidUpdate(){let l=pC.default.findDOMNode(this);this[ML]&&!AL(l)&&(l.scrollTop=l.scrollHeight),super.componentDidUpdate&&super.componentDidUpdate()}},"AutoScrollWrapper"),t.displayName=e.name,t),e)},"default");function jf(e=void 0){if(!e)return{start:0,end:0,paddingTop:0,paddingBottom:0};let{itemCount:t,rowHeight:n,viewportTop:l,viewportHeight:d,itemHeights:h}=e,c=l+d,v=0,C=0,k=0,O=0;if(h){let j=0;for(let B=0;B0&&jv.flows.sort.desc),l=qe(v=>v.flows.sort.column),d=qe(v=>v.options.web_columns),h=n?"sort-desc":"sort-asc",c=d.map(v=>im[v]).filter(v=>v).concat(Pp);return bm.createElement("tr",null,c.map(v=>bm.createElement("th",{className:(0,DL.default)(`col-${v.name}`,l===v.name&&h),key:v.name,onClick:()=>t(rN(v.name===l&&n?void 0:v.name,v.name!==l?!1:!n))},v.headerName)))},"FlowTableHead"));var Vp=fe(Oe()),IL=fe(ti());var FL=Vp.default.memo(o(function({flow:t,selected:n,highlighted:l}){let d=Qt(),h=qe(k=>k.options.web_columns),c=(0,IL.default)({selected:n,highlighted:l,intercepted:t.intercepted,"has-request":t.type==="http"&&t.request,"has-response":t.type==="http"&&t.response}),v=(0,Vp.useCallback)(k=>{let O=k.target;for(;O.parentNode;){if(O.classList.contains("col-quickactions"))return;O=O.parentNode}d(Af(t.id))},[t]),C=h.map(k=>im[k]).filter(k=>k).concat(Pp);return Vp.default.createElement("tr",{className:c,onClick:v},C.map(k=>Vp.default.createElement(k,{key:k.name,flow:t})))},"FlowRow"));var _m=class extends cs.Component{constructor(t,n){super(t,n);this.state={vScroll:jf()},this.onViewportUpdate=this.onViewportUpdate.bind(this)}UNSAFE_componentWillMount(){window.addEventListener("resize",this.onViewportUpdate)}componentDidMount(){this.onViewportUpdate()}UNSAFE_componentWillUnmount(){window.removeEventListener("resize",this.onViewportUpdate)}componentDidUpdate(){if(this.onViewportUpdate(),!this.shouldScrollIntoView)return;this.shouldScrollIntoView=!1;let{rowHeight:t,flows:n,selected:l}=this.props,d=my.default.findDOMNode(this),h=my.default.findDOMNode(this.refs.head),c=h?h.offsetHeight:0,v=n.indexOf(l)*t+c,C=v+t,k=d.scrollTop,O=d.offsetHeight;v-ck+O&&(d.scrollTop=C-O)}UNSAFE_componentWillReceiveProps(t){t.selected&&t.selected!==this.props.selected&&(this.shouldScrollIntoView=!0)}onViewportUpdate(){let t=my.default.findDOMNode(this),n=t.scrollTop||0,l=jf({viewportTop:n,viewportHeight:t.offsetHeight||0,itemCount:this.props.flows.length,rowHeight:this.props.rowHeight});if(this.state.viewportTop!==n||!(0,BL.default)(this.state.vScroll,l)){let d=Math.min(n,l.end*this.props.rowHeight);this.setState({vScroll:l,viewportTop:d})}}render(){let{vScroll:t,viewportTop:n}=this.state,{flows:l,selected:d,highlight:h}=this.props,c=h?Of.parse(h):()=>!1;return cs.createElement("div",{className:"flow-table",onScroll:this.onViewportUpdate},cs.createElement("table",null,cs.createElement("thead",{ref:"head",style:{transform:`translateY(${n}px)`}},cs.createElement(RL,null)),cs.createElement("tbody",null,cs.createElement("tr",{style:{height:t.paddingTop}}),l.slice(t.start,t.end).map(v=>cs.createElement(FL,{key:v.id,flow:v,selected:v===d,highlighted:c(v)})),cs.createElement("tr",{style:{height:t.paddingBottom}}))))}};o(_m,"FlowTable"),Vc(_m,"propTypes",{flows:Em.default.array.isRequired,rowHeight:Em.default.number,highlight:Em.default.string,selected:Em.default.object}),Vc(_m,"defaultProps",{rowHeight:32});var j3=hy(_m),HL=Hi(e=>({flows:e.flows.view,highlight:e.flows.highlight,selected:e.flows.byId[e.flows.selected[0]]}))(j3);var Nr=fe(Oe()),ky=fe(Oe());var zP=fe(UP());function IC(){let e=qe(n=>n.backendState.servers),t;return e.length===0?t="":e.length===1?t="Configure your client to use the following proxy server:":t="Configure your client to use one of the following proxy servers:",Nr.createElement("div",{style:{padding:"1em 2em"}},Nr.createElement("h3",null,"mitmproxy is running."),Nr.createElement("p",null,"No flows have been recorded yet.",Nr.createElement("br",null),t),Nr.createElement("ul",{className:"fa-ul"},e.map((n,l)=>Nr.createElement("li",{key:n.full_spec},Nr.createElement(HB,ke({},n))))))}o(IC,"CaptureSetup");function HB({description:e,listen_addrs:t,last_exception:n,is_running:l,full_spec:d,wireguard_conf:h}){let c=(0,ky.useRef)(null);(0,ky.useEffect)(()=>{h&&c.current&&zP.default.toCanvas(c.current,h,{margin:0,scale:3})},[h]);let v,C=t.length===1||t.length===2&&t[0][1]===t[1][1],k=t.every(B=>["::","0.0.0.0"].includes(B[0]));C&&k?v=nS(["*",t[0][1]]):v=t.map(nS).join(" and "),e=e[0].toUpperCase()+e.substr(1);let O,j;return n?(j="fa-exclamation text-error",O=Nr.createElement(Nr.Fragment,null,e," (",d,"):",Nr.createElement("br",null),n)):l?(j="fa-check text-success",O=`${e} listening at ${v}.`,h&&(O=Nr.createElement(Nr.Fragment,null,O,Nr.createElement("div",{className:"wireguard-config"},Nr.createElement("pre",null,h),Nr.createElement("canvas",{ref:c}))))):(j="fa-pause text-warning",O=Nr.createElement(Nr.Fragment,null,e," (",d,")")),Nr.createElement(Nr.Fragment,null,Nr.createElement("i",{className:`fa fa-li ${j}`}),O)}o(HB,"ServerDescription");function FC(){let e=qe(n=>!!n.flows.byId[n.flows.selected[0]]),t=qe(n=>n.flows.list.length>0);return Zp.createElement("div",{className:"main-view"},t?Zp.createElement(HL,null):Zp.createElement(IC,null),e&&Zp.createElement(qp,{key:"splitter"}),e&&Zp.createElement(fC,{key:"flowDetails"}))}o(FC,"MainView");var Io=fe(Oe()),YP=fe(ti());var oi=fe(Oe());var ps=fe(Oe()),Ny=fe(iu()),$P=fe(ti());var oo=fe(Oe());var so=class extends oo.Component{constructor(t,n){super(t,n);this.state={doc:so.doc}}componentDidMount(){so.xhr||(so.xhr=kt("/filter-help").then(t=>t.json()),so.xhr.catch(()=>{so.xhr=null})),this.state.doc||so.xhr.then(t=>{so.doc=t,this.setState({doc:t})})}render(){let{doc:t}=this.state;return t?oo.default.createElement("table",{className:"table table-condensed"},oo.default.createElement("tbody",null,t.commands.map(n=>oo.default.createElement("tr",{key:n[1],onClick:l=>this.props.selectHandler(n[0].split(" ")[0]+" ")},oo.default.createElement("td",null,n[0].replace(" ","\xA0")),oo.default.createElement("td",null,n[1]))),oo.default.createElement("tr",{key:"docs-link"},oo.default.createElement("td",{colSpan:2},oo.default.createElement("a",{href:"https://mitmproxy.org/docs/latest/concepts-filters/",target:"_blank"},oo.default.createElement("i",{className:"fa fa-external-link"}),"\xA0 mitmproxy docs"))))):oo.default.createElement("i",{className:"fa fa-spinner fa-spin"})}};o(so,"FilterDocs");var Yf=class extends ps.Component{constructor(t,n){super(t,n);this.state={value:this.props.value,focus:!1,mousefocus:!1},this.onChange=this.onChange.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.selectFilter=this.selectFilter.bind(this)}UNSAFE_componentWillReceiveProps(t){this.setState({value:t.value})}isValid(t){try{return t&&Of.parse(t),!0}catch(n){return!1}}getDesc(){if(!this.state.value)return ps.default.createElement(so,{selectHandler:this.selectFilter});try{return Of.parse(this.state.value).desc}catch(t){return""+t}}onChange(t){let n=t.target.value;this.setState({value:n}),this.isValid(n)&&this.props.onChange(n)}onFocus(){this.setState({focus:!0})}onBlur(){this.setState({focus:!1})}onMouseEnter(){this.setState({mousefocus:!0})}onMouseLeave(){this.setState({mousefocus:!1})}onKeyDown(t){(t.key==="Escape"||t.key==="Enter")&&(this.blur(),this.setState({mousefocus:!1})),t.stopPropagation()}selectFilter(t){this.setState({value:t}),Ny.default.findDOMNode(this.refs.input).focus()}blur(){Ny.default.findDOMNode(this.refs.input).blur()}select(){Ny.default.findDOMNode(this.refs.input).select()}render(){let{type:t,color:n,placeholder:l}=this.props,{value:d,focus:h,mousefocus:c}=this.state;return ps.default.createElement("div",{className:(0,$P.default)("filter-input input-group",{"has-error":!this.isValid(d)})},ps.default.createElement("span",{className:"input-group-addon"},ps.default.createElement("i",{className:"fa fa-fw fa-"+t,style:{color:n}})),ps.default.createElement("input",{type:"text",ref:"input",placeholder:l,className:"form-control",value:d,onChange:this.onChange,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown}),(h||c)&&ps.default.createElement("div",{className:"popover bottom",onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave},ps.default.createElement("div",{className:"arrow"}),ps.default.createElement("div",{className:"popover-content"},this.getDesc())))}};o(Yf,"FilterInput");Jp.title="Start";function Jp(){return oi.createElement("div",{className:"main-menu"},oi.createElement("div",{className:"menu-group"},oi.createElement("div",{className:"menu-content"},oi.createElement(UB,null),oi.createElement(zB,null)),oi.createElement("div",{className:"menu-legend"},"Find")),oi.createElement("div",{className:"menu-group"},oi.createElement("div",{className:"menu-content"},oi.createElement(WB,null),oi.createElement($B,null)),oi.createElement("div",{className:"menu-legend"},"Intercept")))}o(Jp,"StartMenu");function WB(){let e=Qt(),t=qe(n=>n.options.intercept);return oi.createElement(Yf,{value:t||"",placeholder:"Intercept",type:"pause",color:"hsl(208, 56%, 53%)",onChange:n=>e(Ip("intercept",n))})}o(WB,"InterceptInput");function UB(){let e=Qt(),t=qe(n=>n.flows.filter);return oi.createElement(Yf,{value:t||"",placeholder:"Search",type:"search",color:"black",onChange:n=>e(D0(n))})}o(UB,"FlowFilterInput");function zB(){let e=Qt(),t=qe(n=>n.flows.highlight);return oi.createElement(Yf,{value:t||"",placeholder:"Highlight",type:"tag",color:"hsl(48, 100%, 50%)",onChange:n=>e(R0(n))})}o(zB,"HighlightInput");function $B(){let e=Qt();return oi.createElement(kr,{className:"btn-sm",title:"[a]ccept all",icon:"fa-forward text-success",onClick:()=>e(I0())},"Resume All")}o($B,"ResumeAll");var Qr=fe(Oe());var Xf=fe(Oe());function BC({value:e,onChange:t,children:n}){return Xf.createElement("div",{className:"menu-entry"},Xf.createElement("label",null,Xf.createElement("input",{type:"checkbox",checked:e,onChange:t}),n))}o(BC,"MenuToggle");function Ly({name:e,children:t}){let n=Qt(),l=qe(d=>d.options[e]);return Xf.createElement(BC,{value:!!l,onChange:()=>n(Ip(e,!l))},t)}o(Ly,"OptionsToggle");function jP(){let e=Gs(),t=qe(n=>n.eventLog.visible);return Xf.createElement(BC,{value:t,onChange:()=>e(Rp())},"Display Event Log")}o(jP,"EventlogToggle");function qP(){let e=Gs(),t=qe(n=>n.commandBar.visible);return Xf.createElement(BC,{value:t,onChange:()=>e(K0())},"Display Command Bar")}o(qP,"CommandBarToggle");var HC=fe(Oe());function WC({children:e,resource:t}){let n=`https://docs.mitmproxy.org/stable/${t}`;return HC.createElement("a",{target:"_blank",href:n},e||HC.createElement("i",{className:"fa fa-question-circle"}))}o(WC,"DocsLink");var Py=fe(Oe());function Ro({children:e}){return window.MITMWEB_STATIC?null:Py.createElement(Py.Fragment,null,e)}o(Ro,"HideInStatic");Oy.title="Options";function Oy(){let e=Qt(),t=o(()=>lN("OptionModal"),"openOptions");return Qr.createElement("div",null,Qr.createElement(Ro,null,Qr.createElement("div",{className:"menu-group"},Qr.createElement("div",{className:"menu-content"},Qr.createElement(kr,{title:"Open Options",icon:"fa-cogs text-primary",onClick:()=>e(t())},"Edit Options ",Qr.createElement("sup",null,"alpha"))),Qr.createElement("div",{className:"menu-legend"},"Options Editor")),Qr.createElement("div",{className:"menu-group"},Qr.createElement("div",{className:"menu-content"},Qr.createElement(Ly,{name:"anticache"},"Strip cache headers"," ",Qr.createElement(WC,{resource:"overview-features/#anticache"})),Qr.createElement(Ly,{name:"showhost"},"Use host header for display"),Qr.createElement(Ly,{name:"ssl_insecure"},"Don't verify server certificates")),Qr.createElement("div",{className:"menu-legend"},"Quick Options"))),Qr.createElement("div",{className:"menu-group"},Qr.createElement("div",{className:"menu-content"},Qr.createElement(jP,null),Qr.createElement(qP,null)),Qr.createElement("div",{className:"menu-legend"},"View Options")))}o(Oy,"OptionMenu");var Hn=fe(Oe());var VP=Hn.memo(o(function(){let t=Gs(),n=qe(l=>l.flows.filter);return Hn.createElement(cu,{className:"pull-left special",text:"File",options:{placement:"bottom-start"}},Hn.createElement("li",null,Hn.createElement(Y0,{icon:"fa-folder-open",text:"\xA0Open...",onClick:l=>l.stopPropagation(),onOpenFile:l=>{t(oN(l)),document.body.click()}})),Hn.createElement(ii,{onClick:()=>location.replace("/flows/dump")},Hn.createElement("i",{className:"fa fa-fw fa-floppy-o"}),"\xA0Save"),Hn.createElement(ii,{onClick:()=>location.replace("/flows/dump?filter="+n)},Hn.createElement("i",{className:"fa fa-fw fa-floppy-o"}),"\xA0Save filtered"),Hn.createElement(ii,{onClick:()=>confirm("Delete all flows?")&&t(U0())},Hn.createElement("i",{className:"fa fa-fw fa-trash"}),"\xA0Clear All"),Hn.createElement(Ro,null,Hn.createElement(mL,null),Hn.createElement("li",null,Hn.createElement("a",{href:"http://mitm.it/",target:"_blank"},Hn.createElement("i",{className:"fa fa-fw fa-external-link"}),"\xA0Install Certificates..."))))},"FileMenu"));var at=fe(Oe());function KP(e){if(navigator.clipboard&&window.isSecureContext)return navigator.clipboard.writeText(e);{let t=document.createElement("textarea");t.value=e,t.style.position="absolute",t.style.opacity="0",document.body.appendChild(t);try{return t.focus(),t.select(),document.execCommand("copy"),Promise.resolve()}catch(n){return alert(e),Promise.reject(n)}finally{t.remove()}}}o(KP,"copyToClipboard");var ed=o((e,t)=>Ia(void 0,null,function*(){let n=yield Pf("export",t,`@${e.id}`);n.value?yield KP(n.value):n.error?alert(n.error):console.error(n)}),"copy");td.title="Flow";function td(){let e=Qt(),t=qe(n=>n.flows.byId[n.flows.selected[0]]);return t?at.createElement("div",{className:"flow-menu"},at.createElement(Ro,null,at.createElement("div",{className:"menu-group"},at.createElement("div",{className:"menu-content"},at.createElement(kr,{title:"[r]eplay flow",icon:"fa-repeat text-primary",onClick:()=>e(Mp(t)),disabled:!_0(t)},"Replay"),at.createElement(kr,{title:"[D]uplicate flow",icon:"fa-copy text-info",onClick:()=>e(H0(t))},"Duplicate"),at.createElement(kr,{disabled:!t||!t.modified,title:"revert changes to flow [V]",icon:"fa-history text-warning",onClick:()=>e(W0(t))},"Revert"),at.createElement(kr,{title:"[d]elete flow",icon:"fa-trash text-danger",onClick:()=>e(B0(t))},"Delete"),at.createElement(KB,{flow:t})),at.createElement("div",{className:"menu-legend"},"Flow Modification"))),at.createElement("div",{className:"menu-group"},at.createElement("div",{className:"menu-content"},at.createElement(jB,{flow:t}),at.createElement(qB,{flow:t})),at.createElement("div",{className:"menu-legend"},"Export")),at.createElement(Ro,null,at.createElement("div",{className:"menu-group"},at.createElement("div",{className:"menu-content"},at.createElement(kr,{disabled:!t||!t.intercepted,title:"[a]ccept intercepted flow",icon:"fa-play text-success",onClick:()=>e(Op(t))},"Resume"),at.createElement(kr,{disabled:!t||!t.intercepted,title:"kill intercepted flow [x]",icon:"fa-times text-danger",onClick:()=>e(F0(t))},"Abort")),at.createElement("div",{className:"menu-legend"},"Interception")))):at.createElement("div",null)}o(td,"FlowMenu");var My=o(e=>{let t=window.open(e,"_blank","noopener,noreferrer");t&&(t.opener=null)},"openInNewTab");function jB({flow:e}){var t;if(e.type!=="http")return at.createElement(kr,{icon:"fa-download",onClick:()=>0,disabled:!0},"Download");if(e.request.contentLength&&!((t=e.response)==null?void 0:t.contentLength))return at.createElement(kr,{icon:"fa-download",onClick:()=>My(Kr.getContentURL(e,e.request))},"Download");if(e.response){let n=e.response;if(!e.request.contentLength&&e.response.contentLength)return at.createElement(kr,{icon:"fa-download",onClick:()=>My(Kr.getContentURL(e,n))},"Download");if(e.request.contentLength&&e.response.contentLength)return at.createElement(cu,{text:at.createElement(kr,{icon:"fa-download",onClick:()=>1},"Download\u25BE"),options:{placement:"bottom-start"}},at.createElement(ii,{onClick:()=>My(Kr.getContentURL(e,e.request))},"Download request"),at.createElement(ii,{onClick:()=>My(Kr.getContentURL(e,n))},"Download response"))}return null}o(jB,"DownloadButton");function qB({flow:e}){return at.createElement(cu,{className:"",text:at.createElement(kr,{title:"Export flow.",icon:"fa-clone",onClick:()=>1,disabled:e.type!=="http"},"Export\u25BE"),options:{placement:"bottom-start"}},at.createElement(ii,{onClick:()=>ed(e,"raw_request")},"Copy raw request"),at.createElement(ii,{onClick:()=>ed(e,"raw_response")},"Copy raw response"),at.createElement(ii,{onClick:()=>ed(e,"raw")},"Copy raw request and response"),at.createElement(ii,{onClick:()=>ed(e,"curl")},"Copy as cURL"),at.createElement(ii,{onClick:()=>ed(e,"httpie")},"Copy as HTTPie"))}o(qB,"ExportButton");var VB={":red_circle:":"\u{1F534}",":orange_circle:":"\u{1F7E0}",":yellow_circle:":"\u{1F7E1}",":green_circle:":"\u{1F7E2}",":large_blue_circle:":"\u{1F535}",":purple_circle:":"\u{1F7E3}",":brown_circle:":"\u{1F7E4}"};function KB({flow:e}){let t=Qt();return at.createElement(cu,{className:"",text:at.createElement(kr,{title:"mark flow",icon:"fa-paint-brush text-success",onClick:()=>1},"Mark\u25BE"),options:{placement:"bottom-start"}},at.createElement(ii,{onClick:()=>t(Wi(e,{marked:""}))},"\u26AA (no marker)"),Object.entries(VB).map(([n,l])=>at.createElement(ii,{key:n,onClick:()=>t(Wi(e,{marked:n}))},l," ",n.replace(/[:_]/g," "))))}o(KB,"MarkButton");var vu=fe(Oe());var GP=vu.memo(o(function(){let t=qe(l=>l.connection.state),n=qe(l=>l.connection.message);switch(t){case ni.INIT:return vu.createElement("span",{className:"connection-indicator init"},"connecting\u2026");case ni.FETCHING:return vu.createElement("span",{className:"connection-indicator fetching"},"fetching data\u2026");case ni.ESTABLISHED:return vu.createElement("span",{className:"connection-indicator established"},"connected");case ni.ERROR:return vu.createElement("span",{className:"connection-indicator error",title:n},"connection lost");case ni.OFFLINE:return vu.createElement("span",{className:"connection-indicator offline"},"offline");default:let l=t;throw"unknown connection state"}},"ConnectionIndicator"));function UC(){let e=qe(v=>v.flows.selected.filter(C=>C in v.flows.byId)),[t,n]=(0,Io.useState)(()=>Jp),[l,d]=(0,Io.useState)(!1),h=[Jp,Oy];e.length>0?(l||(n(()=>td),d(!0)),h.push(td)):(l&&d(!1),t===td&&n(()=>Jp));function c(v,C){C.preventDefault(),n(()=>v)}return o(c,"handleClick"),Io.default.createElement("header",null,Io.default.createElement("nav",{className:"nav-tabs nav-tabs-lg"},Io.default.createElement(VP,null),h.map(v=>Io.default.createElement("a",{key:v.title,href:"#",className:(0,YP.default)({active:v===t}),onClick:C=>c(v,C)},v.title)),Io.default.createElement(Ro,null,Io.default.createElement(GP,null))),Io.default.createElement("div",null,Io.default.createElement(t,null)))}o(UC,"Header");var Je=fe(Oe()),XP=fe(ti());var Ay=function(){"use strict";function e(l,d){function h(){this.constructor=l}o(h,"ctor"),h.prototype=d.prototype,l.prototype=new h}o(e,"peg$subclass");function t(l,d,h,c){this.message=l,this.expected=d,this.found=h,this.location=c,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t)}o(t,"peg$SyntaxError"),e(t,Error);function n(l){var d=arguments.length>1?arguments[1]:{},h=this,c={},v={Expr:Cr},C=Cr,k=o(function(H,ee){return[H,...ee]},"peg$c0"),O=o(function(H){return[H]},"peg$c1"),j=o(function(){return""},"peg$c2"),B={type:"other",description:"string"},X='"',J={type:"literal",value:'"',description:'"\\""'},Z=o(function(H){return H.join("")},"peg$c6"),R="'",A={type:"literal",value:"'",description:`"'"`},I=/^["\\]/,G={type:"class",value:'["\\\\]',description:'["\\\\]'},K={type:"any",description:"any character"},se=o(function(H){return H},"peg$c12"),ne="\\",pe={type:"literal",value:"\\",description:'"\\\\"'},me=/^['\\]/,xe={type:"class",value:"['\\\\]",description:"['\\\\]"},Ve=/^['"\\]/,tt={type:"class",value:`['"\\\\]`,description:`['"\\\\]`},_e="n",St={type:"literal",value:"n",description:'"n"'},We=o(function(){return` -`},"peg$c21"),Ke="r",Ge={type:"literal",value:"r",description:'"r"'},Xe=o(function(){return"\r"},"peg$c24"),nr="t",ct={type:"literal",value:"t",description:'"t"'},Hr=o(function(){return" "},"peg$c27"),Zt={type:"other",description:"whitespace"},_t=/^[ \t\n\r]/,Ct={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},ut={type:"other",description:"control character"},Lr=/^[|&!()~"]/,zt={type:"class",value:'[|&!()~"]',description:'[|&!()~"]'},$t={type:"other",description:"optional whitespace"},ie=0,rt=0,Pr=[{line:1,column:1,seenCR:!1}],Gt=0,Yt=[],Se=0,Or;if("startRule"in d){if(!(d.startRule in v))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');C=v[d.startRule]}function fn(){return l.substring(rt,ie)}o(fn,"text");function Un(){return gr(rt,ie)}o(Un,"location");function si(H){throw Ho(null,[{type:"other",description:H}],l.substring(rt,ie),gr(rt,ie))}o(si,"expected");function cn(H){throw Ho(H,null,l.substring(rt,ie),gr(rt,ie))}o(cn,"error");function Jt(H){var ee=Pr[H],he,Te;if(ee)return ee;for(he=H-1;!Pr[he];)he--;for(ee=Pr[he],ee={line:ee.line,column:ee.column,seenCR:ee.seenCR};heGt&&(Gt=ie,Yt=[]),Yt.push(H))}o(pt,"peg$fail");function Ho(H,ee,he,Te){function ir(Ft){var Wr=1;for(Ft.sort(function(or,li){return or.descriptionli.description?1:0});Wr1?li.slice(0,-1).join(", ")+" or "+li[Ft.length-1]:li[0],lo=Wr?'"'+or(Wr)+'"':"end of input","Expected "+ds+" but "+lo+" found."}return o(Ul,"buildMessage"),ee!==null&&ir(ee),new t(H!==null?H:Ul(ee,he),ee,he,Te)}o(Ho,"peg$buildException");function Cr(){var H,ee,he,Te;if(H=ie,ee=Ui(),ee!==c){if(he=[],Te=$n(),Te!==c)for(;Te!==c;)he.push(Te),Te=$n();else he=c;he!==c?(Te=Cr(),Te!==c?(rt=H,ee=k(ee,Te),H=ee):(ie=H,H=c)):(ie=H,H=c)}else ie=H,H=c;if(H===c&&(H=ie,ee=Ui(),ee!==c&&(rt=H,ee=O(ee)),H=ee,H===c)){for(H=ie,ee=[],he=$n();he!==c;)ee.push(he),he=$n();ee!==c&&(rt=H,ee=j()),H=ee}return H}o(Cr,"peg$parseExpr");function Ui(){var H,ee,he,Te;if(Se++,H=ie,l.charCodeAt(ie)===34?(ee=X,ie++):(ee=c,Se===0&&pt(J)),ee!==c){for(he=[],Te=pn();Te!==c;)he.push(Te),Te=pn();he!==c?(l.charCodeAt(ie)===34?(Te=X,ie++):(Te=c,Se===0&&pt(J)),Te!==c?(rt=H,ee=Z(he),H=ee):(ie=H,H=c)):(ie=H,H=c)}else ie=H,H=c;if(H===c){if(H=ie,l.charCodeAt(ie)===39?(ee=R,ie++):(ee=c,Se===0&&pt(A)),ee!==c){for(he=[],Te=zn();Te!==c;)he.push(Te),Te=zn();he!==c?(l.charCodeAt(ie)===39?(Te=R,ie++):(Te=c,Se===0&&pt(A)),Te!==c?(rt=H,ee=Z(he),H=ee):(ie=H,H=c)):(ie=H,H=c)}else ie=H,H=c;if(H===c){if(H=ie,ee=ie,Se++,he=Mn(),Se--,he===c?ee=void 0:(ie=ee,ee=c),ee!==c){if(he=[],Te=Si(),Te!==c)for(;Te!==c;)he.push(Te),Te=Si();else he=c;he!==c?(rt=H,ee=Z(he),H=ee):(ie=H,H=c)}else ie=H,H=c;if(H===c){if(H=ie,l.charCodeAt(ie)===34?(ee=X,ie++):(ee=c,Se===0&&pt(J)),ee!==c){for(he=[],Te=pn();Te!==c;)he.push(Te),Te=pn();he!==c?(rt=H,ee=Z(he),H=ee):(ie=H,H=c)}else ie=H,H=c;if(H===c)if(H=ie,l.charCodeAt(ie)===39?(ee=R,ie++):(ee=c,Se===0&&pt(A)),ee!==c){for(he=[],Te=zn();Te!==c;)he.push(Te),Te=zn();he!==c?(rt=H,ee=Z(he),H=ee):(ie=H,H=c)}else ie=H,H=c}}}return Se--,H===c&&(ee=c,Se===0&&pt(B)),H}o(Ui,"peg$parseStringLiteral");function pn(){var H,ee,he;return H=ie,ee=ie,Se++,I.test(l.charAt(ie))?(he=l.charAt(ie),ie++):(he=c,Se===0&&pt(G)),Se--,he===c?ee=void 0:(ie=ee,ee=c),ee!==c?(l.length>ie?(he=l.charAt(ie),ie++):(he=c,Se===0&&pt(K)),he!==c?(rt=H,ee=se(he),H=ee):(ie=H,H=c)):(ie=H,H=c),H===c&&(H=ie,l.charCodeAt(ie)===92?(ee=ne,ie++):(ee=c,Se===0&&pt(pe)),ee!==c?(he=Ci(),he!==c?(rt=H,ee=se(he),H=ee):(ie=H,H=c)):(ie=H,H=c)),H}o(pn,"peg$parseDoubleStringChar");function zn(){var H,ee,he;return H=ie,ee=ie,Se++,me.test(l.charAt(ie))?(he=l.charAt(ie),ie++):(he=c,Se===0&&pt(xe)),Se--,he===c?ee=void 0:(ie=ee,ee=c),ee!==c?(l.length>ie?(he=l.charAt(ie),ie++):(he=c,Se===0&&pt(K)),he!==c?(rt=H,ee=se(he),H=ee):(ie=H,H=c)):(ie=H,H=c),H===c&&(H=ie,l.charCodeAt(ie)===92?(ee=ne,ie++):(ee=c,Se===0&&pt(pe)),ee!==c?(he=Ci(),he!==c?(rt=H,ee=se(he),H=ee):(ie=H,H=c)):(ie=H,H=c)),H}o(zn,"peg$parseSingleStringChar");function Si(){var H,ee,he;return H=ie,ee=ie,Se++,he=$n(),Se--,he===c?ee=void 0:(ie=ee,ee=c),ee!==c?(l.length>ie?(he=l.charAt(ie),ie++):(he=c,Se===0&&pt(K)),he!==c?(rt=H,ee=se(he),H=ee):(ie=H,H=c)):(ie=H,H=c),H}o(Si,"peg$parseUnquotedStringChar");function Ci(){var H,ee;return Ve.test(l.charAt(ie))?(H=l.charAt(ie),ie++):(H=c,Se===0&&pt(tt)),H===c&&(H=ie,l.charCodeAt(ie)===110?(ee=_e,ie++):(ee=c,Se===0&&pt(St)),ee!==c&&(rt=H,ee=We()),H=ee,H===c&&(H=ie,l.charCodeAt(ie)===114?(ee=Ke,ie++):(ee=c,Se===0&&pt(Ge)),ee!==c&&(rt=H,ee=Xe()),H=ee,H===c&&(H=ie,l.charCodeAt(ie)===116?(ee=nr,ie++):(ee=c,Se===0&&pt(ct)),ee!==c&&(rt=H,ee=Hr()),H=ee))),H}o(Ci,"peg$parseEscapeSequence");function $n(){var H,ee;return Se++,_t.test(l.charAt(ie))?(H=l.charAt(ie),ie++):(H=c,Se===0&&pt(Ct)),Se--,H===c&&(ee=c,Se===0&&pt(Zt)),H}o($n,"peg$parsews");function Mn(){var H,ee;return Se++,Lr.test(l.charAt(ie))?(H=l.charAt(ie),ie++):(H=c,Se===0&&pt(zt)),Se--,H===c&&(ee=c,Se===0&&pt(ut)),H}o(Mn,"peg$parsecc");function Js(){var H,ee;for(Se++,H=[],ee=$n();ee!==c;)H.push(ee),ee=$n();return Se--,H===c&&(ee=c,Se===0&&pt($t)),H}if(o(Js,"peg$parse__"),Or=C(),Or!==c&&ie===l.length)return Or;throw Or!==c&&ie{t&&t.current.addEventListener("DOMNodeInserted",n=>{let l=n.currentTarget;l.scroll({top:l.scrollHeight,behavior:"auto"})})},[]),Je.default.createElement("div",{className:"command-result",ref:t},e.map((n,l)=>Je.default.createElement("div",{key:l},Je.default.createElement("div",null,Je.default.createElement("strong",null,"$ ",n.command)),n.result)))}o(GB,"Results");function YB({nextArgs:e,currentArg:t,help:n,description:l,availableCommands:d}){let h=[];for(let c=0;c0&&Je.default.createElement("div",null,Je.default.createElement("strong",null,"Argument suggestion:")," ",h),(n==null?void 0:n.includes("->"))&&Je.default.createElement("div",null,Je.default.createElement("strong",null,"Signature help: "),n),l&&Je.default.createElement("div",null,"# ",l),Je.default.createElement("div",null,Je.default.createElement("strong",null,"Available Commands: "),Je.default.createElement("p",{className:"available-commands"},JSON.stringify(d)))))}o(YB,"CommandHelp");function $C(){let[e,t]=(0,Je.useState)(""),[n,l]=(0,Je.useState)(""),[d,h]=(0,Je.useState)(0),[c,v]=(0,Je.useState)([]),[C,k]=(0,Je.useState)([]),[O,j]=(0,Je.useState)({}),[B,X]=(0,Je.useState)([]),[J,Z]=(0,Je.useState)(0),[R,A]=(0,Je.useState)(""),[I,G]=(0,Je.useState)(""),[K,se]=(0,Je.useState)([]),[ne,pe]=(0,Je.useState)([]),[me,xe]=(0,Je.useState)(void 0);(0,Je.useEffect)(()=>{kt("/commands",{method:"GET"}).then(We=>We.json()).then(We=>{j(We),v(zC(We)),k(Object.keys(We))}).catch(We=>console.error(We))},[]),(0,Je.useEffect)(()=>{Pf("commands.history.get").then(We=>{pe(We.value)}).catch(We=>console.error(We))},[]);let Ve=o((We,Ke)=>{var ct,Hr,Zt;let Ge=Ay.parse(Ke),Xe=Ay.parse(We);A((ct=O[Ge[0]])==null?void 0:ct.signature_help),G(((Hr=O[Ge[0]])==null?void 0:Hr.help)||""),v(zC(O,Xe[0])),k(zC(O,Ge[0]));let nr=(Zt=O[Ge[0]])==null?void 0:Zt.parameters.map(_t=>_t.name);nr&&(X([Ge[0],...nr]),Z(Ge.length-1))},"parseCommand"),tt=o(We=>{t(We.target.value),l(We.target.value),h(0)},"onChange"),_e=o(We=>{if(We.key==="Enter"){let[Ke,...Ge]=Ay.parse(e);pe([...ne,e]),Pf("commands.history.add",e).catch(()=>0),kt.post(`/commands/${Ke}`,{arguments:Ge}).then(Xe=>Xe.json()).then(Xe=>{xe(void 0),X([]),se([...K,{command:e,result:JSON.stringify(Xe.value||Xe.error)}])}).catch(Xe=>{xe(void 0),X([]),se([...K,{command:e,result:Xe.toString()}])}),A(""),G(""),t(""),l(""),h(0),v(C)}if(We.key==="ArrowUp"){let Ke;me===void 0?Ke=ne.length-1:Ke=Math.max(0,me-1),t(ne[Ke]),l(ne[Ke]),xe(Ke)}if(We.key==="ArrowDown"){if(me===void 0)return;if(me==ne.length-1)t(""),l(""),xe(void 0);else{let Ke=me+1;t(ne[Ke]),l(ne[Ke]),xe(Ke)}}We.key==="Tab"&&(t(c[d]),h((d+1)%c.length),We.preventDefault()),We.stopPropagation()},"onKeyDown"),St=o(We=>{if(!e){k(Object.keys(O));return}Ve(n,e),We.stopPropagation()},"onKeyUp");return Je.default.createElement("div",{className:"command"},Je.default.createElement("div",{className:"command-title"},"Command Result"),Je.default.createElement(GB,{results:K}),Je.default.createElement(YB,{nextArgs:B,currentArg:J,help:R,description:I,availableCommands:C}),Je.default.createElement("div",{className:(0,XP.default)("command-input input-group")},Je.default.createElement("span",{className:"input-group-addon"},Je.default.createElement("i",{className:"fa fa-fw fa-terminal"})),Je.default.createElement("input",{type:"text",placeholder:"Enter command",className:"form-control",value:e||"",onChange:tt,onKeyDown:_e,onKeyUp:St})))}o($C,"CommandBar");var Wl=fe(Oe()),rd=fe(Cm());var jC=fe(Oe());function qC({checked:e,onToggle:t,text:n}){return jC.default.createElement("div",{className:"btn btn-toggle "+(e?"btn-primary":"btn-default"),onClick:t},jC.default.createElement("i",{className:"fa fa-fw "+(e?"fa-check-square-o":"fa-square-o")}),"\xA0",n)}o(qC,"ToggleButton");var Hl=fe(Oe()),VC=fe(Cm()),QP=fe(iu()),ZP=fe(cC());var Dm=class extends Hl.Component{constructor(t){super(t);this.heights={},this.state={vScroll:jf()},this.onViewportUpdate=this.onViewportUpdate.bind(this)}componentDidMount(){window.addEventListener("resize",this.onViewportUpdate),this.onViewportUpdate()}componentWillUnmount(){window.removeEventListener("resize",this.onViewportUpdate)}componentDidUpdate(){this.onViewportUpdate()}onViewportUpdate(){let t=QP.default.findDOMNode(this),n=jf({itemCount:this.props.events.length,rowHeight:this.props.rowHeight,viewportTop:t.scrollTop,viewportHeight:t.offsetHeight,itemHeights:this.props.events.map(l=>this.heights[l.id])});(0,ZP.default)(this.state.vScroll,n)||this.setState({vScroll:n})}setHeight(t,n){if(n&&!this.heights[t]){let l=n.offsetHeight;this.heights[t]!==l&&(this.heights[t]=l,this.onViewportUpdate())}}render(){let{vScroll:t}=this.state,{events:n}=this.props;return Hl.default.createElement("pre",{onScroll:this.onViewportUpdate},Hl.default.createElement("div",{style:{height:t.paddingTop}}),n.slice(t.start,t.end).map(l=>Hl.default.createElement("div",{key:l.id,ref:d=>this.setHeight(l.id,d)},Hl.default.createElement(XB,{event:l}),l.message)),Hl.default.createElement("div",{style:{height:t.paddingBottom}}))}};o(Dm,"EventLogList"),Dm.propTypes={events:VC.default.array.isRequired,rowHeight:VC.default.number},Dm.defaultProps={rowHeight:18};function XB({event:e}){let t={web:"html5",debug:"bug",warn:"exclamation-triangle",error:"ban"}[e.level]||"info";return Hl.default.createElement("i",{className:`fa fa-fw fa-${t}`})}o(XB,"LogIcon");var JP=hy(Dm);var Rm=class extends Wl.Component{constructor(t,n){super(t,n);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(t){t.preventDefault(),this.dragStart=this.state.height+t.pageY,window.addEventListener("mousemove",this.onDragMove),window.addEventListener("mouseup",this.onDragStop),window.addEventListener("dragend",this.onDragStop)}onDragMove(t){t.preventDefault(),this.setState({height:this.dragStart-t.pageY})}onDragStop(t){t.preventDefault(),window.removeEventListener("mousemove",this.onDragMove)}render(){let{height:t}=this.state,{filters:n,events:l,toggleFilter:d,close:h}=this.props;return Wl.default.createElement("div",{className:"eventlog",style:{height:t}},Wl.default.createElement("div",{onMouseDown:this.onDragStart},"Eventlog",Wl.default.createElement("div",{className:"pull-right"},["debug","info","web","warn","error"].map(c=>Wl.default.createElement(qC,{key:c,text:c,checked:n[c],onToggle:()=>d(c)})),Wl.default.createElement("i",{onClick:h,className:"fa fa-close"}))),Wl.default.createElement(JP,{events:l}))}};o(Rm,"PureEventLog"),Vc(Rm,"propTypes",{filters:rd.default.object.isRequired,events:rd.default.array.isRequired,toggleFilter:rd.default.func.isRequired,close:rd.default.func.isRequired,defaultHeight:rd.default.number}),Vc(Rm,"defaultProps",{defaultHeight:200});var eO=Hi(e=>({filters:e.eventLog.filters,events:e.eventLog.view}),{close:Rp,toggleFilter:vN})(Rm);var un=fe(Oe());function KC(){let e=qe(A=>A.backendState.version),{mode:t,intercept:n,showhost:l,upstream_cert:d,rawtcp:h,http2:c,websocket:v,anticache:C,anticomp:k,stickyauth:O,stickycookie:j,stream_large_bodies:B,listen_host:X,listen_port:J,server:Z,ssl_insecure:R}=qe(A=>A.options);return un.createElement("footer",null,t&&(t.length!==1||t[0]!=="regular")&&un.createElement("span",{className:"label label-success"},t.join(",")),n&&un.createElement("span",{className:"label label-success"},"Intercept: ",n),R&&un.createElement("span",{className:"label label-danger"},"ssl_insecure"),l&&un.createElement("span",{className:"label label-success"},"showhost"),!d&&un.createElement("span",{className:"label label-success"},"no-upstream-cert"),!h&&un.createElement("span",{className:"label label-success"},"no-raw-tcp"),!c&&un.createElement("span",{className:"label label-success"},"no-http2"),!v&&un.createElement("span",{className:"label label-success"},"no-websocket"),C&&un.createElement("span",{className:"label label-success"},"anticache"),k&&un.createElement("span",{className:"label label-success"},"anticomp"),O&&un.createElement("span",{className:"label label-success"},"stickyauth: ",O),j&&un.createElement("span",{className:"label label-success"},"stickycookie: ",j),B&&un.createElement("span",{className:"label label-success"},"stream: ",S0(B)),un.createElement("div",{className:"pull-right"},un.createElement(Ro,null,Z&&un.createElement("span",{className:"label label-primary",title:"HTTP Proxy Server Address"},X||"*",":",J||8080)),un.createElement("span",{className:"label label-default",title:"Mitmproxy Version"},"mitmproxy ",e)))}o(KC,"Footer");var eb=fe(Oe());var JC=fe(Oe());var nd=fe(Oe());function GC({children:e}){return nd.createElement("div",null,nd.createElement("div",{className:"modal-backdrop fade in"}),nd.createElement("div",{className:"modal modal-visible",id:"optionsModal",tabIndex:-1,role:"dialog","aria-labelledby":"options"},nd.createElement("div",{className:"modal-dialog modal-lg",role:"document"},nd.createElement("div",{className:"modal-content"},e))))}o(GC,"ModalLayout");var mr=fe(Oe());var Fo=fe(Oe()),Bo=fe(Cm());var tO=fe(ti()),QB=o(e=>{e.key!=="Escape"&&e.stopPropagation()},"stopPropagation");YC.propTypes={value:Bo.default.bool.isRequired,onChange:Bo.default.func.isRequired};function YC(l){var d=l,{value:e,onChange:t}=d,n=Ws(d,["value","onChange"]);return Fo.default.createElement("div",{className:"checkbox"},Fo.default.createElement("label",null,Fo.default.createElement("input",ke({type:"checkbox",checked:e,onChange:h=>t(h.target.checked)},n)),"Enable"))}o(YC,"BooleanOption");XC.propTypes={value:Bo.default.string,onChange:Bo.default.func.isRequired};function XC(l){var d=l,{value:e,onChange:t}=d,n=Ws(d,["value","onChange"]);return Fo.default.createElement("input",ke({type:"text",value:e||"",onChange:h=>t(h.target.value)},n))}o(XC,"StringOption");function rO(e){return function(l){var d=l,{onChange:t}=d,n=Ws(d,["onChange"]);return Fo.default.createElement(e,ke({onChange:h=>t(h||null)},n))}}o(rO,"Optional");QC.propTypes={value:Bo.default.number.isRequired,onChange:Bo.default.func.isRequired};function QC(l){var d=l,{value:e,onChange:t}=d,n=Ws(d,["value","onChange"]);return Fo.default.createElement("input",ke({type:"number",value:e,onChange:h=>t(parseInt(h.target.value))},n))}o(QC,"NumberOption");nO.propTypes={value:Bo.default.string.isRequired,onChange:Bo.default.func.isRequired};function nO(d){var h=d,{value:e,onChange:t,choices:n}=h,l=Ws(h,["value","onChange","choices"]);return Fo.default.createElement("select",ke({onChange:c=>t(c.target.value),value:e},l),n.map(c=>Fo.default.createElement("option",{key:c,value:c},c)))}o(nO,"ChoicesOption");iO.propTypes={value:Bo.default.arrayOf(Bo.default.string).isRequired,onChange:Bo.default.func.isRequired};function iO(l){var d=l,{value:e,onChange:t}=d,n=Ws(d,["value","onChange"]);let h=Math.max(e.length,1);return Fo.default.createElement("textarea",ke({rows:h,value:e.join(` +`),J}return Nf(function(){C.current=e,k.current=j,O.current=B,v.current=void 0}),Nf(function(){function J(){try{var Z=n.getState(),R=C.current(Z);if(t(R,O.current))return;O.current=R,k.current=Z}catch(A){v.current=A}h()}return o(J,"checkForUpdates"),c.onStateChange=J,c.trySubscribe(),J(),function(){return c.tryUnsubscribe()}},[n,c]),B}o(pF,"useSelectorWithStoreAndSubscription");function Hk(e){e===void 0&&(e=ei);var t=e===ei?v0:function(){return(0,ro.useContext)(e)};return o(function(l,d){d===void 0&&(d=cF);var h=t(),c=h.store,v=h.subscription,C=pF(l,d,c,v);return(0,ro.useDebugValue)(C),C},"useSelector")}o(Hk,"createSelectorHook");var Jx=Hk();var eS=fe(iu());ck(eS.unstable_batchedUpdates);var Wn=fe(Oe());var Wk="UI_FLOWVIEW_SET_TAB",Uk="SET_CONTENT_VIEW_FOR",dF={tab:"request",contentViewFor:{}};function tS(e=dF,t){switch(t.type){case Uk:return Lt(ke({},e),{contentViewFor:Lt(ke({},e.contentViewFor),{[t.messageId]:t.contentView})});case Wk:return Lt(ke({},e),{tab:t.tab?t.tab:"request"});default:return e}}o(tS,"reducer");function Pf(e){return{type:Wk,tab:e}}o(Pf,"selectTab");function w0(e,t){return{type:Uk,messageId:e,contentView:t}}o(w0,"setContentViewFor");var zk=fe(Qh()),hF=fe(Oe());window._=zk.default;window.React=hF;var x0=o(function(e){if(e===0)return"0";for(var t=["b","kb","mb","gb","tb"],n=0;ne);n++);var l;return e%Math.pow(1024,n)==0?l=0:l=1,(e/Math.pow(1024,n)).toFixed(l)+t[n]},"formatSize"),S0=o(function(e){for(var t=e,n=["ms","s","min","h"],l=[1e3,60,60],d=0;Math.abs(t)>=l[d]&&dkt(e,ke({method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},n));kt.post=(e,t,n={})=>kt(e,ke({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},n));function Lf(e,...t){return Ia(this,null,function*(){return yield(yield kt(`/commands/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({arguments:t})})).json()})}o(Lf,"runCommand");var Jh={};Hb(Jh,{ADD:()=>aS,RECEIVE:()=>cS,REMOVE:()=>fS,SET_FILTER:()=>sS,SET_SORT:()=>lS,UPDATE:()=>uS,add:()=>vF,defaultState:()=>C0,receive:()=>xF,reduce:()=>Pp,remove:()=>wF,setFilter:()=>pS,setSort:()=>jk,update:()=>yF});var oS=fe($k()),sS="LIST_SET_FILTER",lS="LIST_SET_SORT",aS="LIST_ADD",uS="LIST_UPDATE",fS="LIST_REMOVE",cS="LIST_RECEIVE",C0={byId:{},list:[],listIndex:{},view:[],viewIndex:{}};function Pp(e=C0,t){let{byId:n,list:l,listIndex:d,view:h,viewIndex:c}=e;switch(t.type){case sS:h=(0,oS.default)(l.filter(t.filter),t.sort),c={},h.forEach((k,O)=>{c[k.id]=O});break;case lS:h=(0,oS.default)([...h],t.sort),c={},h.forEach((k,O)=>{c[k.id]=O});break;case aS:if(t.item.id in n)break;n=Lt(ke({},n),{[t.item.id]:t.item}),d=Lt(ke({},d),{[t.item.id]:l.length}),l=[...l,t.item],t.filter(t.item)&&({view:h,viewIndex:c}=qk(e,t.item,t.sort));break;case uS:n=Lt(ke({},n),{[t.item.id]:t.item}),l=[...l],l[d[t.item.id]]=t.item;let v=t.item.id in c,C=t.filter(t.item);C&&!v?{view:h,viewIndex:c}=qk(e,t.item,t.sort):!C&&v?{data:h,dataIndex:c}=dS(h,c,t.item.id):C&&v&&({view:h,viewIndex:c}=SF(e,t.item,t.sort));break;case fS:if(!(t.id in n))break;n=ke({},n),delete n[t.id],{data:l,dataIndex:d}=dS(l,d,t.id),t.id in c&&({data:h,dataIndex:c}=dS(h,c,t.id));break;case cS:l=t.list,d={},n={},l.forEach((k,O)=>{n[k.id]=k,d[k.id]=O}),h=l.filter(t.filter).sort(t.sort),c={},h.forEach((k,O)=>{c[k.id]=O});break}return{byId:n,list:l,listIndex:d,view:h,viewIndex:c}}o(Pp,"reduce");function pS(e=b0,t=Zh){return{type:sS,filter:e,sort:t}}o(pS,"setFilter");function jk(e=Zh){return{type:lS,sort:e}}o(jk,"setSort");function vF(e,t=b0,n=Zh){return{type:aS,item:e,filter:t,sort:n}}o(vF,"add");function yF(e,t=b0,n=Zh){return{type:uS,item:e,filter:t,sort:n}}o(yF,"update");function wF(e){return{type:fS,id:e}}o(wF,"remove");function xF(e,t=b0,n=Zh){return{type:cS,list:e,filter:t,sort:n}}o(xF,"receive");function qk(e,t,n){let l=CF(e.view,t,n),d=[...e.view],h=ke({},e.viewIndex);d.splice(l,0,t);for(let c=d.length-1;c>=l;c--)h[d[c].id]=c;return{view:d,viewIndex:h}}o(qk,"sortedInsert");function dS(e,t,n){let l=t[n],d=[...e],h=ke({},t);delete h[n],d.splice(l,1);for(let c=d.length-1;c>=l;c--)h[d[c].id]=c;return{data:d,dataIndex:h}}o(dS,"removeData");function SF(e,t,n){let l=[...e.view],d=ke({},e.viewIndex),h=d[t.id];for(l[h]=t;h+10;)l[h]=l[h+1],l[h+1]=t,d[t.id]=h+1,d[l[h].id]=h,++h;for(;h>0&&n(l[h],l[h-1])<0;)l[h]=l[h-1],l[h-1]=t,d[t.id]=h-1,d[l[h].id]=h,--h;return{view:l,viewIndex:d}}o(SF,"sortedUpdate");function CF(e,t,n){let l=0,d=e.length;for(;l>>1;n(t,e[h])>=0?l=h+1:d=h}return l}o(CF,"sortedIndex");function b0(){return!0}o(b0,"defaultFilter");function Zh(e,t){return 0}o(Zh,"defaultSort");var Vk={http:80,https:443},Kr=class{static getContentType(t){var n=Kr.get_first_header(t,/^Content-Type$/i);if(n)return n.split(";")[0].trim()}static get_first_header(t,n){let l=t;l._headerLookups||Object.defineProperty(l,"_headerLookups",{value:{},configurable:!1,enumerable:!1,writable:!1});let d=n.toString();if(!(d in l._headerLookups)){let h;for(let c=0;c{var t,n;switch(e.type){case"http":let l=e.request.contentLength||0;return e.response&&(l+=e.response.contentLength||0),e.websocket&&(l+=e.websocket.messages_meta.contentLength||0),l;case"tcp":case"udp":return e.messages_meta.contentLength||0;case"dns":return(n=(t=e.response)==null?void 0:t.size)!=null?n:0}},"getTotalSize"),_0=o(e=>e.type==="http"&&!e.websocket,"canReplay");var Of=function(){"use strict";function e(l,d){function h(){this.constructor=l}o(h,"ctor"),h.prototype=d.prototype,l.prototype=new h}o(e,"peg$subclass");function t(l,d,h,c){this.message=l,this.expected=d,this.found=h,this.location=c,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t)}o(t,"peg$SyntaxError"),e(t,Error);function n(l){var d=arguments.length>1?arguments[1]:{},h=this,c={},v={start:Ou},C=Ou,k={type:"other",description:"filter expression"},O=o(function(w){return w},"peg$c1"),j={type:"other",description:"whitespace"},B=/^[ \t\n\r]/,X={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},J={type:"other",description:"control character"},Z=/^[|&!()~"]/,R={type:"class",value:'[|&!()~"]',description:'[|&!()~"]'},A={type:"other",description:"optional whitespace"},I="|",G={type:"literal",value:"|",description:'"|"'},K=o(function(w,T){return Au(w,T)},"peg$c11"),se="&",ne={type:"literal",value:"&",description:'"&"'},pe=o(function(w,T){return hd(w,T)},"peg$c14"),me="!",xe={type:"literal",value:"!",description:'"!"'},Ve=o(function(w){return Vo(w)},"peg$c17"),tt="(",Ee={type:"literal",value:"(",description:'"("'},St=")",We={type:"literal",value:")",description:'")"'},Ke=o(function(w){return yr(w)},"peg$c22"),Ge="~all",Xe={type:"literal",value:"~all",description:'"~all"'},nr=o(function(){return fc},"peg$c25"),ct="~a",Hr={type:"literal",value:"~a",description:'"~a"'},Zt=o(function(){return Ko},"peg$c28"),Et="~b",Ct={type:"literal",value:"~b",description:'"~b"'},ut=o(function(w){return na(w)},"peg$c31"),Pr="~bq",zt={type:"literal",value:"~bq",description:'"~bq"'},$t=o(function(w){return Go(w)},"peg$c34"),ie="~bs",rt={type:"literal",value:"~bs",description:'"~bs"'},Lr=o(function(w){return md(w)},"peg$c37"),Gt="~c",Yt={type:"literal",value:"~c",description:'"~c"'},Se=o(function(w){return ia(w)},"peg$c40"),Or="~comment",fn={type:"literal",value:"~comment",description:'"~comment"'},Un=o(function(w){return Ru(w)},"peg$c43"),si="~d",cn={type:"literal",value:"~d",description:'"~d"'},Jt=o(function(w){return Iu(w)},"peg$c46"),gr="~dns",pt={type:"literal",value:"~dns",description:'"~dns"'},Ho=o(function(){return oa},"peg$c49"),Cr="~dst",Ui={type:"literal",value:"~dst",description:'"~dst"'},pn=o(function(w){return Fu(w)},"peg$c52"),zn="~e",Si={type:"literal",value:"~e",description:'"~e"'},Ci=o(function(){return Bu},"peg$c55"),$n="~h",Mn={type:"literal",value:"~h",description:'"~h"'},Js=o(function(w){return Hu(w)},"peg$c58"),H="~hq",ee={type:"literal",value:"~hq",description:'"~hq"'},he=o(function(w){return Yo(w)},"peg$c61"),Te="~hs",ir={type:"literal",value:"~hs",description:'"~hs"'},Ul=o(function(w){return ji(w)},"peg$c64"),Ft="~http",Wr={type:"literal",value:"~http",description:'"~http"'},or=o(function(){return Ss},"peg$c67"),li="~marked",ds={type:"literal",value:"~marked",description:'"~marked"'},lo=o(function(){return zr},"peg$c70"),bi="~marker",el={type:"literal",value:"~marker",description:'"~marker"'},hs=o(function(w){return sa(w)},"peg$c73"),dn="~m",id={type:"literal",value:"~m",description:'"~m"'},tl=o(function(w){return mn(w)},"peg$c76"),Qf="~q",rl={type:"literal",value:"~q",description:'"~q"'},od=o(function(){return qi},"peg$c79"),Zf="~replayq",wu={type:"literal",value:"~replayq",description:'"~replayq"'},sd=o(function(){return al},"peg$c82"),zl="~replays",ms={type:"literal",value:"~replays",description:'"~replays"'},ld=o(function(){return cc},"peg$c85"),Jf="~replay",nl={type:"literal",value:"~replay",description:'"~replay"'},xu=o(function(){return Wu},"peg$c88"),Wo="~src",ad={type:"literal",value:"~src",description:'"~src"'},Uo=o(function(w){return gd(w)},"peg$c91"),$l="~s",ec={type:"literal",value:"~s",description:'"~s"'},jt=o(function(){return Uu},"peg$c94"),Me="~tcp",_i={type:"literal",value:"~tcp",description:'"~tcp"'},Su=o(function(){return la},"peg$c97"),ai="~udp",vt={type:"literal",value:"~udp",description:'"~udp"'},ao=o(function(){return qn},"peg$c100"),zo="~tq",jl={type:"literal",value:"~tq",description:'"~tq"'},ue=o(function(w){return Ti(w)},"peg$c103"),ze="~ts",Cu={type:"literal",value:"~ts",description:'"~ts"'},bu=o(function(w){return pc(w)},"peg$c106"),gs="~t",il={type:"literal",value:"~t",description:'"~t"'},_u=o(function(w){return aa(w)},"peg$c109"),He="~u",ud={type:"literal",value:"~u",description:'"~u"'},ql=o(function(w){return dc(w)},"peg$c112"),uo="~websocket",ui={type:"literal",value:"~websocket",description:'"~websocket"'},tc=o(function(){return Vi},"peg$c115"),Eu={type:"other",description:"integer"},$o=/^['"]/,vs={type:"class",value:`['"]`,description:`['"]`},Tu=/^[0-9]/,ol={type:"class",value:"[0-9]",description:"[0-9]"},Vl=o(function(w){return parseInt(w.join(""),10)},"peg$c121"),Kl={type:"other",description:"string"},fo='"',Gl={type:"literal",value:'"',description:'"\\""'},Yl=o(function(w){return w.join("")},"peg$c125"),rc="'",Xl={type:"literal",value:"'",description:`"'"`},Ei=/^["\\]/,nc={type:"class",value:'["\\\\]',description:'["\\\\]'},Ql={type:"any",description:"any character"},co=o(function(w){return w},"peg$c131"),ys="\\",ic={type:"literal",value:"\\",description:'"\\\\"'},oc=/^['\\]/,fd={type:"class",value:"['\\\\]",description:"['\\\\]"},cd=/^['"\\]/,ku={type:"class",value:`['"\\\\]`,description:`['"\\\\]`},sc="n",Nu={type:"literal",value:"n",description:'"n"'},lc=o(function(){return` +`},"peg$c140"),ac="r",Zl={type:"literal",value:"r",description:'"r"'},Jl=o(function(){return"\r"},"peg$c143"),Pu="t",Ot={type:"literal",value:"t",description:'"t"'},Nt=o(function(){return" "},"peg$c146"),L=0,Re=0,sl=[{line:1,column:1,seenCR:!1}],vr=0,Lu=[],ye=0,jo;if("startRule"in d){if(!(d.startRule in v))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');C=v[d.startRule]}function pd(){return l.substring(Re,L)}o(pd,"text");function qt(){return zi(Re,L)}o(qt,"location");function ea(w){throw ta(null,[{type:"other",description:w}],l.substring(Re,L),zi(Re,L))}o(ea,"expected");function hn(w){throw ta(w,null,l.substring(Re,L),zi(Re,L))}o(hn,"error");function ws(w){var T=sl[w],W,U;if(T)return T;for(W=w-1;!sl[W];)W--;for(T=sl[W],T={line:T.line,column:T.column,seenCR:T.seenCR};Wvr&&(vr=L,Lu=[]),Lu.push(w))}o(Ce,"peg$fail");function ta(w,T,W,U){function wr(gn){var ci=1;for(gn.sort(function(ul,ki){return ul.descriptionki.description?1:0});ci1?ki.slice(0,-1).join(", ")+" or "+ki[gn.length-1]:ki[0],zu=ci?'"'+ul(ci)+'"':"end of input","Expected "+Vn+" but "+zu+" found."}return o(Kt,"buildMessage"),T!==null&&wr(T),new t(w!==null?w:Kt(T,W),T,W,U)}o(ta,"peg$buildException");function Ou(){var w,T,W,U;return ye++,w=L,T=fi(),T!==c?(W=ll(),W!==c?(U=fi(),U!==c?(Re=w,T=O(W),w=T):(L=w,w=c)):(L=w,w=c)):(L=w,w=c),ye--,w===c&&(T=c,ye===0&&Ce(k)),w}o(Ou,"peg$parsestart");function nt(){var w,T;return ye++,B.test(l.charAt(L))?(w=l.charAt(L),L++):(w=c,ye===0&&Ce(X)),ye--,w===c&&(T=c,ye===0&&Ce(j)),w}o(nt,"peg$parsews");function uc(){var w,T;return ye++,Z.test(l.charAt(L))?(w=l.charAt(L),L++):(w=c,ye===0&&Ce(R)),ye--,w===c&&(T=c,ye===0&&Ce(J)),w}o(uc,"peg$parsecc");function fi(){var w,T;for(ye++,w=[],T=nt();T!==c;)w.push(T),T=nt();return ye--,w===c&&(T=c,ye===0&&Ce(A)),w}o(fi,"peg$parse__");function ll(){var w,T,W,U,wr,Kt;return w=L,T=Ur(),T!==c?(W=fi(),W!==c?(l.charCodeAt(L)===124?(U=I,L++):(U=c,ye===0&&Ce(G)),U!==c?(wr=fi(),wr!==c?(Kt=ll(),Kt!==c?(Re=w,T=K(T,Kt),w=T):(L=w,w=c)):(L=w,w=c)):(L=w,w=c)):(L=w,w=c)):(L=w,w=c),w===c&&(w=Ur()),w}o(ll,"peg$parseOrExpr");function Ur(){var w,T,W,U,wr,Kt;if(w=L,T=ra(),T!==c?(W=fi(),W!==c?(l.charCodeAt(L)===38?(U=se,L++):(U=c,ye===0&&Ce(ne)),U!==c?(wr=fi(),wr!==c?(Kt=Ur(),Kt!==c?(Re=w,T=pe(T,Kt),w=T):(L=w,w=c)):(L=w,w=c)):(L=w,w=c)):(L=w,w=c)):(L=w,w=c),w===c){if(w=L,T=ra(),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Ur(),U!==c?(Re=w,T=pe(T,U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;w===c&&(w=ra())}return w}o(Ur,"peg$parseAndExpr");function ra(){var w,T,W,U;return w=L,l.charCodeAt(L)===33?(T=me,L++):(T=c,ye===0&&Ce(xe)),T!==c?(W=fi(),W!==c?(U=ra(),U!==c?(Re=w,T=Ve(U),w=T):(L=w,w=c)):(L=w,w=c)):(L=w,w=c),w===c&&(w=jn()),w}o(ra,"peg$parseNotExpr");function jn(){var w,T,W,U,wr,Kt;return w=L,l.charCodeAt(L)===40?(T=tt,L++):(T=c,ye===0&&Ce(Ee)),T!==c?(W=fi(),W!==c?(U=ll(),U!==c?(wr=fi(),wr!==c?(l.charCodeAt(L)===41?(Kt=St,L++):(Kt=c,ye===0&&Ce(We)),Kt!==c?(Re=w,T=Ke(U),w=T):(L=w,w=c)):(L=w,w=c)):(L=w,w=c)):(L=w,w=c)):(L=w,w=c),w===c&&(w=dd()),w}o(jn,"peg$parseBindingExpr");function dd(){var w,T,W,U;if(w=L,l.substr(L,4)===Ge?(T=Ge,L+=4):(T=c,ye===0&&Ce(Xe)),T!==c&&(Re=w,T=nr()),w=T,w===c&&(w=L,l.substr(L,2)===ct?(T=ct,L+=2):(T=c,ye===0&&Ce(Hr)),T!==c&&(Re=w,T=Zt()),w=T,w===c)){if(w=L,l.substr(L,2)===Et?(T=Et,L+=2):(T=c,ye===0&&Ce(Ct)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=ut(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,3)===Pr?(T=Pr,L+=3):(T=c,ye===0&&Ce(zt)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=$t(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,3)===ie?(T=ie,L+=3):(T=c,ye===0&&Ce(rt)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Lr(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,2)===Gt?(T=Gt,L+=2):(T=c,ye===0&&Ce(Yt)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Mu(),U!==c?(Re=w,T=Se(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,8)===Or?(T=Or,L+=8):(T=c,ye===0&&Ce(fn)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Un(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,2)===si?(T=si,L+=2):(T=c,ye===0&&Ce(cn)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Jt(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c&&(w=L,l.substr(L,4)===gr?(T=gr,L+=4):(T=c,ye===0&&Ce(pt)),T!==c&&(Re=w,T=Ho()),w=T,w===c)){if(w=L,l.substr(L,4)===Cr?(T=Cr,L+=4):(T=c,ye===0&&Ce(Ui)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=pn(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c&&(w=L,l.substr(L,2)===zn?(T=zn,L+=2):(T=c,ye===0&&Ce(Si)),T!==c&&(Re=w,T=Ci()),w=T,w===c)){if(w=L,l.substr(L,2)===$n?(T=$n,L+=2):(T=c,ye===0&&Ce(Mn)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Js(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,3)===H?(T=H,L+=3):(T=c,ye===0&&Ce(ee)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=he(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,3)===Te?(T=Te,L+=3):(T=c,ye===0&&Ce(ir)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Ul(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c&&(w=L,l.substr(L,5)===Ft?(T=Ft,L+=5):(T=c,ye===0&&Ce(Wr)),T!==c&&(Re=w,T=or()),w=T,w===c&&(w=L,l.substr(L,7)===li?(T=li,L+=7):(T=c,ye===0&&Ce(ds)),T!==c&&(Re=w,T=lo()),w=T,w===c))){if(w=L,l.substr(L,7)===bi?(T=bi,L+=7):(T=c,ye===0&&Ce(el)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=hs(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,2)===dn?(T=dn,L+=2):(T=c,ye===0&&Ce(id)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=tl(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c&&(w=L,l.substr(L,2)===Qf?(T=Qf,L+=2):(T=c,ye===0&&Ce(rl)),T!==c&&(Re=w,T=od()),w=T,w===c&&(w=L,l.substr(L,8)===Zf?(T=Zf,L+=8):(T=c,ye===0&&Ce(wu)),T!==c&&(Re=w,T=sd()),w=T,w===c&&(w=L,l.substr(L,8)===zl?(T=zl,L+=8):(T=c,ye===0&&Ce(ms)),T!==c&&(Re=w,T=ld()),w=T,w===c&&(w=L,l.substr(L,7)===Jf?(T=Jf,L+=7):(T=c,ye===0&&Ce(nl)),T!==c&&(Re=w,T=xu()),w=T,w===c))))){if(w=L,l.substr(L,4)===Wo?(T=Wo,L+=4):(T=c,ye===0&&Ce(ad)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=Uo(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c&&(w=L,l.substr(L,2)===$l?(T=$l,L+=2):(T=c,ye===0&&Ce(ec)),T!==c&&(Re=w,T=jt()),w=T,w===c&&(w=L,l.substr(L,4)===Me?(T=Me,L+=4):(T=c,ye===0&&Ce(_i)),T!==c&&(Re=w,T=Su()),w=T,w===c&&(w=L,l.substr(L,4)===ai?(T=ai,L+=4):(T=c,ye===0&&Ce(vt)),T!==c&&(Re=w,T=ao()),w=T,w===c)))){if(w=L,l.substr(L,3)===zo?(T=zo,L+=3):(T=c,ye===0&&Ce(jl)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=ue(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,3)===ze?(T=ze,L+=3):(T=c,ye===0&&Ce(Cu)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=bu(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,2)===gs?(T=gs,L+=2):(T=c,ye===0&&Ce(il)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=_u(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.substr(L,2)===He?(T=He,L+=2):(T=c,ye===0&&Ce(ud)),T!==c){if(W=[],U=nt(),U!==c)for(;U!==c;)W.push(U),U=nt();else W=c;W!==c?(U=Vt(),U!==c?(Re=w,T=ql(U),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;w===c&&(w=L,l.substr(L,10)===uo?(T=uo,L+=10):(T=c,ye===0&&Ce(ui)),T!==c&&(Re=w,T=tc()),w=T,w===c&&(w=L,T=Vt(),T!==c&&(Re=w,T=ql(T)),w=T))}}}}}}}}}}}}}}}}}return w}o(dd,"peg$parseExpr");function Mu(){var w,T,W,U;if(ye++,w=L,$o.test(l.charAt(L))?(T=l.charAt(L),L++):(T=c,ye===0&&Ce(vs)),T===c&&(T=null),T!==c){if(W=[],Tu.test(l.charAt(L))?(U=l.charAt(L),L++):(U=c,ye===0&&Ce(ol)),U!==c)for(;U!==c;)W.push(U),Tu.test(l.charAt(L))?(U=l.charAt(L),L++):(U=c,ye===0&&Ce(ol));else W=c;W!==c?($o.test(l.charAt(L))?(U=l.charAt(L),L++):(U=c,ye===0&&Ce(vs)),U===c&&(U=null),U!==c?(Re=w,T=Vl(W),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;return ye--,w===c&&(T=c,ye===0&&Ce(Eu)),w}o(Mu,"peg$parseIntegerLiteral");function Vt(){var w,T,W,U;if(ye++,w=L,l.charCodeAt(L)===34?(T=fo,L++):(T=c,ye===0&&Ce(Gl)),T!==c){for(W=[],U=xs();U!==c;)W.push(U),U=xs();W!==c?(l.charCodeAt(L)===34?(U=fo,L++):(U=c,ye===0&&Ce(Gl)),U!==c?(Re=w,T=Yl(W),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c){if(w=L,l.charCodeAt(L)===39?(T=rc,L++):(T=c,ye===0&&Ce(Xl)),T!==c){for(W=[],U=qo();U!==c;)W.push(U),U=qo();W!==c?(l.charCodeAt(L)===39?(U=rc,L++):(U=c,ye===0&&Ce(Xl)),U!==c?(Re=w,T=Yl(W),w=T):(L=w,w=c)):(L=w,w=c)}else L=w,w=c;if(w===c)if(w=L,T=L,ye++,W=uc(),ye--,W===c?T=void 0:(L=T,T=c),T!==c){if(W=[],U=yt(),U!==c)for(;U!==c;)W.push(U),U=yt();else W=c;W!==c?(Re=w,T=Yl(W),w=T):(L=w,w=c)}else L=w,w=c}return ye--,w===c&&(T=c,ye===0&&Ce(Kl)),w}o(Vt,"peg$parseStringLiteral");function xs(){var w,T,W;return w=L,T=L,ye++,Ei.test(l.charAt(L))?(W=l.charAt(L),L++):(W=c,ye===0&&Ce(nc)),ye--,W===c?T=void 0:(L=T,T=c),T!==c?(l.length>L?(W=l.charAt(L),L++):(W=c,ye===0&&Ce(Ql)),W!==c?(Re=w,T=co(W),w=T):(L=w,w=c)):(L=w,w=c),w===c&&(w=L,l.charCodeAt(L)===92?(T=ys,L++):(T=c,ye===0&&Ce(ic)),T!==c?(W=$i(),W!==c?(Re=w,T=co(W),w=T):(L=w,w=c)):(L=w,w=c)),w}o(xs,"peg$parseDoubleStringChar");function qo(){var w,T,W;return w=L,T=L,ye++,oc.test(l.charAt(L))?(W=l.charAt(L),L++):(W=c,ye===0&&Ce(fd)),ye--,W===c?T=void 0:(L=T,T=c),T!==c?(l.length>L?(W=l.charAt(L),L++):(W=c,ye===0&&Ce(Ql)),W!==c?(Re=w,T=co(W),w=T):(L=w,w=c)):(L=w,w=c),w===c&&(w=L,l.charCodeAt(L)===92?(T=ys,L++):(T=c,ye===0&&Ce(ic)),T!==c?(W=$i(),W!==c?(Re=w,T=co(W),w=T):(L=w,w=c)):(L=w,w=c)),w}o(qo,"peg$parseSingleStringChar");function yt(){var w,T,W;return w=L,T=L,ye++,W=nt(),ye--,W===c?T=void 0:(L=T,T=c),T!==c?(l.length>L?(W=l.charAt(L),L++):(W=c,ye===0&&Ce(Ql)),W!==c?(Re=w,T=co(W),w=T):(L=w,w=c)):(L=w,w=c),w}o(yt,"peg$parseUnquotedStringChar");function $i(){var w,T;return cd.test(l.charAt(L))?(w=l.charAt(L),L++):(w=c,ye===0&&Ce(ku)),w===c&&(w=L,l.charCodeAt(L)===110?(T=sc,L++):(T=c,ye===0&&Ce(Nu)),T!==c&&(Re=w,T=lc()),w=T,w===c&&(w=L,l.charCodeAt(L)===114?(T=ac,L++):(T=c,ye===0&&Ce(Zl)),T!==c&&(Re=w,T=Jl()),w=T,w===c&&(w=L,l.charCodeAt(L)===116?(T=Pu,L++):(T=c,ye===0&&Ce(Ot)),T!==c&&(Re=w,T=Nt()),w=T))),w}o($i,"peg$parseEscapeSequence");function Au(w,T){function W(){return w.apply(this,arguments)||T.apply(this,arguments)}return o(W,"orFilter"),W.desc=w.desc+" or "+T.desc,W}o(Au,"or");function hd(w,T){function W(){return w.apply(this,arguments)&&T.apply(this,arguments)}return o(W,"andFilter"),W.desc=w.desc+" and "+T.desc,W}o(hd,"and");function Vo(w){function T(){return!w.apply(this,arguments)}return o(T,"notFilter"),T.desc="not "+w.desc,T}o(Vo,"not");function yr(w){function T(){return w.apply(this,arguments)}return o(T,"bindingFilter"),T.desc="("+w.desc+")",T}o(yr,"binding");function fc(w){return!0}o(fc,"allFilter"),fc.desc="all flows";var Du=[new RegExp("text/javascript"),new RegExp("application/x-javascript"),new RegExp("application/javascript"),new RegExp("text/css"),new RegExp("image/.*"),new RegExp("font/.*"),new RegExp("application/font.*")];function Ko(w){if(w.response){for(var T=Ys.getContentType(w.response),W=Du.length;W--;)if(Du[W].test(T))return!0}return!1}o(Ko,"assetFilter"),Ko.desc="is asset";function na(w){w=new RegExp(w,"i");function T(W){return!0}return o(T,"bodyFilter"),T.desc="body filters are not implemented yet, see https://github.com/mitmproxy/mitmproxy/issues/3609",T}o(na,"body");function Go(w){w=new RegExp(w,"i");function T(W){return!0}return o(T,"requestBodyFilter"),T.desc="body filters are not implemented yet, see https://github.com/mitmproxy/mitmproxy/issues/3609",T}o(Go,"requestBody");function md(w){w=new RegExp(w,"i");function T(W){return!0}return o(T,"responseBodyFilter"),T.desc="body filters are not implemented yet, see https://github.com/mitmproxy/mitmproxy/issues/3609",T}o(md,"responseBody");function ia(w){function T(W){return W.response&&W.response.status_code===w}return o(T,"responseCodeFilter"),T.desc="resp. code is "+w,T}o(ia,"responseCode");function Ru(w){w=new RegExp(w,"i");function T(W){return w.test(W.comment)}return o(T,"commentFilter"),T.desc="comment matches "+w,T}o(Ru,"comment");function Iu(w){w=new RegExp(w,"i");function T(W){return W.request&&(w.test(W.request.host)||w.test(W.request.pretty_host))}return o(T,"domainFilter"),T.desc="domain matches "+w,T}o(Iu,"domain");function oa(w){return w.type==="dns"}o(oa,"dnsFilter"),oa.desc="is a DNS Flow";function Fu(w){w=new RegExp(w,"i");function T(W){return!!W.server_conn.address&&w.test(W.server_conn.address[0]+":"+W.server_conn.address[1])}return o(T,"destinationFilter"),T.desc="destination address matches "+w,T}o(Fu,"destination");function Bu(w){return!!w.error}o(Bu,"errorFilter"),Bu.desc="has error";function Hu(w){w=new RegExp(w,"i");function T(W){return W.request&&Oo.match_header(W.request,w)||W.response&&Ys.match_header(W.response,w)}return o(T,"headerFilter"),T.desc="header matches "+w,T}o(Hu,"header");function Yo(w){w=new RegExp(w,"i");function T(W){return W.request&&Oo.match_header(W.request,w)}return o(T,"requestHeaderFilter"),T.desc="req. header matches "+w,T}o(Yo,"requestHeader");function ji(w){w=new RegExp(w,"i");function T(W){return W.response&&Ys.match_header(W.response,w)}return o(T,"responseHeaderFilter"),T.desc="resp. header matches "+w,T}o(ji,"responseHeader");function Ss(w){return w.type==="http"}o(Ss,"httpFilter"),Ss.desc="is an HTTP Flow";function zr(w){return w.marked}o(zr,"markedFilter"),zr.desc="is marked";function sa(w){w=new RegExp(w,"i");function T(W){return w.test(W.marked)}return o(T,"markerFilter"),T.desc="marker matches "+w,T}o(sa,"marker");function mn(w){w=new RegExp(w,"i");function T(W){return W.request&&w.test(W.request.method)}return o(T,"methodFilter"),T.desc="method matches "+w,T}o(mn,"method");function qi(w){return w.request&&!w.response}o(qi,"noResponseFilter"),qi.desc="has no response";function al(w){return w.is_replay==="request"}o(al,"clientReplayFilter"),al.desc="request has been replayed";function cc(w){return w.is_replay==="response"}o(cc,"serverReplayFilter"),cc.desc="response has been replayed";function Wu(w){return!!w.is_replay}o(Wu,"replayFilter"),Wu.desc="flow has been replayed";function gd(w){w=new RegExp(w,"i");function T(W){return!!W.client_conn.peername&&w.test(W.client_conn.peername[0]+":"+W.client_conn.peername[1])}return o(T,"sourceFilter"),T.desc="source address matches "+w,T}o(gd,"source");function Uu(w){return!!w.response}o(Uu,"responseFilter"),Uu.desc="has response";function la(w){return w.type==="tcp"}o(la,"tcpFilter"),la.desc="is a TCP Flow";function qn(w){return w.type==="udp"}o(qn,"udpFilter"),qn.desc="is a UDP Flow";function Ti(w){w=new RegExp(w,"i");function T(W){return W.request&&w.test(Oo.getContentType(W.request))}return o(T,"requestContentTypeFilter"),T.desc="req. content type matches "+w,T}o(Ti,"requestContentType");function pc(w){w=new RegExp(w,"i");function T(W){return W.response&&w.test(Ys.getContentType(W.response))}return o(T,"responseContentTypeFilter"),T.desc="resp. content type matches "+w,T}o(pc,"responseContentType");function aa(w){w=new RegExp(w,"i");function T(W){return W.request&&w.test(Oo.getContentType(W.request))||W.response&&w.test(Ys.getContentType(W.response))}return o(T,"contentTypeFilter"),T.desc="content type matches "+w,T}o(aa,"contentType");function dc(w){w=new RegExp(w,"i");function T(W){var U;if(W.type==="dns"){let wr=(U=W.request)==null?void 0:U.questions[0];return wr&&w.test(wr.name)}return W.request&&w.test(Oo.pretty_url(W.request))}return o(T,"urlFilter"),T.desc="url matches "+w,T}o(dc,"url");function Vi(w){return!!w.websocket}if(o(Vi,"websocketFilter"),Vi.desc="is a Websocket Flow",jo=C(),jo!==c&&L===l.length)return jo;throw jo!==c&&LyS,icon:()=>N0,method:()=>tm,path:()=>P0,quickactions:()=>Lp,size:()=>L0,status:()=>nm,time:()=>O0,timestamp:()=>M0,tls:()=>k0,version:()=>rm});var Xt=fe(Oe());var T0=fe(ti());var k0=o(({flow:e})=>Xt.default.createElement("td",{className:(0,T0.default)("col-tls",e.client_conn.tls_established?"col-tls-https":"col-tls-http")}),"tls");k0.headerName="";k0.sortKey=e=>e.type==="http"&&e.request.scheme;var N0=o(({flow:e})=>Xt.default.createElement("td",{className:"col-icon"},Xt.default.createElement("div",{className:(0,T0.default)("resource-icon",Kk(e))})),"icon");N0.headerName="";N0.sortKey=e=>Kk(e);var Kk=o(e=>{if(e.type!=="http")return e.client_conn.tls_version==="QUIC"?"resource-icon-quic":`resource-icon-${e.type}`;if(e.websocket)return"resource-icon-websocket";if(!e.response)return"resource-icon-plain";var t=Ys.getContentType(e.response)||"";return e.response.status_code===304?"resource-icon-not-modified":300<=e.response.status_code&&e.response.status_code<400?"resource-icon-redirect":t.indexOf("image")>=0?"resource-icon-image":t.indexOf("javascript")>=0?"resource-icon-js":t.indexOf("css")>=0?"resource-icon-css":t.indexOf("html")>=0?"resource-icon-document":"resource-icon-plain"},"getIcon"),Gk=o(e=>{var t,n,l,d;switch(e.type){case"http":return Oo.pretty_url(e.request);case"tcp":case"udp":return`${e.client_conn.peername.join(":")} \u2194 ${(n=(t=e.server_conn)==null?void 0:t.address)==null?void 0:n.join(":")}`;case"dns":return`${e.request.questions.map(h=>`${h.name} ${h.type}`).join(", ")} = ${((d=(l=e.response)==null?void 0:l.answers.map(h=>h.data).join(", "))!=null?d:"...")||"?"}`}},"mainPath"),P0=o(({flow:e})=>{let t;return e.error&&(e.error.msg==="Connection killed."?t=Xt.default.createElement("i",{className:"fa fa-fw fa-times pull-right"}):t=Xt.default.createElement("i",{className:"fa fa-fw fa-exclamation pull-right"})),Xt.default.createElement("td",{className:"col-path"},e.is_replay==="request"&&Xt.default.createElement("i",{className:"fa fa-fw fa-repeat pull-right"}),e.intercepted&&Xt.default.createElement("i",{className:"fa fa-fw fa-pause pull-right"}),t,Xt.default.createElement("span",{className:"marker pull-right"},e.marked),Gk(e))},"path");P0.headerName="Path";P0.sortKey=e=>Gk(e);var tm=o(({flow:e})=>Xt.default.createElement("td",{className:"col-method"},tm.sortKey(e)),"method");tm.headerName="Method";tm.sortKey=e=>{switch(e.type){case"http":return e.websocket?e.client_conn.tls_established?"WSS":"WS":e.request.method;case"dns":return e.request.op_code;default:return e.type.toUpperCase()}};var rm=o(({flow:e})=>Xt.default.createElement("td",{className:"col-http-version"},rm.sortKey(e)),"version");rm.headerName="Version";rm.sortKey=e=>{switch(e.type){case"http":return e.request.http_version;default:return""}};var nm=o(({flow:e})=>{let t="darkred";return e.type!=="http"&&e.type!="dns"||!e.response?Xt.default.createElement("td",{className:"col-status"}):(100<=e.response.status_code&&e.response.status_code<200?t="green":200<=e.response.status_code&&e.response.status_code<300?t="darkgreen":300<=e.response.status_code&&e.response.status_code<400?t="lightblue":(400<=e.response.status_code&&e.response.status_code<500||500<=e.response.status_code&&e.response.status_code<600)&&(t="red"),Xt.default.createElement("td",{className:"col-status",style:{color:t}},nm.sortKey(e)))},"status");nm.headerName="Status";nm.sortKey=e=>{var t,n;switch(e.type){case"http":return(t=e.response)==null?void 0:t.status_code;case"dns":return(n=e.response)==null?void 0:n.response_code;default:return}};var L0=o(({flow:e})=>Xt.default.createElement("td",{className:"col-size"},x0(vS(e))),"size");L0.headerName="Size";L0.sortKey=e=>vS(e);var O0=o(({flow:e})=>{let t=em(e),n=gS(e);return Xt.default.createElement("td",{className:"col-time"},t&&n?S0(1e3*(n-t)):"...")},"time");O0.headerName="Time";O0.sortKey=e=>{let t=em(e),n=gS(e);return t&&n&&n-t};var M0=o(({flow:e})=>{let t=em(e);return Xt.default.createElement("td",{className:"col-timestamp"},t?no(t):"...")},"timestamp");M0.headerName="Start time";M0.sortKey=e=>em(e);var Lp=o(({flow:e})=>{let t=Gs(),[n,l]=(0,Xt.useState)(!1),d=null;return e.intercepted?d=Xt.default.createElement("a",{href:"#",className:"quickaction",onClick:()=>t(Op(e))},Xt.default.createElement("i",{className:"fa fa-fw fa-play text-success"})):_0(e)&&(d=Xt.default.createElement("a",{href:"#",className:"quickaction",onClick:()=>t(Mp(e))},Xt.default.createElement("i",{className:"fa fa-fw fa-repeat text-primary"}))),Xt.default.createElement("td",{className:(0,T0.default)("col-quickactions",{hover:n}),onClick:()=>0},d?Xt.default.createElement("div",null,d):Xt.default.createElement(Xt.default.Fragment,null))},"quickactions");Lp.headerName="";Lp.sortKey=e=>0;var yS={icon:N0,method:tm,version:rm,path:P0,quickactions:Lp,size:L0,status:nm,time:O0,timestamp:M0,tls:k0};var EF="FLOWS_ADD",TF="FLOWS_UPDATE",Yk="FLOWS_REMOVE",kF="FLOWS_RECEIVE",Xk="FLOWS_SELECT",Qk="FLOWS_SET_FILTER",Zk="FLOWS_SET_SORT",Jk="FLOWS_SET_HIGHLIGHT",NF=ke({highlight:void 0,filter:void 0,sort:{column:void 0,desc:!1},selected:[]},C0);function wS(e=NF,t){switch(t.type){case EF:case TF:case Yk:case kF:let n=Jh[t.cmd](t.data,eN(e.filter),xS(e.sort)),l=e.selected;if(t.type===Yk&&e.selected.includes(t.data)){if(e.selected.length>1)l=l.filter(d=>d!==t.data);else if(l=[],t.data in e.viewIndex&&e.view.length>1){let d=e.viewIndex[t.data],h;d===e.view.length-1?h=e.view[d-1]:h=e.view[d+1],l.push(h.id)}}return ke(Lt(ke({},e),{selected:l}),Pp(e,n));case Qk:return ke(Lt(ke({},e),{filter:t.filter}),Pp(e,pS(eN(t.filter),xS(e.sort))));case Jk:return Lt(ke({},e),{highlight:t.highlight});case Zk:return ke(Lt(ke({},e),{sort:t.sort}),Pp(e,jk(xS(t.sort))));case Xk:return Lt(ke({},e),{selected:t.flowIds});default:return e}}o(wS,"reducer");function eN(e){if(!!e)return Of.parse(e)}o(eN,"makeFilter");function xS({column:e,desc:t}){if(!e)return(l,d)=>0;let n=yS[e].sortKey;return(l,d)=>{let h=n(l),c=n(d);return h>c?t?-1:1:hkt(`/flows/${e.id}/resume`,{method:"POST"})}o(Op,"resume");function R0(){return e=>kt("/flows/resume",{method:"POST"})}o(R0,"resumeAll");function I0(e){return t=>kt(`/flows/${e.id}/kill`,{method:"POST"})}o(I0,"kill");function rN(){return e=>kt("/flows/kill",{method:"POST"})}o(rN,"killAll");function F0(e){return t=>kt(`/flows/${e.id}`,{method:"DELETE"})}o(F0,"remove");function B0(e){return t=>kt(`/flows/${e.id}/duplicate`,{method:"POST"})}o(B0,"duplicate");function Mp(e){return t=>kt(`/flows/${e.id}/replay`,{method:"POST"})}o(Mp,"replay");function H0(e){return t=>kt(`/flows/${e.id}/revert`,{method:"POST"})}o(H0,"revert");function Wi(e,t){return n=>kt.put(`/flows/${e.id}`,t)}o(Wi,"update");function nN(e,t,n){let l=new FormData;return t=new window.Blob([t],{type:"plain/text"}),l.append("file",t),d=>kt(`/flows/${e.id}/${n}/content.data`,{method:"POST",body:l})}o(nN,"uploadContent");function W0(){return e=>kt("/clear",{method:"POST"})}o(W0,"clear");function iN(e){let t=new FormData;return t.append("file",e),n=>kt("/flows/dump",{method:"POST",body:t})}o(iN,"upload");function Af(e){return{type:Xk,flowIds:e?[e]:[]}}o(Af,"select");var U0="UI_HIDE_MODAL",oN="UI_SET_ACTIVE_MODAL",PF={activeModal:void 0};function SS(e=PF,t){switch(t.type){case oN:return Lt(ke({},e),{activeModal:t.activeModal});case U0:return Lt(ke({},e),{activeModal:void 0});default:return e}}o(SS,"reducer");function sN(e){return{type:oN,activeModal:e}}o(sN,"setActiveModal");function z0(){return{type:U0}}o(z0,"hideModal");var wm=fe(Oe());var Ut=fe(Oe());var Dp=fe(Oe());var om=fe(Oe()),lN=fe(ti()),aN=(()=>{let e=document.createElement("div");return e.setAttribute("contenteditable","PLAINTEXT-ONLY"),e.contentEditable==="plaintext-only"?"plaintext-only":"true"})(),Ap=!1,Xs=class extends om.Component{constructor(){super(...arguments);this.input=om.default.createRef();this.isEditing=o(()=>{var t;return((t=this.input.current)==null?void 0:t.contentEditable)===aN},"isEditing");this.startEditing=o(()=>{if(!this.input.current)return console.error("unreachable");this.isEditing()||(this.suppress_events=!0,this.input.current.blur(),this.input.current.contentEditable=aN,window.requestAnimationFrame(()=>{var l,d;if(!this.input.current)return;this.input.current.focus(),this.suppress_events=!1;let t=document.createRange();t.selectNodeContents(this.input.current);let n=window.getSelection();n==null||n.removeAllRanges(),n==null||n.addRange(t),(d=(l=this.props).onEditStart)==null||d.call(l)}))},"startEditing");this.resetValue=o(()=>{var t,n;if(!this.input.current)return console.error("unreachable");this.input.current.textContent=this.props.content,(n=(t=this.props).onInput)==null||n.call(t,this.props.content)},"resetValue");this.finishEditing=o(()=>{if(!this.input.current)return console.error("unreachable");this.props.onEditDone(this.input.current.textContent||""),this.input.current.blur(),this.input.current.contentEditable="inherit"},"finishEditing");this.onPaste=o(t=>{t.preventDefault();let n=t.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,n)},"onPaste");this.suppress_events=!1;this.onMouseDown=o(t=>{Ap&&console.debug("onMouseDown",this.suppress_events),this.suppress_events=!0,window.addEventListener("mouseup",this.onMouseUp,{once:!0})},"onMouseDown");this.onMouseUp=o(t=>{var d;let n=t.target===this.input.current,l=!((d=window.getSelection())==null?void 0:d.toString());Ap&&console.warn("mouseUp",this.suppress_events,n,l),n&&l&&this.startEditing(),this.suppress_events=!1},"onMouseUp");this.onClick=o(t=>{Ap&&console.debug("onClick",this.suppress_events)},"onClick");this.onFocus=o(t=>{if(Ap&&console.debug("onFocus",this.props.content,this.suppress_events),!this.input.current)throw"unreachable";this.suppress_events||this.startEditing()},"onFocus");this.onInput=o(t=>{var n,l,d;(d=(l=this.props).onInput)==null||d.call(l,((n=this.input.current)==null?void 0:n.textContent)||"")},"onInput");this.onBlur=o(t=>{Ap&&console.debug("onBlur",this.props.content,this.suppress_events),!this.suppress_events&&this.finishEditing()},"onBlur");this.onKeyDown=o(t=>{var n,l;switch(Ap&&console.debug("keydown",t),t.stopPropagation(),t.key){case"Escape":t.preventDefault(),this.resetValue(),this.finishEditing();break;case"Enter":t.shiftKey||(t.preventDefault(),this.finishEditing());break;default:break}(l=(n=this.props).onKeyDown)==null||l.call(n,t)},"onKeyDown")}render(){let t=(0,lN.default)("inline-input",this.props.className);return om.default.createElement("span",{ref:this.input,tabIndex:0,className:t,placeholder:this.props.placeholder,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onInput:this.onInput,onPaste:this.onPaste,onMouseDown:this.onMouseDown,onClick:this.onClick},this.props.content)}componentDidUpdate(t){var n,l;t.content!==this.props.content&&((l=(n=this.props).onInput)==null||l.call(n,this.props.content))}};o(Xs,"ValueEditor");var uN=fe(ti());function Df(e){let[t,n]=(0,Dp.useState)(e.isValid(e.content)),l=(0,Dp.useRef)(null),d=o(c=>{var v;e.isValid(c)?e.onEditDone(c):(v=l.current)==null||v.resetValue()},"onEditDone"),h=(0,uN.default)(e.className,t?"has-success":"has-warning");return Dp.default.createElement(Xs,Lt(ke({},e),{className:h,onInput:c=>n(e.isValid(c)),onEditDone:d,ref:l}))}o(Df,"ValidateEditor");function CS(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}o(CS,"_defineProperty");function fN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(d){return Object.getOwnPropertyDescriptor(e,d).enumerable})),n.push.apply(n,l)}return n}o(fN,"ownKeys");function $0(e){for(var t=1;tn[l.level])));case dN:case MF:return ke(ke({},e),Pp(e,Jh[t.cmd](t.data,l=>e.filters[l.level])));default:return e}}o(TS,"reduce");function gN(e){return{type:mN,filter:e}}o(gN,"toggleFilter");function Rp(){return{type:hN}}o(Rp,"toggleVisibility");function vN(e,t="web"){let n={id:Math.random().toString(),message:e,level:t};return{type:dN,cmd:"add",data:n}}o(vN,"add");var yN="UI_OPTION_UPDATE_START",wN="UI_OPTION_UPDATE_SUCCESS",xN="UI_OPTION_UPDATE_ERROR",DF={};function kS(e=DF,t){switch(t.type){case yN:return Lt(ke({},e),{[t.option]:{isUpdating:!0,value:t.value,error:!1}});case wN:return Lt(ke({},e),{[t.option]:void 0});case xN:let n=e[t.option].value;return typeof n=="boolean"&&(n=!n),Lt(ke({},e),{[t.option]:{value:n,isUpdating:!1,error:t.error}});case U0:return{};default:return e}}o(kS,"reducer");function SN(e,t){return{type:yN,option:e,value:t}}o(SN,"startUpdate");function CN(e){return{type:wN,option:e}}o(CN,"updateSuccess");function bN(e,t){return{type:xN,option:e,error:t}}o(bN,"updateError");var _N=q0({flow:tS,modal:SS,optionsEditor:kS});var ni;(function(h){h.INIT="CONNECTION_INIT",h.FETCHING="CONNECTION_FETCHING",h.ESTABLISHED="CONNECTION_ESTABLISHED",h.ERROR="CONNECTION_ERROR",h.OFFLINE="CONNECTION_OFFLINE"})(ni||(ni={}));var RF={state:ni.INIT,message:void 0};function NS(e=RF,t){switch(t.type){case ni.ESTABLISHED:case ni.FETCHING:case ni.ERROR:case ni.OFFLINE:return{state:t.type,message:t.message};default:return e}}o(NS,"reducer");function EN(){return{type:ni.FETCHING}}o(EN,"startFetching");function TN(){return{type:ni.ESTABLISHED}}o(TN,"connectionEstablished");function kN(e){return{type:ni.ERROR,message:e}}o(kN,"connectionError");var NN={add_upstream_certs_to_client_chain:!1,allow_hosts:[],anticache:!1,anticomp:!1,block_global:!0,block_list:[],block_private:!1,body_size_limit:void 0,cert_passphrase:void 0,certs:[],ciphers_client:void 0,ciphers_server:void 0,client_certs:void 0,client_replay:[],client_replay_concurrency:1,command_history:!0,confdir:"~/.mitmproxy",connect_addr:void 0,connection_strategy:"eager",console_focus_follow:!1,content_view_lines_cutoff:512,export_preserve_original_ip:!1,hardump:"",http2:!0,http2_ping_keepalive:58,http3:!0,ignore_hosts:[],intercept:void 0,intercept_active:!1,keep_host_header:!1,key_size:2048,listen_host:"",listen_port:void 0,map_local:[],map_remote:[],mode:["regular"],modify_body:[],modify_headers:[],normalize_outbound_headers:!0,onboarding:!0,onboarding_host:"mitm.it",proxy_debug:!1,proxyauth:void 0,rawtcp:!0,readfile_filter:void 0,rfile:void 0,save_stream_file:void 0,save_stream_filter:void 0,scripts:[],server:!0,server_replay:[],server_replay_extra:"forward",server_replay_ignore_content:!1,server_replay_ignore_host:!1,server_replay_ignore_params:[],server_replay_ignore_payload_params:[],server_replay_ignore_port:!1,server_replay_kill_extra:!1,server_replay_nopop:!1,server_replay_refresh:!0,server_replay_reuse:!1,server_replay_use_headers:[],showhost:!1,ssl_insecure:!1,ssl_verify_upstream_trusted_ca:void 0,ssl_verify_upstream_trusted_confdir:void 0,stickyauth:void 0,stickycookie:void 0,stream_large_bodies:void 0,tcp_hosts:[],termlog_verbosity:"info",tls_ecdh_curve_client:void 0,tls_ecdh_curve_server:void 0,tls_version_client_max:"UNBOUNDED",tls_version_client_min:"TLS1_2",tls_version_server_max:"UNBOUNDED",tls_version_server_min:"TLS1_2",udp_hosts:[],upstream_auth:void 0,upstream_cert:!0,validate_inbound_headers:!0,view_filter:void 0,view_order:"time",view_order_reversed:!1,web_columns:["tls","icon","path","method","status","size","time"],web_debug:!1,web_host:"127.0.0.1",web_open_browser:!0,web_port:8081,web_static_viewer:"",websocket:!0};var PS="OPTIONS_RECEIVE",LS="OPTIONS_UPDATE";function OS(e=NN,t){switch(t.type){case PS:let n={};for(let[d,{value:h}]of Object.entries(t.data))n[d]=h;return n;case LS:let l=ke({},e);for(let[d,{value:h}]of Object.entries(t.data))l[d]=h;return l;default:return e}}o(OS,"reducer");function IF(e,t,n){return Ia(this,null,function*(){try{let l=yield kt.put("/options",{[e]:t});if(l.status===200)n(CN(e));else throw yield l.text()}catch(l){n(bN(e,l))}})}o(IF,"pureSendUpdate");var FF=IF;function Ip(e,t){return n=>{n(SN(e,t)),FF(e,t,n)}}o(Ip,"update");function PN(){return e=>kt("/options/save",{method:"POST"})}o(PN,"save");var LN="COMMANDBAR_TOGGLE_VISIBILITY",BF={visible:!1};function MS(e=BF,t){switch(t.type){case LN:return Lt(ke({},e),{visible:!e.visible});default:return e}}o(MS,"reducer");function V0(){return{type:LN}}o(V0,"toggleVisibility");function ON(e){return function(t){var n=t.dispatch,l=t.getState;return function(d){return function(h){return typeof h=="function"?h(n,l,e):d(h)}}}}o(ON,"createThunkMiddleware");var MN=ON();MN.withExtraArgument=ON;var AN=MN;var HF="STATE_RECEIVE",WF="STATE_UPDATE",UF={available:!1,version:"",contentViews:[],servers:[]};function AS(e=UF,t){switch(t.type){case HF:case WF:return ke(Lt(ke({},e),{available:!0}),t.data);default:return e}}o(AS,"reducer");var zF={},$F=o((e=zF,t)=>{switch(t.type){case PS:return t.data;case LS:return ke(ke({},e),t.data);default:return e}},"reducer"),DN=$F;var jF=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__||ES,qF=q0({commandBar:MS,eventLog:TS,flows:wS,connection:NS,ui:_N,options:OS,options_meta:DN,backendState:AS}),VF=o(e=>_S(qF,e,jF(pN(AN))),"createAppStore"),Fp=VF(void 0),Qt=o(()=>Gs(),"useAppDispatch"),qe=Jx;var io=fe(Oe());var RN=fe(Qh()),IN=fe(ti()),DS=class extends io.Component{constructor(){super(...arguments);this.container=io.default.createRef();this.nameInput=io.default.createRef();this.valueInput=io.default.createRef();this.render=o(()=>{let[t,n]=this.props.item;return io.default.createElement("div",{ref:this.container,className:"kv-row",onClick:this.onClick,onKeyDownCapture:this.onKeyDown},io.default.createElement(Xs,{ref:this.nameInput,className:"kv-key",content:t,onEditStart:this.props.onEditStart,onEditDone:l=>this.props.onEditDone([l,n])}),":\xA0",io.default.createElement(Xs,{ref:this.valueInput,className:"kv-value",content:n,onEditStart:this.props.onEditStart,onEditDone:l=>this.props.onEditDone([t,l]),placeholder:"empty"}))},"render");this.onClick=o(t=>{t.target===this.container.current&&this.props.onClickEmptyArea()},"onClick");this.onKeyDown=o(t=>{var n;t.target===((n=this.valueInput.current)==null?void 0:n.input.current)&&t.key==="Tab"&&this.props.onTabNext()},"onKeyDown")}};o(DS,"Row");var Bp=class extends io.Component{constructor(){super(...arguments);this.rowRefs={};this.state={currentList:this.props.data||[],initialList:this.props.data};this.render=o(()=>{this.rowRefs={};let t=this.state.currentList.map((n,l)=>io.default.createElement(DS,{key:l,item:n,onEditStart:()=>this.currentlyEditing=l,onEditDone:d=>this.onEditDone(l,d),onClickEmptyArea:()=>this.onClickEmptyArea(l),onTabNext:()=>this.onTabNext(l),ref:d=>this.rowRefs[l]=d}));return io.default.createElement("div",{className:(0,IN.default)("kv-editor",this.props.className),onMouseDown:this.onMouseDown},t,io.default.createElement("div",{onClick:n=>{n.preventDefault(),this.onClickEmptyArea(this.state.currentList.length-1)},className:"kv-add-row fa fa-plus-square-o",role:"button","aria-label":"Add"}))},"render");this.onEditDone=o((t,n)=>{let l=[...this.state.currentList];n[0]?l[t]=n:l.splice(t,1),this.currentlyEditing=void 0,(0,RN.isEqual)(this.state.currentList,l)||this.props.onChange(l),this.setState({currentList:l})},"onEditDone");this.onClickEmptyArea=o(t=>{if(this.justFinishedEditing)return;let n=[...this.state.currentList];n.splice(t+1,0,["",""]),this.setState({currentList:n},()=>{var l,d;return(d=(l=this.rowRefs[t+1])==null?void 0:l.nameInput.current)==null?void 0:d.startEditing()})},"onClickEmptyArea");this.onTabNext=o(t=>{t==this.state.currentList.length-1&&this.onClickEmptyArea(t)},"onTabNext");this.onMouseDown=o(t=>{this.justFinishedEditing=this.currentlyEditing},"onMouseDown")}static getDerivedStateFromProps(t,n){return t.data!==n.initialList?{currentList:t.data||[],initialList:t.data}:null}};o(Bp,"KeyValueListEditor");var tr=fe(Oe());var sm=fe(Oe());function K0(e,t){let[n,l]=(0,sm.useState)(),[d,h]=(0,sm.useState)();return(0,sm.useEffect)(()=>{d&&d.abort();let c=new AbortController;return kt(e,{signal:c.signal}).then(v=>{if(!v.ok)throw`${v.status} ${v.statusText}`.trim();return v.text()}).then(v=>{l(v)}).catch(v=>{c.signal.aborted||l(`Error getting content: ${v}.`)}),h(c),()=>{c.signal.aborted||c.abort()}},[e,t]),n}o(K0,"useContent");var lm=fe(Oe()),G0=lm.default.memo(o(function({icon:t,text:n,className:l,title:d,onOpenFile:h,onClick:c}){let v;return lm.default.createElement("a",{href:"#",onClick:C=>{v.click(),c&&c(C)},className:l,title:d},lm.default.createElement("i",{className:"fa fa-fw "+t}),n,lm.default.createElement("input",{ref:C=>v=C,className:"hidden",type:"file",onChange:C=>{C.preventDefault(),C.target.files&&C.target.files.length>0&&h(C.target.files[0]),v.value=""}}))},"FileChooser"));var Hp=fe(Oe()),FN=fe(ti());function kr({onClick:e,children:t,icon:n,disabled:l,className:d,title:h}){return Hp.createElement("button",{className:(0,FN.default)(d,"btn btn-default"),onClick:l?void 0:e,disabled:l,title:h},n&&Hp.createElement(Hp.Fragment,null,Hp.createElement("i",{className:"fa "+n}),"\xA0"),t)}o(kr,"Button");var um=fe(Oe()),$N=fe(Oe());var am=fe(Oe()),HN=fe(ti()),WN=fe(BN()),UN=fe(Qh());function zN(e){return e&&e.replace(/\r\n|\r/g,` +`)}o(zN,"normalizeLineEndings");var Wp=class extends am.Component{constructor(t){super(t);this.state={isFocused:!1}}getCodeMirrorInstance(){return this.props.codeMirrorInstance||WN.default}UNSAFE_componentWillMount(){this.props.path&&console.error("Warning: react-codemirror: the `path` prop has been changed to `name`")}componentDidMount(){let t=this.getCodeMirrorInstance();this.codeMirror=t.fromTextArea(this.textareaNode,this.props.options),this.codeMirror.on("change",this.codemirrorValueChanged.bind(this)),this.codeMirror.on("cursorActivity",this.cursorActivity.bind(this)),this.codeMirror.on("focus",this.focusChanged.bind(this,!0)),this.codeMirror.on("blur",this.focusChanged.bind(this,!1)),this.codeMirror.on("scroll",this.scrollChanged.bind(this)),this.codeMirror.setValue(this.props.defaultValue||this.props.value||"")}componentWillUnmount(){this.codeMirror&&this.codeMirror.toTextArea()}UNSAFE_componentWillReceiveProps(t){if(this.codeMirror&&t.value!==void 0&&t.value!==this.props.value&&zN(this.codeMirror.getValue())!==zN(t.value))if(this.props.preserveScrollPosition){var n=this.codeMirror.getScrollInfo();this.codeMirror.setValue(t.value),this.codeMirror.scrollTo(n.left,n.top)}else this.codeMirror.setValue(t.value);if(typeof t.options=="object")for(let l in t.options)t.options.hasOwnProperty(l)&&this.setOptionIfChanged(l,t.options[l])}setOptionIfChanged(t,n){let l=this.codeMirror.getOption(t);UN.default.isEqual(l,n)||this.codeMirror.setOption(t,n)}getCodeMirror(){return this.codeMirror}focus(){this.codeMirror&&this.codeMirror.focus()}focusChanged(t){this.setState({isFocused:t}),this.props.onFocusChange&&this.props.onFocusChange(t)}cursorActivity(t){this.props.onCursorActivity&&this.props.onCursorActivity(t)}scrollChanged(t){this.props.onScroll&&this.props.onScroll(t.getScrollInfo())}codemirrorValueChanged(t,n){this.props.onChange&&n.origin!=="setValue"&&this.props.onChange(t.getValue(),n)}render(){let t=(0,HN.default)("ReactCodeMirror",this.state.isFocused?"ReactCodeMirror--focused":null,this.props.className);return am.createElement("div",{className:t},am.createElement("textarea",{ref:n=>this.textareaNode=n,name:this.props.name||this.props.path,defaultValue:this.props.value,autoComplete:"off",autoFocus:this.props.autoFocus}))}};o(Wp,"CodeMirror"),Wp.defaultProps={preserveScrollPosition:!1};var fm=class extends $N.Component{constructor(){super(...arguments);this.editor=um.createRef();this.getContent=o(()=>{var t;return(t=this.editor.current)==null?void 0:t.codeMirror.getValue()},"getContent");this.render=o(()=>{let t={lineNumbers:!0};return um.createElement("div",{className:"codeeditor",onKeyDown:n=>n.stopPropagation()},um.createElement(Wp,{ref:this.editor,value:this.props.initialContent,onChange:()=>0,options:t}))},"render")}};o(fm,"CodeEditor");var Rf=fe(Oe()),KF=Rf.default.memo(o(function({lines:t,maxLines:n,showMore:l}){return t.length===0?null:Rf.default.createElement("pre",null,t.map((d,h)=>h===n?Rf.default.createElement("button",{key:"showmore",onClick:l,className:"btn btn-xs btn-info"},Rf.default.createElement("i",{className:"fa fa-angle-double-down","aria-hidden":"true"})," ","Show more"):Rf.default.createElement("div",{key:h},d.map(([c,v],C)=>Rf.default.createElement("span",{key:C,className:c},v)))))},"LineRenderer")),Y0=KF;var zf=fe(Oe());var xi=fe(Oe());var X0=fe(Oe());var FS=o(function(t){return t.reduce(function(n,l){var d=l[0],h=l[1];return n[d]=h,n},{})},"fromEntries"),BS=typeof window!="undefined"&&window.document&&window.document.createElement?X0.useLayoutEffect:X0.useEffect;var fu=fe(Oe());var Gr="top",Pn="bottom",ln="right",an="left",Q0="auto",su=[Gr,Pn,ln,an],Rl="start",Z0="end",jN="clippingParents",J0="viewport",Up="popper",qN="reference",HS=su.reduce(function(e,t){return e.concat([t+"-"+Rl,t+"-"+Z0])},[]),ey=[].concat(su,[Q0]).reduce(function(e,t){return e.concat([t,t+"-"+Rl,t+"-"+Z0])},[]),GF="beforeRead",YF="read",XF="afterRead",QF="beforeMain",ZF="main",JF="afterMain",e3="beforeWrite",t3="write",r3="afterWrite",VN=[GF,YF,XF,QF,ZF,JF,e3,t3,r3];function Ln(e){return e?(e.nodeName||"").toLowerCase():null}o(Ln,"getNodeName");function Br(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}o(Br,"getWindow");function Il(e){var t=Br(e).Element;return e instanceof t||e instanceof Element}o(Il,"isElement");function Yr(e){var t=Br(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}o(Yr,"isHTMLElement");function ty(e){if(typeof ShadowRoot=="undefined")return!1;var t=Br(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}o(ty,"isShadowRoot");function n3(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var l=t.styles[n]||{},d=t.attributes[n]||{},h=t.elements[n];!Yr(h)||!Ln(h)||(Object.assign(h.style,l),Object.keys(d).forEach(function(c){var v=d[c];v===!1?h.removeAttribute(c):h.setAttribute(c,v===!0?"":v)}))})}o(n3,"applyStyles");function i3(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(l){var d=t.elements[l],h=t.attributes[l]||{},c=Object.keys(t.styles.hasOwnProperty(l)?t.styles[l]:n[l]),v=c.reduce(function(C,k){return C[k]="",C},{});!Yr(d)||!Ln(d)||(Object.assign(d.style,v),Object.keys(h).forEach(function(C){d.removeAttribute(C)}))})}}o(i3,"effect");var KN={name:"applyStyles",enabled:!0,phase:"write",fn:n3,effect:i3,requires:["computeStyles"]};function On(e){return e.split("-")[0]}o(On,"getBasePlacement");var lu=Math.round;function Mo(e,t){t===void 0&&(t=!1);var n=e.getBoundingClientRect(),l=1,d=1;return Yr(e)&&t&&(l=n.width/e.offsetWidth||1,d=n.height/e.offsetHeight||1),{width:lu(n.width/l),height:lu(n.height/d),top:lu(n.top/d),right:lu(n.right/l),bottom:lu(n.bottom/d),left:lu(n.left/l),x:lu(n.left/l),y:lu(n.top/d)}}o(Mo,"getBoundingClientRect");function If(e){var t=Mo(e),n=e.offsetWidth,l=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-l)<=1&&(l=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:l}}o(If,"getLayoutRect");function cm(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&ty(n)){var l=t;do{if(l&&e.isSameNode(l))return!0;l=l.parentNode||l.host}while(l)}return!1}o(cm,"contains");function wi(e){return Br(e).getComputedStyle(e)}o(wi,"getComputedStyle");function WS(e){return["table","td","th"].indexOf(Ln(e))>=0}o(WS,"isTableElement");function Bn(e){return((Il(e)?e.ownerDocument:e.document)||window.document).documentElement}o(Bn,"getDocumentElement");function Fl(e){return Ln(e)==="html"?e:e.assignedSlot||e.parentNode||(ty(e)?e.host:null)||Bn(e)}o(Fl,"getParentNode");function GN(e){return!Yr(e)||wi(e).position==="fixed"?null:e.offsetParent}o(GN,"getTrueOffsetParent");function o3(e){var t=navigator.userAgent.toLowerCase().indexOf("firefox")!==-1,n=navigator.userAgent.indexOf("Trident")!==-1;if(n&&Yr(e)){var l=wi(e);if(l.position==="fixed")return null}for(var d=Fl(e);Yr(d)&&["html","body"].indexOf(Ln(d))<0;){var h=wi(d);if(h.transform!=="none"||h.perspective!=="none"||h.contain==="paint"||["transform","perspective"].indexOf(h.willChange)!==-1||t&&h.willChange==="filter"||t&&h.filter&&h.filter!=="none")return d;d=d.parentNode}return null}o(o3,"getContainingBlock");function as(e){for(var t=Br(e),n=GN(e);n&&WS(n)&&wi(n).position==="static";)n=GN(n);return n&&(Ln(n)==="html"||Ln(n)==="body"&&wi(n).position==="static")?t:n||o3(e)||t}o(as,"getOffsetParent");function Ff(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}o(Ff,"getMainAxisFromPlacement");var Ao=Math.max,au=Math.min,pm=Math.round;function Bf(e,t,n){return Ao(e,au(t,n))}o(Bf,"within");function dm(){return{top:0,right:0,bottom:0,left:0}}o(dm,"getFreshSideObject");function hm(e){return Object.assign({},dm(),e)}o(hm,"mergePaddingObject");function mm(e,t){return t.reduce(function(n,l){return n[l]=e,n},{})}o(mm,"expandToHashMap");var s3=o(function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,hm(typeof t!="number"?t:mm(t,su))},"toPaddingObject");function l3(e){var t,n=e.state,l=e.name,d=e.options,h=n.elements.arrow,c=n.modifiersData.popperOffsets,v=On(n.placement),C=Ff(v),k=[an,ln].indexOf(v)>=0,O=k?"height":"width";if(!(!h||!c)){var j=s3(d.padding,n),B=If(h),X=C==="y"?Gr:an,J=C==="y"?Pn:ln,Z=n.rects.reference[O]+n.rects.reference[C]-c[C]-n.rects.popper[O],R=c[C]-n.rects.reference[C],A=as(h),I=A?C==="y"?A.clientHeight||0:A.clientWidth||0:0,G=Z/2-R/2,K=j[X],se=I-B[O]-j[J],ne=I/2-B[O]/2+G,pe=Bf(K,ne,se),me=C;n.modifiersData[l]=(t={},t[me]=pe,t.centerOffset=pe-ne,t)}}o(l3,"arrow");function a3(e){var t=e.state,n=e.options,l=n.element,d=l===void 0?"[data-popper-arrow]":l;d!=null&&(typeof d=="string"&&(d=t.elements.popper.querySelector(d),!d)||!cm(t.elements.popper,d)||(t.elements.arrow=d))}o(a3,"effect");var YN={name:"arrow",enabled:!0,phase:"main",fn:l3,effect:a3,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};var u3={top:"auto",right:"auto",bottom:"auto",left:"auto"};function f3(e){var t=e.x,n=e.y,l=window,d=l.devicePixelRatio||1;return{x:pm(pm(t*d)/d)||0,y:pm(pm(n*d)/d)||0}}o(f3,"roundOffsetsByDPR");function XN(e){var t,n=e.popper,l=e.popperRect,d=e.placement,h=e.offsets,c=e.position,v=e.gpuAcceleration,C=e.adaptive,k=e.roundOffsets,O=k===!0?f3(h):typeof k=="function"?k(h):h,j=O.x,B=j===void 0?0:j,X=O.y,J=X===void 0?0:X,Z=h.hasOwnProperty("x"),R=h.hasOwnProperty("y"),A=an,I=Gr,G=window;if(C){var K=as(n),se="clientHeight",ne="clientWidth";K===Br(n)&&(K=Bn(n),wi(K).position!=="static"&&(se="scrollHeight",ne="scrollWidth")),K=K,d===Gr&&(I=Pn,J-=K[se]-l.height,J*=v?1:-1),d===an&&(A=ln,B-=K[ne]-l.width,B*=v?1:-1)}var pe=Object.assign({position:c},C&&u3);if(v){var me;return Object.assign({},pe,(me={},me[I]=R?"0":"",me[A]=Z?"0":"",me.transform=(G.devicePixelRatio||1)<2?"translate("+B+"px, "+J+"px)":"translate3d("+B+"px, "+J+"px, 0)",me))}return Object.assign({},pe,(t={},t[I]=R?J+"px":"",t[A]=Z?B+"px":"",t.transform="",t))}o(XN,"mapToStyles");function c3(e){var t=e.state,n=e.options,l=n.gpuAcceleration,d=l===void 0?!0:l,h=n.adaptive,c=h===void 0?!0:h,v=n.roundOffsets,C=v===void 0?!0:v;if(!1)var k;var O={placement:On(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:d};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,XN(Object.assign({},O,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:c,roundOffsets:C})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,XN(Object.assign({},O,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:C})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}o(c3,"computeStyles");var QN={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:c3,data:{}};var ry={passive:!0};function p3(e){var t=e.state,n=e.instance,l=e.options,d=l.scroll,h=d===void 0?!0:d,c=l.resize,v=c===void 0?!0:c,C=Br(t.elements.popper),k=[].concat(t.scrollParents.reference,t.scrollParents.popper);return h&&k.forEach(function(O){O.addEventListener("scroll",n.update,ry)}),v&&C.addEventListener("resize",n.update,ry),function(){h&&k.forEach(function(O){O.removeEventListener("scroll",n.update,ry)}),v&&C.removeEventListener("resize",n.update,ry)}}o(p3,"effect");var ZN={name:"eventListeners",enabled:!0,phase:"write",fn:o(function(){},"fn"),effect:p3,data:{}};var d3={left:"right",right:"left",bottom:"top",top:"bottom"};function zp(e){return e.replace(/left|right|bottom|top/g,function(t){return d3[t]})}o(zp,"getOppositePlacement");var h3={start:"end",end:"start"};function ny(e){return e.replace(/start|end/g,function(t){return h3[t]})}o(ny,"getOppositeVariationPlacement");function Hf(e){var t=Br(e),n=t.pageXOffset,l=t.pageYOffset;return{scrollLeft:n,scrollTop:l}}o(Hf,"getWindowScroll");function Wf(e){return Mo(Bn(e)).left+Hf(e).scrollLeft}o(Wf,"getWindowScrollBarX");function US(e){var t=Br(e),n=Bn(e),l=t.visualViewport,d=n.clientWidth,h=n.clientHeight,c=0,v=0;return l&&(d=l.width,h=l.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(c=l.offsetLeft,v=l.offsetTop)),{width:d,height:h,x:c+Wf(e),y:v}}o(US,"getViewportRect");function zS(e){var t,n=Bn(e),l=Hf(e),d=(t=e.ownerDocument)==null?void 0:t.body,h=Ao(n.scrollWidth,n.clientWidth,d?d.scrollWidth:0,d?d.clientWidth:0),c=Ao(n.scrollHeight,n.clientHeight,d?d.scrollHeight:0,d?d.clientHeight:0),v=-l.scrollLeft+Wf(e),C=-l.scrollTop;return wi(d||n).direction==="rtl"&&(v+=Ao(n.clientWidth,d?d.clientWidth:0)-h),{width:h,height:c,x:v,y:C}}o(zS,"getDocumentRect");function Uf(e){var t=wi(e),n=t.overflow,l=t.overflowX,d=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+d+l)}o(Uf,"isScrollParent");function iy(e){return["html","body","#document"].indexOf(Ln(e))>=0?e.ownerDocument.body:Yr(e)&&Uf(e)?e:iy(Fl(e))}o(iy,"getScrollParent");function uu(e,t){var n;t===void 0&&(t=[]);var l=iy(e),d=l===((n=e.ownerDocument)==null?void 0:n.body),h=Br(l),c=d?[h].concat(h.visualViewport||[],Uf(l)?l:[]):l,v=t.concat(c);return d?v:v.concat(uu(Fl(c)))}o(uu,"listScrollParents");function $p(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}o($p,"rectToClientRect");function m3(e){var t=Mo(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}o(m3,"getInnerBoundingClientRect");function JN(e,t){return t===J0?$p(US(e)):Yr(t)?m3(t):$p(zS(Bn(e)))}o(JN,"getClientRectFromMixedType");function g3(e){var t=uu(Fl(e)),n=["absolute","fixed"].indexOf(wi(e).position)>=0,l=n&&Yr(e)?as(e):e;return Il(l)?t.filter(function(d){return Il(d)&&cm(d,l)&&Ln(d)!=="body"}):[]}o(g3,"getClippingParents");function $S(e,t,n){var l=t==="clippingParents"?g3(e):[].concat(t),d=[].concat(l,[n]),h=d[0],c=d.reduce(function(v,C){var k=JN(e,C);return v.top=Ao(k.top,v.top),v.right=au(k.right,v.right),v.bottom=au(k.bottom,v.bottom),v.left=Ao(k.left,v.left),v},JN(e,h));return c.width=c.right-c.left,c.height=c.bottom-c.top,c.x=c.left,c.y=c.top,c}o($S,"getClippingRect");function Qs(e){return e.split("-")[1]}o(Qs,"getVariation");function gm(e){var t=e.reference,n=e.element,l=e.placement,d=l?On(l):null,h=l?Qs(l):null,c=t.x+t.width/2-n.width/2,v=t.y+t.height/2-n.height/2,C;switch(d){case Gr:C={x:c,y:t.y-n.height};break;case Pn:C={x:c,y:t.y+t.height};break;case ln:C={x:t.x+t.width,y:v};break;case an:C={x:t.x-n.width,y:v};break;default:C={x:t.x,y:t.y}}var k=d?Ff(d):null;if(k!=null){var O=k==="y"?"height":"width";switch(h){case Rl:C[k]=C[k]-(t[O]/2-n[O]/2);break;case Z0:C[k]=C[k]+(t[O]/2-n[O]/2);break;default:}}return C}o(gm,"computeOffsets");function us(e,t){t===void 0&&(t={});var n=t,l=n.placement,d=l===void 0?e.placement:l,h=n.boundary,c=h===void 0?jN:h,v=n.rootBoundary,C=v===void 0?J0:v,k=n.elementContext,O=k===void 0?Up:k,j=n.altBoundary,B=j===void 0?!1:j,X=n.padding,J=X===void 0?0:X,Z=hm(typeof J!="number"?J:mm(J,su)),R=O===Up?qN:Up,A=e.elements.reference,I=e.rects.popper,G=e.elements[B?R:O],K=$S(Il(G)?G:G.contextElement||Bn(e.elements.popper),c,C),se=Mo(A),ne=gm({reference:se,element:I,strategy:"absolute",placement:d}),pe=$p(Object.assign({},I,ne)),me=O===Up?pe:se,xe={top:K.top-me.top+Z.top,bottom:me.bottom-K.bottom+Z.bottom,left:K.left-me.left+Z.left,right:me.right-K.right+Z.right},Ve=e.modifiersData.offset;if(O===Up&&Ve){var tt=Ve[d];Object.keys(xe).forEach(function(Ee){var St=[ln,Pn].indexOf(Ee)>=0?1:-1,We=[Gr,Pn].indexOf(Ee)>=0?"y":"x";xe[Ee]+=tt[We]*St})}return xe}o(us,"detectOverflow");function jS(e,t){t===void 0&&(t={});var n=t,l=n.placement,d=n.boundary,h=n.rootBoundary,c=n.padding,v=n.flipVariations,C=n.allowedAutoPlacements,k=C===void 0?ey:C,O=Qs(l),j=O?v?HS:HS.filter(function(J){return Qs(J)===O}):su,B=j.filter(function(J){return k.indexOf(J)>=0});B.length===0&&(B=j);var X=B.reduce(function(J,Z){return J[Z]=us(e,{placement:Z,boundary:d,rootBoundary:h,padding:c})[On(Z)],J},{});return Object.keys(X).sort(function(J,Z){return X[J]-X[Z]})}o(jS,"computeAutoPlacement");function v3(e){if(On(e)===Q0)return[];var t=zp(e);return[ny(e),t,ny(t)]}o(v3,"getExpandedFallbackPlacements");function y3(e){var t=e.state,n=e.options,l=e.name;if(!t.modifiersData[l]._skip){for(var d=n.mainAxis,h=d===void 0?!0:d,c=n.altAxis,v=c===void 0?!0:c,C=n.fallbackPlacements,k=n.padding,O=n.boundary,j=n.rootBoundary,B=n.altBoundary,X=n.flipVariations,J=X===void 0?!0:X,Z=n.allowedAutoPlacements,R=t.options.placement,A=On(R),I=A===R,G=C||(I||!J?[zp(R)]:v3(R)),K=[R].concat(G).reduce(function(ut,Pr){return ut.concat(On(Pr)===Q0?jS(t,{placement:Pr,boundary:O,rootBoundary:j,padding:k,flipVariations:J,allowedAutoPlacements:Z}):Pr)},[]),se=t.rects.reference,ne=t.rects.popper,pe=new Map,me=!0,xe=K[0],Ve=0;Ve=0,Ke=We?"width":"height",Ge=us(t,{placement:tt,boundary:O,rootBoundary:j,altBoundary:B,padding:k}),Xe=We?St?ln:an:St?Pn:Gr;se[Ke]>ne[Ke]&&(Xe=zp(Xe));var nr=zp(Xe),ct=[];if(h&&ct.push(Ge[Ee]<=0),v&&ct.push(Ge[Xe]<=0,Ge[nr]<=0),ct.every(function(ut){return ut})){xe=tt,me=!1;break}pe.set(tt,ct)}if(me)for(var Hr=J?3:1,Zt=o(function(Pr){var zt=K.find(function($t){var ie=pe.get($t);if(ie)return ie.slice(0,Pr).every(function(rt){return rt})});if(zt)return xe=zt,"break"},"_loop"),Et=Hr;Et>0;Et--){var Ct=Zt(Et);if(Ct==="break")break}t.placement!==xe&&(t.modifiersData[l]._skip=!0,t.placement=xe,t.reset=!0)}}o(y3,"flip");var eP={name:"flip",enabled:!0,phase:"main",fn:y3,requiresIfExists:["offset"],data:{_skip:!1}};function tP(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}o(tP,"getSideOffsets");function rP(e){return[Gr,ln,Pn,an].some(function(t){return e[t]>=0})}o(rP,"isAnySideFullyClipped");function w3(e){var t=e.state,n=e.name,l=t.rects.reference,d=t.rects.popper,h=t.modifiersData.preventOverflow,c=us(t,{elementContext:"reference"}),v=us(t,{altBoundary:!0}),C=tP(c,l),k=tP(v,d,h),O=rP(C),j=rP(k);t.modifiersData[n]={referenceClippingOffsets:C,popperEscapeOffsets:k,isReferenceHidden:O,hasPopperEscaped:j},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":O,"data-popper-escaped":j})}o(w3,"hide");var nP={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:w3};function x3(e,t,n){var l=On(e),d=[an,Gr].indexOf(l)>=0?-1:1,h=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,c=h[0],v=h[1];return c=c||0,v=(v||0)*d,[an,ln].indexOf(l)>=0?{x:v,y:c}:{x:c,y:v}}o(x3,"distanceAndSkiddingToXY");function S3(e){var t=e.state,n=e.options,l=e.name,d=n.offset,h=d===void 0?[0,0]:d,c=ey.reduce(function(O,j){return O[j]=x3(j,t.rects,h),O},{}),v=c[t.placement],C=v.x,k=v.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=C,t.modifiersData.popperOffsets.y+=k),t.modifiersData[l]=c}o(S3,"offset");var iP={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:S3};function C3(e){var t=e.state,n=e.name;t.modifiersData[n]=gm({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}o(C3,"popperOffsets");var oP={name:"popperOffsets",enabled:!0,phase:"read",fn:C3,data:{}};function qS(e){return e==="x"?"y":"x"}o(qS,"getAltAxis");function b3(e){var t=e.state,n=e.options,l=e.name,d=n.mainAxis,h=d===void 0?!0:d,c=n.altAxis,v=c===void 0?!1:c,C=n.boundary,k=n.rootBoundary,O=n.altBoundary,j=n.padding,B=n.tether,X=B===void 0?!0:B,J=n.tetherOffset,Z=J===void 0?0:J,R=us(t,{boundary:C,rootBoundary:k,padding:j,altBoundary:O}),A=On(t.placement),I=Qs(t.placement),G=!I,K=Ff(A),se=qS(K),ne=t.modifiersData.popperOffsets,pe=t.rects.reference,me=t.rects.popper,xe=typeof Z=="function"?Z(Object.assign({},t.rects,{placement:t.placement})):Z,Ve={x:0,y:0};if(!!ne){if(h||v){var tt=K==="y"?Gr:an,Ee=K==="y"?Pn:ln,St=K==="y"?"height":"width",We=ne[K],Ke=ne[K]+R[tt],Ge=ne[K]-R[Ee],Xe=X?-me[St]/2:0,nr=I===Rl?pe[St]:me[St],ct=I===Rl?-me[St]:-pe[St],Hr=t.elements.arrow,Zt=X&&Hr?If(Hr):{width:0,height:0},Et=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:dm(),Ct=Et[tt],ut=Et[Ee],Pr=Bf(0,pe[St],Zt[St]),zt=G?pe[St]/2-Xe-Pr-Ct-xe:nr-Pr-Ct-xe,$t=G?-pe[St]/2+Xe+Pr+ut+xe:ct+Pr+ut+xe,ie=t.elements.arrow&&as(t.elements.arrow),rt=ie?K==="y"?ie.clientTop||0:ie.clientLeft||0:0,Lr=t.modifiersData.offset?t.modifiersData.offset[t.placement][K]:0,Gt=ne[K]+zt-Lr-rt,Yt=ne[K]+$t-Lr;if(h){var Se=Bf(X?au(Ke,Gt):Ke,We,X?Ao(Ge,Yt):Ge);ne[K]=Se,Ve[K]=Se-We}if(v){var Or=K==="x"?Gr:an,fn=K==="x"?Pn:ln,Un=ne[se],si=Un+R[Or],cn=Un-R[fn],Jt=Bf(X?au(si,Gt):si,Un,X?Ao(cn,Yt):cn);ne[se]=Jt,Ve[se]=Jt-Un}}t.modifiersData[l]=Ve}}o(b3,"preventOverflow");var sP={name:"preventOverflow",enabled:!0,phase:"main",fn:b3,requiresIfExists:["offset"]};function VS(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}o(VS,"getHTMLElementScroll");function KS(e){return e===Br(e)||!Yr(e)?Hf(e):VS(e)}o(KS,"getNodeScroll");function _3(e){var t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,l=t.height/e.offsetHeight||1;return n!==1||l!==1}o(_3,"isElementScaled");function GS(e,t,n){n===void 0&&(n=!1);var l=Yr(t),d=Yr(t)&&_3(t),h=Bn(t),c=Mo(e,d),v={scrollLeft:0,scrollTop:0},C={x:0,y:0};return(l||!l&&!n)&&((Ln(t)!=="body"||Uf(h))&&(v=KS(t)),Yr(t)?(C=Mo(t,!0),C.x+=t.clientLeft,C.y+=t.clientTop):h&&(C.x=Wf(h))),{x:c.left+v.scrollLeft-C.x,y:c.top+v.scrollTop-C.y,width:c.width,height:c.height}}o(GS,"getCompositeRect");function E3(e){var t=new Map,n=new Set,l=[];e.forEach(function(h){t.set(h.name,h)});function d(h){n.add(h.name);var c=[].concat(h.requires||[],h.requiresIfExists||[]);c.forEach(function(v){if(!n.has(v)){var C=t.get(v);C&&d(C)}}),l.push(h)}return o(d,"sort"),e.forEach(function(h){n.has(h.name)||d(h)}),l}o(E3,"order");function YS(e){var t=E3(e);return VN.reduce(function(n,l){return n.concat(t.filter(function(d){return d.phase===l}))},[])}o(YS,"orderModifiers");function XS(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}o(XS,"debounce");function QS(e){var t=e.reduce(function(n,l){var d=n[l.name];return n[l.name]=d?Object.assign({},d,l,{options:Object.assign({},d.options,l.options),data:Object.assign({},d.data,l.data)}):l,n},{});return Object.keys(t).map(function(n){return t[n]})}o(QS,"mergeByName");var lP={placement:"bottom",modifiers:[],strategy:"absolute"};function aP(){for(var e=arguments.length,t=new Array(e),n=0;nxi.default.createElement("li",{role:"separator",className:"divider"}),"Divider");function ii(l){var d=l,{onClick:e,children:t}=d,n=Ws(d,["onClick","children"]);return xi.default.createElement("li",null,xi.default.createElement("a",ke({href:"#",onClick:o(c=>{c.preventDefault(),e()},"click")},n),t))}o(ii,"MenuItem");var cu=xi.default.memo(o(function(v){var C=v,{text:t,children:n,options:l,className:d,onOpen:h}=C,c=Ws(C,["text","children","options","className","onOpen"]);let[k,O]=(0,xi.useState)(null),[j,B]=(0,xi.useState)(!1),[X,J]=(0,xi.useState)(null),{styles:Z,attributes:R}=JS(k,X,ke({},l)),A=o(G=>{B(G),h&&h(G)},"setOpen");(0,xi.useEffect)(()=>{!X||document.addEventListener("click",G=>{X.contains(G.target)?document.addEventListener("click",()=>A(!1),{once:!0}):(G.preventDefault(),G.stopPropagation(),A(!1))},{once:!0,capture:!0})},[X]);let I;return j?I=xi.default.createElement("ul",ke({className:"dropdown-menu show",ref:J,style:Z.popper},R.popper),n):I=null,xi.default.createElement(xi.default.Fragment,null,xi.default.createElement("a",ke({href:"#",ref:O,className:(0,dP.default)(d,{open:j}),onClick:G=>{G.preventDefault(),A(!0)}},c),t),I)},"Dropdown"));function vm({value:e,onChange:t}){let n=qe(d=>d.backendState.contentViews||[]),l=zf.default.createElement("span",null,zf.default.createElement("i",{className:"fa fa-fw fa-files-o"}),"\xA0",zf.default.createElement("b",null,"View:")," ",e.toLowerCase()," ",zf.default.createElement("span",{className:"caret"}));return zf.default.createElement(cu,{text:l,className:"btn btn-default btn-xs",options:{placement:"top-start"}},n.map(d=>zf.default.createElement(ii,{key:d,onClick:()=>t(d)},d.toLowerCase().replace("_"," "))))}o(vm,"ViewSelector");function eC({flow:e,message:t}){let n=Qt(),l=e.request===t?"request":"response",d=qe(J=>J.ui.flow.contentViewFor[e.id+l]||"Auto"),h=(0,tr.useRef)(null),[c,v]=(0,tr.useState)(qe(J=>J.options.content_view_lines_cutoff)),C=(0,tr.useCallback)(()=>v(Math.max(1024,c*2)),[c]),[k,O]=(0,tr.useState)(!1),j;k?j=Kr.getContentURL(e,t):j=Kr.getContentURL(e,t,d,c+1);let B=K0(j,t.contentHash),X=(0,tr.useMemo)(()=>{if(B&&!k)try{return JSON.parse(B)}catch(J){return{description:"Network Error",lines:[[["error",`${B}`]]]}}else return},[B]);if(k)return tr.default.createElement("div",{className:"contentview",key:"edit"},tr.default.createElement("div",{className:"controls"},tr.default.createElement("h5",null,"[Editing]"),tr.default.createElement(kr,{onClick:o(()=>Ia(this,null,function*(){var R;let Z=(R=h.current)==null?void 0:R.getContent();yield n(Wi(e,{[l]:{content:Z}})),O(!1)}),"save"),icon:"fa-check text-success",className:"btn-xs"},"Done"),"\xA0",tr.default.createElement(kr,{onClick:()=>O(!1),icon:"fa-times text-danger",className:"btn-xs"},"Cancel")),tr.default.createElement(fm,{ref:h,initialContent:B||""}));{let J=X?X.description:"Loading...";return tr.default.createElement("div",{className:"contentview",key:"view"},tr.default.createElement("div",{className:"controls"},tr.default.createElement("h5",null,J),tr.default.createElement(kr,{onClick:()=>O(!0),icon:"fa-edit",className:"btn-xs"},"Edit"),"\xA0",tr.default.createElement(G0,{icon:"fa-upload",text:"Replace",title:"Upload a file to replace the content.",onOpenFile:Z=>n(nN(e,Z,l)),className:"btn btn-default btn-xs"}),"\xA0",tr.default.createElement(vm,{value:d,onChange:Z=>n(w0(e.id+l,Z))})),tC.matches(t)&&tr.default.createElement(tC,{flow:e,message:t}),tr.default.createElement(Y0,{lines:(X==null?void 0:X.lines)||[],maxLines:c,showMore:C}))}}o(eC,"HttpMessage");var M3=/^image\/(png|jpe?g|gif|webp|vnc.microsoft.icon|x-icon|svg\+xml)$/i;tC.matches=e=>M3.test(Kr.getContentType(e)||"");function tC({flow:e,message:t}){return tr.default.createElement("div",{className:"flowview-image"},tr.default.createElement("img",{src:Kr.getContentURL(e,t),alt:"preview",className:"img-thumbnail"}))}o(tC,"ViewImage");function A3({flow:e}){let t=Qt();return Ut.createElement("div",{className:"first-line request-line"},Ut.createElement("div",null,Ut.createElement(Df,{content:e.request.method,onEditDone:n=>t(Wi(e,{request:{method:n}})),isValid:n=>n.length>0}),"\xA0",Ut.createElement(Df,{content:Oo.pretty_url(e.request),onEditDone:n=>t(Wi(e,{request:ke({path:""},hS(n))})),isValid:n=>{var l;return!!((l=hS(n))==null?void 0:l.host)}}),"\xA0",Ut.createElement(Df,{content:e.request.http_version,onEditDone:n=>t(Wi(e,{request:{http_version:n}})),isValid:mS})))}o(A3,"RequestLine");function D3({flow:e}){let t=Qt();return Ut.createElement("div",{className:"first-line response-line"},Ut.createElement(Df,{content:e.response.http_version,onEditDone:n=>t(Wi(e,{response:{http_version:n}})),isValid:mS}),"\xA0",Ut.createElement(Df,{content:e.response.status_code+"",onEditDone:n=>t(Wi(e,{response:{code:parseInt(n)}})),isValid:n=>/^\d+$/.test(n)}),e.response.http_version!=="HTTP/2.0"&&Ut.createElement(Ut.Fragment,null,"\xA0",Ut.createElement(Xs,{content:e.response.reason,onEditDone:n=>t(Wi(e,{response:{msg:n}}))})))}o(D3,"ResponseLine");function R3({flow:e,message:t}){let n=Qt(),l=e.request===t?"request":"response";return Ut.createElement(Bp,{className:"headers",data:t.headers,onChange:d=>n(Wi(e,{[l]:{headers:d}}))})}o(R3,"Headers");function I3({flow:e,message:t}){let n=Qt(),l=e.request===t?"request":"response";return!Kr.get_first_header(t,/^trailer$/i)?null:Ut.createElement(Ut.Fragment,null,Ut.createElement("hr",null),Ut.createElement("h5",null,"HTTP Trailers"),Ut.createElement(Bp,{className:"trailers",data:t.trailers,onChange:h=>n(Wi(e,{[l]:{trailers:h}}))}))}o(I3,"Trailers");var mP=Ut.memo(o(function({flow:t,message:n}){let l=t.request===n?"request":"response",d=t.request===n?A3:D3;return Ut.createElement("section",{className:l},Ut.createElement(d,{flow:t}),Ut.createElement(R3,{flow:t,message:n}),Ut.createElement("hr",null),Ut.createElement(eC,{key:t.id+l,flow:t,message:n}),Ut.createElement(I3,{flow:t,message:n}))},"Message"));function rC(){let e=qe(t=>t.flows.byId[t.flows.selected[0]]);return Ut.createElement(mP,{flow:e,message:e.request})}o(rC,"Request");rC.displayName="Request";function nC(){let e=qe(t=>t.flows.byId[t.flows.selected[0]]);return Ut.createElement(mP,{flow:e,message:e.response})}o(nC,"Response");nC.displayName="Response";var Ye=fe(Oe());var F3=o(({message:e})=>Ye.createElement("div",null,e.query?e.op_code:e.response_code,"\xA0",e.truncation?"(Truncated)":""),"Summary"),B3=o(({message:e})=>Ye.createElement(Ye.Fragment,null,Ye.createElement("h5",null,e.recursion_desired?"Recursive ":"","Question"),Ye.createElement("table",null,Ye.createElement("thead",null,Ye.createElement("tr",null,Ye.createElement("th",null,"Name"),Ye.createElement("th",null,"Type"),Ye.createElement("th",null,"Class"))),Ye.createElement("tbody",null,e.questions.map((t,n)=>Ye.createElement("tr",{key:n},Ye.createElement("td",null,t.name),Ye.createElement("td",null,t.type),Ye.createElement("td",null,t.class)))))),"Questions"),iC=o(({name:e,values:t})=>Ye.createElement(Ye.Fragment,null,Ye.createElement("h5",null,e),t.length>0?Ye.createElement("table",null,Ye.createElement("thead",null,Ye.createElement("tr",null,Ye.createElement("th",null,"Name"),Ye.createElement("th",null,"Type"),Ye.createElement("th",null,"Class"),Ye.createElement("th",null,"TTL"),Ye.createElement("th",null,"Data"))),Ye.createElement("tbody",null,t.map((n,l)=>Ye.createElement("tr",{key:l},Ye.createElement("td",null,n.name),Ye.createElement("td",null,n.type),Ye.createElement("td",null,n.class),Ye.createElement("td",null,n.ttl),Ye.createElement("td",null,n.data))))):"\u2014"),"ResourceRecords"),gP=o(({type:e,message:t})=>Ye.createElement("section",{className:"dns-"+e},Ye.createElement("div",{className:`first-line ${e}-line`},Ye.createElement(F3,{message:t})),Ye.createElement(B3,{message:t}),Ye.createElement("hr",null),Ye.createElement(iC,{name:`${t.authoritative_answer?"Authoritative ":""}${t.recursion_available?"Recursive ":""}Answer`,values:t.answers}),Ye.createElement("hr",null),Ye.createElement(iC,{name:"Authority",values:t.authorities}),Ye.createElement("hr",null),Ye.createElement(iC,{name:"Additional",values:t.additionals})),"Message");function oC(){let e=qe(t=>t.flows.byId[t.flows.selected[0]]);return Ye.createElement(gP,{type:"request",message:e.request})}o(oC,"Request");oC.displayName="Request";function sC(){let e=qe(t=>t.flows.byId[t.flows.selected[0]]);return Ye.createElement(gP,{type:"response",message:e.response})}o(sC,"Response");sC.displayName="Response";var _e=fe(Oe());function vP({conn:e}){var n,l,d;let t=null;return"address"in e?t=_e.createElement(_e.Fragment,null,_e.createElement("tr",null,_e.createElement("td",null,"Address:"),_e.createElement("td",null,(n=e.address)==null?void 0:n.join(":"))),e.peername&&_e.createElement("tr",null,_e.createElement("td",null,"Resolved address:"),_e.createElement("td",null,e.peername.join(":"))),e.sockname&&_e.createElement("tr",null,_e.createElement("td",null,"Source address:"),_e.createElement("td",null,e.sockname.join(":")))):((l=e.peername)==null?void 0:l[0])&&(t=_e.createElement(_e.Fragment,null,_e.createElement("tr",null,_e.createElement("td",null,"Address:"),_e.createElement("td",null,(d=e.peername)==null?void 0:d.join(":"))))),_e.createElement("table",{className:"connection-table"},_e.createElement("tbody",null,t,e.sni?_e.createElement("tr",null,_e.createElement("td",null,_e.createElement("abbr",{title:"TLS Server Name Indication"},"SNI"),":"),_e.createElement("td",null,e.sni)):null,e.alpn?_e.createElement("tr",null,_e.createElement("td",null,_e.createElement("abbr",{title:"ALPN protocol negotiated"},"ALPN"),":"),_e.createElement("td",null,e.alpn)):null,e.tls_version?_e.createElement("tr",null,_e.createElement("td",null,"TLS Version:"),_e.createElement("td",null,e.tls_version)):null,e.cipher?_e.createElement("tr",null,_e.createElement("td",null,"TLS Cipher:"),_e.createElement("td",null,e.cipher)):null))}o(vP,"ConnectionInfo");function yP(e){return _e.createElement("dl",{className:"cert-attributes"},e.map(([t,n])=>_e.createElement(_e.Fragment,{key:t},_e.createElement("dt",null,t),_e.createElement("dd",null,n))))}o(yP,"attrList");function H3({flow:e}){var n;let t=(n=e.server_conn)==null?void 0:n.cert;return t?_e.createElement(_e.Fragment,null,_e.createElement("h4",{key:"name"},"Server Certificate"),_e.createElement("table",{className:"certificate-table"},_e.createElement("tbody",null,_e.createElement("tr",null,_e.createElement("td",null,"Type"),_e.createElement("td",null,t.keyinfo[0],", ",t.keyinfo[1]," bits")),_e.createElement("tr",null,_e.createElement("td",null,"SHA256 digest"),_e.createElement("td",null,t.sha256)),_e.createElement("tr",null,_e.createElement("td",null,"Valid from"),_e.createElement("td",null,no(t.notbefore,{milliseconds:!1}))),_e.createElement("tr",null,_e.createElement("td",null,"Valid to"),_e.createElement("td",null,no(t.notafter,{milliseconds:!1}))),_e.createElement("tr",null,_e.createElement("td",null,"Subject Alternative Names"),_e.createElement("td",null,t.altnames.join(", "))),_e.createElement("tr",null,_e.createElement("td",null,"Subject"),_e.createElement("td",null,yP(t.subject))),_e.createElement("tr",null,_e.createElement("td",null,"Issuer"),_e.createElement("td",null,yP(t.issuer))),_e.createElement("tr",null,_e.createElement("td",null,"Serial"),_e.createElement("td",null,t.serial))))):_e.createElement(_e.Fragment,null)}o(H3,"CertificateInfo");function sy({flow:e}){var t;return _e.createElement("section",{className:"detail"},_e.createElement("h4",null,"Client Connection"),_e.createElement(vP,{conn:e.client_conn}),((t=e.server_conn)==null?void 0:t.address)&&_e.createElement(_e.Fragment,null,_e.createElement("h4",null,"Server Connection"),_e.createElement(vP,{conn:e.server_conn})),_e.createElement(H3,{flow:e}))}o(sy,"Connection");sy.displayName="Connection";var ym=fe(Oe());function ly({flow:e}){return ym.createElement("section",{className:"error"},ym.createElement("div",{className:"alert alert-warning"},e.error.msg,ym.createElement("div",null,ym.createElement("small",null,no(e.error.timestamp)))))}o(ly,"Error");ly.displayName="Error";var fs=fe(Oe());function W3({t:e,deltaTo:t,title:n}){return e?fs.createElement("tr",null,fs.createElement("td",null,n,":"),fs.createElement("td",null,no(e),t&&fs.createElement("span",{className:"text-muted"},"(",S0(1e3*(e-t)),")"))):fs.createElement("tr",null)}o(W3,"TimeStamp");function ay({flow:e}){var l,d,h,c,v,C;let t;e.type==="http"?t=e.request.timestamp_start:t=e.client_conn.timestamp_start;let n=[{title:"Server conn. initiated",t:(l=e.server_conn)==null?void 0:l.timestamp_start,deltaTo:t},{title:"Server conn. TCP handshake",t:(d=e.server_conn)==null?void 0:d.timestamp_tcp_setup,deltaTo:t},{title:"Server conn. TLS handshake",t:(h=e.server_conn)==null?void 0:h.timestamp_tls_setup,deltaTo:t},{title:"Server conn. closed",t:(c=e.server_conn)==null?void 0:c.timestamp_end,deltaTo:t},{title:"Client conn. established",t:e.client_conn.timestamp_start,deltaTo:e.type==="http"?t:void 0},{title:"Client conn. TLS handshake",t:e.client_conn.timestamp_tls_setup,deltaTo:t},{title:"Client conn. closed",t:e.client_conn.timestamp_end,deltaTo:t}];return e.type==="http"&&n.push({title:"First request byte",t:e.request.timestamp_start},{title:"Request complete",t:e.request.timestamp_end,deltaTo:t},{title:"First response byte",t:(v=e.response)==null?void 0:v.timestamp_start,deltaTo:t},{title:"Response complete",t:(C=e.response)==null?void 0:C.timestamp_end,deltaTo:t}),fs.createElement("section",{className:"timing"},fs.createElement("h4",null,"Timing"),fs.createElement("table",{className:"timing-table"},fs.createElement("tbody",null,n.filter(k=>!!k.t).sort((k,O)=>k.t-O.t).map(k=>fs.createElement(W3,ke({key:k.title},k))))))}o(ay,"Timing");ay.displayName="Timing";var pu=fe(Oe());var Zs=fe(Oe()),jp=fe(Oe());function $f({flow:e,messages_meta:t}){let n=Qt(),l=qe(k=>k.ui.flow.contentViewFor[e.id+"messages"]||"Auto"),[d,h]=(0,jp.useState)(qe(k=>k.options.content_view_lines_cutoff)),c=(0,jp.useCallback)(()=>h(Math.max(1024,d*2)),[d]),v=K0(Kr.getContentURL(e,"messages",l,d+1),e.id+t.count),C=(0,jp.useMemo)(()=>{if(v)try{return JSON.parse(v)}catch(k){return[{description:"Network Error",lines:[[["error",`${v}`]]]}]}},[v])||[];return Zs.createElement("div",{className:"contentview"},Zs.createElement("div",{className:"controls"},Zs.createElement("h5",null,t.count," Messages"),Zs.createElement(vm,{value:l,onChange:k=>n(w0(e.id+"messages",k))})),C.map((k,O)=>{let j=`fa fa-fw fa-arrow-${k.from_client?"right text-primary":"left text-danger"}`,B=Zs.createElement("div",{key:O},Zs.createElement("small",null,Zs.createElement("i",{className:j}),Zs.createElement("span",{className:"pull-right"},k.timestamp&&no(k.timestamp))),Zs.createElement(Y0,{lines:k.lines,maxLines:d,showMore:c}));return d-=k.lines.length,B}))}o($f,"Messages");function uy({flow:e}){return pu.createElement("section",{className:"websocket"},pu.createElement("h4",null,"WebSocket"),pu.createElement($f,{flow:e,messages_meta:e.websocket.messages_meta}),pu.createElement(U3,{websocket:e.websocket}))}o(uy,"WebSocket");uy.displayName="WebSocket";function U3({websocket:e}){if(!e.timestamp_end)return null;let t=e.close_reason?`(${e.close_reason})`:"";return pu.createElement("div",null,pu.createElement("i",{className:"fa fa-fw fa-window-close text-muted"}),"\xA0 Closed by ",e.closed_by_client?"client":"server"," ","with code ",e.close_code," ",t,".",pu.createElement("small",{className:"pull-right"},no(e.timestamp_end)))}o(U3,"CloseSummary");var wP=fe(ti());var lC=fe(Oe());function fy({flow:e}){return lC.createElement("section",{className:"tcp"},lC.createElement($f,{flow:e,messages_meta:e.messages_meta}))}o(fy,"TcpMessages");fy.displayName="Stream Data";var aC=fe(Oe());function cy({flow:e}){return aC.createElement("section",{className:"udp"},aC.createElement($f,{flow:e,messages_meta:e.messages_meta}))}o(cy,"UdpMessages");cy.displayName="Datagrams";var xP={request:rC,response:nC,error:ly,connection:sy,timing:ay,websocket:uy,tcpmessages:fy,udpmessages:cy,dnsrequest:oC,dnsresponse:sC};function py(e){let t;switch(e.type){case"http":t=["request","response","websocket"].filter(n=>e[n]);break;case"tcp":t=["tcpmessages"];break;case"udp":t=["udpmessages"];break;case"dns":t=["request","response"].filter(n=>e[n]).map(n=>"dns"+n);break}return e.error&&t.push("error"),t.push("connection"),t.push("timing"),t}o(py,"tabsForFlow");function uC(){let e=Qt(),t=qe(h=>h.flows.byId[h.flows.selected[0]]),n=py(t),l=qe(h=>h.ui.flow.tab);n.indexOf(l)<0&&(l==="response"&&t.error?l="error":l==="error"&&"response"in t?l="response":l=n[0]);let d=xP[l];return wm.createElement("div",{className:"flow-detail"},wm.createElement("nav",{className:"nav-tabs nav-tabs-sm"},n.map(h=>wm.createElement("a",{key:h,href:"#",className:(0,wP.default)({active:l===h}),onClick:c=>{c.preventDefault(),e(Pf(h))}},xP[h].displayName))),wm.createElement(d,{flow:t}))}o(uC,"FlowView");function SP(e){if(e.ctrlKey||e.metaKey)return()=>{};let t=e.key;return e.preventDefault(),(n,l)=>{let d=l().flows,h=d.byId[l().flows.selected[0]];switch(t){case"k":case"ArrowUp":n(Mf(d,-1));break;case"j":case"ArrowDown":n(Mf(d,1));break;case" ":case"PageDown":n(Mf(d,10));break;case"PageUp":n(Mf(d,-10));break;case"End":n(Mf(d,1e10));break;case"Home":n(Mf(d,-1e10));break;case"Escape":l().ui.modal.activeModal?n(z0()):n(Af(void 0));break;case"ArrowLeft":{if(!h)break;let c=py(h),v=l().ui.flow.tab,C=c[(Math.max(0,c.indexOf(v))-1+c.length)%c.length];n(Pf(C));break}case"Tab":case"ArrowRight":{if(!h)break;let c=py(h),v=l().ui.flow.tab,C=c[(Math.max(0,c.indexOf(v))+1)%c.length];n(Pf(C));break}case"Delete":case"d":{if(!h)return;n(F0(h));break}case"n":{Lf("view.flows.create","get","https://example.com/");break}case"D":{if(!h)return;n(B0(h));break}case"a":{h&&h.intercepted&&n(Op(h));break}case"A":{n(R0());break}case"r":{h&&n(Mp(h));break}case"v":{h&&h.modified&&n(H0(h));break}case"x":{h&&h.intercepted&&n(I0(h));break}case"X":{n(rN());break}case"z":{n(W0());break}default:return}}}o(SP,"onKeyDown");var Zp=fe(Oe());var xm=fe(Oe()),CP=fe(iu()),bP=fe(ti()),qp=class extends xm.Component{constructor(t,n){super(t,n);this.state={applied:!1,startPos:0,dragPointer:.1},this.onLostPointerCapture=this.onLostPointerCapture.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this)}onPointerDown(t){this.state.dragPointer===.1&&(t.target.setPointerCapture(t.pointerId),this.setState({startPos:this.props.axis==="x"?t.pageX:t.pageY,dragPointer:t.pointerId}))}onLostPointerCapture(t){if(this.state.dragPointer!==t.pointerId)return;let n=t.target.parentNode,l=n.previousElementSibling;n.style.transform="",l.style.flex=`0 0 ${Math.max(0,(this.props.axis==="x"?l.offsetWidth+t.pageX:l.offsetHeight+t.pageY)-this.state.startPos)}px`,n.nextElementSibling.style.flex="1 1 auto",this.setState({applied:!0,dragPointer:.1}),this.onResize()}onPointerMove(t){this.state.dragPointer===t.pointerId&&(t.target.parentNode.style.transform=this.props.axis==="x"?`translateX(${t.pageX-this.state.startPos}px)`:`translateY(${t.pageY-this.state.startPos}px)`)}onResize(){window.setTimeout(()=>window.dispatchEvent(new CustomEvent("resize")),1)}reset(t){if(!this.state.applied)return;let n=CP.default.findDOMNode(this);n.previousElementSibling&&(n.previousElementSibling.style.flex=""),n.nextElementSibling&&(n.nextElementSibling.style.flex=""),t||this.setState({applied:!1}),this.onResize()}componentWillUnmount(){this.reset(!0)}render(){return xm.default.createElement("div",{className:(0,bP.default)("splitter",this.props.axis==="x"?"splitter-x":"splitter-y")},xm.default.createElement("div",{onLostPointerCapture:this.onLostPointerCapture,onPointerDown:this.onPointerDown,onPointerMove:this.onPointerMove}))}};o(qp,"Splitter"),qp.defaultProps={axis:"x"};var cs=fe(Oe()),bm=fe(Sm()),hy=fe(iu());var BP=fe(fC());var cC=fe(iu()),MP=Symbol("shouldStick"),AP=o(e=>Math.round(e.scrollTop)+e.clientHeight===e.scrollHeight,"isAtBottom"),dy=o(e=>{var t;return Object.assign((o(t=class extends e{UNSAFE_componentWillUpdate(){let l=cC.default.findDOMNode(this);this[MP]=l.scrollTop&&AP(l),super.UNSAFE_componentWillUpdate&&super.UNSAFE_componentWillUpdate(),super.componentWillUpdate&&super.componentWillUpdate()}componentDidUpdate(){let l=cC.default.findDOMNode(this);this[MP]&&!AP(l)&&(l.scrollTop=l.scrollHeight),super.componentDidUpdate&&super.componentDidUpdate()}},"AutoScrollWrapper"),t.displayName=e.name,t),e)},"default");function jf(e=void 0){if(!e)return{start:0,end:0,paddingTop:0,paddingBottom:0};let{itemCount:t,rowHeight:n,viewportTop:l,viewportHeight:d,itemHeights:h}=e,c=l+d,v=0,C=0,k=0,O=0;if(h){let j=0;for(let B=0;B0&&jv.flows.sort.desc),l=qe(v=>v.flows.sort.column),d=qe(v=>v.options.web_columns),h=n?"sort-desc":"sort-asc",c=d.map(v=>im[v]).filter(v=>v).concat(Lp);return Cm.createElement("tr",null,c.map(v=>Cm.createElement("th",{className:(0,DP.default)(`col-${v.name}`,l===v.name&&h),key:v.name,onClick:()=>t(tN(v.name===l&&n?void 0:v.name,v.name!==l?!1:!n))},v.headerName)))},"FlowTableHead"));var Vp=fe(Oe()),IP=fe(ti());var FP=Vp.default.memo(o(function({flow:t,selected:n,highlighted:l}){let d=Qt(),h=qe(k=>k.options.web_columns),c=(0,IP.default)({selected:n,highlighted:l,intercepted:t.intercepted,"has-request":t.type==="http"&&t.request,"has-response":t.type==="http"&&t.response}),v=(0,Vp.useCallback)(k=>{let O=k.target;for(;O.parentNode;){if(O.classList.contains("col-quickactions"))return;O=O.parentNode}d(Af(t.id))},[t]),C=h.map(k=>im[k]).filter(k=>k).concat(Lp);return Vp.default.createElement("tr",{className:c,onClick:v},C.map(k=>Vp.default.createElement(k,{key:k.name,flow:t})))},"FlowRow"));var _m=class extends cs.Component{constructor(t,n){super(t,n);this.state={vScroll:jf()},this.onViewportUpdate=this.onViewportUpdate.bind(this)}UNSAFE_componentWillMount(){window.addEventListener("resize",this.onViewportUpdate)}componentDidMount(){this.onViewportUpdate()}UNSAFE_componentWillUnmount(){window.removeEventListener("resize",this.onViewportUpdate)}componentDidUpdate(){if(this.onViewportUpdate(),!this.shouldScrollIntoView)return;this.shouldScrollIntoView=!1;let{rowHeight:t,flows:n,selected:l}=this.props,d=hy.default.findDOMNode(this),h=hy.default.findDOMNode(this.refs.head),c=h?h.offsetHeight:0,v=n.indexOf(l)*t+c,C=v+t,k=d.scrollTop,O=d.offsetHeight;v-ck+O&&(d.scrollTop=C-O)}UNSAFE_componentWillReceiveProps(t){t.selected&&t.selected!==this.props.selected&&(this.shouldScrollIntoView=!0)}onViewportUpdate(){let t=hy.default.findDOMNode(this),n=t.scrollTop||0,l=jf({viewportTop:n,viewportHeight:t.offsetHeight||0,itemCount:this.props.flows.length,rowHeight:this.props.rowHeight});if(this.state.viewportTop!==n||!(0,BP.default)(this.state.vScroll,l)){let d=Math.min(n,l.end*this.props.rowHeight);this.setState({vScroll:l,viewportTop:d})}}render(){let{vScroll:t,viewportTop:n}=this.state,{flows:l,selected:d,highlight:h}=this.props,c=h?Of.parse(h):()=>!1;return cs.createElement("div",{className:"flow-table",onScroll:this.onViewportUpdate},cs.createElement("table",null,cs.createElement("thead",{ref:"head",style:{transform:`translateY(${n}px)`}},cs.createElement(RP,null)),cs.createElement("tbody",null,cs.createElement("tr",{style:{height:t.paddingTop}}),l.slice(t.start,t.end).map(v=>cs.createElement(FP,{key:v.id,flow:v,selected:v===d,highlighted:c(v)})),cs.createElement("tr",{style:{height:t.paddingBottom}}))))}};o(_m,"FlowTable"),Vc(_m,"propTypes",{flows:bm.default.array.isRequired,rowHeight:bm.default.number,highlight:bm.default.string,selected:bm.default.object}),Vc(_m,"defaultProps",{rowHeight:32});var j3=dy(_m),HP=Hi(e=>({flows:e.flows.view,highlight:e.flows.highlight,selected:e.flows.byId[e.flows.selected[0]]}))(j3);var Nr=fe(Oe()),Ty=fe(Oe());var zL=fe(UL());function RC(){let e=qe(n=>n.backendState.servers),t;return e.length===0?t="":e.length===1?t="Configure your client to use the following proxy server:":t="Configure your client to use one of the following proxy servers:",Nr.createElement("div",{style:{padding:"1em 2em"}},Nr.createElement("h3",null,"mitmproxy is running."),Nr.createElement("p",null,"No flows have been recorded yet.",Nr.createElement("br",null),t),Nr.createElement("ul",{className:"fa-ul"},e.map((n,l)=>Nr.createElement("li",{key:n.full_spec},Nr.createElement(HB,ke({},n))))))}o(RC,"CaptureSetup");function HB({description:e,listen_addrs:t,last_exception:n,is_running:l,full_spec:d,wireguard_conf:h}){let c=(0,Ty.useRef)(null);(0,Ty.useEffect)(()=>{h&&c.current&&zL.default.toCanvas(c.current,h,{margin:0,scale:3})},[h]);let v,C=t.length===1||t.length===2&&t[0][1]===t[1][1],k=t.every(B=>["::","0.0.0.0"].includes(B[0]));C&&k?v=rS(["*",t[0][1]]):v=t.map(rS).join(" and "),e=e[0].toUpperCase()+e.substr(1);let O,j;return n?(j="fa-exclamation text-error",O=Nr.createElement(Nr.Fragment,null,e," (",d,"):",Nr.createElement("br",null),n)):l?(j="fa-check text-success",O=`${e} listening at ${v}.`,h&&(O=Nr.createElement(Nr.Fragment,null,O,Nr.createElement("div",{className:"wireguard-config"},Nr.createElement("pre",null,h),Nr.createElement("canvas",{ref:c}))))):(j="fa-pause text-warning",O=Nr.createElement(Nr.Fragment,null,e," (",d,")")),Nr.createElement(Nr.Fragment,null,Nr.createElement("i",{className:`fa fa-li ${j}`}),O)}o(HB,"ServerDescription");function IC(){let e=qe(n=>!!n.flows.byId[n.flows.selected[0]]),t=qe(n=>n.flows.list.length>0);return Zp.createElement("div",{className:"main-view"},t?Zp.createElement(HP,null):Zp.createElement(RC,null),e&&Zp.createElement(qp,{key:"splitter"}),e&&Zp.createElement(uC,{key:"flowDetails"}))}o(IC,"MainView");var Io=fe(Oe()),YL=fe(ti());var oi=fe(Oe());var ps=fe(Oe()),ky=fe(iu()),$L=fe(ti());var oo=fe(Oe());var so=class extends oo.Component{constructor(t,n){super(t,n);this.state={doc:so.doc}}componentDidMount(){so.xhr||(so.xhr=kt("/filter-help").then(t=>t.json()),so.xhr.catch(()=>{so.xhr=null})),this.state.doc||so.xhr.then(t=>{so.doc=t,this.setState({doc:t})})}render(){let{doc:t}=this.state;return t?oo.default.createElement("table",{className:"table table-condensed"},oo.default.createElement("tbody",null,t.commands.map(n=>oo.default.createElement("tr",{key:n[1],onClick:l=>this.props.selectHandler(n[0].split(" ")[0]+" ")},oo.default.createElement("td",null,n[0].replace(" ","\xA0")),oo.default.createElement("td",null,n[1]))),oo.default.createElement("tr",{key:"docs-link"},oo.default.createElement("td",{colSpan:2},oo.default.createElement("a",{href:"https://mitmproxy.org/docs/latest/concepts-filters/",target:"_blank"},oo.default.createElement("i",{className:"fa fa-external-link"}),"\xA0 mitmproxy docs"))))):oo.default.createElement("i",{className:"fa fa-spinner fa-spin"})}};o(so,"FilterDocs");var Yf=class extends ps.Component{constructor(t,n){super(t,n);this.state={value:this.props.value,focus:!1,mousefocus:!1},this.onChange=this.onChange.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.selectFilter=this.selectFilter.bind(this)}UNSAFE_componentWillReceiveProps(t){this.setState({value:t.value})}isValid(t){try{return t&&Of.parse(t),!0}catch(n){return!1}}getDesc(){if(!this.state.value)return ps.default.createElement(so,{selectHandler:this.selectFilter});try{return Of.parse(this.state.value).desc}catch(t){return""+t}}onChange(t){let n=t.target.value;this.setState({value:n}),this.isValid(n)&&this.props.onChange(n)}onFocus(){this.setState({focus:!0})}onBlur(){this.setState({focus:!1})}onMouseEnter(){this.setState({mousefocus:!0})}onMouseLeave(){this.setState({mousefocus:!1})}onKeyDown(t){(t.key==="Escape"||t.key==="Enter")&&(this.blur(),this.setState({mousefocus:!1})),t.stopPropagation()}selectFilter(t){this.setState({value:t}),ky.default.findDOMNode(this.refs.input).focus()}blur(){ky.default.findDOMNode(this.refs.input).blur()}select(){ky.default.findDOMNode(this.refs.input).select()}render(){let{type:t,color:n,placeholder:l}=this.props,{value:d,focus:h,mousefocus:c}=this.state;return ps.default.createElement("div",{className:(0,$L.default)("filter-input input-group",{"has-error":!this.isValid(d)})},ps.default.createElement("span",{className:"input-group-addon"},ps.default.createElement("i",{className:"fa fa-fw fa-"+t,style:{color:n}})),ps.default.createElement("input",{type:"text",ref:"input",placeholder:l,className:"form-control",value:d,onChange:this.onChange,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown}),(h||c)&&ps.default.createElement("div",{className:"popover bottom",onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave},ps.default.createElement("div",{className:"arrow"}),ps.default.createElement("div",{className:"popover-content"},this.getDesc())))}};o(Yf,"FilterInput");Jp.title="Start";function Jp(){return oi.createElement("div",{className:"main-menu"},oi.createElement("div",{className:"menu-group"},oi.createElement("div",{className:"menu-content"},oi.createElement(UB,null),oi.createElement(zB,null)),oi.createElement("div",{className:"menu-legend"},"Find")),oi.createElement("div",{className:"menu-group"},oi.createElement("div",{className:"menu-content"},oi.createElement(WB,null),oi.createElement($B,null)),oi.createElement("div",{className:"menu-legend"},"Intercept")))}o(Jp,"StartMenu");function WB(){let e=Qt(),t=qe(n=>n.options.intercept);return oi.createElement(Yf,{value:t||"",placeholder:"Intercept",type:"pause",color:"hsl(208, 56%, 53%)",onChange:n=>e(Ip("intercept",n))})}o(WB,"InterceptInput");function UB(){let e=Qt(),t=qe(n=>n.flows.filter);return oi.createElement(Yf,{value:t||"",placeholder:"Search",type:"search",color:"black",onChange:n=>e(A0(n))})}o(UB,"FlowFilterInput");function zB(){let e=Qt(),t=qe(n=>n.flows.highlight);return oi.createElement(Yf,{value:t||"",placeholder:"Highlight",type:"tag",color:"hsl(48, 100%, 50%)",onChange:n=>e(D0(n))})}o(zB,"HighlightInput");function $B(){let e=Qt();return oi.createElement(kr,{className:"btn-sm",title:"[a]ccept all",icon:"fa-forward text-success",onClick:()=>e(R0())},"Resume All")}o($B,"ResumeAll");var Qr=fe(Oe());var Xf=fe(Oe());function FC({value:e,onChange:t,children:n}){return Xf.createElement("div",{className:"menu-entry"},Xf.createElement("label",null,Xf.createElement("input",{type:"checkbox",checked:e,onChange:t}),n))}o(FC,"MenuToggle");function Ny({name:e,children:t}){let n=Qt(),l=qe(d=>d.options[e]);return Xf.createElement(FC,{value:!!l,onChange:()=>n(Ip(e,!l))},t)}o(Ny,"OptionsToggle");function jL(){let e=Gs(),t=qe(n=>n.eventLog.visible);return Xf.createElement(FC,{value:t,onChange:()=>e(Rp())},"Display Event Log")}o(jL,"EventlogToggle");function qL(){let e=Gs(),t=qe(n=>n.commandBar.visible);return Xf.createElement(FC,{value:t,onChange:()=>e(V0())},"Display Command Bar")}o(qL,"CommandBarToggle");var BC=fe(Oe());function HC({children:e,resource:t}){let n=`https://docs.mitmproxy.org/stable/${t}`;return BC.createElement("a",{target:"_blank",href:n},e||BC.createElement("i",{className:"fa fa-question-circle"}))}o(HC,"DocsLink");var Py=fe(Oe());function Ro({children:e}){return window.MITMWEB_STATIC?null:Py.createElement(Py.Fragment,null,e)}o(Ro,"HideInStatic");Ly.title="Options";function Ly(){let e=Qt(),t=o(()=>sN("OptionModal"),"openOptions");return Qr.createElement("div",null,Qr.createElement(Ro,null,Qr.createElement("div",{className:"menu-group"},Qr.createElement("div",{className:"menu-content"},Qr.createElement(kr,{title:"Open Options",icon:"fa-cogs text-primary",onClick:()=>e(t())},"Edit Options ",Qr.createElement("sup",null,"alpha"))),Qr.createElement("div",{className:"menu-legend"},"Options Editor")),Qr.createElement("div",{className:"menu-group"},Qr.createElement("div",{className:"menu-content"},Qr.createElement(Ny,{name:"anticache"},"Strip cache headers"," ",Qr.createElement(HC,{resource:"overview-features/#anticache"})),Qr.createElement(Ny,{name:"showhost"},"Use host header for display"),Qr.createElement(Ny,{name:"ssl_insecure"},"Don't verify server certificates")),Qr.createElement("div",{className:"menu-legend"},"Quick Options"))),Qr.createElement("div",{className:"menu-group"},Qr.createElement("div",{className:"menu-content"},Qr.createElement(jL,null),Qr.createElement(qL,null)),Qr.createElement("div",{className:"menu-legend"},"View Options")))}o(Ly,"OptionMenu");var Hn=fe(Oe());var VL=Hn.memo(o(function(){let t=Gs(),n=qe(l=>l.flows.filter);return Hn.createElement(cu,{className:"pull-left special",text:"File",options:{placement:"bottom-start"}},Hn.createElement("li",null,Hn.createElement(G0,{icon:"fa-folder-open",text:"\xA0Open...",onClick:l=>l.stopPropagation(),onOpenFile:l=>{t(iN(l)),document.body.click()}})),Hn.createElement(ii,{onClick:()=>location.replace("/flows/dump")},Hn.createElement("i",{className:"fa fa-fw fa-floppy-o"}),"\xA0Save"),Hn.createElement(ii,{onClick:()=>location.replace("/flows/dump?filter="+n)},Hn.createElement("i",{className:"fa fa-fw fa-floppy-o"}),"\xA0Save filtered"),Hn.createElement(ii,{onClick:()=>confirm("Delete all flows?")&&t(W0())},Hn.createElement("i",{className:"fa fa-fw fa-trash"}),"\xA0Clear All"),Hn.createElement(Ro,null,Hn.createElement(hP,null),Hn.createElement("li",null,Hn.createElement("a",{href:"http://mitm.it/",target:"_blank"},Hn.createElement("i",{className:"fa fa-fw fa-external-link"}),"\xA0Install Certificates..."))))},"FileMenu"));var at=fe(Oe());function KL(e){if(navigator.clipboard&&window.isSecureContext)return navigator.clipboard.writeText(e);{let t=document.createElement("textarea");t.value=e,t.style.position="absolute",t.style.opacity="0",document.body.appendChild(t);try{return t.focus(),t.select(),document.execCommand("copy"),Promise.resolve()}catch(n){return alert(e),Promise.reject(n)}finally{t.remove()}}}o(KL,"copyToClipboard");var ed=o((e,t)=>Ia(void 0,null,function*(){let n=yield Lf("export",t,`@${e.id}`);n.value?yield KL(n.value):n.error?alert(n.error):console.error(n)}),"copy");td.title="Flow";function td(){let e=Qt(),t=qe(n=>n.flows.byId[n.flows.selected[0]]);return t?at.createElement("div",{className:"flow-menu"},at.createElement(Ro,null,at.createElement("div",{className:"menu-group"},at.createElement("div",{className:"menu-content"},at.createElement(kr,{title:"[r]eplay flow",icon:"fa-repeat text-primary",onClick:()=>e(Mp(t)),disabled:!_0(t)},"Replay"),at.createElement(kr,{title:"[D]uplicate flow",icon:"fa-copy text-info",onClick:()=>e(B0(t))},"Duplicate"),at.createElement(kr,{disabled:!t||!t.modified,title:"revert changes to flow [V]",icon:"fa-history text-warning",onClick:()=>e(H0(t))},"Revert"),at.createElement(kr,{title:"[d]elete flow",icon:"fa-trash text-danger",onClick:()=>e(F0(t))},"Delete"),at.createElement(KB,{flow:t})),at.createElement("div",{className:"menu-legend"},"Flow Modification"))),at.createElement("div",{className:"menu-group"},at.createElement("div",{className:"menu-content"},at.createElement(jB,{flow:t}),at.createElement(qB,{flow:t})),at.createElement("div",{className:"menu-legend"},"Export")),at.createElement(Ro,null,at.createElement("div",{className:"menu-group"},at.createElement("div",{className:"menu-content"},at.createElement(kr,{disabled:!t||!t.intercepted,title:"[a]ccept intercepted flow",icon:"fa-play text-success",onClick:()=>e(Op(t))},"Resume"),at.createElement(kr,{disabled:!t||!t.intercepted,title:"kill intercepted flow [x]",icon:"fa-times text-danger",onClick:()=>e(I0(t))},"Abort")),at.createElement("div",{className:"menu-legend"},"Interception")))):at.createElement("div",null)}o(td,"FlowMenu");var Oy=o(e=>{let t=window.open(e,"_blank","noopener,noreferrer");t&&(t.opener=null)},"openInNewTab");function jB({flow:e}){var t;if(e.type!=="http")return at.createElement(kr,{icon:"fa-download",onClick:()=>0,disabled:!0},"Download");if(e.request.contentLength&&!((t=e.response)==null?void 0:t.contentLength))return at.createElement(kr,{icon:"fa-download",onClick:()=>Oy(Kr.getContentURL(e,e.request))},"Download");if(e.response){let n=e.response;if(!e.request.contentLength&&e.response.contentLength)return at.createElement(kr,{icon:"fa-download",onClick:()=>Oy(Kr.getContentURL(e,n))},"Download");if(e.request.contentLength&&e.response.contentLength)return at.createElement(cu,{text:at.createElement(kr,{icon:"fa-download",onClick:()=>1},"Download\u25BE"),options:{placement:"bottom-start"}},at.createElement(ii,{onClick:()=>Oy(Kr.getContentURL(e,e.request))},"Download request"),at.createElement(ii,{onClick:()=>Oy(Kr.getContentURL(e,n))},"Download response"))}return null}o(jB,"DownloadButton");function qB({flow:e}){return at.createElement(cu,{className:"",text:at.createElement(kr,{title:"Export flow.",icon:"fa-clone",onClick:()=>1,disabled:e.type!=="http"},"Export\u25BE"),options:{placement:"bottom-start"}},at.createElement(ii,{onClick:()=>ed(e,"raw_request")},"Copy raw request"),at.createElement(ii,{onClick:()=>ed(e,"raw_response")},"Copy raw response"),at.createElement(ii,{onClick:()=>ed(e,"raw")},"Copy raw request and response"),at.createElement(ii,{onClick:()=>ed(e,"curl")},"Copy as cURL"),at.createElement(ii,{onClick:()=>ed(e,"httpie")},"Copy as HTTPie"))}o(qB,"ExportButton");var VB={":red_circle:":"\u{1F534}",":orange_circle:":"\u{1F7E0}",":yellow_circle:":"\u{1F7E1}",":green_circle:":"\u{1F7E2}",":large_blue_circle:":"\u{1F535}",":purple_circle:":"\u{1F7E3}",":brown_circle:":"\u{1F7E4}"};function KB({flow:e}){let t=Qt();return at.createElement(cu,{className:"",text:at.createElement(kr,{title:"mark flow",icon:"fa-paint-brush text-success",onClick:()=>1},"Mark\u25BE"),options:{placement:"bottom-start"}},at.createElement(ii,{onClick:()=>t(Wi(e,{marked:""}))},"\u26AA (no marker)"),Object.entries(VB).map(([n,l])=>at.createElement(ii,{key:n,onClick:()=>t(Wi(e,{marked:n}))},l," ",n.replace(/[:_]/g," "))))}o(KB,"MarkButton");var vu=fe(Oe());var GL=vu.memo(o(function(){let t=qe(l=>l.connection.state),n=qe(l=>l.connection.message);switch(t){case ni.INIT:return vu.createElement("span",{className:"connection-indicator init"},"connecting\u2026");case ni.FETCHING:return vu.createElement("span",{className:"connection-indicator fetching"},"fetching data\u2026");case ni.ESTABLISHED:return vu.createElement("span",{className:"connection-indicator established"},"connected");case ni.ERROR:return vu.createElement("span",{className:"connection-indicator error",title:n},"connection lost");case ni.OFFLINE:return vu.createElement("span",{className:"connection-indicator offline"},"offline");default:let l=t;throw"unknown connection state"}},"ConnectionIndicator"));function WC(){let e=qe(v=>v.flows.selected.filter(C=>C in v.flows.byId)),[t,n]=(0,Io.useState)(()=>Jp),[l,d]=(0,Io.useState)(!1),h=[Jp,Ly];e.length>0?(l||(n(()=>td),d(!0)),h.push(td)):(l&&d(!1),t===td&&n(()=>Jp));function c(v,C){C.preventDefault(),n(()=>v)}return o(c,"handleClick"),Io.default.createElement("header",null,Io.default.createElement("nav",{className:"nav-tabs nav-tabs-lg"},Io.default.createElement(VL,null),h.map(v=>Io.default.createElement("a",{key:v.title,href:"#",className:(0,YL.default)({active:v===t}),onClick:C=>c(v,C)},v.title)),Io.default.createElement(Ro,null,Io.default.createElement(GL,null))),Io.default.createElement("div",null,Io.default.createElement(t,null)))}o(WC,"Header");var Je=fe(Oe()),XL=fe(ti());var My=function(){"use strict";function e(l,d){function h(){this.constructor=l}o(h,"ctor"),h.prototype=d.prototype,l.prototype=new h}o(e,"peg$subclass");function t(l,d,h,c){this.message=l,this.expected=d,this.found=h,this.location=c,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t)}o(t,"peg$SyntaxError"),e(t,Error);function n(l){var d=arguments.length>1?arguments[1]:{},h=this,c={},v={Expr:Cr},C=Cr,k=o(function(H,ee){return[H,...ee]},"peg$c0"),O=o(function(H){return[H]},"peg$c1"),j=o(function(){return""},"peg$c2"),B={type:"other",description:"string"},X='"',J={type:"literal",value:'"',description:'"\\""'},Z=o(function(H){return H.join("")},"peg$c6"),R="'",A={type:"literal",value:"'",description:`"'"`},I=/^["\\]/,G={type:"class",value:'["\\\\]',description:'["\\\\]'},K={type:"any",description:"any character"},se=o(function(H){return H},"peg$c12"),ne="\\",pe={type:"literal",value:"\\",description:'"\\\\"'},me=/^['\\]/,xe={type:"class",value:"['\\\\]",description:"['\\\\]"},Ve=/^['"\\]/,tt={type:"class",value:`['"\\\\]`,description:`['"\\\\]`},Ee="n",St={type:"literal",value:"n",description:'"n"'},We=o(function(){return` +`},"peg$c21"),Ke="r",Ge={type:"literal",value:"r",description:'"r"'},Xe=o(function(){return"\r"},"peg$c24"),nr="t",ct={type:"literal",value:"t",description:'"t"'},Hr=o(function(){return" "},"peg$c27"),Zt={type:"other",description:"whitespace"},Et=/^[ \t\n\r]/,Ct={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},ut={type:"other",description:"control character"},Pr=/^[|&!()~"]/,zt={type:"class",value:'[|&!()~"]',description:'[|&!()~"]'},$t={type:"other",description:"optional whitespace"},ie=0,rt=0,Lr=[{line:1,column:1,seenCR:!1}],Gt=0,Yt=[],Se=0,Or;if("startRule"in d){if(!(d.startRule in v))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');C=v[d.startRule]}function fn(){return l.substring(rt,ie)}o(fn,"text");function Un(){return gr(rt,ie)}o(Un,"location");function si(H){throw Ho(null,[{type:"other",description:H}],l.substring(rt,ie),gr(rt,ie))}o(si,"expected");function cn(H){throw Ho(H,null,l.substring(rt,ie),gr(rt,ie))}o(cn,"error");function Jt(H){var ee=Lr[H],he,Te;if(ee)return ee;for(he=H-1;!Lr[he];)he--;for(ee=Lr[he],ee={line:ee.line,column:ee.column,seenCR:ee.seenCR};heGt&&(Gt=ie,Yt=[]),Yt.push(H))}o(pt,"peg$fail");function Ho(H,ee,he,Te){function ir(Ft){var Wr=1;for(Ft.sort(function(or,li){return or.descriptionli.description?1:0});Wr1?li.slice(0,-1).join(", ")+" or "+li[Ft.length-1]:li[0],lo=Wr?'"'+or(Wr)+'"':"end of input","Expected "+ds+" but "+lo+" found."}return o(Ul,"buildMessage"),ee!==null&&ir(ee),new t(H!==null?H:Ul(ee,he),ee,he,Te)}o(Ho,"peg$buildException");function Cr(){var H,ee,he,Te;if(H=ie,ee=Ui(),ee!==c){if(he=[],Te=$n(),Te!==c)for(;Te!==c;)he.push(Te),Te=$n();else he=c;he!==c?(Te=Cr(),Te!==c?(rt=H,ee=k(ee,Te),H=ee):(ie=H,H=c)):(ie=H,H=c)}else ie=H,H=c;if(H===c&&(H=ie,ee=Ui(),ee!==c&&(rt=H,ee=O(ee)),H=ee,H===c)){for(H=ie,ee=[],he=$n();he!==c;)ee.push(he),he=$n();ee!==c&&(rt=H,ee=j()),H=ee}return H}o(Cr,"peg$parseExpr");function Ui(){var H,ee,he,Te;if(Se++,H=ie,l.charCodeAt(ie)===34?(ee=X,ie++):(ee=c,Se===0&&pt(J)),ee!==c){for(he=[],Te=pn();Te!==c;)he.push(Te),Te=pn();he!==c?(l.charCodeAt(ie)===34?(Te=X,ie++):(Te=c,Se===0&&pt(J)),Te!==c?(rt=H,ee=Z(he),H=ee):(ie=H,H=c)):(ie=H,H=c)}else ie=H,H=c;if(H===c){if(H=ie,l.charCodeAt(ie)===39?(ee=R,ie++):(ee=c,Se===0&&pt(A)),ee!==c){for(he=[],Te=zn();Te!==c;)he.push(Te),Te=zn();he!==c?(l.charCodeAt(ie)===39?(Te=R,ie++):(Te=c,Se===0&&pt(A)),Te!==c?(rt=H,ee=Z(he),H=ee):(ie=H,H=c)):(ie=H,H=c)}else ie=H,H=c;if(H===c){if(H=ie,ee=ie,Se++,he=Mn(),Se--,he===c?ee=void 0:(ie=ee,ee=c),ee!==c){if(he=[],Te=Si(),Te!==c)for(;Te!==c;)he.push(Te),Te=Si();else he=c;he!==c?(rt=H,ee=Z(he),H=ee):(ie=H,H=c)}else ie=H,H=c;if(H===c){if(H=ie,l.charCodeAt(ie)===34?(ee=X,ie++):(ee=c,Se===0&&pt(J)),ee!==c){for(he=[],Te=pn();Te!==c;)he.push(Te),Te=pn();he!==c?(rt=H,ee=Z(he),H=ee):(ie=H,H=c)}else ie=H,H=c;if(H===c)if(H=ie,l.charCodeAt(ie)===39?(ee=R,ie++):(ee=c,Se===0&&pt(A)),ee!==c){for(he=[],Te=zn();Te!==c;)he.push(Te),Te=zn();he!==c?(rt=H,ee=Z(he),H=ee):(ie=H,H=c)}else ie=H,H=c}}}return Se--,H===c&&(ee=c,Se===0&&pt(B)),H}o(Ui,"peg$parseStringLiteral");function pn(){var H,ee,he;return H=ie,ee=ie,Se++,I.test(l.charAt(ie))?(he=l.charAt(ie),ie++):(he=c,Se===0&&pt(G)),Se--,he===c?ee=void 0:(ie=ee,ee=c),ee!==c?(l.length>ie?(he=l.charAt(ie),ie++):(he=c,Se===0&&pt(K)),he!==c?(rt=H,ee=se(he),H=ee):(ie=H,H=c)):(ie=H,H=c),H===c&&(H=ie,l.charCodeAt(ie)===92?(ee=ne,ie++):(ee=c,Se===0&&pt(pe)),ee!==c?(he=Ci(),he!==c?(rt=H,ee=se(he),H=ee):(ie=H,H=c)):(ie=H,H=c)),H}o(pn,"peg$parseDoubleStringChar");function zn(){var H,ee,he;return H=ie,ee=ie,Se++,me.test(l.charAt(ie))?(he=l.charAt(ie),ie++):(he=c,Se===0&&pt(xe)),Se--,he===c?ee=void 0:(ie=ee,ee=c),ee!==c?(l.length>ie?(he=l.charAt(ie),ie++):(he=c,Se===0&&pt(K)),he!==c?(rt=H,ee=se(he),H=ee):(ie=H,H=c)):(ie=H,H=c),H===c&&(H=ie,l.charCodeAt(ie)===92?(ee=ne,ie++):(ee=c,Se===0&&pt(pe)),ee!==c?(he=Ci(),he!==c?(rt=H,ee=se(he),H=ee):(ie=H,H=c)):(ie=H,H=c)),H}o(zn,"peg$parseSingleStringChar");function Si(){var H,ee,he;return H=ie,ee=ie,Se++,he=$n(),Se--,he===c?ee=void 0:(ie=ee,ee=c),ee!==c?(l.length>ie?(he=l.charAt(ie),ie++):(he=c,Se===0&&pt(K)),he!==c?(rt=H,ee=se(he),H=ee):(ie=H,H=c)):(ie=H,H=c),H}o(Si,"peg$parseUnquotedStringChar");function Ci(){var H,ee;return Ve.test(l.charAt(ie))?(H=l.charAt(ie),ie++):(H=c,Se===0&&pt(tt)),H===c&&(H=ie,l.charCodeAt(ie)===110?(ee=Ee,ie++):(ee=c,Se===0&&pt(St)),ee!==c&&(rt=H,ee=We()),H=ee,H===c&&(H=ie,l.charCodeAt(ie)===114?(ee=Ke,ie++):(ee=c,Se===0&&pt(Ge)),ee!==c&&(rt=H,ee=Xe()),H=ee,H===c&&(H=ie,l.charCodeAt(ie)===116?(ee=nr,ie++):(ee=c,Se===0&&pt(ct)),ee!==c&&(rt=H,ee=Hr()),H=ee))),H}o(Ci,"peg$parseEscapeSequence");function $n(){var H,ee;return Se++,Et.test(l.charAt(ie))?(H=l.charAt(ie),ie++):(H=c,Se===0&&pt(Ct)),Se--,H===c&&(ee=c,Se===0&&pt(Zt)),H}o($n,"peg$parsews");function Mn(){var H,ee;return Se++,Pr.test(l.charAt(ie))?(H=l.charAt(ie),ie++):(H=c,Se===0&&pt(zt)),Se--,H===c&&(ee=c,Se===0&&pt(ut)),H}o(Mn,"peg$parsecc");function Js(){var H,ee;for(Se++,H=[],ee=$n();ee!==c;)H.push(ee),ee=$n();return Se--,H===c&&(ee=c,Se===0&&pt($t)),H}if(o(Js,"peg$parse__"),Or=C(),Or!==c&&ie===l.length)return Or;throw Or!==c&&ie{t&&t.current.addEventListener("DOMNodeInserted",n=>{let l=n.currentTarget;l.scroll({top:l.scrollHeight,behavior:"auto"})})},[]),Je.default.createElement("div",{className:"command-result",ref:t},e.map((n,l)=>Je.default.createElement("div",{key:l},Je.default.createElement("div",null,Je.default.createElement("strong",null,"$ ",n.command)),n.result)))}o(GB,"Results");function YB({nextArgs:e,currentArg:t,help:n,description:l,availableCommands:d}){let h=[];for(let c=0;c0&&Je.default.createElement("div",null,Je.default.createElement("strong",null,"Argument suggestion:")," ",h),(n==null?void 0:n.includes("->"))&&Je.default.createElement("div",null,Je.default.createElement("strong",null,"Signature help: "),n),l&&Je.default.createElement("div",null,"# ",l),Je.default.createElement("div",null,Je.default.createElement("strong",null,"Available Commands: "),Je.default.createElement("p",{className:"available-commands"},JSON.stringify(d)))))}o(YB,"CommandHelp");function zC(){let[e,t]=(0,Je.useState)(""),[n,l]=(0,Je.useState)(""),[d,h]=(0,Je.useState)(0),[c,v]=(0,Je.useState)([]),[C,k]=(0,Je.useState)([]),[O,j]=(0,Je.useState)({}),[B,X]=(0,Je.useState)([]),[J,Z]=(0,Je.useState)(0),[R,A]=(0,Je.useState)(""),[I,G]=(0,Je.useState)(""),[K,se]=(0,Je.useState)([]),[ne,pe]=(0,Je.useState)([]),[me,xe]=(0,Je.useState)(void 0);(0,Je.useEffect)(()=>{kt("/commands",{method:"GET"}).then(We=>We.json()).then(We=>{j(We),v(UC(We)),k(Object.keys(We))}).catch(We=>console.error(We))},[]),(0,Je.useEffect)(()=>{Lf("commands.history.get").then(We=>{pe(We.value)}).catch(We=>console.error(We))},[]);let Ve=o((We,Ke)=>{var ct,Hr,Zt;let Ge=My.parse(Ke),Xe=My.parse(We);A((ct=O[Ge[0]])==null?void 0:ct.signature_help),G(((Hr=O[Ge[0]])==null?void 0:Hr.help)||""),v(UC(O,Xe[0])),k(UC(O,Ge[0]));let nr=(Zt=O[Ge[0]])==null?void 0:Zt.parameters.map(Et=>Et.name);nr&&(X([Ge[0],...nr]),Z(Ge.length-1))},"parseCommand"),tt=o(We=>{t(We.target.value),l(We.target.value),h(0)},"onChange"),Ee=o(We=>{if(We.key==="Enter"){let[Ke,...Ge]=My.parse(e);pe([...ne,e]),Lf("commands.history.add",e).catch(()=>0),kt.post(`/commands/${Ke}`,{arguments:Ge}).then(Xe=>Xe.json()).then(Xe=>{xe(void 0),X([]),se([...K,{command:e,result:JSON.stringify(Xe.value||Xe.error)}])}).catch(Xe=>{xe(void 0),X([]),se([...K,{command:e,result:Xe.toString()}])}),A(""),G(""),t(""),l(""),h(0),v(C)}if(We.key==="ArrowUp"){let Ke;me===void 0?Ke=ne.length-1:Ke=Math.max(0,me-1),t(ne[Ke]),l(ne[Ke]),xe(Ke)}if(We.key==="ArrowDown"){if(me===void 0)return;if(me==ne.length-1)t(""),l(""),xe(void 0);else{let Ke=me+1;t(ne[Ke]),l(ne[Ke]),xe(Ke)}}We.key==="Tab"&&(t(c[d]),h((d+1)%c.length),We.preventDefault()),We.stopPropagation()},"onKeyDown"),St=o(We=>{if(!e){k(Object.keys(O));return}Ve(n,e),We.stopPropagation()},"onKeyUp");return Je.default.createElement("div",{className:"command"},Je.default.createElement("div",{className:"command-title"},"Command Result"),Je.default.createElement(GB,{results:K}),Je.default.createElement(YB,{nextArgs:B,currentArg:J,help:R,description:I,availableCommands:C}),Je.default.createElement("div",{className:(0,XL.default)("command-input input-group")},Je.default.createElement("span",{className:"input-group-addon"},Je.default.createElement("i",{className:"fa fa-fw fa-terminal"})),Je.default.createElement("input",{type:"text",placeholder:"Enter command",className:"form-control",value:e||"",onChange:tt,onKeyDown:Ee,onKeyUp:St})))}o(zC,"CommandBar");var Wl=fe(Oe()),rd=fe(Sm());var $C=fe(Oe());function jC({checked:e,onToggle:t,text:n}){return $C.default.createElement("div",{className:"btn btn-toggle "+(e?"btn-primary":"btn-default"),onClick:t},$C.default.createElement("i",{className:"fa fa-fw "+(e?"fa-check-square-o":"fa-square-o")}),"\xA0",n)}o(jC,"ToggleButton");var Hl=fe(Oe()),qC=fe(Sm()),QL=fe(iu()),ZL=fe(fC());var Am=class extends Hl.Component{constructor(t){super(t);this.heights={},this.state={vScroll:jf()},this.onViewportUpdate=this.onViewportUpdate.bind(this)}componentDidMount(){window.addEventListener("resize",this.onViewportUpdate),this.onViewportUpdate()}componentWillUnmount(){window.removeEventListener("resize",this.onViewportUpdate)}componentDidUpdate(){this.onViewportUpdate()}onViewportUpdate(){let t=QL.default.findDOMNode(this),n=jf({itemCount:this.props.events.length,rowHeight:this.props.rowHeight,viewportTop:t.scrollTop,viewportHeight:t.offsetHeight,itemHeights:this.props.events.map(l=>this.heights[l.id])});(0,ZL.default)(this.state.vScroll,n)||this.setState({vScroll:n})}setHeight(t,n){if(n&&!this.heights[t]){let l=n.offsetHeight;this.heights[t]!==l&&(this.heights[t]=l,this.onViewportUpdate())}}render(){let{vScroll:t}=this.state,{events:n}=this.props;return Hl.default.createElement("pre",{onScroll:this.onViewportUpdate},Hl.default.createElement("div",{style:{height:t.paddingTop}}),n.slice(t.start,t.end).map(l=>Hl.default.createElement("div",{key:l.id,ref:d=>this.setHeight(l.id,d)},Hl.default.createElement(XB,{event:l}),l.message)),Hl.default.createElement("div",{style:{height:t.paddingBottom}}))}};o(Am,"EventLogList"),Am.propTypes={events:qC.default.array.isRequired,rowHeight:qC.default.number},Am.defaultProps={rowHeight:18};function XB({event:e}){let t={web:"html5",debug:"bug",warn:"exclamation-triangle",error:"ban"}[e.level]||"info";return Hl.default.createElement("i",{className:`fa fa-fw fa-${t}`})}o(XB,"LogIcon");var JL=dy(Am);var Dm=class extends Wl.Component{constructor(t,n){super(t,n);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(t){t.preventDefault(),this.dragStart=this.state.height+t.pageY,window.addEventListener("mousemove",this.onDragMove),window.addEventListener("mouseup",this.onDragStop),window.addEventListener("dragend",this.onDragStop)}onDragMove(t){t.preventDefault(),this.setState({height:this.dragStart-t.pageY})}onDragStop(t){t.preventDefault(),window.removeEventListener("mousemove",this.onDragMove)}render(){let{height:t}=this.state,{filters:n,events:l,toggleFilter:d,close:h}=this.props;return Wl.default.createElement("div",{className:"eventlog",style:{height:t}},Wl.default.createElement("div",{onMouseDown:this.onDragStart},"Eventlog",Wl.default.createElement("div",{className:"pull-right"},["debug","info","web","warn","error"].map(c=>Wl.default.createElement(jC,{key:c,text:c,checked:n[c],onToggle:()=>d(c)})),Wl.default.createElement("i",{onClick:h,className:"fa fa-close"}))),Wl.default.createElement(JL,{events:l}))}};o(Dm,"PureEventLog"),Vc(Dm,"propTypes",{filters:rd.default.object.isRequired,events:rd.default.array.isRequired,toggleFilter:rd.default.func.isRequired,close:rd.default.func.isRequired,defaultHeight:rd.default.number}),Vc(Dm,"defaultProps",{defaultHeight:200});var eO=Hi(e=>({filters:e.eventLog.filters,events:e.eventLog.view}),{close:Rp,toggleFilter:gN})(Dm);var un=fe(Oe());function VC(){let e=qe(A=>A.backendState.version),{mode:t,intercept:n,showhost:l,upstream_cert:d,rawtcp:h,http2:c,websocket:v,anticache:C,anticomp:k,stickyauth:O,stickycookie:j,stream_large_bodies:B,listen_host:X,listen_port:J,server:Z,ssl_insecure:R}=qe(A=>A.options);return un.createElement("footer",null,t&&(t.length!==1||t[0]!=="regular")&&un.createElement("span",{className:"label label-success"},t.join(",")),n&&un.createElement("span",{className:"label label-success"},"Intercept: ",n),R&&un.createElement("span",{className:"label label-danger"},"ssl_insecure"),l&&un.createElement("span",{className:"label label-success"},"showhost"),!d&&un.createElement("span",{className:"label label-success"},"no-upstream-cert"),!h&&un.createElement("span",{className:"label label-success"},"no-raw-tcp"),!c&&un.createElement("span",{className:"label label-success"},"no-http2"),!v&&un.createElement("span",{className:"label label-success"},"no-websocket"),C&&un.createElement("span",{className:"label label-success"},"anticache"),k&&un.createElement("span",{className:"label label-success"},"anticomp"),O&&un.createElement("span",{className:"label label-success"},"stickyauth: ",O),j&&un.createElement("span",{className:"label label-success"},"stickycookie: ",j),B&&un.createElement("span",{className:"label label-success"},"stream: ",x0(B)),un.createElement("div",{className:"pull-right"},un.createElement(Ro,null,Z&&un.createElement("span",{className:"label label-primary",title:"HTTP Proxy Server Address"},X||"*",":",J||8080)),un.createElement("span",{className:"label label-default",title:"Mitmproxy Version"},"mitmproxy ",e)))}o(VC,"Footer");var JC=fe(Oe());var ZC=fe(Oe());var nd=fe(Oe());function KC({children:e}){return nd.createElement("div",null,nd.createElement("div",{className:"modal-backdrop fade in"}),nd.createElement("div",{className:"modal modal-visible",id:"optionsModal",tabIndex:-1,role:"dialog","aria-labelledby":"options"},nd.createElement("div",{className:"modal-dialog modal-lg",role:"document"},nd.createElement("div",{className:"modal-content"},e))))}o(KC,"ModalLayout");var mr=fe(Oe());var Fo=fe(Oe()),Bo=fe(Sm());var tO=fe(ti()),QB=o(e=>{e.key!=="Escape"&&e.stopPropagation()},"stopPropagation");GC.propTypes={value:Bo.default.bool.isRequired,onChange:Bo.default.func.isRequired};function GC(l){var d=l,{value:e,onChange:t}=d,n=Ws(d,["value","onChange"]);return Fo.default.createElement("div",{className:"checkbox"},Fo.default.createElement("label",null,Fo.default.createElement("input",ke({type:"checkbox",checked:e,onChange:h=>t(h.target.checked)},n)),"Enable"))}o(GC,"BooleanOption");YC.propTypes={value:Bo.default.string,onChange:Bo.default.func.isRequired};function YC(l){var d=l,{value:e,onChange:t}=d,n=Ws(d,["value","onChange"]);return Fo.default.createElement("input",ke({type:"text",value:e||"",onChange:h=>t(h.target.value)},n))}o(YC,"StringOption");function rO(e){return function(l){var d=l,{onChange:t}=d,n=Ws(d,["onChange"]);return Fo.default.createElement(e,ke({onChange:h=>t(h||null)},n))}}o(rO,"Optional");XC.propTypes={value:Bo.default.number.isRequired,onChange:Bo.default.func.isRequired};function XC(l){var d=l,{value:e,onChange:t}=d,n=Ws(d,["value","onChange"]);return Fo.default.createElement("input",ke({type:"number",value:e,onChange:h=>t(parseInt(h.target.value))},n))}o(XC,"NumberOption");nO.propTypes={value:Bo.default.string.isRequired,onChange:Bo.default.func.isRequired};function nO(d){var h=d,{value:e,onChange:t,choices:n}=h,l=Ws(h,["value","onChange","choices"]);return Fo.default.createElement("select",ke({onChange:c=>t(c.target.value),value:e},l),n.map(c=>Fo.default.createElement("option",{key:c,value:c},c)))}o(nO,"ChoicesOption");iO.propTypes={value:Bo.default.arrayOf(Bo.default.string).isRequired,onChange:Bo.default.func.isRequired};function iO(l){var d=l,{value:e,onChange:t}=d,n=Ws(d,["value","onChange"]);let h=Math.max(e.length,1);return Fo.default.createElement("textarea",ke({rows:h,value:e.join(` `),onChange:c=>t(c.target.value.split(` -`))},n))}o(iO,"StringSequenceOption");var ZB={bool:YC,str:XC,int:QC,"optional str":rO(XC),"optional int":rO(QC),"sequence of str":iO};function JB({choices:e,type:t,value:n,onChange:l,name:d,error:h}){let c,v={};if(e)c=nO,v.choices=e;else if(c=ZB[t],!c)throw`unknown option type ${t}`;return c!==YC&&(v.className="form-control"),Fo.default.createElement("div",{className:(0,tO.default)({"has-error":h})},Fo.default.createElement(c,ke({name:d,value:n,onChange:l,onKeyDown:QB},v)))}o(JB,"PureOption");var oO=Hi((e,{name:t})=>ke(ke({},e.options_meta[t]),e.ui.optionsEditor[t]),(e,{name:t})=>({onChange:n=>e(Ip(t,n))}))(JB);var Dy=fe(Qh());function eH({help:e}){return mr.default.createElement("div",{className:"help-block small"},e)}o(eH,"PureOptionHelp");var tH=Hi((e,{name:t})=>({help:e.options_meta[t].help}))(eH);function rH({error:e}){return e?mr.default.createElement("div",{className:"small text-danger"},e):null}o(rH,"PureOptionError");var nH=Hi((e,{name:t})=>({error:e.ui.optionsEditor[t]&&e.ui.optionsEditor[t].error}))(rH);function iH({value:e,defaultVal:t}){if(e===t)return null;if(typeof t=="boolean")t=t?"true":"false";else if(Array.isArray(t)){if(Dy.default.isEmpty(Dy.default.compact(e))&&Dy.default.isEmpty(t))return null;t="[ ]"}else t===""?t='""':t===null&&(t="null");return mr.default.createElement("div",{className:"small"},"Default: ",mr.default.createElement("strong",null," ",t," ")," ")}o(iH,"PureOptionDefault");var oH=Hi((e,{name:t})=>({value:e.options[t],defaultVal:e.options_meta[t].default}))(iH),ZC=class extends mr.Component{constructor(t,n){super(t,n);this.state={title:"Options"}}componentWillUnmount(){}render(){let{hideModal:t,options:n}=this.props,{title:l}=this.state;return mr.default.createElement("div",null,mr.default.createElement("div",{className:"modal-header"},mr.default.createElement("button",{type:"button",className:"close","data-dismiss":"modal",onClick:()=>{t()}},mr.default.createElement("i",{className:"fa fa-fw fa-times"})),mr.default.createElement("div",{className:"modal-title"},mr.default.createElement("h4",null,l))),mr.default.createElement("div",{className:"modal-body"},mr.default.createElement("div",{className:"form-horizontal"},n.map(d=>mr.default.createElement("div",{key:d,className:"form-group"},mr.default.createElement("div",{className:"col-xs-6"},mr.default.createElement("label",{htmlFor:d},d),mr.default.createElement(tH,{name:d})),mr.default.createElement("div",{className:"col-xs-6"},mr.default.createElement(oO,{name:d}),mr.default.createElement(nH,{name:d}),mr.default.createElement(oH,{name:d})))))),mr.default.createElement("div",{className:"modal-footer"}))}};o(ZC,"PureOptionModal");var sO=Hi(e=>({options:Object.keys(e.options_meta).sort()}),{hideModal:$0,save:PN})(ZC);function sH(){return JC.createElement(GC,null,JC.createElement(sO,null))}o(sH,"OptionModal");var lO=[sH];function tb(){let e=qe(n=>n.ui.modal.activeModal),t=lO.find(n=>n.name===e);return e&&t!==void 0?eb.createElement(t,null):eb.createElement("div",null)}o(tb,"PureModal");var rb=class extends Wn.Component{constructor(){super(...arguments);this.state={};this.render=o(()=>{var l;let{showEventLog:t,showCommandBar:n}=this.props;return this.state.error?(console.log("ERR",this.state),Wn.default.createElement("div",{className:"container"},Wn.default.createElement("h1",null,"mitmproxy has crashed."),Wn.default.createElement("pre",null,this.state.error.stack,Wn.default.createElement("br",null),Wn.default.createElement("br",null),"Component Stack:",(l=this.state.errorInfo)==null?void 0:l.componentStack),Wn.default.createElement("p",null,"Please lodge a bug report at"," ",Wn.default.createElement("a",{href:"https://github.com/mitmproxy/mitmproxy/issues"},"https://github.com/mitmproxy/mitmproxy/issues"),"."))):Wn.default.createElement("div",{id:"container",tabIndex:0},Wn.default.createElement(UC,null),Wn.default.createElement(FC,null),n&&Wn.default.createElement($C,{key:"commandbar"}),t&&Wn.default.createElement(eO,{key:"eventlog"}),Wn.default.createElement(KC,null),Wn.default.createElement(tb,null))},"render")}componentDidMount(){window.addEventListener("keydown",this.props.onKeyDown)}componentWillUnmount(){window.removeEventListener("keydown",this.props.onKeyDown)}componentDidCatch(t,n){this.setState({error:t,errorInfo:n})}};o(rb,"ProxyAppMain");var aO=Hi(e=>({showEventLog:e.eventLog.visible,showCommandBar:e.commandBar.visible}),{onKeyDown:CL})(rb);var yu={SEARCH:"s",HIGHLIGHT:"h",SHOW_EVENTLOG:"e",SHOW_COMMANDBAR:"c"};function lH(e){let[t,n]=window.location.hash.substr(1).split("?",2),l=t.substr(1).split("/");if(l[0]==="flows"&&l.length==3){let[d,h]=l.slice(1);e.dispatch(Af(d)),e.dispatch(Lf(h))}n&&n.split("&").forEach(d=>{let[h,c]=d.split("=",2);switch(c=decodeURIComponent(c),h){case yu.SEARCH:e.dispatch(D0(c));break;case yu.HIGHLIGHT:e.dispatch(R0(c));break;case yu.SHOW_EVENTLOG:e.getState().eventLog.visible||e.dispatch(Rp());break;case yu.SHOW_COMMANDBAR:e.getState().commandBar.visible||e.dispatch(K0());break;default:console.error(`unimplemented query arg: ${d}`)}})}o(lH,"updateStoreFromUrl");function aH(e){let t=e.getState(),n={[yu.SEARCH]:t.flows.filter,[yu.HIGHLIGHT]:t.flows.highlight,[yu.SHOW_EVENTLOG]:t.eventLog.visible,[yu.SHOW_COMMANDBAR]:t.commandBar.visible},l=Object.keys(n).filter(c=>n[c]).map(c=>`${c}=${encodeURIComponent(n[c])}`).join("&"),d;t.flows.selected.length>0?d=`/flows/${t.flows.selected[0]}/${t.ui.flow.tab}`:d="/flows",l&&(d+="?"+l);let h=window.location.pathname;h==="blank"&&(h="/"),window.location.hash.substr(1)!==d&&history.replaceState(void 0,"",`${h}#${d}`)}o(aH,"updateUrlFromStore");function nb(e){lH(e),e.subscribe(()=>aH(e))}o(nb,"initialize");var uH="reset",Im=class{constructor(t){this.activeFetches={},this.store=t,this.connect()}connect(){this.socket=new WebSocket(location.origin.replace("http","ws")+location.pathname.replace(/\/$/,"")+"/updates"),this.socket.addEventListener("open",()=>this.onOpen()),this.socket.addEventListener("close",t=>this.onClose(t)),this.socket.addEventListener("message",t=>this.onMessage(JSON.parse(t.data))),this.socket.addEventListener("error",t=>this.onError(t))}onOpen(){this.fetchData("state"),this.fetchData("flows"),this.fetchData("events"),this.fetchData("options"),this.store.dispatch(TN())}fetchData(t){let n=[];this.activeFetches[t]=n,kt(`./${t}`).then(l=>l.json()).then(l=>{this.activeFetches[t]===n&&this.receive(t,l)})}onMessage(t){if(t.cmd===uH)return this.fetchData(t.resource);if(t.resource in this.activeFetches)this.activeFetches[t.resource].push(t);else{let n=`${t.resource}_${t.cmd}`.toUpperCase();this.store.dispatch(ke({type:n},t))}}receive(t,n){let l=`${t}_RECEIVE`.toUpperCase();this.store.dispatch({type:l,cmd:"receive",resource:t,data:n});let d=this.activeFetches[t];delete this.activeFetches[t],d.forEach(h=>this.onMessage(h)),Object.keys(this.activeFetches).length===0&&this.store.dispatch(kN())}onClose(t){this.store.dispatch(NN(`Connection closed at ${new Date().toUTCString()} with error code ${t.code}.`)),console.error("websocket connection closed",t)}onError(t){console.error("websocket connection errored",arguments)}};o(Im,"WebsocketBackend");var Fm=class{constructor(t){this.store=t,this.onOpen()}onOpen(){this.fetchData("flows"),this.fetchData("options")}fetchData(t){kt(`./${t}`).then(n=>n.json()).then(n=>{this.receive(t,n)})}receive(t,n){let l=`${t}_RECEIVE`.toUpperCase();this.store.dispatch({type:l,cmd:"receive",resource:t,data:n})}};o(Fm,"StaticBackend");nb(Fp);window.MITMWEB_STATIC?window.backend=new Fm(Fp):window.backend=new Im(Fp);window.addEventListener("error",e=>{Fp.dispatch(yN(`${e.message} -${e.error.stack}`))});document.addEventListener("DOMContentLoaded",()=>{(0,uO.render)(ib.createElement(Wx,{store:Fp},ib.createElement(aO,null)),document.getElementById("mitmproxy"))});})(); +`))},n))}o(iO,"StringSequenceOption");var ZB={bool:GC,str:YC,int:XC,"optional str":rO(YC),"optional int":rO(XC),"sequence of str":iO};function JB({choices:e,type:t,value:n,onChange:l,name:d,error:h}){let c,v={};if(e)c=nO,v.choices=e;else if(c=ZB[t],!c)throw`unknown option type ${t}`;return c!==GC&&(v.className="form-control"),Fo.default.createElement("div",{className:(0,tO.default)({"has-error":h})},Fo.default.createElement(c,ke({name:d,value:n,onChange:l,onKeyDown:QB},v)))}o(JB,"PureOption");var oO=Hi((e,{name:t})=>ke(ke({},e.options_meta[t]),e.ui.optionsEditor[t]),(e,{name:t})=>({onChange:n=>e(Ip(t,n))}))(JB);var Ay=fe(Qh());function eH({help:e}){return mr.default.createElement("div",{className:"help-block small"},e)}o(eH,"PureOptionHelp");var tH=Hi((e,{name:t})=>({help:e.options_meta[t].help}))(eH);function rH({error:e}){return e?mr.default.createElement("div",{className:"small text-danger"},e):null}o(rH,"PureOptionError");var nH=Hi((e,{name:t})=>({error:e.ui.optionsEditor[t]&&e.ui.optionsEditor[t].error}))(rH);function iH({value:e,defaultVal:t}){if(e===t)return null;if(typeof t=="boolean")t=t?"true":"false";else if(Array.isArray(t)){if(Ay.default.isEmpty(Ay.default.compact(e))&&Ay.default.isEmpty(t))return null;t="[ ]"}else t===""?t='""':t===null&&(t="null");return mr.default.createElement("div",{className:"small"},"Default: ",mr.default.createElement("strong",null," ",t," ")," ")}o(iH,"PureOptionDefault");var oH=Hi((e,{name:t})=>({value:e.options[t],defaultVal:e.options_meta[t].default}))(iH),QC=class extends mr.Component{constructor(t,n){super(t,n);this.state={title:"Options"}}componentWillUnmount(){}render(){let{hideModal:t,options:n}=this.props,{title:l}=this.state;return mr.default.createElement("div",null,mr.default.createElement("div",{className:"modal-header"},mr.default.createElement("button",{type:"button",className:"close","data-dismiss":"modal",onClick:()=>{t()}},mr.default.createElement("i",{className:"fa fa-fw fa-times"})),mr.default.createElement("div",{className:"modal-title"},mr.default.createElement("h4",null,l))),mr.default.createElement("div",{className:"modal-body"},mr.default.createElement("div",{className:"form-horizontal"},n.map(d=>mr.default.createElement("div",{key:d,className:"form-group"},mr.default.createElement("div",{className:"col-xs-6"},mr.default.createElement("label",{htmlFor:d},d),mr.default.createElement(tH,{name:d})),mr.default.createElement("div",{className:"col-xs-6"},mr.default.createElement(oO,{name:d}),mr.default.createElement(nH,{name:d}),mr.default.createElement(oH,{name:d})))))),mr.default.createElement("div",{className:"modal-footer"}))}};o(QC,"PureOptionModal");var sO=Hi(e=>({options:Object.keys(e.options_meta).sort()}),{hideModal:z0,save:PN})(QC);function sH(){return ZC.createElement(KC,null,ZC.createElement(sO,null))}o(sH,"OptionModal");var lO=[sH];function eb(){let e=qe(n=>n.ui.modal.activeModal),t=lO.find(n=>n.name===e);return e&&t!==void 0?JC.createElement(t,null):JC.createElement("div",null)}o(eb,"PureModal");var tb=class extends Wn.Component{constructor(){super(...arguments);this.state={};this.render=o(()=>{var l;let{showEventLog:t,showCommandBar:n}=this.props;return this.state.error?(console.log("ERR",this.state),Wn.default.createElement("div",{className:"container"},Wn.default.createElement("h1",null,"mitmproxy has crashed."),Wn.default.createElement("pre",null,this.state.error.stack,Wn.default.createElement("br",null),Wn.default.createElement("br",null),"Component Stack:",(l=this.state.errorInfo)==null?void 0:l.componentStack),Wn.default.createElement("p",null,"Please lodge a bug report at"," ",Wn.default.createElement("a",{href:"https://github.com/mitmproxy/mitmproxy/issues"},"https://github.com/mitmproxy/mitmproxy/issues"),"."))):Wn.default.createElement("div",{id:"container",tabIndex:0},Wn.default.createElement(WC,null),Wn.default.createElement(IC,null),n&&Wn.default.createElement(zC,{key:"commandbar"}),t&&Wn.default.createElement(eO,{key:"eventlog"}),Wn.default.createElement(VC,null),Wn.default.createElement(eb,null))},"render")}componentDidMount(){window.addEventListener("keydown",this.props.onKeyDown)}componentWillUnmount(){window.removeEventListener("keydown",this.props.onKeyDown)}componentDidCatch(t,n){this.setState({error:t,errorInfo:n})}};o(tb,"ProxyAppMain");var aO=Hi(e=>({showEventLog:e.eventLog.visible,showCommandBar:e.commandBar.visible}),{onKeyDown:SP})(tb);var yu={SEARCH:"s",HIGHLIGHT:"h",SHOW_EVENTLOG:"e",SHOW_COMMANDBAR:"c"};function lH(e){let[t,n]=window.location.hash.substr(1).split("?",2),l=t.substr(1).split("/");if(l[0]==="flows"&&l.length==3){let[d,h]=l.slice(1);e.dispatch(Af(d)),e.dispatch(Pf(h))}n&&n.split("&").forEach(d=>{let[h,c]=d.split("=",2);switch(c=decodeURIComponent(c),h){case yu.SEARCH:e.dispatch(A0(c));break;case yu.HIGHLIGHT:e.dispatch(D0(c));break;case yu.SHOW_EVENTLOG:e.getState().eventLog.visible||e.dispatch(Rp());break;case yu.SHOW_COMMANDBAR:e.getState().commandBar.visible||e.dispatch(V0());break;default:console.error(`unimplemented query arg: ${d}`)}})}o(lH,"updateStoreFromUrl");function aH(e){let t=e.getState(),n={[yu.SEARCH]:t.flows.filter,[yu.HIGHLIGHT]:t.flows.highlight,[yu.SHOW_EVENTLOG]:t.eventLog.visible,[yu.SHOW_COMMANDBAR]:t.commandBar.visible},l=Object.keys(n).filter(c=>n[c]).map(c=>`${c}=${encodeURIComponent(n[c])}`).join("&"),d;t.flows.selected.length>0?d=`/flows/${t.flows.selected[0]}/${t.ui.flow.tab}`:d="/flows",l&&(d+="?"+l);let h=window.location.pathname;h==="blank"&&(h="/"),window.location.hash.substr(1)!==d&&history.replaceState(void 0,"",`${h}#${d}`)}o(aH,"updateUrlFromStore");function rb(e){lH(e),e.subscribe(()=>aH(e))}o(rb,"initialize");var uH="reset",Rm=class{constructor(t){this.activeFetches={},this.store=t,this.connect()}connect(){this.socket=new WebSocket(location.origin.replace("http","ws")+location.pathname.replace(/\/$/,"")+"/updates"),this.socket.addEventListener("open",()=>this.onOpen()),this.socket.addEventListener("close",t=>this.onClose(t)),this.socket.addEventListener("message",t=>this.onMessage(JSON.parse(t.data))),this.socket.addEventListener("error",t=>this.onError(t))}onOpen(){this.fetchData("state"),this.fetchData("flows"),this.fetchData("events"),this.fetchData("options"),this.store.dispatch(EN())}fetchData(t){let n=[];this.activeFetches[t]=n,kt(`./${t}`).then(l=>l.json()).then(l=>{this.activeFetches[t]===n&&this.receive(t,l)})}onMessage(t){if(t.cmd===uH)return this.fetchData(t.resource);if(t.resource in this.activeFetches)this.activeFetches[t.resource].push(t);else{let n=`${t.resource}_${t.cmd}`.toUpperCase();this.store.dispatch(ke({type:n},t))}}receive(t,n){let l=`${t}_RECEIVE`.toUpperCase();this.store.dispatch({type:l,cmd:"receive",resource:t,data:n});let d=this.activeFetches[t];delete this.activeFetches[t],d.forEach(h=>this.onMessage(h)),Object.keys(this.activeFetches).length===0&&this.store.dispatch(TN())}onClose(t){this.store.dispatch(kN(`Connection closed at ${new Date().toUTCString()} with error code ${t.code}.`)),console.error("websocket connection closed",t)}onError(t){console.error("websocket connection errored",arguments)}};o(Rm,"WebsocketBackend");var Im=class{constructor(t){this.store=t,this.onOpen()}onOpen(){this.fetchData("flows"),this.fetchData("options")}fetchData(t){kt(`./${t}`).then(n=>n.json()).then(n=>{this.receive(t,n)})}receive(t,n){let l=`${t}_RECEIVE`.toUpperCase();this.store.dispatch({type:l,cmd:"receive",resource:t,data:n})}};o(Im,"StaticBackend");rb(Fp);window.MITMWEB_STATIC?window.backend=new Im(Fp):window.backend=new Rm(Fp);window.addEventListener("error",e=>{Fp.dispatch(vN(`${e.message} +${e.error.stack}`))});document.addEventListener("DOMContentLoaded",()=>{(0,uO.render)(nb.createElement(Hx,{store:Fp},nb.createElement(aO,null)),document.getElementById("mitmproxy"))});})(); /* object-assign (c) Sindre Sorhus diff --git a/mitmproxy/version.py b/mitmproxy/version.py index 5e84f10e8e..56d03af7e9 100644 --- a/mitmproxy/version.py +++ b/mitmproxy/version.py @@ -2,7 +2,7 @@ import subprocess import sys -VERSION = "11.0.0.dev" +VERSION = "10.1.6" MITMPROXY = "mitmproxy " + VERSION # Serialization format version. This is displayed nowhere, it just needs to be incremented by one From f1df4fa47982b994f180d6987db8e28dc0a9b78c Mon Sep 17 00:00:00 2001 From: mitmproxy release bot Date: Thu, 14 Dec 2023 09:39:20 +0000 Subject: [PATCH 012/283] reopen main for development --- mitmproxy/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mitmproxy/version.py b/mitmproxy/version.py index 56d03af7e9..5e84f10e8e 100644 --- a/mitmproxy/version.py +++ b/mitmproxy/version.py @@ -2,7 +2,7 @@ import subprocess import sys -VERSION = "10.1.6" +VERSION = "11.0.0.dev" MITMPROXY = "mitmproxy " + VERSION # Serialization format version. This is displayed nowhere, it just needs to be incremented by one From c0f81a8542c210765484e379fe7058b66ee24c16 Mon Sep 17 00:00:00 2001 From: Bakugo Date: Sun, 17 Dec 2023 06:34:53 +0000 Subject: [PATCH 013/283] Update cryptography requirement to >=39.0 (#6555) https://github.com/mitmproxy/mitmproxy/commit/0b5e310881f0116c9e8e2ca5b9da98e258de0a11 uses `load_pem_x509_certificates` which was introduced in cryptography 39.0 but the requirement wasn't updated. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6844a316f5..48551cc83e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ dependencies = [ "asgiref>=3.2.10,<3.8", "Brotli>=1.0,<1.2", "certifi>=2019.9.11", # no semver here - this should always be on the last release! - "cryptography>=38.0,<41.1", + "cryptography>=39.0,<41.1", "flask>=1.1.1,<3.1", "h11>=0.11,<0.15", "h2>=4.1,<5", From 8290c428ca7e6859237b3d000268c6dde1a6e942 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 18 Dec 2023 14:55:49 +0100 Subject: [PATCH 014/283] fix ignore hosts to not drop connections, improve http header handling (#6559) fixes #6554 --- CHANGELOG.md | 11 +- mitmproxy/addons/next_layer.py | 66 ++++++--- test/mitmproxy/addons/test_next_layer.py | 162 ++++++++++++++--------- 3 files changed, 154 insertions(+), 85 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f133bde91d..69600efb9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ ## Unreleased: mitmproxy next +* Fix a regression from mitmproxy 10.1.6 where `ignore_hosts` would terminate requests + instead of forwarding them. + ([#6559](https://github.com/mitmproxy/mitmproxy/pull/6559), @mhils) +* `ignore_hosts` now waits for the entire HTTP headers if it suspects the connection to be HTTP. + ([#6559](https://github.com/mitmproxy/mitmproxy/pull/6559), @mhils) ## 14 December 2023: mitmproxy 10.1.6 @@ -18,17 +23,17 @@ ([#6225](https://github.com/mitmproxy/mitmproxy/issues/6225), @Llama1412) * Fix bug where response flows from HAR files had incorrect `content-length` headers ([#6548](https://github.com/mitmproxy/mitmproxy/pull/6548), @zanieb) -* Improved handling for `--allow-hosts`/`--ignore-hosts` options in WireGuard mode (#5930). +* Improved handling for `allow_hosts`/`ignore_hosts` options in WireGuard mode (#5930). ([#6513](https://github.com/mitmproxy/mitmproxy/pull/6513), @dsphper) * Fix a bug where TCP connections were not closed properly. ([#6543](https://github.com/mitmproxy/mitmproxy/pull/6543), @mhils) -* DNS resolution is now exempted from `--ignore-hosts` in WireGuard Mode. +* DNS resolution is now exempted from `ignore_hosts` in WireGuard Mode. ([#6513](https://github.com/mitmproxy/mitmproxy/pull/6513), @dsphper) * Fix case sensitivity of URL added to blocklist ([#6493](https://github.com/mitmproxy/mitmproxy/pull/6493), @emanuele-em) * Fix a bug where logging was stopped prematurely during shutdown. ([#6541](https://github.com/mitmproxy/mitmproxy/pull/6541), @mhils) -* For plaintext traffic, `--ignore-hosts` now also takes HTTP/1 host headers into account. +* For plaintext traffic, `ignore_hosts` now also takes HTTP/1 host headers into account. ([#6513](https://github.com/mitmproxy/mitmproxy/pull/6513), @dsphper) * Fix empty cookie attributes being set to `Key=` instead of `Key` ([#5084](https://github.com/mitmproxy/mitmproxy/pull/5084), @Speedlulu) diff --git a/mitmproxy/addons/next_layer.py b/mitmproxy/addons/next_layer.py index ce63f81390..7c065f063a 100644 --- a/mitmproxy/addons/next_layer.py +++ b/mitmproxy/addons/next_layer.py @@ -49,6 +49,7 @@ from mitmproxy.proxy.layers.http import HTTPMode from mitmproxy.proxy.layers.quic import quic_parse_client_hello from mitmproxy.proxy.layers.tls import dtls_parse_client_hello +from mitmproxy.proxy.layers.tls import HTTP1_ALPNS from mitmproxy.proxy.layers.tls import HTTP_ALPNS from mitmproxy.proxy.layers.tls import parse_client_hello from mitmproxy.tls import ClientHello @@ -129,7 +130,7 @@ def s(*layers): udp_based = context.client.transport_protocol == "udp" # 1) check for --ignore/--allow - if self._ignore_connection(context, data_client): + if self._ignore_connection(context, data_client, data_server): return ( layers.TCPLayer(context, ignore=True) if tcp_based @@ -182,7 +183,7 @@ def s(*layers): if udp_based: return layers.UDPLayer(context) # 5b) Check for raw tcp mode. - very_likely_http = context.client.alpn and context.client.alpn in HTTP_ALPNS + very_likely_http = context.client.alpn in HTTP_ALPNS probably_no_http = not very_likely_http and ( # the first three bytes should be the HTTP verb, so A-Za-z is expected. len(data_client) < 3 @@ -199,6 +200,7 @@ def _ignore_connection( self, context: Context, data_client: bytes, + data_server: bytes, ) -> bool | None: """ Returns: @@ -220,13 +222,15 @@ def _ignore_connection( hostnames.append(peername) if context.server.address and (server_address := context.server.address[0]): hostnames.append(server_address) + # If we already have a destination address, we can also check for HTTP Host headers. + # But we do need the destination, otherwise we don't know where this connection is going to. + if host_header := self._get_host_header(context, data_client, data_server): + hostnames.append(host_header) if ( client_hello := self._get_client_hello(context, data_client) ) and client_hello.sni: hostnames.append(client_hello.sni) - # If the client data is not a TLS record, try to extract the domain from the HTTP request - elif host := self._extract_http1_host_header(data_client): - hostnames.append(host) + if not hostnames: return False @@ -246,14 +250,39 @@ def _ignore_connection( raise AssertionError() @staticmethod - def _extract_http1_host_header(data_client: bytes) -> str: - pattern = rb"Host:\s+(.+?)\r\n" - match = re.search(pattern, data_client) - return match.group(1).decode() if match else "" - - def _get_client_hello( - self, context: Context, data_client: bytes - ) -> ClientHello | None: + def _get_host_header( + context: Context, + data_client: bytes, + data_server: bytes, + ) -> str | None: + """ + Try to read a host header from data_client. + + Returns: + The host header value, or None, if no host header was found. + + Raises: + NeedsMoreData, if the HTTP request is incomplete. + """ + if context.client.transport_protocol != "tcp" or data_server: + return None + + host_header_expected = context.client.alpn in HTTP1_ALPNS or re.match( + rb"[A-Z]{3,}.+HTTP/", data_client, re.IGNORECASE + ) + if host_header_expected: + if m := re.search(rb"\r\n(?:Host: (.+))?\r\n", data_client, re.IGNORECASE): + if host := m.group(1): + return host.decode("utf-8", "surrogateescape") + else: + return None # \r\n\r\n - header end came first. + else: + raise NeedsMoreData + else: + return None + + @staticmethod + def _get_client_hello(context: Context, data_client: bytes) -> ClientHello | None: """ Try to read a TLS/DTLS/QUIC ClientHello from data_client. @@ -293,7 +322,8 @@ def _get_client_hello( case _: # pragma: no cover assert_never(context.client.transport_protocol) - def _setup_reverse_proxy(self, context: Context, data_client: bytes) -> Layer: + @staticmethod + def _setup_reverse_proxy(context: Context, data_client: bytes) -> Layer: spec = cast(mode_specs.ReverseMode, context.client.proxy_mode) stack = tunnel.LayerStack() @@ -353,7 +383,8 @@ def _setup_reverse_proxy(self, context: Context, data_client: bytes) -> Layer: return stack[0] - def _setup_explicit_http_proxy(self, context: Context, data_client: bytes) -> Layer: + @staticmethod + def _setup_explicit_http_proxy(context: Context, data_client: bytes) -> Layer: stack = tunnel.LayerStack() if context.client.transport_protocol == "udp": @@ -368,9 +399,8 @@ def _setup_explicit_http_proxy(self, context: Context, data_client: bytes) -> La return stack[0] - def _is_destination_in_hosts( - self, context: Context, hosts: Iterable[re.Pattern] - ) -> bool: + @staticmethod + def _is_destination_in_hosts(context: Context, hosts: Iterable[re.Pattern]) -> bool: return any( (context.server.address and rex.search(context.server.address[0])) or (context.client.sni and rex.search(context.client.sni)) diff --git a/test/mitmproxy/addons/test_next_layer.py b/test/mitmproxy/addons/test_next_layer.py index b91a942237..bd67a83e6e 100644 --- a/test/mitmproxy/addons/test_next_layer.py +++ b/test/mitmproxy/addons/test_next_layer.py @@ -12,6 +12,7 @@ from mitmproxy.addons.next_layer import NeedsMoreData from mitmproxy.addons.next_layer import NextLayer from mitmproxy.addons.next_layer import stack_match +from mitmproxy.connection import Address from mitmproxy.connection import Client from mitmproxy.connection import TransportProtocol from mitmproxy.proxy.context import Context @@ -90,7 +91,10 @@ dns_query = bytes.fromhex("002a01000001000000000000076578616d706c6503636f6d0000010001") -http_query = b"GET / HTTP/1.1\r\nHost: example.com\r\n\r\n" +http_get = b"GET / HTTP/1.1\r\nHost: example.com\r\n\r\n" +http_get_absolute = b"GET http://example.com/ HTTP/1.1\r\n\r\n" + +http_connect = b"CONNECT example.com:443 HTTP/1.1\r\nHost: example.com:443\r\n\r\n" class TestNextLayer: @@ -103,40 +107,46 @@ def test_configure(self): ) @pytest.mark.parametrize( - "mode, ignore, allow, transport_protocol, server_address, data_client, result", + "ignore, allow, transport_protocol, server_address, data_client, result", [ + # ignore pytest.param( - [], - [], - ["example.com"], - "tcp", - "example.org", - http_query, - False, - id="extract host from http request", + [], [], "example.com", "tcp", b"", False, id="nothing ignored" ), pytest.param( - ["wireguard"], - ["example.com"], - [], - "udp", - "10.0.0.53", - dns_query, - False, - id="special handling for wireguard mode", + ["example.com"], [], "tcp", "example.com", b"", True, id="address" ), - # ignore pytest.param( - [], [], [], "example.com", "tcp", b"", False, id="nothing ignored" + ["1.2.3.4"], [], "tcp", "example.com", b"", True, id="ip address" ), pytest.param( - [], ["example.com"], [], "tcp", "example.com", b"", True, id="address" + ["example.com"], + [], + "tcp", + "192.0.2.1", + http_get, + True, + id="http host header", ), pytest.param( - [], ["1.2.3.4"], [], "tcp", "example.com", b"", True, id="ip address" + ["example.com"], + [], + "tcp", + "192.0.2.1", + http_get.replace(b"Host", b"X-Host"), + False, + id="http host header missing", ), pytest.param( + ["example.com"], [], + "tcp", + "192.0.2.1", + http_get.split(b"\r\n", 1)[0], + NeedsMoreData, + id="incomplete http host header", + ), + pytest.param( ["example.com"], [], "tcp", @@ -146,7 +156,6 @@ def test_configure(self): id="partial address match", ), pytest.param( - [], ["example.com"], [], "tcp", @@ -156,7 +165,6 @@ def test_configure(self): id="no destination info", ), pytest.param( - [], ["example.com"], [], "tcp", @@ -166,7 +174,6 @@ def test_configure(self): id="no sni", ), pytest.param( - [], ["example.com"], [], "tcp", @@ -176,7 +183,6 @@ def test_configure(self): id="sni", ), pytest.param( - [], ["example.com"], [], "tcp", @@ -186,7 +192,6 @@ def test_configure(self): id="incomplete client hello", ), pytest.param( - [], ["example.com"], [], "tcp", @@ -196,7 +201,6 @@ def test_configure(self): id="invalid client hello", ), pytest.param( - [], ["example.com"], [], "tcp", @@ -206,7 +210,6 @@ def test_configure(self): id="sni mismatch", ), pytest.param( - [], ["example.com"], [], "udp", @@ -216,7 +219,6 @@ def test_configure(self): id="dtls sni", ), pytest.param( - [], ["example.com"], [], "udp", @@ -226,7 +228,6 @@ def test_configure(self): id="incomplete dtls client hello", ), pytest.param( - [], ["example.com"], [], "udp", @@ -236,7 +237,6 @@ def test_configure(self): id="invalid dtls client hello", ), pytest.param( - [], ["example.com"], [], "udp", @@ -247,7 +247,6 @@ def test_configure(self): ), # allow pytest.param( - [], [], ["example.com"], "tcp", @@ -257,7 +256,6 @@ def test_configure(self): id="allow: allow", ), pytest.param( - [], [], ["example.com"], "tcp", @@ -267,7 +265,6 @@ def test_configure(self): id="allow: ignore", ), pytest.param( - [], [], ["example.com"], "tcp", @@ -280,7 +277,6 @@ def test_configure(self): ) def test_ignore_connection( self, - mode: list[str], ignore: list[str], allow: list[str], transport_protocol: TransportProtocol, @@ -294,8 +290,6 @@ def test_ignore_connection( tctx.configure(nl, ignore_hosts=ignore) if allow: tctx.configure(nl, allow_hosts=allow) - if mode: - tctx.options.mode = mode ctx = Context( Client(peername=("192.168.0.42", 51234), sockname=("0.0.0.0", 8080)), tctx.options, @@ -304,15 +298,11 @@ def test_ignore_connection( if server_address: ctx.server.address = (server_address, 443) ctx.server.peername = ("1.2.3.4", 443) - if "wireguard" in tctx.options.mode: - ctx.server.peername = ("10.0.0.53", 53) - ctx.server.address = ("10.0.0.53", 53) - ctx.client.proxy_mode = ProxyMode.parse("wireguard") if result is NeedsMoreData: with pytest.raises(NeedsMoreData): - nl._ignore_connection(ctx, data_client) + nl._ignore_connection(ctx, data_client, b"") else: - assert nl._ignore_connection(ctx, data_client) is result + assert nl._ignore_connection(ctx, data_client, b"") is result def test_next_layer(self, monkeypatch, caplog): caplog.set_level(logging.INFO) @@ -333,7 +323,7 @@ def test_next_layer(self, monkeypatch, caplog): assert m.layer is preexisting m.layer = None - monkeypatch.setattr(m, "data_client", lambda: http_query) + monkeypatch.setattr(m, "data_client", lambda: http_get) nl.next_layer(m) assert m.layer @@ -358,6 +348,7 @@ class TConf: tcp_hosts: Sequence[str] = () udp_hosts: Sequence[str] = () ignore_conn: bool = False + server_address: Address | None = None explicit_proxy_configs = [ @@ -365,8 +356,27 @@ class TConf: TConf( before=[modes.HttpProxy], after=[modes.HttpProxy, HttpLayer], + data_client=http_connect, ), - id=f"explicit proxy: regular http", + id=f"explicit proxy: regular http connect", + ), + pytest.param( + TConf( + before=[modes.HttpProxy], + after=[modes.HttpProxy, HttpLayer], + ignore_hosts=[".+"], + data_client=http_connect, + ), + id=f"explicit proxy: regular http connect disregards ignore_hosts", + ), + pytest.param( + TConf( + before=[modes.HttpProxy], + after=[modes.HttpProxy, HttpLayer], + ignore_hosts=[".+"], + data_client=http_get_absolute, + ), + id=f"explicit proxy: HTTP over regular proxy disregards ignore_hosts", ), pytest.param( TConf( @@ -542,6 +552,18 @@ class TConf: ), id="reverse proxy: quic", ), + pytest.param( + TConf( + before=[modes.ReverseProxy], + after=[modes.ReverseProxy, TCPLayer], + proxy_mode=f"reverse:http://example.com", + ignore_hosts=["example.com"], + server_address=("example.com", 80), + data_client=http_get, + ignore_conn=True, + ), + id="reverse proxy: ignore_hosts", + ), ] ) @@ -584,14 +606,15 @@ class TConf: http := TConf( before=[modes.TransparentProxy], after=[modes.TransparentProxy, HttpLayer], - data_client=b"GET / HTTP/1.1\r\n", + server_address=("192.0.2.1", 80), + data_client=http_get, ), id="transparent proxy: http", ), pytest.param( dataclasses.replace( http, - tcp_hosts=["example.com"], + tcp_hosts=["192.0.2.1"], after=[modes.TransparentProxy, TCPLayer], ), id="transparent proxy: tcp_hosts", @@ -599,25 +622,17 @@ class TConf: pytest.param( dataclasses.replace( http, - ignore_hosts=["example.com"], + ignore_hosts=["192.0.2.1"], after=[modes.TransparentProxy, TCPLayer], ignore_conn=True, ), id="transparent proxy: ignore_hosts", ), pytest.param( - dns := TConf( - before=[modes.TransparentProxy], - after=[modes.TransparentProxy, DNSLayer], - transport_protocol="udp", - data_client=dns_query, - ), - id="transparent proxy: dns", - ), - pytest.param( - TConf( + udp := TConf( before=[modes.TransparentProxy], after=[modes.TransparentProxy, UDPLayer], + server_address=("192.0.2.1", 53), transport_protocol="udp", data_client=b"\xFF", ), @@ -625,12 +640,32 @@ class TConf: ), pytest.param( dataclasses.replace( - dns, - udp_hosts=["example.com"], + udp, + after=[modes.TransparentProxy, DNSLayer], + data_client=dns_query, + ), + id="transparent proxy: dns", + ), + pytest.param( + dataclasses.replace( + udp, + udp_hosts=["192.0.2.1"], after=[modes.TransparentProxy, UDPLayer], ), id="transparent proxy: udp_hosts", ), + pytest.param( + TConf( + before=[modes.TransparentProxy], + after=[modes.TransparentProxy, DNSLayer], + proxy_mode="wireguard", + server_address=("10.0.0.53", 53), + ignore_hosts=[".+"], + transport_protocol="udp", + data_client=dns_query, + ), + id="wireguard proxy: dns should not be ignored", + ), ] @@ -658,8 +693,7 @@ def test_next_layer( Client(peername=("192.168.0.42", 51234), sockname=("0.0.0.0", 8080)), tctx.options, ) - ctx.server.address = ("example.com", 42) - # these aren't properly set up, but this does not matter here. + ctx.server.address = test_conf.server_address ctx.client.transport_protocol = test_conf.transport_protocol ctx.client.proxy_mode = ProxyMode.parse(test_conf.proxy_mode) ctx.layers = [x(ctx) for x in test_conf.before] @@ -668,7 +702,7 @@ def test_next_layer( data_client=test_conf.data_client, data_server=test_conf.data_server, ) - assert stack_match(ctx, test_conf.after) + assert stack_match(ctx, test_conf.after), f"Unexpected stack: {ctx.layers}" last_layer = ctx.layers[-1] if isinstance(last_layer, (UDPLayer, TCPLayer)): From 89189849c0134cb4dd8a229035ea5e892100b775 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 19 Dec 2023 13:20:43 +0100 Subject: [PATCH 015/283] Remove Links to Slack Workspace (#6560) We want to focus on GitHub Discussions going forward. --- README.md | 4 ---- docs/src/content/overview-getting-started.md | 1 - 2 files changed, 5 deletions(-) diff --git a/README.md b/README.md index f23dbd7c9e..5563ec46bf 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,3 @@ use GitHub Discussions! As an open source project, mitmproxy welcomes contributions of all forms. [![Dev Guide](https://shields.mitmproxy.org/badge/dev_docs-CONTRIBUTING.md-blue)](./CONTRIBUTING.md) - -Also, please feel free to join our developer Slack! However, please note that the primary purpose of our Slack is direct communication between maintainers and contributors. **If you have questions where the answer might be valuable to others, please use [GitHub Discussions](https://github.com/mitmproxy/mitmproxy/discussions) and not Slack.** - -[![Slack Developer Chat](https://shields.mitmproxy.org/badge/slack-mitmproxy-E01563.svg)](http://slack.mitmproxy.org/) diff --git a/docs/src/content/overview-getting-started.md b/docs/src/content/overview-getting-started.md index 7bcfd63598..944bb5f295 100644 --- a/docs/src/content/overview-getting-started.md +++ b/docs/src/content/overview-getting-started.md @@ -49,4 +49,3 @@ new flow and you can inspect it. * [**GitHub**](https://github.com/mitmproxy/mitmproxy): If you want to ask usage questions, contribute to mitmproxy, or submit a bug report, please use GitHub. -* [**Slack**](https://mitmproxy.slack.com): For ephemeral development questions/coordination, please use our Slack channel. From 95c5bf9d5da827c79a28e00c7dbc9bf913f0afb2 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 1 Jan 2024 14:03:06 +0100 Subject: [PATCH 016/283] switch to stock aioquic (#6573) --- pyproject.toml | 2 +- test/mitmproxy/proxy/layers/test_modes.py | 8 ++++---- test/mitmproxy/proxy/layers/test_quic.py | 17 +++++++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 48551cc83e..b922af166a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ classifiers = [ # https://packaging.python.org/en/latest/discussions/install-requires-vs-requirements/#install-requires # It is not considered best practice to use install_requires to pin dependencies to specific versions. dependencies = [ - "aioquic_mitmproxy>=0.9.21,<0.10", + "aioquic>=0.9.24,<0.10", "asgiref>=3.2.10,<3.8", "Brotli>=1.0,<1.2", "certifi>=2019.9.11", # no semver here - this should always be on the last release! diff --git a/test/mitmproxy/proxy/layers/test_modes.py b/test/mitmproxy/proxy/layers/test_modes.py index f99685c3f5..bc64a6512d 100644 --- a/test/mitmproxy/proxy/layers/test_modes.py +++ b/test/mitmproxy/proxy/layers/test_modes.py @@ -196,8 +196,8 @@ def test_reverse_dns(tctx): def test_quic(tctx: Context, keep_host_header: bool): with taddons.context(): tctx.options.keep_host_header = keep_host_header - tctx.server.sni = "other" - tctx.client.proxy_mode = ProxyMode.parse("reverse:quic://1.2.3.4:5") + tctx.server.sni = "other.example.com" + tctx.client.proxy_mode = ProxyMode.parse("reverse:quic://example.org:443") client_hello = Placeholder(bytes) def set_settings(data: quic.QuicTlsData): @@ -215,9 +215,9 @@ def set_settings(data: quic.QuicTlsData): << SendData(tctx.server, client_hello) << RequestWakeup(Placeholder(float)) ) - assert tctx.server.address == ("1.2.3.4", 5) + assert tctx.server.address == ("example.org", 443) assert quic.quic_parse_client_hello(client_hello()).sni == ( - "other" if keep_host_header else "1.2.3.4" + "other.example.com" if keep_host_header else "example.org" ) diff --git a/test/mitmproxy/proxy/layers/test_quic.py b/test/mitmproxy/proxy/layers/test_quic.py index 54ae91f340..b44e7ef3b4 100644 --- a/test/mitmproxy/proxy/layers/test_quic.py +++ b/test/mitmproxy/proxy/layers/test_quic.py @@ -840,7 +840,9 @@ def test_untrusted_cert(self, tctx: context.Context): playbook >> events.Wakeup(playbook.actual[9]) << commands.Log( - "Server QUIC handshake failed. Certificate does not match hostname 'wrong.host.mitmproxy.org'", + tutils.StrMatching( + "Server QUIC handshake failed. hostname 'wrong.host.mitmproxy.org' doesn't match" + ), WARNING, ) << tls.TlsFailedServerHook(tls_hook_data) @@ -848,12 +850,13 @@ def test_untrusted_cert(self, tctx: context.Context): << commands.CloseConnection(tctx.server) << commands.SendData( tctx.client, - b"open-connection failed: Certificate does not match hostname 'wrong.host.mitmproxy.org'", + tutils.BytesMatching( + b"open-connection failed: hostname 'wrong.host.mitmproxy.org' doesn't match" + ), ) ) - assert ( - tls_hook_data().conn.error - == "Certificate does not match hostname 'wrong.host.mitmproxy.org'" + assert tls_hook_data().conn.error.startswith( + "hostname 'wrong.host.mitmproxy.org' doesn't match" ) assert not tctx.server.tls_established @@ -1133,7 +1136,9 @@ def test_mitmproxy_ca_is_untrusted(self, tctx: context.Context): playbook >> events.Wakeup(playbook.actual[7]) << commands.Log( - "Client QUIC handshake failed. Certificate does not match hostname 'wrong.host.mitmproxy.org'", + tutils.StrMatching( + "Client QUIC handshake failed. hostname 'wrong.host.mitmproxy.org' doesn't match" + ), WARNING, ) << tls.TlsFailedClientHook(tls_hook_data) From 0aee9914c12dff3f07a760d0d58c540772e2567c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jan 2024 06:38:17 +0100 Subject: [PATCH 017/283] Bump pyinstaller from 6.2.0 to 6.3.0 (#6576) Bumps [pyinstaller](https://github.com/pyinstaller/pyinstaller) from 6.2.0 to 6.3.0.
Release notes

Sourced from pyinstaller's releases.

v6.3.0

Please see the v6.3.0 section of the changelog for a list of the changes since v6.2.0.

Changelog

Sourced from pyinstaller's changelog.

6.3.0 (2023-12-10)

Bugfix


* (Linux) Optimize the automatic binary-vs-data classification by
avoiding
  ``objdump`` based check on files that do not have ELF signature. This
mitigates noticeably longer analysis times for projects with large
number of
  (data) files. (:issue:`8148`)
* (Windows) Add Windows error code 110 (``ERROR_OPEN_FAILED``) to the
list of
error codes eligible for the retry mechanism that attempts to mitigate
build
  failures due to anti-virus program interference. (:issue:`8138`)
* (Windows) Fix issue with non-functional :func:`time.sleep()` when
building
  program with Python <= 3.8.6 or Python 3.9.0. (:issue:`8104`)
* (Windows) Fix issue with splash screen in ``onefile`` mode failing to
extract
``VCRUNTIME140.dll`` from the archive due to character-case mismatch. We
now
  perform case-insensitive comparison between the name listed in splash
  dependency list and the names in archive TOC. (:issue:`8103`)
* Fix PEP 597 EncodingWarnings when :envvar:`PYTHONWARNDEFAULTENCODING`
is set
  to true. (:issue:`8117`)
* Fix pre-safe-import hooks for ``six.moves``,
``urllib3.packages.six.moves``,
and ``setuptools.extern.six.moves`` to gracefully handle cases when the
corresponding ``six`` package is unavailable, as the hook may end up
being
  executed even in that case. (:issue:`8145`)
* Fix symbolic link tracking in ``MERGE`` processing, so that distinct
symbolic
links with same relative target (e.g. ``Current -> A`` symbolic links
in Qt
.framework bundles collected on macOS) are properly processed, and kept
in the
  original TOC upon their first occurrence. (:issue:`8124`)

Hooks


* Add hook for ``gi.repository.DBus``. (:issue:`8149`)
* Add hooks for ``gi.repository.AppIndicator3`` and
  ``gi.repository.AyatanaAppIndicator3``. (:issue:`8149`)


Bootloader
</code></pre>
<ul>
<li>When setting up embedded Python interpreter configuration, set
<code>PyConfig.install_signal_handlers=1</code> to install
signal handlers.
This matches the behavior of PyInstaller 5.x bootloaders, where
interpreter
was initialized via <code>Py_Initialize()</code>, which in
turn calls
<code>Py_InitializeEx(1)</code>, i.e., with
<code>install_sigs=1</code>.
(:issue:<code>8105</code>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>

<ul>
<li><a
href="https://github.com/pyinstaller/pyinstaller/commit/f563dce1e83fd5ec72a20dffd2ac24be3e647150"><code>f563dce</code></a>
Release v6.3.0. [skip ci]</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller/commit/79aa828e130ef334ab228f6fa43a28ade41596ca"><code>79aa828</code></a>
hooks: gi: add hook for gi.repository.DBus</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller/commit/3f42b9574fe290fa3e2853a07d6c6c02f2dd5875"><code>3f42b95</code></a>
hooks: gi: add hooks for AppIndicator3 and
AyatanaAppIndicator3</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller/commit/b262373f689df7bc75cd7bc35bb64f8b42932062"><code>b262373</code></a>
Tests: Requirements: Scheduled weekly dependency update for week 50
(<a
href="https://redirect.github.com/pyinstaller/pyinstaller/issues/8157">#8157</a>)</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller/commit/0f51fca360e052a027c263400d028efc724024ce"><code>0f51fca</code></a>
bindepend: optimize binary-vs-data classification on linux</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller/commit/14af1e7143dcc456c363fdfee816560f4b9b553c"><code>14af1e7</code></a>
building: add an INFO message at start of binary-vs-data
reclassification</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller/commit/8c4d099e5f647ffb393adea6da227d1f123adf01"><code>8c4d099</code></a>
pre-safe-import-hooks: create six.move runtime package only if six is
available</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller/commit/ac91826b1f9fa5ed12763d37eca009ff6ed275ab"><code>ac91826</code></a>
pre-safe-import-hooks: gracefully handle cases when six is
unavailable</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller/commit/bb1b306ccaf2274100e8b1eec321b1c7f3352322"><code>bb1b306</code></a>
Tests: Requirements: Scheduled weekly dependency update for week 49
(<a
href="https://redirect.github.com/pyinstaller/pyinstaller/issues/8142">#8142</a>)</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller/commit/ac7f6835c28b01af32c5f0924767556e9c1a16a0"><code>ac7f683</code></a>
building: retry mechanism: enable retry on winerror 110</li>
<li>Additional commits viewable in <a
href="https://github.com/pyinstaller/pyinstaller/compare/v6.2.0...v6.3.0">compare
view</a></li>
</ul>
</details>

<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pyinstaller&package-manager=pip&previous-version=6.2.0&new-version=6.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b922af166a..70294dbc43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ dev = [ "click>=7.0,<8.2", "hypothesis>=5.8,<7", "pdoc>=4.0.0", - "pyinstaller==6.2.0", + "pyinstaller==6.3.0", "pytest-asyncio>=0.17,<0.22", "pytest-cov>=2.7.1,<4.2", "pytest-timeout>=1.3.3,<2.3", From 553fd5e6bfae77f9d16ad33fd3c860d98c0c0de1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jan 2024 06:41:01 +0100 Subject: [PATCH 018/283] Bump the github-actions group with 4 updates (#6577) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 4 updates: [install-pinned/ruff](https://github.com/install-pinned/ruff), [actions/setup-python](https://github.com/actions/setup-python), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact). Updates `install-pinned/ruff` from 0e35bc58bd73769469284df9e1f8898daeea8768 to 4ec70113ad8b512f13948b8d9855ac59675535d2
Commits

Updates `actions/setup-python` from 4 to 5
Release notes

Sourced from actions/setup-python's releases.

v5.0.0

What's Changed

In scope of this release, we update node version runtime from node16 to node20 (actions/setup-python#772). Besides, we update dependencies to the latest versions.

Full Changelog: https://github.com/actions/setup-python/compare/v4.8.0...v5.0.0

v4.8.0

What's Changed

In scope of this release we added support for GraalPy (actions/setup-python#694). You can use this snippet to set up GraalPy:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
  with:
    python-version: 'graalpy-22.3'
- run: python my_script.py

Besides, the release contains such changes as:

New Contributors

Full Changelog: https://github.com/actions/setup-python/compare/v4...v4.8.0

v4.7.1

What's Changed

Full Changelog: https://github.com/actions/setup-python/compare/v4...v4.7.1

v4.7.0

In scope of this release, the support for reading python version from pyproject.toml was added (actions/setup-python#669).

      - name: Setup Python
        uses: actions/setup-python@v4
</tr></table>

... (truncated)

Commits

Updates `actions/upload-artifact` from 3 to 4
Release notes

Sourced from actions/upload-artifact's releases.

v4.0.0

What's Changed

The release of upload-artifact@v4 and download-artifact@v4 are major changes to the backend architecture of Artifacts. They have numerous performance and behavioral improvements.

For more information, see the @​actions/artifact documentation.

New Contributors

Full Changelog: https://github.com/actions/upload-artifact/compare/v3...v4.0.0

v3.1.3

What's Changed

Full Changelog: https://github.com/actions/upload-artifact/compare/v3...v3.1.3

v3.1.2

  • Update all @actions/* NPM packages to their latest versions- #374
  • Update all dev dependencies to their most recent versions - #375

v3.1.1

  • Update actions/core package to latest version to remove set-output deprecation warning #351

v3.1.0

What's Changed

Commits

Updates `actions/download-artifact` from 3 to 4
Release notes

Sourced from actions/download-artifact's releases.

v4.0.0

What's Changed

The release of upload-artifact@v4 and download-artifact@v4 are major changes to the backend architecture of Artifacts. They have numerous performance and behavioral improvements.

For more information, see the @​actions/artifact documentation.

New Contributors

Full Changelog: https://github.com/actions/download-artifact/compare/v3...v4.0.0

v3.0.2

  • Bump @actions/artifact to v1.1.1 - actions/download-artifact#195
  • Fixed a bug in Node16 where if an HTTP download finished too quickly (<1ms, e.g. when it's mocked) we attempt to delete a temp file that has not been created yet actions/toolkit#1278

v3.0.1

Commits
  • f44cd7b Merge pull request #259 from actions/robherley/glob-downloads
  • 3181fe8 add some migration docs
  • aaaac7b licensed cache
  • 7c9182f update readme
  • b94e701 licensed cache
  • 0b55470 add test case for globbed downloads to same directory
  • 0b51c2e update prettier/eslint versions
  • c4c6db7 support globbing artifact list & merging download directory
  • 1bd0606 Merge pull request #252 from stchr/patch-1
  • eff4d42 fix default for run-id
  • Additional commits viewable in compare view

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .github/workflows/autofix.yml | 2 +- .github/workflows/main.yml | 28 +++++++++++++-------------- .github/workflows/release.yml | 2 +- mitmproxy/io/har.py | 2 +- mitmproxy/proxy/layers/http/_http2.py | 6 +++--- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 8ee552c49e..aa637f74ae 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: install-pinned/ruff@0e35bc58bd73769469284df9e1f8898daeea8768 + - uses: install-pinned/ruff@4ec70113ad8b512f13948b8d9855ac59675535d2 - run: ruff --fix-only . - run: ruff format . diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e2b9bd6a74..3818b86415 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,7 +59,7 @@ jobs: with: persist-credentials: false fetch-depth: 0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.py }} - run: pip install tox @@ -95,7 +95,7 @@ jobs: with: persist-credentials: false fetch-depth: 0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: .github/python-version.txt - if: matrix.platform == 'windows' @@ -134,7 +134,7 @@ jobs: (github.ref == 'refs/heads/citest' || startsWith(github.ref, 'refs/tags/')) run: python -u release/build.py --dirty installbuilder-installer msix-installer - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: # artifacts must have different names, see https://github.com/actions/upload-artifact/issues/24 name: binaries.${{ matrix.platform }} @@ -173,7 +173,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: .github/python-version.txt - run: | @@ -182,7 +182,7 @@ jobs: sudo dpkg -i hugo*.deb - run: pip install -e .[dev] - run: ./docs/build.py - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: docs path: docs/public @@ -192,7 +192,7 @@ jobs: env: DOCS_ARCHIVE: true - if: startsWith(github.ref, 'refs/tags/') - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: docs-archive path: docs/public @@ -229,10 +229,10 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: .github/python-version.txt - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: binaries.linux path: release/dist @@ -266,7 +266,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: .github/python-version.txt - run: sudo apt-get update @@ -274,24 +274,24 @@ jobs: - if: startsWith(github.ref, 'refs/tags/') run: sudo apt-get install -y twine - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: docs path: docs/public - if: startsWith(github.ref, 'refs/tags/') - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: docs-archive path: docs/archive - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: binaries.windows path: release/dist - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: binaries.linux path: release/dist - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: binaries.macos path: release/dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 69db1f7eed..161d80e7b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version-file: .github/node-version.txt - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: .github/python-version.txt - run: ./release/release.py ${{ inputs.version }} ${{ inputs.skip-branch-status-check }} diff --git a/mitmproxy/io/har.py b/mitmproxy/io/har.py index c3178214bc..e6eea00618 100644 --- a/mitmproxy/io/har.py +++ b/mitmproxy/io/har.py @@ -13,7 +13,7 @@ def fix_headers( - request_headers: list[dict[str, str]] | list[tuple[str, str]] + request_headers: list[dict[str, str]] | list[tuple[str, str]], ) -> http.Headers: """Converts provided headers into (b"header-name", b"header-value") tuples""" flow_headers: list[tuple[bytes, bytes]] = [] diff --git a/mitmproxy/proxy/layers/http/_http2.py b/mitmproxy/proxy/layers/http/_http2.py index 0843850193..b2fa851e2c 100644 --- a/mitmproxy/proxy/layers/http/_http2.py +++ b/mitmproxy/proxy/layers/http/_http2.py @@ -604,7 +604,7 @@ def handle_h2_event(self, event: h2.events.Event) -> CommandGenerator[bool]: def split_pseudo_headers( - h2_headers: Sequence[tuple[bytes, bytes]] + h2_headers: Sequence[tuple[bytes, bytes]], ) -> tuple[dict[bytes, bytes], http.Headers]: pseudo_headers: dict[bytes, bytes] = {} i = 0 @@ -624,7 +624,7 @@ def split_pseudo_headers( def parse_h2_request_headers( - h2_headers: Sequence[tuple[bytes, bytes]] + h2_headers: Sequence[tuple[bytes, bytes]], ) -> tuple[str, int, bytes, bytes, bytes, bytes, http.Headers]: """Split HTTP/2 pseudo-headers from the actual headers and parse them.""" pseudo_headers, headers = split_pseudo_headers(h2_headers) @@ -654,7 +654,7 @@ def parse_h2_request_headers( def parse_h2_response_headers( - h2_headers: Sequence[tuple[bytes, bytes]] + h2_headers: Sequence[tuple[bytes, bytes]], ) -> tuple[int, http.Headers]: """Split HTTP/2 pseudo-headers from the actual headers and parse them.""" pseudo_headers, headers = split_pseudo_headers(h2_headers) From ed532e92791489795c1141c3f112210f7d4483bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jan 2024 05:44:17 +0000 Subject: [PATCH 019/283] Update pytest-asyncio requirement from <0.22,>=0.17 to >=0.17,<0.24 (#6574) Updates the requirements on [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) to permit the latest version.
Release notes

Sourced from pytest-asyncio's releases.

pytest-asyncio 0.23.3

0.23.3 (2024-01-01)

  • Fixes a bug that caused event loops to be closed prematurely when using async generator fixtures with class scope or wider in a function-scoped test #706
  • Fixes various bugs that caused an internal pytest error during test collection #711 #713 #719

Known issues

As of v0.23, pytest-asyncio attaches an asyncio event loop to each item of the test suite (i.e. session, packages, modules, classes, functions) and allows tests to be run in those loops when marked accordingly. Pytest-asyncio currently assumes that async fixture scope is correlated with the new event loop scope. This prevents fixtures from being evaluated independently from the event loop scope and breaks some existing test suites (see #706). For example, a test suite may require all fixtures and tests to run in the same event loop, but have async fixtures that are set up and torn down for each module. If you're affected by this issue, please continue using the v0.21 release, until it is resolved.

Commits
  • 260b791 [docs] Prepare release of v0.23.3.
  • 6a253e2 [docs] Shorten changelog by combining multiple issues.
  • e2cbb90 [docs] Mention correct issue in changelog.
  • 0c522bf [fix] Fixes a bug that caused an internal pytest error when using ImportWarni...
  • 31c7e6f Build(deps): Bump coverage from 7.3.3 to 7.3.4 in /dependencies/default
  • 38d5c7e Build(deps): Bump sphinx-rtd-theme in /dependencies/docs
  • 650ec58 Build(deps): Bump babel from 2.13.1 to 2.14.0 in /dependencies/docs
  • 0166a7e Build(deps): Bump typing-extensions in /dependencies/default
  • 3a15f30 Build(deps): Bump coverage from 7.3.2 to 7.3.3 in /dependencies/default
  • 28e91f0 Build(deps): Bump hypothesis in /dependencies/default
  • Additional commits viewable in compare view

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 70294dbc43..3ca9b14083 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ dev = [ "hypothesis>=5.8,<7", "pdoc>=4.0.0", "pyinstaller==6.3.0", - "pytest-asyncio>=0.17,<0.22", + "pytest-asyncio>=0.17,<0.24", "pytest-cov>=2.7.1,<4.2", "pytest-timeout>=1.3.3,<2.3", "pytest-xdist>=2.1.0,<3.6", From 6e38a56f4c399551c3fe3d399bddfa8083ccd0f1 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 4 Jan 2024 10:53:13 +0100 Subject: [PATCH 020/283] implement UDP streams (#6557) based on https://github.com/mitmproxy/mitmproxy_rs/pull/127 --- mitmproxy/addons/keepserving.py | 5 +- mitmproxy/addons/proxyserver.py | 5 +- mitmproxy/addons/readfile.py | 4 +- mitmproxy/addons/script.py | 3 + mitmproxy/certs.py | 6 +- mitmproxy/master.py | 12 +- mitmproxy/net/udp.py | 279 --------------------- mitmproxy/proxy/layers/quic.py | 39 ++- mitmproxy/proxy/layers/udp.py | 12 +- mitmproxy/proxy/mode_servers.py | 123 +++------ mitmproxy/proxy/server.py | 59 ++--- mitmproxy/utils/asyncio_utils.py | 31 +++ pyproject.toml | 7 +- release/selftest.py | 2 + test/conftest.py | 14 ++ test/mitmproxy/addons/test_asgiapp.py | 1 - test/mitmproxy/addons/test_errorcheck.py | 13 +- test/mitmproxy/addons/test_proxyserver.py | 133 ++++++---- test/mitmproxy/net/test_udp.py | 102 -------- test/mitmproxy/net/test_udp_wireguard.py | 1 - test/mitmproxy/proxy/layers/test_quic.py | 24 +- test/mitmproxy/proxy/layers/test_udp.py | 1 - test/mitmproxy/proxy/test_mode_servers.py | 65 ++--- test/mitmproxy/proxy/test_tutils.py | 6 + test/mitmproxy/proxy/tutils.py | 12 +- test/mitmproxy/test_master.py | 30 ++- test/mitmproxy/utils/test_asyncio_utils.py | 50 +++- 27 files changed, 380 insertions(+), 659 deletions(-) delete mode 100644 mitmproxy/net/udp.py delete mode 100644 test/mitmproxy/net/test_udp.py delete mode 100644 test/mitmproxy/net/test_udp_wireguard.py diff --git a/mitmproxy/addons/keepserving.py b/mitmproxy/addons/keepserving.py index efe296ab36..04554c9f34 100644 --- a/mitmproxy/addons/keepserving.py +++ b/mitmproxy/addons/keepserving.py @@ -3,6 +3,7 @@ import asyncio from mitmproxy import ctx +from mitmproxy.utils import asyncio_utils class KeepServing: @@ -44,4 +45,6 @@ def running(self): ctx.options.rfile, ] if any(opts) and not ctx.options.keepserving: - self._watch_task = asyncio.get_running_loop().create_task(self.watch()) + self._watch_task = asyncio_utils.create_task( + self.watch(), name="keepserving" + ) diff --git a/mitmproxy/addons/proxyserver.py b/mitmproxy/addons/proxyserver.py index 1335f28f68..5e21ade679 100644 --- a/mitmproxy/addons/proxyserver.py +++ b/mitmproxy/addons/proxyserver.py @@ -33,6 +33,7 @@ from mitmproxy.proxy.mode_servers import ProxyConnectionHandler from mitmproxy.proxy.mode_servers import ServerInstance from mitmproxy.proxy.mode_servers import ServerManager +from mitmproxy.utils import asyncio_utils from mitmproxy.utils import human from mitmproxy.utils import signals @@ -276,7 +277,9 @@ def configure(self, updated) -> None: ) if self.is_running: - self._update_task = asyncio.create_task(self.servers.update(modes)) + self._update_task = asyncio_utils.create_task( + self.servers.update(modes), name="update servers" + ) async def setup_servers(self) -> bool: """Setup proxy servers. This may take an indefinite amount of time to complete (e.g. on permission prompts).""" diff --git a/mitmproxy/addons/readfile.py b/mitmproxy/addons/readfile.py index 63f7b1dbde..ff010d41fd 100644 --- a/mitmproxy/addons/readfile.py +++ b/mitmproxy/addons/readfile.py @@ -11,6 +11,8 @@ from mitmproxy import flowfilter from mitmproxy import io +logger = logging.getLogger(__name__) + class ReadFile: """ @@ -68,7 +70,7 @@ async def doread(self, rfile: str) -> None: try: await self.load_flows_from_path(rfile) except exceptions.FlowReadException as e: - raise exceptions.OptionsError(e) from e + logger.exception(f"Failed to read {ctx.options.rfile}: {e}") finally: self._read_task = None diff --git a/mitmproxy/addons/script.py b/mitmproxy/addons/script.py index a9b864cc8e..69a7bc805d 100644 --- a/mitmproxy/addons/script.py +++ b/mitmproxy/addons/script.py @@ -128,6 +128,9 @@ def loadscript(self): ctx.master.addons.invoke_addon_sync(self.ns, hooks.RunningHook()) async def watcher(self): + # Script loading is terminally confused at the moment. + # This here is a stopgap workaround to defer loading. + await asyncio.sleep(0) last_mtime = 0.0 while True: try: diff --git a/mitmproxy/certs.py b/mitmproxy/certs.py index 858b46de4e..173311c1d3 100644 --- a/mitmproxy/certs.py +++ b/mitmproxy/certs.py @@ -100,16 +100,20 @@ def issuer(self) -> list[tuple[str, str]]: @property def notbefore(self) -> datetime.datetime: + # TODO: Use self._cert.not_valid_before_utc once cryptography 42 hits. # x509.Certificate.not_valid_before is a naive datetime in UTC return self._cert.not_valid_before.replace(tzinfo=datetime.timezone.utc) @property def notafter(self) -> datetime.datetime: + # TODO: Use self._cert.not_valid_after_utc once cryptography 42 hits. # x509.Certificate.not_valid_after is a naive datetime in UTC return self._cert.not_valid_after.replace(tzinfo=datetime.timezone.utc) def has_expired(self) -> bool: - return datetime.datetime.utcnow() > self._cert.not_valid_after + if sys.version_info < (3, 11): # pragma: no cover + return datetime.datetime.utcnow() > self._cert.not_valid_after + return datetime.datetime.now(datetime.UTC) > self.notafter @property def subject(self) -> list[tuple[str, str]]: diff --git a/mitmproxy/master.py b/mitmproxy/master.py index aa92df9749..69740280cb 100644 --- a/mitmproxy/master.py +++ b/mitmproxy/master.py @@ -4,6 +4,7 @@ from . import ctx as mitmproxy_ctx from .addons import termlog from .proxy.mode_specs import ReverseMode +from .utils import asyncio_utils from mitmproxy import addonmanager from mitmproxy import command from mitmproxy import eventsequence @@ -51,9 +52,10 @@ def __init__( mitmproxy_ctx.options = self.options async def run(self) -> None: - old_handler = self.event_loop.get_exception_handler() - self.event_loop.set_exception_handler(self._asyncio_exception_handler) - try: + with ( + asyncio_utils.install_exception_handler(self._asyncio_exception_handler), + asyncio_utils.set_eager_task_factory(), + ): self.should_exit.clear() if ec := self.addons.get("errorcheck"): @@ -67,17 +69,15 @@ async def run(self) -> None: ], return_when=asyncio.FIRST_COMPLETED, ) + await self.running() if ec := self.addons.get("errorcheck"): await ec.shutdown_if_errored() ec.finish() - await self.running() try: await self.should_exit.wait() finally: # .wait might be cancelled (e.g. by sys.exit) await self.done() - finally: - self.event_loop.set_exception_handler(old_handler) def shutdown(self): """ diff --git a/mitmproxy/net/udp.py b/mitmproxy/net/udp.py deleted file mode 100644 index 37892c997f..0000000000 --- a/mitmproxy/net/udp.py +++ /dev/null @@ -1,279 +0,0 @@ -from __future__ import annotations - -import asyncio -import logging -import socket -from collections.abc import Callable -from typing import Any -from typing import cast -from typing import Union - -import mitmproxy_rs - -from mitmproxy.connection import Address -from mitmproxy.utils import human - -logger = logging.getLogger(__name__) - -MAX_DATAGRAM_SIZE = 65535 - 20 - -DatagramReceivedCallback = Callable[ - [asyncio.DatagramTransport, bytes, Address, Address], None -] -""" -Callable that gets invoked when a datagram is received. -The first argument is the outgoing transport. -The second argument is the received payload. -The third argument is the source address, also referred to as `remote_addr` or `peername`. -The fourth argument is the destination address, also referred to as `local_addr` or `sockname`. -""" - -# to make mypy happy -SockAddress = Union[tuple[str, int], tuple[str, int, int, int]] - - -class DrainableDatagramProtocol(asyncio.DatagramProtocol): - _loop: asyncio.AbstractEventLoop - _closed: asyncio.Event - _paused: int - _can_write: asyncio.Event - _sock: socket.socket | None - - def __init__(self, loop: asyncio.AbstractEventLoop | None) -> None: - self._loop = asyncio.get_running_loop() if loop is None else loop - self._closed = asyncio.Event() - self._paused = 0 - self._can_write = asyncio.Event() - self._can_write.set() - self._sock = None - - def __repr__(self) -> str: - return f"<{self.__class__.__name__} socket={self._sock!r}>" - - @property - def sockets(self) -> tuple[socket.socket, ...]: - return () if self._sock is None else (self._sock,) - - def connection_made(self, transport: asyncio.BaseTransport) -> None: - self._sock = transport.get_extra_info("socket") - - def connection_lost(self, exc: Exception | None) -> None: - self._closed.set() - if exc: - logger.warning(f"Connection lost on {self!r}: {exc!r}") # pragma: no cover - - def pause_writing(self) -> None: - self._paused = self._paused + 1 - if self._paused == 1: - self._can_write.clear() - - def resume_writing(self) -> None: - assert self._paused > 0 - self._paused = self._paused - 1 - if self._paused == 0: - self._can_write.set() - - async def drain(self) -> None: - await self._can_write.wait() - - def error_received(self, exc: Exception) -> None: - logger.warning(f"Send/receive on {self!r} failed: {exc!r}") # pragma: no cover - - async def wait_closed(self) -> None: - await self._closed.wait() - - -class UdpServer(DrainableDatagramProtocol): - """UDP server similar to base_events.Server""" - - # _datagram_received_cb: DatagramReceivedCallback - _transport: asyncio.DatagramTransport | None - _local_addr: Address | None - - def __init__( - self, - datagram_received_cb: DatagramReceivedCallback, - loop: asyncio.AbstractEventLoop | None, - ) -> None: - super().__init__(loop) - self._datagram_received_cb = datagram_received_cb - self._transport = None - self._local_addr = None - - def connection_made(self, transport: asyncio.BaseTransport) -> None: - if self._transport is None: - self._transport = cast(asyncio.DatagramTransport, transport) - self._transport.set_protocol(self) - self._local_addr = transport.get_extra_info("sockname") - super().connection_made(transport) - - def datagram_received(self, data: bytes, addr: Any) -> None: - assert self._transport is not None - assert self._local_addr is not None - self._datagram_received_cb(self._transport, data, addr, self._local_addr) - - def close(self) -> None: - if self._transport is not None: - self._transport.close() - - -class DatagramReader: - _packets: asyncio.Queue[bytes] - _eof: bool - - def __init__(self) -> None: - self._packets = asyncio.Queue(42) # ~2.75MB - self._eof = False - - def feed_data(self, data: bytes, remote_addr: Address) -> None: - assert len(data) <= MAX_DATAGRAM_SIZE - if self._eof: - logger.info( - f"Received UDP packet from {human.format_address(remote_addr)} after EOF." - ) - else: - try: - self._packets.put_nowait(data) - except asyncio.QueueFull: - logger.debug( - f"Dropped UDP packet from {human.format_address(remote_addr)}." - ) - - def feed_eof(self) -> None: - self._eof = True - try: - self._packets.put_nowait(b"") - except asyncio.QueueFull: - pass - - async def read(self, n: int) -> bytes: - assert n >= MAX_DATAGRAM_SIZE - if self._eof: - try: - return self._packets.get_nowait() - except asyncio.QueueEmpty: - return b"" - else: - try: - return await self._packets.get() - except RuntimeError: # pragma: no cover - # event loop got closed - return b"" - - -class DatagramWriter: - _transport: asyncio.DatagramTransport | mitmproxy_rs.DatagramTransport - _remote_addr: Address - _reader: DatagramReader | None - _closed: asyncio.Event | None - - def __init__( - self, - transport: asyncio.DatagramTransport | mitmproxy_rs.DatagramTransport, - remote_addr: Address, - reader: DatagramReader | None = None, - ) -> None: - """ - Create a new datagram writer around the given transport. - Specify a reader to prevent closing the transport and instead only feed EOF to the reader. - """ - self._transport = transport - self._remote_addr = remote_addr - if reader is not None: - self._reader = reader - self._closed = asyncio.Event() - else: - self._reader = None - self._closed = None - - @property - def _protocol( - self, - ) -> DrainableDatagramProtocol | mitmproxy_rs.DatagramTransport: - return self._transport.get_protocol() # type: ignore - - def write(self, data: bytes) -> None: - self._transport.sendto(data, self._remote_addr) - - def write_eof(self) -> None: - raise OSError("UDP does not support half-closing.") - - def get_extra_info(self, name: str, default: Any = None) -> Any: - if name == "peername": - return self._remote_addr - else: - return self._transport.get_extra_info(name, default) - - def close(self) -> None: - if self._closed is None: - self._transport.close() - else: - self._closed.set() - assert self._reader - self._reader.feed_eof() - - def is_closing(self) -> bool: - if self._closed is None: - return self._transport.is_closing() - else: - return self._closed.is_set() - - async def wait_closed(self) -> None: - if self._closed is None: - await self._protocol.wait_closed() - else: - await self._closed.wait() - - async def drain(self) -> None: - await self._protocol.drain() - - -class UdpClient(DrainableDatagramProtocol): - """UDP protocol for upstream connections.""" - - _reader: DatagramReader - - def __init__(self, reader: DatagramReader, loop: asyncio.AbstractEventLoop | None): - super().__init__(loop) - self._reader = reader - - def datagram_received(self, data: bytes, remote_addr: Address) -> None: - self._reader.feed_data(data, remote_addr) - - def connection_lost(self, exc: Exception | None) -> None: - self._reader.feed_eof() - super().connection_lost(exc) - - -async def start_server( - datagram_received_cb: DatagramReceivedCallback, - host: str, - port: int, -) -> UdpServer: - """UDP variant of asyncio.start_server.""" - - assert host, "Cannot bind to an empty host for UDP sockets on Windows or Ubuntu." - loop = asyncio.get_running_loop() - _, protocol = await loop.create_datagram_endpoint( - lambda: UdpServer(datagram_received_cb, loop), - local_addr=(host, port), - ) - assert isinstance(protocol, UdpServer) - return protocol - - -async def open_connection( - host: str, port: int, *, local_addr: Address | None = None -) -> tuple[DatagramReader, DatagramWriter]: - """UDP variant of asyncio.open_connection.""" - - loop = asyncio.get_running_loop() - reader = DatagramReader() - transport, _ = await loop.create_datagram_endpoint( - lambda: UdpClient(reader, loop), local_addr=local_addr, remote_addr=(host, port) - ) - writer = DatagramWriter( - cast(asyncio.DatagramTransport, transport), - remote_addr=transport.get_extra_info("peername"), - ) - return reader, writer diff --git a/mitmproxy/proxy/layers/quic.py b/mitmproxy/proxy/layers/quic.py index b3428fd2d7..f37e37be3d 100644 --- a/mitmproxy/proxy/layers/quic.py +++ b/mitmproxy/proxy/layers/quic.py @@ -130,6 +130,11 @@ class QuicStreamDataReceived(QuicStreamEvent): end_stream: bool """Whether the STREAM frame had the FIN bit set.""" + def __repr__(self): + target = type(self.connection).__name__.lower() + end_stream = "[end_stream] " if self.end_stream else "" + return f"QuicStreamDataReceived({target} on {self.stream_id}, {end_stream}{self.data!r})" + @dataclass class QuicStreamReset(QuicStreamEvent): @@ -169,6 +174,11 @@ def __init__( self.data = data self.end_stream = end_stream + def __repr__(self): + target = type(self.connection).__name__.lower() + end_stream = "[end_stream] " if self.end_stream else "" + return f"SendQuicStreamData({target} on {self.stream_id}, {end_stream}{self.data!r})" + class ResetQuicStream(QuicStreamCommand): """Abruptly terminate the sending part of a stream.""" @@ -766,7 +776,7 @@ def get_next_available_stream_id( self.next_stream_id[index] = stream_id + 4 return stream_id - def done(self, _) -> layer.CommandGenerator[None]: + def done(self, _) -> layer.CommandGenerator[None]: # pragma: no cover yield from () @@ -791,9 +801,11 @@ def _handle_event(self, event: events.Event) -> layer.CommandGenerator[None]: # TunnelLayer has no understanding of wakeups, so we turn this into an empty DataReceived event # which TunnelLayer recognizes as belonging to our connection. assert self.quic - timer = self._wakeup_commands.pop(event.command) + scheduled_time = self._wakeup_commands.pop(event.command) if self.quic._state is not QuicConnectionState.TERMINATED: - self.quic.handle_timer(now=max(timer, self._time())) + # weird quirk: asyncio sometimes returns a bit ahead of time. + now = max(scheduled_time, self._time()) + self.quic.handle_timer(now) yield from super()._handle_event( events.DataReceived(self.tunnel_connection, b"") ) @@ -872,18 +884,23 @@ def tls_interact(self) -> layer.CommandGenerator[None]: # send all queued datagrams assert self.quic - for data, addr in self.quic.datagrams_to_send(now=self._time()): + now = self._time() + + for data, addr in self.quic.datagrams_to_send(now=now): assert addr == self.conn.peername yield commands.SendData(self.tunnel_connection, data) - # request a new wakeup if all pending requests trigger at a later time timer = self.quic.get_timer() - if timer is not None and not any( - existing <= timer for existing in self._wakeup_commands.values() - ): - command = commands.RequestWakeup(timer - self._time()) - self._wakeup_commands[command] = timer - yield command + if timer is not None: + # smooth wakeups a bit. + smoothed = timer + 0.002 + # request a new wakeup if all pending requests trigger at a later time + if not any( + existing <= smoothed for existing in self._wakeup_commands.values() + ): + command = commands.RequestWakeup(timer - now) + self._wakeup_commands[command] = timer + yield command def receive_handshake_data( self, data: bytes diff --git a/mitmproxy/proxy/layers/udp.py b/mitmproxy/proxy/layers/udp.py index fd7e65227f..e7a889c847 100644 --- a/mitmproxy/proxy/layers/udp.py +++ b/mitmproxy/proxy/layers/udp.py @@ -119,13 +119,11 @@ def relay_messages(self, event: events.Event) -> layer.CommandGenerator[None]: yield commands.SendData(send_to, event.data) elif isinstance(event, events.ConnectionClosed): - if send_to.connected: - yield commands.CloseConnection(send_to) - else: - self._handle_event = self.done - if self.flow: - yield UdpEndHook(self.flow) - self.flow.live = False + self._handle_event = self.done + yield commands.CloseConnection(send_to) + if self.flow: + yield UdpEndHook(self.flow) + self.flow.live = False else: raise AssertionError(f"Unexpected event: {event}") diff --git a/mitmproxy/proxy/mode_servers.py b/mitmproxy/proxy/mode_servers.py index f051a9f45e..cbe861c2ae 100644 --- a/mitmproxy/proxy/mode_servers.py +++ b/mitmproxy/proxy/mode_servers.py @@ -38,7 +38,6 @@ from mitmproxy import platform from mitmproxy.connection import Address from mitmproxy.net import local_ip -from mitmproxy.net import udp from mitmproxy.proxy import commands from mitmproxy.proxy import layers from mitmproxy.proxy import mode_specs @@ -183,16 +182,17 @@ def to_json(self) -> dict: "listen_addrs": self.listen_addrs, } - async def handle_tcp_connection( + async def handle_stream( self, - reader: asyncio.StreamReader | mitmproxy_rs.TcpStream, - writer: asyncio.StreamWriter | mitmproxy_rs.TcpStream, + reader: asyncio.StreamReader | mitmproxy_rs.Stream, + writer: asyncio.StreamWriter | mitmproxy_rs.Stream, ) -> None: handler = ProxyConnectionHandler( ctx.master, reader, writer, ctx.options, self.mode ) handler.layer = self.make_top_layer(handler.layer.context) if isinstance(self.mode, mode_specs.TransparentMode): + assert isinstance(writer, asyncio.StreamWriter) s = cast(socket.socket, writer.get_extra_info("socket")) try: assert platform.original_addr @@ -206,53 +206,18 @@ async def handle_tcp_connection( handler.layer.context.server.address = original_dst elif isinstance(self.mode, (mode_specs.WireGuardMode, mode_specs.LocalMode)): handler.layer.context.server.address = writer.get_extra_info( - "destination_address", handler.layer.context.client.sockname + "remote_endpoint", handler.layer.context.client.sockname ) with self.manager.register_connection(handler.layer.context.client.id, handler): await handler.handle_client() - def handle_udp_datagram( - self, - transport: asyncio.DatagramTransport | mitmproxy_rs.DatagramTransport, - data: bytes, - remote_addr: Address, - local_addr: Address, - ) -> None: - # temporary workaround: we don't have a client uuid here. - connection_id = (remote_addr, local_addr) - if connection_id not in self.manager.connections: - reader = udp.DatagramReader() - writer = udp.DatagramWriter(transport, remote_addr, reader) - handler = ProxyConnectionHandler( - ctx.master, reader, writer, ctx.options, self.mode - ) - handler.timeout_watchdog.CONNECTION_TIMEOUT = 20 - handler.layer = self.make_top_layer(handler.layer.context) - handler.layer.context.client.transport_protocol = "udp" - handler.layer.context.server.transport_protocol = "udp" - if isinstance(self.mode, (mode_specs.WireGuardMode, mode_specs.LocalMode)): - handler.layer.context.server.address = local_addr - - # pre-register here - we may get datagrams before the task is executed. - self.manager.connections[connection_id] = handler - t = asyncio.create_task(self.handle_udp_connection(connection_id, handler)) - # assign it somewhere so that it does not get garbage-collected. - handler._handle_udp_task = t # type: ignore - else: - handler = self.manager.connections[connection_id] - reader = cast(udp.DatagramReader, handler.transports[handler.client].reader) - reader.feed_data(data, remote_addr) - - async def handle_udp_connection( - self, connection_id: tuple, handler: ProxyConnectionHandler - ) -> None: - with self.manager.register_connection(connection_id, handler): - await handler.handle_client() + async def handle_udp_stream(self, stream: mitmproxy_rs.Stream) -> None: + await self.handle_stream(stream, stream) class AsyncioServerInstance(ServerInstance[M], metaclass=ABCMeta): - _servers: list[asyncio.Server | udp.UdpServer] + _servers: list[asyncio.Server | mitmproxy_rs.UdpServer] def __init__(self, *args, **kwargs) -> None: self._servers = [] @@ -264,9 +229,13 @@ def is_running(self) -> bool: @property def listen_addrs(self) -> tuple[Address, ...]: - return tuple( - sock.getsockname() for serv in self._servers for sock in serv.sockets - ) + addrs = [] + for s in self._servers: + if isinstance(s, mitmproxy_rs.UdpServer): + addrs.append(s.getsockname()) + else: + addrs.extend(sock.getsockname() for sock in s.sockets) + return tuple(addrs) async def _start(self) -> None: assert not self._servers @@ -296,7 +265,7 @@ async def _stop(self) -> None: async def listen( self, host: str, port: int - ) -> list[asyncio.Server | udp.UdpServer]: + ) -> list[asyncio.Server | mitmproxy_rs.UdpServer]: if self.mode.transport_protocol == "tcp": # workaround for https://github.com/python/cpython/issues/89856: # We want both IPv4 and IPv6 sockets to bind to the same port. @@ -309,28 +278,27 @@ async def listen( fixed_port = s.getsockname()[1] s.close() return [ - await asyncio.start_server( - self.handle_tcp_connection, host, fixed_port - ) + await asyncio.start_server(self.handle_stream, host, fixed_port) ] except Exception as e: logger.debug( f"Failed to listen on a single port ({e!r}), falling back to default behavior." ) - return [await asyncio.start_server(self.handle_tcp_connection, host, port)] + return [await asyncio.start_server(self.handle_stream, host, port)] elif self.mode.transport_protocol == "udp": - # create_datagram_endpoint only creates one (non-dual-stack) socket, so we spawn two servers instead. - if not host: - ipv4 = await udp.start_server( - self.handle_udp_datagram, + # we start two servers for dual-stack support. + # On Linux, this would also be achievable by toggling IPV6_V6ONLY off, but this here works cross-platform. + if host == "": + ipv4 = await mitmproxy_rs.start_udp_server( "0.0.0.0", port, + self.handle_udp_stream, ) try: - ipv6 = await udp.start_server( - self.handle_udp_datagram, + ipv6 = await mitmproxy_rs.start_udp_server( "::", - port or ipv4.sockets[0].getsockname()[1], + ipv4.getsockname()[1], + self.handle_udp_stream, ) except Exception: # pragma: no cover logger.debug("Failed to listen on '::', listening on IPv4 only.") @@ -338,10 +306,10 @@ async def listen( else: # pragma: no cover return [ipv4, ipv6] return [ - await udp.start_server( - self.handle_udp_datagram, + await mitmproxy_rs.start_udp_server( host, port, + self.handle_udp_stream, ) ] else: @@ -401,12 +369,12 @@ async def _start(self) -> None: _ = mitmproxy_rs.pubkey(self.server_key) self._server = await mitmproxy_rs.start_wireguard_server( - host, + host or "127.0.0.1", port, self.server_key, [p], - self.wg_handle_tcp_connection, - self.handle_udp_datagram, + self.wg_handle_stream, + self.wg_handle_stream, ) conf = self.client_conf() @@ -443,8 +411,8 @@ async def _stop(self) -> None: finally: self._server = None - async def wg_handle_tcp_connection(self, stream: mitmproxy_rs.TcpStream) -> None: - await self.handle_tcp_connection(stream, stream) + async def wg_handle_stream(self, stream: mitmproxy_rs.Stream) -> None: + await self.handle_stream(stream, stream) class LocalRedirectorInstance(ServerInstance[mode_specs.LocalMode]): @@ -462,27 +430,12 @@ def make_top_layer(self, context: Context) -> Layer: return layers.modes.TransparentProxy(context) @classmethod - async def redirector_handle_tcp_connection( - cls, stream: mitmproxy_rs.TcpStream - ) -> None: - if cls._instance is not None: - await cls._instance.handle_tcp_connection(stream, stream) - - @classmethod - def redirector_handle_datagram( + async def redirector_handle_stream( cls, - transport: mitmproxy_rs.DatagramTransport, - data: bytes, - remote_addr: Address, - local_addr: Address, + stream: mitmproxy_rs.Stream, ) -> None: if cls._instance is not None: - cls._instance.handle_udp_datagram( - transport=transport, - data=data, - remote_addr=remote_addr, - local_addr=local_addr, - ) + await cls._instance.handle_stream(stream, stream) async def _start(self) -> None: if self._instance: @@ -500,8 +453,8 @@ async def _start(self) -> None: if cls._server is None: try: cls._server = await mitmproxy_rs.start_local_redirector( - cls.redirector_handle_tcp_connection, - cls.redirector_handle_datagram, + cls.redirector_handle_stream, + cls.redirector_handle_stream, ) except Exception: cls._instance = None diff --git a/mitmproxy/proxy/server.py b/mitmproxy/proxy/server.py index 58068fa80f..c829bb249b 100644 --- a/mitmproxy/proxy/server.py +++ b/mitmproxy/proxy/server.py @@ -29,7 +29,6 @@ from mitmproxy.connection import Client from mitmproxy.connection import Connection from mitmproxy.connection import ConnectionState -from mitmproxy.net import udp from mitmproxy.proxy import commands from mitmproxy.proxy import events from mitmproxy.proxy import layer @@ -44,14 +43,18 @@ logger = logging.getLogger(__name__) +TCP_TIMEOUT = 60 * 10 +UDP_TIMEOUT = 20 + class TimeoutWatchdog: last_activity: float - CONNECTION_TIMEOUT = 10 * 60 + timeout: int can_timeout: asyncio.Event blocker: int - def __init__(self, callback: Callable[[], Awaitable]): + def __init__(self, timeout: int, callback: Callable[[], Awaitable]): + self.timeout = timeout self.callback = callback self.last_activity = time.time() self.can_timeout = asyncio.Event() @@ -65,10 +68,8 @@ async def watch(self): try: while True: await self.can_timeout.wait() - await asyncio.sleep( - self.CONNECTION_TIMEOUT - (time.time() - self.last_activity) - ) - if self.last_activity + self.CONNECTION_TIMEOUT < time.time(): + await asyncio.sleep(self.timeout - (time.time() - self.last_activity)) + if self.last_activity + self.timeout < time.time(): await self.callback() return except asyncio.CancelledError: @@ -90,12 +91,8 @@ def disarm(self): @dataclass class ConnectionIO: handler: asyncio.Task | None = None - reader: None | ( - asyncio.StreamReader | udp.DatagramReader | mitmproxy_rs.TcpStream - ) = None - writer: None | ( - asyncio.StreamWriter | udp.DatagramWriter | mitmproxy_rs.TcpStream - ) = None + reader: asyncio.StreamReader | mitmproxy_rs.Stream | None = None + writer: asyncio.StreamWriter | mitmproxy_rs.Stream | None = None class ConnectionHandler(metaclass=abc.ABCMeta): @@ -118,7 +115,11 @@ def __init__(self, context: Context) -> None: # In a reverse proxy scenario, this is necessary as we would otherwise hang # on protocols that start with a server greeting. self.layer = layer.NextLayer(context, ask_on_start=True) - self.timeout_watchdog = TimeoutWatchdog(self.on_timeout) + if self.client.transport_protocol == "tcp": + timeout = TCP_TIMEOUT + else: + timeout = UDP_TIMEOUT + self.timeout_watchdog = TimeoutWatchdog(timeout, self.on_timeout) # workaround for https://bugs.python.org/issue40124 / https://bugs.python.org/issue29930 self._drain_lock = asyncio.Lock() @@ -200,8 +201,8 @@ async def open_connection(self, command: commands.OpenConnection) -> None: return async with self.max_conns[command.connection.address]: - reader: asyncio.StreamReader | udp.DatagramReader - writer: asyncio.StreamWriter | udp.DatagramWriter + reader: asyncio.StreamReader | mitmproxy_rs.Stream + writer: asyncio.StreamWriter | mitmproxy_rs.Stream try: command.connection.timestamp_start = time.time() if command.connection.transport_protocol == "tcp": @@ -210,7 +211,7 @@ async def open_connection(self, command: commands.OpenConnection) -> None: local_addr=command.connection.sockname, ) elif command.connection.transport_protocol == "udp": - reader, writer = await udp.open_connection( + reader = writer = await mitmproxy_rs.open_udp_connection( *command.connection.address, local_addr=command.connection.sockname, ) @@ -297,14 +298,15 @@ async def handle_connection(self, connection: Connection) -> None: cancelled = e break - if cancelled is None: + if cancelled is None and connection.transport_protocol == "tcp": + # TCP connections can be half-closed. connection.state &= ~ConnectionState.CAN_READ else: connection.state = ConnectionState.CLOSED self.server_event(events.ConnectionClosed(connection)) - if cancelled is None and connection.state is ConnectionState.CAN_WRITE: + if connection.state is ConnectionState.CAN_WRITE: # we may still use this connection to *send* stuff, # even though the remote has closed their side of the connection. # to make this work we keep this task running and wait for cancellation. @@ -345,7 +347,8 @@ async def on_timeout(self) -> None: # there is a super short window between connection close and watchdog cancellation pass else: - self.log(f"Closing connection due to inactivity: {self.client}") + if self.client.transport_protocol == "tcp": + self.log(f"Closing connection due to inactivity: {self.client}") assert handler handler.cancel("timeout") @@ -450,23 +453,15 @@ def close_connection( class LiveConnectionHandler(ConnectionHandler, metaclass=abc.ABCMeta): def __init__( self, - reader: asyncio.StreamReader | mitmproxy_rs.TcpStream, - writer: asyncio.StreamWriter | mitmproxy_rs.TcpStream, + reader: asyncio.StreamReader | mitmproxy_rs.Stream, + writer: asyncio.StreamWriter | mitmproxy_rs.Stream, options: moptions.Options, mode: mode_specs.ProxyMode, ) -> None: - # mitigate impact of https://github.com/mitmproxy/mitmproxy/issues/6204: - # For UDP, we don't get an accurate sockname from the transport when binding to all interfaces, - # however we would later need that to generate matching certificates. - # Until this is fixed properly, we can at least make the localhost case work. - sockname = writer.get_extra_info("sockname") - if sockname == "::": - sockname = "::1" - elif sockname == "0.0.0.0": - sockname = "127.0.0.1" client = Client( + transport_protocol=writer.get_extra_info("transport_protocol", "tcp"), peername=writer.get_extra_info("peername"), - sockname=sockname, + sockname=writer.get_extra_info("sockname"), timestamp_start=time.time(), proxy_mode=mode, state=ConnectionState.OPEN, diff --git a/mitmproxy/utils/asyncio_utils.py b/mitmproxy/utils/asyncio_utils.py index 95c01edd00..c545a13d65 100644 --- a/mitmproxy/utils/asyncio_utils.py +++ b/mitmproxy/utils/asyncio_utils.py @@ -1,6 +1,10 @@ import asyncio +import os +import sys import time from collections.abc import Coroutine +from collections.abc import Iterator +from contextlib import contextmanager from mitmproxy.utils import human @@ -27,6 +31,8 @@ def set_task_debug_info( ) -> None: """Set debug info for an externally-spawned task.""" task.created = time.time() # type: ignore + if __debug__ is True and (test := os.environ.get("PYTEST_CURRENT_TEST", None)): + name = f"{name} [created in {test}]" task.set_name(name) if client: task.client = client # type: ignore @@ -55,3 +61,28 @@ def task_repr(task: asyncio.Task) -> str: if client: client = f"{human.format_address(client)}: " return f"{client}{name}{age}" + + +@contextmanager +def install_exception_handler(handler) -> Iterator[None]: + loop = asyncio.get_running_loop() + existing = loop.get_exception_handler() + loop.set_exception_handler(handler) + try: + yield + finally: + loop.set_exception_handler(existing) + + +@contextmanager +def set_eager_task_factory() -> Iterator[None]: + loop = asyncio.get_running_loop() + if sys.version_info < (3, 12): # pragma: no cover + yield + else: + existing = loop.get_task_factory() + loop.set_task_factory(asyncio.eager_task_factory) # type: ignore + try: + yield + finally: + loop.set_task_factory(existing) diff --git a/pyproject.toml b/pyproject.toml index 3ca9b14083..fc5ecdf973 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ dependencies = [ "hyperframe>=6.0,<7", "kaitaistruct>=0.10,<0.11", "ldap3>=2.8,<2.10", - "mitmproxy_rs>=0.4,<0.5", + "mitmproxy_rs>=0.5.1,<0.6", "msgpack>=1.0.0, <1.1.0", "passlib>=1.6.5, <1.8", "protobuf>=3.14,<5", @@ -66,7 +66,7 @@ dev = [ "hypothesis>=5.8,<7", "pdoc>=4.0.0", "pyinstaller==6.3.0", - "pytest-asyncio>=0.17,<0.24", + "pytest-asyncio>=0.23,<0.24", "pytest-cov>=2.7.1,<4.2", "pytest-timeout>=1.3.3,<2.3", "pytest-xdist>=2.1.0,<3.6", @@ -130,8 +130,11 @@ testpaths = "test" addopts = "--capture=no --color=yes" filterwarnings = [ "ignore::DeprecationWarning:tornado.*:", + "ignore:datetime.datetime.utcnow:DeprecationWarning:aioquic.*:", "error::RuntimeWarning", "error::pytest.PytestUnraisableExceptionWarning", + # The following warning should only appear on Python 3.11 and below where eager_task_factory is not present + "default:coroutine 'ConnectionHandler.hook_task' was never awaited:RuntimeWarning", ] [tool.mypy] diff --git a/release/selftest.py b/release/selftest.py index b601772f18..f61940fd3a 100644 --- a/release/selftest.py +++ b/release/selftest.py @@ -29,6 +29,8 @@ def running(): async def make_request(): try: cafile = Path(ctx.options.confdir).expanduser() / "mitmproxy-ca.pem" + while not cafile.exists(): + await asyncio.sleep(0.01) ssl_ctx = ssl.create_default_context(cafile=cafile) port = ctx.master.addons.get("proxyserver").listen_addrs()[0][1] reader, writer = await asyncio.open_connection("127.0.0.1", port, ssl=ssl_ctx) diff --git a/test/conftest.py b/test/conftest.py index 63d2164110..b002c450bf 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -3,6 +3,7 @@ import asyncio import os import socket +import sys import pytest @@ -28,6 +29,19 @@ skip_no_ipv6 = pytest.mark.skipif(no_ipv6, reason="Host has no IPv6 support") +class EagerTaskCreationEventLoopPolicy(asyncio.DefaultEventLoopPolicy): + def new_event_loop(self): + loop = super().new_event_loop() + if sys.version_info >= (3, 12): + loop.set_task_factory(asyncio.eager_task_factory) + return loop + + +@pytest.fixture() +def event_loop_policy(request): + return EagerTaskCreationEventLoopPolicy() + + @pytest.fixture() def tdata(): return data.Data(__name__) diff --git a/test/mitmproxy/addons/test_asgiapp.py b/test/mitmproxy/addons/test_asgiapp.py index 233188b39a..fd331cdd72 100644 --- a/test/mitmproxy/addons/test_asgiapp.py +++ b/test/mitmproxy/addons/test_asgiapp.py @@ -14,7 +14,6 @@ @tapp.route("/") def hello(): - print("CALLED") return "testapp" diff --git a/test/mitmproxy/addons/test_errorcheck.py b/test/mitmproxy/addons/test_errorcheck.py index b96a6dbadc..a9ab75ad56 100644 --- a/test/mitmproxy/addons/test_errorcheck.py +++ b/test/mitmproxy/addons/test_errorcheck.py @@ -9,8 +9,9 @@ def test_errorcheck(tdata, capsys): """Integration test: Make sure that we catch errors on startup an exit.""" with pytest.raises(SystemExit): - main.mitmproxy( + main.mitmdump( [ + "-n", "-s", tdata.path("mitmproxy/data/addonscripts/load_error.py"), ] @@ -30,4 +31,12 @@ async def test_error_message(capsys): logging.error("wat") with pytest.raises(SystemExit): await e.shutdown_if_errored() - assert "Errors logged during startup" in capsys.readouterr().err + assert "Errors logged during startup, exiting..." in capsys.readouterr().err + + +async def test_repeat_error_on_stderr(capsys): + e = ErrorCheck(repeat_errors_on_stderr=True) + logging.error("wat") + with pytest.raises(SystemExit): + await e.shutdown_if_errored() + assert "Error logged during startup:\nwat" in capsys.readouterr().err diff --git a/test/mitmproxy/addons/test_proxyserver.py b/test/mitmproxy/addons/test_proxyserver.py index 00f959fb2b..2f22736a64 100644 --- a/test/mitmproxy/addons/test_proxyserver.py +++ b/test/mitmproxy/addons/test_proxyserver.py @@ -12,6 +12,7 @@ from typing import TypeVar from unittest.mock import Mock +import mitmproxy_rs import pytest from aioquic.asyncio.protocol import QuicConnectionProtocol from aioquic.asyncio.server import QuicServer @@ -32,7 +33,6 @@ from mitmproxy.addons.proxyserver import Proxyserver from mitmproxy.addons.tlsconfig import TlsConfig from mitmproxy.connection import Address -from mitmproxy.net import udp from mitmproxy.proxy import layers from mitmproxy.proxy import server_hooks from mitmproxy.test import taddons @@ -102,19 +102,27 @@ async def server_handler( assert state.flows[0].request.path == "/hello" assert state.flows[0].response.status_code == 204 - # Waiting here until everything is really torn down... takes some effort. - conn_handler = list(ps.connections.values())[0] - client_handler = conn_handler.transports[conn_handler.client].handler writer.close() await writer.wait_closed() - try: - await client_handler - except asyncio.CancelledError: - pass - for _ in range(5): - # Get all other scheduled coroutines to run. - await asyncio.sleep(0) - assert repr(ps) == "Proxyserver(0 active conns)" + await _wait_for_connection_closes(ps) + + +async def _wait_for_connection_closes(ps: Proxyserver): + # Waiting here until everything is really torn down... takes some effort. + client_handlers = [ + conn_handler.transports[conn_handler.client].handler + for conn_handler in ps.connections.values() + if conn_handler.client in conn_handler.transports + ] + for client_handler in client_handlers: + try: + await asyncio.wait_for(client_handler, 5) + except asyncio.CancelledError: + pass + for _ in range(5): + # Get all other scheduled coroutines to run. + await asyncio.sleep(0) + assert not ps.connections async def test_inject() -> None: @@ -152,6 +160,7 @@ async def server_handler( writer.close() await writer.wait_closed() + await _wait_for_connection_closes(ps) async def test_inject_fail(caplog) -> None: @@ -200,6 +209,7 @@ async def test_self_connect(): assert "Request destination unknown" in server.error tctx.configure(ps, server=False) assert await ps.setup_servers() + await _wait_for_connection_closes(ps) def test_options(): @@ -253,6 +263,7 @@ async def _raise(*_): setattr(server, "stop", _raise) tctx.configure(ps, server=False) await caplog_async.await_log("cannot close") + await _wait_for_connection_closes(ps) class DummyResolver: @@ -280,32 +291,33 @@ async def test_dns(caplog_async) -> None: await caplog_async.await_log("DNS server listening at") assert ps.servers dns_addr = ps.servers["dns@127.0.0.1:0"].listen_addrs[0] - r, w = await udp.open_connection(*dns_addr) + s = await mitmproxy_rs.open_udp_connection(*dns_addr) req = tdnsreq() - w.write(req.packed) - resp = dns.Message.unpack(await r.read(udp.MAX_DATAGRAM_SIZE)) + s.write(req.packed) + resp = dns.Message.unpack(await s.read(65535)) assert req.id == resp.id and "8.8.8.8" in str(resp) assert len(ps.connections) == 1 - w.write(req.packed) - resp = dns.Message.unpack(await r.read(udp.MAX_DATAGRAM_SIZE)) + s.write(req.packed) + resp = dns.Message.unpack(await s.read(65535)) assert req.id == resp.id and "8.8.8.8" in str(resp) assert len(ps.connections) == 1 req.id = req.id + 1 - w.write(req.packed) - resp = dns.Message.unpack(await r.read(udp.MAX_DATAGRAM_SIZE)) + s.write(req.packed) + resp = dns.Message.unpack(await s.read(65535)) assert req.id == resp.id and "8.8.8.8" in str(resp) assert len(ps.connections) == 1 - dns_layer = ps.connections[(w.get_extra_info("sockname"), dns_addr)].layer - assert isinstance(dns_layer, layers.DNSLayer) - assert len(dns_layer.flows) == 2 + (dns_conn,) = ps.connections.values() + assert isinstance(dns_conn.layer, layers.DNSLayer) + assert len(dns_conn.layer.flows) == 2 - w.write(b"\x00") + s.write(b"\x00") await caplog_async.await_log("sent an invalid message") tctx.configure(ps, server=False) await caplog_async.await_log("stopped") - w.close() - await w.wait_closed() + s.close() + await s.wait_closed() + await _wait_for_connection_closes(ps) def test_validation_no_transparent(monkeypatch): @@ -327,22 +339,38 @@ def test_transparent_init(monkeypatch): @asynccontextmanager -async def udp_server(handle_conn) -> Address: - server = await udp.start_server(handle_conn, "127.0.0.1", 0) +async def udp_server( + handle_datagram: Callable[ + [asyncio.DatagramTransport, bytes, tuple[str, int]], None + ], +) -> Address: + class ServerProtocol(asyncio.DatagramProtocol): + def connection_made(self, transport): + self.transport = transport + + def datagram_received(self, data, addr): + handle_datagram(self.transport, data, addr) + + loop = asyncio.get_running_loop() + transport, _ = await loop.create_datagram_endpoint( + lambda: ServerProtocol(), + local_addr=("127.0.0.1", 0), + ) + socket = transport.get_extra_info("socket") + try: - yield server.sockets[0].getsockname() + yield socket.getsockname() finally: - server.close() + transport.close() async def test_udp(caplog_async) -> None: caplog_async.set_level("INFO") - def server_handler( + def handle_datagram( transport: asyncio.DatagramTransport, data: bytes, remote_addr: Address, - _: Address, ): assert data == b"\x16" transport.sendto(b"\x01", remote_addr) @@ -351,7 +379,7 @@ def server_handler( nl = NextLayer() with taddons.context(ps, nl) as tctx: - async with udp_server(server_handler) as server_addr: + async with udp_server(handle_datagram) as server_addr: mode = f"reverse:udp://{server_addr[0]}:{server_addr[1]}@127.0.0.1:0" tctx.configure(ps, mode=[mode]) assert await ps.setup_servers() @@ -361,16 +389,17 @@ def server_handler( ) assert ps.servers addr = ps.servers[mode].listen_addrs[0] - r, w = await udp.open_connection(*addr) - w.write(b"\x16") - assert b"\x01" == await r.read(udp.MAX_DATAGRAM_SIZE) + stream = await mitmproxy_rs.open_udp_connection(*addr) + stream.write(b"\x16") + assert b"\x01" == await stream.read(65535) assert repr(ps) == "Proxyserver(1 active conns)" assert len(ps.connections) == 1 tctx.configure(ps, server=False) await caplog_async.await_log("stopped") - w.close() - await w.wait_closed() + stream.close() + await stream.wait_closed() + await _wait_for_connection_closes(ps) class H3EchoServer(QuicConnectionProtocol): @@ -467,7 +496,7 @@ async def quic_server( class QuicClient(QuicConnectionProtocol): - TIMEOUT: ClassVar[int] = 5 + TIMEOUT: ClassVar[int] = 10 def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) @@ -745,18 +774,14 @@ def assert_no_data(response: H3Response): assert r5.trailers == [(b"x-response", b"everything but end_stream")] -@pytest.mark.parametrize("connection_strategy", ["lazy", "eager"]) @pytest.mark.parametrize("scheme", ["http3", "quic"]) -async def test_reverse_http3_and_quic_stream( - caplog_async, scheme: str, connection_strategy: str -) -> None: +async def test_reverse_http3_and_quic_stream(caplog_async, scheme: str) -> None: caplog_async.set_level("INFO") ps = Proxyserver() nl = NextLayer() ta = TlsConfig() with taddons.context(ps, nl, ta) as tctx: tctx.options.keep_host_header = True - tctx.options.connection_strategy = connection_strategy ta.configure(["confdir"]) async with quic_server(H3EchoServer, alpn=["h3"]) as server_addr: mode = f"reverse:{scheme}://{server_addr[0]}:{server_addr[1]}@127.0.0.1:0" @@ -778,24 +803,18 @@ async def test_reverse_http3_and_quic_stream( await _test_echo(client, strict=scheme == "http3") assert len(ps.connections) == 1 - # dirty hack: forcibly close all connections so that there are no unexpected asyncio tasks - # that may cause test failures because they have not been run. - for conn in ps.servers[mode].manager.connections.values(): - await conn.on_timeout() - tctx.configure(ps, server=False) await caplog_async.await_log(f"stopped") + await _wait_for_connection_closes(ps) -@pytest.mark.parametrize("connection_strategy", ["lazy", "eager"]) -async def test_reverse_quic_datagram(caplog_async, connection_strategy: str) -> None: +async def test_reverse_quic_datagram(caplog_async) -> None: caplog_async.set_level("INFO") ps = Proxyserver() nl = NextLayer() ta = TlsConfig() with taddons.context(ps, nl, ta) as tctx: tctx.options.keep_host_header = True - tctx.options.connection_strategy = connection_strategy ta.configure(["confdir"]) async with quic_server(QuicDatagramEchoServer, alpn=["dgram"]) as server_addr: mode = f"reverse:quic://{server_addr[0]}:{server_addr[1]}@127.0.0.1:0" @@ -821,6 +840,7 @@ async def test_reverse_quic_datagram(caplog_async, connection_strategy: str) -> tctx.configure(ps, server=False) await caplog_async.await_log("stopped") + await _wait_for_connection_closes(ps) @pytest.mark.skip("HTTP/3 for regular mode is not fully supported yet") @@ -832,17 +852,19 @@ async def test_regular_http3(caplog_async, monkeypatch) -> None: with taddons.context(ps, nl, ta) as tctx: ta.configure(["confdir"]) async with quic_server(H3EchoServer, alpn=["h3"]) as server_addr: - orig_open_connection = udp.open_connection + orig_open_connection = mitmproxy_rs.open_udp_connection - def open_connection_path( + async def open_connection_path( host: str, port: int, *args, **kwargs - ) -> udp.UdpClient: + ) -> mitmproxy_rs.Stream: if host == "example.mitmproxy.org" and port == 443: host = server_addr[0] port = server_addr[1] return orig_open_connection(host, port, *args, **kwargs) - monkeypatch.setattr(udp, "open_connection", open_connection_path) + monkeypatch.setattr( + mitmproxy_rs, "open_udp_connection", open_connection_path + ) mode = f"http3@127.0.0.1:0" tctx.configure( ta, @@ -862,3 +884,4 @@ def open_connection_path( tctx.configure(ps, server=False) await caplog_async.await_log("stopped") + await _wait_for_connection_closes(ps) diff --git a/test/mitmproxy/net/test_udp.py b/test/mitmproxy/net/test_udp.py deleted file mode 100644 index b8f5250943..0000000000 --- a/test/mitmproxy/net/test_udp.py +++ /dev/null @@ -1,102 +0,0 @@ -import asyncio - -import pytest - -from mitmproxy.connection import Address -from mitmproxy.net.udp import DatagramReader -from mitmproxy.net.udp import DatagramWriter -from mitmproxy.net.udp import MAX_DATAGRAM_SIZE -from mitmproxy.net.udp import open_connection -from mitmproxy.net.udp import start_server - - -async def test_client_server(): - server_reader = DatagramReader() - server_writer: DatagramWriter | None = None - - def handle_datagram( - transport: asyncio.DatagramTransport, - data: bytes, - remote_addr: Address, - local_addr: Address, - ): - nonlocal server_reader, server_writer - if server_writer is None: - server_writer = DatagramWriter(transport, remote_addr, server_reader) - server_reader.feed_data(data, remote_addr) - - server = await start_server(handle_datagram, "127.0.0.1", 0) - assert repr(server).startswith("> quic.QuicConnectionClosed(tctx.client, 42, None, "bye") << quic.CloseQuicConnection(tctx.server, 42, None, "bye") + << udp.UdpEndHook(udpflow) << tcp.TcpEndHook(tcpflow) - >> tutils.reply() + >> tutils.reply(to=-2) + >> tutils.reply(to=-2) >> quic.QuicConnectionClosed(tctx.server, 42, None, "bye") - << udp.UdpEndHook(udpflow) - >> tutils.reply() ) def test_invalid_stream_event(self, tctx: context.Context): @@ -728,7 +728,7 @@ def make_server_conn(tls_start: quic.QuicTlsData) -> None: return tutils.reply(*args, side_effect=make_server_conn, **kwargs) -class TestServerTLS: +class TestServerQuic: def test_repr(self, tctx: context.Context): assert repr(quic.ServerQuicLayer(tctx, time=lambda: 0)) @@ -789,7 +789,7 @@ def test_simple(self, tctx: context.Context): tssl.now = tssl.now + 60 assert ( playbook - >> events.Wakeup(playbook.actual[4]) + >> tutils.reply(to=commands.RequestWakeup) << commands.CloseConnection(tctx.server) >> events.ConnectionClosed(tctx.server) << None @@ -838,7 +838,7 @@ def test_untrusted_cert(self, tctx: context.Context): tls_hook_data = tutils.Placeholder(quic.QuicTlsData) assert ( playbook - >> events.Wakeup(playbook.actual[9]) + >> tutils.reply(to=commands.RequestWakeup) << commands.Log( tutils.StrMatching( "Server QUIC handshake failed. hostname 'wrong.host.mitmproxy.org' doesn't match" @@ -890,7 +890,7 @@ def make_client_tls_layer( return playbook, client_layer, tssl_client -class TestClientTLS: +class TestClientQuic: def test_http3_disabled(self, tctx: context.Context): """Test that we swallow QUIC packets if QUIC and HTTP/3 are disabled.""" tctx.options.http3 = False @@ -904,7 +904,7 @@ def test_http3_disabled(self, tctx: context.Context): ) def test_client_only(self, tctx: context.Context): - """Test TLS with client only""" + """Test QUIC with client only""" playbook, client_layer, tssl_client = make_client_tls_layer(tctx) client_layer.debug = " " assert not tctx.client.tls_established @@ -942,9 +942,11 @@ def test_client_only(self, tctx: context.Context): tssl_client.now = tssl_client.now + 60 assert ( playbook - >> events.Wakeup(playbook.actual[16]) + >> tutils.reply(to=commands.RequestWakeup) << commands.Log( - " >> Wakeup(command=RequestWakeup({'delay': 0.20000000000000004}))", + tutils.StrMatching( + r" >> Wakeup\(command=RequestWakeup\({'delay': [.\d]+}\)\)" + ), DEBUG, ) << commands.Log( @@ -1134,7 +1136,7 @@ def test_mitmproxy_ca_is_untrusted(self, tctx: context.Context): tssl_client.now = tssl_client.now + 60 assert ( playbook - >> events.Wakeup(playbook.actual[7]) + >> tutils.reply(to=commands.RequestWakeup) << commands.Log( tutils.StrMatching( "Client QUIC handshake failed. hostname 'wrong.host.mitmproxy.org' doesn't match" diff --git a/test/mitmproxy/proxy/layers/test_udp.py b/test/mitmproxy/proxy/layers/test_udp.py index 9b8d3b419f..1253a510a0 100644 --- a/test/mitmproxy/proxy/layers/test_udp.py +++ b/test/mitmproxy/proxy/layers/test_udp.py @@ -59,7 +59,6 @@ def test_simple(tctx): << SendData(tctx.client, b"hi") >> ConnectionClosed(tctx.server) << CloseConnection(tctx.client) - >> ConnectionClosed(tctx.client) << udp.UdpEndHook(f) >> reply() >> DataReceived(tctx.server, b"ignored") diff --git a/test/mitmproxy/proxy/test_mode_servers.py b/test/mitmproxy/proxy/test_mode_servers.py index 9071e28c71..26e53345e3 100644 --- a/test/mitmproxy/proxy/test_mode_servers.py +++ b/test/mitmproxy/proxy/test_mode_servers.py @@ -1,6 +1,5 @@ import asyncio import platform -from typing import cast from unittest.mock import AsyncMock from unittest.mock import MagicMock from unittest.mock import Mock @@ -10,8 +9,6 @@ import mitmproxy.platform from mitmproxy.addons.proxyserver import Proxyserver -from mitmproxy.net import udp -from mitmproxy.proxy.mode_servers import DnsInstance from mitmproxy.proxy.mode_servers import LocalRedirectorInstance from mitmproxy.proxy.mode_servers import ServerInstance from mitmproxy.proxy.mode_servers import WireGuardServerInstance @@ -263,13 +260,13 @@ async def test_udp_start_stop(caplog_async): assert await caplog_async.await_log("server listening") host, port, *_ = inst.listen_addrs[0] - reader, writer = await udp.open_connection(host, port) + stream = await mitmproxy_rs.open_udp_connection(host, port) - writer.write(b"\x00\x00\x01") + stream.write(b"\x00\x00\x01") assert await caplog_async.await_log("sent an invalid message") - writer.close() - await writer.wait_closed() + stream.close() + await stream.wait_closed() await inst.stop() assert await caplog_async.await_log("stopped") @@ -284,32 +281,12 @@ async def test_udp_start_error(): port = inst.listen_addrs[0][1] inst2 = ServerInstance.make(f"dns@127.0.0.1:{port}", manager) with pytest.raises( - OSError, match=f"server failed to listen on 127\\.0\\.0\\.1:{port}" + Exception, match=f"Failed to bind UDP socket to 127.0.0.1:{port}" ): await inst2.start() await inst.stop() -async def test_udp_connection_reuse(monkeypatch): - manager = MagicMock() - manager.connections = {} - - monkeypatch.setattr(udp, "DatagramWriter", MagicMock()) - monkeypatch.setattr(DnsInstance, "handle_udp_connection", AsyncMock()) - - with taddons.context(): - inst = cast(DnsInstance, ServerInstance.make("dns", manager)) - inst.handle_udp_datagram( - MagicMock(), b"\x00\x00\x01", ("remoteaddr", 0), ("localaddr", 0) - ) - inst.handle_udp_datagram( - MagicMock(), b"\x00\x00\x02", ("remoteaddr", 0), ("localaddr", 0) - ) - await asyncio.sleep(0) - - assert len(inst.manager.connections) == 1 - - async def test_udp_dual_stack(caplog_async): caplog_async.set_level("DEBUG") manager = MagicMock() @@ -321,19 +298,19 @@ async def test_udp_dual_stack(caplog_async): assert await caplog_async.await_log("server listening") _, port, *_ = inst.listen_addrs[0] - reader, writer = await udp.open_connection("127.0.0.1", port) - writer.write(b"\x00\x00\x01") + stream = await mitmproxy_rs.open_udp_connection("127.0.0.1", port) + stream.write(b"\x00\x00\x01") assert await caplog_async.await_log("sent an invalid message") - writer.close() - await writer.wait_closed() + stream.close() + await stream.wait_closed() if "listening on IPv4 only" not in caplog_async.caplog.text: caplog_async.clear() - reader, writer = await udp.open_connection("::1", port) - writer.write(b"\x00\x00\x01") + stream = await mitmproxy_rs.open_udp_connection("::1", port) + stream.write(b"\x00\x00\x01") assert await caplog_async.await_log("sent an invalid message") - writer.close() - await writer.wait_closed() + stream.close() + await stream.wait_closed() await inst.stop() assert await caplog_async.await_log("stopped") @@ -399,19 +376,15 @@ async def test_always_uses_current_instance(patched_local_redirector, monkeypatc manager = MagicMock() with taddons.context(): - inst1 = ServerInstance.make(f"local:curl", manager) + inst1 = LocalRedirectorInstance.make(f"local:curl", manager) await inst1.start() await inst1.stop() - handle_tcp, handle_udp = patched_local_redirector.await_args[0] + handle_stream, _ = patched_local_redirector.await_args[0] - inst2 = ServerInstance.make(f"local:wget", manager) + inst2 = LocalRedirectorInstance.make(f"local:wget", manager) await inst2.start() - monkeypatch.setattr(inst2, "handle_tcp_connection", h_tcp := AsyncMock()) - await handle_tcp(Mock()) - assert h_tcp.await_count - - monkeypatch.setattr(inst2, "handle_udp_datagram", h_udp := Mock()) - handle_udp(Mock(), b"", ("", 0), ("", 0)) - assert h_udp.called + monkeypatch.setattr(inst2, "handle_stream", handler := AsyncMock()) + await handle_stream(Mock()) + assert handler.await_count diff --git a/test/mitmproxy/proxy/test_tutils.py b/test/mitmproxy/proxy/test_tutils.py index ec676405b3..735b31dda5 100644 --- a/test/mitmproxy/proxy/test_tutils.py +++ b/test/mitmproxy/proxy/test_tutils.py @@ -114,6 +114,12 @@ def test_command_reply(tplaybook): assert tplaybook assert tplaybook.actual[1] == tplaybook.actual[2].command + tplaybook >> TEvent((42,)) + tplaybook << TCommand(42) + tplaybook >> tutils.reply(to=TCommand) + assert tplaybook + assert tplaybook.actual[4] == tplaybook.actual[5].command + def test_default_playbook(tctx): p = tutils.Playbook(TLayer(tctx)) diff --git a/test/mitmproxy/proxy/tutils.py b/test/mitmproxy/proxy/tutils.py index 22543e397d..4c821eddc2 100644 --- a/test/mitmproxy/proxy/tutils.py +++ b/test/mitmproxy/proxy/tutils.py @@ -298,13 +298,13 @@ def __del__(self): class reply(events.Event): args: tuple[Any, ...] - to: commands.Command | int + to: commands.Command | type[commands.Command] | int side_effect: Callable[[Any], Any] def __init__( self, *args, - to: commands.Command | int = -1, + to: commands.Command | type[commands.Command] | int = -1, side_effect: Callable[[Any], None] = lambda x: None, ): """Utility method to reply to the latest hook in playbooks.""" @@ -322,6 +322,14 @@ def playbook_eval(self, playbook: Playbook) -> events.CommandCompleted: raise AssertionError(f"There is no command at offset {self.to}: {to}") else: self.to = to + elif isinstance(self.to, type): + for cmd in reversed(playbook.actual): + if isinstance(cmd, self.to): + assert isinstance(cmd, commands.Command) + self.to = cmd + break + else: + raise AssertionError(f"There is no command of type {self.to}.") for cmd in reversed(playbook.actual): if eq(self.to, cmd): self.to = cmd diff --git a/test/mitmproxy/test_master.py b/test/mitmproxy/test_master.py index df7cea8360..04e0bb6005 100644 --- a/test/mitmproxy/test_master.py +++ b/test/mitmproxy/test_master.py @@ -1,4 +1,5 @@ import asyncio +import gc from mitmproxy.master import Master @@ -7,17 +8,26 @@ async def err(): raise RuntimeError -class TaskError: - def running(self): - # not assigned to anything - asyncio.create_task(err()) - - async def test_exception_handler(caplog_async): caplog_async.set_level("ERROR") - m = Master(None) - m.addons.add(TaskError()) - running = asyncio.create_task(m.run()) + + # start proxy master and let it initialize its exception handler + master = Master(None) + running = asyncio.create_task(master.run()) + await asyncio.sleep(0) + + # create a task with an unhandled exception... + task = asyncio.create_task(err()) + # make sure said task is run... + await asyncio.sleep(0) + + # and garbage-collected... + assert task + del task + gc.collect() + + # and ensure that this triggered a log entry. await caplog_async.await_log("Traceback") - m.shutdown() + + master.shutdown() await running diff --git a/test/mitmproxy/utils/test_asyncio_utils.py b/test/mitmproxy/utils/test_asyncio_utils.py index 1b59da8b62..05891221b3 100644 --- a/test/mitmproxy/utils/test_asyncio_utils.py +++ b/test/mitmproxy/utils/test_asyncio_utils.py @@ -1,4 +1,8 @@ import asyncio +import gc +import sys + +import pytest from mitmproxy.utils import asyncio_utils @@ -8,10 +12,52 @@ async def ttask(): await asyncio.sleep(999) -async def test_simple(): +async def test_simple(monkeypatch): + monkeypatch.setenv("PYTEST_CURRENT_TEST", "test_foo") task = asyncio_utils.create_task(ttask(), name="ttask", client=("127.0.0.1", 42313)) - assert asyncio_utils.task_repr(task) == "127.0.0.1:42313: ttask (age: 0s)" + assert ( + asyncio_utils.task_repr(task) + == "127.0.0.1:42313: ttask [created in test_foo] (age: 0s)" + ) await asyncio.sleep(0) assert "newname" in asyncio_utils.task_repr(task) delattr(task, "created") assert asyncio_utils.task_repr(task) + + +async def _raise(): + raise RuntimeError() + + +async def test_install_exception_handler(): + e = asyncio.Event() + with asyncio_utils.install_exception_handler(lambda *_, **__: e.set()): + t = asyncio.create_task(_raise()) + await asyncio.sleep(0) + assert t.done() + del t + gc.collect() + await e.wait() + + +async def test_eager_task_factory(): + x = False + + async def task(): + nonlocal x + x = True + + # assert that override works... + assert type(asyncio.get_event_loop_policy()) is asyncio.DefaultEventLoopPolicy + + with asyncio_utils.set_eager_task_factory(): + _ = asyncio.create_task(task()) + if sys.version_info >= (3, 12): + # ...and the context manager is effective + assert x + + +@pytest.fixture() +def event_loop_policy(request): + # override EagerTaskCreationEventLoopPolicy from top-level conftest + return asyncio.DefaultEventLoopPolicy() From 5640c53d04e79c8e5e00fb7611639a82205a5d42 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 4 Jan 2024 12:10:45 +0100 Subject: [PATCH 021/283] update CHANGELOG --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69600efb9f..1d9b8ba9ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ ## Unreleased: mitmproxy next +* *Local Redirect Mode* is now officially available on + [macOS](https://mitmproxy.org/posts/local-redirect/macos/) + and [Windows](https://mitmproxy.org/posts/local-redirect/windows/). + See the linked blog posts for details. (@emanuele-em, @mhils) +* UDP streams are now backed by a new implementation in `mitmproxy_rs`. + This represents a major API change as UDP traffic is now exposed as streams + instead of a callback for each packet. (@mhils) * Fix a regression from mitmproxy 10.1.6 where `ignore_hosts` would terminate requests instead of forwarding them. ([#6559](https://github.com/mitmproxy/mitmproxy/pull/6559), @mhils) From fb45c18e01f5eded15a441d8f43e5f346c485226 Mon Sep 17 00:00:00 2001 From: mitmproxy release bot Date: Thu, 4 Jan 2024 12:00:25 +0000 Subject: [PATCH 022/283] mitmproxy 10.2.0 --- CHANGELOG.md | 4 ++++ mitmproxy/version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d9b8ba9ec..b4cb9a8c11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ ## Unreleased: mitmproxy next + + +## 04 January 2024: mitmproxy 10.2.0 + * *Local Redirect Mode* is now officially available on [macOS](https://mitmproxy.org/posts/local-redirect/macos/) and [Windows](https://mitmproxy.org/posts/local-redirect/windows/). diff --git a/mitmproxy/version.py b/mitmproxy/version.py index 5e84f10e8e..e3fafa88d8 100644 --- a/mitmproxy/version.py +++ b/mitmproxy/version.py @@ -2,7 +2,7 @@ import subprocess import sys -VERSION = "11.0.0.dev" +VERSION = "10.2.0" MITMPROXY = "mitmproxy " + VERSION # Serialization format version. This is displayed nowhere, it just needs to be incremented by one From 770443ee8928bf2948662548c8666024439f8449 Mon Sep 17 00:00:00 2001 From: mitmproxy release bot Date: Thu, 4 Jan 2024 12:00:25 +0000 Subject: [PATCH 023/283] reopen main for development --- mitmproxy/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mitmproxy/version.py b/mitmproxy/version.py index e3fafa88d8..5e84f10e8e 100644 --- a/mitmproxy/version.py +++ b/mitmproxy/version.py @@ -2,7 +2,7 @@ import subprocess import sys -VERSION = "10.2.0" +VERSION = "11.0.0.dev" MITMPROXY = "mitmproxy " + VERSION # Serialization format version. This is displayed nowhere, it just needs to be incremented by one From a9b8a00b70245204e2e66119b5e1043a9037f931 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 4 Jan 2024 14:29:00 +0100 Subject: [PATCH 024/283] fix #6529 (#6581) --- CHANGELOG.md | 2 ++ mitmproxy/proxy/mode_servers.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cb9a8c11..73a46539f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ## Unreleased: mitmproxy next +* Fix a bug where a traceback is shown during shutdown. + ([#6581](https://github.com/mitmproxy/mitmproxy/pull/6581), @mhils) ## 04 January 2024: mitmproxy 10.2.0 diff --git a/mitmproxy/proxy/mode_servers.py b/mitmproxy/proxy/mode_servers.py index cbe861c2ae..c66b61811c 100644 --- a/mitmproxy/proxy/mode_servers.py +++ b/mitmproxy/proxy/mode_servers.py @@ -234,7 +234,10 @@ def listen_addrs(self) -> tuple[Address, ...]: if isinstance(s, mitmproxy_rs.UdpServer): addrs.append(s.getsockname()) else: - addrs.extend(sock.getsockname() for sock in s.sockets) + try: + addrs.extend(sock.getsockname() for sock in s.sockets) + except OSError: # pragma: no cover + pass # this can fail during shutdown, see https://github.com/mitmproxy/mitmproxy/issues/6529 return tuple(addrs) async def _start(self) -> None: From ae00e82c3a0733f82db476a0496349a4969a86c0 Mon Sep 17 00:00:00 2001 From: Jon Brown Date: Thu, 4 Jan 2024 05:35:17 -0800 Subject: [PATCH 025/283] remove mention of ctx.log from addon example (#6552) [#5590](https://github.com/mitmproxy/mitmproxy/pull/5590) made the switch to standard logging, but this part of the addons documentation references the previous `ctx.log` approach. --- CHANGELOG.md | 24 +++++++++++++----------- docs/src/content/addons-overview.md | 11 +++-------- mitmproxy/ctx.py | 4 +++- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73a46539f1..e40679ec8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,14 @@ # Release History - ## Unreleased: mitmproxy next +* Remove stale reference to `ctx.log` in addon documentation. + ([#6552](https://github.com/mitmproxy/mitmproxy/pull/6552), @brojonat) * Fix a bug where a traceback is shown during shutdown. ([#6581](https://github.com/mitmproxy/mitmproxy/pull/6581), @mhils) @@ -136,7 +138,7 @@ details. - On Windows, `mitmproxy-rs` now depends on `mitmproxy-windows`. We only provide binary wheels for this package to simplify our deployment process, see CI for how to build from source. - + ([#6303](https://github.com/mitmproxy/mitmproxy/issues/6303), @mhils) * Increase maximum dump file size accepted by mitmweb ([#6373](https://github.com/mitmproxy/mitmproxy/pull/6373), @t-wy) @@ -146,7 +148,7 @@ * Add experimental support for HTTP/3 and QUIC. ([#5435](https://github.com/mitmproxy/mitmproxy/issues/5435), @meitinger) -* ASGI/WSGI apps can now listen on all ports for a specific hostname. +* ASGI/WSGI apps can now listen on all ports for a specific hostname. This makes it simpler to accept both HTTP and HTTPS. ([#5725](https://github.com/mitmproxy/mitmproxy/pull/5725), @mhils) * Add `replay.server.add` command for adding flows to server replay buffer @@ -218,7 +220,7 @@ ([#5414](https://github.com/mitmproxy/mitmproxy/pull/5414), @meitinger) * Add WireGuard mode to enable transparent proxying via WireGuard. ([#5562](https://github.com/mitmproxy/mitmproxy/pull/5562), @decathorpe, @mhils) -* Add DTLS support. +* Add DTLS support. ([#5397](https://github.com/mitmproxy/mitmproxy/pull/5397), @kckeiks). * Add a quick help bar to mitmproxy. ([#5381](https://github.com/mitmproxy/mitmproxy/pull/5381/), [#5652](https://github.com/mitmproxy/mitmproxy/pull/5652), @kckeiks, @mhils). @@ -231,7 +233,7 @@ * Deprecate `mitmproxy.ctx.log` in favor of Python's builtin `logging` module. See [the docs](https://docs.mitmproxy.org/dev/addons-api-changelog/) for details and upgrade instructions. ([#5590](https://github.com/mitmproxy/mitmproxy/pull/5590), @mhils) - + ### Breaking Changes * The `mode` option is now a list of server specs instead of a single spec. @@ -248,7 +250,7 @@ ([#5623](https://github.com/mitmproxy/mitmproxy/issues/5623), @SapiensAnatis) * Add MQTT content view. ([#5588](https://github.com/mitmproxy/mitmproxy/pull/5588), @nikitastupin, @abbbe) -* Setting `connection_strategy` to `lazy` now also disables early +* Setting `connection_strategy` to `lazy` now also disables early upstream connections to fetch TLS certificate details. ([#5487](https://github.com/mitmproxy/mitmproxy/pull/5487), @mhils) * Fix order of event hooks on startup. @@ -318,7 +320,7 @@ ([#4469](https://github.com/mitmproxy/mitmproxy/issues/4469), @mhils) * Add flatpak support to the browser addon ([#5200](https://github.com/mitmproxy/mitmproxy/issues/5200), @pauloromeira) -* Add example addon to dump contents to files based on a filter expression +* Add example addon to dump contents to files based on a filter expression ([#5190](https://github.com/mitmproxy/mitmproxy/issues/5190), @redraw) * Fix a bug where the wrong SNI is sent to an upstream HTTPS proxy ([#5109](https://github.com/mitmproxy/mitmproxy/issues/5109), @mhils) @@ -328,14 +330,14 @@ ([#5217](https://github.com/mitmproxy/mitmproxy/issues/5217), @randomstuff) * Improve cut addon to better handle binary contents ([#3965](https://github.com/mitmproxy/mitmproxy/issues/3965), @mhils) -* Fix text truncation for full-width characters +* Fix text truncation for full-width characters ([#4278](https://github.com/mitmproxy/mitmproxy/issues/4278), @kjy00302) * Fix mitmweb export copy failed in non-secure domain. ([#5264](https://github.com/mitmproxy/mitmproxy/issues/5264), @Pactortester) * Add example script for manipulating cookies. ([#5278](https://github.com/mitmproxy/mitmproxy/issues/5278), @WillahScott) -* When opening an external viewer for message contents, mailcap files are not considered anymore. - This preempts the upcoming deprecation of Python's `mailcap` module. +* When opening an external viewer for message contents, mailcap files are not considered anymore. + This preempts the upcoming deprecation of Python's `mailcap` module. ([#5297](https://github.com/mitmproxy/mitmproxy/issues/5297), @KORraNpl) * Fix hostname encoding for IDNA domains in upstream mode. ([#5316](https://github.com/mitmproxy/mitmproxy/issues/5316), @nneonneo) @@ -396,7 +398,7 @@ * Add ability to specify custom ports with LDAP authentication (#5068, @demonoidvk) * Add support for rotating saved streams every hour or day (@EndUser509) * Console Improvements on Windows (@mhils) -* Fix processing of `--set` options (#5067, @marwinxxii) +* Fix processing of `--set` options (#5067, @marwinxxii) * Lowercase user-added header names and emit a log message to notify the user when using HTTP/2 (#4746, @mhils) * Exit early if there are errors on startup (#4544, @mhils) * Fixed encoding guessing: only search for meta tags in HTML bodies (##4566, @Prinzhorn) diff --git a/docs/src/content/addons-overview.md b/docs/src/content/addons-overview.md index a4f48efed0..e8bdba7b60 100644 --- a/docs/src/content/addons-overview.md +++ b/docs/src/content/addons-overview.md @@ -25,9 +25,9 @@ them to keys in the interactive tools. {{< example src="examples/addons/anatomy.py" lang="py" >}} Above is a simple addon that keeps track of the number of flows (or more -specifically HTTP requests) we've seen. Every time it sees a new flow, it uses -mitmproxy's internal logging mechanism to announce its tally. The output can be -found in the event log in the interactive tools, or on the console in mitmdump. +specifically HTTP requests) we've seen. Every time it sees a new flow, it +increments and logs its tally. The output can be found in the event log in the +interactive tools, or on the console in mitmdump. Take it for a spin and make sure that it does what it's supposed to, by loading it into your mitmproxy tool of choice. We'll use mitmdump in these examples, @@ -45,11 +45,6 @@ Here are a few things to note about the code above: - The `request` method is an example of an *event*. Addons simply implement a method for each event they want to handle. Each event and its signature are documented in the [API documentation]({{< relref "addons-api" >}}). -- Finally, the `ctx` module is a holdall module that exposes a set of standard - objects that are commonly used in addons. We could pass a `ctx` object as the - first parameter to every event, but we've found it neater to just expose it as - an importable global. In this case, we're using the `ctx.log` object to do our - logging. # Abbreviated Scripting Syntax diff --git a/mitmproxy/ctx.py b/mitmproxy/ctx.py index 8380a100be..e83983a4cb 100644 --- a/mitmproxy/ctx.py +++ b/mitmproxy/ctx.py @@ -7,6 +7,8 @@ import mitmproxy.master import mitmproxy.options -log: mitmproxy.log.Log master: mitmproxy.master.Master options: mitmproxy.options.Options + +log: mitmproxy.log.Log +"""Deprecated: Use Python's builtin `logging` module instead.""" From 3a3d69eb42f1110c2249672cb3dd24d0ef2c582b Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sat, 6 Jan 2024 14:26:16 +0100 Subject: [PATCH 026/283] Wireguard mode: bind to 0.0.0.0 (#6587) fix #6586 --- CHANGELOG.md | 3 +++ mitmproxy/proxy/mode_servers.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e40679ec8d..494dc2535f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ ## Unreleased: mitmproxy next +* Fix a regression introduced in mitmproxy 10.2.0: WireGuard servers + now bind to all interfaces again. + ([#6587](https://github.com/mitmproxy/mitmproxy/pull/6587), @mhils) * Remove stale reference to `ctx.log` in addon documentation. ([#6552](https://github.com/mitmproxy/mitmproxy/pull/6552), @brojonat) * Fix a bug where a traceback is shown during shutdown. diff --git a/mitmproxy/proxy/mode_servers.py b/mitmproxy/proxy/mode_servers.py index c66b61811c..04fda09c5f 100644 --- a/mitmproxy/proxy/mode_servers.py +++ b/mitmproxy/proxy/mode_servers.py @@ -372,7 +372,7 @@ async def _start(self) -> None: _ = mitmproxy_rs.pubkey(self.server_key) self._server = await mitmproxy_rs.start_wireguard_server( - host or "127.0.0.1", + host or "0.0.0.0", port, self.server_key, [p], From a7edbdf74c1084fa41b1eb89195451269587fa62 Mon Sep 17 00:00:00 2001 From: mitmproxy release bot Date: Sat, 6 Jan 2024 14:17:25 +0000 Subject: [PATCH 027/283] mitmproxy 10.2.1 --- CHANGELOG.md | 4 ++++ mitmproxy/version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 494dc2535f..796d831c41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ ## Unreleased: mitmproxy next + + +## 06 January 2024: mitmproxy 10.2.1 + * Fix a regression introduced in mitmproxy 10.2.0: WireGuard servers now bind to all interfaces again. ([#6587](https://github.com/mitmproxy/mitmproxy/pull/6587), @mhils) diff --git a/mitmproxy/version.py b/mitmproxy/version.py index 5e84f10e8e..be10ff779a 100644 --- a/mitmproxy/version.py +++ b/mitmproxy/version.py @@ -2,7 +2,7 @@ import subprocess import sys -VERSION = "11.0.0.dev" +VERSION = "10.2.1" MITMPROXY = "mitmproxy " + VERSION # Serialization format version. This is displayed nowhere, it just needs to be incremented by one From d032c8abd80f5b9aa66d297571f1581a5d69ce73 Mon Sep 17 00:00:00 2001 From: mitmproxy release bot Date: Sat, 6 Jan 2024 14:17:25 +0000 Subject: [PATCH 028/283] reopen main for development --- mitmproxy/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mitmproxy/version.py b/mitmproxy/version.py index be10ff779a..5e84f10e8e 100644 --- a/mitmproxy/version.py +++ b/mitmproxy/version.py @@ -2,7 +2,7 @@ import subprocess import sys -VERSION = "10.2.1" +VERSION = "11.0.0.dev" MITMPROXY = "mitmproxy " + VERSION # Serialization format version. This is displayed nowhere, it just needs to be incremented by one From c2dd0d5a42987526f9878f52870d9a5f4a1f5dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B3pez=20Guimaraes?= <112760654+DaniElectra@users.noreply.github.com> Date: Sun, 7 Jan 2024 19:48:50 +0100 Subject: [PATCH 029/283] savehar: Fix timings being set to null (#6578) --- CHANGELOG.md | 2 ++ mitmproxy/addons/savehar.py | 6 +++--- test/mitmproxy/addons/test_savehar.py | 2 +- test/mitmproxy/data/flows/error_log.har | 6 +++--- test/mitmproxy/data/flows/incomplete_log.har | 18 +++++++++--------- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 796d831c41..9001a50c0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,8 @@ ([#6559](https://github.com/mitmproxy/mitmproxy/pull/6559), @mhils) * `ignore_hosts` now waits for the entire HTTP headers if it suspects the connection to be HTTP. ([#6559](https://github.com/mitmproxy/mitmproxy/pull/6559), @mhils) +* Fix bug where insecure HTTP requests are saved incorrectly when exporting to HAR files. + ([#6578](https://github.com/mitmproxy/mitmproxy/pull/6578), @DaniElectra) ## 14 December 2023: mitmproxy 10.1.6 diff --git a/mitmproxy/addons/savehar.py b/mitmproxy/addons/savehar.py index 5e3f22ad48..d1402c0c3a 100644 --- a/mitmproxy/addons/savehar.py +++ b/mitmproxy/addons/savehar.py @@ -144,11 +144,11 @@ def flow_entry(self, flow: http.HTTPFlow, servers_seen: set[Server]) -> dict: - flow.server_conn.timestamp_tcp_setup ) else: - ssl_time = None + ssl_time = -1.0 servers_seen.add(flow.server_conn) else: - connect_time = None - ssl_time = None + connect_time = -1.0 + ssl_time = -1.0 if flow.request.timestamp_end: send = 1000 * (flow.request.timestamp_end - flow.request.timestamp_start) diff --git a/test/mitmproxy/addons/test_savehar.py b/test/mitmproxy/addons/test_savehar.py index c725ece55c..23d5671702 100644 --- a/test/mitmproxy/addons/test_savehar.py +++ b/test/mitmproxy/addons/test_savehar.py @@ -141,7 +141,7 @@ def test_tls_setup(): flow = tflow.twebsocketflow() flow.server_conn.timestamp_tls_setup = None - assert s.flow_entry(flow, servers_seen)["timings"]["ssl"] is None + assert s.flow_entry(flow, servers_seen)["timings"]["ssl"] == -1.0 def test_binary_content(): diff --git a/test/mitmproxy/data/flows/error_log.har b/test/mitmproxy/data/flows/error_log.har index f41ee9575e..11e4c48796 100644 --- a/test/mitmproxy/data/flows/error_log.har +++ b/test/mitmproxy/data/flows/error_log.har @@ -61,8 +61,8 @@ }, "cache": {}, "timings": { - "connect": null, - "ssl": null, + "connect": -1.0, + "ssl": -1.0, "send": 2.851247787475586, "receive": 0, "wait": 0 @@ -169,4 +169,4 @@ } ] } -} \ No newline at end of file +} diff --git a/test/mitmproxy/data/flows/incomplete_log.har b/test/mitmproxy/data/flows/incomplete_log.har index 5b4c48fc6f..2d2c3709e3 100644 --- a/test/mitmproxy/data/flows/incomplete_log.har +++ b/test/mitmproxy/data/flows/incomplete_log.har @@ -45,8 +45,8 @@ }, "cache": {}, "timings": { - "connect": null, - "ssl": null, + "connect": -1.0, + "ssl": -1.0, "send": 0.0, "receive": 0, "wait": 0 @@ -89,8 +89,8 @@ }, "cache": {}, "timings": { - "connect": null, - "ssl": null, + "connect": -1.0, + "ssl": -1.0, "send": 0.00095367431640625, "receive": 0, "wait": 0 @@ -138,8 +138,8 @@ }, "cache": {}, "timings": { - "connect": null, - "ssl": null, + "connect": -1.0, + "ssl": -1.0, "send": 0.0, "receive": 0, "wait": 0 @@ -187,8 +187,8 @@ }, "cache": {}, "timings": { - "connect": null, - "ssl": null, + "connect": -1.0, + "ssl": -1.0, "send": 0.0, "receive": 0, "wait": 0 @@ -196,4 +196,4 @@ } ] } -} \ No newline at end of file +} From 8fc114a9b254f55e5c917fa1be9f91235aaf0137 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 8 Jan 2024 08:54:48 +0100 Subject: [PATCH 030/283] fix CHANGELOG --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9001a50c0d..2cf2563774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ## Unreleased: mitmproxy next +* Fix bug where insecure HTTP requests are saved incorrectly when exporting to HAR files. + ([#6578](https://github.com/mitmproxy/mitmproxy/pull/6578), @DaniElectra) ## 06 January 2024: mitmproxy 10.2.1 @@ -34,8 +36,6 @@ ([#6559](https://github.com/mitmproxy/mitmproxy/pull/6559), @mhils) * `ignore_hosts` now waits for the entire HTTP headers if it suspects the connection to be HTTP. ([#6559](https://github.com/mitmproxy/mitmproxy/pull/6559), @mhils) -* Fix bug where insecure HTTP requests are saved incorrectly when exporting to HAR files. - ([#6578](https://github.com/mitmproxy/mitmproxy/pull/6578), @DaniElectra) ## 14 December 2023: mitmproxy 10.1.6 From 4101e8aeef770df29a7f8cf8d74c88c2ac6c04ba Mon Sep 17 00:00:00 2001 From: Ngoc Pham Date: Mon, 8 Jan 2024 17:02:43 -0500 Subject: [PATCH 031/283] docs: Rosetta is required on Apple Silicon (#6591) --- docs/src/content/overview-installation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/src/content/overview-installation.md b/docs/src/content/overview-installation.md index 8f7e86d5e8..db6f952969 100644 --- a/docs/src/content/overview-installation.md +++ b/docs/src/content/overview-installation.md @@ -21,6 +21,8 @@ brew install mitmproxy Alternatively, you can download standalone binaries on [mitmproxy.org](https://mitmproxy.org/). +NOTE: For Apple Silicon, Rosetta is required. + ## Linux The recommended way to install mitmproxy on Linux is to download the From 08eb515635c8fd6d66d3a2364b7e9b5f4ccc601e Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 17 Jan 2024 17:58:35 +0100 Subject: [PATCH 032/283] fix client playback (#6605) --- CHANGELOG.md | 2 ++ mitmproxy/addons/clientplayback.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cf2563774..a6fb92cedb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ## Unreleased: mitmproxy next +* Fix a regression where clientplayback would break due to eager task execution. + ([#6605](https://github.com/mitmproxy/mitmproxy/pull/6605), @mhils) * Fix bug where insecure HTTP requests are saved incorrectly when exporting to HAR files. ([#6578](https://github.com/mitmproxy/mitmproxy/pull/6578), @DaniElectra) diff --git a/mitmproxy/addons/clientplayback.py b/mitmproxy/addons/clientplayback.py index d24548c39f..6982db329e 100644 --- a/mitmproxy/addons/clientplayback.py +++ b/mitmproxy/addons/clientplayback.py @@ -156,10 +156,10 @@ def __init__(self): self.replay_tasks = set() def running(self): + self.options = ctx.options self.playback_task = asyncio_utils.create_task( self.playback(), name="client playback" ) - self.options = ctx.options async def done(self): if self.playback_task: From c6defba77de473e02a87dde60382e8d11bcc11a0 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sun, 21 Jan 2024 14:53:02 +0100 Subject: [PATCH 033/283] websockets: do not process start event before redirecting event handlers (#6609) fix #6608 --- CHANGELOG.md | 2 ++ mitmproxy/proxy/layers/http/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6fb92cedb..fa9f94ecb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ * Fix a regression where clientplayback would break due to eager task execution. ([#6605](https://github.com/mitmproxy/mitmproxy/pull/6605), @mhils) +* Fix a regression where WebSocket connections would break due to eager task execution. + ([#6609](https://github.com/mitmproxy/mitmproxy/pull/6609), @mhils) * Fix bug where insecure HTTP requests are saved incorrectly when exporting to HAR files. ([#6578](https://github.com/mitmproxy/mitmproxy/pull/6578), @DaniElectra) diff --git a/mitmproxy/proxy/layers/http/__init__.py b/mitmproxy/proxy/layers/http/__init__.py index 419d2971b3..b9ef755216 100644 --- a/mitmproxy/proxy/layers/http/__init__.py +++ b/mitmproxy/proxy/layers/http/__init__.py @@ -528,8 +528,8 @@ def flow_done(self) -> layer.CommandGenerator[None]: yield commands.Log( f"{self.debug}[http] upgrading to {self.child_layer}", DEBUG ) - yield from self.child_layer.handle_event(events.Start()) self._handle_event = self.passthrough + yield from self.child_layer.handle_event(events.Start()) else: yield DropStream(self.stream_id) @@ -749,8 +749,8 @@ def handle_connect_finish(self): if 200 <= self.flow.response.status_code < 300: self.child_layer = self.child_layer or layer.NextLayer(self.context) - yield from self.child_layer.handle_event(events.Start()) self._handle_event = self.passthrough + yield from self.child_layer.handle_event(events.Start()) yield SendHttp( ResponseHeaders(self.stream_id, self.flow.response, True), self.context.client, From 09f47197114fd1a94a45c388c12c5437e1d4c0ec Mon Sep 17 00:00:00 2001 From: Louis <25756888+LouisAsanaka@users.noreply.github.com> Date: Sun, 21 Jan 2024 09:07:14 -0800 Subject: [PATCH 034/283] allow_hosts/ignore_hosts option now matches against the full `host:port` string (#6594) Co-authored-by: Maximilian Hils Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- CHANGELOG.md | 2 ++ mitmproxy/addons/next_layer.py | 30 ++++++++++++-------- test/mitmproxy/addons/test_next_layer.py | 36 ++++++++++++++++++------ 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa9f94ecb5..7b2d279fc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ ([#6609](https://github.com/mitmproxy/mitmproxy/pull/6609), @mhils) * Fix bug where insecure HTTP requests are saved incorrectly when exporting to HAR files. ([#6578](https://github.com/mitmproxy/mitmproxy/pull/6578), @DaniElectra) +* `allow_hosts`/`ignore_hosts` option now matches against the full `host:port` string. + ([#6594](https://github.com/mitmproxy/mitmproxy/pull/6594), @LouisAsanaka) ## 06 January 2024: mitmproxy 10.2.1 diff --git a/mitmproxy/addons/next_layer.py b/mitmproxy/addons/next_layer.py index 7c065f063a..b1a586d3a8 100644 --- a/mitmproxy/addons/next_layer.py +++ b/mitmproxy/addons/next_layer.py @@ -218,18 +218,24 @@ def _ignore_connection( ) and context.server.address == ("10.0.0.53", 53): return False hostnames: list[str] = [] - if context.server.peername and (peername := context.server.peername[0]): - hostnames.append(peername) - if context.server.address and (server_address := context.server.address[0]): - hostnames.append(server_address) - # If we already have a destination address, we can also check for HTTP Host headers. - # But we do need the destination, otherwise we don't know where this connection is going to. + if context.server.peername: + host, port = context.server.peername + hostnames.append(f"{host}:{port}") + if context.server.address: + host, port = context.server.address + hostnames.append(f"{host}:{port}") + + # We also want to check for TLS SNI and HTTP host headers, but in order to ignore connections based on that + # they must have a destination address. If they don't, we don't know how to establish an upstream connection + # if we ignore. if host_header := self._get_host_header(context, data_client, data_server): + if not re.search(r":\d+$", host_header): + host_header = f"{host_header}:{port}" hostnames.append(host_header) - if ( - client_hello := self._get_client_hello(context, data_client) - ) and client_hello.sni: - hostnames.append(client_hello.sni) + if ( + client_hello := self._get_client_hello(context, data_client) + ) and client_hello.sni: + hostnames.append(f"{client_hello.sni}:{port}") if not hostnames: return False @@ -271,7 +277,9 @@ def _get_host_header( rb"[A-Z]{3,}.+HTTP/", data_client, re.IGNORECASE ) if host_header_expected: - if m := re.search(rb"\r\n(?:Host: (.+))?\r\n", data_client, re.IGNORECASE): + if m := re.search( + rb"\r\n(?:Host:\s+(.+?)\s*)?\r\n", data_client, re.IGNORECASE + ): if host := m.group(1): return host.decode("utf-8", "surrogateescape") else: diff --git a/test/mitmproxy/addons/test_next_layer.py b/test/mitmproxy/addons/test_next_layer.py index bd67a83e6e..480ab3d399 100644 --- a/test/mitmproxy/addons/test_next_layer.py +++ b/test/mitmproxy/addons/test_next_layer.py @@ -117,7 +117,25 @@ def test_configure(self): ["example.com"], [], "tcp", "example.com", b"", True, id="address" ), pytest.param( - ["1.2.3.4"], [], "tcp", "example.com", b"", True, id="ip address" + ["192.0.2.1"], [], "tcp", "example.com", b"", True, id="ip address" + ), + pytest.param( + ["example.com:443"], + [], + "tcp", + "example.com", + b"", + True, + id="port matches", + ), + pytest.param( + ["example.com:123"], + [], + "tcp", + "example.com", + b"", + False, + id="port does not match", ), pytest.param( ["example.com"], @@ -177,7 +195,7 @@ def test_configure(self): ["example.com"], [], "tcp", - None, + "192.0.2.1", client_hello_with_extensions, True, id="sni", @@ -186,7 +204,7 @@ def test_configure(self): ["example.com"], [], "tcp", - None, + "192.0.2.1", client_hello_with_extensions[:-5], NeedsMoreData, id="incomplete client hello", @@ -195,7 +213,7 @@ def test_configure(self): ["example.com"], [], "tcp", - None, + "192.0.2.1", client_hello_no_extensions[:9] + b"\x00" * 200, False, id="invalid client hello", @@ -213,7 +231,7 @@ def test_configure(self): ["example.com"], [], "udp", - None, + "192.0.2.1", dtls_client_hello_with_extensions, True, id="dtls sni", @@ -222,7 +240,7 @@ def test_configure(self): ["example.com"], [], "udp", - None, + "192.0.2.1", dtls_client_hello_with_extensions[:-5], NeedsMoreData, id="incomplete dtls client hello", @@ -231,7 +249,7 @@ def test_configure(self): ["example.com"], [], "udp", - None, + "192.0.2.1", dtls_client_hello_with_extensions[:9] + b"\x00" * 200, False, id="invalid dtls client hello", @@ -240,7 +258,7 @@ def test_configure(self): ["example.com"], [], "udp", - None, + "192.0.2.1", quic_client_hello, True, id="quic sni", @@ -297,7 +315,7 @@ def test_ignore_connection( ctx.client.transport_protocol = transport_protocol if server_address: ctx.server.address = (server_address, 443) - ctx.server.peername = ("1.2.3.4", 443) + ctx.server.peername = ("192.0.2.1", 443) if result is NeedsMoreData: with pytest.raises(NeedsMoreData): nl._ignore_connection(ctx, data_client, b"") From d75dc95a1e4a3368134640ff8087e5a77b06986e Mon Sep 17 00:00:00 2001 From: mitmproxy release bot Date: Sun, 21 Jan 2024 17:09:27 +0000 Subject: [PATCH 035/283] mitmproxy 10.2.2 --- CHANGELOG.md | 4 ++++ mitmproxy/version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b2d279fc5..e62c58a26d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ ## Unreleased: mitmproxy next + + +## 21 January 2024: mitmproxy 10.2.2 + * Fix a regression where clientplayback would break due to eager task execution. ([#6605](https://github.com/mitmproxy/mitmproxy/pull/6605), @mhils) * Fix a regression where WebSocket connections would break due to eager task execution. diff --git a/mitmproxy/version.py b/mitmproxy/version.py index 5e84f10e8e..31a286097f 100644 --- a/mitmproxy/version.py +++ b/mitmproxy/version.py @@ -2,7 +2,7 @@ import subprocess import sys -VERSION = "11.0.0.dev" +VERSION = "10.2.2" MITMPROXY = "mitmproxy " + VERSION # Serialization format version. This is displayed nowhere, it just needs to be incremented by one From b89de7346ffe014f6cf7a27f349064c3abcbbfdc Mon Sep 17 00:00:00 2001 From: mitmproxy release bot Date: Sun, 21 Jan 2024 17:09:27 +0000 Subject: [PATCH 036/283] reopen main for development --- mitmproxy/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mitmproxy/version.py b/mitmproxy/version.py index 31a286097f..5e84f10e8e 100644 --- a/mitmproxy/version.py +++ b/mitmproxy/version.py @@ -2,7 +2,7 @@ import subprocess import sys -VERSION = "10.2.2" +VERSION = "11.0.0.dev" MITMPROXY = "mitmproxy " + VERSION # Serialization format version. This is displayed nowhere, it just needs to be incremented by one From 865e1138da1d6983d9f184ef2a0a68a16840c498 Mon Sep 17 00:00:00 2001 From: dq <60581181+dqxpb@users.noreply.github.com> Date: Tue, 23 Jan 2024 20:29:24 +0000 Subject: [PATCH 037/283] fix IPv6 matches against the full host:port string (#6614) --- CHANGELOG.md | 2 ++ mitmproxy/addons/next_layer.py | 4 ++-- test/mitmproxy/addons/test_next_layer.py | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e62c58a26d..59d2d451c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ## Unreleased: mitmproxy next +* Fix a regression where `allow_hosts`/`ignore_hosts` would break with IPv6 connections. + ([#6614](https://github.com/mitmproxy/mitmproxy/pull/6614), @dqxpb) ## 21 January 2024: mitmproxy 10.2.2 diff --git a/mitmproxy/addons/next_layer.py b/mitmproxy/addons/next_layer.py index b1a586d3a8..1f65aff0e0 100644 --- a/mitmproxy/addons/next_layer.py +++ b/mitmproxy/addons/next_layer.py @@ -219,10 +219,10 @@ def _ignore_connection( return False hostnames: list[str] = [] if context.server.peername: - host, port = context.server.peername + host, port, *_ = context.server.peername hostnames.append(f"{host}:{port}") if context.server.address: - host, port = context.server.address + host, port, *_ = context.server.address hostnames.append(f"{host}:{port}") # We also want to check for TLS SNI and HTTP host headers, but in order to ignore connections based on that diff --git a/test/mitmproxy/addons/test_next_layer.py b/test/mitmproxy/addons/test_next_layer.py index 480ab3d399..67d387606a 100644 --- a/test/mitmproxy/addons/test_next_layer.py +++ b/test/mitmproxy/addons/test_next_layer.py @@ -119,6 +119,15 @@ def test_configure(self): pytest.param( ["192.0.2.1"], [], "tcp", "example.com", b"", True, id="ip address" ), + pytest.param( + ["2001:db8::1"], + [], + "tcp", + "ipv6.example.com", + b"", + True, + id="ipv6 address", + ), pytest.param( ["example.com:443"], [], @@ -315,7 +324,11 @@ def test_ignore_connection( ctx.client.transport_protocol = transport_protocol if server_address: ctx.server.address = (server_address, 443) - ctx.server.peername = ("192.0.2.1", 443) + ctx.server.peername = ( + ("2001:db8::1", 443, 0, 0) + if server_address.startswith("ipv6") + else ("192.0.2.1", 443) + ) if result is NeedsMoreData: with pytest.raises(NeedsMoreData): nl._ignore_connection(ctx, data_client, b"") From b389f63cef99c40116484d1812bdb87ce67d6e60 Mon Sep 17 00:00:00 2001 From: dq <60581181+dqxpb@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:36:52 +0000 Subject: [PATCH 038/283] Micro-fix to arrange items in the right order. (#6616) #### Description Minor correction that does not change test case result however passes params in the intended order. --- test/mitmproxy/addons/test_next_layer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mitmproxy/addons/test_next_layer.py b/test/mitmproxy/addons/test_next_layer.py index 67d387606a..e9d628a4e5 100644 --- a/test/mitmproxy/addons/test_next_layer.py +++ b/test/mitmproxy/addons/test_next_layer.py @@ -111,7 +111,7 @@ def test_configure(self): [ # ignore pytest.param( - [], [], "example.com", "tcp", b"", False, id="nothing ignored" + [], [], "tcp", "example.com", b"", False, id="nothing ignored" ), pytest.param( ["example.com"], [], "tcp", "example.com", b"", True, id="address" From c49c38e4c80fd4ad491986a2a7f8a18e75e16b2f Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 29 Jan 2024 08:35:37 +0100 Subject: [PATCH 039/283] remove leftover command line switch rawtcp is enabled by default nowadays --- examples/addons/tcp-simple.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/addons/tcp-simple.py b/examples/addons/tcp-simple.py index ed90ba48f1..659e21f2f5 100644 --- a/examples/addons/tcp-simple.py +++ b/examples/addons/tcp-simple.py @@ -8,7 +8,7 @@ Example Invocation: - mitmdump --rawtcp --tcp-hosts ".*" -s examples/tcp-simple.py + mitmdump --tcp-hosts ".*" -s examples/tcp-simple.py """ import logging From ec96b98f7f83d5a99cfa8b4d93fd76e7da5e3988 Mon Sep 17 00:00:00 2001 From: basedBaba <144726228+basedBaba@users.noreply.github.com> Date: Thu, 1 Feb 2024 04:07:39 +0530 Subject: [PATCH 040/283] fix: save failed connect request urls to har files correctly (#6599) --- CHANGELOG.md | 2 ++ mitmproxy/addons/savehar.py | 7 ++++++- test/mitmproxy/addons/test_savehar.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59d2d451c6..d703c1561c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ ([#6578](https://github.com/mitmproxy/mitmproxy/pull/6578), @DaniElectra) * `allow_hosts`/`ignore_hosts` option now matches against the full `host:port` string. ([#6594](https://github.com/mitmproxy/mitmproxy/pull/6594), @LouisAsanaka) +* Fix bug where failed CONNECT request URLs are saved to HAR files incorrectly. + ([#6599](https://github.com/mitmproxy/mitmproxy/pull/6599), @basedBaba) ## 06 January 2024: mitmproxy 10.2.1 diff --git a/mitmproxy/addons/savehar.py b/mitmproxy/addons/savehar.py index d1402c0c3a..49d3f38689 100644 --- a/mitmproxy/addons/savehar.py +++ b/mitmproxy/addons/savehar.py @@ -227,6 +227,11 @@ def flow_entry(self, flow: http.HTTPFlow, servers_seen: set[Server]) -> dict: if flow.error: response["_error"] = flow.error.msg + if flow.request.method == "CONNECT": + url = f"https://{flow.request.pretty_url}/" + else: + url = flow.request.pretty_url + entry: dict[str, Any] = { "startedDateTime": datetime.fromtimestamp( flow.request.timestamp_start, timezone.utc @@ -234,7 +239,7 @@ def flow_entry(self, flow: http.HTTPFlow, servers_seen: set[Server]) -> dict: "time": sum(v for v in timings.values() if v is not None and v >= 0), "request": { "method": flow.request.method, - "url": flow.request.pretty_url, + "url": url, "httpVersion": flow.request.http_version, "cookies": self.format_multidict(flow.request.cookies), "headers": self.format_multidict(flow.request.headers), diff --git a/test/mitmproxy/addons/test_savehar.py b/test/mitmproxy/addons/test_savehar.py index 23d5671702..e8ec7bac44 100644 --- a/test/mitmproxy/addons/test_savehar.py +++ b/test/mitmproxy/addons/test_savehar.py @@ -173,6 +173,18 @@ def test_savehar(log_file: Path, tmp_path: Path, monkeypatch): assert actual_har == expected_har +def test_flow_entry(): + """https://github.com/mitmproxy/mitmproxy/issues/6579""" + s = SaveHar() + req = Request.make("CONNECT", "https://test.test/") + flow = tflow.tflow(req=req) + servers_seen: set[Server] = set() + + flow_entry = s.flow_entry(flow, servers_seen) + + assert flow_entry["request"]["url"].startswith("https") + + class TestHardumpOption: def test_simple(self, capsys): s = SaveHar() From 6afa7081e8d5b63908c3515c051324a369967160 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 31 Jan 2024 23:44:02 +0100 Subject: [PATCH 041/283] fix CHANGELOG --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d703c1561c..0d2466da0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ * Fix a regression where `allow_hosts`/`ignore_hosts` would break with IPv6 connections. ([#6614](https://github.com/mitmproxy/mitmproxy/pull/6614), @dqxpb) +* Fix bug where failed CONNECT request URLs are saved to HAR files incorrectly. + ([#6599](https://github.com/mitmproxy/mitmproxy/pull/6599), @basedBaba) ## 21 January 2024: mitmproxy 10.2.2 @@ -21,8 +23,6 @@ ([#6578](https://github.com/mitmproxy/mitmproxy/pull/6578), @DaniElectra) * `allow_hosts`/`ignore_hosts` option now matches against the full `host:port` string. ([#6594](https://github.com/mitmproxy/mitmproxy/pull/6594), @LouisAsanaka) -* Fix bug where failed CONNECT request URLs are saved to HAR files incorrectly. - ([#6599](https://github.com/mitmproxy/mitmproxy/pull/6599), @basedBaba) ## 06 January 2024: mitmproxy 10.2.1 From 6bd19a77e2bb91274204420b8f211aff9eee0e31 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 1 Feb 2024 00:20:19 +0100 Subject: [PATCH 042/283] build macOS arm64 binaries (#6633) --- .github/workflows/main.yml | 15 ++++++++++----- CHANGELOG.md | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3818b86415..a9c26365c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,8 +81,10 @@ jobs: fail-fast: false matrix: include: + - image: macos-14 + platform: macos-arm64 - image: macos-12 - platform: macos + platform: macos-x86_64 - image: windows-2019 platform: windows - image: ubuntu-20.04 # Oldest available version so we get oldest glibc possible. @@ -105,8 +107,7 @@ jobs: key: installbuilder - run: pip install .[dev] # pyinstaller 5.9 does not like pyproject.toml + editable installs. - # macOS x64. Due to GHA limitations, we are currently building the Apple Silicon app bundle outside of CI. - - if: matrix.platform == 'macos' && github.repository == 'mitmproxy/mitmproxy' + - if: startsWith(matrix.platform, 'macos') && github.repository == 'mitmproxy/mitmproxy' && (startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/')) id: keychain uses: apple-actions/import-codesign-certs@5565bb656f60c98c8fc515f3444dd8db73545dc2 @@ -114,7 +115,7 @@ jobs: keychain: ${{ runner.temp }}/temp p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }} p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} - - if: matrix.platform == 'macos' && github.repository == 'mitmproxy/mitmproxy' + - if: startsWith(matrix.platform, 'macos') && github.repository == 'mitmproxy/mitmproxy' && (startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/')) run: | python -u release/build.py macos-app \ @@ -293,7 +294,11 @@ jobs: path: release/dist - uses: actions/download-artifact@v4 with: - name: binaries.macos + name: binaries.macos-x86_64 + path: release/dist + - uses: actions/download-artifact@v4 + with: + name: binaries.macos-arm64 path: release/dist - run: ls docs/public - run: ls release/dist diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d2466da0d..44b4369036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ ([#6614](https://github.com/mitmproxy/mitmproxy/pull/6614), @dqxpb) * Fix bug where failed CONNECT request URLs are saved to HAR files incorrectly. ([#6599](https://github.com/mitmproxy/mitmproxy/pull/6599), @basedBaba) +* Add an arm64 variant for the precompiled macOS app. + ([#6633](https://github.com/mitmproxy/mitmproxy/pull/6633), @mhils) ## 21 January 2024: mitmproxy 10.2.2 From 8ad77e8e8c3c22bfb4dff737bb38d1fe5b0b378e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 23:21:58 +0100 Subject: [PATCH 043/283] Update pytest requirement from <8,>=6.1.0 to >=6.1.0,<9 (#6637) Updates the requirements on [pytest](https://github.com/pytest-dev/pytest) to permit the latest version.
Release notes

Sourced from pytest's releases.

pytest 8.0.0 (2024-01-27)

See 8.0.0rc1 and 8.0.0rc2 for the full changes since pytest 7.4!

Bug Fixes

  • #11842: Properly escape the reason of a skip <pytest.mark.skip ref>{.interpreted-text role="ref"} mark when writing JUnit XML files.
  • #11861: Avoid microsecond exceeds 1_000_000 when using log-date-format with %f specifier, which might cause the test suite to crash.
Commits
  • 478f823 Prepare release version 8.0.0
  • 6085900 [8.0.x] fix: avoid rounding microsecond to 1_000_000 (#11863)
  • 3b41c65 [8.0.x] Escape skip reason in junitxml (#11845)
  • 747072a [8.0.x] Update docstring of scripts/generate-gh-release-notes.py (#11768)
  • 011a475 Properly attach packages to the GH release notes (#11839) (#11840)
  • 97960bd Merge pull request #11835 from pytest-dev/release-8.0.0rc2
  • 6be0a3c Prepare release version 8.0.0rc2
  • 44ffe07 Merge pull request #11837 from pytest-dev/backport-11836-to-8.0.x
  • 14ecb04 [8.0.x] testing: temporarily disable test due to hypothesis issue
  • 41c8dab Merge pull request #11831 from bluetech/backport-11825-to-8.0.x
  • Additional commits viewable in compare view

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fc5ecdf973..2f0044b6bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ dev = [ "pytest-cov>=2.7.1,<4.2", "pytest-timeout>=1.3.3,<2.3", "pytest-xdist>=2.1.0,<3.6", - "pytest>=6.1.0,<8", + "pytest>=6.1.0,<9", "requests>=2.9.1,<3", "tox>=3.5,<5", "wheel>=0.36.2,<0.43", From e6dc1a9abe296b992f60cf7a1a483353474fa695 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 23:22:24 +0100 Subject: [PATCH 044/283] Update cryptography requirement from <41.1,>=39.0 to >=39.0,<42.1 (#6636) Updates the requirements on [cryptography](https://github.com/pyca/cryptography) to permit the latest version.
Changelog

Sourced from cryptography's changelog.

42.0.2 - 2024-01-30


* Updated Windows, macOS, and Linux wheels to be compiled with OpenSSL
3.2.1.
* Fixed an issue that prevented the use of Python buffer protocol
objects in
  ``sign`` and ``verify`` methods on asymmetric keys.
* Fixed an issue with incorrect keyword-argument naming with
``EllipticCurvePrivateKey``

:meth:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey.exchange`,
  ``X25519PrivateKey``

:meth:`~cryptography.hazmat.primitives.asymmetric.x25519.X25519PrivateKey.exchange`,
  ``X448PrivateKey``

:meth:`~cryptography.hazmat.primitives.asymmetric.x448.X448PrivateKey.exchange`,
  and ``DHPrivateKey``

:meth:`~cryptography.hazmat.primitives.asymmetric.dh.DHPrivateKey.exchange`.

.. _v42-0-1:

42.0.1 - 2024-01-24

  • Fixed an issue with incorrect keyword-argument naming with EllipticCurvePrivateKey :meth:~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey.sign.
  • Resolved compatibility issue with loading certain RSA public keys in :func:~cryptography.hazmat.primitives.serialization.load_pem_public_key.

.. _v42-0-0:

42.0.0 - 2024-01-22


* **BACKWARDS INCOMPATIBLE:** Dropped support for LibreSSL < 3.7.
* **BACKWARDS INCOMPATIBLE:** Loading a PKCS7 with no content field
using

:func:`~cryptography.hazmat.primitives.serialization.pkcs7.load_pem_pkcs7_certificates`
  or

:func:`~cryptography.hazmat.primitives.serialization.pkcs7.load_der_pkcs7_certificates`
  will now raise a ``ValueError`` rather than return an empty list.
* Parsing SSH certificates no longer permits malformed critical options
with
  values, as documented in the 41.0.2 release notes.
* Updated Windows, macOS, and Linux wheels to be compiled with OpenSSL
3.2.0.
* Updated the minimum supported Rust version (MSRV) to 1.63.0, from
1.56.0.
* We now publish both ``py37`` and ``py39`` ``abi3`` wheels. This should
resolve some errors relating to initializing a module multiple times per
  process.
* Support
:class:`~cryptography.hazmat.primitives.asymmetric.padding.PSS` for
X.509 certificate signing requests and certificate revocation lists with
the
  keyword-only argument ``rsa_padding`` on the ``sign`` methods for
  :class:`~cryptography.x509.CertificateSigningRequestBuilder` and
  :class:`~cryptography.x509.CertificateRevocationListBuilder`.
* Added support for obtaining X.509 certificate signing request
signature
  algorithm parameters (including PSS) via
</tr></table>

... (truncated)

Commits

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2f0044b6bc..3d391fe19f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ dependencies = [ "asgiref>=3.2.10,<3.8", "Brotli>=1.0,<1.2", "certifi>=2019.9.11", # no semver here - this should always be on the last release! - "cryptography>=39.0,<41.1", + "cryptography>=39.0,<42.1", "flask>=1.1.1,<3.1", "h11>=0.11,<0.15", "h2>=4.1,<5", From 6c7089f7a3bdc2f13017599fc9edfe247af65b67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 22:43:05 +0000 Subject: [PATCH 045/283] Bump the github-actions group with 2 updates (#6638) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 2 updates: [install-pinned/ruff](https://github.com/install-pinned/ruff) and [actions/cache](https://github.com/actions/cache). Updates `install-pinned/ruff` from 4ec70113ad8b512f13948b8d9855ac59675535d2 to fe472defb50a6a2c00ea3a3982534e86e69991e8
Commits

Updates `actions/cache` from 3 to 4
Release notes

Sourced from actions/cache's releases.

v4.0.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/cache/compare/v3...v4.0.0

v3.3.3

What's Changed

New Contributors

Full Changelog: https://github.com/actions/cache/compare/v3...v3.3.3

v3.3.2

What's Changed

New Contributors

Full Changelog: https://github.com/actions/cache/compare/v3...v3.3.2

v3.3.1

What's Changed

Full Changelog: https://github.com/actions/cache/compare/v3...v3.3.1

v3.3.0

What's Changed

... (truncated)

Changelog

Sourced from actions/cache's changelog.

Releases

3.0.0

  • Updated minimum runner version support from node 12 -> node 16

3.0.1

  • Added support for caching from GHES 3.5.
  • Fixed download issue for files > 2GB during restore.

3.0.2

  • Added support for dynamic cache size cap on GHES.

3.0.3

  • Fixed avoiding empty cache save when no files are available for caching. (issue)

3.0.4

  • Fixed tar creation error while trying to create tar with path as ~/ home folder on ubuntu-latest. (issue)

3.0.5

  • Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit. (PR)

3.0.6

  • Fixed #809 - zstd -d: no such file or directory error
  • Fixed #833 - cache doesn't work with github workspace directory

3.0.7

  • Fixed #810 - download stuck issue. A new timeout is introduced in the download process to abort the download if it gets stuck and doesn't finish within an hour.

3.0.8

  • Fix zstd not working for windows on gnu tar in issues #888 and #891.
  • Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable SEGMENT_DOWNLOAD_TIMEOUT_MINS. Default is 60 minutes.

3.0.9

  • Enhanced the warning message for cache unavailablity in case of GHES.

3.0.10

  • Fix a bug with sorting inputs.
  • Update definition for restore-keys in README.md

... (truncated)

Commits

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/autofix.yml | 2 +- .github/workflows/main.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index aa637f74ae..d0401d85da 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: install-pinned/ruff@4ec70113ad8b512f13948b8d9855ac59675535d2 + - uses: install-pinned/ruff@fe472defb50a6a2c00ea3a3982534e86e69991e8 - run: ruff --fix-only . - run: ruff format . diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a9c26365c8..2d8815c9ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -101,7 +101,7 @@ jobs: with: python-version-file: .github/python-version.txt - if: matrix.platform == 'windows' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: release/installbuilder/setup key: installbuilder @@ -152,7 +152,7 @@ jobs: with: node-version-file: .github/node-version.txt - name: Cache Node.js modules - uses: actions/cache@v3 + uses: actions/cache@v4 with: # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/.npm From 1a02ebb89f6765d827f2fe0086dfe5960eb6e093 Mon Sep 17 00:00:00 2001 From: Ha Anh Vu <75315486+haanhvu@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:11:03 +0700 Subject: [PATCH 046/283] Fix `Couldn't parse: falling back to Raw` for empty JSON array (#6619) #### Description fix #6603 #### Checklist - [x] I have updated tests where applicable. - [ ] I have added an entry to the CHANGELOG. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- mitmproxy/contentviews/graphql.py | 7 ++++++- test/mitmproxy/contentviews/test_graphql.py | 1 + test/mitmproxy/contentviews/test_json.py | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mitmproxy/contentviews/graphql.py b/mitmproxy/contentviews/graphql.py index 5263b75f5f..b76b7bf054 100644 --- a/mitmproxy/contentviews/graphql.py +++ b/mitmproxy/contentviews/graphql.py @@ -30,7 +30,12 @@ def is_graphql_query(data): def is_graphql_batch_query(data): - return isinstance(data, list) and isinstance(data[0], dict) and "query" in data[0] + return ( + isinstance(data, list) + and len(data) > 0 + and isinstance(data[0], dict) + and "query" in data[0] + ) class ViewGraphQL(base.View): diff --git a/test/mitmproxy/contentviews/test_graphql.py b/test/mitmproxy/contentviews/test_graphql.py index 89beda814c..f10af244ff 100644 --- a/test/mitmproxy/contentviews/test_graphql.py +++ b/test/mitmproxy/contentviews/test_graphql.py @@ -19,6 +19,7 @@ def test_render_priority(): assert 0 == v.render_priority( b"""[{"xquery": "query P { \\n }"}]""", content_type="application/json" ) + assert 0 == v.render_priority(b"""[]""", content_type="application/json") assert 0 == v.render_priority(b"}", content_type="application/json") diff --git a/test/mitmproxy/contentviews/test_json.py b/test/mitmproxy/contentviews/test_json.py index 9711a64659..413f19fd57 100644 --- a/test/mitmproxy/contentviews/test_json.py +++ b/test/mitmproxy/contentviews/test_json.py @@ -78,6 +78,22 @@ def test_format_json(): [("text", " "), ("text", "]"), ("text", "")], [("text", ""), ("text", "}")], ] + assert list(json.format_json({"list": []})) == [ + [("text", "{"), ("text", "")], + [ + ("text", " "), + ("Token_Name_Tag", '"list"'), + ("text", ": "), + ("text", "[]"), + ("text", ""), + ], + [("text", ""), ("text", "}")], + ] + assert list(json.format_json(None)) == [[("Token_Keyword_Constant", "null")]] + assert list(json.format_json(True)) == [[("Token_Keyword_Constant", "true")]] + assert list(json.format_json(1)) == [[("Token_Literal_Number", "1")]] + assert list(json.format_json("test")) == [[("Token_Literal_String", '"test"')]] + assert list(json.format_json([])) == [[("text", "[]")]] def test_view_json(): @@ -88,6 +104,7 @@ def test_view_json(): assert v(b"[1, 2, 3, 4, 5]") assert v(b'{"foo" : 3}') assert v(b'{"foo": true, "nullvalue": null}') + assert v(b"[]") @given(binary()) From d317304268e89224f073f3b8fbc39de08fc0c903 Mon Sep 17 00:00:00 2001 From: Sujal Singh Date: Tue, 13 Feb 2024 15:28:34 +0530 Subject: [PATCH 047/283] Remove duplicate answers in DNS queries (#6648) #### Description Fixes #6647 by assuming all DNS queries are made over UDP, will need to be reworked when TCP support is added. #### Checklist - [x] I have updated tests where applicable. - [x] I have added an entry to the CHANGELOG. --- CHANGELOG.md | 2 ++ mitmproxy/addons/dns_resolver.py | 4 +++- test/mitmproxy/addons/test_dns_resolver.py | 6 +++--- test/mitmproxy/addons/test_proxyserver.py | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44b4369036..8e613d5da0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ ([#6599](https://github.com/mitmproxy/mitmproxy/pull/6599), @basedBaba) * Add an arm64 variant for the precompiled macOS app. ([#6633](https://github.com/mitmproxy/mitmproxy/pull/6633), @mhils) +* Fix duplicate answers being returned in DNS queries. + ([#6648](https://github.com/mitmproxymitmproxy/pull/6648), @sujaldev) ## 21 January 2024: mitmproxy 10.2.2 diff --git a/mitmproxy/addons/dns_resolver.py b/mitmproxy/addons/dns_resolver.py index 63718050eb..e46ee52b04 100644 --- a/mitmproxy/addons/dns_resolver.py +++ b/mitmproxy/addons/dns_resolver.py @@ -26,7 +26,9 @@ async def resolve_question_by_name( ip: Callable[[str], ipaddress.IPv4Address | ipaddress.IPv6Address], ) -> Iterable[dns.ResourceRecord]: try: - addrinfos = await loop.getaddrinfo(host=question.name, port=0, family=family) + addrinfos = await loop.getaddrinfo( + host=question.name, port=0, family=family, type=socket.SOCK_STREAM + ) except socket.gaierror as e: if e.errno == socket.EAI_NONAME: raise ResolveError(dns.response_codes.NXDOMAIN) diff --git a/test/mitmproxy/addons/test_dns_resolver.py b/test/mitmproxy/addons/test_dns_resolver.py index a72d5ed257..a998ef264e 100644 --- a/test/mitmproxy/addons/test_dns_resolver.py +++ b/test/mitmproxy/addons/test_dns_resolver.py @@ -41,18 +41,18 @@ async def getnameinfo(self, socketaddr: Address, flags: int = 0): e.errno = socket.EAI_NONAME raise e - async def getaddrinfo(self, host: str, port: int, *, family: int): + async def getaddrinfo(self, host: str, port: int, *, family: int, type: int): e = socket.gaierror() e.errno = socket.EAI_NONAME if family == socket.AF_INET: if host == "dns.google": - return [(socket.AF_INET, None, None, None, ("8.8.8.8", port))] + return [(socket.AF_INET, type, None, None, ("8.8.8.8", port))] elif family == socket.AF_INET6: if host == "dns.google": return [ ( socket.AF_INET6, - None, + type, None, None, ("2001:4860:4860::8888", port, None, None), diff --git a/test/mitmproxy/addons/test_proxyserver.py b/test/mitmproxy/addons/test_proxyserver.py index 2f22736a64..0269dcd403 100644 --- a/test/mitmproxy/addons/test_proxyserver.py +++ b/test/mitmproxy/addons/test_proxyserver.py @@ -270,9 +270,9 @@ class DummyResolver: async def dns_request(self, flow: dns.DNSFlow) -> None: flow.response = await dns_resolver.resolve_message(flow.request, self) - async def getaddrinfo(self, host: str, port: int, *, family: int): + async def getaddrinfo(self, host: str, port: int, *, family: int, type: int): if family == socket.AF_INET and host == "dns.google": - return [(socket.AF_INET, None, None, None, ("8.8.8.8", port))] + return [(socket.AF_INET, type, None, None, ("8.8.8.8", port))] e = socket.gaierror() e.errno = socket.EAI_NONAME raise e From 2a82674fdc7aa1b7dde398565f6524f6dbab7828 Mon Sep 17 00:00:00 2001 From: Herman Ho Date: Tue, 13 Feb 2024 15:28:00 +0000 Subject: [PATCH 048/283] Fix error message in OpenSSL >=3.2.0 (#6658) Fix the test cases for OpenSSL v3 Ref: https://github.com/openssl/openssl/commit/81b741f68984b2620166d0d6271fbd946bab9e7f https://github.com/openssl/openssl/commit/4030869d24309bfb5292e7bec41cd2b3012ba99d --- mitmproxy/proxy/layers/tls.py | 6 ++++-- pyproject.toml | 2 +- test/mitmproxy/proxy/layers/test_tls.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mitmproxy/proxy/layers/tls.py b/mitmproxy/proxy/layers/tls.py index ab8ea154ce..792a74b5d4 100644 --- a/mitmproxy/proxy/layers/tls.py +++ b/mitmproxy/proxy/layers/tls.py @@ -318,9 +318,9 @@ def receive_handshake_data( err = f"Certificate verify failed: {error}" elif last_err in [ ("SSL routines", "ssl3_read_bytes", "tlsv1 alert unknown ca"), - ("SSL routines", "ssl3_read_bytes", "sslv3 alert bad certificate"), + ("SSL routines", "ssl3_read_bytes", "ssl/tls alert bad certificate"), ("SSL routines", "", "tlsv1 alert unknown ca"), # OpenSSL 3+ - ("SSL routines", "", "sslv3 alert bad certificate"), # OpenSSL 3+ + ("SSL routines", "", "ssl/tls alert bad certificate"), # OpenSSL 3+ ]: assert isinstance(last_err, tuple) err = last_err[2] @@ -329,6 +329,8 @@ def receive_handshake_data( in [ ("SSL routines", "ssl3_get_record", "wrong version number"), ("SSL routines", "", "wrong version number"), # OpenSSL 3+ + ("SSL routines", "", "packet length too long"), # OpenSSL 3+ + ("SSL routines", "", "record layer failure"), # OpenSSL 3+ ] and data[:4].isascii() ): diff --git a/pyproject.toml b/pyproject.toml index 3d391fe19f..3c064ca988 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ dependencies = [ "passlib>=1.6.5, <1.8", "protobuf>=3.14,<5", "pydivert>=2.0.3,<2.2; sys_platform == 'win32'", - "pyOpenSSL>=22.1,<23.4", + "pyOpenSSL>=22.1,<24.1", "pyparsing>=2.4.2,<3.2", "pyperclip>=1.6.0,<1.9", "ruamel.yaml>=0.16,<0.19", diff --git a/test/mitmproxy/proxy/layers/test_tls.py b/test/mitmproxy/proxy/layers/test_tls.py index 9960f8b748..d7c200932c 100644 --- a/test/mitmproxy/proxy/layers/test_tls.py +++ b/test/mitmproxy/proxy/layers/test_tls.py @@ -666,7 +666,7 @@ def test_mitmproxy_ca_is_untrusted(self, tctx: context.Context): >> events.DataReceived(tctx.client, tssl_client.bio_read()) << commands.Log( "Client TLS handshake failed. The client does not trust the proxy's certificate " - "for wrong.host.mitmproxy.org (sslv3 alert bad certificate)", + "for wrong.host.mitmproxy.org (ssl/tls alert bad certificate)", WARNING, ) << tls.TlsFailedClientHook(tls_hook_data) From 1f2e1a254a68e54e60360b66762ed6bdf2ff26be Mon Sep 17 00:00:00 2001 From: basedBaba <144726228+basedBaba@users.noreply.github.com> Date: Wed, 14 Feb 2024 15:09:29 +0530 Subject: [PATCH 049/283] fix: generate wireguard config with correct endpoint when using two or more active nics (#6659) #### Description Fix issue #6656 This generates a wireguard config with the correct endpoint when using two or more active NICs. #### Checklist - [x] I have updated tests where applicable. - [x] I have added an entry to the CHANGELOG. --------- Co-authored-by: Maximilian Hils --- CHANGELOG.md | 2 ++ mitmproxy/proxy/mode_servers.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e613d5da0..58ba79b88d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ ([#6633](https://github.com/mitmproxy/mitmproxy/pull/6633), @mhils) * Fix duplicate answers being returned in DNS queries. ([#6648](https://github.com/mitmproxymitmproxy/pull/6648), @sujaldev) +* Fix bug where wireguard config is generated with incorrect endpoint when two or more NICs are active. + ([#6659](https://github.com/mitmproxy/mitmproxy/pull/6659), @basedBaba) ## 21 January 2024: mitmproxy 10.2.2 diff --git a/mitmproxy/proxy/mode_servers.py b/mitmproxy/proxy/mode_servers.py index 04fda09c5f..aac2126339 100644 --- a/mitmproxy/proxy/mode_servers.py +++ b/mitmproxy/proxy/mode_servers.py @@ -387,7 +387,11 @@ async def _start(self) -> None: def client_conf(self) -> str | None: if not self._server: return None - host = local_ip.get_local_ip() or local_ip.get_local_ip6() + host = ( + self.mode.listen_host(ctx.options.listen_host) + or local_ip.get_local_ip() + or local_ip.get_local_ip6() + ) port = self.mode.listen_port(ctx.options.listen_port) return textwrap.dedent( f""" From fbc373bc9d03e0d75cad980b2193780f50d1c15f Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 15 Feb 2024 22:49:19 +0100 Subject: [PATCH 050/283] Make tests pass on older OpenSSL (#6665) This re-adds some log messages adjusted in 2a82674fdc7aa1b7dde398565f6524f6dbab7828. We shouldn't fail tests for this. refs https://github.com/pyca/cryptography/pull/10391 --- mitmproxy/proxy/layers/tls.py | 4 +++- test/mitmproxy/proxy/layers/test_tls.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mitmproxy/proxy/layers/tls.py b/mitmproxy/proxy/layers/tls.py index 792a74b5d4..3b006becb0 100644 --- a/mitmproxy/proxy/layers/tls.py +++ b/mitmproxy/proxy/layers/tls.py @@ -318,9 +318,11 @@ def receive_handshake_data( err = f"Certificate verify failed: {error}" elif last_err in [ ("SSL routines", "ssl3_read_bytes", "tlsv1 alert unknown ca"), + ("SSL routines", "ssl3_read_bytes", "sslv3 alert bad certificate"), ("SSL routines", "ssl3_read_bytes", "ssl/tls alert bad certificate"), ("SSL routines", "", "tlsv1 alert unknown ca"), # OpenSSL 3+ - ("SSL routines", "", "ssl/tls alert bad certificate"), # OpenSSL 3+ + ("SSL routines", "", "sslv3 alert bad certificate"), # OpenSSL 3+ + ("SSL routines", "", "ssl/tls alert bad certificate"), # OpenSSL 3.2+ ]: assert isinstance(last_err, tuple) err = last_err[2] diff --git a/test/mitmproxy/proxy/layers/test_tls.py b/test/mitmproxy/proxy/layers/test_tls.py index d7c200932c..6e08fa7c10 100644 --- a/test/mitmproxy/proxy/layers/test_tls.py +++ b/test/mitmproxy/proxy/layers/test_tls.py @@ -665,8 +665,10 @@ def test_mitmproxy_ca_is_untrusted(self, tctx: context.Context): playbook >> events.DataReceived(tctx.client, tssl_client.bio_read()) << commands.Log( - "Client TLS handshake failed. The client does not trust the proxy's certificate " - "for wrong.host.mitmproxy.org (ssl/tls alert bad certificate)", + tutils.StrMatching( + "Client TLS handshake failed. The client does not trust the proxy's certificate " + "for wrong.host.mitmproxy.org" + ), WARNING, ) << tls.TlsFailedClientHook(tls_hook_data) From 3ba4b65ecda926958c5ca2a3c7dd3df2f0ee1eee Mon Sep 17 00:00:00 2001 From: Mike Anselmi Date: Fri, 16 Feb 2024 14:37:24 -0500 Subject: [PATCH 051/283] Fix ca_file containing multiple CAs (#6666) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### Description Unfortunately 0b5e310881f0116c9e8e2ca5b9da98e258de0a11 broke mitmproxy's ability to issue leaf certificates if `ca_file` contains multiple CAs. This PR restores that capability. The issue lies in `mitmproxy/certs.py` - specifically, in the `from_files` method of the `CertStore` class. Before 0b5e310881f0116c9e8e2ca5b9da98e258de0a11, the issuing CA was identified like this: ``` python raw = ca_file.read_bytes() key = load_pem_private_key(raw, passphrase) … certs = re.split(rb"(?=-----BEGIN CERTIFICATE-----)", raw) ca = Cert.from_pem(certs[1]) ``` This worked even when `ca_file` contained multiple CAs. For example, consider this example: ``` -----BEGIN PRIVATE KEY----- REDACTED -----END PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICmTCCAfqgAwIBAgIRAIqaBJ6aU5wXT+5JAn8Uj1IwCgYIKoZIzj0EAwQwMDEu MCwGA1UEAxMlbWFuc2VsbWkgSW50ZXJtZWRpYXRlIENBICgyMDIzLTA0LTExKTAe Fw0yNDAyMTQxNzEzMDBaFw0yNDAyMTUxNzE0MDBaMB8xHTAbBgNVBAMTFG1pdG1w cm94eSBJc3N1aW5nIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEeKTLpy6KeiWN 89S9UJoTM9w6HyrEiVByf/ie2wUX3vR/3nHVMTi5XZQD6/8h3A9yUWwtRtVDj55D STbPKjN6G8t/Qh1dGz2vanNjmWNlceM3DOIlT30vmR5+GrUOwj+7o4HoMIHlMA4G A1UdDwEB/wQEAwIBhjAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwEwEgYD VR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQUkf9kgx5DbP0B66Ir6oLUDV/CIU4w HwYDVR0jBBgwFoAUqBYQLb8rkIidwq5dYuiDFdKhY48wYAYMKwYBBAGCpGTGKEAB BFAwTgIBAQQcbWlrZUBtYW5zZWxtaS5jb206aXNzdWluZy1jYQQrYmZhODBJaGMz VXNUcU0yQlp6ZG1rYW1OLW1XNGtpWTJrM1g5X19kd3Q0bzAKBggqhkjOPQQDBAOB jAAwgYgCQgF/QLZ0cThJKeoeIk4dY4+Z2MdIey7kvvy1jwlWrsOqOY+UXUWHXRlj oXZN92imAKqgLU5T859MMqWrjA1LjN7w6QJCAY+2xN7ovry3WSMqwnu86NuPL8vh fjftZeIW5GWuLzOsEFt7SfWMhkmFc/jcFpZ/qlolPhvr6E170zNhHUSMKvjb -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIICcjCCAdSgAwIBAgIQeK+VyMjx85py1kqGdjn5nTAKBggqhkjOPQQDBDAoMSYw JAYDVQQDEx1tYW5zZWxtaSBSb290IENBICgyMDIzLTA0LTExKTAeFw0yMzA0MTEw MjIzMzdaFw0yODA0MDkwMjIzMzdaMDAxLjAsBgNVBAMTJW1hbnNlbG1pIEludGVy bWVkaWF0ZSBDQSAoMjAyMy0wNC0xMSkwgZswEAYHKoZIzj0CAQYFK4EEACMDgYYA BADhbjtnME8IDpBab8MogM0HchH0V9B8Qx7nRXK+tbGyyHlgLjIBYF/erJGBP0md RMAxU5x/nPlHPODRBkJhB0wbcwGC9zjQQyxfhG75806QzkaZSsC0kFZ9d3JG4fjn uenY1S2VZ5qE0gDc8Qmfyjcx7KqxQKwS9RwtG1ymAmWgvmGIJ6OBlDCBkTAOBgNV HQ8BAf8EBAMCAQYwEgYDVR0TAQH/BAgwBgEB/wIBATAdBgNVHQ4EFgQUqBYQLb8r kIidwq5dYuiDFdKhY48wHwYDVR0jBBgwFoAU6+JptrrPiOuWZyKvwg0EJz5TkW8w KwYDVR0fBCQwIjAgoB6gHIYaaHR0cDovL2NhLm1hbnNlbG1pLmNvbS9jcmwwCgYI KoZIzj0EAwQDgYsAMIGHAkEw/A2kiL4Kt9/8PND89vlXEehqeymFgats62a3UMU2 g3zATES/WI2E1IgqIsmB6ILRgWMslzpH+NGP+JJkFCz9cwJCAJaRlnOc3xafHZta 0Xwr5YUVAAfmVOj9a2XAsNlNuMy2t8cmeeGmQjrZwCuivlzLOp19Ge3Mi0dnzeV+ 5L2rBOCL -----END CERTIFICATE----- ``` `certs` would have three elements: the private key, the issuing CA and the intermediate CA. As a result, `ca = Cert.from_pem(certs[1])` would select the first CA (the issuing CA). From 0b5e310881f0116c9e8e2ca5b9da98e258de0a11 onward, we instead have ``` python raw = ca_file.read_bytes() key = load_pem_private_key(raw, passphrase) … certs = x509.load_pem_x509_certificates(raw) ca = Cert(certs[-1]) ``` Now, `certs` would have only two elements: the issuing CA and the intermediate CA. (`x509.load_pem_x509_certificates` discards the private key.) As a result, `ca = Cert(certs[-1])` must instead be `ca = Cert(certs[0])`, otherwise the `ca` and `key` won't correspond to each other and we'll eventually see an error like this when mitmproxy tries to generate a leaf certificate: ``` Addon error: [('x509 certificate routines', '', 'key values mismatch')] Traceback (most recent call last): File "/Users/manselmi/repos/mitmproxy/mitmproxy/addons/tlsconfig.py", line 208, in tls_start_client tls_start.ssl_conn.use_privatekey( File "/Users/manselmi/virtualenv/mitmproxy-py312/lib/python3.12/site-packages/OpenSSL/SSL.py", line 1949, in use_privatekey self._context._raise_passphrase_exception() File "/Users/manselmi/virtualenv/mitmproxy-py312/lib/python3.12/site-packages/OpenSSL/SSL.py", line 1123, in _raise_passphrase_exception _raise_current_error() File "/Users/manselmi/virtualenv/mitmproxy-py312/lib/python3.12/site-packages/OpenSSL/_util.py", line 57, in exception_from_error_queue raise exception_type(errors) OpenSSL.SSL.Error: [('x509 certificate routines', '', 'key values mismatch')] ``` --- CHANGELOG.md | 2 ++ mitmproxy/certs.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58ba79b88d..051202a58b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ ([#6648](https://github.com/mitmproxymitmproxy/pull/6648), @sujaldev) * Fix bug where wireguard config is generated with incorrect endpoint when two or more NICs are active. ([#6659](https://github.com/mitmproxy/mitmproxy/pull/6659), @basedBaba) +* Fix a regression when leaf cert creation would fail with intermediate CAs in `ca_file`. + ([#6666](https://github.com/mitmproxy/mitmproxy/pull/6666), @manselmi) ## 21 January 2024: mitmproxy 10.2.2 diff --git a/mitmproxy/certs.py b/mitmproxy/certs.py index 173311c1d3..b054acf42e 100644 --- a/mitmproxy/certs.py +++ b/mitmproxy/certs.py @@ -415,7 +415,7 @@ def from_files( key = load_pem_private_key(raw, passphrase) dh = cls.load_dhparam(dhparam_file) certs = x509.load_pem_x509_certificates(raw) - ca = Cert(certs[-1]) + ca = Cert(certs[0]) if len(certs) > 1: chain_file: Path | None = ca_file else: From 240a286b2a3cedd0193b660e5217adfa46bb82b3 Mon Sep 17 00:00:00 2001 From: Matteo Luppi <100372313+lups2000@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:59:35 +0100 Subject: [PATCH 052/283] Fix bug scripts in Mitmweb (#6668) #### Description This PR should fix issue: #6002 #### Checklist - [x] I have updated tests where applicable. - [ ] I have added an entry to the CHANGELOG. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../__tests__/components/Modal/OptionSpec.tsx | 2 +- web/src/js/components/Modal/Option.jsx | 19 +++++++++++++++++-- web/src/js/ducks/options.ts | 4 +++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/web/src/js/__tests__/components/Modal/OptionSpec.tsx b/web/src/js/__tests__/components/Modal/OptionSpec.tsx index 47540f73db..5c74048bb1 100644 --- a/web/src/js/__tests__/components/Modal/OptionSpec.tsx +++ b/web/src/js/__tests__/components/Modal/OptionSpec.tsx @@ -97,6 +97,6 @@ describe("StringOption Component", () => { it("should handle onChange", () => { let mockEvent = { target: { value: "a\nb\nc\n" } }; tree.props.onChange(mockEvent); - expect(onChangeFn).toBeCalledWith(["a", "b", "c", ""]); + expect(onChangeFn).toBeCalledWith(["a", "b", "c"]); }); }); diff --git a/web/src/js/components/Modal/Option.jsx b/web/src/js/components/Modal/Option.jsx index 7ea333139e..f6841aeb03 100644 --- a/web/src/js/components/Modal/Option.jsx +++ b/web/src/js/components/Modal/Option.jsx @@ -99,11 +99,26 @@ StringSequenceOption.propTypes = { function StringSequenceOption({ value, onChange, ...props }) { const height = Math.max(value.length, 1); + + const [textAreaValue, setTextAreaValue] = React.useState(value.join("\n")); + + const handleChange = (e) => { + const newValue = e.target.value; + setTextAreaValue(newValue); //save in the state the current input value + onChange( + //we send to the backend only the strings that are not empty + newValue + .split("\n") + .map((line) => line.trim()) + .filter((line) => line !== "") + ); + }; + return (