Explorar o código

browser: en-US Intl, form constraint validation, stripped prelude

QuickJS has no Intl, so the Cloudron dashboard's Domains view threw
"'Intl' is not defined" in prettyLongDate.  The prelude now provides an
en-US-only subset: DateTimeFormat (UTC), NumberFormat, RelativeTimeFormat,
DurationFormat, DisplayNames, Collator, PluralRules, ListFormat and a stub
Locale, and routes toLocale*String and localeCompare through it (checked
against node's ICU Intl on 525 cases).  Behind it the domain dialog called
form.checkValidity(); controls and forms now have checkValidity,
reportValidity, validity and setCustomValidity.

To pay for it in the rootfs pack, the new host tool tools/jsstrip.c drops
the prelude's comments, indentation and non-separating blanks before
js_prelude.S embeds it: prelude gzip 18,467 -> 20,252 bytes in total.
Johannes Zellner hai 2 días
pai
achega
56aba2f2e6
Modificáronse 7 ficheiros con 710 adicións e 7 borrados
  1. 1 0
      .gitignore
  2. 26 2
      AGENTS.md
  3. 16 3
      Makefile
  4. 0 0
      docs/userland.html
  5. 175 0
      tools/jsstrip.c
  6. 3 2
      user/apps/browser/js_prelude.S
  7. 489 0
      user/apps/browser/js_prelude.js

+ 1 - 0
.gitignore

@@ -12,6 +12,7 @@ netmonitor
 mkpack
 mkrootfs
 mkrtwtbl
+jsstrip
 tls_test
 img_test
 img_test_asan

+ 26 - 2
AGENTS.md

@@ -16,7 +16,7 @@ Targets i586 (first-gen Pentium); runs under QEMU or on real hardware.
 | `user/` | `ucmd_lib.h` (the ring-3 syscall wrappers) and `ucmd.ld` |
 | `user/apps/<name>/` | One ring-3 program per directory: entry file `ucmd_<name>.c` plus private modules (`browser/` holds `browser.c`, `browser_html.c`, `js_*.c`, `svg_raster.c`; `chat/` holds `chat_login.c`; `gallery/` holds the real `gallery.c` behind the `ucmd_gallery.c` launcher; `hello/` has its own `hello.ld`) |
 | `user/lib/<lib>/` | Ring-3 libraries: `libc`, `ngui`, `ufont`, `img`, `tls` (crypto incl. `wpa_crypto.c`), `uhttp`, `ujson`, `uwm` (`uwm_lib.c`), `wifi` (`wifi_store.c`, `wpa.c`); host tests live next to their library |
-| `tools/` | Host tools (`mkpack.c`, `mkrootfs.c`, `mkrtwtbl.c`, `mkcursors.c`, `mkicons.c`, `mkwoff.py`, `kexec_send.c`, `netkexec_send.c`, `netmonitor.c`, `flash.sh`, `xcursor_trim.py`), the QMP test scripts and `cursor_test.c` |
+| `tools/` | Host tools (`mkpack.c`, `mkrootfs.c`, `mkrtwtbl.c`, `mkcursors.c`, `mkicons.c`, `jsstrip.c`, `mkwoff.py`, `kexec_send.c`, `netkexec_send.c`, `netmonitor.c`, `flash.sh`, `xcursor_trim.py`), the QMP test scripts and `cursor_test.c` |
 | `assets/` | Imported assets: `assets/cursors/adwaita/` (the Adwaita 24 px Xcursor files) and `assets/icons/adwaita/` (the Adwaita symbolic SVGs used as UI icons), both LGPL-3 / CC-BY-SA-3.0, with README and licences |
 | `host/` | Linux SDL3 browser harness |
 
@@ -1988,8 +1988,26 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   run (the microtask checkpoint, `mu_do_jobs`) and reported only if no
   handler was attached by then (`Promise.reject(e).then(f).catch(g)` used
   to print "Uncaught").  `js_prelude.js` (embedded by `js_prelude.S`, run once per
-  state before the page's scripts) implements the Web APIs in JavaScript on
+  state before the page's scripts; the build embeds
+  `build/user/apps/browser/js_prelude.min.js`, which the host tool
+  `tools/jsstrip.c` makes by dropping comments, indentation and the blanks
+  that do not separate two tokens -- ~4 KB of gzip in the rootfs pack, with
+  names and line breaks kept) implements the Web APIs in JavaScript on
   three C primitives (`__nb_http`, `__nb_storage`, `__nb_resolve`):
+  an en-US-only `Intl` (QuickJS has none; the Cloudron dashboard's date
+  helpers threw `'Intl' is not defined`): `DateTimeFormat` (fields,
+  `dateStyle`/`timeStyle`, `formatToParts`, always UTC, which is also
+  `resolvedOptions().timeZone`), `NumberFormat` (decimal/percent/currency/
+  unit, compact, significant digits, sign display), `RelativeTimeFormat`,
+  `DurationFormat`, `DisplayNames` (a small language/region table),
+  `Collator`, `PluralRules`, `ListFormat` and a stub `Locale`; it also
+  replaces `Date.prototype.toLocale*String`, `Number.prototype.
+  toLocaleString` and `String.prototype.localeCompare` (ICU-like: case- and
+  accent-blind first, whitespace < punctuation < digits < letters);
+  constraint validation (`checkValidity`/`reportValidity`/`validity`/
+  `setCustomValidity` on controls and forms: required, min/maxlength,
+  pattern, email/url syntax, number min/max; `reportValidity` shows no
+  bubble; the dashboard's domain dialog calls it on every input),
   `fetch`/`Request`/`Response`/`Headers`, `XMLHttpRequest`, `URL`/
   `URLSearchParams`, `TextEncoder`/`TextDecoder`, `btoa`/`atob`, `Blob`/
   `File`/`FormData` (urlencoded only), `AbortController`,
@@ -3037,6 +3055,12 @@ and the WM falls back to polling (`io_keyboard_irq_masked()`).
     small RX ring and stall TLS handshakes into a 10 s timeout; use e1000
     (the shared receive-window budget in `tcp.c` limits, but does not
     rule out, such overruns).
+    `Intl` is a small en-US subset: the locale argument is ignored (a
+    `de` formatter prints English), every date is formatted in UTC
+    whatever `timeZone` says, `DisplayNames` knows ~45 languages and ~18
+    regions (others fall back to the code), and number rounding goes
+    through binary `toFixed` (ICU rounds the decimal value, so a few
+    halfway cases differ).
     `DOMParser` and `document.implementation.createHTMLDocument` return an
     inert detached document (its nodes live in the page arena; markup goes
     through the innerHTML fragment parser, split at `<head>`/`<body>`),

+ 16 - 3
Makefile

@@ -587,9 +587,9 @@ $(HOST_BUILD)/host/%.o: host/%.c
 	@mkdir -p $(dir $@)
 	$(HOST_CC) $(HOST_CFLAGS) $(DEPFLAGS) -c -o $@ $<
 
-$(HOST_BUILD)/js_prelude.o: user/apps/browser/js_prelude.S user/apps/browser/js_prelude.js
+$(HOST_BUILD)/js_prelude.o: user/apps/browser/js_prelude.S $(BR)/js_prelude.min.js
 	@mkdir -p $(dir $@)
-	$(HOST_CC) -m32 -Wa,-Iuser/apps/browser -c -o $@ $<
+	$(HOST_CC) -m32 -Wa,-I$(BR) -c -o $@ $<
 
 $(HOST_BUILD)/user/apps/browser/browser.o: HOST_EXTRA = -D_start=browser_start
 $(HOST_BUILD)/user/apps/curl/ucmd_curl.o: HOST_EXTRA = -D_start=curl_start
@@ -784,6 +784,19 @@ netmonitor: tools/netmonitor.c
 mkicons: tools/mkicons.c include/icon_abi.h user/apps/browser/svg_raster.c user/apps/browser/svg_raster.h
 	gcc -O2 -Wall -Wextra -Iinclude -o $@ tools/mkicons.c user/apps/browser/svg_raster.c -lm
 
+jsstrip: tools/jsstrip.c
+	gcc -O2 -Wall -Wextra -o $@ $<
+
+# The browser prelude is embedded without its comments and indentation
+# (tools/jsstrip.c): ~3.5 KB of gzip in the rootfs pack.
+$(BR)/js_prelude.min.js: user/apps/browser/js_prelude.js jsstrip
+	@mkdir -p $(@D)
+	./jsstrip $< $@
+
+$(BR)/js_prelude.o: user/apps/browser/js_prelude.S $(BR)/js_prelude.min.js
+	@mkdir -p $(@D)
+	$(AS) $(ASFLAGS) -I$(BR) -o $@ $<
+
 mkcursors: tools/mkcursors.c include/cursor_abi.h
 	gcc -O2 -Wall -Wextra -Iinclude -o $@ $<
 
@@ -1254,7 +1267,7 @@ clean:
 	      cmds.pack cmds-lite.pack cmds_pack_gz.bin cmds_lite_gz.bin \
 	      rootfs.bin rootfs-full.bin cmds.img \
 	      firmware/*.ucode firmware/*.tbl firmware/*.bin cursors/*.cur icons/*.icn \
-	      mkpack mkrootfs mkrtwtbl mkcursors mkicons cursor_test kexec_send netkexec_send netmonitor \
+	      mkpack mkrootfs mkrtwtbl mkcursors mkicons jsstrip cursor_test kexec_send netkexec_send netmonitor \
 	      browser-host host-curl \
 	      ufont_test ufont_test_asan svg_test touchpad_gesture_test \
 	      ujson_test uhttp_cookie_test chat_login_test tls_test wpa_test \

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
docs/userland.html


+ 175 - 0
tools/jsstrip.c

@@ -0,0 +1,175 @@
+/* jsstrip: drop comments, indentation and blank lines from the browser's
+ * JavaScript prelude before it is embedded (js_prelude.S), so the source
+ * can stay commented without costing rootfs pack space.
+ *
+ * Usage: jsstrip <in.js> <out.js>
+ *
+ * Deliberately not a minifier: names stay and line breaks are kept (ASI and
+ * error line numbers stay sane).  Within a line a run of blanks (or a
+ * removed comment) survives as one space only where dropping it could join
+ * two tokens: between identifier characters, "+ +"/"- -", next to a '/',
+ * and a digit before '.'.  String and regex literals are copied verbatim;
+ * a template literal is refused because `${}` nesting is not tracked (the
+ * prelude has none). */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static const char *src;
+static long len, pos;
+static int line = 1;
+
+static int ident(char c)
+{
+	return c == '_' || c == '$' || (unsigned char)c >= 0x80 ||
+	       (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') ||
+	       (c >= 'A' && c <= 'Z');
+}
+
+static int need_space(char a, char b)
+{
+	return (ident(a) && ident(b)) || ((a == '+' || a == '-') && a == b) ||
+	       a == '/' || b == '/' || (b == '.' && a >= '0' && a <= '9');
+}
+
+static void die(const char *msg)
+{
+	fprintf(stderr, "jsstrip: line %d: %s\n", line, msg);
+	exit(1);
+}
+
+/* A '/' starts a regex unless the previous significant token can end an
+ * expression (identifier, number, ')' or ']'); "return /x/" etc. is
+ * handled by the keyword check. */
+static int regex_allowed(const char *out, long n)
+{
+	long i = n, j;
+
+	while (i > 0 && (out[i - 1] == ' ' || out[i - 1] == '\n'))
+		i--;
+	if (i == 0)
+		return 1;
+	if (out[i - 1] == ')' || out[i - 1] == ']')
+		return 0;
+	j = i;
+	while (j > 0 && (out[j - 1] == '_' || out[j - 1] == '$' ||
+			 (out[j - 1] >= '0' && out[j - 1] <= '9') ||
+			 (out[j - 1] >= 'a' && out[j - 1] <= 'z') ||
+			 (out[j - 1] >= 'A' && out[j - 1] <= 'Z')))
+		j--;
+	if (j == i)
+		return 1;	/* punctuation */
+	return (i - j == 6 && !memcmp(out + j, "return", 6)) ||
+	       (i - j == 6 && !memcmp(out + j, "typeof", 6)) ||
+	       (i - j == 4 && !memcmp(out + j, "case", 4)) ||
+	       (i - j == 2 && !memcmp(out + j, "in", 2));
+}
+
+int main(int argc, char **argv)
+{
+	FILE *f;
+	char *out;
+	long n = 0;
+	int bol = 1;	/* at the beginning of an output line */
+	int gap = 0;	/* blanks or a comment since the last output char */
+
+	if (argc != 3) {
+		fprintf(stderr, "usage: jsstrip in.js out.js\n");
+		return 2;
+	}
+	f = fopen(argv[1], "rb");
+	if (!f || fseek(f, 0, SEEK_END) || (len = ftell(f)) < 0)
+		die("cannot read input");
+	rewind(f);
+	src = malloc(len + 1);
+	out = malloc(len + 1);
+	if (!src || !out || fread((char *)src, 1, len, f) != (size_t)len)
+		die("cannot read input");
+	fclose(f);
+
+	while (pos < len) {
+		char c = src[pos];
+
+		if (c == '\n') {
+			line++;
+			pos++;
+			/* drop empty lines */
+			if (!bol)
+				out[n++] = '\n';
+			bol = 1;
+			gap = 0;
+			continue;
+		}
+		if (c == ' ' || c == '\t' || c == '\r') {
+			pos++;
+			gap = 1;
+			continue;
+		}
+		if (c == '/' && pos + 1 < len && src[pos + 1] == '/') {
+			while (pos < len && src[pos] != '\n')
+				pos++;
+			continue;
+		}
+		if (c == '/' && pos + 1 < len && src[pos + 1] == '*') {
+			pos += 2;
+			while (pos + 1 < len &&
+			       !(src[pos] == '*' && src[pos + 1] == '/')) {
+				/* keep a newline a multi-line comment spanned, so
+				 * a comment cannot join two statements */
+				if (src[pos] == '\n') {
+					line++;
+					if (!bol) {
+						out[n++] = '\n';
+						bol = 1;
+					}
+				}
+				pos++;
+			}
+			if (pos + 1 >= len)
+				die("unterminated comment");
+			pos += 2;
+			gap = 1;
+			continue;
+		}
+		if (c == '`')
+			die("template literals are not supported");
+		if (gap && !bol && need_space(out[n - 1], c))
+			out[n++] = ' ';
+		gap = 0;
+		bol = 0;
+		if (c == '"' || c == '\'' ||
+		    (c == '/' && regex_allowed(out, n))) {
+			char q = c, d;
+			int cclass = 0;	/* inside a regex [...] a '/' is literal */
+
+			out[n++] = src[pos++];
+			for (;;) {
+				if (pos >= len || src[pos] == '\n')
+					die("unterminated string or regex");
+				d = src[pos];
+				out[n++] = src[pos++];
+				if (d == '\\') {
+					if (pos >= len)
+						die("unterminated literal");
+					out[n++] = src[pos++];
+				} else if (q == '/' && d == '[') {
+					cclass = 1;
+				} else if (q == '/' && d == ']') {
+					cclass = 0;
+				} else if (d == q && !cclass) {
+					break;
+				}
+			}
+			continue;
+		}
+		out[n++] = src[pos++];
+	}
+	while (n > 0 && out[n - 1] == '\n')
+		n--;
+	out[n++] = '\n';
+
+	f = fopen(argv[2], "wb");
+	if (!f || fwrite(out, 1, n, f) != (size_t)n || fclose(f))
+		die("cannot write output");
+	return 0;
+}

+ 3 - 2
user/apps/browser/js_prelude.S

@@ -1,8 +1,9 @@
 /* Embeds js_prelude.js (the browser's Web API layer) as a NUL-terminated
- * string for js_browser.c. */
+ * string for js_browser.c.  The build strips its comments and indentation
+ * first (tools/jsstrip.c -> build/user/apps/browser/js_prelude.min.js). */
 	.section .rodata
 	.globl js_prelude_source
 js_prelude_source:
-	.incbin "js_prelude.js"
+	.incbin "js_prelude.min.js"
 	.byte 0
 	.section .note.GNU-stack,"",@progbits

+ 489 - 0
user/apps/browser/js_prelude.js

@@ -1228,7 +1228,46 @@ Object.defineProperty(nodeproto, "content", { configurable: true,
 function toNode(n) {
 	return typeof n === "object" && n !== null ? n : doc.createTextNode(String(n));
 }
+/* Constraint validation (no UI: reportValidity only answers): required,
+ * min/maxlength, pattern, email/url syntax, number min/max and
+ * setCustomValidity().  A form is valid when all its controls are. */
+function validity(e) {
+	var t = String(e.type || "").toLowerCase(), v = String(e.value || ""),
+	    a = function (n) { return e.getAttribute(n); }, r = {}, p;
+	if (e.disabled || /^(hidden|submit|button|reset|image)$/.test(t)) {
+		r.valid = true;
+		return r;
+	}
+	r.customError = !!e.__nb_cv;
+	r.valueMissing = e.hasAttribute("required") &&
+		(/^(checkbox|radio)$/.test(t) ? !e.checked : v === "");
+	if (v) {
+		r.tooShort = v.length < +(a("minlength") || 0);
+		r.tooLong = a("maxlength") !== null && v.length > +a("maxlength");
+		p = a("pattern");
+		try { r.patternMismatch = p !== null && !new RegExp("^(?:" + p + ")$").test(v); } catch (x) {}
+		r.typeMismatch = t === "email" ? !/^[^\s@]+@[^\s@]+$/.test(v) :
+			t === "url" && !/^[a-z][\w+.-]*:/i.test(v);
+		r.rangeUnderflow = t === "number" && a("min") !== null && +v < +a("min");
+		r.rangeOverflow = t === "number" && a("max") !== null && +v > +a("max");
+	}
+	r.valid = !Object.keys(r).some(function (k) { return r[k]; });
+	return r;
+}
+function checkValidity() {
+	var l = /^form$/i.test(this.tagName) ?
+		this.querySelectorAll("input,select,textarea") : [this], i;
+	for (i = 0; i < l.length; i++)
+		if (!validity(l[i]).valid) return false;
+	return true;
+}
+Object.defineProperty(nodeproto, "validity", { configurable: true,
+	get: function () { return validity(this); } });
 Object.assign(nodeproto, {
+	checkValidity: checkValidity,
+	reportValidity: checkValidity,
+	setCustomValidity: function (m) { this.__nb_cv = String(m); },
+
 	setAttributeNS: function (ns, n, v) {
 		this.setAttribute(String(n).replace(/^[^:]*:/, ""), v);
 	},
@@ -1662,6 +1701,456 @@ class PerformanceObserver {
 PerformanceObserver.supportedEntryTypes = [];
 def("PerformanceObserver", PerformanceObserver);
 
+/* ---- Intl: QuickJS has none.  A small en-US-only subset; every locale
+ * argument is accepted and ignored, and dates are formatted in UTC (the
+ * libc's only zone, so Date's local getters agree). ---- */
+(function () {
+var MON = "January February March April May June July August September October November December".split(" "),
+	DAY = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" ");
+function opt(o) { return o == null ? {} : Object(o); }
+function ctor(f, p) {
+	f.prototype = p;
+	f.supportedLocalesOf = function (l) {
+		return [].concat(l === undefined ? [] : l).map(String);
+	};
+	return f;
+}
+function parts2s(p) { return p.map(function (x) { return x.value; }).join(""); }
+function pad2(n) { return (n < 10 ? "0" : "") + n; }
+
+var CUR = { USD: "$", EUR: "€", GBP: "£", JPY: "¥", INR: "₹" };
+var UNIT = { byte: "byte", kilobyte: "kB", megabyte: "MB", gigabyte: "GB",
+	terabyte: "TB", petabyte: "PB", bit: "bit", kilobit: "kb",
+	megabit: "Mb", gigabit: "Gb", millisecond: "ms", second: "sec",
+	minute: "min", hour: "hr", day: "day", week: "wk", month: "mth",
+	year: "yr", percent: "%", meter: "m", kilometer: "km",
+	celsius: "°C" };
+function NumberFormat(l, o) {
+	if (!(this instanceof NumberFormat)) return new NumberFormat(l, o);
+	o = opt(o);
+	var st = o.style || "decimal", cur = st === "currency" ?
+		String(o.currency).toUpperCase() : undefined,
+	    dmin = cur ? (cur === "JPY" ? 0 : 2) : 0,
+	    dmax = cur ? dmin : st === "percent" ? 0 : 3,
+	    mn = o.minimumFractionDigits, mx = o.maximumFractionDigits;
+	if (mn === undefined) mn = mx === undefined ? dmin : Math.min(dmin, mx);
+	if (mx === undefined) mx = Math.max(mn, dmax);
+	this.o = { locale: "en-US", numberingSystem: "latn", style: st,
+		currency: cur, currencyDisplay: o.currencyDisplay || "symbol",
+		unit: o.unit, unitDisplay: o.unitDisplay || "short",
+		minimumIntegerDigits: o.minimumIntegerDigits || 1,
+		minimumFractionDigits: +mn, maximumFractionDigits: +mx,
+		maximumSignificantDigits: o.maximumSignificantDigits,
+		useGrouping: o.useGrouping === undefined ? "auto" : o.useGrouping,
+		notation: o.notation || "standard",
+		signDisplay: o.signDisplay || "auto" };
+}
+ctor(NumberFormat, {
+	formatToParts: function (x) {
+		var o = this.o, p = [], v = Number(x), neg = v < 0 ||
+			Object.is(v, -0), sfx = "", s, i, k;
+		function add(t, s) { if (s) p.push({ type: t, value: s }); }
+		if (isNaN(v)) return [{ type: "nan", value: "NaN" }];
+		v = Math.abs(v);
+		if (o.style === "percent") v *= 100;
+		function rnd(v) {
+			var sig = o.maximumSignificantDigits ||
+				(o.notation === "compact" && v < 99.5 ? 2 : 0), f, s;
+			if (sig) v = +v.toPrecision(sig);
+			f = sig ? Math.max(0, sig - 1 - Math.floor(Math.log10(v || 1))) :
+				o.notation === "compact" ? 0 : o.maximumFractionDigits;
+			s = v.toFixed(Math.min(f, 20));
+			while (/\.\d*0$/.test(s) && s.length - s.indexOf(".") - 1 >
+			       (sig ? 0 : o.minimumFractionDigits))
+				s = s.slice(0, -1);
+			return s.replace(/\.$/, "");
+		}
+		if (!isFinite(v)) s = "\u221e";
+		else if (o.notation === "compact") {
+			for (k = 0; k < 4 && +rnd(v / Math.pow(1000, k)) >= 1000; k++);
+			s = rnd(v / Math.pow(1000, k));
+			sfx = k ? "KMBT"[k - 1] : "";
+		} else s = rnd(v);
+		i = s.split(".");
+		while (i[0].length < o.minimumIntegerDigits) i[0] = "0" + i[0];
+		var sd = o.signDisplay, zero = +s === 0 || s === "0";
+		if (sd === "never" || (sd === "exceptZero" || sd === "negative") && zero)
+			neg = false;
+		add(neg ? "minusSign" : "plusSign", neg ? "-" :
+			sd === "always" || sd === "exceptZero" && !zero ? "+" : "");
+		if (o.currency) {
+			var sym = o.currencyDisplay === "code" ? o.currency + " " :
+				CUR[o.currency] || o.currency + " ";
+			add("currency", sym);
+		}
+		if (o.useGrouping !== false && !/^∞/.test(s) &&
+			(o.useGrouping !== "min2" || i[0].length > 4))
+			i[0].split(/(?=(?:\d{3})+$)/).forEach(function (d, n) {
+				if (n) add("group", ",");
+				add("integer", d);
+			});
+		else add(isFinite(v) ? "integer" : "infinity", i[0]);
+		if (i[1]) { add("decimal", "."); add("fraction", i[1]); }
+		add("compact", sfx);
+		if (o.style === "percent") add("percentSign", "%");
+		if (o.style === "unit") {
+			var u = o.unit, d = o.unitDisplay, w = UNIT[u] || u;
+			if (d === "long") w = " " + u + (+s === 1 ? "" : "s");
+			else w = (d === "narrow" ? "" : " ") + w +
+				(u === "day" && +s !== 1 && d !== "narrow" ? "s" : "");
+			add("unit", w);
+		}
+		return p;
+	},
+	resolvedOptions: function () { return Object.assign({}, this.o); }
+});
+Object.defineProperty(NumberFormat.prototype, "format", { get: function () {
+	var self = this;
+	return function (x) { return parts2s(self.formatToParts(x)); };
+} });
+
+var DFIELDS = ["weekday", "year", "month", "day"],
+	TFIELDS = ["dayPeriod", "hour", "minute", "second",
+		   "fractionalSecondDigits"];
+var DSTY = { full: { weekday: "long", month: "long", day: "numeric",
+		     year: "numeric" },
+	     long: { month: "long", day: "numeric", year: "numeric" },
+	     medium: { month: "short", day: "numeric", year: "numeric" },
+	     short: { month: "numeric", day: "numeric", year: "2-digit" } };
+function has(o, l) { return l.some(function (k) { return o[k] !== undefined; }); }
+/* need/def: "date"/"time"/"any", "date"/"time"/"all" (ECMA-402
+ * ToDateTimeOptions). */
+function dtopts(o, need, def) {
+	var r = {}, k;
+	o = opt(o);
+	for (k in o) r[k] = o[k];
+	if (o.dateStyle || o.timeStyle) {
+		if (o.dateStyle) Object.assign(r, DSTY[o.dateStyle]);
+		if (o.timeStyle) {
+			r.hour = "numeric"; r.minute = "2-digit";
+			if (o.timeStyle !== "short") r.second = "2-digit";
+			if (/full|long/.test(o.timeStyle)) r.timeZoneName = "short";
+		}
+	} else if (!(need !== "time" && has(o, DFIELDS) ||
+		     need !== "date" && has(o, TFIELDS))) {
+		if (def !== "time") r.year = r.month = r.day = "numeric";
+		if (def !== "date") r.hour = r.minute = r.second = "numeric";
+	}
+	r.locale = "en-US"; r.calendar = "gregory"; r.numberingSystem = "latn";
+	r.timeZone = "UTC";
+	if (r.hour) {
+		r.hour12 = o.hour12 !== undefined ? !!o.hour12 :
+			!/h2[34]/.test(o.hourCycle);
+		r.hourCycle = r.hour12 ? "h12" : "h23";
+	}
+	return r;
+}
+function DateTimeFormat(l, o) {
+	if (!(this instanceof DateTimeFormat)) return new DateTimeFormat(l, o);
+	this.o = this.o || dtopts(o, "any", "date");
+}
+function dtparts(o, d) {
+	var p = [], t = new Date(+d), h, m, n, txt;
+	function add(ty, v) { p.push({ type: ty, value: String(v) }); }
+	function lit(v) { add("literal", v); }
+	if (isNaN(t)) throw new RangeError("Invalid time value");
+	m = t.getUTCMonth(); n = t.getUTCFullYear();
+	function yr() { add("year", o.year === "2-digit" ? pad2(n % 100) : n); }
+	function dy() { add("day", o.day === "2-digit" ? pad2(t.getUTCDate()) : t.getUTCDate()); }
+	if (o.weekday) {
+		txt = DAY[t.getUTCDay()];
+		add("weekday", o.weekday === "long" ? txt : o.weekday === "narrow" ? txt[0] : txt.slice(0, 3));
+		if (o.month || o.day || o.year) lit(", ");
+	}
+	if (/^(long|short|narrow)$/.test(o.month)) {
+		txt = MON[m];
+		add("month", o.month === "long" ? txt : o.month === "narrow" ? txt[0] : txt.slice(0, 3));
+		if (o.day) { lit(" "); dy(); }
+		if (o.year) { lit(o.day ? ", " : " "); yr(); }
+	} else {
+		[["month", o.month], ["day", o.day], ["year", o.year]].forEach(function (f) {
+			if (!f[1]) return;
+			if (p.length && p[p.length - 1].type !== "literal") lit("/");
+			if (f[0] === "month") add("month", f[1] === "2-digit" ? pad2(m + 1) : m + 1);
+			else if (f[0] === "day") dy();
+			else yr();
+		});
+	}
+	if (o.hour || o.minute || o.second) {
+		if (p.length) lit(o.dateStyle && /full|long/.test(o.dateStyle) && o.timeStyle ? " at " : ", ");
+		h = t.getUTCHours();
+		if (o.hour) {
+			n = o.hour12 ? h % 12 || 12 : h;
+			add("hour", o.hour === "2-digit" || !o.hour12 ? pad2(n) : n);
+		}
+		if (o.minute) {
+			if (o.hour) lit(":");
+			add("minute", o.hour || o.minute === "2-digit" ? pad2(t.getUTCMinutes()) : t.getUTCMinutes());
+		}
+		if (o.second) {
+			if (o.hour || o.minute) lit(":");
+			add("second", o.hour || o.minute || o.second === "2-digit" ? pad2(t.getUTCSeconds()) : t.getUTCSeconds());
+		}
+		if (o.fractionalSecondDigits) {
+			lit(".");
+			add("fractionalSecond", String(1000 + t.getUTCMilliseconds()).slice(1, 1 + o.fractionalSecondDigits));
+		}
+		if (o.hour && o.hour12) { lit(" "); add("dayPeriod", h < 12 ? "AM" : "PM"); }
+	}
+	if (o.timeZoneName) { lit(" "); add("timeZoneName", "UTC"); }
+	return p;
+}
+ctor(DateTimeFormat, {
+	formatToParts: function (d) {
+		return dtparts(this.o, d === undefined ? Date.now() : d);
+	},
+	formatRange: function (a, b) {
+		return this.format(a) + " – " + this.format(b);
+	},
+	resolvedOptions: function () { return Object.assign({}, this.o); }
+});
+Object.defineProperty(DateTimeFormat.prototype, "format", { get: function () {
+	var self = this;
+	return function (d) { return parts2s(self.formatToParts(d)); };
+} });
+function dtf(need, def) {
+	return function (l, o) {
+		if (isNaN(this)) return "Invalid Date";
+		var f = Object.create(DateTimeFormat.prototype);
+		f.o = dtopts(o, need, def);
+		return f.format(this);
+	};
+}
+Date.prototype.toLocaleString = dtf("any", "all");
+Date.prototype.toLocaleDateString = dtf("date", "date");
+Date.prototype.toLocaleTimeString = dtf("time", "time");
+Number.prototype.toLocaleString = function (l, o) {
+	return NumberFormat(l, o).format(this);
+};
+
+var RTU = { second: "sec.", minute: "min.", hour: "hr.", day: "day",
+	week: "wk.", month: "mo.", quarter: "qtr.", year: "yr." };
+function RelativeTimeFormat(l, o) {
+	o = opt(o);
+	this.o = { locale: "en-US", numberingSystem: "latn",
+		style: o.style || "long", numeric: o.numeric || "always" };
+}
+ctor(RelativeTimeFormat, {
+	format: function (v, u) {
+		v = Number(v);
+		u = String(u).replace(/s$/, "");
+		if (!RTU[u]) throw new RangeError("Invalid unit: " + u);
+		if (this.o.numeric === "auto" && (v === 0 || Math.abs(v) === 1 &&
+						 u !== "second" && u !== "minute" && u !== "hour")) {
+			if (u === "second") return "now";
+			if (u === "day") return v ? v < 0 ? "yesterday" : "tomorrow" : "today";
+			return (v ? v < 0 ? "last " : "next " : "this ") + u;
+		}
+		var a = Math.abs(v), w = this.o.style === "long" || u === "day" ?
+			u + (a === 1 ? "" : "s") : u === "quarter" && a !== 1 ?
+			"qtrs." : RTU[u],
+		    s = NumberFormat().format(a) + " " + w;
+		return v < 0 || Object.is(v, -0) ? s + " ago" : "in " + s;
+	},
+	formatToParts: function (v, u) {
+		return [{ type: "literal", value: this.format(v, u) }];
+	},
+	resolvedOptions: function () { return Object.assign({}, this.o); }
+});
+
+var DUR = [["years", "yr", "y"], ["months", "mth", "mo"], ["weeks", "wk", "w"],
+	   ["days", "day", "d"], ["hours", "hr", "h"], ["minutes", "min", "m"],
+	   ["seconds", "sec", "s"], ["milliseconds", "ms", "ms"],
+	   ["microseconds", "μs", "μs"],
+	   ["nanoseconds", "ns", "ns"]];
+function DurationFormat(l, o) {
+	o = opt(o);
+	this.o = { locale: "en-US", numberingSystem: "latn",
+		style: o.style || "short" };
+}
+ctor(DurationFormat, {
+	format: function (d) {
+		var st = this.o.style, out = [];
+		d = opt(d);
+		if (st === "digital") {
+			var hms = [d.hours || 0, pad2(d.minutes || 0), pad2(d.seconds || 0)].join(":");
+			out = DUR.slice(0, 4).filter(function (u) { return d[u[0]]; })
+				.map(function (u) { return d[u[0]] + " " + u[0].slice(0, d[u[0]] === 1 ? -1 : undefined); });
+			out.push(hms);
+			return out.join(", ");
+		}
+		DUR.forEach(function (u) {
+			var v = d[u[0]];
+			if (!v) return;
+			out.push(st === "narrow" ? v + u[2] : v + " " +
+				(st === "long" ? u[0].slice(0, Math.abs(v) === 1 ? -1 : undefined) :
+				 u[1] + (u[1] === "day" && v !== 1 ? "s" : "")));
+		});
+		return out.join(st === "narrow" ? " " : ", ");
+	},
+	resolvedOptions: function () { return Object.assign({}, this.o); }
+});
+
+var LANG = { en: "English", de: "German", fr: "French", es: "Spanish",
+	it: "Italian", nl: "Dutch", pt: "Portuguese", ru: "Russian",
+	zh: "Chinese", ja: "Japanese", ko: "Korean", pl: "Polish",
+	tr: "Turkish", cs: "Czech", da: "Danish", sv: "Swedish",
+	fi: "Finnish", nb: "Norwegian Bokmål", no: "Norwegian",
+	uk: "Ukrainian", hu: "Hungarian", el: "Greek", ro: "Romanian",
+	vi: "Vietnamese", id: "Indonesian", ar: "Arabic", he: "Hebrew",
+	hi: "Hindi", fa: "Persian", sk: "Slovak", bg: "Bulgarian",
+	hr: "Croatian", sr: "Serbian", sl: "Slovenian", et: "Estonian",
+	lv: "Latvian", lt: "Lithuanian", ca: "Catalan", gl: "Galician",
+	eu: "Basque", th: "Thai", ms: "Malay", ta: "Tamil", bn: "Bangla",
+	"en-US": "American English", "en-GB": "British English",
+	"pt-BR": "Brazilian Portuguese", "pt-PT": "European Portuguese",
+	"es-MX": "Mexican Spanish", "fr-CA": "Canadian French" };
+var REG = { US: "United States", GB: "United Kingdom", DE: "Germany",
+	FR: "France", ES: "Spain", IT: "Italy", NL: "Netherlands",
+	BR: "Brazil", PT: "Portugal", CN: "China", TW: "Taiwan",
+	JP: "Japan", IN: "India", CA: "Canada", AU: "Australia",
+	AT: "Austria", CH: "Switzerland", RU: "Russia" };
+function DisplayNames(l, o) {
+	o = opt(o);
+	this.o = { locale: "en-US", style: o.style || "long",
+		type: o.type, fallback: o.fallback || "code" };
+}
+ctor(DisplayNames, {
+	of: function (c) {
+		c = String(c);
+		var t = this.o.type, s = c.split(/[-_]/), r;
+		if (t === "region") r = REG[c.toUpperCase()];
+		else if (t === "language") {
+			r = LANG[s[0].toLowerCase() + "-" + s[1]] || LANG[s[0].toLowerCase()];
+			if (r && s[1] && !LANG[s[0].toLowerCase() + "-" + s[1]]) r = REG[s[1].toUpperCase()] ?
+				r + " (" + REG[s[1].toUpperCase()] + ")" : r + " (" + s[1] + ")";
+		}
+		return r || (this.o.fallback === "none" ? undefined : c);
+	},
+	resolvedOptions: function () { return Object.assign({}, this.o); }
+});
+
+/* Collation: case- and accent-blind first (ICU's primary strength), then
+ * accents, then lower before upper; digit runs compare by value when
+ * numeric is set. */
+function fold(s) {
+	return /^[\x00-\x7f]*$/.test(s) ? s : s.normalize("NFD").replace(/[̀-ͯ]/g, "");
+}
+/* Code-point order within a class; ICU's classes order whitespace,
+ * punctuation/symbols, digits, letters. */
+function cls(c) {
+	return c <= 32 ? 0 : c >= 48 && c <= 57 ? 2 : c >= 65 && c <= 90 ||
+		c >= 97 && c <= 122 || c > 127 ? 3 : 1;
+}
+function cmp(a, b, num) {
+	var i = 0, j = 0, x, y, m, n;
+	while (i < a.length && j < b.length) {
+		x = a.charCodeAt(i); y = b.charCodeAt(j);
+		if (num && cls(x) === 2 && cls(y) === 2) {
+			m = /^0*(\d*)/.exec(a.slice(i).match(/^\d+/)[0])[1];
+			n = /^0*(\d*)/.exec(b.slice(j).match(/^\d+/)[0])[1];
+			if (m.length !== n.length) return m.length < n.length ? -1 : 1;
+			if (m !== n) return m < n ? -1 : 1;
+			i += a.slice(i).match(/^\d+/)[0].length;
+			j += b.slice(j).match(/^\d+/)[0].length;
+			continue;
+		}
+		if (x !== y) return cls(x) - cls(y) || (x < y ? -1 : 1);
+		i++; j++;
+	}
+	return i < a.length ? 1 : j < b.length ? -1 : 0;
+}
+function Collator(l, o) {
+	if (!(this instanceof Collator)) return new Collator(l, o);
+	o = opt(o);
+	var r = this.o = { locale: "en-US", usage: o.usage || "sort",
+		sensitivity: o.sensitivity || "variant",
+		ignorePunctuation: !!o.ignorePunctuation,
+		numeric: !!o.numeric, caseFirst: o.caseFirst || "false",
+		collation: "default" };
+	this.compare = function (a, b) {
+		a = String(a); b = String(b);
+		if (r.ignorePunctuation) {
+			a = a.replace(/[\s!-/:-@[-`{-~]/g, "");
+			b = b.replace(/[\s!-/:-@[-`{-~]/g, "");
+		}
+		var fa = fold(a), fb = fold(b),
+		    c = cmp(fa.toLowerCase(), fb.toLowerCase(), r.numeric);
+		if (c || r.sensitivity === "base") return c;
+		if (r.sensitivity !== "case" && (c = cmp(a.toLowerCase(), b.toLowerCase(), r.numeric)))
+			return c;
+		if (r.sensitivity === "accent") return 0;
+		c = -cmp(r.sensitivity === "case" ? fa : a, r.sensitivity === "case" ? fb : b, r.numeric);
+		return r.caseFirst === "upper" ? -c : c;
+	};
+}
+ctor(Collator, {
+	resolvedOptions: function () { return Object.assign({}, this.o); }
+});
+var coll0 = new Collator();
+String.prototype.localeCompare = function (t, l, o) {
+	return (o ? new Collator(l, o) : coll0).compare(this, t);
+};
+
+function PluralRules(l, o) {
+	o = opt(o);
+	this.o = { locale: "en-US", type: o.type || "cardinal",
+		pluralCategories: o.type === "ordinal" ?
+			["few", "one", "two", "other"] : ["one", "other"] };
+}
+ctor(PluralRules, {
+	select: function (n) {
+		n = Math.abs(Number(n));
+		if (this.o.type !== "ordinal") return n === 1 ? "one" : "other";
+		var a = n % 10, b = n % 100;
+		return a === 1 && b !== 11 ? "one" : a === 2 && b !== 12 ? "two" :
+			a === 3 && b !== 13 ? "few" : "other";
+	},
+	resolvedOptions: function () { return Object.assign({}, this.o); }
+});
+
+function ListFormat(l, o) {
+	o = opt(o);
+	this.o = { locale: "en-US", type: o.type || "conjunction",
+		style: o.style || "long" };
+}
+ctor(ListFormat, {
+	format: function (l) {
+		var a = Array.from(l || [], String), t = this.o.type,
+		    w = t === "disjunction" ? " or " : t === "unit" ? ", " :
+			this.o.style === "long" ? " and " : this.o.style === "short" ? " & " : ", ";
+		if (t === "unit" && this.o.style === "narrow") return a.join(" ");
+		if (a.length < 3) return a.join(w);
+		return a.slice(0, -1).join(", ") + (t === "unit" || w === ", " ?
+			", " : "," + w) + a[a.length - 1];
+	},
+	resolvedOptions: function () { return Object.assign({}, this.o); }
+});
+
+function Locale(t) {
+	var s = String(t).split(/[-_]/);
+	this.baseName = String(t).replace(/_/g, "-");
+	this.language = s[0].toLowerCase();
+	this.region = s.length > 1 && /^[A-Za-z]{2}$|^\d{3}$/.test(s[s.length - 1]) ?
+		s[s.length - 1].toUpperCase() : undefined;
+}
+Locale.prototype.toString = function () { return this.baseName; };
+Locale.prototype.maximize = Locale.prototype.minimize = function () { return this; };
+
+def("Intl", Object.defineProperty({
+	DateTimeFormat: DateTimeFormat, NumberFormat: NumberFormat,
+	RelativeTimeFormat: RelativeTimeFormat, DurationFormat: DurationFormat,
+	DisplayNames: DisplayNames, Collator: Collator,
+	PluralRules: PluralRules, ListFormat: ListFormat, Locale: Locale,
+	getCanonicalLocales: function (l) {
+		return [].concat(l === undefined ? [] : l).map(String);
+	},
+	supportedValuesOf: function (k) {
+		return k === "timeZone" ? ["UTC"] : k === "calendar" ? ["gregory"] : [];
+	}
+}, Symbol.toStringTag, { value: "Intl", configurable: true }));
+})();
+
 /* ---- CSS namespace ----
  * escape() is the CSSOM serialization of an identifier; supports() gives
  * the cascade's own @supports answer (true unless it asks for selector()),

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio