@modelform/react-native 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -382,8 +382,8 @@ function interpolate(text, ctx) {
382
382
  const builtins = builtinValues(ctx);
383
383
  return text.replace(
384
384
  /\$(\w+)|\$\{(\w+)(?::(\w+))?\}|\[\[(\w+)(?::(\w+))?\]\]/g,
385
- (match, plain, braced, bracedFmt, old, oldFmt) => {
386
- const name = _nullishCoalesce(_nullishCoalesce(plain, () => ( braced)), () => ( old));
385
+ (match, plain2, braced, bracedFmt, old, oldFmt) => {
386
+ const name = _nullishCoalesce(_nullishCoalesce(plain2, () => ( braced)), () => ( old));
387
387
  const format3 = _nullishCoalesce(bracedFmt, () => ( oldFmt));
388
388
  const scoped = _optionalChain([ctx, 'access', _30 => _30.scoped, 'optionalAccess', _31 => _31[name]]);
389
389
  const value = scoped ? scoped.value : ctx.values[name];
@@ -1694,7 +1694,10 @@ function parseSpokenDuration(text) {
1694
1694
  return clock[1] != null ? h * 3600 + m * 60 + s + Number(`0.${f}`) : m * 60 + s + Number(`0.${f}`);
1695
1695
  }
1696
1696
  }
1697
- const lower = text.toLowerCase().replace(/\ban hour\b/g, "one hour").replace(/\ba minute\b/g, "one minute").replace(/(\S+) (hours?|minutes?) and a half/g, "$1 and a half $2");
1697
+ const lower = text.toLowerCase().replace(
1698
+ /\b(?:(?:a|one|three) )?(half|quarters?)(?: of)? an? (hour|minute)\b/g,
1699
+ (m, part, unit) => `${part === "half" ? 0.5 : m.startsWith("three") ? 0.75 : 0.25} ${unit}`
1700
+ ).replace(/\ban hour\b/g, "one hour").replace(/\ba minute\b/g, "one minute").replace(/(\S+) (hours?|minutes?) and a half/g, "$1 and a half $2");
1698
1701
  const parts = lower.split(/\b(hours?|hrs?|minutes?|mins?|seconds?|secs?)\b/);
1699
1702
  const scale = (unit) => unit.startsWith("h") ? 3600 : unit.startsWith("m") ? 60 : 1;
1700
1703
  let total = 0;
@@ -1807,6 +1810,533 @@ function dictationHints(panel, choices2) {
1807
1810
  return out;
1808
1811
  }
1809
1812
 
1813
+ // src/core/formFill.ts
1814
+ var choicesOf = (p, runtime) => _nullishCoalesce((p.options.choicesFrom ? runtime[p.options.choicesFrom] : p.options.choices), () => ( []));
1815
+ function fillForm(dashboard, choices2 = {}) {
1816
+ const fields = [];
1817
+ const panels = {};
1818
+ for (const p of plainInputPanels(dashboard)) {
1819
+ const o = p.options;
1820
+ if (p.type === "input-counter" || panels[o.metric]) continue;
1821
+ const base = { key: o.metric, label: p.title || o.metric };
1822
+ let field2;
1823
+ switch (p.type) {
1824
+ case "input-number":
1825
+ field2 = { ...base, type: "number", unit: o.unit, min: o.min, max: o.max };
1826
+ break;
1827
+ case "input-rating":
1828
+ field2 = { ...base, type: "number", min: Math.round(_nullishCoalesce(o.min, () => ( 1))), max: Math.round(_nullishCoalesce(o.max, () => ( 5))) };
1829
+ break;
1830
+ case "input-slider":
1831
+ field2 = { ...base, type: "number", unit: o.unit, min: _nullishCoalesce(o.min, () => ( 0)), max: _nullishCoalesce(o.max, () => ( 10)), choices: _optionalChain([o, 'access', _156 => _156.labels, 'optionalAccess', _157 => _157.length]) ? o.labels : void 0 };
1832
+ break;
1833
+ case "input-duration":
1834
+ field2 = { ...base, type: "duration" };
1835
+ break;
1836
+ case "input-select": {
1837
+ const labels = choicesOf(p, choices2).map((c) => c.label);
1838
+ if (!labels.length) continue;
1839
+ field2 = { ...base, type: o.multi ? "choices" : "choice", choices: labels };
1840
+ break;
1841
+ }
1842
+ case "input-toggle":
1843
+ field2 = { ...base, type: "boolean" };
1844
+ break;
1845
+ case "input-text":
1846
+ field2 = { ...base, type: "text" };
1847
+ break;
1848
+ default:
1849
+ continue;
1850
+ }
1851
+ fields.push(Object.fromEntries(Object.entries(field2).filter(([, v]) => v !== void 0)));
1852
+ panels[o.metric] = p;
1853
+ }
1854
+ return { fields, panels, choices: choices2 };
1855
+ }
1856
+ function describe(f) {
1857
+ const range = f.min != null && f.max != null ? `, from ${f.min} to ${f.max}` : f.min != null ? `, ${f.min} or more` : f.max != null ? `, at most ${f.max}` : "";
1858
+ switch (f.type) {
1859
+ case "number":
1860
+ return `a number${f.unit ? ` in ${f.unit}` : ""}${range}${f.choices ? ` (${f.choices.join(" \u2026 ")} along the scale)` : ""}`;
1861
+ case "duration":
1862
+ return "a duration in seconds";
1863
+ case "choice":
1864
+ return `one of: ${f.choices.map((c) => JSON.stringify(c)).join(", ")}`;
1865
+ case "choices":
1866
+ return `a list of any of: ${f.choices.map((c) => JSON.stringify(c)).join(", ")}`;
1867
+ case "boolean":
1868
+ return "true or false";
1869
+ case "text":
1870
+ return "text, in the user\u2019s words";
1871
+ }
1872
+ }
1873
+ function fillSchema(form) {
1874
+ const properties = {};
1875
+ for (const f of form.fields) {
1876
+ const description = `${f.label}: ${describe(f)}`;
1877
+ switch (f.type) {
1878
+ case "number":
1879
+ case "duration":
1880
+ properties[f.key] = { type: "number", description, ...f.min != null && { minimum: f.min }, ...f.max != null && { maximum: f.max } };
1881
+ break;
1882
+ case "choice":
1883
+ properties[f.key] = { type: "string", enum: f.choices, description };
1884
+ break;
1885
+ case "choices":
1886
+ properties[f.key] = { type: "array", items: { type: "string", enum: f.choices }, description };
1887
+ break;
1888
+ case "boolean":
1889
+ properties[f.key] = { type: "boolean", description };
1890
+ break;
1891
+ case "text":
1892
+ properties[f.key] = { type: "string", description };
1893
+ break;
1894
+ }
1895
+ }
1896
+ return { type: "object", properties, required: [], additionalProperties: false };
1897
+ }
1898
+ function fillPrompt(form, said) {
1899
+ const instructions = [
1900
+ "You fill in a form from what the user said.",
1901
+ "Reply with one JSON object and nothing else. Its keys are field keys from the list below.",
1902
+ "Only include fields the user gave a value for; leave the others out. Never guess or make up values.",
1903
+ "Numbers are plain numbers without units. Choices use the exact text listed."
1904
+ ].join(" ");
1905
+ const list = form.fields.map((f) => `- ${f.key}: ${f.label}, ${describe(f)}`).join("\n");
1906
+ const example = form.fields.find((f) => f.type === "number");
1907
+ const prompt = [
1908
+ `Fields:
1909
+ ${list}`,
1910
+ example ? `Example: if the user said "${example.label.toLowerCase()} 3" the answer is {"${example.key}": 3}` : "",
1911
+ `The user said: "${said.replace(/"/g, "'")}"`,
1912
+ "JSON:"
1913
+ ].filter(Boolean).join("\n\n");
1914
+ return { instructions, prompt };
1915
+ }
1916
+ function parseFillAnswer(answer) {
1917
+ if (answer && typeof answer === "object" && !Array.isArray(answer)) return answer;
1918
+ if (typeof answer !== "string") return null;
1919
+ const start = answer.indexOf("{");
1920
+ const end = answer.lastIndexOf("}");
1921
+ if (start < 0 || end <= start) return null;
1922
+ try {
1923
+ const v = JSON.parse(answer.slice(start, end + 1));
1924
+ return v && typeof v === "object" && !Array.isArray(v) ? v : null;
1925
+ } catch (e11) {
1926
+ return null;
1927
+ }
1928
+ }
1929
+ function asSaid(v) {
1930
+ if (v == null) return null;
1931
+ if (typeof v === "boolean") return v ? "yes" : "no";
1932
+ if (typeof v === "number") return Number.isFinite(v) ? String(v) : null;
1933
+ if (typeof v === "string") return v.trim() || null;
1934
+ if (Array.isArray(v)) return v.map(asSaid).filter(Boolean).join(", ") || null;
1935
+ return null;
1936
+ }
1937
+ function readFill(form, answer) {
1938
+ const result = { values: {}, problems: [] };
1939
+ const obj = parseFillAnswer(answer);
1940
+ if (!obj) return { values: {}, problems: [{ key: "", problem: "The answer wasn\u2019t a JSON object" }] };
1941
+ for (const f of form.fields) {
1942
+ const raw = obj[f.key];
1943
+ const panel = form.panels[f.key];
1944
+ const choices2 = choicesOf(panel, form.choices);
1945
+ if (panel.type === "input-select" && !panel.options.multi) {
1946
+ const byValue = choices2.find((c) => c.value === raw);
1947
+ if (byValue) {
1948
+ result.values[f.key] = byValue.value;
1949
+ continue;
1950
+ }
1951
+ }
1952
+ const said = asSaid(raw);
1953
+ if (said == null) continue;
1954
+ const r = spokenValue(panel, said, null, choices2);
1955
+ if ("value" in r) result.values[f.key] = r.value;
1956
+ else result.problems.push({ key: f.key, problem: r.problem });
1957
+ }
1958
+ return result;
1959
+ }
1960
+ function modelFiller(generate, fallback) {
1961
+ return async (form, said) => {
1962
+ let result = null;
1963
+ try {
1964
+ const { instructions, prompt } = fillPrompt(form, said);
1965
+ result = readFill(form, await generate(instructions, prompt, fillSchema(form)));
1966
+ if (result.problems.some((p) => p.key === "")) result = null;
1967
+ } catch (e12) {
1968
+ result = null;
1969
+ }
1970
+ if (!fallback) return _nullishCoalesce(result, () => ( { values: {}, problems: [{ key: "", problem: "The model couldn\u2019t fill the form" }] }));
1971
+ const rules = await fallback(form, said);
1972
+ if (!result) return rules;
1973
+ const values = { ...rules.values, ...result.values };
1974
+ const problems = [...result.problems, ...rules.problems.filter((p) => !(p.key in values))];
1975
+ return { values, problems };
1976
+ };
1977
+ }
1978
+ function fillHints(form) {
1979
+ const out = /* @__PURE__ */ new Set();
1980
+ for (const f of form.fields) {
1981
+ out.add(f.label);
1982
+ if (f.unit) out.add(f.unit);
1983
+ for (const c of _nullishCoalesce(f.choices, () => ( []))) out.add(c);
1984
+ }
1985
+ return [...out];
1986
+ }
1987
+
1988
+ // src/core/ruleFill.ts
1989
+ var IRREGULAR = {
1990
+ slept: "sleep",
1991
+ felt: "feel",
1992
+ ran: "run",
1993
+ swam: "swim",
1994
+ rode: "ride",
1995
+ drank: "drink",
1996
+ drunk: "drink",
1997
+ ate: "eat",
1998
+ weigh: "weight",
1999
+ weighs: "weight",
2000
+ weighed: "weight",
2001
+ weighing: "weight"
2002
+ };
2003
+ var SYNONYMS = [
2004
+ ["alcohol", "drink", "drinks", "booze"],
2005
+ ["mood", "feel", "feeling"],
2006
+ ["run", "jog"],
2007
+ ["ride", "bike", "cycle"],
2008
+ ["strength", "gym", "lift"]
2009
+ ];
2010
+ var STOP = /* @__PURE__ */ new Set(["a", "an", "the", "and", "or", "no", "not", "i", "it", "is", "was", "at", "in", "of", "to", "for", "my", "me", "on", "yes"]);
2011
+ function stem(word) {
2012
+ let w = word.toLowerCase().replace(/['’]/g, "");
2013
+ w = _nullishCoalesce(IRREGULAR[w], () => ( w));
2014
+ const cut = (suffix, add = "") => {
2015
+ if (!w.endsWith(suffix) || w.length - suffix.length < 3) return false;
2016
+ w = w.slice(0, -suffix.length) + add;
2017
+ return true;
2018
+ };
2019
+ const cutDone = cut("ations", "at") || cut("ation", "at") || cut("ing") || cut("ed");
2020
+ if (!cutDone && !w.endsWith("ss")) cut("s");
2021
+ if (cutDone && /([b-df-hj-np-tv-z])\1$/.test(w) && !/(ll|ss|ff|zz)$/.test(w)) w = w.slice(0, -1);
2022
+ if (w.length > 3 && w.endsWith("e")) w = w.slice(0, -1);
2023
+ return w;
2024
+ }
2025
+ var GLUED_UNIT = /^(\d+(?:[.,]\d+)?)(k|km|kms|kg|kgs|lb|lbs|h|hr|hrs|min|mins|s|sec|secs|mi|m)$/;
2026
+ function tokenize(said) {
2027
+ const out = [];
2028
+ const add = (text, at, end) => out.push({ text, stem: stem(text), at, end });
2029
+ for (const m of said.matchAll(/[\p{L}\p{N}]+(?:['’.,][\p{L}\p{N}]+)*/gu)) {
2030
+ const at = m.index;
2031
+ const raw = m[0].toLowerCase();
2032
+ const glued = GLUED_UNIT.exec(raw);
2033
+ if (glued) {
2034
+ add(glued[1], at, at + glued[1].length);
2035
+ add(glued[2], at + glued[1].length, at + raw.length);
2036
+ } else add(raw, at, at + raw.length);
2037
+ }
2038
+ return out;
2039
+ }
2040
+ var plain = (t) => t.text.replace(/['’]/g, "");
2041
+ var phrase = (text, label, synonym = false) => {
2042
+ const words2 = tokenize(text).map((t) => t.text);
2043
+ if (!words2.length || !label && words2.length === 1 && STOP.has(words2[0])) return null;
2044
+ return { words: words2, stems: words2.map(stem), synonym, label };
2045
+ };
2046
+ function phrasesFor(names, label = false) {
2047
+ const out = [];
2048
+ for (const name of names) {
2049
+ const p = phrase(name, label);
2050
+ if (!p) continue;
2051
+ out.push(p);
2052
+ if (p.stems.length === 1) {
2053
+ for (const group of SYNONYMS)
2054
+ if (group.some((g) => stem(g) === p.stems[0])) {
2055
+ for (const g of group) if (stem(g) !== p.stems[0]) out.push(phrase(g, label, true));
2056
+ }
2057
+ }
2058
+ }
2059
+ return out;
2060
+ }
2061
+ function findPhrases(tokens, targets) {
2062
+ const all = targets.flatMap((t) => t.phrases.map((p) => ({ ...t, p }))).sort((a, b) => b.p.stems.length - a.p.stems.length);
2063
+ const hits = [];
2064
+ for (const { key, label, p } of all)
2065
+ for (let i = 0; i + p.stems.length <= tokens.length; i++) {
2066
+ const span = tokens.slice(i, i + p.stems.length);
2067
+ if (span.some((t, n) => !t.stem || t.stem !== p.stems[n] || !p.label && STOP.has(t.text))) continue;
2068
+ const end = i + p.stems.length;
2069
+ if (hits.some((h) => i < h.end && end > h.start)) continue;
2070
+ const exact = span.every((t, n) => t.text === p.words[n]);
2071
+ hits.push({ key, label, start: i, end, kind: p.synonym ? "synonym" : exact ? "exact" : "form" });
2072
+ }
2073
+ return hits.sort((a, b) => a.start - b.start);
2074
+ }
2075
+ var namesOf = (f) => [.../* @__PURE__ */ new Set([f.label, f.key.replace(/[-_]+/g, " ")])];
2076
+ var NUMBER_WORDS = new Set(
2077
+ "zero oh nought one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty thirty forty fifty sixty seventy eighty ninety hundred thousand".split(" ")
2078
+ );
2079
+ var TIME_UNITS = {
2080
+ s: 1,
2081
+ sec: 1,
2082
+ secs: 1,
2083
+ second: 1,
2084
+ seconds: 1,
2085
+ min: 60,
2086
+ mins: 60,
2087
+ minute: 60,
2088
+ minutes: 60,
2089
+ h: 3600,
2090
+ hr: 3600,
2091
+ hrs: 3600,
2092
+ hour: 3600,
2093
+ hours: 3600
2094
+ };
2095
+ var UNIT_WORDS = {
2096
+ kg: ["kg", "kgs", "kilo", "kilos", "kilogram", "kilograms"],
2097
+ lb: ["lb", "lbs", "pound", "pounds"],
2098
+ km: ["km", "kms", "kilometer", "kilometers", "kilometre", "kilometres", "k"],
2099
+ mi: ["mi", "mile", "miles"],
2100
+ m: ["m", "meter", "meters", "metre", "metres"]
2101
+ };
2102
+ var isDigits = (t) => !!t && /^\d/.test(t.text);
2103
+ var isNumberWord2 = (t) => !!t && NUMBER_WORDS.has(t.text);
2104
+ var isTimeUnit = (t) => !!t && t.text in TIME_UNITS;
2105
+ var is = (t, ...words2) => !!t && words2.includes(t.text);
2106
+ var timeScale = (unit) => unit ? TIME_UNITS[unit.toLowerCase()] : void 0;
2107
+ var unitWords = (unit) => _nullishCoalesce(UNIT_WORDS[unit.toLowerCase()], () => ( [unit.toLowerCase()]));
2108
+ function numberStarts(tokens, i) {
2109
+ const t = tokens[i];
2110
+ const next = tokens[i + 1];
2111
+ if (isDigits(t) || isNumberWord2(t)) return true;
2112
+ if (is(t, "a", "an")) return is(next, "half", "quarter", "hundred", "thousand", "hour", "minute");
2113
+ if (is(t, "half", "quarter")) return is(next, "a", "an", "of", "hour", "minute");
2114
+ return false;
2115
+ }
2116
+ function numberAt(said, tokens, i, stop) {
2117
+ let k = i;
2118
+ let time = false;
2119
+ const numberish = (j) => {
2120
+ const t = tokens[j];
2121
+ const next = tokens[j + 1];
2122
+ if (isDigits(t) || isNumberWord2(t) || is(t, "point", "half", "quarter")) return true;
2123
+ if (is(t, "and")) return j + 1 < stop && (isDigits(next) || isNumberWord2(next) || is(next, "a"));
2124
+ if (is(t, "a", "an")) return is(next, "half", "quarter", "hundred", "thousand", "hour", "minute");
2125
+ if (is(t, "of")) return is(tokens[j - 1], "half", "quarter") && is(next, "a", "an");
2126
+ return false;
2127
+ };
2128
+ while (k < stop) {
2129
+ if (numberish(k)) k++;
2130
+ else if (isTimeUnit(tokens[k])) {
2131
+ time = true;
2132
+ k++;
2133
+ if (!(k < stop && (numberStarts(tokens, k) || is(tokens[k], "and") && numberish(k)))) break;
2134
+ } else break;
2135
+ }
2136
+ while (k > i && is(tokens[k - 1], "and", "a", "an", "of")) k--;
2137
+ if (k <= i) return null;
2138
+ const text = said.slice(tokens[i].at, tokens[k - 1].end);
2139
+ if (time) {
2140
+ const seconds = parseSpokenDuration(text);
2141
+ return seconds == null ? null : { end: k, text, seconds };
2142
+ }
2143
+ if (parseSpokenNumber(text) == null) return null;
2144
+ const unit = k < stop && !STOP.has(tokens[k].text) ? tokens[k].text : void 0;
2145
+ return { end: unit ? k + 1 : k, text, unit };
2146
+ }
2147
+ var round = (n) => Math.round(n * 1e3) / 1e3;
2148
+ function spanValue(f, span) {
2149
+ const scale = timeScale(f.unit);
2150
+ if (span.seconds != null) {
2151
+ if (f.type === "duration") return span.seconds;
2152
+ return scale ? round(span.seconds / scale) : null;
2153
+ }
2154
+ if (span.unit && f.unit && !scale && !unitWords(f.unit).includes(span.unit) && Object.values(UNIT_WORDS).some((ws) => ws.includes(span.unit))) return null;
2155
+ return f.type === "duration" ? span.text : parseSpokenNumber(span.text);
2156
+ }
2157
+ var SCALE_WORDS = {
2158
+ terrible: 0,
2159
+ awful: 0,
2160
+ horrible: 0,
2161
+ dreadful: 0,
2162
+ miserable: 0,
2163
+ worst: 0,
2164
+ bad: 0.25,
2165
+ low: 0.25,
2166
+ poor: 0.25,
2167
+ rough: 0.25,
2168
+ down: 0.25,
2169
+ rubbish: 0.25,
2170
+ easy: 0,
2171
+ light: 0.25,
2172
+ ok: 0.5,
2173
+ okay: 0.5,
2174
+ fine: 0.5,
2175
+ alright: 0.5,
2176
+ average: 0.5,
2177
+ meh: 0.5,
2178
+ moderate: 0.5,
2179
+ normal: 0.5,
2180
+ good: 0.75,
2181
+ decent: 0.75,
2182
+ nice: 0.75,
2183
+ happy: 0.75,
2184
+ high: 0.75,
2185
+ hard: 0.75,
2186
+ tough: 0.75,
2187
+ great: 1,
2188
+ amazing: 1,
2189
+ excellent: 1,
2190
+ fantastic: 1,
2191
+ brilliant: 1,
2192
+ awesome: 1,
2193
+ wonderful: 1,
2194
+ perfect: 1,
2195
+ best: 1,
2196
+ brutal: 1
2197
+ };
2198
+ var INTENSIFIERS = /* @__PURE__ */ new Set(["very", "really", "super", "so", "extremely", "totally", "incredibly"]);
2199
+ function scaleValue(f, tokens, from, to) {
2200
+ if (f.min == null || f.max == null || f.unit) return null;
2201
+ for (let j = Math.max(0, from); j < to; j++) {
2202
+ const w = plain(tokens[j]);
2203
+ if (!(w in SCALE_WORDS)) continue;
2204
+ if (is(tokens[j - 1], "not") || is(tokens[j - 2], "not")) return null;
2205
+ let x = SCALE_WORDS[w];
2206
+ if (INTENSIFIERS.has(_nullishCoalesce(_optionalChain([tokens, 'access', _158 => _158[j - 1], 'optionalAccess', _159 => _159.text]), () => ( ""))) && x !== 0.5) x = x < 0.5 ? Math.max(0, x - 0.25) : Math.min(1, x + 0.25);
2207
+ return { value: Math.round(f.min + x * (f.max - f.min)), at: j };
2208
+ }
2209
+ return null;
2210
+ }
2211
+ var NEGATIONS = /* @__PURE__ */ new Set(["no", "not", "didnt", "dont", "never", "skipped", "skip", "without", "zero", "none", "havent", "hasnt", "wasnt", "nope", "cant", "couldnt"]);
2212
+ function negatedBefore(tokens, start, free) {
2213
+ for (let j = start - 1; j >= Math.max(0, start - 3); j--) {
2214
+ if (!free[j]) return null;
2215
+ if (NEGATIONS.has(plain(tokens[j])) && !is(tokens[j + 1], "wait")) return j;
2216
+ }
2217
+ return null;
2218
+ }
2219
+ var CORRECTIONS = [["no", "wait"], ["wait"], ["sorry"], ["actually"], ["i", "mean"], ["make", "that"], ["scratch", "that"], ["or", "rather"], ["correction"]];
2220
+ function lastCorrection(tokens, from, to) {
2221
+ let last = null;
2222
+ for (let j = from; j < to; j++)
2223
+ for (const c of CORRECTIONS) if (c.every((w, n) => _optionalChain([tokens, 'access', _160 => _160[j + n], 'optionalAccess', _161 => _161.text]) === w) && j + c.length <= to) last = j + c.length;
2224
+ return last;
2225
+ }
2226
+ var LEAD = /^[\s,:;.-]*(?:(?:is|was|were|of|at|about|around|to|=)\b[\s,:;.-]*)*/i;
2227
+ var MAX_GAP = 4;
2228
+ function valueAfter(said, f, h, tokens, stop, free, nextIsToggle) {
2229
+ const from = h.end;
2230
+ if (f.type === "text") {
2231
+ if (from >= stop) return null;
2232
+ const text = said.slice(tokens[from].at, tokens[stop - 1].end).replace(LEAD, "").replace(/[\s,;.]+$/, "");
2233
+ return text ? { value: text, end: stop } : null;
2234
+ }
2235
+ if (f.type === "boolean") {
2236
+ const after = tokens.slice(from, Math.min(stop, from + 2));
2237
+ const last = after[after.length - 1];
2238
+ const lastIsNo = !!last && from + after.length === stop && nextIsToggle && NEGATIONS.has(plain(last));
2239
+ const yes = lastIsNo ? null : parseSpokenYesNo(after.map((t) => t.text).join(" "));
2240
+ if (yes != null) return { value: yes, end: from + after.length };
2241
+ const neg = negatedBefore(tokens, h.start, free);
2242
+ if (neg != null) return { value: false, end: h.end, start: neg };
2243
+ return h.kind === "synonym" ? null : { value: true, end: h.end };
2244
+ }
2245
+ if (f.type === "choice" || f.type === "choices") {
2246
+ if (from >= stop) return null;
2247
+ const labels = choiceLabels(f, tokens.slice(from, stop));
2248
+ if (!labels.length || f.type === "choice" && labels.length > 1) return null;
2249
+ return { value: f.type === "choice" ? labels[0] : labels, end: stop };
2250
+ }
2251
+ const fix = lastCorrection(tokens, from, stop);
2252
+ for (const start of fix != null ? [fix, from] : [from])
2253
+ for (let j = start; j < Math.min(stop, start + MAX_GAP + 1); j++) {
2254
+ if (!numberStarts(tokens, j)) continue;
2255
+ const span = numberAt(said, tokens, j, stop);
2256
+ const value = span && spanValue(f, span);
2257
+ if (span && value != null) return { value, end: span.end };
2258
+ break;
2259
+ }
2260
+ const near = Math.min(stop, from + 3);
2261
+ if (f.choices && from < near) {
2262
+ const [hit] = matchChoices(said.slice(tokens[from].at, tokens[near - 1].end), f.choices.map((label) => ({ label, value: label })));
2263
+ if (hit != null) return { value: hit, end: near };
2264
+ }
2265
+ const scale = scaleValue(f, tokens, from, near);
2266
+ if (scale) return { value: scale.value, end: scale.at + 1 };
2267
+ const before = scaleValue(f, tokens, h.start - 2, h.start);
2268
+ if (before && tokens.slice(before.at, h.start).every((_, n) => free[before.at + n]) && !/[,.;]/.test(said.slice(tokens[before.at].end, tokens[h.start].at)))
2269
+ return { value: before.value, end: h.end, start: before.at };
2270
+ return null;
2271
+ }
2272
+ function choiceLabels(f, tokens) {
2273
+ const hits = findPhrases(tokens, (_nullishCoalesce(f.choices, () => ( []))).map((label) => ({ key: f.key, label, phrases: phrasesFor([label], true) })));
2274
+ return [...new Set(hits.map((h) => h.label))];
2275
+ }
2276
+ function ruleFill(form, said) {
2277
+ const tokens = tokenize(said);
2278
+ const free = tokens.map(() => true);
2279
+ const take = (from, to) => {
2280
+ for (let j = from; j < to; j++) free[j] = false;
2281
+ };
2282
+ const fieldOf = (key) => form.fields.find((f) => f.key === key);
2283
+ const named = [];
2284
+ let inText = false;
2285
+ for (const h of findPhrases(tokens, form.fields.map((f) => ({ key: f.key, phrases: phrasesFor(namesOf(f)) })))) {
2286
+ if (inText && h.kind !== "exact") continue;
2287
+ named.push(h);
2288
+ inText = fieldOf(h.key).type === "text";
2289
+ }
2290
+ for (const h of named) take(h.start, h.end);
2291
+ const answer = {};
2292
+ for (const f of form.fields) {
2293
+ const mine = named.map((h, i) => ({ h, i })).filter(({ h }) => h.key === f.key);
2294
+ for (const { h, i } of mine.reverse()) {
2295
+ const stop = _nullishCoalesce(_optionalChain([named, 'access', _162 => _162[i + 1], 'optionalAccess', _163 => _163.start]), () => ( tokens.length));
2296
+ const nextIsToggle = !!named[i + 1] && fieldOf(named[i + 1].key).type === "boolean";
2297
+ const found = valueAfter(said, f, h, tokens, stop, free, nextIsToggle);
2298
+ if (!found) continue;
2299
+ answer[f.key] = found.value;
2300
+ take(_nullishCoalesce(found.start, () => ( h.start)), found.end);
2301
+ break;
2302
+ }
2303
+ }
2304
+ const open = (f) => !(f.key in answer);
2305
+ const timeFields = () => form.fields.filter((f) => open(f) && (f.type === "duration" || f.type === "number" && timeScale(f.unit)));
2306
+ for (let j = 0; j < tokens.length; j++) {
2307
+ if (!free[j] || !numberStarts(tokens, j)) continue;
2308
+ let stop = j;
2309
+ while (stop < tokens.length && free[stop]) stop++;
2310
+ const span = numberAt(said, tokens, j, stop);
2311
+ if (!span) continue;
2312
+ let field2;
2313
+ if (span.seconds != null) {
2314
+ const unitSaid = tokens.slice(j, span.end).find(isTimeUnit).text;
2315
+ const candidates = timeFields();
2316
+ field2 = _nullishCoalesce(candidates.find((f) => timeScale(f.unit) === TIME_UNITS[unitSaid]), () => ( (candidates.length === 1 ? candidates[0] : void 0)));
2317
+ } else if (span.unit) {
2318
+ const matching = form.fields.filter((f) => open(f) && f.type === "number" && f.unit && !timeScale(f.unit) && unitWords(f.unit).includes(span.unit));
2319
+ if (matching.length === 1) field2 = matching[0];
2320
+ }
2321
+ const value = field2 && spanValue(field2, span);
2322
+ if (field2 && value != null) {
2323
+ answer[field2.key] = value;
2324
+ take(j, span.end);
2325
+ j = span.end - 1;
2326
+ }
2327
+ }
2328
+ const unclaimed = tokens.map((t, j) => free[j] ? t : { ...t, stem: "", text: "" });
2329
+ const choiceFields = form.fields.filter((f) => open(f) && (f.type === "choice" || f.type === "choices"));
2330
+ const mentioned = choiceFields.map((f) => ({ f, labels: choiceLabels(f, unclaimed) })).filter((c) => c.labels.length);
2331
+ if (mentioned.length === 1) {
2332
+ const [{ f, labels }] = mentioned;
2333
+ if (f.type === "choices") answer[f.key] = labels;
2334
+ else if (labels.length === 1) answer[f.key] = labels[0];
2335
+ }
2336
+ return readFill(form, answer);
2337
+ }
2338
+ var ruleFiller = async (form, said) => ruleFill(form, said);
2339
+
1810
2340
  // src/core/local.ts
1811
2341
  var LOCAL_DATASOURCE_TYPE = "modelform-local";
1812
2342
  var LEGACY_LOCAL_DATASOURCE_TYPE = "dashkit-local";
@@ -1883,7 +2413,7 @@ function buildFrames(target, entries, request, label, siblings = []) {
1883
2413
  const fill = _nullishCoalesce(target.fillZero, () => ( (aggregate === "sum" || aggregate === "count")));
1884
2414
  ({ times, values } = bucketize(rows, aggregate, bucket, request.range, fill));
1885
2415
  }
1886
- const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall', _156 => _156(labelKey, group)]), () => ( group));
2416
+ const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall', _164 => _164(labelKey, group)]), () => ( group));
1887
2417
  return {
1888
2418
  name,
1889
2419
  refId: target.refId,
@@ -1939,7 +2469,7 @@ function bucketize(rows, aggregate, bucket, range, fillZero) {
1939
2469
  const keys = fillZero ? step.range(range.from, range.to) : [...sums.keys()].sort((a, b) => a - b);
1940
2470
  const values = keys.map((k) => {
1941
2471
  const vs = sums.get(k);
1942
- return _optionalChain([vs, 'optionalAccess', _157 => _157.length]) ? reduce2(vs, aggregate) : fillZero ? 0 : null;
2472
+ return _optionalChain([vs, 'optionalAccess', _165 => _165.length]) ? reduce2(vs, aggregate) : fillZero ? 0 : null;
1943
2473
  });
1944
2474
  return { times: keys, values };
1945
2475
  }
@@ -2020,17 +2550,17 @@ function parseGazetteer(json) {
2020
2550
  };
2021
2551
  if (Array.isArray(json)) {
2022
2552
  for (const item of json) {
2023
- const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _158 => _158.latitude]), () => ( _optionalChain([item, 'optionalAccess', _159 => _159.lat]))));
2024
- const lon = Number(_nullishCoalesce(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _160 => _160.longitude]), () => ( _optionalChain([item, 'optionalAccess', _161 => _161.lon]))), () => ( _optionalChain([item, 'optionalAccess', _162 => _162.lng]))));
2553
+ const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _166 => _166.latitude]), () => ( _optionalChain([item, 'optionalAccess', _167 => _167.lat]))));
2554
+ const lon = Number(_nullishCoalesce(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _168 => _168.longitude]), () => ( _optionalChain([item, 'optionalAccess', _169 => _169.lon]))), () => ( _optionalChain([item, 'optionalAccess', _170 => _170.lng]))));
2025
2555
  if (!Number.isFinite(lat) || !Number.isFinite(lon)) continue;
2026
2556
  const p = { lon, lat };
2027
2557
  add(item.key, p);
2028
2558
  for (const k of [..._nullishCoalesce(item.keys, () => ( [])), ..._nullishCoalesce(item.keywords, () => ( []))]) add(k, p);
2029
2559
  add(item.name, p);
2030
2560
  }
2031
- } else if (_optionalChain([json, 'optionalAccess', _163 => _163.type]) === "FeatureCollection") {
2561
+ } else if (_optionalChain([json, 'optionalAccess', _171 => _171.type]) === "FeatureCollection") {
2032
2562
  for (const f of _nullishCoalesce(json.features, () => ( []))) {
2033
- const p = featurePoint(_optionalChain([f, 'optionalAccess', _164 => _164.geometry]));
2563
+ const p = featurePoint(_optionalChain([f, 'optionalAccess', _172 => _172.geometry]));
2034
2564
  if (!p) continue;
2035
2565
  add(f.id, p);
2036
2566
  for (const v of Object.values(_nullishCoalesce(f.properties, () => ( {})))) if (typeof v === "string") add(v, p);
@@ -2039,7 +2569,7 @@ function parseGazetteer(json) {
2039
2569
  return { find: (key) => _nullishCoalesce(exact.get(key), () => ( folded.get(key.toLowerCase()))) };
2040
2570
  }
2041
2571
  function featurePoint(geometry) {
2042
- if (!_optionalChain([geometry, 'optionalAccess', _165 => _165.coordinates])) return void 0;
2572
+ if (!_optionalChain([geometry, 'optionalAccess', _173 => _173.coordinates])) return void 0;
2043
2573
  if (geometry.type === "Point") {
2044
2574
  const [lon, lat] = geometry.coordinates;
2045
2575
  return Number.isFinite(lon) && Number.isFinite(lat) ? { lon, lat } : void 0;
@@ -2068,7 +2598,7 @@ function loadGazetteer(path, ds) {
2068
2598
  const json = absolute ? fetch(path).then((r) => {
2069
2599
  if (!r.ok) throw new Error(`${r.status} ${r.statusText}`);
2070
2600
  return r.json();
2071
- }) : _optionalChain([ds, 'optionalAccess', _166 => _166.publicFile]) ? ds.publicFile(path) : Promise.reject(new Error(`${path} is served by Grafana, and this dashboard has no Grafana connection`));
2601
+ }) : _optionalChain([ds, 'optionalAccess', _174 => _174.publicFile]) ? ds.publicFile(path) : Promise.reject(new Error(`${path} is served by Grafana, and this dashboard has no Grafana connection`));
2072
2602
  const run2 = json.then(parseGazetteer);
2073
2603
  run2.catch(() => loaded.get(path) === run2 && loaded.delete(path));
2074
2604
  loaded.set(path, run2);
@@ -2108,7 +2638,7 @@ function macro(path, format3, ctx) {
2108
2638
  switch (head) {
2109
2639
  case "__from":
2110
2640
  case "__to": {
2111
- const ms = head === "__from" ? _optionalChain([ctx, 'access', _167 => _167.range, 'optionalAccess', _168 => _168.from]) : _optionalChain([ctx, 'access', _169 => _169.range, 'optionalAccess', _170 => _170.to]);
2641
+ const ms = head === "__from" ? _optionalChain([ctx, 'access', _175 => _175.range, 'optionalAccess', _176 => _176.from]) : _optionalChain([ctx, 'access', _177 => _177.range, 'optionalAccess', _178 => _178.to]);
2112
2642
  if (ms == null) return void 0;
2113
2643
  if (format3 === "date" || format3 === "date:iso") return new Date(ms).toISOString();
2114
2644
  if (format3 === "date:seconds") return String(Math.floor(ms / 1e3));
@@ -2145,13 +2675,13 @@ function macro(path, format3, ctx) {
2145
2675
  }
2146
2676
  return void 0;
2147
2677
  case "__series":
2148
- return rest[0] === "name" ? _nullishCoalesce(_nullishCoalesce(d.seriesName, () => ( _optionalChain([d, 'access', _171 => _171.frame, 'optionalAccess', _172 => _172.name]))), () => ( d.fieldName)) : void 0;
2678
+ return rest[0] === "name" ? _nullishCoalesce(_nullishCoalesce(d.seriesName, () => ( _optionalChain([d, 'access', _179 => _179.frame, 'optionalAccess', _180 => _180.name]))), () => ( d.fieldName)) : void 0;
2149
2679
  case "__data": {
2150
2680
  const m = /^fields(?:\.([\w-]+)|\["([^"]*)"\]|\[(\d+)\])/.exec(rest.join("."));
2151
2681
  if (!m || !d.frame || d.row == null) return void 0;
2152
2682
  const key = _nullishCoalesce(m[1], () => ( m[2]));
2153
- const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access', _173 => _173.config, 'optionalAccess', _174 => _174.displayName]) === key) : d.frame.fields[Number(m[3])];
2154
- const v = _optionalChain([f, 'optionalAccess', _175 => _175.values, 'access', _176 => _176[d.row]]);
2683
+ const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access', _181 => _181.config, 'optionalAccess', _182 => _182.displayName]) === key) : d.frame.fields[Number(m[3])];
2684
+ const v = _optionalChain([f, 'optionalAccess', _183 => _183.values, 'access', _184 => _184[d.row]]);
2155
2685
  if (v == null) return void 0;
2156
2686
  return f.type === "time" ? String(toMillis(v)) : String(v);
2157
2687
  }
@@ -2162,9 +2692,9 @@ function urlTime(raw, ms) {
2162
2692
  return raw.trim().startsWith("now") ? encodeURIComponent(raw.trim()) : String(ms);
2163
2693
  }
2164
2694
  function allVariables(ctx) {
2165
- const names = (_nullishCoalesce(_optionalChain([ctx, 'access', _177 => _177.dashboard, 'optionalAccess', _178 => _178.templating, 'optionalAccess', _179 => _179.list]), () => ( []))).filter((v) => v.type !== "adhoc").map((v) => v.name);
2695
+ const names = (_nullishCoalesce(_optionalChain([ctx, 'access', _185 => _185.dashboard, 'optionalAccess', _186 => _186.templating, 'optionalAccess', _187 => _187.list]), () => ( []))).filter((v) => v.type !== "adhoc").map((v) => v.name);
2166
2696
  return (names.length ? names : Object.keys(ctx.values)).flatMap((n) => {
2167
- const v = _nullishCoalesce(_optionalChain([ctx, 'access', _180 => _180.scoped, 'optionalAccess', _181 => _181[n], 'optionalAccess', _182 => _182.value]), () => ( ctx.values[n]));
2697
+ const v = _nullishCoalesce(_optionalChain([ctx, 'access', _188 => _188.scoped, 'optionalAccess', _189 => _189[n], 'optionalAccess', _190 => _190.value]), () => ( ctx.values[n]));
2168
2698
  return v == null ? [] : [queryParam(n, v)];
2169
2699
  }).join("&");
2170
2700
  }
@@ -2175,7 +2705,7 @@ function parseDashboardLink(href, grafanaUrl) {
2175
2705
  const base = grafanaUrl ? /^(?:[a-z][a-z0-9+.-]*:)?\/\/([^/?#]+)([^?#]*)/i.exec(grafanaUrl.trim()) : null;
2176
2706
  if (host && (!base || base[1].toLowerCase() !== host.toLowerCase())) return null;
2177
2707
  if (scheme && !/^https?:$/i.test(scheme)) return null;
2178
- const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess', _183 => _183[2]]), () => ( ""))).replace(/\/+$/, "");
2708
+ const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess', _191 => _191[2]]), () => ( ""))).replace(/\/+$/, "");
2179
2709
  const path = prefix && rawPath.startsWith(prefix + "/") ? rawPath.slice(prefix.length) : rawPath;
2180
2710
  const p = /^\/d\/([^/]+)(?:\/[^/]*)?\/?$/.exec(path);
2181
2711
  if (!p) return null;
@@ -2194,17 +2724,17 @@ function parseDashboardLink(href, grafanaUrl) {
2194
2724
  function decode(s) {
2195
2725
  try {
2196
2726
  return decodeURIComponent(s.replace(/\+/g, " "));
2197
- } catch (e11) {
2727
+ } catch (e13) {
2198
2728
  return s;
2199
2729
  }
2200
2730
  }
2201
2731
  function applyDashboardLink(dashboard, target) {
2202
- const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access', _184 => _184.time, 'optionalAccess', _185 => _185.from]) || "now-6h", to: target.to || _optionalChain([dashboard, 'access', _186 => _186.time, 'optionalAccess', _187 => _187.to]) || "now" } : dashboard.time;
2203
- const list = _optionalChain([dashboard, 'access', _188 => _188.templating, 'optionalAccess', _189 => _189.list, 'access', _190 => _190.map, 'call', _191 => _191((v) => {
2732
+ const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access', _192 => _192.time, 'optionalAccess', _193 => _193.from]) || "now-6h", to: target.to || _optionalChain([dashboard, 'access', _194 => _194.time, 'optionalAccess', _195 => _195.to]) || "now" } : dashboard.time;
2733
+ const list = _optionalChain([dashboard, 'access', _196 => _196.templating, 'optionalAccess', _197 => _197.list, 'access', _198 => _198.map, 'call', _199 => _199((v) => {
2204
2734
  const values = target.vars[v.name];
2205
- if (!_optionalChain([values, 'optionalAccess', _192 => _192.length])) return v;
2735
+ if (!_optionalChain([values, 'optionalAccess', _200 => _200.length])) return v;
2206
2736
  const value = v.multi ? values : values[0];
2207
- const text = (Array.isArray(value) ? value : [value]).map((x) => x === "$__all" ? "All" : _nullishCoalesce(_optionalChain([v, 'access', _193 => _193.options, 'optionalAccess', _194 => _194.find, 'call', _195 => _195((o) => o.value === x), 'optionalAccess', _196 => _196.text]), () => ( x)));
2737
+ const text = (Array.isArray(value) ? value : [value]).map((x) => x === "$__all" ? "All" : _nullishCoalesce(_optionalChain([v, 'access', _201 => _201.options, 'optionalAccess', _202 => _202.find, 'call', _203 => _203((o) => o.value === x), 'optionalAccess', _204 => _204.text]), () => ( x)));
2208
2738
  return { ...v, current: { text: v.multi ? text : text[0], value } };
2209
2739
  })]);
2210
2740
  return { ...dashboard, time, templating: list ? { ...dashboard.templating, list } : dashboard.templating };
@@ -8338,7 +8868,7 @@ function removeAt(root, pointer) {
8338
8868
  const segs = pointer.split("/").slice(1).map((s) => s.replace(/~1/g, "/").replace(/~0/g, "~"));
8339
8869
  const last = segs.pop();
8340
8870
  let parent = root;
8341
- for (const s of segs) parent = _optionalChain([parent, 'optionalAccess', _197 => _197[s]]);
8871
+ for (const s of segs) parent = _optionalChain([parent, 'optionalAccess', _205 => _205[s]]);
8342
8872
  if (Array.isArray(parent)) {
8343
8873
  parent.splice(Number(last), 1);
8344
8874
  return { array: parentOf(pointer), index: Number(last) };
@@ -8350,7 +8880,7 @@ function cleanDashboard(json) {
8350
8880
  const value = structuredClone(json);
8351
8881
  const removed = [];
8352
8882
  const deletedKeys = /* @__PURE__ */ new Set();
8353
- for (let round = 0; round < 10 && !validateDashboard(value); round++) {
8883
+ for (let round2 = 0; round2 < 10 && !validateDashboard(value); round2++) {
8354
8884
  const errors = collapseUnions((_nullishCoalesce(validateDashboard.errors, () => ( []))).filter((e) => !noise(e)));
8355
8885
  const targets = /* @__PURE__ */ new Map();
8356
8886
  for (const e of errors) {
@@ -8511,7 +9041,7 @@ var STANDARD = [
8511
9041
  ]
8512
9042
  }
8513
9043
  },
8514
- { path: field("color.fixedColor"), label: "Color", category: "Standard options", control: { kind: "color" }, showIf: (p) => _optionalChain([p, 'access', _198 => _198.fieldConfig, 'optionalAccess', _199 => _199.defaults, 'optionalAccess', _200 => _200.color, 'optionalAccess', _201 => _201.mode]) === "fixed" }
9044
+ { path: field("color.fixedColor"), label: "Color", category: "Standard options", control: { kind: "color" }, showIf: (p) => _optionalChain([p, 'access', _206 => _206.fieldConfig, 'optionalAccess', _207 => _207.defaults, 'optionalAccess', _208 => _208.color, 'optionalAccess', _209 => _209.mode]) === "fixed" }
8515
9045
  ];
8516
9046
  var THRESHOLDS = {
8517
9047
  path: field("thresholds"),
@@ -8537,7 +9067,7 @@ var CALC = {
8537
9067
  default: "lastNotNull",
8538
9068
  control: { kind: "select", choices: Object.entries(REDUCER_LABELS).map(([value, label]) => ({ label, value })) },
8539
9069
  stored: "string[]",
8540
- get: (p) => _optionalChain([p, 'access', _202 => _202.options, 'optionalAccess', _203 => _203.reduceOptions, 'optionalAccess', _204 => _204.calcs, 'optionalAccess', _205 => _205[0]]),
9070
+ get: (p) => _optionalChain([p, 'access', _210 => _210.options, 'optionalAccess', _211 => _211.reduceOptions, 'optionalAccess', _212 => _212.calcs, 'optionalAccess', _213 => _213[0]]),
8541
9071
  set: (p, v) => setOptionValue(p, "options.reduceOptions.calcs", v === void 0 ? void 0 : [v])
8542
9072
  };
8543
9073
  var LEGEND = {
@@ -8547,9 +9077,9 @@ var LEGEND = {
8547
9077
  help: "When there are two or more series.",
8548
9078
  default: true,
8549
9079
  control: { kind: "boolean" },
8550
- get: (p) => _optionalChain([p, 'access', _206 => _206.options, 'optionalAccess', _207 => _207.legend, 'optionalAccess', _208 => _208.showLegend]) !== false && _optionalChain([p, 'access', _209 => _209.options, 'optionalAccess', _210 => _210.legend, 'optionalAccess', _211 => _211.displayMode]) !== "hidden",
9080
+ get: (p) => _optionalChain([p, 'access', _214 => _214.options, 'optionalAccess', _215 => _215.legend, 'optionalAccess', _216 => _216.showLegend]) !== false && _optionalChain([p, 'access', _217 => _217.options, 'optionalAccess', _218 => _218.legend, 'optionalAccess', _219 => _219.displayMode]) !== "hidden",
8551
9081
  // Grafana's older displayMode "hidden" would otherwise keep it hidden.
8552
- set: (p, v) => setOptionValue(v ? setOptionValue(p, "options.legend.displayMode", _optionalChain([p, 'access', _212 => _212.options, 'optionalAccess', _213 => _213.legend, 'optionalAccess', _214 => _214.displayMode]) === "hidden" ? void 0 : _optionalChain([p, 'access', _215 => _215.options, 'optionalAccess', _216 => _216.legend, 'optionalAccess', _217 => _217.displayMode])) : p, "options.legend.showLegend", v ? void 0 : false)
9082
+ set: (p, v) => setOptionValue(v ? setOptionValue(p, "options.legend.displayMode", _optionalChain([p, 'access', _220 => _220.options, 'optionalAccess', _221 => _221.legend, 'optionalAccess', _222 => _222.displayMode]) === "hidden" ? void 0 : _optionalChain([p, 'access', _223 => _223.options, 'optionalAccess', _224 => _224.legend, 'optionalAccess', _225 => _225.displayMode])) : p, "options.legend.showLegend", v ? void 0 : false)
8553
9083
  };
8554
9084
  var AXIS_LABEL = { path: field("custom.axisLabel"), label: "Axis label", category: "Axis", control: { kind: "text" } };
8555
9085
  var AXIS_PLACEMENT = {
@@ -8803,7 +9333,7 @@ function overrideProperties(type) {
8803
9333
  return out;
8804
9334
  }
8805
9335
  function panelOverrides(panel) {
8806
- const o = _optionalChain([panel, 'access', _218 => _218.fieldConfig, 'optionalAccess', _219 => _219.overrides]);
9336
+ const o = _optionalChain([panel, 'access', _226 => _226.fieldConfig, 'optionalAccess', _227 => _227.overrides]);
8807
9337
  return Array.isArray(o) ? o : [];
8808
9338
  }
8809
9339
  function setOverrides(panel, overrides) {
@@ -8851,7 +9381,7 @@ function prepareDashboard(json, file) {
8851
9381
  });
8852
9382
  dashboard.panels.forEach((p, i) => {
8853
9383
  for (const r of cleanPanelOptions(p)) removed.push({ path: `panels[${i}]${r.path}`, message: r.message });
8854
- _optionalChain([p, 'access', _220 => _220.panels, 'optionalAccess', _221 => _221.forEach, 'call', _222 => _222((child, j) => {
9384
+ _optionalChain([p, 'access', _228 => _228.panels, 'optionalAccess', _229 => _229.forEach, 'call', _230 => _230((child, j) => {
8855
9385
  for (const r of cleanPanelOptions(child)) removed.push({ path: `panels[${i}].panels[${j}]${r.path}`, message: r.message });
8856
9386
  })]);
8857
9387
  });
@@ -8874,7 +9404,7 @@ function groupIssues(dashboard) {
8874
9404
  for (const { p, at } of located2) if (isInputPanel(p) && !recordedAt.has(p.options.metric)) recordedAt.set(p.options.metric, at);
8875
9405
  for (const { p, at } of located2) {
8876
9406
  if (p.type !== INPUT_GROUP) continue;
8877
- const fields = _optionalChain([p, 'access', _223 => _223.options, 'optionalAccess', _224 => _224.fields]);
9407
+ const fields = _optionalChain([p, 'access', _231 => _231.options, 'optionalAccess', _232 => _232.fields]);
8878
9408
  if (!Array.isArray(fields) || !fields.length) {
8879
9409
  out.push({ path: `${at}.options.fields`, message: "a group needs at least one field" });
8880
9410
  continue;
@@ -8891,7 +9421,7 @@ function groupIssues(dashboard) {
8891
9421
  else recordedAt.set(metric, fat);
8892
9422
  mine.push(metric);
8893
9423
  });
8894
- const titleFrom = _optionalChain([p, 'access', _225 => _225.options, 'optionalAccess', _226 => _226.titleFrom]);
9424
+ const titleFrom = _optionalChain([p, 'access', _233 => _233.options, 'optionalAccess', _234 => _234.titleFrom]);
8895
9425
  if (titleFrom !== void 0 && !mine.includes(titleFrom)) out.push({ path: `${at}.options.titleFrom`, message: `must be the metric of one of the group\u2019s fields` });
8896
9426
  }
8897
9427
  return out;
@@ -8902,7 +9432,7 @@ function panelProblem(p) {
8902
9432
  const g = p.gridPos;
8903
9433
  if (!isObject3(g) || !["x", "y", "w", "h"].every((k) => typeof g[k] === "number"))
8904
9434
  return { at: ".gridPos", message: "must have numeric x, y, w and h", summary: "has no usable gridPos" };
8905
- if (p.type.startsWith("input-") && p.type !== INPUT_GROUP && !nonEmptyString(_optionalChain([p, 'access', _227 => _227.options, 'optionalAccess', _228 => _228.metric]))) {
9435
+ if (p.type.startsWith("input-") && p.type !== INPUT_GROUP && !nonEmptyString(_optionalChain([p, 'access', _235 => _235.options, 'optionalAccess', _236 => _236.metric]))) {
8906
9436
  const message = `${p.type} needs a metric to record to`;
8907
9437
  return { at: ".options.metric", message, summary: message };
8908
9438
  }
@@ -8978,17 +9508,17 @@ function resolveUrl(base, rel) {
8978
9508
  function httpFetchJson(options = {}) {
8979
9509
  const seen = /* @__PURE__ */ new Map();
8980
9510
  return async (url, { accept = "application/json", signal } = {}) => {
8981
- const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access', _229 => _229.headers, 'optionalCall', _230 => _230()]), async () => ( {}));
9511
+ const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access', _237 => _237.headers, 'optionalCall', _238 => _238()]), async () => ( {}));
8982
9512
  const key = JSON.stringify([url, accept, extra]);
8983
9513
  const last = seen.get(key);
8984
9514
  const get = (etag2) => fetch(url, { headers: { Accept: accept, ...extra, ...etag2 && { "If-None-Match": etag2 } }, cache: "no-store", signal });
8985
- const res = await get(_optionalChain([last, 'optionalAccess', _231 => _231.etag])).catch((e) => {
8986
- if (!last || _optionalChain([signal, 'optionalAccess', _232 => _232.aborted])) throw e;
9515
+ const res = await get(_optionalChain([last, 'optionalAccess', _239 => _239.etag])).catch((e) => {
9516
+ if (!last || _optionalChain([signal, 'optionalAccess', _240 => _240.aborted])) throw e;
8987
9517
  seen.delete(key);
8988
9518
  return get();
8989
9519
  });
8990
9520
  if (res.status === 304 && last) return last.json;
8991
- if (!res.ok) throw new Error(_nullishCoalesce(_optionalChain([options, 'access', _233 => _233.httpError, 'optionalCall', _234 => _234(res.status)]), () => ( `HTTP ${res.status}`)));
9521
+ if (!res.ok) throw new Error(_nullishCoalesce(_optionalChain([options, 'access', _241 => _241.httpError, 'optionalCall', _242 => _242(res.status)]), () => ( `HTTP ${res.status}`)));
8992
9522
  const json = JSON.parse(await res.text());
8993
9523
  const etag = res.headers.get("ETag");
8994
9524
  if (etag) seen.set(key, { etag, json });
@@ -9077,7 +9607,7 @@ function revalidateBundle(bundle) {
9077
9607
  }
9078
9608
  const checked = { manifest, documents };
9079
9609
  return validateBundle(checked).some((i) => i.severity === "error") ? void 0 : checked;
9080
- } catch (e12) {
9610
+ } catch (e14) {
9081
9611
  return void 0;
9082
9612
  }
9083
9613
  }
@@ -9110,8 +9640,8 @@ var ConfigLoader = (_class2 = class {
9110
9640
  async start() {
9111
9641
  const { url, cache: cache2 } = this.options;
9112
9642
  if (!url) return;
9113
- const cached = await _optionalChain([cache2, 'optionalAccess', _235 => _235.read, 'call', _236 => _236(), 'access', _237 => _237.catch, 'call', _238 => _238(() => null)]);
9114
- const bundle = _optionalChain([cached, 'optionalAccess', _239 => _239.url]) === url ? revalidateBundle(cached.bundle) : void 0;
9643
+ const cached = await _optionalChain([cache2, 'optionalAccess', _243 => _243.read, 'call', _244 => _244(), 'access', _245 => _245.catch, 'call', _246 => _246(() => null)]);
9644
+ const bundle = _optionalChain([cached, 'optionalAccess', _247 => _247.url]) === url ? revalidateBundle(cached.bundle) : void 0;
9115
9645
  if (cached && bundle && !this.snapshot.fetchedAt) {
9116
9646
  this.lastJson = JSON.stringify(bundle);
9117
9647
  this.set({ bundle, source: "cache", fetchedAt: cached.fetchedAt, revision: cached.revision });
@@ -9141,7 +9671,7 @@ var ConfigLoader = (_class2 = class {
9141
9671
  if (!bundle) {
9142
9672
  const errors = issues.filter((i) => i.severity === "error").length;
9143
9673
  const needsUpdate = issues.some((i) => i.code === "newer-version");
9144
- const error = unreachable ? _optionalChain([issues, 'access', _240 => _240[0], 'optionalAccess', _241 => _241.message]) : needsUpdate ? "a newer format" : errors === 1 ? "1 error" : `${errors} errors`;
9674
+ const error = unreachable ? _optionalChain([issues, 'access', _248 => _248[0], 'optionalAccess', _249 => _249.message]) : needsUpdate ? "a newer format" : errors === 1 ? "1 error" : `${errors} errors`;
9145
9675
  return this.set(
9146
9676
  { loading: false, error, unreachable: !!unreachable, needsUpdate, issues },
9147
9677
  this.snapshot.loading || error !== this.snapshot.error || !!unreachable !== !!this.snapshot.unreachable || needsUpdate !== !!this.snapshot.needsUpdate || !sameIssues(issues, this.snapshot.issues)
@@ -9151,7 +9681,7 @@ var ConfigLoader = (_class2 = class {
9151
9681
  const changed = json !== this.lastJson;
9152
9682
  this.lastJson = json;
9153
9683
  const fetchedAt = Date.now();
9154
- if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess', _242 => _242.write, 'call', _243 => _243({ url, fetchedAt, bundle, revision }), 'access', _244 => _244.catch, 'call', _245 => _245(() => {
9684
+ if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess', _250 => _250.write, 'call', _251 => _251({ url, fetchedAt, bundle, revision }), 'access', _252 => _252.catch, 'call', _253 => _253(() => {
9155
9685
  })]);
9156
9686
  this.set(
9157
9687
  { ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, unreachable: void 0, needsUpdate: void 0, issues },
@@ -9168,7 +9698,7 @@ var ConfigLoader = (_class2 = class {
9168
9698
  /** Stops the loader: cancels a fetch in flight, and nothing it does afterwards changes the state or the cache. */
9169
9699
  dispose() {
9170
9700
  this.disposed = true;
9171
- _optionalChain([this, 'access', _246 => _246.controller, 'optionalAccess', _247 => _247.abort, 'call', _248 => _248()]);
9701
+ _optionalChain([this, 'access', _254 => _254.controller, 'optionalAccess', _255 => _255.abort, 'call', _256 => _256()]);
9172
9702
  this.listeners.clear();
9173
9703
  }
9174
9704
  /** `notify: false` drops the patch, so the snapshot only changes when listeners hear about it. */
@@ -9189,7 +9719,7 @@ function tabIdFor(title, taken) {
9189
9719
  }
9190
9720
  function screenOfType(type, from, docs) {
9191
9721
  const shown = from ? screenDocuments(from) : [];
9192
- const firstOf = (ids) => _nullishCoalesce(_nullishCoalesce(_optionalChain([shown, 'access', _249 => _249.find, 'call', _250 => _250((d) => ids.includes(d.id)), 'optionalAccess', _251 => _251.id]), () => ( ids[0])), () => ( ""));
9722
+ const firstOf = (ids) => _nullishCoalesce(_nullishCoalesce(_optionalChain([shown, 'access', _257 => _257.find, 'call', _258 => _258((d) => ids.includes(d.id)), 'optionalAccess', _259 => _259.id]), () => ( ids[0])), () => ( ""));
9193
9723
  switch (type) {
9194
9724
  case "dashboard":
9195
9725
  return { type, dashboard: firstOf(docs.dashboards) };
@@ -9202,7 +9732,7 @@ function screenOfType(type, from, docs) {
9202
9732
  }
9203
9733
  }
9204
9734
  function screenDocuments(screen) {
9205
- switch (_optionalChain([screen, 'optionalAccess', _252 => _252.type])) {
9735
+ switch (_optionalChain([screen, 'optionalAccess', _260 => _260.type])) {
9206
9736
  case "dashboard":
9207
9737
  return [{ id: screen.dashboard, kind: "dashboard" }];
9208
9738
  case "forms":
@@ -10617,8 +11147,8 @@ function removeNode(text, path) {
10617
11147
  const tree = parseTree2(text);
10618
11148
  const value = tree && findNodeAtLocation2(tree, path);
10619
11149
  if (!value) return text;
10620
- const node = _optionalChain([value, 'access', _253 => _253.parent, 'optionalAccess', _254 => _254.type]) === "property" ? value.parent : value;
10621
- const siblings = _nullishCoalesce(_optionalChain([node, 'access', _255 => _255.parent, 'optionalAccess', _256 => _256.children]), () => ( []));
11150
+ const node = _optionalChain([value, 'access', _261 => _261.parent, 'optionalAccess', _262 => _262.type]) === "property" ? value.parent : value;
11151
+ const siblings = _nullishCoalesce(_optionalChain([node, 'access', _263 => _263.parent, 'optionalAccess', _264 => _264.children]), () => ( []));
10622
11152
  const i = siblings.indexOf(node);
10623
11153
  const next = siblings[i + 1];
10624
11154
  const prev = siblings[i - 1];
@@ -10689,7 +11219,7 @@ function parseManifest(text) {
10689
11219
  let value;
10690
11220
  try {
10691
11221
  value = JSON.parse(text);
10692
- } catch (e13) {
11222
+ } catch (e15) {
10693
11223
  throw new Error("The manifest isn\u2019t valid JSON");
10694
11224
  }
10695
11225
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("The manifest isn\u2019t an object");
@@ -10701,20 +11231,20 @@ function removeDocumentFromManifest(text, id) {
10701
11231
  const edits = [];
10702
11232
  const removedTabs = [];
10703
11233
  for (let i = tabs.length - 1; i >= 0; i--) {
10704
- const screen = _optionalChain([tabs, 'access', _257 => _257[i], 'optionalAccess', _258 => _258.screen]);
11234
+ const screen = _optionalChain([tabs, 'access', _265 => _265[i], 'optionalAccess', _266 => _266.screen]);
10705
11235
  const at = ["tabs", i, "screen"];
10706
11236
  const removeTab = () => {
10707
11237
  edits.push({ path: ["tabs", i], remove: true });
10708
11238
  removedTabs.unshift(_nullishCoalesce(tabs[i].title, () => ( tabs[i].id)));
10709
11239
  };
10710
- if (_optionalChain([screen, 'optionalAccess', _259 => _259.type]) === "dashboard" && screen.dashboard === id) removeTab();
10711
- else if (_optionalChain([screen, 'optionalAccess', _260 => _260.type]) === "forms" && Array.isArray(screen.forms) && screen.forms.includes(id)) {
11240
+ if (_optionalChain([screen, 'optionalAccess', _267 => _267.type]) === "dashboard" && screen.dashboard === id) removeTab();
11241
+ else if (_optionalChain([screen, 'optionalAccess', _268 => _268.type]) === "forms" && Array.isArray(screen.forms) && screen.forms.includes(id)) {
10712
11242
  if (screen.forms.every((f) => f === id)) removeTab();
10713
11243
  else for (let j = screen.forms.length - 1; j >= 0; j--) if (screen.forms[j] === id) edits.push({ path: [...at, "forms", j], remove: true });
10714
- } else if (_optionalChain([screen, 'optionalAccess', _261 => _261.type]) === "menu" && Array.isArray(screen.items))
11244
+ } else if (_optionalChain([screen, 'optionalAccess', _269 => _269.type]) === "menu" && Array.isArray(screen.items))
10715
11245
  for (let j = screen.items.length - 1; j >= 0; j--) {
10716
11246
  const item = screen.items[j];
10717
- if (_optionalChain([item, 'optionalAccess', _262 => _262.dashboard]) === id || _optionalChain([item, 'optionalAccess', _263 => _263.form]) === id) edits.push({ path: [...at, "items", j], remove: true });
11247
+ if (_optionalChain([item, 'optionalAccess', _270 => _270.dashboard]) === id || _optionalChain([item, 'optionalAccess', _271 => _271.form]) === id) edits.push({ path: [...at, "items", j], remove: true });
10718
11248
  }
10719
11249
  }
10720
11250
  if (tabs.length && removedTabs.length === tabs.length) throw new Error(`Every tab shows only "${id}". Add another tab first`);
@@ -10727,21 +11257,21 @@ function renameDocumentInManifest(text, from, to, path) {
10727
11257
  if (to !== from && to in manifest.documents) throw new Error(`There\u2019s already a document "${to}"`);
10728
11258
  const edits = [];
10729
11259
  (Array.isArray(manifest.tabs) ? manifest.tabs : []).forEach((tab, i) => {
10730
- const screen = _optionalChain([tab, 'optionalAccess', _264 => _264.screen]);
11260
+ const screen = _optionalChain([tab, 'optionalAccess', _272 => _272.screen]);
10731
11261
  const at = ["tabs", i, "screen"];
10732
- if (_optionalChain([screen, 'optionalAccess', _265 => _265.type]) === "dashboard" && screen.dashboard === from) edits.push({ path: [...at, "dashboard"], value: to });
10733
- if (_optionalChain([screen, 'optionalAccess', _266 => _266.type]) === "forms" && Array.isArray(screen.forms))
11262
+ if (_optionalChain([screen, 'optionalAccess', _273 => _273.type]) === "dashboard" && screen.dashboard === from) edits.push({ path: [...at, "dashboard"], value: to });
11263
+ if (_optionalChain([screen, 'optionalAccess', _274 => _274.type]) === "forms" && Array.isArray(screen.forms))
10734
11264
  screen.forms.forEach((f, j) => f === from && edits.push({ path: [...at, "forms", j], value: to }));
10735
- if (_optionalChain([screen, 'optionalAccess', _267 => _267.type]) === "menu" && Array.isArray(screen.items))
11265
+ if (_optionalChain([screen, 'optionalAccess', _275 => _275.type]) === "menu" && Array.isArray(screen.items))
10736
11266
  screen.items.forEach((item, j) => {
10737
- if (_optionalChain([item, 'optionalAccess', _268 => _268.dashboard]) === from) edits.push({ path: [...at, "items", j, "dashboard"], value: to });
10738
- if (_optionalChain([item, 'optionalAccess', _269 => _269.form]) === from) edits.push({ path: [...at, "items", j, "form"], value: to });
11267
+ if (_optionalChain([item, 'optionalAccess', _276 => _276.dashboard]) === from) edits.push({ path: [...at, "items", j, "dashboard"], value: to });
11268
+ if (_optionalChain([item, 'optionalAccess', _277 => _277.form]) === from) edits.push({ path: [...at, "items", j, "form"], value: to });
10739
11269
  });
10740
11270
  });
10741
11271
  if (path !== void 0) edits.push({ path: ["documents", from], value: path });
10742
11272
  let out = applyJsonEdits(text, edits);
10743
11273
  if (to !== from) {
10744
- const key = _optionalChain([findNodeAtLocation2, 'call', _270 => _270(parseTree2(out), ["documents", from]), 'optionalAccess', _271 => _271.parent, 'optionalAccess', _272 => _272.children, 'optionalAccess', _273 => _273[0]]);
11274
+ const key = _optionalChain([findNodeAtLocation2, 'call', _278 => _278(parseTree2(out), ["documents", from]), 'optionalAccess', _279 => _279.parent, 'optionalAccess', _280 => _280.children, 'optionalAccess', _281 => _281[0]]);
10745
11275
  if (key) out = out.slice(0, key.offset) + JSON.stringify(to) + out.slice(key.offset + key.length);
10746
11276
  }
10747
11277
  return out;
@@ -10751,7 +11281,7 @@ function parse2(text) {
10751
11281
  try {
10752
11282
  const d = JSON.parse(text);
10753
11283
  return d && Array.isArray(d.panels) && d.panels.every((p) => p && typeof p === "object") ? d : void 0;
10754
- } catch (e14) {
11284
+ } catch (e16) {
10755
11285
  return void 0;
10756
11286
  }
10757
11287
  }
@@ -10762,17 +11292,17 @@ function inputs(text) {
10762
11292
  if (d)
10763
11293
  for (const p of d.panels.flatMap((x) => x.type === "row" ? [x, ..._nullishCoalesce(x.panels, () => ( []))] : [x])) {
10764
11294
  if (typeof p.id !== "number") continue;
10765
- if (isInputGroup(p)) p.options.fields.forEach((f, i) => typeof _optionalChain([f, 'optionalAccess', _274 => _274.options, 'optionalAccess', _275 => _275.metric]) === "string" && out.set(`${p.id}.${i}`, { metric: f.options.metric, title: f.title }));
11295
+ if (isInputGroup(p)) p.options.fields.forEach((f, i) => typeof _optionalChain([f, 'optionalAccess', _282 => _282.options, 'optionalAccess', _283 => _283.metric]) === "string" && out.set(`${p.id}.${i}`, { metric: f.options.metric, title: f.title }));
10766
11296
  else if (isInputPanel(p)) out.set(String(p.id), { metric: p.options.metric, title: p.title });
10767
11297
  }
10768
- } catch (e15) {
11298
+ } catch (e17) {
10769
11299
  }
10770
11300
  return out;
10771
11301
  }
10772
11302
  function reads(text, metric) {
10773
11303
  const d = parse2(text);
10774
11304
  const panels = d ? d.panels.flatMap((p) => p.type === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]) : [];
10775
- return panels.some((p) => (_nullishCoalesce(_optionalChain([p, 'optionalAccess', _276 => _276.targets]), () => ( []))).some((t) => t.metric === metric));
11305
+ return panels.some((p) => (_nullishCoalesce(_optionalChain([p, 'optionalAccess', _284 => _284.targets]), () => ( []))).some((t) => t.metric === metric));
10776
11306
  }
10777
11307
  function metricChanges(before, after) {
10778
11308
  const merged = { ...before, ...after };
@@ -10787,7 +11317,7 @@ function metricChanges(before, after) {
10787
11317
  for (const [file, text] of Object.entries(after)) {
10788
11318
  const old = inputs(before[file]);
10789
11319
  for (const [id, input] of inputs(text))
10790
- if (_optionalChain([old, 'access', _277 => _277.get, 'call', _278 => _278(id), 'optionalAccess', _279 => _279.metric]) === metric && input.metric !== metric) rename ??= { metric, renamedTo: input.metric, file, input: input.title, readBy };
11320
+ if (_optionalChain([old, 'access', _285 => _285.get, 'call', _286 => _286(id), 'optionalAccess', _287 => _287.metric]) === metric && input.metric !== metric) rename ??= { metric, renamedTo: input.metric, file, input: input.title, readBy };
10791
11321
  }
10792
11322
  changes.push(_nullishCoalesce(rename, () => ( { metric, readBy })));
10793
11323
  }
@@ -10827,14 +11357,14 @@ function variableWithType(v, type) {
10827
11357
  }
10828
11358
  function currentFor(v, value) {
10829
11359
  const options = variableOptions({ ...v, current: void 0 });
10830
- const text = (x) => x === ALL ? "All" : _nullishCoalesce(_optionalChain([options, 'access', _280 => _280.find, 'call', _281 => _281((o) => o.value === x), 'optionalAccess', _282 => _282.text]), () => ( x));
11360
+ const text = (x) => x === ALL ? "All" : _nullishCoalesce(_optionalChain([options, 'access', _288 => _288.find, 'call', _289 => _289((o) => o.value === x), 'optionalAccess', _290 => _290.text]), () => ( x));
10831
11361
  return Array.isArray(value) ? { text: value.map(text), value } : { text: text(value), value };
10832
11362
  }
10833
11363
  function variableWithQuery(v, query) {
10834
11364
  const { options: _, current, ...rest } = v;
10835
11365
  const next = { ...rest, query };
10836
11366
  if (v.type === "textbox" || v.type === "constant") return { ...next, current: { text: query, value: query } };
10837
- const value = selectValue(next, _optionalChain([current, 'optionalAccess', _283 => _283.value]), variableOptions(next));
11367
+ const value = selectValue(next, _optionalChain([current, 'optionalAccess', _291 => _291.value]), variableOptions(next));
10838
11368
  return { ...next, current: currentFor(next, value) };
10839
11369
  }
10840
11370
  function variableWithCurrent(v, value) {
@@ -10844,13 +11374,13 @@ function variableWithFlags(v, flags) {
10844
11374
  const next = { ...v, ...flags };
10845
11375
  if (!next.multi) delete next.multi;
10846
11376
  if (!next.includeAll) delete next.includeAll;
10847
- const raw = _optionalChain([v, 'access', _284 => _284.current, 'optionalAccess', _285 => _285.value]);
11377
+ const raw = _optionalChain([v, 'access', _292 => _292.current, 'optionalAccess', _293 => _293.value]);
10848
11378
  const current = next.multi ? raw == null ? [] : Array.isArray(raw) ? raw : [raw] : Array.isArray(raw) ? raw[0] : raw;
10849
11379
  return variableWithCurrent(next, selectValue(next, current, variableOptions({ ...next, current: void 0 })));
10850
11380
  }
10851
11381
  var refers = (name, flags) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\[${name}(:\\w+)?\\]\\]`, flags);
10852
11382
  function allPanels2(dashboard) {
10853
- return (_nullishCoalesce(dashboard.panels, () => ( []))).flatMap((p) => _optionalChain([p, 'optionalAccess', _286 => _286.type]) === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]).filter((p) => p && typeof p === "object");
11383
+ return (_nullishCoalesce(dashboard.panels, () => ( []))).flatMap((p) => _optionalChain([p, 'optionalAccess', _294 => _294.type]) === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]).filter((p) => p && typeof p === "object");
10854
11384
  }
10855
11385
  function variableUses(dashboard, name) {
10856
11386
  const re = refers(name);
@@ -10922,7 +11452,7 @@ function locate(text, tree, path) {
10922
11452
  for (let n = segs.length; n >= 0; n--) {
10923
11453
  const node = findNodeAtLocation2(tree, segs.slice(0, n));
10924
11454
  if (!node) continue;
10925
- const key = _optionalChain([node, 'access', _287 => _287.parent, 'optionalAccess', _288 => _288.type]) === "property" ? _optionalChain([node, 'access', _289 => _289.parent, 'access', _290 => _290.children, 'optionalAccess', _291 => _291[0]]) : void 0;
11455
+ const key = _optionalChain([node, 'access', _295 => _295.parent, 'optionalAccess', _296 => _296.type]) === "property" ? _optionalChain([node, 'access', _297 => _297.parent, 'access', _298 => _298.children, 'optionalAccess', _299 => _299[0]]) : void 0;
10926
11456
  if ((node.type === "object" || node.type === "array") && key) return located(text, key.offset, key.length);
10927
11457
  if (node.type === "object" || node.type === "array") return located(text, node.offset, 1);
10928
11458
  return located(text, node.offset, node.length);
@@ -11051,12 +11581,12 @@ async function errorText(res) {
11051
11581
  const body = await res.text();
11052
11582
  try {
11053
11583
  return _nullishCoalesce(JSON.parse(body).error, () => ( body));
11054
- } catch (e16) {
11584
+ } catch (e18) {
11055
11585
  return body || `HTTP ${res.status}`;
11056
11586
  }
11057
11587
  }
11058
11588
  async function authHeaders(token) {
11059
- const t = await _optionalChain([token, 'optionalCall', _292 => _292()]);
11589
+ const t = await _optionalChain([token, 'optionalCall', _300 => _300()]);
11060
11590
  return t ? { Authorization: `Bearer ${t}` } : {};
11061
11591
  }
11062
11592
  var HttpConfigFiles = (_class3 = class {
@@ -11089,7 +11619,7 @@ var HttpConfigFiles = (_class3 = class {
11089
11619
  let body;
11090
11620
  try {
11091
11621
  body = JSON.parse(await res.text());
11092
- } catch (e17) {
11622
+ } catch (e19) {
11093
11623
  return null;
11094
11624
  }
11095
11625
  if (!isBundleResponse(body)) return null;
@@ -11162,20 +11692,20 @@ function fetchJsonWithToken(token) {
11162
11692
  return httpFetchJson({ headers: () => authHeaders(token), httpError: (status) => status === 401 ? "not signed in" : `HTTP ${status}` });
11163
11693
  }
11164
11694
  async function readConfigFiles(source) {
11165
- const all = await _optionalChain([source, 'access', _293 => _293.readAll, 'optionalCall', _294 => _294()]);
11695
+ const all = await _optionalChain([source, 'access', _301 => _301.readAll, 'optionalCall', _302 => _302()]);
11166
11696
  const read = all ? async (p) => {
11167
11697
  if (!(p in all)) throw new Error(NOT_FOUND);
11168
11698
  return all[p];
11169
11699
  } : (p) => source.read(p);
11170
11700
  const files = { [source.manifestPath]: await read(source.manifestPath) };
11171
11701
  const { value } = parseJsonText(files[source.manifestPath]);
11172
- const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _295 => _295.documents]), () => ( {}));
11702
+ const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _303 => _303.documents]), () => ( {}));
11173
11703
  const paths = [...new Set(Object.values(documents).filter((d) => typeof d === "string"))];
11174
11704
  await Promise.all(
11175
11705
  paths.map(async (p) => {
11176
11706
  try {
11177
11707
  files[p] = await read(p);
11178
- } catch (e18) {
11708
+ } catch (e20) {
11179
11709
  }
11180
11710
  })
11181
11711
  );
@@ -11223,7 +11753,7 @@ var CANVAS_ROW_HEADER = 32;
11223
11753
  function panelSize(panel, mode) {
11224
11754
  const p = pos(panel);
11225
11755
  if (mode === "grid") return { span: clampW(p.w), h: clampH(p.h) };
11226
- return { span: panelSpan(panel, "phone"), h: clampH(_nullishCoalesce(_optionalChain([panel, 'access', _296 => _296.mobile, 'optionalAccess', _297 => _297.h]), () => ( p.h))) };
11756
+ return { span: panelSpan(panel, "phone"), h: clampH(_nullishCoalesce(_optionalChain([panel, 'access', _304 => _304.mobile, 'optionalAccess', _305 => _305.h]), () => ( p.h))) };
11227
11757
  }
11228
11758
  function layoutCanvas(panels, order, mode, width, override) {
11229
11759
  return mode === "grid" ? layoutGridCanvas(panels, width, override) : layoutPhoneCanvas(panels, order, width, override);
@@ -11243,7 +11773,7 @@ function layoutGridCanvas(panels, width, override) {
11243
11773
  boxes = [...boxes];
11244
11774
  boxes[override.index] = b;
11245
11775
  }
11246
- const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess', _298 => _298.index]));
11776
+ const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess', _306 => _306.index]));
11247
11777
  const items = settled.map((b, index) => {
11248
11778
  const row = isRow(panels[index]);
11249
11779
  return { index, row, x: b.x * colW, y: gridOffsetPx(b.y), width: b.w * colW - CANVAS_GAP, height: row ? gridUnitsToPx(1) : gridUnitsToPx(b.h), span: b.w, h: b.h };
@@ -11287,12 +11817,12 @@ function layoutPhoneCanvas(panels, order, width, override) {
11287
11817
  y += CANVAS_ROW_HEADER + CANVAS_GAP;
11288
11818
  continue;
11289
11819
  }
11290
- if (mode === "phone" && _optionalChain([panel, 'access', _299 => _299.mobile, 'optionalAccess', _300 => _300.hidden])) {
11820
+ if (mode === "phone" && _optionalChain([panel, 'access', _307 => _307.mobile, 'optionalAccess', _308 => _308.hidden])) {
11291
11821
  hidden.push(index);
11292
11822
  continue;
11293
11823
  }
11294
11824
  const natural = panelSize(panel, mode);
11295
- const size = _optionalChain([override, 'optionalAccess', _301 => _301.index]) === index ? { span: clampW(_nullishCoalesce(override.span, () => ( natural.span))), h: clampH(_nullishCoalesce(override.h, () => ( natural.h))) } : natural;
11825
+ const size = _optionalChain([override, 'optionalAccess', _309 => _309.index]) === index ? { span: clampW(_nullishCoalesce(override.span, () => ( natural.span))), h: clampH(_nullishCoalesce(override.h, () => ( natural.h))) } : natural;
11296
11826
  if (used + size.span > GRID_COLUMNS) flush();
11297
11827
  line.push({ index, row: false, x: 0, y: 0, width: 0, height: 0, ...size });
11298
11828
  used += size.span;
@@ -11310,7 +11840,7 @@ function dropTarget(canvas, x, y, dragging) {
11310
11840
  for (const c of pool) if (distance(c) < distance(best)) best = c;
11311
11841
  const after = best.row ? y > best.y + best.height / 2 : x > best.x + best.width / 2;
11312
11842
  if (!after) return best.index;
11313
- return _nullishCoalesce(_optionalChain([items, 'access', _302 => _302[items.indexOf(best) + 1], 'optionalAccess', _303 => _303.index]), () => ( null));
11843
+ return _nullishCoalesce(_optionalChain([items, 'access', _310 => _310[items.indexOf(best) + 1], 'optionalAccess', _311 => _311.index]), () => ( null));
11314
11844
  }
11315
11845
  function movePanel(panels, index, before) {
11316
11846
  if (before === index) return panels;
@@ -11522,9 +12052,9 @@ var refers2 = (name) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\
11522
12052
  var withChildren = (p) => [p, ...isRow(p) ? _nullishCoalesce(p.panels, () => ( [])) : []];
11523
12053
  function panelMetrics(p) {
11524
12054
  const found = [];
11525
- if (isInputType(p.type) && typeof _optionalChain([p, 'access', _304 => _304.options, 'optionalAccess', _305 => _305.metric]) === "string") found.push(p.options.metric);
11526
- if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _306 => _306.options, 'optionalAccess', _307 => _307.fields]))) {
11527
- for (const f of p.options.fields) if (typeof _optionalChain([f, 'optionalAccess', _308 => _308.options, 'optionalAccess', _309 => _309.metric]) === "string") found.push(f.options.metric);
12055
+ if (isInputType(p.type) && typeof _optionalChain([p, 'access', _312 => _312.options, 'optionalAccess', _313 => _313.metric]) === "string") found.push(p.options.metric);
12056
+ if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _314 => _314.options, 'optionalAccess', _315 => _315.fields]))) {
12057
+ for (const f of p.options.fields) if (typeof _optionalChain([f, 'optionalAccess', _316 => _316.options, 'optionalAccess', _317 => _317.metric]) === "string") found.push(f.options.metric);
11528
12058
  }
11529
12059
  for (const t of _nullishCoalesce(p.targets, () => ( []))) if (typeof t.metric === "string" && t.metric && !t.metric.startsWith("$")) found.push(t.metric);
11530
12060
  return found;
@@ -11532,15 +12062,15 @@ function panelMetrics(p) {
11532
12062
  function renameMetrics(panels, map) {
11533
12063
  const rename = (p) => {
11534
12064
  let out = p;
11535
- if (isInputType(p.type) && typeof _optionalChain([p, 'access', _310 => _310.options, 'optionalAccess', _311 => _311.metric]) === "string" && map[p.options.metric]) out = { ...out, options: { ...out.options, metric: map[p.options.metric] } };
11536
- if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _312 => _312.options, 'optionalAccess', _313 => _313.fields]))) {
12065
+ if (isInputType(p.type) && typeof _optionalChain([p, 'access', _318 => _318.options, 'optionalAccess', _319 => _319.metric]) === "string" && map[p.options.metric]) out = { ...out, options: { ...out.options, metric: map[p.options.metric] } };
12066
+ if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _320 => _320.options, 'optionalAccess', _321 => _321.fields]))) {
11537
12067
  const to = (m) => typeof m === "string" && map[m] || m;
11538
- const fields = p.options.fields.map((f) => _optionalChain([f, 'optionalAccess', _314 => _314.options]) && to(f.options.metric) !== f.options.metric ? { ...f, options: { ...f.options, metric: to(f.options.metric) } } : f);
12068
+ const fields = p.options.fields.map((f) => _optionalChain([f, 'optionalAccess', _322 => _322.options]) && to(f.options.metric) !== f.options.metric ? { ...f, options: { ...f.options, metric: to(f.options.metric) } } : f);
11539
12069
  const titleFrom = to(p.options.titleFrom);
11540
12070
  out = { ...out, options: { ...out.options, fields, ...titleFrom !== void 0 && { titleFrom } } };
11541
12071
  }
11542
- if (_optionalChain([p, 'access', _315 => _315.targets, 'optionalAccess', _316 => _316.some, 'call', _317 => _317((t) => typeof t.metric === "string" && map[t.metric])])) out = { ...out, targets: p.targets.map((t) => typeof t.metric === "string" && map[t.metric] ? { ...t, metric: map[t.metric] } : t) };
11543
- if (_optionalChain([p, 'access', _318 => _318.panels, 'optionalAccess', _319 => _319.length])) out = { ...out, panels: p.panels.map(rename) };
12072
+ if (_optionalChain([p, 'access', _323 => _323.targets, 'optionalAccess', _324 => _324.some, 'call', _325 => _325((t) => typeof t.metric === "string" && map[t.metric])])) out = { ...out, targets: p.targets.map((t) => typeof t.metric === "string" && map[t.metric] ? { ...t, metric: map[t.metric] } : t) };
12073
+ if (_optionalChain([p, 'access', _326 => _326.panels, 'optionalAccess', _327 => _327.length])) out = { ...out, panels: p.panels.map(rename) };
11544
12074
  return out;
11545
12075
  };
11546
12076
  return panels.map(rename);
@@ -11560,7 +12090,7 @@ function copyPanels(dashboard, indices) {
11560
12090
  }
11561
12091
  }
11562
12092
  const chosen = order.filter((i) => picked.has(i)).map((i) => panels[i]);
11563
- return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access', _320 => _320.templating, 'optionalAccess', _321 => _321.list]), () => ( [])));
12093
+ return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access', _328 => _328.templating, 'optionalAccess', _329 => _329.list]), () => ( [])));
11564
12094
  }
11565
12095
  function snippetOf(panels, available) {
11566
12096
  const left = Math.min(...panels.map((p) => pos2(p).x));
@@ -11600,7 +12130,7 @@ function parseSnippet(text) {
11600
12130
  let json;
11601
12131
  try {
11602
12132
  json = JSON.parse(text);
11603
- } catch (e19) {
12133
+ } catch (e21) {
11604
12134
  return { error: "That isn\u2019t JSON" };
11605
12135
  }
11606
12136
  let panels;
@@ -11628,7 +12158,7 @@ var sameVariable = (a, b) => {
11628
12158
  return strip(a) === strip(b);
11629
12159
  };
11630
12160
  function previewPaste(dashboard, snippet) {
11631
- const { added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _322 => _322.templating, 'optionalAccess', _323 => _323.list]), () => ( [])), snippet.variables);
12161
+ const { added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _330 => _330.templating, 'optionalAccess', _331 => _331.list]), () => ( [])), snippet.variables);
11632
12162
  return { added, renamed };
11633
12163
  }
11634
12164
  function mergeVariables(existing, incoming) {
@@ -11665,7 +12195,7 @@ function pasteSnippet(dashboard, snippet, options = {}) {
11665
12195
  return true;
11666
12196
  };
11667
12197
  let incoming = snippet.panels.filter(keep).map((p) => p.panels ? { ...p, panels: p.panels.filter(keep) } : p);
11668
- const { variables, added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _324 => _324.templating, 'optionalAccess', _325 => _325.list]), () => ( [])), snippet.variables);
12198
+ const { variables, added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _332 => _332.templating, 'optionalAccess', _333 => _333.list]), () => ( [])), snippet.variables);
11669
12199
  for (const [from, to] of Object.entries(renamed)) incoming = renameVariableInPanels(incoming, from, to);
11670
12200
  if (options.metrics) incoming = renameMetrics(incoming, options.metrics);
11671
12201
  const after = options.after != null ? existing[options.after] : void 0;
@@ -11715,7 +12245,7 @@ function parseTemplate(text) {
11715
12245
  let json;
11716
12246
  try {
11717
12247
  json = JSON.parse(text);
11718
- } catch (e20) {
12248
+ } catch (e22) {
11719
12249
  return { error: "That isn\u2019t JSON" };
11720
12250
  }
11721
12251
  if (!isObject5(json) || json.$modelform !== "template") return { error: "That isn\u2019t a template" };
@@ -11730,7 +12260,7 @@ function parseTemplate(text) {
11730
12260
  if (seen.has(d.id)) return { error: `Two documents are called "${d.id}"` };
11731
12261
  seen.add(d.id);
11732
12262
  const { dashboard, issues } = prepareDashboard(d.dashboard, d.id);
11733
- if (!dashboard) return { error: `"${d.id}" can\u2019t be shown: ${_nullishCoalesce(_optionalChain([issues, 'access', _326 => _326.find, 'call', _327 => _327((x) => x.severity === "error"), 'optionalAccess', _328 => _328.message]), () => ( "it isn\u2019t a dashboard"))}` };
12263
+ if (!dashboard) return { error: `"${d.id}" can\u2019t be shown: ${_nullishCoalesce(_optionalChain([issues, 'access', _334 => _334.find, 'call', _335 => _335((x) => x.severity === "error"), 'optionalAccess', _336 => _336.message]), () => ( "it isn\u2019t a dashboard"))}` };
11734
12264
  if (dashboard.kind && dashboard.kind !== d.kind) return { error: `"${d.id}" is listed as a ${d.kind} but says it\u2019s a ${dashboard.kind}` };
11735
12265
  documents.push({ kind: d.kind, id: d.id, dashboard });
11736
12266
  }
@@ -11781,7 +12311,7 @@ function applyTemplate(manifestText, paths, template, options = {}) {
11781
12311
  let manifest;
11782
12312
  try {
11783
12313
  manifest = JSON.parse(manifestText);
11784
- } catch (e21) {
12314
+ } catch (e23) {
11785
12315
  throw new Error("The manifest isn\u2019t valid JSON");
11786
12316
  }
11787
12317
  const taken = new Set(Object.keys(_nullishCoalesce(manifest.documents, () => ( {}))));
@@ -11808,9 +12338,9 @@ function applyTemplate(manifestText, paths, template, options = {}) {
11808
12338
  }
11809
12339
  const tabIds = (_nullishCoalesce(manifest.tabs, () => ( []))).map((t) => t.id);
11810
12340
  const added = [];
11811
- let at = _nullishCoalesce(_optionalChain([manifest, 'access', _329 => _329.tabs, 'optionalAccess', _330 => _330.length]), () => ( 0));
12341
+ let at = _nullishCoalesce(_optionalChain([manifest, 'access', _337 => _337.tabs, 'optionalAccess', _338 => _338.length]), () => ( 0));
11812
12342
  for (const tab of template.tabs) {
11813
- if (!_optionalChain([options, 'access', _331 => _331.tabs, 'optionalAccess', _332 => _332.includes, 'call', _333 => _333(tab.id)])) continue;
12343
+ if (!_optionalChain([options, 'access', _339 => _339.tabs, 'optionalAccess', _340 => _340.includes, 'call', _341 => _341(tab.id)])) continue;
11814
12344
  const screen = retarget(tab.screen, ids);
11815
12345
  if (!screen) continue;
11816
12346
  const id = tabIdFor(tab.id, tabIds);
@@ -12011,7 +12541,7 @@ function jsonFromAnswer(text) {
12011
12541
  for (const block of blocks.reverse()) {
12012
12542
  try {
12013
12543
  return JSON.parse(block);
12014
- } catch (e22) {
12544
+ } catch (e24) {
12015
12545
  }
12016
12546
  }
12017
12547
  throw new Error("There\u2019s no JSON in that answer");
@@ -12032,7 +12562,7 @@ function readTemplateAnswer(text) {
12032
12562
  );
12033
12563
  const kept = new Set(template.tabs.map((t) => t.id));
12034
12564
  for (const [i, tab] of (Array.isArray(raw.tabs) ? raw.tabs : []).entries()) {
12035
- const id = _optionalChain([tab, 'optionalAccess', _334 => _334.id]);
12565
+ const id = _optionalChain([tab, 'optionalAccess', _342 => _342.id]);
12036
12566
  if (typeof id !== "string" || !kept.has(id)) warnings.push(`tabs[${i}] was left out: it needs an id, a title and a screen showing only this template\u2019s documents`);
12037
12567
  }
12038
12568
  const kinds = new Map(template.documents.map((d) => [d.id, d.kind]));
@@ -12080,9 +12610,9 @@ function readDocumentAnswer(text, kind) {
12080
12610
  return { error: e.message };
12081
12611
  }
12082
12612
  const wrapper = json;
12083
- if (_optionalChain([wrapper, 'optionalAccess', _335 => _335.$modelform]) === "template") {
12613
+ if (_optionalChain([wrapper, 'optionalAccess', _343 => _343.$modelform]) === "template") {
12084
12614
  if (!Array.isArray(wrapper.documents) || wrapper.documents.length !== 1) return { error: `That\u2019s a template, not one ${kind}` };
12085
- json = _optionalChain([wrapper, 'access', _336 => _336.documents, 'access', _337 => _337[0], 'optionalAccess', _338 => _338.dashboard]);
12615
+ json = _optionalChain([wrapper, 'access', _344 => _344.documents, 'access', _345 => _345[0], 'optionalAccess', _346 => _346.dashboard]);
12086
12616
  }
12087
12617
  if (!json || typeof json !== "object" || Array.isArray(json)) return { error: `That isn\u2019t a ${kind}` };
12088
12618
  const raw = json;
@@ -12121,8 +12651,8 @@ function documentChanges(before, after) {
12121
12651
  const what = [];
12122
12652
  if (was.title !== p.title) what.push("title");
12123
12653
  if (was.type !== p.type) what.push("type");
12124
- if (_optionalChain([was, 'access', _339 => _339.gridPos, 'optionalAccess', _340 => _340.x]) !== _optionalChain([p, 'access', _341 => _341.gridPos, 'optionalAccess', _342 => _342.x]) || _optionalChain([was, 'access', _343 => _343.gridPos, 'optionalAccess', _344 => _344.y]) !== _optionalChain([p, 'access', _345 => _345.gridPos, 'optionalAccess', _346 => _346.y])) what.push("position");
12125
- if (_optionalChain([was, 'access', _347 => _347.gridPos, 'optionalAccess', _348 => _348.w]) !== _optionalChain([p, 'access', _349 => _349.gridPos, 'optionalAccess', _350 => _350.w]) || _optionalChain([was, 'access', _351 => _351.gridPos, 'optionalAccess', _352 => _352.h]) !== _optionalChain([p, 'access', _353 => _353.gridPos, 'optionalAccess', _354 => _354.h])) what.push("size");
12654
+ if (_optionalChain([was, 'access', _347 => _347.gridPos, 'optionalAccess', _348 => _348.x]) !== _optionalChain([p, 'access', _349 => _349.gridPos, 'optionalAccess', _350 => _350.x]) || _optionalChain([was, 'access', _351 => _351.gridPos, 'optionalAccess', _352 => _352.y]) !== _optionalChain([p, 'access', _353 => _353.gridPos, 'optionalAccess', _354 => _354.y])) what.push("position");
12655
+ if (_optionalChain([was, 'access', _355 => _355.gridPos, 'optionalAccess', _356 => _356.w]) !== _optionalChain([p, 'access', _357 => _357.gridPos, 'optionalAccess', _358 => _358.w]) || _optionalChain([was, 'access', _359 => _359.gridPos, 'optionalAccess', _360 => _360.h]) !== _optionalChain([p, 'access', _361 => _361.gridPos, 'optionalAccess', _362 => _362.h])) what.push("size");
12126
12656
  if (!same(was.options, p.options)) what.push("options");
12127
12657
  if (!same(was.targets, p.targets) || !same(was.datasource, p.datasource) || !same(was.transformations, p.transformations)) what.push("queries");
12128
12658
  if (!same(was.fieldConfig, p.fieldConfig)) what.push("field config");
@@ -12379,4 +12909,14 @@ function documentChanges(before, after) {
12379
12909
 
12380
12910
 
12381
12911
 
12382
- exports.frameLength = frameLength; exports.timeField = timeField; exports.numberFields = numberFields; exports.fieldDisplayName = fieldDisplayName; exports.toSeries = toSeries; exports.toXYSeries = toXYSeries; exports.uniqueNames = uniqueNames; exports.toMillis = toMillis; exports.parseTime = parseTime; exports.parseRange = parseRange; exports.addTime = addTime; exports.startOf = startOf; exports.parseDuration = parseDuration; exports.calculateInterval = calculateInterval; exports.formatDuration = formatDuration; exports.TIME_PRESETS = TIME_PRESETS; exports.RELATIVE_RANGES = RELATIVE_RANGES; exports.parseLocalDateTime = parseLocalDateTime; exports.formatLocalDateTime = formatLocalDateTime; exports.timeExprError = timeExprError; exports.describeRange = describeRange; exports.zoomRange = zoomRange; exports.ALL = ALL; exports.initialVariableValues = initialVariableValues; exports.variableOptions = variableOptions; exports.variableInfo = variableInfo; exports.visibleVariables = visibleVariables; exports.isSqlDatasource = isSqlDatasource; exports.framesToOptions = framesToOptions; exports.refineOptions = refineOptions; exports.selectValue = selectValue; exports.variableReferences = variableReferences; exports.interpolate = interpolate; exports.queryParam = queryParam; exports.interpolateDeep = interpolateDeep; exports.resolveTimezone = resolveTimezone; exports.valueText = valueText; exports.GRID_COLUMNS = GRID_COLUMNS; exports.gridUnitsToPx = gridUnitsToPx; exports.gridOffsetPx = gridOffsetPx; exports.compactGrid = compactGrid; exports.isRow = isRow; exports.layoutDashboard = layoutDashboard; exports.repeatOptions = repeatOptions; exports.panelKey = panelKey; exports.panelSpan = panelSpan; exports.applyTransformations = applyTransformations; exports.DASHBOARD_DS = DASHBOARD_DS; exports.dashboardSourceIds = dashboardSourceIds; exports.panelHasQueries = panelHasQueries; exports.queryPanel = queryPanel; exports.normalizeRef = normalizeRef; exports.refreshedVariables = refreshedVariables; exports.variableDependents = variableDependents; exports.variableOrder = variableOrder; exports.resolveVariables = resolveVariables; exports.REDUCER_LABELS = REDUCER_LABELS; exports.isReducer = isReducer; exports.reduce = reduce; exports.INPUT_OPTION_KEYS = INPUT_OPTION_KEYS; exports.INPUT_TYPES = INPUT_TYPES; exports.isInputType = isInputType; exports.isInputPanel = isInputPanel; exports.INPUT_GROUP = INPUT_GROUP; exports.isFormPanelType = isFormPanelType; exports.isInputGroup = isInputGroup; exports.GROUP_FIELD_TYPES = GROUP_FIELD_TYPES; exports.groupFields = groupFields; exports.inputPanels = inputPanels; exports.documentKind = documentKind; exports.inputGroups = inputGroups; exports.plainInputPanels = plainInputPanels; exports.parseClockDigits = parseClockDigits; exports.formatClock = formatClock; exports.toEntries = toEntries; exports.newSaveId = newSaveId; exports.isEmptyItem = isEmptyItem; exports.groupToEntries = groupToEntries; exports.entriesToItems = entriesToItems; exports.groupProblems = groupProblems; exports.sameSave = sameSave; exports.inputProblem = inputProblem; exports.entryToInputValue = entryToInputValue; exports.textSuggestions = textSuggestions; exports.entriesSavedWith = entriesSavedWith; exports.formatValue = formatValue; exports.thresholdStep = thresholdStep; exports.NAMED_COLORS = NAMED_COLORS; exports.resolveColor = resolveColor; exports.SERIES_PALETTE = SERIES_PALETTE; exports.seriesColor = seriesColor; exports.mappedResult = mappedResult; exports.formatDisplay = formatDisplay; exports.valueColor = valueColor; exports.resolveFieldConfig = resolveFieldConfig; exports.fieldMatches = fieldMatches; exports.GrafanaError = GrafanaError; exports.GrafanaClient = GrafanaClient; exports.GrafanaDataSource = GrafanaDataSource; exports.fromWire = fromWire; exports.parseSpokenNumber = parseSpokenNumber; exports.parseSpokenDuration = parseSpokenDuration; exports.matchChoices = matchChoices; exports.parseSpokenYesNo = parseSpokenYesNo; exports.spokenValue = spokenValue; exports.DICTATION_TYPES = DICTATION_TYPES; exports.takesDictation = takesDictation; exports.dictationHints = dictationHints; exports.LOCAL_DATASOURCE_TYPE = LOCAL_DATASOURCE_TYPE; exports.isLocalDatasource = isLocalDatasource; exports.LocalDataSource = LocalDataSource; exports.groupField = groupField; exports.buildFrames = buildFrames; exports.MemoryEntryStore = MemoryEntryStore; exports.DEFAULT_GAZETTEER = DEFAULT_GAZETTEER; exports.parseGazetteer = parseGazetteer; exports.loadGazetteer = loadGazetteer; exports.resolveLinks = resolveLinks; exports.parseDashboardLink = parseDashboardLink; exports.applyDashboardLink = applyDashboardLink; exports.appSchema = appSchema; exports.dashboardSchema = dashboardSchema; exports.pointerToPath = pointerToPath; exports.manifestSchemaIssues = manifestSchemaIssues; exports.dashboardSchemaIssues = dashboardSchemaIssues; exports.cleanDashboard = cleanDashboard; exports.MAPPING_TYPES = MAPPING_TYPES; exports.SPECIAL_MATCHES = SPECIAL_MATCHES; exports.mappingRows = mappingRows; exports.rowsToMappings = rowsToMappings; exports.mappingRow = mappingRow; exports.mappingProblem = mappingProblem; exports.OPTION_CATEGORIES = OPTION_CATEGORIES; exports.UNIT_CHOICES = UNIT_CHOICES; exports.panelOptions = panelOptions; exports.getPath = getPath; exports.optionValue = optionValue; exports.setOption = setOption; exports.setOptionValue = setOptionValue; exports.cleanPanelOptions = cleanPanelOptions; exports.OVERRIDE_MATCHERS = OVERRIDE_MATCHERS; exports.overrideProperties = overrideProperties; exports.panelOverrides = panelOverrides; exports.setOverrides = setOverrides; exports.MANIFEST_VERSION = MANIFEST_VERSION; exports.requiredManifestVersion = requiredManifestVersion; exports.validateManifest = validateManifest; exports.prepareDashboard = prepareDashboard; exports.validateDashboard = validateDashboard2; exports.validateBundle = validateBundle; exports.resolveUrl = resolveUrl; exports.httpFetchJson = httpFetchJson; exports.defaultFetchJson = defaultFetchJson; exports.BUNDLE_TYPE = BUNDLE_TYPE; exports.BUNDLE_ACCEPT = BUNDLE_ACCEPT; exports.isBundleResponse = isBundleResponse; exports.bundleRoot = bundleRoot; exports.assembleFromResponse = assembleFromResponse; exports.assembleBundle = assembleBundle; exports.fetchBundle = fetchBundle; exports.revalidateBundle = revalidateBundle; exports.ConfigLoader = ConfigLoader; exports.tabIdFor = tabIdFor; exports.screenOfType = screenOfType; exports.screenDocuments = screenDocuments; exports.documentUses = documentUses; exports.stringifyCompact = stringifyCompact; exports.applyJsonEdits = applyJsonEdits; exports.diffJson = diffJson; exports.documentIdFor = documentIdFor; exports.removeDocumentFromManifest = removeDocumentFromManifest; exports.renameDocumentInManifest = renameDocumentInManifest; exports.metricChanges = metricChanges; exports.REFRESH_CHOICES = REFRESH_CHOICES; exports.EDITABLE_VARIABLE_TYPES = EDITABLE_VARIABLE_TYPES; exports.isEditableVariableType = isEditableVariableType; exports.variableNameError = variableNameError; exports.newVariable = newVariable; exports.variableWithType = variableWithType; exports.variableWithQuery = variableWithQuery; exports.variableWithCurrent = variableWithCurrent; exports.variableWithFlags = variableWithFlags; exports.variableUses = variableUses; exports.renameVariableInPanels = renameVariableInPanels; exports.lineColumn = lineColumn; exports.parseJsonText = parseJsonText; exports.splitPath = splitPath; exports.locate = locate; exports.checkFiles = checkFiles; exports.bundleFromFiles = bundleFromFiles; exports.formatJsonText = formatJsonText; exports.setJsonValue = setJsonValue; exports.PANEL_TYPES = PANEL_TYPES; exports.newPanel = newPanel; exports.newDocument = newDocument; exports.SaveConflictError = SaveConflictError; exports.HttpConfigFiles = HttpConfigFiles; exports.fetchJsonWithToken = fetchJsonWithToken; exports.readConfigFiles = readConfigFiles; exports.readingOrder = readingOrder; exports.repack = repack; exports.CANVAS_GAP = CANVAS_GAP; exports.CANVAS_ROW_HEADER = CANVAS_ROW_HEADER; exports.panelSize = panelSize; exports.layoutCanvas = layoutCanvas; exports.dropTarget = dropTarget; exports.movePanel = movePanel; exports.resizePanel = resizePanel; exports.setHiddenOnPhones = setHiddenOnPhones; exports.nextPanelId = nextPanelId; exports.insertPanel = insertPanel; exports.duplicatePanel = duplicatePanel; exports.removePanel = removePanel; exports.expandRow = expandRow; exports.collapseRow = collapseRow; exports.settleLayout = settleLayout; exports.placePanel = placePanel; exports.snapToGrid = snapToGrid; exports.panelEdits = panelEdits; exports.sampleEntries = sampleEntries; exports.SNIPPET_VERSION = SNIPPET_VERSION; exports.panelMetrics = panelMetrics; exports.renameMetrics = renameMetrics; exports.copyPanels = copyPanels; exports.parseSnippet = parseSnippet; exports.previewPaste = previewPaste; exports.pasteSnippet = pasteSnippet; exports.TEMPLATE_VERSION = TEMPLATE_VERSION; exports.makeTemplate = makeTemplate; exports.parseTemplate = parseTemplate; exports.templateNeeds = templateNeeds; exports.applyTemplate = applyTemplate; exports.DOCUMENT_GUIDE = DOCUMENT_GUIDE; exports.AUTHORING_GUIDE = AUTHORING_GUIDE; exports.EXAMPLE_TEMPLATE = EXAMPLE_TEMPLATE; exports.templatePrompt = templatePrompt; exports.jsonFromAnswer = jsonFromAnswer; exports.readTemplateAnswer = readTemplateAnswer; exports.fixTemplatePrompt = fixTemplatePrompt; exports.documentPrompt = documentPrompt; exports.readDocumentAnswer = readDocumentAnswer; exports.fixDocumentPrompt = fixDocumentPrompt; exports.documentChanges = documentChanges;
12912
+
12913
+
12914
+
12915
+
12916
+
12917
+
12918
+
12919
+
12920
+
12921
+
12922
+ exports.frameLength = frameLength; exports.timeField = timeField; exports.numberFields = numberFields; exports.fieldDisplayName = fieldDisplayName; exports.toSeries = toSeries; exports.toXYSeries = toXYSeries; exports.uniqueNames = uniqueNames; exports.toMillis = toMillis; exports.parseTime = parseTime; exports.parseRange = parseRange; exports.addTime = addTime; exports.startOf = startOf; exports.parseDuration = parseDuration; exports.calculateInterval = calculateInterval; exports.formatDuration = formatDuration; exports.TIME_PRESETS = TIME_PRESETS; exports.RELATIVE_RANGES = RELATIVE_RANGES; exports.parseLocalDateTime = parseLocalDateTime; exports.formatLocalDateTime = formatLocalDateTime; exports.timeExprError = timeExprError; exports.describeRange = describeRange; exports.zoomRange = zoomRange; exports.ALL = ALL; exports.initialVariableValues = initialVariableValues; exports.variableOptions = variableOptions; exports.variableInfo = variableInfo; exports.visibleVariables = visibleVariables; exports.isSqlDatasource = isSqlDatasource; exports.framesToOptions = framesToOptions; exports.refineOptions = refineOptions; exports.selectValue = selectValue; exports.variableReferences = variableReferences; exports.interpolate = interpolate; exports.queryParam = queryParam; exports.interpolateDeep = interpolateDeep; exports.resolveTimezone = resolveTimezone; exports.valueText = valueText; exports.GRID_COLUMNS = GRID_COLUMNS; exports.gridUnitsToPx = gridUnitsToPx; exports.gridOffsetPx = gridOffsetPx; exports.compactGrid = compactGrid; exports.isRow = isRow; exports.layoutDashboard = layoutDashboard; exports.repeatOptions = repeatOptions; exports.panelKey = panelKey; exports.panelSpan = panelSpan; exports.applyTransformations = applyTransformations; exports.DASHBOARD_DS = DASHBOARD_DS; exports.dashboardSourceIds = dashboardSourceIds; exports.panelHasQueries = panelHasQueries; exports.queryPanel = queryPanel; exports.normalizeRef = normalizeRef; exports.refreshedVariables = refreshedVariables; exports.variableDependents = variableDependents; exports.variableOrder = variableOrder; exports.resolveVariables = resolveVariables; exports.REDUCER_LABELS = REDUCER_LABELS; exports.isReducer = isReducer; exports.reduce = reduce; exports.INPUT_OPTION_KEYS = INPUT_OPTION_KEYS; exports.INPUT_TYPES = INPUT_TYPES; exports.isInputType = isInputType; exports.isInputPanel = isInputPanel; exports.INPUT_GROUP = INPUT_GROUP; exports.isFormPanelType = isFormPanelType; exports.isInputGroup = isInputGroup; exports.GROUP_FIELD_TYPES = GROUP_FIELD_TYPES; exports.groupFields = groupFields; exports.inputPanels = inputPanels; exports.documentKind = documentKind; exports.inputGroups = inputGroups; exports.plainInputPanels = plainInputPanels; exports.parseClockDigits = parseClockDigits; exports.formatClock = formatClock; exports.toEntries = toEntries; exports.newSaveId = newSaveId; exports.isEmptyItem = isEmptyItem; exports.groupToEntries = groupToEntries; exports.entriesToItems = entriesToItems; exports.groupProblems = groupProblems; exports.sameSave = sameSave; exports.inputProblem = inputProblem; exports.entryToInputValue = entryToInputValue; exports.textSuggestions = textSuggestions; exports.entriesSavedWith = entriesSavedWith; exports.formatValue = formatValue; exports.thresholdStep = thresholdStep; exports.NAMED_COLORS = NAMED_COLORS; exports.resolveColor = resolveColor; exports.SERIES_PALETTE = SERIES_PALETTE; exports.seriesColor = seriesColor; exports.mappedResult = mappedResult; exports.formatDisplay = formatDisplay; exports.valueColor = valueColor; exports.resolveFieldConfig = resolveFieldConfig; exports.fieldMatches = fieldMatches; exports.GrafanaError = GrafanaError; exports.GrafanaClient = GrafanaClient; exports.GrafanaDataSource = GrafanaDataSource; exports.fromWire = fromWire; exports.parseSpokenNumber = parseSpokenNumber; exports.parseSpokenDuration = parseSpokenDuration; exports.matchChoices = matchChoices; exports.parseSpokenYesNo = parseSpokenYesNo; exports.spokenValue = spokenValue; exports.DICTATION_TYPES = DICTATION_TYPES; exports.takesDictation = takesDictation; exports.dictationHints = dictationHints; exports.choicesOf = choicesOf; exports.fillForm = fillForm; exports.fillSchema = fillSchema; exports.fillPrompt = fillPrompt; exports.parseFillAnswer = parseFillAnswer; exports.readFill = readFill; exports.modelFiller = modelFiller; exports.fillHints = fillHints; exports.ruleFill = ruleFill; exports.ruleFiller = ruleFiller; exports.LOCAL_DATASOURCE_TYPE = LOCAL_DATASOURCE_TYPE; exports.isLocalDatasource = isLocalDatasource; exports.LocalDataSource = LocalDataSource; exports.groupField = groupField; exports.buildFrames = buildFrames; exports.MemoryEntryStore = MemoryEntryStore; exports.DEFAULT_GAZETTEER = DEFAULT_GAZETTEER; exports.parseGazetteer = parseGazetteer; exports.loadGazetteer = loadGazetteer; exports.resolveLinks = resolveLinks; exports.parseDashboardLink = parseDashboardLink; exports.applyDashboardLink = applyDashboardLink; exports.appSchema = appSchema; exports.dashboardSchema = dashboardSchema; exports.pointerToPath = pointerToPath; exports.manifestSchemaIssues = manifestSchemaIssues; exports.dashboardSchemaIssues = dashboardSchemaIssues; exports.cleanDashboard = cleanDashboard; exports.MAPPING_TYPES = MAPPING_TYPES; exports.SPECIAL_MATCHES = SPECIAL_MATCHES; exports.mappingRows = mappingRows; exports.rowsToMappings = rowsToMappings; exports.mappingRow = mappingRow; exports.mappingProblem = mappingProblem; exports.OPTION_CATEGORIES = OPTION_CATEGORIES; exports.UNIT_CHOICES = UNIT_CHOICES; exports.panelOptions = panelOptions; exports.getPath = getPath; exports.optionValue = optionValue; exports.setOption = setOption; exports.setOptionValue = setOptionValue; exports.cleanPanelOptions = cleanPanelOptions; exports.OVERRIDE_MATCHERS = OVERRIDE_MATCHERS; exports.overrideProperties = overrideProperties; exports.panelOverrides = panelOverrides; exports.setOverrides = setOverrides; exports.MANIFEST_VERSION = MANIFEST_VERSION; exports.requiredManifestVersion = requiredManifestVersion; exports.validateManifest = validateManifest; exports.prepareDashboard = prepareDashboard; exports.validateDashboard = validateDashboard2; exports.validateBundle = validateBundle; exports.resolveUrl = resolveUrl; exports.httpFetchJson = httpFetchJson; exports.defaultFetchJson = defaultFetchJson; exports.BUNDLE_TYPE = BUNDLE_TYPE; exports.BUNDLE_ACCEPT = BUNDLE_ACCEPT; exports.isBundleResponse = isBundleResponse; exports.bundleRoot = bundleRoot; exports.assembleFromResponse = assembleFromResponse; exports.assembleBundle = assembleBundle; exports.fetchBundle = fetchBundle; exports.revalidateBundle = revalidateBundle; exports.ConfigLoader = ConfigLoader; exports.tabIdFor = tabIdFor; exports.screenOfType = screenOfType; exports.screenDocuments = screenDocuments; exports.documentUses = documentUses; exports.stringifyCompact = stringifyCompact; exports.applyJsonEdits = applyJsonEdits; exports.diffJson = diffJson; exports.documentIdFor = documentIdFor; exports.removeDocumentFromManifest = removeDocumentFromManifest; exports.renameDocumentInManifest = renameDocumentInManifest; exports.metricChanges = metricChanges; exports.REFRESH_CHOICES = REFRESH_CHOICES; exports.EDITABLE_VARIABLE_TYPES = EDITABLE_VARIABLE_TYPES; exports.isEditableVariableType = isEditableVariableType; exports.variableNameError = variableNameError; exports.newVariable = newVariable; exports.variableWithType = variableWithType; exports.variableWithQuery = variableWithQuery; exports.variableWithCurrent = variableWithCurrent; exports.variableWithFlags = variableWithFlags; exports.variableUses = variableUses; exports.renameVariableInPanels = renameVariableInPanels; exports.lineColumn = lineColumn; exports.parseJsonText = parseJsonText; exports.splitPath = splitPath; exports.locate = locate; exports.checkFiles = checkFiles; exports.bundleFromFiles = bundleFromFiles; exports.formatJsonText = formatJsonText; exports.setJsonValue = setJsonValue; exports.PANEL_TYPES = PANEL_TYPES; exports.newPanel = newPanel; exports.newDocument = newDocument; exports.SaveConflictError = SaveConflictError; exports.HttpConfigFiles = HttpConfigFiles; exports.fetchJsonWithToken = fetchJsonWithToken; exports.readConfigFiles = readConfigFiles; exports.readingOrder = readingOrder; exports.repack = repack; exports.CANVAS_GAP = CANVAS_GAP; exports.CANVAS_ROW_HEADER = CANVAS_ROW_HEADER; exports.panelSize = panelSize; exports.layoutCanvas = layoutCanvas; exports.dropTarget = dropTarget; exports.movePanel = movePanel; exports.resizePanel = resizePanel; exports.setHiddenOnPhones = setHiddenOnPhones; exports.nextPanelId = nextPanelId; exports.insertPanel = insertPanel; exports.duplicatePanel = duplicatePanel; exports.removePanel = removePanel; exports.expandRow = expandRow; exports.collapseRow = collapseRow; exports.settleLayout = settleLayout; exports.placePanel = placePanel; exports.snapToGrid = snapToGrid; exports.panelEdits = panelEdits; exports.sampleEntries = sampleEntries; exports.SNIPPET_VERSION = SNIPPET_VERSION; exports.panelMetrics = panelMetrics; exports.renameMetrics = renameMetrics; exports.copyPanels = copyPanels; exports.parseSnippet = parseSnippet; exports.previewPaste = previewPaste; exports.pasteSnippet = pasteSnippet; exports.TEMPLATE_VERSION = TEMPLATE_VERSION; exports.makeTemplate = makeTemplate; exports.parseTemplate = parseTemplate; exports.templateNeeds = templateNeeds; exports.applyTemplate = applyTemplate; exports.DOCUMENT_GUIDE = DOCUMENT_GUIDE; exports.AUTHORING_GUIDE = AUTHORING_GUIDE; exports.EXAMPLE_TEMPLATE = EXAMPLE_TEMPLATE; exports.templatePrompt = templatePrompt; exports.jsonFromAnswer = jsonFromAnswer; exports.readTemplateAnswer = readTemplateAnswer; exports.fixTemplatePrompt = fixTemplatePrompt; exports.documentPrompt = documentPrompt; exports.readDocumentAnswer = readDocumentAnswer; exports.fixDocumentPrompt = fixDocumentPrompt; exports.documentChanges = documentChanges;